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 #if RTE_VERSION < RTE_VERSION_NUM(16, 7, 0, 0) 65 #define DPDK_VHOST_USER 1 67 #define DPDK_VHOST_USER 0 72 #define NB_MBUF (16<<10) 86 #define foreach_dpdk_pmd \ 87 _ ("rte_nicvf_pmd", THUNDERX) \ 88 _ ("rte_em_pmd", E1000EM) \ 89 _ ("rte_igb_pmd", IGB) \ 90 _ ("rte_igbvf_pmd", IGBVF) \ 91 _ ("rte_ixgbe_pmd", IXGBE) \ 92 _ ("rte_ixgbevf_pmd", IXGBEVF) \ 93 _ ("rte_i40e_pmd", I40E) \ 94 _ ("rte_i40evf_pmd", I40EVF) \ 95 _ ("rte_virtio_pmd", VIRTIO) \ 96 _ ("rte_enic_pmd", ENIC) \ 97 _ ("rte_vmxnet3_pmd", VMXNET3) \ 98 _ ("AF_PACKET PMD", AF_PACKET) \ 99 _ ("rte_bond_pmd", BOND) \ 100 _ ("rte_pmd_fm10k", FM10K) \ 101 _ ("rte_cxgbe_pmd", CXGBE) \ 102 _ ("rte_dpaa2_dpni", DPAA2) 107 #define _(s,f) VNET_DPDK_PMD_##f, 130 #define DPDK_EFD_MAX_DISCARD_RATE 10 153 u32 n_since_last_int;
165 char sock_filename[256];
172 dpdk_vu_vring vrings[VHOST_MAX_QUEUE_PAIRS * 2];
180 u32 hw_if_index,
u32 n_packets);
234 struct rte_eth_conf port_conf;
235 struct rte_eth_txconf tx_conf;
244 struct virtio_net vu_vhost_dev;
246 dpdk_vu_intf_t *vu_intf;
252 struct rte_eth_link link;
255 struct rte_eth_stats stats;
256 struct rte_eth_stats last_stats;
257 struct rte_eth_stats last_cleared_stats;
258 #if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0) 262 struct rte_eth_xstats *xstats;
263 struct rte_eth_xstats *last_cleared_xstats;
273 #define DPDK_TX_RING_SIZE (4 * 1024) 275 #define DPDK_STATS_POLL_INTERVAL (10.0) 276 #define DPDK_MIN_STATS_POLL_INTERVAL (0.001) 278 #define DPDK_LINK_POLL_INTERVAL (3.0) 279 #define DPDK_MIN_LINK_POLL_INTERVAL (0.001) 296 #define DPDK_EFD_DISABLED 0 297 #define DPDK_EFD_DISCARD_ENABLED (1 << 0) 298 #define DPDK_EFD_MONITOR_ENABLED (1 << 1) 299 #define DPDK_EFD_DROPALL_ENABLED (1 << 2) 301 #define DPDK_EFD_DEFAULT_DEVICE_QUEUE_HI_THRESH_PCT 90 302 #define DPDK_EFD_DEFAULT_CONSEC_FULL_FRAMES_HI_THRESH 6 312 #define foreach_dpdk_device_config_item \ 324 #define DPDK_DEVICE_VLAN_STRIP_DEFAULT 0 325 #define DPDK_DEVICE_VLAN_STRIP_OFF 1 326 #define DPDK_DEVICE_VLAN_STRIP_ON 2 328 #define _(x) uword x; 482 struct ether_addr mc_addr_vec[],
int naddr);
498 #define foreach_dpdk_error \ 499 _(NONE, "no error") \ 500 _(RX_PACKET_ERROR, "Rx packet errors") \ 501 _(RX_BAD_FCS, "Rx bad fcs") \ 502 _(L4_CHECKSUM_ERROR, "Rx L4 checksum errors") \ 503 _(IP_CHECKSUM_ERROR, "Rx ip checksum errors") \ 504 _(RX_ALLOC_FAIL, "rx buf alloc from free list failed") \ 505 _(RX_ALLOC_NO_PHYSMEM, "rx buf alloc failed no physmem") \ 506 _(RX_ALLOC_DROP_PKTS, "rx packets dropped due to alloc error") \ 507 _(IPV4_EFD_DROP_PKTS, "IPV4 Early Fast Discard rx drops") \ 508 _(IPV6_EFD_DROP_PKTS, "IPV6 Early Fast Discard rx drops") \ 509 _(MPLS_EFD_DROP_PKTS, "MPLS Early Fast Discard rx drops") \ 510 _(VLAN_EFD_DROP_PKTS, "VLAN Early Fast Discard rx drops") 514 #define _(f,s) DPDK_ERROR_##f, 540 struct rte_mbuf *mb);
567 #define EFD_OPERATION_LESS_THAN 0 568 #define EFD_OPERATION_GREATER_OR_EQUAL 1 580 void dpdk_vhost_user_process_init (
void **ctx);
581 void dpdk_vhost_user_process_cleanup (
void *ctx);
587 const char *sock_filename,
591 u8 renumber,
u32 custom_dev_instance,
594 const char *sock_filename,
598 u8 renumber,
u32 custom_dev_instance);
618 struct rte_eth_stats *dest);
638 void devinitfn_ ##d(void); \ 639 __attribute__((unused)) void (* volatile pf)(void); \ 640 pf = devinitfn_ ##d; \ 643 #ifdef RTE_LIBRTE_EM_PMD 646 #ifdef RTE_LIBRTE_IGB_PMD 649 #ifdef RTE_LIBRTE_IXGBE_PMD 652 #ifdef RTE_LIBRTE_I40E_PMD 653 _(rte_i40e_driver) _(rte_i40evf_driver)
655 #ifdef RTE_LIBRTE_FM10K_PMD 658 #ifdef RTE_LIBRTE_VIRTIO_PMD 661 #ifdef RTE_LIBRTE_VMXNET3_PMD 662 _(rte_vmxnet3_driver)
664 #ifdef RTE_LIBRTE_VICE_PMD 667 #ifdef RTE_LIBRTE_ENIC_PMD 670 #ifdef RTE_LIBRTE_PMD_AF_PACKET 673 #ifdef RTE_LIBRTE_CXGBE_PMD 676 #ifdef RTE_LIBRTE_PMD_BOND 679 #ifdef RTE_LIBRTE_DPAA2_PMD 690 __attribute__((unused)) void (* volatile pf)(void); \ 693 #ifdef RTE_LIBRTE_THUNDERVNIC_PMD 694 _(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
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
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)
u8 interface_name_format_decimal
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)
u32 vhost_coalesce_frames
#define foreach_dpdk_error
i8 dpdk_get_cpu_socket(vnet_hw_interface_t *hi)
PCAP utility definitions.
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 enable_tcp_udp_checksum
struct rte_eth_xstat * last_cleared_xstats
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)
void * dpdk_input_efd_multiarch_select()
struct rte_mbuf *** tx_vectors
foreach_dpdk_device_config_item clib_bitmap_t * workers
#define static_always_inline
PCAP main state data structure.
dpdk_config_main_t dpdk_config_main
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
dpdk_device_config_t default_devconf
void dpdk_set_next_node(dpdk_rx_next_t, char *)
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
unformat_function_t unformat_socket_mem
int input_cpu_first_index
u32 dpdk_interface_tx_vector(vlib_main_t *vm, u32 dev_instance)
u32 dpdk_get_admin_up_down_in_progress(void)
format_function_t format_dpdk_rx_rte_mbuf
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
void * dpdk_input_multiarch_select()
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
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)
dpdk_port_type_t port_type
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)
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)
u8 nchannels_set_manually
u16 * cpu_socket_id_by_queue
dpdk_device_config_t * dev_confs
struct rte_mbuf *** rx_vectors
#define VHOST_MEMORY_MAX_NREGIONS
int dpdk_set_stat_poll_interval(f64 interval)
uword admin_up_down_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
format_function_t format_dpdk_device
void dpdk_efd_update_counters(dpdk_device_t *xd, u32 n_buffers, u16 enabled)
struct rte_eth_xstat * xstats
u8 * interface_name_suffix
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_input_rss_multiarch_select()
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)
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)
u32 buffer_flags_template
u32 vlib_buffer_free_list_index
#define foreach_dpdk_device_config_item
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define vec_foreach(var, vec)
Vector iterator.
uword * device_config_index_by_pci_addr
uword * dpdk_device_by_kni_port_id
uword * vu_sw_if_index_by_listener_fd
f64 link_state_poll_interval
dpdk_config_main_t * conf
uword * vu_sw_if_index_by_sock_fd