summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/devices/dpdk/device.c42
-rw-r--r--vnet/vnet/devices/dpdk/dpdk.h7
-rw-r--r--vnet/vnet/devices/dpdk/node.c3
3 files changed, 32 insertions, 20 deletions
diff --git a/vnet/vnet/devices/dpdk/device.c b/vnet/vnet/devices/dpdk/device.c
index be54bd27c8d..119d6039f74 100644
--- a/vnet/vnet/devices/dpdk/device.c
+++ b/vnet/vnet/devices/dpdk/device.c
@@ -1165,27 +1165,29 @@ dpdk_subif_add_del_function (vnet_main_t * vnm,
dpdk_device_t *xd = vec_elt_at_index (xm->devices, hw->dev_instance);
vnet_sw_interface_t *t = (vnet_sw_interface_t *) st;
int r, vlan_offload;
- u32 prev_subifs = xd->vlan_subifs;
+ u32 prev_subifs = xd->num_subifs;
+ clib_error_t *err = 0;
if (is_add)
- xd->vlan_subifs++;
- else if (xd->vlan_subifs)
- xd->vlan_subifs--;
+ xd->num_subifs++;
+ else if (xd->num_subifs)
+ xd->num_subifs--;
if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
- return 0;
+ goto done;
/* currently we program VLANS only for IXGBE VF and I40E VF */
if ((xd->pmd != VNET_DPDK_PMD_IXGBEVF) && (xd->pmd != VNET_DPDK_PMD_I40EVF))
- return 0;
+ goto done;
if (t->sub.eth.flags.no_tags == 1)
- return 0;
+ goto done;
if ((t->sub.eth.flags.one_tag != 1) || (t->sub.eth.flags.exact_match != 1))
{
- xd->vlan_subifs = prev_subifs;
- return clib_error_return (0, "unsupported VLAN setup");
+ xd->num_subifs = prev_subifs;
+ err = clib_error_return (0, "unsupported VLAN setup");
+ goto done;
}
vlan_offload = rte_eth_dev_get_vlan_offload (xd->device_index);
@@ -1193,9 +1195,10 @@ dpdk_subif_add_del_function (vnet_main_t * vnm,
if ((r = rte_eth_dev_set_vlan_offload (xd->device_index, vlan_offload)))
{
- xd->vlan_subifs = prev_subifs;
- return clib_error_return (0, "rte_eth_dev_set_vlan_offload[%d]: err %d",
- xd->device_index, r);
+ xd->num_subifs = prev_subifs;
+ err = clib_error_return (0, "rte_eth_dev_set_vlan_offload[%d]: err %d",
+ xd->device_index, r);
+ goto done;
}
@@ -1203,12 +1206,19 @@ dpdk_subif_add_del_function (vnet_main_t * vnm,
rte_eth_dev_vlan_filter (xd->device_index, t->sub.eth.outer_vlan_id,
is_add)))
{
- xd->vlan_subifs = prev_subifs;
- return clib_error_return (0, "rte_eth_dev_vlan_filter[%d]: err %d",
- xd->device_index, r);
+ xd->num_subifs = prev_subifs;
+ err = clib_error_return (0, "rte_eth_dev_vlan_filter[%d]: err %d",
+ xd->device_index, r);
+ goto done;
}
- return 0;
+done:
+ if (xd->num_subifs)
+ xd->flags |= DPDK_DEVICE_FLAG_HAVE_SUBIF;
+ else
+ xd->flags &= ~DPDK_DEVICE_FLAG_HAVE_SUBIF;
+
+ return err;
}
/* *INDENT-OFF* */
diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h
index 025ebf4c234..2cb301ce291 100644
--- a/vnet/vnet/devices/dpdk/dpdk.h
+++ b/vnet/vnet/devices/dpdk/dpdk.h
@@ -203,9 +203,6 @@ typedef struct
/* vector of traced contexts, per device */
u32 *d_trace_buffers;
- /* number of sub-interfaces */
- u16 vlan_subifs;
-
dpdk_pmd_t pmd:8;
i8 cpu_socket;
@@ -215,11 +212,15 @@ typedef struct
#define DPDK_DEVICE_FLAG_PMD (1 << 2)
#define DPDK_DEVICE_FLAG_KNI (1 << 3)
#define DPDK_DEVICE_FLAG_VHOST_USER (1 << 4)
+#define DPDK_DEVICE_FLAG_HAVE_SUBIF (1 << 5)
CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
u8 *interface_name_suffix;
+ /* number of sub-interfaces */
+ u16 num_subifs;
+
/* PMD related */
u16 tx_q_used;
u16 rx_q_used;
diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c
index 5852b3dcffe..a9e286e56eb 100644
--- a/vnet/vnet/devices/dpdk/node.c
+++ b/vnet/vnet/devices/dpdk/node.c
@@ -121,7 +121,8 @@ dpdk_rx_next_and_error_from_mb_flags_x1 (dpdk_device_t * xd,
HANDOFF_DISPATCH_NEXT_ETHERNET_INPUT;
}
else
- if (PREDICT_FALSE (xd->vlan_subifs || (mb_flags & PKT_RX_VLAN_PKT)))
+ if (PREDICT_FALSE ((xd->flags & DPDK_DEVICE_FLAG_HAVE_SUBIF) ||
+ (mb_flags & PKT_RX_VLAN_PKT)))
n0 = DPDK_RX_NEXT_ETHERNET_INPUT;
else
{