RDMA/hns: Fix querying wrong SCC context for DIP algorithm
authorwenglianfa <wenglianfa@huawei.com>
Sat, 26 Jul 2025 07:53:45 +0000 (15:53 +0800)
committerLeon Romanovsky <leon@kernel.org>
Wed, 13 Aug 2025 10:34:25 +0000 (06:34 -0400)
When using DIP algorithm, all QPs establishing connections with
the same destination IP share the same SCC, which is indexed by
dip_idx, but dip_idx isn't necessarily equal to qpn. Therefore,
dip_idx should be used to query SCC context instead of qpn.

Fixes: 124a9fbe43aa ("RDMA/hns: Append SCC context to the raw dump of QPC")
Signed-off-by: wenglianfa <wenglianfa@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20250726075345.846957-1-huangjunxian6@hisilicon.com
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_restrack.c

index 64bca08f3f1a74fd0ede411f29076231a5837d06..244a4780d3a65d159ee6275ada1c6275c7b4fe0d 100644 (file)
@@ -5476,7 +5476,7 @@ out:
        return ret;
 }
 
-static int hns_roce_v2_query_sccc(struct hns_roce_dev *hr_dev, u32 qpn,
+static int hns_roce_v2_query_sccc(struct hns_roce_dev *hr_dev, u32 sccn,
                                  void *buffer)
 {
        struct hns_roce_v2_scc_context *context;
@@ -5488,7 +5488,7 @@ static int hns_roce_v2_query_sccc(struct hns_roce_dev *hr_dev, u32 qpn,
                return PTR_ERR(mailbox);
 
        ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_SCCC,
-                               qpn);
+                               sccn);
        if (ret)
                goto out;
 
index f637b73b946e44402f9fa81db8a03c2692bbcb85..230187dda6a07b20836e8810d618376714fa1cab 100644 (file)
@@ -100,6 +100,7 @@ int hns_roce_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ib_qp)
                struct hns_roce_v2_qp_context qpc;
                struct hns_roce_v2_scc_context sccc;
        } context = {};
+       u32 sccn = hr_qp->qpn;
        int ret;
 
        if (!hr_dev->hw->query_qpc)
@@ -116,7 +117,13 @@ int hns_roce_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ib_qp)
            !hr_dev->hw->query_sccc)
                goto out;
 
-       ret = hr_dev->hw->query_sccc(hr_dev, hr_qp->qpn, &context.sccc);
+       if (hr_qp->cong_type == CONG_TYPE_DIP) {
+               if (!hr_qp->dip)
+                       goto out;
+               sccn = hr_qp->dip->dip_idx;
+       }
+
+       ret = hr_dev->hw->query_sccc(hr_dev, sccn, &context.sccc);
        if (ret)
                ibdev_warn_ratelimited(&hr_dev->ib_dev,
                                       "failed to query SCCC, ret = %d.\n",