/* The datasheet for the X710 and XL710 indicate that the maximum value for *theITRis8160usecwhichisthencalledoutas0xFF0witha2usec *resolution.8160is0x1FE0whenwrittenoutinhex.Soinsteadofstoring *theregistervaluewhichisdividedby2letsusetheactualvaluesand *avoidanexcessiveamountoftranslation.
*/ #define I40E_ITR_DYNAMIC 0x8000 /* use top bit as a flag */ #define I40E_ITR_MASK 0x1FFE /* mask for ITR register value */ #define I40E_MIN_ITR 2/* reg uses 2 usec resolution */ #define I40E_ITR_20K 50 #define I40E_ITR_8K 122 #define I40E_MAX_ITR 8160/* maximum value as per datasheet */ #define ITR_TO_REG(setting) ((setting) & ~I40E_ITR_DYNAMIC) #define ITR_REG_ALIGN(setting) __ALIGN_MASK(setting, ~I40E_ITR_MASK) #define ITR_IS_DYNAMIC(setting) (!!((setting) & I40E_ITR_DYNAMIC))
/* 0x40 is the enable bit for interrupt rate limiting, and must be set if *thevalueoftheratelimitisnon-zero
*/ #define INTRL_ENA BIT(6) #define I40E_MAX_INTRL 0x3B /* reg uses 4 usec resolution */ #define INTRL_REG_TO_USEC(intrl) ((intrl & ~INTRL_ENA) << 2)
/* this enum matches hardware bits and is meant to be used by DYN_CTLN *registersandQINTregistersormoregenerallyanywhereinthemanual *mentioningITR_INDX,ITR_NONEcannotbeusedasanindex'n'intoany *registerbutinsteadisaspecialvaluemeaning"don'tupdate"ITR0/1/2.
*/ enum i40e_dyn_idx {
I40E_IDX_ITR0 = 0,
I40E_IDX_ITR1 = 1,
I40E_IDX_ITR2 = 2,
I40E_ITR_NONE = 3/* ITR_NONE must not be used as an index */
};
/* these are indexes into ITRN registers */ #define I40E_RX_ITR I40E_IDX_ITR0 #define I40E_TX_ITR I40E_IDX_ITR1 #define I40E_SW_ITR I40E_IDX_ITR2
/* Supported Rx Buffer Sizes (a multiple of 128) */ #define I40E_RXBUFFER_256 256 #define I40E_RXBUFFER_1536 1536/* 128B aligned standard Ethernet frame */ #define I40E_RXBUFFER_2048 2048 #define I40E_RXBUFFER_3072 3072/* Used for large frames w/ padding */ #define I40E_MAX_RXBUFFER 9728/* largest size for single descriptor */
/* NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we *reserve2more,andskb_shared_infoaddsanadditional384bytesmore, *thisaddsupto512bytesofextradatameaningthesmallestallocation *wecouldhaveis1K. *i.e.RXBUFFER_256-->960byteskb(size-1024slab) *i.e.RXBUFFER_512-->1216byteskb(size-2048slab)
*/ #define I40E_RX_HDR_SIZE I40E_RXBUFFER_256 #define I40E_PACKET_HDR_PAD (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2)) #define i40e_rx_desc i40e_16byte_rx_desc
staticinlineint i40e_skb_pad(void)
{ int rx_buf_len;
/* If a 2K buffer cannot handle a standard Ethernet frame then *optimizepaddingfora3Kbufferinsteadofa1.5Kbuffer. * *Fora3Kbufferweneedtoaddenoughpaddingtoallowfor *tailroomduetoNET_IP_ALIGNpossiblyshiftingusoutof *cache-linealignment.
*/ if (I40E_2K_TOO_SMALL_WITH_PADDING)
rx_buf_len = I40E_RXBUFFER_3072 + SKB_DATA_ALIGN(NET_IP_ALIGN); else
rx_buf_len = I40E_RXBUFFER_1536;
/* if needed make room for NET_IP_ALIGN */
rx_buf_len -= NET_IP_ALIGN;
enum i40e_ring_state {
__I40E_TX_FDIR_INIT_DONE,
__I40E_TX_XPS_INIT_DONE,
__I40E_RING_STATE_NBITS /* must be last */
};
/* some useful defines for virtchannel interface, which *istheonlyremaininguserofheadersplit
*/ #define I40E_RX_DTYPE_HEADER_SPLIT 1 #define I40E_RX_SPLIT_L2 0x1 #define I40E_RX_SPLIT_IP 0x2 #define I40E_RX_SPLIT_TCP_UDP 0x4 #define I40E_RX_SPLIT_SCTP 0x8
/* struct that defines a descriptor ring, associated with a VSI */ struct i40e_ring { struct i40e_ring *next; /* pointer to next ring in q_vector */ void *desc; /* Descriptor ring memory */ struct device *dev; /* Used for DMA mapping */ struct net_device *netdev; /* netdev ring maps to */ struct bpf_prog *xdp_prog; union { struct i40e_tx_buffer *tx_bi; struct i40e_rx_buffer *rx_bi; struct xdp_buff **rx_bi_zc;
};
DECLARE_BITMAP(state, __I40E_RING_STATE_NBITS);
u16 queue_index; /* Queue number of ring */
u8 dcb_tc; /* Traffic class of ring */
u8 __iomem *tail;
/* Storing xdp_buff on ring helps in saving the state of partially built *packetwheni40e_clean_rx_ring_irq()mustreturnbeforeitseesEOP *andtoresumepacketbuildingforthisringinthenextcallto *i40e_clean_rx_ring_irq().
*/ struct xdp_buff xdp;
/* Next descriptor to be processed; next_to_clean is updated only on *processingEOPdescriptor
*/
u16 next_to_process; /* high bit set means dynamic, use accessor routines to read/write. *hardwareonlysupports2usresolutionfortheITRregisters. *thesevaluesalwaysstoretheUSERsetting,andmustbeconverted *beforeprogrammingtoaregister.
*/
u16 itr_setting;
u16 count; /* Number of descriptors */
u16 reg_idx; /* HW register index of the ring */
u16 rx_buf_len;
/* used in interrupt processing */
u16 next_to_use;
u16 next_to_clean;
u16 xdp_tx_active;
u8 atr_sample_rate;
u8 atr_count;
bool ring_active; /* is ring online or not */ bool arm_wb; /* do something to arm write back */
u8 packet_stride;
struct i40e_ring_container { struct i40e_ring *ring; /* pointer to linked list of ring(s) */ unsignedlong next_update; /* jiffies value of next update */ unsignedint total_bytes; /* total bytes processed this int */ unsignedint total_packets; /* total packets processed this int */
u16 count;
u16 target_itr; /* target ITR setting for ring(s) */
u16 current_itr; /* current ITR setting for ring(s) */
};
/* iterator for handling rings in ring container */ #define i40e_for_each_ring(pos, head) \ for (pos = (head).ring; pos != NULL; pos = pos->next)
/** *i40e_chk_linearize-Checkiftherearemorethan8fragmentsperpacket *@skb:sendbuffer *@count:numberofbuffersused * *Note:OurHWcan'tscatter-gathermorethan8fragmentstobuild *apacketonthewireandsoweneedtofigureoutthecaseswherewe *needtolinearizetheskb.
**/ staticinlinebool i40e_chk_linearize(struct sk_buff *skb, int count)
{ /* Both TSO and single send will work if count is less than 8 */ if (likely(count < I40E_MAX_BUFFER_TXD)) returnfalse;
if (skb_is_gso(skb)) return __i40e_chk_linearize(skb);
/* we can support up to 8 data buffers for a single send */ return count != I40E_MAX_BUFFER_TXD;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.