app/testpmd: move dumping packets to a separate function
[dpdk.git] / app / test-pmd / testpmd.h
index 1af87b8..cba9640 100644 (file)
@@ -57,10 +57,10 @@ typedef uint16_t streamid_t;
 
 #define MAX_QUEUE_ID ((1 << (sizeof(queueid_t) * 8)) - 1)
 
-#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
-#define TM_MODE                        1
+#if defined RTE_LIBRTE_PMD_SOFTNIC
+#define SOFTNIC                        1
 #else
-#define TM_MODE                        0
+#define SOFTNIC                        0
 #endif
 
 enum {
@@ -69,6 +69,16 @@ enum {
        PORT_TOPOLOGY_LOOP,
 };
 
+enum {
+       MP_ALLOC_NATIVE, /**< allocate and populate mempool natively */
+       MP_ALLOC_ANON,
+       /**< allocate mempool natively, but populate using anonymous memory */
+       MP_ALLOC_XMEM,
+       /**< allocate and populate mempool using anonymous memory */
+       MP_ALLOC_XMEM_HUGE
+       /**< allocate and populate mempool using anonymous hugepage memory */
+};
+
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
 /**
  * The data structure associated with RX and TX packet burst statistics
@@ -112,6 +122,8 @@ struct fwd_stream {
        unsigned int fwd_dropped; /**< received packets not forwarded */
        unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum */
        unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
+       unsigned int rx_bad_outer_l4_csum;
+       /**< received packets has bad outer l4 checksum */
        unsigned int gro_times; /**< GRO operation times */
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
        uint64_t     core_cycles; /**< used for RX and TX processing */
@@ -124,46 +136,21 @@ struct fwd_stream {
 
 /** Descriptor for a single flow. */
 struct port_flow {
-       size_t size; /**< Allocated space including data[]. */
        struct port_flow *next; /**< Next flow in list. */
        struct port_flow *tmp; /**< Temporary linking. */
        uint32_t id; /**< Flow rule ID. */
        struct rte_flow *flow; /**< Opaque flow object returned by PMD. */
-       struct rte_flow_attr attr; /**< Attributes. */
-       struct rte_flow_item *pattern; /**< Pattern. */
-       struct rte_flow_action *actions; /**< Actions. */
-       uint8_t data[]; /**< Storage for pattern/actions. */
-};
-
-#ifdef TM_MODE
-/**
- * Soft port tm related parameters
- */
-struct softnic_port_tm {
-       uint32_t default_hierarchy_enable; /**< def hierarchy enable flag */
-       uint32_t hierarchy_config;  /**< set to 1 if hierarchy configured */
-
-       uint32_t n_subports_per_port;  /**< Num of subport nodes per port */
-       uint32_t n_pipes_per_subport;  /**< Num of pipe nodes per subport */
-
-       uint64_t tm_pktfield0_slabpos;  /**< Pkt field position for subport */
-       uint64_t tm_pktfield0_slabmask; /**< Pkt field mask for the subport */
-       uint64_t tm_pktfield0_slabshr;
-       uint64_t tm_pktfield1_slabpos; /**< Pkt field position for the pipe */
-       uint64_t tm_pktfield1_slabmask; /**< Pkt field mask for the pipe */
-       uint64_t tm_pktfield1_slabshr;
-       uint64_t tm_pktfield2_slabpos; /**< Pkt field position table index */
-       uint64_t tm_pktfield2_slabmask; /**< Pkt field mask for tc table idx */
-       uint64_t tm_pktfield2_slabshr;
-       uint64_t tm_tc_table[64];  /**< TC translation table */
+       struct rte_flow_conv_rule rule; /* Saved flow rule description. */
+       uint8_t data[]; /**< Storage for flow rule description */
 };
 
+#ifdef SOFTNIC
 /**
  * The data structure associate with softnic port
  */
 struct softnic_port {
-       unsigned int tm_flag;   /**< set to 1 if tm feature is enabled */
-       struct softnic_port_tm tm;      /**< softnic port tm parameters */
+       uint32_t default_tm_hierarchy_enable; /**< default tm hierarchy */
+       struct fwd_lcore **fwd_lcore_arg; /**< softnic fwd core parameters */
 };
 #endif
 
@@ -187,6 +174,8 @@ struct rte_port {
        void                    *fwd_ctx;   /**< Forwarding mode context */
        uint64_t                rx_bad_ip_csum; /**< rx pkts with bad ip checksum  */
        uint64_t                rx_bad_l4_csum; /**< rx pkts with bad l4 checksum */
+       uint64_t                rx_bad_outer_l4_csum;
+       /**< rx pkts with bad outer l4 checksum */
        uint8_t                 tx_queue_stats_mapping_enabled;
        uint8_t                 rx_queue_stats_mapping_enabled;
        volatile uint16_t        port_status;    /**< port started or not */
@@ -202,9 +191,8 @@ struct rte_port {
        uint32_t                mc_addr_nb; /**< nb. of addr. in mc_addr_pool */
        uint8_t                 slave_flag; /**< bonding slave port */
        struct port_flow        *flow_list; /**< Associated flows. */
-#ifdef TM_MODE
-       unsigned int                    softnic_enable; /**< softnic flag */
-       struct softnic_port     softport;  /**< softnic port params */
+#ifdef SOFTNIC
+       struct softnic_port     softport;  /**< softnic params */
 #endif
 };
 
@@ -266,9 +254,9 @@ extern struct fwd_engine rx_only_engine;
 extern struct fwd_engine tx_only_engine;
 extern struct fwd_engine csum_fwd_engine;
 extern struct fwd_engine icmp_echo_engine;
-#ifdef TM_MODE
-extern struct fwd_engine softnic_tm_engine;
-extern struct fwd_engine softnic_tm_bypass_engine;
+extern struct fwd_engine noisy_vnf_engine;
+#ifdef SOFTNIC
+extern struct fwd_engine softnic_fwd_engine;
 #endif
 #ifdef RTE_LIBRTE_IEEE1588
 extern struct fwd_engine ieee1588_fwd_engine;
@@ -328,15 +316,16 @@ extern uint8_t  numa_support; /**< set by "--numa" parameter */
 extern uint16_t port_topology; /**< set by "--port-topology" parameter */
 extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */
 extern uint8_t flow_isolate_all; /**< set by "--flow-isolate-all */
-extern uint8_t  mp_anon; /**< set by "--mp-anon" parameter */
+extern uint8_t  mp_alloc_type;
+/**< set by "--mp-anon" or "--mp-alloc" parameter */
 extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
 extern volatile int test_done; /* stop packet forwarding when set to 1. */
 extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
 extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
 extern uint32_t event_print_mask;
-extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
-
 /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
+extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
+extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */
 
 #ifdef RTE_LIBRTE_IXGBE_BYPASS
 extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */
@@ -399,6 +388,13 @@ extern int8_t rx_drop_en;
 extern int16_t tx_free_thresh;
 extern int16_t tx_rs_thresh;
 
+extern uint16_t noisy_tx_sw_bufsz;
+extern uint16_t noisy_tx_sw_buf_flush_time;
+extern uint64_t noisy_lkup_mem_sz;
+extern uint64_t noisy_lkup_num_writes;
+extern uint64_t noisy_lkup_num_reads;
+extern uint64_t noisy_lkup_num_reads_writes;
+
 extern uint8_t dcb_config;
 extern uint8_t dcb_test;
 
@@ -479,6 +475,38 @@ struct gso_status {
 extern struct gso_status gso_ports[RTE_MAX_ETHPORTS];
 extern uint16_t gso_max_segment_size;
 
+/* VXLAN encap/decap parameters. */
+struct vxlan_encap_conf {
+       uint32_t select_ipv4:1;
+       uint32_t select_vlan:1;
+       uint8_t vni[3];
+       rte_be16_t udp_src;
+       rte_be16_t udp_dst;
+       rte_be32_t ipv4_src;
+       rte_be32_t ipv4_dst;
+       uint8_t ipv6_src[16];
+       uint8_t ipv6_dst[16];
+       rte_be16_t vlan_tci;
+       uint8_t eth_src[ETHER_ADDR_LEN];
+       uint8_t eth_dst[ETHER_ADDR_LEN];
+};
+struct vxlan_encap_conf vxlan_encap_conf;
+
+/* NVGRE encap/decap parameters. */
+struct nvgre_encap_conf {
+       uint32_t select_ipv4:1;
+       uint32_t select_vlan:1;
+       uint8_t tni[3];
+       rte_be32_t ipv4_src;
+       rte_be32_t ipv4_dst;
+       uint8_t ipv6_src[16];
+       uint8_t ipv6_dst[16];
+       rte_be16_t vlan_tci;
+       uint8_t eth_src[ETHER_ADDR_LEN];
+       uint8_t eth_dst[ETHER_ADDR_LEN];
+};
+struct nvgre_encap_conf nvgre_encap_conf;
+
 static inline unsigned int
 lcore_num(void)
 {
@@ -586,6 +614,8 @@ void nic_xstats_display(portid_t port_id);
 void nic_xstats_clear(portid_t port_id);
 void nic_stats_mapping_display(portid_t port_id);
 void port_infos_display(portid_t port_id);
+void port_summary_display(portid_t port_id);
+void port_summary_header_display(void);
 void port_offload_cap_display(portid_t port_id);
 void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
 void tx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
@@ -596,6 +626,7 @@ void fwd_config_setup(void);
 void set_def_fwd_config(void);
 void reconfig(portid_t new_port_id, unsigned socket_id);
 int init_fwd_streams(void);
+void update_fwd_ports(portid_t new_pid);
 
 void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
 
@@ -699,8 +730,7 @@ int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate);
 int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
                                uint64_t q_msk);
 
-void port_rss_hash_conf_show(portid_t port_id, char rss_info[],
-                            int show_rss_key);
+void port_rss_hash_conf_show(portid_t port_id, int show_rss_key);
 void port_rss_hash_key_update(portid_t port_id, char rss_type[],
                              uint8_t *hash_key, uint hash_key_len);
 int rx_queue_id_is_invalid(queueid_t rxq_id);
@@ -726,6 +756,7 @@ enum print_warning {
        DISABLED_WARN
 };
 int port_id_is_invalid(portid_t port_id, enum print_warning warning);
+void print_valid_ports(void);
 int new_socket_id(unsigned int socket_id);
 
 queueid_t get_allowed_max_nb_rxq(portid_t *pid);
@@ -733,6 +764,9 @@ int check_nb_rxq(queueid_t rxq);
 queueid_t get_allowed_max_nb_txq(portid_t *pid);
 int check_nb_txq(queueid_t txq);
 
+void dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+        uint16_t nb_pkts, int is_rx);
+
 /*
  * Work-around of a compilation error with ICC on invocations of the
  * rte_be_to_cpu_16() function.