net/mlx4_en: Pad ethernet packets smaller than 17 bytes
authorEugenia Emantayev <eugenia@mellanox.com>
Sun, 2 Mar 2014 08:24:59 +0000 (10:24 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Mar 2014 01:04:00 +0000 (20:04 -0500)
Hardware can't accept packets smaller than 17 bytes. Therefore need to
pad with zeros.

Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/en_tx.c

index 8dc7637f5844b7500b84bd64d3c65029e4623273..781ebca81d0e81390248954c99f2faaf40132347 100644 (file)
@@ -585,7 +585,13 @@ 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);
+               if (likely(skb->len >= MIN_PKT_LEN)) {
+                       inl->byte_count = cpu_to_be32(1 << 31 | skb->len);
+               } else {
+                       inl->byte_count = cpu_to_be32(1 << 31 | MIN_PKT_LEN);
+                       memset(((void *)(inl + 1)) + skb->len, 0,
+                              MIN_PKT_LEN - skb->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,