fix lack of MAC type when set MAC address
cover fix lack of MAC type when set MAC address
Fix lack of MAC type when set MAC address in i40evf and iavf PMD.
Robin Zhang (2):
net/i40e: fix lack of MAC type when set MAC address net/iavf: fix lack of MAC type when set MAC address
drivers/net/i40e/base/virtchnl.h | 29 +++++++++- drivers/net/i40e/i40e_ethdev_vf.c | 91 +++++++++++++++---------------- drivers/net/iavf/iavf.h | 2 +- drivers/net/iavf/iavf_ethdev.c | 16 +++--- drivers/net/iavf/iavf_vchnl.c | 5 +- 5 files changed, 85 insertions(+), 58 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 net/i40e: fix lack of MAC type when set MAC address
Currently, there is no way for a VF driver to specify that it wants to change its device/primary unicast MAC address. This makes it difficult/impossible for the PF driver to track the VF's device/primary unicast MAC address, which is used for VM/VF reboot and displaying on the host. Fix this by using 2 bits of a pad byte in the virtchnl_ether_addr structure so the VF can specify what type of MAC it's adding/deleting.
Below are the values that should be used by all VF drivers going forward.
VIRTCHNL_ETHER_ADDR_LEGACY(0):
- The type should only ever be 0 for legacy AVF drivers (i.e. drivers that don't support the new type bits). The PF drivers will track VF's device/primary unicast MAC using with best effort.
VIRTCHNL_ETHER_ADDR_PRIMARY(1):
- This type should only be used when the VF is changing their device/primary unicast MAC. It should be used for both delete and add cases related to the device/primary unicast MAC.
VIRTCHNL_ETHER_ADDR_EXTRA(2):
- This type should be used when the VF is adding and/or deleting MAC addresses that are not the device/primary unicast MAC. For example, extra unicast addresses and multicast addresses assuming the PF supports "extra" addresses at all.
If a PF is parsing the type field of the virtchnl_ether_addr, then it should use the VIRTCHNL_ETHER_ADDR_TYPE_MASK to mask the first two bits of the type field since 0, 1, and 2 are the only valid values.
For i40evf PMD, when set default MAC address, use type VIRTCHNL_ETHER_ADDR_PRIMARY as this case is changing device/primary unicast MAC. For other cases, such as adding or deleting extra unicast addresses and multicast addresses, use type VIRTCHNL_ETHER_ADDR_EXTRA.
--- drivers/net/i40e/base/virtchnl.h | 29 +++++++++- drivers/net/i40e/i40e_ethdev_vf.c | 91 +++++++++++++++---------------- 2 files changed, 73 insertions(+), 47 deletions(-)
drivers/net/i40e/base/virtchnl.h +28 -1
@@ -402,9 +402,36 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);* PF removes the filters and returns status. */ +/* VIRTCHNL_ETHER_ADDR_LEGACY +* Prior to adding the @type member to virtchnl_ether_addr, there were 2 pad +* bytes. Moving forward all VF drivers should not set type to +* VIRTCHNL_ETHER_ADDR_LEGACY. This is only here to not break previous/legacy +* behavior. The control plane function (i.e. PF) can use a best effort method +* of tracking the primary/device unicast in this case, but there is no +* guarantee and functionality depends on the implementation of the PF. +*/ + +/* VIRTCHNL_ETHER_ADDR_PRIMARY +* All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_PRIMARY for the +* primary/device unicast MAC address filter for VIRTCHNL_OP_ADD_ETH_ADDR and +* VIRTCHNL_OP_DEL_ETH_ADDR. This allows for the underlying control plane +* function (i.e. PF) to accurately track and use this MAC address for +* displaying on the host and for VM/function reset. +*/ + +/* VIRTCHNL_ETHER_ADDR_EXTRA +* All VF drivers should set @type to VIRTCHNL_ETHER_ADDR_EXTRA for any extra +* unicast and/or multicast filters that are being added/deleted via +* VIRTCHNL_OP_DEL_ETH_ADDR/VIRTCHNL_OP_ADD_ETH_ADDR respectively. +*/ struct virtchnl_ether_addr {u8 addr[VIRTCHNL_ETH_LENGTH_OF_ADDRESS ]; -u8 pad[2 ]; +u8 type; +#define VIRTCHNL_ETHER_ADDR_LEGACY 0 +#define VIRTCHNL_ETHER_ADDR_PRIMARY 1 +#define VIRTCHNL_ETHER_ADDR_EXTRA 2 +#define VIRTCHNL_ETHER_ADDR_TYPE_MASK 3/* first two bits of type are valid */ +u8 pad; };VIRTCHNL_CHECK_STRUCT_LEN (8 , virtchnl_ether_addr);
drivers/net/i40e/i40e_ethdev_vf.c +45 -46
171 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/2 net/iavf: fix lack of MAC type when set MAC address
In reply to Robin ZhangWhen set default MAC address, use type VIRTCHNL_ETHER_ADDR_PRIMARY as this case is changing device/primary unicast MAC. For other cases, such as adding or deleting extra unicast addresses and multicast addresses, use type VIRTCHNL_ETHER_ADDR_EXTRA.
--- drivers/net/iavf/iavf.h | 2 +- drivers/net/iavf/iavf_ethdev.c | 16 +++++++--------- drivers/net/iavf/iavf_vchnl.c | 5 ++++- 3 files changed, 12 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf.h +1 -1
@@ -328,7 +328,7 @@ int iavf_query_stats(struct iavf_adapter *adapter,int iavf_config_promisc (struct iavf_adapter *adapter,bool enable_unicast,bool enable_multicast);int iavf_add_del_eth_addr (struct iavf_adapter *adapter, -struct rte_ether_addr *addr,bool add); +struct rte_ether_addr *addr,bool add,uint8_t type);int iavf_add_del_vlan (struct iavf_adapter *adapter,uint16_t vlanid,bool add);int iavf_fdir_add (struct iavf_adapter *adapter,struct iavf_fdir_conf *filter);int iavf_fdir_del (struct iavf_adapter *adapter,struct iavf_fdir_conf *filter);
drivers/net/iavf/iavf_ethdev.c +7 -9
@@ -998,7 +998,7 @@ iavf_dev_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *addr,return -EINVAL ; } - err =iavf_add_del_eth_addr (adapter, addr, true); + err =iavf_add_del_eth_addr (adapter, addr, true,VIRTCHNL_ETHER_ADDR_EXTRA );if (err) {PMD_DRV_LOG (ERR ,"fail to add MAC address" );return -EIO ;
@@ -1020,7 +1020,7 @@ iavf_dev_del_mac_addr(struct rte_eth_dev *dev, uint32_t index) addr = &dev->data->mac_addrs[index]; - err =iavf_add_del_eth_addr (adapter, addr, false); + err =iavf_add_del_eth_addr (adapter, addr, false,VIRTCHNL_ETHER_ADDR_EXTRA );if (err)PMD_DRV_LOG (ERR ,"fail to delete MAC address" );
@@ -1331,17 +1331,15 @@ iavf_dev_set_default_mac_addr(struct rte_eth_dev *dev,struct iavf_adapter *adapter =IAVF_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private);struct iavf_hw *hw =IAVF_DEV_PRIVATE_TO_HW (adapter); -struct rte_ether_addr *perm_addr, *old_addr; +struct rte_ether_addr *old_addr;int ret; old_addr = (struct rte_ether_addr *)hw->mac.addr; - perm_addr = (struct rte_ether_addr *)hw->mac.perm_addr; -/* If the MAC address is configured by host, skip the setting */ -if (rte_is_valid_assigned_ether_addr (perm_addr)) -return -EPERM ; +if (rte_is_same_ether_addr (old_addr, mac_addr)) +return 0 ; - ret =iavf_add_del_eth_addr (adapter, old_addr, false); + ret =iavf_add_del_eth_addr (adapter, old_addr, false,VIRTCHNL_ETHER_ADDR_PRIMARY );if (ret) PMD_DRV_LOG(ERR, "Fail to delete old MAC:" " %02X:%02X:%02X:%02X:%02X:%02X",
@@ -1352,7 +1350,7 @@ iavf_dev_set_default_mac_addr(struct rte_eth_dev *dev, old_addr->addr_bytes[4 ], old_addr->addr_bytes[5]); - ret =iavf_add_del_eth_addr (adapter, mac_addr, true); + ret =iavf_add_del_eth_addr (adapter, mac_addr, true,VIRTCHNL_ETHER_ADDR_PRIMARY );if (ret) PMD_DRV_LOG(ERR, "Fail to add new MAC:" " %02X:%02X:%02X:%02X:%02X:%02X",
drivers/net/iavf/iavf_vchnl.c +4 -1
@@ -1166,6 +1166,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)continue ;rte_memcpy (list->list[j].addr, addr->addr_bytes,sizeof (addr->addr_bytes)); + list->list[j].type =VIRTCHNL_ETHER_ADDR_EXTRA ; PMD_DRV_LOG(DEBUG, "add/rm mac:%x:%x:%x:%x:%x:%x", addr->addr_bytes[0], addr->addr_bytes[1], addr->addr_bytes[2], addr->addr_bytes[3],
@@ -1261,7 +1262,7 @@ iavf_config_promisc(struct iavf_adapter *adapter,int iavf_add_del_eth_addr (struct iavf_adapter *adapter,struct rte_ether_addr *addr, -bool add) +bool add,uint8_t type) {struct virtchnl_ether_addr_list *list;struct iavf_info *vf =IAVF_DEV_PRIVATE_TO_VF (adapter);
@@ -1273,6 +1274,7 @@ iavf_add_del_eth_addr(struct iavf_adapter *adapter, struct rte_ether_addr *addr, list = (struct virtchnl_ether_addr_list *)cmd_buffer; list->vsi_id = vf->vsi_res->vsi_id; list->num_elements =1 ; + list->list[0 ].type = type;rte_memcpy (list->list[0 ].addr, addr->addr_bytes,sizeof (addr->addr_bytes));
@@ -1550,6 +1552,7 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,memcpy (list->list[i].addr, mc_addrs[i].addr_bytes,sizeof (list->list[i].addr)); + list->list[i].type =VIRTCHNL_ETHER_ADDR_EXTRA ; } args.ops = add ?VIRTCHNL_OP_ADD_ETH_ADDR :VIRTCHNL_OP_DEL_ETH_ADDR ;
Signature · 1 line
2.25.1
Quoted 7 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Robin Zhang
Sent: March 19, 2021 17:20
To: Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Zhang, RobinX <[email protected]>
Subject: [dpdk-dev] [PATCH 0/2] fix lack of MAC type when set MAC address
Zhang, Qi Z
AppliedQuoted 21 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Chen, BoX C
Sent: Friday, April 16, 2021 10:03 AM
To: Zhang, RobinX <[email protected]>; Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Xia, YanX <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 0/2] fix lack of MAC type when set MAC addressQuoted 8 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Robin Zhang
Sent: March 19, 2021 17:20
To: Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Wu, Jingjing <[email protected]>
Cc: [email protected]; Zhang, RobinX <[email protected]>
Subject: [dpdk-dev] [PATCH 0/2] fix lack of MAC type when set MAC address
Quoted 1 line
Tested-by Yan Xia <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi