RDMA/hns: Do shift on traffic class when using RoCEv2
authorWeihang Li <liweihang@huawei.com>
Fri, 11 Dec 2020 01:37:29 +0000 (09:37 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 11 Dec 2020 19:21:33 +0000 (15:21 -0400)
The high 6 bits of traffic class in GRH is DSCP (Differentiated Services
Codepoint), the driver should shift it before the hardware gets it when
using RoCEv2.

Fixes: 606bf89e98ef ("RDMA/hns: Refactor for hns_roce_v2_modify_qp function")
Fixes: fba429fcf9a5 ("RDMA/hns: Fix missing fields in address vector")
Link: https://lore.kernel.org/r/1607650657-35992-4-git-send-email-liweihang@huawei.com
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/hns/hns_roce_ah.c
drivers/infiniband/hw/hns/hns_roce_device.h
drivers/infiniband/hw/hns/hns_roce_hw_v2.c

index b09ef3335e96884f1626ce1bac73cbce7fb338c7..c9a44dbe60d42e81a16b9a0292562aa5ce701370 100644 (file)
@@ -77,7 +77,7 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
        ah->av.flowlabel = grh->flow_label;
        ah->av.udp_sport = get_ah_udp_sport(ah_attr);
        ah->av.sl = rdma_ah_get_sl(ah_attr);
-       ah->av.tclass = grh->traffic_class;
+       ah->av.tclass = get_tclass(grh);
 
        memcpy(ah->av.dgid, grh->dgid.raw, HNS_ROCE_GID_SIZE);
        memcpy(ah->av.mac, ah_attr->roce.dmac, ETH_ALEN);
index 60b8349cd2f87b62e3af4c901d88e6bbff9f2594..4ba6ff57f68d358d12c68a3c0837485200e2de47 100644 (file)
@@ -1148,6 +1148,14 @@ static inline u32 to_hr_hem_entries_shift(u32 count, u32 buf_shift)
        return ilog2(to_hr_hem_entries_count(count, buf_shift));
 }
 
+#define DSCP_SHIFT 2
+
+static inline u8 get_tclass(const struct ib_global_route *grh)
+{
+       return grh->sgid_attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP ?
+              grh->traffic_class >> DSCP_SHIFT : grh->traffic_class;
+}
+
 int hns_roce_init_uar_table(struct hns_roce_dev *dev);
 int hns_roce_uar_alloc(struct hns_roce_dev *dev, struct hns_roce_uar *uar);
 void hns_roce_uar_free(struct hns_roce_dev *dev, struct hns_roce_uar *uar);
index 8d37067a736d6f2929f4fbca5d3b80e779b2d9d8..7a0c1abde02de321ba1a73233c57ef93fcbf17d6 100644 (file)
@@ -4596,15 +4596,11 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,
        roce_set_field(qpc_mask->byte_24_mtu_tc, V2_QPC_BYTE_24_HOP_LIMIT_M,
                       V2_QPC_BYTE_24_HOP_LIMIT_S, 0);
 
-       if (is_udp)
-               roce_set_field(context->byte_24_mtu_tc, V2_QPC_BYTE_24_TC_M,
-                              V2_QPC_BYTE_24_TC_S, grh->traffic_class >> 2);
-       else
-               roce_set_field(context->byte_24_mtu_tc, V2_QPC_BYTE_24_TC_M,
-                              V2_QPC_BYTE_24_TC_S, grh->traffic_class);
-
+       roce_set_field(context->byte_24_mtu_tc, V2_QPC_BYTE_24_TC_M,
+                      V2_QPC_BYTE_24_TC_S, get_tclass(&attr->ah_attr.grh));
        roce_set_field(qpc_mask->byte_24_mtu_tc, V2_QPC_BYTE_24_TC_M,
                       V2_QPC_BYTE_24_TC_S, 0);
+
        roce_set_field(context->byte_28_at_fl, V2_QPC_BYTE_28_FL_M,
                       V2_QPC_BYTE_28_FL_S, grh->flow_label);
        roce_set_field(qpc_mask->byte_28_at_fl, V2_QPC_BYTE_28_FL_M,