15 #ifndef __included_dpdk_h__ 16 #define __included_dpdk_h__ 21 #include <rte_config.h> 23 #include <rte_common.h> 26 #include <rte_memory.h> 27 #include <rte_memzone.h> 28 #include <rte_tailq.h> 30 #include <rte_per_lcore.h> 31 #include <rte_launch.h> 32 #include <rte_atomic.h> 33 #include <rte_cycles.h> 34 #include <rte_prefetch.h> 35 #include <rte_lcore.h> 36 #include <rte_per_lcore.h> 37 #include <rte_branch_prediction.h> 38 #include <rte_interrupts.h> 40 #include <rte_random.h> 41 #include <rte_debug.h> 42 #include <rte_ether.h> 43 #include <rte_ethdev.h> 45 #include <rte_mempool.h> 50 #include <rte_virtio_net.h> 51 #include <rte_pci_dev_ids.h> 52 #include <rte_version.h> 53 #include <rte_eth_bond.h> 59 #define always_inline static inline 61 #define always_inline static inline __attribute__ ((__always_inline__)) 64 #define NB_MBUF (32<<10) 78 #define foreach_dpdk_pmd \ 79 _ ("rte_nicvf_pmd", THUNDERX) \ 80 _ ("rte_em_pmd", E1000EM) \ 81 _ ("rte_igb_pmd", IGB) \ 82 _ ("rte_igbvf_pmd", IGBVF) \ 83 _ ("rte_ixgbe_pmd", IXGBE) \ 84 _ ("rte_ixgbevf_pmd", IXGBEVF) \ 85 _ ("rte_i40e_pmd", I40E) \ 86 _ ("rte_i40evf_pmd", I40EVF) \ 87 _ ("rte_virtio_pmd", VIRTIO) \ 88 _ ("rte_vice_pmd", VICE) \ 89 _ ("rte_enic_pmd", ENIC) \ 90 _ ("rte_vmxnet3_pmd", VMXNET3) \ 91 _ ("AF_PACKET PMD", AF_PACKET) \ 92 _ ("rte_bond_pmd", BOND) \ 93 _ ("rte_pmd_fm10k", FM10K) \ 94 _ ("rte_cxgbe_pmd", CXGBE) 98 #define _(s,f) VNET_DPDK_PMD_##f, 102 VNET_DPDK_PMD_NETMAP,
114 VNET_DPDK_PORT_TYPE_NETMAP,
125 #define DPDK_EFD_MAX_DISCARD_RATE 10 143 #if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0) 158 char sock_filename[256];
165 #if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0) 229 struct rte_eth_conf port_conf;
230 struct rte_eth_txconf tx_conf;
238 struct virtio_net vu_vhost_dev;
245 struct rte_eth_link link;
248 struct rte_eth_stats stats;
249 struct rte_eth_stats last_stats;
250 struct rte_eth_stats last_cleared_stats;
277 #define DPDK_TX_RING_SIZE (4 * 1024) 279 #define DPDK_STATS_POLL_INTERVAL (10.0) 280 #define DPDK_MIN_STATS_POLL_INTERVAL (0.001) 282 #define DPDK_LINK_POLL_INTERVAL (3.0) 283 #define DPDK_MIN_LINK_POLL_INTERVAL (0.001) 298 #define DPDK_EFD_DISABLED 0 299 #define DPDK_EFD_DISCARD_ENABLED (1 << 0) 300 #define DPDK_EFD_MONITOR_ENABLED (1 << 1) 301 #define DPDK_EFD_DROPALL_ENABLED (1 << 2) 303 #define DPDK_EFD_DEFAULT_DEVICE_QUEUE_HI_THRESH_PCT 90 304 #define DPDK_EFD_DEFAULT_CONSEC_FULL_FRAMES_HI_THRESH 6 450 struct ether_addr mc_addr_vec[],
int naddr);
477 #define foreach_dpdk_error \ 478 _(NONE, "no error") \ 479 _(RX_PACKET_ERROR, "Rx packet errors") \ 480 _(RX_BAD_FCS, "Rx bad fcs") \ 481 _(L4_CHECKSUM_ERROR, "Rx L4 checksum errors") \ 482 _(IP_CHECKSUM_ERROR, "Rx ip checksum errors") \ 483 _(RX_ALLOC_FAIL, "rx buf alloc from free list failed") \ 484 _(RX_ALLOC_NO_PHYSMEM, "rx buf alloc failed no physmem") \ 485 _(RX_ALLOC_DROP_PKTS, "rx packets dropped due to alloc error") \ 486 _(IPV4_EFD_DROP_PKTS, "IPV4 Early Fast Discard rx drops") \ 487 _(IPV6_EFD_DROP_PKTS, "IPV6 Early Fast Discard rx drops") \ 488 _(MPLS_EFD_DROP_PKTS, "MPLS Early Fast Discard rx drops") \ 489 _(VLAN_EFD_DROP_PKTS, "VLAN Early Fast Discard rx drops") 492 #define _(f,s) DPDK_ERROR_##f, 518 struct rte_mbuf *mb);
545 #define EFD_OPERATION_LESS_THAN 0 546 #define EFD_OPERATION_GREATER_OR_EQUAL 1 550 u32 mpls_exp,
u32 mpls_op,
551 u32 vlan_cos,
u32 vlan_op);
563 const char * sock_filename,
567 u8 renumber,
u32 custom_dev_instance,
570 const char * sock_filename,
574 u8 renumber,
u32 custom_dev_instance);
613 void devinitfn_ ##d(void); \ 614 __attribute__((unused)) void (* volatile pf)(void); \ 615 pf = devinitfn_ ##d; \ 618 #ifdef RTE_LIBRTE_EM_PMD 622 #ifdef RTE_LIBRTE_IGB_PMD 626 #ifdef RTE_LIBRTE_IXGBE_PMD 630 #ifdef RTE_LIBRTE_I40E_PMD 635 #ifdef RTE_LIBRTE_FM10K_PMD 639 #ifdef RTE_LIBRTE_VIRTIO_PMD 643 #ifdef RTE_LIBRTE_VMXNET3_PMD 644 _(rte_vmxnet3_driver)
647 #ifdef RTE_LIBRTE_VICE_PMD 651 #ifdef RTE_LIBRTE_ENIC_PMD 655 #ifdef RTE_LIBRTE_PMD_AF_PACKET 659 #ifdef RTE_LIBRTE_CXGBE_PMD 663 #ifdef RTE_LIBRTE_PMD_BOND 676 __attribute__((unused)) void (* volatile pf)(void); \ 680 #ifdef RTE_LIBRTE_THUNDERVNIC_PMD 681 _(rte_nicvf_pmd_init)
void(* dpdk_flowcontrol_callback_t)(vlib_main_t *vm, u32 hw_if_index, u32 n_packets)
void dpdk_device_lock_free(dpdk_device_t *xd)
f64 time_last_link_update
void dpdk_io_thread(vlib_worker_thread_t *w, u32 instances, u32 instance_id, char *worker_name, dpdk_io_thread_callback_t callback)
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
vlib_node_registration_t dpdk_io_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_io_input_node)
struct rte_mbuf * dpdk_replicate_packet_mb(vlib_buffer_t *b)
void post_sw_interface_set_flags(vlib_main_t *vm, u32 sw_if_index, u32 flags)
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)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
void dpdk_vhost_user_send_interrupt(vlib_main_t *vm, dpdk_device_t *xd, int idx)
vnet_device_class_t dpdk_device_class
clib_error_t * dpdk_set_mc_filter(vnet_hw_interface_t *hi, struct ether_addr mc_addr_vec[], int naddr)
#define foreach_dpdk_error
int dpdk_vhost_user_delete_if(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index)
i8 dpdk_get_cpu_socket(vnet_hw_interface_t *hi)
u32 vhost_coalesce_frames
uword dpdk_input_rss(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *f)
void(* dpdk_io_thread_callback_t)(vlib_main_t *vm)
static void dpdk_pmd_constructor_init()
struct dpdk_efd_t dpdk_efd_t
dpdk_pmd_t dpdk_get_pmd_type(vnet_hw_interface_t *hi)
struct _vlib_node_registration vlib_node_registration_t
u32 per_interface_next_index
u8 nchannels_set_manually
format_function_t format_dpdk_rte_mbuf
struct _vnet_device_class vnet_device_class_t
format_function_t format_dpdk_tx_dma_trace
clib_error_t * dpdk_port_setup(dpdk_main_t *dm, dpdk_device_t *xd)
u32 dpdk_get_handoff_node_index(void)
u8 dpdk_vhost_user_want_interrupt(dpdk_device_t *xd, int idx)
struct rte_mbuf *** tx_vectors
#define static_always_inline
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
void dpdk_set_next_node(dpdk_rx_next_t, char *)
unformat_function_t unformat_socket_mem
int input_cpu_first_index
u32 dpdk_interface_tx_vector(vlib_main_t *vm, u32 dev_instance)
void dpdk_vhost_user_process_cleanup(void *ctx)
u32 dpdk_get_admin_up_down_in_progress(void)
format_function_t format_dpdk_rx_rte_mbuf
struct rte_eth_xstats * last_cleared_xstats
vlib_node_registration_t handoff_dispatch_node
(constructor) VLIB_REGISTER_NODE (handoff_dispatch_node)
f64 time_last_stats_update
u16 consec_full_frames_hi_thresh
format_function_t format_dpdk_rx_dma_trace
dpdk_device_and_queue_t ** devices_by_cpu
static_always_inline void increment_efd_drop_counter(vlib_main_t *vm, u32 counter_index, u32 count)
int dpdk_set_link_state_poll_interval(f64 interval)
u32 consec_full_frames_cnt
vlib_error_main_t error_main
int dpdk_vhost_user_dump_ifs(vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_details_t **out_vuids)
void vnet_buffer_needs_dpdk_mb(vlib_buffer_t *b)
dpdk_flowcontrol_callback_t flowcontrol_callback
static u64 vnet_get_aggregate_rx_packets(void)
void efd_config(u32 enabled, u32 ip_prec, u32 ip_op, u32 mpls_exp, u32 mpls_op, u32 vlan_cos, u32 vlan_op)
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)
dpdk_port_type_t port_type
vlib_frame_queue_elt_t * vlib_get_handoff_queue_elt(u32 vlib_worker_index)
void dpdk_rx_trace(dpdk_main_t *dm, vlib_node_runtime_t *node, dpdk_device_t *xd, u16 queue_id, u32 *buffers, uword n_buffers)
frame_queue_nelt_counter_t * frame_queue_histogram
void dpdk_thread_input(dpdk_main_t *dm, dpdk_device_t *xd)
clib_error_t * dpdk_get_hw_interface_stats(u32 hw_if_index, struct rte_eth_stats *dest)
u16 * cpu_socket_id_by_queue
struct rte_mbuf *** rx_vectors
#define VHOST_MEMORY_MAX_NREGIONS
int dpdk_set_stat_poll_interval(f64 interval)
format_function_t format_dpdk_device
void dpdk_efd_update_counters(dpdk_device_t *xd, u32 n_buffers, u16 enabled)
void dpdk_set_flowcontrol_callback(vlib_main_t *vm, dpdk_flowcontrol_callback_t callback)
format_function_t format_dpdk_device_name
u32 * vu_inactive_interfaces_device_index
void dpdk_vhost_user_process_init(void **ctx)
void dpdk_device_lock_init(dpdk_device_t *xd)
struct rte_mbuf * dpdk_zerocopy_replicate_packet_mb(vlib_buffer_t *b)
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
clib_error_t * dpdk_set_mac_address(vnet_hw_interface_t *hi, char *address)
u32 is_efd_discardable(vlib_thread_main_t *tm, vlib_buffer_t *b0, struct rte_mbuf *mb)
frame_queue_trace_t * frame_queue_traces
u8 interface_name_format_decimal
int dpdk_io_thread_release(void)
u32 ethernet_input_node_index
dpdk_efd_agent_t efd_agent
u8 admin_up_down_in_progress
void set_efd_bitmap(u8 *bitmap, u32 value, u32 op)
struct rte_eth_xstats * xstats
u32 buffer_flags_template
u32 vlib_buffer_free_list_index
volatile u32 io_thread_release
#define vec_foreach(var, vec)
Vector iterator.
uword dpdk_vhost_user_process_if(vlib_main_t *vm, dpdk_device_t *xd, void *ctx)
always_inline u32 counter_index(vlib_main_t *vm, vlib_error_t e)
uword * dpdk_device_by_kni_port_id
uword * vu_sw_if_index_by_listener_fd
f64 link_state_poll_interval
uword * vu_sw_if_index_by_sock_fd