diff options
Diffstat (limited to 'vnet')
-rw-r--r-- | vnet/vnet/devices/dpdk/cli.c | 2 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/device.c | 20 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/dpdk.h | 16 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/dpdk_priv.h | 2 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/format.c | 14 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/init.c | 8 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/node.c | 6 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/vhost_user.c | 10 |
8 files changed, 36 insertions, 42 deletions
diff --git a/vnet/vnet/devices/dpdk/cli.c b/vnet/vnet/devices/dpdk/cli.c index f257a8bb892..2ffb95884d3 100644 --- a/vnet/vnet/devices/dpdk/cli.c +++ b/vnet/vnet/devices/dpdk/cli.c @@ -713,7 +713,7 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input, hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); - if (xd->dev_type != VNET_DPDK_DEV_ETH) + if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0) return clib_error_return (0, "number of descriptors can be set only for " "physical devices"); diff --git a/vnet/vnet/devices/dpdk/device.c b/vnet/vnet/devices/dpdk/device.c index 2ccfcdaa148..be54bd27c8d 100644 --- a/vnet/vnet/devices/dpdk/device.c +++ b/vnet/vnet/devices/dpdk/device.c @@ -323,7 +323,7 @@ static_always_inline * This device only supports one TX queue, * and we're running multi-threaded... */ - if (PREDICT_FALSE (xd->dev_type != VNET_DPDK_DEV_VHOST_USER && + if (PREDICT_FALSE ((xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) == 0 && xd->lockp != 0)) { queue_id = queue_id % xd->tx_q_used; @@ -332,7 +332,7 @@ static_always_inline queue_id = (queue_id + 1) % xd->tx_q_used; } - if (PREDICT_TRUE (xd->dev_type == VNET_DPDK_DEV_ETH)) + if (PREDICT_TRUE (xd->flags & DPDK_DEVICE_FLAG_PMD)) { if (PREDICT_TRUE (tx_head > tx_tail)) { @@ -366,7 +366,7 @@ static_always_inline } } #if DPDK_VHOST_USER - else if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER) + else if (xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) { u32 offset = 0; if (xd->need_txlock) @@ -484,7 +484,7 @@ static_always_inline } #endif #if RTE_LIBRTE_KNI - else if (xd->dev_type == VNET_DPDK_DEV_KNI) + else if (xd->flags & DPDK_DEVICE_FLAG_KNI) { if (PREDICT_TRUE (tx_head > tx_tail)) { @@ -522,7 +522,7 @@ static_always_inline rv = 0; } - if (PREDICT_FALSE (xd->dev_type != VNET_DPDK_DEV_VHOST_USER && + if (PREDICT_FALSE ((xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) == 0 && xd->lockp != 0)) *xd->lockp[queue_id] = 0; @@ -919,7 +919,7 @@ dpdk_device_renumber (vnet_hw_interface_t * hi, u32 new_dev_instance) dpdk_main_t *dm = &dpdk_main; dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance); - if (!xd || xd->dev_type != VNET_DPDK_DEV_VHOST_USER) + if (!xd || (xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) == 0) { clib_warning ("cannot renumber non-vhost-user interface (sw_if_index: %d)", @@ -950,7 +950,7 @@ dpdk_clear_hw_interface_counters (u32 instance) sizeof (xd->last_cleared_xstats[0])); #if DPDK_VHOST_USER - if (PREDICT_FALSE (xd->dev_type == VNET_DPDK_DEV_VHOST_USER)) + if (PREDICT_FALSE (xd->flags & DPDK_DEVICE_FLAG_VHOST_USER)) { int i; for (i = 0; i < xd->rx_q_used * VIRTIO_QNUM; i++) @@ -1025,7 +1025,7 @@ dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags) int rv = 0; #ifdef RTE_LIBRTE_KNI - if (xd->dev_type == VNET_DPDK_DEV_KNI) + if (xd->flags & DPDK_DEVICE_FLAG_KNI) { if (is_up) { @@ -1066,7 +1066,7 @@ dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags) } #endif #if DPDK_VHOST_USER - if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER) + if (xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) { if (is_up) { @@ -1172,7 +1172,7 @@ dpdk_subif_add_del_function (vnet_main_t * vnm, else if (xd->vlan_subifs) xd->vlan_subifs--; - if (xd->dev_type != VNET_DPDK_DEV_ETH) + if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0) return 0; /* currently we program VLANS only for IXGBE VF and I40E VF */ diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h index e7c177b9329..025ebf4c234 100644 --- a/vnet/vnet/devices/dpdk/dpdk.h +++ b/vnet/vnet/devices/dpdk/dpdk.h @@ -75,14 +75,6 @@ extern vnet_device_class_t dpdk_device_class; extern vlib_node_registration_t dpdk_input_node; extern vlib_node_registration_t handoff_dispatch_node; -typedef enum -{ - VNET_DPDK_DEV_ETH = 1, /* Standard DPDK PMD driver */ - VNET_DPDK_DEV_KNI, /* Kernel NIC Interface */ - VNET_DPDK_DEV_VHOST_USER, - VNET_DPDK_DEV_UNKNOWN, /* must be last */ -} dpdk_device_type_t; - #define foreach_dpdk_pmd \ _ ("rte_nicvf_pmd", THUNDERX) \ _ ("rte_em_pmd", E1000EM) \ @@ -214,13 +206,15 @@ typedef struct /* number of sub-interfaces */ u16 vlan_subifs; - dpdk_device_type_t dev_type:8; dpdk_pmd_t pmd:8; i8 cpu_socket; u16 flags; -#define DPDK_DEVICE_FLAG_ADMIN_UP (1 << 0) -#define DPDK_DEVICE_FLAG_PROMISC (1 << 1) +#define DPDK_DEVICE_FLAG_ADMIN_UP (1 << 0) +#define DPDK_DEVICE_FLAG_PROMISC (1 << 1) +#define DPDK_DEVICE_FLAG_PMD (1 << 2) +#define DPDK_DEVICE_FLAG_KNI (1 << 3) +#define DPDK_DEVICE_FLAG_VHOST_USER (1 << 4) CLIB_CACHE_LINE_ALIGN_MARK (cacheline1); diff --git a/vnet/vnet/devices/dpdk/dpdk_priv.h b/vnet/vnet/devices/dpdk/dpdk_priv.h index 0abe6306c89..fd4f2d7ed0b 100644 --- a/vnet/vnet/devices/dpdk/dpdk_priv.h +++ b/vnet/vnet/devices/dpdk/dpdk_priv.h @@ -88,7 +88,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now) u64 rxerrors, last_rxerrors; /* only update counters for PMD interfaces */ - if (xd->dev_type != VNET_DPDK_DEV_ETH) + if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0) return; xd->time_last_stats_update = now ? now : xd->time_last_stats_update; diff --git a/vnet/vnet/devices/dpdk/format.c b/vnet/vnet/devices/dpdk/format.c index 1f401a9e01b..ef7ee0e7853 100644 --- a/vnet/vnet/devices/dpdk/format.c +++ b/vnet/vnet/devices/dpdk/format.c @@ -166,14 +166,14 @@ format_dpdk_device_name (u8 * s, va_list * args) devname_format = "%s%x/%x/%x"; #ifdef RTE_LIBRTE_KNI - if (dm->devices[i].dev_type == VNET_DPDK_DEV_KNI) + if (dm->devices[i].flags & DPDK_DEVICE_FLAG_KNI) { return format (s, "kni%d", dm->devices[i].kni_port_id); } else #endif #if DPDK_VHOST_USER - if (dm->devices[i].dev_type == VNET_DPDK_DEV_VHOST_USER) + if (dm->devices[i].flags & DPDK_DEVICE_FLAG_VHOST_USER) { return format (s, "VirtualEthernet0/0/%d", dm->devices[i].vu_if_id); } @@ -226,11 +226,11 @@ format_dpdk_device_type (u8 * s, va_list * args) char *dev_type; u32 i = va_arg (*args, u32); - if (dm->devices[i].dev_type == VNET_DPDK_DEV_KNI) + if (dm->devices[i].flags & DPDK_DEVICE_FLAG_KNI) { return format (s, "Kernel NIC Interface"); } - else if (dm->devices[i].dev_type == VNET_DPDK_DEV_VHOST_USER) + else if (dm->devices[i].flags & DPDK_DEVICE_FLAG_VHOST_USER) { return format (s, "vhost-user interface"); } @@ -401,7 +401,7 @@ format_dpdk_device (u8 * s, va_list * args) rte_eth_dev_info_get (xd->device_index, &di); - if (verbose > 1 && xd->dev_type == VNET_DPDK_DEV_ETH) + if (verbose > 1 && xd->flags & DPDK_DEVICE_FLAG_PMD) { struct rte_pci_device *pci; struct rte_eth_rss_conf rss_conf; @@ -455,7 +455,7 @@ format_dpdk_device (u8 * s, va_list * args) format_dpdk_rss_hf_name, di.flow_type_rss_offloads); } - if (verbose && xd->dev_type == VNET_DPDK_DEV_VHOST_USER) + if (verbose && xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) { s = format (s, "%Uqueue size (max): rx %d (%d) tx %d (%d)\n", format_white_space, indent + 2, @@ -527,7 +527,7 @@ format_dpdk_device (u8 * s, va_list * args) #endif #if DPDK_VHOST_USER - if (verbose && xd->dev_type == VNET_DPDK_DEV_VHOST_USER) + if (verbose && xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) { int i; for (i = 0; i < xd->rx_q_used * VIRTIO_QNUM; i++) diff --git a/vnet/vnet/devices/dpdk/init.c b/vnet/vnet/devices/dpdk/init.c index 7b657209ccb..a2cc8849f41 100644 --- a/vnet/vnet/devices/dpdk/init.c +++ b/vnet/vnet/devices/dpdk/init.c @@ -405,7 +405,7 @@ dpdk_lib_init (dpdk_main_t * dm) else xd->rx_q_used = 1; - xd->dev_type = VNET_DPDK_DEV_ETH; + xd->flags |= DPDK_DEVICE_FLAG_PMD; /* workaround for drivers not setting driver_name */ if ((!dev_info.driver_name) && (dev_info.pci_dev)) @@ -755,7 +755,7 @@ dpdk_lib_init (dpdk_main_t * dm) /* Create vnet interface */ vec_add2_aligned (dm->devices, xd, 1, CLIB_CACHE_LINE_BYTES); - xd->dev_type = VNET_DPDK_DEV_KNI; + xd->flags |= DPDK_DEVICE_FLAG_KNI; xd->device_index = xd - dm->devices; ASSERT (nports + i == xd->device_index); @@ -1458,7 +1458,7 @@ dpdk_update_link_state (dpdk_device_t * xd, f64 now) u8 hw_flags_chg = 0; /* only update link state for PMD interfaces */ - if (xd->dev_type != VNET_DPDK_DEV_ETH) + if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0) return; xd->time_last_link_update = now ? now : xd->time_last_link_update; @@ -1757,7 +1757,7 @@ dpdk_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) dpdk_update_link_state (xd, now); #if DPDK_VHOST_USER - if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER) + if (xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) if (dpdk_vhost_user_process_if (vm, xd, vu_state) != 0) continue; #endif diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c index 54a6a503cd0..5852b3dcffe 100644 --- a/vnet/vnet/devices/dpdk/node.c +++ b/vnet/vnet/devices/dpdk/node.c @@ -287,7 +287,7 @@ dpdk_rx_burst (dpdk_main_t * dm, dpdk_device_t * xd, u16 queue_id) n_left = VLIB_FRAME_SIZE; n_buffers = 0; - if (PREDICT_TRUE (xd->dev_type == VNET_DPDK_DEV_ETH)) + if (PREDICT_TRUE (xd->flags & DPDK_DEVICE_FLAG_PMD)) { while (n_left) { @@ -303,7 +303,7 @@ dpdk_rx_burst (dpdk_main_t * dm, dpdk_device_t * xd, u16 queue_id) } } #if DPDK_VHOST_USER - else if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER) + else if (xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) { vlib_main_t *vm = vlib_get_main (); vlib_buffer_main_t *bm = vm->buffer_main; @@ -367,7 +367,7 @@ dpdk_rx_burst (dpdk_main_t * dm, dpdk_device_t * xd, u16 queue_id) } #endif #ifdef RTE_LIBRTE_KNI - else if (xd->dev_type == VNET_DPDK_DEV_KNI) + else if (xd->flags & DPDK_DEVICE_FLAG_KNI) { n_buffers = rte_kni_rx_burst (xd->kni, xd->rx_vectors[queue_id], VLIB_FRAME_SIZE); diff --git a/vnet/vnet/devices/dpdk/vhost_user.c b/vnet/vnet/devices/dpdk/vhost_user.c index 58cff7b940f..f8910ad65d7 100644 --- a/vnet/vnet/devices/dpdk/vhost_user.c +++ b/vnet/vnet/devices/dpdk/vhost_user.c @@ -137,7 +137,7 @@ dpdk_vhost_user_device_from_hw_if_index (u32 hw_if_index) vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index); dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance); - if (xd->dev_type != VNET_DPDK_DEV_VHOST_USER) + if ((xd->flags DPDK_DEVICE_FLAG_VHOST_USER) == 0) return 0; return xd; @@ -221,7 +221,7 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id, u8 * hwaddr) if (vec_len (dm->devices) > vui_idx) { xd = vec_elt_at_index (dm->devices, vui_idx); - if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER) + if (xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) { DBG_SOCK ("reusing inactive vhost-user interface sw_if_index %d", @@ -283,7 +283,7 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id, u8 * hwaddr) { // vui was not retrieved from inactive ifaces - create new vec_add2_aligned (dm->devices, xd, 1, CLIB_CACHE_LINE_BYTES); - xd->dev_type = VNET_DPDK_DEV_VHOST_USER; + xd->flags |= DPDK_DEVICE_FLAG_VHOST_USER; xd->rx_q_used = num_qpairs; xd->tx_q_used = num_qpairs; xd->vu_vhost_dev.virt_qp_nb = num_qpairs; @@ -1661,7 +1661,7 @@ dpdk_vhost_user_dump_ifs (vnet_main_t * vnm, vlib_main_t * vm, vec_foreach (xd, dm->devices) { - if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER && xd->vu_intf->active) + if ((xd->flags & DPDK_DEVICE_FLAG_VHOST_USER) && xd->vu_intf->active) vec_add1 (hw_if_indices, xd->vlib_hw_if_index); } @@ -1988,7 +1988,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm, { vec_foreach (xd, dm->devices) { - if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER && xd->vu_intf->active) + if ((xd->flags DPDK_DEVICE_FLAG_VHOST_USER) && xd->vu_intf->active) vec_add1 (hw_if_indices, xd->vlib_hw_if_index); } } |