netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.h.duyck@intel.com>
To: Amir Vadai <amirv@mellanox.com>, "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>,
	netdev@vger.kernel.org, Or Gerlitz <ogerlitz@mellanox.com>,
	Yevgeny Petrilin <yevgenyp@mellanox.com>,
	Ido Shamay <idos@mellanox.com>,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH net-next V1 1/2] net: Header length compution function
Date: Mon, 28 Jul 2014 07:50:44 -0700	[thread overview]
Message-ID: <53D66344.2050207@intel.com> (raw)
In-Reply-To: <1406546881-21863-2-git-send-email-amirv@mellanox.com>

On 07/28/2014 04:28 AM, Amir Vadai wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> 
> This commit is based on Eric Dumazet suggestion.
> Use flow dissector to calculate header length.
> Tested the following with a mlx4, and it indeed speeds up GRE traffic,
> as GRO packets can now contain 17 MSS instead of 8.
> (Pulling payload means GRO had to use 2 'frags' per MSS)
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Amir Vadai <amirv@mellanox.com>
> ---
>  include/linux/skbuff.h    |  1 +
>  net/core/flow_dissector.c | 24 ++++++++++++++++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index b613557..1f9af4d 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -3133,6 +3133,7 @@ bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
>  int skb_checksum_setup(struct sk_buff *skb, bool recalculate);
>  
>  u32 __skb_get_poff(const struct sk_buff *skb);
> +u32 eth_frame_headlen(void *data, unsigned int len);
>  
>  /**
>   * skb_head_is_locked - Determine if the skb->head is locked down
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index 5f362c1..c3afd27 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c
> @@ -343,6 +343,30 @@ u32 __skb_get_poff(const struct sk_buff *skb)
>  	return poff;
>  }
>  
> +
> +/* Helper to find length of headers in an ethernet frame.
> + * This can help drivers to pull exact amount of bytes into
> + * skb->head to get optimal GRO performance.
> + * TODO: Could also return rxhash while we do a complete flow dissection.
> + */
> +u32 eth_frame_headlen(void *data, unsigned int len)
> +{
> +	const struct ethhdr *eth = data;
> +	struct sk_buff skb;
> +
> +	if (unlikely(len < ETH_HLEN))
> +		return len;
> +
> +	skb.protocol = eth->h_proto;
> +	skb.head = data + ETH_HLEN;
> +	skb.data = skb.head;
> +	skb_reset_network_header(&skb);
> +	skb.len = len - ETH_HLEN;
> +	skb.data_len = 0;
> +	return __skb_get_poff(&skb) + ETH_HLEN;
> +}

I'm still not a big fan of allocating an sk_buff on the stack.  Seems
like it isn't maintainable and really opens things up to possible issues
if someone ever extends the __skb_get_poff call.  But I'm not going to
force the issue since for now this isn't impacting igb or ixgbe.

Thanks,

Alex

  reply	other threads:[~2014-07-28 14:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 11:27 [PATCH net-next V1 0/2] Helper to find length of headers in an ethernet frame Amir Vadai
2014-07-28 11:28 ` [PATCH net-next V1 1/2] net: Header length compution function Amir Vadai
2014-07-28 14:50   ` Alexander Duyck [this message]
2014-07-28 21:26     ` Cong Wang
2014-07-28 22:42       ` David Miller
2014-07-28 23:08         ` Alexander Duyck
2014-07-28 11:28 ` [PATCH net-next V1 2/2] net/mlx4_en: Copy exact header to SKB linear part Amir Vadai

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=53D66344.2050207@intel.com \
    --to=alexander.h.duyck@intel.com \
    --cc=amirv@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=idos@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=yevgenyp@mellanox.com \
    /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;
as well as URLs for NNTP newsgroup(s).