From 8fbf781e3b3630c25a361f7c5e3642350dcd21c9 Mon Sep 17 00:00:00 2001
From: Chengchang Tang <tangchengchang@huawei.com>
Date: Fri, 2 Jun 2023 10:33:16 +0800
Subject: [PATCH 4/4] libhns: Add a judgment to the congestion control
 algorithm

driver inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I7A7HI

---------------------------------------------------------------

The congestion control algorithm is used only when the comp_mask flag
HNSDV_QP_INIT_ATTR_MASK_QP_CONGEST_TYPE is seted.

A check on comp_mask is added to prevent invalid parameter errors caused
by unconfigured congestion control algorithm types.

Fixes: 7623f24781f1 ("libhns: Support congestion control algorithm configuration")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
---
 providers/hns/hns_roce_u_verbs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 6c6120c..fa27fc1 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -988,6 +988,9 @@ static int check_qp_congest_type(struct hns_roce_context *ctx,
 {
 	struct hns_roce_device *hr_dev = to_hr_dev(ctx->ibv_ctx.context.device);
 
+	if (!(hns_attr->comp_mask & HNSDV_QP_INIT_ATTR_MASK_QP_CONGEST_TYPE))
+		return 0;
+
 	if (!check_comp_mask(hns_attr->congest_type, hr_dev->congest_type)) {
 		verbs_err(&ctx->ibv_ctx, "unsupported congest type 0x%x.\n",
 			  hns_attr->congest_type);
-- 
2.25.1

