public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-rc 0/7] Bugfixes for hns RoCE
@ 2023-10-17 12:52 Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 1/7] RDMA/hns: Fix printing level of asynchronous events Junxian Huang
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Junxian Huang @ 2023-10-17 12:52 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

Here is a patchset of several bugfixes.

Chengchang Tang (3):
  RDMA/hns: Fix printing level of asynchronous events
  RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common()
  RDMA/hns: Fix signed-unsigned mixed comparisons

Junxian Huang (2):
  RDMA/hns: Fix unnecessary port_num transition in HW stats allocation
  RDMA/hns: Fix init failure of RoCE VF and HIP08

Luoyouming (2):
  RDMA/hns: Add check for SL
  RDMA/hns: The UD mode can only be configured with DCQCN

 drivers/infiniband/hw/hns/hns_roce_ah.c    | 13 ++++++++-
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 34 +++++++++++++---------
 drivers/infiniband/hw/hns/hns_roce_main.c  | 22 +++++++-------
 drivers/infiniband/hw/hns/hns_roce_qp.c    |  2 +-
 4 files changed, 43 insertions(+), 28 deletions(-)

--
2.30.0


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

* [PATCH for-rc 1/7] RDMA/hns: Fix printing level of asynchronous events
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
@ 2023-10-17 12:52 ` Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 2/7] RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common() Junxian Huang
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Junxian Huang @ 2023-10-17 12:52 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

From: Chengchang Tang <tangchengchang@huawei.com>

The current driver will print all asynchronous events. Some of the
print levels are set improperly, e.g. SRQ limit reach and SRQ last
wqe reach, which may also occur during normal operation of the software.
Currently, the information of these event is printed as a warning,
which causes a large amount of printing even during normal use of the
application. As a result, the service performance deteriorates.

This patch fixes the printing storms by modifying the print level.

Fixes: b00a92c8f2ca ("RDMA/hns: Move all prints out of irq handle")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++---
 1 file changed, 3 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 d82daff2d9bd..2b8f6489ab3d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -5804,7 +5804,7 @@ static void hns_roce_irq_work_handle(struct work_struct *work)
 	case HNS_ROCE_EVENT_TYPE_COMM_EST:
 		break;
 	case HNS_ROCE_EVENT_TYPE_SQ_DRAINED:
-		ibdev_warn(ibdev, "send queue drained.\n");
+		ibdev_dbg(ibdev, "send queue drained.\n");
 		break;
 	case HNS_ROCE_EVENT_TYPE_WQ_CATAS_ERROR:
 		ibdev_err(ibdev, "local work queue 0x%x catast error, sub_event type is: %d\n",
@@ -5819,10 +5819,10 @@ static void hns_roce_irq_work_handle(struct work_struct *work)
 			  irq_work->queue_num, irq_work->sub_type);
 		break;
 	case HNS_ROCE_EVENT_TYPE_SRQ_LIMIT_REACH:
-		ibdev_warn(ibdev, "SRQ limit reach.\n");
+		ibdev_dbg(ibdev, "SRQ limit reach.\n");
 		break;
 	case HNS_ROCE_EVENT_TYPE_SRQ_LAST_WQE_REACH:
-		ibdev_warn(ibdev, "SRQ last wqe reach.\n");
+		ibdev_dbg(ibdev, "SRQ last wqe reach.\n");
 		break;
 	case HNS_ROCE_EVENT_TYPE_SRQ_CATAS_ERROR:
 		ibdev_err(ibdev, "SRQ catas error.\n");
-- 
2.30.0


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

* [PATCH for-rc 2/7] RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common()
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 1/7] RDMA/hns: Fix printing level of asynchronous events Junxian Huang
@ 2023-10-17 12:52 ` Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 3/7] RDMA/hns: Fix signed-unsigned mixed comparisons Junxian Huang
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Junxian Huang @ 2023-10-17 12:52 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

From: Chengchang Tang <tangchengchang@huawei.com>

