Skip to content

Commit f7bb0d7

Browse files
mfijalkoanguy11
authored andcommitted
i40e: store the result of i40e_rx_offset() onto i40e_ring
Output of i40e_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 i40e_ring that is meant to hold the i40e_rx_offset() result and use it within i40e_clean_rx_irq(). Furthermore, use it within i40e_alloc_mapped_page(). Last but not least, un-inline the function of interest so that compiler makes the decision about inlining as it lives in .c file. 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 f892a9a commit f7bb0d7

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

drivers/net/ethernet/intel/i40e/i40e_txrx.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,17 @@ void i40e_free_rx_resources(struct i40e_ring *rx_ring)
15691569
}
15701570
}
15711571

1572+
/**
1573+
* i40e_rx_offset - Return expected offset into page to access data
1574+
* @rx_ring: Ring we are requesting offset of
1575+
*
1576+
* Returns the offset value for ring into the data buffer.
1577+
*/
1578+
static unsigned int i40e_rx_offset(struct i40e_ring *rx_ring)
1579+
{
1580+
return ring_uses_build_skb(rx_ring) ? I40E_SKB_PAD : 0;
1581+
}
1582+
15721583
/**
15731584
* i40e_setup_rx_descriptors - Allocate Rx descriptors
15741585
* @rx_ring: Rx descriptor ring (for a specific queue) to setup
@@ -1597,6 +1608,7 @@ int i40e_setup_rx_descriptors(struct i40e_ring *rx_ring)
15971608
rx_ring->next_to_alloc = 0;
15981609
rx_ring->next_to_clean = 0;
15991610
rx_ring->next_to_use = 0;
1611+
rx_ring->rx_offset = i40e_rx_offset(rx_ring);
16001612

16011613
/* XDP RX-queue info only needed for RX rings exposed to XDP */
16021614
if (rx_ring->vsi->type == I40E_VSI_MAIN) {
@@ -1632,17 +1644,6 @@ void i40e_release_rx_desc(struct i40e_ring *rx_ring, u32 val)
16321644
writel(val, rx_ring->tail);
16331645
}
16341646

1635-
/**
1636-
* i40e_rx_offset - Return expected offset into page to access data
1637-
* @rx_ring: Ring we are requesting offset of
1638-
*
1639-
* Returns the offset value for ring into the data buffer.
1640-
*/
1641-
static inline unsigned int i40e_rx_offset(struct i40e_ring *rx_ring)
1642-
{
1643-
return ring_uses_build_skb(rx_ring) ? I40E_SKB_PAD : 0;
1644-
}
1645-
16461647
static unsigned int i40e_rx_frame_truesize(struct i40e_ring *rx_ring,
16471648
unsigned int size)
16481649
{
@@ -1651,8 +1652,8 @@ static unsigned int i40e_rx_frame_truesize(struct i40e_ring *rx_ring,
16511652
#if (PAGE_SIZE < 8192)
16521653
truesize = i40e_rx_pg_size(rx_ring) / 2; /* Must be power-of-2 */
16531654
#else
1654-
truesize = i40e_rx_offset(rx_ring) ?
1655-
SKB_DATA_ALIGN(size + i40e_rx_offset(rx_ring)) +
1655+
truesize = rx_ring->rx_offset ?
1656+
SKB_DATA_ALIGN(size + rx_ring->rx_offset) +
16561657
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) :
16571658
SKB_DATA_ALIGN(size);
16581659
#endif
@@ -1703,7 +1704,7 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring,
17031704

17041705
bi->dma = dma;
17051706
bi->page = page;
1706-
bi->page_offset = i40e_rx_offset(rx_ring);
1707+
bi->page_offset = rx_ring->rx_offset;
17071708
page_ref_add(page, USHRT_MAX - 1);
17081709
bi->pagecnt_bias = USHRT_MAX;
17091710

@@ -2057,7 +2058,7 @@ static void i40e_add_rx_frag(struct i40e_ring *rx_ring,
20572058
#if (PAGE_SIZE < 8192)
20582059
unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
20592060
#else
2060-
unsigned int truesize = SKB_DATA_ALIGN(size + i40e_rx_offset(rx_ring));
2061+
unsigned int truesize = SKB_DATA_ALIGN(size + rx_ring->rx_offset);
20612062
#endif
20622063

20632064
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page,
@@ -2453,8 +2454,9 @@ static void i40e_inc_ntc(struct i40e_ring *rx_ring)
24532454
static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
24542455
{
24552456
unsigned int total_rx_bytes = 0, total_rx_packets = 0, frame_sz = 0;
2456-
struct sk_buff *skb = rx_ring->skb;
24572457
u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
2458+
unsigned int offset = rx_ring->rx_offset;
2459+
struct sk_buff *skb = rx_ring->skb;
24582460
unsigned int xdp_xmit = 0;
24592461
bool failure = false;
24602462
struct xdp_buff xdp;
@@ -2514,7 +2516,6 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
25142516

25152517
/* retrieve a buffer from the ring */
25162518
if (!skb) {
2517-
unsigned int offset = i40e_rx_offset(rx_ring);
25182519
unsigned char *hard_start;
25192520

25202521
hard_start = page_address(rx_buffer->page) +

drivers/net/ethernet/intel/i40e/i40e_txrx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ struct i40e_ring {
387387
*/
388388

389389
struct i40e_channel *ch;
390+
u16 rx_offset;
390391
struct xdp_rxq_info xdp_rxq;
391392
struct xsk_buff_pool *xsk_pool;
392393
struct xdp_desc *xsk_descs; /* For storing descriptors in the AF_XDP ZC path */

0 commit comments

Comments
 (0)