2018-03-22 10:08:48 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2018-04-26 08:08:09 -07:00
|
|
|
/* Copyright(c) 2013 - 2018 Intel Corporation. */
|
2013-12-21 06:13:06 +00:00
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
#ifndef _IAVF_TXRX_H_
|
|
|
|
#define _IAVF_TXRX_H_
|
2013-12-21 06:13:06 +00:00
|
|
|
|
2014-04-09 05:59:02 +00:00
|
|
|
/* Interrupt Throttling and Rate Limiting Goodies */
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_DEFAULT_IRQ_WORK 256
|
2017-12-29 08:51:08 -05:00
|
|
|
|
|
|
|
/* The datasheet for the X710 and XL710 indicate that the maximum value for
|
|
|
|
* the ITR is 8160usec which is then called out as 0xFF0 with a 2usec
|
|
|
|
* resolution. 8160 is 0x1FE0 when written out in hex. So instead of storing
|
|
|
|
* the register value which is divided by 2 lets use the actual values and
|
|
|
|
* avoid an excessive amount of translation.
|
|
|
|
*/
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_ITR_DYNAMIC 0x8000 /* use top bit as a flag */
|
|
|
|
#define IAVF_ITR_MASK 0x1FFE /* mask for ITR register value */
|
|
|
|
#define IAVF_ITR_100K 10 /* all values below must be even */
|
|
|
|
#define IAVF_ITR_50K 20
|
|
|
|
#define IAVF_ITR_20K 50
|
|
|
|
#define IAVF_ITR_18K 60
|
|
|
|
#define IAVF_ITR_8K 122
|
|
|
|
#define IAVF_MAX_ITR 8160 /* maximum value as per datasheet */
|
|
|
|
#define ITR_TO_REG(setting) ((setting) & ~IAVF_ITR_DYNAMIC)
|
|
|
|
#define ITR_REG_ALIGN(setting) __ALIGN_MASK(setting, ~IAVF_ITR_MASK)
|
|
|
|
#define ITR_IS_DYNAMIC(setting) (!!((setting) & IAVF_ITR_DYNAMIC))
|
|
|
|
|
|
|
|
#define IAVF_ITR_RX_DEF (IAVF_ITR_20K | IAVF_ITR_DYNAMIC)
|
|
|
|
#define IAVF_ITR_TX_DEF (IAVF_ITR_20K | IAVF_ITR_DYNAMIC)
|
2017-12-29 08:51:08 -05:00
|
|
|
|
2015-09-28 14:12:37 -04:00
|
|
|
/* 0x40 is the enable bit for interrupt rate limiting, and must be set if
|
|
|
|
* the value of the rate limit is non-zero
|
|
|
|
*/
|
|
|
|
#define INTRL_ENA BIT(6)
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_MAX_INTRL 0x3B /* reg uses 4 usec resolution */
|
2015-09-28 14:12:37 -04:00
|
|
|
#define INTRL_REG_TO_USEC(intrl) ((intrl & ~INTRL_ENA) << 2)
|
|
|
|
#define INTRL_USEC_TO_REG(set) ((set) ? ((set) >> 2) | INTRL_ENA : 0)
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_INTRL_8K 125 /* 8000 ints/sec */
|
|
|
|
#define IAVF_INTRL_62K 16 /* 62500 ints/sec */
|
|
|
|
#define IAVF_INTRL_83K 12 /* 83333 ints/sec */
|
2013-12-21 06:13:06 +00:00
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_QUEUE_END_OF_LIST 0x7FF
|
2013-12-21 06:13:06 +00:00
|
|
|
|
|
|
|
/* this enum matches hardware bits and is meant to be used by DYN_CTLN
|
|
|
|
* registers and QINT registers or more generally anywhere in the manual
|
|
|
|
* mentioning ITR_INDX, ITR_NONE cannot be used as an index 'n' into any
|
|
|
|
* register but instead is a special value meaning "don't update" ITR0/1/2.
|
|
|
|
*/
|
2018-09-14 17:37:55 -07:00
|
|
|
enum iavf_dyn_idx_t {
|
|
|
|
IAVF_IDX_ITR0 = 0,
|
|
|
|
IAVF_IDX_ITR1 = 1,
|
|
|
|
IAVF_IDX_ITR2 = 2,
|
|
|
|
IAVF_ITR_NONE = 3 /* ITR_NONE must not be used as an index */
|
2013-12-21 06:13:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* these are indexes into ITRN registers */
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_RX_ITR IAVF_IDX_ITR0
|
|
|
|
#define IAVF_TX_ITR IAVF_IDX_ITR1
|
|
|
|
#define IAVF_PE_ITR IAVF_IDX_ITR2
|
2013-12-21 06:13:06 +00:00
|
|
|
|
|
|
|
/* Supported RSS offloads */
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_DEFAULT_RSS_HENA ( \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV4_UDP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV4_SCTP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV4_TCP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV4_OTHER) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_FRAG_IPV4) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV6_UDP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV6_TCP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV6_SCTP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV6_OTHER) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_FRAG_IPV6) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_L2_PAYLOAD))
|
|
|
|
|
|
|
|
#define IAVF_DEFAULT_RSS_HENA_EXPANDED (IAVF_DEFAULT_RSS_HENA | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_IPV6_TCP_SYN_NO_ACK) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) | \
|
|
|
|
BIT_ULL(IAVF_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP))
|
2015-06-23 19:00:04 -04:00
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
#define iavf_rx_desc iavf_32byte_rx_desc
|
2016-04-18 11:33:46 -07:00
|
|
|
|
|
|
|
/**
|
2018-09-14 17:37:55 -07:00
|
|
|
* iavf_test_staterr - tests bits in Rx descriptor status and error fields
|
2016-04-18 11:33:46 -07:00
|
|
|
* @rx_desc: pointer to receive descriptor (in le64 format)
|
|
|
|
* @stat_err_bits: value to mask
|
|
|
|
*
|
|
|
|
* This function does some fast chicanery in order to return the
|
|
|
|
* value of the mask which is really only used for boolean tests.
|
|
|
|
* The status_error_len doesn't need to be shifted because it begins
|
|
|
|
* at offset zero.
|
|
|
|
*/
|
2018-09-14 17:37:55 -07:00
|
|
|
static inline bool iavf_test_staterr(union iavf_rx_desc *rx_desc,
|
2016-04-18 11:33:46 -07:00
|
|
|
const u64 stat_err_bits)
|
|
|
|
{
|
|
|
|
return !!(rx_desc->wb.qword1.status_error_len &
|
|
|
|
cpu_to_le64(stat_err_bits));
|
|
|
|
}
|
2013-12-21 06:13:06 +00:00
|
|
|
|
|
|
|
/* How many Rx Buffers do we bundle into one write to the hardware ? */
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_RX_INCREMENT(r, i) \
|
2015-01-24 09:58:35 +00:00
|
|
|
do { \
|
|
|
|
(i)++; \
|
|
|
|
if ((i) == (r)->count) \
|
|
|
|
i = 0; \
|
|
|
|
r->next_to_clean = i; \
|
|
|
|
} while (0)
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_RX_NEXT_DESC(r, i, n) \
|
2013-12-21 06:13:06 +00:00
|
|
|
do { \
|
|
|
|
(i)++; \
|
|
|
|
if ((i) == (r)->count) \
|
|
|
|
i = 0; \
|
2018-09-14 17:37:49 -07:00
|
|
|
(n) = IAVF_RX_DESC((r), (i)); \
|
2013-12-21 06:13:06 +00:00
|
|
|
} while (0)
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_RX_NEXT_DESC_PREFETCH(r, i, n) \
|
2013-12-21 06:13:06 +00:00
|
|
|
do { \
|
2018-09-14 17:37:55 -07:00
|
|
|
IAVF_RX_NEXT_DESC((r), (i), (n)); \
|
2013-12-21 06:13:06 +00:00
|
|
|
prefetch((n)); \
|
|
|
|
} while (0)
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_MAX_BUFFER_TXD 8
|
|
|
|
#define IAVF_MIN_TX_LEN 17
|
2016-02-19 12:17:08 -08:00
|
|
|
|
|
|
|
/* The size limit for a transmit buffer in a descriptor is (16K - 1).
|
|
|
|
* In order to align with the read requests we will align the value to
|
|
|
|
* the nearest 4K which represents our maximum read request size.
|
|
|
|
*/
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_MAX_READ_REQ_SIZE 4096
|
|
|
|
#define IAVF_MAX_DATA_PER_TXD (16 * 1024 - 1)
|
|
|
|
#define IAVF_MAX_DATA_PER_TXD_ALIGNED \
|
|
|
|
(IAVF_MAX_DATA_PER_TXD & ~(IAVF_MAX_READ_REQ_SIZE - 1))
|
2016-02-19 12:17:08 -08:00
|
|
|
|
2016-11-08 13:05:14 -08:00
|
|
|
/**
|
2018-09-14 17:37:55 -07:00
|
|
|
* iavf_txd_use_count - estimate the number of descriptors needed for Tx
|
2016-11-08 13:05:14 -08:00
|
|
|
* @size: transmit request size in bytes
|
|
|
|
*
|
|
|
|
* Due to hardware alignment restrictions (4K alignment), we need to
|
|
|
|
* assume that we can have no more than 12K of data per descriptor, even
|
|
|
|
* though each descriptor can take up to 16K - 1 bytes of aligned memory.
|
|
|
|
* Thus, we need to divide by 12K. But division is slow! Instead,
|
|
|
|
* we decompose the operation into shifts and one relatively cheap
|
|
|
|
* multiply operation.
|
|
|
|
*
|
|
|
|
* To divide by 12K, we first divide by 4K, then divide by 3:
|
|
|
|
* To divide by 4K, shift right by 12 bits
|
|
|
|
* To divide by 3, multiply by 85, then divide by 256
|
|
|
|
* (Divide by 256 is done by shifting right by 8 bits)
|
|
|
|
* Finally, we add one to round up. Because 256 isn't an exact multiple of
|
|
|
|
* 3, we'll underestimate near each multiple of 12K. This is actually more
|
|
|
|
* accurate as we have 4K - 1 of wiggle room that we can fit into the last
|
|
|
|
* segment. For our purposes this is accurate out to 1M which is orders of
|
|
|
|
* magnitude greater than our largest possible GSO size.
|
|
|
|
*
|
|
|
|
* This would then be implemented as:
|
|
|
|
* return (((size >> 12) * 85) >> 8) + 1;
|
|
|
|
*
|
|
|
|
* Since multiplication and division are commutative, we can reorder
|
|
|
|
* operations into:
|
|
|
|
* return ((size * 85) >> 20) + 1;
|
2016-02-19 12:17:08 -08:00
|
|
|
*/
|
2018-09-14 17:37:55 -07:00
|
|
|
static inline unsigned int iavf_txd_use_count(unsigned int size)
|
2016-02-19 12:17:08 -08:00
|
|
|
{
|
2016-11-08 13:05:14 -08:00
|
|
|
return ((size * 85) >> 20) + 1;
|
2016-02-19 12:17:08 -08:00
|
|
|
}
|
2013-12-21 06:13:06 +00:00
|
|
|
|
|
|
|
/* Tx Descriptors needed, worst case */
|
2018-01-26 08:54:45 -08:00
|
|
|
#define DESC_NEEDED (MAX_SKB_FRAGS + 6)
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_MIN_DESC_PENDING 4
|
|
|
|
|
2021-11-29 16:16:02 -08:00
|
|
|
#define IAVF_TX_FLAGS_HW_VLAN BIT(1)
|
|
|
|
#define IAVF_TX_FLAGS_SW_VLAN BIT(2)
|
|
|
|
#define IAVF_TX_FLAGS_TSO BIT(3)
|
|
|
|
#define IAVF_TX_FLAGS_IPV4 BIT(4)
|
|
|
|
#define IAVF_TX_FLAGS_IPV6 BIT(5)
|
|
|
|
#define IAVF_TX_FLAGS_FCCRC BIT(6)
|
|
|
|
#define IAVF_TX_FLAGS_FSO BIT(7)
|
|
|
|
#define IAVF_TX_FLAGS_FD_SB BIT(9)
|
|
|
|
#define IAVF_TX_FLAGS_VXLAN_TUNNEL BIT(10)
|
|
|
|
#define IAVF_TX_FLAGS_HW_OUTER_SINGLE_VLAN BIT(11)
|
|
|
|
#define IAVF_TX_FLAGS_VLAN_MASK 0xffff0000
|
|
|
|
#define IAVF_TX_FLAGS_VLAN_PRIO_MASK 0xe0000000
|
|
|
|
#define IAVF_TX_FLAGS_VLAN_PRIO_SHIFT 29
|
|
|
|
#define IAVF_TX_FLAGS_VLAN_SHIFT 16
|
2018-09-14 17:37:55 -07:00
|
|
|
|
|
|
|
struct iavf_tx_buffer {
|
|
|
|
struct iavf_tx_desc *next_to_watch;
|
2014-06-04 08:45:15 +00:00
|
|
|
union {
|
|
|
|
struct sk_buff *skb;
|
|
|
|
void *raw_buf;
|
|
|
|
};
|
2013-12-21 06:13:06 +00:00
|
|
|
unsigned int bytecount;
|
|
|
|
unsigned short gso_segs;
|
2015-08-28 17:55:54 -04:00
|
|
|
|
2013-12-21 06:13:06 +00:00
|
|
|
DEFINE_DMA_UNMAP_ADDR(dma);
|
|
|
|
DEFINE_DMA_UNMAP_LEN(len);
|
|
|
|
u32 tx_flags;
|
|
|
|
};
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_queue_stats {
|
2013-12-21 06:13:06 +00:00
|
|
|
u64 packets;
|
|
|
|
u64 bytes;
|
|
|
|
};
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_tx_queue_stats {
|
2013-12-21 06:13:06 +00:00
|
|
|
u64 restart_queue;
|
|
|
|
u64 tx_busy;
|
|
|
|
u64 tx_done_old;
|
2015-08-27 11:42:29 -04:00
|
|
|
u64 tx_linearize;
|
2015-10-21 19:47:08 -04:00
|
|
|
u64 tx_force_wb;
|
2016-01-15 14:33:12 -08:00
|
|
|
u64 tx_lost_interrupt;
|
2013-12-21 06:13:06 +00:00
|
|
|
};
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_rx_queue_stats {
|
2013-12-21 06:13:06 +00:00
|
|
|
u64 non_eop_descs;
|
|
|
|
u64 alloc_page_failed;
|
|
|
|
u64 alloc_buff_failed;
|
|
|
|
};
|
|
|
|
|
2016-04-18 11:33:47 -07:00
|
|
|
/* some useful defines for virtchannel interface, which
|
|
|
|
* is the only remaining user of header split
|
|
|
|
*/
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_RX_DTYPE_NO_SPLIT 0
|
|
|
|
#define IAVF_RX_DTYPE_HEADER_SPLIT 1
|
|
|
|
#define IAVF_RX_DTYPE_SPLIT_ALWAYS 2
|
|
|
|
#define IAVF_RX_SPLIT_L2 0x1
|
|
|
|
#define IAVF_RX_SPLIT_IP 0x2
|
|
|
|
#define IAVF_RX_SPLIT_TCP_UDP 0x4
|
|
|
|
#define IAVF_RX_SPLIT_SCTP 0x8
|
2013-12-21 06:13:06 +00:00
|
|
|
|
|
|
|
/* struct that defines a descriptor ring, associated with a VSI */
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_ring {
|
|
|
|
struct iavf_ring *next; /* pointer to next ring in q_vector */
|
2013-12-21 06:13:06 +00:00
|
|
|
void *desc; /* Descriptor ring memory */
|
2024-04-18 13:36:15 +02:00
|
|
|
union {
|
|
|
|
struct page_pool *pp; /* Used on Rx for buffer management */
|
|
|
|
struct device *dev; /* Used on Tx for DMA mapping */
|
|
|
|
};
|
2013-12-21 06:13:06 +00:00
|
|
|
struct net_device *netdev; /* netdev ring maps to */
|
|
|
|
union {
|
2024-04-18 13:36:15 +02:00
|
|
|
struct libeth_fqe *rx_fqes;
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_tx_buffer *tx_bi;
|
2013-12-21 06:13:06 +00:00
|
|
|
};
|
|
|
|
u8 __iomem *tail;
|
2024-04-18 13:36:15 +02:00
|
|
|
u32 truesize;
|
|
|
|
|
2024-04-18 13:36:14 +02:00
|
|
|
u16 queue_index; /* Queue number of ring */
|
2013-12-21 06:13:06 +00:00
|
|
|
|
2016-09-12 14:18:44 -07:00
|
|
|
/* high bit set means dynamic, use accessors routines to read/write.
|
|
|
|
* hardware only supports 2us resolution for the ITR registers.
|
|
|
|
* these values always store the USER setting, and must be converted
|
|
|
|
* before programming to a register.
|
|
|
|
*/
|
2017-12-29 08:49:28 -05:00
|
|
|
u16 itr_setting;
|
2016-09-12 14:18:44 -07:00
|
|
|
|
2013-12-21 06:13:06 +00:00
|
|
|
u16 count; /* Number of descriptors */
|
|
|
|
|
|
|
|
/* used in interrupt processing */
|
|
|
|
u16 next_to_use;
|
|
|
|
u16 next_to_clean;
|
|
|
|
|
2015-06-05 12:20:30 -04:00
|
|
|
u16 flags;
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_TXR_FLAGS_WB_ON_ITR BIT(0)
|
2024-04-18 13:36:14 +02:00
|
|
|
#define IAVF_TXR_FLAGS_ARM_WB BIT(1)
|
iavf: kill "legacy-rx" for good
Ever since build_skb() became stable, the old way with allocating an skb
for storing the headers separately, which will be then copied manually,
was slower, less flexible, and thus obsolete.
* It had higher pressure on MM since it actually allocates new pages,
which then get split and refcount-biased (NAPI page cache);
* It implies memcpy() of packet headers (40+ bytes per each frame);
* the actual header length was calculated via eth_get_headlen(), which
invokes Flow Dissector and thus wastes a bunch of CPU cycles;
* XDP makes it even more weird since it requires headroom for long and
also tailroom for some time (since mbuf landed). Take a look at the
ice driver, which is built around work-arounds to make XDP work with
it.
Even on some quite low-end hardware (not a common case for 100G NICs) it
was performing worse.
The only advantage "legacy-rx" had is that it didn't require any
reserved headroom and tailroom. But iavf didn't use this, as it always
splits pages into two halves of 2k, while that save would only be useful
when striding. And again, XDP effectively removes that sole pro.
There's a train of features to land in IAVF soon: Page Pool, XDP, XSk,
multi-buffer etc. Each new would require adding more and more Danse
Macabre for absolutely no reason, besides making hotpath less and less
effective.
Remove the "feature" with all the related code. This includes at least
one very hot branch (typically hit on each new frame), which was either
always-true or always-false at least for a complete NAPI bulk of 64
frames, the whole private flags cruft, and so on. Some stats:
Function: add/remove: 0/4 grow/shrink: 0/7 up/down: 0/-721 (-721)
RO Data: add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-40 (-40)
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2024-04-18 13:36:08 +02:00
|
|
|
/* BIT(2) is free */
|
2021-11-29 16:16:02 -08:00
|
|
|
#define IAVF_TXRX_FLAGS_VLAN_TAG_LOC_L2TAG1 BIT(3)
|
|
|
|
#define IAVF_TXR_FLAGS_VLAN_TAG_LOC_L2TAG2 BIT(4)
|
|
|
|
#define IAVF_RXR_FLAGS_VLAN_TAG_LOC_L2TAG2_2 BIT(5)
|
2015-06-05 12:20:31 -04:00
|
|
|
|
2013-12-21 06:13:06 +00:00
|
|
|
/* stats structs */
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_queue_stats stats;
|
2013-12-21 06:13:06 +00:00
|
|
|
struct u64_stats_sync syncp;
|
|
|
|
union {
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_tx_queue_stats tx_stats;
|
|
|
|
struct iavf_rx_queue_stats rx_stats;
|
2013-12-21 06:13:06 +00:00
|
|
|
};
|
|
|
|
|
2024-04-18 13:36:14 +02:00
|
|
|
int prev_pkt_ctr; /* For Tx stall detection */
|
2013-12-21 06:13:06 +00:00
|
|
|
unsigned int size; /* length of descriptor ring in bytes */
|
|
|
|
dma_addr_t dma; /* physical address of ring */
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_vsi *vsi; /* Backreference to associated VSI */
|
|
|
|
struct iavf_q_vector *q_vector; /* Backreference to associated vector */
|
2013-12-21 06:13:06 +00:00
|
|
|
|
|
|
|
struct rcu_head rcu; /* to avoid race on free */
|
2018-09-14 17:37:46 -07:00
|
|
|
struct sk_buff *skb; /* When iavf_clean_rx_ring_irq() must
|
2017-02-09 23:40:25 -08:00
|
|
|
* return before it sees the EOP for
|
|
|
|
* the current packet, we save that skb
|
|
|
|
* here and resume receiving this
|
|
|
|
* packet the next time
|
2018-09-14 17:37:46 -07:00
|
|
|
* iavf_clean_rx_ring_irq() is called
|
2017-02-09 23:40:25 -08:00
|
|
|
* for this ring.
|
|
|
|
*/
|
2024-04-18 13:36:15 +02:00
|
|
|
|
|
|
|
u32 rx_buf_len;
|
2013-12-21 06:13:06 +00:00
|
|
|
} ____cacheline_internodealigned_in_smp;
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
#define IAVF_ITR_ADAPTIVE_MIN_INC 0x0002
|
|
|
|
#define IAVF_ITR_ADAPTIVE_MIN_USECS 0x0002
|
|
|
|
#define IAVF_ITR_ADAPTIVE_MAX_USECS 0x007e
|
|
|
|
#define IAVF_ITR_ADAPTIVE_LATENCY 0x8000
|
|
|
|
#define IAVF_ITR_ADAPTIVE_BULK 0x0000
|
|
|
|
#define ITR_IS_BULK(x) (!((x) & IAVF_ITR_ADAPTIVE_LATENCY))
|
2013-12-21 06:13:06 +00:00
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
struct iavf_ring_container {
|
|
|
|
struct iavf_ring *ring; /* pointer to linked list of ring(s) */
|
2017-12-29 08:52:19 -05:00
|
|
|
unsigned long next_update; /* jiffies value of next update */
|
2013-12-21 06:13:06 +00:00
|
|
|
unsigned int total_bytes; /* total bytes processed this int */
|
|
|
|
unsigned int total_packets; /* total packets processed this int */
|
|
|
|
u16 count;
|
2017-12-29 08:51:25 -05:00
|
|
|
u16 target_itr; /* target ITR setting for ring(s) */
|
|
|
|
u16 current_itr; /* current ITR setting for ring(s) */
|
2013-12-21 06:13:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* iterator for handling rings in ring container */
|
2018-09-14 17:37:55 -07:00
|
|
|
#define iavf_for_each_ring(pos, head) \
|
2013-12-21 06:13:06 +00:00
|
|
|
for (pos = (head).ring; pos != NULL; pos = pos->next)
|
|
|
|
|
2018-09-14 17:37:55 -07:00
|
|
|
bool iavf_alloc_rx_buffers(struct iavf_ring *rxr, u16 cleaned_count);
|
2018-09-14 17:37:46 -07:00
|
|
|
netdev_tx_t iavf_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
|
2018-09-14 17:37:55 -07:00
|
|
|
int iavf_setup_tx_descriptors(struct iavf_ring *tx_ring);
|
|
|
|
int iavf_setup_rx_descriptors(struct iavf_ring *rx_ring);
|
|
|
|
void iavf_free_tx_resources(struct iavf_ring *tx_ring);
|
|
|
|
void iavf_free_rx_resources(struct iavf_ring *rx_ring);
|
2018-09-14 17:37:46 -07:00
|
|
|
int iavf_napi_poll(struct napi_struct *napi, int budget);
|
2018-09-14 17:37:55 -07:00
|
|
|
void iavf_detect_recover_hung(struct iavf_vsi *vsi);
|
|
|
|
int __iavf_maybe_stop_tx(struct iavf_ring *tx_ring, int size);
|
2018-09-14 17:37:46 -07:00
|
|
|
bool __iavf_chk_linearize(struct sk_buff *skb);
|
2015-11-06 15:26:02 -08:00
|
|
|
|
2016-02-17 11:02:43 -08:00
|
|
|
/**
|
2018-09-14 17:37:55 -07:00
|
|
|
* iavf_xmit_descriptor_count - calculate number of Tx descriptors needed
|
2016-02-17 11:02:43 -08:00
|
|
|
* @skb: send buffer
|
|
|
|
*
|
|
|
|
* Returns number of data descriptors needed for this skb. Returns 0 to indicate
|
|
|
|
* there is not enough descriptors available in this ring since we need at least
|
|
|
|
* one descriptor.
|
|
|
|
**/
|
2018-09-14 17:37:55 -07:00
|
|
|
static inline int iavf_xmit_descriptor_count(struct sk_buff *skb)
|
2016-02-17 11:02:43 -08:00
|
|
|
{
|
2019-07-22 20:08:25 -07:00
|
|
|
const skb_frag_t *frag = &skb_shinfo(skb)->frags[0];
|
2016-02-17 11:02:43 -08:00
|
|
|
unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
|
|
|
|
int count = 0, size = skb_headlen(skb);
|
|
|
|
|
|
|
|
for (;;) {
|
2018-09-14 17:37:55 -07:00
|
|
|
count += iavf_txd_use_count(size);
|
2016-02-17 11:02:43 -08:00
|
|
|
|
|
|
|
if (!nr_frags--)
|
|
|
|
break;
|
|
|
|
|
|
|
|
size = skb_frag_size(frag++);
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-09-14 17:37:55 -07:00
|
|
|
* iavf_maybe_stop_tx - 1st level check for Tx stop conditions
|
2016-02-17 11:02:43 -08:00
|
|
|
* @tx_ring: the ring to be checked
|
|
|
|
* @size: the size buffer we want to assure is available
|
|
|
|
*
|
|
|
|
* Returns 0 if stop is not needed
|
|
|
|
**/
|
2018-09-14 17:37:55 -07:00
|
|
|
static inline int iavf_maybe_stop_tx(struct iavf_ring *tx_ring, int size)
|
2016-02-17 11:02:43 -08:00
|
|
|
{
|
2018-09-14 17:37:55 -07:00
|
|
|
if (likely(IAVF_DESC_UNUSED(tx_ring) >= size))
|
2016-02-17 11:02:43 -08:00
|
|
|
return 0;
|
2018-09-14 17:37:46 -07:00
|
|
|
return __iavf_maybe_stop_tx(tx_ring, size);
|
2016-02-17 11:02:43 -08:00
|
|
|
}
|
2016-02-17 11:02:50 -08:00
|
|
|
|
|
|
|
/**
|
2018-09-14 17:37:55 -07:00
|
|
|
* iavf_chk_linearize - Check if there are more than 8 fragments per packet
|
2016-02-17 11:02:50 -08:00
|
|
|
* @skb: send buffer
|
|
|
|
* @count: number of buffers used
|
|
|
|
*
|
|
|
|
* Note: Our HW can't scatter-gather more than 8 fragments to build
|
|
|
|
* a packet on the wire and so we need to figure out the cases where we
|
|
|
|
* need to linearize the skb.
|
|
|
|
**/
|
2018-09-14 17:37:55 -07:00
|
|
|
static inline bool iavf_chk_linearize(struct sk_buff *skb, int count)
|
2016-02-17 11:02:50 -08:00
|
|
|
{
|
2016-03-30 16:15:37 -07:00
|
|
|
/* Both TSO and single send will work if count is less than 8 */
|
2018-09-14 17:37:55 -07:00
|
|
|
if (likely(count < IAVF_MAX_BUFFER_TXD))
|
2016-02-17 11:02:50 -08:00
|
|
|
return false;
|
|
|
|
|
2016-03-30 16:15:37 -07:00
|
|
|
if (skb_is_gso(skb))
|
2018-09-14 17:37:46 -07:00
|
|
|
return __iavf_chk_linearize(skb);
|
2016-03-30 16:15:37 -07:00
|
|
|
|
|
|
|
/* we can support up to 8 data buffers for a single send */
|
2018-09-14 17:37:55 -07:00
|
|
|
return count != IAVF_MAX_BUFFER_TXD;
|
2016-02-17 11:02:50 -08:00
|
|
|
}
|
2016-09-12 14:18:40 -07:00
|
|
|
/**
|
2020-09-25 15:24:37 -07:00
|
|
|
* txring_txq - helper to convert from a ring to a queue
|
2016-09-12 14:18:40 -07:00
|
|
|
* @ring: Tx ring to find the netdev equivalent of
|
|
|
|
**/
|
2018-09-14 17:37:55 -07:00
|
|
|
static inline struct netdev_queue *txring_txq(const struct iavf_ring *ring)
|
2016-09-12 14:18:40 -07:00
|
|
|
{
|
|
|
|
return netdev_get_tx_queue(ring->netdev, ring->queue_index);
|
|
|
|
}
|
2018-09-14 17:37:55 -07:00
|
|
|
#endif /* _IAVF_TXRX_H_ */
|