ucmd in hns_roce_create_qp_common() are not initialized. But it works fine
until new member sdb_addr is added to struct hns_roce_ib_create_qp.

If the user-mode driver uses an old version ABI, then the value of the new
member will be undefined after ib_copy_from_udata().

This patch fixes it by initialize this variable to 0. And the default value
of the new member sdb_addr will be 0 which is invalid.

Fixes: 0425e3e6e0c7 ("RDMA/hns: Support flush cqe for hip08 in kernel space")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index cdc1c6de43a1..828b58534aa9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -1064,7 +1064,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
 {
 	struct hns_roce_ib_create_qp_resp resp = {};
 	struct ib_device *ibdev = &hr_dev->ib_dev;
-	struct hns_roce_ib_create_qp ucmd;
+	struct hns_roce_ib_create_qp ucmd = {};
 	int ret;
 
 	mutex_init(&hr_qp->mutex);
-- 
2.30.0


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

* [PATCH for-rc 3/7] RDMA/hns: Fix signed-unsigned mixed comparisons
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 1/7] RDMA/hns: Fix printing level of asynchronous events Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 2/7] RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common() Junxian Huang
@ 2023-10-17 12:52 ` Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 4/7] RDMA/hns: Add check for SL Junxian Huang
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Junxian Huang @ 2023-10-17 12:52 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

From: Chengchang Tang <tangchengchang@huawei.com>

The ib_mtu_enum_to_int() and uverbs_attr_get_len() may returns a negative
value. In this case, mixed comparisons of signed and unsigned types will
throw wrong results.

This patch adds judgement for this situation.

Fixes: 30b707886aeb ("RDMA/hns: Support inline data in extented sge space for RC")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 2b8f6489ab3d..3daa684f8836 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -270,7 +270,7 @@ static bool check_inl_data_len(struct hns_roce_qp *qp, unsigned int len)
 	struct hns_roce_dev *hr_dev = to_hr_dev(qp->ibqp.device);
 	int mtu = ib_mtu_enum_to_int(qp->path_mtu);
 
-	if (len > qp->max_inline_data || len > mtu) {
+	if (mtu < 0 || len > qp->max_inline_data || len > mtu) {
 		ibdev_err(&hr_dev->ib_dev,
 			  "invalid length of data, data len = %u, max inline len = %u, path mtu = %d.\n",
 			  len, qp->max_inline_data, mtu);
-- 
2.30.0


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

* [PATCH for-rc 4/7] RDMA/hns: Add check for SL
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
                   ` (2 preceding siblings ...)
  2023-10-17 12:52 ` [PATCH for-rc 3/7] RDMA/hns: Fix signed-unsigned mixed comparisons Junxian Huang
@ 2023-10-17 12:52 ` Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 5/7] RDMA/hns: The UD mode can only be configured with DCQCN Junxian Huang
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Junxian Huang @ 2023-10-17 12:52 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

From: Luoyouming <luoyouming@huawei.com>

SL set by users may exceed the capability of devices. So add check
for this situation.

Fixes: fba429fcf9a5 ("RDMA/hns: Fix missing fields in address vector")
Fixes: 70f92521584f ("RDMA/hns: Use the reserved loopback QPs to free MR before destroying MPT")
Fixes: f0cb411aad23 ("RDMA/hns: Use new interface to modify QP context")
Signed-off-by: Luoyouming <luoyouming@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_ah.c    | 13 +++++++++++-
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 23 ++++++++++++----------
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c
index e77fcc74f15c..3df032ddda18 100644
--- a/drivers/infiniband/hw/hns/hns_roce_ah.c
+++ b/drivers/infiniband/hw/hns/hns_roce_ah.c
@@ -33,7 +33,9 @@
 #include <linux/pci.h>
 #include <rdma/ib_addr.h>
 #include <rdma/ib_cache.h>
+#include "hnae3.h"
 #include "hns_roce_device.h"
