Skip to content

Commit c0d4e9d

Browse files
mfijalkoanguy11
authored andcommitted
ixgbe: store the result of ixgbe_rx_offset() onto ixgbe_ring
Output of ixgbe_rx_offset() is based on ethtool's priv flag setting, which when changed, causes PF reset (disables napi, frees irqs, loads different Rx mem model, etc.). This means that within napi its result is constant and there is no reason to call it per each processed frame. Add new 'rx_offset' field to ixgbe_ring that is meant to hold the ixgbe_rx_offset() result and use it within ixgbe_clean_rx_irq(). Furthermore, use it within ixgbe_alloc_mapped_page(). Last but not least, un-inline the function of interest as it lives in .c file so let compiler do the decision about the inlining. Reviewed-by: Björn Töpel <[email protected]> Signed-off-by: Maciej Fijalkowski <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent f1b1f40 commit c0d4e9d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ struct ixgbe_ring {
349349
struct ixgbe_tx_queue_stats tx_stats;
350350
struct ixgbe_rx_queue_stats rx_stats;
351351
};
352+
u16 rx_offset;
352353
struct xdp_rxq_info xdp_rxq;
353354
struct xsk_buff_pool *xsk_pool;
354355
u16 ring_idx; /* {rx,tx,xdp}_ring back reference idx */

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ static inline void ixgbe_rx_checksum(struct ixgbe_ring *ring,
15201520
}
15211521
}
15221522

1523-
static inline unsigned int ixgbe_rx_offset(struct ixgbe_ring *rx_ring)
1523+
static unsigned int ixgbe_rx_offset(struct ixgbe_ring *rx_ring)
15241524
{
15251525
return ring_uses_build_skb(rx_ring) ? IXGBE_SKB_PAD : 0;
15261526
}
@@ -1561,7 +1561,7 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring *rx_ring,
15611561

15621562
bi->dma = dma;
15631563
bi->page = page;
1564-
bi->page_offset = ixgbe_rx_offset(rx_ring);
1564+
bi->page_offset = rx_ring->rx_offset;
15651565
page_ref_add(page, USHRT_MAX - 1);
15661566
bi->pagecnt_bias = USHRT_MAX;
15671567
rx_ring->rx_stats.alloc_rx_page++;
@@ -2001,8 +2001,8 @@ static void ixgbe_add_rx_frag(struct ixgbe_ring *rx_ring,
20012001
#if (PAGE_SIZE < 8192)
20022002
unsigned int truesize = ixgbe_rx_pg_size(rx_ring) / 2;
20032003
#else
2004-
unsigned int truesize = ring_uses_build_skb(rx_ring) ?
2005-
SKB_DATA_ALIGN(IXGBE_SKB_PAD + size) :
2004+
unsigned int truesize = rx_ring->rx_offset ?
2005+
SKB_DATA_ALIGN(rx_ring->rx_offset + size) :
20062006
SKB_DATA_ALIGN(size);
20072007
#endif
20082008
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page,
@@ -2249,8 +2249,8 @@ static unsigned int ixgbe_rx_frame_truesize(struct ixgbe_ring *rx_ring,
22492249
#if (PAGE_SIZE < 8192)
22502250
truesize = ixgbe_rx_pg_size(rx_ring) / 2; /* Must be power-of-2 */
22512251
#else
2252-
truesize = ring_uses_build_skb(rx_ring) ?
2253-
SKB_DATA_ALIGN(IXGBE_SKB_PAD + size) +
2252+
truesize = rx_ring->rx_offset ?
2253+
SKB_DATA_ALIGN(rx_ring->rx_offset + size) +
22542254
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) :
22552255
SKB_DATA_ALIGN(size);
22562256
#endif
@@ -2293,6 +2293,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
22932293
unsigned int mss = 0;
22942294
#endif /* IXGBE_FCOE */
22952295
u16 cleaned_count = ixgbe_desc_unused(rx_ring);
2296+
unsigned int offset = rx_ring->rx_offset;
22962297
unsigned int xdp_xmit = 0;
22972298
struct xdp_buff xdp;
22982299

@@ -2330,7 +2331,6 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
23302331

23312332
/* retrieve a buffer from the ring */
23322333
if (!skb) {
2333-
unsigned int offset = ixgbe_rx_offset(rx_ring);
23342334
unsigned char *hard_start;
23352335

23362336
hard_start = page_address(rx_buffer->page) +
@@ -6578,6 +6578,7 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
65786578

65796579
rx_ring->next_to_clean = 0;
65806580
rx_ring->next_to_use = 0;
6581+
rx_ring->rx_offset = ixgbe_rx_offset(rx_ring);
65816582

65826583
/* XDP RX-queue info */
65836584
if (xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev,

0 commit comments

Comments
 (0)