igc: Introduce igc_get_rx_frame_truesize() helper
The RX frame truesize calculation is scattered throughout the RX code. This patch creates the helper function igc_get_rx_frame_truesize() and uses it where applicable. Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Vedang Patel <vedang.patel@intel.com> Signed-off-by: Jithu Joseph <jithu.joseph@intel.com> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Tested-by: Dvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
This commit is contained in:
parent
613cf199fd
commit
a39f5e5305
|
@ -1509,6 +1509,22 @@ static void igc_rx_buffer_flip(struct igc_rx_buffer *buffer,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int igc_get_rx_frame_truesize(struct igc_ring *ring,
|
||||||
|
unsigned int size)
|
||||||
|
{
|
||||||
|
unsigned int truesize;
|
||||||
|
|
||||||
|
#if (PAGE_SIZE < 8192)
|
||||||
|
truesize = igc_rx_pg_size(ring) / 2;
|
||||||
|
#else
|
||||||
|
truesize = ring_uses_build_skb(ring) ?
|
||||||
|
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
|
||||||
|
SKB_DATA_ALIGN(IGC_SKB_PAD + size) :
|
||||||
|
SKB_DATA_ALIGN(size);
|
||||||
|
#endif
|
||||||
|
return truesize;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
@ -1544,12 +1560,7 @@ static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
|
void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
|
||||||
#if (PAGE_SIZE < 8192)
|
unsigned int truesize = igc_get_rx_frame_truesize(rx_ring, size);
|
||||||
unsigned int truesize = igc_rx_pg_size(rx_ring) / 2;
|
|
||||||
#else
|
|
||||||
unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
|
|
||||||
SKB_DATA_ALIGN(IGC_SKB_PAD + size);
|
|
||||||
#endif
|
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
|
||||||
/* prefetch first cache line of first page */
|
/* prefetch first cache line of first page */
|
||||||
|
@ -1574,11 +1585,7 @@ static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
|
void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
|
||||||
#if (PAGE_SIZE < 8192)
|
unsigned int truesize = igc_get_rx_frame_truesize(rx_ring, size);
|
||||||
unsigned int truesize = igc_rx_pg_size(rx_ring) / 2;
|
|
||||||
#else
|
|
||||||
unsigned int truesize = SKB_DATA_ALIGN(size);
|
|
||||||
#endif
|
|
||||||
unsigned int headlen;
|
unsigned int headlen;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue