Commit 613cf199 authored by Andre Guedes's avatar Andre Guedes Committed by Tony Nguyen

igc: Introduce igc_rx_buffer_flip() helper

The igc driver implements the same page recycling scheme from other
Intel drivers which reuses the page by flipping the buffer. The code
to handle buffer flips is duplicated in many locations so introduce
the igc_rx_buffer_flip() helper and use it where applicable.
Signed-off-by: default avatarAndre Guedes <andre.guedes@intel.com>
Signed-off-by: default avatarVedang Patel <vedang.patel@intel.com>
Signed-off-by: default avatarJithu Joseph <jithu.joseph@intel.com>
Reviewed-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: default avatarDvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 2f019ebd
...@@ -1499,6 +1499,16 @@ static struct igc_rx_buffer *igc_get_rx_buffer(struct igc_ring *rx_ring, ...@@ -1499,6 +1499,16 @@ static struct igc_rx_buffer *igc_get_rx_buffer(struct igc_ring *rx_ring,
return rx_buffer; return rx_buffer;
} }
static void igc_rx_buffer_flip(struct igc_rx_buffer *buffer,
unsigned int truesize)
{
#if (PAGE_SIZE < 8192)
buffer->page_offset ^= truesize;
#else
buffer->page_offset += truesize;
#endif
}
/** /**
* igc_add_rx_frag - Add contents of Rx buffer to sk_buff * igc_add_rx_frag - Add contents of Rx buffer to sk_buff
* @rx_ring: rx descriptor ring to transact packets on * @rx_ring: rx descriptor ring to transact packets on
...@@ -1513,20 +1523,19 @@ static void igc_add_rx_frag(struct igc_ring *rx_ring, ...@@ -1513,20 +1523,19 @@ static void igc_add_rx_frag(struct igc_ring *rx_ring,
struct sk_buff *skb, struct sk_buff *skb,
unsigned int size) unsigned int size)
{ {
#if (PAGE_SIZE < 8192) unsigned int truesize;
unsigned int truesize = igc_rx_pg_size(rx_ring) / 2;
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page, #if (PAGE_SIZE < 8192)
rx_buffer->page_offset, size, truesize); truesize = igc_rx_pg_size(rx_ring) / 2;
rx_buffer->page_offset ^= truesize;
#else #else
unsigned int truesize = ring_uses_build_skb(rx_ring) ? truesize = ring_uses_build_skb(rx_ring) ?
SKB_DATA_ALIGN(IGC_SKB_PAD + size) : SKB_DATA_ALIGN(IGC_SKB_PAD + size) :
SKB_DATA_ALIGN(size); SKB_DATA_ALIGN(size);
#endif
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page, skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page,
rx_buffer->page_offset, size, truesize); rx_buffer->page_offset, size, truesize);
rx_buffer->page_offset += truesize;
#endif igc_rx_buffer_flip(rx_buffer, truesize);
} }
static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring, static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring,
...@@ -1555,13 +1564,7 @@ static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring, ...@@ -1555,13 +1564,7 @@ static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring,
skb_reserve(skb, IGC_SKB_PAD); skb_reserve(skb, IGC_SKB_PAD);
__skb_put(skb, size); __skb_put(skb, size);
/* update buffer offset */ igc_rx_buffer_flip(rx_buffer, truesize);
#if (PAGE_SIZE < 8192)
rx_buffer->page_offset ^= truesize;
#else
rx_buffer->page_offset += truesize;
#endif
return skb; return skb;
} }
...@@ -1607,11 +1610,7 @@ static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring, ...@@ -1607,11 +1610,7 @@ static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring,
skb_add_rx_frag(skb, 0, rx_buffer->page, skb_add_rx_frag(skb, 0, rx_buffer->page,
(va + headlen) - page_address(rx_buffer->page), (va + headlen) - page_address(rx_buffer->page),
size, truesize); size, truesize);
#if (PAGE_SIZE < 8192) igc_rx_buffer_flip(rx_buffer, truesize);
rx_buffer->page_offset ^= truesize;
#else
rx_buffer->page_offset += truesize;
#endif
} else { } else {
rx_buffer->pagecnt_bias++; rx_buffer->pagecnt_bias++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment