Commit a1799222 authored by Junxin Chen's avatar Junxin Chen Committed by Fengyan
Browse files

UNIC: Support using MC GUID and table management

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


CVE: NA

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

The MC guid is designed to send ub network control packets
to the peer end without knowing the peer guid. The packets
whose destination address is the MC guid can be sent to all
ports that support the MC guid. It is defined as 112-bit 1
and 16-bit protocol. Therefore, the valid data of the MC guid
is the last 16 bits. If the peer end supports an MC guid, it
indicates that the packets of the corresponding protocol
can be processed.

The driver implements a new .set_rx_mode for the ub to reuse
the ip maddr adding and deleting interfaces. Because the
original interface supports only an 8-byte address, only
the lower 64 bits of the mc guid can be configured. In addition,
the upper 48 bits of the 64 bits must be 1.

In terms of hardware entry management, hardware entries are
limited and one entry can be shared by multiple functions.
Therefore, entries are managed by checking whether the entry
exists before being added. In addition, promiscuous entries
are enabled when the number of entries is full. In addition,
for security purposes, hardware entries cannot be configured
for virtual functions.

Signed-off-by: default avatarJunxin Chen <chenjunxin1@huawei.com>
Signed-off-by: default avatarHaibin Lu <luhaibin10@hisilicon.com>
parent 1cdab773
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ enum HCLGE_MBX_OPCODE {
	HCLGE_MBX_SET_QB = 0x28,        /* (VF -> PF) set queue bonding */
	HCLGE_MBX_PUSH_QB_STATE,        /* (PF -> VF) push qb state */

	HCLGE_UNIC_MBX_SET_IP = 0x51,	/* (VF -> PF) set ip addr */
	HCLGE_MBX_SET_MGUID = 0x50,	/* (VF -> PF) set mc guid */
	HCLGE_UNIC_MBX_SET_IP,		/* (VF -> PF) set ip addr */

	HCLGE_MBX_GET_VF_FLR_STATUS = 200, /* (M7 -> PF) get vf flr status */
	HCLGE_MBX_PUSH_LINK_STATUS,	/* (M7 -> PF) get port link status */
@@ -83,6 +84,12 @@ enum hclge_mbx_vlan_cfg_subcode {
	HCLGE_MBX_ENABLE_VLAN_FILTER,
};

/* below are per-VF mc guid subcodes */
enum hclge_mbx_mc_guid_subcode {
	HCLGE_MBX_MC_GUID_MC_ADD = 0,		/* add new MC guid addr */
	HCLGE_MBX_MC_GUID_MC_DELETE,		/* delete MC guid addr */
};

enum hclge_mbx_tbl_cfg_subcode {
	HCLGE_MBX_VPORT_LIST_CLEAR,
};
+2 −1
Original line number Diff line number Diff line
@@ -952,7 +952,8 @@ struct hnae3_udma_private_info {
#define HNAE3_BPE		BIT(2)	/* broadcast promisc enable */
#define HNAE3_OVERFLOW_UPE	BIT(3)	/* unicast mac vlan overflow */
#define HNAE3_OVERFLOW_MPE	BIT(4)	/* multicast mac vlan overflow */
#define HNAE3_UPE		(HNAE3_USER_UPE | HNAE3_OVERFLOW_UPE)
#define HNAE3_OVERFLOW_MGP	BIT(5)	/* multicast guid overflow */
#define HNAE3_UPE		(HNAE3_USER_UPE | HNAE3_OVERFLOW_UPE | HNAE3_OVERFLOW_MGP)
#define HNAE3_MPE		(HNAE3_USER_MPE | HNAE3_OVERFLOW_MPE)

enum hnae3_pflag {
+1 −0
Original line number Diff line number Diff line
@@ -316,6 +316,7 @@ enum hclge_opcode_type {
	HCLGE_OPC_ADD_IP_TBL		= 0xA100,
	HCLGE_OPC_DEL_IP_TBL		= 0xA101,
	HCLGE_OPC_COMM_CFG_FUNC_GUID	= 0xA122,
	HCLGE_OPC_CFG_MC_GUID_CMD	= 0xA123,
};

enum hclge_comm_cmd_return_status {
+14 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ struct hclge_comm_unic_addr_node {
	enum HCLGE_COMM_ADDR_NODE_STATE state;
	union {
		u8 unic_addr[UNIC_ADDR_LEN];
		u8 mguid[UBL_ALEN];
		struct {
			u8 prefix[HCLGE_COMM_MGUID_PREFIX_LEN];
			__le16 proto;
@@ -62,6 +63,19 @@ struct hclge_comm_func_guid_cmd {
	__le16 rsv3;
};

#define HCLGE_COMM_FORMAT_GUID_ADDR_LEN		48
#define HCLGE_COMM_FORMAT_GUID_ADDR_PROTO_HIGH	14
#define HCLGE_COMM_FORMAT_GUID_ADDR_PROTO_LOW	15

static inline void hclge_comm_format_guid_addr(char *format_guid_addr,
					       const u8 *guid_addr)
{
	snprintf(format_guid_addr, HCLGE_COMM_FORMAT_GUID_ADDR_LEN,
		 "ff:ff:**:**:**:**:**:**:**:**:**:**:**:**:%02x:%02x",
		 guid_addr[HCLGE_COMM_FORMAT_GUID_ADDR_PROTO_HIGH],
		 guid_addr[HCLGE_COMM_FORMAT_GUID_ADDR_PROTO_LOW]);
}

static inline bool hclge_comm_unic_addr_equal(const u8 *addr1, const u8 *addr2)
{
	const u32 *a = (const u32 *)addr1;
+3 −1
Original line number Diff line number Diff line
@@ -3288,7 +3288,9 @@ const struct net_device_ops hns3_unic_netdev_ops = {
	.ndo_features_check	= hns3_features_check,
	.ndo_get_stats64	= hns3_nic_get_stats64,
	.ndo_setup_tc		= hns3_nic_setup_tc,
	.ndo_set_rx_mode	= hns3_nic_set_rx_mode,
#ifdef CONFIG_HNS3_UBL
	.ndo_set_rx_mode	= hns3_unic_set_rx_mode,
#endif
	.ndo_set_vf_trust	= hns3_set_vf_trust,
#ifdef CONFIG_RFS_ACCEL
	.ndo_rx_flow_steer	= hns3_rx_flow_steer,
Loading