Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v6 3/9] igc: Introduce igc_rx_buffer_flip() helper
Date: Tue, 2 Mar 2021 10:20:57 +0200	[thread overview]
Message-ID: <7dba7277-1e6b-1093-474b-8002c0e1b1b6@linux.intel.com> (raw)
In-Reply-To: <20210210215848.24514-4-vedang.patel@intel.com>

On 10/02/2021 23:58, Vedang Patel wrote:
> From: Andre Guedes <andre.guedes@intel.com>
> 
> 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: Andre Guedes <andre.guedes@intel.com>
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Vedang Patel <vedang.patel@intel.com>
> ---
>   drivers/net/ethernet/intel/igc/igc_main.c | 43 +++++++++++------------
>   1 file changed, 21 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 261672797346..1157a24f6d26 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -1500,6 +1500,16 @@ static struct igc_rx_buffer *igc_get_rx_buffer(struct igc_ring *rx_ring,
>   	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
>    * @rx_ring: rx descriptor ring to transact packets on
> @@ -1514,20 +1524,19 @@ static void igc_add_rx_frag(struct igc_ring *rx_ring,
>   			    struct sk_buff *skb,
>   			    unsigned int size)
>   {
> -#if (PAGE_SIZE < 8192)
> -	unsigned int truesize = igc_rx_pg_size(rx_ring) / 2;
> +	unsigned int truesize;
>   
> -	skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page,
> -			rx_buffer->page_offset, size, truesize);
> -	rx_buffer->page_offset ^= truesize;
> +#if (PAGE_SIZE < 8192)
> +	truesize = igc_rx_pg_size(rx_ring) / 2;
>   #else
> -	unsigned int truesize = ring_uses_build_skb(rx_ring) ?
> -				SKB_DATA_ALIGN(IGC_SKB_PAD + size) :
> -				SKB_DATA_ALIGN(size);
> +	truesize = ring_uses_build_skb(rx_ring) ?
> +		   SKB_DATA_ALIGN(IGC_SKB_PAD + size) :
> +		   SKB_DATA_ALIGN(size);
> +#endif
>   	skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page,
>   			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,
> @@ -1556,13 +1565,7 @@ static struct sk_buff *igc_build_skb(struct igc_ring *rx_ring,
>   	skb_reserve(skb, IGC_SKB_PAD);
>   	__skb_put(skb, size);
>   
> -	/* update buffer offset */
> -#if (PAGE_SIZE < 8192)
> -	rx_buffer->page_offset ^= truesize;
> -#else
> -	rx_buffer->page_offset += truesize;
> -#endif
> -
> +	igc_rx_buffer_flip(rx_buffer, truesize);
>   	return skb;
>   }
>   
> @@ -1608,11 +1611,7 @@ static struct sk_buff *igc_construct_skb(struct igc_ring *rx_ring,
>   		skb_add_rx_frag(skb, 0, rx_buffer->page,
>   				(va + headlen) - page_address(rx_buffer->page),
>   				size, truesize);
> -#if (PAGE_SIZE < 8192)
> -		rx_buffer->page_offset ^= truesize;
> -#else
> -		rx_buffer->page_offset += truesize;
> -#endif
> +		igc_rx_buffer_flip(rx_buffer, truesize);
>   	} else {
>   		rx_buffer->pagecnt_bias++;
>   	}
> 
Tested-by: Dvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>

  reply	other threads:[~2021-03-02  8:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 21:58 [Intel-wired-lan] [PATCH net-next v6 0/9] igc: Add XDP support Vedang Patel
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 1/9] igc: Fix igc_ptp_rx_pktstamp() Vedang Patel
2021-02-11  0:30   ` Nguyen, Anthony L
2021-02-12 19:16     ` Joseph, Jithu
2021-03-02  8:20   ` Dvora Fuxbrumer
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 2/9] igc: Remove unused argument from igc_tx_cmd_type() Vedang Patel
2021-03-02  8:20   ` Dvora Fuxbrumer
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 3/9] igc: Introduce igc_rx_buffer_flip() helper Vedang Patel
2021-03-02  8:20   ` Dvora Fuxbrumer [this message]
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 4/9] igc: Introduce igc_get_rx_frame_truesize() helper Vedang Patel
2021-03-02  8:21   ` Dvora Fuxbrumer
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 5/9] igc: Refactor Rx timestamp handling Vedang Patel
2021-03-02  8:21   ` Dvora Fuxbrumer
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 6/9] igc: Add set/clear large buffer helpers Vedang Patel
2021-03-02  8:21   ` Dvora Fuxbrumer
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 7/9] igc: Add initial XDP support Vedang Patel
2021-03-02  8:22   ` Dvora Fuxbrumer
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 8/9] igc: Add support for XDP_TX action Vedang Patel
2021-03-02  8:22   ` Dvora Fuxbrumer
2021-02-10 21:58 ` [Intel-wired-lan] [PATCH net-next v6 9/9] igc: Add support for XDP_REDIRECT action Vedang Patel
2021-03-02  8:22   ` Dvora Fuxbrumer
2021-03-02  8:19 ` [Intel-wired-lan] [PATCH net-next v6 0/9] igc: Add XDP support Dvora Fuxbrumer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7dba7277-1e6b-1093-474b-8002c0e1b1b6@linux.intel.com \
    --to=dvorax.fuxbrumer@linux.intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox