Skip to content

Commit f1b1f40

Browse files
mfijalkoanguy11
authored andcommitted
ice: store the result of ice_rx_offset() onto ice_ring
Output of ice_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 ice_ring that is meant to hold the ice_rx_offset() result and use it within ice_clean_rx_irq(). Furthermore, use it within ice_alloc_mapped_page(). 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 f7bb0d7 commit f1b1f40

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

drivers/net/ethernet/intel/ice/ice_txrx.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,22 @@ void ice_free_rx_ring(struct ice_ring *rx_ring)
443443
}
444444
}
445445

446+
/**
447+
* ice_rx_offset - Return expected offset into page to access data
448+
* @rx_ring: Ring we are requesting offset of
449+
*
450+
* Returns the offset value for ring into the data buffer.
451+
*/
452+
static unsigned int ice_rx_offset(struct ice_ring *rx_ring)
453+
{
454+
if (ice_ring_uses_build_skb(rx_ring))
455+
return ICE_SKB_PAD;
456+
else if (ice_is_xdp_ena_vsi(rx_ring->vsi))
457+
return XDP_PACKET_HEADROOM;
458+
459+
return 0;
460+
}
461+
446462
/**
447463
* ice_setup_rx_ring - Allocate the Rx descriptors
448464
* @rx_ring: the Rx ring to set up
@@ -477,6 +493,7 @@ int ice_setup_rx_ring(struct ice_ring *rx_ring)
477493

478494
rx_ring->next_to_use = 0;
479495
rx_ring->next_to_clean = 0;
496+
rx_ring->rx_offset = ice_rx_offset(rx_ring);
480497

481498
if (ice_is_xdp_ena_vsi(rx_ring->vsi))
482499
WRITE_ONCE(rx_ring->xdp_prog, rx_ring->vsi->xdp_prog);
@@ -494,22 +511,6 @@ int ice_setup_rx_ring(struct ice_ring *rx_ring)
494511
return -ENOMEM;
495512
}
496513

497-
/**
498-
* ice_rx_offset - Return expected offset into page to access data
499-
* @rx_ring: Ring we are requesting offset of
500-
*
501-
* Returns the offset value for ring into the data buffer.
502-
*/
503-
static unsigned int ice_rx_offset(struct ice_ring *rx_ring)
504-
{
505-
if (ice_ring_uses_build_skb(rx_ring))
506-
return ICE_SKB_PAD;
507-
else if (ice_is_xdp_ena_vsi(rx_ring->vsi))
508-
return XDP_PACKET_HEADROOM;
509-
510-
return 0;
511-
}
512-
513514
static unsigned int
514515
ice_rx_frame_truesize(struct ice_ring *rx_ring, unsigned int __maybe_unused size)
515516
{
@@ -518,8 +519,8 @@ ice_rx_frame_truesize(struct ice_ring *rx_ring, unsigned int __maybe_unused size
518519
#if (PAGE_SIZE < 8192)
519520
truesize = ice_rx_pg_size(rx_ring) / 2; /* Must be power-of-2 */
520521
#else
521-
truesize = ice_rx_offset(rx_ring) ?
522-
SKB_DATA_ALIGN(ice_rx_offset(rx_ring) + size) +
522+
truesize = rx_ring->rx_offset ?
523+
SKB_DATA_ALIGN(rx_ring->rx_offset + size) +
523524
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) :
524525
SKB_DATA_ALIGN(size);
525526
#endif
@@ -652,7 +653,7 @@ ice_alloc_mapped_page(struct ice_ring *rx_ring, struct ice_rx_buf *bi)
652653

653654
bi->dma = dma;
654655
bi->page = page;
655-
bi->page_offset = ice_rx_offset(rx_ring);
656+
bi->page_offset = rx_ring->rx_offset;
656657
page_ref_add(page, USHRT_MAX - 1);
657658
bi->pagecnt_bias = USHRT_MAX;
658659

@@ -805,7 +806,7 @@ ice_add_rx_frag(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf,
805806
struct sk_buff *skb, unsigned int size)
806807
{
807808
#if (PAGE_SIZE >= 8192)
808-
unsigned int truesize = SKB_DATA_ALIGN(size + ice_rx_offset(rx_ring));
809+
unsigned int truesize = SKB_DATA_ALIGN(size + rx_ring->rx_offset);
809810
#else
810811
unsigned int truesize = ice_rx_pg_size(rx_ring) / 2;
811812
#endif
@@ -1071,6 +1072,7 @@ int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget)
10711072
{
10721073
unsigned int total_rx_bytes = 0, total_rx_pkts = 0, frame_sz = 0;
10731074
u16 cleaned_count = ICE_DESC_UNUSED(rx_ring);
1075+
unsigned int offset = rx_ring->rx_offset;
10741076
unsigned int xdp_res, xdp_xmit = 0;
10751077
struct sk_buff *skb = rx_ring->skb;
10761078
struct bpf_prog *xdp_prog = NULL;
@@ -1085,7 +1087,6 @@ int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget)
10851087

10861088
/* start the loop to process Rx packets bounded by 'budget' */
10871089
while (likely(total_rx_pkts < (unsigned int)budget)) {
1088-
unsigned int offset = ice_rx_offset(rx_ring);
10891090
union ice_32b_rx_flex_desc *rx_desc;
10901091
struct ice_rx_buf *rx_buf;
10911092
unsigned char *hard_start;

drivers/net/ethernet/intel/ice/ice_txrx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ struct ice_ring {
294294
struct rcu_head rcu; /* to avoid race on free */
295295
struct bpf_prog *xdp_prog;
296296
struct xsk_buff_pool *xsk_pool;
297+
u16 rx_offset;
297298
/* CL3 - 3rd cacheline starts here */
298299
struct xdp_rxq_info xdp_rxq;
299300
struct sk_buff *skb;

0 commit comments

Comments
 (0)