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 3491097..e7313c2 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 61c4981..fe7e1ac 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 b9be376..abeb1ab 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -2018,7 +2018,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)
From: Yangyang Li liyangyang20@huawei.com
driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8AL44
--------------------------------------------------------------------------
For RDMA over UB Link mode, UB Link replaces the current Ethernet. Add a new ARP protocol HW ID 38 and enable CM link building and netdevice event for this mode.
Signed-off-by: Yangyang Li liyangyang20@huawei.com Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Haoyue Xu xuhaoyue1@hisilicon.com --- drivers/infiniband/core/cma.c | 3 ++- drivers/infiniband/core/roce_gid_mgmt.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 82640924e990..672cc8571ac9 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -582,7 +582,8 @@ cma_validate_port(struct ib_device *device, u8 port, if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) return ERR_PTR(-ENODEV);
- if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) { + if ((dev_type == ARPHRD_ETHER || dev_type == ARPHRD_UB) + && rdma_protocol_roce(device, port)) { ndev = dev_get_by_index(dev_addr->net, bound_if_index); if (!ndev) return ERR_PTR(-ENODEV); diff --git a/drivers/infiniband/core/roce_gid_mgmt.c b/drivers/infiniband/core/roce_gid_mgmt.c index 6b8364bb032d..282b595b0754 100644 --- a/drivers/infiniband/core/roce_gid_mgmt.c +++ b/drivers/infiniband/core/roce_gid_mgmt.c @@ -754,7 +754,7 @@ static int netdevice_event(struct notifier_block *this, unsigned long event, struct net_device *ndev = netdev_notifier_info_to_dev(ptr); struct netdev_event_work_cmd cmds[ROCE_NETDEV_CALLBACK_SZ] = { {NULL} };
- if (ndev->type != ARPHRD_ETHER) + if (ndev->type != ARPHRD_ETHER && ndev->type != ARPHRD_UB) return NOTIFY_DONE;
switch (event) { @@ -820,7 +820,7 @@ static int addr_event(struct notifier_block *this, unsigned long event, struct update_gid_event_work *work; enum gid_op_type gid_op;
- if (ndev->type != ARPHRD_ETHER) + if (ndev->type != ARPHRD_ETHER && ndev->type != ARPHRD_UB) return NOTIFY_DONE;
switch (event) {
driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8AL44
--------------------------------------------------------------------------
This patch supports RDMA VF over UBL.
Signed-off-by: Chengchang Tang tangchengchang@huawei.com Signed-off-by: Haoyue Xu xuhaoyue1@hisilicon.com Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 32 +++++++++++++++++++--- drivers/infiniband/hw/hns/hns_roce_main.c | 2 ++ 2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 1051135ae306..8ea24e75e513 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -3406,7 +3406,9 @@ static int hns_roce_v2_set_gid(struct hns_roce_dev *hr_dev, int gid_index, else sgid_type = GID_TYPE_FLAG_ROCE_V2_IPV6; } else if (attr->gid_type == IB_GID_TYPE_ROCE) { - if (hr_dev->mac_type == HNAE3_MAC_ROH) + if (hr_dev->mac_type == HNAE3_MAC_ROH || + hr_dev->pci_dev->device == + HNAE3_DEV_ID_RDMA_OVER_UBL_VF) return -EPERM; sgid_type = GID_TYPE_FLAG_ROCE_V1; } @@ -7191,6 +7193,27 @@ static const struct pci_device_id hns_roce_hw_v2_pci_tbl[] = {
MODULE_DEVICE_TABLE(pci, hns_roce_hw_v2_pci_tbl);
+static const struct pci_device_id hns_roce_ubl_tbl[] = { + { PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_RDMA_OVER_UBL_VF), + HNAE3_DEV_SUPPORT_ROCE_DCB_BITS }, + + /* required last entry */ + {0, } +}; + +MODULE_DEVICE_TABLE(pci, hns_roce_ubl_tbl); + +static const struct pci_device_id *get_pci_device_id(struct pci_dev *pci_dev) +{ + const struct pci_device_id *id; + + id = pci_match_id(hns_roce_hw_v2_pci_tbl, pci_dev); + if (id) + return id; + + return pci_match_id(hns_roce_ubl_tbl, pci_dev); +} + static void hns_roce_hw_v2_get_cfg(struct hns_roce_dev *hr_dev, struct hnae3_handle *handle) { @@ -7199,7 +7222,7 @@ static void hns_roce_hw_v2_get_cfg(struct hns_roce_dev *hr_dev, int i;
hr_dev->pci_dev = handle->pdev; - id = pci_match_id(hns_roce_hw_v2_pci_tbl, hr_dev->pci_dev); + id = get_pci_device_id(hr_dev->pci_dev); hr_dev->is_vf = id->driver_data; hr_dev->dev = &handle->pdev->dev; hr_dev->hw = &hns_roce_hw_v2; @@ -7246,8 +7269,9 @@ static bool check_vf_support(struct pci_dev *vf) handle = &hdev->vport[0].roce; hr_dev = handle->priv;
+ /* In UB link vf can not find the pf device */ if (!hr_dev) - return false; + return true;
bond_grp = hns_roce_get_bond_grp(get_hr_netdev(hr_dev, 0), pf->bus->number); @@ -7344,7 +7368,7 @@ static int hns_roce_hw_v2_init_instance(struct hnae3_handle *handle) goto reset_chk_err; }
- id = pci_match_id(hns_roce_hw_v2_pci_tbl, handle->pdev); + id = get_pci_device_id(handle->pdev); if (!id) return 0;
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 8f7838463248..51628ab5bae4 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -732,6 +732,8 @@ static int hns_roce_port_immutable(struct ib_device *ib_dev, u8 port_num,
if (to_hr_dev(ib_dev)->mac_type == HNAE3_MAC_ROH) immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP; + else if (to_hr_dev(ib_dev)->pci_dev->device == HNAE3_DEV_ID_RDMA_OVER_UBL_VF) + immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP; else if (to_hr_dev(ib_dev)->caps.flags & HNS_ROCE_CAP_FLAG_ROCE_V1_V2) immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE | RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP;