net/mlx4_en: Use union for BlueFlame WQE
authorAmir Vadai <amirv@mellanox.com>
Sun, 2 Mar 2014 08:25:04 +0000 (10:25 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Mar 2014 01:04:01 +0000 (20:04 -0500)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/en_tx.c
include/linux/mlx4/qp.h

index 56e8fbc128f864daafc462aec17069cf3d9f7e55..69c2fcef9d4cb79209a97b27f81e3fad27a776fd 100644 (file)
@@ -876,7 +876,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 */
index 59f8ba84568bef4a4e17ed21240c163d6953a912..b66e7610d4eec9f4d67e5f8bbd745bb6cbd3c99a 100644 (file)
@@ -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)