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 : : extern uint16_t mempool_flags;
488 : :
489 : : /**
490 : : * Forwarding Configuration
491 : : *
492 : : */
493 : : struct fwd_config {
494 : : struct fwd_engine *fwd_eng; /**< Packet forwarding mode. */
495 : : streamid_t nb_fwd_streams; /**< Nb. of forward streams to process. */
496 : : lcoreid_t nb_fwd_lcores; /**< Nb. of logical cores to launch. */
497 : : portid_t nb_fwd_ports; /**< Nb. of ports involved. */
498 : : };
499 : :
500 : : /**
501 : : * DCB mode enable
502 : : */
503 : : enum dcb_mode_enable
504 : : {
505 : : DCB_VT_ENABLED,
506 : : DCB_ENABLED
507 : : };
508 : :
509 : : extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */
510 : : extern uint8_t xstats_hide_disabled; /**< Hide disabled xstat for xstats display */
511 : : extern uint8_t xstats_show_state; /**< Show xstat state in xstats display */
512 : :
513 : : /* globals used for configuration */
514 : : extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */
515 : : extern uint8_t record_burst_stats; /**< Enables display of RX and TX bursts */
516 : : extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */
517 : : extern int testpmd_logtype; /**< Log type for testpmd logs */
518 : : extern uint8_t interactive;
519 : : extern uint8_t auto_start;
520 : : extern uint8_t tx_first;
521 : : extern struct cmdline_file_info cmdline_files[MAX_CMDLINE_FILENAMES]; /**< offline commands files */
522 : : extern unsigned int cmdline_file_count; /**< number of cmdline files */
523 : : extern uint8_t numa_support; /**< set by "--numa" parameter */
524 : : extern uint16_t port_topology; /**< set by "--port-topology" parameter */
525 : : extern uint8_t no_flush_rx; /**<set by "--no-flush-rx" parameter */
526 : : extern uint8_t flow_isolate_all; /**< set by "--flow-isolate-all */
527 : : extern uint8_t no_flow_flush; /**< set by "--disable-flow-flush" parameter */
528 : : extern uint8_t mp_alloc_type;
529 : : /**< set by "--mp-anon" or "--mp-alloc" parameter */
530 : : extern uint32_t eth_link_speed;
531 : : extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
532 : : extern uint8_t no_device_start; /**<set by "--disable-device-start" parameter */
533 : : extern volatile int test_done; /* stop packet forwarding when set to 1. */
534 : : extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
535 : : extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
536 : : extern uint32_t event_print_mask;
537 : : /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
538 : : extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */
539 : : extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */
540 : : extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */
541 : : extern uint8_t clear_ptypes; /**< disabled by set ptype cmd */
542 : :
543 : : /*
544 : : * Store specified sockets on which memory pool to be used by ports
545 : : * is allocated.
546 : : */
547 : : extern uint8_t port_numa[RTE_MAX_ETHPORTS];
548 : :
549 : : /*
550 : : * Store specified sockets on which RX ring to be used by ports
551 : : * is allocated.
552 : : */
553 : : extern uint8_t rxring_numa[RTE_MAX_ETHPORTS];
554 : :
555 : : /*
556 : : * Store specified sockets on which TX ring to be used by ports
557 : : * is allocated.
558 : : */
559 : : extern uint8_t txring_numa[RTE_MAX_ETHPORTS];
560 : :
561 : : extern uint8_t socket_num;
562 : :
563 : : /*
564 : : * Configuration of logical cores:
565 : : * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores
566 : : */
567 : : extern lcoreid_t nb_lcores; /**< Number of logical cores probed at init time. */
568 : : extern lcoreid_t nb_cfg_lcores; /**< Number of configured logical cores. */
569 : : extern lcoreid_t nb_fwd_lcores; /**< Number of forwarding logical cores. */
570 : : extern unsigned int fwd_lcores_cpuids[RTE_MAX_LCORE];
571 : : extern unsigned int num_sockets;
572 : : extern unsigned int socket_ids[RTE_MAX_NUMA_NODES];
573 : :
574 : : /*
575 : : * Configuration of Ethernet ports:
576 : : * nb_fwd_ports <= nb_cfg_ports <= nb_ports
577 : : */
578 : : extern portid_t nb_ports; /**< Number of ethernet ports probed at init time. */
579 : : extern portid_t nb_cfg_ports; /**< Number of configured ports. */
580 : : extern portid_t nb_fwd_ports; /**< Number of forwarding ports. */
581 : : extern portid_t fwd_ports_ids[RTE_MAX_ETHPORTS];
582 : : extern struct rte_port *ports;
583 : :
584 : : extern struct rte_eth_rxmode rx_mode;
585 : : extern struct rte_eth_txmode tx_mode;
586 : :
587 : : extern uint64_t rss_hf;
588 : : extern bool force_rss;
589 : :
590 : : extern queueid_t nb_hairpinq;
591 : : extern queueid_t nb_rxq;
592 : : extern queueid_t nb_txq;
593 : :
594 : : extern uint16_t nb_rxd;
595 : : extern uint16_t nb_txd;
596 : :
597 : : extern int16_t rx_free_thresh;
598 : : extern int8_t rx_drop_en;
599 : : extern int16_t tx_free_thresh;
600 : : extern int16_t tx_rs_thresh;
601 : :
602 : : extern enum noisy_fwd_mode noisy_fwd_mode;
603 : : extern const char * const noisy_fwd_mode_desc[];
604 : : extern uint16_t noisy_tx_sw_bufsz;
605 : : extern uint16_t noisy_tx_sw_buf_flush_time;
606 : : extern uint64_t noisy_lkup_mem_sz;
607 : : extern uint64_t noisy_lkup_num_writes;
608 : : extern uint64_t noisy_lkup_num_reads;
609 : : extern uint64_t noisy_lkup_num_reads_writes;
610 : :
611 : : extern uint8_t dcb_config;
612 : :
613 : : extern uint32_t mbuf_data_size_n;
614 : : extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
615 : : /**< Mbuf data space size. */
616 : : extern uint32_t param_total_num_mbufs;
617 : :
618 : : extern uint16_t stats_period;
619 : :
620 : : extern struct rte_eth_xstat_name *xstats_display;
621 : : extern unsigned int xstats_display_num;
622 : :
623 : : extern uint32_t hairpin_mode;
624 : :
625 : : #ifdef RTE_LIB_LATENCYSTATS
626 : : extern uint8_t latencystats_enabled;
627 : : extern lcoreid_t latencystats_lcore_id;
628 : : #endif
629 : :
630 : : #ifdef RTE_LIB_BITRATESTATS
631 : : extern lcoreid_t bitrate_lcore_id;
632 : : extern uint8_t bitrate_enabled;
633 : : #endif
634 : :
635 : : extern uint32_t max_rx_pkt_len;
636 : :
637 : : /*
638 : : * Configuration of packet segments used to scatter received packets
639 : : * if some of split features is configured.
640 : : */
641 : : extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
642 : : extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
643 : : extern uint8_t rx_pkt_nb_segs; /**< Number of segments to split */
644 : : extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
645 : : extern uint8_t rx_pkt_nb_offs; /**< Number of specified offsets */
646 : :
647 : : extern uint8_t multi_rx_mempool; /**< Enables multi-rx-mempool feature. */
648 : :
649 : : /*
650 : : * Configuration of packet segments used by the "txonly" processing engine.
651 : : */
652 : : #define TXONLY_DEF_PACKET_LEN 64
653 : : extern uint16_t tx_pkt_length; /**< Length of TXONLY packet */
654 : : extern uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT]; /**< Seg. lengths */
655 : : extern uint8_t tx_pkt_nb_segs; /**< Number of segments in TX packets */
656 : : extern uint32_t tx_pkt_times_intra;
657 : : extern uint32_t tx_pkt_times_inter;
658 : :
659 : : enum tx_pkt_split {
660 : : TX_PKT_SPLIT_OFF,
661 : : TX_PKT_SPLIT_ON,
662 : : TX_PKT_SPLIT_RND,
663 : : };
664 : :
665 : : extern enum tx_pkt_split tx_pkt_split;
666 : :
667 : : extern uint8_t txonly_multi_flow;
668 : :
669 : : extern uint32_t rxq_share;
670 : :
671 : : extern uint16_t nb_pkt_per_burst;
672 : : extern uint16_t nb_pkt_flowgen_clones;
673 : : extern int nb_flows_flowgen;
674 : : extern uint16_t mb_mempool_cache;
675 : : extern int8_t rx_pthresh;
676 : : extern int8_t rx_hthresh;
677 : : extern int8_t rx_wthresh;
678 : : extern int8_t tx_pthresh;
679 : : extern int8_t tx_hthresh;
680 : : extern int8_t tx_wthresh;
681 : :
682 : : extern uint16_t tx_udp_src_port;
683 : : extern uint16_t tx_udp_dst_port;
684 : :
685 : : extern uint32_t tx_ip_src_addr;
686 : : extern uint32_t tx_ip_dst_addr;
687 : :
688 : : extern struct fwd_config cur_fwd_config;
689 : : extern struct fwd_engine *cur_fwd_eng;
690 : : extern uint32_t retry_enabled;
691 : : extern struct fwd_lcore **fwd_lcores;
692 : : extern struct fwd_stream **fwd_streams;
693 : :
694 : : extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */
695 : : extern uint16_t geneve_udp_port; /**< UDP port of tunnel GENEVE. */
696 : :
697 : : extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
698 : : extern struct rte_ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
699 : :
700 : : extern uint32_t burst_tx_delay_time; /**< Burst tx delay time(us) for mac-retry. */
701 : : extern uint32_t burst_tx_retry_num; /**< Burst tx retry number for mac-retry. */
702 : :
703 : : #ifdef RTE_LIB_GRO
704 : : #define GRO_DEFAULT_ITEM_NUM_PER_FLOW 32
705 : : #define GRO_DEFAULT_FLOW_NUM (RTE_GRO_MAX_BURST_ITEM_NUM / \
706 : : GRO_DEFAULT_ITEM_NUM_PER_FLOW)
707 : :
708 : : #define GRO_DEFAULT_FLUSH_CYCLES 1
709 : : #define GRO_MAX_FLUSH_CYCLES 4
710 : :
711 : : struct gro_status {
712 : : struct rte_gro_param param;
713 : : uint8_t enable;
714 : : };
715 : : extern struct gro_status gro_ports[RTE_MAX_ETHPORTS];
716 : : extern uint8_t gro_flush_cycles;
717 : : #endif /* RTE_LIB_GRO */
718 : :
719 : : #ifdef RTE_LIB_GSO
720 : : #define GSO_MAX_PKT_BURST 2048
721 : : struct gso_status {
722 : : uint8_t enable;
723 : : };
724 : : extern struct gso_status gso_ports[RTE_MAX_ETHPORTS];
725 : : extern uint16_t gso_max_segment_size;
726 : : #endif /* RTE_LIB_GSO */
727 : :
728 : : /* VXLAN encap/decap parameters. */
729 : : struct vxlan_encap_conf {
730 : : uint32_t select_ipv4:1;
731 : : uint32_t select_vlan:1;
732 : : uint32_t select_tos_ttl:1;
733 : : uint8_t vni[3];
734 : : rte_be16_t udp_src;
735 : : rte_be16_t udp_dst;
736 : : rte_be32_t ipv4_src;
737 : : rte_be32_t ipv4_dst;
738 : : struct rte_ipv6_addr ipv6_src;
739 : : struct rte_ipv6_addr ipv6_dst;
740 : : rte_be16_t vlan_tci;
741 : : uint8_t ip_tos;
742 : : uint8_t ip_ttl;
743 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
744 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
745 : : };
746 : :
747 : : extern struct vxlan_encap_conf vxlan_encap_conf;
748 : :
749 : : /* NVGRE encap/decap parameters. */
750 : : struct nvgre_encap_conf {
751 : : uint32_t select_ipv4:1;
752 : : uint32_t select_vlan:1;
753 : : uint8_t tni[3];
754 : : rte_be32_t ipv4_src;
755 : : rte_be32_t ipv4_dst;
756 : : struct rte_ipv6_addr ipv6_src;
757 : : struct rte_ipv6_addr ipv6_dst;
758 : : rte_be16_t vlan_tci;
759 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
760 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
761 : : };
762 : :
763 : : extern struct nvgre_encap_conf nvgre_encap_conf;
764 : :
765 : : /* L2 encap parameters. */
766 : : struct l2_encap_conf {
767 : : uint32_t select_ipv4:1;
768 : : uint32_t select_vlan:1;
769 : : rte_be16_t vlan_tci;
770 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
771 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
772 : : };
773 : : extern struct l2_encap_conf l2_encap_conf;
774 : :
775 : : /* L2 decap parameters. */
776 : : struct l2_decap_conf {
777 : : uint32_t select_vlan:1;
778 : : };
779 : : extern struct l2_decap_conf l2_decap_conf;
780 : :
781 : : /* MPLSoGRE encap parameters. */
782 : : struct mplsogre_encap_conf {
783 : : uint32_t select_ipv4:1;
784 : : uint32_t select_vlan:1;
785 : : uint8_t label[3];
786 : : rte_be32_t ipv4_src;
787 : : rte_be32_t ipv4_dst;
788 : : struct rte_ipv6_addr ipv6_src;
789 : : struct rte_ipv6_addr ipv6_dst;
790 : : rte_be16_t vlan_tci;
791 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
792 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
793 : : };
794 : : extern struct mplsogre_encap_conf mplsogre_encap_conf;
795 : :
796 : : /* MPLSoGRE decap parameters. */
797 : : struct mplsogre_decap_conf {
798 : : uint32_t select_ipv4:1;
799 : : uint32_t select_vlan:1;
800 : : };
801 : : extern struct mplsogre_decap_conf mplsogre_decap_conf;
802 : :
803 : : /* MPLSoUDP encap parameters. */
804 : : struct mplsoudp_encap_conf {
805 : : uint32_t select_ipv4:1;
806 : : uint32_t select_vlan:1;
807 : : uint8_t label[3];
808 : : rte_be16_t udp_src;
809 : : rte_be16_t udp_dst;
810 : : rte_be32_t ipv4_src;
811 : : rte_be32_t ipv4_dst;
812 : : struct rte_ipv6_addr ipv6_src;
813 : : struct rte_ipv6_addr ipv6_dst;
814 : : rte_be16_t vlan_tci;
815 : : uint8_t eth_src[RTE_ETHER_ADDR_LEN];
816 : : uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
817 : : };
818 : : extern struct mplsoudp_encap_conf mplsoudp_encap_conf;
819 : :
820 : : /* MPLSoUDP decap parameters. */
821 : : struct mplsoudp_decap_conf {
822 : : uint32_t select_ipv4:1;
823 : : uint32_t select_vlan:1;
824 : : };
825 : : extern struct mplsoudp_decap_conf mplsoudp_decap_conf;
826 : :
827 : : extern enum rte_eth_rx_mq_mode rx_mq_mode;
828 : :
829 : : extern struct rte_flow_action_conntrack conntrack_context;
830 : :
831 : : extern int proc_id;
832 : : extern unsigned int num_procs;
833 : :
834 : : static inline bool
835 : : is_proc_primary(void)
836 : : {
837 : 0 : return rte_eal_process_type() == RTE_PROC_PRIMARY;
838 : : }
839 : :
840 : : static inline struct fwd_lcore *
841 : : lcore_to_fwd_lcore(uint16_t lcore_id)
842 : : {
843 : : unsigned int i;
844 : :
845 : 0 : for (i = 0; i < cur_fwd_config.nb_fwd_lcores; ++i) {
846 : 0 : if (fwd_lcores_cpuids[i] == lcore_id)
847 : 0 : return fwd_lcores[i];
848 : : }
849 : :
850 : : return NULL;
851 : : }
852 : :
853 : : static inline struct fwd_lcore *
854 : 0 : current_fwd_lcore(void)
855 : : {
856 : : struct fwd_lcore *fc = lcore_to_fwd_lcore(rte_lcore_id());
857 : :
858 : 0 : if (fc == NULL)
859 : 0 : rte_panic("lcore_id of current thread not found in fwd_lcores_cpuids\n");
860 : :
861 : 0 : return fc;
862 : : }
863 : :
864 : : void
865 : : parse_fwd_portlist(const char *port);
866 : :
867 : : /* Mbuf Pools */
868 : : static inline void
869 : 0 : mbuf_poolname_build(unsigned int sock_id, char *mp_name,
870 : : int name_size, uint16_t idx)
871 : : {
872 : 0 : if (!idx)
873 : 0 : snprintf(mp_name, name_size,
874 : : MBUF_POOL_NAME_PFX "_%u", sock_id);
875 : : else
876 : 0 : snprintf(mp_name, name_size,
877 : : MBUF_POOL_NAME_PFX "_%hu_%hu", (uint16_t)sock_id, idx);
878 : 0 : }
879 : :
880 : : static inline struct rte_mempool *
881 : : mbuf_pool_find(unsigned int sock_id, uint16_t idx)
882 : : {
883 : : char pool_name[RTE_MEMPOOL_NAMESIZE];
884 : :
885 : 0 : mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
886 : 0 : return rte_mempool_lookup((const char *)pool_name);
887 : : }
888 : :
889 : : static inline uint16_t
890 : 0 : common_fwd_stream_receive(struct fwd_stream *fs, struct rte_mbuf **burst,
891 : : unsigned int nb_pkts)
892 : : {
893 : : uint16_t nb_rx;
894 : :
895 : 0 : nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, burst, nb_pkts);
896 : 0 : if (record_burst_stats)
897 : 0 : fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
898 : 0 : fs->rx_packets += nb_rx;
899 : 0 : return nb_rx;
900 : : }
901 : :
902 : : static inline uint16_t
903 : 0 : common_fwd_stream_transmit(struct fwd_stream *fs, struct rte_mbuf **burst,
904 : : unsigned int nb_pkts)
905 : : {
906 : : uint16_t nb_tx;
907 : : uint32_t retry;
908 : :
909 : 0 : nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, burst, nb_pkts);
910 : : /*
911 : : * Retry if necessary
912 : : */
913 : 0 : if (unlikely(nb_tx < nb_pkts) && fs->retry_enabled) {
914 : : retry = 0;
915 : 0 : while (nb_tx < nb_pkts && retry++ < burst_tx_retry_num) {
916 : 0 : rte_delay_us(burst_tx_delay_time);
917 : 0 : nb_tx += rte_eth_tx_burst(fs->tx_port, fs->tx_queue,
918 : 0 : &burst[nb_tx], nb_pkts - nb_tx);
919 : : }
920 : : }
921 : 0 : fs->tx_packets += nb_tx;
922 : 0 : if (record_burst_stats)
923 : 0 : fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
924 : 0 : if (unlikely(nb_tx < nb_pkts)) {
925 : 0 : fs->fwd_dropped += (nb_pkts - nb_tx);
926 : 0 : rte_pktmbuf_free_bulk(&burst[nb_tx], nb_pkts - nb_tx);
927 : : }
928 : :
929 : 0 : return nb_tx;
930 : : }
931 : :
932 : : /* Prototypes */
933 : : unsigned int parse_item_list(const char *str, const char *item_name,
934 : : unsigned int max_items,
935 : : unsigned int *parsed_items, int check_unique_values);
936 : : unsigned int parse_hdrs_list(const char *str, const char *item_name,
937 : : unsigned int max_item,
938 : : unsigned int *parsed_items);
939 : : void launch_args_parse(int argc, char** argv);
940 : : void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
941 : : int cmdline_read_from_file(const char *filename, bool echo);
942 : : int init_cmdline(void);
943 : : void prompt(void);
944 : : void prompt_exit(void);
945 : : void nic_stats_display(portid_t port_id);
946 : : void nic_stats_clear(portid_t port_id);
947 : : void nic_xstats_display(portid_t port_id);
948 : : void nic_xstats_clear(portid_t port_id);
949 : : void nic_xstats_set_counter(portid_t port_id, char *counter_name, int on);
950 : : void device_infos_display(const char *identifier);
951 : : void port_infos_display(portid_t port_id);
952 : : void port_summary_display(portid_t port_id);
953 : : void port_eeprom_display(portid_t port_id);
954 : : void port_eeprom_set(portid_t port_id, uint32_t magic, uint32_t offset,
955 : : uint32_t length, uint8_t *value);
956 : : void port_module_eeprom_display(portid_t port_id);
957 : : void port_summary_header_display(void);
958 : : void rx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
959 : : void tx_queue_infos_display(portid_t port_idi, uint16_t queue_id);
960 : : void fwd_lcores_config_display(void);
961 : : bool pkt_fwd_shared_rxq_check(void);
962 : : void pkt_fwd_config_display(struct fwd_config *cfg);
963 : : void rxtx_config_display(void);
964 : : void fwd_config_setup(void);
965 : : void set_def_fwd_config(void);
966 : : void reconfig(portid_t new_port_id, unsigned socket_id);
967 : : int init_fwd_streams(void);
968 : : void update_fwd_ports(portid_t new_pid);
969 : :
970 : : void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
971 : : void set_dev_led(portid_t port_id, bool active);
972 : :
973 : : void port_mtu_set(portid_t port_id, uint16_t mtu);
974 : : int port_action_handle_create(portid_t port_id, uint32_t id, bool indirect_list,
975 : : const struct rte_flow_indir_action_conf *conf,
976 : : const struct rte_flow_action *action);
977 : : int port_action_handle_destroy(portid_t port_id,
978 : : uint32_t n, const uint32_t *action);
979 : : int port_action_handle_flush(portid_t port_id);
980 : : struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
981 : : uint32_t id);
982 : : int port_action_handle_update(portid_t port_id, uint32_t id,
983 : : const struct rte_flow_action *action);
984 : : void
985 : : port_action_handle_query_update(portid_t port_id, uint32_t id,
986 : : enum rte_flow_query_update_mode qu_mode,
987 : : const struct rte_flow_action *action);
988 : : int port_flow_get_info(portid_t port_id);
989 : : int port_flow_configure(portid_t port_id,
990 : : const struct rte_flow_port_attr *port_attr,
991 : : uint16_t nb_queue,
992 : : const struct rte_flow_queue_attr *queue_attr);
993 : : int port_flow_pattern_template_create(portid_t port_id, uint32_t id,
994 : : const struct rte_flow_pattern_template_attr *attr,
995 : : const struct rte_flow_item *pattern);
996 : : int port_flow_pattern_template_destroy(portid_t port_id, uint32_t n,
997 : : const uint32_t *template);
998 : : int port_flow_pattern_template_flush(portid_t port_id);
999 : : int port_flow_actions_template_create(portid_t port_id, uint32_t id,
1000 : : const struct rte_flow_actions_template_attr *attr,
1001 : : const struct rte_flow_action *actions,
1002 : : const struct rte_flow_action *masks);
1003 : : int port_flow_actions_template_destroy(portid_t port_id, uint32_t n,
1004 : : const uint32_t *template);
1005 : : int port_flow_actions_template_flush(portid_t port_id);
1006 : : int port_flow_template_table_create(portid_t port_id, uint32_t id,
1007 : : const struct rte_flow_template_table_attr *table_attr,
1008 : : uint32_t nb_pattern_templates, uint32_t *pattern_templates,
1009 : : uint32_t nb_actions_templates, uint32_t *actions_templates);
1010 : : int port_flow_template_table_destroy(portid_t port_id,
1011 : : uint32_t n, const uint32_t *table);
1012 : : int port_queue_flow_update_resized(portid_t port_id, queueid_t queue_id,
1013 : : bool postpone, uint32_t flow_id);
1014 : : int port_flow_template_table_flush(portid_t port_id);
1015 : : int port_flow_template_table_resize_complete(portid_t port_id, uint32_t table_id);
1016 : : int port_flow_template_table_resize(portid_t port_id,
1017 : : uint32_t table_id, uint32_t flows_num);
1018 : : int port_queue_group_set_miss_actions(portid_t port_id, const struct rte_flow_attr *attr,
1019 : : const struct rte_flow_action *actions);
1020 : : int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
1021 : : bool postpone, uint32_t table_id, uint32_t rule_idx,
1022 : : uint32_t pattern_idx, uint32_t actions_idx,
1023 : : const struct rte_flow_item *pattern,
1024 : : const struct rte_flow_action *actions);
1025 : : int port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,
1026 : : bool postpone, uint32_t n, const uint64_t *rule);
1027 : : int port_queue_flow_update(portid_t port_id, queueid_t queue_id,
1028 : : bool postpone, uint32_t rule_idx, uint32_t actions_idx,
1029 : : const struct rte_flow_action *actions);
1030 : : int port_queue_action_handle_create(portid_t port_id, uint32_t queue_id,
1031 : : bool postpone, uint32_t id,
1032 : : bool indirect_list,
1033 : : const struct rte_flow_indir_action_conf *conf,
1034 : : const struct rte_flow_action *action);
1035 : : int port_queue_action_handle_destroy(portid_t port_id,
1036 : : uint32_t queue_id, bool postpone,
1037 : : uint32_t n, const uint32_t *action);
1038 : : int port_queue_action_handle_update(portid_t port_id, uint32_t queue_id,
1039 : : bool postpone, uint32_t id,
1040 : : const struct rte_flow_action *action);
1041 : : int port_queue_action_handle_query(portid_t port_id, uint32_t queue_id,
1042 : : bool postpone, uint32_t id);
1043 : : void
1044 : : port_queue_action_handle_query_update(portid_t port_id,
1045 : : uint32_t queue_id, bool postpone,
1046 : : uint32_t id,
1047 : : enum rte_flow_query_update_mode qu_mode,
1048 : : const struct rte_flow_action *action);
1049 : : int port_queue_flow_push(portid_t port_id, queueid_t queue_id);
1050 : : int port_queue_flow_pull(portid_t port_id, queueid_t queue_id);
1051 : : int port_flow_hash_calc(portid_t port_id, uint32_t table_id,
1052 : : uint8_t pattern_template_index, const struct rte_flow_item pattern[]);
1053 : : int port_flow_hash_calc_encap(portid_t port_id,
1054 : : enum rte_flow_encap_hash_field encap_hash_field,
1055 : : const struct rte_flow_item pattern[]);
1056 : : void port_queue_flow_aged(portid_t port_id, uint32_t queue_id, uint8_t destroy);
1057 : : int port_flow_validate(portid_t port_id,
1058 : : const struct rte_flow_attr *attr,
1059 : : const struct rte_flow_item *pattern,
1060 : : const struct rte_flow_action *actions,
1061 : : const struct tunnel_ops *tunnel_ops);
1062 : : int port_flow_create(portid_t port_id,
1063 : : const struct rte_flow_attr *attr,
1064 : : const struct rte_flow_item *pattern,
1065 : : const struct rte_flow_action *actions,
1066 : : const struct tunnel_ops *tunnel_ops,
1067 : : uintptr_t user_id);
1068 : : int port_action_handle_query(portid_t port_id, uint32_t id);
1069 : : void update_age_action_context(const struct rte_flow_action *actions,
1070 : : struct port_flow *pf);
1071 : : int mcast_addr_pool_destroy(portid_t port_id);
1072 : : int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule,
1073 : : bool is_user_id);
1074 : : int port_flow_update(portid_t port_id, uint32_t rule,
1075 : : const struct rte_flow_action *actions, bool is_user_id);
1076 : : int port_flow_flush(portid_t port_id);
1077 : : int port_flow_dump(portid_t port_id, bool dump_all,
1078 : : uint64_t rule, const char *file_name,
1079 : : bool is_user_id);
1080 : : int port_flow_query(portid_t port_id, uint64_t rule,
1081 : : const struct rte_flow_action *action, bool is_user_id);
1082 : : void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
1083 : : void port_flow_aged(portid_t port_id, uint8_t destroy);
1084 : : const char *port_flow_tunnel_type(struct rte_flow_tunnel *tunnel);
1085 : : struct port_flow_tunnel *
1086 : : port_flow_locate_tunnel(uint16_t port_id, struct rte_flow_tunnel *tun);
1087 : : void port_flow_tunnel_list(portid_t port_id);
1088 : : void port_flow_tunnel_destroy(portid_t port_id, uint32_t tunnel_id);
1089 : : void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops);
1090 : : int port_flow_isolate(portid_t port_id, int set);
1091 : : int port_meter_policy_add(portid_t port_id, uint32_t policy_id,
1092 : : const struct rte_flow_action *actions);
1093 : : struct rte_flow_meter_profile *port_meter_profile_get_by_id(portid_t port_id,
1094 : : uint32_t id);
1095 : : struct rte_flow_meter_policy *port_meter_policy_get_by_id(portid_t port_id,
1096 : : uint32_t id);
1097 : :
1098 : : void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id);
1099 : : void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id);
1100 : :
1101 : : int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc);
1102 : : int set_fwd_lcores_mask(uint64_t lcoremask);
1103 : : void set_fwd_lcores_number(uint16_t nb_lc);
1104 : :
1105 : : void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt);
1106 : : void set_fwd_ports_mask(uint64_t portmask);
1107 : : void set_fwd_ports_number(uint16_t nb_pt);
1108 : : int port_is_forwarding(portid_t port_id);
1109 : :
1110 : : void rx_vlan_strip_set(portid_t port_id, int on);
1111 : : void rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on);
1112 : :
1113 : : void rx_vlan_filter_set(portid_t port_id, int on);
1114 : : void rx_vlan_all_filter_set(portid_t port_id, int on);
1115 : : void rx_vlan_qinq_strip_set(portid_t port_id, int on);
1116 : : int rx_vft_set(portid_t port_id, uint16_t vlan_id, int on);
1117 : : void vlan_extend_set(portid_t port_id, int on);
1118 : : void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
1119 : : uint16_t tp_id);
1120 : : void tx_vlan_set(portid_t port_id, uint16_t vlan_id);
1121 : : void tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer);
1122 : : void tx_vlan_reset(portid_t port_id);
1123 : : void tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on);
1124 : :
1125 : : void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value);
1126 : :
1127 : : void set_xstats_hide_zero(uint8_t on_off);
1128 : : void set_xstats_show_state(uint8_t on_off);
1129 : : void set_xstats_hide_disabled(uint8_t on_off);
1130 : :
1131 : : void set_record_core_cycles(uint8_t on_off);
1132 : : void set_record_burst_stats(uint8_t on_off);
1133 : : void set_verbose_level(uint16_t vb_level);
1134 : : void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
1135 : : void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs);
1136 : : void show_rx_pkt_hdrs(void);
1137 : : void show_rx_pkt_segments(void);
1138 : : void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
1139 : : void show_rx_pkt_offsets(void);
1140 : : void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
1141 : : void show_tx_pkt_segments(void);
1142 : : void set_tx_pkt_times(unsigned int *tx_times);
1143 : : void show_tx_pkt_times(void);
1144 : : void set_tx_pkt_split(const char *name);
1145 : : int parse_fec_mode(const char *name, uint32_t *fec_capa);
1146 : : void show_fec_capability(uint32_t num, struct rte_eth_fec_capa *speed_fec_capa);
1147 : : void set_nb_pkt_per_burst(uint16_t pkt_burst);
1148 : : char *list_pkt_forwarding_modes(void);
1149 : : char *list_pkt_forwarding_retry_modes(void);
1150 : : void set_pkt_forwarding_mode(const char *fwd_mode);
1151 : : void start_packet_forwarding(int with_tx_first);
1152 : : void fwd_stats_display(void);
1153 : : void fwd_stats_reset(void);
1154 : : void stop_packet_forwarding(void);
1155 : : void dev_set_link_up(portid_t pid);
1156 : : void dev_set_link_down(portid_t pid);
1157 : : void init_port_config(void);
1158 : : void set_port_member_flag(portid_t member_pid);
1159 : : void clear_port_member_flag(portid_t member_pid);
1160 : : uint8_t port_is_bonding_member(portid_t member_pid);
1161 : :
1162 : : int init_port_dcb_config(portid_t pid, enum dcb_mode_enable dcb_mode,
1163 : : enum rte_eth_nb_tcs num_tcs,
1164 : : uint8_t pfc_en,
1165 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
1166 : : uint8_t prio_tc_en,
1167 : : uint8_t keep_qnum);
1168 : : int start_port(portid_t pid);
1169 : : void stop_port(portid_t pid);
1170 : : void close_port(portid_t pid);
1171 : : void reset_port(portid_t pid);
1172 : : void attach_port(char *identifier);
1173 : : void detach_devargs(char *identifier);
1174 : : void detach_port_device(portid_t port_id);
1175 : : int all_ports_stopped(void);
1176 : : int port_is_stopped(portid_t port_id);
1177 : : int port_is_started(portid_t port_id);
1178 : : void pmd_test_exit(void);
1179 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
1180 : : void fdir_get_infos(portid_t port_id);
1181 : : #endif
1182 : : void port_rss_reta_info(portid_t port_id,
1183 : : struct rte_eth_rss_reta_entry64 *reta_conf,
1184 : : uint16_t nb_entries);
1185 : :
1186 : : void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
1187 : :
1188 : : int
1189 : : rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
1190 : : uint16_t nb_rx_desc, unsigned int socket_id,
1191 : : struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp);
1192 : :
1193 : : int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint32_t rate);
1194 : : int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint32_t rate,
1195 : : uint64_t q_msk);
1196 : :
1197 : : int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id,
1198 : : uint8_t avail_thresh);
1199 : :
1200 : : void port_rss_hash_conf_show(portid_t port_id, int show_rss_key, int show_rss_algo);
1201 : : void port_rss_hash_key_update(portid_t port_id, char rss_type[],
1202 : : uint8_t *hash_key, uint8_t hash_key_len);
1203 : : int rx_queue_id_is_invalid(queueid_t rxq_id);
1204 : : int tx_queue_id_is_invalid(queueid_t txq_id);
1205 : : #ifdef RTE_LIB_GRO
1206 : : void setup_gro(const char *onoff, portid_t port_id);
1207 : : void setup_gro_flush_cycles(uint8_t cycles);
1208 : : void show_gro(portid_t port_id);
1209 : : #endif
1210 : : #ifdef RTE_LIB_GSO
1211 : : void setup_gso(const char *mode, portid_t port_id);
1212 : : #endif
1213 : : int eth_dev_info_get_print_err(uint16_t port_id,
1214 : : struct rte_eth_dev_info *dev_info);
1215 : : int eth_dev_conf_get_print_err(uint16_t port_id,
1216 : : struct rte_eth_conf *dev_conf);
1217 : : void eth_set_promisc_mode(uint16_t port_id, int enable);
1218 : : void eth_set_allmulticast_mode(uint16_t port, int enable);
1219 : : int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
1220 : : int eth_macaddr_get_print_err(uint16_t port_id,
1221 : : struct rte_ether_addr *mac_addr);
1222 : :
1223 : : /* Functions to display the set of MAC addresses added to a port*/
1224 : : void show_macs(portid_t port_id);
1225 : : void show_mcast_macs(portid_t port_id);
1226 : :
1227 : : /* Functions to manage the set of filtered Multicast MAC addresses */
1228 : : void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr);
1229 : : void mcast_addr_remove(portid_t port_id, struct rte_ether_addr *mc_addr);
1230 : : void mcast_addr_flush(portid_t port_id);
1231 : : void port_dcb_info_display(portid_t port_id);
1232 : :
1233 : : uint8_t *open_file(const char *file_path, uint32_t *size);
1234 : : int save_file(const char *file_path, uint8_t *buf, uint32_t size);
1235 : : int close_file(uint8_t *buf);
1236 : :
1237 : : enum print_warning {
1238 : : ENABLED_WARN = 0,
1239 : : DISABLED_WARN
1240 : : };
1241 : : int port_id_is_invalid(portid_t port_id, enum print_warning warning);
1242 : : void print_valid_ports(void);
1243 : : int new_socket_id(unsigned int socket_id);
1244 : :
1245 : : queueid_t get_allowed_max_nb_rxq(portid_t *pid);
1246 : : int check_nb_rxq(queueid_t rxq);
1247 : : queueid_t get_allowed_max_nb_txq(portid_t *pid);
1248 : : int check_nb_txq(queueid_t txq);
1249 : : int check_nb_rxd(queueid_t rxd);
1250 : : int check_nb_txd(queueid_t txd);
1251 : : queueid_t get_allowed_max_nb_hairpinq(portid_t *pid);
1252 : : int check_nb_hairpinq(queueid_t hairpinq);
1253 : :
1254 : : uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1255 : : uint16_t nb_pkts, __rte_unused uint16_t max_pkts,
1256 : : __rte_unused void *user_param);
1257 : :
1258 : : uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
1259 : : uint16_t nb_pkts, __rte_unused void *user_param);
1260 : :
1261 : : void add_rx_dump_callbacks(portid_t portid);
1262 : : void remove_rx_dump_callbacks(portid_t portid);
1263 : : void add_tx_dump_callbacks(portid_t portid);
1264 : : void remove_tx_dump_callbacks(portid_t portid);
1265 : : void configure_rxtx_dump_callbacks(uint16_t verbose);
1266 : :
1267 : : uint16_t tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue,
1268 : : struct rte_mbuf *pkts[], uint16_t nb_pkts,
1269 : : __rte_unused void *user_param);
1270 : : void add_tx_md_callback(portid_t portid);
1271 : : void remove_tx_md_callback(portid_t portid);
1272 : :
1273 : : uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue,
1274 : : struct rte_mbuf *pkts[], uint16_t nb_pkts,
1275 : : __rte_unused void *user_param);
1276 : : void add_tx_dynf_callback(portid_t portid);
1277 : : void remove_tx_dynf_callback(portid_t portid);
1278 : : int update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen);
1279 : : void flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename);
1280 : : void flex_item_destroy(portid_t port_id, uint16_t flex_id);
1281 : : void port_flex_item_flush(portid_t port_id);
1282 : :
1283 : : extern int flow_parse(const char *src, void *result, unsigned int size,
1284 : : struct rte_flow_attr **attr,
1285 : : struct rte_flow_item **pattern,
1286 : : struct rte_flow_action **actions);
1287 : : int setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi);
1288 : : int hairpin_bind(uint16_t cfg_pi, portid_t *pl, portid_t *peer_pl);
1289 : : void hairpin_map_usage(void);
1290 : : int parse_hairpin_map(const char *hpmap);
1291 : :
1292 : : uint64_t str_to_rsstypes(const char *str);
1293 : : const char *rsstypes_to_str(uint64_t rss_type);
1294 : :
1295 : : uint16_t str_to_flowtype(const char *string);
1296 : : const char *flowtype_to_str(uint16_t flow_type);
1297 : :
1298 : : /* For registering driver specific testpmd commands. */
1299 : : struct testpmd_driver_commands {
1300 : : TAILQ_ENTRY(testpmd_driver_commands) next;
1301 : : struct {
1302 : : cmdline_parse_inst_t *ctx;
1303 : : const char *help;
1304 : : } commands[];
1305 : : };
1306 : :
1307 : : void testpmd_add_driver_commands(struct testpmd_driver_commands *c);
1308 : : #define TESTPMD_ADD_DRIVER_COMMANDS(c) \
1309 : : RTE_INIT(__##c) \
1310 : : { \
1311 : : testpmd_add_driver_commands(&c); \
1312 : : }
1313 : :
1314 : : #define RTE_BE_TO_CPU_16(be_16_v) rte_be_to_cpu_16((be_16_v))
1315 : : #define RTE_CPU_TO_BE_16(cpu_16_v) rte_cpu_to_be_16((cpu_16_v))
1316 : :
1317 : : #define TESTPMD_LOG(level, fmt, ...) \
1318 : : rte_log(RTE_LOG_ ## level, testpmd_logtype, "testpmd: " fmt, ## __VA_ARGS__)
1319 : :
1320 : : #endif /* _TESTPMD_H_ */
|