Commit 46685dc2 authored by Ke Chen's avatar Ke Chen Committed by Jiantao Xiao
Browse files

net: hns3: add ROH MAC type definitions and support query MAC type

driver inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9A3QT


CVE: NA

----------------------------------------------------------------------

HNAE3 framework add MAC type definitions for NIC or RoCE or ROH clients.

There are two types of MAC in Hip09, ethernet and ROH. In ROH
type, some operations are different, such as setting MAC address.
This type will be used as the judgment condition in subsequent
patches.

Signed-off-by: default avatarYufeng Mo <moyufeng@huawei.com>
Signed-off-by: default avatarKe Chen <chenke54@huawei.com>
Reviewed-by: default avatarGang Zhang <gang.zhang@huawei.com>
Reviewed-by: default avatarYefeng Yan <yanyefeng@huawei.com>
Reviewed-by: default avatarJingchao Dai <daijingchao1@huawei.com>
Reviewed-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarJiantao Xiao <xiaojiantao1@h-partners.com>
parent 4aef02ae
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -231,6 +231,11 @@ enum hnae3_client_type {
	HNAE3_CLIENT_ROCE,
};

enum hnae3_mac_type {
	HNAE3_MAC_ETH,
	HNAE3_MAC_ROH,
};

/* mac media type */
enum hnae3_media_type {
	HNAE3_MEDIA_TYPE_UNKNOWN,
@@ -939,6 +944,10 @@ struct hnae3_handle {

	unsigned long supported_pflags;
	unsigned long priv_flags;

	enum hnae3_mac_type mac_type;

	unsigned long link_change_assert_time;
};

#define hnae3_set_field(origin, mask, shift, val) \
@@ -953,6 +962,11 @@ struct hnae3_handle {
#define hnae3_get_bit(origin, shift) \
	hnae3_get_field(origin, 0x1 << (shift), shift)

static inline bool hnae3_check_roh_mac_type(struct hnae3_handle *handle)
{
	return handle->mac_type == HNAE3_MAC_ROH;
}

#define HNAE3_FORMAT_MAC_ADDR_LEN	18
#define HNAE3_FORMAT_MAC_ADDR_OFFSET_0	0
#define HNAE3_FORMAT_MAC_ADDR_OFFSET_4	4
+17 −1
Original line number Diff line number Diff line
@@ -387,6 +387,16 @@ static int hclge_dbg_dump_mac_speed_duplex(struct hclge_dev *hdev, char *buf,
	return 0;
}

static void hclge_dbg_dump_mac_type(struct hclge_dev *hdev, char *buf, int len,
				    int *pos)
{
	struct hclge_vport *vport = &hdev->vport[0];
	struct hnae3_handle *handle = &vport->nic;

	*pos += scnprintf(buf + *pos, len - *pos, "type: %s\n",
			  handle->mac_type ? "ROH" : "Ethernet");
}

static int hclge_dbg_dump_mac(struct hclge_dev *hdev, char *buf, int len)
{
	int pos = 0;
@@ -400,7 +410,13 @@ static int hclge_dbg_dump_mac(struct hclge_dev *hdev, char *buf, int len)
	if (ret)
		return ret;

	return hclge_dbg_dump_mac_speed_duplex(hdev, buf, len, &pos);
	ret = hclge_dbg_dump_mac_speed_duplex(hdev, buf, len, &pos);
	if (ret)
		return ret;

	hclge_dbg_dump_mac_type(hdev, buf, len, &pos);

	return 0;
}

static int hclge_dbg_dump_dcb_qset(struct hclge_dev *hdev, char *buf, int len,
+16 −0
Original line number Diff line number Diff line
@@ -1479,6 +1479,20 @@ static int hclge_query_dev_specs(struct hclge_dev *hdev)
	return 0;
}

static void hclge_mac_type_init(struct hclge_dev *hdev)
{
	struct hclge_vport *vport = &hdev->vport[0];
	struct hnae3_handle *handle = &vport->nic;
	u32 dev_id = hdev->pdev->device;

	if (dev_id == HNAE3_DEV_ID_100G_ROH ||
	    dev_id == HNAE3_DEV_ID_200G_ROH ||
	    dev_id == HNAE3_DEV_ID_400G_ROH)
		handle->mac_type = HNAE3_MAC_ROH;
	else
		handle->mac_type = HNAE3_MAC_ETH;
}

static int hclge_get_cap(struct hclge_dev *hdev)
{
	int ret;
@@ -2946,6 +2960,8 @@ static int hclge_mac_init(struct hclge_dev *hdev)
	struct hclge_mac *mac = &hdev->hw.mac;
	int ret;

	hclge_roh_convert_mac_addr(hdev);
	hclge_mac_type_init(hdev);
	hdev->support_sfp_query = true;

	if (!test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state))