Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2017 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _TESTPMD_H_
6 : : #define _TESTPMD_H_
7 : :
8 : : #include <stdbool.h>
9 : :
10 : : #ifdef RTE_LIB_GRO
11 : : #include <rte_gro.h>
12 : : #endif
13 : : #ifdef RTE_LIB_GSO
14 : : #include <rte_gso.h>
15 : : #endif
16 : : #include <rte_os_shim.h>
17 : : #include <rte_ethdev.h>
18 : : #include <rte_flow.h>
19 : : #include <rte_mbuf_dyn.h>
20 : :
21 : : #include <cmdline.h>
22 : : #include <cmdline_parse.h>
23 : :
24 : : #include <sys/queue.h>
25 : : #ifdef RTE_HAS_JANSSON
26 : : #include <jansson.h>
27 : : #endif
28 : :
29 : : #define RTE_PORT_ALL (~(portid_t)0x0)
30 : :
31 : : #define RTE_PORT_STOPPED (uint16_t)0
32 : : #define RTE_PORT_STARTED (uint16_t)1
33 : : #define RTE_PORT_CLOSED (uint16_t)2
34 : : #define RTE_PORT_HANDLING (uint16_t)3
35 : :
36 : : extern uint8_t cl_quit;
37 : : extern volatile uint8_t f_quit;
38 : :
39 : : /* Max number of cmdline files we can take on testpmd cmdline */
40 : : #define MAX_CMDLINE_FILENAMES 16
41 : :
42 : : /* Structure to track cmdline files and their echo settings */
43 : : struct cmdline_file_info {
44 : : char filename[PATH_MAX]; /**< Path to the cmdline file */
45 : : bool echo; /**< Whether to echo commands from this file */
46 : : };
47 : :
48 : : /*
49 : : * It is used to allocate the memory for hash key.
50 : : * The hash key size is NIC dependent.
51 : : */
52 : : #define RSS_HASH_KEY_LENGTH 64
53 : :
54 : : /*
55 : : * Default size of the mbuf data buffer to receive standard 1518-byte
56 : : * Ethernet frames in a mono-segment memory buffer.
57 : : */
58 : : #define DEFAULT_MBUF_DATA_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
59 : : /**< Default size of mbuf data buffer. */
60 : :
61 : : /*
62 : : * The maximum number of segments per packet is used when creating
63 : : * scattered transmit packets composed of a list of mbufs.
64 : : */
65 : : #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
66 : :
67 : : /*
68 : : * The maximum number of segments per packet is used to configure
69 : : * buffer split feature, also specifies the maximum amount of
70 : : * optional Rx pools to allocate mbufs to split.
71 : : */
72 : : #define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
73 : :
74 : : /* The prefix of the mbuf pool names created by the application. */
75 : : #define MBUF_POOL_NAME_PFX "mb_pool"
76 : :
77 : : #define RX_DESC_MAX 2048
78 : : #define TX_DESC_MAX 2048
79 : :
80 : : #define MAX_PKT_BURST 512
81 : : #define DEF_PKT_BURST 32
82 : :
83 : : #define DEF_MBUF_CACHE 250
84 : :
85 : : #define RTE_CACHE_LINE_SIZE_ROUNDUP(size) \
86 : : (RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / RTE_CACHE_LINE_SIZE))
87 : :
88 : : #define NUMA_NO_CONFIG 0xFF
89 : : #define UMA_NO_CONFIG 0xFF
90 : :
91 : : #define MIN_TOTAL_NUM_MBUFS 1024
92 : :
93 : : /* Maximum number of pools supported per Rx queue */
94 : : #define MAX_MEMPOOL 8
95 : :
96 : : typedef uint32_t lcoreid_t;
97 : : typedef uint16_t portid_t;
98 : : typedef uint16_t queueid_t;
99 : : typedef uint16_t streamid_t;
100 : :
101 : : enum {
102 : : PORT_TOPOLOGY_PAIRED,
103 : : PORT_TOPOLOGY_CHAINED,
104 : : PORT_TOPOLOGY_LOOP,
105 : : };
106 : :
107 : : enum {
108 : : MP_ALLOC_NATIVE, /**< allocate and populate mempool natively */
109 : : MP_ALLOC_ANON,
110 : : /**< allocate mempool natively, but populate using anonymous memory */
111 : : MP_ALLOC_XMEM,
112 : : /**< allocate and populate mempool using anonymous memory */
113 : : MP_ALLOC_XMEM_HUGE,
114 : : /**< allocate and populate mempool using anonymous hugepage memory */
115 : : MP_ALLOC_XBUF
116 : : /**< allocate mempool natively, use rte_pktmbuf_pool_create_extbuf */
117 : : };
118 : :
119 : : enum {
120 : : QUEUE_JOB_TYPE_FLOW_CREATE,
121 : : QUEUE_JOB_TYPE_FLOW_DESTROY,
122 : : QUEUE_JOB_TYPE_FLOW_TRANSFER,
123 : : QUEUE_JOB_TYPE_FLOW_UPDATE,
124 : : QUEUE_JOB_TYPE_ACTION_CREATE,
125 : : QUEUE_JOB_TYPE_ACTION_DESTROY,
126 : : QUEUE_JOB_TYPE_ACTION_UPDATE,
127 : : QUEUE_JOB_TYPE_ACTION_QUERY,
128 : : };
129 : :
130 : : enum noisy_fwd_mode {
131 : : NOISY_FWD_MODE_IO,
132 : : NOISY_FWD_MODE_MAC,
133 : : NOISY_FWD_MODE_MACSWAP,
134 : : NOISY_FWD_MODE_5TSWAP,
135 : : NOISY_FWD_MODE_MAX,
136 : : };
137 : :
138 : : /**
139 : : * Command line arguments parser sets `hairpin_multiport_mode` to True
140 : : * if explicit hairpin map configuration mode was used.
141 : : */
142 : : extern bool hairpin_multiport_mode;
143 : :
144 : : /** Hairpin maps list. */
145 : : struct hairpin_map;
146 : : extern void hairpin_add_multiport_map(struct hairpin_map *map);
147 : :
148 : : /**
149 : : * The data structure associated with RX and TX packet burst statistics
150 : : * that are recorded for each forwarding stream.
151 : : */
152 : : struct pkt_burst_stats {
153 : : unsigned int pkt_burst_spread[MAX_PKT_BURST + 1];
154 : : };
155 : :
156 : :
157 : : #define TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE 64
158 : : /** Information for a given RSS type. */
159 : : struct rss_type_info {
160 : : const char *str; /**< Type name. */
161 : : uint64_t rss_type; /**< Type value. */
162 : : };
163 : :
164 : : /**
165 : : * RSS type information table.
166 : : *
167 : : * An entry with a NULL type name terminates the list.
168 : : */
169 : : extern const struct rss_type_info rss_type_table[];
170 : :
171 : : /**
172 : : * Dynf name array.
173 : : *
174 : : * Array that holds the name for each dynf.
175 : : */
176 : : extern char dynf_names[64][RTE_MBUF_DYN_NAMESIZE];
177 : :
178 : : /**
179 : : * The data structure associated with a forwarding stream between a receive
180 : : * port/queue and a transmit port/queue.
181 : : */
182 : : struct fwd_stream {
183 : : /* "read-only" data */
184 : : portid_t rx_port; /**< port to poll for received packets */
185 : : queueid_t rx_queue; /**< RX queue to poll on "rx_port" */
186 : : portid_t tx_port; /**< forwarding port of received packets */
187 : : queueid_t tx_queue; /**< TX queue to send forwarded packets */
188 : : streamid_t peer_addr; /**< index of peer ethernet address of packets */
189 : : bool disabled; /**< the stream is disabled and should not run */
190 : :
191 : : unsigned int retry_enabled;
192 : :
193 : : /* "read-write" results */
194 : : uint64_t rx_packets; /**< received packets */
195 : : uint64_t tx_packets; /**< received packets transmitted */
196 : : uint64_t fwd_dropped; /**< received packets not forwarded */
197 : : uint64_t rx_bad_ip_csum ; /**< received packets has bad ip checksum */
198 : : uint64_t rx_bad_l4_csum ; /**< received packets has bad l4 checksum */
199 : : uint64_t rx_bad_outer_l4_csum;
200 : : /**< received packets has bad outer l4 checksum */
201 : : uint64_t rx_bad_outer_ip_csum;
202 : : /**< received packets having bad outer ip checksum */
203 : : uint64_t ts_skew; /**< TX scheduling timestamp */
204 : : #ifdef RTE_LIB_GRO
205 : : unsigned int gro_times; /**< GRO operation times */
206 : : #endif
207 : : uint64_t busy_cycles; /**< used with --record-core-cycles */
208 : : struct pkt_burst_stats rx_burst_stats;
209 : : struct pkt_burst_stats tx_burst_stats;
210 : : struct fwd_lcore *lcore; /**< Lcore being scheduled. */
211 : : /**< Rx queue information for recycling mbufs */
212 : : struct rte_eth_recycle_rxq_info recycle_rxq_info;
213 : : };
214 : :
215 : : /**
216 : : * Age action context types, must be included inside the age action
217 : : * context structure.
218 : : */
219 : : enum age_action_context_type {
220 : : ACTION_AGE_CONTEXT_TYPE_FLOW,
221 : : ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION,
222 : : };
223 : :
224 : : /** Descriptor for a template. */
225 : : struct port_template {
226 : : struct port_template *next; /**< Next template in list. */
227 : : struct port_template *tmp; /**< Temporary linking. */
228 : : uint32_t id; /**< Template ID. */
229 : : union {
230 : : struct rte_flow_pattern_template *pattern_template;
231 : : struct rte_flow_actions_template *actions_template;
232 : : } template; /**< PMD opaque template object */
233 : : };
234 : :
235 : : /** Descriptor for a flow table. */
236 : : struct port_table {
237 : : struct port_table *next; /**< Next table in list. */
238 : : struct port_table *tmp; /**< Temporary linking. */
239 : : uint32_t id; /**< Table ID. */
240 : : uint32_t nb_pattern_templates; /**< Number of pattern templates. */
241 : : uint32_t nb_actions_templates; /**< Number of actions templates. */
242 : : struct rte_flow_template_table_attr attr; /**< Table attributes. */
243 : : struct rte_flow_template_table *table; /**< PMD opaque template object */
244 : : };
245 : :
246 : : /** Descriptor for a single flow. */
247 : : struct port_flow {
248 : : struct port_flow *next; /**< Next flow in list. */
249 : : struct port_flow *tmp; /**< Temporary linking. */
250 : : uint64_t id; /**< Flow rule ID. */
251 : : uint64_t user_id; /**< User rule ID. */
252 : : struct port_table *table; /**< Flow table. */
253 : : struct rte_flow *flow; /**< Opaque flow object returned by PMD. */
254 : : struct rte_flow_conv_rule rule; /**< Saved flow rule description. */
255 : : enum age_action_context_type age_type; /**< Age action context type. */
256 : : uint8_t data[]; /**< Storage for flow rule description */
257 : : };
258 : :
259 : : /* Descriptor for indirect action */
260 : : struct port_indirect_action {
261 : : struct port_indirect_action *next; /**< Next flow in list. */
262 : : uint32_t id; /**< Indirect action ID. */
263 : : enum rte_flow_action_type type; /**< Action type. */
264 : : union {
265 : : struct rte_flow_action_handle *handle;
266 : : /**< Indirect action handle. */
267 : : struct rte_flow_action_list_handle *list_handle;
268 : : /**< Indirect action list handle*/
269 : : };
270 : : enum age_action_context_type age_type; /**< Age action context type. */
271 : : };
272 : :
273 : : /* Descriptor for action query data. */
274 : : union port_action_query {
275 : : struct rte_flow_query_count count;
276 : : struct rte_flow_query_age age;
277 : : struct rte_flow_action_conntrack ct;
278 : : struct rte_flow_query_quota quota;
279 : : };
280 : :
281 : : /* Descriptor for queue job. */
282 : : struct queue_job {
283 : : uint32_t type; /**< Job type. */
284 : : union {
285 : : struct port_flow *pf;
286 : : struct port_indirect_action *pia;
287 : : };
288 : : union port_action_query query;
289 : : };
290 : :
291 : : struct port_flow_tunnel {
292 : : LIST_ENTRY(port_flow_tunnel) chain;
293 : : struct rte_flow_action *pmd_actions;
294 : : struct rte_flow_item *pmd_items;
295 : : uint32_t id;
296 : : uint32_t num_pmd_actions;
297 : : uint32_t num_pmd_items;
298 : : struct rte_flow_tunnel tunnel;
299 : : struct rte_flow_action *actions;
300 : : struct rte_flow_item *items;
301 : : };
302 : :
303 : : struct tunnel_ops {
304 : : uint32_t id;
305 : : char type[16];
306 : : uint32_t enabled:1;
307 : : uint32_t actions:1;
308 : : uint32_t items:1;
309 : : };
310 : :
311 : : /** Information for an extended statistics to show. */
312 : : struct xstat_display_info {
313 : : /** Supported xstats IDs in the order of xstats_display */
314 : : uint64_t *ids_supp;
315 : : size_t ids_supp_sz;
316 : : uint64_t *prev_values;
317 : : uint64_t *curr_values;
318 : : uint64_t prev_ns;
319 : : bool allocated;
320 : : };
321 : :
322 : : /** RX queue configuration and state. */
323 : : struct port_rxqueue {
324 : : struct rte_eth_rxconf conf;
325 : : uint8_t state; /**< RTE_ETH_QUEUE_STATE_* value. */
326 : : };
327 : :
328 : : /** TX queue configuration and state. */
329 : : struct port_txqueue {
330 : : struct rte_eth_txconf conf;
331 : : uint8_t state; /**< RTE_ETH_QUEUE_STATE_* value. */
332 : : };
333 : :
334 : : /**
335 : : * The data structure associated with each port.
336 : : */
337 : : struct rte_port {
338 : : struct rte_eth_dev_info dev_info; /**< Device info + driver name */
339 : : struct rte_eth_conf dev_conf; /**< Port configuration. */
340 : : struct rte_ether_addr eth_addr; /**< Port ethernet address */
341 : : struct rte_eth_stats stats; /**< Last port statistics */
342 : : unsigned int socket_id; /**< For NUMA support */
343 : : uint16_t parse_tunnel:1; /**< Parse internal headers */
344 : : uint16_t tso_segsz; /**< Segmentation offload MSS for non-tunneled packets. */
345 : : uint16_t tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */
346 : : uint16_t tx_vlan_id;/**< The tag ID */
347 : : uint16_t tx_vlan_id_outer;/**< The outer tag ID */
348 : : volatile uint16_t port_status; /**< port started or not */
349 : : uint8_t need_setup; /**< port just attached */
350 : : uint8_t need_reconfig; /**< need reconfiguring port or not */
351 : : uint8_t need_reconfig_queues; /**< need reconfiguring queues or not */
352 : : uint8_t rss_flag; /**< enable rss or not */
353 : : uint8_t dcb_flag; /**< enable dcb */
354 : : uint16_t nb_rx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue rx desc number */
355 : : uint16_t nb_tx_desc[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue tx desc number */
356 : : struct port_rxqueue rxq[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue Rx config and state */
357 : : struct port_txqueue txq[RTE_MAX_QUEUES_PER_PORT+1]; /**< per queue Tx config and state */
358 : : struct rte_ether_addr *mc_addr_pool; /**< pool of multicast addrs */
359 : : uint32_t mc_addr_nb; /**< nb. of addr. in mc_addr_pool */
360 : : queueid_t queue_nb; /**< nb. of queues for flow rules */
361 : : uint32_t queue_sz; /**< size of a queue for flow rules */
362 : : uint8_t member_flag : 1, /**< bonding member port */
363 : : bond_flag : 1, /**< port is bond device */
364 : : fwd_mac_swap : 1, /**< swap packet MAC before forward */
365 : : update_conf : 1; /**< need to update bonding device configuration */
366 : : struct port_template *pattern_templ_list; /**< Pattern templates. */
367 : : struct port_template *actions_templ_list; /**< Actions templates. */
368 : : struct port_table *table_list; /**< Flow tables. */
369 : : struct port_flow *flow_list; /**< Associated flows. */
370 : : struct port_indirect_action *actions_list;
371 : : /**< Associated indirect actions. */
372 : : LIST_HEAD(, port_flow_tunnel) flow_tunnel_list;
373 : : const struct rte_eth_rxtx_callback *rx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
374 : : const struct rte_eth_rxtx_callback *tx_dump_cb[RTE_MAX_QUEUES_PER_PORT+1];
375 : : /**< metadata value to insert in Tx packets. */
376 : : uint32_t tx_metadata;
377 : : const struct rte_eth_rxtx_callback *tx_set_md_cb[RTE_MAX_QUEUES_PER_PORT+1];
378 : : /**< dynamic flags. */
379 : : uint64_t mbuf_dynf;
380 : : const struct rte_eth_rxtx_callback *tx_set_dynf_cb[RTE_MAX_QUEUES_PER_PORT+1];
381 : : struct xstat_display_info xstats_info;
382 : : };
383 : :
384 : : /**
385 : : * The data structure associated with each forwarding logical core.
386 : : * The logical cores are internally numbered by a core index from 0 to
387 : : * the maximum number of logical cores - 1.
388 : : * The system CPU identifier of all logical cores are setup in a global
389 : : * CPU id. configuration table.
390 : : */
391 : : struct fwd_lcore {
392 : : #ifdef RTE_LIB_GSO
393 : : struct rte_gso_ctx gso_ctx; /**< GSO context */
394 : : #endif
395 : : struct rte_mempool *mbp; /**< The mbuf pool to use by this core */
396 : : #ifdef RTE_LIB_GRO
397 : : void *gro_ctx; /**< GRO context */
398 : : #endif
399 : : streamid_t stream_idx; /**< index of 1st stream in "fwd_streams" */
400 : : streamid_t stream_nb; /**< number of streams in "fwd_streams" */
401 : : lcoreid_t cpuid_idx; /**< index of logical core in CPU id table */
402 : : volatile char stopped; /**< stop forwarding when set */
403 : : uint64_t total_cycles; /**< used with --record-core-cycles */
404 : : };
405 : :
406 : : /*
407 : : * Forwarding mode operations:
408 : : * - IO forwarding mode (default mode)
409 : : * Forwards packets unchanged.
410 : : *
411 : : * - MAC forwarding mode
412 : : * Set the source and the destination Ethernet addresses of packets
413 : : * before forwarding them.
414 : : *
415 : : * - IEEE1588 forwarding mode
416 : : * Check that received IEEE1588 Precise Time Protocol (PTP) packets are
417 : : * filtered and timestamped by the hardware.
418 : : * Forwards packets unchanged on the same port.
419 : : * Check that sent IEEE1588 PTP packets are timestamped by the hardware.
420 : : */
421 : : typedef int (*port_fwd_begin_t)(portid_t pi);
422 : : typedef void (*port_fwd_end_t)(portid_t pi);
423 : : typedef void (*stream_init_t)(struct fwd_stream *fs);
424 : : typedef bool (*packet_fwd_t)(struct fwd_stream *fs);
425 : :
426 : : struct fwd_engine {
427 : : const char *fwd_mode_name; /**< Forwarding mode name. */
428 : : port_fwd_begin_t port_fwd_begin; /**< NULL if nothing special to do. */
429 : : port_fwd_end_t port_fwd_end; /**< NULL if nothing special to do. */
430 : : stream_init_t stream_init; /**< NULL if nothing special to do. */
431 : : packet_fwd_t packet_fwd; /**< Mandatory. */
432 : : const char *status; /**< NULL if nothing to display. */
433 : : };
434 : :
435 : : void common_fwd_stream_init(struct fwd_stream *fs);
436 : :
437 : : #define FLEX_ITEM_MAX_SAMPLES_NUM 16
438 : : #define FLEX_ITEM_MAX_LINKS_NUM 16
439 : : #define FLEX_MAX_FLOW_PATTERN_LENGTH 64
440 : : #define FLEX_MAX_PARSERS_NUM 8
441 : : #define FLEX_MAX_PATTERNS_NUM 64
442 : : #define FLEX_PARSER_ERR ((struct flex_item *)-1)
443 : :
444 : : struct flex_item {
445 : : struct rte_flow_item_flex_conf flex_conf;
446 : : struct rte_flow_item_flex_handle *flex_handle;
447 : : uint32_t flex_id;
448 : : };
449 : :
450 : : struct flex_pattern {
451 : : struct rte_flow_item_flex spec, mask;
452 : : uint8_t spec_pattern[FLEX_MAX_FLOW_PATTERN_LENGTH];
453 : : uint8_t mask_pattern[FLEX_MAX_FLOW_PATTERN_LENGTH];
454 : : };
455 : : extern struct flex_item *flex_items[RTE_MAX_ETHPORTS][FLEX_MAX_PARSERS_NUM];
456 : : extern struct flex_pattern flex_patterns[FLEX_MAX_PATTERNS_NUM];
457 : :
458 : : #define BURST_TX_WAIT_US 1
459 : : #define BURST_TX_RETRIES 64
460 : :
461 : : extern uint32_t burst_tx_delay_time;
462 : : extern uint32_t burst_tx_retry_num;
463 : :
464 : : extern struct fwd_engine io_fwd_engine;
465 : : extern struct fwd_engine mac_fwd_engine;
466 : : extern struct fwd_engine mac_swap_engine;
467 : : extern struct fwd_engine flow_gen_engine;
468 : : extern struct fwd_engine rx_only_engine;
469 : : extern struct fwd_engine tx_only_engine;
470 : : extern struct fwd_engine csum_fwd_engine;
471 : : extern struct fwd_engine icmp_echo_engine;
472 : : extern struct fwd_engine noisy_vnf_engine;
473 : : extern struct fwd_engine five_tuple_swap_fwd_engine;
474 : : extern struct fwd_engine recycle_mbufs_engine;
475 : : #ifdef RTE_LIBRTE_IEEE1588
476 : : extern struct fwd_engine ieee1588_fwd_engine;
477 : : #endif
478 : : extern struct fwd_engine shared_rxq_engine;
479 : :
480 : : extern struct fwd_engine * fwd_engines[]; /**< NULL terminated array. */
481 : : extern cmdline_parse_inst_t cmd_set_raw;
482 : : extern cmdline_parse_inst_t cmd_show_set_raw;
483 : : extern cmdline_parse_inst_t cmd_show_set_raw_all;
484 : : extern cmdline_parse_inst_t cmd_set_flex_is_pattern;
485 : : extern cmdline_parse_inst_t cmd_set_flex_spec_pattern;
486 : :
487 : : #define DEFAULT_DCB_FWD_TC_MASK 0xFF
488 : : extern uint8_t dcb_fwd_tc_mask;
489 : : extern uint8_t dcb_fwd_tc_cores;
490 : :
491 : : extern uint16_t mempool_flags;
492 : :
493 : : /**
494 : : * Forwarding Configuration
495 : : *
496 : : */
497 : : struct fwd_config {
498 : : struct fwd_engine *fwd_eng; /**< Packet forwarding mode. */
499 : : streamid_t nb_fwd_streams; /**< Nb. of forward streams to process. */
500 : : lcoreid_t nb_fwd_lcores; /**< Nb. of logical cores to launch. */
501 : : portid_t nb_fwd_ports; /**< Nb. of ports involved. */
502 : : };
503 : :
504 : : /**
505 : : * DCB mode enable
506 : : */
507 : : enum dcb_mode_enable
508 : : {
509 : : DCB_VT_ENABLED,
510 : : DCB_ENABLED
511 : : };
512 : :
513 : : extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */
514 : : extern uint8_t xstats_hide_disabled; /**< Hide disabled xstat for xstats display */
515 : : extern uint8_t xstats_show_state; /**< Show xstat state in xstats display */
516 : :
517 : : /* globals used for configuration */
518 : : extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */
519 : : extern uint8_t record_burst_stats; /**< Enables display of RX and TX bursts */
520 : : extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */
521 : : extern int testpmd_logtype; /**< Log type for testpmd logs */
522 : : extern uint8_t interactive;
523 : : extern uint8_t auto_start;
524 : : extern uint8_t tx_first;
525 : : extern struct cmdline_file_info cmdline_files[MAX_CMDLINE_FILENAMES]; /**< offline commands files */
526 : : extern unsigned int cmdline_file_count; /**< number of cmdline files */
527 : : extern uint8_t numa_support; /**< set by "--numa" parameter */
528 : : extern uint16_t port_topology; /**< set by "--port-topology" parameter */
529 : : extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */
530 : : extern uint8_t flow_isolate_all; /**< set by "--flow-isolate-all */
531 : : extern uint8_t no_flow_flush; /**< set by "--disable-flow-flush" parameter */
532 : : extern uint8_t mp_alloc_type;
533 : : /**< set by "--mp-anon" or "--mp-alloc" parameter */
534 : : extern uint32_t eth_link_speed;
535 : : extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
536 : : extern uint8_t no_device_start; /**<set by "--disable-device-start" parameter */
537 : : extern volatile int test_done; /* stop packet forwarding when set to 1. */
538 : : extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
539 : : extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
540 : : extern uint32_t event_print_mask;
541 : : /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
542 : : extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */
543 : : extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
544 : : extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */
545 : : extern uint8_t clear_ptypes; /**< disabled by set ptype cmd */
546 : :
547 : : /*
548 : : * Store specified sockets on which memory pool to be used by ports
549 : : * is allocated.
550 : : */
551 : : extern uint8_t port_numa[RTE_MAX_ETHPORTS];
552 : :
553 : : /*
554 : : * Store specified sockets on which RX ring to be used by ports
555 : : * is allocated.
556 : : */
557 : : extern uint8_t rxring_numa[RTE_MAX_ETHPORTS];
558 : :
559 : : /*
560 : : * Store specified sockets on which TX ring to be used by ports
561 : : * is allocated.
562 : : */
563 : : extern uint8_t txring_numa[RTE_MAX_ETHPORTS];
564 : :
565 : : extern uint8_t socket_num;
566 : :
567 : : /*
568 : : * Configuration of logical cores:
569 : : * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores
570 : : */
571 : : extern lcoreid_t nb_lcores; /**< Number of logical cores probed at init time. */
572 : : extern lcoreid_t nb_cfg_lcores; /**< Number of configured logical cores. */
573 : : extern lcoreid_t nb_fwd_lcores; /**< Number of forwarding logical cores. */
574 : : extern unsigned int fwd_lcores_cpuids[RTE_MAX_LCORE];
575 : : extern unsigned int num_sockets;
576 : : extern unsigned int socket_ids[RTE_MAX_NUMA_NODES];
577 : :
578 : : /*
579 : : * Configuration of Ethernet ports:
580 : : * nb_fwd_ports <= nb_cfg_ports <= nb_ports
581 : : */
582 : : extern portid_t nb_ports; /**< Number of ethernet ports probed at init time. */
583 : : extern portid_t nb_cfg_ports; /**< Number of configured ports. */
584 : : extern portid_t nb_fwd_ports; /**< Number of forwarding ports. */
585 : : extern portid_t fwd_ports_ids[RTE_MAX_ETHPORTS];
586 : : extern struct rte_port *ports;
587 : :
588 : : extern struct rte_eth_rxmode rx_mode;
589 : : extern struct rte_eth_txmode tx_mode;
590 : :
591 : : extern uint64_t rss_hf;
592 : : extern bool force_rss;
593 : :
594 : : extern queueid_t nb_hairpinq;
595 : : extern queueid_t nb_rxq;
596 : : extern queueid_t nb_txq;
597 : :
598 : : extern uint16_t nb_rxd;
599 : : extern uint16_t nb_txd;
600 : :
601 : : extern int16_t rx_free_thresh;
602 : : extern int8_t rx_drop_en;
603 : : extern int16_t tx_free_thresh;
604 : : extern int16_t tx_rs_thresh;
605 : :
606 : : extern enum noisy_fwd_mode noisy_fwd_mode;
607 : : extern const char * const noisy_fwd_mode_desc[];
608 : : extern uint16_t noisy_tx_sw_bufsz;
609 : : extern uint16_t noisy_tx_sw_buf_flush_time;
610 : : extern uint64_t noisy_lkup_mem_sz;
611 : : extern uint64_t noisy_lkup_num_writes;
612 : : extern uint64_t noisy_lkup_num_reads;
613 : : extern uint64_t noisy_lkup_num_reads_writes;
614 : :
615 : : extern uint8_t dcb_config;
616 : :
617 : : extern uint32_t mbuf_data_size_n;
618 : : extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
619 : : /**< Mbuf data space size. */
620 : : extern uint32_t param_total_num_mbufs;
621 : :
622 : : extern uint16_t stats_period;
623 : :
624 : : extern struct rte_eth_xstat_name *xstats_display;
625 : : extern unsigned int xstats_display_num;
626 : :
627 : : extern uint32_t hairpin_mode;
628 : :
629 : : #ifdef RTE_LIB_LATENCYSTATS
630 : : extern uint8_t latencystats_enabled;
631 : : extern lcoreid_t latencystats_lcore_id;
632 : : #endif
633 : :
634 : : #ifdef RTE_LIB_BITRATESTATS
635 : : extern lcoreid_t bitrate_lcore_id;
636 : : extern uint8_t bitrate_enabled;
637 : : #endif
638 : :
639 : : extern uint32_t max_rx_pkt_len;
640 : :
641 : : /*
642 : : * Configuration of packet segments used to scatter received packets
643 : : * if some of split features is configured.
644 : : */
645 : : extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
646 : : extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
647 : : extern uint8_t rx_pkt_nb_segs; /**< Number of segments to split */
648 : : extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
649 : : extern uint8_t rx_pkt_nb_offs; /**< Number of specified offsets */
650 : :
651 : : extern uint8_t multi_rx_mempool; /**< Enables multi-rx-mempool feature. */
652 : :
653 : : /*
654 : : * Configuration of packet segments used by the "txonly" processing engine.
655 : : */
656 : : #define TXONLY_DEF_PACKET_LEN 64
657 : : extern uint16_t tx_pkt_length; /**< Length of TXONLY packet */
658 : : extern uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */
659 : : extern uint8_t tx_pkt_nb_segs; /**< Number of segments in TX packets */
660 : : extern uint32_t tx_pkt_times_intra;
661 : : extern uint32_t tx_pkt_times_inter;
662 : :
663 : : enum tx_pkt_split {
664 : : TX_PKT_SPLIT_OFF,
665 : : TX_PKT_SPLIT_ON,
666 : : TX_PKT_SPLIT_RND,
667 : : };
668 : :
669 : : extern enum tx_pkt_split tx_pkt_split;
670 : :
671 : : extern uint8_t txonly_multi_flow;
672 : :
673 : : extern uint32_t rxq_share;
674 : :
675 : : extern uint16_t nb_pkt_per_burst;
676 : : extern uint16_t nb_pkt_flowgen_clones;
677 : : extern int nb_flows_flowgen;
678 : : extern uint16_t mb_mempool_cache;
679 : : extern int8_t rx_pthresh;
680 : : extern int8_t rx_hthresh;
681 : : extern int8_t rx_wthresh;
682 : : extern int8_t tx_pthresh;
683 : : extern int8_t tx_hthresh;
684 : : extern int8_t tx_wthresh;
685 : :
686 : : extern uint16_t tx_udp_src_port;
687 : : extern uint16_t tx_udp_dst_port;
688 : :
689 : : extern uint32_t tx_ip_src_addr;
690 : : extern uint32_t tx_ip_dst_addr;
691 : :
692 : : extern struct fwd_config cur_fwd_config;
693 : : extern struct fwd_engine *cur_fwd_eng;
694 : : extern uint32_t retry_enabled;
695 : : extern struct fwd_lcore **fwd_lcores;
696 : : extern struct fwd_stream **fwd_streams;
697 : :
698 : : extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */
699 : : extern uint16_t geneve_udp_port; /**< UDP port of tunnel GENEVE. */
700 : :
701 : : extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
702 : : extern struct rte_ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
703 : :
704 : : extern uint32_t burst_tx_delay_time; /**< Burst tx delay time(us) for mac-retry. */
705 : : extern uint32_t burst_tx_retry_num; /**< Burst tx retry number for mac-retry. */
706 : :
707 : : #ifdef RTE_LIB_GRO
708 : : #define GRO_DEFAULT_ITEM_NUM_PER_FLOW 32
709 : : #define GRO_DEFAULT_FLOW_NUM (RTE_GRO_MAX_BURST_ITEM_NUM / \
710 : : GRO_DEFAULT_ITEM_NUM_PER_FLOW)
711 : :
712 : : #define GRO_DEFAULT_FLUSH_CYCLES 1
713 : : #define GRO_MAX_FLUSH_CYCLES 4
714 : :
715 : : struct gro_status {
716 : : struct rte_gro_param param;
717 : : uint8_t enable;
718 : : };
719 : : extern struct gro_status gro_ports[RTE_MAX_ETHPORTS];
720 : : extern uint8_t gro_flush_cycles;
721 : : #endif /* RTE_LIB_GRO */
722 : :
723 : : #ifdef RTE_LIB_GSO
724 : : #define GSO_MAX_PKT_BURST 2048
725 : : struct gso_status {
726 : : uint8_t enable;
727 : : };
728 : : extern struct gso_status gso_ports[RTE_MAX_ETHPORTS];
729 : : extern uint16_t gso_max_segment_size;
730 : : #endif /* RTE_LIB_GSO */
731 : :
732 : : /* VXLAN encap/decap parameters. */
733 : : struct vxlan_encap_conf {
734 : : uint32_t select_ipv4:1;
735 : : uint32_t select_vlan:1;
736 : : uint32_t select_tos_ttl:1;
737 : : uint8_t vni[3];
738 : : rte_be16_t udp_src;
739 : : rte_be16_t udp_dst;
740 : : rte_be32_t ipv4_src;
741 : : rte_be32_t ipv4_dst;
742 : : struct rte_ipv6_addr ipv6_src;
743 : : struct rte_ipv6_addr ipv6_dst;
744 : : rte_be16_t vlan_tci;
745 : : uint8_t ip_tos;
746 : : uint8_t ip_ttl;
747 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
748 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
749 : : };
750 : :
751 : : extern struct vxlan_encap_conf vxlan_encap_conf;
752 : :
753 : : /* NVGRE encap/decap parameters. */
754 : : struct nvgre_encap_conf {
755 : : uint32_t select_ipv4:1;
756 : : uint32_t select_vlan:1;
757 : : uint8_t tni[3];
758 : : rte_be32_t ipv4_src;
759 : : rte_be32_t ipv4_dst;
760 : : struct rte_ipv6_addr ipv6_src;
761 : : struct rte_ipv6_addr ipv6_dst;
762 : : rte_be16_t vlan_tci;
763 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
764 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
765 : : };
766 : :
767 : : extern struct nvgre_encap_conf nvgre_encap_conf;
768 : :
769 : : /* L2 encap parameters. */
770 : : struct l2_encap_conf {
771 : : uint32_t select_ipv4:1;
772 : : uint32_t select_vlan:1;
773 : : rte_be16_t vlan_tci;
774 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
775 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
776 : : };
777 : : extern struct l2_encap_conf l2_encap_conf;
778 : :
779 : : /* L2 decap parameters. */
780 : : struct l2_decap_conf {
781 : : uint32_t select_vlan:1;
782 : : };
783 : : extern struct l2_decap_conf l2_decap_conf;
784 : :
785 : : /* MPLSoGRE encap parameters. */
786 : : struct mplsogre_encap_conf {
787 : : uint32_t select_ipv4:1;
788 : : uint32_t select_vlan:1;
789 : : uint8_t label[3];
790 : : rte_be32_t ipv4_src;
791 : : rte_be32_t ipv4_dst;
792 : : struct rte_ipv6_addr ipv6_src;
793 : : struct rte_ipv6_addr ipv6_dst;
794 : : rte_be16_t vlan_tci;
795 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
796 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
797 : : };
798 : : extern struct mplsogre_encap_conf mplsogre_encap_conf;
799 : :
800 : : /* MPLSoGRE decap parameters. */
801 : : struct mplsogre_decap_conf {
802 : : uint32_t select_ipv4:1;
803 : : uint32_t select_vlan:1;
804 : : };
805 : : extern struct mplsogre_decap_conf mplsogre_decap_conf;
806 : :
807 : : /* MPLSoUDP encap parameters. */
808 : : struct mplsoudp_encap_conf {
809 : : uint32_t select_ipv4:1;
810 : : uint32_t select_vlan:1;
811 : : uint8_t label[3];
812 : : rte_be16_t udp_src;
813 : : rte_be16_t udp_dst;
814 : : rte_be32_t ipv4_src;
815 : : rte_be32_t ipv4_dst;
816 : : struct rte_ipv6_addr ipv6_src;
817 : : struct rte_ipv6_addr ipv6_dst;
818 : : rte_be16_t vlan_tci;
819 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
820 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
821 : : };
822 : : extern struct mplsoudp_encap_conf mplsoudp_encap_conf;
823 : :
824 : : /* MPLSoUDP decap parameters. */
825 : : struct mplsoudp_decap_conf {
826 : : uint32_t select_ipv4:1;
827 : : uint32_t select_vlan:1;
828 : : };
829 : : extern struct mplsoudp_decap_conf mplsoudp_decap_conf;
830 : :
831 : : extern enum rte_eth_rx_mq_mode rx_mq_mode;
832 : :
833 : : extern struct rte_flow_action_conntrack conntrack_context;
834 : :
835 : : extern int proc_id;
836 : : extern unsigned int num_procs;
837 : :
838 : : static inline bool
839 : : is_proc_primary(void)
840 : : {
841 : 0 : return rte_eal_process_type() == RTE_PROC_PRIMARY;
842 : : }
843 : :
844 : : static inline struct fwd_lcore *
845 : : lcore_to_fwd_lcore(uint16_t lcore_id)
846 : : {
847 : : unsigned int i;
848 : :
849 : 0 : for (i = 0; i < cur_fwd_config.nb_fwd_lcores; ++i) {
850 : 0 : if (fwd_lcores_cpuids[i] == lcore_id)
851 : 0 : return fwd_lcores[i];
852 : : }
853 : :
854 : : return NULL;
855 : : }
856 : :
857 : : static inline struct fwd_lcore *
858 : 0 : current_fwd_lcore(void)
859 : : {
860 : : struct fwd_lcore *fc = lcore_to_fwd_lcore(rte_lcore_id());
861 : :
862 : 0 : if (fc == NULL)
863 : 0 : rte_panic("lcore_id of current thread not found in fwd_lcores_cpuids\n");
864 : :
865 : 0 : return fc;
866 : : }
867 : :
868 : : void
869 : : parse_fwd_portlist(const char *port);
870 : :
871 : : /* Mbuf Pools */
872 : : static inline void
873 : 0 : mbuf_poolname_build(unsigned int sock_id, char *mp_name,
874 : : int name_size, uint16_t idx)
875 : : {
876 : 0 : if (!idx)
877 : 0 : snprintf(mp_name, name_size,
878 : : MBUF_POOL_NAME_PFX "_%u", sock_id);
879 : : else
880 : 0 : snprintf(mp_name, name_size,
881 : : MBUF_POOL_NAME_PFX "_%hu_%hu", (uint16_t)sock_id, idx);
882 : 0 : }
883 : :
884 : : static inline struct rte_mempool *
885 : : mbuf_pool_find(unsigned int sock_id, uint16_t idx)
886 : : {
887 : : char pool_name[RTE_MEMPOOL_NAMESIZE];
888 : :
889 : 0 : mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
890 : 0 : return rte_mempool_lookup((const char *)pool_name);
891 : : }
892 : :
893 : : static inline uint16_t
894 : 0 : common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst,
895 : : unsigned int nb_pkts)
896 : : {
897 : : uint16_t nb_rx;
898 : :
899 : 0 : nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, burst, nb_pkts);
900 : 0 : if (record_burst_stats)
901 : 0 : fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
902 : 0 : fs->rx_packets += nb_rx;
903 : 0 : return nb_rx;
904 : : }
905 : :
906 : : static inline uint16_t
907 : 0 : common_fwd_stream_transmit(struct fwd_stream *fs, struct rte_mbuf **burst,
908 : : unsigned int nb_pkts)
909 : : {
910 : : uint16_t nb_tx;
911 : : uint32_t retry;
912 : :
913 : 0 : nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, burst, nb_pkts);
914 : : /*
915 : : * Retry if necessary
916 : : */
917 : 0 : if (unlikely(nb_tx < nb_pkts) && fs->retry_enabled) {
918 : : retry = 0;
919 : 0 : while (nb_tx < nb_pkts && retry++ < burst_tx_retry_num) {
920 : 0 : rte_delay_us(burst_tx_delay_time);
921 : 0 : nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue,
922 : 0 : &burst[nb_tx], nb_pkts - nb_tx);
923 : : }
924 : : }
925 : 0 : fs->tx_packets += nb_tx;
926 : 0 : if (record_burst_stats)
927 : 0 : fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
928 : 0 : if (unlikely(nb_tx < nb_pkts)) {
929 : 0 : fs->fwd_dropped += (nb_pkts - nb_tx);
930 : 0 : rte_pktmbuf_free_bulk(&burst[nb_tx], nb_pkts - nb_tx);
931 : : }
932 : :
933 : 0 : return nb_tx;
934 : : }
935 : :
936 : : /* Prototypes */
937 : : unsigned int parse_item_list(const char *str, const char *item_name,
938 : : unsigned int max_items,
939 : : unsigned int *parsed_items, int check_unique_values);
940 : : unsigned int parse_hdrs_list(const char *str, const char *item_name,
941 : : unsigned int max_item,
942 : : unsigned int *parsed_items);
943 : : void launch_args_parse(int argc, char** argv);
944 : : void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
945 : : int cmdline_read_from_file(const char *filename, bool echo);
946 : : int init_cmdline(void);
947 : : void prompt(void);
948 : : void prompt_exit(void);
949 : : void nic_stats_display(portid_t port_id);
950 : : void nic_stats_clear(portid_t port_id);
951 : : void nic_xstats_display(portid_t port_id);
952 : : void nic_xstats_clear(portid_t port_id);
953 : : void nic_xstats_set_counter(portid_t port_id, char *counter_name, int on);
954 : : void device_infos_display(const char *identifier);
955 : : void port_infos_display(portid_t port_id);
956 : : void port_summary_display(portid_t port_id);
957 : : void port_eeprom_display(portid_t port_id);
958 : : void port_eeprom_set(portid_t port_id, uint32_t magic, uint32_t offset,
959 : : uint32_t length, uint8_t *value);
960 : : void port_module_eeprom_display(portid_t port_id);
961 : : void port_summary_header_display(void);
962 : : void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
963 : : void tx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
964 : : void fwd_lcores_config_display(void);
965 : : bool pkt_fwd_shared_rxq_check(void);
966 : : void pkt_fwd_config_display(struct fwd_config *cfg);
967 : : void rxtx_config_display(void);
968 : : void fwd_config_setup(void);
969 : : void set_def_fwd_config(void);
970 : : void reconfig(portid_t new_port_id, unsigned socket_id);
971 : : int init_fwd_streams(void);
972 : : void update_fwd_ports(portid_t new_pid);
973 : :
974 : : void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
975 : : void set_dev_led(portid_t port_id, bool active);
976 : :
977 : : void port_mtu_set(portid_t port_id, uint16_t mtu);
978 : : int port_action_handle_create(portid_t port_id, uint32_t id, bool indirect_list,
979 : : const struct rte_flow_indir_action_conf *conf,
980 : : const struct rte_flow_action *action);
981 : : int port_action_handle_destroy(portid_t port_id,
982 : : uint32_t n, const uint32_t *action);
983 : : int port_action_handle_flush(portid_t port_id);
984 : : struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
985 : : uint32_t id);
986 : : int port_action_handle_update(portid_t port_id, uint32_t id,
987 : : const struct rte_flow_action *action);
988 : : void
989 : : port_action_handle_query_update(portid_t port_id, uint32_t id,
990 : : enum rte_flow_query_update_mode qu_mode,
991 : : const struct rte_flow_action *action);
992 : : int port_flow_get_info(portid_t port_id);
993 : : int port_flow_configure(portid_t port_id,
994 : : const struct rte_flow_port_attr *port_attr,
995 : : uint16_t nb_queue,
996 : : const struct rte_flow_queue_attr *queue_attr);
997 : : int port_flow_pattern_template_create(portid_t port_id, uint32_t id,
998 : : const struct rte_flow_pattern_template_attr *attr,
999 : : const struct rte_flow_item *pattern);
1000 : : int port_flow_pattern_template_destroy(portid_t port_id, uint32_t n,
1001 : : const uint32_t *template);
1002 : : int port_flow_pattern_template_flush(portid_t port_id);
1003 : : int port_flow_actions_template_create(portid_t port_id, uint32_t id,
1004 : : const struct rte_flow_actions_template_attr *attr,
1005 : : const struct rte_flow_action *actions,
1006 : : const struct rte_flow_action *masks);
1007 : : int port_flow_actions_template_destroy(portid_t port_id, uint32_t n,
1008 : : const uint32_t *template);
1009 : : int port_flow_actions_template_flush(portid_t port_id);
1010 : : int port_flow_template_table_create(portid_t port_id, uint32_t id,
1011 : : const struct rte_flow_template_table_attr *table_attr,
1012 : : uint32_t nb_pattern_templates, uint32_t *pattern_templates,
1013 : : uint32_t nb_actions_templates, uint32_t *actions_templates);
1014 : : int port_flow_template_table_destroy(portid_t port_id,
1015 : : uint32_t n, const uint32_t *table);
1016 : : int port_queue_flow_update_resized(portid_t port_id, queueid_t queue_id,
1017 : : bool postpone, uint32_t flow_id);
1018 : : int port_flow_template_table_flush(portid_t port_id);
1019 : : int port_flow_template_table_resize_complete(portid_t port_id, uint32_t table_id);
1020 : : int port_flow_template_table_resize(portid_t port_id,
1021 : : uint32_t table_id, uint32_t flows_num);
1022 : : int port_queue_group_set_miss_actions(portid_t port_id, const struct rte_flow_attr *attr,
1023 : : const struct rte_flow_action *actions);
1024 : : int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
1025 : : bool postpone, uint32_t table_id, uint32_t rule_idx,
1026 : : uint32_t pattern_idx, uint32_t actions_idx,
1027 : : const struct rte_flow_item *pattern,
1028 : : const struct rte_flow_action *actions);
1029 : : int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
1030 : : bool postpone, uint32_t n, const uint64_t *rule);
1031 : : int port_queue_flow_update(portid_t port_id, queueid_t queue_id,
1032 : : bool postpone, uint32_t rule_idx, uint32_t actions_idx,
1033 : : const struct rte_flow_action *actions);
1034 : : int port_queue_action_handle_create(portid_t port_id, uint32_t queue_id,
1035 : : bool postpone, uint32_t id,
1036 : : bool indirect_list,
1037 : : const struct rte_flow_indir_action_conf *conf,
1038 : : const struct rte_flow_action *action);
1039 : : int port_queue_action_handle_destroy(portid_t port_id,
1040 : : uint32_t queue_id, bool postpone,
1041 : : uint32_t n, const uint32_t *action);
1042 : : int port_queue_action_handle_update(portid_t port_id, uint32_t queue_id,
1043 : : bool postpone, uint32_t id,
1044 : : const struct rte_flow_action *action);
1045 : : int port_queue_action_handle_query(portid_t port_id, uint32_t queue_id,
1046 : : bool postpone, uint32_t id);
1047 : : void
1048 : : port_queue_action_handle_query_update(portid_t port_id,
1049 : : uint32_t queue_id, bool postpone,
1050 : : uint32_t id,
1051 : : enum rte_flow_query_update_mode qu_mode,
1052 : : const struct rte_flow_action *action);
1053 : : int port_queue_flow_push(portid_t port_id, queueid_t queue_id);
1054 : : int port_queue_flow_pull(portid_t port_id, queueid_t queue_id);
1055 : : int port_flow_hash_calc(portid_t port_id, uint32_t table_id,
1056 : : uint8_t pattern_template_index, const struct rte_flow_item pattern[]);
1057 : : int port_flow_hash_calc_encap(portid_t port_id,
1058 : : enum rte_flow_encap_hash_field encap_hash_field,
1059 : : const struct rte_flow_item pattern[]);
1060 : : void port_queue_flow_aged(portid_t port_id, uint32_t queue_id, uint8_t destroy);
1061 : : int port_flow_validate(portid_t port_id,
1062 : : const struct rte_flow_attr *attr,
1063 : : const struct rte_flow_item *pattern,
1064 : : const struct rte_flow_action *actions,
1065 : : const struct tunnel_ops *tunnel_ops);
1066 : : int port_flow_create(portid_t port_id,
1067 : : const struct rte_flow_attr *attr,
1068 : : const struct rte_flow_item *pattern,
1069 : : const struct rte_flow_action *actions,
1070 : : const struct tunnel_ops *tunnel_ops,
1071 : : uintptr_t user_id);
1072 : : int port_action_handle_query(portid_t port_id, uint32_t id);
1073 : : void update_age_action_context(const struct rte_flow_action *actions,
1074 : : struct port_flow *pf);
1075 : : int mcast_addr_pool_destroy(portid_t port_id);
1076 : : int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule,
1077 : : bool is_user_id);
1078 : : int port_flow_update(portid_t port_id, uint32_t rule,
1079 : : const struct rte_flow_action *actions, bool is_user_id);
1080 : : int port_flow_flush(portid_t port_id);
1081 : : int port_flow_dump(portid_t port_id, bool dump_all,
1082 : : uint64_t rule, const char *file_name,
1083 : : bool is_user_id);
1084 : : int port_flow_query(portid_t port_id, uint64_t rule,
1085 : : const struct rte_flow_action *action, bool is_user_id);
1086 : : void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
1087 : : void port_flow_aged(portid_t port_id, uint8_t destroy);
1088 : : const char *port_flow_tunnel_type(struct rte_flow_tunnel *tunnel);
1089 : : struct port_flow_tunnel *
1090 : : port_flow_locate_tunnel(uint16_t port_id, struct rte_flow_tunnel *tun);
1091 : : void port_flow_tunnel_list(portid_t port_id);
1092 : : void port_flow_tunnel_destroy(portid_t port_id, uint32_t tunnel_id);
1093 : : void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops);
1094 : : int port_flow_isolate(portid_t port_id, int set);
1095 : : int port_meter_policy_add(portid_t port_id, uint32_t policy_id,
1096 : : const struct rte_flow_action *actions);
1097 : : struct rte_flow_meter_profile *port_meter_profile_get_by_id(portid_t port_id,
1098 : : uint32_t id);
1099 : : struct rte_flow_meter_policy *port_meter_policy_get_by_id(portid_t port_id,
1100 : : uint32_t id);
1101 : :
1102 : : void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id);
1103 : : void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id);
1104 : :
1105 : : int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc);
1106 : : int set_fwd_lcores_mask(uint64_t lcoremask);
1107 : : void set_fwd_lcores_number(uint16_t nb_lc);
1108 : :
1109 : : void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt);
1110 : : void set_fwd_ports_mask(uint64_t portmask);
1111 : : void set_fwd_ports_number(uint16_t nb_pt);
1112 : : int port_is_forwarding(portid_t port_id);
1113 : :
1114 : : void rx_vlan_strip_set(portid_t port_id, int on);
1115 : : void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on);
1116 : :
1117 : : void rx_vlan_filter_set(portid_t port_id, int on);
1118 : : void rx_vlan_all_filter_set(portid_t port_id, int on);
1119 : : void rx_vlan_qinq_strip_set(portid_t port_id, int on);
1120 : : int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on);
1121 : : void vlan_extend_set(portid_t port_id, int on);
1122 : : void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
1123 : : uint16_t tp_id);
1124 : : void tx_vlan_set(portid_t port_id, uint16_t vlan_id);
1125 : : void tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer);
1126 : : void tx_vlan_reset(portid_t port_id);
1127 : : void tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on);
1128 : :
1129 : : void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value);
1130 : :
1131 : : void set_xstats_hide_zero(uint8_t on_off);
1132 : : void set_xstats_show_state(uint8_t on_off);
1133 : : void set_xstats_hide_disabled(uint8_t on_off);
1134 : :
1135 : : void set_record_core_cycles(uint8_t on_off);
1136 : : void set_record_burst_stats(uint8_t on_off);
1137 : : void set_verbose_level(uint16_t vb_level);
1138 : : void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
1139 : : void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs);
1140 : : void show_rx_pkt_hdrs(void);
1141 : : void show_rx_pkt_segments(void);
1142 : : void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
1143 : : void show_rx_pkt_offsets(void);
1144 : : void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
1145 : : void show_tx_pkt_segments(void);
1146 : : void set_tx_pkt_times(unsigned int *tx_times);
1147 : : void show_tx_pkt_times(void);
1148 : : void set_tx_pkt_split(const char *name);
1149 : : int parse_fec_mode(const char *name, uint32_t *fec_capa);
1150 : : void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa);
1151 : : void set_nb_pkt_per_burst(uint16_t pkt_burst);
1152 : : char *list_pkt_forwarding_modes(void);
1153 : : char *list_pkt_forwarding_retry_modes(void);
1154 : : void set_pkt_forwarding_mode(const char *fwd_mode);
1155 : : void start_packet_forwarding(int with_tx_first);
1156 : : void fwd_stats_display(void);
1157 : : void fwd_stats_reset(void);
1158 : : void stop_packet_forwarding(void);
1159 : : void dev_set_link_up(portid_t pid);
1160 : : void dev_set_link_down(portid_t pid);
1161 : : void init_port_config(void);
1162 : : void set_port_member_flag(portid_t member_pid);
1163 : : void clear_port_member_flag(portid_t member_pid);
1164 : : uint8_t port_is_bonding_member(portid_t member_pid);
1165 : :
1166 : : int init_port_dcb_config(portid_t pid, enum dcb_mode_enable dcb_mode,
1167 : : enum rte_eth_nb_tcs num_tcs,
1168 : : uint8_t pfc_en,
1169 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
1170 : : uint8_t prio_tc_en,
1171 : : uint8_t keep_qnum);
1172 : : int start_port(portid_t pid);
1173 : : void stop_port(portid_t pid);
1174 : : void close_port(portid_t pid);
1175 : : void reset_port(portid_t pid);
1176 : : void attach_port(char *identifier);
1177 : : void detach_devargs(char *identifier);
1178 : : void detach_port_device(portid_t port_id);
1179 : : int all_ports_stopped(void);
1180 : : int port_is_stopped(portid_t port_id);
1181 : : int port_is_started(portid_t port_id);
1182 : : void pmd_test_exit(void);
1183 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
1184 : : void fdir_get_infos(portid_t port_id);
1185 : : #endif
1186 : : void port_rss_reta_info(portid_t port_id,
1187 : : struct rte_eth_rss_reta_entry64 *reta_conf,
1188 : : uint16_t nb_entries);
1189 : :
1190 : : void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
1191 : :
1192 : : int
1193 : : rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
1194 : : uint16_t nb_rx_desc, unsigned int socket_id,
1195 : : struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp);
1196 : :
1197 : : int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint32_t rate);
1198 : : int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint32_t rate,
1199 : : uint64_t q_msk);
1200 : :
1201 : : int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id,
1202 : : uint8_t avail_thresh);
1203 : :
1204 : : void port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_algo);
1205 : : void port_rss_hash_key_update(portid_t port_id, char rss_type[],
1206 : : uint8_t *hash_key, uint8_t hash_key_len);
1207 : : int rx_queue_id_is_invalid(queueid_t rxq_id);
1208 : : int tx_queue_id_is_invalid(queueid_t txq_id);
1209 : : #ifdef RTE_LIB_GRO
1210 : : void setup_gro(const char *onoff, portid_t port_id);
1211 : : void setup_gro_flush_cycles(uint8_t cycles);
1212 : : void show_gro(portid_t port_id);
1213 : : #endif
1214 : : #ifdef RTE_LIB_GSO
1215 : : void setup_gso(const char *mode, portid_t port_id);
1216 : : #endif
1217 : : int eth_dev_info_get_print_err(uint16_t port_id,
1218 : : struct rte_eth_dev_info *dev_info);
1219 : : int eth_dev_conf_get_print_err(uint16_t port_id,
1220 : : struct rte_eth_conf *dev_conf);
1221 : : void eth_set_promisc_mode(uint16_t port_id, int enable);
1222 : : void eth_set_allmulticast_mode(uint16_t port, int enable);
1223 : : int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
1224 : : int eth_macaddr_get_print_err(uint16_t port_id,
1225 : : struct rte_ether_addr *mac_addr);
1226 : :
1227 : : /* Functions to display the set of MAC addresses added to a port*/
1228 : : void show_macs(portid_t port_id);
1229 : : void show_mcast_macs(portid_t port_id);
1230 : :
1231 : : /* Functions to manage the set of filtered Multicast MAC addresses */
1232 : : void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr);
1233 : : void mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr);
1234 : : void mcast_addr_flush(portid_t port_id);
1235 : : void port_dcb_info_display(portid_t port_id);
1236 : :
1237 : : uint8_t *open_file(const char *file_path, uint32_t *size);
1238 : : int save_file(const char *file_path, uint8_t *buf, uint32_t size);
1239 : : int close_file(uint8_t *buf);
1240 : :
1241 : : enum print_warning {
1242 : : ENABLED_WARN = 0,
1243 : : DISABLED_WARN
1244 : : };
1245 : : int port_id_is_invalid(portid_t port_id, enum print_warning warning);
1246 : : void print_valid_ports(void);
1247 : : int new_socket_id(unsigned int socket_id);
1248 : :
1249 : : queueid_t get_allowed_max_nb_rxq(portid_t *pid);
1250 : : int check_nb_rxq(queueid_t rxq);
1251 : : queueid_t get_allowed_max_nb_txq(portid_t *pid);
1252 : : int check_nb_txq(queueid_t txq);
1253 : : int check_nb_rxd(queueid_t rxd);
1254 : : int check_nb_txd(queueid_t txd);
1255 : : queueid_t get_allowed_max_nb_hairpinq(portid_t *pid);
1256 : : int check_nb_hairpinq(queueid_t hairpinq);
1257 : :
1258 : : uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1259 : : uint16_t nb_pkts, __rte_unused uint16_t max_pkts,
1260 : : __rte_unused void *user_param);
1261 : :
1262 : : uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1263 : : uint16_t nb_pkts, __rte_unused void *user_param);
1264 : :
1265 : : void add_rx_dump_callbacks(portid_t portid);
1266 : : void remove_rx_dump_callbacks(portid_t portid);
1267 : : void add_tx_dump_callbacks(portid_t portid);
1268 : : void remove_tx_dump_callbacks(portid_t portid);
1269 : : void configure_rxtx_dump_callbacks(uint16_t verbose);
1270 : :
1271 : : uint16_t tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue,
1272 : : struct rte_mbuf *pkts[], uint16_t nb_pkts,
1273 : : __rte_unused void *user_param);
1274 : : void add_tx_md_callback(portid_t portid);
1275 : : void remove_tx_md_callback(portid_t portid);
1276 : :
1277 : : uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
1278 : : struct rte_mbuf *pkts[], uint16_t nb_pkts,
1279 : : __rte_unused void *user_param);
1280 : : void add_tx_dynf_callback(portid_t portid);
1281 : : void remove_tx_dynf_callback(portid_t portid);
1282 : : int update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen);
1283 : : void flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename);
1284 : : void flex_item_destroy(portid_t port_id, uint16_t flex_id);
1285 : : void port_flex_item_flush(portid_t port_id);
1286 : :
1287 : : extern int flow_parse(const char *src, void *result, unsigned int size,
1288 : : struct rte_flow_attr **attr,
1289 : : struct rte_flow_item **pattern,
1290 : : struct rte_flow_action **actions);
1291 : : int setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi);
1292 : : int hairpin_bind(uint16_t cfg_pi, portid_t *pl, portid_t *peer_pl);
1293 : : void hairpin_map_usage(void);
1294 : : int parse_hairpin_map(const char *hpmap);
1295 : :
1296 : : uint64_t str_to_rsstypes(const char *str);
1297 : : const char *rsstypes_to_str(uint64_t rss_type);
1298 : :
1299 : : uint16_t str_to_flowtype(const char *string);
1300 : : const char *flowtype_to_str(uint16_t flow_type);
1301 : :
1302 : : /* For registering driver specific testpmd commands. */
1303 : : struct testpmd_driver_commands {
1304 : : TAILQ_ENTRY(testpmd_driver_commands) next;
1305 : : struct {
1306 : : cmdline_parse_inst_t *ctx;
1307 : : const char *help;
1308 : : } commands[];
1309 : : };
1310 : :
1311 : : void testpmd_add_driver_commands(struct testpmd_driver_commands *c);
1312 : : #define TESTPMD_ADD_DRIVER_COMMANDS(c) \
1313 : : RTE_INIT(__##c) \
1314 : : { \
1315 : : testpmd_add_driver_commands(&c); \
1316 : : }
1317 : :
1318 : : #define RTE_BE_TO_CPU_16(be_16_v) rte_be_to_cpu_16((be_16_v))
1319 : : #define RTE_CPU_TO_BE_16(cpu_16_v) rte_cpu_to_be_16((cpu_16_v))
1320 : :
1321 : : #define TESTPMD_LOG(level, fmt, ...) \
1322 : : rte_log(RTE_LOG_ ## level, testpmd_logtype, "testpmd: " fmt, ## __VA_ARGS__)
1323 : :
1324 : : #endif /* _TESTPMD_H_ */
|