Hi Slava, Monday, July 29, 2019 6:27 PM, Viacheslav Ovsiienko: > Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix ESXi VLAN in virtual machine > > On ESXi setups when we have SR-IOV and E-Switch enabled there is the > problem to receive VLAN traffic on VF interfaces. The NIC driver in ESXi > hypervisor does not setup E-Switch vport setting correctly and VLAN traffic > targeted to VF is dropped. > > The patch provides the temporary workaround - if the rule containing the > VLAN pattern is being installed for VF the VLAN network interface over VF is > created, like the command does: > > ip link add link vf.if name mlx5.wa.1.100 type vlan id 100 > > The PMD in DPDK maintains the database of created VLAN interfaces for > each existing VF and requested VLAN tags. When all of the RTE Flows using > the given VLAN tag are removed the created VLAN interface with this VLAN > tag is deleted. > > The name of created VLAN interface follows the format: > > evmlx.d1.d2, where d1 is VF interface ifindex, d2 - VLAN ifindex > > Implementation limitations: > > - mask in rules is ignored, rule must specify VLAN tags exactly, > no wildcards (which are implemented by the masks) are allowed > > - virtual environment is detected via rte_hypervisor() call, > currently it checks the RTE_CPUFLAG_HYPERVISOR flag for x86 > platform. For other architectures workaround always > applied for the Flow over PCI VF > > Signed-off-by: Viacheslav Ovsiienko <viachesl...@mellanox.com> > Acked-by: Matan Azrad <ma...@mellanox.com> > --- > v2: - rebase > v1: - > https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch > es.dpdk.org%2Fpatch%2F56450%2F&data=02%7C01%7Cshahafs%40mel > lanox.com%7C3f213439528840d072f308d714393442%7Ca652971c7d2e4d9ba6 > a4d149256f461b%7C0%7C0%7C637000108243298850&sdata=sXgknK92ce > Xr7QXrdzQU6iUHzFDZZufEGU8Butqst6I%3D&reserved=0 > > drivers/net/mlx5/mlx5.c | 6 + > drivers/net/mlx5/mlx5.h | 30 ++++ > drivers/net/mlx5/mlx5_flow.c | 22 +++ > drivers/net/mlx5/mlx5_flow.h | 5 + > drivers/net/mlx5/mlx5_flow_dv.c | 33 ++++- > drivers/net/mlx5/mlx5_flow_verbs.c | 25 +++- > drivers/net/mlx5/mlx5_nl.c | 279 > +++++++++++++++++++++++++++++++++++++ > 7 files changed, 396 insertions(+), 4 deletions(-) >
[...] > + > +/** > + * Acquire VLAN interface with specified tag for ESXi workaround. > + * > + * @param[in] dev > + * Ethernet device object, Netlink context provider. > + * @param[in] vlan > + * Object representing the network device to acquire. > + */ > +void mlx5_vlan_esxi_acquire(struct rte_eth_dev *dev, > + struct mlx5_vf_vlan *vlan) > +{ > + struct mlx5_priv *priv = dev->data->dev_private; > + struct mlx5_vlan_esxi_context *esxi = priv->esxi_context; > + struct mlx5_vlan_dev *vlan_dev = &esxi->vlan_dev[0]; > + > + assert(!vlan->created); > + assert(priv->esxi_context); > + if (vlan->created || !esxi) > + return; > + if (vlan_dev[vlan->tag].refcnt == 0) { > + assert(!vlan_dev[vlan->tag].ifindex); > + vlan_dev[vlan->tag].ifindex = > + mlx5_vlan_esxi_create(esxi, > + esxi->vf_ifindex, > + vlan->tag); > + } > + if (vlan_dev[vlan->tag].ifindex) { > + vlan_dev[vlan->tag].refcnt++; > + vlan->created = 1; > + } > +} > + > +/* > + * Create per ethernet device VLAN ESXi workaround context */ struct > +mlx5_vlan_esxi_context * mlx5_vlan_esxi_init(struct rte_eth_dev *dev, I would rather avoid the esxi word all over this patch. You cannot know whether other HV do it also. Better to make it generic lke mlx5_vlan_context or what ever other name you prefer. > + uint32_t ifindex) > +{ > + struct mlx5_priv *priv = dev->data->dev_private; > + struct mlx5_dev_config *config = &priv->config; > + struct mlx5_vlan_esxi_context *esxi; > + > + /* Do not engage workaround over PF. */ > + if (!config->vf) > + return NULL; I think the check should be only for VF. The below can be dropped. Because even if the VF is probed on the HV and use legacy switch, still VLAN traffic will not reach the target VF. > + /* Check whether there is virtual environment */ > + if (rte_hypervisor_get() == RTE_HYPERVISOR_NONE) > + return NULL;