Skip resolving MAC for RDMA over UBLink

For RDMA over UBLink, MAC Layer if replaced by UBLink, and thus the
MAC addr is not nedded. So skip the MAC addr resolving for this mode.

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Haoyue Xu <xuhaoyue1@hisilicon.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Signed-off-by: Juan Zhou <zhoujuan51@h-partners.com>
(cherry picked from commit 333b7848bd0c6a33c5bcfdef18fa6bae578fd7cc)
This commit is contained in:
Juan Zhou 2023-10-26 15:02:44 +08:00 committed by openeuler-sync-bot
parent a0dcb93164
commit 4cc4e9a1ad
2 changed files with 163 additions and 1 deletions

View File

@ -0,0 +1,155 @@
From c77fa69a300e97cc37bb5189f79e3a1ca6f30ac5 Mon Sep 17 00:00:00 2001
From: Chengchang Tang <tangchengchang@huawei.com>
Date: Thu, 26 Oct 2023 14:35:03 +0800
Subject: [PATCH] libhns: Skip resolving MAC for RDMA over UBLink
driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8AL44
For RDMA over UBLink, MAC Layer if replaced by UBLink, and thus the
MAC addr is not nedded. So skip the MAC addr resolving for this mode.
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Haoyue Xu <xuhaoyue1@hisilicon.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
providers/hns/hns_roce_u.c | 37 +++++++++++++++++++++++++++++++-
providers/hns/hns_roce_u.h | 9 ++++----
providers/hns/hns_roce_u_hw_v2.c | 2 +-
providers/hns/hns_roce_u_verbs.c | 3 ++-
4 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
index 02ad880..cef64ec 100644
--- a/providers/hns/hns_roce_u.c
+++ b/providers/hns/hns_roce_u.c
@@ -56,6 +56,7 @@ static const struct verbs_match_ent hca_table[] = {
VERBS_PCI_MATCH(PCI_VENDOR_ID_HUAWEI, 0xA22C, &hns_roce_u_hw_v2),
VERBS_PCI_MATCH(PCI_VENDOR_ID_HUAWEI, 0xA22D, &hns_roce_u_hw_v2),
VERBS_PCI_MATCH(PCI_VENDOR_ID_HUAWEI, 0xA22F, &hns_roce_u_hw_v2),
+ VERBS_PCI_MATCH(PCI_VENDOR_ID_HUAWEI, 0xA26A, &hns_roce_u_hw_v2),
{}
};
@@ -95,6 +96,23 @@ static const struct verbs_context_ops hns_common_ops = {
.alloc_parent_domain = hns_roce_u_alloc_pad,
};
+static struct {
+ uint32_t device_id;
+ enum hns_device_link_type link_type;
+} device_link_types[] = {
+ {0xA222, HNS_DEV_LINK_TYPE_ETH},
+ {0xA223, HNS_DEV_LINK_TYPE_ETH},
+ {0xA224, HNS_DEV_LINK_TYPE_ETH},
+ {0xA225, HNS_DEV_LINK_TYPE_ETH},
+ {0xA226, HNS_DEV_LINK_TYPE_ETH},
+ {0xA228, HNS_DEV_LINK_TYPE_ETH},
+ {0xA22F, HNS_DEV_LINK_TYPE_ETH},
+ {0xA227, HNS_DEV_LINK_TYPE_HCCS},
+ {0xA22C, HNS_DEV_LINK_TYPE_HCCS},
+ {0xA22D, HNS_DEV_LINK_TYPE_HCCS},
+ {0xA26A, HNS_DEV_LINK_TYPE_UB}
+};
+
static int mmap_dca(struct hns_roce_context *ctx, int cmd_fd,
int page_size, size_t size, uint64_t mmap_key)
{
@@ -256,6 +274,21 @@ static int hns_roce_mmap(struct hns_roce_device *hr_dev,
return 0;
}
+static int get_link_type(uint32_t device_id,
+ enum hns_device_link_type *link_type)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(device_link_types); i++) {
+ if (device_id == device_link_types[i].device_id) {
+ *link_type = device_link_types[i].link_type;
+ return 0;
+ }
+ }
+
+ return ENOENT;
+}
+
static uint32_t calc_table_shift(uint32_t entry_count, uint32_t size_shift)
{
uint32_t count_shift = hr_ilog32(entry_count);
@@ -302,7 +335,6 @@ static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
&resp.ibv_resp, sizeof(resp)))
goto err_free;
- hr_dev->mac_type = resp.mac_type;
hr_dev->congest_type = resp.congest_type;
if (!resp.cqe_size)
@@ -338,6 +370,9 @@ static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
goto err_free;
hr_dev->hw_version = dev_attrs.hw_ver;
+ if (get_link_type(dev_attrs.vendor_part_id, &hr_dev->link_type))
+ hr_dev->link_type = resp.mac_type;
+
context->max_qp_wr = dev_attrs.max_qp_wr;
context->max_sge = dev_attrs.max_sge;
context->max_cqe = dev_attrs.max_cqe;
diff --git a/providers/hns/hns_roce_u.h b/providers/hns/hns_roce_u.h
index 197bde9..662eb8a 100644
--- a/providers/hns/hns_roce_u.h
+++ b/providers/hns/hns_roce_u.h
@@ -161,9 +161,10 @@ enum {
#define HNS_ROCE_SRQ_TABLE_BITS 8
#define HNS_ROCE_SRQ_TABLE_SIZE BIT(HNS_ROCE_SRQ_TABLE_BITS)
-enum {
- HNAE3_MAC_ETH,
- HNAE3_MAC_ROH,
+enum hns_device_link_type {
+ HNS_DEV_LINK_TYPE_ETH,
+ HNS_DEV_LINK_TYPE_HCCS,
+ HNS_DEV_LINK_TYPE_UB,
};
struct hns_roce_device {
@@ -171,7 +172,7 @@ struct hns_roce_device {
int page_size;
const struct hns_roce_u_hw *u_hw;
int hw_version;
- uint8_t mac_type;
+ enum hns_device_link_type link_type;
uint8_t congest_type;
};
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index 714a34e..fbd02dc 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -1431,7 +1431,7 @@ static int set_ud_wqe(void *wqe, struct hns_roce_qp *qp, struct ibv_send_wr *wr,
if (ret)
return ret;
- if (hr_dev->mac_type == HNAE3_MAC_ROH)
+ if (hr_dev->link_type == HNS_DEV_LINK_TYPE_HCCS)
ud_sq_wqe->dmac[0] = 0xFF;
ret = fill_ud_data_seg(ud_sq_wqe, qp, wr, sge_info);
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 1c2d94d..c3b01a0 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -2019,7 +2019,8 @@ struct ibv_ah *hns_roce_u_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
if (ibv_cmd_create_ah(pd, &ah->ibv_ah, attr, &resp.ibv_resp, sizeof(resp)))
goto err;
- if (ibv_resolve_eth_l2_from_gid(pd->context, attr, ah->av.mac, NULL))
+ if (hr_dev->link_type != HNS_DEV_LINK_TYPE_UB &&
+ ibv_resolve_eth_l2_from_gid(pd->context, attr, ah->av.mac, NULL))
goto err;
if (resp.tc_mode == HNS_ROCE_TC_MAP_MODE_DSCP)
--
2.25.1

View File

@ -1,6 +1,6 @@
Name: rdma-core Name: rdma-core
Version: 41.0 Version: 41.0
Release: 17 Release: 18
Summary: RDMA core userspace libraries and daemons Summary: RDMA core userspace libraries and daemons
License: GPLv2 or BSD License: GPLv2 or BSD
Url: https://github.com/linux-rdma/rdma-core Url: https://github.com/linux-rdma/rdma-core
@ -66,6 +66,7 @@ patch56: 0057-libhns-Fix-missing-reset-notification.patch
patch57: 0058-libhns-Support-flexible-WQE-buffer-page-size.patch patch57: 0058-libhns-Support-flexible-WQE-buffer-page-size.patch
patch58: 0059-Update-kernel-headers.patch patch58: 0059-Update-kernel-headers.patch
patch59: 0060-libhns-Support-SRQ-record-doorbell.patch patch59: 0060-libhns-Support-SRQ-record-doorbell.patch
patch60: 0061-libhns-Skip-resolving-MAC-for-RDMA-over-UBLink.patch
BuildRequires: binutils cmake >= 2.8.11 gcc libudev-devel pkgconfig pkgconfig(libnl-3.0) BuildRequires: binutils cmake >= 2.8.11 gcc libudev-devel pkgconfig pkgconfig(libnl-3.0)
BuildRequires: pkgconfig(libnl-route-3.0) valgrind-devel systemd systemd-devel BuildRequires: pkgconfig(libnl-route-3.0) valgrind-devel systemd systemd-devel
@ -313,6 +314,12 @@ fi
%{_mandir}/* %{_mandir}/*
%changelog %changelog
* Thu Oct 26 2023 Juan Zhou <zhoujuan51@h-partners.com> - 41.0-18
- Type: requirement
- ID: NA
- SUG: NA
- DESC: Skip resolving MAC for RDMA over UBLink
* Wed Oct 25 2023 Ran Zhou <zhouran10@h-partners.com> - 41.0-17 * Wed Oct 25 2023 Ran Zhou <zhouran10@h-partners.com> - 41.0-17
- Type: requirement - Type: requirement
- ID: NA - ID: NA