xref: /dpdk/app/test-pmd/cmdline.c (revision b6f30094e511c22f038907a507d16f7cc022c682)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5 
6 #include <ctype.h>
7 #include <stdarg.h>
8 #include <errno.h>
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <unistd.h>
14 #include <inttypes.h>
15 #include <sys/queue.h>
16 
17 #include <rte_common.h>
18 #include <rte_byteorder.h>
19 #include <rte_log.h>
20 #include <rte_debug.h>
21 #include <rte_cycles.h>
22 #include <rte_memory.h>
23 #include <rte_memzone.h>
24 #include <rte_malloc.h>
25 #include <rte_launch.h>
26 #include <rte_eal.h>
27 #include <rte_per_lcore.h>
28 #include <rte_lcore.h>
29 #include <rte_branch_prediction.h>
30 #include <rte_ring.h>
31 #include <rte_mempool.h>
32 #include <rte_interrupts.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_string_fns.h>
36 #include <rte_devargs.h>
37 #include <rte_flow.h>
38 #ifdef RTE_LIB_GRO
39 #include <rte_gro.h>
40 #endif
41 #include <rte_mbuf_dyn.h>
42 #include <rte_trace.h>
43 
44 #include <cmdline_rdline.h>
45 #include <cmdline_parse.h>
46 #include <cmdline_parse_num.h>
47 #include <cmdline_parse_string.h>
48 #include <cmdline_parse_ipaddr.h>
49 #include <cmdline_parse_etheraddr.h>
50 #include <cmdline_socket.h>
51 #include <cmdline.h>
52 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
53 #include <rte_pmd_dpaa.h>
54 #endif
55 #ifdef RTE_NET_IXGBE
56 #include <rte_pmd_ixgbe.h>
57 #endif
58 #ifdef RTE_NET_I40E
59 #include <rte_pmd_i40e.h>
60 #endif
61 #ifdef RTE_NET_BNXT
62 #include <rte_pmd_bnxt.h>
63 #endif
64 #include "testpmd.h"
65 #include "cmdline_cman.h"
66 #include "cmdline_mtr.h"
67 #include "cmdline_tm.h"
68 #include "bpf_cmd.h"
69 
70 static struct cmdline *testpmd_cl;
71 static cmdline_parse_ctx_t *main_ctx;
72 static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
73 	TAILQ_HEAD_INITIALIZER(driver_commands_head);
74 
75 /* *** Help command with introduction. *** */
76 struct cmd_help_brief_result {
77 	cmdline_fixed_string_t help;
78 };
79 
80 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
81                                   struct cmdline *cl,
82                                   __rte_unused void *data)
83 {
84 	cmdline_printf(
85 		cl,
86 		"\n"
87 		"Help is available for the following sections:\n\n"
88 		"    help control                    : Start and stop forwarding.\n"
89 		"    help display                    : Displaying port, stats and config "
90 		"information.\n"
91 		"    help config                     : Configuration information.\n"
92 		"    help ports                      : Configuring ports.\n"
93 		"    help filters                    : Filters configuration help.\n"
94 		"    help traffic_management         : Traffic Management commands.\n"
95 		"    help devices                    : Device related commands.\n"
96 		"    help drivers                    : Driver specific commands.\n"
97 		"    help all                        : All of the above sections.\n\n"
98 	);
99 
100 }
101 
102 static cmdline_parse_token_string_t cmd_help_brief_help =
103 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 
105 static cmdline_parse_inst_t cmd_help_brief = {
106 	.f = cmd_help_brief_parsed,
107 	.data = NULL,
108 	.help_str = "help: Show help",
109 	.tokens = {
110 		(void *)&cmd_help_brief_help,
111 		NULL,
112 	},
113 };
114 
115 /* *** Help command with help sections. *** */
116 struct cmd_help_long_result {
117 	cmdline_fixed_string_t help;
118 	cmdline_fixed_string_t section;
119 };
120 
121 static void cmd_help_long_parsed(void *parsed_result,
122                                  struct cmdline *cl,
123                                  __rte_unused void *data)
124 {
125 	int show_all = 0;
126 	struct cmd_help_long_result *res = parsed_result;
127 
128 	if (!strcmp(res->section, "all"))
129 		show_all = 1;
130 
131 	if (show_all || !strcmp(res->section, "control")) {
132 
133 		cmdline_printf(
134 			cl,
135 			"\n"
136 			"Control forwarding:\n"
137 			"-------------------\n\n"
138 
139 			"start\n"
140 			"    Start packet forwarding with current configuration.\n\n"
141 
142 			"start tx_first\n"
143 			"    Start packet forwarding with current config"
144 			" after sending one burst of packets.\n\n"
145 
146 			"stop\n"
147 			"    Stop packet forwarding, and display accumulated"
148 			" statistics.\n\n"
149 
150 			"quit\n"
151 			"    Quit to prompt.\n\n"
152 		);
153 	}
154 
155 	if (show_all || !strcmp(res->section, "display")) {
156 
157 		cmdline_printf(
158 			cl,
159 			"\n"
160 			"Display:\n"
161 			"--------\n\n"
162 
163 			"show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
164 			"    Display information for port_id, or all.\n\n"
165 
166 			"show port info (port_id) representor\n"
167 			"    Show supported representors for a specific port\n\n"
168 
169 			"show port port_id (module_eeprom|eeprom)\n"
170 			"    Display the module EEPROM or EEPROM information for port_id.\n\n"
171 
172 			"show port X rss reta (size) (mask0,mask1,...)\n"
173 			"    Display the rss redirection table entry indicated"
174 			" by masks on port X. size is used to indicate the"
175 			" hardware supported reta size\n\n"
176 
177 			"show port (port_id) rss-hash [key | algorithm]\n"
178 			"    Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
179 
180 			"clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 			"    Clear information for port_id, or all.\n\n"
182 
183 			"show (rxq|txq) info (port_id) (queue_id)\n"
184 			"    Display information for configured RX/TX queue.\n\n"
185 
186 			"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
187 			"    Display the given configuration.\n\n"
188 
189 			"read rxd (port_id) (queue_id) (rxd_id)\n"
190 			"    Display an RX descriptor of a port RX queue.\n\n"
191 
192 			"read txd (port_id) (queue_id) (txd_id)\n"
193 			"    Display a TX descriptor of a port TX queue.\n\n"
194 
195 			"show vf stats (port_id) (vf_id)\n"
196 			"    Display a VF's statistics.\n\n"
197 
198 			"clear vf stats (port_id) (vf_id)\n"
199 			"    Reset a VF's statistics.\n\n"
200 
201 			"show port meter stats (port_id) (meter_id) (clear)\n"
202 			"    Get meter stats on a port\n\n"
203 
204 			"show fwd stats all\n"
205 			"    Display statistics for all fwd engines.\n\n"
206 
207 			"clear fwd stats all\n"
208 			"    Clear statistics for all fwd engines.\n\n"
209 
210 			"show port (port_id) rx_offload capabilities\n"
211 			"    List all per queue and per port Rx offloading"
212 			" capabilities of a port\n\n"
213 
214 			"show port (port_id) rx_offload configuration\n"
215 			"    List port level and all queue level"
216 			" Rx offloading configuration\n\n"
217 
218 			"show port (port_id) tx_offload capabilities\n"
219 			"    List all per queue and per port"
220 			" Tx offloading capabilities of a port\n\n"
221 
222 			"show port (port_id) tx_offload configuration\n"
223 			"    List port level and all queue level"
224 			" Tx offloading configuration\n\n"
225 
226 			"show port (port_id) tx_metadata\n"
227 			"    Show Tx metadata value set"
228 			" for a specific port\n\n"
229 
230 			"show port (port_id) ptypes\n"
231 			"    Show port supported ptypes"
232 			" for a specific port\n\n"
233 
234 			"show device info (<identifier>|all)"
235 			"       Show general information about devices probed.\n\n"
236 
237 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
238 			"       Show status of rx|tx descriptor.\n\n"
239 
240 			"show port (port_id) rxq (queue_id) desc used count\n"
241 			"    Show current number of filled receive"
242 			" packet descriptors.\n\n"
243 
244 			"show port (port_id) macs|mcast_macs"
245 			"       Display list of mac addresses added to port.\n\n"
246 
247 			"show port (port_id) flow transfer proxy\n"
248 			"	Display proxy port to manage transfer flows\n\n"
249 
250 			"show port (port_id) fec capabilities"
251 			"	Show fec capabilities of a port.\n\n"
252 
253 			"show port (port_id) fec_mode"
254 			"	Show fec mode of a port.\n\n"
255 
256 			"show port (port_id) flow_ctrl"
257 			"	Show flow control info of a port.\n\n"
258 
259 			"dump_physmem\n"
260 			"    Dumps all physical memory segment layouts\n\n"
261 
262 			"dump_socket_mem\n"
263 			"    Dumps the memory usage of all sockets\n\n"
264 
265 			"dump_memzone\n"
266 			"    Dumps the layout of all memory zones\n\n"
267 
268 			"dump_struct_sizes\n"
269 			"    Dumps the size of all memory structures\n\n"
270 
271 			"dump_ring\n"
272 			"    Dumps the status of all or specific element in DPDK rings\n\n"
273 
274 			"dump_mempool\n"
275 			"    Dumps the statistics of all or specific memory pool\n\n"
276 
277 			"dump_devargs\n"
278 			"    Dumps the user device list\n\n"
279 
280 			"dump_lcores\n"
281 			"    Dumps the logical cores list\n\n"
282 
283 			"dump_trace\n"
284 			"    Dumps the tracing data to the folder according to the current EAL settings\n\n"
285 
286 			"dump_log_types\n"
287 			"    Dumps the log level for all the dpdk modules\n\n"
288 		);
289 	}
290 
291 	if (show_all || !strcmp(res->section, "config")) {
292 		cmdline_printf(
293 			cl,
294 			"\n"
295 			"Configuration:\n"
296 			"--------------\n"
297 			"Configuration changes only become active when"
298 			" forwarding is started/restarted.\n\n"
299 
300 			"set default\n"
301 			"    Reset forwarding to the default configuration.\n\n"
302 
303 			"set verbose (level)\n"
304 			"    Set the debug verbosity level X.\n\n"
305 
306 			"set log global|(type) (level)\n"
307 			"    Set the log level.\n\n"
308 
309 			"set nbport (num)\n"
310 			"    Set number of ports.\n\n"
311 
312 			"set nbcore (num)\n"
313 			"    Set number of cores.\n\n"
314 
315 			"set coremask (mask)\n"
316 			"    Set the forwarding cores hexadecimal mask.\n\n"
317 
318 			"set portmask (mask)\n"
319 			"    Set the forwarding ports hexadecimal mask.\n\n"
320 
321 			"set burst (num)\n"
322 			"    Set number of packets per burst.\n\n"
323 
324 			"set burst tx delay (microseconds) retry (num)\n"
325 			"    Set the transmit delay time and number of retries,"
326 			" effective when retry is enabled.\n\n"
327 
328 			"set rxoffs (x[,y]*)\n"
329 			"    Set the offset of each packet segment on"
330 			" receiving if split feature is engaged."
331 			" Affects only the queues configured with split"
332 			" offloads.\n\n"
333 
334 			"set rxpkts (x[,y]*)\n"
335 			"    Set the length of each segment to scatter"
336 			" packets on receiving if split feature is engaged."
337 			" Affects only the queues configured with split"
338 			" offloads.\n\n"
339 
340 			"set rxhdrs (eth[,ipv4])*\n"
341 			"    Set the protocol hdr of each segment to scatter"
342 			" packets on receiving if split feature is engaged."
343 			" Affects only the queues configured with split"
344 			" offloads.\n"
345 			"    Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
346 			"ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
347 			"grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
348 			"inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
349 			"inner-ipv4-sctp|inner-ipv6-sctp\n\n"
350 
351 			"set txpkts (x[,y]*)\n"
352 			"    Set the length of each segment of TXONLY"
353 			" and optionally CSUM packets.\n\n"
354 
355 			"set txsplit (off|on|rand)\n"
356 			"    Set the split policy for the TX packets."
357 			" Right now only applicable for CSUM and TXONLY"
358 			" modes\n\n"
359 
360 			"set txtimes (x, y)\n"
361 			"    Set the scheduling on timestamps"
362 			" timings for the TXONLY mode\n\n"
363 
364 			"set corelist (x[,y]*)\n"
365 			"    Set the list of forwarding cores.\n\n"
366 
367 			"set portlist (x[,y]*)\n"
368 			"    Set the list of forwarding ports.\n\n"
369 
370 			"set port setup on (iterator|event)\n"
371 			"    Select how attached port is retrieved for setup.\n\n"
372 
373 			"set tx loopback (port_id) (on|off)\n"
374 			"    Enable or disable tx loopback.\n\n"
375 
376 			"set all queues drop (port_id) (on|off)\n"
377 			"    Set drop enable bit for all queues.\n\n"
378 
379 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
380 			"    Set MAC antispoof for a VF from the PF.\n\n"
381 
382 			"vlan set stripq (on|off) (port_id,queue_id)\n"
383 			"    Set the VLAN strip for a queue on a port.\n\n"
384 
385 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
386 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
387 
388 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
389 			"    Set VLAN insert for a VF from the PF.\n\n"
390 
391 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
392 			"    Set VLAN antispoof for a VF from the PF.\n\n"
393 
394 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
395 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
396 
397 			"vlan set (inner|outer) tpid (value) (port_id)\n"
398 			"    Set the VLAN TPID for Packet Filtering on"
399 			" a port\n\n"
400 
401 			"rx_vlan add (vlan_id|all) (port_id)\n"
402 			"    Add a vlan_id, or all identifiers, to the set"
403 			" of VLAN identifiers filtered by port_id.\n\n"
404 
405 			"rx_vlan rm (vlan_id|all) (port_id)\n"
406 			"    Remove a vlan_id, or all identifiers, from the set"
407 			" of VLAN identifiers filtered by port_id.\n\n"
408 
409 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
410 			"    Add a vlan_id, to the set of VLAN identifiers"
411 			"filtered for VF(s) from port_id.\n\n"
412 
413 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
414 			"    Remove a vlan_id, to the set of VLAN identifiers"
415 			"filtered for VF(s) from port_id.\n\n"
416 
417 			"rx_vxlan_port add (udp_port) (port_id)\n"
418 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
419 
420 			"rx_vxlan_port rm (udp_port) (port_id)\n"
421 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
422 
423 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
424 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
425 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
426 
427 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
428 			"    Set port based TX VLAN insertion.\n\n"
429 
430 			"tx_vlan reset (port_id)\n"
431 			"    Disable hardware insertion of a VLAN header in"
432 			" packets sent on a port.\n\n"
433 
434 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
435 			"    Select hardware or software calculation of the"
436 			" checksum when transmitting a packet using the"
437 			" csum forward engine.\n"
438 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
439 			"    outer-ip concerns the outer IP layer in"
440 			"    outer-udp concerns the outer UDP layer in"
441 			" case the packet is recognized as a tunnel packet by"
442 			" the forward engine (vxlan, gre and ipip are supported)\n"
443 			"    Please check the NIC datasheet for HW limits.\n\n"
444 
445 			"csum parse-tunnel (on|off) (tx_port_id)\n"
446 			"    If disabled, treat tunnel packets as non-tunneled"
447 			" packets (treat inner headers as payload). The port\n"
448 			"    argument is the port used for TX in csum forward"
449 			" engine.\n\n"
450 
451 			"csum show (port_id)\n"
452 			"    Display tx checksum offload configuration\n\n"
453 
454 			"tso set (segsize) (portid)\n"
455 			"    Enable TCP Segmentation Offload in csum forward"
456 			" engine.\n"
457 			"    Please check the NIC datasheet for HW limits.\n\n"
458 
459 			"tso show (portid)"
460 			"    Display the status of TCP Segmentation Offload.\n\n"
461 
462 #ifdef RTE_LIB_GRO
463 			"set port (port_id) gro on|off\n"
464 			"    Enable or disable Generic Receive Offload in"
465 			" csum forwarding engine.\n\n"
466 
467 			"show port (port_id) gro\n"
468 			"    Display GRO configuration.\n\n"
469 
470 			"set gro flush (cycles)\n"
471 			"    Set the cycle to flush GROed packets from"
472 			" reassembly tables.\n\n"
473 #endif
474 
475 #ifdef RTE_LIB_GSO
476 			"set port (port_id) gso (on|off)"
477 			"    Enable or disable Generic Segmentation Offload in"
478 			" csum forwarding engine.\n\n"
479 
480 			"set gso segsz (length)\n"
481 			"    Set max packet length for output GSO segments,"
482 			" including packet header and payload.\n\n"
483 
484 			"show port (port_id) gso\n"
485 			"    Show GSO configuration.\n\n"
486 #endif
487 
488 			"set fwd (%s)\n"
489 			"    Set packet forwarding mode.\n\n"
490 
491 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 			"    Add a MAC address on port_id.\n\n"
493 
494 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
495 			"    Remove a MAC address from port_id.\n\n"
496 
497 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
498 			"    Set the default MAC address for port_id.\n\n"
499 
500 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
501 			"    Add a MAC address for a VF on the port.\n\n"
502 
503 			"mcast_addr add (port_id) (mcast_addr)\n"
504 			"    Add a multicast MAC addresses on port_id.\n\n"
505 
506 			"mcast_addr remove (port_id) (mcast_addr)\n"
507 			"    Remove a multicast MAC address from port_id.\n\n"
508 
509 			"mcast_addr flush (port_id)\n"
510 			"    Flush all multicast MAC addresses on port_id.\n\n"
511 
512 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
513 			"    Set the MAC address for a VF from the PF.\n\n"
514 
515 			"set eth-peer (port_id) (peer_addr)\n"
516 			"    set the peer address for certain port.\n\n"
517 
518 			"set port (port_id) uta (mac_address|all) (on|off)\n"
519 			"    Add/Remove a or all unicast hash filter(s)"
520 			"from port X.\n\n"
521 
522 			"set promisc (port_id|all) (on|off)\n"
523 			"    Set the promiscuous mode on port_id, or all.\n\n"
524 
525 			"set allmulti (port_id|all) (on|off)\n"
526 			"    Set the allmulti mode on port_id, or all.\n\n"
527 
528 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
529 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
530 			" (on|off) autoneg (on|off) (port_id)\n"
531 			"set flow_ctrl rx (on|off) (portid)\n"
532 			"set flow_ctrl tx (on|off) (portid)\n"
533 			"set flow_ctrl high_water (high_water) (portid)\n"
534 			"set flow_ctrl low_water (low_water) (portid)\n"
535 			"set flow_ctrl pause_time (pause_time) (portid)\n"
536 			"set flow_ctrl send_xon (send_xon) (portid)\n"
537 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
538 			"set flow_ctrl autoneg (on|off) (port_id)\n"
539 			"    Set the link flow control parameter on a port.\n\n"
540 
541 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
542 			" (low_water) (pause_time) (priority) (port_id)\n"
543 			"    Set the priority flow control parameter on a"
544 			" port.\n\n"
545 
546 			"set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
547 			" (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
548 			"    Set the queue priority flow control parameter on a"
549 			" given Rx and Tx queues of a port.\n\n"
550 
551 			"set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
552 			"    set available descriptors threshold for Rx queue\n\n"
553 
554 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
555 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
556 			" queue on port.\n"
557 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
558 			" on port 0 to mapping 5.\n\n"
559 
560 			"set xstats-hide-zero on|off\n"
561 			"    Set the option to hide the zero values"
562 			" for xstats display.\n"
563 
564 			"set record-core-cycles on|off\n"
565 			"    Set the option to enable measurement of CPU cycles.\n"
566 
567 			"set record-burst-stats on|off\n"
568 			"    Set the option to enable display of RX and TX bursts.\n"
569 
570 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
571 			"    Enable/Disable a VF receive/transmit from a port\n\n"
572 
573 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
574 			"|MPE) (on|off)\n"
575 			"    AUPE:accepts untagged VLAN;"
576 			"ROPE:accept unicast hash\n\n"
577 			"    BAM:accepts broadcast packets;"
578 			"MPE:accepts all multicast packets\n\n"
579 			"    Enable/Disable a VF receive mode of a port\n\n"
580 
581 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
582 			"    Set rate limit for a queue of a port\n\n"
583 
584 			"set port (port_id) vf (vf_id) rate (rate_num) "
585 			"queue_mask (queue_mask_value)\n"
586 			"    Set rate limit for queues in VF of a port\n\n"
587 
588 			"set flush_rx (on|off)\n"
589 			"   Flush (default) or don't flush RX streams before"
590 			" forwarding. Mainly used with PCAP drivers.\n\n"
591 
592 			"set link-up port (port_id)\n"
593 			"	Set link up for a port.\n\n"
594 
595 			"set link-down port (port_id)\n"
596 			"	Set link down for a port.\n\n"
597 
598 			"set port (port_id) ptype_mask (ptype_mask)\n"
599 			"    set packet types classification for a specific port\n\n"
600 
601 			"show port meter cap (port_id)\n"
602 			"    Show port meter capability information\n\n"
603 
604 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
605 			"    meter profile add - srtcm rfc 2697\n\n"
606 
607 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
608 			"    meter profile add - trtcm rfc 2698\n\n"
609 
610 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
611 			"    meter profile add - trtcm rfc 4115\n\n"
612 
613 			"del port meter profile (port_id) (profile_id)\n"
614 			"    meter profile delete\n\n"
615 
616 			"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
617 			"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
618 			"(dscp_tbl_entry63)]\n"
619 			"    meter create\n\n"
620 
621 			"enable port meter (port_id) (mtr_id)\n"
622 			"    meter enable\n\n"
623 
624 			"disable port meter (port_id) (mtr_id)\n"
625 			"    meter disable\n\n"
626 
627 			"del port meter (port_id) (mtr_id)\n"
628 			"    meter delete\n\n"
629 
630 			"add port meter policy (port_id) (policy_id) g_actions (actions)\n"
631 			"y_actions (actions) r_actions (actions)\n"
632 			"    meter policy add\n\n"
633 
634 			"del port meter policy (port_id) (policy_id)\n"
635 			"    meter policy delete\n\n"
636 
637 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
638 			"    meter update meter profile\n\n"
639 
640 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
641 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
642 			"    update meter dscp table entries\n\n"
643 
644 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
645 			"(action0) [(action1) (action2)]\n"
646 			"    meter update policer action\n\n"
647 
648 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
649 			"    meter update stats\n\n"
650 
651 			"set port (port_id) fec_mode auto|off|rs|baser\n"
652 			"    set fec mode for a specific port\n\n"
653 
654 			"show port cman capa (port_id)\n"
655 			"    Show congestion management capabilities\n\n"
656 
657 			"show port cman config (port_id)\n"
658 			"    Show congestion management configuration\n\n"
659 
660 			"set port cman config (port_id) (queue_id) default | "
661 			"[obj (queue|queue_mempool) mode red (min_thresh) "
662 			"(max_thresh) (prob_inv)]\n"
663 			"    Set congestion management configuration\n\n"
664 
665 			, list_pkt_forwarding_modes()
666 		);
667 	}
668 
669 	if (show_all || !strcmp(res->section, "ports")) {
670 
671 		cmdline_printf(
672 			cl,
673 			"\n"
674 			"Port Operations:\n"
675 			"----------------\n\n"
676 
677 			"port start (port_id|all)\n"
678 			"    Start all ports or port_id.\n\n"
679 
680 			"port stop (port_id|all)\n"
681 			"    Stop all ports or port_id.\n\n"
682 
683 			"port close (port_id|all)\n"
684 			"    Close all ports or port_id.\n\n"
685 
686 			"port reset (port_id|all)\n"
687 			"    Reset all ports or port_id.\n\n"
688 
689 			"port attach (ident)\n"
690 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
691 
692 			"port detach (port_id)\n"
693 			"    Detach physical or virtual dev by port_id\n\n"
694 
695 			"port config (port_id|all)"
696 			" speed (10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto)"
697 			" duplex (half|full|auto)\n"
698 			"    Set speed and duplex for all ports or port_id\n\n"
699 
700 			"port config (port_id|all) loopback (mode)\n"
701 			"    Set loopback mode for all ports or port_id\n\n"
702 
703 			"port config all (rxq|txq|rxd|txd) (value)\n"
704 			"    Set number for rxq/txq/rxd/txd.\n\n"
705 
706 			"port config all max-pkt-len (value)\n"
707 			"    Set the max packet length.\n\n"
708 
709 			"port config all max-lro-pkt-size (value)\n"
710 			"    Set the max LRO aggregated packet size.\n\n"
711 
712 			"port config all drop-en (on|off)\n"
713 			"    Enable or disable packet drop on all RX queues of all ports when no "
714 			"receive buffers available.\n\n"
715 
716 			"port config all rss (all|default|level-default|level-outer|level-inner|"
717 			"ip|tcp|udp|sctp|tunnel|vlan|none|"
718 			"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
719 			"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
720 			"l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
721 			"esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
722 			"l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
723 			"l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
724 			"    Set the RSS mode.\n\n"
725 
726 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
727 			"    Set the RSS redirection table.\n\n"
728 
729 			"port config (port_id) dcb vt (on|off) (traffic_class)"
730 			" pfc (on|off)\n"
731 			"    Set the DCB mode.\n\n"
732 
733 			"port config all burst (value)\n"
734 			"    Set the number of packets per burst.\n\n"
735 
736 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
737 			" (value)\n"
738 			"    Set the ring prefetch/host/writeback threshold"
739 			" for tx/rx queue.\n\n"
740 
741 			"port config all (txfreet|txrst|rxfreet) (value)\n"
742 			"    Set free threshold for rx/tx, or set"
743 			" tx rs bit threshold.\n\n"
744 			"port config mtu X value\n"
745 			"    Set the MTU of port X to a given value\n\n"
746 
747 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
748 			"    Set a rx/tx queue's ring size configuration, the new"
749 			" value will take effect after command that (re-)start the port"
750 			" or command that setup the specific queue\n\n"
751 
752 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
753 			"    Start/stop a rx/tx queue of port X. Only take effect"
754 			" when port X is started\n\n"
755 
756 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
757 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
758 			" take effect when port X is stopped.\n\n"
759 
760 			"port (port_id) (rxq|txq) (queue_id) setup\n"
761 			"    Setup a rx/tx queue of port X.\n\n"
762 
763 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
764 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
765 
766 			"port config (port_id|all) rx_offload all|vlan_strip|"
767 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
768 			"outer_ipv4_cksum|macsec_strip|"
769 			"vlan_filter|vlan_extend|scatter|"
770 			"buffer_split|timestamp|security|keep_crc on|off\n"
771 			"     Enable or disable a per port Rx offloading"
772 			" on all Rx queues of a port\n\n"
773 
774 			"port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
775 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
776 			"outer_ipv4_cksum|macsec_strip|"
777 			"vlan_filter|vlan_extend|scatter|"
778 			"buffer_split|timestamp|security|keep_crc on|off\n"
779 			"    Enable or disable a per queue Rx offloading"
780 			" only on a specific Rx queue\n\n"
781 
782 			"port config (port_id|all) tx_offload all|vlan_insert|"
783 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
784 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
785 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
786 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
787 			"security on|off\n"
788 			"    Enable or disable a per port Tx offloading"
789 			" on all Tx queues of a port\n\n"
790 
791 			"port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
792 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
793 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
794 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
795 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
796 			" on|off\n"
797 			"    Enable or disable a per queue Tx offloading"
798 			" only on a specific Tx queue\n\n"
799 
800 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
801 			"    Load an eBPF program as a callback"
802 			" for particular RX/TX queue\n\n"
803 
804 			"bpf-unload rx|tx (port) (queue)\n"
805 			"    Unload previously loaded eBPF program"
806 			" for particular RX/TX queue\n\n"
807 
808 			"port config (port_id) tx_metadata (value)\n"
809 			"    Set Tx metadata value per port. Testpmd will add this value"
810 			" to any Tx packet sent from this port\n\n"
811 
812 			"port config (port_id) dynf (name) set|clear\n"
813 			"    Register a dynf and Set/clear this flag on Tx. "
814 			"Testpmd will set this value to any Tx packet "
815 			"sent from this port\n\n"
816 
817 			"port cleanup (port_id) txq (queue_id) (free_cnt)\n"
818 			"    Cleanup txq mbufs for a specific Tx queue\n\n"
819 
820 			"port config (port_id) txq (queue_id) affinity (value)\n"
821 			"    Map a Tx queue with an aggregated port "
822 			"of the DPDK port\n\n"
823 		);
824 	}
825 
826 	if (show_all || !strcmp(res->section, "filters")) {
827 
828 		cmdline_printf(
829 			cl,
830 			"\n"
831 			"filters:\n"
832 			"--------\n\n"
833 
834 			"flow validate {port_id}"
835 			" [group {group_id}] [priority {level}]"
836 			" [ingress] [egress]"
837 			" pattern {item} [/ {item} [...]] / end"
838 			" actions {action} [/ {action} [...]] / end\n"
839 			"    Check whether a flow rule can be created.\n\n"
840 
841 			"flow create {port_id}"
842 			" [group {group_id}] [priority {level}]"
843 			" [ingress] [egress]"
844 			" pattern {item} [/ {item} [...]] / end"
845 			" actions {action} [/ {action} [...]] / end\n"
846 			"    Create a flow rule.\n\n"
847 
848 			"flow destroy {port_id} rule {rule_id} [...]\n"
849 			"    Destroy specific flow rules.\n\n"
850 
851 			"flow flush {port_id}\n"
852 			"    Destroy all flow rules.\n\n"
853 
854 			"flow query {port_id} {rule_id} {action}\n"
855 			"    Query an existing flow rule.\n\n"
856 
857 			"flow list {port_id} [group {group_id}] [...]\n"
858 			"    List existing flow rules sorted by priority,"
859 			" filtered by group identifiers.\n\n"
860 
861 			"flow isolate {port_id} {boolean}\n"
862 			"    Restrict ingress traffic to the defined"
863 			" flow rules\n\n"
864 
865 			"flow aged {port_id} [destroy]\n"
866 			"    List and destroy aged flows"
867 			" flow rules\n\n"
868 
869 			"flow indirect_action {port_id} create"
870 			" [action_id {indirect_action_id}]"
871 			" [ingress] [egress]"
872 			" action {action} / end\n"
873 			"    Create indirect action.\n\n"
874 
875 			"flow indirect_action {port_id} update"
876 			" {indirect_action_id} action {action} / end\n"
877 			"    Update indirect action.\n\n"
878 
879 			"flow indirect_action {port_id} destroy"
880 			" action_id {indirect_action_id} [...]\n"
881 			"    Destroy specific indirect actions.\n\n"
882 
883 			"flow indirect_action {port_id} query"
884 			" {indirect_action_id}\n"
885 			"    Query an existing indirect action.\n\n"
886 
887 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
888 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
889 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
890 			"       Configure the VXLAN encapsulation for flows.\n\n"
891 
892 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
893 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
894 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
895 			" eth-dst (eth-dst)\n"
896 			"       Configure the VXLAN encapsulation for flows.\n\n"
897 
898 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
899 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
900 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
901 			" eth-dst (eth-dst)\n"
902 			"       Configure the VXLAN encapsulation for flows.\n\n"
903 
904 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
905 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
906 			" (eth-dst)\n"
907 			"       Configure the NVGRE encapsulation for flows.\n\n"
908 
909 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
910 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
911 			" eth-src (eth-src) eth-dst (eth-dst)\n"
912 			"       Configure the NVGRE encapsulation for flows.\n\n"
913 
914 			"set raw_encap {flow items}\n"
915 			"	Configure the encapsulation with raw data.\n\n"
916 
917 			"set raw_decap {flow items}\n"
918 			"	Configure the decapsulation with raw data.\n\n"
919 
920 		);
921 	}
922 
923 	if (show_all || !strcmp(res->section, "traffic_management")) {
924 		cmdline_printf(
925 			cl,
926 			"\n"
927 			"Traffic Management:\n"
928 			"--------------\n"
929 			"show port tm cap (port_id)\n"
930 			"       Display the port TM capability.\n\n"
931 
932 			"show port tm level cap (port_id) (level_id)\n"
933 			"       Display the port TM hierarchical level capability.\n\n"
934 
935 			"show port tm node cap (port_id) (node_id)\n"
936 			"       Display the port TM node capability.\n\n"
937 
938 			"show port tm node type (port_id) (node_id)\n"
939 			"       Display the port TM node type.\n\n"
940 
941 			"show port tm node stats (port_id) (node_id) (clear)\n"
942 			"       Display the port TM node stats.\n\n"
943 
944 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
945 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
946 			" (packet_length_adjust) (packet_mode)\n"
947 			"       Add port tm node private shaper profile.\n\n"
948 
949 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
950 			"       Delete port tm node private shaper profile.\n\n"
951 
952 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
953 			" (shaper_profile_id)\n"
954 			"       Add/update port tm node shared shaper.\n\n"
955 
956 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
957 			"       Delete port tm node shared shaper.\n\n"
958 
959 			"set port tm node shaper profile (port_id) (node_id)"
960 			" (shaper_profile_id)\n"
961 			"       Set port tm node shaper profile.\n\n"
962 
963 			"add port tm node wred profile (port_id) (wred_profile_id)"
964 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
965 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
966 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
967 			"       Add port tm node wred profile.\n\n"
968 
969 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
970 			"       Delete port tm node wred profile.\n\n"
971 
972 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
973 			" (priority) (weight) (level_id) (shaper_profile_id)"
974 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
975 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
976 			"       Add port tm nonleaf node.\n\n"
977 
978 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
979 			" (priority) (weight) (level_id) (shaper_profile_id)"
980 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
981 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
982 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
983 
984 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
985 			" (priority) (weight) (level_id) (shaper_profile_id)"
986 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
987 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
988 			"       Add port tm leaf node.\n\n"
989 
990 			"del port tm node (port_id) (node_id)\n"
991 			"       Delete port tm node.\n\n"
992 
993 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
994 			" (priority) (weight)\n"
995 			"       Set port tm node parent.\n\n"
996 
997 			"suspend port tm node (port_id) (node_id)"
998 			"       Suspend tm node.\n\n"
999 
1000 			"resume port tm node (port_id) (node_id)"
1001 			"       Resume tm node.\n\n"
1002 
1003 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1004 			"       Commit tm hierarchy.\n\n"
1005 
1006 			"set port tm mark ip_ecn (port) (green) (yellow)"
1007 			" (red)\n"
1008 			"    Enables/Disables the traffic management marking"
1009 			" for IP ECN (Explicit Congestion Notification)"
1010 			" packets on a given port\n\n"
1011 
1012 			"set port tm mark ip_dscp (port) (green) (yellow)"
1013 			" (red)\n"
1014 			"    Enables/Disables the traffic management marking"
1015 			" on the port for IP dscp packets\n\n"
1016 
1017 			"set port tm mark vlan_dei (port) (green) (yellow)"
1018 			" (red)\n"
1019 			"    Enables/Disables the traffic management marking"
1020 			" on the port for VLAN packets with DEI enabled\n\n"
1021 		);
1022 	}
1023 
1024 	if (show_all || !strcmp(res->section, "devices")) {
1025 		cmdline_printf(
1026 			cl,
1027 			"\n"
1028 			"Device Operations:\n"
1029 			"--------------\n"
1030 			"device detach (identifier)\n"
1031 			"       Detach device by identifier.\n\n"
1032 		);
1033 	}
1034 
1035 	if (show_all || !strcmp(res->section, "drivers")) {
1036 		struct testpmd_driver_commands *c;
1037 		unsigned int i;
1038 
1039 		cmdline_printf(
1040 			cl,
1041 			"\n"
1042 			"Driver specific:\n"
1043 			"----------------\n"
1044 		);
1045 		TAILQ_FOREACH(c, &driver_commands_head, next) {
1046 			for (i = 0; c->commands[i].ctx != NULL; i++)
1047 				cmdline_printf(cl, "%s\n", c->commands[i].help);
1048 		}
1049 	}
1050 }
1051 
1052 static cmdline_parse_token_string_t cmd_help_long_help =
1053 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1054 
1055 static cmdline_parse_token_string_t cmd_help_long_section =
1056 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1057 		"all#control#display#config#ports#"
1058 		"filters#traffic_management#devices#drivers");
1059 
1060 static cmdline_parse_inst_t cmd_help_long = {
1061 	.f = cmd_help_long_parsed,
1062 	.data = NULL,
1063 	.help_str = "help all|control|display|config|ports|"
1064 		"filters|traffic_management|devices|drivers: "
1065 		"Show help",
1066 	.tokens = {
1067 		(void *)&cmd_help_long_help,
1068 		(void *)&cmd_help_long_section,
1069 		NULL,
1070 	},
1071 };
1072 
1073 
1074 /* *** start/stop/close all ports *** */
1075 struct cmd_operate_port_result {
1076 	cmdline_fixed_string_t keyword;
1077 	cmdline_fixed_string_t name;
1078 	cmdline_fixed_string_t value;
1079 };
1080 
1081 static void cmd_operate_port_parsed(void *parsed_result,
1082 				__rte_unused struct cmdline *cl,
1083 				__rte_unused void *data)
1084 {
1085 	struct cmd_operate_port_result *res = parsed_result;
1086 
1087 	if (!strcmp(res->name, "start"))
1088 		start_port(RTE_PORT_ALL);
1089 	else if (!strcmp(res->name, "stop"))
1090 		stop_port(RTE_PORT_ALL);
1091 	else if (!strcmp(res->name, "close"))
1092 		close_port(RTE_PORT_ALL);
1093 	else if (!strcmp(res->name, "reset"))
1094 		reset_port(RTE_PORT_ALL);
1095 	else
1096 		fprintf(stderr, "Unknown parameter\n");
1097 }
1098 
1099 static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1100 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1101 								"port");
1102 static cmdline_parse_token_string_t cmd_operate_port_all_port =
1103 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1104 						"start#stop#close#reset");
1105 static cmdline_parse_token_string_t cmd_operate_port_all_all =
1106 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1107 
1108 static cmdline_parse_inst_t cmd_operate_port = {
1109 	.f = cmd_operate_port_parsed,
1110 	.data = NULL,
1111 	.help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1112 	.tokens = {
1113 		(void *)&cmd_operate_port_all_cmd,
1114 		(void *)&cmd_operate_port_all_port,
1115 		(void *)&cmd_operate_port_all_all,
1116 		NULL,
1117 	},
1118 };
1119 
1120 /* *** start/stop/close specific port *** */
1121 struct cmd_operate_specific_port_result {
1122 	cmdline_fixed_string_t keyword;
1123 	cmdline_fixed_string_t name;
1124 	uint8_t value;
1125 };
1126 
1127 static void cmd_operate_specific_port_parsed(void *parsed_result,
1128 			__rte_unused struct cmdline *cl,
1129 				__rte_unused void *data)
1130 {
1131 	struct cmd_operate_specific_port_result *res = parsed_result;
1132 
1133 	if (!strcmp(res->name, "start"))
1134 		start_port(res->value);
1135 	else if (!strcmp(res->name, "stop"))
1136 		stop_port(res->value);
1137 	else if (!strcmp(res->name, "close"))
1138 		close_port(res->value);
1139 	else if (!strcmp(res->name, "reset"))
1140 		reset_port(res->value);
1141 	else
1142 		fprintf(stderr, "Unknown parameter\n");
1143 }
1144 
1145 static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1146 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1147 							keyword, "port");
1148 static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1149 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1150 						name, "start#stop#close#reset");
1151 static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1152 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1153 							value, RTE_UINT8);
1154 
1155 static cmdline_parse_inst_t cmd_operate_specific_port = {
1156 	.f = cmd_operate_specific_port_parsed,
1157 	.data = NULL,
1158 	.help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1159 	.tokens = {
1160 		(void *)&cmd_operate_specific_port_cmd,
1161 		(void *)&cmd_operate_specific_port_port,
1162 		(void *)&cmd_operate_specific_port_id,
1163 		NULL,
1164 	},
1165 };
1166 
1167 /* *** enable port setup (after attach) via iterator or event *** */
1168 struct cmd_set_port_setup_on_result {
1169 	cmdline_fixed_string_t set;
1170 	cmdline_fixed_string_t port;
1171 	cmdline_fixed_string_t setup;
1172 	cmdline_fixed_string_t on;
1173 	cmdline_fixed_string_t mode;
1174 };
1175 
1176 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1177 				__rte_unused struct cmdline *cl,
1178 				__rte_unused void *data)
1179 {
1180 	struct cmd_set_port_setup_on_result *res = parsed_result;
1181 
1182 	if (strcmp(res->mode, "event") == 0)
1183 		setup_on_probe_event = true;
1184 	else if (strcmp(res->mode, "iterator") == 0)
1185 		setup_on_probe_event = false;
1186 	else
1187 		fprintf(stderr, "Unknown mode\n");
1188 }
1189 
1190 static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1191 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1192 			set, "set");
1193 static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1194 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1195 			port, "port");
1196 static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1197 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1198 			setup, "setup");
1199 static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1200 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1201 			on, "on");
1202 static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1203 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1204 			mode, "iterator#event");
1205 
1206 static cmdline_parse_inst_t cmd_set_port_setup_on = {
1207 	.f = cmd_set_port_setup_on_parsed,
1208 	.data = NULL,
1209 	.help_str = "set port setup on iterator|event",
1210 	.tokens = {
1211 		(void *)&cmd_set_port_setup_on_set,
1212 		(void *)&cmd_set_port_setup_on_port,
1213 		(void *)&cmd_set_port_setup_on_setup,
1214 		(void *)&cmd_set_port_setup_on_on,
1215 		(void *)&cmd_set_port_setup_on_mode,
1216 		NULL,
1217 	},
1218 };
1219 
1220 /* *** attach a specified port *** */
1221 struct cmd_operate_attach_port_result {
1222 	cmdline_fixed_string_t port;
1223 	cmdline_fixed_string_t keyword;
1224 	cmdline_multi_string_t identifier;
1225 };
1226 
1227 static void cmd_operate_attach_port_parsed(void *parsed_result,
1228 				__rte_unused struct cmdline *cl,
1229 				__rte_unused void *data)
1230 {
1231 	struct cmd_operate_attach_port_result *res = parsed_result;
1232 
1233 	if (!strcmp(res->keyword, "attach"))
1234 		attach_port(res->identifier);
1235 	else
1236 		fprintf(stderr, "Unknown parameter\n");
1237 }
1238 
1239 static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1240 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1241 			port, "port");
1242 static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1243 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1244 			keyword, "attach");
1245 static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1246 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1247 			identifier, TOKEN_STRING_MULTI);
1248 
1249 static cmdline_parse_inst_t cmd_operate_attach_port = {
1250 	.f = cmd_operate_attach_port_parsed,
1251 	.data = NULL,
1252 	.help_str = "port attach <identifier>: "
1253 		"(identifier: pci address or virtual dev name)",
1254 	.tokens = {
1255 		(void *)&cmd_operate_attach_port_port,
1256 		(void *)&cmd_operate_attach_port_keyword,
1257 		(void *)&cmd_operate_attach_port_identifier,
1258 		NULL,
1259 	},
1260 };
1261 
1262 /* *** detach a specified port *** */
1263 struct cmd_operate_detach_port_result {
1264 	cmdline_fixed_string_t port;
1265 	cmdline_fixed_string_t keyword;
1266 	portid_t port_id;
1267 };
1268 
1269 static void cmd_operate_detach_port_parsed(void *parsed_result,
1270 				__rte_unused struct cmdline *cl,
1271 				__rte_unused void *data)
1272 {
1273 	struct cmd_operate_detach_port_result *res = parsed_result;
1274 
1275 	if (!strcmp(res->keyword, "detach")) {
1276 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1277 		detach_port_device(res->port_id);
1278 	} else {
1279 		fprintf(stderr, "Unknown parameter\n");
1280 	}
1281 }
1282 
1283 static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1284 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1285 			port, "port");
1286 static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1287 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1288 			keyword, "detach");
1289 static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1290 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1291 			port_id, RTE_UINT16);
1292 
1293 static cmdline_parse_inst_t cmd_operate_detach_port = {
1294 	.f = cmd_operate_detach_port_parsed,
1295 	.data = NULL,
1296 	.help_str = "port detach <port_id>",
1297 	.tokens = {
1298 		(void *)&cmd_operate_detach_port_port,
1299 		(void *)&cmd_operate_detach_port_keyword,
1300 		(void *)&cmd_operate_detach_port_port_id,
1301 		NULL,
1302 	},
1303 };
1304 
1305 /* *** detach device by identifier *** */
1306 struct cmd_operate_detach_device_result {
1307 	cmdline_fixed_string_t device;
1308 	cmdline_fixed_string_t keyword;
1309 	cmdline_fixed_string_t identifier;
1310 };
1311 
1312 static void cmd_operate_detach_device_parsed(void *parsed_result,
1313 				__rte_unused struct cmdline *cl,
1314 				__rte_unused void *data)
1315 {
1316 	struct cmd_operate_detach_device_result *res = parsed_result;
1317 
1318 	if (!strcmp(res->keyword, "detach"))
1319 		detach_devargs(res->identifier);
1320 	else
1321 		fprintf(stderr, "Unknown parameter\n");
1322 }
1323 
1324 static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1325 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1326 			device, "device");
1327 static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1328 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1329 			keyword, "detach");
1330 static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1331 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1332 			identifier, NULL);
1333 
1334 static cmdline_parse_inst_t cmd_operate_detach_device = {
1335 	.f = cmd_operate_detach_device_parsed,
1336 	.data = NULL,
1337 	.help_str = "device detach <identifier>:"
1338 		"(identifier: pci address or virtual dev name)",
1339 	.tokens = {
1340 		(void *)&cmd_operate_detach_device_device,
1341 		(void *)&cmd_operate_detach_device_keyword,
1342 		(void *)&cmd_operate_detach_device_identifier,
1343 		NULL,
1344 	},
1345 };
1346 /* *** configure speed for all ports *** */
1347 struct cmd_config_speed_all {
1348 	cmdline_fixed_string_t port;
1349 	cmdline_fixed_string_t keyword;
1350 	cmdline_fixed_string_t all;
1351 	cmdline_fixed_string_t item1;
1352 	cmdline_fixed_string_t item2;
1353 	cmdline_fixed_string_t value1;
1354 	cmdline_fixed_string_t value2;
1355 };
1356 
1357 static int
1358 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1359 {
1360 
1361 	int duplex;
1362 
1363 	if (!strcmp(duplexstr, "half")) {
1364 		duplex = RTE_ETH_LINK_HALF_DUPLEX;
1365 	} else if (!strcmp(duplexstr, "full")) {
1366 		duplex = RTE_ETH_LINK_FULL_DUPLEX;
1367 	} else if (!strcmp(duplexstr, "auto")) {
1368 		duplex = RTE_ETH_LINK_FULL_DUPLEX;
1369 	} else {
1370 		fprintf(stderr, "Unknown duplex parameter\n");
1371 		return -1;
1372 	}
1373 
1374 	if (!strcmp(speedstr, "10")) {
1375 		*speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1376 				RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1377 	} else if (!strcmp(speedstr, "100")) {
1378 		*speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1379 				RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1380 	} else {
1381 		if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1382 			fprintf(stderr, "Invalid speed/duplex parameters\n");
1383 			return -1;
1384 		}
1385 		if (!strcmp(speedstr, "1000")) {
1386 			*speed = RTE_ETH_LINK_SPEED_1G;
1387 		} else if (!strcmp(speedstr, "2500")) {
1388 			*speed = RTE_ETH_LINK_SPEED_2_5G;
1389 		} else if (!strcmp(speedstr, "5000")) {
1390 			*speed = RTE_ETH_LINK_SPEED_5G;
1391 		} else if (!strcmp(speedstr, "10000")) {
1392 			*speed = RTE_ETH_LINK_SPEED_10G;
1393 		} else if (!strcmp(speedstr, "25000")) {
1394 			*speed = RTE_ETH_LINK_SPEED_25G;
1395 		} else if (!strcmp(speedstr, "40000")) {
1396 			*speed = RTE_ETH_LINK_SPEED_40G;
1397 		} else if (!strcmp(speedstr, "50000")) {
1398 			*speed = RTE_ETH_LINK_SPEED_50G;
1399 		} else if (!strcmp(speedstr, "100000")) {
1400 			*speed = RTE_ETH_LINK_SPEED_100G;
1401 		} else if (!strcmp(speedstr, "200000")) {
1402 			*speed = RTE_ETH_LINK_SPEED_200G;
1403 		} else if (!strcmp(speedstr, "400000")) {
1404 			*speed = RTE_ETH_LINK_SPEED_400G;
1405 		} else if (!strcmp(speedstr, "auto")) {
1406 			*speed = RTE_ETH_LINK_SPEED_AUTONEG;
1407 		} else {
1408 			fprintf(stderr, "Unknown speed parameter\n");
1409 			return -1;
1410 		}
1411 	}
1412 
1413 	if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1414 		*speed |= RTE_ETH_LINK_SPEED_FIXED;
1415 
1416 	return 0;
1417 }
1418 
1419 static void
1420 cmd_config_speed_all_parsed(void *parsed_result,
1421 			__rte_unused struct cmdline *cl,
1422 			__rte_unused void *data)
1423 {
1424 	struct cmd_config_speed_all *res = parsed_result;
1425 	uint32_t link_speed;
1426 	portid_t pid;
1427 
1428 	if (!all_ports_stopped()) {
1429 		fprintf(stderr, "Please stop all ports first\n");
1430 		return;
1431 	}
1432 
1433 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1434 			&link_speed) < 0)
1435 		return;
1436 
1437 	RTE_ETH_FOREACH_DEV(pid) {
1438 		ports[pid].dev_conf.link_speeds = link_speed;
1439 	}
1440 
1441 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1442 }
1443 
1444 static cmdline_parse_token_string_t cmd_config_speed_all_port =
1445 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1446 static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1447 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1448 							"config");
1449 static cmdline_parse_token_string_t cmd_config_speed_all_all =
1450 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1451 static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1452 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1453 static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1454 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1455 				"10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1456 static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1457 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1458 static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1459 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1460 						"half#full#auto");
1461 
1462 static cmdline_parse_inst_t cmd_config_speed_all = {
1463 	.f = cmd_config_speed_all_parsed,
1464 	.data = NULL,
1465 	.help_str = "port config all speed "
1466 		"10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1467 							"half|full|auto",
1468 	.tokens = {
1469 		(void *)&cmd_config_speed_all_port,
1470 		(void *)&cmd_config_speed_all_keyword,
1471 		(void *)&cmd_config_speed_all_all,
1472 		(void *)&cmd_config_speed_all_item1,
1473 		(void *)&cmd_config_speed_all_value1,
1474 		(void *)&cmd_config_speed_all_item2,
1475 		(void *)&cmd_config_speed_all_value2,
1476 		NULL,
1477 	},
1478 };
1479 
1480 /* *** configure speed for specific port *** */
1481 struct cmd_config_speed_specific {
1482 	cmdline_fixed_string_t port;
1483 	cmdline_fixed_string_t keyword;
1484 	portid_t id;
1485 	cmdline_fixed_string_t item1;
1486 	cmdline_fixed_string_t item2;
1487 	cmdline_fixed_string_t value1;
1488 	cmdline_fixed_string_t value2;
1489 };
1490 
1491 static void
1492 cmd_config_speed_specific_parsed(void *parsed_result,
1493 				__rte_unused struct cmdline *cl,
1494 				__rte_unused void *data)
1495 {
1496 	struct cmd_config_speed_specific *res = parsed_result;
1497 	uint32_t link_speed;
1498 
1499 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1500 		return;
1501 
1502 	if (!port_is_stopped(res->id)) {
1503 		fprintf(stderr, "Please stop port %d first\n", res->id);
1504 		return;
1505 	}
1506 
1507 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1508 			&link_speed) < 0)
1509 		return;
1510 
1511 	ports[res->id].dev_conf.link_speeds = link_speed;
1512 
1513 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1514 }
1515 
1516 
1517 static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1518 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1519 								"port");
1520 static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1521 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1522 								"config");
1523 static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1524 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1525 static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1526 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1527 								"speed");
1528 static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1529 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1530 				"10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1531 static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1532 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1533 								"duplex");
1534 static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1535 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1536 							"half#full#auto");
1537 
1538 static cmdline_parse_inst_t cmd_config_speed_specific = {
1539 	.f = cmd_config_speed_specific_parsed,
1540 	.data = NULL,
1541 	.help_str = "port config <port_id> speed "
1542 		"10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1543 							"half|full|auto",
1544 	.tokens = {
1545 		(void *)&cmd_config_speed_specific_port,
1546 		(void *)&cmd_config_speed_specific_keyword,
1547 		(void *)&cmd_config_speed_specific_id,
1548 		(void *)&cmd_config_speed_specific_item1,
1549 		(void *)&cmd_config_speed_specific_value1,
1550 		(void *)&cmd_config_speed_specific_item2,
1551 		(void *)&cmd_config_speed_specific_value2,
1552 		NULL,
1553 	},
1554 };
1555 
1556 /* *** configure loopback for all ports *** */
1557 struct cmd_config_loopback_all {
1558 	cmdline_fixed_string_t port;
1559 	cmdline_fixed_string_t keyword;
1560 	cmdline_fixed_string_t all;
1561 	cmdline_fixed_string_t item;
1562 	uint32_t mode;
1563 };
1564 
1565 static void
1566 cmd_config_loopback_all_parsed(void *parsed_result,
1567 			__rte_unused struct cmdline *cl,
1568 			__rte_unused void *data)
1569 {
1570 	struct cmd_config_loopback_all *res = parsed_result;
1571 	portid_t pid;
1572 
1573 	if (!all_ports_stopped()) {
1574 		fprintf(stderr, "Please stop all ports first\n");
1575 		return;
1576 	}
1577 
1578 	RTE_ETH_FOREACH_DEV(pid) {
1579 		ports[pid].dev_conf.lpbk_mode = res->mode;
1580 	}
1581 
1582 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1583 }
1584 
1585 static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1586 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1587 static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1588 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1589 							"config");
1590 static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1591 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1592 static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1593 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1594 							"loopback");
1595 static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1596 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1597 
1598 static cmdline_parse_inst_t cmd_config_loopback_all = {
1599 	.f = cmd_config_loopback_all_parsed,
1600 	.data = NULL,
1601 	.help_str = "port config all loopback <mode>",
1602 	.tokens = {
1603 		(void *)&cmd_config_loopback_all_port,
1604 		(void *)&cmd_config_loopback_all_keyword,
1605 		(void *)&cmd_config_loopback_all_all,
1606 		(void *)&cmd_config_loopback_all_item,
1607 		(void *)&cmd_config_loopback_all_mode,
1608 		NULL,
1609 	},
1610 };
1611 
1612 /* *** configure loopback for specific port *** */
1613 struct cmd_config_loopback_specific {
1614 	cmdline_fixed_string_t port;
1615 	cmdline_fixed_string_t keyword;
1616 	uint16_t port_id;
1617 	cmdline_fixed_string_t item;
1618 	uint32_t mode;
1619 };
1620 
1621 static void
1622 cmd_config_loopback_specific_parsed(void *parsed_result,
1623 				__rte_unused struct cmdline *cl,
1624 				__rte_unused void *data)
1625 {
1626 	struct cmd_config_loopback_specific *res = parsed_result;
1627 
1628 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1629 		return;
1630 
1631 	if (!port_is_stopped(res->port_id)) {
1632 		fprintf(stderr, "Please stop port %u first\n", res->port_id);
1633 		return;
1634 	}
1635 
1636 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1637 
1638 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1639 }
1640 
1641 
1642 static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1643 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1644 								"port");
1645 static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1646 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1647 								"config");
1648 static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1649 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1650 								RTE_UINT16);
1651 static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1652 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1653 								"loopback");
1654 static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1655 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1656 			      RTE_UINT32);
1657 
1658 static cmdline_parse_inst_t cmd_config_loopback_specific = {
1659 	.f = cmd_config_loopback_specific_parsed,
1660 	.data = NULL,
1661 	.help_str = "port config <port_id> loopback <mode>",
1662 	.tokens = {
1663 		(void *)&cmd_config_loopback_specific_port,
1664 		(void *)&cmd_config_loopback_specific_keyword,
1665 		(void *)&cmd_config_loopback_specific_id,
1666 		(void *)&cmd_config_loopback_specific_item,
1667 		(void *)&cmd_config_loopback_specific_mode,
1668 		NULL,
1669 	},
1670 };
1671 
1672 /* *** configure txq/rxq, txd/rxd *** */
1673 struct cmd_config_rx_tx {
1674 	cmdline_fixed_string_t port;
1675 	cmdline_fixed_string_t keyword;
1676 	cmdline_fixed_string_t all;
1677 	cmdline_fixed_string_t name;
1678 	uint16_t value;
1679 };
1680 
1681 static void
1682 cmd_config_rx_tx_parsed(void *parsed_result,
1683 			__rte_unused struct cmdline *cl,
1684 			__rte_unused void *data)
1685 {
1686 	struct cmd_config_rx_tx *res = parsed_result;
1687 
1688 	if (!all_ports_stopped()) {
1689 		fprintf(stderr, "Please stop all ports first\n");
1690 		return;
1691 	}
1692 	if (!strcmp(res->name, "rxq")) {
1693 		if (!res->value && !nb_txq) {
1694 			fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1695 			return;
1696 		}
1697 		if (check_nb_rxq(res->value) != 0)
1698 			return;
1699 		nb_rxq = res->value;
1700 	}
1701 	else if (!strcmp(res->name, "txq")) {
1702 		if (!res->value && !nb_rxq) {
1703 			fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1704 			return;
1705 		}
1706 		if (check_nb_txq(res->value) != 0)
1707 			return;
1708 		nb_txq = res->value;
1709 	}
1710 	else if (!strcmp(res->name, "rxd")) {
1711 		if (check_nb_rxd(res->value) != 0)
1712 			return;
1713 		nb_rxd = res->value;
1714 	} else if (!strcmp(res->name, "txd")) {
1715 		if (check_nb_txd(res->value) != 0)
1716 			return;
1717 
1718 		nb_txd = res->value;
1719 	} else {
1720 		fprintf(stderr, "Unknown parameter\n");
1721 		return;
1722 	}
1723 
1724 	fwd_config_setup();
1725 
1726 	init_port_config();
1727 
1728 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1729 }
1730 
1731 static cmdline_parse_token_string_t cmd_config_rx_tx_port =
1732 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1733 static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1734 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1735 static cmdline_parse_token_string_t cmd_config_rx_tx_all =
1736 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1737 static cmdline_parse_token_string_t cmd_config_rx_tx_name =
1738 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1739 						"rxq#txq#rxd#txd");
1740 static cmdline_parse_token_num_t cmd_config_rx_tx_value =
1741 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1742 
1743 static cmdline_parse_inst_t cmd_config_rx_tx = {
1744 	.f = cmd_config_rx_tx_parsed,
1745 	.data = NULL,
1746 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1747 	.tokens = {
1748 		(void *)&cmd_config_rx_tx_port,
1749 		(void *)&cmd_config_rx_tx_keyword,
1750 		(void *)&cmd_config_rx_tx_all,
1751 		(void *)&cmd_config_rx_tx_name,
1752 		(void *)&cmd_config_rx_tx_value,
1753 		NULL,
1754 	},
1755 };
1756 
1757 /* *** config max packet length *** */
1758 struct cmd_config_max_pkt_len_result {
1759 	cmdline_fixed_string_t port;
1760 	cmdline_fixed_string_t keyword;
1761 	cmdline_fixed_string_t all;
1762 	cmdline_fixed_string_t name;
1763 	uint32_t value;
1764 };
1765 
1766 static void
1767 cmd_config_max_pkt_len_parsed(void *parsed_result,
1768 				__rte_unused struct cmdline *cl,
1769 				__rte_unused void *data)
1770 {
1771 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1772 	portid_t port_id;
1773 	int ret;
1774 
1775 	if (strcmp(res->name, "max-pkt-len") != 0) {
1776 		printf("Unknown parameter\n");
1777 		return;
1778 	}
1779 
1780 	if (!all_ports_stopped()) {
1781 		fprintf(stderr, "Please stop all ports first\n");
1782 		return;
1783 	}
1784 
1785 	RTE_ETH_FOREACH_DEV(port_id) {
1786 		struct rte_port *port = &ports[port_id];
1787 
1788 		if (res->value < RTE_ETHER_MIN_LEN) {
1789 			fprintf(stderr,
1790 				"max-pkt-len can not be less than %d\n",
1791 				RTE_ETHER_MIN_LEN);
1792 			return;
1793 		}
1794 
1795 		ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1796 		if (ret != 0) {
1797 			fprintf(stderr,
1798 				"rte_eth_dev_info_get() failed for port %u\n",
1799 				port_id);
1800 			return;
1801 		}
1802 
1803 		update_mtu_from_frame_size(port_id, res->value);
1804 	}
1805 
1806 	init_port_config();
1807 
1808 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1809 }
1810 
1811 static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1812 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1813 								"port");
1814 static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1815 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1816 								"config");
1817 static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1818 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1819 								"all");
1820 static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1821 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1822 								"max-pkt-len");
1823 static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1824 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1825 								RTE_UINT32);
1826 
1827 static cmdline_parse_inst_t cmd_config_max_pkt_len = {
1828 	.f = cmd_config_max_pkt_len_parsed,
1829 	.data = NULL,
1830 	.help_str = "port config all max-pkt-len <value>",
1831 	.tokens = {
1832 		(void *)&cmd_config_max_pkt_len_port,
1833 		(void *)&cmd_config_max_pkt_len_keyword,
1834 		(void *)&cmd_config_max_pkt_len_all,
1835 		(void *)&cmd_config_max_pkt_len_name,
1836 		(void *)&cmd_config_max_pkt_len_value,
1837 		NULL,
1838 	},
1839 };
1840 
1841 /* *** config max LRO aggregated packet size *** */
1842 struct cmd_config_max_lro_pkt_size_result {
1843 	cmdline_fixed_string_t port;
1844 	cmdline_fixed_string_t keyword;
1845 	cmdline_fixed_string_t all;
1846 	cmdline_fixed_string_t name;
1847 	uint32_t value;
1848 };
1849 
1850 static void
1851 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1852 				__rte_unused struct cmdline *cl,
1853 				__rte_unused void *data)
1854 {
1855 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1856 	portid_t pid;
1857 
1858 	if (!all_ports_stopped()) {
1859 		fprintf(stderr, "Please stop all ports first\n");
1860 		return;
1861 	}
1862 
1863 	RTE_ETH_FOREACH_DEV(pid) {
1864 		struct rte_port *port = &ports[pid];
1865 
1866 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1867 			if (res->value ==
1868 					port->dev_conf.rxmode.max_lro_pkt_size)
1869 				return;
1870 
1871 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1872 		} else {
1873 			fprintf(stderr, "Unknown parameter\n");
1874 			return;
1875 		}
1876 	}
1877 
1878 	init_port_config();
1879 
1880 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1881 }
1882 
1883 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1884 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1885 				 port, "port");
1886 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1887 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1888 				 keyword, "config");
1889 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
1890 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1891 				 all, "all");
1892 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
1893 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1894 				 name, "max-lro-pkt-size");
1895 static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
1896 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1897 			      value, RTE_UINT32);
1898 
1899 static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
1900 	.f = cmd_config_max_lro_pkt_size_parsed,
1901 	.data = NULL,
1902 	.help_str = "port config all max-lro-pkt-size <value>",
1903 	.tokens = {
1904 		(void *)&cmd_config_max_lro_pkt_size_port,
1905 		(void *)&cmd_config_max_lro_pkt_size_keyword,
1906 		(void *)&cmd_config_max_lro_pkt_size_all,
1907 		(void *)&cmd_config_max_lro_pkt_size_name,
1908 		(void *)&cmd_config_max_lro_pkt_size_value,
1909 		NULL,
1910 	},
1911 };
1912 
1913 /* *** configure port MTU *** */
1914 struct cmd_config_mtu_result {
1915 	cmdline_fixed_string_t port;
1916 	cmdline_fixed_string_t keyword;
1917 	cmdline_fixed_string_t mtu;
1918 	portid_t port_id;
1919 	uint16_t value;
1920 };
1921 
1922 static void
1923 cmd_config_mtu_parsed(void *parsed_result,
1924 		      __rte_unused struct cmdline *cl,
1925 		      __rte_unused void *data)
1926 {
1927 	struct cmd_config_mtu_result *res = parsed_result;
1928 
1929 	port_mtu_set(res->port_id, res->value);
1930 }
1931 
1932 static cmdline_parse_token_string_t cmd_config_mtu_port =
1933 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1934 				 "port");
1935 static cmdline_parse_token_string_t cmd_config_mtu_keyword =
1936 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1937 				 "config");
1938 static cmdline_parse_token_string_t cmd_config_mtu_mtu =
1939 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1940 				 "mtu");
1941 static cmdline_parse_token_num_t cmd_config_mtu_port_id =
1942 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
1943 				 RTE_UINT16);
1944 static cmdline_parse_token_num_t cmd_config_mtu_value =
1945 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
1946 				 RTE_UINT16);
1947 
1948 static cmdline_parse_inst_t cmd_config_mtu = {
1949 	.f = cmd_config_mtu_parsed,
1950 	.data = NULL,
1951 	.help_str = "port config mtu <port_id> <value>",
1952 	.tokens = {
1953 		(void *)&cmd_config_mtu_port,
1954 		(void *)&cmd_config_mtu_keyword,
1955 		(void *)&cmd_config_mtu_mtu,
1956 		(void *)&cmd_config_mtu_port_id,
1957 		(void *)&cmd_config_mtu_value,
1958 		NULL,
1959 	},
1960 };
1961 
1962 /* *** configure rx mode *** */
1963 struct cmd_config_rx_mode_flag {
1964 	cmdline_fixed_string_t port;
1965 	cmdline_fixed_string_t keyword;
1966 	cmdline_fixed_string_t all;
1967 	cmdline_fixed_string_t name;
1968 	cmdline_fixed_string_t value;
1969 };
1970 
1971 static void
1972 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1973 				__rte_unused struct cmdline *cl,
1974 				__rte_unused void *data)
1975 {
1976 	struct cmd_config_rx_mode_flag *res = parsed_result;
1977 
1978 	if (!all_ports_stopped()) {
1979 		fprintf(stderr, "Please stop all ports first\n");
1980 		return;
1981 	}
1982 
1983 	if (!strcmp(res->name, "drop-en")) {
1984 		if (!strcmp(res->value, "on"))
1985 			rx_drop_en = 1;
1986 		else if (!strcmp(res->value, "off"))
1987 			rx_drop_en = 0;
1988 		else {
1989 			fprintf(stderr, "Unknown parameter\n");
1990 			return;
1991 		}
1992 	} else {
1993 		fprintf(stderr, "Unknown parameter\n");
1994 		return;
1995 	}
1996 
1997 	init_port_config();
1998 
1999 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2000 }
2001 
2002 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2003 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2004 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2005 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2006 								"config");
2007 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2008 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2009 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2010 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2011 					"drop-en");
2012 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2013 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2014 							"on#off");
2015 
2016 static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2017 	.f = cmd_config_rx_mode_flag_parsed,
2018 	.data = NULL,
2019 	.help_str = "port config all drop-en on|off",
2020 	.tokens = {
2021 		(void *)&cmd_config_rx_mode_flag_port,
2022 		(void *)&cmd_config_rx_mode_flag_keyword,
2023 		(void *)&cmd_config_rx_mode_flag_all,
2024 		(void *)&cmd_config_rx_mode_flag_name,
2025 		(void *)&cmd_config_rx_mode_flag_value,
2026 		NULL,
2027 	},
2028 };
2029 
2030 /* *** configure rss *** */
2031 struct cmd_config_rss {
2032 	cmdline_fixed_string_t port;
2033 	cmdline_fixed_string_t keyword;
2034 	cmdline_fixed_string_t all;
2035 	cmdline_fixed_string_t name;
2036 	cmdline_fixed_string_t value;
2037 };
2038 
2039 static void
2040 cmd_config_rss_parsed(void *parsed_result,
2041 			__rte_unused struct cmdline *cl,
2042 			__rte_unused void *data)
2043 {
2044 	struct cmd_config_rss *res = parsed_result;
2045 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2046 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2047 	int use_default = 0;
2048 	int all_updated = 1;
2049 	int diag;
2050 	uint16_t i;
2051 	int ret;
2052 
2053 	if (!strcmp(res->value, "level-default")) {
2054 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2055 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2056 	} else if (!strcmp(res->value, "level-outer")) {
2057 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2058 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2059 	} else if (!strcmp(res->value, "level-inner")) {
2060 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2061 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2062 	} else if (!strcmp(res->value, "default")) {
2063 		use_default = 1;
2064 	} else if (isdigit(res->value[0])) {
2065 		int value = atoi(res->value);
2066 		if (value > 0 && value < 64)
2067 			rss_conf.rss_hf = 1ULL << (uint8_t)value;
2068 		else {
2069 			fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2070 			return;
2071 		}
2072 	} else if (!strcmp(res->value, "none")) {
2073 		rss_conf.rss_hf = 0;
2074 	} else {
2075 		rss_conf.rss_hf = str_to_rsstypes(res->value);
2076 		if (rss_conf.rss_hf == 0) {
2077 			fprintf(stderr, "Unknown parameter\n");
2078 			return;
2079 		}
2080 	}
2081 	rss_conf.rss_key = NULL;
2082 	/* Update global configuration for RSS types. */
2083 	RTE_ETH_FOREACH_DEV(i) {
2084 		struct rte_eth_rss_conf local_rss_conf;
2085 
2086 		ret = eth_dev_info_get_print_err(i, &dev_info);
2087 		if (ret != 0)
2088 			return;
2089 
2090 		if (use_default)
2091 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2092 
2093 		local_rss_conf = rss_conf;
2094 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2095 			dev_info.flow_type_rss_offloads;
2096 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2097 			printf("Port %u modified RSS hash function based on hardware support,"
2098 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2099 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2100 		}
2101 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2102 		if (diag < 0) {
2103 			all_updated = 0;
2104 			fprintf(stderr,
2105 				"Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2106 				i, -diag, strerror(-diag));
2107 		}
2108 	}
2109 	if (all_updated && !use_default) {
2110 		rss_hf = rss_conf.rss_hf;
2111 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2112 	}
2113 }
2114 
2115 static cmdline_parse_token_string_t cmd_config_rss_port =
2116 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2117 static cmdline_parse_token_string_t cmd_config_rss_keyword =
2118 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2119 static cmdline_parse_token_string_t cmd_config_rss_all =
2120 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2121 static cmdline_parse_token_string_t cmd_config_rss_name =
2122 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2123 static cmdline_parse_token_string_t cmd_config_rss_value =
2124 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2125 
2126 static cmdline_parse_inst_t cmd_config_rss = {
2127 	.f = cmd_config_rss_parsed,
2128 	.data = NULL,
2129 	.help_str = "port config all rss "
2130 		"all|default|level-default|level-outer|level-inner|"
2131 		"ip|tcp|udp|sctp|tunnel|vlan|none|"
2132 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2133 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2134 		"l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2135 		"esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2136 		"l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2137 		"l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2138 	.tokens = {
2139 		(void *)&cmd_config_rss_port,
2140 		(void *)&cmd_config_rss_keyword,
2141 		(void *)&cmd_config_rss_all,
2142 		(void *)&cmd_config_rss_name,
2143 		(void *)&cmd_config_rss_value,
2144 		NULL,
2145 	},
2146 };
2147 
2148 /* *** configure rss hash key *** */
2149 struct cmd_config_rss_hash_key {
2150 	cmdline_fixed_string_t port;
2151 	cmdline_fixed_string_t config;
2152 	portid_t port_id;
2153 	cmdline_fixed_string_t rss_hash_key;
2154 	cmdline_fixed_string_t rss_type;
2155 	cmdline_fixed_string_t key;
2156 };
2157 
2158 static uint8_t
2159 hexa_digit_to_value(char hexa_digit)
2160 {
2161 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2162 		return (uint8_t) (hexa_digit - '0');
2163 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2164 		return (uint8_t) ((hexa_digit - 'a') + 10);
2165 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2166 		return (uint8_t) ((hexa_digit - 'A') + 10);
2167 	/* Invalid hexa digit */
2168 	return 0xFF;
2169 }
2170 
2171 static uint8_t
2172 parse_and_check_key_hexa_digit(char *key, int idx)
2173 {
2174 	uint8_t hexa_v;
2175 
2176 	hexa_v = hexa_digit_to_value(key[idx]);
2177 	if (hexa_v == 0xFF)
2178 		fprintf(stderr,
2179 			"invalid key: character %c at position %d is not a valid hexa digit\n",
2180 			key[idx], idx);
2181 	return hexa_v;
2182 }
2183 
2184 static void
2185 cmd_config_rss_hash_key_parsed(void *parsed_result,
2186 			       __rte_unused struct cmdline *cl,
2187 			       __rte_unused void *data)
2188 {
2189 	struct cmd_config_rss_hash_key *res = parsed_result;
2190 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2191 	uint8_t xdgt0;
2192 	uint8_t xdgt1;
2193 	int i;
2194 	struct rte_eth_dev_info dev_info;
2195 	uint8_t hash_key_size;
2196 	uint32_t key_len;
2197 	int ret;
2198 
2199 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2200 	if (ret != 0)
2201 		return;
2202 
2203 	if (dev_info.hash_key_size > 0 &&
2204 			dev_info.hash_key_size <= sizeof(hash_key))
2205 		hash_key_size = dev_info.hash_key_size;
2206 	else {
2207 		fprintf(stderr,
2208 			"dev_info did not provide a valid hash key size\n");
2209 		return;
2210 	}
2211 	/* Check the length of the RSS hash key */
2212 	key_len = strlen(res->key);
2213 	if (key_len != (hash_key_size * 2)) {
2214 		fprintf(stderr,
2215 			"key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2216 			(int)key_len, hash_key_size * 2);
2217 		return;
2218 	}
2219 	/* Translate RSS hash key into binary representation */
2220 	for (i = 0; i < hash_key_size; i++) {
2221 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2222 		if (xdgt0 == 0xFF)
2223 			return;
2224 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2225 		if (xdgt1 == 0xFF)
2226 			return;
2227 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2228 	}
2229 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2230 			hash_key_size);
2231 }
2232 
2233 static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2234 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2235 static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2236 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2237 				 "config");
2238 static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2239 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2240 				 RTE_UINT16);
2241 static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2242 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2243 				 rss_hash_key, "rss-hash-key");
2244 static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2245 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2246 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2247 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2248 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2249 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2250 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2251 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2252 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2253 static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2254 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2255 
2256 static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2257 	.f = cmd_config_rss_hash_key_parsed,
2258 	.data = NULL,
2259 	.help_str = "port config <port_id> rss-hash-key "
2260 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2261 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2262 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2263 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2264 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2265 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2266 		"<string of hex digits (variable length, NIC dependent)>",
2267 	.tokens = {
2268 		(void *)&cmd_config_rss_hash_key_port,
2269 		(void *)&cmd_config_rss_hash_key_config,
2270 		(void *)&cmd_config_rss_hash_key_port_id,
2271 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2272 		(void *)&cmd_config_rss_hash_key_rss_type,
2273 		(void *)&cmd_config_rss_hash_key_value,
2274 		NULL,
2275 	},
2276 };
2277 
2278 /* *** cleanup txq mbufs *** */
2279 struct cmd_cleanup_txq_mbufs_result {
2280 	cmdline_fixed_string_t port;
2281 	cmdline_fixed_string_t keyword;
2282 	cmdline_fixed_string_t name;
2283 	uint16_t port_id;
2284 	uint16_t queue_id;
2285 	uint32_t free_cnt;
2286 };
2287 
2288 static void
2289 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2290 			     __rte_unused struct cmdline *cl,
2291 			     __rte_unused void *data)
2292 {
2293 	struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2294 	uint16_t port_id = res->port_id;
2295 	uint16_t queue_id = res->queue_id;
2296 	uint32_t free_cnt = res->free_cnt;
2297 	struct rte_eth_txq_info qinfo;
2298 	int ret;
2299 
2300 	if (test_done == 0) {
2301 		fprintf(stderr, "Please stop forwarding first\n");
2302 		return;
2303 	}
2304 
2305 	if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2306 		fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2307 			port_id, queue_id);
2308 		return;
2309 	}
2310 
2311 	if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2312 		fprintf(stderr, "Tx queue %u not started\n", queue_id);
2313 		return;
2314 	}
2315 
2316 	ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2317 	if (ret < 0) {
2318 		fprintf(stderr,
2319 			"Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2320 			port_id, queue_id, strerror(-ret), ret);
2321 		return;
2322 	}
2323 
2324 	printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2325 	       port_id, queue_id, ret);
2326 }
2327 
2328 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2329 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2330 				 "port");
2331 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2332 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2333 				 "cleanup");
2334 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2335 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2336 			      RTE_UINT16);
2337 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2338 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2339 				 "txq");
2340 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2341 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2342 			      RTE_UINT16);
2343 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2344 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2345 			      RTE_UINT32);
2346 
2347 static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2348 	.f = cmd_cleanup_txq_mbufs_parsed,
2349 	.data = NULL,
2350 	.help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2351 	.tokens = {
2352 		(void *)&cmd_cleanup_txq_mbufs_port,
2353 		(void *)&cmd_cleanup_txq_mbufs_cleanup,
2354 		(void *)&cmd_cleanup_txq_mbufs_port_id,
2355 		(void *)&cmd_cleanup_txq_mbufs_txq,
2356 		(void *)&cmd_cleanup_txq_mbufs_queue_id,
2357 		(void *)&cmd_cleanup_txq_mbufs_free_cnt,
2358 		NULL,
2359 	},
2360 };
2361 
2362 /* *** configure port rxq/txq ring size *** */
2363 struct cmd_config_rxtx_ring_size {
2364 	cmdline_fixed_string_t port;
2365 	cmdline_fixed_string_t config;
2366 	portid_t portid;
2367 	cmdline_fixed_string_t rxtxq;
2368 	uint16_t qid;
2369 	cmdline_fixed_string_t rsize;
2370 	uint16_t size;
2371 };
2372 
2373 static void
2374 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2375 				 __rte_unused struct cmdline *cl,
2376 				 __rte_unused void *data)
2377 {
2378 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2379 	struct rte_port *port;
2380 	uint8_t isrx;
2381 
2382 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2383 		return;
2384 
2385 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2386 		fprintf(stderr, "Invalid port id\n");
2387 		return;
2388 	}
2389 
2390 	port = &ports[res->portid];
2391 
2392 	if (!strcmp(res->rxtxq, "rxq"))
2393 		isrx = 1;
2394 	else if (!strcmp(res->rxtxq, "txq"))
2395 		isrx = 0;
2396 	else {
2397 		fprintf(stderr, "Unknown parameter\n");
2398 		return;
2399 	}
2400 
2401 	if (isrx && rx_queue_id_is_invalid(res->qid))
2402 		return;
2403 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2404 		return;
2405 
2406 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2407 		fprintf(stderr,
2408 			"Invalid rx ring_size, must > rx_free_thresh: %d\n",
2409 			rx_free_thresh);
2410 		return;
2411 	}
2412 
2413 	if (isrx)
2414 		port->nb_rx_desc[res->qid] = res->size;
2415 	else
2416 		port->nb_tx_desc[res->qid] = res->size;
2417 
2418 	cmd_reconfig_device_queue(res->portid, 0, 1);
2419 }
2420 
2421 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2422 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2423 				 port, "port");
2424 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2425 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2426 				 config, "config");
2427 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2428 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2429 				 portid, RTE_UINT16);
2430 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2431 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2432 				 rxtxq, "rxq#txq");
2433 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2434 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2435 			      qid, RTE_UINT16);
2436 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2437 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2438 				 rsize, "ring_size");
2439 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2440 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2441 			      size, RTE_UINT16);
2442 
2443 static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2444 	.f = cmd_config_rxtx_ring_size_parsed,
2445 	.data = NULL,
2446 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2447 	.tokens = {
2448 		(void *)&cmd_config_rxtx_ring_size_port,
2449 		(void *)&cmd_config_rxtx_ring_size_config,
2450 		(void *)&cmd_config_rxtx_ring_size_portid,
2451 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2452 		(void *)&cmd_config_rxtx_ring_size_qid,
2453 		(void *)&cmd_config_rxtx_ring_size_rsize,
2454 		(void *)&cmd_config_rxtx_ring_size_size,
2455 		NULL,
2456 	},
2457 };
2458 
2459 /* *** configure port rxq/txq start/stop *** */
2460 struct cmd_config_rxtx_queue {
2461 	cmdline_fixed_string_t port;
2462 	portid_t portid;
2463 	cmdline_fixed_string_t rxtxq;
2464 	uint16_t qid;
2465 	cmdline_fixed_string_t opname;
2466 };
2467 
2468 static void
2469 cmd_config_rxtx_queue_parsed(void *parsed_result,
2470 			__rte_unused struct cmdline *cl,
2471 			__rte_unused void *data)
2472 {
2473 	struct cmd_config_rxtx_queue *res = parsed_result;
2474 	struct rte_port *port;
2475 	uint8_t isrx;
2476 	uint8_t isstart;
2477 	uint8_t *state;
2478 	int ret = 0;
2479 
2480 	if (test_done == 0) {
2481 		fprintf(stderr, "Please stop forwarding first\n");
2482 		return;
2483 	}
2484 
2485 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2486 		return;
2487 
2488 	if (port_is_started(res->portid) != 1) {
2489 		fprintf(stderr, "Please start port %u first\n", res->portid);
2490 		return;
2491 	}
2492 
2493 	if (!strcmp(res->rxtxq, "rxq"))
2494 		isrx = 1;
2495 	else if (!strcmp(res->rxtxq, "txq"))
2496 		isrx = 0;
2497 	else {
2498 		fprintf(stderr, "Unknown parameter\n");
2499 		return;
2500 	}
2501 
2502 	if (isrx && rx_queue_id_is_invalid(res->qid))
2503 		return;
2504 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2505 		return;
2506 
2507 	if (!strcmp(res->opname, "start"))
2508 		isstart = 1;
2509 	else if (!strcmp(res->opname, "stop"))
2510 		isstart = 0;
2511 	else {
2512 		fprintf(stderr, "Unknown parameter\n");
2513 		return;
2514 	}
2515 
2516 	if (isstart && isrx)
2517 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2518 	else if (!isstart && isrx)
2519 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2520 	else if (isstart && !isrx)
2521 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2522 	else
2523 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2524 
2525 	if (ret == -ENOTSUP) {
2526 		fprintf(stderr, "Function not supported in PMD\n");
2527 		return;
2528 	}
2529 
2530 	port = &ports[res->portid];
2531 	state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2532 	*state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2533 			   RTE_ETH_QUEUE_STATE_STOPPED;
2534 }
2535 
2536 static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2537 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2538 static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2539 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2540 static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2541 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2542 static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2543 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2544 static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2545 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2546 						"start#stop");
2547 
2548 static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2549 	.f = cmd_config_rxtx_queue_parsed,
2550 	.data = NULL,
2551 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2552 	.tokens = {
2553 		(void *)&cmd_config_rxtx_queue_port,
2554 		(void *)&cmd_config_rxtx_queue_portid,
2555 		(void *)&cmd_config_rxtx_queue_rxtxq,
2556 		(void *)&cmd_config_rxtx_queue_qid,
2557 		(void *)&cmd_config_rxtx_queue_opname,
2558 		NULL,
2559 	},
2560 };
2561 
2562 /* *** configure port rxq/txq deferred start on/off *** */
2563 struct cmd_config_deferred_start_rxtx_queue {
2564 	cmdline_fixed_string_t port;
2565 	portid_t port_id;
2566 	cmdline_fixed_string_t rxtxq;
2567 	uint16_t qid;
2568 	cmdline_fixed_string_t opname;
2569 	cmdline_fixed_string_t state;
2570 };
2571 
2572 static void
2573 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2574 			__rte_unused struct cmdline *cl,
2575 			__rte_unused void *data)
2576 {
2577 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2578 	struct rte_port *port;
2579 	uint8_t isrx;
2580 	uint8_t ison;
2581 	uint8_t needreconfig = 0;
2582 
2583 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2584 		return;
2585 
2586 	if (port_is_started(res->port_id) != 0) {
2587 		fprintf(stderr, "Please stop port %u first\n", res->port_id);
2588 		return;
2589 	}
2590 
2591 	port = &ports[res->port_id];
2592 
2593 	isrx = !strcmp(res->rxtxq, "rxq");
2594 
2595 	if (isrx && rx_queue_id_is_invalid(res->qid))
2596 		return;
2597 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2598 		return;
2599 
2600 	ison = !strcmp(res->state, "on");
2601 
2602 	if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2603 		port->rxq[res->qid].conf.rx_deferred_start = ison;
2604 		needreconfig = 1;
2605 	} else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2606 		port->txq[res->qid].conf.tx_deferred_start = ison;
2607 		needreconfig = 1;
2608 	}
2609 
2610 	if (needreconfig)
2611 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2612 }
2613 
2614 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2615 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2616 						port, "port");
2617 static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2618 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2619 						port_id, RTE_UINT16);
2620 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2621 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2622 						rxtxq, "rxq#txq");
2623 static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2624 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2625 						qid, RTE_UINT16);
2626 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2627 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2628 						opname, "deferred_start");
2629 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2630 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2631 						state, "on#off");
2632 
2633 static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2634 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2635 	.data = NULL,
2636 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2637 	.tokens = {
2638 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2639 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2640 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2641 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2642 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2643 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2644 		NULL,
2645 	},
2646 };
2647 
2648 /* *** configure port rxq/txq setup *** */
2649 struct cmd_setup_rxtx_queue {
2650 	cmdline_fixed_string_t port;
2651 	portid_t portid;
2652 	cmdline_fixed_string_t rxtxq;
2653 	uint16_t qid;
2654 	cmdline_fixed_string_t setup;
2655 };
2656 
2657 /* Common CLI fields for queue setup */
2658 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2659 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2660 static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2661 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2662 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2663 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2664 static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2665 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2666 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2667 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2668 
2669 static void
2670 cmd_setup_rxtx_queue_parsed(
2671 	void *parsed_result,
2672 	__rte_unused struct cmdline *cl,
2673 	__rte_unused void *data)
2674 {
2675 	struct cmd_setup_rxtx_queue *res = parsed_result;
2676 	struct rte_port *port;
2677 	struct rte_mempool *mp;
2678 	unsigned int socket_id;
2679 	uint8_t isrx = 0;
2680 	int ret;
2681 
2682 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2683 		return;
2684 
2685 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2686 		fprintf(stderr, "Invalid port id\n");
2687 		return;
2688 	}
2689 
2690 	if (!strcmp(res->rxtxq, "rxq"))
2691 		isrx = 1;
2692 	else if (!strcmp(res->rxtxq, "txq"))
2693 		isrx = 0;
2694 	else {
2695 		fprintf(stderr, "Unknown parameter\n");
2696 		return;
2697 	}
2698 
2699 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2700 		fprintf(stderr, "Invalid rx queue\n");
2701 		return;
2702 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2703 		fprintf(stderr, "Invalid tx queue\n");
2704 		return;
2705 	}
2706 
2707 	port = &ports[res->portid];
2708 	if (isrx) {
2709 		socket_id = rxring_numa[res->portid];
2710 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2711 			socket_id = port->socket_id;
2712 
2713 		mp = mbuf_pool_find(socket_id, 0);
2714 		if (mp == NULL) {
2715 			fprintf(stderr,
2716 				"Failed to setup RX queue: No mempool allocation on the socket %d\n",
2717 				rxring_numa[res->portid]);
2718 			return;
2719 		}
2720 		ret = rx_queue_setup(res->portid,
2721 				     res->qid,
2722 				     port->nb_rx_desc[res->qid],
2723 				     socket_id,
2724 				     &port->rxq[res->qid].conf,
2725 				     mp);
2726 		if (ret)
2727 			fprintf(stderr, "Failed to setup RX queue\n");
2728 	} else {
2729 		socket_id = txring_numa[res->portid];
2730 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2731 			socket_id = port->socket_id;
2732 
2733 		if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2734 			fprintf(stderr,
2735 				"Failed to setup TX queue: not enough descriptors\n");
2736 			return;
2737 		}
2738 		ret = rte_eth_tx_queue_setup(res->portid,
2739 					     res->qid,
2740 					     port->nb_tx_desc[res->qid],
2741 					     socket_id,
2742 					     &port->txq[res->qid].conf);
2743 		if (ret)
2744 			fprintf(stderr, "Failed to setup TX queue\n");
2745 	}
2746 }
2747 
2748 static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2749 	.f = cmd_setup_rxtx_queue_parsed,
2750 	.data = NULL,
2751 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2752 	.tokens = {
2753 		(void *)&cmd_setup_rxtx_queue_port,
2754 		(void *)&cmd_setup_rxtx_queue_portid,
2755 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2756 		(void *)&cmd_setup_rxtx_queue_qid,
2757 		(void *)&cmd_setup_rxtx_queue_setup,
2758 		NULL,
2759 	},
2760 };
2761 
2762 
2763 /* *** Configure RSS RETA *** */
2764 struct cmd_config_rss_reta {
2765 	cmdline_fixed_string_t port;
2766 	cmdline_fixed_string_t keyword;
2767 	portid_t port_id;
2768 	cmdline_fixed_string_t name;
2769 	cmdline_fixed_string_t list_name;
2770 	cmdline_fixed_string_t list_of_items;
2771 };
2772 
2773 static int
2774 parse_reta_config(const char *str,
2775 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2776 		  uint16_t nb_entries)
2777 {
2778 	int i;
2779 	unsigned size;
2780 	uint16_t hash_index, idx, shift;
2781 	uint16_t nb_queue;
2782 	char s[256];
2783 	const char *p, *p0 = str;
2784 	char *end;
2785 	enum fieldnames {
2786 		FLD_HASH_INDEX = 0,
2787 		FLD_QUEUE,
2788 		_NUM_FLD
2789 	};
2790 	unsigned long int_fld[_NUM_FLD];
2791 	char *str_fld[_NUM_FLD];
2792 
2793 	while ((p = strchr(p0,'(')) != NULL) {
2794 		++p;
2795 		if((p0 = strchr(p,')')) == NULL)
2796 			return -1;
2797 
2798 		size = p0 - p;
2799 		if(size >= sizeof(s))
2800 			return -1;
2801 
2802 		snprintf(s, sizeof(s), "%.*s", size, p);
2803 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2804 			return -1;
2805 		for (i = 0; i < _NUM_FLD; i++) {
2806 			errno = 0;
2807 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2808 			if (errno != 0 || end == str_fld[i] ||
2809 					int_fld[i] > 65535)
2810 				return -1;
2811 		}
2812 
2813 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2814 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2815 
2816 		if (hash_index >= nb_entries) {
2817 			fprintf(stderr, "Invalid RETA hash index=%d\n",
2818 				hash_index);
2819 			return -1;
2820 		}
2821 
2822 		idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2823 		shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2824 		reta_conf[idx].mask |= (1ULL << shift);
2825 		reta_conf[idx].reta[shift] = nb_queue;
2826 	}
2827 
2828 	return 0;
2829 }
2830 
2831 static void
2832 cmd_set_rss_reta_parsed(void *parsed_result,
2833 			__rte_unused struct cmdline *cl,
2834 			__rte_unused void *data)
2835 {
2836 	int ret;
2837 	struct rte_eth_dev_info dev_info;
2838 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2839 	struct cmd_config_rss_reta *res = parsed_result;
2840 
2841 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2842 	if (ret != 0)
2843 		return;
2844 
2845 	if (dev_info.reta_size == 0) {
2846 		fprintf(stderr,
2847 			"Redirection table size is 0 which is invalid for RSS\n");
2848 		return;
2849 	} else
2850 		printf("The reta size of port %d is %u\n",
2851 			res->port_id, dev_info.reta_size);
2852 	if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
2853 		fprintf(stderr,
2854 			"Currently do not support more than %u entries of redirection table\n",
2855 			RTE_ETH_RSS_RETA_SIZE_512);
2856 		return;
2857 	}
2858 
2859 	memset(reta_conf, 0, sizeof(reta_conf));
2860 	if (!strcmp(res->list_name, "reta")) {
2861 		if (parse_reta_config(res->list_of_items, reta_conf,
2862 						dev_info.reta_size)) {
2863 			fprintf(stderr,
2864 				"Invalid RSS Redirection Table config entered\n");
2865 			return;
2866 		}
2867 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2868 				reta_conf, dev_info.reta_size);
2869 		if (ret != 0)
2870 			fprintf(stderr,
2871 				"Bad redirection table parameter, return code = %d\n",
2872 				ret);
2873 	}
2874 }
2875 
2876 static cmdline_parse_token_string_t cmd_config_rss_reta_port =
2877 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2878 static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2879 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2880 static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2881 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2882 static cmdline_parse_token_string_t cmd_config_rss_reta_name =
2883 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2884 static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2885 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2886 static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2887         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2888                                  NULL);
2889 static cmdline_parse_inst_t cmd_config_rss_reta = {
2890 	.f = cmd_set_rss_reta_parsed,
2891 	.data = NULL,
2892 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2893 	.tokens = {
2894 		(void *)&cmd_config_rss_reta_port,
2895 		(void *)&cmd_config_rss_reta_keyword,
2896 		(void *)&cmd_config_rss_reta_port_id,
2897 		(void *)&cmd_config_rss_reta_name,
2898 		(void *)&cmd_config_rss_reta_list_name,
2899 		(void *)&cmd_config_rss_reta_list_of_items,
2900 		NULL,
2901 	},
2902 };
2903 
2904 /* *** SHOW PORT RETA INFO *** */
2905 struct cmd_showport_reta {
2906 	cmdline_fixed_string_t show;
2907 	cmdline_fixed_string_t port;
2908 	portid_t port_id;
2909 	cmdline_fixed_string_t rss;
2910 	cmdline_fixed_string_t reta;
2911 	uint16_t size;
2912 	cmdline_fixed_string_t list_of_items;
2913 };
2914 
2915 static int
2916 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2917 			   uint16_t nb_entries,
2918 			   char *str)
2919 {
2920 	uint32_t size;
2921 	const char *p, *p0 = str;
2922 	char s[256];
2923 	char *end;
2924 	char *str_fld[8];
2925 	uint16_t i;
2926 	uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
2927 			RTE_ETH_RETA_GROUP_SIZE;
2928 	int ret;
2929 
2930 	p = strchr(p0, '(');
2931 	if (p == NULL)
2932 		return -1;
2933 	p++;
2934 	p0 = strchr(p, ')');
2935 	if (p0 == NULL)
2936 		return -1;
2937 	size = p0 - p;
2938 	if (size >= sizeof(s)) {
2939 		fprintf(stderr,
2940 			"The string size exceeds the internal buffer size\n");
2941 		return -1;
2942 	}
2943 	snprintf(s, sizeof(s), "%.*s", size, p);
2944 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2945 	if (ret <= 0 || ret != num) {
2946 		fprintf(stderr,
2947 			"The bits of masks do not match the number of reta entries: %u\n",
2948 			num);
2949 		return -1;
2950 	}
2951 	for (i = 0; i < ret; i++)
2952 		conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
2953 
2954 	return 0;
2955 }
2956 
2957 static void
2958 cmd_showport_reta_parsed(void *parsed_result,
2959 			 __rte_unused struct cmdline *cl,
2960 			 __rte_unused void *data)
2961 {
2962 	struct cmd_showport_reta *res = parsed_result;
2963 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2964 	struct rte_eth_dev_info dev_info;
2965 	uint16_t max_reta_size;
2966 	int ret;
2967 
2968 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2969 	if (ret != 0)
2970 		return;
2971 
2972 	max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
2973 	if (res->size == 0 || res->size > max_reta_size) {
2974 		fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
2975 			res->size, max_reta_size);
2976 		return;
2977 	}
2978 
2979 	memset(reta_conf, 0, sizeof(reta_conf));
2980 	if (showport_parse_reta_config(reta_conf, res->size,
2981 				res->list_of_items) < 0) {
2982 		fprintf(stderr, "Invalid string: %s for reta masks\n",
2983 			res->list_of_items);
2984 		return;
2985 	}
2986 	port_rss_reta_info(res->port_id, reta_conf, res->size);
2987 }
2988 
2989 static cmdline_parse_token_string_t cmd_showport_reta_show =
2990 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
2991 static cmdline_parse_token_string_t cmd_showport_reta_port =
2992 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
2993 static cmdline_parse_token_num_t cmd_showport_reta_port_id =
2994 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
2995 static cmdline_parse_token_string_t cmd_showport_reta_rss =
2996 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2997 static cmdline_parse_token_string_t cmd_showport_reta_reta =
2998 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2999 static cmdline_parse_token_num_t cmd_showport_reta_size =
3000 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3001 static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3002 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3003 					list_of_items, NULL);
3004 
3005 static cmdline_parse_inst_t cmd_showport_reta = {
3006 	.f = cmd_showport_reta_parsed,
3007 	.data = NULL,
3008 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3009 	.tokens = {
3010 		(void *)&cmd_showport_reta_show,
3011 		(void *)&cmd_showport_reta_port,
3012 		(void *)&cmd_showport_reta_port_id,
3013 		(void *)&cmd_showport_reta_rss,
3014 		(void *)&cmd_showport_reta_reta,
3015 		(void *)&cmd_showport_reta_size,
3016 		(void *)&cmd_showport_reta_list_of_items,
3017 		NULL,
3018 	},
3019 };
3020 
3021 /* *** Show RSS hash configuration *** */
3022 struct cmd_showport_rss_hash {
3023 	cmdline_fixed_string_t show;
3024 	cmdline_fixed_string_t port;
3025 	portid_t port_id;
3026 	cmdline_fixed_string_t rss_hash;
3027 	cmdline_fixed_string_t rss_type;
3028 	cmdline_fixed_string_t key; /* optional argument */
3029 	cmdline_fixed_string_t algorithm; /* optional argument */
3030 };
3031 
3032 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3033 				__rte_unused struct cmdline *cl,
3034 				__rte_unused void *data)
3035 {
3036 	struct cmd_showport_rss_hash *res = parsed_result;
3037 
3038 	port_rss_hash_conf_show(res->port_id,
3039 		!strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3040 }
3041 
3042 static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3043 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3044 static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3045 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3046 static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3047 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3048 				 RTE_UINT16);
3049 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3050 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3051 				 "rss-hash");
3052 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3053 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3054 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3055 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3056 
3057 static cmdline_parse_inst_t cmd_showport_rss_hash = {
3058 	.f = cmd_showport_rss_hash_parsed,
3059 	.data = NULL,
3060 	.help_str = "show port <port_id> rss-hash",
3061 	.tokens = {
3062 		(void *)&cmd_showport_rss_hash_show,
3063 		(void *)&cmd_showport_rss_hash_port,
3064 		(void *)&cmd_showport_rss_hash_port_id,
3065 		(void *)&cmd_showport_rss_hash_rss_hash,
3066 		NULL,
3067 	},
3068 };
3069 
3070 static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3071 	.f = cmd_showport_rss_hash_parsed,
3072 	.data = NULL,
3073 	.help_str = "show port <port_id> rss-hash key",
3074 	.tokens = {
3075 		(void *)&cmd_showport_rss_hash_show,
3076 		(void *)&cmd_showport_rss_hash_port,
3077 		(void *)&cmd_showport_rss_hash_port_id,
3078 		(void *)&cmd_showport_rss_hash_rss_hash,
3079 		(void *)&cmd_showport_rss_hash_rss_key,
3080 		NULL,
3081 	},
3082 };
3083 
3084 static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3085 	.f = cmd_showport_rss_hash_parsed,
3086 	.data = NULL,
3087 	.help_str = "show port <port_id> rss-hash algorithm",
3088 	.tokens = {
3089 		(void *)&cmd_showport_rss_hash_show,
3090 		(void *)&cmd_showport_rss_hash_port,
3091 		(void *)&cmd_showport_rss_hash_port_id,
3092 		(void *)&cmd_showport_rss_hash_rss_hash,
3093 		(void *)&cmd_showport_rss_hash_rss_algo,
3094 		NULL,
3095 	},
3096 };
3097 
3098 /* *** Configure DCB *** */
3099 struct cmd_config_dcb {
3100 	cmdline_fixed_string_t port;
3101 	cmdline_fixed_string_t config;
3102 	portid_t port_id;
3103 	cmdline_fixed_string_t dcb;
3104 	cmdline_fixed_string_t vt;
3105 	cmdline_fixed_string_t vt_en;
3106 	uint8_t num_tcs;
3107 	cmdline_fixed_string_t pfc;
3108 	cmdline_fixed_string_t pfc_en;
3109 };
3110 
3111 static void
3112 cmd_config_dcb_parsed(void *parsed_result,
3113                         __rte_unused struct cmdline *cl,
3114                         __rte_unused void *data)
3115 {
3116 	struct cmd_config_dcb *res = parsed_result;
3117 	struct rte_eth_dcb_info dcb_info;
3118 	portid_t port_id = res->port_id;
3119 	struct rte_port *port;
3120 	uint8_t pfc_en;
3121 	int ret;
3122 
3123 	port = &ports[port_id];
3124 	/** Check if the port is not started **/
3125 	if (port->port_status != RTE_PORT_STOPPED) {
3126 		fprintf(stderr, "Please stop port %d first\n", port_id);
3127 		return;
3128 	}
3129 
3130 	if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3131 		fprintf(stderr,
3132 			"The invalid number of traffic class, only 4 or 8 allowed.\n");
3133 		return;
3134 	}
3135 
3136 	if (nb_fwd_lcores < res->num_tcs) {
3137 		fprintf(stderr,
3138 			"nb_cores shouldn't be less than number of TCs.\n");
3139 		return;
3140 	}
3141 
3142 	/* Check whether the port supports the report of DCB info. */
3143 	ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3144 	if (ret == -ENOTSUP) {
3145 		fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3146 		return;
3147 	}
3148 
3149 	if (!strncmp(res->pfc_en, "on", 2))
3150 		pfc_en = 1;
3151 	else
3152 		pfc_en = 0;
3153 
3154 	/* DCB in VT mode */
3155 	if (!strncmp(res->vt_en, "on", 2))
3156 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3157 				(enum rte_eth_nb_tcs)res->num_tcs,
3158 				pfc_en);
3159 	else
3160 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3161 				(enum rte_eth_nb_tcs)res->num_tcs,
3162 				pfc_en);
3163 	if (ret != 0) {
3164 		fprintf(stderr, "Cannot initialize network ports.\n");
3165 		return;
3166 	}
3167 
3168 	fwd_config_setup();
3169 
3170 	cmd_reconfig_device_queue(port_id, 1, 1);
3171 }
3172 
3173 static cmdline_parse_token_string_t cmd_config_dcb_port =
3174         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3175 static cmdline_parse_token_string_t cmd_config_dcb_config =
3176         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3177 static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3178 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3179 static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3180         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3181 static cmdline_parse_token_string_t cmd_config_dcb_vt =
3182         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3183 static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3184         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3185 static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3186 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3187 static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3188         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3189 static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3190         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3191 
3192 static cmdline_parse_inst_t cmd_config_dcb = {
3193 	.f = cmd_config_dcb_parsed,
3194 	.data = NULL,
3195 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3196 	.tokens = {
3197 		(void *)&cmd_config_dcb_port,
3198 		(void *)&cmd_config_dcb_config,
3199 		(void *)&cmd_config_dcb_port_id,
3200 		(void *)&cmd_config_dcb_dcb,
3201 		(void *)&cmd_config_dcb_vt,
3202 		(void *)&cmd_config_dcb_vt_en,
3203 		(void *)&cmd_config_dcb_num_tcs,
3204 		(void *)&cmd_config_dcb_pfc,
3205 		(void *)&cmd_config_dcb_pfc_en,
3206                 NULL,
3207         },
3208 };
3209 
3210 /* *** configure number of packets per burst *** */
3211 struct cmd_config_burst {
3212 	cmdline_fixed_string_t port;
3213 	cmdline_fixed_string_t keyword;
3214 	cmdline_fixed_string_t all;
3215 	cmdline_fixed_string_t name;
3216 	uint16_t value;
3217 };
3218 
3219 static void
3220 cmd_config_burst_parsed(void *parsed_result,
3221 			__rte_unused struct cmdline *cl,
3222 			__rte_unused void *data)
3223 {
3224 	struct cmd_config_burst *res = parsed_result;
3225 	struct rte_eth_dev_info dev_info;
3226 	uint16_t rec_nb_pkts;
3227 	int ret;
3228 
3229 	if (!all_ports_stopped()) {
3230 		fprintf(stderr, "Please stop all ports first\n");
3231 		return;
3232 	}
3233 
3234 	if (!strcmp(res->name, "burst")) {
3235 		if (res->value == 0) {
3236 			/* If user gives a value of zero, query the PMD for
3237 			 * its recommended Rx burst size. Testpmd uses a single
3238 			 * size for all ports, so assume all ports are the same
3239 			 * NIC model and use the values from Port 0.
3240 			 */
3241 			ret = eth_dev_info_get_print_err(0, &dev_info);
3242 			if (ret != 0)
3243 				return;
3244 
3245 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3246 
3247 			if (rec_nb_pkts == 0) {
3248 				printf("PMD does not recommend a burst size.\n"
3249 					"User provided value must be between"
3250 					" 1 and %d\n", MAX_PKT_BURST);
3251 				return;
3252 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3253 				printf("PMD recommended burst size of %d"
3254 					" exceeds maximum value of %d\n",
3255 					rec_nb_pkts, MAX_PKT_BURST);
3256 				return;
3257 			}
3258 			printf("Using PMD-provided burst value of %d\n",
3259 				rec_nb_pkts);
3260 			nb_pkt_per_burst = rec_nb_pkts;
3261 		} else if (res->value > MAX_PKT_BURST) {
3262 			fprintf(stderr, "burst must be >= 1 && <= %d\n",
3263 				MAX_PKT_BURST);
3264 			return;
3265 		} else
3266 			nb_pkt_per_burst = res->value;
3267 	} else {
3268 		fprintf(stderr, "Unknown parameter\n");
3269 		return;
3270 	}
3271 
3272 	init_port_config();
3273 
3274 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3275 }
3276 
3277 static cmdline_parse_token_string_t cmd_config_burst_port =
3278 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3279 static cmdline_parse_token_string_t cmd_config_burst_keyword =
3280 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3281 static cmdline_parse_token_string_t cmd_config_burst_all =
3282 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3283 static cmdline_parse_token_string_t cmd_config_burst_name =
3284 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3285 static cmdline_parse_token_num_t cmd_config_burst_value =
3286 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3287 
3288 static cmdline_parse_inst_t cmd_config_burst = {
3289 	.f = cmd_config_burst_parsed,
3290 	.data = NULL,
3291 	.help_str = "port config all burst <value>",
3292 	.tokens = {
3293 		(void *)&cmd_config_burst_port,
3294 		(void *)&cmd_config_burst_keyword,
3295 		(void *)&cmd_config_burst_all,
3296 		(void *)&cmd_config_burst_name,
3297 		(void *)&cmd_config_burst_value,
3298 		NULL,
3299 	},
3300 };
3301 
3302 /* *** configure rx/tx queues *** */
3303 struct cmd_config_thresh {
3304 	cmdline_fixed_string_t port;
3305 	cmdline_fixed_string_t keyword;
3306 	cmdline_fixed_string_t all;
3307 	cmdline_fixed_string_t name;
3308 	uint8_t value;
3309 };
3310 
3311 static void
3312 cmd_config_thresh_parsed(void *parsed_result,
3313 			__rte_unused struct cmdline *cl,
3314 			__rte_unused void *data)
3315 {
3316 	struct cmd_config_thresh *res = parsed_result;
3317 
3318 	if (!all_ports_stopped()) {
3319 		fprintf(stderr, "Please stop all ports first\n");
3320 		return;
3321 	}
3322 
3323 	if (!strcmp(res->name, "txpt"))
3324 		tx_pthresh = res->value;
3325 	else if(!strcmp(res->name, "txht"))
3326 		tx_hthresh = res->value;
3327 	else if(!strcmp(res->name, "txwt"))
3328 		tx_wthresh = res->value;
3329 	else if(!strcmp(res->name, "rxpt"))
3330 		rx_pthresh = res->value;
3331 	else if(!strcmp(res->name, "rxht"))
3332 		rx_hthresh = res->value;
3333 	else if(!strcmp(res->name, "rxwt"))
3334 		rx_wthresh = res->value;
3335 	else {
3336 		fprintf(stderr, "Unknown parameter\n");
3337 		return;
3338 	}
3339 
3340 	init_port_config();
3341 
3342 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3343 }
3344 
3345 static cmdline_parse_token_string_t cmd_config_thresh_port =
3346 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3347 static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3348 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3349 static cmdline_parse_token_string_t cmd_config_thresh_all =
3350 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3351 static cmdline_parse_token_string_t cmd_config_thresh_name =
3352 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3353 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3354 static cmdline_parse_token_num_t cmd_config_thresh_value =
3355 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3356 
3357 static cmdline_parse_inst_t cmd_config_thresh = {
3358 	.f = cmd_config_thresh_parsed,
3359 	.data = NULL,
3360 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3361 	.tokens = {
3362 		(void *)&cmd_config_thresh_port,
3363 		(void *)&cmd_config_thresh_keyword,
3364 		(void *)&cmd_config_thresh_all,
3365 		(void *)&cmd_config_thresh_name,
3366 		(void *)&cmd_config_thresh_value,
3367 		NULL,
3368 	},
3369 };
3370 
3371 /* *** configure free/rs threshold *** */
3372 struct cmd_config_threshold {
3373 	cmdline_fixed_string_t port;
3374 	cmdline_fixed_string_t keyword;
3375 	cmdline_fixed_string_t all;
3376 	cmdline_fixed_string_t name;
3377 	uint16_t value;
3378 };
3379 
3380 static void
3381 cmd_config_threshold_parsed(void *parsed_result,
3382 			__rte_unused struct cmdline *cl,
3383 			__rte_unused void *data)
3384 {
3385 	struct cmd_config_threshold *res = parsed_result;
3386 
3387 	if (!all_ports_stopped()) {
3388 		fprintf(stderr, "Please stop all ports first\n");
3389 		return;
3390 	}
3391 
3392 	if (!strcmp(res->name, "txfreet"))
3393 		tx_free_thresh = res->value;
3394 	else if (!strcmp(res->name, "txrst"))
3395 		tx_rs_thresh = res->value;
3396 	else if (!strcmp(res->name, "rxfreet"))
3397 		rx_free_thresh = res->value;
3398 	else {
3399 		fprintf(stderr, "Unknown parameter\n");
3400 		return;
3401 	}
3402 
3403 	init_port_config();
3404 
3405 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3406 }
3407 
3408 static cmdline_parse_token_string_t cmd_config_threshold_port =
3409 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3410 static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3411 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3412 								"config");
3413 static cmdline_parse_token_string_t cmd_config_threshold_all =
3414 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3415 static cmdline_parse_token_string_t cmd_config_threshold_name =
3416 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3417 						"txfreet#txrst#rxfreet");
3418 static cmdline_parse_token_num_t cmd_config_threshold_value =
3419 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3420 
3421 static cmdline_parse_inst_t cmd_config_threshold = {
3422 	.f = cmd_config_threshold_parsed,
3423 	.data = NULL,
3424 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3425 	.tokens = {
3426 		(void *)&cmd_config_threshold_port,
3427 		(void *)&cmd_config_threshold_keyword,
3428 		(void *)&cmd_config_threshold_all,
3429 		(void *)&cmd_config_threshold_name,
3430 		(void *)&cmd_config_threshold_value,
3431 		NULL,
3432 	},
3433 };
3434 
3435 /* *** stop *** */
3436 struct cmd_stop_result {
3437 	cmdline_fixed_string_t stop;
3438 };
3439 
3440 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3441 			    __rte_unused struct cmdline *cl,
3442 			    __rte_unused void *data)
3443 {
3444 	stop_packet_forwarding();
3445 }
3446 
3447 static cmdline_parse_token_string_t cmd_stop_stop =
3448 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3449 
3450 static cmdline_parse_inst_t cmd_stop = {
3451 	.f = cmd_stop_parsed,
3452 	.data = NULL,
3453 	.help_str = "stop: Stop packet forwarding",
3454 	.tokens = {
3455 		(void *)&cmd_stop_stop,
3456 		NULL,
3457 	},
3458 };
3459 
3460 static unsigned int
3461 get_ptype(char *value)
3462 {
3463 	uint32_t protocol;
3464 
3465 	if (!strcmp(value, "eth"))
3466 		protocol = RTE_PTYPE_L2_ETHER;
3467 	else if (!strcmp(value, "ipv4"))
3468 		protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3469 	else if (!strcmp(value, "ipv6"))
3470 		protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3471 	else if (!strcmp(value, "ipv4-tcp"))
3472 		protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3473 	else if (!strcmp(value, "ipv4-udp"))
3474 		protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3475 	else if (!strcmp(value, "ipv4-sctp"))
3476 		protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3477 	else if (!strcmp(value, "ipv6-tcp"))
3478 		protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3479 	else if (!strcmp(value, "ipv6-udp"))
3480 		protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3481 	else if (!strcmp(value, "ipv6-sctp"))
3482 		protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3483 	else if (!strcmp(value, "grenat"))
3484 		protocol = RTE_PTYPE_TUNNEL_GRENAT;
3485 	else if (!strcmp(value, "inner-eth"))
3486 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
3487 	else if (!strcmp(value, "inner-ipv4"))
3488 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3489 				RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
3490 	else if (!strcmp(value, "inner-ipv6"))
3491 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3492 				RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
3493 	else if (!strcmp(value, "inner-ipv4-tcp"))
3494 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3495 				RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3496 	else if (!strcmp(value, "inner-ipv4-udp"))
3497 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3498 				RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3499 	else if (!strcmp(value, "inner-ipv4-sctp"))
3500 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3501 				RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3502 	else if (!strcmp(value, "inner-ipv6-tcp"))
3503 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3504 				RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3505 	else if (!strcmp(value, "inner-ipv6-udp"))
3506 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3507 				RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3508 	else if (!strcmp(value, "inner-ipv6-sctp"))
3509 		protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3510 				RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3511 	else {
3512 		fprintf(stderr, "Unsupported protocol: %s\n", value);
3513 		protocol = RTE_PTYPE_UNKNOWN;
3514 	}
3515 
3516 	return protocol;
3517 }
3518 
3519 /* *** SET RXHDRSLIST *** */
3520 
3521 unsigned int
3522 parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
3523 				unsigned int *parsed_items)
3524 {
3525 	unsigned int nb_item;
3526 	char *cur;
3527 	char *tmp;
3528 
3529 	nb_item = 0;
3530 	char *str2 = strdup(str);
3531 	if (str2 == NULL)
3532 		return nb_item;
3533 	cur = strtok_r(str2, ",", &tmp);
3534 	while (cur != NULL) {
3535 		parsed_items[nb_item] = get_ptype(cur);
3536 		cur = strtok_r(NULL, ",", &tmp);
3537 		nb_item++;
3538 	}
3539 	if (nb_item > max_items)
3540 		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3541 			item_name, nb_item + 1, max_items);
3542 	free(str2);
3543 	return nb_item;
3544 }
3545 
3546 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3547 
3548 unsigned int
3549 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3550 		unsigned int *parsed_items, int check_unique_values)
3551 {
3552 	unsigned int nb_item;
3553 	unsigned int value;
3554 	unsigned int i;
3555 	unsigned int j;
3556 	int value_ok;
3557 	char c;
3558 
3559 	/*
3560 	 * First parse all items in the list and store their value.
3561 	 */
3562 	value = 0;
3563 	nb_item = 0;
3564 	value_ok = 0;
3565 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3566 		c = str[i];
3567 		if ((c >= '0') && (c <= '9')) {
3568 			value = (unsigned int) (value * 10 + (c - '0'));
3569 			value_ok = 1;
3570 			continue;
3571 		}
3572 		if (c != ',') {
3573 			fprintf(stderr, "character %c is not a decimal digit\n", c);
3574 			return 0;
3575 		}
3576 		if (! value_ok) {
3577 			fprintf(stderr, "No valid value before comma\n");
3578 			return 0;
3579 		}
3580 		if (nb_item < max_items) {
3581 			parsed_items[nb_item] = value;
3582 			value_ok = 0;
3583 			value = 0;
3584 		}
3585 		nb_item++;
3586 	}
3587 	if (nb_item >= max_items) {
3588 		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3589 			item_name, nb_item + 1, max_items);
3590 		return 0;
3591 	}
3592 	parsed_items[nb_item++] = value;
3593 	if (! check_unique_values)
3594 		return nb_item;
3595 
3596 	/*
3597 	 * Then, check that all values in the list are different.
3598 	 * No optimization here...
3599 	 */
3600 	for (i = 0; i < nb_item; i++) {
3601 		for (j = i + 1; j < nb_item; j++) {
3602 			if (parsed_items[j] == parsed_items[i]) {
3603 				fprintf(stderr,
3604 					"duplicated %s %u at index %u and %u\n",
3605 					item_name, parsed_items[i], i, j);
3606 				return 0;
3607 			}
3608 		}
3609 	}
3610 	return nb_item;
3611 }
3612 
3613 struct cmd_set_list_result {
3614 	cmdline_fixed_string_t cmd_keyword;
3615 	cmdline_fixed_string_t list_name;
3616 	cmdline_fixed_string_t list_of_items;
3617 };
3618 
3619 static void cmd_set_list_parsed(void *parsed_result,
3620 				__rte_unused struct cmdline *cl,
3621 				__rte_unused void *data)
3622 {
3623 	struct cmd_set_list_result *res;
3624 	union {
3625 		unsigned int lcorelist[RTE_MAX_LCORE];
3626 		unsigned int portlist[RTE_MAX_ETHPORTS];
3627 	} parsed_items;
3628 	unsigned int nb_item;
3629 
3630 	if (test_done == 0) {
3631 		fprintf(stderr, "Please stop forwarding first\n");
3632 		return;
3633 	}
3634 
3635 	res = parsed_result;
3636 	if (!strcmp(res->list_name, "corelist")) {
3637 		nb_item = parse_item_list(res->list_of_items, "core",
3638 					  RTE_MAX_LCORE,
3639 					  parsed_items.lcorelist, 1);
3640 		if (nb_item > 0) {
3641 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3642 			fwd_config_setup();
3643 		}
3644 		return;
3645 	}
3646 	if (!strcmp(res->list_name, "portlist")) {
3647 		nb_item = parse_item_list(res->list_of_items, "port",
3648 					  RTE_MAX_ETHPORTS,
3649 					  parsed_items.portlist, 1);
3650 		if (nb_item > 0) {
3651 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3652 			fwd_config_setup();
3653 		}
3654 	}
3655 }
3656 
3657 static cmdline_parse_token_string_t cmd_set_list_keyword =
3658 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3659 				 "set");
3660 static cmdline_parse_token_string_t cmd_set_list_name =
3661 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3662 				 "corelist#portlist");
3663 static cmdline_parse_token_string_t cmd_set_list_of_items =
3664 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3665 				 NULL);
3666 
3667 static cmdline_parse_inst_t cmd_set_fwd_list = {
3668 	.f = cmd_set_list_parsed,
3669 	.data = NULL,
3670 	.help_str = "set corelist|portlist <list0[,list1]*>",
3671 	.tokens = {
3672 		(void *)&cmd_set_list_keyword,
3673 		(void *)&cmd_set_list_name,
3674 		(void *)&cmd_set_list_of_items,
3675 		NULL,
3676 	},
3677 };
3678 
3679 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3680 
3681 struct cmd_setmask_result {
3682 	cmdline_fixed_string_t set;
3683 	cmdline_fixed_string_t mask;
3684 	uint64_t hexavalue;
3685 };
3686 
3687 static void cmd_set_mask_parsed(void *parsed_result,
3688 				__rte_unused struct cmdline *cl,
3689 				__rte_unused void *data)
3690 {
3691 	struct cmd_setmask_result *res = parsed_result;
3692 
3693 	if (test_done == 0) {
3694 		fprintf(stderr, "Please stop forwarding first\n");
3695 		return;
3696 	}
3697 	if (!strcmp(res->mask, "coremask")) {
3698 		set_fwd_lcores_mask(res->hexavalue);
3699 		fwd_config_setup();
3700 	} else if (!strcmp(res->mask, "portmask")) {
3701 		set_fwd_ports_mask(res->hexavalue);
3702 		fwd_config_setup();
3703 	}
3704 }
3705 
3706 static cmdline_parse_token_string_t cmd_setmask_set =
3707 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3708 static cmdline_parse_token_string_t cmd_setmask_mask =
3709 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3710 				 "coremask#portmask");
3711 static cmdline_parse_token_num_t cmd_setmask_value =
3712 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3713 
3714 static cmdline_parse_inst_t cmd_set_fwd_mask = {
3715 	.f = cmd_set_mask_parsed,
3716 	.data = NULL,
3717 	.help_str = "set coremask|portmask <hexadecimal value>",
3718 	.tokens = {
3719 		(void *)&cmd_setmask_set,
3720 		(void *)&cmd_setmask_mask,
3721 		(void *)&cmd_setmask_value,
3722 		NULL,
3723 	},
3724 };
3725 
3726 /*
3727  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3728  */
3729 struct cmd_set_result {
3730 	cmdline_fixed_string_t set;
3731 	cmdline_fixed_string_t what;
3732 	uint16_t value;
3733 };
3734 
3735 static void cmd_set_parsed(void *parsed_result,
3736 			   __rte_unused struct cmdline *cl,
3737 			   __rte_unused void *data)
3738 {
3739 	struct cmd_set_result *res = parsed_result;
3740 	if (!strcmp(res->what, "nbport")) {
3741 		set_fwd_ports_number(res->value);
3742 		fwd_config_setup();
3743 	} else if (!strcmp(res->what, "nbcore")) {
3744 		set_fwd_lcores_number(res->value);
3745 		fwd_config_setup();
3746 	} else if (!strcmp(res->what, "burst"))
3747 		set_nb_pkt_per_burst(res->value);
3748 	else if (!strcmp(res->what, "verbose"))
3749 		set_verbose_level(res->value);
3750 }
3751 
3752 static cmdline_parse_token_string_t cmd_set_set =
3753 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3754 static cmdline_parse_token_string_t cmd_set_what =
3755 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3756 				 "nbport#nbcore#burst#verbose");
3757 static cmdline_parse_token_num_t cmd_set_value =
3758 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3759 
3760 static cmdline_parse_inst_t cmd_set_numbers = {
3761 	.f = cmd_set_parsed,
3762 	.data = NULL,
3763 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3764 	.tokens = {
3765 		(void *)&cmd_set_set,
3766 		(void *)&cmd_set_what,
3767 		(void *)&cmd_set_value,
3768 		NULL,
3769 	},
3770 };
3771 
3772 /* *** SET LOG LEVEL CONFIGURATION *** */
3773 
3774 struct cmd_set_log_result {
3775 	cmdline_fixed_string_t set;
3776 	cmdline_fixed_string_t log;
3777 	cmdline_fixed_string_t type;
3778 	uint32_t level;
3779 };
3780 
3781 static void
3782 cmd_set_log_parsed(void *parsed_result,
3783 		   __rte_unused struct cmdline *cl,
3784 		   __rte_unused void *data)
3785 {
3786 	struct cmd_set_log_result *res;
3787 	int ret;
3788 
3789 	res = parsed_result;
3790 	if (!strcmp(res->type, "global"))
3791 		rte_log_set_global_level(res->level);
3792 	else {
3793 		ret = rte_log_set_level_regexp(res->type, res->level);
3794 		if (ret < 0)
3795 			fprintf(stderr, "Unable to set log level\n");
3796 	}
3797 }
3798 
3799 static cmdline_parse_token_string_t cmd_set_log_set =
3800 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3801 static cmdline_parse_token_string_t cmd_set_log_log =
3802 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3803 static cmdline_parse_token_string_t cmd_set_log_type =
3804 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3805 static cmdline_parse_token_num_t cmd_set_log_level =
3806 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3807 
3808 static cmdline_parse_inst_t cmd_set_log = {
3809 	.f = cmd_set_log_parsed,
3810 	.data = NULL,
3811 	.help_str = "set log global|<type> <level>",
3812 	.tokens = {
3813 		(void *)&cmd_set_log_set,
3814 		(void *)&cmd_set_log_log,
3815 		(void *)&cmd_set_log_type,
3816 		(void *)&cmd_set_log_level,
3817 		NULL,
3818 	},
3819 };
3820 
3821 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3822 
3823 struct cmd_set_rxoffs_result {
3824 	cmdline_fixed_string_t cmd_keyword;
3825 	cmdline_fixed_string_t rxoffs;
3826 	cmdline_fixed_string_t seg_offsets;
3827 };
3828 
3829 static void
3830 cmd_set_rxoffs_parsed(void *parsed_result,
3831 		      __rte_unused struct cmdline *cl,
3832 		      __rte_unused void *data)
3833 {
3834 	struct cmd_set_rxoffs_result *res;
3835 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3836 	unsigned int nb_segs;
3837 
3838 	res = parsed_result;
3839 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3840 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3841 	if (nb_segs > 0)
3842 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3843 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3844 }
3845 
3846 static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3847 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3848 				 cmd_keyword, "set");
3849 static cmdline_parse_token_string_t cmd_set_rxoffs_name =
3850 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3851 				 rxoffs, "rxoffs");
3852 static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3853 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3854 				 seg_offsets, NULL);
3855 
3856 static cmdline_parse_inst_t cmd_set_rxoffs = {
3857 	.f = cmd_set_rxoffs_parsed,
3858 	.data = NULL,
3859 	.help_str = "set rxoffs <len0[,len1]*>",
3860 	.tokens = {
3861 		(void *)&cmd_set_rxoffs_keyword,
3862 		(void *)&cmd_set_rxoffs_name,
3863 		(void *)&cmd_set_rxoffs_offsets,
3864 		NULL,
3865 	},
3866 };
3867 
3868 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3869 
3870 struct cmd_set_rxpkts_result {
3871 	cmdline_fixed_string_t cmd_keyword;
3872 	cmdline_fixed_string_t rxpkts;
3873 	cmdline_fixed_string_t seg_lengths;
3874 };
3875 
3876 static void
3877 cmd_set_rxpkts_parsed(void *parsed_result,
3878 		      __rte_unused struct cmdline *cl,
3879 		      __rte_unused void *data)
3880 {
3881 	struct cmd_set_rxpkts_result *res;
3882 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3883 	unsigned int nb_segs;
3884 
3885 	res = parsed_result;
3886 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3887 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3888 	if (nb_segs > 0)
3889 		set_rx_pkt_segments(seg_lengths, nb_segs);
3890 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3891 }
3892 
3893 static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3894 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3895 				 cmd_keyword, "set");
3896 static cmdline_parse_token_string_t cmd_set_rxpkts_name =
3897 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3898 				 rxpkts, "rxpkts");
3899 static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3900 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3901 				 seg_lengths, NULL);
3902 
3903 static cmdline_parse_inst_t cmd_set_rxpkts = {
3904 	.f = cmd_set_rxpkts_parsed,
3905 	.data = NULL,
3906 	.help_str = "set rxpkts <len0[,len1]*>",
3907 	.tokens = {
3908 		(void *)&cmd_set_rxpkts_keyword,
3909 		(void *)&cmd_set_rxpkts_name,
3910 		(void *)&cmd_set_rxpkts_lengths,
3911 		NULL,
3912 	},
3913 };
3914 
3915 /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
3916 struct cmd_set_rxhdrs_result {
3917 	cmdline_fixed_string_t set;
3918 	cmdline_fixed_string_t rxhdrs;
3919 	cmdline_fixed_string_t values;
3920 };
3921 
3922 static void
3923 cmd_set_rxhdrs_parsed(void *parsed_result,
3924 		      __rte_unused struct cmdline *cl,
3925 		      __rte_unused void *data)
3926 {
3927 	struct cmd_set_rxhdrs_result *res;
3928 	unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
3929 	unsigned int nb_segs;
3930 
3931 	res = parsed_result;
3932 	nb_segs = parse_hdrs_list(res->values, "segment hdrs",
3933 				  MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
3934 	if (nb_segs > 0)
3935 		set_rx_pkt_hdrs(seg_hdrs, nb_segs);
3936 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3937 }
3938 
3939 static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
3940 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
3941 				set, "set");
3942 static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
3943 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
3944 				rxhdrs, "rxhdrs");
3945 static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
3946 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
3947 				values, NULL);
3948 
3949 static cmdline_parse_inst_t cmd_set_rxhdrs = {
3950 	.f = cmd_set_rxhdrs_parsed,
3951 	.data = NULL,
3952 	.help_str = "set rxhdrs <eth[,ipv4]*>",
3953 	.tokens = {
3954 		(void *)&cmd_set_rxhdrs_set,
3955 		(void *)&cmd_set_rxhdrs_rxhdrs,
3956 		(void *)&cmd_set_rxhdrs_values,
3957 		NULL,
3958 	},
3959 };
3960 
3961 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3962 
3963 struct cmd_set_txpkts_result {
3964 	cmdline_fixed_string_t cmd_keyword;
3965 	cmdline_fixed_string_t txpkts;
3966 	cmdline_fixed_string_t seg_lengths;
3967 };
3968 
3969 static void
3970 cmd_set_txpkts_parsed(void *parsed_result,
3971 		      __rte_unused struct cmdline *cl,
3972 		      __rte_unused void *data)
3973 {
3974 	struct cmd_set_txpkts_result *res;
3975 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3976 	unsigned int nb_segs;
3977 
3978 	res = parsed_result;
3979 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3980 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3981 	if (nb_segs > 0)
3982 		set_tx_pkt_segments(seg_lengths, nb_segs);
3983 }
3984 
3985 static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3986 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3987 				 cmd_keyword, "set");
3988 static cmdline_parse_token_string_t cmd_set_txpkts_name =
3989 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3990 				 txpkts, "txpkts");
3991 static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3992 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3993 				 seg_lengths, NULL);
3994 
3995 static cmdline_parse_inst_t cmd_set_txpkts = {
3996 	.f = cmd_set_txpkts_parsed,
3997 	.data = NULL,
3998 	.help_str = "set txpkts <len0[,len1]*>",
3999 	.tokens = {
4000 		(void *)&cmd_set_txpkts_keyword,
4001 		(void *)&cmd_set_txpkts_name,
4002 		(void *)&cmd_set_txpkts_lengths,
4003 		NULL,
4004 	},
4005 };
4006 
4007 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4008 
4009 struct cmd_set_txsplit_result {
4010 	cmdline_fixed_string_t cmd_keyword;
4011 	cmdline_fixed_string_t txsplit;
4012 	cmdline_fixed_string_t mode;
4013 };
4014 
4015 static void
4016 cmd_set_txsplit_parsed(void *parsed_result,
4017 		      __rte_unused struct cmdline *cl,
4018 		      __rte_unused void *data)
4019 {
4020 	struct cmd_set_txsplit_result *res;
4021 
4022 	res = parsed_result;
4023 	set_tx_pkt_split(res->mode);
4024 }
4025 
4026 static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4027 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4028 				 cmd_keyword, "set");
4029 static cmdline_parse_token_string_t cmd_set_txsplit_name =
4030 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4031 				 txsplit, "txsplit");
4032 static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4033 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4034 				 mode, NULL);
4035 
4036 static cmdline_parse_inst_t cmd_set_txsplit = {
4037 	.f = cmd_set_txsplit_parsed,
4038 	.data = NULL,
4039 	.help_str = "set txsplit on|off|rand",
4040 	.tokens = {
4041 		(void *)&cmd_set_txsplit_keyword,
4042 		(void *)&cmd_set_txsplit_name,
4043 		(void *)&cmd_set_txsplit_mode,
4044 		NULL,
4045 	},
4046 };
4047 
4048 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4049 
4050 struct cmd_set_txtimes_result {
4051 	cmdline_fixed_string_t cmd_keyword;
4052 	cmdline_fixed_string_t txtimes;
4053 	cmdline_fixed_string_t tx_times;
4054 };
4055 
4056 static void
4057 cmd_set_txtimes_parsed(void *parsed_result,
4058 		       __rte_unused struct cmdline *cl,
4059 		       __rte_unused void *data)
4060 {
4061 	struct cmd_set_txtimes_result *res;
4062 	unsigned int tx_times[2] = {0, 0};
4063 	unsigned int n_times;
4064 
4065 	res = parsed_result;
4066 	n_times = parse_item_list(res->tx_times, "tx times",
4067 				  2, tx_times, 0);
4068 	if (n_times == 2)
4069 		set_tx_pkt_times(tx_times);
4070 }
4071 
4072 static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4073 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4074 				 cmd_keyword, "set");
4075 static cmdline_parse_token_string_t cmd_set_txtimes_name =
4076 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4077 				 txtimes, "txtimes");
4078 static cmdline_parse_token_string_t cmd_set_txtimes_value =
4079 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4080 				 tx_times, NULL);
4081 
4082 static cmdline_parse_inst_t cmd_set_txtimes = {
4083 	.f = cmd_set_txtimes_parsed,
4084 	.data = NULL,
4085 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
4086 	.tokens = {
4087 		(void *)&cmd_set_txtimes_keyword,
4088 		(void *)&cmd_set_txtimes_name,
4089 		(void *)&cmd_set_txtimes_value,
4090 		NULL,
4091 	},
4092 };
4093 
4094 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4095 struct cmd_rx_vlan_filter_all_result {
4096 	cmdline_fixed_string_t rx_vlan;
4097 	cmdline_fixed_string_t what;
4098 	cmdline_fixed_string_t all;
4099 	portid_t port_id;
4100 };
4101 
4102 static void
4103 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4104 			      __rte_unused struct cmdline *cl,
4105 			      __rte_unused void *data)
4106 {
4107 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4108 
4109 	if (!strcmp(res->what, "add"))
4110 		rx_vlan_all_filter_set(res->port_id, 1);
4111 	else
4112 		rx_vlan_all_filter_set(res->port_id, 0);
4113 }
4114 
4115 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4116 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4117 				 rx_vlan, "rx_vlan");
4118 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4119 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4120 				 what, "add#rm");
4121 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4122 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4123 				 all, "all");
4124 static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4125 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4126 			      port_id, RTE_UINT16);
4127 
4128 static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4129 	.f = cmd_rx_vlan_filter_all_parsed,
4130 	.data = NULL,
4131 	.help_str = "rx_vlan add|rm all <port_id>: "
4132 		"Add/Remove all identifiers to/from the set of VLAN "
4133 		"identifiers filtered by a port",
4134 	.tokens = {
4135 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4136 		(void *)&cmd_rx_vlan_filter_all_what,
4137 		(void *)&cmd_rx_vlan_filter_all_all,
4138 		(void *)&cmd_rx_vlan_filter_all_portid,
4139 		NULL,
4140 	},
4141 };
4142 
4143 /* *** VLAN OFFLOAD SET ON A PORT *** */
4144 struct cmd_vlan_offload_result {
4145 	cmdline_fixed_string_t vlan;
4146 	cmdline_fixed_string_t set;
4147 	cmdline_fixed_string_t vlan_type;
4148 	cmdline_fixed_string_t what;
4149 	cmdline_fixed_string_t on;
4150 	cmdline_fixed_string_t port_id;
4151 };
4152 
4153 static void
4154 cmd_vlan_offload_parsed(void *parsed_result,
4155 			  __rte_unused struct cmdline *cl,
4156 			  __rte_unused void *data)
4157 {
4158 	int on;
4159 	struct cmd_vlan_offload_result *res = parsed_result;
4160 	char *str;
4161 	int i, len = 0;
4162 	portid_t port_id = 0;
4163 	unsigned int tmp;
4164 
4165 	str = res->port_id;
4166 	len = strnlen(str, STR_TOKEN_SIZE);
4167 	i = 0;
4168 	/* Get port_id first */
4169 	while(i < len){
4170 		if(str[i] == ',')
4171 			break;
4172 
4173 		i++;
4174 	}
4175 	str[i]='\0';
4176 	tmp = strtoul(str, NULL, 0);
4177 	/* If port_id greater that what portid_t can represent, return */
4178 	if(tmp >= RTE_MAX_ETHPORTS)
4179 		return;
4180 	port_id = (portid_t)tmp;
4181 
4182 	if (!strcmp(res->on, "on"))
4183 		on = 1;
4184 	else
4185 		on = 0;
4186 
4187 	if (!strcmp(res->what, "strip"))
4188 		rx_vlan_strip_set(port_id,  on);
4189 	else if(!strcmp(res->what, "stripq")){
4190 		uint16_t queue_id = 0;
4191 
4192 		/* No queue_id, return */
4193 		if(i + 1 >= len) {
4194 			fprintf(stderr, "must specify (port,queue_id)\n");
4195 			return;
4196 		}
4197 		tmp = strtoul(str + i + 1, NULL, 0);
4198 		/* If queue_id greater that what 16-bits can represent, return */
4199 		if(tmp > 0xffff)
4200 			return;
4201 
4202 		queue_id = (uint16_t)tmp;
4203 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4204 	}
4205 	else if (!strcmp(res->what, "filter"))
4206 		rx_vlan_filter_set(port_id, on);
4207 	else if (!strcmp(res->what, "qinq_strip"))
4208 		rx_vlan_qinq_strip_set(port_id, on);
4209 	else
4210 		vlan_extend_set(port_id, on);
4211 
4212 	return;
4213 }
4214 
4215 static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4216 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4217 				 vlan, "vlan");
4218 static cmdline_parse_token_string_t cmd_vlan_offload_set =
4219 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4220 				 set, "set");
4221 static cmdline_parse_token_string_t cmd_vlan_offload_what =
4222 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4223 				what, "strip#filter#qinq_strip#extend#stripq");
4224 static cmdline_parse_token_string_t cmd_vlan_offload_on =
4225 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4226 			      on, "on#off");
4227 static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4228 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4229 			      port_id, NULL);
4230 
4231 static cmdline_parse_inst_t cmd_vlan_offload = {
4232 	.f = cmd_vlan_offload_parsed,
4233 	.data = NULL,
4234 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4235 		"<port_id[,queue_id]>: "
4236 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4237 	.tokens = {
4238 		(void *)&cmd_vlan_offload_vlan,
4239 		(void *)&cmd_vlan_offload_set,
4240 		(void *)&cmd_vlan_offload_what,
4241 		(void *)&cmd_vlan_offload_on,
4242 		(void *)&cmd_vlan_offload_portid,
4243 		NULL,
4244 	},
4245 };
4246 
4247 /* *** VLAN TPID SET ON A PORT *** */
4248 struct cmd_vlan_tpid_result {
4249 	cmdline_fixed_string_t vlan;
4250 	cmdline_fixed_string_t set;
4251 	cmdline_fixed_string_t vlan_type;
4252 	cmdline_fixed_string_t what;
4253 	uint16_t tp_id;
4254 	portid_t port_id;
4255 };
4256 
4257 static void
4258 cmd_vlan_tpid_parsed(void *parsed_result,
4259 			  __rte_unused struct cmdline *cl,
4260 			  __rte_unused void *data)
4261 {
4262 	struct cmd_vlan_tpid_result *res = parsed_result;
4263 	enum rte_vlan_type vlan_type;
4264 
4265 	if (!strcmp(res->vlan_type, "inner"))
4266 		vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4267 	else if (!strcmp(res->vlan_type, "outer"))
4268 		vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4269 	else {
4270 		fprintf(stderr, "Unknown vlan type\n");
4271 		return;
4272 	}
4273 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4274 }
4275 
4276 static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4277 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4278 				 vlan, "vlan");
4279 static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4280 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4281 				 set, "set");
4282 static cmdline_parse_token_string_t cmd_vlan_type =
4283 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4284 				 vlan_type, "inner#outer");
4285 static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4286 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4287 				 what, "tpid");
4288 static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4289 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4290 			      tp_id, RTE_UINT16);
4291 static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4292 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4293 			      port_id, RTE_UINT16);
4294 
4295 static cmdline_parse_inst_t cmd_vlan_tpid = {
4296 	.f = cmd_vlan_tpid_parsed,
4297 	.data = NULL,
4298 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4299 		"Set the VLAN Ether type",
4300 	.tokens = {
4301 		(void *)&cmd_vlan_tpid_vlan,
4302 		(void *)&cmd_vlan_tpid_set,
4303 		(void *)&cmd_vlan_type,
4304 		(void *)&cmd_vlan_tpid_what,
4305 		(void *)&cmd_vlan_tpid_tpid,
4306 		(void *)&cmd_vlan_tpid_portid,
4307 		NULL,
4308 	},
4309 };
4310 
4311 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4312 struct cmd_rx_vlan_filter_result {
4313 	cmdline_fixed_string_t rx_vlan;
4314 	cmdline_fixed_string_t what;
4315 	uint16_t vlan_id;
4316 	portid_t port_id;
4317 };
4318 
4319 static void
4320 cmd_rx_vlan_filter_parsed(void *parsed_result,
4321 			  __rte_unused struct cmdline *cl,
4322 			  __rte_unused void *data)
4323 {
4324 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4325 
4326 	if (!strcmp(res->what, "add"))
4327 		rx_vft_set(res->port_id, res->vlan_id, 1);
4328 	else
4329 		rx_vft_set(res->port_id, res->vlan_id, 0);
4330 }
4331 
4332 static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4333 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4334 				 rx_vlan, "rx_vlan");
4335 static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4336 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4337 				 what, "add#rm");
4338 static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4339 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4340 			      vlan_id, RTE_UINT16);
4341 static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4342 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4343 			      port_id, RTE_UINT16);
4344 
4345 static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4346 	.f = cmd_rx_vlan_filter_parsed,
4347 	.data = NULL,
4348 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4349 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4350 		"identifiers filtered by a port",
4351 	.tokens = {
4352 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4353 		(void *)&cmd_rx_vlan_filter_what,
4354 		(void *)&cmd_rx_vlan_filter_vlanid,
4355 		(void *)&cmd_rx_vlan_filter_portid,
4356 		NULL,
4357 	},
4358 };
4359 
4360 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4361 struct cmd_tx_vlan_set_result {
4362 	cmdline_fixed_string_t tx_vlan;
4363 	cmdline_fixed_string_t set;
4364 	portid_t port_id;
4365 	uint16_t vlan_id;
4366 };
4367 
4368 static void
4369 cmd_tx_vlan_set_parsed(void *parsed_result,
4370 		       __rte_unused struct cmdline *cl,
4371 		       __rte_unused void *data)
4372 {
4373 	struct cmd_tx_vlan_set_result *res = parsed_result;
4374 
4375 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4376 		return;
4377 
4378 	if (!port_is_stopped(res->port_id)) {
4379 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4380 		return;
4381 	}
4382 
4383 	tx_vlan_set(res->port_id, res->vlan_id);
4384 
4385 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4386 }
4387 
4388 static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4389 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4390 				 tx_vlan, "tx_vlan");
4391 static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4392 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4393 				 set, "set");
4394 static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4395 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4396 			      port_id, RTE_UINT16);
4397 static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4398 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4399 			      vlan_id, RTE_UINT16);
4400 
4401 static cmdline_parse_inst_t cmd_tx_vlan_set = {
4402 	.f = cmd_tx_vlan_set_parsed,
4403 	.data = NULL,
4404 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4405 		"Enable hardware insertion of a single VLAN header "
4406 		"with a given TAG Identifier in packets sent on a port",
4407 	.tokens = {
4408 		(void *)&cmd_tx_vlan_set_tx_vlan,
4409 		(void *)&cmd_tx_vlan_set_set,
4410 		(void *)&cmd_tx_vlan_set_portid,
4411 		(void *)&cmd_tx_vlan_set_vlanid,
4412 		NULL,
4413 	},
4414 };
4415 
4416 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4417 struct cmd_tx_vlan_set_qinq_result {
4418 	cmdline_fixed_string_t tx_vlan;
4419 	cmdline_fixed_string_t set;
4420 	portid_t port_id;
4421 	uint16_t vlan_id;
4422 	uint16_t vlan_id_outer;
4423 };
4424 
4425 static void
4426 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4427 			    __rte_unused struct cmdline *cl,
4428 			    __rte_unused void *data)
4429 {
4430 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4431 
4432 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4433 		return;
4434 
4435 	if (!port_is_stopped(res->port_id)) {
4436 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4437 		return;
4438 	}
4439 
4440 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4441 
4442 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4443 }
4444 
4445 static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4446 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4447 		tx_vlan, "tx_vlan");
4448 static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4449 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4450 		set, "set");
4451 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4452 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4453 		port_id, RTE_UINT16);
4454 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4455 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4456 		vlan_id, RTE_UINT16);
4457 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4458 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4459 		vlan_id_outer, RTE_UINT16);
4460 
4461 static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4462 	.f = cmd_tx_vlan_set_qinq_parsed,
4463 	.data = NULL,
4464 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4465 		"Enable hardware insertion of double VLAN header "
4466 		"with given TAG Identifiers in packets sent on a port",
4467 	.tokens = {
4468 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4469 		(void *)&cmd_tx_vlan_set_qinq_set,
4470 		(void *)&cmd_tx_vlan_set_qinq_portid,
4471 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4472 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4473 		NULL,
4474 	},
4475 };
4476 
4477 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4478 struct cmd_tx_vlan_set_pvid_result {
4479 	cmdline_fixed_string_t tx_vlan;
4480 	cmdline_fixed_string_t set;
4481 	cmdline_fixed_string_t pvid;
4482 	portid_t port_id;
4483 	uint16_t vlan_id;
4484 	cmdline_fixed_string_t mode;
4485 };
4486 
4487 static void
4488 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4489 			    __rte_unused struct cmdline *cl,
4490 			    __rte_unused void *data)
4491 {
4492 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4493 
4494 	if (strcmp(res->mode, "on") == 0)
4495 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4496 	else
4497 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4498 }
4499 
4500 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4501 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4502 				 tx_vlan, "tx_vlan");
4503 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4504 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4505 				 set, "set");
4506 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4507 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4508 				 pvid, "pvid");
4509 static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4510 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4511 			     port_id, RTE_UINT16);
4512 static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4513 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4514 			      vlan_id, RTE_UINT16);
4515 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4516 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4517 				 mode, "on#off");
4518 
4519 static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4520 	.f = cmd_tx_vlan_set_pvid_parsed,
4521 	.data = NULL,
4522 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4523 	.tokens = {
4524 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4525 		(void *)&cmd_tx_vlan_set_pvid_set,
4526 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4527 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4528 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4529 		(void *)&cmd_tx_vlan_set_pvid_mode,
4530 		NULL,
4531 	},
4532 };
4533 
4534 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4535 struct cmd_tx_vlan_reset_result {
4536 	cmdline_fixed_string_t tx_vlan;
4537 	cmdline_fixed_string_t reset;
4538 	portid_t port_id;
4539 };
4540 
4541 static void
4542 cmd_tx_vlan_reset_parsed(void *parsed_result,
4543 			 __rte_unused struct cmdline *cl,
4544 			 __rte_unused void *data)
4545 {
4546 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4547 
4548 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4549 		return;
4550 
4551 	if (!port_is_stopped(res->port_id)) {
4552 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4553 		return;
4554 	}
4555 
4556 	tx_vlan_reset(res->port_id);
4557 
4558 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4559 }
4560 
4561 static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4562 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4563 				 tx_vlan, "tx_vlan");
4564 static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4565 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4566 				 reset, "reset");
4567 static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4568 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4569 			      port_id, RTE_UINT16);
4570 
4571 static cmdline_parse_inst_t cmd_tx_vlan_reset = {
4572 	.f = cmd_tx_vlan_reset_parsed,
4573 	.data = NULL,
4574 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4575 		"VLAN header in packets sent on a port",
4576 	.tokens = {
4577 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4578 		(void *)&cmd_tx_vlan_reset_reset,
4579 		(void *)&cmd_tx_vlan_reset_portid,
4580 		NULL,
4581 	},
4582 };
4583 
4584 
4585 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4586 struct cmd_csum_result {
4587 	cmdline_fixed_string_t csum;
4588 	cmdline_fixed_string_t mode;
4589 	cmdline_fixed_string_t proto;
4590 	cmdline_fixed_string_t hwsw;
4591 	portid_t port_id;
4592 };
4593 
4594 static void
4595 csum_show(int port_id)
4596 {
4597 	struct rte_eth_dev_info dev_info;
4598 	uint64_t tx_offloads;
4599 	int ret;
4600 
4601 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4602 	printf("Parse tunnel is %s\n",
4603 		(ports[port_id].parse_tunnel) ? "on" : "off");
4604 	printf("IP checksum offload is %s\n",
4605 		(tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4606 	printf("UDP checksum offload is %s\n",
4607 		(tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4608 	printf("TCP checksum offload is %s\n",
4609 		(tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4610 	printf("SCTP checksum offload is %s\n",
4611 		(tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4612 	printf("Outer-Ip checksum offload is %s\n",
4613 		(tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4614 	printf("Outer-Udp checksum offload is %s\n",
4615 		(tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4616 
4617 	/* display warnings if configuration is not supported by the NIC */
4618 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4619 	if (ret != 0)
4620 		return;
4621 
4622 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4623 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4624 		fprintf(stderr,
4625 			"Warning: hardware IP checksum enabled but not supported by port %d\n",
4626 			port_id);
4627 	}
4628 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4629 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4630 		fprintf(stderr,
4631 			"Warning: hardware UDP checksum enabled but not supported by port %d\n",
4632 			port_id);
4633 	}
4634 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4635 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4636 		fprintf(stderr,
4637 			"Warning: hardware TCP checksum enabled but not supported by port %d\n",
4638 			port_id);
4639 	}
4640 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4641 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4642 		fprintf(stderr,
4643 			"Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4644 			port_id);
4645 	}
4646 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4647 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4648 		fprintf(stderr,
4649 			"Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4650 			port_id);
4651 	}
4652 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4653 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4654 			== 0) {
4655 		fprintf(stderr,
4656 			"Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4657 			port_id);
4658 	}
4659 }
4660 
4661 static void
4662 cmd_config_queue_tx_offloads(struct rte_port *port)
4663 {
4664 	int k;
4665 
4666 	/* Apply queue tx offloads configuration */
4667 	for (k = 0; k < port->dev_info.max_tx_queues; k++)
4668 		port->txq[k].conf.offloads =
4669 			port->dev_conf.txmode.offloads;
4670 }
4671 
4672 static void
4673 cmd_csum_parsed(void *parsed_result,
4674 		       __rte_unused struct cmdline *cl,
4675 		       __rte_unused void *data)
4676 {
4677 	struct cmd_csum_result *res = parsed_result;
4678 	int hw = 0;
4679 	uint64_t csum_offloads = 0;
4680 	struct rte_eth_dev_info dev_info;
4681 	int ret;
4682 
4683 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4684 		fprintf(stderr, "invalid port %d\n", res->port_id);
4685 		return;
4686 	}
4687 	if (!port_is_stopped(res->port_id)) {
4688 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4689 		return;
4690 	}
4691 
4692 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4693 	if (ret != 0)
4694 		return;
4695 
4696 	if (!strcmp(res->mode, "set")) {
4697 
4698 		if (!strcmp(res->hwsw, "hw"))
4699 			hw = 1;
4700 
4701 		if (!strcmp(res->proto, "ip")) {
4702 			if (hw == 0 || (dev_info.tx_offload_capa &
4703 						RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4704 				csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4705 			} else {
4706 				fprintf(stderr,
4707 					"IP checksum offload is not supported by port %u\n",
4708 					res->port_id);
4709 			}
4710 		} else if (!strcmp(res->proto, "udp")) {
4711 			if (hw == 0 || (dev_info.tx_offload_capa &
4712 						RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4713 				csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4714 			} else {
4715 				fprintf(stderr,
4716 					"UDP checksum offload is not supported by port %u\n",
4717 					res->port_id);
4718 			}
4719 		} else if (!strcmp(res->proto, "tcp")) {
4720 			if (hw == 0 || (dev_info.tx_offload_capa &
4721 						RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4722 				csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4723 			} else {
4724 				fprintf(stderr,
4725 					"TCP checksum offload is not supported by port %u\n",
4726 					res->port_id);
4727 			}
4728 		} else if (!strcmp(res->proto, "sctp")) {
4729 			if (hw == 0 || (dev_info.tx_offload_capa &
4730 						RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4731 				csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4732 			} else {
4733 				fprintf(stderr,
4734 					"SCTP checksum offload is not supported by port %u\n",
4735 					res->port_id);
4736 			}
4737 		} else if (!strcmp(res->proto, "outer-ip")) {
4738 			if (hw == 0 || (dev_info.tx_offload_capa &
4739 					RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4740 				csum_offloads |=
4741 						RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4742 			} else {
4743 				fprintf(stderr,
4744 					"Outer IP checksum offload is not supported by port %u\n",
4745 					res->port_id);
4746 			}
4747 		} else if (!strcmp(res->proto, "outer-udp")) {
4748 			if (hw == 0 || (dev_info.tx_offload_capa &
4749 					RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4750 				csum_offloads |=
4751 						RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4752 			} else {
4753 				fprintf(stderr,
4754 					"Outer UDP checksum offload is not supported by port %u\n",
4755 					res->port_id);
4756 			}
4757 		}
4758 
4759 		if (hw) {
4760 			ports[res->port_id].dev_conf.txmode.offloads |=
4761 							csum_offloads;
4762 		} else {
4763 			ports[res->port_id].dev_conf.txmode.offloads &=
4764 							(~csum_offloads);
4765 		}
4766 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4767 	}
4768 	csum_show(res->port_id);
4769 
4770 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4771 }
4772 
4773 static cmdline_parse_token_string_t cmd_csum_csum =
4774 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4775 				csum, "csum");
4776 static cmdline_parse_token_string_t cmd_csum_mode =
4777 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4778 				mode, "set");
4779 static cmdline_parse_token_string_t cmd_csum_proto =
4780 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4781 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4782 static cmdline_parse_token_string_t cmd_csum_hwsw =
4783 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4784 				hwsw, "hw#sw");
4785 static cmdline_parse_token_num_t cmd_csum_portid =
4786 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4787 				port_id, RTE_UINT16);
4788 
4789 static cmdline_parse_inst_t cmd_csum_set = {
4790 	.f = cmd_csum_parsed,
4791 	.data = NULL,
4792 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4793 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4794 		"using csum forward engine",
4795 	.tokens = {
4796 		(void *)&cmd_csum_csum,
4797 		(void *)&cmd_csum_mode,
4798 		(void *)&cmd_csum_proto,
4799 		(void *)&cmd_csum_hwsw,
4800 		(void *)&cmd_csum_portid,
4801 		NULL,
4802 	},
4803 };
4804 
4805 static cmdline_parse_token_string_t cmd_csum_mode_show =
4806 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4807 				mode, "show");
4808 
4809 static cmdline_parse_inst_t cmd_csum_show = {
4810 	.f = cmd_csum_parsed,
4811 	.data = NULL,
4812 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4813 	.tokens = {
4814 		(void *)&cmd_csum_csum,
4815 		(void *)&cmd_csum_mode_show,
4816 		(void *)&cmd_csum_portid,
4817 		NULL,
4818 	},
4819 };
4820 
4821 /* Enable/disable tunnel parsing */
4822 struct cmd_csum_tunnel_result {
4823 	cmdline_fixed_string_t csum;
4824 	cmdline_fixed_string_t parse;
4825 	cmdline_fixed_string_t onoff;
4826 	portid_t port_id;
4827 };
4828 
4829 static void
4830 cmd_csum_tunnel_parsed(void *parsed_result,
4831 		       __rte_unused struct cmdline *cl,
4832 		       __rte_unused void *data)
4833 {
4834 	struct cmd_csum_tunnel_result *res = parsed_result;
4835 
4836 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4837 		return;
4838 
4839 	if (!strcmp(res->onoff, "on"))
4840 		ports[res->port_id].parse_tunnel = 1;
4841 	else
4842 		ports[res->port_id].parse_tunnel = 0;
4843 
4844 	csum_show(res->port_id);
4845 }
4846 
4847 static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4848 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4849 				csum, "csum");
4850 static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4851 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4852 				parse, "parse-tunnel");
4853 static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4854 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4855 				onoff, "on#off");
4856 static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4857 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4858 				port_id, RTE_UINT16);
4859 
4860 static cmdline_parse_inst_t cmd_csum_tunnel = {
4861 	.f = cmd_csum_tunnel_parsed,
4862 	.data = NULL,
4863 	.help_str = "csum parse-tunnel on|off <port_id>: "
4864 		"Enable/Disable parsing of tunnels for csum engine",
4865 	.tokens = {
4866 		(void *)&cmd_csum_tunnel_csum,
4867 		(void *)&cmd_csum_tunnel_parse,
4868 		(void *)&cmd_csum_tunnel_onoff,
4869 		(void *)&cmd_csum_tunnel_portid,
4870 		NULL,
4871 	},
4872 };
4873 
4874 struct cmd_csum_mac_swap_result {
4875 	cmdline_fixed_string_t csum;
4876 	cmdline_fixed_string_t parse;
4877 	cmdline_fixed_string_t onoff;
4878 	portid_t port_id;
4879 };
4880 
4881 static void
4882 cmd_csum_mac_swap_parsed(void *parsed_result,
4883 		       __rte_unused struct cmdline *cl,
4884 		       __rte_unused void *data)
4885 {
4886 	struct cmd_csum_mac_swap_result *res = parsed_result;
4887 
4888 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4889 		return;
4890 	if (strcmp(res->onoff, "on") == 0)
4891 		ports[res->port_id].fwd_mac_swap = 1;
4892 	else
4893 		ports[res->port_id].fwd_mac_swap = 0;
4894 }
4895 
4896 static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
4897 	TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4898 				 csum, "csum");
4899 static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
4900 	TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4901 				 parse, "mac-swap");
4902 static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
4903 	TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4904 				 onoff, "on#off");
4905 static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
4906 	TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
4907 			      port_id, RTE_UINT16);
4908 
4909 static cmdline_parse_inst_t cmd_csum_mac_swap = {
4910 	.f = cmd_csum_mac_swap_parsed,
4911 	.data = NULL,
4912 	.help_str = "csum mac-swap on|off <port_id>: "
4913 		    "Enable/Disable forward mac address swap",
4914 	.tokens = {
4915 		(void *)&cmd_csum_mac_swap_csum,
4916 		(void *)&cmd_csum_mac_swap_parse,
4917 		(void *)&cmd_csum_mac_swap_onoff,
4918 		(void *)&cmd_csum_mac_swap_portid,
4919 		NULL,
4920 	},
4921 };
4922 
4923 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4924 struct cmd_tso_set_result {
4925 	cmdline_fixed_string_t tso;
4926 	cmdline_fixed_string_t mode;
4927 	uint16_t tso_segsz;
4928 	portid_t port_id;
4929 };
4930 
4931 static void
4932 cmd_tso_set_parsed(void *parsed_result,
4933 		       __rte_unused struct cmdline *cl,
4934 		       __rte_unused void *data)
4935 {
4936 	struct cmd_tso_set_result *res = parsed_result;
4937 	struct rte_eth_dev_info dev_info;
4938 	uint64_t offloads;
4939 	int ret;
4940 
4941 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4942 		return;
4943 	if (!port_is_stopped(res->port_id)) {
4944 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4945 		return;
4946 	}
4947 
4948 	if (!strcmp(res->mode, "set"))
4949 		ports[res->port_id].tso_segsz = res->tso_segsz;
4950 
4951 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4952 	if (ret != 0)
4953 		return;
4954 
4955 	if (ports[res->port_id].tso_segsz != 0) {
4956 		if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
4957 				RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
4958 			fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
4959 				res->port_id);
4960 			return;
4961 		}
4962 		/* display warnings if configuration is not supported by the NIC */
4963 		if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
4964 			printf("Warning: port %d doesn't support TSO\n", res->port_id);
4965 		if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
4966 			printf("Warning: port %d doesn't support UFO\n", res->port_id);
4967 	}
4968 
4969 	if (ports[res->port_id].tso_segsz == 0) {
4970 		ports[res->port_id].dev_conf.txmode.offloads &=
4971 			~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
4972 		printf("TSO and UFO for non-tunneled packets is disabled\n");
4973 	} else {
4974 		offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
4975 					RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
4976 		offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
4977 					RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
4978 		ports[res->port_id].dev_conf.txmode.offloads |= offloads;
4979 		printf("segment size for non-tunneled packets is %d\n",
4980 			ports[res->port_id].tso_segsz);
4981 	}
4982 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4983 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4984 }
4985 
4986 static cmdline_parse_token_string_t cmd_tso_set_tso =
4987 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4988 				tso, "tso");
4989 static cmdline_parse_token_string_t cmd_tso_set_mode =
4990 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4991 				mode, "set");
4992 static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4993 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4994 				tso_segsz, RTE_UINT16);
4995 static cmdline_parse_token_num_t cmd_tso_set_portid =
4996 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4997 				port_id, RTE_UINT16);
4998 
4999 static cmdline_parse_inst_t cmd_tso_set = {
5000 	.f = cmd_tso_set_parsed,
5001 	.data = NULL,
5002 	.help_str = "tso set <tso_segsz> <port_id>: "
5003 		"Set TSO segment size of non-tunneled packets for csum engine "
5004 		"(0 to disable)",
5005 	.tokens = {
5006 		(void *)&cmd_tso_set_tso,
5007 		(void *)&cmd_tso_set_mode,
5008 		(void *)&cmd_tso_set_tso_segsz,
5009 		(void *)&cmd_tso_set_portid,
5010 		NULL,
5011 	},
5012 };
5013 
5014 static cmdline_parse_token_string_t cmd_tso_show_mode =
5015 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5016 				mode, "show");
5017 
5018 
5019 static cmdline_parse_inst_t cmd_tso_show = {
5020 	.f = cmd_tso_set_parsed,
5021 	.data = NULL,
5022 	.help_str = "tso show <port_id>: "
5023 		"Show TSO segment size of non-tunneled packets for csum engine",
5024 	.tokens = {
5025 		(void *)&cmd_tso_set_tso,
5026 		(void *)&cmd_tso_show_mode,
5027 		(void *)&cmd_tso_set_portid,
5028 		NULL,
5029 	},
5030 };
5031 
5032 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5033 struct cmd_tunnel_tso_set_result {
5034 	cmdline_fixed_string_t tso;
5035 	cmdline_fixed_string_t mode;
5036 	uint16_t tso_segsz;
5037 	portid_t port_id;
5038 };
5039 
5040 static void
5041 check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5042 {
5043 	if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5044 		printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5045 			port_id);
5046 	if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5047 		printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5048 			port_id);
5049 	if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5050 		printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5051 			port_id);
5052 	if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5053 		printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5054 			port_id);
5055 	if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5056 		printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5057 			port_id);
5058 	if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5059 		printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5060 			port_id);
5061 }
5062 
5063 static void
5064 cmd_tunnel_tso_set_parsed(void *parsed_result,
5065 			  __rte_unused struct cmdline *cl,
5066 			  __rte_unused void *data)
5067 {
5068 	struct cmd_tunnel_tso_set_result *res = parsed_result;
5069 	struct rte_eth_dev_info dev_info;
5070 	uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5071 				RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5072 				RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5073 				RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5074 				RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5075 				RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5076 	int ret;
5077 
5078 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5079 		return;
5080 	if (!port_is_stopped(res->port_id)) {
5081 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
5082 		return;
5083 	}
5084 
5085 	if (!strcmp(res->mode, "set"))
5086 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5087 
5088 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
5089 		ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5090 		printf("TSO for tunneled packets is disabled\n");
5091 	} else {
5092 		ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5093 		if (ret != 0)
5094 			return;
5095 
5096 		if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5097 			fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5098 				res->port_id);
5099 			return;
5100 		}
5101 
5102 		/* Below conditions are needed to make it work:
5103 		 * (1) tunnel TSO is supported by the NIC;
5104 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5105 		 * are recognized;
5106 		 * (3) for tunneled pkts with outer L3 of IPv4,
5107 		 * "csum set outer-ip" must be set to hw, because after tso,
5108 		 * total_len of outer IP header is changed, and the checksum
5109 		 * of outer IP header calculated by sw should be wrong; that
5110 		 * is not necessary for IPv6 tunneled pkts because there's no
5111 		 * checksum in IP header anymore.
5112 		 */
5113 		if (!ports[res->port_id].parse_tunnel) {
5114 			fprintf(stderr,
5115 				"Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5116 			return;
5117 		}
5118 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
5119 		      RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5120 			fprintf(stderr,
5121 				"Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5122 			return;
5123 		}
5124 
5125 		check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5126 		ports[res->port_id].dev_conf.txmode.offloads |=
5127 				(all_tunnel_tso & dev_info.tx_offload_capa);
5128 		printf("TSO segment size for tunneled packets is %d\n",
5129 			ports[res->port_id].tunnel_tso_segsz);
5130 	}
5131 
5132 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
5133 	cmd_reconfig_device_queue(res->port_id, 1, 1);
5134 }
5135 
5136 static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5137 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5138 				tso, "tunnel_tso");
5139 static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5140 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5141 				mode, "set");
5142 static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5143 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5144 				tso_segsz, RTE_UINT16);
5145 static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5146 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5147 				port_id, RTE_UINT16);
5148 
5149 static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5150 	.f = cmd_tunnel_tso_set_parsed,
5151 	.data = NULL,
5152 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5153 		"Set TSO segment size of tunneled packets for csum engine "
5154 		"(0 to disable)",
5155 	.tokens = {
5156 		(void *)&cmd_tunnel_tso_set_tso,
5157 		(void *)&cmd_tunnel_tso_set_mode,
5158 		(void *)&cmd_tunnel_tso_set_tso_segsz,
5159 		(void *)&cmd_tunnel_tso_set_portid,
5160 		NULL,
5161 	},
5162 };
5163 
5164 static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5165 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5166 				mode, "show");
5167 
5168 
5169 static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5170 	.f = cmd_tunnel_tso_set_parsed,
5171 	.data = NULL,
5172 	.help_str = "tunnel_tso show <port_id> "
5173 		"Show TSO segment size of tunneled packets for csum engine",
5174 	.tokens = {
5175 		(void *)&cmd_tunnel_tso_set_tso,
5176 		(void *)&cmd_tunnel_tso_show_mode,
5177 		(void *)&cmd_tunnel_tso_set_portid,
5178 		NULL,
5179 	},
5180 };
5181 
5182 #ifdef RTE_LIB_GRO
5183 /* *** SET GRO FOR A PORT *** */
5184 struct cmd_gro_enable_result {
5185 	cmdline_fixed_string_t cmd_set;
5186 	cmdline_fixed_string_t cmd_port;
5187 	cmdline_fixed_string_t cmd_keyword;
5188 	cmdline_fixed_string_t cmd_onoff;
5189 	portid_t cmd_pid;
5190 };
5191 
5192 static void
5193 cmd_gro_enable_parsed(void *parsed_result,
5194 		__rte_unused struct cmdline *cl,
5195 		__rte_unused void *data)
5196 {
5197 	struct cmd_gro_enable_result *res;
5198 
5199 	res = parsed_result;
5200 	if (!strcmp(res->cmd_keyword, "gro"))
5201 		setup_gro(res->cmd_onoff, res->cmd_pid);
5202 }
5203 
5204 static cmdline_parse_token_string_t cmd_gro_enable_set =
5205 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5206 			cmd_set, "set");
5207 static cmdline_parse_token_string_t cmd_gro_enable_port =
5208 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5209 			cmd_keyword, "port");
5210 static cmdline_parse_token_num_t cmd_gro_enable_pid =
5211 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5212 			cmd_pid, RTE_UINT16);
5213 static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5214 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5215 			cmd_keyword, "gro");
5216 static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5217 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5218 			cmd_onoff, "on#off");
5219 
5220 static cmdline_parse_inst_t cmd_gro_enable = {
5221 	.f = cmd_gro_enable_parsed,
5222 	.data = NULL,
5223 	.help_str = "set port <port_id> gro on|off",
5224 	.tokens = {
5225 		(void *)&cmd_gro_enable_set,
5226 		(void *)&cmd_gro_enable_port,
5227 		(void *)&cmd_gro_enable_pid,
5228 		(void *)&cmd_gro_enable_keyword,
5229 		(void *)&cmd_gro_enable_onoff,
5230 		NULL,
5231 	},
5232 };
5233 
5234 /* *** DISPLAY GRO CONFIGURATION *** */
5235 struct cmd_gro_show_result {
5236 	cmdline_fixed_string_t cmd_show;
5237 	cmdline_fixed_string_t cmd_port;
5238 	cmdline_fixed_string_t cmd_keyword;
5239 	portid_t cmd_pid;
5240 };
5241 
5242 static void
5243 cmd_gro_show_parsed(void *parsed_result,
5244 		__rte_unused struct cmdline *cl,
5245 		__rte_unused void *data)
5246 {
5247 	struct cmd_gro_show_result *res;
5248 
5249 	res = parsed_result;
5250 	if (!strcmp(res->cmd_keyword, "gro"))
5251 		show_gro(res->cmd_pid);
5252 }
5253 
5254 static cmdline_parse_token_string_t cmd_gro_show_show =
5255 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5256 			cmd_show, "show");
5257 static cmdline_parse_token_string_t cmd_gro_show_port =
5258 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5259 			cmd_port, "port");
5260 static cmdline_parse_token_num_t cmd_gro_show_pid =
5261 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5262 			cmd_pid, RTE_UINT16);
5263 static cmdline_parse_token_string_t cmd_gro_show_keyword =
5264 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5265 			cmd_keyword, "gro");
5266 
5267 static cmdline_parse_inst_t cmd_gro_show = {
5268 	.f = cmd_gro_show_parsed,
5269 	.data = NULL,
5270 	.help_str = "show port <port_id> gro",
5271 	.tokens = {
5272 		(void *)&cmd_gro_show_show,
5273 		(void *)&cmd_gro_show_port,
5274 		(void *)&cmd_gro_show_pid,
5275 		(void *)&cmd_gro_show_keyword,
5276 		NULL,
5277 	},
5278 };
5279 
5280 /* *** SET FLUSH CYCLES FOR GRO *** */
5281 struct cmd_gro_flush_result {
5282 	cmdline_fixed_string_t cmd_set;
5283 	cmdline_fixed_string_t cmd_keyword;
5284 	cmdline_fixed_string_t cmd_flush;
5285 	uint8_t cmd_cycles;
5286 };
5287 
5288 static void
5289 cmd_gro_flush_parsed(void *parsed_result,
5290 		__rte_unused struct cmdline *cl,
5291 		__rte_unused void *data)
5292 {
5293 	struct cmd_gro_flush_result *res;
5294 
5295 	res = parsed_result;
5296 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5297 			(!strcmp(res->cmd_flush, "flush")))
5298 		setup_gro_flush_cycles(res->cmd_cycles);
5299 }
5300 
5301 static cmdline_parse_token_string_t cmd_gro_flush_set =
5302 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5303 			cmd_set, "set");
5304 static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5305 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5306 			cmd_keyword, "gro");
5307 static cmdline_parse_token_string_t cmd_gro_flush_flush =
5308 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5309 			cmd_flush, "flush");
5310 static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5311 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5312 			cmd_cycles, RTE_UINT8);
5313 
5314 static cmdline_parse_inst_t cmd_gro_flush = {
5315 	.f = cmd_gro_flush_parsed,
5316 	.data = NULL,
5317 	.help_str = "set gro flush <cycles>",
5318 	.tokens = {
5319 		(void *)&cmd_gro_flush_set,
5320 		(void *)&cmd_gro_flush_keyword,
5321 		(void *)&cmd_gro_flush_flush,
5322 		(void *)&cmd_gro_flush_cycles,
5323 		NULL,
5324 	},
5325 };
5326 #endif /* RTE_LIB_GRO */
5327 
5328 #ifdef RTE_LIB_GSO
5329 /* *** ENABLE/DISABLE GSO *** */
5330 struct cmd_gso_enable_result {
5331 	cmdline_fixed_string_t cmd_set;
5332 	cmdline_fixed_string_t cmd_port;
5333 	cmdline_fixed_string_t cmd_keyword;
5334 	cmdline_fixed_string_t cmd_mode;
5335 	portid_t cmd_pid;
5336 };
5337 
5338 static void
5339 cmd_gso_enable_parsed(void *parsed_result,
5340 		__rte_unused struct cmdline *cl,
5341 		__rte_unused void *data)
5342 {
5343 	struct cmd_gso_enable_result *res;
5344 
5345 	res = parsed_result;
5346 	if (!strcmp(res->cmd_keyword, "gso"))
5347 		setup_gso(res->cmd_mode, res->cmd_pid);
5348 }
5349 
5350 static cmdline_parse_token_string_t cmd_gso_enable_set =
5351 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5352 			cmd_set, "set");
5353 static cmdline_parse_token_string_t cmd_gso_enable_port =
5354 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5355 			cmd_port, "port");
5356 static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5357 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5358 			cmd_keyword, "gso");
5359 static cmdline_parse_token_string_t cmd_gso_enable_mode =
5360 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5361 			cmd_mode, "on#off");
5362 static cmdline_parse_token_num_t cmd_gso_enable_pid =
5363 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5364 			cmd_pid, RTE_UINT16);
5365 
5366 static cmdline_parse_inst_t cmd_gso_enable = {
5367 	.f = cmd_gso_enable_parsed,
5368 	.data = NULL,
5369 	.help_str = "set port <port_id> gso on|off",
5370 	.tokens = {
5371 		(void *)&cmd_gso_enable_set,
5372 		(void *)&cmd_gso_enable_port,
5373 		(void *)&cmd_gso_enable_pid,
5374 		(void *)&cmd_gso_enable_keyword,
5375 		(void *)&cmd_gso_enable_mode,
5376 		NULL,
5377 	},
5378 };
5379 
5380 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5381 struct cmd_gso_size_result {
5382 	cmdline_fixed_string_t cmd_set;
5383 	cmdline_fixed_string_t cmd_keyword;
5384 	cmdline_fixed_string_t cmd_segsz;
5385 	uint16_t cmd_size;
5386 };
5387 
5388 static void
5389 cmd_gso_size_parsed(void *parsed_result,
5390 		       __rte_unused struct cmdline *cl,
5391 		       __rte_unused void *data)
5392 {
5393 	struct cmd_gso_size_result *res = parsed_result;
5394 
5395 	if (test_done == 0) {
5396 		fprintf(stderr,
5397 			"Before setting GSO segsz, please first stop forwarding\n");
5398 		return;
5399 	}
5400 
5401 	if (!strcmp(res->cmd_keyword, "gso") &&
5402 			!strcmp(res->cmd_segsz, "segsz")) {
5403 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5404 			fprintf(stderr,
5405 				"gso_size should be larger than %zu. Please input a legal value\n",
5406 				RTE_GSO_SEG_SIZE_MIN);
5407 		else
5408 			gso_max_segment_size = res->cmd_size;
5409 	}
5410 }
5411 
5412 static cmdline_parse_token_string_t cmd_gso_size_set =
5413 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5414 				cmd_set, "set");
5415 static cmdline_parse_token_string_t cmd_gso_size_keyword =
5416 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5417 				cmd_keyword, "gso");
5418 static cmdline_parse_token_string_t cmd_gso_size_segsz =
5419 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5420 				cmd_segsz, "segsz");
5421 static cmdline_parse_token_num_t cmd_gso_size_size =
5422 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5423 				cmd_size, RTE_UINT16);
5424 
5425 static cmdline_parse_inst_t cmd_gso_size = {
5426 	.f = cmd_gso_size_parsed,
5427 	.data = NULL,
5428 	.help_str = "set gso segsz <length>",
5429 	.tokens = {
5430 		(void *)&cmd_gso_size_set,
5431 		(void *)&cmd_gso_size_keyword,
5432 		(void *)&cmd_gso_size_segsz,
5433 		(void *)&cmd_gso_size_size,
5434 		NULL,
5435 	},
5436 };
5437 
5438 /* *** SHOW GSO CONFIGURATION *** */
5439 struct cmd_gso_show_result {
5440 	cmdline_fixed_string_t cmd_show;
5441 	cmdline_fixed_string_t cmd_port;
5442 	cmdline_fixed_string_t cmd_keyword;
5443 	portid_t cmd_pid;
5444 };
5445 
5446 static void
5447 cmd_gso_show_parsed(void *parsed_result,
5448 		       __rte_unused struct cmdline *cl,
5449 		       __rte_unused void *data)
5450 {
5451 	struct cmd_gso_show_result *res = parsed_result;
5452 
5453 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5454 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5455 		return;
5456 	}
5457 	if (!strcmp(res->cmd_keyword, "gso")) {
5458 		if (gso_ports[res->cmd_pid].enable) {
5459 			printf("Max GSO'd packet size: %uB\n"
5460 					"Supported GSO types: TCP/IPv4, "
5461 					"UDP/IPv4, VxLAN with inner "
5462 					"TCP/IPv4 packet, GRE with inner "
5463 					"TCP/IPv4 packet\n",
5464 					gso_max_segment_size);
5465 		} else
5466 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5467 	}
5468 }
5469 
5470 static cmdline_parse_token_string_t cmd_gso_show_show =
5471 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5472 		cmd_show, "show");
5473 static cmdline_parse_token_string_t cmd_gso_show_port =
5474 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5475 		cmd_port, "port");
5476 static cmdline_parse_token_string_t cmd_gso_show_keyword =
5477 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5478 				cmd_keyword, "gso");
5479 static cmdline_parse_token_num_t cmd_gso_show_pid =
5480 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5481 				cmd_pid, RTE_UINT16);
5482 
5483 static cmdline_parse_inst_t cmd_gso_show = {
5484 	.f = cmd_gso_show_parsed,
5485 	.data = NULL,
5486 	.help_str = "show port <port_id> gso",
5487 	.tokens = {
5488 		(void *)&cmd_gso_show_show,
5489 		(void *)&cmd_gso_show_port,
5490 		(void *)&cmd_gso_show_pid,
5491 		(void *)&cmd_gso_show_keyword,
5492 		NULL,
5493 	},
5494 };
5495 #endif /* RTE_LIB_GSO */
5496 
5497 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5498 struct cmd_set_flush_rx {
5499 	cmdline_fixed_string_t set;
5500 	cmdline_fixed_string_t flush_rx;
5501 	cmdline_fixed_string_t mode;
5502 };
5503 
5504 static void
5505 cmd_set_flush_rx_parsed(void *parsed_result,
5506 		__rte_unused struct cmdline *cl,
5507 		__rte_unused void *data)
5508 {
5509 	struct cmd_set_flush_rx *res = parsed_result;
5510 
5511 	if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5512 		printf("multi-process doesn't support to flush Rx queues.\n");
5513 		return;
5514 	}
5515 
5516 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5517 }
5518 
5519 static cmdline_parse_token_string_t cmd_setflushrx_set =
5520 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5521 			set, "set");
5522 static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5523 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5524 			flush_rx, "flush_rx");
5525 static cmdline_parse_token_string_t cmd_setflushrx_mode =
5526 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5527 			mode, "on#off");
5528 
5529 
5530 static cmdline_parse_inst_t cmd_set_flush_rx = {
5531 	.f = cmd_set_flush_rx_parsed,
5532 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5533 	.data = NULL,
5534 	.tokens = {
5535 		(void *)&cmd_setflushrx_set,
5536 		(void *)&cmd_setflushrx_flush_rx,
5537 		(void *)&cmd_setflushrx_mode,
5538 		NULL,
5539 	},
5540 };
5541 
5542 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5543 struct cmd_set_link_check {
5544 	cmdline_fixed_string_t set;
5545 	cmdline_fixed_string_t link_check;
5546 	cmdline_fixed_string_t mode;
5547 };
5548 
5549 static void
5550 cmd_set_link_check_parsed(void *parsed_result,
5551 		__rte_unused struct cmdline *cl,
5552 		__rte_unused void *data)
5553 {
5554 	struct cmd_set_link_check *res = parsed_result;
5555 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5556 }
5557 
5558 static cmdline_parse_token_string_t cmd_setlinkcheck_set =
5559 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5560 			set, "set");
5561 static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5562 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5563 			link_check, "link_check");
5564 static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5565 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5566 			mode, "on#off");
5567 
5568 
5569 static cmdline_parse_inst_t cmd_set_link_check = {
5570 	.f = cmd_set_link_check_parsed,
5571 	.help_str = "set link_check on|off: Enable/Disable link status check "
5572 	            "when starting/stopping a port",
5573 	.data = NULL,
5574 	.tokens = {
5575 		(void *)&cmd_setlinkcheck_set,
5576 		(void *)&cmd_setlinkcheck_link_check,
5577 		(void *)&cmd_setlinkcheck_mode,
5578 		NULL,
5579 	},
5580 };
5581 
5582 /* *** SET FORWARDING MODE *** */
5583 struct cmd_set_fwd_mode_result {
5584 	cmdline_fixed_string_t set;
5585 	cmdline_fixed_string_t fwd;
5586 	cmdline_fixed_string_t mode;
5587 };
5588 
5589 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5590 				    __rte_unused struct cmdline *cl,
5591 				    __rte_unused void *data)
5592 {
5593 	struct cmd_set_fwd_mode_result *res = parsed_result;
5594 
5595 	retry_enabled = 0;
5596 	set_pkt_forwarding_mode(res->mode);
5597 }
5598 
5599 static cmdline_parse_token_string_t cmd_setfwd_set =
5600 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5601 static cmdline_parse_token_string_t cmd_setfwd_fwd =
5602 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5603 static cmdline_parse_token_string_t cmd_setfwd_mode =
5604 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5605 		"" /* defined at init */);
5606 
5607 static cmdline_parse_inst_t cmd_set_fwd_mode = {
5608 	.f = cmd_set_fwd_mode_parsed,
5609 	.data = NULL,
5610 	.help_str = NULL, /* defined at init */
5611 	.tokens = {
5612 		(void *)&cmd_setfwd_set,
5613 		(void *)&cmd_setfwd_fwd,
5614 		(void *)&cmd_setfwd_mode,
5615 		NULL,
5616 	},
5617 };
5618 
5619 static void cmd_set_fwd_mode_init(void)
5620 {
5621 	char *modes, *c;
5622 	static char token[128];
5623 	static char help[256];
5624 	cmdline_parse_token_string_t *token_struct;
5625 
5626 	modes = list_pkt_forwarding_modes();
5627 	snprintf(help, sizeof(help), "set fwd %s: "
5628 		"Set packet forwarding mode", modes);
5629 	cmd_set_fwd_mode.help_str = help;
5630 
5631 	/* string token separator is # */
5632 	for (c = token; *modes != '\0'; modes++)
5633 		if (*modes == '|')
5634 			*c++ = '#';
5635 		else
5636 			*c++ = *modes;
5637 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5638 	token_struct->string_data.str = token;
5639 }
5640 
5641 /* *** SET RETRY FORWARDING MODE *** */
5642 struct cmd_set_fwd_retry_mode_result {
5643 	cmdline_fixed_string_t set;
5644 	cmdline_fixed_string_t fwd;
5645 	cmdline_fixed_string_t mode;
5646 	cmdline_fixed_string_t retry;
5647 };
5648 
5649 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5650 			    __rte_unused struct cmdline *cl,
5651 			    __rte_unused void *data)
5652 {
5653 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5654 
5655 	retry_enabled = 1;
5656 	set_pkt_forwarding_mode(res->mode);
5657 }
5658 
5659 static cmdline_parse_token_string_t cmd_setfwd_retry_set =
5660 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5661 			set, "set");
5662 static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5663 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5664 			fwd, "fwd");
5665 static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5666 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5667 			mode,
5668 		"" /* defined at init */);
5669 static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5670 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5671 			retry, "retry");
5672 
5673 static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5674 	.f = cmd_set_fwd_retry_mode_parsed,
5675 	.data = NULL,
5676 	.help_str = NULL, /* defined at init */
5677 	.tokens = {
5678 		(void *)&cmd_setfwd_retry_set,
5679 		(void *)&cmd_setfwd_retry_fwd,
5680 		(void *)&cmd_setfwd_retry_mode,
5681 		(void *)&cmd_setfwd_retry_retry,
5682 		NULL,
5683 	},
5684 };
5685 
5686 static void cmd_set_fwd_retry_mode_init(void)
5687 {
5688 	char *modes, *c;
5689 	static char token[128];
5690 	static char help[256];
5691 	cmdline_parse_token_string_t *token_struct;
5692 
5693 	modes = list_pkt_forwarding_retry_modes();
5694 	snprintf(help, sizeof(help), "set fwd %s retry: "
5695 		"Set packet forwarding mode with retry", modes);
5696 	cmd_set_fwd_retry_mode.help_str = help;
5697 
5698 	/* string token separator is # */
5699 	for (c = token; *modes != '\0'; modes++)
5700 		if (*modes == '|')
5701 			*c++ = '#';
5702 		else
5703 			*c++ = *modes;
5704 	token_struct = (cmdline_parse_token_string_t *)
5705 		cmd_set_fwd_retry_mode.tokens[2];
5706 	token_struct->string_data.str = token;
5707 }
5708 
5709 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5710 struct cmd_set_burst_tx_retry_result {
5711 	cmdline_fixed_string_t set;
5712 	cmdline_fixed_string_t burst;
5713 	cmdline_fixed_string_t tx;
5714 	cmdline_fixed_string_t delay;
5715 	uint32_t time;
5716 	cmdline_fixed_string_t retry;
5717 	uint32_t retry_num;
5718 };
5719 
5720 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5721 					__rte_unused struct cmdline *cl,
5722 					__rte_unused void *data)
5723 {
5724 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
5725 
5726 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5727 		&& !strcmp(res->tx, "tx")) {
5728 		if (!strcmp(res->delay, "delay"))
5729 			burst_tx_delay_time = res->time;
5730 		if (!strcmp(res->retry, "retry"))
5731 			burst_tx_retry_num = res->retry_num;
5732 	}
5733 
5734 }
5735 
5736 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5737 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5738 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5739 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5740 				 "burst");
5741 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5742 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5743 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5744 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5745 static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5746 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
5747 				 RTE_UINT32);
5748 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5749 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5750 static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5751 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
5752 				 RTE_UINT32);
5753 
5754 static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5755 	.f = cmd_set_burst_tx_retry_parsed,
5756 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5757 	.tokens = {
5758 		(void *)&cmd_set_burst_tx_retry_set,
5759 		(void *)&cmd_set_burst_tx_retry_burst,
5760 		(void *)&cmd_set_burst_tx_retry_tx,
5761 		(void *)&cmd_set_burst_tx_retry_delay,
5762 		(void *)&cmd_set_burst_tx_retry_time,
5763 		(void *)&cmd_set_burst_tx_retry_retry,
5764 		(void *)&cmd_set_burst_tx_retry_retry_num,
5765 		NULL,
5766 	},
5767 };
5768 
5769 /* *** SET PROMISC MODE *** */
5770 struct cmd_set_promisc_mode_result {
5771 	cmdline_fixed_string_t set;
5772 	cmdline_fixed_string_t promisc;
5773 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5774 	uint16_t port_num;               /* valid if "allports" argument == 0 */
5775 	cmdline_fixed_string_t mode;
5776 };
5777 
5778 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5779 					__rte_unused struct cmdline *cl,
5780 					void *allports)
5781 {
5782 	struct cmd_set_promisc_mode_result *res = parsed_result;
5783 	int enable;
5784 	portid_t i;
5785 
5786 	if (!strcmp(res->mode, "on"))
5787 		enable = 1;
5788 	else
5789 		enable = 0;
5790 
5791 	/* all ports */
5792 	if (allports) {
5793 		RTE_ETH_FOREACH_DEV(i)
5794 			eth_set_promisc_mode(i, enable);
5795 	} else {
5796 		eth_set_promisc_mode(res->port_num, enable);
5797 	}
5798 }
5799 
5800 static cmdline_parse_token_string_t cmd_setpromisc_set =
5801 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5802 static cmdline_parse_token_string_t cmd_setpromisc_promisc =
5803 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5804 				 "promisc");
5805 static cmdline_parse_token_string_t cmd_setpromisc_portall =
5806 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5807 				 "all");
5808 static cmdline_parse_token_num_t cmd_setpromisc_portnum =
5809 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5810 			      RTE_UINT16);
5811 static cmdline_parse_token_string_t cmd_setpromisc_mode =
5812 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5813 				 "on#off");
5814 
5815 static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5816 	.f = cmd_set_promisc_mode_parsed,
5817 	.data = (void *)1,
5818 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
5819 	.tokens = {
5820 		(void *)&cmd_setpromisc_set,
5821 		(void *)&cmd_setpromisc_promisc,
5822 		(void *)&cmd_setpromisc_portall,
5823 		(void *)&cmd_setpromisc_mode,
5824 		NULL,
5825 	},
5826 };
5827 
5828 static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5829 	.f = cmd_set_promisc_mode_parsed,
5830 	.data = (void *)0,
5831 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5832 	.tokens = {
5833 		(void *)&cmd_setpromisc_set,
5834 		(void *)&cmd_setpromisc_promisc,
5835 		(void *)&cmd_setpromisc_portnum,
5836 		(void *)&cmd_setpromisc_mode,
5837 		NULL,
5838 	},
5839 };
5840 
5841 /* *** SET ALLMULTI MODE *** */
5842 struct cmd_set_allmulti_mode_result {
5843 	cmdline_fixed_string_t set;
5844 	cmdline_fixed_string_t allmulti;
5845 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5846 	uint16_t port_num;               /* valid if "allports" argument == 0 */
5847 	cmdline_fixed_string_t mode;
5848 };
5849 
5850 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5851 					__rte_unused struct cmdline *cl,
5852 					void *allports)
5853 {
5854 	struct cmd_set_allmulti_mode_result *res = parsed_result;
5855 	int enable;
5856 	portid_t i;
5857 
5858 	if (!strcmp(res->mode, "on"))
5859 		enable = 1;
5860 	else
5861 		enable = 0;
5862 
5863 	/* all ports */
5864 	if (allports) {
5865 		RTE_ETH_FOREACH_DEV(i) {
5866 			eth_set_allmulticast_mode(i, enable);
5867 		}
5868 	}
5869 	else {
5870 		eth_set_allmulticast_mode(res->port_num, enable);
5871 	}
5872 }
5873 
5874 static cmdline_parse_token_string_t cmd_setallmulti_set =
5875 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5876 static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5877 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5878 				 "allmulti");
5879 static cmdline_parse_token_string_t cmd_setallmulti_portall =
5880 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5881 				 "all");
5882 static cmdline_parse_token_num_t cmd_setallmulti_portnum =
5883 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5884 			      RTE_UINT16);
5885 static cmdline_parse_token_string_t cmd_setallmulti_mode =
5886 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5887 				 "on#off");
5888 
5889 static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5890 	.f = cmd_set_allmulti_mode_parsed,
5891 	.data = (void *)1,
5892 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5893 	.tokens = {
5894 		(void *)&cmd_setallmulti_set,
5895 		(void *)&cmd_setallmulti_allmulti,
5896 		(void *)&cmd_setallmulti_portall,
5897 		(void *)&cmd_setallmulti_mode,
5898 		NULL,
5899 	},
5900 };
5901 
5902 static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5903 	.f = cmd_set_allmulti_mode_parsed,
5904 	.data = (void *)0,
5905 	.help_str = "set allmulti <port_id> on|off: "
5906 		"Set allmulti mode on port_id",
5907 	.tokens = {
5908 		(void *)&cmd_setallmulti_set,
5909 		(void *)&cmd_setallmulti_allmulti,
5910 		(void *)&cmd_setallmulti_portnum,
5911 		(void *)&cmd_setallmulti_mode,
5912 		NULL,
5913 	},
5914 };
5915 
5916 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
5917 struct cmd_link_flow_ctrl_show {
5918 	cmdline_fixed_string_t show;
5919 	cmdline_fixed_string_t port;
5920 	portid_t port_id;
5921 	cmdline_fixed_string_t flow_ctrl;
5922 };
5923 
5924 static cmdline_parse_token_string_t cmd_lfc_show_show =
5925 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
5926 				show, "show");
5927 static cmdline_parse_token_string_t cmd_lfc_show_port =
5928 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
5929 				port, "port");
5930 static cmdline_parse_token_num_t cmd_lfc_show_portid =
5931 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
5932 				port_id, RTE_UINT16);
5933 static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
5934 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
5935 				flow_ctrl, "flow_ctrl");
5936 
5937 static void
5938 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
5939 			      __rte_unused struct cmdline *cl,
5940 			      __rte_unused void *data)
5941 {
5942 	struct cmd_link_flow_ctrl_show *res = parsed_result;
5943 	static const char *info_border = "*********************";
5944 	struct rte_eth_fc_conf fc_conf;
5945 	bool rx_fc_en = false;
5946 	bool tx_fc_en = false;
5947 	int ret;
5948 
5949 	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5950 	if (ret != 0) {
5951 		fprintf(stderr,
5952 			"Failed to get current flow ctrl information: err = %d\n",
5953 			ret);
5954 		return;
5955 	}
5956 
5957 	if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
5958 		rx_fc_en = true;
5959 	if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
5960 		tx_fc_en = true;
5961 
5962 	printf("\n%s Flow control infos for port %-2d %s\n",
5963 		info_border, res->port_id, info_border);
5964 	printf("FC mode:\n");
5965 	printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
5966 	printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
5967 	printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
5968 	printf("Pause time: 0x%x\n", fc_conf.pause_time);
5969 	printf("High waterline: 0x%x\n", fc_conf.high_water);
5970 	printf("Low waterline: 0x%x\n", fc_conf.low_water);
5971 	printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
5972 	printf("Forward MAC control frames: %s\n",
5973 		fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
5974 	printf("\n%s**************   End  ***********%s\n",
5975 		info_border, info_border);
5976 }
5977 
5978 static cmdline_parse_inst_t cmd_link_flow_control_show = {
5979 	.f = cmd_link_flow_ctrl_show_parsed,
5980 	.data = NULL,
5981 	.help_str = "show port <port_id> flow_ctrl",
5982 	.tokens = {
5983 		(void *)&cmd_lfc_show_show,
5984 		(void *)&cmd_lfc_show_port,
5985 		(void *)&cmd_lfc_show_portid,
5986 		(void *)&cmd_lfc_show_flow_ctrl,
5987 		NULL,
5988 	},
5989 };
5990 
5991 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5992 struct cmd_link_flow_ctrl_set_result {
5993 	cmdline_fixed_string_t set;
5994 	cmdline_fixed_string_t flow_ctrl;
5995 	cmdline_fixed_string_t rx;
5996 	cmdline_fixed_string_t rx_lfc_mode;
5997 	cmdline_fixed_string_t tx;
5998 	cmdline_fixed_string_t tx_lfc_mode;
5999 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6000 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6001 	cmdline_fixed_string_t autoneg_str;
6002 	cmdline_fixed_string_t autoneg;
6003 	cmdline_fixed_string_t hw_str;
6004 	uint32_t high_water;
6005 	cmdline_fixed_string_t lw_str;
6006 	uint32_t low_water;
6007 	cmdline_fixed_string_t pt_str;
6008 	uint16_t pause_time;
6009 	cmdline_fixed_string_t xon_str;
6010 	uint16_t send_xon;
6011 	portid_t port_id;
6012 };
6013 
6014 static cmdline_parse_token_string_t cmd_lfc_set_set =
6015 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6016 				set, "set");
6017 static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6018 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6019 				flow_ctrl, "flow_ctrl");
6020 static cmdline_parse_token_string_t cmd_lfc_set_rx =
6021 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6022 				rx, "rx");
6023 static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6024 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6025 				rx_lfc_mode, "on#off");
6026 static cmdline_parse_token_string_t cmd_lfc_set_tx =
6027 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6028 				tx, "tx");
6029 static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6030 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6031 				tx_lfc_mode, "on#off");
6032 static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6033 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6034 				hw_str, "high_water");
6035 static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6036 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6037 				high_water, RTE_UINT32);
6038 static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6039 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6040 				lw_str, "low_water");
6041 static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6042 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6043 				low_water, RTE_UINT32);
6044 static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6045 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6046 				pt_str, "pause_time");
6047 static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6048 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6049 				pause_time, RTE_UINT16);
6050 static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6051 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6052 				xon_str, "send_xon");
6053 static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6054 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6055 				send_xon, RTE_UINT16);
6056 static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6057 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6058 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6059 static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6060 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6061 				mac_ctrl_frame_fwd_mode, "on#off");
6062 static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6063 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6064 				autoneg_str, "autoneg");
6065 static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6066 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6067 				autoneg, "on#off");
6068 static cmdline_parse_token_num_t cmd_lfc_set_portid =
6069 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6070 				port_id, RTE_UINT16);
6071 
6072 /* forward declaration */
6073 static void
6074 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6075 			      void *data);
6076 
6077 static cmdline_parse_inst_t cmd_link_flow_control_set = {
6078 	.f = cmd_link_flow_ctrl_set_parsed,
6079 	.data = NULL,
6080 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6081 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6082 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6083 	.tokens = {
6084 		(void *)&cmd_lfc_set_set,
6085 		(void *)&cmd_lfc_set_flow_ctrl,
6086 		(void *)&cmd_lfc_set_rx,
6087 		(void *)&cmd_lfc_set_rx_mode,
6088 		(void *)&cmd_lfc_set_tx,
6089 		(void *)&cmd_lfc_set_tx_mode,
6090 		(void *)&cmd_lfc_set_high_water,
6091 		(void *)&cmd_lfc_set_low_water,
6092 		(void *)&cmd_lfc_set_pause_time,
6093 		(void *)&cmd_lfc_set_send_xon,
6094 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6095 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6096 		(void *)&cmd_lfc_set_autoneg_str,
6097 		(void *)&cmd_lfc_set_autoneg,
6098 		(void *)&cmd_lfc_set_portid,
6099 		NULL,
6100 	},
6101 };
6102 
6103 static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6104 	.f = cmd_link_flow_ctrl_set_parsed,
6105 	.data = (void *)&cmd_link_flow_control_set_rx,
6106 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6107 		"Change rx flow control parameter",
6108 	.tokens = {
6109 		(void *)&cmd_lfc_set_set,
6110 		(void *)&cmd_lfc_set_flow_ctrl,
6111 		(void *)&cmd_lfc_set_rx,
6112 		(void *)&cmd_lfc_set_rx_mode,
6113 		(void *)&cmd_lfc_set_portid,
6114 		NULL,
6115 	},
6116 };
6117 
6118 static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6119 	.f = cmd_link_flow_ctrl_set_parsed,
6120 	.data = (void *)&cmd_link_flow_control_set_tx,
6121 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6122 		"Change tx flow control parameter",
6123 	.tokens = {
6124 		(void *)&cmd_lfc_set_set,
6125 		(void *)&cmd_lfc_set_flow_ctrl,
6126 		(void *)&cmd_lfc_set_tx,
6127 		(void *)&cmd_lfc_set_tx_mode,
6128 		(void *)&cmd_lfc_set_portid,
6129 		NULL,
6130 	},
6131 };
6132 
6133 static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6134 	.f = cmd_link_flow_ctrl_set_parsed,
6135 	.data = (void *)&cmd_link_flow_control_set_hw,
6136 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6137 		"Change high water flow control parameter",
6138 	.tokens = {
6139 		(void *)&cmd_lfc_set_set,
6140 		(void *)&cmd_lfc_set_flow_ctrl,
6141 		(void *)&cmd_lfc_set_high_water_str,
6142 		(void *)&cmd_lfc_set_high_water,
6143 		(void *)&cmd_lfc_set_portid,
6144 		NULL,
6145 	},
6146 };
6147 
6148 static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6149 	.f = cmd_link_flow_ctrl_set_parsed,
6150 	.data = (void *)&cmd_link_flow_control_set_lw,
6151 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
6152 		"Change low water flow control parameter",
6153 	.tokens = {
6154 		(void *)&cmd_lfc_set_set,
6155 		(void *)&cmd_lfc_set_flow_ctrl,
6156 		(void *)&cmd_lfc_set_low_water_str,
6157 		(void *)&cmd_lfc_set_low_water,
6158 		(void *)&cmd_lfc_set_portid,
6159 		NULL,
6160 	},
6161 };
6162 
6163 static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6164 	.f = cmd_link_flow_ctrl_set_parsed,
6165 	.data = (void *)&cmd_link_flow_control_set_pt,
6166 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
6167 		"Change pause time flow control parameter",
6168 	.tokens = {
6169 		(void *)&cmd_lfc_set_set,
6170 		(void *)&cmd_lfc_set_flow_ctrl,
6171 		(void *)&cmd_lfc_set_pause_time_str,
6172 		(void *)&cmd_lfc_set_pause_time,
6173 		(void *)&cmd_lfc_set_portid,
6174 		NULL,
6175 	},
6176 };
6177 
6178 static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6179 	.f = cmd_link_flow_ctrl_set_parsed,
6180 	.data = (void *)&cmd_link_flow_control_set_xon,
6181 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
6182 		"Change send_xon flow control parameter",
6183 	.tokens = {
6184 		(void *)&cmd_lfc_set_set,
6185 		(void *)&cmd_lfc_set_flow_ctrl,
6186 		(void *)&cmd_lfc_set_send_xon_str,
6187 		(void *)&cmd_lfc_set_send_xon,
6188 		(void *)&cmd_lfc_set_portid,
6189 		NULL,
6190 	},
6191 };
6192 
6193 static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6194 	.f = cmd_link_flow_ctrl_set_parsed,
6195 	.data = (void *)&cmd_link_flow_control_set_macfwd,
6196 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6197 		"Change mac ctrl fwd flow control parameter",
6198 	.tokens = {
6199 		(void *)&cmd_lfc_set_set,
6200 		(void *)&cmd_lfc_set_flow_ctrl,
6201 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6202 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6203 		(void *)&cmd_lfc_set_portid,
6204 		NULL,
6205 	},
6206 };
6207 
6208 static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6209 	.f = cmd_link_flow_ctrl_set_parsed,
6210 	.data = (void *)&cmd_link_flow_control_set_autoneg,
6211 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
6212 		"Change autoneg flow control parameter",
6213 	.tokens = {
6214 		(void *)&cmd_lfc_set_set,
6215 		(void *)&cmd_lfc_set_flow_ctrl,
6216 		(void *)&cmd_lfc_set_autoneg_str,
6217 		(void *)&cmd_lfc_set_autoneg,
6218 		(void *)&cmd_lfc_set_portid,
6219 		NULL,
6220 	},
6221 };
6222 
6223 static void
6224 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6225 			      __rte_unused struct cmdline *cl,
6226 			      void *data)
6227 {
6228 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6229 	cmdline_parse_inst_t *cmd = data;
6230 	struct rte_eth_fc_conf fc_conf;
6231 	int rx_fc_en = 0;
6232 	int tx_fc_en = 0;
6233 	int ret;
6234 
6235 	/*
6236 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6237 	 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6238 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6239 	 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6240 	 */
6241 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6242 			{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6243 	};
6244 
6245 	/* Partial command line, retrieve current configuration */
6246 	if (cmd) {
6247 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6248 		if (ret != 0) {
6249 			fprintf(stderr,
6250 				"cannot get current flow ctrl parameters, return code = %d\n",
6251 				ret);
6252 			return;
6253 		}
6254 
6255 		if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6256 		    (fc_conf.mode == RTE_ETH_FC_FULL))
6257 			rx_fc_en = 1;
6258 		if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6259 		    (fc_conf.mode == RTE_ETH_FC_FULL))
6260 			tx_fc_en = 1;
6261 	}
6262 
6263 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6264 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6265 
6266 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6267 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6268 
6269 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6270 
6271 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6272 		fc_conf.high_water = res->high_water;
6273 
6274 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6275 		fc_conf.low_water = res->low_water;
6276 
6277 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6278 		fc_conf.pause_time = res->pause_time;
6279 
6280 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6281 		fc_conf.send_xon = res->send_xon;
6282 
6283 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6284 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6285 			fc_conf.mac_ctrl_frame_fwd = 1;
6286 		else
6287 			fc_conf.mac_ctrl_frame_fwd = 0;
6288 	}
6289 
6290 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6291 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6292 
6293 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6294 	if (ret != 0)
6295 		fprintf(stderr,
6296 			"bad flow control parameter, return code = %d\n",
6297 			ret);
6298 }
6299 
6300 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6301 struct cmd_priority_flow_ctrl_set_result {
6302 	cmdline_fixed_string_t set;
6303 	cmdline_fixed_string_t pfc_ctrl;
6304 	cmdline_fixed_string_t rx;
6305 	cmdline_fixed_string_t rx_pfc_mode;
6306 	cmdline_fixed_string_t tx;
6307 	cmdline_fixed_string_t tx_pfc_mode;
6308 	uint32_t high_water;
6309 	uint32_t low_water;
6310 	uint16_t pause_time;
6311 	uint8_t  priority;
6312 	portid_t port_id;
6313 };
6314 
6315 static void
6316 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6317 		       __rte_unused struct cmdline *cl,
6318 		       __rte_unused void *data)
6319 {
6320 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6321 	struct rte_eth_pfc_conf pfc_conf;
6322 	int rx_fc_enable, tx_fc_enable;
6323 	int ret;
6324 
6325 	/*
6326 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6327 	 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6328 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6329 	 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6330 	 */
6331 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6332 		{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6333 	};
6334 
6335 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6336 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6337 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6338 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6339 	pfc_conf.fc.high_water = res->high_water;
6340 	pfc_conf.fc.low_water  = res->low_water;
6341 	pfc_conf.fc.pause_time = res->pause_time;
6342 	pfc_conf.priority      = res->priority;
6343 
6344 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6345 	if (ret != 0)
6346 		fprintf(stderr,
6347 			"bad priority flow control parameter, return code = %d\n",
6348 			ret);
6349 }
6350 
6351 static cmdline_parse_token_string_t cmd_pfc_set_set =
6352 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6353 				set, "set");
6354 static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6355 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6356 				pfc_ctrl, "pfc_ctrl");
6357 static cmdline_parse_token_string_t cmd_pfc_set_rx =
6358 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6359 				rx, "rx");
6360 static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6361 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6362 				rx_pfc_mode, "on#off");
6363 static cmdline_parse_token_string_t cmd_pfc_set_tx =
6364 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6365 				tx, "tx");
6366 static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6367 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6368 				tx_pfc_mode, "on#off");
6369 static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6370 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6371 				high_water, RTE_UINT32);
6372 static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6373 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6374 				low_water, RTE_UINT32);
6375 static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6376 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6377 				pause_time, RTE_UINT16);
6378 static cmdline_parse_token_num_t cmd_pfc_set_priority =
6379 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6380 				priority, RTE_UINT8);
6381 static cmdline_parse_token_num_t cmd_pfc_set_portid =
6382 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6383 				port_id, RTE_UINT16);
6384 
6385 static cmdline_parse_inst_t cmd_priority_flow_control_set = {
6386 	.f = cmd_priority_flow_ctrl_set_parsed,
6387 	.data = NULL,
6388 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6389 		"<pause_time> <priority> <port_id>: "
6390 		"Configure the Ethernet priority flow control",
6391 	.tokens = {
6392 		(void *)&cmd_pfc_set_set,
6393 		(void *)&cmd_pfc_set_flow_ctrl,
6394 		(void *)&cmd_pfc_set_rx,
6395 		(void *)&cmd_pfc_set_rx_mode,
6396 		(void *)&cmd_pfc_set_tx,
6397 		(void *)&cmd_pfc_set_tx_mode,
6398 		(void *)&cmd_pfc_set_high_water,
6399 		(void *)&cmd_pfc_set_low_water,
6400 		(void *)&cmd_pfc_set_pause_time,
6401 		(void *)&cmd_pfc_set_priority,
6402 		(void *)&cmd_pfc_set_portid,
6403 		NULL,
6404 	},
6405 };
6406 
6407 struct cmd_queue_priority_flow_ctrl_set_result {
6408 	cmdline_fixed_string_t set;
6409 	cmdline_fixed_string_t pfc_queue_ctrl;
6410 	portid_t port_id;
6411 	cmdline_fixed_string_t rx;
6412 	cmdline_fixed_string_t rx_pfc_mode;
6413 	uint16_t tx_qid;
6414 	uint8_t  tx_tc;
6415 	cmdline_fixed_string_t tx;
6416 	cmdline_fixed_string_t tx_pfc_mode;
6417 	uint16_t rx_qid;
6418 	uint8_t  rx_tc;
6419 	uint16_t pause_time;
6420 };
6421 
6422 static void
6423 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
6424 					__rte_unused struct cmdline *cl,
6425 					__rte_unused void *data)
6426 {
6427 	struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
6428 	struct rte_eth_pfc_queue_conf pfc_queue_conf;
6429 	int rx_fc_enable, tx_fc_enable;
6430 	int ret;
6431 
6432 	/*
6433 	 * Rx on/off, flow control is enabled/disabled on RX side. This can
6434 	 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
6435 	 * side. Tx on/off, flow control is enabled/disabled on TX side. This
6436 	 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
6437 	 * the Tx side.
6438 	 */
6439 	static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
6440 		{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
6441 		{RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6442 	};
6443 
6444 	memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
6445 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
6446 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
6447 	pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
6448 	pfc_queue_conf.rx_pause.tc  = res->tx_tc;
6449 	pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
6450 	pfc_queue_conf.tx_pause.tc  = res->rx_tc;
6451 	pfc_queue_conf.tx_pause.rx_qid  = res->rx_qid;
6452 	pfc_queue_conf.tx_pause.pause_time = res->pause_time;
6453 
6454 	ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
6455 							     &pfc_queue_conf);
6456 	if (ret != 0) {
6457 		fprintf(stderr,
6458 			"bad queue priority flow control parameter, rc = %d\n",
6459 			ret);
6460 	}
6461 }
6462 
6463 static cmdline_parse_token_string_t cmd_q_pfc_set_set =
6464 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6465 				set, "set");
6466 static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
6467 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6468 				pfc_queue_ctrl, "pfc_queue_ctrl");
6469 static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
6470 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6471 				port_id, RTE_UINT16);
6472 static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
6473 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6474 				rx, "rx");
6475 static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
6476 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6477 				rx_pfc_mode, "on#off");
6478 static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
6479 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6480 				tx_qid, RTE_UINT16);
6481 static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
6482 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6483 				tx_tc, RTE_UINT8);
6484 static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
6485 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6486 				tx, "tx");
6487 static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
6488 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6489 				tx_pfc_mode, "on#off");
6490 static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
6491 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6492 				rx_qid, RTE_UINT16);
6493 static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
6494 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6495 				rx_tc, RTE_UINT8);
6496 static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
6497 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6498 				pause_time, RTE_UINT16);
6499 
6500 static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
6501 	.f = cmd_queue_priority_flow_ctrl_set_parsed,
6502 	.data = NULL,
6503 	.help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
6504 		"tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
6505 		"Configure the Ethernet queue priority flow control",
6506 	.tokens = {
6507 		(void *)&cmd_q_pfc_set_set,
6508 		(void *)&cmd_q_pfc_set_flow_ctrl,
6509 		(void *)&cmd_q_pfc_set_portid,
6510 		(void *)&cmd_q_pfc_set_rx,
6511 		(void *)&cmd_q_pfc_set_rx_mode,
6512 		(void *)&cmd_q_pfc_set_tx_qid,
6513 		(void *)&cmd_q_pfc_set_tx_tc,
6514 		(void *)&cmd_q_pfc_set_tx,
6515 		(void *)&cmd_q_pfc_set_tx_mode,
6516 		(void *)&cmd_q_pfc_set_rx_qid,
6517 		(void *)&cmd_q_pfc_set_rx_tc,
6518 		(void *)&cmd_q_pfc_set_pause_time,
6519 		NULL,
6520 	},
6521 };
6522 
6523 /* *** RESET CONFIGURATION *** */
6524 struct cmd_reset_result {
6525 	cmdline_fixed_string_t reset;
6526 	cmdline_fixed_string_t def;
6527 };
6528 
6529 static void cmd_reset_parsed(__rte_unused void *parsed_result,
6530 			     struct cmdline *cl,
6531 			     __rte_unused void *data)
6532 {
6533 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6534 	set_def_fwd_config();
6535 }
6536 
6537 static cmdline_parse_token_string_t cmd_reset_set =
6538 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6539 static cmdline_parse_token_string_t cmd_reset_def =
6540 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6541 				 "default");
6542 
6543 static cmdline_parse_inst_t cmd_reset = {
6544 	.f = cmd_reset_parsed,
6545 	.data = NULL,
6546 	.help_str = "set default: Reset default forwarding configuration",
6547 	.tokens = {
6548 		(void *)&cmd_reset_set,
6549 		(void *)&cmd_reset_def,
6550 		NULL,
6551 	},
6552 };
6553 
6554 /* *** START FORWARDING *** */
6555 struct cmd_start_result {
6556 	cmdline_fixed_string_t start;
6557 };
6558 
6559 static cmdline_parse_token_string_t cmd_start_start =
6560 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6561 
6562 static void cmd_start_parsed(__rte_unused void *parsed_result,
6563 			     __rte_unused struct cmdline *cl,
6564 			     __rte_unused void *data)
6565 {
6566 	start_packet_forwarding(0);
6567 }
6568 
6569 static cmdline_parse_inst_t cmd_start = {
6570 	.f = cmd_start_parsed,
6571 	.data = NULL,
6572 	.help_str = "start: Start packet forwarding",
6573 	.tokens = {
6574 		(void *)&cmd_start_start,
6575 		NULL,
6576 	},
6577 };
6578 
6579 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6580 struct cmd_start_tx_first_result {
6581 	cmdline_fixed_string_t start;
6582 	cmdline_fixed_string_t tx_first;
6583 };
6584 
6585 static void
6586 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
6587 			  __rte_unused struct cmdline *cl,
6588 			  __rte_unused void *data)
6589 {
6590 	start_packet_forwarding(1);
6591 }
6592 
6593 static cmdline_parse_token_string_t cmd_start_tx_first_start =
6594 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6595 				 "start");
6596 static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6597 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6598 				 tx_first, "tx_first");
6599 
6600 static cmdline_parse_inst_t cmd_start_tx_first = {
6601 	.f = cmd_start_tx_first_parsed,
6602 	.data = NULL,
6603 	.help_str = "start tx_first: Start packet forwarding, "
6604 		"after sending 1 burst of packets",
6605 	.tokens = {
6606 		(void *)&cmd_start_tx_first_start,
6607 		(void *)&cmd_start_tx_first_tx_first,
6608 		NULL,
6609 	},
6610 };
6611 
6612 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6613 struct cmd_start_tx_first_n_result {
6614 	cmdline_fixed_string_t start;
6615 	cmdline_fixed_string_t tx_first;
6616 	uint32_t tx_num;
6617 };
6618 
6619 static void
6620 cmd_start_tx_first_n_parsed(void *parsed_result,
6621 			  __rte_unused struct cmdline *cl,
6622 			  __rte_unused void *data)
6623 {
6624 	struct cmd_start_tx_first_n_result *res = parsed_result;
6625 
6626 	start_packet_forwarding(res->tx_num);
6627 }
6628 
6629 static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6630 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6631 			start, "start");
6632 static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6633 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6634 			tx_first, "tx_first");
6635 static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6636 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6637 			tx_num, RTE_UINT32);
6638 
6639 static cmdline_parse_inst_t cmd_start_tx_first_n = {
6640 	.f = cmd_start_tx_first_n_parsed,
6641 	.data = NULL,
6642 	.help_str = "start tx_first <num>: "
6643 		"packet forwarding, after sending <num> bursts of packets",
6644 	.tokens = {
6645 		(void *)&cmd_start_tx_first_n_start,
6646 		(void *)&cmd_start_tx_first_n_tx_first,
6647 		(void *)&cmd_start_tx_first_n_tx_num,
6648 		NULL,
6649 	},
6650 };
6651 
6652 /* *** SET LINK UP *** */
6653 struct cmd_set_link_up_result {
6654 	cmdline_fixed_string_t set;
6655 	cmdline_fixed_string_t link_up;
6656 	cmdline_fixed_string_t port;
6657 	portid_t port_id;
6658 };
6659 
6660 static cmdline_parse_token_string_t cmd_set_link_up_set =
6661 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6662 static cmdline_parse_token_string_t cmd_set_link_up_link_up =
6663 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6664 				"link-up");
6665 static cmdline_parse_token_string_t cmd_set_link_up_port =
6666 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6667 static cmdline_parse_token_num_t cmd_set_link_up_port_id =
6668 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
6669 				RTE_UINT16);
6670 
6671 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
6672 			     __rte_unused struct cmdline *cl,
6673 			     __rte_unused void *data)
6674 {
6675 	struct cmd_set_link_up_result *res = parsed_result;
6676 	dev_set_link_up(res->port_id);
6677 }
6678 
6679 static cmdline_parse_inst_t cmd_set_link_up = {
6680 	.f = cmd_set_link_up_parsed,
6681 	.data = NULL,
6682 	.help_str = "set link-up port <port id>",
6683 	.tokens = {
6684 		(void *)&cmd_set_link_up_set,
6685 		(void *)&cmd_set_link_up_link_up,
6686 		(void *)&cmd_set_link_up_port,
6687 		(void *)&cmd_set_link_up_port_id,
6688 		NULL,
6689 	},
6690 };
6691 
6692 /* *** SET LINK DOWN *** */
6693 struct cmd_set_link_down_result {
6694 	cmdline_fixed_string_t set;
6695 	cmdline_fixed_string_t link_down;
6696 	cmdline_fixed_string_t port;
6697 	portid_t port_id;
6698 };
6699 
6700 static cmdline_parse_token_string_t cmd_set_link_down_set =
6701 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6702 static cmdline_parse_token_string_t cmd_set_link_down_link_down =
6703 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6704 				"link-down");
6705 static cmdline_parse_token_string_t cmd_set_link_down_port =
6706 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6707 static cmdline_parse_token_num_t cmd_set_link_down_port_id =
6708 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
6709 				RTE_UINT16);
6710 
6711 static void cmd_set_link_down_parsed(
6712 				__rte_unused void *parsed_result,
6713 				__rte_unused struct cmdline *cl,
6714 				__rte_unused void *data)
6715 {
6716 	struct cmd_set_link_down_result *res = parsed_result;
6717 	dev_set_link_down(res->port_id);
6718 }
6719 
6720 static cmdline_parse_inst_t cmd_set_link_down = {
6721 	.f = cmd_set_link_down_parsed,
6722 	.data = NULL,
6723 	.help_str = "set link-down port <port id>",
6724 	.tokens = {
6725 		(void *)&cmd_set_link_down_set,
6726 		(void *)&cmd_set_link_down_link_down,
6727 		(void *)&cmd_set_link_down_port,
6728 		(void *)&cmd_set_link_down_port_id,
6729 		NULL,
6730 	},
6731 };
6732 
6733 /* *** SHOW CFG *** */
6734 struct cmd_showcfg_result {
6735 	cmdline_fixed_string_t show;
6736 	cmdline_fixed_string_t cfg;
6737 	cmdline_fixed_string_t what;
6738 };
6739 
6740 static void cmd_showcfg_parsed(void *parsed_result,
6741 			       __rte_unused struct cmdline *cl,
6742 			       __rte_unused void *data)
6743 {
6744 	struct cmd_showcfg_result *res = parsed_result;
6745 	if (!strcmp(res->what, "rxtx"))
6746 		rxtx_config_display();
6747 	else if (!strcmp(res->what, "cores"))
6748 		fwd_lcores_config_display();
6749 	else if (!strcmp(res->what, "fwd"))
6750 		pkt_fwd_config_display(&cur_fwd_config);
6751 	else if (!strcmp(res->what, "rxoffs"))
6752 		show_rx_pkt_offsets();
6753 	else if (!strcmp(res->what, "rxpkts"))
6754 		show_rx_pkt_segments();
6755 	else if (!strcmp(res->what, "rxhdrs"))
6756 		show_rx_pkt_hdrs();
6757 	else if (!strcmp(res->what, "txpkts"))
6758 		show_tx_pkt_segments();
6759 	else if (!strcmp(res->what, "txtimes"))
6760 		show_tx_pkt_times();
6761 }
6762 
6763 static cmdline_parse_token_string_t cmd_showcfg_show =
6764 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6765 static cmdline_parse_token_string_t cmd_showcfg_port =
6766 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6767 static cmdline_parse_token_string_t cmd_showcfg_what =
6768 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6769 				 "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
6770 
6771 static cmdline_parse_inst_t cmd_showcfg = {
6772 	.f = cmd_showcfg_parsed,
6773 	.data = NULL,
6774 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
6775 	.tokens = {
6776 		(void *)&cmd_showcfg_show,
6777 		(void *)&cmd_showcfg_port,
6778 		(void *)&cmd_showcfg_what,
6779 		NULL,
6780 	},
6781 };
6782 
6783 /* *** SHOW ALL PORT INFO *** */
6784 struct cmd_showportall_result {
6785 	cmdline_fixed_string_t show;
6786 	cmdline_fixed_string_t port;
6787 	cmdline_fixed_string_t what;
6788 	cmdline_fixed_string_t all;
6789 };
6790 
6791 static void cmd_showportall_parsed(void *parsed_result,
6792 				__rte_unused struct cmdline *cl,
6793 				__rte_unused void *data)
6794 {
6795 	portid_t i;
6796 
6797 	struct cmd_showportall_result *res = parsed_result;
6798 	if (!strcmp(res->show, "clear")) {
6799 		if (!strcmp(res->what, "stats"))
6800 			RTE_ETH_FOREACH_DEV(i)
6801 				nic_stats_clear(i);
6802 		else if (!strcmp(res->what, "xstats"))
6803 			RTE_ETH_FOREACH_DEV(i)
6804 				nic_xstats_clear(i);
6805 	} else if (!strcmp(res->what, "info"))
6806 		RTE_ETH_FOREACH_DEV(i)
6807 			port_infos_display(i);
6808 	else if (!strcmp(res->what, "summary")) {
6809 		port_summary_header_display();
6810 		RTE_ETH_FOREACH_DEV(i)
6811 			port_summary_display(i);
6812 	}
6813 	else if (!strcmp(res->what, "stats"))
6814 		RTE_ETH_FOREACH_DEV(i)
6815 			nic_stats_display(i);
6816 	else if (!strcmp(res->what, "xstats"))
6817 		RTE_ETH_FOREACH_DEV(i)
6818 			nic_xstats_display(i);
6819 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
6820 	else if (!strcmp(res->what, "fdir"))
6821 		RTE_ETH_FOREACH_DEV(i)
6822 			fdir_get_infos(i);
6823 #endif
6824 	else if (!strcmp(res->what, "dcb_tc"))
6825 		RTE_ETH_FOREACH_DEV(i)
6826 			port_dcb_info_display(i);
6827 }
6828 
6829 static cmdline_parse_token_string_t cmd_showportall_show =
6830 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6831 				 "show#clear");
6832 static cmdline_parse_token_string_t cmd_showportall_port =
6833 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6834 static cmdline_parse_token_string_t cmd_showportall_what =
6835 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6836 				 "info#summary#stats#xstats#fdir#dcb_tc");
6837 static cmdline_parse_token_string_t cmd_showportall_all =
6838 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6839 static cmdline_parse_inst_t cmd_showportall = {
6840 	.f = cmd_showportall_parsed,
6841 	.data = NULL,
6842 	.help_str = "show|clear port "
6843 		"info|summary|stats|xstats|fdir|dcb_tc all",
6844 	.tokens = {
6845 		(void *)&cmd_showportall_show,
6846 		(void *)&cmd_showportall_port,
6847 		(void *)&cmd_showportall_what,
6848 		(void *)&cmd_showportall_all,
6849 		NULL,
6850 	},
6851 };
6852 
6853 /* *** SHOW PORT INFO *** */
6854 struct cmd_showport_result {
6855 	cmdline_fixed_string_t show;
6856 	cmdline_fixed_string_t port;
6857 	cmdline_fixed_string_t what;
6858 	uint16_t portnum;
6859 };
6860 
6861 static void cmd_showport_parsed(void *parsed_result,
6862 				__rte_unused struct cmdline *cl,
6863 				__rte_unused void *data)
6864 {
6865 	struct cmd_showport_result *res = parsed_result;
6866 	if (!strcmp(res->show, "clear")) {
6867 		if (!strcmp(res->what, "stats"))
6868 			nic_stats_clear(res->portnum);
6869 		else if (!strcmp(res->what, "xstats"))
6870 			nic_xstats_clear(res->portnum);
6871 	} else if (!strcmp(res->what, "info"))
6872 		port_infos_display(res->portnum);
6873 	else if (!strcmp(res->what, "summary")) {
6874 		port_summary_header_display();
6875 		port_summary_display(res->portnum);
6876 	}
6877 	else if (!strcmp(res->what, "stats"))
6878 		nic_stats_display(res->portnum);
6879 	else if (!strcmp(res->what, "xstats"))
6880 		nic_xstats_display(res->portnum);
6881 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
6882 	else if (!strcmp(res->what, "fdir"))
6883 		 fdir_get_infos(res->portnum);
6884 #endif
6885 	else if (!strcmp(res->what, "dcb_tc"))
6886 		port_dcb_info_display(res->portnum);
6887 }
6888 
6889 static cmdline_parse_token_string_t cmd_showport_show =
6890 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6891 				 "show#clear");
6892 static cmdline_parse_token_string_t cmd_showport_port =
6893 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6894 static cmdline_parse_token_string_t cmd_showport_what =
6895 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6896 				 "info#summary#stats#xstats#fdir#dcb_tc");
6897 static cmdline_parse_token_num_t cmd_showport_portnum =
6898 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
6899 
6900 static cmdline_parse_inst_t cmd_showport = {
6901 	.f = cmd_showport_parsed,
6902 	.data = NULL,
6903 	.help_str = "show|clear port "
6904 		"info|summary|stats|xstats|fdir|dcb_tc "
6905 		"<port_id>",
6906 	.tokens = {
6907 		(void *)&cmd_showport_show,
6908 		(void *)&cmd_showport_port,
6909 		(void *)&cmd_showport_what,
6910 		(void *)&cmd_showport_portnum,
6911 		NULL,
6912 	},
6913 };
6914 
6915 /* *** show port representors information *** */
6916 struct cmd_representor_info_result {
6917 	cmdline_fixed_string_t cmd_show;
6918 	cmdline_fixed_string_t cmd_port;
6919 	cmdline_fixed_string_t cmd_info;
6920 	cmdline_fixed_string_t cmd_keyword;
6921 	portid_t cmd_pid;
6922 };
6923 
6924 static void
6925 cmd_representor_info_parsed(void *parsed_result,
6926 		__rte_unused struct cmdline *cl,
6927 		__rte_unused void *data)
6928 {
6929 	struct cmd_representor_info_result *res = parsed_result;
6930 	struct rte_eth_representor_info *info;
6931 	struct rte_eth_representor_range *range;
6932 	uint32_t range_diff;
6933 	uint32_t i;
6934 	int ret;
6935 	int num;
6936 
6937 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
6938 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
6939 		return;
6940 	}
6941 
6942 	ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
6943 	if (ret < 0) {
6944 		fprintf(stderr,
6945 			"Failed to get the number of representor info ranges for port %hu: %s\n",
6946 			res->cmd_pid, rte_strerror(-ret));
6947 		return;
6948 	}
6949 	num = ret;
6950 
6951 	info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
6952 	if (info == NULL) {
6953 		fprintf(stderr,
6954 			"Failed to allocate memory for representor info for port %hu\n",
6955 			res->cmd_pid);
6956 		return;
6957 	}
6958 	info->nb_ranges_alloc = num;
6959 
6960 	ret = rte_eth_representor_info_get(res->cmd_pid, info);
6961 	if (ret < 0) {
6962 		fprintf(stderr,
6963 			"Failed to get the representor info for port %hu: %s\n",
6964 			res->cmd_pid, rte_strerror(-ret));
6965 		free(info);
6966 		return;
6967 	}
6968 
6969 	printf("Port controller: %hu\n", info->controller);
6970 	printf("Port PF: %hu\n", info->pf);
6971 
6972 	printf("Ranges: %u\n", info->nb_ranges);
6973 	for (i = 0; i < info->nb_ranges; i++) {
6974 		range = &info->ranges[i];
6975 		range_diff = range->id_end - range->id_base;
6976 
6977 		printf("%u. ", i + 1);
6978 		printf("'%s' ", range->name);
6979 		if (range_diff > 0)
6980 			printf("[%u-%u]: ", range->id_base, range->id_end);
6981 		else
6982 			printf("[%u]: ", range->id_base);
6983 
6984 		printf("Controller %d, PF %d", range->controller, range->pf);
6985 
6986 		switch (range->type) {
6987 		case RTE_ETH_REPRESENTOR_NONE:
6988 			printf(", NONE\n");
6989 			break;
6990 		case RTE_ETH_REPRESENTOR_VF:
6991 			if (range_diff > 0)
6992 				printf(", VF %d..%d\n", range->vf,
6993 				       range->vf + range_diff);
6994 			else
6995 				printf(", VF %d\n", range->vf);
6996 			break;
6997 		case RTE_ETH_REPRESENTOR_SF:
6998 			printf(", SF %d\n", range->sf);
6999 			break;
7000 		case RTE_ETH_REPRESENTOR_PF:
7001 			if (range_diff > 0)
7002 				printf("..%d\n", range->pf + range_diff);
7003 			else
7004 				printf("\n");
7005 			break;
7006 		default:
7007 			printf(", UNKNOWN TYPE %d\n", range->type);
7008 			break;
7009 		}
7010 	}
7011 
7012 	free(info);
7013 }
7014 
7015 static cmdline_parse_token_string_t cmd_representor_info_show =
7016 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7017 			cmd_show, "show");
7018 static cmdline_parse_token_string_t cmd_representor_info_port =
7019 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7020 			cmd_port, "port");
7021 static cmdline_parse_token_string_t cmd_representor_info_info =
7022 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7023 			cmd_info, "info");
7024 static cmdline_parse_token_num_t cmd_representor_info_pid =
7025 	TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7026 			cmd_pid, RTE_UINT16);
7027 static cmdline_parse_token_string_t cmd_representor_info_keyword =
7028 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7029 			cmd_keyword, "representor");
7030 
7031 static cmdline_parse_inst_t cmd_representor_info = {
7032 	.f = cmd_representor_info_parsed,
7033 	.data = NULL,
7034 	.help_str = "show port info <port_id> representor",
7035 	.tokens = {
7036 		(void *)&cmd_representor_info_show,
7037 		(void *)&cmd_representor_info_port,
7038 		(void *)&cmd_representor_info_info,
7039 		(void *)&cmd_representor_info_pid,
7040 		(void *)&cmd_representor_info_keyword,
7041 		NULL,
7042 	},
7043 };
7044 
7045 
7046 /* *** SHOW DEVICE INFO *** */
7047 struct cmd_showdevice_result {
7048 	cmdline_fixed_string_t show;
7049 	cmdline_fixed_string_t device;
7050 	cmdline_fixed_string_t what;
7051 	cmdline_fixed_string_t identifier;
7052 };
7053 
7054 static void cmd_showdevice_parsed(void *parsed_result,
7055 				__rte_unused struct cmdline *cl,
7056 				__rte_unused void *data)
7057 {
7058 	struct cmd_showdevice_result *res = parsed_result;
7059 	if (!strcmp(res->what, "info")) {
7060 		if (!strcmp(res->identifier, "all"))
7061 			device_infos_display(NULL);
7062 		else
7063 			device_infos_display(res->identifier);
7064 	}
7065 }
7066 
7067 static cmdline_parse_token_string_t cmd_showdevice_show =
7068 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7069 				 "show");
7070 static cmdline_parse_token_string_t cmd_showdevice_device =
7071 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7072 static cmdline_parse_token_string_t cmd_showdevice_what =
7073 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7074 				 "info");
7075 static cmdline_parse_token_string_t cmd_showdevice_identifier =
7076 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7077 			identifier, NULL);
7078 
7079 static cmdline_parse_inst_t cmd_showdevice = {
7080 	.f = cmd_showdevice_parsed,
7081 	.data = NULL,
7082 	.help_str = "show device info <identifier>|all",
7083 	.tokens = {
7084 		(void *)&cmd_showdevice_show,
7085 		(void *)&cmd_showdevice_device,
7086 		(void *)&cmd_showdevice_what,
7087 		(void *)&cmd_showdevice_identifier,
7088 		NULL,
7089 	},
7090 };
7091 
7092 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7093 struct cmd_showeeprom_result {
7094 	cmdline_fixed_string_t show;
7095 	cmdline_fixed_string_t port;
7096 	uint16_t portnum;
7097 	cmdline_fixed_string_t type;
7098 };
7099 
7100 static void cmd_showeeprom_parsed(void *parsed_result,
7101 		__rte_unused struct cmdline *cl,
7102 		__rte_unused void *data)
7103 {
7104 	struct cmd_showeeprom_result *res = parsed_result;
7105 
7106 	if (!strcmp(res->type, "eeprom"))
7107 		port_eeprom_display(res->portnum);
7108 	else if (!strcmp(res->type, "module_eeprom"))
7109 		port_module_eeprom_display(res->portnum);
7110 	else
7111 		fprintf(stderr, "Unknown argument\n");
7112 }
7113 
7114 static cmdline_parse_token_string_t cmd_showeeprom_show =
7115 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7116 static cmdline_parse_token_string_t cmd_showeeprom_port =
7117 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7118 static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7119 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7120 			RTE_UINT16);
7121 static cmdline_parse_token_string_t cmd_showeeprom_type =
7122 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7123 
7124 static cmdline_parse_inst_t cmd_showeeprom = {
7125 	.f = cmd_showeeprom_parsed,
7126 	.data = NULL,
7127 	.help_str = "show port <port_id> module_eeprom|eeprom",
7128 	.tokens = {
7129 		(void *)&cmd_showeeprom_show,
7130 		(void *)&cmd_showeeprom_port,
7131 		(void *)&cmd_showeeprom_portnum,
7132 		(void *)&cmd_showeeprom_type,
7133 		NULL,
7134 	},
7135 };
7136 
7137 /* *** SHOW QUEUE INFO *** */
7138 struct cmd_showqueue_result {
7139 	cmdline_fixed_string_t show;
7140 	cmdline_fixed_string_t type;
7141 	cmdline_fixed_string_t what;
7142 	uint16_t portnum;
7143 	uint16_t queuenum;
7144 };
7145 
7146 static void
7147 cmd_showqueue_parsed(void *parsed_result,
7148 	__rte_unused struct cmdline *cl,
7149 	__rte_unused void *data)
7150 {
7151 	struct cmd_showqueue_result *res = parsed_result;
7152 
7153 	if (!strcmp(res->type, "rxq"))
7154 		rx_queue_infos_display(res->portnum, res->queuenum);
7155 	else if (!strcmp(res->type, "txq"))
7156 		tx_queue_infos_display(res->portnum, res->queuenum);
7157 }
7158 
7159 static cmdline_parse_token_string_t cmd_showqueue_show =
7160 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7161 static cmdline_parse_token_string_t cmd_showqueue_type =
7162 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7163 static cmdline_parse_token_string_t cmd_showqueue_what =
7164 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7165 static cmdline_parse_token_num_t cmd_showqueue_portnum =
7166 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7167 		RTE_UINT16);
7168 static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7169 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7170 		RTE_UINT16);
7171 
7172 static cmdline_parse_inst_t cmd_showqueue = {
7173 	.f = cmd_showqueue_parsed,
7174 	.data = NULL,
7175 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7176 	.tokens = {
7177 		(void *)&cmd_showqueue_show,
7178 		(void *)&cmd_showqueue_type,
7179 		(void *)&cmd_showqueue_what,
7180 		(void *)&cmd_showqueue_portnum,
7181 		(void *)&cmd_showqueue_queuenum,
7182 		NULL,
7183 	},
7184 };
7185 
7186 /* show/clear fwd engine statistics */
7187 struct fwd_result {
7188 	cmdline_fixed_string_t action;
7189 	cmdline_fixed_string_t fwd;
7190 	cmdline_fixed_string_t stats;
7191 	cmdline_fixed_string_t all;
7192 };
7193 
7194 static cmdline_parse_token_string_t cmd_fwd_action =
7195 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7196 static cmdline_parse_token_string_t cmd_fwd_fwd =
7197 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7198 static cmdline_parse_token_string_t cmd_fwd_stats =
7199 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7200 static cmdline_parse_token_string_t cmd_fwd_all =
7201 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7202 
7203 static void
7204 cmd_showfwdall_parsed(void *parsed_result,
7205 		      __rte_unused struct cmdline *cl,
7206 		      __rte_unused void *data)
7207 {
7208 	struct fwd_result *res = parsed_result;
7209 
7210 	if (!strcmp(res->action, "show"))
7211 		fwd_stats_display();
7212 	else
7213 		fwd_stats_reset();
7214 }
7215 
7216 static cmdline_parse_inst_t cmd_showfwdall = {
7217 	.f = cmd_showfwdall_parsed,
7218 	.data = NULL,
7219 	.help_str = "show|clear fwd stats all",
7220 	.tokens = {
7221 		(void *)&cmd_fwd_action,
7222 		(void *)&cmd_fwd_fwd,
7223 		(void *)&cmd_fwd_stats,
7224 		(void *)&cmd_fwd_all,
7225 		NULL,
7226 	},
7227 };
7228 
7229 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7230 struct cmd_read_rxd_txd_result {
7231 	cmdline_fixed_string_t read;
7232 	cmdline_fixed_string_t rxd_txd;
7233 	portid_t port_id;
7234 	uint16_t queue_id;
7235 	uint16_t desc_id;
7236 };
7237 
7238 static void
7239 cmd_read_rxd_txd_parsed(void *parsed_result,
7240 			__rte_unused struct cmdline *cl,
7241 			__rte_unused void *data)
7242 {
7243 	struct cmd_read_rxd_txd_result *res = parsed_result;
7244 
7245 	if (!strcmp(res->rxd_txd, "rxd"))
7246 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7247 	else if (!strcmp(res->rxd_txd, "txd"))
7248 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7249 }
7250 
7251 static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7252 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7253 static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7254 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7255 				 "rxd#txd");
7256 static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7257 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7258 				 RTE_UINT16);
7259 static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7260 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
7261 				 RTE_UINT16);
7262 static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7263 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
7264 				 RTE_UINT16);
7265 
7266 static cmdline_parse_inst_t cmd_read_rxd_txd = {
7267 	.f = cmd_read_rxd_txd_parsed,
7268 	.data = NULL,
7269 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7270 	.tokens = {
7271 		(void *)&cmd_read_rxd_txd_read,
7272 		(void *)&cmd_read_rxd_txd_rxd_txd,
7273 		(void *)&cmd_read_rxd_txd_port_id,
7274 		(void *)&cmd_read_rxd_txd_queue_id,
7275 		(void *)&cmd_read_rxd_txd_desc_id,
7276 		NULL,
7277 	},
7278 };
7279 
7280 /* *** QUIT *** */
7281 struct cmd_quit_result {
7282 	cmdline_fixed_string_t quit;
7283 };
7284 
7285 static void cmd_quit_parsed(__rte_unused void *parsed_result,
7286 			    struct cmdline *cl,
7287 			    __rte_unused void *data)
7288 {
7289 	cmdline_quit(cl);
7290 	cl_quit = 1;
7291 }
7292 
7293 static cmdline_parse_token_string_t cmd_quit_quit =
7294 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7295 
7296 static cmdline_parse_inst_t cmd_quit = {
7297 	.f = cmd_quit_parsed,
7298 	.data = NULL,
7299 	.help_str = "quit: Exit application",
7300 	.tokens = {
7301 		(void *)&cmd_quit_quit,
7302 		NULL,
7303 	},
7304 };
7305 
7306 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7307 struct cmd_mac_addr_result {
7308 	cmdline_fixed_string_t mac_addr_cmd;
7309 	cmdline_fixed_string_t what;
7310 	uint16_t port_num;
7311 	struct rte_ether_addr address;
7312 };
7313 
7314 static void cmd_mac_addr_parsed(void *parsed_result,
7315 		__rte_unused struct cmdline *cl,
7316 		__rte_unused void *data)
7317 {
7318 	struct cmd_mac_addr_result *res = parsed_result;
7319 	int ret;
7320 
7321 	if (strcmp(res->what, "add") == 0)
7322 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7323 	else if (strcmp(res->what, "set") == 0)
7324 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7325 						       &res->address);
7326 	else
7327 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7328 
7329 	/* check the return value and print it if is < 0 */
7330 	if(ret < 0)
7331 		fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
7332 
7333 }
7334 
7335 static cmdline_parse_token_string_t cmd_mac_addr_cmd =
7336 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7337 				"mac_addr");
7338 static cmdline_parse_token_string_t cmd_mac_addr_what =
7339 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7340 				"add#remove#set");
7341 static cmdline_parse_token_num_t cmd_mac_addr_portnum =
7342 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7343 					RTE_UINT16);
7344 static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7345 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7346 
7347 static cmdline_parse_inst_t cmd_mac_addr = {
7348 	.f = cmd_mac_addr_parsed,
7349 	.data = (void *)0,
7350 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7351 			"Add/Remove/Set MAC address on port_id",
7352 	.tokens = {
7353 		(void *)&cmd_mac_addr_cmd,
7354 		(void *)&cmd_mac_addr_what,
7355 		(void *)&cmd_mac_addr_portnum,
7356 		(void *)&cmd_mac_addr_addr,
7357 		NULL,
7358 	},
7359 };
7360 
7361 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7362 struct cmd_eth_peer_result {
7363 	cmdline_fixed_string_t set;
7364 	cmdline_fixed_string_t eth_peer;
7365 	portid_t port_id;
7366 	cmdline_fixed_string_t peer_addr;
7367 };
7368 
7369 static void cmd_set_eth_peer_parsed(void *parsed_result,
7370 			__rte_unused struct cmdline *cl,
7371 			__rte_unused void *data)
7372 {
7373 		struct cmd_eth_peer_result *res = parsed_result;
7374 
7375 		if (test_done == 0) {
7376 			fprintf(stderr, "Please stop forwarding first\n");
7377 			return;
7378 		}
7379 		if (!strcmp(res->eth_peer, "eth-peer")) {
7380 			set_fwd_eth_peer(res->port_id, res->peer_addr);
7381 			fwd_config_setup();
7382 		}
7383 }
7384 static cmdline_parse_token_string_t cmd_eth_peer_set =
7385 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7386 static cmdline_parse_token_string_t cmd_eth_peer =
7387 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7388 static cmdline_parse_token_num_t cmd_eth_peer_port_id =
7389 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
7390 		RTE_UINT16);
7391 static cmdline_parse_token_string_t cmd_eth_peer_addr =
7392 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7393 
7394 static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7395 	.f = cmd_set_eth_peer_parsed,
7396 	.data = NULL,
7397 	.help_str = "set eth-peer <port_id> <peer_mac>",
7398 	.tokens = {
7399 		(void *)&cmd_eth_peer_set,
7400 		(void *)&cmd_eth_peer,
7401 		(void *)&cmd_eth_peer_port_id,
7402 		(void *)&cmd_eth_peer_addr,
7403 		NULL,
7404 	},
7405 };
7406 
7407 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7408 struct cmd_set_qmap_result {
7409 	cmdline_fixed_string_t set;
7410 	cmdline_fixed_string_t qmap;
7411 	cmdline_fixed_string_t what;
7412 	portid_t port_id;
7413 	uint16_t queue_id;
7414 	uint8_t map_value;
7415 };
7416 
7417 static void
7418 cmd_set_qmap_parsed(void *parsed_result,
7419 		       __rte_unused struct cmdline *cl,
7420 		       __rte_unused void *data)
7421 {
7422 	struct cmd_set_qmap_result *res = parsed_result;
7423 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7424 
7425 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7426 }
7427 
7428 static cmdline_parse_token_string_t cmd_setqmap_set =
7429 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7430 				 set, "set");
7431 static cmdline_parse_token_string_t cmd_setqmap_qmap =
7432 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7433 				 qmap, "stat_qmap");
7434 static cmdline_parse_token_string_t cmd_setqmap_what =
7435 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7436 				 what, "tx#rx");
7437 static cmdline_parse_token_num_t cmd_setqmap_portid =
7438 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7439 			      port_id, RTE_UINT16);
7440 static cmdline_parse_token_num_t cmd_setqmap_queueid =
7441 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7442 			      queue_id, RTE_UINT16);
7443 static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7444 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7445 			      map_value, RTE_UINT8);
7446 
7447 static cmdline_parse_inst_t cmd_set_qmap = {
7448 	.f = cmd_set_qmap_parsed,
7449 	.data = NULL,
7450 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7451 		"Set statistics mapping value on tx|rx queue_id of port_id",
7452 	.tokens = {
7453 		(void *)&cmd_setqmap_set,
7454 		(void *)&cmd_setqmap_qmap,
7455 		(void *)&cmd_setqmap_what,
7456 		(void *)&cmd_setqmap_portid,
7457 		(void *)&cmd_setqmap_queueid,
7458 		(void *)&cmd_setqmap_mapvalue,
7459 		NULL,
7460 	},
7461 };
7462 
7463 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
7464 struct cmd_set_xstats_hide_zero_result {
7465 	cmdline_fixed_string_t keyword;
7466 	cmdline_fixed_string_t name;
7467 	cmdline_fixed_string_t on_off;
7468 };
7469 
7470 static void
7471 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7472 			__rte_unused struct cmdline *cl,
7473 			__rte_unused void *data)
7474 {
7475 	struct cmd_set_xstats_hide_zero_result *res;
7476 	uint16_t on_off = 0;
7477 
7478 	res = parsed_result;
7479 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7480 	set_xstats_hide_zero(on_off);
7481 }
7482 
7483 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7484 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7485 				 keyword, "set");
7486 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7487 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7488 				 name, "xstats-hide-zero");
7489 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7490 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7491 				 on_off, "on#off");
7492 
7493 static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7494 	.f = cmd_set_xstats_hide_zero_parsed,
7495 	.data = NULL,
7496 	.help_str = "set xstats-hide-zero on|off",
7497 	.tokens = {
7498 		(void *)&cmd_set_xstats_hide_zero_keyword,
7499 		(void *)&cmd_set_xstats_hide_zero_name,
7500 		(void *)&cmd_set_xstats_hide_zero_on_off,
7501 		NULL,
7502 	},
7503 };
7504 
7505 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
7506 struct cmd_set_record_core_cycles_result {
7507 	cmdline_fixed_string_t keyword;
7508 	cmdline_fixed_string_t name;
7509 	cmdline_fixed_string_t on_off;
7510 };
7511 
7512 static void
7513 cmd_set_record_core_cycles_parsed(void *parsed_result,
7514 			__rte_unused struct cmdline *cl,
7515 			__rte_unused void *data)
7516 {
7517 	struct cmd_set_record_core_cycles_result *res;
7518 	uint16_t on_off = 0;
7519 
7520 	res = parsed_result;
7521 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7522 	set_record_core_cycles(on_off);
7523 }
7524 
7525 static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
7526 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7527 				 keyword, "set");
7528 static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
7529 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7530 				 name, "record-core-cycles");
7531 static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
7532 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7533 				 on_off, "on#off");
7534 
7535 static cmdline_parse_inst_t cmd_set_record_core_cycles = {
7536 	.f = cmd_set_record_core_cycles_parsed,
7537 	.data = NULL,
7538 	.help_str = "set record-core-cycles on|off",
7539 	.tokens = {
7540 		(void *)&cmd_set_record_core_cycles_keyword,
7541 		(void *)&cmd_set_record_core_cycles_name,
7542 		(void *)&cmd_set_record_core_cycles_on_off,
7543 		NULL,
7544 	},
7545 };
7546 
7547 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
7548 struct cmd_set_record_burst_stats_result {
7549 	cmdline_fixed_string_t keyword;
7550 	cmdline_fixed_string_t name;
7551 	cmdline_fixed_string_t on_off;
7552 };
7553 
7554 static void
7555 cmd_set_record_burst_stats_parsed(void *parsed_result,
7556 			__rte_unused struct cmdline *cl,
7557 			__rte_unused void *data)
7558 {
7559 	struct cmd_set_record_burst_stats_result *res;
7560 	uint16_t on_off = 0;
7561 
7562 	res = parsed_result;
7563 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7564 	set_record_burst_stats(on_off);
7565 }
7566 
7567 static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
7568 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7569 				 keyword, "set");
7570 static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
7571 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7572 				 name, "record-burst-stats");
7573 static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
7574 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7575 				 on_off, "on#off");
7576 
7577 static cmdline_parse_inst_t cmd_set_record_burst_stats = {
7578 	.f = cmd_set_record_burst_stats_parsed,
7579 	.data = NULL,
7580 	.help_str = "set record-burst-stats on|off",
7581 	.tokens = {
7582 		(void *)&cmd_set_record_burst_stats_keyword,
7583 		(void *)&cmd_set_record_burst_stats_name,
7584 		(void *)&cmd_set_record_burst_stats_on_off,
7585 		NULL,
7586 	},
7587 };
7588 
7589 /* *** CONFIGURE UNICAST HASH TABLE *** */
7590 struct cmd_set_uc_hash_table {
7591 	cmdline_fixed_string_t set;
7592 	cmdline_fixed_string_t port;
7593 	portid_t port_id;
7594 	cmdline_fixed_string_t what;
7595 	struct rte_ether_addr address;
7596 	cmdline_fixed_string_t mode;
7597 };
7598 
7599 static void
7600 cmd_set_uc_hash_parsed(void *parsed_result,
7601 		       __rte_unused struct cmdline *cl,
7602 		       __rte_unused void *data)
7603 {
7604 	int ret=0;
7605 	struct cmd_set_uc_hash_table *res = parsed_result;
7606 
7607 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7608 
7609 	if (strcmp(res->what, "uta") == 0)
7610 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7611 						&res->address,(uint8_t)is_on);
7612 	if (ret < 0)
7613 		fprintf(stderr,
7614 			"bad unicast hash table parameter, return code = %d\n",
7615 			ret);
7616 
7617 }
7618 
7619 static cmdline_parse_token_string_t cmd_set_uc_hash_set =
7620 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7621 				 set, "set");
7622 static cmdline_parse_token_string_t cmd_set_uc_hash_port =
7623 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7624 				 port, "port");
7625 static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7626 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7627 			      port_id, RTE_UINT16);
7628 static cmdline_parse_token_string_t cmd_set_uc_hash_what =
7629 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7630 				 what, "uta");
7631 static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7632 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7633 				address);
7634 static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7635 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7636 				 mode, "on#off");
7637 
7638 static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7639 	.f = cmd_set_uc_hash_parsed,
7640 	.data = NULL,
7641 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
7642 	.tokens = {
7643 		(void *)&cmd_set_uc_hash_set,
7644 		(void *)&cmd_set_uc_hash_port,
7645 		(void *)&cmd_set_uc_hash_portid,
7646 		(void *)&cmd_set_uc_hash_what,
7647 		(void *)&cmd_set_uc_hash_mac,
7648 		(void *)&cmd_set_uc_hash_mode,
7649 		NULL,
7650 	},
7651 };
7652 
7653 struct cmd_set_uc_all_hash_table {
7654 	cmdline_fixed_string_t set;
7655 	cmdline_fixed_string_t port;
7656 	portid_t port_id;
7657 	cmdline_fixed_string_t what;
7658 	cmdline_fixed_string_t value;
7659 	cmdline_fixed_string_t mode;
7660 };
7661 
7662 static void
7663 cmd_set_uc_all_hash_parsed(void *parsed_result,
7664 		       __rte_unused struct cmdline *cl,
7665 		       __rte_unused void *data)
7666 {
7667 	int ret=0;
7668 	struct cmd_set_uc_all_hash_table *res = parsed_result;
7669 
7670 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7671 
7672 	if ((strcmp(res->what, "uta") == 0) &&
7673 		(strcmp(res->value, "all") == 0))
7674 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7675 	if (ret < 0)
7676 		fprintf(stderr,
7677 			"bad unicast hash table parameter, return code = %d\n",
7678 			ret);
7679 }
7680 
7681 static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7682 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7683 				 set, "set");
7684 static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7685 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7686 				 port, "port");
7687 static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7688 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7689 			      port_id, RTE_UINT16);
7690 static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7691 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7692 				 what, "uta");
7693 static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7694 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7695 				value,"all");
7696 static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7697 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7698 				 mode, "on#off");
7699 
7700 static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7701 	.f = cmd_set_uc_all_hash_parsed,
7702 	.data = NULL,
7703 	.help_str = "set port <port_id> uta all on|off",
7704 	.tokens = {
7705 		(void *)&cmd_set_uc_all_hash_set,
7706 		(void *)&cmd_set_uc_all_hash_port,
7707 		(void *)&cmd_set_uc_all_hash_portid,
7708 		(void *)&cmd_set_uc_all_hash_what,
7709 		(void *)&cmd_set_uc_all_hash_value,
7710 		(void *)&cmd_set_uc_all_hash_mode,
7711 		NULL,
7712 	},
7713 };
7714 
7715 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7716 struct cmd_set_vf_traffic {
7717 	cmdline_fixed_string_t set;
7718 	cmdline_fixed_string_t port;
7719 	portid_t port_id;
7720 	cmdline_fixed_string_t vf;
7721 	uint8_t vf_id;
7722 	cmdline_fixed_string_t what;
7723 	cmdline_fixed_string_t mode;
7724 };
7725 
7726 static void
7727 cmd_set_vf_traffic_parsed(void *parsed_result,
7728 		       __rte_unused struct cmdline *cl,
7729 		       __rte_unused void *data)
7730 {
7731 	struct cmd_set_vf_traffic *res = parsed_result;
7732 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7733 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7734 
7735 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7736 }
7737 
7738 static cmdline_parse_token_string_t cmd_setvf_traffic_set =
7739 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7740 				 set, "set");
7741 static cmdline_parse_token_string_t cmd_setvf_traffic_port =
7742 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7743 				 port, "port");
7744 static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7745 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7746 			      port_id, RTE_UINT16);
7747 static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7748 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7749 				 vf, "vf");
7750 static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7751 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7752 			      vf_id, RTE_UINT8);
7753 static cmdline_parse_token_string_t cmd_setvf_traffic_what =
7754 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7755 				 what, "tx#rx");
7756 static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7757 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7758 				 mode, "on#off");
7759 
7760 static cmdline_parse_inst_t cmd_set_vf_traffic = {
7761 	.f = cmd_set_vf_traffic_parsed,
7762 	.data = NULL,
7763 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7764 	.tokens = {
7765 		(void *)&cmd_setvf_traffic_set,
7766 		(void *)&cmd_setvf_traffic_port,
7767 		(void *)&cmd_setvf_traffic_portid,
7768 		(void *)&cmd_setvf_traffic_vf,
7769 		(void *)&cmd_setvf_traffic_vfid,
7770 		(void *)&cmd_setvf_traffic_what,
7771 		(void *)&cmd_setvf_traffic_mode,
7772 		NULL,
7773 	},
7774 };
7775 
7776 /* *** CONFIGURE VF RECEIVE MODE *** */
7777 struct cmd_set_vf_rxmode {
7778 	cmdline_fixed_string_t set;
7779 	cmdline_fixed_string_t port;
7780 	portid_t port_id;
7781 	cmdline_fixed_string_t vf;
7782 	uint8_t vf_id;
7783 	cmdline_fixed_string_t what;
7784 	cmdline_fixed_string_t mode;
7785 	cmdline_fixed_string_t on;
7786 };
7787 
7788 static void
7789 cmd_set_vf_rxmode_parsed(void *parsed_result,
7790 		       __rte_unused struct cmdline *cl,
7791 		       __rte_unused void *data)
7792 {
7793 	int ret = -ENOTSUP;
7794 	uint16_t vf_rxmode = 0;
7795 	struct cmd_set_vf_rxmode *res = parsed_result;
7796 
7797 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7798 	if (!strcmp(res->what,"rxmode")) {
7799 		if (!strcmp(res->mode, "AUPE"))
7800 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
7801 		else if (!strcmp(res->mode, "ROPE"))
7802 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
7803 		else if (!strcmp(res->mode, "BAM"))
7804 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
7805 		else if (!strncmp(res->mode, "MPE",3))
7806 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
7807 	}
7808 
7809 	RTE_SET_USED(is_on);
7810 	RTE_SET_USED(vf_rxmode);
7811 
7812 #ifdef RTE_NET_IXGBE
7813 	if (ret == -ENOTSUP)
7814 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7815 						  vf_rxmode, (uint8_t)is_on);
7816 #endif
7817 #ifdef RTE_NET_BNXT
7818 	if (ret == -ENOTSUP)
7819 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7820 						 vf_rxmode, (uint8_t)is_on);
7821 #endif
7822 	if (ret < 0)
7823 		fprintf(stderr,
7824 			"bad VF receive mode parameter, return code = %d\n",
7825 			ret);
7826 }
7827 
7828 static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7829 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7830 				 set, "set");
7831 static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7832 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7833 				 port, "port");
7834 static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7835 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7836 			      port_id, RTE_UINT16);
7837 static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7838 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7839 				 vf, "vf");
7840 static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7841 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7842 			      vf_id, RTE_UINT8);
7843 static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7844 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7845 				 what, "rxmode");
7846 static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7847 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7848 				 mode, "AUPE#ROPE#BAM#MPE");
7849 static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7850 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7851 				 on, "on#off");
7852 
7853 static cmdline_parse_inst_t cmd_set_vf_rxmode = {
7854 	.f = cmd_set_vf_rxmode_parsed,
7855 	.data = NULL,
7856 	.help_str = "set port <port_id> vf <vf_id> rxmode "
7857 		"AUPE|ROPE|BAM|MPE on|off",
7858 	.tokens = {
7859 		(void *)&cmd_set_vf_rxmode_set,
7860 		(void *)&cmd_set_vf_rxmode_port,
7861 		(void *)&cmd_set_vf_rxmode_portid,
7862 		(void *)&cmd_set_vf_rxmode_vf,
7863 		(void *)&cmd_set_vf_rxmode_vfid,
7864 		(void *)&cmd_set_vf_rxmode_what,
7865 		(void *)&cmd_set_vf_rxmode_mode,
7866 		(void *)&cmd_set_vf_rxmode_on,
7867 		NULL,
7868 	},
7869 };
7870 
7871 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7872 struct cmd_vf_mac_addr_result {
7873 	cmdline_fixed_string_t mac_addr_cmd;
7874 	cmdline_fixed_string_t what;
7875 	cmdline_fixed_string_t port;
7876 	uint16_t port_num;
7877 	cmdline_fixed_string_t vf;
7878 	uint8_t vf_num;
7879 	struct rte_ether_addr address;
7880 };
7881 
7882 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7883 		__rte_unused struct cmdline *cl,
7884 		__rte_unused void *data)
7885 {
7886 	struct cmd_vf_mac_addr_result *res = parsed_result;
7887 	int ret = -ENOTSUP;
7888 
7889 	if (strcmp(res->what, "add") != 0)
7890 		return;
7891 
7892 #ifdef RTE_NET_I40E
7893 	if (ret == -ENOTSUP)
7894 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7895 						   &res->address);
7896 #endif
7897 #ifdef RTE_NET_BNXT
7898 	if (ret == -ENOTSUP)
7899 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7900 						res->vf_num);
7901 #endif
7902 
7903 	if(ret < 0)
7904 		fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7905 
7906 }
7907 
7908 static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7909 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7910 				mac_addr_cmd,"mac_addr");
7911 static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7912 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7913 				what,"add");
7914 static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7915 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7916 				port,"port");
7917 static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7918 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7919 				port_num, RTE_UINT16);
7920 static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7921 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7922 				vf,"vf");
7923 static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7924 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7925 				vf_num, RTE_UINT8);
7926 static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7927 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7928 				address);
7929 
7930 static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7931 	.f = cmd_vf_mac_addr_parsed,
7932 	.data = (void *)0,
7933 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7934 		"Add MAC address filtering for a VF on port_id",
7935 	.tokens = {
7936 		(void *)&cmd_vf_mac_addr_cmd,
7937 		(void *)&cmd_vf_mac_addr_what,
7938 		(void *)&cmd_vf_mac_addr_port,
7939 		(void *)&cmd_vf_mac_addr_portnum,
7940 		(void *)&cmd_vf_mac_addr_vf,
7941 		(void *)&cmd_vf_mac_addr_vfnum,
7942 		(void *)&cmd_vf_mac_addr_addr,
7943 		NULL,
7944 	},
7945 };
7946 
7947 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7948 struct cmd_vf_rx_vlan_filter {
7949 	cmdline_fixed_string_t rx_vlan;
7950 	cmdline_fixed_string_t what;
7951 	uint16_t vlan_id;
7952 	cmdline_fixed_string_t port;
7953 	portid_t port_id;
7954 	cmdline_fixed_string_t vf;
7955 	uint64_t vf_mask;
7956 };
7957 
7958 static void
7959 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7960 			  __rte_unused struct cmdline *cl,
7961 			  __rte_unused void *data)
7962 {
7963 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
7964 	int ret = -ENOTSUP;
7965 
7966 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7967 
7968 #ifdef RTE_NET_IXGBE
7969 	if (ret == -ENOTSUP)
7970 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7971 				res->vlan_id, res->vf_mask, is_add);
7972 #endif
7973 #ifdef RTE_NET_I40E
7974 	if (ret == -ENOTSUP)
7975 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7976 				res->vlan_id, res->vf_mask, is_add);
7977 #endif
7978 #ifdef RTE_NET_BNXT
7979 	if (ret == -ENOTSUP)
7980 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7981 				res->vlan_id, res->vf_mask, is_add);
7982 #endif
7983 
7984 	switch (ret) {
7985 	case 0:
7986 		break;
7987 	case -EINVAL:
7988 		fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
7989 			res->vlan_id, res->vf_mask);
7990 		break;
7991 	case -ENODEV:
7992 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
7993 		break;
7994 	case -ENOTSUP:
7995 		fprintf(stderr, "function not implemented or supported\n");
7996 		break;
7997 	default:
7998 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
7999 	}
8000 }
8001 
8002 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8003 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8004 				 rx_vlan, "rx_vlan");
8005 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8006 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8007 				 what, "add#rm");
8008 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8009 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8010 			      vlan_id, RTE_UINT16);
8011 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8012 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8013 				 port, "port");
8014 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8015 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8016 			      port_id, RTE_UINT16);
8017 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8018 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8019 				 vf, "vf");
8020 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8021 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8022 			      vf_mask, RTE_UINT64);
8023 
8024 static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8025 	.f = cmd_vf_rx_vlan_filter_parsed,
8026 	.data = NULL,
8027 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8028 		"(vf_mask = hexadecimal VF mask)",
8029 	.tokens = {
8030 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8031 		(void *)&cmd_vf_rx_vlan_filter_what,
8032 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8033 		(void *)&cmd_vf_rx_vlan_filter_port,
8034 		(void *)&cmd_vf_rx_vlan_filter_portid,
8035 		(void *)&cmd_vf_rx_vlan_filter_vf,
8036 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8037 		NULL,
8038 	},
8039 };
8040 
8041 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8042 struct cmd_queue_rate_limit_result {
8043 	cmdline_fixed_string_t set;
8044 	cmdline_fixed_string_t port;
8045 	uint16_t port_num;
8046 	cmdline_fixed_string_t queue;
8047 	uint8_t queue_num;
8048 	cmdline_fixed_string_t rate;
8049 	uint32_t rate_num;
8050 };
8051 
8052 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8053 		__rte_unused struct cmdline *cl,
8054 		__rte_unused void *data)
8055 {
8056 	struct cmd_queue_rate_limit_result *res = parsed_result;
8057 	int ret = 0;
8058 
8059 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8060 		&& (strcmp(res->queue, "queue") == 0)
8061 		&& (strcmp(res->rate, "rate") == 0))
8062 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8063 					res->rate_num);
8064 	if (ret < 0)
8065 		fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8066 			strerror(-ret));
8067 
8068 }
8069 
8070 static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8071 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8072 				set, "set");
8073 static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8074 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8075 				port, "port");
8076 static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8077 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8078 				port_num, RTE_UINT16);
8079 static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8080 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8081 				queue, "queue");
8082 static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8083 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8084 				queue_num, RTE_UINT8);
8085 static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8086 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8087 				rate, "rate");
8088 static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8089 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8090 				rate_num, RTE_UINT32);
8091 
8092 static cmdline_parse_inst_t cmd_queue_rate_limit = {
8093 	.f = cmd_queue_rate_limit_parsed,
8094 	.data = (void *)0,
8095 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8096 		"Set rate limit for a queue on port_id",
8097 	.tokens = {
8098 		(void *)&cmd_queue_rate_limit_set,
8099 		(void *)&cmd_queue_rate_limit_port,
8100 		(void *)&cmd_queue_rate_limit_portnum,
8101 		(void *)&cmd_queue_rate_limit_queue,
8102 		(void *)&cmd_queue_rate_limit_queuenum,
8103 		(void *)&cmd_queue_rate_limit_rate,
8104 		(void *)&cmd_queue_rate_limit_ratenum,
8105 		NULL,
8106 	},
8107 };
8108 
8109 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8110 struct cmd_vf_rate_limit_result {
8111 	cmdline_fixed_string_t set;
8112 	cmdline_fixed_string_t port;
8113 	uint16_t port_num;
8114 	cmdline_fixed_string_t vf;
8115 	uint8_t vf_num;
8116 	cmdline_fixed_string_t rate;
8117 	uint32_t rate_num;
8118 	cmdline_fixed_string_t q_msk;
8119 	uint64_t q_msk_val;
8120 };
8121 
8122 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8123 		__rte_unused struct cmdline *cl,
8124 		__rte_unused void *data)
8125 {
8126 	struct cmd_vf_rate_limit_result *res = parsed_result;
8127 	int ret = 0;
8128 
8129 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8130 		&& (strcmp(res->vf, "vf") == 0)
8131 		&& (strcmp(res->rate, "rate") == 0)
8132 		&& (strcmp(res->q_msk, "queue_mask") == 0))
8133 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
8134 					res->rate_num, res->q_msk_val);
8135 	if (ret < 0)
8136 		fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8137 			strerror(-ret));
8138 
8139 }
8140 
8141 static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8142 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8143 				set, "set");
8144 static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8145 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8146 				port, "port");
8147 static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8148 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8149 				port_num, RTE_UINT16);
8150 static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8151 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8152 				vf, "vf");
8153 static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8154 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8155 				vf_num, RTE_UINT8);
8156 static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8157 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8158 				rate, "rate");
8159 static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8160 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8161 				rate_num, RTE_UINT32);
8162 static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8163 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8164 				q_msk, "queue_mask");
8165 static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8166 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8167 				q_msk_val, RTE_UINT64);
8168 
8169 static cmdline_parse_inst_t cmd_vf_rate_limit = {
8170 	.f = cmd_vf_rate_limit_parsed,
8171 	.data = (void *)0,
8172 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8173 		"queue_mask <queue_mask_value>: "
8174 		"Set rate limit for queues of VF on port_id",
8175 	.tokens = {
8176 		(void *)&cmd_vf_rate_limit_set,
8177 		(void *)&cmd_vf_rate_limit_port,
8178 		(void *)&cmd_vf_rate_limit_portnum,
8179 		(void *)&cmd_vf_rate_limit_vf,
8180 		(void *)&cmd_vf_rate_limit_vfnum,
8181 		(void *)&cmd_vf_rate_limit_rate,
8182 		(void *)&cmd_vf_rate_limit_ratenum,
8183 		(void *)&cmd_vf_rate_limit_q_msk,
8184 		(void *)&cmd_vf_rate_limit_q_msk_val,
8185 		NULL,
8186 	},
8187 };
8188 
8189 /* *** CONFIGURE TUNNEL UDP PORT *** */
8190 struct cmd_tunnel_udp_config {
8191 	cmdline_fixed_string_t rx_vxlan_port;
8192 	cmdline_fixed_string_t what;
8193 	uint16_t udp_port;
8194 	portid_t port_id;
8195 };
8196 
8197 static void
8198 cmd_tunnel_udp_config_parsed(void *parsed_result,
8199 			  __rte_unused struct cmdline *cl,
8200 			  __rte_unused void *data)
8201 {
8202 	struct cmd_tunnel_udp_config *res = parsed_result;
8203 	struct rte_eth_udp_tunnel tunnel_udp;
8204 	int ret;
8205 
8206 	tunnel_udp.udp_port = res->udp_port;
8207 	tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8208 
8209 	if (!strcmp(res->what, "add"))
8210 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8211 						      &tunnel_udp);
8212 	else
8213 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8214 							 &tunnel_udp);
8215 
8216 	if (ret < 0)
8217 		fprintf(stderr, "udp tunneling add error: (%s)\n",
8218 			strerror(-ret));
8219 }
8220 
8221 static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
8222 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8223 				rx_vxlan_port, "rx_vxlan_port");
8224 static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8225 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8226 				what, "add#rm");
8227 static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8228 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8229 				udp_port, RTE_UINT16);
8230 static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8231 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8232 				port_id, RTE_UINT16);
8233 
8234 static cmdline_parse_inst_t cmd_tunnel_udp_config = {
8235 	.f = cmd_tunnel_udp_config_parsed,
8236 	.data = (void *)0,
8237 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8238 		"Add/Remove a tunneling UDP port filter",
8239 	.tokens = {
8240 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
8241 		(void *)&cmd_tunnel_udp_config_what,
8242 		(void *)&cmd_tunnel_udp_config_udp_port,
8243 		(void *)&cmd_tunnel_udp_config_port_id,
8244 		NULL,
8245 	},
8246 };
8247 
8248 struct cmd_config_tunnel_udp_port {
8249 	cmdline_fixed_string_t port;
8250 	cmdline_fixed_string_t config;
8251 	portid_t port_id;
8252 	cmdline_fixed_string_t udp_tunnel_port;
8253 	cmdline_fixed_string_t action;
8254 	cmdline_fixed_string_t tunnel_type;
8255 	uint16_t udp_port;
8256 };
8257 
8258 static void
8259 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8260 			       __rte_unused struct cmdline *cl,
8261 			       __rte_unused void *data)
8262 {
8263 	struct cmd_config_tunnel_udp_port *res = parsed_result;
8264 	struct rte_eth_udp_tunnel tunnel_udp;
8265 	int ret = 0;
8266 
8267 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8268 		return;
8269 
8270 	tunnel_udp.udp_port = res->udp_port;
8271 
8272 	if (!strcmp(res->tunnel_type, "vxlan")) {
8273 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8274 	} else if (!strcmp(res->tunnel_type, "geneve")) {
8275 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
8276 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8277 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
8278 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
8279 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
8280 	} else {
8281 		fprintf(stderr, "Invalid tunnel type\n");
8282 		return;
8283 	}
8284 
8285 	if (!strcmp(res->action, "add"))
8286 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8287 						      &tunnel_udp);
8288 	else
8289 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8290 							 &tunnel_udp);
8291 
8292 	if (ret < 0)
8293 		fprintf(stderr, "udp tunneling port add error: (%s)\n",
8294 			strerror(-ret));
8295 }
8296 
8297 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8298 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8299 				 "port");
8300 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8301 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8302 				 "config");
8303 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8304 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8305 			      RTE_UINT16);
8306 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8307 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8308 				 udp_tunnel_port,
8309 				 "udp_tunnel_port");
8310 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8311 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8312 				 "add#rm");
8313 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8314 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8315 				 "vxlan#geneve#vxlan-gpe#ecpri");
8316 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8317 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8318 			      RTE_UINT16);
8319 
8320 static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8321 	.f = cmd_cfg_tunnel_udp_port_parsed,
8322 	.data = NULL,
8323 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
8324 		"geneve|vxlan-gpe|ecpri <udp_port>",
8325 	.tokens = {
8326 		(void *)&cmd_config_tunnel_udp_port_port,
8327 		(void *)&cmd_config_tunnel_udp_port_config,
8328 		(void *)&cmd_config_tunnel_udp_port_port_id,
8329 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
8330 		(void *)&cmd_config_tunnel_udp_port_action,
8331 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
8332 		(void *)&cmd_config_tunnel_udp_port_value,
8333 		NULL,
8334 	},
8335 };
8336 
8337 /* ******************************************************************************** */
8338 
8339 struct cmd_dump_result {
8340 	cmdline_fixed_string_t dump;
8341 };
8342 
8343 static void
8344 dump_struct_sizes(void)
8345 {
8346 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8347 	DUMP_SIZE(struct rte_mbuf);
8348 	DUMP_SIZE(struct rte_mempool);
8349 	DUMP_SIZE(struct rte_ring);
8350 #undef DUMP_SIZE
8351 }
8352 
8353 
8354 /* Dump the socket memory statistics on console */
8355 static void
8356 dump_socket_mem(FILE *f)
8357 {
8358 	struct rte_malloc_socket_stats socket_stats;
8359 	unsigned int i;
8360 	size_t total = 0;
8361 	size_t alloc = 0;
8362 	size_t free = 0;
8363 	unsigned int n_alloc = 0;
8364 	unsigned int n_free = 0;
8365 	static size_t last_allocs;
8366 	static size_t last_total;
8367 
8368 
8369 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
8370 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
8371 		    !socket_stats.heap_totalsz_bytes)
8372 			continue;
8373 		total += socket_stats.heap_totalsz_bytes;
8374 		alloc += socket_stats.heap_allocsz_bytes;
8375 		free += socket_stats.heap_freesz_bytes;
8376 		n_alloc += socket_stats.alloc_count;
8377 		n_free += socket_stats.free_count;
8378 		fprintf(f,
8379 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8380 			i,
8381 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
8382 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
8383 			(double)socket_stats.heap_allocsz_bytes * 100 /
8384 			(double)socket_stats.heap_totalsz_bytes,
8385 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
8386 			socket_stats.alloc_count,
8387 			socket_stats.free_count);
8388 	}
8389 	fprintf(f,
8390 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8391 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
8392 		total ? ((double)alloc * 100 / (double)total) : 0,
8393 		(double)free / (1024 * 1024),
8394 		n_alloc, n_free);
8395 	if (last_allocs)
8396 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
8397 			((double)total - (double)last_total) / (1024 * 1024),
8398 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
8399 	last_allocs = alloc;
8400 	last_total = total;
8401 }
8402 
8403 static void cmd_dump_parsed(void *parsed_result,
8404 			    __rte_unused struct cmdline *cl,
8405 			    __rte_unused void *data)
8406 {
8407 	struct cmd_dump_result *res = parsed_result;
8408 
8409 	if (!strcmp(res->dump, "dump_physmem"))
8410 		rte_dump_physmem_layout(stdout);
8411 	else if (!strcmp(res->dump, "dump_socket_mem"))
8412 		dump_socket_mem(stdout);
8413 	else if (!strcmp(res->dump, "dump_memzone"))
8414 		rte_memzone_dump(stdout);
8415 	else if (!strcmp(res->dump, "dump_struct_sizes"))
8416 		dump_struct_sizes();
8417 	else if (!strcmp(res->dump, "dump_ring"))
8418 		rte_ring_list_dump(stdout);
8419 	else if (!strcmp(res->dump, "dump_mempool"))
8420 		rte_mempool_list_dump(stdout);
8421 	else if (!strcmp(res->dump, "dump_devargs"))
8422 		rte_devargs_dump(stdout);
8423 	else if (!strcmp(res->dump, "dump_lcores"))
8424 		rte_lcore_dump(stdout);
8425 #ifndef RTE_EXEC_ENV_WINDOWS
8426 	else if (!strcmp(res->dump, "dump_trace"))
8427 		rte_trace_save();
8428 #endif
8429 	else if (!strcmp(res->dump, "dump_log_types"))
8430 		rte_log_dump(stdout);
8431 }
8432 
8433 static cmdline_parse_token_string_t cmd_dump_dump =
8434 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8435 		"dump_physmem#"
8436 		"dump_memzone#"
8437 		"dump_socket_mem#"
8438 		"dump_struct_sizes#"
8439 		"dump_ring#"
8440 		"dump_mempool#"
8441 		"dump_devargs#"
8442 		"dump_lcores#"
8443 #ifndef RTE_EXEC_ENV_WINDOWS
8444 		"dump_trace#"
8445 #endif
8446 		"dump_log_types");
8447 
8448 static cmdline_parse_inst_t cmd_dump = {
8449 	.f = cmd_dump_parsed,  /* function to call */
8450 	.data = NULL,      /* 2nd arg of func */
8451 	.help_str = "Dump status",
8452 	.tokens = {        /* token list, NULL terminated */
8453 		(void *)&cmd_dump_dump,
8454 		NULL,
8455 	},
8456 };
8457 
8458 /* ******************************************************************************** */
8459 
8460 struct cmd_dump_one_result {
8461 	cmdline_fixed_string_t dump;
8462 	cmdline_fixed_string_t name;
8463 };
8464 
8465 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8466 				__rte_unused void *data)
8467 {
8468 	struct cmd_dump_one_result *res = parsed_result;
8469 
8470 	if (!strcmp(res->dump, "dump_ring")) {
8471 		struct rte_ring *r;
8472 		r = rte_ring_lookup(res->name);
8473 		if (r == NULL) {
8474 			cmdline_printf(cl, "Cannot find ring\n");
8475 			return;
8476 		}
8477 		rte_ring_dump(stdout, r);
8478 	} else if (!strcmp(res->dump, "dump_mempool")) {
8479 		struct rte_mempool *mp;
8480 		mp = rte_mempool_lookup(res->name);
8481 		if (mp == NULL) {
8482 			cmdline_printf(cl, "Cannot find mempool\n");
8483 			return;
8484 		}
8485 		rte_mempool_dump(stdout, mp);
8486 	}
8487 }
8488 
8489 static cmdline_parse_token_string_t cmd_dump_one_dump =
8490 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8491 				 "dump_ring#dump_mempool");
8492 
8493 static cmdline_parse_token_string_t cmd_dump_one_name =
8494 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8495 
8496 static cmdline_parse_inst_t cmd_dump_one = {
8497 	.f = cmd_dump_one_parsed,  /* function to call */
8498 	.data = NULL,      /* 2nd arg of func */
8499 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8500 	.tokens = {        /* token list, NULL terminated */
8501 		(void *)&cmd_dump_one_dump,
8502 		(void *)&cmd_dump_one_name,
8503 		NULL,
8504 	},
8505 };
8506 
8507 /* *** Filters Control *** */
8508 
8509 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8510 do { \
8511 	if ((ip_addr).family == AF_INET) \
8512 		(ip) = (ip_addr).addr.ipv4.s_addr; \
8513 	else { \
8514 		fprintf(stderr, "invalid parameter.\n"); \
8515 		return; \
8516 	} \
8517 } while (0)
8518 
8519 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8520 do { \
8521 	if ((ip_addr).family == AF_INET6) \
8522 		rte_memcpy(&(ip), \
8523 				 &((ip_addr).addr.ipv6), \
8524 				 sizeof(struct in6_addr)); \
8525 	else { \
8526 		fprintf(stderr, "invalid parameter.\n"); \
8527 		return; \
8528 	} \
8529 } while (0)
8530 
8531 /* Generic flow interface command. */
8532 extern cmdline_parse_inst_t cmd_flow;
8533 
8534 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
8535 struct cmd_mcast_addr_result {
8536 	cmdline_fixed_string_t mcast_addr_cmd;
8537 	cmdline_fixed_string_t what;
8538 	uint16_t port_num;
8539 	struct rte_ether_addr mc_addr;
8540 };
8541 
8542 static void cmd_mcast_addr_parsed(void *parsed_result,
8543 		__rte_unused struct cmdline *cl,
8544 		__rte_unused void *data)
8545 {
8546 	struct cmd_mcast_addr_result *res = parsed_result;
8547 
8548 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
8549 		fprintf(stderr,
8550 			"Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
8551 			RTE_ETHER_ADDR_BYTES(&res->mc_addr));
8552 		return;
8553 	}
8554 	if (strcmp(res->what, "add") == 0)
8555 		mcast_addr_add(res->port_num, &res->mc_addr);
8556 	else
8557 		mcast_addr_remove(res->port_num, &res->mc_addr);
8558 }
8559 
8560 static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
8561 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8562 				 mcast_addr_cmd, "mcast_addr");
8563 static cmdline_parse_token_string_t cmd_mcast_addr_what =
8564 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8565 				 "add#remove");
8566 static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
8567 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8568 				 RTE_UINT16);
8569 static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
8570 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8571 
8572 static cmdline_parse_inst_t cmd_mcast_addr = {
8573 	.f = cmd_mcast_addr_parsed,
8574 	.data = (void *)0,
8575 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
8576 		"Add/Remove multicast MAC address on port_id",
8577 	.tokens = {
8578 		(void *)&cmd_mcast_addr_cmd,
8579 		(void *)&cmd_mcast_addr_what,
8580 		(void *)&cmd_mcast_addr_portnum,
8581 		(void *)&cmd_mcast_addr_addr,
8582 		NULL,
8583 	},
8584 };
8585 
8586 /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
8587 struct cmd_mcast_addr_flush_result {
8588 	cmdline_fixed_string_t mcast_addr_cmd;
8589 	cmdline_fixed_string_t what;
8590 	uint16_t port_num;
8591 };
8592 
8593 static void cmd_mcast_addr_flush_parsed(void *parsed_result,
8594 		__rte_unused struct cmdline *cl,
8595 		__rte_unused void *data)
8596 {
8597 	struct cmd_mcast_addr_flush_result *res = parsed_result;
8598 
8599 	mcast_addr_flush(res->port_num);
8600 }
8601 
8602 static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
8603 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8604 				 mcast_addr_cmd, "mcast_addr");
8605 static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
8606 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8607 				 "flush");
8608 static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
8609 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8610 				 RTE_UINT16);
8611 
8612 static cmdline_parse_inst_t cmd_mcast_addr_flush = {
8613 	.f = cmd_mcast_addr_flush_parsed,
8614 	.data = (void *)0,
8615 	.help_str = "mcast_addr flush <port_id> : "
8616 		"flush all multicast MAC addresses on port_id",
8617 	.tokens = {
8618 		(void *)&cmd_mcast_addr_flush_cmd,
8619 		(void *)&cmd_mcast_addr_flush_what,
8620 		(void *)&cmd_mcast_addr_flush_portnum,
8621 		NULL,
8622 	},
8623 };
8624 
8625 /* vf vlan anti spoof configuration */
8626 
8627 /* Common result structure for vf vlan anti spoof */
8628 struct cmd_vf_vlan_anti_spoof_result {
8629 	cmdline_fixed_string_t set;
8630 	cmdline_fixed_string_t vf;
8631 	cmdline_fixed_string_t vlan;
8632 	cmdline_fixed_string_t antispoof;
8633 	portid_t port_id;
8634 	uint32_t vf_id;
8635 	cmdline_fixed_string_t on_off;
8636 };
8637 
8638 /* Common CLI fields for vf vlan anti spoof enable disable */
8639 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
8640 	TOKEN_STRING_INITIALIZER
8641 		(struct cmd_vf_vlan_anti_spoof_result,
8642 		 set, "set");
8643 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
8644 	TOKEN_STRING_INITIALIZER
8645 		(struct cmd_vf_vlan_anti_spoof_result,
8646 		 vf, "vf");
8647 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
8648 	TOKEN_STRING_INITIALIZER
8649 		(struct cmd_vf_vlan_anti_spoof_result,
8650 		 vlan, "vlan");
8651 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
8652 	TOKEN_STRING_INITIALIZER
8653 		(struct cmd_vf_vlan_anti_spoof_result,
8654 		 antispoof, "antispoof");
8655 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
8656 	TOKEN_NUM_INITIALIZER
8657 		(struct cmd_vf_vlan_anti_spoof_result,
8658 		 port_id, RTE_UINT16);
8659 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
8660 	TOKEN_NUM_INITIALIZER
8661 		(struct cmd_vf_vlan_anti_spoof_result,
8662 		 vf_id, RTE_UINT32);
8663 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
8664 	TOKEN_STRING_INITIALIZER
8665 		(struct cmd_vf_vlan_anti_spoof_result,
8666 		 on_off, "on#off");
8667 
8668 static void
8669 cmd_set_vf_vlan_anti_spoof_parsed(
8670 	void *parsed_result,
8671 	__rte_unused struct cmdline *cl,
8672 	__rte_unused void *data)
8673 {
8674 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
8675 	int ret = -ENOTSUP;
8676 
8677 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8678 
8679 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8680 		return;
8681 
8682 #ifdef RTE_NET_IXGBE
8683 	if (ret == -ENOTSUP)
8684 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
8685 				res->vf_id, is_on);
8686 #endif
8687 #ifdef RTE_NET_I40E
8688 	if (ret == -ENOTSUP)
8689 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
8690 				res->vf_id, is_on);
8691 #endif
8692 #ifdef RTE_NET_BNXT
8693 	if (ret == -ENOTSUP)
8694 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
8695 				res->vf_id, is_on);
8696 #endif
8697 
8698 	switch (ret) {
8699 	case 0:
8700 		break;
8701 	case -EINVAL:
8702 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
8703 		break;
8704 	case -ENODEV:
8705 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
8706 		break;
8707 	case -ENOTSUP:
8708 		fprintf(stderr, "function not implemented\n");
8709 		break;
8710 	default:
8711 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8712 	}
8713 }
8714 
8715 static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
8716 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
8717 	.data = NULL,
8718 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
8719 	.tokens = {
8720 		(void *)&cmd_vf_vlan_anti_spoof_set,
8721 		(void *)&cmd_vf_vlan_anti_spoof_vf,
8722 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
8723 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
8724 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
8725 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
8726 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
8727 		NULL,
8728 	},
8729 };
8730 
8731 /* vf mac anti spoof configuration */
8732 
8733 /* Common result structure for vf mac anti spoof */
8734 struct cmd_vf_mac_anti_spoof_result {
8735 	cmdline_fixed_string_t set;
8736 	cmdline_fixed_string_t vf;
8737 	cmdline_fixed_string_t mac;
8738 	cmdline_fixed_string_t antispoof;
8739 	portid_t port_id;
8740 	uint32_t vf_id;
8741 	cmdline_fixed_string_t on_off;
8742 };
8743 
8744 /* Common CLI fields for vf mac anti spoof enable disable */
8745 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
8746 	TOKEN_STRING_INITIALIZER
8747 		(struct cmd_vf_mac_anti_spoof_result,
8748 		 set, "set");
8749 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
8750 	TOKEN_STRING_INITIALIZER
8751 		(struct cmd_vf_mac_anti_spoof_result,
8752 		 vf, "vf");
8753 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
8754 	TOKEN_STRING_INITIALIZER
8755 		(struct cmd_vf_mac_anti_spoof_result,
8756 		 mac, "mac");
8757 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
8758 	TOKEN_STRING_INITIALIZER
8759 		(struct cmd_vf_mac_anti_spoof_result,
8760 		 antispoof, "antispoof");
8761 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
8762 	TOKEN_NUM_INITIALIZER
8763 		(struct cmd_vf_mac_anti_spoof_result,
8764 		 port_id, RTE_UINT16);
8765 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
8766 	TOKEN_NUM_INITIALIZER
8767 		(struct cmd_vf_mac_anti_spoof_result,
8768 		 vf_id, RTE_UINT32);
8769 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
8770 	TOKEN_STRING_INITIALIZER
8771 		(struct cmd_vf_mac_anti_spoof_result,
8772 		 on_off, "on#off");
8773 
8774 static void
8775 cmd_set_vf_mac_anti_spoof_parsed(
8776 	void *parsed_result,
8777 	__rte_unused struct cmdline *cl,
8778 	__rte_unused void *data)
8779 {
8780 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
8781 	int ret = -ENOTSUP;
8782 
8783 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8784 
8785 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8786 		return;
8787 
8788 #ifdef RTE_NET_IXGBE
8789 	if (ret == -ENOTSUP)
8790 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
8791 			res->vf_id, is_on);
8792 #endif
8793 #ifdef RTE_NET_I40E
8794 	if (ret == -ENOTSUP)
8795 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
8796 			res->vf_id, is_on);
8797 #endif
8798 #ifdef RTE_NET_BNXT
8799 	if (ret == -ENOTSUP)
8800 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
8801 			res->vf_id, is_on);
8802 #endif
8803 
8804 	switch (ret) {
8805 	case 0:
8806 		break;
8807 	case -EINVAL:
8808 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
8809 			res->vf_id, is_on);
8810 		break;
8811 	case -ENODEV:
8812 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
8813 		break;
8814 	case -ENOTSUP:
8815 		fprintf(stderr, "function not implemented\n");
8816 		break;
8817 	default:
8818 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8819 	}
8820 }
8821 
8822 static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
8823 	.f = cmd_set_vf_mac_anti_spoof_parsed,
8824 	.data = NULL,
8825 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
8826 	.tokens = {
8827 		(void *)&cmd_vf_mac_anti_spoof_set,
8828 		(void *)&cmd_vf_mac_anti_spoof_vf,
8829 		(void *)&cmd_vf_mac_anti_spoof_mac,
8830 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
8831 		(void *)&cmd_vf_mac_anti_spoof_port_id,
8832 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
8833 		(void *)&cmd_vf_mac_anti_spoof_on_off,
8834 		NULL,
8835 	},
8836 };
8837 
8838 /* vf vlan strip queue configuration */
8839 
8840 /* Common result structure for vf mac anti spoof */
8841 struct cmd_vf_vlan_stripq_result {
8842 	cmdline_fixed_string_t set;
8843 	cmdline_fixed_string_t vf;
8844 	cmdline_fixed_string_t vlan;
8845 	cmdline_fixed_string_t stripq;
8846 	portid_t port_id;
8847 	uint16_t vf_id;
8848 	cmdline_fixed_string_t on_off;
8849 };
8850 
8851 /* Common CLI fields for vf vlan strip enable disable */
8852 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
8853 	TOKEN_STRING_INITIALIZER
8854 		(struct cmd_vf_vlan_stripq_result,
8855 		 set, "set");
8856 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
8857 	TOKEN_STRING_INITIALIZER
8858 		(struct cmd_vf_vlan_stripq_result,
8859 		 vf, "vf");
8860 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
8861 	TOKEN_STRING_INITIALIZER
8862 		(struct cmd_vf_vlan_stripq_result,
8863 		 vlan, "vlan");
8864 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
8865 	TOKEN_STRING_INITIALIZER
8866 		(struct cmd_vf_vlan_stripq_result,
8867 		 stripq, "stripq");
8868 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
8869 	TOKEN_NUM_INITIALIZER
8870 		(struct cmd_vf_vlan_stripq_result,
8871 		 port_id, RTE_UINT16);
8872 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
8873 	TOKEN_NUM_INITIALIZER
8874 		(struct cmd_vf_vlan_stripq_result,
8875 		 vf_id, RTE_UINT16);
8876 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
8877 	TOKEN_STRING_INITIALIZER
8878 		(struct cmd_vf_vlan_stripq_result,
8879 		 on_off, "on#off");
8880 
8881 static void
8882 cmd_set_vf_vlan_stripq_parsed(
8883 	void *parsed_result,
8884 	__rte_unused struct cmdline *cl,
8885 	__rte_unused void *data)
8886 {
8887 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
8888 	int ret = -ENOTSUP;
8889 
8890 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8891 
8892 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8893 		return;
8894 
8895 #ifdef RTE_NET_IXGBE
8896 	if (ret == -ENOTSUP)
8897 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
8898 			res->vf_id, is_on);
8899 #endif
8900 #ifdef RTE_NET_I40E
8901 	if (ret == -ENOTSUP)
8902 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
8903 			res->vf_id, is_on);
8904 #endif
8905 #ifdef RTE_NET_BNXT
8906 	if (ret == -ENOTSUP)
8907 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
8908 			res->vf_id, is_on);
8909 #endif
8910 
8911 	switch (ret) {
8912 	case 0:
8913 		break;
8914 	case -EINVAL:
8915 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
8916 			res->vf_id, is_on);
8917 		break;
8918 	case -ENODEV:
8919 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
8920 		break;
8921 	case -ENOTSUP:
8922 		fprintf(stderr, "function not implemented\n");
8923 		break;
8924 	default:
8925 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8926 	}
8927 }
8928 
8929 static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
8930 	.f = cmd_set_vf_vlan_stripq_parsed,
8931 	.data = NULL,
8932 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
8933 	.tokens = {
8934 		(void *)&cmd_vf_vlan_stripq_set,
8935 		(void *)&cmd_vf_vlan_stripq_vf,
8936 		(void *)&cmd_vf_vlan_stripq_vlan,
8937 		(void *)&cmd_vf_vlan_stripq_stripq,
8938 		(void *)&cmd_vf_vlan_stripq_port_id,
8939 		(void *)&cmd_vf_vlan_stripq_vf_id,
8940 		(void *)&cmd_vf_vlan_stripq_on_off,
8941 		NULL,
8942 	},
8943 };
8944 
8945 /* vf vlan insert configuration */
8946 
8947 /* Common result structure for vf vlan insert */
8948 struct cmd_vf_vlan_insert_result {
8949 	cmdline_fixed_string_t set;
8950 	cmdline_fixed_string_t vf;
8951 	cmdline_fixed_string_t vlan;
8952 	cmdline_fixed_string_t insert;
8953 	portid_t port_id;
8954 	uint16_t vf_id;
8955 	uint16_t vlan_id;
8956 };
8957 
8958 /* Common CLI fields for vf vlan insert enable disable */
8959 static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
8960 	TOKEN_STRING_INITIALIZER
8961 		(struct cmd_vf_vlan_insert_result,
8962 		 set, "set");
8963 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
8964 	TOKEN_STRING_INITIALIZER
8965 		(struct cmd_vf_vlan_insert_result,
8966 		 vf, "vf");
8967 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
8968 	TOKEN_STRING_INITIALIZER
8969 		(struct cmd_vf_vlan_insert_result,
8970 		 vlan, "vlan");
8971 static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
8972 	TOKEN_STRING_INITIALIZER
8973 		(struct cmd_vf_vlan_insert_result,
8974 		 insert, "insert");
8975 static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
8976 	TOKEN_NUM_INITIALIZER
8977 		(struct cmd_vf_vlan_insert_result,
8978 		 port_id, RTE_UINT16);
8979 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
8980 	TOKEN_NUM_INITIALIZER
8981 		(struct cmd_vf_vlan_insert_result,
8982 		 vf_id, RTE_UINT16);
8983 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
8984 	TOKEN_NUM_INITIALIZER
8985 		(struct cmd_vf_vlan_insert_result,
8986 		 vlan_id, RTE_UINT16);
8987 
8988 static void
8989 cmd_set_vf_vlan_insert_parsed(
8990 	void *parsed_result,
8991 	__rte_unused struct cmdline *cl,
8992 	__rte_unused void *data)
8993 {
8994 	struct cmd_vf_vlan_insert_result *res = parsed_result;
8995 	int ret = -ENOTSUP;
8996 
8997 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8998 		return;
8999 
9000 #ifdef RTE_NET_IXGBE
9001 	if (ret == -ENOTSUP)
9002 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9003 			res->vlan_id);
9004 #endif
9005 #ifdef RTE_NET_I40E
9006 	if (ret == -ENOTSUP)
9007 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9008 			res->vlan_id);
9009 #endif
9010 #ifdef RTE_NET_BNXT
9011 	if (ret == -ENOTSUP)
9012 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9013 			res->vlan_id);
9014 #endif
9015 
9016 	switch (ret) {
9017 	case 0:
9018 		break;
9019 	case -EINVAL:
9020 		fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9021 			res->vf_id, res->vlan_id);
9022 		break;
9023 	case -ENODEV:
9024 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
9025 		break;
9026 	case -ENOTSUP:
9027 		fprintf(stderr, "function not implemented\n");
9028 		break;
9029 	default:
9030 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9031 	}
9032 }
9033 
9034 static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9035 	.f = cmd_set_vf_vlan_insert_parsed,
9036 	.data = NULL,
9037 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9038 	.tokens = {
9039 		(void *)&cmd_vf_vlan_insert_set,
9040 		(void *)&cmd_vf_vlan_insert_vf,
9041 		(void *)&cmd_vf_vlan_insert_vlan,
9042 		(void *)&cmd_vf_vlan_insert_insert,
9043 		(void *)&cmd_vf_vlan_insert_port_id,
9044 		(void *)&cmd_vf_vlan_insert_vf_id,
9045 		(void *)&cmd_vf_vlan_insert_vlan_id,
9046 		NULL,
9047 	},
9048 };
9049 
9050 /* tx loopback configuration */
9051 
9052 /* Common result structure for tx loopback */
9053 struct cmd_tx_loopback_result {
9054 	cmdline_fixed_string_t set;
9055 	cmdline_fixed_string_t tx;
9056 	cmdline_fixed_string_t loopback;
9057 	portid_t port_id;
9058 	cmdline_fixed_string_t on_off;
9059 };
9060 
9061 /* Common CLI fields for tx loopback enable disable */
9062 static cmdline_parse_token_string_t cmd_tx_loopback_set =
9063 	TOKEN_STRING_INITIALIZER
9064 		(struct cmd_tx_loopback_result,
9065 		 set, "set");
9066 static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9067 	TOKEN_STRING_INITIALIZER
9068 		(struct cmd_tx_loopback_result,
9069 		 tx, "tx");
9070 static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9071 	TOKEN_STRING_INITIALIZER
9072 		(struct cmd_tx_loopback_result,
9073 		 loopback, "loopback");
9074 static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9075 	TOKEN_NUM_INITIALIZER
9076 		(struct cmd_tx_loopback_result,
9077 		 port_id, RTE_UINT16);
9078 static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
9079 	TOKEN_STRING_INITIALIZER
9080 		(struct cmd_tx_loopback_result,
9081 		 on_off, "on#off");
9082 
9083 static void
9084 cmd_set_tx_loopback_parsed(
9085 	void *parsed_result,
9086 	__rte_unused struct cmdline *cl,
9087 	__rte_unused void *data)
9088 {
9089 	struct cmd_tx_loopback_result *res = parsed_result;
9090 	int ret = -ENOTSUP;
9091 
9092 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9093 
9094 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9095 		return;
9096 
9097 #ifdef RTE_NET_IXGBE
9098 	if (ret == -ENOTSUP)
9099 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
9100 #endif
9101 #ifdef RTE_NET_I40E
9102 	if (ret == -ENOTSUP)
9103 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
9104 #endif
9105 #ifdef RTE_NET_BNXT
9106 	if (ret == -ENOTSUP)
9107 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
9108 #endif
9109 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
9110 	if (ret == -ENOTSUP)
9111 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
9112 #endif
9113 
9114 	switch (ret) {
9115 	case 0:
9116 		break;
9117 	case -EINVAL:
9118 		fprintf(stderr, "invalid is_on %d\n", is_on);
9119 		break;
9120 	case -ENODEV:
9121 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
9122 		break;
9123 	case -ENOTSUP:
9124 		fprintf(stderr, "function not implemented\n");
9125 		break;
9126 	default:
9127 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9128 	}
9129 }
9130 
9131 static cmdline_parse_inst_t cmd_set_tx_loopback = {
9132 	.f = cmd_set_tx_loopback_parsed,
9133 	.data = NULL,
9134 	.help_str = "set tx loopback <port_id> on|off",
9135 	.tokens = {
9136 		(void *)&cmd_tx_loopback_set,
9137 		(void *)&cmd_tx_loopback_tx,
9138 		(void *)&cmd_tx_loopback_loopback,
9139 		(void *)&cmd_tx_loopback_port_id,
9140 		(void *)&cmd_tx_loopback_on_off,
9141 		NULL,
9142 	},
9143 };
9144 
9145 /* all queues drop enable configuration */
9146 
9147 /* Common result structure for all queues drop enable */
9148 struct cmd_all_queues_drop_en_result {
9149 	cmdline_fixed_string_t set;
9150 	cmdline_fixed_string_t all;
9151 	cmdline_fixed_string_t queues;
9152 	cmdline_fixed_string_t drop;
9153 	portid_t port_id;
9154 	cmdline_fixed_string_t on_off;
9155 };
9156 
9157 /* Common CLI fields for tx loopback enable disable */
9158 static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
9159 	TOKEN_STRING_INITIALIZER
9160 		(struct cmd_all_queues_drop_en_result,
9161 		 set, "set");
9162 static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
9163 	TOKEN_STRING_INITIALIZER
9164 		(struct cmd_all_queues_drop_en_result,
9165 		 all, "all");
9166 static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
9167 	TOKEN_STRING_INITIALIZER
9168 		(struct cmd_all_queues_drop_en_result,
9169 		 queues, "queues");
9170 static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
9171 	TOKEN_STRING_INITIALIZER
9172 		(struct cmd_all_queues_drop_en_result,
9173 		 drop, "drop");
9174 static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
9175 	TOKEN_NUM_INITIALIZER
9176 		(struct cmd_all_queues_drop_en_result,
9177 		 port_id, RTE_UINT16);
9178 static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
9179 	TOKEN_STRING_INITIALIZER
9180 		(struct cmd_all_queues_drop_en_result,
9181 		 on_off, "on#off");
9182 
9183 static void
9184 cmd_set_all_queues_drop_en_parsed(
9185 	void *parsed_result,
9186 	__rte_unused struct cmdline *cl,
9187 	__rte_unused void *data)
9188 {
9189 	struct cmd_all_queues_drop_en_result *res = parsed_result;
9190 	int ret = -ENOTSUP;
9191 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9192 
9193 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9194 		return;
9195 
9196 #ifdef RTE_NET_IXGBE
9197 	if (ret == -ENOTSUP)
9198 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
9199 #endif
9200 #ifdef RTE_NET_BNXT
9201 	if (ret == -ENOTSUP)
9202 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
9203 #endif
9204 	switch (ret) {
9205 	case 0:
9206 		break;
9207 	case -EINVAL:
9208 		fprintf(stderr, "invalid is_on %d\n", is_on);
9209 		break;
9210 	case -ENODEV:
9211 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
9212 		break;
9213 	case -ENOTSUP:
9214 		fprintf(stderr, "function not implemented\n");
9215 		break;
9216 	default:
9217 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9218 	}
9219 }
9220 
9221 static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
9222 	.f = cmd_set_all_queues_drop_en_parsed,
9223 	.data = NULL,
9224 	.help_str = "set all queues drop <port_id> on|off",
9225 	.tokens = {
9226 		(void *)&cmd_all_queues_drop_en_set,
9227 		(void *)&cmd_all_queues_drop_en_all,
9228 		(void *)&cmd_all_queues_drop_en_queues,
9229 		(void *)&cmd_all_queues_drop_en_drop,
9230 		(void *)&cmd_all_queues_drop_en_port_id,
9231 		(void *)&cmd_all_queues_drop_en_on_off,
9232 		NULL,
9233 	},
9234 };
9235 
9236 /* vf mac address configuration */
9237 
9238 /* Common result structure for vf mac address */
9239 struct cmd_set_vf_mac_addr_result {
9240 	cmdline_fixed_string_t set;
9241 	cmdline_fixed_string_t vf;
9242 	cmdline_fixed_string_t mac;
9243 	cmdline_fixed_string_t addr;
9244 	portid_t port_id;
9245 	uint16_t vf_id;
9246 	struct rte_ether_addr mac_addr;
9247 
9248 };
9249 
9250 /* Common CLI fields for vf split drop enable disable */
9251 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
9252 	TOKEN_STRING_INITIALIZER
9253 		(struct cmd_set_vf_mac_addr_result,
9254 		 set, "set");
9255 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
9256 	TOKEN_STRING_INITIALIZER
9257 		(struct cmd_set_vf_mac_addr_result,
9258 		 vf, "vf");
9259 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
9260 	TOKEN_STRING_INITIALIZER
9261 		(struct cmd_set_vf_mac_addr_result,
9262 		 mac, "mac");
9263 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
9264 	TOKEN_STRING_INITIALIZER
9265 		(struct cmd_set_vf_mac_addr_result,
9266 		 addr, "addr");
9267 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
9268 	TOKEN_NUM_INITIALIZER
9269 		(struct cmd_set_vf_mac_addr_result,
9270 		 port_id, RTE_UINT16);
9271 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
9272 	TOKEN_NUM_INITIALIZER
9273 		(struct cmd_set_vf_mac_addr_result,
9274 		 vf_id, RTE_UINT16);
9275 static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
9276 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
9277 		 mac_addr);
9278 
9279 static void
9280 cmd_set_vf_mac_addr_parsed(
9281 	void *parsed_result,
9282 	__rte_unused struct cmdline *cl,
9283 	__rte_unused void *data)
9284 {
9285 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
9286 	int ret = -ENOTSUP;
9287 
9288 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9289 		return;
9290 
9291 #ifdef RTE_NET_IXGBE
9292 	if (ret == -ENOTSUP)
9293 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
9294 				&res->mac_addr);
9295 #endif
9296 #ifdef RTE_NET_I40E
9297 	if (ret == -ENOTSUP)
9298 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
9299 				&res->mac_addr);
9300 #endif
9301 #ifdef RTE_NET_BNXT
9302 	if (ret == -ENOTSUP)
9303 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
9304 				&res->mac_addr);
9305 #endif
9306 
9307 	switch (ret) {
9308 	case 0:
9309 		break;
9310 	case -EINVAL:
9311 		fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
9312 		break;
9313 	case -ENODEV:
9314 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
9315 		break;
9316 	case -ENOTSUP:
9317 		fprintf(stderr, "function not implemented\n");
9318 		break;
9319 	default:
9320 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9321 	}
9322 }
9323 
9324 static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
9325 	.f = cmd_set_vf_mac_addr_parsed,
9326 	.data = NULL,
9327 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
9328 	.tokens = {
9329 		(void *)&cmd_set_vf_mac_addr_set,
9330 		(void *)&cmd_set_vf_mac_addr_vf,
9331 		(void *)&cmd_set_vf_mac_addr_mac,
9332 		(void *)&cmd_set_vf_mac_addr_addr,
9333 		(void *)&cmd_set_vf_mac_addr_port_id,
9334 		(void *)&cmd_set_vf_mac_addr_vf_id,
9335 		(void *)&cmd_set_vf_mac_addr_mac_addr,
9336 		NULL,
9337 	},
9338 };
9339 
9340 /** Set VXLAN encapsulation details */
9341 struct cmd_set_vxlan_result {
9342 	cmdline_fixed_string_t set;
9343 	cmdline_fixed_string_t vxlan;
9344 	cmdline_fixed_string_t pos_token;
9345 	cmdline_fixed_string_t ip_version;
9346 	uint32_t vlan_present:1;
9347 	uint32_t vni;
9348 	uint16_t udp_src;
9349 	uint16_t udp_dst;
9350 	cmdline_ipaddr_t ip_src;
9351 	cmdline_ipaddr_t ip_dst;
9352 	uint16_t tci;
9353 	uint8_t tos;
9354 	uint8_t ttl;
9355 	struct rte_ether_addr eth_src;
9356 	struct rte_ether_addr eth_dst;
9357 };
9358 
9359 static cmdline_parse_token_string_t cmd_set_vxlan_set =
9360 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
9361 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
9362 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
9363 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
9364 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9365 				 "vxlan-tos-ttl");
9366 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
9367 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9368 				 "vxlan-with-vlan");
9369 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
9370 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9371 				 "ip-version");
9372 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
9373 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
9374 				 "ipv4#ipv6");
9375 static cmdline_parse_token_string_t cmd_set_vxlan_vni =
9376 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9377 				 "vni");
9378 static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
9379 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
9380 static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
9381 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9382 				 "udp-src");
9383 static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
9384 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
9385 static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
9386 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9387 				 "udp-dst");
9388 static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
9389 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
9390 static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
9391 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9392 				 "ip-tos");
9393 static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
9394 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
9395 static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
9396 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9397 				 "ip-ttl");
9398 static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
9399 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
9400 static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
9401 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9402 				 "ip-src");
9403 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
9404 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
9405 static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
9406 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9407 				 "ip-dst");
9408 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
9409 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
9410 static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
9411 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9412 				 "vlan-tci");
9413 static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
9414 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
9415 static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
9416 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9417 				 "eth-src");
9418 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
9419 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
9420 static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
9421 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9422 				 "eth-dst");
9423 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
9424 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
9425 
9426 static void cmd_set_vxlan_parsed(void *parsed_result,
9427 	__rte_unused struct cmdline *cl,
9428 	__rte_unused void *data)
9429 {
9430 	struct cmd_set_vxlan_result *res = parsed_result;
9431 	union {
9432 		uint32_t vxlan_id;
9433 		uint8_t vni[4];
9434 	} id = {
9435 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
9436 	};
9437 
9438 	vxlan_encap_conf.select_tos_ttl = 0;
9439 	if (strcmp(res->vxlan, "vxlan") == 0)
9440 		vxlan_encap_conf.select_vlan = 0;
9441 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
9442 		vxlan_encap_conf.select_vlan = 1;
9443 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
9444 		vxlan_encap_conf.select_vlan = 0;
9445 		vxlan_encap_conf.select_tos_ttl = 1;
9446 	}
9447 	if (strcmp(res->ip_version, "ipv4") == 0)
9448 		vxlan_encap_conf.select_ipv4 = 1;
9449 	else if (strcmp(res->ip_version, "ipv6") == 0)
9450 		vxlan_encap_conf.select_ipv4 = 0;
9451 	else
9452 		return;
9453 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
9454 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
9455 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
9456 	vxlan_encap_conf.ip_tos = res->tos;
9457 	vxlan_encap_conf.ip_ttl = res->ttl;
9458 	if (vxlan_encap_conf.select_ipv4) {
9459 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
9460 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
9461 	} else {
9462 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
9463 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
9464 	}
9465 	if (vxlan_encap_conf.select_vlan)
9466 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9467 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
9468 		   RTE_ETHER_ADDR_LEN);
9469 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9470 		   RTE_ETHER_ADDR_LEN);
9471 }
9472 
9473 static cmdline_parse_inst_t cmd_set_vxlan = {
9474 	.f = cmd_set_vxlan_parsed,
9475 	.data = NULL,
9476 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
9477 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
9478 		" eth-src <eth-src> eth-dst <eth-dst>",
9479 	.tokens = {
9480 		(void *)&cmd_set_vxlan_set,
9481 		(void *)&cmd_set_vxlan_vxlan,
9482 		(void *)&cmd_set_vxlan_ip_version,
9483 		(void *)&cmd_set_vxlan_ip_version_value,
9484 		(void *)&cmd_set_vxlan_vni,
9485 		(void *)&cmd_set_vxlan_vni_value,
9486 		(void *)&cmd_set_vxlan_udp_src,
9487 		(void *)&cmd_set_vxlan_udp_src_value,
9488 		(void *)&cmd_set_vxlan_udp_dst,
9489 		(void *)&cmd_set_vxlan_udp_dst_value,
9490 		(void *)&cmd_set_vxlan_ip_src,
9491 		(void *)&cmd_set_vxlan_ip_src_value,
9492 		(void *)&cmd_set_vxlan_ip_dst,
9493 		(void *)&cmd_set_vxlan_ip_dst_value,
9494 		(void *)&cmd_set_vxlan_eth_src,
9495 		(void *)&cmd_set_vxlan_eth_src_value,
9496 		(void *)&cmd_set_vxlan_eth_dst,
9497 		(void *)&cmd_set_vxlan_eth_dst_value,
9498 		NULL,
9499 	},
9500 };
9501 
9502 static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
9503 	.f = cmd_set_vxlan_parsed,
9504 	.data = NULL,
9505 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
9506 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
9507 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9508 		" eth-dst <eth-dst>",
9509 	.tokens = {
9510 		(void *)&cmd_set_vxlan_set,
9511 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
9512 		(void *)&cmd_set_vxlan_ip_version,
9513 		(void *)&cmd_set_vxlan_ip_version_value,
9514 		(void *)&cmd_set_vxlan_vni,
9515 		(void *)&cmd_set_vxlan_vni_value,
9516 		(void *)&cmd_set_vxlan_udp_src,
9517 		(void *)&cmd_set_vxlan_udp_src_value,
9518 		(void *)&cmd_set_vxlan_udp_dst,
9519 		(void *)&cmd_set_vxlan_udp_dst_value,
9520 		(void *)&cmd_set_vxlan_ip_tos,
9521 		(void *)&cmd_set_vxlan_ip_tos_value,
9522 		(void *)&cmd_set_vxlan_ip_ttl,
9523 		(void *)&cmd_set_vxlan_ip_ttl_value,
9524 		(void *)&cmd_set_vxlan_ip_src,
9525 		(void *)&cmd_set_vxlan_ip_src_value,
9526 		(void *)&cmd_set_vxlan_ip_dst,
9527 		(void *)&cmd_set_vxlan_ip_dst_value,
9528 		(void *)&cmd_set_vxlan_eth_src,
9529 		(void *)&cmd_set_vxlan_eth_src_value,
9530 		(void *)&cmd_set_vxlan_eth_dst,
9531 		(void *)&cmd_set_vxlan_eth_dst_value,
9532 		NULL,
9533 	},
9534 };
9535 
9536 static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
9537 	.f = cmd_set_vxlan_parsed,
9538 	.data = NULL,
9539 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
9540 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
9541 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
9542 		" <eth-dst>",
9543 	.tokens = {
9544 		(void *)&cmd_set_vxlan_set,
9545 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
9546 		(void *)&cmd_set_vxlan_ip_version,
9547 		(void *)&cmd_set_vxlan_ip_version_value,
9548 		(void *)&cmd_set_vxlan_vni,
9549 		(void *)&cmd_set_vxlan_vni_value,
9550 		(void *)&cmd_set_vxlan_udp_src,
9551 		(void *)&cmd_set_vxlan_udp_src_value,
9552 		(void *)&cmd_set_vxlan_udp_dst,
9553 		(void *)&cmd_set_vxlan_udp_dst_value,
9554 		(void *)&cmd_set_vxlan_ip_src,
9555 		(void *)&cmd_set_vxlan_ip_src_value,
9556 		(void *)&cmd_set_vxlan_ip_dst,
9557 		(void *)&cmd_set_vxlan_ip_dst_value,
9558 		(void *)&cmd_set_vxlan_vlan,
9559 		(void *)&cmd_set_vxlan_vlan_value,
9560 		(void *)&cmd_set_vxlan_eth_src,
9561 		(void *)&cmd_set_vxlan_eth_src_value,
9562 		(void *)&cmd_set_vxlan_eth_dst,
9563 		(void *)&cmd_set_vxlan_eth_dst_value,
9564 		NULL,
9565 	},
9566 };
9567 
9568 /** Set NVGRE encapsulation details */
9569 struct cmd_set_nvgre_result {
9570 	cmdline_fixed_string_t set;
9571 	cmdline_fixed_string_t nvgre;
9572 	cmdline_fixed_string_t pos_token;
9573 	cmdline_fixed_string_t ip_version;
9574 	uint32_t tni;
9575 	cmdline_ipaddr_t ip_src;
9576 	cmdline_ipaddr_t ip_dst;
9577 	uint16_t tci;
9578 	struct rte_ether_addr eth_src;
9579 	struct rte_ether_addr eth_dst;
9580 };
9581 
9582 static cmdline_parse_token_string_t cmd_set_nvgre_set =
9583 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
9584 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
9585 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
9586 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
9587 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
9588 				 "nvgre-with-vlan");
9589 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
9590 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9591 				 "ip-version");
9592 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
9593 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
9594 				 "ipv4#ipv6");
9595 static cmdline_parse_token_string_t cmd_set_nvgre_tni =
9596 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9597 				 "tni");
9598 static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
9599 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
9600 static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
9601 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9602 				 "ip-src");
9603 static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
9604 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
9605 static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
9606 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9607 				 "ip-dst");
9608 static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
9609 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
9610 static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
9611 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9612 				 "vlan-tci");
9613 static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
9614 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
9615 static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
9616 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9617 				 "eth-src");
9618 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
9619 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
9620 static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
9621 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9622 				 "eth-dst");
9623 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
9624 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
9625 
9626 static void cmd_set_nvgre_parsed(void *parsed_result,
9627 	__rte_unused struct cmdline *cl,
9628 	__rte_unused void *data)
9629 {
9630 	struct cmd_set_nvgre_result *res = parsed_result;
9631 	union {
9632 		uint32_t nvgre_tni;
9633 		uint8_t tni[4];
9634 	} id = {
9635 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
9636 	};
9637 
9638 	if (strcmp(res->nvgre, "nvgre") == 0)
9639 		nvgre_encap_conf.select_vlan = 0;
9640 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
9641 		nvgre_encap_conf.select_vlan = 1;
9642 	if (strcmp(res->ip_version, "ipv4") == 0)
9643 		nvgre_encap_conf.select_ipv4 = 1;
9644 	else if (strcmp(res->ip_version, "ipv6") == 0)
9645 		nvgre_encap_conf.select_ipv4 = 0;
9646 	else
9647 		return;
9648 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
9649 	if (nvgre_encap_conf.select_ipv4) {
9650 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
9651 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
9652 	} else {
9653 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
9654 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
9655 	}
9656 	if (nvgre_encap_conf.select_vlan)
9657 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9658 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
9659 		   RTE_ETHER_ADDR_LEN);
9660 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9661 		   RTE_ETHER_ADDR_LEN);
9662 }
9663 
9664 static cmdline_parse_inst_t cmd_set_nvgre = {
9665 	.f = cmd_set_nvgre_parsed,
9666 	.data = NULL,
9667 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
9668 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9669 		" eth-dst <eth-dst>",
9670 	.tokens = {
9671 		(void *)&cmd_set_nvgre_set,
9672 		(void *)&cmd_set_nvgre_nvgre,
9673 		(void *)&cmd_set_nvgre_ip_version,
9674 		(void *)&cmd_set_nvgre_ip_version_value,
9675 		(void *)&cmd_set_nvgre_tni,
9676 		(void *)&cmd_set_nvgre_tni_value,
9677 		(void *)&cmd_set_nvgre_ip_src,
9678 		(void *)&cmd_set_nvgre_ip_src_value,
9679 		(void *)&cmd_set_nvgre_ip_dst,
9680 		(void *)&cmd_set_nvgre_ip_dst_value,
9681 		(void *)&cmd_set_nvgre_eth_src,
9682 		(void *)&cmd_set_nvgre_eth_src_value,
9683 		(void *)&cmd_set_nvgre_eth_dst,
9684 		(void *)&cmd_set_nvgre_eth_dst_value,
9685 		NULL,
9686 	},
9687 };
9688 
9689 static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
9690 	.f = cmd_set_nvgre_parsed,
9691 	.data = NULL,
9692 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
9693 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
9694 		" eth-src <eth-src> eth-dst <eth-dst>",
9695 	.tokens = {
9696 		(void *)&cmd_set_nvgre_set,
9697 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
9698 		(void *)&cmd_set_nvgre_ip_version,
9699 		(void *)&cmd_set_nvgre_ip_version_value,
9700 		(void *)&cmd_set_nvgre_tni,
9701 		(void *)&cmd_set_nvgre_tni_value,
9702 		(void *)&cmd_set_nvgre_ip_src,
9703 		(void *)&cmd_set_nvgre_ip_src_value,
9704 		(void *)&cmd_set_nvgre_ip_dst,
9705 		(void *)&cmd_set_nvgre_ip_dst_value,
9706 		(void *)&cmd_set_nvgre_vlan,
9707 		(void *)&cmd_set_nvgre_vlan_value,
9708 		(void *)&cmd_set_nvgre_eth_src,
9709 		(void *)&cmd_set_nvgre_eth_src_value,
9710 		(void *)&cmd_set_nvgre_eth_dst,
9711 		(void *)&cmd_set_nvgre_eth_dst_value,
9712 		NULL,
9713 	},
9714 };
9715 
9716 /** Set L2 encapsulation details */
9717 struct cmd_set_l2_encap_result {
9718 	cmdline_fixed_string_t set;
9719 	cmdline_fixed_string_t l2_encap;
9720 	cmdline_fixed_string_t pos_token;
9721 	cmdline_fixed_string_t ip_version;
9722 	uint32_t vlan_present:1;
9723 	uint16_t tci;
9724 	struct rte_ether_addr eth_src;
9725 	struct rte_ether_addr eth_dst;
9726 };
9727 
9728 static cmdline_parse_token_string_t cmd_set_l2_encap_set =
9729 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
9730 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
9731 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
9732 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
9733 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
9734 				 "l2_encap-with-vlan");
9735 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
9736 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9737 				 "ip-version");
9738 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
9739 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
9740 				 "ipv4#ipv6");
9741 static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
9742 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9743 				 "vlan-tci");
9744 static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
9745 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
9746 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
9747 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9748 				 "eth-src");
9749 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
9750 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
9751 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
9752 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9753 				 "eth-dst");
9754 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
9755 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
9756 
9757 static void cmd_set_l2_encap_parsed(void *parsed_result,
9758 	__rte_unused struct cmdline *cl,
9759 	__rte_unused void *data)
9760 {
9761 	struct cmd_set_l2_encap_result *res = parsed_result;
9762 
9763 	if (strcmp(res->l2_encap, "l2_encap") == 0)
9764 		l2_encap_conf.select_vlan = 0;
9765 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
9766 		l2_encap_conf.select_vlan = 1;
9767 	if (strcmp(res->ip_version, "ipv4") == 0)
9768 		l2_encap_conf.select_ipv4 = 1;
9769 	else if (strcmp(res->ip_version, "ipv6") == 0)
9770 		l2_encap_conf.select_ipv4 = 0;
9771 	else
9772 		return;
9773 	if (l2_encap_conf.select_vlan)
9774 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9775 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
9776 		   RTE_ETHER_ADDR_LEN);
9777 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9778 		   RTE_ETHER_ADDR_LEN);
9779 }
9780 
9781 static cmdline_parse_inst_t cmd_set_l2_encap = {
9782 	.f = cmd_set_l2_encap_parsed,
9783 	.data = NULL,
9784 	.help_str = "set l2_encap ip-version ipv4|ipv6"
9785 		" eth-src <eth-src> eth-dst <eth-dst>",
9786 	.tokens = {
9787 		(void *)&cmd_set_l2_encap_set,
9788 		(void *)&cmd_set_l2_encap_l2_encap,
9789 		(void *)&cmd_set_l2_encap_ip_version,
9790 		(void *)&cmd_set_l2_encap_ip_version_value,
9791 		(void *)&cmd_set_l2_encap_eth_src,
9792 		(void *)&cmd_set_l2_encap_eth_src_value,
9793 		(void *)&cmd_set_l2_encap_eth_dst,
9794 		(void *)&cmd_set_l2_encap_eth_dst_value,
9795 		NULL,
9796 	},
9797 };
9798 
9799 static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
9800 	.f = cmd_set_l2_encap_parsed,
9801 	.data = NULL,
9802 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
9803 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
9804 	.tokens = {
9805 		(void *)&cmd_set_l2_encap_set,
9806 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
9807 		(void *)&cmd_set_l2_encap_ip_version,
9808 		(void *)&cmd_set_l2_encap_ip_version_value,
9809 		(void *)&cmd_set_l2_encap_vlan,
9810 		(void *)&cmd_set_l2_encap_vlan_value,
9811 		(void *)&cmd_set_l2_encap_eth_src,
9812 		(void *)&cmd_set_l2_encap_eth_src_value,
9813 		(void *)&cmd_set_l2_encap_eth_dst,
9814 		(void *)&cmd_set_l2_encap_eth_dst_value,
9815 		NULL,
9816 	},
9817 };
9818 
9819 /** Set L2 decapsulation details */
9820 struct cmd_set_l2_decap_result {
9821 	cmdline_fixed_string_t set;
9822 	cmdline_fixed_string_t l2_decap;
9823 	cmdline_fixed_string_t pos_token;
9824 	uint32_t vlan_present:1;
9825 };
9826 
9827 static cmdline_parse_token_string_t cmd_set_l2_decap_set =
9828 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
9829 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
9830 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
9831 				 "l2_decap");
9832 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
9833 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
9834 				 "l2_decap-with-vlan");
9835 
9836 static void cmd_set_l2_decap_parsed(void *parsed_result,
9837 	__rte_unused struct cmdline *cl,
9838 	__rte_unused void *data)
9839 {
9840 	struct cmd_set_l2_decap_result *res = parsed_result;
9841 
9842 	if (strcmp(res->l2_decap, "l2_decap") == 0)
9843 		l2_decap_conf.select_vlan = 0;
9844 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
9845 		l2_decap_conf.select_vlan = 1;
9846 }
9847 
9848 static cmdline_parse_inst_t cmd_set_l2_decap = {
9849 	.f = cmd_set_l2_decap_parsed,
9850 	.data = NULL,
9851 	.help_str = "set l2_decap",
9852 	.tokens = {
9853 		(void *)&cmd_set_l2_decap_set,
9854 		(void *)&cmd_set_l2_decap_l2_decap,
9855 		NULL,
9856 	},
9857 };
9858 
9859 static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
9860 	.f = cmd_set_l2_decap_parsed,
9861 	.data = NULL,
9862 	.help_str = "set l2_decap-with-vlan",
9863 	.tokens = {
9864 		(void *)&cmd_set_l2_decap_set,
9865 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
9866 		NULL,
9867 	},
9868 };
9869 
9870 /** Set MPLSoGRE encapsulation details */
9871 struct cmd_set_mplsogre_encap_result {
9872 	cmdline_fixed_string_t set;
9873 	cmdline_fixed_string_t mplsogre;
9874 	cmdline_fixed_string_t pos_token;
9875 	cmdline_fixed_string_t ip_version;
9876 	uint32_t vlan_present:1;
9877 	uint32_t label;
9878 	cmdline_ipaddr_t ip_src;
9879 	cmdline_ipaddr_t ip_dst;
9880 	uint16_t tci;
9881 	struct rte_ether_addr eth_src;
9882 	struct rte_ether_addr eth_dst;
9883 };
9884 
9885 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
9886 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
9887 				 "set");
9888 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
9889 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
9890 				 "mplsogre_encap");
9891 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
9892 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9893 				 mplsogre, "mplsogre_encap-with-vlan");
9894 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
9895 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9896 				 pos_token, "ip-version");
9897 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
9898 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9899 				 ip_version, "ipv4#ipv6");
9900 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
9901 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9902 				 pos_token, "label");
9903 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
9904 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
9905 			      RTE_UINT32);
9906 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
9907 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9908 				 pos_token, "ip-src");
9909 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
9910 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
9911 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
9912 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9913 				 pos_token, "ip-dst");
9914 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
9915 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
9916 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
9917 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9918 				 pos_token, "vlan-tci");
9919 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
9920 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
9921 			      RTE_UINT16);
9922 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
9923 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9924 				 pos_token, "eth-src");
9925 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
9926 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9927 				    eth_src);
9928 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
9929 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9930 				 pos_token, "eth-dst");
9931 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
9932 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9933 				    eth_dst);
9934 
9935 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
9936 	__rte_unused struct cmdline *cl,
9937 	__rte_unused void *data)
9938 {
9939 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
9940 	union {
9941 		uint32_t mplsogre_label;
9942 		uint8_t label[4];
9943 	} id = {
9944 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
9945 	};
9946 
9947 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
9948 		mplsogre_encap_conf.select_vlan = 0;
9949 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
9950 		mplsogre_encap_conf.select_vlan = 1;
9951 	if (strcmp(res->ip_version, "ipv4") == 0)
9952 		mplsogre_encap_conf.select_ipv4 = 1;
9953 	else if (strcmp(res->ip_version, "ipv6") == 0)
9954 		mplsogre_encap_conf.select_ipv4 = 0;
9955 	else
9956 		return;
9957 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
9958 	if (mplsogre_encap_conf.select_ipv4) {
9959 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
9960 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
9961 	} else {
9962 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
9963 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
9964 	}
9965 	if (mplsogre_encap_conf.select_vlan)
9966 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9967 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
9968 		   RTE_ETHER_ADDR_LEN);
9969 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9970 		   RTE_ETHER_ADDR_LEN);
9971 }
9972 
9973 static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
9974 	.f = cmd_set_mplsogre_encap_parsed,
9975 	.data = NULL,
9976 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
9977 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9978 		" eth-dst <eth-dst>",
9979 	.tokens = {
9980 		(void *)&cmd_set_mplsogre_encap_set,
9981 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
9982 		(void *)&cmd_set_mplsogre_encap_ip_version,
9983 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
9984 		(void *)&cmd_set_mplsogre_encap_label,
9985 		(void *)&cmd_set_mplsogre_encap_label_value,
9986 		(void *)&cmd_set_mplsogre_encap_ip_src,
9987 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
9988 		(void *)&cmd_set_mplsogre_encap_ip_dst,
9989 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
9990 		(void *)&cmd_set_mplsogre_encap_eth_src,
9991 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
9992 		(void *)&cmd_set_mplsogre_encap_eth_dst,
9993 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
9994 		NULL,
9995 	},
9996 };
9997 
9998 static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
9999 	.f = cmd_set_mplsogre_encap_parsed,
10000 	.data = NULL,
10001 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10002 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
10003 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10004 	.tokens = {
10005 		(void *)&cmd_set_mplsogre_encap_set,
10006 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10007 		(void *)&cmd_set_mplsogre_encap_ip_version,
10008 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
10009 		(void *)&cmd_set_mplsogre_encap_label,
10010 		(void *)&cmd_set_mplsogre_encap_label_value,
10011 		(void *)&cmd_set_mplsogre_encap_ip_src,
10012 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
10013 		(void *)&cmd_set_mplsogre_encap_ip_dst,
10014 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
10015 		(void *)&cmd_set_mplsogre_encap_vlan,
10016 		(void *)&cmd_set_mplsogre_encap_vlan_value,
10017 		(void *)&cmd_set_mplsogre_encap_eth_src,
10018 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
10019 		(void *)&cmd_set_mplsogre_encap_eth_dst,
10020 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
10021 		NULL,
10022 	},
10023 };
10024 
10025 /** Set MPLSoGRE decapsulation details */
10026 struct cmd_set_mplsogre_decap_result {
10027 	cmdline_fixed_string_t set;
10028 	cmdline_fixed_string_t mplsogre;
10029 	cmdline_fixed_string_t pos_token;
10030 	cmdline_fixed_string_t ip_version;
10031 	uint32_t vlan_present:1;
10032 };
10033 
10034 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10035 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10036 				 "set");
10037 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10038 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10039 				 "mplsogre_decap");
10040 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10041 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10042 				 mplsogre, "mplsogre_decap-with-vlan");
10043 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10044 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10045 				 pos_token, "ip-version");
10046 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10047 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10048 				 ip_version, "ipv4#ipv6");
10049 
10050 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10051 	__rte_unused struct cmdline *cl,
10052 	__rte_unused void *data)
10053 {
10054 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
10055 
10056 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10057 		mplsogre_decap_conf.select_vlan = 0;
10058 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10059 		mplsogre_decap_conf.select_vlan = 1;
10060 	if (strcmp(res->ip_version, "ipv4") == 0)
10061 		mplsogre_decap_conf.select_ipv4 = 1;
10062 	else if (strcmp(res->ip_version, "ipv6") == 0)
10063 		mplsogre_decap_conf.select_ipv4 = 0;
10064 }
10065 
10066 static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10067 	.f = cmd_set_mplsogre_decap_parsed,
10068 	.data = NULL,
10069 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10070 	.tokens = {
10071 		(void *)&cmd_set_mplsogre_decap_set,
10072 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10073 		(void *)&cmd_set_mplsogre_decap_ip_version,
10074 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
10075 		NULL,
10076 	},
10077 };
10078 
10079 static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
10080 	.f = cmd_set_mplsogre_decap_parsed,
10081 	.data = NULL,
10082 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
10083 	.tokens = {
10084 		(void *)&cmd_set_mplsogre_decap_set,
10085 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
10086 		(void *)&cmd_set_mplsogre_decap_ip_version,
10087 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
10088 		NULL,
10089 	},
10090 };
10091 
10092 /** Set MPLSoUDP encapsulation details */
10093 struct cmd_set_mplsoudp_encap_result {
10094 	cmdline_fixed_string_t set;
10095 	cmdline_fixed_string_t mplsoudp;
10096 	cmdline_fixed_string_t pos_token;
10097 	cmdline_fixed_string_t ip_version;
10098 	uint32_t vlan_present:1;
10099 	uint32_t label;
10100 	uint16_t udp_src;
10101 	uint16_t udp_dst;
10102 	cmdline_ipaddr_t ip_src;
10103 	cmdline_ipaddr_t ip_dst;
10104 	uint16_t tci;
10105 	struct rte_ether_addr eth_src;
10106 	struct rte_ether_addr eth_dst;
10107 };
10108 
10109 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
10110 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
10111 				 "set");
10112 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
10113 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
10114 				 "mplsoudp_encap");
10115 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
10116 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10117 				 mplsoudp, "mplsoudp_encap-with-vlan");
10118 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
10119 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10120 				 pos_token, "ip-version");
10121 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
10122 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10123 				 ip_version, "ipv4#ipv6");
10124 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
10125 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10126 				 pos_token, "label");
10127 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
10128 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
10129 			      RTE_UINT32);
10130 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
10131 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10132 				 pos_token, "udp-src");
10133 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
10134 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
10135 			      RTE_UINT16);
10136 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
10137 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10138 				 pos_token, "udp-dst");
10139 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
10140 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
10141 			      RTE_UINT16);
10142 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
10143 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10144 				 pos_token, "ip-src");
10145 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
10146 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
10147 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
10148 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10149 				 pos_token, "ip-dst");
10150 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
10151 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
10152 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
10153 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10154 				 pos_token, "vlan-tci");
10155 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
10156 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
10157 			      RTE_UINT16);
10158 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
10159 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10160 				 pos_token, "eth-src");
10161 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
10162 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10163 				    eth_src);
10164 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
10165 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10166 				 pos_token, "eth-dst");
10167 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
10168 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10169 				    eth_dst);
10170 
10171 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
10172 	__rte_unused struct cmdline *cl,
10173 	__rte_unused void *data)
10174 {
10175 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
10176 	union {
10177 		uint32_t mplsoudp_label;
10178 		uint8_t label[4];
10179 	} id = {
10180 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
10181 	};
10182 
10183 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
10184 		mplsoudp_encap_conf.select_vlan = 0;
10185 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
10186 		mplsoudp_encap_conf.select_vlan = 1;
10187 	if (strcmp(res->ip_version, "ipv4") == 0)
10188 		mplsoudp_encap_conf.select_ipv4 = 1;
10189 	else if (strcmp(res->ip_version, "ipv6") == 0)
10190 		mplsoudp_encap_conf.select_ipv4 = 0;
10191 	else
10192 		return;
10193 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
10194 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10195 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10196 	if (mplsoudp_encap_conf.select_ipv4) {
10197 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
10198 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
10199 	} else {
10200 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
10201 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
10202 	}
10203 	if (mplsoudp_encap_conf.select_vlan)
10204 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10205 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
10206 		   RTE_ETHER_ADDR_LEN);
10207 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10208 		   RTE_ETHER_ADDR_LEN);
10209 }
10210 
10211 static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
10212 	.f = cmd_set_mplsoudp_encap_parsed,
10213 	.data = NULL,
10214 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
10215 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
10216 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
10217 	.tokens = {
10218 		(void *)&cmd_set_mplsoudp_encap_set,
10219 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
10220 		(void *)&cmd_set_mplsoudp_encap_ip_version,
10221 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
10222 		(void *)&cmd_set_mplsoudp_encap_label,
10223 		(void *)&cmd_set_mplsoudp_encap_label_value,
10224 		(void *)&cmd_set_mplsoudp_encap_udp_src,
10225 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
10226 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
10227 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10228 		(void *)&cmd_set_mplsoudp_encap_ip_src,
10229 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
10230 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
10231 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10232 		(void *)&cmd_set_mplsoudp_encap_eth_src,
10233 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
10234 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
10235 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10236 		NULL,
10237 	},
10238 };
10239 
10240 static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
10241 	.f = cmd_set_mplsoudp_encap_parsed,
10242 	.data = NULL,
10243 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
10244 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
10245 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10246 		" eth-src <eth-src> eth-dst <eth-dst>",
10247 	.tokens = {
10248 		(void *)&cmd_set_mplsoudp_encap_set,
10249 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
10250 		(void *)&cmd_set_mplsoudp_encap_ip_version,
10251 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
10252 		(void *)&cmd_set_mplsoudp_encap_label,
10253 		(void *)&cmd_set_mplsoudp_encap_label_value,
10254 		(void *)&cmd_set_mplsoudp_encap_udp_src,
10255 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
10256 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
10257 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10258 		(void *)&cmd_set_mplsoudp_encap_ip_src,
10259 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
10260 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
10261 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10262 		(void *)&cmd_set_mplsoudp_encap_vlan,
10263 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
10264 		(void *)&cmd_set_mplsoudp_encap_eth_src,
10265 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
10266 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
10267 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10268 		NULL,
10269 	},
10270 };
10271 
10272 /** Set MPLSoUDP decapsulation details */
10273 struct cmd_set_mplsoudp_decap_result {
10274 	cmdline_fixed_string_t set;
10275 	cmdline_fixed_string_t mplsoudp;
10276 	cmdline_fixed_string_t pos_token;
10277 	cmdline_fixed_string_t ip_version;
10278 	uint32_t vlan_present:1;
10279 };
10280 
10281 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
10282 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
10283 				 "set");
10284 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
10285 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
10286 				 "mplsoudp_decap");
10287 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
10288 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10289 				 mplsoudp, "mplsoudp_decap-with-vlan");
10290 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
10291 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10292 				 pos_token, "ip-version");
10293 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
10294 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10295 				 ip_version, "ipv4#ipv6");
10296 
10297 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
10298 	__rte_unused struct cmdline *cl,
10299 	__rte_unused void *data)
10300 {
10301 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
10302 
10303 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
10304 		mplsoudp_decap_conf.select_vlan = 0;
10305 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
10306 		mplsoudp_decap_conf.select_vlan = 1;
10307 	if (strcmp(res->ip_version, "ipv4") == 0)
10308 		mplsoudp_decap_conf.select_ipv4 = 1;
10309 	else if (strcmp(res->ip_version, "ipv6") == 0)
10310 		mplsoudp_decap_conf.select_ipv4 = 0;
10311 }
10312 
10313 static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
10314 	.f = cmd_set_mplsoudp_decap_parsed,
10315 	.data = NULL,
10316 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
10317 	.tokens = {
10318 		(void *)&cmd_set_mplsoudp_decap_set,
10319 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
10320 		(void *)&cmd_set_mplsoudp_decap_ip_version,
10321 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
10322 		NULL,
10323 	},
10324 };
10325 
10326 static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
10327 	.f = cmd_set_mplsoudp_decap_parsed,
10328 	.data = NULL,
10329 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
10330 	.tokens = {
10331 		(void *)&cmd_set_mplsoudp_decap_set,
10332 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
10333 		(void *)&cmd_set_mplsoudp_decap_ip_version,
10334 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
10335 		NULL,
10336 	},
10337 };
10338 
10339 /** Set connection tracking object common details */
10340 struct cmd_set_conntrack_common_result {
10341 	cmdline_fixed_string_t set;
10342 	cmdline_fixed_string_t conntrack;
10343 	cmdline_fixed_string_t common;
10344 	cmdline_fixed_string_t peer;
10345 	cmdline_fixed_string_t is_orig;
10346 	cmdline_fixed_string_t enable;
10347 	cmdline_fixed_string_t live;
10348 	cmdline_fixed_string_t sack;
10349 	cmdline_fixed_string_t cack;
10350 	cmdline_fixed_string_t last_dir;
10351 	cmdline_fixed_string_t liberal;
10352 	cmdline_fixed_string_t state;
10353 	cmdline_fixed_string_t max_ack_win;
10354 	cmdline_fixed_string_t retrans;
10355 	cmdline_fixed_string_t last_win;
10356 	cmdline_fixed_string_t last_seq;
10357 	cmdline_fixed_string_t last_ack;
10358 	cmdline_fixed_string_t last_end;
10359 	cmdline_fixed_string_t last_index;
10360 	uint8_t stat;
10361 	uint8_t factor;
10362 	uint16_t peer_port;
10363 	uint32_t is_original;
10364 	uint32_t en;
10365 	uint32_t is_live;
10366 	uint32_t s_ack;
10367 	uint32_t c_ack;
10368 	uint32_t ld;
10369 	uint32_t lb;
10370 	uint8_t re_num;
10371 	uint8_t li;
10372 	uint16_t lw;
10373 	uint32_t ls;
10374 	uint32_t la;
10375 	uint32_t le;
10376 };
10377 
10378 static cmdline_parse_token_string_t cmd_set_conntrack_set =
10379 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10380 				 set, "set");
10381 static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
10382 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10383 				 conntrack, "conntrack");
10384 static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
10385 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10386 				 common, "com");
10387 static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
10388 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10389 				 peer, "peer");
10390 static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
10391 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10392 			      peer_port, RTE_UINT16);
10393 static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
10394 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10395 				 is_orig, "is_orig");
10396 static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
10397 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10398 			      is_original, RTE_UINT32);
10399 static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
10400 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10401 				 enable, "enable");
10402 static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
10403 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10404 			      en, RTE_UINT32);
10405 static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
10406 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10407 				 live, "live");
10408 static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
10409 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10410 			      is_live, RTE_UINT32);
10411 static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
10412 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10413 				 sack, "sack");
10414 static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
10415 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10416 			      s_ack, RTE_UINT32);
10417 static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
10418 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10419 				 cack, "cack");
10420 static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
10421 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10422 			      c_ack, RTE_UINT32);
10423 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
10424 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10425 				 last_dir, "last_dir");
10426 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
10427 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10428 			      ld, RTE_UINT32);
10429 static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
10430 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10431 				 liberal, "liberal");
10432 static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
10433 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10434 			      lb, RTE_UINT32);
10435 static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
10436 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10437 				 state, "state");
10438 static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
10439 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10440 			      stat, RTE_UINT8);
10441 static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
10442 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10443 				 max_ack_win, "max_ack_win");
10444 static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
10445 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10446 			      factor, RTE_UINT8);
10447 static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
10448 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10449 				 retrans, "r_lim");
10450 static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
10451 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10452 			      re_num, RTE_UINT8);
10453 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
10454 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10455 				 last_win, "last_win");
10456 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
10457 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10458 			      lw, RTE_UINT16);
10459 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
10460 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10461 				 last_seq, "last_seq");
10462 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
10463 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10464 			      ls, RTE_UINT32);
10465 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
10466 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10467 				 last_ack, "last_ack");
10468 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
10469 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10470 			      la, RTE_UINT32);
10471 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
10472 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10473 				 last_end, "last_end");
10474 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
10475 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10476 			      le, RTE_UINT32);
10477 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
10478 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10479 				 last_index, "last_index");
10480 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
10481 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10482 			      li, RTE_UINT8);
10483 
10484 static void cmd_set_conntrack_common_parsed(void *parsed_result,
10485 	__rte_unused struct cmdline *cl,
10486 	__rte_unused void *data)
10487 {
10488 	struct cmd_set_conntrack_common_result *res = parsed_result;
10489 
10490 	/* No need to swap to big endian. */
10491 	conntrack_context.peer_port = res->peer_port;
10492 	conntrack_context.is_original_dir = res->is_original;
10493 	conntrack_context.enable = res->en;
10494 	conntrack_context.live_connection = res->is_live;
10495 	conntrack_context.selective_ack = res->s_ack;
10496 	conntrack_context.challenge_ack_passed = res->c_ack;
10497 	conntrack_context.last_direction = res->ld;
10498 	conntrack_context.liberal_mode = res->lb;
10499 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
10500 	conntrack_context.max_ack_window = res->factor;
10501 	conntrack_context.retransmission_limit = res->re_num;
10502 	conntrack_context.last_window = res->lw;
10503 	conntrack_context.last_index =
10504 		(enum rte_flow_conntrack_tcp_last_index)res->li;
10505 	conntrack_context.last_seq = res->ls;
10506 	conntrack_context.last_ack = res->la;
10507 	conntrack_context.last_end = res->le;
10508 }
10509 
10510 static cmdline_parse_inst_t cmd_set_conntrack_common = {
10511 	.f = cmd_set_conntrack_common_parsed,
10512 	.data = NULL,
10513 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
10514 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
10515 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
10516 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
10517 		" last_index <flag>",
10518 	.tokens = {
10519 		(void *)&cmd_set_conntrack_set,
10520 		(void *)&cmd_set_conntrack_conntrack,
10521 		(void *)&cmd_set_conntrack_common_com,
10522 		(void *)&cmd_set_conntrack_common_peer,
10523 		(void *)&cmd_set_conntrack_common_peer_value,
10524 		(void *)&cmd_set_conntrack_common_is_orig,
10525 		(void *)&cmd_set_conntrack_common_is_orig_value,
10526 		(void *)&cmd_set_conntrack_common_enable,
10527 		(void *)&cmd_set_conntrack_common_enable_value,
10528 		(void *)&cmd_set_conntrack_common_live,
10529 		(void *)&cmd_set_conntrack_common_live_value,
10530 		(void *)&cmd_set_conntrack_common_sack,
10531 		(void *)&cmd_set_conntrack_common_sack_value,
10532 		(void *)&cmd_set_conntrack_common_cack,
10533 		(void *)&cmd_set_conntrack_common_cack_value,
10534 		(void *)&cmd_set_conntrack_common_last_dir,
10535 		(void *)&cmd_set_conntrack_common_last_dir_value,
10536 		(void *)&cmd_set_conntrack_common_liberal,
10537 		(void *)&cmd_set_conntrack_common_liberal_value,
10538 		(void *)&cmd_set_conntrack_common_state,
10539 		(void *)&cmd_set_conntrack_common_state_value,
10540 		(void *)&cmd_set_conntrack_common_max_ackwin,
10541 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
10542 		(void *)&cmd_set_conntrack_common_retrans,
10543 		(void *)&cmd_set_conntrack_common_retrans_value,
10544 		(void *)&cmd_set_conntrack_common_last_win,
10545 		(void *)&cmd_set_conntrack_common_last_win_value,
10546 		(void *)&cmd_set_conntrack_common_last_seq,
10547 		(void *)&cmd_set_conntrack_common_last_seq_value,
10548 		(void *)&cmd_set_conntrack_common_last_ack,
10549 		(void *)&cmd_set_conntrack_common_last_ack_value,
10550 		(void *)&cmd_set_conntrack_common_last_end,
10551 		(void *)&cmd_set_conntrack_common_last_end_value,
10552 		(void *)&cmd_set_conntrack_common_last_index,
10553 		(void *)&cmd_set_conntrack_common_last_index_value,
10554 		NULL,
10555 	},
10556 };
10557 
10558 /** Set connection tracking object both directions' details */
10559 struct cmd_set_conntrack_dir_result {
10560 	cmdline_fixed_string_t set;
10561 	cmdline_fixed_string_t conntrack;
10562 	cmdline_fixed_string_t dir;
10563 	cmdline_fixed_string_t scale;
10564 	cmdline_fixed_string_t fin;
10565 	cmdline_fixed_string_t ack_seen;
10566 	cmdline_fixed_string_t unack;
10567 	cmdline_fixed_string_t sent_end;
10568 	cmdline_fixed_string_t reply_end;
10569 	cmdline_fixed_string_t max_win;
10570 	cmdline_fixed_string_t max_ack;
10571 	uint32_t factor;
10572 	uint32_t f;
10573 	uint32_t as;
10574 	uint32_t un;
10575 	uint32_t se;
10576 	uint32_t re;
10577 	uint32_t mw;
10578 	uint32_t ma;
10579 };
10580 
10581 static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
10582 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10583 				 dir, "orig#rply");
10584 static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
10585 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10586 				 scale, "scale");
10587 static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
10588 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10589 			      factor, RTE_UINT32);
10590 static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
10591 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10592 				 fin, "fin");
10593 static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
10594 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10595 			      f, RTE_UINT32);
10596 static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
10597 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10598 				 ack_seen, "acked");
10599 static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
10600 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10601 			      as, RTE_UINT32);
10602 static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
10603 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10604 				 unack, "unack_data");
10605 static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
10606 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10607 			      un, RTE_UINT32);
10608 static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
10609 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10610 				 sent_end, "sent_end");
10611 static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
10612 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10613 			      se, RTE_UINT32);
10614 static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
10615 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10616 				 reply_end, "reply_end");
10617 static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
10618 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10619 			      re, RTE_UINT32);
10620 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
10621 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10622 				 max_win, "max_win");
10623 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
10624 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10625 			      mw, RTE_UINT32);
10626 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
10627 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10628 				 max_ack, "max_ack");
10629 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
10630 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10631 			      ma, RTE_UINT32);
10632 
10633 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
10634 	__rte_unused struct cmdline *cl,
10635 	__rte_unused void *data)
10636 {
10637 	struct cmd_set_conntrack_dir_result *res = parsed_result;
10638 	struct rte_flow_tcp_dir_param *dir = NULL;
10639 
10640 	if (strcmp(res->dir, "orig") == 0)
10641 		dir = &conntrack_context.original_dir;
10642 	else if (strcmp(res->dir, "rply") == 0)
10643 		dir = &conntrack_context.reply_dir;
10644 	else
10645 		return;
10646 	dir->scale = res->factor;
10647 	dir->close_initiated = res->f;
10648 	dir->last_ack_seen = res->as;
10649 	dir->data_unacked = res->un;
10650 	dir->sent_end = res->se;
10651 	dir->reply_end = res->re;
10652 	dir->max_ack = res->ma;
10653 	dir->max_win = res->mw;
10654 }
10655 
10656 static cmdline_parse_inst_t cmd_set_conntrack_dir = {
10657 	.f = cmd_set_conntrack_dir_parsed,
10658 	.data = NULL,
10659 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
10660 		    " acked <seen> unack_data <unack> sent_end <sent>"
10661 		    " reply_end <reply> max_win <win> max_ack <ack>",
10662 	.tokens = {
10663 		(void *)&cmd_set_conntrack_set,
10664 		(void *)&cmd_set_conntrack_conntrack,
10665 		(void *)&cmd_set_conntrack_dir_dir,
10666 		(void *)&cmd_set_conntrack_dir_scale,
10667 		(void *)&cmd_set_conntrack_dir_scale_value,
10668 		(void *)&cmd_set_conntrack_dir_fin,
10669 		(void *)&cmd_set_conntrack_dir_fin_value,
10670 		(void *)&cmd_set_conntrack_dir_ack,
10671 		(void *)&cmd_set_conntrack_dir_ack_value,
10672 		(void *)&cmd_set_conntrack_dir_unack_data,
10673 		(void *)&cmd_set_conntrack_dir_unack_data_value,
10674 		(void *)&cmd_set_conntrack_dir_sent_end,
10675 		(void *)&cmd_set_conntrack_dir_sent_end_value,
10676 		(void *)&cmd_set_conntrack_dir_reply_end,
10677 		(void *)&cmd_set_conntrack_dir_reply_end_value,
10678 		(void *)&cmd_set_conntrack_dir_max_win,
10679 		(void *)&cmd_set_conntrack_dir_max_win_value,
10680 		(void *)&cmd_set_conntrack_dir_max_ack,
10681 		(void *)&cmd_set_conntrack_dir_max_ack_value,
10682 		NULL,
10683 	},
10684 };
10685 
10686 /* show vf stats */
10687 
10688 /* Common result structure for show vf stats */
10689 struct cmd_show_vf_stats_result {
10690 	cmdline_fixed_string_t show;
10691 	cmdline_fixed_string_t vf;
10692 	cmdline_fixed_string_t stats;
10693 	portid_t port_id;
10694 	uint16_t vf_id;
10695 };
10696 
10697 /* Common CLI fields show vf stats*/
10698 static cmdline_parse_token_string_t cmd_show_vf_stats_show =
10699 	TOKEN_STRING_INITIALIZER
10700 		(struct cmd_show_vf_stats_result,
10701 		 show, "show");
10702 static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
10703 	TOKEN_STRING_INITIALIZER
10704 		(struct cmd_show_vf_stats_result,
10705 		 vf, "vf");
10706 static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
10707 	TOKEN_STRING_INITIALIZER
10708 		(struct cmd_show_vf_stats_result,
10709 		 stats, "stats");
10710 static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
10711 	TOKEN_NUM_INITIALIZER
10712 		(struct cmd_show_vf_stats_result,
10713 		 port_id, RTE_UINT16);
10714 static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
10715 	TOKEN_NUM_INITIALIZER
10716 		(struct cmd_show_vf_stats_result,
10717 		 vf_id, RTE_UINT16);
10718 
10719 static void
10720 cmd_show_vf_stats_parsed(
10721 	void *parsed_result,
10722 	__rte_unused struct cmdline *cl,
10723 	__rte_unused void *data)
10724 {
10725 	struct cmd_show_vf_stats_result *res = parsed_result;
10726 	struct rte_eth_stats stats;
10727 	int ret = -ENOTSUP;
10728 	static const char *nic_stats_border = "########################";
10729 
10730 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10731 		return;
10732 
10733 	memset(&stats, 0, sizeof(stats));
10734 
10735 #ifdef RTE_NET_I40E
10736 	if (ret == -ENOTSUP)
10737 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
10738 						res->vf_id,
10739 						&stats);
10740 #endif
10741 #ifdef RTE_NET_BNXT
10742 	if (ret == -ENOTSUP)
10743 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
10744 						res->vf_id,
10745 						&stats);
10746 #endif
10747 
10748 	switch (ret) {
10749 	case 0:
10750 		break;
10751 	case -EINVAL:
10752 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10753 		break;
10754 	case -ENODEV:
10755 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
10756 		break;
10757 	case -ENOTSUP:
10758 		fprintf(stderr, "function not implemented\n");
10759 		break;
10760 	default:
10761 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10762 	}
10763 
10764 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
10765 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
10766 
10767 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
10768 	       "%-"PRIu64"\n",
10769 	       stats.ipackets, stats.imissed, stats.ibytes);
10770 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
10771 	printf("  RX-nombuf:  %-10"PRIu64"\n",
10772 	       stats.rx_nombuf);
10773 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
10774 	       "%-"PRIu64"\n",
10775 	       stats.opackets, stats.oerrors, stats.obytes);
10776 
10777 	printf("  %s############################%s\n",
10778 			       nic_stats_border, nic_stats_border);
10779 }
10780 
10781 static cmdline_parse_inst_t cmd_show_vf_stats = {
10782 	.f = cmd_show_vf_stats_parsed,
10783 	.data = NULL,
10784 	.help_str = "show vf stats <port_id> <vf_id>",
10785 	.tokens = {
10786 		(void *)&cmd_show_vf_stats_show,
10787 		(void *)&cmd_show_vf_stats_vf,
10788 		(void *)&cmd_show_vf_stats_stats,
10789 		(void *)&cmd_show_vf_stats_port_id,
10790 		(void *)&cmd_show_vf_stats_vf_id,
10791 		NULL,
10792 	},
10793 };
10794 
10795 /* clear vf stats */
10796 
10797 /* Common result structure for clear vf stats */
10798 struct cmd_clear_vf_stats_result {
10799 	cmdline_fixed_string_t clear;
10800 	cmdline_fixed_string_t vf;
10801 	cmdline_fixed_string_t stats;
10802 	portid_t port_id;
10803 	uint16_t vf_id;
10804 };
10805 
10806 /* Common CLI fields clear vf stats*/
10807 static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
10808 	TOKEN_STRING_INITIALIZER
10809 		(struct cmd_clear_vf_stats_result,
10810 		 clear, "clear");
10811 static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
10812 	TOKEN_STRING_INITIALIZER
10813 		(struct cmd_clear_vf_stats_result,
10814 		 vf, "vf");
10815 static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
10816 	TOKEN_STRING_INITIALIZER
10817 		(struct cmd_clear_vf_stats_result,
10818 		 stats, "stats");
10819 static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
10820 	TOKEN_NUM_INITIALIZER
10821 		(struct cmd_clear_vf_stats_result,
10822 		 port_id, RTE_UINT16);
10823 static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
10824 	TOKEN_NUM_INITIALIZER
10825 		(struct cmd_clear_vf_stats_result,
10826 		 vf_id, RTE_UINT16);
10827 
10828 static void
10829 cmd_clear_vf_stats_parsed(
10830 	void *parsed_result,
10831 	__rte_unused struct cmdline *cl,
10832 	__rte_unused void *data)
10833 {
10834 	struct cmd_clear_vf_stats_result *res = parsed_result;
10835 	int ret = -ENOTSUP;
10836 
10837 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10838 		return;
10839 
10840 #ifdef RTE_NET_I40E
10841 	if (ret == -ENOTSUP)
10842 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
10843 						  res->vf_id);
10844 #endif
10845 #ifdef RTE_NET_BNXT
10846 	if (ret == -ENOTSUP)
10847 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
10848 						  res->vf_id);
10849 #endif
10850 
10851 	switch (ret) {
10852 	case 0:
10853 		break;
10854 	case -EINVAL:
10855 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10856 		break;
10857 	case -ENODEV:
10858 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
10859 		break;
10860 	case -ENOTSUP:
10861 		fprintf(stderr, "function not implemented\n");
10862 		break;
10863 	default:
10864 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10865 	}
10866 }
10867 
10868 static cmdline_parse_inst_t cmd_clear_vf_stats = {
10869 	.f = cmd_clear_vf_stats_parsed,
10870 	.data = NULL,
10871 	.help_str = "clear vf stats <port_id> <vf_id>",
10872 	.tokens = {
10873 		(void *)&cmd_clear_vf_stats_clear,
10874 		(void *)&cmd_clear_vf_stats_vf,
10875 		(void *)&cmd_clear_vf_stats_stats,
10876 		(void *)&cmd_clear_vf_stats_port_id,
10877 		(void *)&cmd_clear_vf_stats_vf_id,
10878 		NULL,
10879 	},
10880 };
10881 
10882 /* Common result structure for file commands */
10883 struct cmd_cmdfile_result {
10884 	cmdline_fixed_string_t load;
10885 	cmdline_fixed_string_t filename;
10886 };
10887 
10888 /* Common CLI fields for file commands */
10889 static cmdline_parse_token_string_t cmd_load_cmdfile =
10890 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
10891 static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
10892 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
10893 
10894 static void
10895 cmd_load_from_file_parsed(
10896 	void *parsed_result,
10897 	__rte_unused struct cmdline *cl,
10898 	__rte_unused void *data)
10899 {
10900 	struct cmd_cmdfile_result *res = parsed_result;
10901 
10902 	cmdline_read_from_file(res->filename);
10903 }
10904 
10905 static cmdline_parse_inst_t cmd_load_from_file = {
10906 	.f = cmd_load_from_file_parsed,
10907 	.data = NULL,
10908 	.help_str = "load <filename>",
10909 	.tokens = {
10910 		(void *)&cmd_load_cmdfile,
10911 		(void *)&cmd_load_cmdfile_filename,
10912 		NULL,
10913 	},
10914 };
10915 
10916 /* Get Rx offloads capabilities */
10917 struct cmd_rx_offload_get_capa_result {
10918 	cmdline_fixed_string_t show;
10919 	cmdline_fixed_string_t port;
10920 	portid_t port_id;
10921 	cmdline_fixed_string_t rx_offload;
10922 	cmdline_fixed_string_t capabilities;
10923 };
10924 
10925 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
10926 	TOKEN_STRING_INITIALIZER
10927 		(struct cmd_rx_offload_get_capa_result,
10928 		 show, "show");
10929 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
10930 	TOKEN_STRING_INITIALIZER
10931 		(struct cmd_rx_offload_get_capa_result,
10932 		 port, "port");
10933 static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
10934 	TOKEN_NUM_INITIALIZER
10935 		(struct cmd_rx_offload_get_capa_result,
10936 		 port_id, RTE_UINT16);
10937 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
10938 	TOKEN_STRING_INITIALIZER
10939 		(struct cmd_rx_offload_get_capa_result,
10940 		 rx_offload, "rx_offload");
10941 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
10942 	TOKEN_STRING_INITIALIZER
10943 		(struct cmd_rx_offload_get_capa_result,
10944 		 capabilities, "capabilities");
10945 
10946 static void
10947 print_rx_offloads(uint64_t offloads)
10948 {
10949 	uint64_t single_offload;
10950 	int begin;
10951 	int end;
10952 	int bit;
10953 
10954 	if (offloads == 0)
10955 		return;
10956 
10957 	begin = rte_ctz64(offloads);
10958 	end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
10959 
10960 	single_offload = 1ULL << begin;
10961 	for (bit = begin; bit < end; bit++) {
10962 		if (offloads & single_offload)
10963 			printf(" %s",
10964 			       rte_eth_dev_rx_offload_name(single_offload));
10965 		single_offload <<= 1;
10966 	}
10967 }
10968 
10969 static void
10970 cmd_rx_offload_get_capa_parsed(
10971 	void *parsed_result,
10972 	__rte_unused struct cmdline *cl,
10973 	__rte_unused void *data)
10974 {
10975 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
10976 	struct rte_eth_dev_info dev_info;
10977 	portid_t port_id = res->port_id;
10978 	uint64_t queue_offloads;
10979 	uint64_t port_offloads;
10980 	int ret;
10981 
10982 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
10983 	if (ret != 0)
10984 		return;
10985 
10986 	queue_offloads = dev_info.rx_queue_offload_capa;
10987 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
10988 
10989 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
10990 	printf("  Per Queue :");
10991 	print_rx_offloads(queue_offloads);
10992 
10993 	printf("\n");
10994 	printf("  Per Port  :");
10995 	print_rx_offloads(port_offloads);
10996 	printf("\n\n");
10997 }
10998 
10999 static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
11000 	.f = cmd_rx_offload_get_capa_parsed,
11001 	.data = NULL,
11002 	.help_str = "show port <port_id> rx_offload capabilities",
11003 	.tokens = {
11004 		(void *)&cmd_rx_offload_get_capa_show,
11005 		(void *)&cmd_rx_offload_get_capa_port,
11006 		(void *)&cmd_rx_offload_get_capa_port_id,
11007 		(void *)&cmd_rx_offload_get_capa_rx_offload,
11008 		(void *)&cmd_rx_offload_get_capa_capabilities,
11009 		NULL,
11010 	}
11011 };
11012 
11013 /* Get Rx offloads configuration */
11014 struct cmd_rx_offload_get_configuration_result {
11015 	cmdline_fixed_string_t show;
11016 	cmdline_fixed_string_t port;
11017 	portid_t port_id;
11018 	cmdline_fixed_string_t rx_offload;
11019 	cmdline_fixed_string_t configuration;
11020 };
11021 
11022 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11023 	TOKEN_STRING_INITIALIZER
11024 		(struct cmd_rx_offload_get_configuration_result,
11025 		 show, "show");
11026 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11027 	TOKEN_STRING_INITIALIZER
11028 		(struct cmd_rx_offload_get_configuration_result,
11029 		 port, "port");
11030 static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11031 	TOKEN_NUM_INITIALIZER
11032 		(struct cmd_rx_offload_get_configuration_result,
11033 		 port_id, RTE_UINT16);
11034 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11035 	TOKEN_STRING_INITIALIZER
11036 		(struct cmd_rx_offload_get_configuration_result,
11037 		 rx_offload, "rx_offload");
11038 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11039 	TOKEN_STRING_INITIALIZER
11040 		(struct cmd_rx_offload_get_configuration_result,
11041 		 configuration, "configuration");
11042 
11043 static void
11044 cmd_rx_offload_get_configuration_parsed(
11045 	void *parsed_result,
11046 	__rte_unused struct cmdline *cl,
11047 	__rte_unused void *data)
11048 {
11049 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
11050 	struct rte_eth_dev_info dev_info;
11051 	portid_t port_id = res->port_id;
11052 	struct rte_port *port = &ports[port_id];
11053 	struct rte_eth_conf dev_conf;
11054 	uint64_t port_offloads;
11055 	uint64_t queue_offloads;
11056 	uint16_t nb_rx_queues;
11057 	int q;
11058 	int ret;
11059 
11060 	printf("Rx Offloading Configuration of port %d :\n", port_id);
11061 
11062 	ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11063 	if (ret != 0)
11064 		return;
11065 
11066 	port_offloads = dev_conf.rxmode.offloads;
11067 	printf("  Port :");
11068 	print_rx_offloads(port_offloads);
11069 	printf("\n");
11070 
11071 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11072 	if (ret != 0)
11073 		return;
11074 
11075 	nb_rx_queues = dev_info.nb_rx_queues;
11076 	for (q = 0; q < nb_rx_queues; q++) {
11077 		queue_offloads = port->rxq[q].conf.offloads;
11078 		printf("  Queue[%2d] :", q);
11079 		print_rx_offloads(queue_offloads);
11080 		printf("\n");
11081 	}
11082 	printf("\n");
11083 }
11084 
11085 static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
11086 	.f = cmd_rx_offload_get_configuration_parsed,
11087 	.data = NULL,
11088 	.help_str = "show port <port_id> rx_offload configuration",
11089 	.tokens = {
11090 		(void *)&cmd_rx_offload_get_configuration_show,
11091 		(void *)&cmd_rx_offload_get_configuration_port,
11092 		(void *)&cmd_rx_offload_get_configuration_port_id,
11093 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
11094 		(void *)&cmd_rx_offload_get_configuration_configuration,
11095 		NULL,
11096 	}
11097 };
11098 
11099 /* Enable/Disable a per port offloading */
11100 struct cmd_config_per_port_rx_offload_result {
11101 	cmdline_fixed_string_t port;
11102 	cmdline_fixed_string_t config;
11103 	portid_t port_id;
11104 	cmdline_fixed_string_t rx_offload;
11105 	cmdline_fixed_string_t offload;
11106 	cmdline_fixed_string_t on_off;
11107 };
11108 
11109 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
11110 	TOKEN_STRING_INITIALIZER
11111 		(struct cmd_config_per_port_rx_offload_result,
11112 		 port, "port");
11113 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
11114 	TOKEN_STRING_INITIALIZER
11115 		(struct cmd_config_per_port_rx_offload_result,
11116 		 config, "config");
11117 static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
11118 	TOKEN_NUM_INITIALIZER
11119 		(struct cmd_config_per_port_rx_offload_result,
11120 		 port_id, RTE_UINT16);
11121 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
11122 	TOKEN_STRING_INITIALIZER
11123 		(struct cmd_config_per_port_rx_offload_result,
11124 		 rx_offload, "rx_offload");
11125 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
11126 	TOKEN_STRING_INITIALIZER
11127 		(struct cmd_config_per_port_rx_offload_result,
11128 		 offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11129 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11130 			   "vlan_filter#vlan_extend#"
11131 			   "scatter#buffer_split#timestamp#security#"
11132 			   "keep_crc#rss_hash");
11133 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
11134 	TOKEN_STRING_INITIALIZER
11135 		(struct cmd_config_per_port_rx_offload_result,
11136 		 on_off, "on#off");
11137 
11138 static uint64_t
11139 search_rx_offload(const char *name)
11140 {
11141 	uint64_t single_offload;
11142 	const char *single_name;
11143 	int found = 0;
11144 	unsigned int bit;
11145 
11146 	single_offload = 1;
11147 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11148 		single_name = rte_eth_dev_rx_offload_name(single_offload);
11149 		if (!strcasecmp(single_name, name)) {
11150 			found = 1;
11151 			break;
11152 		}
11153 		single_offload <<= 1;
11154 	}
11155 
11156 	if (found)
11157 		return single_offload;
11158 
11159 	return 0;
11160 }
11161 
11162 static void
11163 config_port_rx_offload(portid_t port_id, char *name, bool on)
11164 {
11165 	struct rte_eth_dev_info dev_info;
11166 	struct rte_port *port = &ports[port_id];
11167 	uint16_t nb_rx_queues;
11168 	uint64_t offload;
11169 	int q;
11170 	int ret;
11171 
11172 	if (port->port_status != RTE_PORT_STOPPED) {
11173 		fprintf(stderr,
11174 			"Error: Can't config offload when Port %d is not stopped\n",
11175 			port_id);
11176 		return;
11177 	}
11178 
11179 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11180 	if (ret != 0)
11181 		return;
11182 
11183 	if (!strcmp(name, "all")) {
11184 		offload = dev_info.rx_offload_capa;
11185 	} else {
11186 		offload = search_rx_offload(name);
11187 		if (offload == 0) {
11188 			fprintf(stderr, "Unknown offload name: %s\n", name);
11189 			return;
11190 		}
11191 		if ((offload & dev_info.rx_offload_capa) == 0) {
11192 			fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11193 				port_id, name);
11194 			return;
11195 		}
11196 	}
11197 
11198 	nb_rx_queues = dev_info.nb_rx_queues;
11199 	if (on) {
11200 		port->dev_conf.rxmode.offloads |= offload;
11201 		for (q = 0; q < nb_rx_queues; q++)
11202 			port->rxq[q].conf.offloads |= offload;
11203 	} else {
11204 		port->dev_conf.rxmode.offloads &= ~offload;
11205 		for (q = 0; q < nb_rx_queues; q++)
11206 			port->rxq[q].conf.offloads &= ~offload;
11207 	}
11208 
11209 	cmd_reconfig_device_queue(port_id, 1, 1);
11210 }
11211 
11212 static void
11213 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
11214 				__rte_unused struct cmdline *cl,
11215 				__rte_unused void *data)
11216 {
11217 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
11218 	bool on;
11219 
11220 	on = strcmp(res->on_off, "on") == 0;
11221 	config_port_rx_offload(res->port_id, res->offload, on);
11222 }
11223 
11224 static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
11225 	.f = cmd_config_per_port_rx_offload_parsed,
11226 	.data = NULL,
11227 	.help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
11228 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11229 		    "macsec_strip|vlan_filter|vlan_extend|"
11230 		    "scatter|buffer_split|timestamp|security|"
11231 		    "keep_crc|rss_hash on|off",
11232 	.tokens = {
11233 		(void *)&cmd_config_per_port_rx_offload_result_port,
11234 		(void *)&cmd_config_per_port_rx_offload_result_config,
11235 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
11236 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
11237 		(void *)&cmd_config_per_port_rx_offload_result_offload,
11238 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
11239 		NULL,
11240 	}
11241 };
11242 
11243 /* Enable/Disable all port Rx offloading */
11244 struct cmd_config_all_port_rx_offload_result {
11245 	cmdline_fixed_string_t port;
11246 	cmdline_fixed_string_t config;
11247 	cmdline_fixed_string_t port_all;
11248 	cmdline_fixed_string_t rx_offload;
11249 	cmdline_fixed_string_t offload;
11250 	cmdline_fixed_string_t on_off;
11251 };
11252 
11253 static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
11254 	TOKEN_STRING_INITIALIZER
11255 		(struct cmd_config_all_port_rx_offload_result,
11256 		 port, "port");
11257 static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
11258 	TOKEN_STRING_INITIALIZER
11259 		(struct cmd_config_all_port_rx_offload_result,
11260 		 config, "config");
11261 
11262 static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
11263 	TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
11264 				 port_all, "all");
11265 static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
11266 	TOKEN_STRING_INITIALIZER
11267 		(struct cmd_config_all_port_rx_offload_result,
11268 		 rx_offload, "rx_offload");
11269 static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
11270 	TOKEN_STRING_INITIALIZER
11271 		(struct cmd_config_all_port_rx_offload_result,
11272 		 offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11273 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11274 			   "vlan_filter#vlan_extend#"
11275 			   "scatter#buffer_split#timestamp#security#"
11276 			   "keep_crc#rss_hash");
11277 static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
11278 	TOKEN_STRING_INITIALIZER
11279 		(struct cmd_config_all_port_rx_offload_result,
11280 		 on_off, "on#off");
11281 
11282 static void
11283 cmd_config_all_port_rx_offload_parsed(void *parsed_result,
11284 				__rte_unused struct cmdline *cl,
11285 				__rte_unused void *data)
11286 {
11287 	struct cmd_config_all_port_rx_offload_result *res = parsed_result;
11288 	bool on_off;
11289 	portid_t i;
11290 
11291 	on_off = strcmp(res->on_off, "on") == 0;
11292 	RTE_ETH_FOREACH_DEV(i)
11293 		config_port_rx_offload(i, res->offload, on_off);
11294 
11295 }
11296 
11297 static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
11298 	.f = cmd_config_all_port_rx_offload_parsed,
11299 	.data = NULL,
11300 	.help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
11301 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11302 		    "macsec_strip|vlan_filter|vlan_extend|"
11303 		    "scatter|buffer_split|timestamp|security|"
11304 		    "keep_crc|rss_hash on|off",
11305 	.tokens = {
11306 		(void *)&cmd_config_all_port_rx_offload_result_port,
11307 		(void *)&cmd_config_all_port_rx_offload_result_config,
11308 		(void *)&cmd_config_all_port_rx_offload_result_port_all,
11309 		(void *)&cmd_config_all_port_rx_offload_result_rx_offload,
11310 		(void *)&cmd_config_all_port_rx_offload_result_offload,
11311 		(void *)&cmd_config_all_port_rx_offload_result_on_off,
11312 		NULL,
11313 	}
11314 };
11315 
11316 /* Enable/Disable a per queue offloading */
11317 struct cmd_config_per_queue_rx_offload_result {
11318 	cmdline_fixed_string_t port;
11319 	portid_t port_id;
11320 	cmdline_fixed_string_t rxq;
11321 	uint16_t queue_id;
11322 	cmdline_fixed_string_t rx_offload;
11323 	cmdline_fixed_string_t offload;
11324 	cmdline_fixed_string_t on_off;
11325 };
11326 
11327 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
11328 	TOKEN_STRING_INITIALIZER
11329 		(struct cmd_config_per_queue_rx_offload_result,
11330 		 port, "port");
11331 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
11332 	TOKEN_NUM_INITIALIZER
11333 		(struct cmd_config_per_queue_rx_offload_result,
11334 		 port_id, RTE_UINT16);
11335 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
11336 	TOKEN_STRING_INITIALIZER
11337 		(struct cmd_config_per_queue_rx_offload_result,
11338 		 rxq, "rxq");
11339 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
11340 	TOKEN_NUM_INITIALIZER
11341 		(struct cmd_config_per_queue_rx_offload_result,
11342 		 queue_id, RTE_UINT16);
11343 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
11344 	TOKEN_STRING_INITIALIZER
11345 		(struct cmd_config_per_queue_rx_offload_result,
11346 		 rx_offload, "rx_offload");
11347 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
11348 	TOKEN_STRING_INITIALIZER
11349 		(struct cmd_config_per_queue_rx_offload_result,
11350 		 offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11351 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11352 			   "vlan_filter#vlan_extend#"
11353 			   "scatter#buffer_split#timestamp#security#keep_crc");
11354 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
11355 	TOKEN_STRING_INITIALIZER
11356 		(struct cmd_config_per_queue_rx_offload_result,
11357 		 on_off, "on#off");
11358 
11359 static void
11360 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
11361 				__rte_unused struct cmdline *cl,
11362 				__rte_unused void *data)
11363 {
11364 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
11365 	struct rte_eth_dev_info dev_info;
11366 	portid_t port_id = res->port_id;
11367 	uint16_t queue_id = res->queue_id;
11368 	struct rte_port *port = &ports[port_id];
11369 	uint64_t offload;
11370 	int ret;
11371 
11372 	if (port->port_status != RTE_PORT_STOPPED) {
11373 		fprintf(stderr,
11374 			"Error: Can't config offload when Port %d is not stopped\n",
11375 			port_id);
11376 		return;
11377 	}
11378 
11379 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11380 	if (ret != 0)
11381 		return;
11382 
11383 	if (queue_id >= dev_info.nb_rx_queues) {
11384 		fprintf(stderr,
11385 			"Error: input queue_id should be 0 ... %d\n",
11386 			dev_info.nb_rx_queues - 1);
11387 		return;
11388 	}
11389 
11390 	if (!strcmp(res->offload, "all")) {
11391 		offload = dev_info.rx_queue_offload_capa;
11392 	} else {
11393 		offload = search_rx_offload(res->offload);
11394 		if (offload == 0) {
11395 			fprintf(stderr, "Unknown offload name: %s\n", res->offload);
11396 			return;
11397 		}
11398 		if ((offload & dev_info.rx_queue_offload_capa) == 0) {
11399 			fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
11400 				port_id, res->offload);
11401 			return;
11402 		}
11403 	}
11404 
11405 	if (!strcmp(res->on_off, "on"))
11406 		port->rxq[queue_id].conf.offloads |= offload;
11407 	else
11408 		port->rxq[queue_id].conf.offloads &= ~offload;
11409 
11410 	cmd_reconfig_device_queue(port_id, 1, 1);
11411 }
11412 
11413 static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
11414 	.f = cmd_config_per_queue_rx_offload_parsed,
11415 	.data = NULL,
11416 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
11417 		    "all|vlan_strip|ipv4_cksum|"
11418 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11419 		    "macsec_strip|vlan_filter|vlan_extend|"
11420 		    "scatter|buffer_split|timestamp|security|"
11421 		    "keep_crc on|off",
11422 	.tokens = {
11423 		(void *)&cmd_config_per_queue_rx_offload_result_port,
11424 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
11425 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
11426 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
11427 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
11428 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
11429 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
11430 		NULL,
11431 	}
11432 };
11433 
11434 /* Get Tx offloads capabilities */
11435 struct cmd_tx_offload_get_capa_result {
11436 	cmdline_fixed_string_t show;
11437 	cmdline_fixed_string_t port;
11438 	portid_t port_id;
11439 	cmdline_fixed_string_t tx_offload;
11440 	cmdline_fixed_string_t capabilities;
11441 };
11442 
11443 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
11444 	TOKEN_STRING_INITIALIZER
11445 		(struct cmd_tx_offload_get_capa_result,
11446 		 show, "show");
11447 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
11448 	TOKEN_STRING_INITIALIZER
11449 		(struct cmd_tx_offload_get_capa_result,
11450 		 port, "port");
11451 static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
11452 	TOKEN_NUM_INITIALIZER
11453 		(struct cmd_tx_offload_get_capa_result,
11454 		 port_id, RTE_UINT16);
11455 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
11456 	TOKEN_STRING_INITIALIZER
11457 		(struct cmd_tx_offload_get_capa_result,
11458 		 tx_offload, "tx_offload");
11459 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
11460 	TOKEN_STRING_INITIALIZER
11461 		(struct cmd_tx_offload_get_capa_result,
11462 		 capabilities, "capabilities");
11463 
11464 static void
11465 print_tx_offloads(uint64_t offloads)
11466 {
11467 	uint64_t single_offload;
11468 	int begin;
11469 	int end;
11470 	int bit;
11471 
11472 	if (offloads == 0)
11473 		return;
11474 
11475 	begin = rte_ctz64(offloads);
11476 	end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11477 
11478 	single_offload = 1ULL << begin;
11479 	for (bit = begin; bit < end; bit++) {
11480 		if (offloads & single_offload)
11481 			printf(" %s",
11482 			       rte_eth_dev_tx_offload_name(single_offload));
11483 		single_offload <<= 1;
11484 	}
11485 }
11486 
11487 static void
11488 cmd_tx_offload_get_capa_parsed(
11489 	void *parsed_result,
11490 	__rte_unused struct cmdline *cl,
11491 	__rte_unused void *data)
11492 {
11493 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
11494 	struct rte_eth_dev_info dev_info;
11495 	portid_t port_id = res->port_id;
11496 	uint64_t queue_offloads;
11497 	uint64_t port_offloads;
11498 	int ret;
11499 
11500 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11501 	if (ret != 0)
11502 		return;
11503 
11504 	queue_offloads = dev_info.tx_queue_offload_capa;
11505 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
11506 
11507 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
11508 	printf("  Per Queue :");
11509 	print_tx_offloads(queue_offloads);
11510 
11511 	printf("\n");
11512 	printf("  Per Port  :");
11513 	print_tx_offloads(port_offloads);
11514 	printf("\n\n");
11515 }
11516 
11517 static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
11518 	.f = cmd_tx_offload_get_capa_parsed,
11519 	.data = NULL,
11520 	.help_str = "show port <port_id> tx_offload capabilities",
11521 	.tokens = {
11522 		(void *)&cmd_tx_offload_get_capa_show,
11523 		(void *)&cmd_tx_offload_get_capa_port,
11524 		(void *)&cmd_tx_offload_get_capa_port_id,
11525 		(void *)&cmd_tx_offload_get_capa_tx_offload,
11526 		(void *)&cmd_tx_offload_get_capa_capabilities,
11527 		NULL,
11528 	}
11529 };
11530 
11531 /* Get Tx offloads configuration */
11532 struct cmd_tx_offload_get_configuration_result {
11533 	cmdline_fixed_string_t show;
11534 	cmdline_fixed_string_t port;
11535 	portid_t port_id;
11536 	cmdline_fixed_string_t tx_offload;
11537 	cmdline_fixed_string_t configuration;
11538 };
11539 
11540 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
11541 	TOKEN_STRING_INITIALIZER
11542 		(struct cmd_tx_offload_get_configuration_result,
11543 		 show, "show");
11544 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
11545 	TOKEN_STRING_INITIALIZER
11546 		(struct cmd_tx_offload_get_configuration_result,
11547 		 port, "port");
11548 static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
11549 	TOKEN_NUM_INITIALIZER
11550 		(struct cmd_tx_offload_get_configuration_result,
11551 		 port_id, RTE_UINT16);
11552 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
11553 	TOKEN_STRING_INITIALIZER
11554 		(struct cmd_tx_offload_get_configuration_result,
11555 		 tx_offload, "tx_offload");
11556 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
11557 	TOKEN_STRING_INITIALIZER
11558 		(struct cmd_tx_offload_get_configuration_result,
11559 		 configuration, "configuration");
11560 
11561 static void
11562 cmd_tx_offload_get_configuration_parsed(
11563 	void *parsed_result,
11564 	__rte_unused struct cmdline *cl,
11565 	__rte_unused void *data)
11566 {
11567 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
11568 	struct rte_eth_dev_info dev_info;
11569 	portid_t port_id = res->port_id;
11570 	struct rte_port *port = &ports[port_id];
11571 	struct rte_eth_conf dev_conf;
11572 	uint64_t port_offloads;
11573 	uint64_t queue_offloads;
11574 	uint16_t nb_tx_queues;
11575 	int q;
11576 	int ret;
11577 
11578 	printf("Tx Offloading Configuration of port %d :\n", port_id);
11579 
11580 	ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11581 	if (ret != 0)
11582 		return;
11583 
11584 	port_offloads = dev_conf.txmode.offloads;
11585 	printf("  Port :");
11586 	print_tx_offloads(port_offloads);
11587 	printf("\n");
11588 
11589 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11590 	if (ret != 0)
11591 		return;
11592 
11593 	nb_tx_queues = dev_info.nb_tx_queues;
11594 	for (q = 0; q < nb_tx_queues; q++) {
11595 		queue_offloads = port->txq[q].conf.offloads;
11596 		printf("  Queue[%2d] :", q);
11597 		print_tx_offloads(queue_offloads);
11598 		printf("\n");
11599 	}
11600 	printf("\n");
11601 }
11602 
11603 static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
11604 	.f = cmd_tx_offload_get_configuration_parsed,
11605 	.data = NULL,
11606 	.help_str = "show port <port_id> tx_offload configuration",
11607 	.tokens = {
11608 		(void *)&cmd_tx_offload_get_configuration_show,
11609 		(void *)&cmd_tx_offload_get_configuration_port,
11610 		(void *)&cmd_tx_offload_get_configuration_port_id,
11611 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
11612 		(void *)&cmd_tx_offload_get_configuration_configuration,
11613 		NULL,
11614 	}
11615 };
11616 
11617 /* Enable/Disable a per port offloading */
11618 struct cmd_config_per_port_tx_offload_result {
11619 	cmdline_fixed_string_t port;
11620 	cmdline_fixed_string_t config;
11621 	portid_t port_id;
11622 	cmdline_fixed_string_t tx_offload;
11623 	cmdline_fixed_string_t offload;
11624 	cmdline_fixed_string_t on_off;
11625 };
11626 
11627 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
11628 	TOKEN_STRING_INITIALIZER
11629 		(struct cmd_config_per_port_tx_offload_result,
11630 		 port, "port");
11631 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
11632 	TOKEN_STRING_INITIALIZER
11633 		(struct cmd_config_per_port_tx_offload_result,
11634 		 config, "config");
11635 static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
11636 	TOKEN_NUM_INITIALIZER
11637 		(struct cmd_config_per_port_tx_offload_result,
11638 		 port_id, RTE_UINT16);
11639 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
11640 	TOKEN_STRING_INITIALIZER
11641 		(struct cmd_config_per_port_tx_offload_result,
11642 		 tx_offload, "tx_offload");
11643 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
11644 	TOKEN_STRING_INITIALIZER
11645 		(struct cmd_config_per_port_tx_offload_result,
11646 		 offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11647 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11648 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11649 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11650 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
11651 			  "send_on_timestamp");
11652 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
11653 	TOKEN_STRING_INITIALIZER
11654 		(struct cmd_config_per_port_tx_offload_result,
11655 		 on_off, "on#off");
11656 
11657 static uint64_t
11658 search_tx_offload(const char *name)
11659 {
11660 	uint64_t single_offload;
11661 	const char *single_name;
11662 	int found = 0;
11663 	unsigned int bit;
11664 
11665 	single_offload = 1;
11666 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11667 		single_name = rte_eth_dev_tx_offload_name(single_offload);
11668 		if (single_name == NULL)
11669 			break;
11670 		if (!strcasecmp(single_name, name)) {
11671 			found = 1;
11672 			break;
11673 		} else if (!strcasecmp(single_name, "UNKNOWN"))
11674 			break;
11675 		single_offload <<= 1;
11676 	}
11677 
11678 	if (found)
11679 		return single_offload;
11680 
11681 	return 0;
11682 }
11683 
11684 static void
11685 config_port_tx_offload(portid_t port_id, char *name, bool on)
11686 {
11687 	struct rte_eth_dev_info dev_info;
11688 	struct rte_port *port = &ports[port_id];
11689 	uint16_t nb_tx_queues;
11690 	uint64_t offload;
11691 	int q;
11692 	int ret;
11693 
11694 	if (port->port_status != RTE_PORT_STOPPED) {
11695 		fprintf(stderr,
11696 			"Error: Can't config offload when Port %d is not stopped\n",
11697 			port_id);
11698 		return;
11699 	}
11700 
11701 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11702 	if (ret != 0)
11703 		return;
11704 
11705 	if (!strcmp(name, "all")) {
11706 		offload = dev_info.tx_offload_capa;
11707 	} else {
11708 		offload = search_tx_offload(name);
11709 		if (offload == 0) {
11710 			fprintf(stderr, "Unknown offload name: %s\n", name);
11711 			return;
11712 		}
11713 		if ((offload & dev_info.tx_offload_capa) == 0) {
11714 			fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11715 				port_id, name);
11716 			return;
11717 		}
11718 	}
11719 
11720 	nb_tx_queues = dev_info.nb_tx_queues;
11721 	if (on) {
11722 		port->dev_conf.txmode.offloads |= offload;
11723 		for (q = 0; q < nb_tx_queues; q++)
11724 			port->txq[q].conf.offloads |= offload;
11725 	} else {
11726 		port->dev_conf.txmode.offloads &= ~offload;
11727 		for (q = 0; q < nb_tx_queues; q++)
11728 			port->txq[q].conf.offloads &= ~offload;
11729 	}
11730 
11731 	cmd_reconfig_device_queue(port_id, 1, 1);
11732 }
11733 
11734 static void
11735 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
11736 				__rte_unused struct cmdline *cl,
11737 				__rte_unused void *data)
11738 {
11739 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
11740 	bool on;
11741 
11742 	on = strcmp(res->on_off, "on") == 0;
11743 	config_port_tx_offload(res->port_id, res->offload, on);
11744 }
11745 
11746 static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
11747 	.f = cmd_config_per_port_tx_offload_parsed,
11748 	.data = NULL,
11749 	.help_str = "port config <port_id> tx_offload "
11750 		    "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11751 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11752 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11753 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11754 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
11755 		    "send_on_timestamp on|off",
11756 	.tokens = {
11757 		(void *)&cmd_config_per_port_tx_offload_result_port,
11758 		(void *)&cmd_config_per_port_tx_offload_result_config,
11759 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
11760 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
11761 		(void *)&cmd_config_per_port_tx_offload_result_offload,
11762 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
11763 		NULL,
11764 	}
11765 };
11766 
11767 /* Enable/Disable all port Tx offloading */
11768 struct cmd_config_all_port_tx_offload_result {
11769 	cmdline_fixed_string_t port;
11770 	cmdline_fixed_string_t config;
11771 	cmdline_fixed_string_t port_all;
11772 	cmdline_fixed_string_t tx_offload;
11773 	cmdline_fixed_string_t offload;
11774 	cmdline_fixed_string_t on_off;
11775 };
11776 
11777 static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
11778 	TOKEN_STRING_INITIALIZER
11779 		(struct cmd_config_all_port_tx_offload_result,
11780 		 port, "port");
11781 static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
11782 	TOKEN_STRING_INITIALIZER
11783 		(struct cmd_config_all_port_tx_offload_result,
11784 		 config, "config");
11785 static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
11786 	TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
11787 				 port_all, "all");
11788 static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
11789 	TOKEN_STRING_INITIALIZER
11790 		(struct cmd_config_all_port_tx_offload_result,
11791 		 tx_offload, "tx_offload");
11792 static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
11793 	TOKEN_STRING_INITIALIZER
11794 		(struct cmd_config_all_port_tx_offload_result,
11795 		 offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11796 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11797 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11798 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11799 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
11800 			  "send_on_timestamp");
11801 static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
11802 	TOKEN_STRING_INITIALIZER
11803 		(struct cmd_config_all_port_tx_offload_result,
11804 		 on_off, "on#off");
11805 
11806 static void
11807 cmd_config_all_port_tx_offload_parsed(void *parsed_result,
11808 				__rte_unused struct cmdline *cl,
11809 				__rte_unused void *data)
11810 {
11811 	struct cmd_config_all_port_tx_offload_result *res = parsed_result;
11812 	portid_t i;
11813 	bool on_off;
11814 
11815 	on_off = strcmp(res->on_off, "on") == 0;
11816 	RTE_ETH_FOREACH_DEV(i)
11817 		config_port_tx_offload(i, res->offload, on_off);
11818 }
11819 
11820 static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
11821 	.f = cmd_config_all_port_tx_offload_parsed,
11822 	.data = NULL,
11823 	.help_str = "port config all tx_offload "
11824 		    "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11825 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11826 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11827 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11828 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
11829 		    "send_on_timestamp on|off",
11830 	.tokens = {
11831 		(void *)&cmd_config_all_port_tx_offload_result_port,
11832 		(void *)&cmd_config_all_port_tx_offload_result_config,
11833 		(void *)&cmd_config_all_port_tx_offload_result_port_all,
11834 		(void *)&cmd_config_all_port_tx_offload_result_tx_offload,
11835 		(void *)&cmd_config_all_port_tx_offload_result_offload,
11836 		(void *)&cmd_config_all_port_tx_offload_result_on_off,
11837 		NULL,
11838 	}
11839 };
11840 
11841 /* Enable/Disable a per queue offloading */
11842 struct cmd_config_per_queue_tx_offload_result {
11843 	cmdline_fixed_string_t port;
11844 	portid_t port_id;
11845 	cmdline_fixed_string_t txq;
11846 	uint16_t queue_id;
11847 	cmdline_fixed_string_t tx_offload;
11848 	cmdline_fixed_string_t offload;
11849 	cmdline_fixed_string_t on_off;
11850 };
11851 
11852 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
11853 	TOKEN_STRING_INITIALIZER
11854 		(struct cmd_config_per_queue_tx_offload_result,
11855 		 port, "port");
11856 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
11857 	TOKEN_NUM_INITIALIZER
11858 		(struct cmd_config_per_queue_tx_offload_result,
11859 		 port_id, RTE_UINT16);
11860 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
11861 	TOKEN_STRING_INITIALIZER
11862 		(struct cmd_config_per_queue_tx_offload_result,
11863 		 txq, "txq");
11864 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
11865 	TOKEN_NUM_INITIALIZER
11866 		(struct cmd_config_per_queue_tx_offload_result,
11867 		 queue_id, RTE_UINT16);
11868 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
11869 	TOKEN_STRING_INITIALIZER
11870 		(struct cmd_config_per_queue_tx_offload_result,
11871 		 tx_offload, "tx_offload");
11872 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
11873 	TOKEN_STRING_INITIALIZER
11874 		(struct cmd_config_per_queue_tx_offload_result,
11875 		 offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11876 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11877 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11878 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11879 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
11880 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
11881 	TOKEN_STRING_INITIALIZER
11882 		(struct cmd_config_per_queue_tx_offload_result,
11883 		 on_off, "on#off");
11884 
11885 static void
11886 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
11887 				__rte_unused struct cmdline *cl,
11888 				__rte_unused void *data)
11889 {
11890 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
11891 	struct rte_eth_dev_info dev_info;
11892 	portid_t port_id = res->port_id;
11893 	uint16_t queue_id = res->queue_id;
11894 	struct rte_port *port = &ports[port_id];
11895 	uint64_t offload;
11896 	int ret;
11897 
11898 	if (port->port_status != RTE_PORT_STOPPED) {
11899 		fprintf(stderr,
11900 			"Error: Can't config offload when Port %d is not stopped\n",
11901 			port_id);
11902 		return;
11903 	}
11904 
11905 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11906 	if (ret != 0)
11907 		return;
11908 
11909 	if (queue_id >= dev_info.nb_tx_queues) {
11910 		fprintf(stderr,
11911 			"Error: input queue_id should be 0 ... %d\n",
11912 			dev_info.nb_tx_queues - 1);
11913 		return;
11914 	}
11915 
11916 	if (!strcmp(res->offload, "all")) {
11917 		offload = dev_info.tx_queue_offload_capa;
11918 	} else {
11919 		offload = search_tx_offload(res->offload);
11920 		if (offload == 0) {
11921 			fprintf(stderr, "Unknown offload name: %s\n", res->offload);
11922 			return;
11923 		}
11924 		if ((offload & dev_info.tx_queue_offload_capa) == 0) {
11925 			fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
11926 				port_id, res->offload);
11927 			return;
11928 		}
11929 	}
11930 
11931 	if (!strcmp(res->on_off, "on"))
11932 		port->txq[queue_id].conf.offloads |= offload;
11933 	else
11934 		port->txq[queue_id].conf.offloads &= ~offload;
11935 
11936 	cmd_reconfig_device_queue(port_id, 1, 1);
11937 }
11938 
11939 static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
11940 	.f = cmd_config_per_queue_tx_offload_parsed,
11941 	.data = NULL,
11942 	.help_str = "port <port_id> txq <queue_id> tx_offload "
11943 		    "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11944 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11945 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11946 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11947 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
11948 		    "on|off",
11949 	.tokens = {
11950 		(void *)&cmd_config_per_queue_tx_offload_result_port,
11951 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
11952 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
11953 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
11954 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
11955 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
11956 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
11957 		NULL,
11958 	}
11959 };
11960 
11961 /* *** configure tx_metadata for specific port *** */
11962 struct cmd_config_tx_metadata_specific_result {
11963 	cmdline_fixed_string_t port;
11964 	cmdline_fixed_string_t keyword;
11965 	uint16_t port_id;
11966 	cmdline_fixed_string_t item;
11967 	uint32_t value;
11968 };
11969 
11970 static void
11971 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
11972 				__rte_unused struct cmdline *cl,
11973 				__rte_unused void *data)
11974 {
11975 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
11976 
11977 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11978 		return;
11979 	ports[res->port_id].tx_metadata = res->value;
11980 	/* Add/remove callback to insert valid metadata in every Tx packet. */
11981 	if (ports[res->port_id].tx_metadata)
11982 		add_tx_md_callback(res->port_id);
11983 	else
11984 		remove_tx_md_callback(res->port_id);
11985 	rte_flow_dynf_metadata_register();
11986 }
11987 
11988 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
11989 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
11990 			port, "port");
11991 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
11992 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
11993 			keyword, "config");
11994 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
11995 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
11996 			port_id, RTE_UINT16);
11997 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
11998 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
11999 			item, "tx_metadata");
12000 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
12001 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12002 			value, RTE_UINT32);
12003 
12004 static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12005 	.f = cmd_config_tx_metadata_specific_parsed,
12006 	.data = NULL,
12007 	.help_str = "port config <port_id> tx_metadata <value>",
12008 	.tokens = {
12009 		(void *)&cmd_config_tx_metadata_specific_port,
12010 		(void *)&cmd_config_tx_metadata_specific_keyword,
12011 		(void *)&cmd_config_tx_metadata_specific_id,
12012 		(void *)&cmd_config_tx_metadata_specific_item,
12013 		(void *)&cmd_config_tx_metadata_specific_value,
12014 		NULL,
12015 	},
12016 };
12017 
12018 /* *** set dynf *** */
12019 struct cmd_config_tx_dynf_specific_result {
12020 	cmdline_fixed_string_t port;
12021 	cmdline_fixed_string_t keyword;
12022 	uint16_t port_id;
12023 	cmdline_fixed_string_t item;
12024 	cmdline_fixed_string_t name;
12025 	cmdline_fixed_string_t value;
12026 };
12027 
12028 static void
12029 cmd_config_dynf_specific_parsed(void *parsed_result,
12030 				__rte_unused struct cmdline *cl,
12031 				__rte_unused void *data)
12032 {
12033 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12034 	struct rte_mbuf_dynflag desc_flag;
12035 	int flag;
12036 	uint64_t old_port_flags;
12037 
12038 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12039 		return;
12040 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
12041 	if (flag <= 0) {
12042 		if (strlcpy(desc_flag.name, res->name,
12043 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
12044 			fprintf(stderr, "Flag name too long\n");
12045 			return;
12046 		}
12047 		desc_flag.flags = 0;
12048 		flag = rte_mbuf_dynflag_register(&desc_flag);
12049 		if (flag < 0) {
12050 			fprintf(stderr, "Can't register flag\n");
12051 			return;
12052 		}
12053 		strcpy(dynf_names[flag], desc_flag.name);
12054 	}
12055 	old_port_flags = ports[res->port_id].mbuf_dynf;
12056 	if (!strcmp(res->value, "set")) {
12057 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
12058 		if (old_port_flags == 0)
12059 			add_tx_dynf_callback(res->port_id);
12060 	} else {
12061 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
12062 		if (ports[res->port_id].mbuf_dynf == 0)
12063 			remove_tx_dynf_callback(res->port_id);
12064 	}
12065 }
12066 
12067 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
12068 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12069 			keyword, "port");
12070 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
12071 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12072 			keyword, "config");
12073 static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
12074 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12075 			port_id, RTE_UINT16);
12076 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
12077 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12078 			item, "dynf");
12079 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
12080 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12081 			name, NULL);
12082 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
12083 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12084 			value, "set#clear");
12085 
12086 static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
12087 	.f = cmd_config_dynf_specific_parsed,
12088 	.data = NULL,
12089 	.help_str = "port config <port id> dynf <name> set|clear",
12090 	.tokens = {
12091 		(void *)&cmd_config_tx_dynf_specific_port,
12092 		(void *)&cmd_config_tx_dynf_specific_keyword,
12093 		(void *)&cmd_config_tx_dynf_specific_port_id,
12094 		(void *)&cmd_config_tx_dynf_specific_item,
12095 		(void *)&cmd_config_tx_dynf_specific_name,
12096 		(void *)&cmd_config_tx_dynf_specific_value,
12097 		NULL,
12098 	},
12099 };
12100 
12101 /* *** display tx_metadata per port configuration *** */
12102 struct cmd_show_tx_metadata_result {
12103 	cmdline_fixed_string_t cmd_show;
12104 	cmdline_fixed_string_t cmd_port;
12105 	cmdline_fixed_string_t cmd_keyword;
12106 	portid_t cmd_pid;
12107 };
12108 
12109 static void
12110 cmd_show_tx_metadata_parsed(void *parsed_result,
12111 		__rte_unused struct cmdline *cl,
12112 		__rte_unused void *data)
12113 {
12114 	struct cmd_show_tx_metadata_result *res = parsed_result;
12115 
12116 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12117 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
12118 		return;
12119 	}
12120 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
12121 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
12122 		       ports[res->cmd_pid].tx_metadata);
12123 	}
12124 }
12125 
12126 static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
12127 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12128 			cmd_show, "show");
12129 static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
12130 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12131 			cmd_port, "port");
12132 static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
12133 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
12134 			cmd_pid, RTE_UINT16);
12135 static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
12136 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12137 			cmd_keyword, "tx_metadata");
12138 
12139 static cmdline_parse_inst_t cmd_show_tx_metadata = {
12140 	.f = cmd_show_tx_metadata_parsed,
12141 	.data = NULL,
12142 	.help_str = "show port <port_id> tx_metadata",
12143 	.tokens = {
12144 		(void *)&cmd_show_tx_metadata_show,
12145 		(void *)&cmd_show_tx_metadata_port,
12146 		(void *)&cmd_show_tx_metadata_pid,
12147 		(void *)&cmd_show_tx_metadata_keyword,
12148 		NULL,
12149 	},
12150 };
12151 
12152 /* *** show fec capability per port configuration *** */
12153 struct cmd_show_fec_capability_result {
12154 	cmdline_fixed_string_t cmd_show;
12155 	cmdline_fixed_string_t cmd_port;
12156 	cmdline_fixed_string_t cmd_fec;
12157 	cmdline_fixed_string_t cmd_keyword;
12158 	portid_t cmd_pid;
12159 };
12160 
12161 static void
12162 cmd_show_fec_capability_parsed(void *parsed_result,
12163 		__rte_unused struct cmdline *cl,
12164 		__rte_unused void *data)
12165 {
12166 	struct cmd_show_fec_capability_result *res = parsed_result;
12167 	struct rte_eth_fec_capa *speed_fec_capa;
12168 	unsigned int num;
12169 	int ret;
12170 
12171 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12172 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12173 		return;
12174 	}
12175 
12176 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
12177 	if (ret == -ENOTSUP) {
12178 		fprintf(stderr, "Function not implemented\n");
12179 		return;
12180 	} else if (ret < 0) {
12181 		fprintf(stderr, "Get FEC capability failed: %d\n", ret);
12182 		return;
12183 	}
12184 
12185 	num = (unsigned int)ret;
12186 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
12187 	if (speed_fec_capa == NULL) {
12188 		fprintf(stderr, "Failed to alloc FEC capability buffer\n");
12189 		return;
12190 	}
12191 
12192 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
12193 	if (ret < 0) {
12194 		fprintf(stderr, "Error getting FEC capability: %d\n", ret);
12195 		goto out;
12196 	}
12197 
12198 	show_fec_capability(num, speed_fec_capa);
12199 out:
12200 	free(speed_fec_capa);
12201 }
12202 
12203 static cmdline_parse_token_string_t cmd_show_fec_capability_show =
12204 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12205 			cmd_show, "show");
12206 static cmdline_parse_token_string_t cmd_show_fec_capability_port =
12207 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12208 			cmd_port, "port");
12209 static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
12210 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
12211 			cmd_pid, RTE_UINT16);
12212 static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
12213 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12214 			cmd_fec, "fec");
12215 static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
12216 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12217 			cmd_keyword, "capabilities");
12218 
12219 static cmdline_parse_inst_t cmd_show_capability = {
12220 	.f = cmd_show_fec_capability_parsed,
12221 	.data = NULL,
12222 	.help_str = "show port <port_id> fec capabilities",
12223 	.tokens = {
12224 		(void *)&cmd_show_fec_capability_show,
12225 		(void *)&cmd_show_fec_capability_port,
12226 		(void *)&cmd_show_fec_capability_pid,
12227 		(void *)&cmd_show_fec_capability_fec,
12228 		(void *)&cmd_show_fec_capability_keyword,
12229 		NULL,
12230 	},
12231 };
12232 
12233 /* *** show fec mode per port configuration *** */
12234 struct cmd_show_fec_metadata_result {
12235 	cmdline_fixed_string_t cmd_show;
12236 	cmdline_fixed_string_t cmd_port;
12237 	cmdline_fixed_string_t cmd_keyword;
12238 	portid_t cmd_pid;
12239 };
12240 
12241 static void
12242 cmd_show_fec_mode_parsed(void *parsed_result,
12243 		__rte_unused struct cmdline *cl,
12244 		__rte_unused void *data)
12245 {
12246 #define FEC_NAME_SIZE 16
12247 	struct cmd_show_fec_metadata_result *res = parsed_result;
12248 	uint32_t mode;
12249 	char buf[FEC_NAME_SIZE];
12250 	int ret;
12251 
12252 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12253 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12254 		return;
12255 	}
12256 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
12257 	if (ret == -ENOTSUP) {
12258 		fprintf(stderr, "Function not implemented\n");
12259 		return;
12260 	} else if (ret < 0) {
12261 		fprintf(stderr, "Get FEC mode failed\n");
12262 		return;
12263 	}
12264 
12265 	switch (mode) {
12266 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
12267 		strlcpy(buf, "off", sizeof(buf));
12268 		break;
12269 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
12270 		strlcpy(buf, "auto", sizeof(buf));
12271 		break;
12272 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
12273 		strlcpy(buf, "baser", sizeof(buf));
12274 		break;
12275 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
12276 		strlcpy(buf, "rs", sizeof(buf));
12277 		break;
12278 	case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
12279 		strlcpy(buf, "llrs", sizeof(buf));
12280 		break;
12281 	default:
12282 		return;
12283 	}
12284 
12285 	printf("%s\n", buf);
12286 }
12287 
12288 static cmdline_parse_token_string_t cmd_show_fec_mode_show =
12289 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12290 			cmd_show, "show");
12291 static cmdline_parse_token_string_t cmd_show_fec_mode_port =
12292 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12293 			cmd_port, "port");
12294 static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
12295 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
12296 			cmd_pid, RTE_UINT16);
12297 static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
12298 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12299 			cmd_keyword, "fec_mode");
12300 
12301 static cmdline_parse_inst_t cmd_show_fec_mode = {
12302 	.f = cmd_show_fec_mode_parsed,
12303 	.data = NULL,
12304 	.help_str = "show port <port_id> fec_mode",
12305 	.tokens = {
12306 		(void *)&cmd_show_fec_mode_show,
12307 		(void *)&cmd_show_fec_mode_port,
12308 		(void *)&cmd_show_fec_mode_pid,
12309 		(void *)&cmd_show_fec_mode_keyword,
12310 		NULL,
12311 	},
12312 };
12313 
12314 /* *** set fec mode per port configuration *** */
12315 struct cmd_set_port_fec_mode {
12316 	cmdline_fixed_string_t set;
12317 	cmdline_fixed_string_t port;
12318 	portid_t port_id;
12319 	cmdline_fixed_string_t fec_mode;
12320 	cmdline_fixed_string_t fec_value;
12321 };
12322 
12323 /* Common CLI fields for set fec mode */
12324 static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
12325 	TOKEN_STRING_INITIALIZER
12326 		(struct cmd_set_port_fec_mode,
12327 		 set, "set");
12328 static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
12329 	TOKEN_STRING_INITIALIZER
12330 		(struct cmd_set_port_fec_mode,
12331 		 port, "port");
12332 static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
12333 	TOKEN_NUM_INITIALIZER
12334 		(struct cmd_set_port_fec_mode,
12335 		 port_id, RTE_UINT16);
12336 static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
12337 	TOKEN_STRING_INITIALIZER
12338 		(struct cmd_set_port_fec_mode,
12339 		 fec_mode, "fec_mode");
12340 static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
12341 	TOKEN_STRING_INITIALIZER
12342 		(struct cmd_set_port_fec_mode,
12343 		 fec_value, NULL);
12344 
12345 static void
12346 cmd_set_port_fec_mode_parsed(
12347 	void *parsed_result,
12348 	__rte_unused struct cmdline *cl,
12349 	__rte_unused void *data)
12350 {
12351 	struct cmd_set_port_fec_mode *res = parsed_result;
12352 	uint16_t port_id = res->port_id;
12353 	uint32_t fec_capa;
12354 	int ret;
12355 
12356 	ret = parse_fec_mode(res->fec_value, &fec_capa);
12357 	if (ret < 0) {
12358 		fprintf(stderr, "Unknown fec mode: %s for port %d\n",
12359 				res->fec_value,	port_id);
12360 		return;
12361 	}
12362 
12363 	ret = rte_eth_fec_set(port_id, fec_capa);
12364 	if (ret == -ENOTSUP) {
12365 		fprintf(stderr, "Function not implemented\n");
12366 		return;
12367 	} else if (ret < 0) {
12368 		fprintf(stderr, "Set FEC mode failed\n");
12369 		return;
12370 	}
12371 }
12372 
12373 static cmdline_parse_inst_t cmd_set_fec_mode = {
12374 	.f = cmd_set_port_fec_mode_parsed,
12375 	.data = NULL,
12376 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
12377 	.tokens = {
12378 		(void *)&cmd_set_port_fec_mode_set,
12379 		(void *)&cmd_set_port_fec_mode_port,
12380 		(void *)&cmd_set_port_fec_mode_port_id,
12381 		(void *)&cmd_set_port_fec_mode_str,
12382 		(void *)&cmd_set_port_fec_mode_value,
12383 		NULL,
12384 	},
12385 };
12386 
12387 /* *** set available descriptors threshold for an RxQ of a port *** */
12388 struct cmd_set_rxq_avail_thresh_result {
12389 	cmdline_fixed_string_t set;
12390 	cmdline_fixed_string_t port;
12391 	uint16_t port_num;
12392 	cmdline_fixed_string_t rxq;
12393 	uint16_t rxq_num;
12394 	cmdline_fixed_string_t avail_thresh;
12395 	uint8_t avail_thresh_num;
12396 };
12397 
12398 static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
12399 		__rte_unused struct cmdline *cl,
12400 		__rte_unused void *data)
12401 {
12402 	struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
12403 	int ret = 0;
12404 
12405 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
12406 	    && (strcmp(res->rxq, "rxq") == 0)
12407 	    && (strcmp(res->avail_thresh, "avail_thresh") == 0))
12408 		ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
12409 				  res->avail_thresh_num);
12410 	if (ret < 0)
12411 		printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
12412 
12413 }
12414 
12415 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
12416 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12417 				set, "set");
12418 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
12419 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12420 				port, "port");
12421 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
12422 	TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12423 				port_num, RTE_UINT16);
12424 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
12425 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12426 				rxq, "rxq");
12427 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
12428 	TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12429 				rxq_num, RTE_UINT16);
12430 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
12431 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12432 				avail_thresh, "avail_thresh");
12433 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
12434 	TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12435 				avail_thresh_num, RTE_UINT8);
12436 
12437 static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
12438 	.f = cmd_set_rxq_avail_thresh_parsed,
12439 	.data = (void *)0,
12440 	.help_str =
12441 		"set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
12442 		"Set available descriptors threshold for Rx queue",
12443 	.tokens = {
12444 		(void *)&cmd_set_rxq_avail_thresh_set,
12445 		(void *)&cmd_set_rxq_avail_thresh_port,
12446 		(void *)&cmd_set_rxq_avail_thresh_portnum,
12447 		(void *)&cmd_set_rxq_avail_thresh_rxq,
12448 		(void *)&cmd_set_rxq_avail_thresh_rxqnum,
12449 		(void *)&cmd_set_rxq_avail_thresh_avail_thresh,
12450 		(void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
12451 		NULL,
12452 	},
12453 };
12454 
12455 /* show port supported ptypes */
12456 
12457 /* Common result structure for show port ptypes */
12458 struct cmd_show_port_supported_ptypes_result {
12459 	cmdline_fixed_string_t show;
12460 	cmdline_fixed_string_t port;
12461 	portid_t port_id;
12462 	cmdline_fixed_string_t ptypes;
12463 };
12464 
12465 /* Common CLI fields for show port ptypes */
12466 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
12467 	TOKEN_STRING_INITIALIZER
12468 		(struct cmd_show_port_supported_ptypes_result,
12469 		 show, "show");
12470 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
12471 	TOKEN_STRING_INITIALIZER
12472 		(struct cmd_show_port_supported_ptypes_result,
12473 		 port, "port");
12474 static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
12475 	TOKEN_NUM_INITIALIZER
12476 		(struct cmd_show_port_supported_ptypes_result,
12477 		 port_id, RTE_UINT16);
12478 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
12479 	TOKEN_STRING_INITIALIZER
12480 		(struct cmd_show_port_supported_ptypes_result,
12481 		 ptypes, "ptypes");
12482 
12483 static void
12484 cmd_show_port_supported_ptypes_parsed(
12485 	void *parsed_result,
12486 	__rte_unused struct cmdline *cl,
12487 	__rte_unused void *data)
12488 {
12489 #define RSVD_PTYPE_MASK       0xf0000000
12490 #define MAX_PTYPES_PER_LAYER  16
12491 #define LTYPE_NAMESIZE        32
12492 #define PTYPE_NAMESIZE        256
12493 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
12494 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
12495 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
12496 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
12497 	uint16_t port_id = res->port_id;
12498 	int ret, i;
12499 
12500 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
12501 	if (ret < 0)
12502 		return;
12503 
12504 	while (ptype_mask != RSVD_PTYPE_MASK) {
12505 
12506 		switch (ptype_mask) {
12507 		case RTE_PTYPE_L2_MASK:
12508 			strlcpy(ltype, "L2", sizeof(ltype));
12509 			break;
12510 		case RTE_PTYPE_L3_MASK:
12511 			strlcpy(ltype, "L3", sizeof(ltype));
12512 			break;
12513 		case RTE_PTYPE_L4_MASK:
12514 			strlcpy(ltype, "L4", sizeof(ltype));
12515 			break;
12516 		case RTE_PTYPE_TUNNEL_MASK:
12517 			strlcpy(ltype, "Tunnel", sizeof(ltype));
12518 			break;
12519 		case RTE_PTYPE_INNER_L2_MASK:
12520 			strlcpy(ltype, "Inner L2", sizeof(ltype));
12521 			break;
12522 		case RTE_PTYPE_INNER_L3_MASK:
12523 			strlcpy(ltype, "Inner L3", sizeof(ltype));
12524 			break;
12525 		case RTE_PTYPE_INNER_L4_MASK:
12526 			strlcpy(ltype, "Inner L4", sizeof(ltype));
12527 			break;
12528 		default:
12529 			return;
12530 		}
12531 
12532 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
12533 						       ptype_mask, ptypes,
12534 						       MAX_PTYPES_PER_LAYER);
12535 
12536 		if (ret > 0)
12537 			printf("Supported %s ptypes:\n", ltype);
12538 		else
12539 			printf("%s ptypes unsupported\n", ltype);
12540 
12541 		for (i = 0; i < ret; ++i) {
12542 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
12543 			printf("%s\n", buf);
12544 		}
12545 
12546 		ptype_mask <<= 4;
12547 	}
12548 }
12549 
12550 static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
12551 	.f = cmd_show_port_supported_ptypes_parsed,
12552 	.data = NULL,
12553 	.help_str = "show port <port_id> ptypes",
12554 	.tokens = {
12555 		(void *)&cmd_show_port_supported_ptypes_show,
12556 		(void *)&cmd_show_port_supported_ptypes_port,
12557 		(void *)&cmd_show_port_supported_ptypes_port_id,
12558 		(void *)&cmd_show_port_supported_ptypes_ptypes,
12559 		NULL,
12560 	},
12561 };
12562 
12563 /* *** display rx/tx descriptor status *** */
12564 struct cmd_show_rx_tx_desc_status_result {
12565 	cmdline_fixed_string_t cmd_show;
12566 	cmdline_fixed_string_t cmd_port;
12567 	cmdline_fixed_string_t cmd_keyword;
12568 	cmdline_fixed_string_t cmd_desc;
12569 	cmdline_fixed_string_t cmd_status;
12570 	portid_t cmd_pid;
12571 	portid_t cmd_qid;
12572 	portid_t cmd_did;
12573 };
12574 
12575 static void
12576 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
12577 		__rte_unused struct cmdline *cl,
12578 		__rte_unused void *data)
12579 {
12580 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
12581 	int rc;
12582 
12583 	if (!strcmp(res->cmd_keyword, "rxq")) {
12584 		if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12585 			fprintf(stderr,
12586 				"Invalid input: port id = %d, queue id = %d\n",
12587 				res->cmd_pid, res->cmd_qid);
12588 			return;
12589 		}
12590 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
12591 					     res->cmd_did);
12592 		if (rc < 0) {
12593 			fprintf(stderr,
12594 				"Invalid input: queue id = %d, desc id = %d\n",
12595 				res->cmd_qid, res->cmd_did);
12596 			return;
12597 		}
12598 		if (rc == RTE_ETH_RX_DESC_AVAIL)
12599 			printf("Desc status = AVAILABLE\n");
12600 		else if (rc == RTE_ETH_RX_DESC_DONE)
12601 			printf("Desc status = DONE\n");
12602 		else
12603 			printf("Desc status = UNAVAILABLE\n");
12604 	} else if (!strcmp(res->cmd_keyword, "txq")) {
12605 		if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12606 			fprintf(stderr,
12607 				"Invalid input: port id = %d, queue id = %d\n",
12608 				res->cmd_pid, res->cmd_qid);
12609 			return;
12610 		}
12611 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
12612 					     res->cmd_did);
12613 		if (rc < 0) {
12614 			fprintf(stderr,
12615 				"Invalid input: queue id = %d, desc id = %d\n",
12616 				res->cmd_qid, res->cmd_did);
12617 			return;
12618 		}
12619 		if (rc == RTE_ETH_TX_DESC_FULL)
12620 			printf("Desc status = FULL\n");
12621 		else if (rc == RTE_ETH_TX_DESC_DONE)
12622 			printf("Desc status = DONE\n");
12623 		else
12624 			printf("Desc status = UNAVAILABLE\n");
12625 	}
12626 }
12627 
12628 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
12629 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12630 			cmd_show, "show");
12631 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
12632 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12633 			cmd_port, "port");
12634 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
12635 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12636 			cmd_pid, RTE_UINT16);
12637 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
12638 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12639 			cmd_keyword, "rxq#txq");
12640 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
12641 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12642 			cmd_qid, RTE_UINT16);
12643 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
12644 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12645 			cmd_desc, "desc");
12646 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
12647 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12648 			cmd_did, RTE_UINT16);
12649 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
12650 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12651 			cmd_status, "status");
12652 static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
12653 	.f = cmd_show_rx_tx_desc_status_parsed,
12654 	.data = NULL,
12655 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
12656 		"status",
12657 	.tokens = {
12658 		(void *)&cmd_show_rx_tx_desc_status_show,
12659 		(void *)&cmd_show_rx_tx_desc_status_port,
12660 		(void *)&cmd_show_rx_tx_desc_status_pid,
12661 		(void *)&cmd_show_rx_tx_desc_status_keyword,
12662 		(void *)&cmd_show_rx_tx_desc_status_qid,
12663 		(void *)&cmd_show_rx_tx_desc_status_desc,
12664 		(void *)&cmd_show_rx_tx_desc_status_did,
12665 		(void *)&cmd_show_rx_tx_desc_status_status,
12666 		NULL,
12667 	},
12668 };
12669 
12670 /* *** display rx queue desc used count *** */
12671 struct cmd_show_rx_queue_desc_used_count_result {
12672 	cmdline_fixed_string_t cmd_show;
12673 	cmdline_fixed_string_t cmd_port;
12674 	cmdline_fixed_string_t cmd_rxq;
12675 	cmdline_fixed_string_t cmd_desc;
12676 	cmdline_fixed_string_t cmd_used;
12677 	cmdline_fixed_string_t cmd_count;
12678 	portid_t cmd_pid;
12679 	portid_t cmd_qid;
12680 };
12681 
12682 static void
12683 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
12684 		__rte_unused struct cmdline *cl,
12685 		__rte_unused void *data)
12686 {
12687 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
12688 	int rc;
12689 
12690 	if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12691 		fprintf(stderr,
12692 			"Invalid input: port id = %d, queue id = %d\n",
12693 			res->cmd_pid, res->cmd_qid);
12694 		return;
12695 	}
12696 
12697 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
12698 	if (rc < 0) {
12699 		fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
12700 		return;
12701 	}
12702 	printf("Used desc count = %d\n", rc);
12703 }
12704 
12705 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
12706 	TOKEN_STRING_INITIALIZER
12707 		(struct cmd_show_rx_queue_desc_used_count_result,
12708 		 cmd_show, "show");
12709 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
12710 	TOKEN_STRING_INITIALIZER
12711 		(struct cmd_show_rx_queue_desc_used_count_result,
12712 		 cmd_port, "port");
12713 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
12714 	TOKEN_NUM_INITIALIZER
12715 		(struct cmd_show_rx_queue_desc_used_count_result,
12716 		 cmd_pid, RTE_UINT16);
12717 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
12718 	TOKEN_STRING_INITIALIZER
12719 		(struct cmd_show_rx_queue_desc_used_count_result,
12720 		 cmd_rxq, "rxq");
12721 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
12722 	TOKEN_NUM_INITIALIZER
12723 		(struct cmd_show_rx_queue_desc_used_count_result,
12724 		 cmd_qid, RTE_UINT16);
12725 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
12726 	TOKEN_STRING_INITIALIZER
12727 		(struct cmd_show_rx_queue_desc_used_count_result,
12728 		 cmd_count, "desc");
12729 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
12730 	TOKEN_STRING_INITIALIZER
12731 		(struct cmd_show_rx_queue_desc_used_count_result,
12732 		 cmd_count, "used");
12733 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
12734 	TOKEN_STRING_INITIALIZER
12735 		(struct cmd_show_rx_queue_desc_used_count_result,
12736 		 cmd_count, "count");
12737 static cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
12738 	.f = cmd_show_rx_queue_desc_used_count_parsed,
12739 	.data = NULL,
12740 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
12741 	.tokens = {
12742 		(void *)&cmd_show_rx_queue_desc_used_count_show,
12743 		(void *)&cmd_show_rx_queue_desc_used_count_port,
12744 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
12745 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
12746 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
12747 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
12748 		(void *)&cmd_show_rx_queue_desc_used_count_used,
12749 		(void *)&cmd_show_rx_queue_desc_used_count_count,
12750 		NULL,
12751 	},
12752 };
12753 
12754 /* Common result structure for set port ptypes */
12755 struct cmd_set_port_ptypes_result {
12756 	cmdline_fixed_string_t set;
12757 	cmdline_fixed_string_t port;
12758 	portid_t port_id;
12759 	cmdline_fixed_string_t ptype_mask;
12760 	uint32_t mask;
12761 };
12762 
12763 /* Common CLI fields for set port ptypes */
12764 static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
12765 	TOKEN_STRING_INITIALIZER
12766 		(struct cmd_set_port_ptypes_result,
12767 		 set, "set");
12768 static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
12769 	TOKEN_STRING_INITIALIZER
12770 		(struct cmd_set_port_ptypes_result,
12771 		 port, "port");
12772 static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
12773 	TOKEN_NUM_INITIALIZER
12774 		(struct cmd_set_port_ptypes_result,
12775 		 port_id, RTE_UINT16);
12776 static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
12777 	TOKEN_STRING_INITIALIZER
12778 		(struct cmd_set_port_ptypes_result,
12779 		 ptype_mask, "ptype_mask");
12780 static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
12781 	TOKEN_NUM_INITIALIZER
12782 		(struct cmd_set_port_ptypes_result,
12783 		 mask, RTE_UINT32);
12784 
12785 static void
12786 cmd_set_port_ptypes_parsed(
12787 	void *parsed_result,
12788 	__rte_unused struct cmdline *cl,
12789 	__rte_unused void *data)
12790 {
12791 	struct cmd_set_port_ptypes_result *res = parsed_result;
12792 #define PTYPE_NAMESIZE        256
12793 	char ptype_name[PTYPE_NAMESIZE];
12794 	uint16_t port_id = res->port_id;
12795 	uint32_t ptype_mask = res->mask;
12796 	int ret, i;
12797 
12798 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
12799 					       NULL, 0);
12800 	if (ret <= 0) {
12801 		fprintf(stderr, "Port %d doesn't support any ptypes.\n",
12802 			port_id);
12803 		return;
12804 	}
12805 
12806 	uint32_t ptypes[ret];
12807 
12808 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
12809 	if (ret < 0) {
12810 		fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
12811 			port_id);
12812 		return;
12813 	}
12814 
12815 	printf("Successfully set following ptypes for Port %d\n", port_id);
12816 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
12817 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
12818 		printf("%s\n", ptype_name);
12819 	}
12820 
12821 	clear_ptypes = false;
12822 }
12823 
12824 static cmdline_parse_inst_t cmd_set_port_ptypes = {
12825 	.f = cmd_set_port_ptypes_parsed,
12826 	.data = NULL,
12827 	.help_str = "set port <port_id> ptype_mask <mask>",
12828 	.tokens = {
12829 		(void *)&cmd_set_port_ptypes_set,
12830 		(void *)&cmd_set_port_ptypes_port,
12831 		(void *)&cmd_set_port_ptypes_port_id,
12832 		(void *)&cmd_set_port_ptypes_mask_str,
12833 		(void *)&cmd_set_port_ptypes_mask_u32,
12834 		NULL,
12835 	},
12836 };
12837 
12838 /* *** display mac addresses added to a port *** */
12839 struct cmd_showport_macs_result {
12840 	cmdline_fixed_string_t cmd_show;
12841 	cmdline_fixed_string_t cmd_port;
12842 	cmdline_fixed_string_t cmd_keyword;
12843 	portid_t cmd_pid;
12844 };
12845 
12846 static void
12847 cmd_showport_macs_parsed(void *parsed_result,
12848 		__rte_unused struct cmdline *cl,
12849 		__rte_unused void *data)
12850 {
12851 	struct cmd_showport_macs_result *res = parsed_result;
12852 
12853 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
12854 		return;
12855 
12856 	if (!strcmp(res->cmd_keyword, "macs"))
12857 		show_macs(res->cmd_pid);
12858 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
12859 		show_mcast_macs(res->cmd_pid);
12860 }
12861 
12862 static cmdline_parse_token_string_t cmd_showport_macs_show =
12863 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12864 			cmd_show, "show");
12865 static cmdline_parse_token_string_t cmd_showport_macs_port =
12866 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12867 			cmd_port, "port");
12868 static cmdline_parse_token_num_t cmd_showport_macs_pid =
12869 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
12870 			cmd_pid, RTE_UINT16);
12871 static cmdline_parse_token_string_t cmd_showport_macs_keyword =
12872 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12873 			cmd_keyword, "macs#mcast_macs");
12874 
12875 static cmdline_parse_inst_t cmd_showport_macs = {
12876 	.f = cmd_showport_macs_parsed,
12877 	.data = NULL,
12878 	.help_str = "show port <port_id> macs|mcast_macs",
12879 	.tokens = {
12880 		(void *)&cmd_showport_macs_show,
12881 		(void *)&cmd_showport_macs_port,
12882 		(void *)&cmd_showport_macs_pid,
12883 		(void *)&cmd_showport_macs_keyword,
12884 		NULL,
12885 	},
12886 };
12887 
12888 /* *** show flow transfer proxy port ID for the given port *** */
12889 struct cmd_show_port_flow_transfer_proxy_result {
12890 	cmdline_fixed_string_t show;
12891 	cmdline_fixed_string_t port;
12892 	portid_t port_id;
12893 	cmdline_fixed_string_t flow;
12894 	cmdline_fixed_string_t transfer;
12895 	cmdline_fixed_string_t proxy;
12896 };
12897 
12898 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
12899 	TOKEN_STRING_INITIALIZER
12900 		(struct cmd_show_port_flow_transfer_proxy_result,
12901 		 show, "show");
12902 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
12903 	TOKEN_STRING_INITIALIZER
12904 		(struct cmd_show_port_flow_transfer_proxy_result,
12905 		 port, "port");
12906 static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
12907 	TOKEN_NUM_INITIALIZER
12908 		(struct cmd_show_port_flow_transfer_proxy_result,
12909 		 port_id, RTE_UINT16);
12910 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
12911 	TOKEN_STRING_INITIALIZER
12912 		(struct cmd_show_port_flow_transfer_proxy_result,
12913 		 flow, "flow");
12914 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
12915 	TOKEN_STRING_INITIALIZER
12916 		(struct cmd_show_port_flow_transfer_proxy_result,
12917 		 transfer, "transfer");
12918 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
12919 	TOKEN_STRING_INITIALIZER
12920 		(struct cmd_show_port_flow_transfer_proxy_result,
12921 		 proxy, "proxy");
12922 
12923 static void
12924 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
12925 					 __rte_unused struct cmdline *cl,
12926 					 __rte_unused void *data)
12927 {
12928 	struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
12929 	portid_t proxy_port_id;
12930 	int ret;
12931 
12932 	printf("\n");
12933 
12934 	ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
12935 	if (ret != 0) {
12936 		fprintf(stderr, "Failed to pick transfer proxy: %s\n",
12937 			rte_strerror(-ret));
12938 		return;
12939 	}
12940 
12941 	printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
12942 }
12943 
12944 static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
12945 	.f = cmd_show_port_flow_transfer_proxy_parsed,
12946 	.data = NULL,
12947 	.help_str = "show port <port_id> flow transfer proxy",
12948 	.tokens = {
12949 		(void *)&cmd_show_port_flow_transfer_proxy_show,
12950 		(void *)&cmd_show_port_flow_transfer_proxy_port,
12951 		(void *)&cmd_show_port_flow_transfer_proxy_port_id,
12952 		(void *)&cmd_show_port_flow_transfer_proxy_flow,
12953 		(void *)&cmd_show_port_flow_transfer_proxy_transfer,
12954 		(void *)&cmd_show_port_flow_transfer_proxy_proxy,
12955 		NULL,
12956 	}
12957 };
12958 
12959 /* *** configure port txq affinity value *** */
12960 struct cmd_config_tx_affinity_map {
12961 	cmdline_fixed_string_t port;
12962 	cmdline_fixed_string_t config;
12963 	portid_t portid;
12964 	cmdline_fixed_string_t txq;
12965 	uint16_t qid;
12966 	cmdline_fixed_string_t affinity;
12967 	uint8_t value;
12968 };
12969 
12970 static void
12971 cmd_config_tx_affinity_map_parsed(void *parsed_result,
12972 				  __rte_unused struct cmdline *cl,
12973 				  __rte_unused void *data)
12974 {
12975 	struct cmd_config_tx_affinity_map *res = parsed_result;
12976 	int ret;
12977 
12978 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
12979 		return;
12980 
12981 	if (res->portid == (portid_t)RTE_PORT_ALL) {
12982 		printf("Invalid port id\n");
12983 		return;
12984 	}
12985 
12986 	if (strcmp(res->txq, "txq")) {
12987 		printf("Unknown parameter\n");
12988 		return;
12989 	}
12990 	if (tx_queue_id_is_invalid(res->qid))
12991 		return;
12992 
12993 	ret = rte_eth_dev_count_aggr_ports(res->portid);
12994 	if (ret < 0) {
12995 		printf("Failed to count the aggregated ports: (%s)\n",
12996 			strerror(-ret));
12997 		return;
12998 	}
12999 
13000 	ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
13001 	if (ret != 0) {
13002 		printf("Failed to map tx queue with an aggregated port: %s\n",
13003 			rte_strerror(-ret));
13004 		return;
13005 	}
13006 }
13007 
13008 cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13009 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13010 				 port, "port");
13011 cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13012 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13013 				 config, "config");
13014 cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13015 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13016 				 portid, RTE_UINT16);
13017 cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13018 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13019 				 txq, "txq");
13020 cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
13021 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13022 			      qid, RTE_UINT16);
13023 cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
13024 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13025 				 affinity, "affinity");
13026 cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
13027 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13028 			      value, RTE_UINT8);
13029 
13030 static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
13031 	.f = cmd_config_tx_affinity_map_parsed,
13032 	.data = (void *)0,
13033 	.help_str = "port config <port_id> txq <queue_id> affinity <value>",
13034 	.tokens = {
13035 		(void *)&cmd_config_tx_affinity_map_port,
13036 		(void *)&cmd_config_tx_affinity_map_config,
13037 		(void *)&cmd_config_tx_affinity_map_portid,
13038 		(void *)&cmd_config_tx_affinity_map_txq,
13039 		(void *)&cmd_config_tx_affinity_map_qid,
13040 		(void *)&cmd_config_tx_affinity_map_affinity,
13041 		(void *)&cmd_config_tx_affinity_map_value,
13042 		NULL,
13043 	},
13044 };
13045 
13046 /* ******************************************************************************** */
13047 
13048 /* list of instructions */
13049 static cmdline_parse_ctx_t builtin_ctx[] = {
13050 	(cmdline_parse_inst_t *)&cmd_help_brief,
13051 	(cmdline_parse_inst_t *)&cmd_help_long,
13052 	(cmdline_parse_inst_t *)&cmd_quit,
13053 	(cmdline_parse_inst_t *)&cmd_load_from_file,
13054 	(cmdline_parse_inst_t *)&cmd_showport,
13055 	(cmdline_parse_inst_t *)&cmd_showqueue,
13056 	(cmdline_parse_inst_t *)&cmd_showeeprom,
13057 	(cmdline_parse_inst_t *)&cmd_showportall,
13058 	(cmdline_parse_inst_t *)&cmd_representor_info,
13059 	(cmdline_parse_inst_t *)&cmd_showdevice,
13060 	(cmdline_parse_inst_t *)&cmd_showcfg,
13061 	(cmdline_parse_inst_t *)&cmd_showfwdall,
13062 	(cmdline_parse_inst_t *)&cmd_start,
13063 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
13064 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13065 	(cmdline_parse_inst_t *)&cmd_set_link_up,
13066 	(cmdline_parse_inst_t *)&cmd_set_link_down,
13067 	(cmdline_parse_inst_t *)&cmd_reset,
13068 	(cmdline_parse_inst_t *)&cmd_set_numbers,
13069 	(cmdline_parse_inst_t *)&cmd_set_log,
13070 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
13071 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
13072 	(cmdline_parse_inst_t *)&cmd_set_rxhdrs,
13073 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
13074 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
13075 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
13076 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
13077 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13078 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13079 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13080 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13081 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13082 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13083 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13084 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13085 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
13086 	(cmdline_parse_inst_t *)&cmd_set_link_check,
13087 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
13088 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
13089 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13090 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13091 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13092 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13093 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13094 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13095 	(cmdline_parse_inst_t *)&cmd_csum_set,
13096 	(cmdline_parse_inst_t *)&cmd_csum_show,
13097 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
13098 	(cmdline_parse_inst_t *)&cmd_csum_mac_swap,
13099 	(cmdline_parse_inst_t *)&cmd_tso_set,
13100 	(cmdline_parse_inst_t *)&cmd_tso_show,
13101 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13102 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13103 #ifdef RTE_LIB_GRO
13104 	(cmdline_parse_inst_t *)&cmd_gro_enable,
13105 	(cmdline_parse_inst_t *)&cmd_gro_flush,
13106 	(cmdline_parse_inst_t *)&cmd_gro_show,
13107 #endif
13108 #ifdef RTE_LIB_GSO
13109 	(cmdline_parse_inst_t *)&cmd_gso_enable,
13110 	(cmdline_parse_inst_t *)&cmd_gso_size,
13111 	(cmdline_parse_inst_t *)&cmd_gso_show,
13112 #endif
13113 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13114 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13115 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13116 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13117 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13118 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13119 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13120 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13121 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13122 	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
13123 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13124 	(cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
13125 	(cmdline_parse_inst_t *)&cmd_config_dcb,
13126 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13127 	(cmdline_parse_inst_t *)&cmd_stop,
13128 	(cmdline_parse_inst_t *)&cmd_mac_addr,
13129 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
13130 	(cmdline_parse_inst_t *)&cmd_set_qmap,
13131 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
13132 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
13133 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
13134 	(cmdline_parse_inst_t *)&cmd_operate_port,
13135 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
13136 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
13137 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
13138 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
13139 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
13140 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
13141 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
13142 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
13143 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
13144 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
13145 	(cmdline_parse_inst_t *)&cmd_config_mtu,
13146 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13147 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
13148 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13149 	(cmdline_parse_inst_t *)&cmd_config_rss,
13150 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
13151 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13152 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
13153 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
13154 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
13155 	(cmdline_parse_inst_t *)&cmd_showport_reta,
13156 	(cmdline_parse_inst_t *)&cmd_showport_macs,
13157 	(cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
13158 	(cmdline_parse_inst_t *)&cmd_config_burst,
13159 	(cmdline_parse_inst_t *)&cmd_config_thresh,
13160 	(cmdline_parse_inst_t *)&cmd_config_threshold,
13161 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13162 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13163 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13164 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13165 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13166 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13167 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13168 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_algo,
13169 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13170 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
13171 	(cmdline_parse_inst_t *)&cmd_dump,
13172 	(cmdline_parse_inst_t *)&cmd_dump_one,
13173 	(cmdline_parse_inst_t *)&cmd_flow,
13174 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
13175 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
13176 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
13177 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
13178 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
13179 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
13180 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
13181 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
13182 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
13183 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
13184 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
13185 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
13186 	(cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
13187 	(cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
13188 	(cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
13189 	(cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
13190 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
13191 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
13192 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
13193 	(cmdline_parse_inst_t *)&cmd_mcast_addr_flush,
13194 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13195 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13196 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13197 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13198 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13199 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13200 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13201 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13202 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13203 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13204 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13205 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
13206 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
13207 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
13208 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
13209 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
13210 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
13211 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
13212 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
13213 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
13214 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
13215 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
13216 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
13217 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
13218 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
13219 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
13220 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
13221 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
13222 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
13223 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
13224 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
13225 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13226 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
13227 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
13228 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
13229 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
13230 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
13231 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
13232 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
13233 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
13234 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
13235 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
13236 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
13237 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
13238 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
13239 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
13240 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
13241 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
13242 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
13243 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
13244 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
13245 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
13246 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
13247 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
13248 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
13249 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
13250 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
13251 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
13252 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
13253 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
13254 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
13255 	(cmdline_parse_inst_t *)&cmd_config_all_port_rx_offload,
13256 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
13257 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
13258 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
13259 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
13260 	(cmdline_parse_inst_t *)&cmd_config_all_port_tx_offload,
13261 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
13262 #ifdef RTE_LIB_BPF
13263 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
13264 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
13265 #endif
13266 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
13267 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
13268 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
13269 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
13270 	(cmdline_parse_inst_t *)&cmd_set_raw,
13271 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
13272 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
13273 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
13274 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
13275 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
13276 	(cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh,
13277 	(cmdline_parse_inst_t *)&cmd_show_capability,
13278 	(cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
13279 	(cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
13280 	(cmdline_parse_inst_t *)&cmd_show_port_cman_capa,
13281 	(cmdline_parse_inst_t *)&cmd_show_port_cman_config,
13282 	(cmdline_parse_inst_t *)&cmd_set_port_cman_config,
13283 	(cmdline_parse_inst_t *)&cmd_config_tx_affinity_map,
13284 	NULL,
13285 };
13286 
13287 void
13288 testpmd_add_driver_commands(struct testpmd_driver_commands *c)
13289 {
13290 	TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
13291 }
13292 
13293 int
13294 init_cmdline(void)
13295 {
13296 	struct testpmd_driver_commands *c;
13297 	unsigned int count;
13298 	unsigned int i;
13299 
13300 	/* initialize non-constant commands */
13301 	cmd_set_fwd_mode_init();
13302 	cmd_set_fwd_retry_mode_init();
13303 
13304 	count = 0;
13305 	for (i = 0; builtin_ctx[i] != NULL; i++)
13306 		count++;
13307 	TAILQ_FOREACH(c, &driver_commands_head, next) {
13308 		for (i = 0; c->commands[i].ctx != NULL; i++)
13309 			count++;
13310 	}
13311 
13312 	/* cmdline expects a NULL terminated array */
13313 	main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
13314 	if (main_ctx == NULL)
13315 		return -1;
13316 
13317 	count = 0;
13318 	for (i = 0; builtin_ctx[i] != NULL; i++, count++)
13319 		main_ctx[count] = builtin_ctx[i];
13320 	TAILQ_FOREACH(c, &driver_commands_head, next) {
13321 		for (i = 0; c->commands[i].ctx != NULL; i++, count++)
13322 			main_ctx[count] = c->commands[i].ctx;
13323 	}
13324 
13325 	return 0;
13326 }
13327 
13328 /* read cmdline commands from file */
13329 void
13330 cmdline_read_from_file(const char *filename)
13331 {
13332 	struct cmdline *cl;
13333 
13334 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13335 	if (cl == NULL) {
13336 		fprintf(stderr,
13337 			"Failed to create file based cmdline context: %s\n",
13338 			filename);
13339 		return;
13340 	}
13341 
13342 	cmdline_interact(cl);
13343 	cmdline_quit(cl);
13344 
13345 	cmdline_free(cl);
13346 
13347 	printf("Read CLI commands from %s\n", filename);
13348 }
13349 
13350 void
13351 prompt_exit(void)
13352 {
13353 	cmdline_quit(testpmd_cl);
13354 }
13355 
13356 /* prompt function, called from main on MAIN lcore */
13357 void
13358 prompt(void)
13359 {
13360 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13361 	if (testpmd_cl == NULL) {
13362 		fprintf(stderr,
13363 			"Failed to create stdin based cmdline context\n");
13364 		return;
13365 	}
13366 
13367 	cmdline_interact(testpmd_cl);
13368 	cmdline_stdin_exit(testpmd_cl);
13369 }
13370 
13371 void
13372 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13373 {
13374 	if (id == (portid_t)RTE_PORT_ALL) {
13375 		portid_t pid;
13376 
13377 		RTE_ETH_FOREACH_DEV(pid) {
13378 			/* check if need_reconfig has been set to 1 */
13379 			if (ports[pid].need_reconfig == 0)
13380 				ports[pid].need_reconfig = dev;
13381 			/* check if need_reconfig_queues has been set to 1 */
13382 			if (ports[pid].need_reconfig_queues == 0)
13383 				ports[pid].need_reconfig_queues = queue;
13384 		}
13385 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13386 		/* check if need_reconfig has been set to 1 */
13387 		if (ports[id].need_reconfig == 0)
13388 			ports[id].need_reconfig = dev;
13389 		/* check if need_reconfig_queues has been set to 1 */
13390 		if (ports[id].need_reconfig_queues == 0)
13391 			ports[id].need_reconfig_queues = queue;
13392 	}
13393 }
13394