#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
-#ifdef RTE_LIBRTE_KNI
-#include <rte_kni.h>
-#endif
#include <rte_virtio_net.h>
-#include <rte_pci_dev_ids.h>
#include <rte_version.h>
#include <rte_eth_bond.h>
+#include <rte_sched.h>
#include <vnet/unix/pcap.h>
-#include <vnet/devices/virtio/vhost-user.h>
#if CLIB_DEBUG > 0
#define always_inline static inline
#define always_inline static inline __attribute__ ((__always_inline__))
#endif
-#if RTE_VERSION < RTE_VERSION_NUM(16, 7, 0, 0)
-#define DPDK_VHOST_USER 1
-#else
-#define DPDK_VHOST_USER 0
-#endif
-
#include <vlib/pci/pci.h>
#define NB_MBUF (16<<10)
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) \
u32 total_packet_cnt;
} dpdk_efd_agent_t;
-#if DPDK_VHOST_USER
-typedef struct
-{
- int callfd;
- int kickfd;
- int errfd;
- int enabled;
- u32 callfd_idx;
- u32 n_since_last_int;
- f64 int_deadline;
- u64 packets;
- u64 bytes;
-} dpdk_vu_vring;
-
-typedef struct
-{
- u32 is_up;
- u32 unix_fd;
- u32 unix_file_index;
- u32 client_fd;
- char sock_filename[256];
- int sock_errno;
- u8 sock_is_server;
- u8 active;
-
- u64 feature_mask;
- u32 num_vrings;
- dpdk_vu_vring vrings[VHOST_MAX_QUEUE_PAIRS * 2];
- u64 region_addr[VHOST_MEMORY_MAX_NREGIONS];
- u32 region_fd[VHOST_MEMORY_MAX_NREGIONS];
- u64 region_offset[VHOST_MEMORY_MAX_NREGIONS];
-} dpdk_vu_intf_t;
-#endif
-
typedef void (*dpdk_flowcontrol_callback_t) (vlib_main_t * vm,
u32 hw_if_index, u32 n_packets);
u64 tx_tail;
} tx_ring_hdr_t;
+typedef struct
+{
+ struct rte_ring *swq;
+
+ u64 hqos_field0_slabmask;
+ u32 hqos_field0_slabpos;
+ u32 hqos_field0_slabshr;
+ u64 hqos_field1_slabmask;
+ u32 hqos_field1_slabpos;
+ u32 hqos_field1_slabshr;
+ u64 hqos_field2_slabmask;
+ u32 hqos_field2_slabpos;
+ u32 hqos_field2_slabshr;
+ u32 hqos_tc_table[64];
+} dpdk_device_hqos_per_worker_thread_t;
+
+typedef struct
+{
+ struct rte_ring **swq;
+ struct rte_mbuf **pkts_enq;
+ struct rte_mbuf **pkts_deq;
+ struct rte_sched_port *hqos;
+ u32 hqos_burst_enq;
+ u32 hqos_burst_deq;
+ u32 pkts_enq_len;
+ u32 swq_pos;
+} dpdk_device_hqos_per_hqos_thread_t;
+
typedef struct
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
/* vector of traced contexts, per device */
u32 *d_trace_buffers;
- /* number of sub-interfaces */
- u16 vlan_subifs;
-
- dpdk_device_type_t dev_type:8;
dpdk_pmd_t pmd:8;
i8 cpu_socket;
- u8 admin_up;
- u8 promisc;
+ u16 flags;
+#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_HAVE_SUBIF (1 << 5)
+#define DPDK_DEVICE_FLAG_HQOS (1 << 6)
+
+ u16 nb_tx_desc;
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;
u16 nb_rx_desc;
- u16 nb_tx_desc;
u16 *cpu_socket_id_by_queue;
struct rte_eth_conf port_conf;
struct rte_eth_txconf tx_conf;
- /* KNI related */
- struct rte_kni *kni;
- u8 kni_port_id;
-
-#if DPDK_VHOST_USER
- /* vhost-user related */
- u32 vu_if_id;
- struct virtio_net vu_vhost_dev;
- u32 vu_is_running;
- dpdk_vu_intf_t *vu_intf;
-#endif
+ /* HQoS related */
+ dpdk_device_hqos_per_worker_thread_t *hqos_wt;
+ dpdk_device_hqos_per_hqos_thread_t *hqos_ht;
/* af_packet */
u8 af_packet_port_id;
struct rte_eth_stats stats;
struct rte_eth_stats last_stats;
struct rte_eth_stats last_cleared_stats;
-#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
struct rte_eth_xstat *xstats;
struct rte_eth_xstat *last_cleared_xstats;
-#else
- struct rte_eth_xstats *xstats;
- struct rte_eth_xstats *last_cleared_xstats;
-#endif
f64 time_last_stats_update;
dpdk_port_type_t port_type;
dpdk_efd_agent_t efd_agent;
- u8 need_txlock; /* Used by VNET_DPDK_DEV_VHOST_USER */
} dpdk_device_t;
-
-#define DPDK_TX_RING_SIZE (4 * 1024)
-
#define DPDK_STATS_POLL_INTERVAL (10.0)
#define DPDK_MIN_STATS_POLL_INTERVAL (0.001) /* 1msec */
u64 aggregate_rx_packets;
} dpdk_worker_t;
+typedef struct
+{
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+
+ /* total input packet counter */
+ u64 aggregate_rx_packets;
+} dpdk_hqos_thread_t;
+
typedef struct
{
u32 device;
u16 pad;
} dpdk_efd_t;
+#ifndef DPDK_HQOS_DBG_BYPASS
+#define DPDK_HQOS_DBG_BYPASS 0
+#endif
+
+typedef struct dpdk_device_config_hqos_t
+{
+ u32 hqos_thread;
+ u32 hqos_thread_valid;
+
+ u32 swq_size;
+ u32 burst_enq;
+ u32 burst_deq;
+
+ u32 pktfield0_slabpos;
+ u32 pktfield1_slabpos;
+ u32 pktfield2_slabpos;
+ u64 pktfield0_slabmask;
+ u64 pktfield1_slabmask;
+ u64 pktfield2_slabmask;
+ u32 tc_table[64];
+
+ struct rte_sched_port_params port;
+ struct rte_sched_subport_params *subport;
+ struct rte_sched_pipe_params *pipe;
+ uint32_t *pipe_map;
+} dpdk_device_config_hqos_t;
+
+int dpdk_hqos_validate_mask (u64 mask, u32 n);
+void dpdk_device_config_hqos_pipe_profile_default (dpdk_device_config_hqos_t *
+ hqos, u32 pipe_profile_id);
+void dpdk_device_config_hqos_default (dpdk_device_config_hqos_t * hqos);
+clib_error_t *dpdk_port_setup_hqos (dpdk_device_t * xd,
+ dpdk_device_config_hqos_t * hqos);
+void dpdk_hqos_metadata_set (dpdk_device_hqos_per_worker_thread_t * hqos,
+ struct rte_mbuf **pkts, u32 n_pkts);
+
#define foreach_dpdk_device_config_item \
_ (num_rx_queues) \
_ (num_tx_queues) \
foreach_dpdk_device_config_item
#undef _
clib_bitmap_t * workers;
+ u32 hqos_enabled;
+ dpdk_device_config_hqos_t hqos;
} dpdk_device_config_t;
typedef struct
*/
u8 interface_name_format_decimal;
- /* virtio vhost-user switch */
- u8 use_virtio_vhost;
-
- /* vhost-user coalescence frames config */
- u32 vhost_coalesce_frames;
- f64 vhost_coalesce_time;
-
/* per-device config */
dpdk_device_config_t default_devconf;
dpdk_device_config_t *dev_confs;
/* Devices */
dpdk_device_t *devices;
dpdk_device_and_queue_t **devices_by_cpu;
+ dpdk_device_and_queue_t **devices_by_hqos_cpu;
/* per-thread recycle lists */
u32 **recycle;
/* dpdk worker "threads" */
dpdk_worker_t *workers;
+ /* dpdk HQoS "threads" */
+ dpdk_hqos_thread_t *hqos_threads;
/* Ethernet input node index */
u32 ethernet_input_node_index;
uword *vu_sw_if_index_by_sock_fd;
u32 *vu_inactive_interfaces_device_index;
- u32 next_vu_if_id;
-
/* efd (early-fast-discard) settings */
dpdk_efd_t efd;
int input_cpu_first_index;
int input_cpu_count;
+ /* which cpus are running I/O TX */
+ int hqos_cpu_first_index;
+ int hqos_cpu_count;
+
/* control interval of dpdk link state and stat polling */
f64 link_state_poll_interval;
f64 stat_poll_interval;
u32 is_efd_discardable (vlib_thread_main_t * tm, vlib_buffer_t * b0,
struct rte_mbuf *mb);
-#if DPDK_VHOST_USER
-/* dpdk vhost-user interrupt management */
-u8 dpdk_vhost_user_want_interrupt (dpdk_device_t * xd, int idx);
-void dpdk_vhost_user_send_interrupt (vlib_main_t * vm, dpdk_device_t * xd,
- int idx);
-#endif
-
-
static inline u64
vnet_get_aggregate_rx_packets (void)
{
void post_sw_interface_set_flags (vlib_main_t * vm, u32 sw_if_index,
u32 flags);
-#if DPDK_VHOST_USER
-typedef struct vhost_user_memory vhost_user_memory_t;
-
-void dpdk_vhost_user_process_init (void **ctx);
-void dpdk_vhost_user_process_cleanup (void *ctx);
-uword dpdk_vhost_user_process_if (vlib_main_t * vm, dpdk_device_t * xd,
- void *ctx);
-
-// vhost-user calls
-int dpdk_vhost_user_create_if (vnet_main_t * vnm, vlib_main_t * vm,
- const char *sock_filename,
- u8 is_server,
- u32 * sw_if_index,
- u64 feature_mask,
- u8 renumber, u32 custom_dev_instance,
- u8 * hwaddr);
-int dpdk_vhost_user_modify_if (vnet_main_t * vnm, vlib_main_t * vm,
- const char *sock_filename,
- u8 is_server,
- u32 sw_if_index,
- u64 feature_mask,
- u8 renumber, u32 custom_dev_instance);
-int dpdk_vhost_user_delete_if (vnet_main_t * vnm, vlib_main_t * vm,
- u32 sw_if_index);
-int dpdk_vhost_user_dump_ifs (vnet_main_t * vnm, vlib_main_t * vm,
- vhost_user_intf_details_t ** out_vuids);
-#endif
-
u32 dpdk_get_admin_up_down_in_progress (void);
u32 dpdk_num_mbufs (void);
format_function_t format_dpdk_rx_rte_mbuf;
unformat_function_t unformat_socket_mem;
clib_error_t *unformat_rss_fn (unformat_input_t * input, uword * rss_fn);
-
-
-static inline void
-dpdk_pmd_constructor_init ()
-{
- /* Add references to DPDK Driver Constructor functions to get the dynamic
- * loader to pull in the driver library & run the constructors.
- */
-#define _(d) \
- do { \
- void devinitfn_ ##d(void); \
- __attribute__((unused)) void (* volatile pf)(void); \
- pf = devinitfn_ ##d; \
- } while(0);
-
-#ifdef RTE_LIBRTE_EM_PMD
- _(em_pmd_drv)
-#endif
-#ifdef RTE_LIBRTE_IGB_PMD
- _(pmd_igb_drv)
-#endif
-#ifdef RTE_LIBRTE_IXGBE_PMD
- _(rte_ixgbe_driver)
-#endif
-#ifdef RTE_LIBRTE_I40E_PMD
- _(rte_i40e_driver) _(rte_i40evf_driver)
-#endif
-#ifdef RTE_LIBRTE_FM10K_PMD
- _(rte_fm10k_driver)
-#endif
-#ifdef RTE_LIBRTE_VIRTIO_PMD
- _(rte_virtio_driver)
-#endif
-#ifdef RTE_LIBRTE_VMXNET3_PMD
- _(rte_vmxnet3_driver)
-#endif
-#ifdef RTE_LIBRTE_VICE_PMD
- _(rte_vice_driver)
-#endif
-#ifdef RTE_LIBRTE_ENIC_PMD
- _(rte_enic_driver)
-#endif
-#ifdef RTE_LIBRTE_PMD_AF_PACKET
- _(pmd_af_packet_drv)
-#endif
-#ifdef RTE_LIBRTE_CXGBE_PMD
- _(rte_cxgbe_driver)
-#endif
-#ifdef RTE_LIBRTE_PMD_BOND
- _(bond_drv)
-#endif
-#ifdef RTE_LIBRTE_DPAA2_PMD
- _(pmd_dpaa2_drv)
-#endif
-#undef _
-/*
- * At the moment, the ThunderX NIC driver doesn't have
- * an entry point named "devinitfn_rte_xxx_driver"
- */
-#define _(d) \
- do { \
- void d(void); \
- __attribute__((unused)) void (* volatile pf)(void); \
- pf = d; \
- } while(0);
-#ifdef RTE_LIBRTE_THUNDERVNIC_PMD
- _(rte_nicvf_pmd_init)
-#endif
-#undef _
-}
+clib_error_t *unformat_hqos (unformat_input_t * input,
+ dpdk_device_config_hqos_t * hqos);
uword
admin_up_down_process (vlib_main_t * vm,