+#include "hns_roce_hw_v2.h"
 
 static inline u16 get_ah_udp_sport(const struct rdma_ah_attr *ah_attr)
 {
@@ -57,6 +59,7 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
 	struct hns_roce_dev *hr_dev = to_hr_dev(ibah->device);
 	struct hns_roce_ah *ah = to_hr_ah(ibah);
 	int ret = 0;
+	u32 max_sl;
 
 	if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08 && udata)
 		return -EOPNOTSUPP;
@@ -70,9 +73,17 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
 	ah->av.hop_limit = grh->hop_limit;
 	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 = get_tclass(grh);
 
+	ah->av.sl = rdma_ah_get_sl(ah_attr);
+	max_sl = min_t(u32, MAX_SERVICE_LEVEL, hr_dev->caps.sl_num - 1);
+	if (unlikely(ah->av.sl > max_sl)) {
+		ibdev_err_ratelimited(&hr_dev->ib_dev,
+				      "failed to set sl, sl (%u) shouldn't be larger than %u.\n",
+				      ah->av.sl, max_sl);
+		return -EINVAL;
+	}
+
 	memcpy(ah->av.dgid, grh->dgid.raw, HNS_ROCE_GID_SIZE);
 	memcpy(ah->av.mac, ah_attr->roce.dmac, ETH_ALEN);
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 3daa684f8836..b7faf5c8f6ba 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4821,22 +4821,32 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,
 	struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
 	struct ib_device *ibdev = &hr_dev->ib_dev;
 	const struct ib_gid_attr *gid_attr = NULL;
+	u8 sl = rdma_ah_get_sl(&attr->ah_attr);
 	int is_roce_protocol;
 	u16 vlan_id = 0xffff;
 	bool is_udp = false;
+	u32 max_sl;
 	u8 ib_port;
 	u8 hr_port;
 	int ret;
 
+	max_sl = min_t(u32, MAX_SERVICE_LEVEL, hr_dev->caps.sl_num - 1);
+	if (unlikely(sl > max_sl)) {
+		ibdev_err_ratelimited(ibdev,
+				      "failed to fill QPC, sl (%u) shouldn't be larger than %u.\n",
+				      sl, max_sl);
+		return -EINVAL;
+	}
+
 	/*
 	 * If free_mr_en of qp is set, it means that this qp comes from
 	 * free mr. This qp will perform the loopback operation.
 	 * In the loopback scenario, only sl needs to be set.
 	 */
 	if (hr_qp->free_mr_en) {
-		hr_reg_write(context, QPC_SL, rdma_ah_get_sl(&attr->ah_attr));
+		hr_reg_write(context, QPC_SL, sl);
 		hr_reg_clear(qpc_mask, QPC_SL);
-		hr_qp->sl = rdma_ah_get_sl(&attr->ah_attr);
+		hr_qp->sl = sl;
 		return 0;
 	}
 
@@ -4903,14 +4913,7 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,
 	memcpy(context->dgid, grh->dgid.raw, sizeof(grh->dgid.raw));
 	memset(qpc_mask->dgid, 0, sizeof(grh->dgid.raw));
 
-	hr_qp->sl = rdma_ah_get_sl(&attr->ah_attr);
-	if (unlikely(hr_qp->sl > MAX_SERVICE_LEVEL)) {
-		ibdev_err(ibdev,
-			  "failed to fill QPC, sl (%u) shouldn't be larger than %d.\n",
-			  hr_qp->sl, MAX_SERVICE_LEVEL);
-		return -EINVAL;
-	}
-
+	hr_qp->sl = sl;
 	hr_reg_write(context, QPC_SL, hr_qp->sl);
 	hr_reg_clear(qpc_mask, QPC_SL);
 
-- 
2.30.0


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

* [PATCH for-rc 5/7] RDMA/hns: The UD mode can only be configured with DCQCN
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
                   ` (3 preceding siblings ...)
  2023-10-17 12:52 ` [PATCH for-rc 4/7] RDMA/hns: Add check for SL Junxian Huang
