netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] mlx4_en: dont change mac_header on xmit
@ 2012-02-25 10:51 Eric Dumazet
  2012-03-04 11:19 ` Or Gerlitz
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Dumazet @ 2012-02-25 10:51 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Yevgeny Petrilin

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(-)

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next] mlx4_en: dont change mac_header on xmit
  2012-02-25 10:51 [PATCH net-next] mlx4_en: dont change mac_header on xmit Eric Dumazet
@ 2012-03-04 11:19 ` Or Gerlitz
  2012-03-04 15:56   ` Eric Dumazet
  0 siblings, 1 reply; 8+ messages in thread
From: Or Gerlitz @ 2012-03-04 11:19 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Yevgeny Petrilin

> +       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>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next] mlx4_en: dont change mac_header on xmit
  2012-03-04 11:19 ` Or Gerlitz
@ 2012-03-04 15:56   ` Eric Dumazet
  2012-03-04 20:02     ` Or Gerlitz
  2012-03-05 15:01     ` [PATCH net-next] mlx4_en: remove sparse errors Eric Dumazet
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Dumazet @ 2012-03-04 15:56 UTC (permalink / raw)
  To: Or Gerlitz; +Cc: David Miller, netdev, Yevgeny Petrilin

Le dimanche 04 mars 2012 à 13:19 +0200, Or Gerlitz a écrit :
> > +       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>

Oh yes, I forgot about sparse, sorry.
By the way you have existing problems about ctrl_flags

drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1013:34: warning: invalid assignment: |=
drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1013:34:    left side has type unsigned int
drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1013:34:    right side has type restricted __be32
drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1015:34: warning: invalid assignment: &=
drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1015:34:    left side has type unsigned int
drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1015:34:    right side has type restricted __be32
drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1069:26: warning: incorrect type in assignment (different base types)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1069:26:    expected unsigned int [unsigned] [usertype] ctrl_flags
drivers/net/ethernet/mellanox/mlx4/en_netdev.c:1069:26:    got restricted __be32 [usertype] <noident>


Probably something like this is needed, but you also need to take a look
at the ctrl_flags problem.

I have to run, will submit official patch at the end of the (sunny)day,
if you dont beat me ;)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 2fd5140..50b3fa5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -686,8 +686,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	/* Copy dst mac address to wqe */
 	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));
+	tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest);
+	tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2));
 	/* Handle LSO (TSO) packets */
 	if (lso_header_size) {
 		/* Mark opcode as LSO */

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next] mlx4_en: dont change mac_header on xmit
  2012-03-04 15:56   ` Eric Dumazet
@ 2012-03-04 20:02     ` Or Gerlitz
  2012-03-05 15:01     ` [PATCH net-next] mlx4_en: remove sparse errors Eric Dumazet
  1 sibling, 0 replies; 8+ messages in thread
From: Or Gerlitz @ 2012-03-04 20:02 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Yevgeny Petrilin

On Sun, Mar 4, 2012 at 5:56 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:

> By the way you have existing problems about ctrl_flags

Yep, we will submit patch to fix that tomorrow or so


> I have to run, will submit official patch at the end of the (sunny)day, if you dont beat me

thanks

Or.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next] mlx4_en: remove sparse errors
  2012-03-04 15:56   ` Eric Dumazet
  2012-03-04 20:02     ` Or Gerlitz
@ 2012-03-05 15:01     ` Eric Dumazet
  2012-03-05 21:43       ` David Miller
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Dumazet @ 2012-03-05 15:01 UTC (permalink / raw)
  To: Or Gerlitz; +Cc: David Miller, netdev, Yevgeny Petrilin

Fix new sparse errors introduced in commit 6221217199 (mlx4_en: dont
change mac_header on xmit)

Reported-by: Or Gerlitz <or.gerlitz@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
---
 drivers/net/ethernet/mellanox/mlx4/en_tx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 2fd5140..50b3fa5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -686,8 +686,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	/* Copy dst mac address to wqe */
 	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));
+	tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest);
+	tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2));
 	/* Handle LSO (TSO) packets */
 	if (lso_header_size) {
 		/* Mark opcode as LSO */

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next] mlx4_en: remove sparse errors
  2012-03-05 15:01     ` [PATCH net-next] mlx4_en: remove sparse errors Eric Dumazet
@ 2012-03-05 21:43       ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2012-03-05 21:43 UTC (permalink / raw)
  To: eric.dumazet; +Cc: or.gerlitz, netdev, yevgenyp

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 05 Mar 2012 07:01:14 -0800

> Fix new sparse errors introduced in commit 6221217199 (mlx4_en: dont
> change mac_header on xmit)
> 
> Reported-by: Or Gerlitz <or.gerlitz@gmail.com>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: Yevgeny Petrilin <yevgenyp@mellanox.co.il>

Applied, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next] mlx4_en: dont change mac_header on xmit
  2012-02-26 19:12 ` [PATCH net-next] mlx4_en: dont change mac_header on xmit Eugenia Emantayev
@ 2012-02-26 19:27   ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2012-02-26 19:27 UTC (permalink / raw)
  To: eugenia; +Cc: eric.dumazet, netdev, yevgenyp

From: Eugenia Emantayev <eugenia@mellanox.com>
Date: Sun, 26 Feb 2012 19:12:12 +0000

> From: Eric Dumazet [mailto:eric.dumazet@gmail.com]
> Sent: Saturday, February 25, 2012 12:51 PM
> 
>> 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 !
> 
> Tested and approved, thanks.
> --

Applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH net-next] mlx4_en: dont change mac_header on xmit
       [not found] <953B660C027164448AE903364AC447D2618B88E7@MTLDAG02.mtl.com>
@ 2012-02-26 19:12 ` Eugenia Emantayev
  2012-02-26 19:27   ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Eugenia Emantayev @ 2012-02-26 19:12 UTC (permalink / raw)
  To: davem, eric.dumazet; +Cc: netdev, Yevgeny Petrilin, Eugenia Emantayev

From: Eric Dumazet [mailto:eric.dumazet@gmail.com]
Sent: Saturday, February 25, 2012 12:51 PM

> 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 !

Tested and approved, thanks.
--
Eugenia Emantayev

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-03-05 21:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-25 10:51 [PATCH net-next] mlx4_en: dont change mac_header on xmit Eric Dumazet
2012-03-04 11:19 ` Or Gerlitz
2012-03-04 15:56   ` Eric Dumazet
2012-03-04 20:02     ` Or Gerlitz
2012-03-05 15:01     ` [PATCH net-next] mlx4_en: remove sparse errors Eric Dumazet
2012-03-05 21:43       ` David Miller
     [not found] <953B660C027164448AE903364AC447D2618B88E7@MTLDAG02.mtl.com>
2012-02-26 19:12 ` [PATCH net-next] mlx4_en: dont change mac_header on xmit Eugenia Emantayev
2012-02-26 19:27   ` David Miller

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).