All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Vadai <amirv@mellanox.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: "David S. Miller" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Yevgeny Petrilin <yevgenyp@mellanox.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Eugenia Emantayev <eugenia@mellanox.com>
Subject: Re: net/mlx4_en: Pad ethernet packets smaller than 17 bytes
Date: Thu, 27 Feb 2014 16:02:05 +0200	[thread overview]
Message-ID: <20140227140203.GA13112@mtl-eit-vdi-22.mtl.labs.mlnx> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D0F6CCB7E@AcuExch.aculab.com>

On 27/02/14 13:08 +0000, David Laight wrote:
> From: Amir Vadai
> > Hardware can't accept packets smaller than 17 bytes. Therefore need to pad with
> > zeros.
> 
> Can they actually happen?
> A 16 byte packet would only have 2 bytes following the ethertype/length.
> The shortest LLC packets have 3 bytes.
Raw sockets might send such packets and it will put the HW into
unstable state.

> It may well be safe to discard them.
Yep - that another option.

> 
> ...
> > 
> > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > index 8dc7637..268cc4a 100644
> > --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > @@ -585,12 +585,19 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *sk
> >  	int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl;
> > 
> >  	if (skb->len <= spc) {
> > -		inl->byte_count = cpu_to_be32(1 << 31 | skb->len);
> > +		inl->byte_count = cpu_to_be32(1 << 31 |
> > +					      max_t(typeof(skb->len),
> > +						    skb->len,
> > +						    MIN_PKT_LEN));
> >  		skb_copy_from_linear_data(skb, inl + 1, skb_headlen(skb));
> >  		if (skb_shinfo(skb)->nr_frags)
> >  			memcpy(((void *)(inl + 1)) + skb_headlen(skb), fragptr,
> >  			       skb_frag_size(&skb_shinfo(skb)->frags[0]));
> 
> Is there guaranteed to be only 1 fragment here?
> 
Yes, skb will not be classified as inline-able if nr_frags != 1.
See is_inline()

> > +		if (skb->len < MIN_PKT_LEN)
> > +			memset(((void *)(inl + 1)) + skb->len, 0,
> > +			       MIN_PKT_LEN - skb->len);
> > +
> 
> In any case you don't want 2 checks for skb->len < MIN_PKT_LEN,
> so reassign to inl->byte_count here.
> An unlikely() probably wouldn't go amiss either.
Right - will fix it for V1

> 
> 	David
> 

Thanks,
Amir

  reply	other threads:[~2014-02-27 14:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27 12:26 [PATCH net-next 0/9] net/mlx4: Mellanox driver update 27-02-2014 Amir Vadai
2014-02-27 12:26 ` [PATCH net-next 1/9] net/mlx4_en: Fix UP limit in ieee_ets->prio_tc Amir Vadai
2014-02-27 12:26 ` [PATCH net-next 2/9] net/mlx4_en: Verify mlx4_en module parameters Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 3/9] net/mlx4_en: Pad ethernet packets smaller than 17 bytes Amir Vadai
2014-02-27 13:08   ` David Laight
2014-02-27 14:02     ` Amir Vadai [this message]
2014-02-27 14:44       ` Eric Dumazet
2014-02-27 15:46         ` Amir Vadai
2014-02-27 20:36           ` David Miller
2014-02-27 21:47             ` Amir Vadai
2014-02-27 21:58               ` David Miller
2014-02-27 12:27 ` [PATCH net-next 4/9] net/mlx4_en: Move queue stopped/waked counters to be per ring Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 5/9] net/mlx4: Replace mlx4_en_mac_to_u64() with mlx4_mac_to_u64() Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 6/9] net/mlx4_en: Fix selftest failing on non 10G link speed Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 7/9] net/mlx4_core: Fix sparse warning Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 8/9] net/mlx4_en: Use union for BlueFlame WQE Amir Vadai
2014-02-27 12:27 ` [PATCH net-next 9/9] net/mlx4_en: Change Connect-X description in kconfig 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=20140227140203.GA13112@mtl-eit-vdi-22.mtl.labs.mlnx \
    --to=amirv@mellanox.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=davem@davemloft.net \
    --cc=eugenia@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.