@ 2023-10-17 12:52 ` Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 6/7] RDMA/hns: Fix unnecessary port_num transition in HW stats allocation Junxian Huang
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Junxian Huang @ 2023-10-17 12:52 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

From: Luoyouming <luoyouming@huawei.com>

Due to hardware limitations, only DCQCN is supported for UD. Therefore, the
default algorithm for UD is set to DCQCN.

Fixes: f91696f2f053 ("RDMA/hns: Support congestion control type selection according to the FW")
Signed-off-by: Luoyouming <luoyouming@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index b7faf5c8f6ba..58d14f1562b9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4725,6 +4725,9 @@ static int check_cong_type(struct ib_qp *ibqp,
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
 
+	if (ibqp->qp_type == IB_QPT_UD)
+		hr_dev->caps.cong_type = CONG_TYPE_DCQCN;
+
 	/* different congestion types match different configurations */
 	switch (hr_dev->caps.cong_type) {
 	case CONG_TYPE_DCQCN:
-- 
2.30.0


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

* [PATCH for-rc 6/7] RDMA/hns: Fix unnecessary port_num transition in HW stats allocation
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
                   ` (4 preceding siblings ...)
  2023-10-17 12:52 ` [PATCH for-rc 5/7] RDMA/hns: The UD mode can only be configured with DCQCN Junxian Huang
@ 2023-10-17 12:52 ` Junxian Huang
  2023-10-17 12:52 ` [PATCH for-rc 7/7] RDMA/hns: Fix init failure of RoCE VF and HIP08 Junxian Huang
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Junxian Huang @ 2023-10-17 12:52 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

The num_ports capability of devices should be compared with the
number of port(i.e. the input param "port_num") but not the port
index(i.e. port_num - 1).

Fixes: 5a87279591a1 ("RDMA/hns: Support hns HW stats")
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
index d9d546cdef52..e1a88f2d51b6 100644
--- a/drivers/infiniband/hw/hns/hns_roce_main.c
+++ b/drivers/infiniband/hw/hns/hns_roce_main.c
@@ -547,9 +547,8 @@ static struct rdma_hw_stats *hns_roce_alloc_hw_port_stats(
 				struct ib_device *device, u32 port_num)
 {
 	struct hns_roce_dev *hr_dev = to_hr_dev(device);
-	u32 port = port_num - 1;
 
-	if (port > hr_dev->caps.num_ports) {
+	if (port_num > hr_dev->caps.num_ports) {
 		ibdev_err(device, "invalid port num.\n");
 		return NULL;
 	}
-- 
2.30.0


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

* [PATCH for-rc 7/7] RDMA/hns: Fix init failure of RoCE VF and HIP08
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
                   ` (5 preceding siblings ...)
  2023-10-17 12:52 ` [PATCH for-rc 6/7] RDMA/hns: Fix unnecessary port_num transition in HW stats allocation Junxian Huang
@ 2023-10-17 12:52 ` Junxian Huang
  2023-10-19  6:53 ` [PATCH for-rc 0/7] Bugfixes for hns RoCE Leon Romanovsky
  2023-10-19  6:53 ` Leon Romanovsky
  8 siblings, 0 replies; 10+ messages in thread
From: Junxian Huang @ 2023-10-17 12:52 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, linuxarm, linux-kernel, huangjunxian6

During device init, a struct for HW stats will be allocated. As HW
stats are not supported for VF and HIP08, currently
hns_roce_alloc_hw_port_stats() returns NULL in this case. However,
ib-core considers the returned NULL pointer as memory allocation
failure and returns ENOMEM, eventually leading to the failure of VF
and HIP08 init.

In the case where the driver does not support the .alloc_hw_port_stats()
ops, ib-core will return EOPNOTSUPP and ignore this error code in the
upper layer function. So for VF and HIP08, just don't set the HW stats
ops to ib-core.

Fixes: 5a87279591a1 ("RDMA/hns: Support hns HW stats")
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
 drivers/infiniband/hw/hns/hns_roce_main.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
index e1a88f2d51b6..4a9cd4d21bc9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_main.c
+++ b/drivers/infiniband/hw/hns/hns_roce_main.c
@@ -553,10 +553,6 @@ static struct rdma_hw_stats *hns_roce_alloc_hw_port_stats(
 		return NULL;
 	}
 
