Skip to content

Commit

Permalink
net/i40e: enable VF to program MAC address
Browse files Browse the repository at this point in the history
Due to the restriction of the flag I40E_FLAG_VF_MAC_BY_PF,
VF cannot program the MAC address.
In order to solve this inflexibility, the use of I40E_FLAG_VF_MAC_BY_PF
has been deleted in the code implementation to ensure that
VF can flexibly program the MAC address.

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
  • Loading branch information
Guinan Sun authored and Ferruh Yigit committed Apr 21, 2020
1 parent 2adbcce commit 34283fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
4 changes: 1 addition & 3 deletions drivers/net/i40e/i40e_ethdev.h
Expand Up @@ -124,7 +124,6 @@ enum i40e_flxpld_layer_idx {
#define I40E_FLAG_FDIR (1ULL << 6)
#define I40E_FLAG_VXLAN (1ULL << 7)
#define I40E_FLAG_RSS_AQ_CAPABLE (1ULL << 8)
#define I40E_FLAG_VF_MAC_BY_PF (1ULL << 9)
#define I40E_FLAG_ALL (I40E_FLAG_RSS | \
I40E_FLAG_DCB | \
I40E_FLAG_VMDQ | \
Expand All @@ -133,8 +132,7 @@ enum i40e_flxpld_layer_idx {
I40E_FLAG_HEADER_SPLIT_ENABLED | \
I40E_FLAG_FDIR | \
I40E_FLAG_VXLAN | \
I40E_FLAG_RSS_AQ_CAPABLE | \
I40E_FLAG_VF_MAC_BY_PF)
I40E_FLAG_RSS_AQ_CAPABLE)

#define I40E_RSS_OFFLOAD_ALL ( \
ETH_RSS_FRAG_IPV4 | \
Expand Down
8 changes: 1 addition & 7 deletions drivers/net/i40e/i40e_ethdev_vf.c
Expand Up @@ -1309,10 +1309,8 @@ i40evf_init_vf(struct rte_eth_dev *dev)
vf->vsi.adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);

/* Store the MAC address configured by host, or generate random one */
if (rte_is_valid_assigned_ether_addr(
if (!rte_is_valid_assigned_ether_addr(
(struct rte_ether_addr *)hw->mac.addr))
vf->flags |= I40E_FLAG_VF_MAC_BY_PF;
else
rte_eth_random_addr(hw->mac.addr); /* Generate a random one */

I40E_WRITE_REG(hw, I40E_VFINT_DYN_CTL01,
Expand Down Expand Up @@ -2780,17 +2778,13 @@ static int
i40evf_set_default_mac_addr(struct rte_eth_dev *dev,
struct rte_ether_addr *mac_addr)
{
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);

if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
PMD_DRV_LOG(ERR, "Tried to set invalid MAC address.");
return -EINVAL;
}

if (vf->flags & I40E_FLAG_VF_MAC_BY_PF)
return -EPERM;

i40evf_del_mac_addr_by_addr(dev, (struct rte_ether_addr *)hw->mac.addr);

if (i40evf_add_mac_addr(dev, mac_addr, 0, 0) != 0)
Expand Down

0 comments on commit 34283fc

Please sign in to comment.