Unverified Commit 1789f7b7 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!231 ROH: Support ROH basic functions and adapt ROH mode for RDMA/hns driver

Merge Pull Request from: @chenke1978 
 
[Description]
The ROH module driver consists of the ROH Core and ROH DRV
modules, which work with hardware to implement communication
between nodes through HCCS packets.
ROH Core is a protocol stack of the ROH architecture. It provides
related services for upper layers by invoking operation interfaces
provided by the ROH DRV.
The ROH DRV implements the lower layer functions of the ROH
featureand provides a series of interfaces for operating hardware
for the ROH Core.

This patch supports basic ROH functions, such as: sysfs file node
query, abnormal interrupt handling, reset capability and dfx
information query.

RDMA/hns supports ROH mode, mainly adapted to the device id of ROH,
and the different capabilities and features of RDMA/hns in ROH mode.

[Testing]
kernel options:
CONFIG_ROH=m
CONFIG_ROH_HNS=m

Test passed with below step:
1. Using a hardware environment that supports ROH, insmod net/hns,
 RDMA/hns and ROH related drivers:
 insmod hnae3.ko
 insmod hclge.ko
 insmod hns3.ko
 insmod roh_core.ko
 insmod hns-roh-v1.ko
 insmod hns-roce-hw-v2.ko
2. Check whether ROH generates the corresponding sysfs node:
 ls /sys/class/roh/hns3_0/
3. Check whether the abnormal interrupt information of roh is correct.
 The down or up of the network device link corresponding to roh will
 cause the roh abnormal interrupt count to increase.
 cat /proc/interrupts | grep roh
4. Configure the network port ip and check whether the ip/mac has the
 correct mapping relationship.
5. Query eid to check whether it complies with ip conversion rules:
 cat /sys/class/roh/hns3_0/node_eid
6. Use ping to check Ethernet communication is normal.
7. Use perftest to check RDMA communication is normal.
8. Use the "ethtool --reset eth1 all" command to trigger a reset. 
 
Link:https://gitee.com/openeuler/kernel/pulls/231

 
Reviewed-by: default avatarLing Mingqiang <lingmingqiang@huawei.com>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents e29772f7 abbb9e1d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -955,6 +955,7 @@ struct hns_roce_dev {
	struct hns_roce_hem_table  gmv_table;

	int			cmd_mod;
	u8			mac_type;
	int			loop_idc;
	u32			sdb_offset;
	u32			odb_offset;
+35 −0
Original line number Diff line number Diff line
@@ -476,6 +476,7 @@ static inline int set_ud_wqe(struct hns_roce_qp *qp,
			     void *wqe, unsigned int *sge_idx,
			     unsigned int owner_bit)
{
	struct hns_roce_dev *hr_dev = to_hr_dev(qp->ibqp.device);
	struct hns_roce_ah *ah = to_hr_ah(ud_wr(wr)->ah);
	struct hns_roce_v2_ud_send_wqe *ud_sq_wqe = wqe;
	unsigned int curr_idx = *sge_idx;
@@ -509,6 +510,9 @@ static inline int set_ud_wqe(struct hns_roce_qp *qp,
	if (ret)
		return ret;

	if (hr_dev->mac_type == HNAE3_MAC_ROH && qp->ibqp.qp_type == IB_QPT_GSI)
		ud_sq_wqe->dmac[0] = 0xFF;

	qp->sl = to_hr_ah(ud_wr(wr)->ah)->av.sl;

	set_extend_sge(qp, wr->sg_list, &curr_idx, valid_num_sge);
@@ -2397,6 +2401,28 @@ static int hns_roce_query_pf_caps(struct hns_roce_dev *hr_dev)
	return 0;
}

static void hns_roce_set_mac_type(struct hns_roce_dev *hr_dev)
{
	struct hns_roce_cmq_desc desc;
	int ret;

	if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08)
		return;

	hns_roce_cmq_setup_basic_desc(&desc, HNS_QUERY_MAC_TYPE, true);
	ret = hns_roce_cmq_send(hr_dev, &desc, 1);
	if (ret == CMD_NOT_EXIST)
		return;

	if (ret) {
		dev_err(hr_dev->dev, "failed to get mac mod, ret = %d.\n", ret);
		return;
	}

	if (le32_to_cpu(desc.data[0]))
		hr_dev->mac_type = HNAE3_MAC_ROH;
}

static int config_hem_entry_size(struct hns_roce_dev *hr_dev, u32 type, u32 val)
{
	struct hns_roce_cmq_desc desc;
@@ -3044,6 +3070,8 @@ static int hns_roce_v2_init(struct hns_roce_dev *hr_dev)
	if (ret)
		return ret;

	hns_roce_set_mac_type(hr_dev);

	ret = get_hem_table(hr_dev);
	if (ret)
		return ret;
@@ -3276,6 +3304,8 @@ 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)
				return -EPERM;
			sgid_type = GID_TYPE_FLAG_ROCE_V1;
		}
	}
@@ -6850,6 +6880,11 @@ static const struct pci_device_id hns_roce_hw_v2_pci_tbl[] = {
	{PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_200G_RDMA), 0},
	{PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_RDMA_DCB_PFC_VF),
	 HNAE3_DEV_SUPPORT_ROCE_DCB_BITS},

	{ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_100G_ROH), 0 },
	{ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_200G_ROH), 0 },
	{ PCI_VDEVICE(HUAWEI, HNAE3_DEV_ID_400G_ROH), 0 },

	/* required last entry */
	{0, }
};
+1 −0
Original line number Diff line number Diff line
@@ -226,6 +226,7 @@ enum {
/* CMQ command */
enum hns_roce_opcode_type {
	HNS_QUERY_FW_VER				= 0x0001,
	HNS_QUERY_MAC_TYPE				= 0x0389,
	HNS_ROCE_OPC_QUERY_HW_VER			= 0x8000,
	HNS_ROCE_OPC_CFG_GLOBAL_PARAM			= 0x8001,
	HNS_ROCE_OPC_ALLOC_PF_RES			= 0x8004,
+9 −3
Original line number Diff line number Diff line
@@ -430,6 +430,7 @@ static int hns_roce_alloc_ucontext(struct ib_ucontext *uctx,
	}

	resp.cqe_size = hr_dev->caps.cqe_sz;
	resp.mac_type = hr_dev->mac_type;

	ret = ib_copy_to_udata(udata, &resp,
			       min(udata->outlen, sizeof(resp)));
@@ -511,9 +512,14 @@ static int hns_roce_port_immutable(struct ib_device *ib_dev, u8 port_num,
	immutable->gid_tbl_len = attr.gid_tbl_len;

	immutable->max_mad_size = IB_MGMT_MAD_SIZE;

	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)->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;
	else
		immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE;
	if (to_hr_dev(ib_dev)->caps.flags & HNS_ROCE_CAP_FLAG_ROCE_V1_V2)
		immutable->core_cap_flags |= RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP;

	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -3,5 +3,5 @@
# Makefile for the Linux kernel ROH Core drivers.
#

roh_core-objs := main.o core.o
roh_core-objs := main.o core.o sysfs.o
obj-$(CONFIG_ROH) += roh_core.o
Loading