From 08ac303e43492c8b25911340fb62811289dd3935 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Mon, 15 Jul 2019 01:04:11 -0700 Subject: dpdk: fix vlan stripping Type: fix Fixes: ce3e971 Change-Id: I30bbeced2f5ae7613e65546f2b9b41e2fb514208 Signed-off-by: Damjan Marion --- src/plugins/dpdk/device/init.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index d15f5bf4774..07cbbf99725 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -266,7 +266,7 @@ dpdk_lib_init (dpdk_main_t * dm) RTE_ETH_FOREACH_DEV(i) { u8 addr[6]; - u8 vlan_strip = 0; + int vlan_off; struct rte_eth_dev_info dev_info; struct rte_pci_device *pci_dev; struct rte_eth_link l; @@ -778,22 +778,26 @@ dpdk_lib_init (dpdk_main_t * dm) * VLAN stripping: default to VLAN strip disabled, unless specified * otherwise in the startup config. */ - if (devconf->vlan_strip_offload == DPDK_DEVICE_VLAN_STRIP_ON) - vlan_strip = 1; - if (vlan_strip) + vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id); + if (devconf->vlan_strip_offload == DPDK_DEVICE_VLAN_STRIP_ON) { - int vlan_off; - vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id); vlan_off |= ETH_VLAN_STRIP_OFFLOAD; - if (vlan_off) - xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; - else - xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; - if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) == 0) + if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0) dpdk_log_info ("VLAN strip enabled for interface\n"); else dpdk_log_warn ("VLAN strip cannot be supported by interface\n"); + xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; + } + else + { + if (vlan_off & ETH_VLAN_STRIP_OFFLOAD) + { + vlan_off &= ~ETH_VLAN_STRIP_OFFLOAD; + if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0) + dpdk_log_warn ("set VLAN offload failed\n"); + } + xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; } if (hi) -- cgit 1.2.3-korg