diff mbox

[net-next] mlx4_en: dont change mac_header on xmit

Message ID 1330167065.2462.53.camel@edumazet-laptop
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Feb. 25, 2012, 10:51 a.m. UTC
A driver xmit function is not allowed to change skb without special
care.

mlx4_en_xmit() should not call skb_reset_mac_header() and instead should
use skb->data to access ethernet header.

This removes a dumb test : if (ethh && ethh->h_dest)

Also remove this slow mlx4_en_mac_to_u64() call, we can use
get_unaligned() to get faster code.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
---
Please test this patch before we can commit it, thanks !

 drivers/net/ethernet/mellanox/mlx4/en_tx.c |   15 +++------------
 include/linux/mlx4/qp.h                    |    5 ++++-
 2 files changed, 7 insertions(+), 13 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Or Gerlitz March 4, 2012, 11:19 a.m. UTC | #1
> +       ethh = (struct ethhdr *)skb->data;
> +       tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((u16 *)ethh->h_dest);
> +       tx_desc->ctrl.imm = get_unaligned((u32 *)(ethh->h_dest + 2));

Hi Eric,

commit 622121719934f60378279eb440d3cec2fc3176d2 of your triggers the
below sparse
warnings, could you advise what would be the correct way to fix that out?

Or.

 CHECK   drivers/net/ethernet/mellanox/mlx4/en_tx.c
drivers/net/ethernet/mellanox/mlx4/en_tx.c:689:40: warning: incorrect
type in assignment (different base types)
drivers/net/ethernet/mellanox/mlx4/en_tx.c:689:40:    expected
restricted __be16 <noident>
drivers/net/ethernet/mellanox/mlx4/en_tx.c:689:40:    got unsigned
short [unsigned] <noident>
drivers/net/ethernet/mellanox/mlx4/en_tx.c:690:27: warning: incorrect
type in assignment (different base types)
drivers/net/ethernet/mellanox/mlx4/en_tx.c:690:27:    expected
restricted __be32 [usertype] imm
drivers/net/ethernet/mellanox/mlx4/en_tx.c:690:27:    got unsigned int
[unsigned] <noident>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index ff32505..2fd5140 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -601,8 +601,6 @@  netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 	struct skb_frag_struct *frag;
 	struct mlx4_en_tx_info *tx_info;
 	struct ethhdr *ethh;
-	u64 mac;
-	u32 mac_l, mac_h;
 	int tx_ind = 0;
 	int nr_txbb;
 	int desc_size;
@@ -687,16 +685,9 @@  netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	/* Copy dst mac address to wqe */
-	skb_reset_mac_header(skb);
-	ethh = eth_hdr(skb);
-	if (ethh && ethh->h_dest) {
-		mac = mlx4_en_mac_to_u64(ethh->h_dest);
-		mac_h = (u32) ((mac & 0xffff00000000ULL) >> 16);
-		mac_l = (u32) (mac & 0xffffffff);
-		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(mac_h);
-		tx_desc->ctrl.imm = cpu_to_be32(mac_l);
-	}
-
+	ethh = (struct ethhdr *)skb->data;
+	tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((u16 *)ethh->h_dest);
+	tx_desc->ctrl.imm = get_unaligned((u32 *)(ethh->h_dest + 2));
 	/* Handle LSO (TSO) packets */
 	if (lso_header_size) {
 		/* Mark opcode as LSO */
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index bee8fa2..091f9e7 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -212,7 +212,10 @@  struct mlx4_wqe_ctrl_seg {
 	 * [1]   SE (solicited event)
 	 * [0]   FL (force loopback)
 	 */
-	__be32			srcrb_flags;
+	union {
+		__be32			srcrb_flags;
+		__be16			srcrb_flags16[2];
+	};
 	/*
 	 * imm is immediate data for send/RDMA write w/ immediate;
 	 * also invalidation key for send with invalidate; input