#include <rte_dev.h>
#include <rte_log.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_memzone.h>
#include <rte_tailq.h>
#include <rte_eal.h>
#define always_inline static inline __attribute__ ((__always_inline__))
#endif
-#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
#define NB_MBUF (32<<10)
-vnet_device_class_t dpdk_device_class;
+extern vnet_device_class_t dpdk_device_class;
extern vlib_node_registration_t dpdk_input_node;
extern vlib_node_registration_t dpdk_io_input_node;
extern vlib_node_registration_t handoff_dispatch_node;
struct rte_eth_stats stats;
struct rte_eth_stats last_stats;
+ struct rte_eth_stats last_cleared_stats;
struct rte_eth_xstats * xstats;
+ struct rte_eth_xstats * last_cleared_xstats;
f64 time_last_stats_update;
dpdk_port_type_t port_type;
i32 n_vectors[MAX_NELTS];
} frame_queue_trace_t;
+typedef struct {
+ u64 count[MAX_NELTS];
+} frame_queue_nelt_counter_t;
+
#define DPDK_TX_RING_SIZE (4 * 1024)
#define DPDK_STATS_POLL_INTERVAL (10.0)
u16 pad;
} dpdk_efd_t;
+typedef struct {
+
+ /* Config stuff */
+ u8 ** eal_init_args;
+ u8 * eal_init_args_str;
+ u8 * eth_if_blacklist;
+ u8 * eth_if_whitelist;
+ u8 * uio_driver_name;
+ u8 no_multi_seg;
+ u8 enable_tcp_udp_checksum;
+
+ /* Required config parameters */
+ u8 coremask_set_manually;
+ u8 nchannels_set_manually;
+ u32 coremask;
+ u32 nchannels;
+ u32 num_mbufs;
+ u32 use_rss;
+ u32 max_tx_queues;
+ u8 num_kni;/* while kni_init allows u32, port_id in callback fn is only u8 */
+
+ /*
+ * format interface names ala xxxEthernet%d/%d/%d instead of
+ * xxxEthernet%x/%x/%x. For VIRL.
+ */
+ 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;
+
+} dpdk_config_main_t;
+
+dpdk_config_main_t dpdk_config_main;
+
typedef struct {
/* Devices */
/* vlib buffer free list, must be same size as an rte_mbuf */
u32 vlib_buffer_free_list_index;
- /*
- * format interface names ala xxxEthernet%d/%d/%d instead of
- * xxxEthernet%x/%x/%x. For VIRL.
- */
- u8 interface_name_format_decimal;
-
-
/* dpdk worker "threads" */
dpdk_worker_t * workers;
- /* Config stuff */
- u8 ** eal_init_args;
- u8 * eal_init_args_str;
- u8 * eth_if_blacklist;
- u8 * eth_if_whitelist;
- u8 * uio_driver_name;
- u8 no_multi_seg;
-
- /* Required config parameters */
- u8 coremask_set_manually;
- u8 nchannels_set_manually;
- u32 coremask;
- u32 nchannels;
- u32 num_mbufs;
- u32 use_rss;
- u32 max_tx_queues;
- u8 num_kni; /* while kni_init allows u32, port_id in callback fn is only u8 */
/* Ethernet input node index */
u32 ethernet_input_node_index;
u32 pcap_sw_if_index;
u32 pcap_pkts_to_capture;
- /* virtio vhost-user switch */
- u8 use_virtio_vhost;
-
- /* vhost-user coalescence frames config */
- u32 vhost_coalesce_frames;
- f64 vhost_coalesce_time;
-
/* hashes */
uword * dpdk_device_by_kni_port_id;
uword * vu_sw_if_index_by_listener_fd;
f64 link_state_poll_interval;
f64 stat_poll_interval;
+ /* for frame queue tracing */
+ frame_queue_trace_t *frame_queue_traces;
+ frame_queue_nelt_counter_t *frame_queue_histogram;
+
/* convenience */
vlib_main_t * vlib_main;
vnet_main_t * vnet_main;
+ dpdk_config_main_t * conf;
} dpdk_main_t;
dpdk_main_t dpdk_main;
void set_efd_bitmap (u8 *bitmap, u32 value, u32 op);
+struct rte_mbuf * dpdk_replicate_packet_mb (vlib_buffer_t * b);
+struct rte_mbuf * dpdk_zerocopy_replicate_packet_mb (vlib_buffer_t * b);
+
#define foreach_dpdk_error \
_(NONE, "no error") \
_(RX_PACKET_ERROR, "Rx packet errors") \
u32 dpdk_get_admin_up_down_in_progress (void);
-uword
-dpdk_input_rss (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * f);
+u32 dpdk_num_mbufs (void);
+
+int dpdk_io_thread_release (void);
+
+dpdk_pmd_t dpdk_get_pmd_type (vnet_hw_interface_t *hi);
+
+i8 dpdk_get_cpu_socket (vnet_hw_interface_t *hi);
+
+void * dpdk_input_multiarch_select();
+void * dpdk_input_rss_multiarch_select();
+void * dpdk_input_efd_multiarch_select();
+
+clib_error_t*
+dpdk_get_hw_interface_stats (u32 hw_if_index, struct rte_eth_stats* dest);
format_function_t format_dpdk_device_name;
format_function_t format_dpdk_device;
format_function_t format_dpdk_rx_rte_mbuf;
unformat_function_t unformat_socket_mem;
+
+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
+
+#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 _
+
+}
+
+uword
+admin_up_down_process (vlib_main_t * vm,
+ vlib_node_runtime_t * rt,
+ vlib_frame_t * f);
+
#endif /* __included_dpdk_h__ */