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)
156 lines
5.1 KiB
Diff
156 lines
5.1 KiB
Diff
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
|
|
|