All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Vadai <amirv@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Yevgeny Petrilin <yevgenyp@mellanox.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Amir Vadai <amirv@mellanox.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH net-next 8/9] net/mlx4_en: Use union for BlueFlame WQE
Date: Thu, 27 Feb 2014 14:27:05 +0200	[thread overview]
Message-ID: <1393504026-13384-9-git-send-email-amirv@mellanox.com> (raw)
In-Reply-To: <1393504026-13384-1-git-send-email-amirv@mellanox.com>

When BlueFlame is turned on, control segment of the TX WQE is changed,
and the second line of it is used for QPN.
Changed code to use a union in the mlx4_wqe_ctrl_seg instead of casting.
This makes the code clearer and solves the static checker warning:

drivers/net/ethernet/mellanox/mlx4/en_tx.c:839 mlx4_en_xmit()
	warn: potential memory corrupting cast 4 vs 2 bytes

CC: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_tx.c |  3 ++-
 include/linux/mlx4/qp.h                    | 11 ++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 9730373..fda88a8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -877,7 +877,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 	skb_tx_timestamp(skb);
 
 	if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && !vlan_tx_tag_present(skb)) {
-		*(__be32 *) (&tx_desc->ctrl.vlan_tag) |= cpu_to_be32(ring->doorbell_qpn);
+		tx_desc->ctrl.bf_qpn |= cpu_to_be32(ring->doorbell_qpn);
+
 		op_own |= htonl((bf_index & 0xffff) << 8);
 		/* Ensure new descirptor hits memory
 		* before setting ownership of this descriptor to HW */
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index 59f8ba8..b66e761 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -270,9 +270,14 @@ enum {
 
 struct mlx4_wqe_ctrl_seg {
 	__be32			owner_opcode;
-	__be16			vlan_tag;
-	u8			ins_vlan;
-	u8			fence_size;
+	union {
+		struct {
+			__be16			vlan_tag;
+			u8			ins_vlan;
+			u8			fence_size;
+		};
+		__be32			bf_qpn;
+	};
 	/*
 	 * High 24 bits are SRC remote buffer; low 8 bits are flags:
 	 * [7]   SO (strong ordering)
-- 
1.8.3.4

  parent reply	other threads:[~2014-02-27 12:27 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
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 ` Amir Vadai [this message]
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=1393504026-13384-9-git-send-email-amirv@mellanox.com \
    --to=amirv@mellanox.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --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.