-	if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08 ||
-	    hr_dev->is_vf)
-		return NULL;
-
 	return rdma_alloc_hw_stats_struct(hns_roce_port_stats_descs,
 					  ARRAY_SIZE(hns_roce_port_stats_descs),
 					  RDMA_HW_STATS_DEFAULT_LIFESPAN);
@@ -576,10 +572,6 @@ static int hns_roce_get_hw_stats(struct ib_device *device,
 	if (port > hr_dev->caps.num_ports)
 		return -EINVAL;
 
-	if (hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08 ||
-	    hr_dev->is_vf)
-		return -EOPNOTSUPP;
-
 	ret = hr_dev->hw->query_hw_counter(hr_dev, stats->value, port,
 					   &num_counters);
 	if (ret) {
@@ -633,8 +625,6 @@ static const struct ib_device_ops hns_roce_dev_ops = {
 	.query_pkey = hns_roce_query_pkey,
 	.query_port = hns_roce_query_port,
 	.reg_user_mr = hns_roce_reg_user_mr,
-	.alloc_hw_port_stats = hns_roce_alloc_hw_port_stats,
-	.get_hw_stats = hns_roce_get_hw_stats,
 
 	INIT_RDMA_OBJ_SIZE(ib_ah, hns_roce_ah, ibah),
 	INIT_RDMA_OBJ_SIZE(ib_cq, hns_roce_cq, ib_cq),
@@ -643,6 +633,11 @@ static const struct ib_device_ops hns_roce_dev_ops = {
 	INIT_RDMA_OBJ_SIZE(ib_ucontext, hns_roce_ucontext, ibucontext),
 };
 
+static const struct ib_device_ops hns_roce_dev_hw_stats_ops = {
+	.alloc_hw_port_stats = hns_roce_alloc_hw_port_stats,
+	.get_hw_stats = hns_roce_get_hw_stats,
+};
+
 static const struct ib_device_ops hns_roce_dev_mr_ops = {
 	.rereg_user_mr = hns_roce_rereg_user_mr,
 };
@@ -719,6 +714,10 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
 	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_XRC)
 		ib_set_device_ops(ib_dev, &hns_roce_dev_xrcd_ops);
 
+	if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09 &&
+	    !hr_dev->is_vf)
+		ib_set_device_ops(ib_dev, &hns_roce_dev_hw_stats_ops);
+
 	ib_set_device_ops(ib_dev, hr_dev->hw->hns_roce_dev_ops);
 	ib_set_device_ops(ib_dev, &hns_roce_dev_ops);
 	ib_set_device_ops(ib_dev, &hns_roce_dev_restrack_ops);
-- 
2.30.0


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

* Re: [PATCH for-rc 0/7] Bugfixes for hns RoCE
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
                   ` (6 preceding siblings ...)
  2023-10-17 12:52 ` [PATCH for-rc 7/7] RDMA/hns: Fix init failure of RoCE VF and HIP08 Junxian Huang
@ 2023-10-19  6:53 ` Leon Romanovsky
  2023-10-19  6:53 ` Leon Romanovsky
  8 siblings, 0 replies; 10+ messages in thread
From: Leon Romanovsky @ 2023-10-19  6:53 UTC (permalink / raw)
  To: Junxian Huang; +Cc: jgg, linux-rdma, linuxarm, linux-kernel

On Tue, Oct 17, 2023 at 08:52:32PM +0800, Junxian Huang wrote:
> Here is a patchset of several bugfixes.
> 
> Chengchang Tang (3):
>   RDMA/hns: Fix printing level of asynchronous events
>   RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common()
>   RDMA/hns: Fix signed-unsigned mixed comparisons
> 
> Junxian Huang (2):
>   RDMA/hns: Fix unnecessary port_num transition in HW stats allocation
>   RDMA/hns: Fix init failure of RoCE VF and HIP08
> 
> Luoyouming (2):
>   RDMA/hns: Add check for SL
>   RDMA/hns: The UD mode can only be configured with DCQCN

I took all these patches to -next, we are in -rc6 now.

Thanks

> 
>  drivers/infiniband/hw/hns/hns_roce_ah.c    | 13 ++++++++-
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 34 +++++++++++++---------
>  drivers/infiniband/hw/hns/hns_roce_main.c  | 22 +++++++-------
>  drivers/infiniband/hw/hns/hns_roce_qp.c    |  2 +-
>  4 files changed, 43 insertions(+), 28 deletions(-)
> 
> --
> 2.30.0
> 

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

* Re: [PATCH for-rc 0/7] Bugfixes for hns RoCE
  2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
                   ` (7 preceding siblings ...)
  2023-10-19  6:53 ` [PATCH for-rc 0/7] Bugfixes for hns RoCE Leon Romanovsky
@ 2023-10-19  6:53 ` Leon Romanovsky
  8 siblings, 0 replies; 10+ messages in thread
From: Leon Romanovsky @ 2023-10-19  6:53 UTC (permalink / raw)
  To: jgg, Junxian Huang; +Cc: linux-rdma, linuxarm, linux-kernel


On Tue, 17 Oct 2023 20:52:32 +0800, Junxian Huang wrote:
> Here is a patchset of several bugfixes.
> 
> Chengchang Tang (3):
>   RDMA/hns: Fix printing level of asynchronous events
>   RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common()
>   RDMA/hns: Fix signed-unsigned mixed comparisons
> 
> [...]

Applied, thanks!

[1/7] RDMA/hns: Fix printing level of asynchronous events
      https://git.kernel.org/rdma/rdma/c/9faef73ef4f666
[2/7] RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common()
      https://git.kernel.org/rdma/rdma/c/c64e9710f9241e
[3/7] RDMA/hns: Fix signed-unsigned mixed comparisons
      https://git.kernel.org/rdma/rdma/c/b5f9efff101b06
[4/7] RDMA/hns: Add check for SL
      https://git.kernel.org/rdma/rdma/c/5e617c18b1f34e
[5/7] RDMA/hns: The UD mode can only be configured with DCQCN
      https://git.kernel.org/rdma/rdma/c/27c5fd271d8b87
[6/7] RDMA/hns: Fix unnecessary port_num transition in HW stats allocation
      https://git.kernel.org/rdma/rdma/c/b4a797b894dc91
[7/7] RDMA/hns: Fix init failure of RoCE VF and HIP08
      https://git.kernel.org/rdma/rdma/c/07f06e0e5cd995

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

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

end of thread, other threads:[~2023-10-19  6:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-17 12:52 [PATCH for-rc 0/7] Bugfixes for hns RoCE Junxian Huang
2023-10-17 12:52 ` [PATCH for-rc 1/7] RDMA/hns: Fix printing level of asynchronous events Junxian Huang
2023-10-17 12:52 ` [PATCH for-rc 2/7] RDMA/hns: Fix uninitialized ucmd in hns_roce_create_qp_common() Junxian Huang
2023-10-17 12:52 ` [PATCH for-rc 3/7] RDMA/hns: Fix signed-unsigned mixed comparisons Junxian Huang
2023-10-17 12:52 ` [PATCH for-rc 4/7] RDMA/hns: Add check for SL Junxian Huang
2023-10-17 12:52 ` [PATCH for-rc 5/7] RDMA/hns: The UD mode can only be configured with DCQCN Junxian Huang
2023-10-17 12:52 ` [PATCH for-rc 6/7] RDMA/hns: Fix unnecessary port_num transition in HW stats allocation Junxian Huang
2023-10-17 12:52 ` [PATCH for-rc 7/7] RDMA/hns: Fix init failure of RoCE VF and HIP08 Junxian Huang
2023-10-19  6:53 ` [PATCH for-rc 0/7] Bugfixes for hns RoCE Leon Romanovsky
2023-10-19  6:53 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox