linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next] RDMA/hns: Fix querying wrong SCC context for DIP algorithm
@ 2025-07-26  7:53 Junxian Huang
  2025-07-29 16:26 ` Zhu Yanjun
  2025-08-13 10:34 ` Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: Junxian Huang @ 2025-07-26  7:53 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, huangjunxian6, tangchengchang

From: wenglianfa <wenglianfa@huawei.com>

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>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c    | 4 ++--
 drivers/infiniband/hw/hns/hns_roce_restrack.c | 9 ++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 64bca08f3f1a..244a4780d3a6 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -5476,7 +5476,7 @@ static int hns_roce_v2_query_srqc(struct hns_roce_dev *hr_dev, u32 srqn,
 	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;
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_restrack.c b/drivers/infiniband/hw/hns/hns_roce_restrack.c
index f637b73b946e..230187dda6a0 100644
--- a/drivers/infiniband/hw/hns/hns_roce_restrack.c
+++ b/drivers/infiniband/hw/hns/hns_roce_restrack.c
@@ -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",
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-next] RDMA/hns: Fix querying wrong SCC context for DIP algorithm
  2025-07-26  7:53 [PATCH for-next] RDMA/hns: Fix querying wrong SCC context for DIP algorithm Junxian Huang
@ 2025-07-29 16:26 ` Zhu Yanjun
  2025-08-13 10:34 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Zhu Yanjun @ 2025-07-29 16:26 UTC (permalink / raw)
  To: Junxian Huang, jgg, leon; +Cc: linux-rdma, linuxarm, tangchengchang

在 2025/7/26 0:53, Junxian Huang 写道:
> From: wenglianfa <wenglianfa@huawei.com>
> 
> 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>

Replace qpn with sccn.
The term DIP algorithm typically refers to Deterministic IP, a selection 
algorithm used to pick a destination GID (Global Identifier) when 
multiple IP addresses are available.

Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>

Zhu Yanjun

> ---
>   drivers/infiniband/hw/hns/hns_roce_hw_v2.c    | 4 ++--
>   drivers/infiniband/hw/hns/hns_roce_restrack.c | 9 ++++++++-
>   2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> index 64bca08f3f1a..244a4780d3a6 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> @@ -5476,7 +5476,7 @@ static int hns_roce_v2_query_srqc(struct hns_roce_dev *hr_dev, u32 srqn,
>   	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;
>   
> diff --git a/drivers/infiniband/hw/hns/hns_roce_restrack.c b/drivers/infiniband/hw/hns/hns_roce_restrack.c
> index f637b73b946e..230187dda6a0 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_restrack.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_restrack.c
> @@ -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",


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-next] RDMA/hns: Fix querying wrong SCC context for DIP algorithm
  2025-07-26  7:53 [PATCH for-next] RDMA/hns: Fix querying wrong SCC context for DIP algorithm Junxian Huang
  2025-07-29 16:26 ` Zhu Yanjun
@ 2025-08-13 10:34 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2025-08-13 10:34 UTC (permalink / raw)
  To: jgg, Junxian Huang; +Cc: linux-rdma, linuxarm, tangchengchang


On Sat, 26 Jul 2025 15:53:45 +0800, Junxian Huang wrote:
> 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.
> 
> 

Applied, thanks!

[1/1] RDMA/hns: Fix querying wrong SCC context for DIP algorithm
      https://git.kernel.org/rdma/rdma/c/085a1b42e52750

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-13 10:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-26  7:53 [PATCH for-next] RDMA/hns: Fix querying wrong SCC context for DIP algorithm Junxian Huang
2025-07-29 16:26 ` Zhu Yanjun
2025-08-13 10:34 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).