]> git.openfabrics.org - ~shefty/libmlx4.git/commitdiff
Fix IBoE SL -> 802.1Q priority-bits mapping
authorOr Gerlitz <ogerlitz@mellanox.com>
Sun, 11 Dec 2011 14:45:40 +0000 (16:45 +0200)
committerRoland Dreier <roland@purestorage.com>
Fri, 23 Mar 2012 21:44:34 +0000 (14:44 -0700)
For IBoE, SLs 0-7 are mapped to Ethernet 802.1Q user priority bits
(pbits) which are part of the VLAN tag.  SLs 8-15 are reserved.

Under Ethernet, the ConnectX firmware decodes/encodes the four-bit SL
field in various constructs such as QPC / UD WQE / CQE as PPP0 and not
as 0PPP.  This matches the fact that within the VLAN tag the pbits are
located in bits 15-13 and not 12-14.

The current code was buggy around this:

 - The encoding into the address handle was wrong which resulted in
   wrong priority-bits for datagram WQEs.
 - Decoding from the CQE was wrong, which resulted in wrong input into
   an AH built up from a completion, eg consumers of ibv_init_ah_from_wc().

This is fixed by using PPP0 where appropriate.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
src/cq.c
src/verbs.c

index 873c1a263cb9e349c1f9418bdf499a6686f8f2b1..8f7a8cce094b70b51b3d912b5489f7a8611f0560 100644 (file)
--- a/src/cq.c
+++ b/src/cq.c
@@ -317,12 +317,15 @@ static int mlx4_poll_one(struct mlx4_cq *cq,
                }
 
                wc->slid           = ntohs(cqe->rlid);
-               wc->sl             = ntohs(cqe->sl_vid) >> 12;
                g_mlpath_rqpn      = ntohl(cqe->g_mlpath_rqpn);
                wc->src_qp         = g_mlpath_rqpn & 0xffffff;
                wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f;
                wc->wc_flags      |= g_mlpath_rqpn & 0x80000000 ? IBV_WC_GRH : 0;
                wc->pkey_index     = ntohl(cqe->immed_rss_invalid) & 0x7f;
+               if ((*cur_qp)->link_layer == IBV_LINK_LAYER_ETHERNET)
+                       wc->sl     = ntohs(cqe->sl_vid) >> 13;
+               else
+                       wc->sl     = ntohs(cqe->sl_vid) >> 12;
        }
 
        return CQ_OK;
index f5f870d6dd879dee84cb6e3d3f96b320a6ffa4e1..18ec4f1dfa511b2f5b784c7a0402e3783a9bccc9 100644 (file)
@@ -677,13 +677,14 @@ struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
        if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
                ah->av.g_slid = attr->src_path_bits;
                ah->av.dlid   = htons(attr->dlid);
-       }
+               ah->av.sl_tclass_flowlabel = htonl(attr->sl << 28);
+       } else
+               ah->av.sl_tclass_flowlabel = htonl(attr->sl << 29);
 
        if (attr->static_rate) {
                ah->av.stat_rate = attr->static_rate + MLX4_STAT_RATE_OFFSET;
                /* XXX check rate cap? */
        }
-       ah->av.sl_tclass_flowlabel = htonl(attr->sl << 28);
        if (attr->is_global) {
                ah->av.g_slid   |= 0x80;
                ah->av.gid_index = attr->grh.sgid_index;