xref: /dpdk/app/test-pmd/cmdline.c (revision f8dbaebbf1c9efcbb2e2354b341ed62175466a57)
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 <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include <inttypes.h>
13 #include <sys/queue.h>
14 
15 #include <rte_common.h>
16 #include <rte_byteorder.h>
17 #include <rte_log.h>
18 #include <rte_debug.h>
19 #include <rte_cycles.h>
20 #include <rte_memory.h>
21 #include <rte_memzone.h>
22 #include <rte_malloc.h>
23 #include <rte_launch.h>
24 #include <rte_eal.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
27 #include <rte_branch_prediction.h>
28 #include <rte_ring.h>
29 #include <rte_mempool.h>
30 #include <rte_interrupts.h>
31 #include <rte_pci.h>
32 #include <rte_ether.h>
33 #include <rte_ethdev.h>
34 #include <rte_string_fns.h>
35 #include <rte_devargs.h>
36 #include <rte_flow.h>
37 #ifdef RTE_LIB_GRO
38 #include <rte_gro.h>
39 #endif
40 #include <rte_mbuf_dyn.h>
41 
42 #include <cmdline_rdline.h>
43 #include <cmdline_parse.h>
44 #include <cmdline_parse_num.h>
45 #include <cmdline_parse_string.h>
46 #include <cmdline_parse_ipaddr.h>
47 #include <cmdline_parse_etheraddr.h>
48 #include <cmdline_socket.h>
49 #include <cmdline.h>
50 #ifdef RTE_NET_BOND
51 #include <rte_eth_bond.h>
52 #include <rte_eth_bond_8023ad.h>
53 #endif
54 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
55 #include <rte_pmd_dpaa.h>
56 #endif
57 #ifdef RTE_NET_IXGBE
58 #include <rte_pmd_ixgbe.h>
59 #endif
60 #ifdef RTE_NET_I40E
61 #include <rte_pmd_i40e.h>
62 #endif
63 #ifdef RTE_NET_BNXT
64 #include <rte_pmd_bnxt.h>
65 #endif
66 #include "testpmd.h"
67 #include "cmdline_mtr.h"
68 #include "cmdline_tm.h"
69 #include "bpf_cmd.h"
70 
71 static struct cmdline *testpmd_cl;
72 
73 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
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 registers                  : Reading and setting port registers.\n"
94 		"    help filters                    : Filters configuration help.\n"
95 		"    help traffic_management         : Traffic Management commands.\n"
96 		"    help devices                    : Device related cmds.\n"
97 		"    help all                        : All of the above sections.\n\n"
98 	);
99 
100 }
101 
102 cmdline_parse_token_string_t cmd_help_brief_help =
103 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 
105 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]\n"
178 			"    Display the RSS hash functions and RSS hash key 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|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 			"ddp get list (port_id)\n"
196 			"    Get ddp profile info list\n\n"
197 
198 			"ddp get info (profile_path)\n"
199 			"    Get ddp profile information.\n\n"
200 
201 			"show vf stats (port_id) (vf_id)\n"
202 			"    Display a VF's statistics.\n\n"
203 
204 			"clear vf stats (port_id) (vf_id)\n"
205 			"    Reset a VF's statistics.\n\n"
206 
207 			"show port (port_id) pctype mapping\n"
208 			"    Get flow ptype to pctype mapping on a port\n\n"
209 
210 			"show port meter stats (port_id) (meter_id) (clear)\n"
211 			"    Get meter stats on a port\n\n"
212 
213 			"show fwd stats all\n"
214 			"    Display statistics for all fwd engines.\n\n"
215 
216 			"clear fwd stats all\n"
217 			"    Clear statistics for all fwd engines.\n\n"
218 
219 			"show port (port_id) rx_offload capabilities\n"
220 			"    List all per queue and per port Rx offloading"
221 			" capabilities of a port\n\n"
222 
223 			"show port (port_id) rx_offload configuration\n"
224 			"    List port level and all queue level"
225 			" Rx offloading configuration\n\n"
226 
227 			"show port (port_id) tx_offload capabilities\n"
228 			"    List all per queue and per port"
229 			" Tx offloading capabilities of a port\n\n"
230 
231 			"show port (port_id) tx_offload configuration\n"
232 			"    List port level and all queue level"
233 			" Tx offloading configuration\n\n"
234 
235 			"show port (port_id) tx_metadata\n"
236 			"    Show Tx metadata value set"
237 			" for a specific port\n\n"
238 
239 			"show port (port_id) ptypes\n"
240 			"    Show port supported ptypes"
241 			" for a specific port\n\n"
242 
243 			"show device info (<identifier>|all)"
244 			"       Show general information about devices probed.\n\n"
245 
246 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 			"       Show status of rx|tx descriptor.\n\n"
248 
249 			"show port (port_id) rxq (queue_id) desc used count\n"
250 			"    Show current number of filled receive"
251 			" packet descriptors.\n\n"
252 
253 			"show port (port_id) macs|mcast_macs"
254 			"       Display list of mac addresses added to port.\n\n"
255 
256 			"show port (port_id) flow transfer proxy\n"
257 			"	Display proxy port to manage transfer flows\n\n"
258 
259 			"show port (port_id) fec capabilities"
260 			"	Show fec capabilities of a port.\n\n"
261 
262 			"show port (port_id) fec_mode"
263 			"	Show fec mode of a port.\n\n"
264 
265 			"show port (port_id) flow_ctrl"
266 			"	Show flow control info of a port.\n\n"
267 		);
268 	}
269 
270 	if (show_all || !strcmp(res->section, "config")) {
271 		cmdline_printf(
272 			cl,
273 			"\n"
274 			"Configuration:\n"
275 			"--------------\n"
276 			"Configuration changes only become active when"
277 			" forwarding is started/restarted.\n\n"
278 
279 			"set default\n"
280 			"    Reset forwarding to the default configuration.\n\n"
281 
282 			"set verbose (level)\n"
283 			"    Set the debug verbosity level X.\n\n"
284 
285 			"set log global|(type) (level)\n"
286 			"    Set the log level.\n\n"
287 
288 			"set nbport (num)\n"
289 			"    Set number of ports.\n\n"
290 
291 			"set nbcore (num)\n"
292 			"    Set number of cores.\n\n"
293 
294 			"set coremask (mask)\n"
295 			"    Set the forwarding cores hexadecimal mask.\n\n"
296 
297 			"set portmask (mask)\n"
298 			"    Set the forwarding ports hexadecimal mask.\n\n"
299 
300 			"set burst (num)\n"
301 			"    Set number of packets per burst.\n\n"
302 
303 			"set burst tx delay (microseconds) retry (num)\n"
304 			"    Set the transmit delay time and number of retries,"
305 			" effective when retry is enabled.\n\n"
306 
307 			"set rxoffs (x[,y]*)\n"
308 			"    Set the offset of each packet segment on"
309 			" receiving if split feature is engaged."
310 			" Affects only the queues configured with split"
311 			" offloads.\n\n"
312 
313 			"set rxpkts (x[,y]*)\n"
314 			"    Set the length of each segment to scatter"
315 			" packets on receiving if split feature is engaged."
316 			" Affects only the queues configured with split"
317 			" offloads.\n\n"
318 
319 			"set txpkts (x[,y]*)\n"
320 			"    Set the length of each segment of TXONLY"
321 			" and optionally CSUM packets.\n\n"
322 
323 			"set txsplit (off|on|rand)\n"
324 			"    Set the split policy for the TX packets."
325 			" Right now only applicable for CSUM and TXONLY"
326 			" modes\n\n"
327 
328 			"set txtimes (x, y)\n"
329 			"    Set the scheduling on timestamps"
330 			" timings for the TXONLY mode\n\n"
331 
332 			"set corelist (x[,y]*)\n"
333 			"    Set the list of forwarding cores.\n\n"
334 
335 			"set portlist (x[,y]*)\n"
336 			"    Set the list of forwarding ports.\n\n"
337 
338 			"set port setup on (iterator|event)\n"
339 			"    Select how attached port is retrieved for setup.\n\n"
340 
341 			"set tx loopback (port_id) (on|off)\n"
342 			"    Enable or disable tx loopback.\n\n"
343 
344 			"set all queues drop (port_id) (on|off)\n"
345 			"    Set drop enable bit for all queues.\n\n"
346 
347 			"set vf split drop (port_id) (vf_id) (on|off)\n"
348 			"    Set split drop enable bit for a VF from the PF.\n\n"
349 
350 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
351 			"    Set MAC antispoof for a VF from the PF.\n\n"
352 
353 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
354 			"    Enable MACsec offload.\n\n"
355 
356 			"set macsec offload (port_id) off\n"
357 			"    Disable MACsec offload.\n\n"
358 
359 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
360 			"    Configure MACsec secure connection (SC).\n\n"
361 
362 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
363 			"    Configure MACsec secure association (SA).\n\n"
364 
365 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
366 			"    Set VF broadcast for a VF from the PF.\n\n"
367 
368 			"vlan set stripq (on|off) (port_id,queue_id)\n"
369 			"    Set the VLAN strip for a queue on a port.\n\n"
370 
371 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
372 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
373 
374 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
375 			"    Set VLAN insert for a VF from the PF.\n\n"
376 
377 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
378 			"    Set VLAN antispoof for a VF from the PF.\n\n"
379 
380 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
381 			"    Set VLAN tag for a VF from the PF.\n\n"
382 
383 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
384 			"    Set a VF's max bandwidth(Mbps).\n\n"
385 
386 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
387 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
388 
389 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
390 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
391 
392 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
393 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
394 
395 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
396 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
397 
398 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
399 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
400 
401 			"vlan set (inner|outer) tpid (value) (port_id)\n"
402 			"    Set the VLAN TPID for Packet Filtering on"
403 			" a port\n\n"
404 
405 			"rx_vlan add (vlan_id|all) (port_id)\n"
406 			"    Add a vlan_id, or all identifiers, to the set"
407 			" of VLAN identifiers filtered by port_id.\n\n"
408 
409 			"rx_vlan rm (vlan_id|all) (port_id)\n"
410 			"    Remove a vlan_id, or all identifiers, from the set"
411 			" of VLAN identifiers filtered by port_id.\n\n"
412 
413 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
414 			"    Add a vlan_id, to the set of VLAN identifiers"
415 			"filtered for VF(s) from port_id.\n\n"
416 
417 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
418 			"    Remove a vlan_id, to the set of VLAN identifiers"
419 			"filtered for VF(s) from port_id.\n\n"
420 
421 			"rx_vxlan_port add (udp_port) (port_id)\n"
422 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
423 
424 			"rx_vxlan_port rm (udp_port) (port_id)\n"
425 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
426 
427 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
429 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
430 
431 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
432 			"    Set port based TX VLAN insertion.\n\n"
433 
434 			"tx_vlan reset (port_id)\n"
435 			"    Disable hardware insertion of a VLAN header in"
436 			" packets sent on a port.\n\n"
437 
438 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 			"    Select hardware or software calculation of the"
440 			" checksum when transmitting a packet using the"
441 			" csum forward engine.\n"
442 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
443 			"    outer-ip concerns the outer IP layer in"
444 			"    outer-udp concerns the outer UDP layer in"
445 			" case the packet is recognized as a tunnel packet by"
446 			" the forward engine (vxlan, gre and ipip are supported)\n"
447 			"    Please check the NIC datasheet for HW limits.\n\n"
448 
449 			"csum parse-tunnel (on|off) (tx_port_id)\n"
450 			"    If disabled, treat tunnel packets as non-tunneled"
451 			" packets (treat inner headers as payload). The port\n"
452 			"    argument is the port used for TX in csum forward"
453 			" engine.\n\n"
454 
455 			"csum show (port_id)\n"
456 			"    Display tx checksum offload configuration\n\n"
457 
458 			"tso set (segsize) (portid)\n"
459 			"    Enable TCP Segmentation Offload in csum forward"
460 			" engine.\n"
461 			"    Please check the NIC datasheet for HW limits.\n\n"
462 
463 			"tso show (portid)"
464 			"    Display the status of TCP Segmentation Offload.\n\n"
465 
466 #ifdef RTE_LIB_GRO
467 			"set port (port_id) gro on|off\n"
468 			"    Enable or disable Generic Receive Offload in"
469 			" csum forwarding engine.\n\n"
470 
471 			"show port (port_id) gro\n"
472 			"    Display GRO configuration.\n\n"
473 
474 			"set gro flush (cycles)\n"
475 			"    Set the cycle to flush GROed packets from"
476 			" reassembly tables.\n\n"
477 #endif
478 
479 #ifdef RTE_LIB_GSO
480 			"set port (port_id) gso (on|off)"
481 			"    Enable or disable Generic Segmentation Offload in"
482 			" csum forwarding engine.\n\n"
483 
484 			"set gso segsz (length)\n"
485 			"    Set max packet length for output GSO segments,"
486 			" including packet header and payload.\n\n"
487 
488 			"show port (port_id) gso\n"
489 			"    Show GSO configuration.\n\n"
490 #endif
491 
492 			"set fwd (%s)\n"
493 			"    Set packet forwarding mode.\n\n"
494 
495 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
496 			"    Add a MAC address on port_id.\n\n"
497 
498 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
499 			"    Remove a MAC address from port_id.\n\n"
500 
501 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
502 			"    Set the default MAC address for port_id.\n\n"
503 
504 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
505 			"    Add a MAC address for a VF on the port.\n\n"
506 
507 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
508 			"    Set the MAC address for a VF from the PF.\n\n"
509 
510 			"set eth-peer (port_id) (peer_addr)\n"
511 			"    set the peer address for certain port.\n\n"
512 
513 			"set port (port_id) uta (mac_address|all) (on|off)\n"
514 			"    Add/Remove a or all unicast hash filter(s)"
515 			"from port X.\n\n"
516 
517 			"set promisc (port_id|all) (on|off)\n"
518 			"    Set the promiscuous mode on port_id, or all.\n\n"
519 
520 			"set allmulti (port_id|all) (on|off)\n"
521 			"    Set the allmulti mode on port_id, or all.\n\n"
522 
523 			"set vf promisc (port_id) (vf_id) (on|off)\n"
524 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
525 
526 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
527 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
528 
529 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
530 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
531 			" (on|off) autoneg (on|off) (port_id)\n"
532 			"set flow_ctrl rx (on|off) (portid)\n"
533 			"set flow_ctrl tx (on|off) (portid)\n"
534 			"set flow_ctrl high_water (high_water) (portid)\n"
535 			"set flow_ctrl low_water (low_water) (portid)\n"
536 			"set flow_ctrl pause_time (pause_time) (portid)\n"
537 			"set flow_ctrl send_xon (send_xon) (portid)\n"
538 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
539 			"set flow_ctrl autoneg (on|off) (port_id)\n"
540 			"    Set the link flow control parameter on a port.\n\n"
541 
542 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
543 			" (low_water) (pause_time) (priority) (port_id)\n"
544 			"    Set the priority flow control parameter on a"
545 			" port.\n\n"
546 
547 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
548 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
549 			" queue on port.\n"
550 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
551 			" on port 0 to mapping 5.\n\n"
552 
553 			"set xstats-hide-zero on|off\n"
554 			"    Set the option to hide the zero values"
555 			" for xstats display.\n"
556 
557 			"set record-core-cycles on|off\n"
558 			"    Set the option to enable measurement of CPU cycles.\n"
559 
560 			"set record-burst-stats on|off\n"
561 			"    Set the option to enable display of RX and TX bursts.\n"
562 
563 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
564 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
565 
566 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
567 			"|MPE) (on|off)\n"
568 			"    AUPE:accepts untagged VLAN;"
569 			"ROPE:accept unicast hash\n\n"
570 			"    BAM:accepts broadcast packets;"
571 			"MPE:accepts all multicast packets\n\n"
572 			"    Enable/Disable a VF receive mode of a port\n\n"
573 
574 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
575 			"    Set rate limit for a queue of a port\n\n"
576 
577 			"set port (port_id) vf (vf_id) rate (rate_num) "
578 			"queue_mask (queue_mask_value)\n"
579 			"    Set rate limit for queues in VF of a port\n\n"
580 
581 			"set flush_rx (on|off)\n"
582 			"   Flush (default) or don't flush RX streams before"
583 			" forwarding. Mainly used with PCAP drivers.\n\n"
584 
585 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
586 			"   Set the bypass mode for the lowest port on bypass enabled"
587 			" NIC.\n\n"
588 
589 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
590 			"mode (normal|bypass|isolate) (port_id)\n"
591 			"   Set the event required to initiate specified bypass mode for"
592 			" the lowest port on a bypass enabled NIC where:\n"
593 			"       timeout   = enable bypass after watchdog timeout.\n"
594 			"       os_on     = enable bypass when OS/board is powered on.\n"
595 			"       os_off    = enable bypass when OS/board is powered off.\n"
596 			"       power_on  = enable bypass when power supply is turned on.\n"
597 			"       power_off = enable bypass when power supply is turned off."
598 			"\n\n"
599 
600 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
601 			"   Set the bypass watchdog timeout to 'n' seconds"
602 			" where 0 = instant.\n\n"
603 
604 			"show bypass config (port_id)\n"
605 			"   Show the bypass configuration for a bypass enabled NIC"
606 			" using the lowest port on the NIC.\n\n"
607 
608 #ifdef RTE_NET_BOND
609 			"create bonded device (mode) (socket)\n"
610 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
611 
612 			"add bonding slave (slave_id) (port_id)\n"
613 			"	Add a slave device to a bonded device.\n\n"
614 
615 			"remove bonding slave (slave_id) (port_id)\n"
616 			"	Remove a slave device from a bonded device.\n\n"
617 
618 			"set bonding mode (value) (port_id)\n"
619 			"	Set the bonding mode on a bonded device.\n\n"
620 
621 			"set bonding primary (slave_id) (port_id)\n"
622 			"	Set the primary slave for a bonded device.\n\n"
623 
624 			"show bonding config (port_id)\n"
625 			"	Show the bonding config for port_id.\n\n"
626 
627 			"show bonding lacp info (port_id)\n"
628 			"	Show the bonding lacp information for port_id.\n\n"
629 
630 			"set bonding mac_addr (port_id) (address)\n"
631 			"	Set the MAC address of a bonded device.\n\n"
632 
633 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
634 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
635 
636 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
637 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
638 
639 			"set bonding mon_period (port_id) (value)\n"
640 			"	Set the bonding link status monitoring polling period in ms.\n\n"
641 
642 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
643 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
644 
645 #endif
646 			"set link-up port (port_id)\n"
647 			"	Set link up for a port.\n\n"
648 
649 			"set link-down port (port_id)\n"
650 			"	Set link down for a port.\n\n"
651 
652 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
653 			"    Load a profile package on a port\n\n"
654 
655 			"ddp del (port_id) (backup_profile_path)\n"
656 			"    Delete a profile package from a port\n\n"
657 
658 			"ptype mapping get (port_id) (valid_only)\n"
659 			"    Get ptype mapping on a port\n\n"
660 
661 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
662 			"    Replace target with the pkt_type in ptype mapping\n\n"
663 
664 			"ptype mapping reset (port_id)\n"
665 			"    Reset ptype mapping on a port\n\n"
666 
667 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
668 			"    Update a ptype mapping item on a port\n\n"
669 
670 			"set port (port_id) ptype_mask (ptype_mask)\n"
671 			"    set packet types classification for a specific port\n\n"
672 
673 			"set port (port_id) queue-region region_id (value) "
674 			"queue_start_index (value) queue_num (value)\n"
675 			"    Set a queue region on a port\n\n"
676 
677 			"set port (port_id) queue-region region_id (value) "
678 			"flowtype (value)\n"
679 			"    Set a flowtype region index on a port\n\n"
680 
681 			"set port (port_id) queue-region UP (value) region_id (value)\n"
682 			"    Set the mapping of User Priority to "
683 			"queue region on a port\n\n"
684 
685 			"set port (port_id) queue-region flush (on|off)\n"
686 			"    flush all queue region related configuration\n\n"
687 
688 			"show port meter cap (port_id)\n"
689 			"    Show port meter capability information\n\n"
690 
691 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
692 			"    meter profile add - srtcm rfc 2697\n\n"
693 
694 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
695 			"    meter profile add - trtcm rfc 2698\n\n"
696 
697 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
698 			"    meter profile add - trtcm rfc 4115\n\n"
699 
700 			"del port meter profile (port_id) (profile_id)\n"
701 			"    meter profile delete\n\n"
702 
703 			"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
704 			"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
705 			"(dscp_tbl_entry63)]\n"
706 			"    meter create\n\n"
707 
708 			"enable port meter (port_id) (mtr_id)\n"
709 			"    meter enable\n\n"
710 
711 			"disable port meter (port_id) (mtr_id)\n"
712 			"    meter disable\n\n"
713 
714 			"del port meter (port_id) (mtr_id)\n"
715 			"    meter delete\n\n"
716 
717 			"add port meter policy (port_id) (policy_id) g_actions (actions)\n"
718 			"y_actions (actions) r_actions (actions)\n"
719 			"    meter policy add\n\n"
720 
721 			"del port meter policy (port_id) (policy_id)\n"
722 			"    meter policy delete\n\n"
723 
724 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 			"    meter update meter profile\n\n"
726 
727 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 			"    update meter dscp table entries\n\n"
730 
731 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 			"(action0) [(action1) (action2)]\n"
733 			"    meter update policer action\n\n"
734 
735 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 			"    meter update stats\n\n"
737 
738 			"show port (port_id) queue-region\n"
739 			"    show all queue region related configuration info\n\n"
740 
741 			"set port (port_id) fec_mode auto|off|rs|baser\n"
742 			"    set fec mode for a specific port\n\n"
743 
744 			, list_pkt_forwarding_modes()
745 		);
746 	}
747 
748 	if (show_all || !strcmp(res->section, "ports")) {
749 
750 		cmdline_printf(
751 			cl,
752 			"\n"
753 			"Port Operations:\n"
754 			"----------------\n\n"
755 
756 			"port start (port_id|all)\n"
757 			"    Start all ports or port_id.\n\n"
758 
759 			"port stop (port_id|all)\n"
760 			"    Stop all ports or port_id.\n\n"
761 
762 			"port close (port_id|all)\n"
763 			"    Close all ports or port_id.\n\n"
764 
765 			"port reset (port_id|all)\n"
766 			"    Reset all ports or port_id.\n\n"
767 
768 			"port attach (ident)\n"
769 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
770 
771 			"port detach (port_id)\n"
772 			"    Detach physical or virtual dev by port_id\n\n"
773 
774 			"port config (port_id|all)"
775 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
776 			" duplex (half|full|auto)\n"
777 			"    Set speed and duplex for all ports or port_id\n\n"
778 
779 			"port config (port_id|all) loopback (mode)\n"
780 			"    Set loopback mode for all ports or port_id\n\n"
781 
782 			"port config all (rxq|txq|rxd|txd) (value)\n"
783 			"    Set number for rxq/txq/rxd/txd.\n\n"
784 
785 			"port config all max-pkt-len (value)\n"
786 			"    Set the max packet length.\n\n"
787 
788 			"port config all max-lro-pkt-size (value)\n"
789 			"    Set the max LRO aggregated packet size.\n\n"
790 
791 			"port config all drop-en (on|off)\n"
792 			"    Enable or disable packet drop on all RX queues of all ports when no "
793 			"receive buffers available.\n\n"
794 
795 			"port config all rss (all|default|ip|tcp|udp|sctp|"
796 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
797 			"level-outer|level-inner|<flowtype_id>)\n"
798 			"    Set the RSS mode.\n\n"
799 
800 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
801 			"    Set the RSS redirection table.\n\n"
802 
803 			"port config (port_id) dcb vt (on|off) (traffic_class)"
804 			" pfc (on|off)\n"
805 			"    Set the DCB mode.\n\n"
806 
807 			"port config all burst (value)\n"
808 			"    Set the number of packets per burst.\n\n"
809 
810 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
811 			" (value)\n"
812 			"    Set the ring prefetch/host/writeback threshold"
813 			" for tx/rx queue.\n\n"
814 
815 			"port config all (txfreet|txrst|rxfreet) (value)\n"
816 			"    Set free threshold for rx/tx, or set"
817 			" tx rs bit threshold.\n\n"
818 			"port config mtu X value\n"
819 			"    Set the MTU of port X to a given value\n\n"
820 
821 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
822 			"    Set a rx/tx queue's ring size configuration, the new"
823 			" value will take effect after command that (re-)start the port"
824 			" or command that setup the specific queue\n\n"
825 
826 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
827 			"    Start/stop a rx/tx queue of port X. Only take effect"
828 			" when port X is started\n\n"
829 
830 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
831 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
832 			" take effect when port X is stopped.\n\n"
833 
834 			"port (port_id) (rxq|txq) (queue_id) setup\n"
835 			"    Setup a rx/tx queue of port X.\n\n"
836 
837 			"port config (port_id) pctype mapping reset\n"
838 			"    Reset flow type to pctype mapping on a port\n\n"
839 
840 			"port config (port_id) pctype mapping update"
841 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
842 			"    Update a flow type to pctype mapping item on a port\n\n"
843 
844 			"port config (port_id) pctype (pctype_id) hash_inset|"
845 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
846 			" (field_idx)\n"
847 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
848 
849 			"port config (port_id) pctype (pctype_id) hash_inset|"
850 			"fdir_inset|fdir_flx_inset clear all"
851 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
852 
853 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
854 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
855 
856 			"port config <port_id> rx_offload vlan_strip|"
857 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
858 			"outer_ipv4_cksum|macsec_strip|header_split|"
859 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
860 			"buffer_split|timestamp|security|keep_crc on|off\n"
861 			"     Enable or disable a per port Rx offloading"
862 			" on all Rx queues of a port\n\n"
863 
864 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
865 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
866 			"outer_ipv4_cksum|macsec_strip|header_split|"
867 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
868 			"buffer_split|timestamp|security|keep_crc on|off\n"
869 			"    Enable or disable a per queue Rx offloading"
870 			" only on a specific Rx queue\n\n"
871 
872 			"port config (port_id) tx_offload vlan_insert|"
873 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
874 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
875 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
876 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
877 			"security on|off\n"
878 			"    Enable or disable a per port Tx offloading"
879 			" on all Tx queues of a port\n\n"
880 
881 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
882 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
883 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
884 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
885 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
886 			" on|off\n"
887 			"    Enable or disable a per queue Tx offloading"
888 			" only on a specific Tx queue\n\n"
889 
890 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
891 			"    Load an eBPF program as a callback"
892 			" for particular RX/TX queue\n\n"
893 
894 			"bpf-unload rx|tx (port) (queue)\n"
895 			"    Unload previously loaded eBPF program"
896 			" for particular RX/TX queue\n\n"
897 
898 			"port config (port_id) tx_metadata (value)\n"
899 			"    Set Tx metadata value per port. Testpmd will add this value"
900 			" to any Tx packet sent from this port\n\n"
901 
902 			"port config (port_id) dynf (name) set|clear\n"
903 			"    Register a dynf and Set/clear this flag on Tx. "
904 			"Testpmd will set this value to any Tx packet "
905 			"sent from this port\n\n"
906 
907 			"port cleanup (port_id) txq (queue_id) (free_cnt)\n"
908 			"    Cleanup txq mbufs for a specific Tx queue\n\n"
909 		);
910 	}
911 
912 	if (show_all || !strcmp(res->section, "registers")) {
913 
914 		cmdline_printf(
915 			cl,
916 			"\n"
917 			"Registers:\n"
918 			"----------\n\n"
919 
920 			"read reg (port_id) (address)\n"
921 			"    Display value of a port register.\n\n"
922 
923 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
924 			"    Display a port register bit field.\n\n"
925 
926 			"read regbit (port_id) (address) (bit_x)\n"
927 			"    Display a single port register bit.\n\n"
928 
929 			"write reg (port_id) (address) (value)\n"
930 			"    Set value of a port register.\n\n"
931 
932 			"write regfield (port_id) (address) (bit_x) (bit_y)"
933 			" (value)\n"
934 			"    Set bit field of a port register.\n\n"
935 
936 			"write regbit (port_id) (address) (bit_x) (value)\n"
937 			"    Set single bit value of a port register.\n\n"
938 		);
939 	}
940 	if (show_all || !strcmp(res->section, "filters")) {
941 
942 		cmdline_printf(
943 			cl,
944 			"\n"
945 			"filters:\n"
946 			"--------\n\n"
947 
948 #ifdef RTE_NET_I40E
949 			"flow_director_filter (port_id) mode raw (add|del|update)"
950 			" flow (flow_id) (drop|fwd) queue (queue_id)"
951 			" fd_id (fd_id_value) packet (packet file name)\n"
952 			"    Add/Del a raw type flow director filter.\n\n"
953 #endif
954 
955 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
956 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
957 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
958 			"    Set flow director IP mask.\n\n"
959 
960 			"flow_director_mask (port_id) mode MAC-VLAN"
961 			" vlan (vlan_value)\n"
962 			"    Set flow director MAC-VLAN mask.\n\n"
963 
964 			"flow_director_mask (port_id) mode Tunnel"
965 			" vlan (vlan_value) mac (mac_value)"
966 			" tunnel-type (tunnel_type_value)"
967 			" tunnel-id (tunnel_id_value)\n"
968 			"    Set flow director Tunnel mask.\n\n"
969 
970 			"flow_director_flex_payload (port_id)"
971 			" (raw|l2|l3|l4) (config)\n"
972 			"    Configure flex payload selection.\n\n"
973 
974 			"flow validate {port_id}"
975 			" [group {group_id}] [priority {level}]"
976 			" [ingress] [egress]"
977 			" pattern {item} [/ {item} [...]] / end"
978 			" actions {action} [/ {action} [...]] / end\n"
979 			"    Check whether a flow rule can be created.\n\n"
980 
981 			"flow create {port_id}"
982 			" [group {group_id}] [priority {level}]"
983 			" [ingress] [egress]"
984 			" pattern {item} [/ {item} [...]] / end"
985 			" actions {action} [/ {action} [...]] / end\n"
986 			"    Create a flow rule.\n\n"
987 
988 			"flow destroy {port_id} rule {rule_id} [...]\n"
989 			"    Destroy specific flow rules.\n\n"
990 
991 			"flow flush {port_id}\n"
992 			"    Destroy all flow rules.\n\n"
993 
994 			"flow query {port_id} {rule_id} {action}\n"
995 			"    Query an existing flow rule.\n\n"
996 
997 			"flow list {port_id} [group {group_id}] [...]\n"
998 			"    List existing flow rules sorted by priority,"
999 			" filtered by group identifiers.\n\n"
1000 
1001 			"flow isolate {port_id} {boolean}\n"
1002 			"    Restrict ingress traffic to the defined"
1003 			" flow rules\n\n"
1004 
1005 			"flow aged {port_id} [destroy]\n"
1006 			"    List and destroy aged flows"
1007 			" flow rules\n\n"
1008 
1009 			"flow indirect_action {port_id} create"
1010 			" [action_id {indirect_action_id}]"
1011 			" [ingress] [egress]"
1012 			" action {action} / end\n"
1013 			"    Create indirect action.\n\n"
1014 
1015 			"flow indirect_action {port_id} update"
1016 			" {indirect_action_id} action {action} / end\n"
1017 			"    Update indirect action.\n\n"
1018 
1019 			"flow indirect_action {port_id} destroy"
1020 			" action_id {indirect_action_id} [...]\n"
1021 			"    Destroy specific indirect actions.\n\n"
1022 
1023 			"flow indirect_action {port_id} query"
1024 			" {indirect_action_id}\n"
1025 			"    Query an existing indirect action.\n\n"
1026 
1027 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1028 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1029 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1030 			"       Configure the VXLAN encapsulation for flows.\n\n"
1031 
1032 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1033 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1034 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1035 			" eth-dst (eth-dst)\n"
1036 			"       Configure the VXLAN encapsulation for flows.\n\n"
1037 
1038 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1039 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1040 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1041 			" eth-dst (eth-dst)\n"
1042 			"       Configure the VXLAN encapsulation for flows.\n\n"
1043 
1044 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1045 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1046 			" (eth-dst)\n"
1047 			"       Configure the NVGRE encapsulation for flows.\n\n"
1048 
1049 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1050 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1051 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1052 			"       Configure the NVGRE encapsulation for flows.\n\n"
1053 
1054 			"set raw_encap {flow items}\n"
1055 			"	Configure the encapsulation with raw data.\n\n"
1056 
1057 			"set raw_decap {flow items}\n"
1058 			"	Configure the decapsulation with raw data.\n\n"
1059 
1060 		);
1061 	}
1062 
1063 	if (show_all || !strcmp(res->section, "traffic_management")) {
1064 		cmdline_printf(
1065 			cl,
1066 			"\n"
1067 			"Traffic Management:\n"
1068 			"--------------\n"
1069 			"show port tm cap (port_id)\n"
1070 			"       Display the port TM capability.\n\n"
1071 
1072 			"show port tm level cap (port_id) (level_id)\n"
1073 			"       Display the port TM hierarchical level capability.\n\n"
1074 
1075 			"show port tm node cap (port_id) (node_id)\n"
1076 			"       Display the port TM node capability.\n\n"
1077 
1078 			"show port tm node type (port_id) (node_id)\n"
1079 			"       Display the port TM node type.\n\n"
1080 
1081 			"show port tm node stats (port_id) (node_id) (clear)\n"
1082 			"       Display the port TM node stats.\n\n"
1083 
1084 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1085 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1086 			" (packet_length_adjust) (packet_mode)\n"
1087 			"       Add port tm node private shaper profile.\n\n"
1088 
1089 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1090 			"       Delete port tm node private shaper profile.\n\n"
1091 
1092 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1093 			" (shaper_profile_id)\n"
1094 			"       Add/update port tm node shared shaper.\n\n"
1095 
1096 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1097 			"       Delete port tm node shared shaper.\n\n"
1098 
1099 			"set port tm node shaper profile (port_id) (node_id)"
1100 			" (shaper_profile_id)\n"
1101 			"       Set port tm node shaper profile.\n\n"
1102 
1103 			"add port tm node wred profile (port_id) (wred_profile_id)"
1104 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1105 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1106 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1107 			"       Add port tm node wred profile.\n\n"
1108 
1109 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1110 			"       Delete port tm node wred profile.\n\n"
1111 
1112 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1113 			" (priority) (weight) (level_id) (shaper_profile_id)"
1114 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1115 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1116 			"       Add port tm nonleaf node.\n\n"
1117 
1118 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1119 			" (priority) (weight) (level_id) (shaper_profile_id)"
1120 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1121 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1122 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
1123 
1124 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1125 			" (priority) (weight) (level_id) (shaper_profile_id)"
1126 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1127 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1128 			"       Add port tm leaf node.\n\n"
1129 
1130 			"del port tm node (port_id) (node_id)\n"
1131 			"       Delete port tm node.\n\n"
1132 
1133 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1134 			" (priority) (weight)\n"
1135 			"       Set port tm node parent.\n\n"
1136 
1137 			"suspend port tm node (port_id) (node_id)"
1138 			"       Suspend tm node.\n\n"
1139 
1140 			"resume port tm node (port_id) (node_id)"
1141 			"       Resume tm node.\n\n"
1142 
1143 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1144 			"       Commit tm hierarchy.\n\n"
1145 
1146 			"set port tm mark ip_ecn (port) (green) (yellow)"
1147 			" (red)\n"
1148 			"    Enables/Disables the traffic management marking"
1149 			" for IP ECN (Explicit Congestion Notification)"
1150 			" packets on a given port\n\n"
1151 
1152 			"set port tm mark ip_dscp (port) (green) (yellow)"
1153 			" (red)\n"
1154 			"    Enables/Disables the traffic management marking"
1155 			" on the port for IP dscp packets\n\n"
1156 
1157 			"set port tm mark vlan_dei (port) (green) (yellow)"
1158 			" (red)\n"
1159 			"    Enables/Disables the traffic management marking"
1160 			" on the port for VLAN packets with DEI enabled\n\n"
1161 		);
1162 	}
1163 
1164 	if (show_all || !strcmp(res->section, "devices")) {
1165 		cmdline_printf(
1166 			cl,
1167 			"\n"
1168 			"Device Operations:\n"
1169 			"--------------\n"
1170 			"device detach (identifier)\n"
1171 			"       Detach device by identifier.\n\n"
1172 		);
1173 	}
1174 
1175 }
1176 
1177 cmdline_parse_token_string_t cmd_help_long_help =
1178 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1179 
1180 cmdline_parse_token_string_t cmd_help_long_section =
1181 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1182 			"all#control#display#config#"
1183 			"ports#registers#filters#traffic_management#devices");
1184 
1185 cmdline_parse_inst_t cmd_help_long = {
1186 	.f = cmd_help_long_parsed,
1187 	.data = NULL,
1188 	.help_str = "help all|control|display|config|ports|register|"
1189 		"filters|traffic_management|devices: "
1190 		"Show help",
1191 	.tokens = {
1192 		(void *)&cmd_help_long_help,
1193 		(void *)&cmd_help_long_section,
1194 		NULL,
1195 	},
1196 };
1197 
1198 
1199 /* *** start/stop/close all ports *** */
1200 struct cmd_operate_port_result {
1201 	cmdline_fixed_string_t keyword;
1202 	cmdline_fixed_string_t name;
1203 	cmdline_fixed_string_t value;
1204 };
1205 
1206 static void cmd_operate_port_parsed(void *parsed_result,
1207 				__rte_unused struct cmdline *cl,
1208 				__rte_unused void *data)
1209 {
1210 	struct cmd_operate_port_result *res = parsed_result;
1211 
1212 	if (!strcmp(res->name, "start"))
1213 		start_port(RTE_PORT_ALL);
1214 	else if (!strcmp(res->name, "stop"))
1215 		stop_port(RTE_PORT_ALL);
1216 	else if (!strcmp(res->name, "close"))
1217 		close_port(RTE_PORT_ALL);
1218 	else if (!strcmp(res->name, "reset"))
1219 		reset_port(RTE_PORT_ALL);
1220 	else
1221 		fprintf(stderr, "Unknown parameter\n");
1222 }
1223 
1224 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1225 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1226 								"port");
1227 cmdline_parse_token_string_t cmd_operate_port_all_port =
1228 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1229 						"start#stop#close#reset");
1230 cmdline_parse_token_string_t cmd_operate_port_all_all =
1231 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1232 
1233 cmdline_parse_inst_t cmd_operate_port = {
1234 	.f = cmd_operate_port_parsed,
1235 	.data = NULL,
1236 	.help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1237 	.tokens = {
1238 		(void *)&cmd_operate_port_all_cmd,
1239 		(void *)&cmd_operate_port_all_port,
1240 		(void *)&cmd_operate_port_all_all,
1241 		NULL,
1242 	},
1243 };
1244 
1245 /* *** start/stop/close specific port *** */
1246 struct cmd_operate_specific_port_result {
1247 	cmdline_fixed_string_t keyword;
1248 	cmdline_fixed_string_t name;
1249 	uint8_t value;
1250 };
1251 
1252 static void cmd_operate_specific_port_parsed(void *parsed_result,
1253 			__rte_unused struct cmdline *cl,
1254 				__rte_unused void *data)
1255 {
1256 	struct cmd_operate_specific_port_result *res = parsed_result;
1257 
1258 	if (!strcmp(res->name, "start"))
1259 		start_port(res->value);
1260 	else if (!strcmp(res->name, "stop"))
1261 		stop_port(res->value);
1262 	else if (!strcmp(res->name, "close"))
1263 		close_port(res->value);
1264 	else if (!strcmp(res->name, "reset"))
1265 		reset_port(res->value);
1266 	else
1267 		fprintf(stderr, "Unknown parameter\n");
1268 }
1269 
1270 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1271 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1272 							keyword, "port");
1273 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1274 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1275 						name, "start#stop#close#reset");
1276 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1277 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1278 							value, RTE_UINT8);
1279 
1280 cmdline_parse_inst_t cmd_operate_specific_port = {
1281 	.f = cmd_operate_specific_port_parsed,
1282 	.data = NULL,
1283 	.help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1284 	.tokens = {
1285 		(void *)&cmd_operate_specific_port_cmd,
1286 		(void *)&cmd_operate_specific_port_port,
1287 		(void *)&cmd_operate_specific_port_id,
1288 		NULL,
1289 	},
1290 };
1291 
1292 /* *** enable port setup (after attach) via iterator or event *** */
1293 struct cmd_set_port_setup_on_result {
1294 	cmdline_fixed_string_t set;
1295 	cmdline_fixed_string_t port;
1296 	cmdline_fixed_string_t setup;
1297 	cmdline_fixed_string_t on;
1298 	cmdline_fixed_string_t mode;
1299 };
1300 
1301 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1302 				__rte_unused struct cmdline *cl,
1303 				__rte_unused void *data)
1304 {
1305 	struct cmd_set_port_setup_on_result *res = parsed_result;
1306 
1307 	if (strcmp(res->mode, "event") == 0)
1308 		setup_on_probe_event = true;
1309 	else if (strcmp(res->mode, "iterator") == 0)
1310 		setup_on_probe_event = false;
1311 	else
1312 		fprintf(stderr, "Unknown mode\n");
1313 }
1314 
1315 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1316 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1317 			set, "set");
1318 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1319 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1320 			port, "port");
1321 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1322 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1323 			setup, "setup");
1324 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1325 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1326 			on, "on");
1327 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1328 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1329 			mode, "iterator#event");
1330 
1331 cmdline_parse_inst_t cmd_set_port_setup_on = {
1332 	.f = cmd_set_port_setup_on_parsed,
1333 	.data = NULL,
1334 	.help_str = "set port setup on iterator|event",
1335 	.tokens = {
1336 		(void *)&cmd_set_port_setup_on_set,
1337 		(void *)&cmd_set_port_setup_on_port,
1338 		(void *)&cmd_set_port_setup_on_setup,
1339 		(void *)&cmd_set_port_setup_on_on,
1340 		(void *)&cmd_set_port_setup_on_mode,
1341 		NULL,
1342 	},
1343 };
1344 
1345 /* *** attach a specified port *** */
1346 struct cmd_operate_attach_port_result {
1347 	cmdline_fixed_string_t port;
1348 	cmdline_fixed_string_t keyword;
1349 	cmdline_multi_string_t identifier;
1350 };
1351 
1352 static void cmd_operate_attach_port_parsed(void *parsed_result,
1353 				__rte_unused struct cmdline *cl,
1354 				__rte_unused void *data)
1355 {
1356 	struct cmd_operate_attach_port_result *res = parsed_result;
1357 
1358 	if (!strcmp(res->keyword, "attach"))
1359 		attach_port(res->identifier);
1360 	else
1361 		fprintf(stderr, "Unknown parameter\n");
1362 }
1363 
1364 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1365 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1366 			port, "port");
1367 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1368 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1369 			keyword, "attach");
1370 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1371 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1372 			identifier, TOKEN_STRING_MULTI);
1373 
1374 cmdline_parse_inst_t cmd_operate_attach_port = {
1375 	.f = cmd_operate_attach_port_parsed,
1376 	.data = NULL,
1377 	.help_str = "port attach <identifier>: "
1378 		"(identifier: pci address or virtual dev name)",
1379 	.tokens = {
1380 		(void *)&cmd_operate_attach_port_port,
1381 		(void *)&cmd_operate_attach_port_keyword,
1382 		(void *)&cmd_operate_attach_port_identifier,
1383 		NULL,
1384 	},
1385 };
1386 
1387 /* *** detach a specified port *** */
1388 struct cmd_operate_detach_port_result {
1389 	cmdline_fixed_string_t port;
1390 	cmdline_fixed_string_t keyword;
1391 	portid_t port_id;
1392 };
1393 
1394 static void cmd_operate_detach_port_parsed(void *parsed_result,
1395 				__rte_unused struct cmdline *cl,
1396 				__rte_unused void *data)
1397 {
1398 	struct cmd_operate_detach_port_result *res = parsed_result;
1399 
1400 	if (!strcmp(res->keyword, "detach")) {
1401 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1402 		detach_port_device(res->port_id);
1403 	} else {
1404 		fprintf(stderr, "Unknown parameter\n");
1405 	}
1406 }
1407 
1408 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1409 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1410 			port, "port");
1411 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1412 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1413 			keyword, "detach");
1414 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1415 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1416 			port_id, RTE_UINT16);
1417 
1418 cmdline_parse_inst_t cmd_operate_detach_port = {
1419 	.f = cmd_operate_detach_port_parsed,
1420 	.data = NULL,
1421 	.help_str = "port detach <port_id>",
1422 	.tokens = {
1423 		(void *)&cmd_operate_detach_port_port,
1424 		(void *)&cmd_operate_detach_port_keyword,
1425 		(void *)&cmd_operate_detach_port_port_id,
1426 		NULL,
1427 	},
1428 };
1429 
1430 /* *** detach device by identifier *** */
1431 struct cmd_operate_detach_device_result {
1432 	cmdline_fixed_string_t device;
1433 	cmdline_fixed_string_t keyword;
1434 	cmdline_fixed_string_t identifier;
1435 };
1436 
1437 static void cmd_operate_detach_device_parsed(void *parsed_result,
1438 				__rte_unused struct cmdline *cl,
1439 				__rte_unused void *data)
1440 {
1441 	struct cmd_operate_detach_device_result *res = parsed_result;
1442 
1443 	if (!strcmp(res->keyword, "detach"))
1444 		detach_devargs(res->identifier);
1445 	else
1446 		fprintf(stderr, "Unknown parameter\n");
1447 }
1448 
1449 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1450 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1451 			device, "device");
1452 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1453 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1454 			keyword, "detach");
1455 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1456 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1457 			identifier, NULL);
1458 
1459 cmdline_parse_inst_t cmd_operate_detach_device = {
1460 	.f = cmd_operate_detach_device_parsed,
1461 	.data = NULL,
1462 	.help_str = "device detach <identifier>:"
1463 		"(identifier: pci address or virtual dev name)",
1464 	.tokens = {
1465 		(void *)&cmd_operate_detach_device_device,
1466 		(void *)&cmd_operate_detach_device_keyword,
1467 		(void *)&cmd_operate_detach_device_identifier,
1468 		NULL,
1469 	},
1470 };
1471 /* *** configure speed for all ports *** */
1472 struct cmd_config_speed_all {
1473 	cmdline_fixed_string_t port;
1474 	cmdline_fixed_string_t keyword;
1475 	cmdline_fixed_string_t all;
1476 	cmdline_fixed_string_t item1;
1477 	cmdline_fixed_string_t item2;
1478 	cmdline_fixed_string_t value1;
1479 	cmdline_fixed_string_t value2;
1480 };
1481 
1482 static int
1483 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1484 {
1485 
1486 	int duplex;
1487 
1488 	if (!strcmp(duplexstr, "half")) {
1489 		duplex = RTE_ETH_LINK_HALF_DUPLEX;
1490 	} else if (!strcmp(duplexstr, "full")) {
1491 		duplex = RTE_ETH_LINK_FULL_DUPLEX;
1492 	} else if (!strcmp(duplexstr, "auto")) {
1493 		duplex = RTE_ETH_LINK_FULL_DUPLEX;
1494 	} else {
1495 		fprintf(stderr, "Unknown duplex parameter\n");
1496 		return -1;
1497 	}
1498 
1499 	if (!strcmp(speedstr, "10")) {
1500 		*speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1501 				RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1502 	} else if (!strcmp(speedstr, "100")) {
1503 		*speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1504 				RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1505 	} else {
1506 		if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1507 			fprintf(stderr, "Invalid speed/duplex parameters\n");
1508 			return -1;
1509 		}
1510 		if (!strcmp(speedstr, "1000")) {
1511 			*speed = RTE_ETH_LINK_SPEED_1G;
1512 		} else if (!strcmp(speedstr, "10000")) {
1513 			*speed = RTE_ETH_LINK_SPEED_10G;
1514 		} else if (!strcmp(speedstr, "25000")) {
1515 			*speed = RTE_ETH_LINK_SPEED_25G;
1516 		} else if (!strcmp(speedstr, "40000")) {
1517 			*speed = RTE_ETH_LINK_SPEED_40G;
1518 		} else if (!strcmp(speedstr, "50000")) {
1519 			*speed = RTE_ETH_LINK_SPEED_50G;
1520 		} else if (!strcmp(speedstr, "100000")) {
1521 			*speed = RTE_ETH_LINK_SPEED_100G;
1522 		} else if (!strcmp(speedstr, "200000")) {
1523 			*speed = RTE_ETH_LINK_SPEED_200G;
1524 		} else if (!strcmp(speedstr, "auto")) {
1525 			*speed = RTE_ETH_LINK_SPEED_AUTONEG;
1526 		} else {
1527 			fprintf(stderr, "Unknown speed parameter\n");
1528 			return -1;
1529 		}
1530 	}
1531 
1532 	if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1533 		*speed |= RTE_ETH_LINK_SPEED_FIXED;
1534 
1535 	return 0;
1536 }
1537 
1538 static void
1539 cmd_config_speed_all_parsed(void *parsed_result,
1540 			__rte_unused struct cmdline *cl,
1541 			__rte_unused void *data)
1542 {
1543 	struct cmd_config_speed_all *res = parsed_result;
1544 	uint32_t link_speed;
1545 	portid_t pid;
1546 
1547 	if (!all_ports_stopped()) {
1548 		fprintf(stderr, "Please stop all ports first\n");
1549 		return;
1550 	}
1551 
1552 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1553 			&link_speed) < 0)
1554 		return;
1555 
1556 	RTE_ETH_FOREACH_DEV(pid) {
1557 		ports[pid].dev_conf.link_speeds = link_speed;
1558 	}
1559 
1560 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1561 }
1562 
1563 cmdline_parse_token_string_t cmd_config_speed_all_port =
1564 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1565 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1566 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1567 							"config");
1568 cmdline_parse_token_string_t cmd_config_speed_all_all =
1569 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1570 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1571 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1572 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1573 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1574 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1575 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1576 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1577 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1578 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1579 						"half#full#auto");
1580 
1581 cmdline_parse_inst_t cmd_config_speed_all = {
1582 	.f = cmd_config_speed_all_parsed,
1583 	.data = NULL,
1584 	.help_str = "port config all speed "
1585 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1586 							"half|full|auto",
1587 	.tokens = {
1588 		(void *)&cmd_config_speed_all_port,
1589 		(void *)&cmd_config_speed_all_keyword,
1590 		(void *)&cmd_config_speed_all_all,
1591 		(void *)&cmd_config_speed_all_item1,
1592 		(void *)&cmd_config_speed_all_value1,
1593 		(void *)&cmd_config_speed_all_item2,
1594 		(void *)&cmd_config_speed_all_value2,
1595 		NULL,
1596 	},
1597 };
1598 
1599 /* *** configure speed for specific port *** */
1600 struct cmd_config_speed_specific {
1601 	cmdline_fixed_string_t port;
1602 	cmdline_fixed_string_t keyword;
1603 	portid_t id;
1604 	cmdline_fixed_string_t item1;
1605 	cmdline_fixed_string_t item2;
1606 	cmdline_fixed_string_t value1;
1607 	cmdline_fixed_string_t value2;
1608 };
1609 
1610 static void
1611 cmd_config_speed_specific_parsed(void *parsed_result,
1612 				__rte_unused struct cmdline *cl,
1613 				__rte_unused void *data)
1614 {
1615 	struct cmd_config_speed_specific *res = parsed_result;
1616 	uint32_t link_speed;
1617 
1618 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1619 		return;
1620 
1621 	if (!port_is_stopped(res->id)) {
1622 		fprintf(stderr, "Please stop port %d first\n", res->id);
1623 		return;
1624 	}
1625 
1626 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1627 			&link_speed) < 0)
1628 		return;
1629 
1630 	ports[res->id].dev_conf.link_speeds = link_speed;
1631 
1632 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1633 }
1634 
1635 
1636 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1637 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1638 								"port");
1639 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1640 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1641 								"config");
1642 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1643 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1644 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1645 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1646 								"speed");
1647 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1648 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1649 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1650 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1651 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1652 								"duplex");
1653 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1654 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1655 							"half#full#auto");
1656 
1657 cmdline_parse_inst_t cmd_config_speed_specific = {
1658 	.f = cmd_config_speed_specific_parsed,
1659 	.data = NULL,
1660 	.help_str = "port config <port_id> speed "
1661 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1662 							"half|full|auto",
1663 	.tokens = {
1664 		(void *)&cmd_config_speed_specific_port,
1665 		(void *)&cmd_config_speed_specific_keyword,
1666 		(void *)&cmd_config_speed_specific_id,
1667 		(void *)&cmd_config_speed_specific_item1,
1668 		(void *)&cmd_config_speed_specific_value1,
1669 		(void *)&cmd_config_speed_specific_item2,
1670 		(void *)&cmd_config_speed_specific_value2,
1671 		NULL,
1672 	},
1673 };
1674 
1675 /* *** configure loopback for all ports *** */
1676 struct cmd_config_loopback_all {
1677 	cmdline_fixed_string_t port;
1678 	cmdline_fixed_string_t keyword;
1679 	cmdline_fixed_string_t all;
1680 	cmdline_fixed_string_t item;
1681 	uint32_t mode;
1682 };
1683 
1684 static void
1685 cmd_config_loopback_all_parsed(void *parsed_result,
1686 			__rte_unused struct cmdline *cl,
1687 			__rte_unused void *data)
1688 {
1689 	struct cmd_config_loopback_all *res = parsed_result;
1690 	portid_t pid;
1691 
1692 	if (!all_ports_stopped()) {
1693 		fprintf(stderr, "Please stop all ports first\n");
1694 		return;
1695 	}
1696 
1697 	RTE_ETH_FOREACH_DEV(pid) {
1698 		ports[pid].dev_conf.lpbk_mode = res->mode;
1699 	}
1700 
1701 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1702 }
1703 
1704 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1705 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1706 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1707 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1708 							"config");
1709 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1710 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1711 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1712 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1713 							"loopback");
1714 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1715 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1716 
1717 cmdline_parse_inst_t cmd_config_loopback_all = {
1718 	.f = cmd_config_loopback_all_parsed,
1719 	.data = NULL,
1720 	.help_str = "port config all loopback <mode>",
1721 	.tokens = {
1722 		(void *)&cmd_config_loopback_all_port,
1723 		(void *)&cmd_config_loopback_all_keyword,
1724 		(void *)&cmd_config_loopback_all_all,
1725 		(void *)&cmd_config_loopback_all_item,
1726 		(void *)&cmd_config_loopback_all_mode,
1727 		NULL,
1728 	},
1729 };
1730 
1731 /* *** configure loopback for specific port *** */
1732 struct cmd_config_loopback_specific {
1733 	cmdline_fixed_string_t port;
1734 	cmdline_fixed_string_t keyword;
1735 	uint16_t port_id;
1736 	cmdline_fixed_string_t item;
1737 	uint32_t mode;
1738 };
1739 
1740 static void
1741 cmd_config_loopback_specific_parsed(void *parsed_result,
1742 				__rte_unused struct cmdline *cl,
1743 				__rte_unused void *data)
1744 {
1745 	struct cmd_config_loopback_specific *res = parsed_result;
1746 
1747 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1748 		return;
1749 
1750 	if (!port_is_stopped(res->port_id)) {
1751 		fprintf(stderr, "Please stop port %u first\n", res->port_id);
1752 		return;
1753 	}
1754 
1755 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1756 
1757 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1758 }
1759 
1760 
1761 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1762 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1763 								"port");
1764 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1765 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1766 								"config");
1767 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1768 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1769 								RTE_UINT16);
1770 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1771 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1772 								"loopback");
1773 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1774 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1775 			      RTE_UINT32);
1776 
1777 cmdline_parse_inst_t cmd_config_loopback_specific = {
1778 	.f = cmd_config_loopback_specific_parsed,
1779 	.data = NULL,
1780 	.help_str = "port config <port_id> loopback <mode>",
1781 	.tokens = {
1782 		(void *)&cmd_config_loopback_specific_port,
1783 		(void *)&cmd_config_loopback_specific_keyword,
1784 		(void *)&cmd_config_loopback_specific_id,
1785 		(void *)&cmd_config_loopback_specific_item,
1786 		(void *)&cmd_config_loopback_specific_mode,
1787 		NULL,
1788 	},
1789 };
1790 
1791 /* *** configure txq/rxq, txd/rxd *** */
1792 struct cmd_config_rx_tx {
1793 	cmdline_fixed_string_t port;
1794 	cmdline_fixed_string_t keyword;
1795 	cmdline_fixed_string_t all;
1796 	cmdline_fixed_string_t name;
1797 	uint16_t value;
1798 };
1799 
1800 static void
1801 cmd_config_rx_tx_parsed(void *parsed_result,
1802 			__rte_unused struct cmdline *cl,
1803 			__rte_unused void *data)
1804 {
1805 	struct cmd_config_rx_tx *res = parsed_result;
1806 
1807 	if (!all_ports_stopped()) {
1808 		fprintf(stderr, "Please stop all ports first\n");
1809 		return;
1810 	}
1811 	if (!strcmp(res->name, "rxq")) {
1812 		if (!res->value && !nb_txq) {
1813 			fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1814 			return;
1815 		}
1816 		if (check_nb_rxq(res->value) != 0)
1817 			return;
1818 		nb_rxq = res->value;
1819 	}
1820 	else if (!strcmp(res->name, "txq")) {
1821 		if (!res->value && !nb_rxq) {
1822 			fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1823 			return;
1824 		}
1825 		if (check_nb_txq(res->value) != 0)
1826 			return;
1827 		nb_txq = res->value;
1828 	}
1829 	else if (!strcmp(res->name, "rxd")) {
1830 		if (check_nb_rxd(res->value) != 0)
1831 			return;
1832 		nb_rxd = res->value;
1833 	} else if (!strcmp(res->name, "txd")) {
1834 		if (check_nb_txd(res->value) != 0)
1835 			return;
1836 
1837 		nb_txd = res->value;
1838 	} else {
1839 		fprintf(stderr, "Unknown parameter\n");
1840 		return;
1841 	}
1842 
1843 	fwd_config_setup();
1844 
1845 	init_port_config();
1846 
1847 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1848 }
1849 
1850 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1851 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1852 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1853 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1854 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1855 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1856 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1857 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1858 						"rxq#txq#rxd#txd");
1859 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1860 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1861 
1862 cmdline_parse_inst_t cmd_config_rx_tx = {
1863 	.f = cmd_config_rx_tx_parsed,
1864 	.data = NULL,
1865 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1866 	.tokens = {
1867 		(void *)&cmd_config_rx_tx_port,
1868 		(void *)&cmd_config_rx_tx_keyword,
1869 		(void *)&cmd_config_rx_tx_all,
1870 		(void *)&cmd_config_rx_tx_name,
1871 		(void *)&cmd_config_rx_tx_value,
1872 		NULL,
1873 	},
1874 };
1875 
1876 /* *** config max packet length *** */
1877 struct cmd_config_max_pkt_len_result {
1878 	cmdline_fixed_string_t port;
1879 	cmdline_fixed_string_t keyword;
1880 	cmdline_fixed_string_t all;
1881 	cmdline_fixed_string_t name;
1882 	uint32_t value;
1883 };
1884 
1885 static void
1886 cmd_config_max_pkt_len_parsed(void *parsed_result,
1887 				__rte_unused struct cmdline *cl,
1888 				__rte_unused void *data)
1889 {
1890 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1891 	portid_t port_id;
1892 	int ret;
1893 
1894 	if (strcmp(res->name, "max-pkt-len") != 0) {
1895 		printf("Unknown parameter\n");
1896 		return;
1897 	}
1898 
1899 	if (!all_ports_stopped()) {
1900 		fprintf(stderr, "Please stop all ports first\n");
1901 		return;
1902 	}
1903 
1904 	RTE_ETH_FOREACH_DEV(port_id) {
1905 		struct rte_port *port = &ports[port_id];
1906 
1907 		if (res->value < RTE_ETHER_MIN_LEN) {
1908 			fprintf(stderr,
1909 				"max-pkt-len can not be less than %d\n",
1910 				RTE_ETHER_MIN_LEN);
1911 			return;
1912 		}
1913 
1914 		ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1915 		if (ret != 0) {
1916 			fprintf(stderr,
1917 				"rte_eth_dev_info_get() failed for port %u\n",
1918 				port_id);
1919 			return;
1920 		}
1921 
1922 		update_mtu_from_frame_size(port_id, res->value);
1923 	}
1924 
1925 	init_port_config();
1926 
1927 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1928 }
1929 
1930 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1931 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1932 								"port");
1933 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1934 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1935 								"config");
1936 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1937 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1938 								"all");
1939 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1940 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1941 								"max-pkt-len");
1942 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1943 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1944 								RTE_UINT32);
1945 
1946 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1947 	.f = cmd_config_max_pkt_len_parsed,
1948 	.data = NULL,
1949 	.help_str = "port config all max-pkt-len <value>",
1950 	.tokens = {
1951 		(void *)&cmd_config_max_pkt_len_port,
1952 		(void *)&cmd_config_max_pkt_len_keyword,
1953 		(void *)&cmd_config_max_pkt_len_all,
1954 		(void *)&cmd_config_max_pkt_len_name,
1955 		(void *)&cmd_config_max_pkt_len_value,
1956 		NULL,
1957 	},
1958 };
1959 
1960 /* *** config max LRO aggregated packet size *** */
1961 struct cmd_config_max_lro_pkt_size_result {
1962 	cmdline_fixed_string_t port;
1963 	cmdline_fixed_string_t keyword;
1964 	cmdline_fixed_string_t all;
1965 	cmdline_fixed_string_t name;
1966 	uint32_t value;
1967 };
1968 
1969 static void
1970 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1971 				__rte_unused struct cmdline *cl,
1972 				__rte_unused void *data)
1973 {
1974 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1975 	portid_t pid;
1976 
1977 	if (!all_ports_stopped()) {
1978 		fprintf(stderr, "Please stop all ports first\n");
1979 		return;
1980 	}
1981 
1982 	RTE_ETH_FOREACH_DEV(pid) {
1983 		struct rte_port *port = &ports[pid];
1984 
1985 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1986 			if (res->value ==
1987 					port->dev_conf.rxmode.max_lro_pkt_size)
1988 				return;
1989 
1990 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1991 		} else {
1992 			fprintf(stderr, "Unknown parameter\n");
1993 			return;
1994 		}
1995 	}
1996 
1997 	init_port_config();
1998 
1999 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2000 }
2001 
2002 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2003 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2004 				 port, "port");
2005 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2006 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2007 				 keyword, "config");
2008 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2009 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2010 				 all, "all");
2011 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2012 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2013 				 name, "max-lro-pkt-size");
2014 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2015 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 			      value, RTE_UINT32);
2017 
2018 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2019 	.f = cmd_config_max_lro_pkt_size_parsed,
2020 	.data = NULL,
2021 	.help_str = "port config all max-lro-pkt-size <value>",
2022 	.tokens = {
2023 		(void *)&cmd_config_max_lro_pkt_size_port,
2024 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2025 		(void *)&cmd_config_max_lro_pkt_size_all,
2026 		(void *)&cmd_config_max_lro_pkt_size_name,
2027 		(void *)&cmd_config_max_lro_pkt_size_value,
2028 		NULL,
2029 	},
2030 };
2031 
2032 /* *** configure port MTU *** */
2033 struct cmd_config_mtu_result {
2034 	cmdline_fixed_string_t port;
2035 	cmdline_fixed_string_t keyword;
2036 	cmdline_fixed_string_t mtu;
2037 	portid_t port_id;
2038 	uint16_t value;
2039 };
2040 
2041 static void
2042 cmd_config_mtu_parsed(void *parsed_result,
2043 		      __rte_unused struct cmdline *cl,
2044 		      __rte_unused void *data)
2045 {
2046 	struct cmd_config_mtu_result *res = parsed_result;
2047 
2048 	if (res->value < RTE_ETHER_MIN_LEN) {
2049 		fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2050 		return;
2051 	}
2052 	port_mtu_set(res->port_id, res->value);
2053 }
2054 
2055 cmdline_parse_token_string_t cmd_config_mtu_port =
2056 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2057 				 "port");
2058 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2059 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2060 				 "config");
2061 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2062 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2063 				 "mtu");
2064 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2065 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2066 				 RTE_UINT16);
2067 cmdline_parse_token_num_t cmd_config_mtu_value =
2068 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2069 				 RTE_UINT16);
2070 
2071 cmdline_parse_inst_t cmd_config_mtu = {
2072 	.f = cmd_config_mtu_parsed,
2073 	.data = NULL,
2074 	.help_str = "port config mtu <port_id> <value>",
2075 	.tokens = {
2076 		(void *)&cmd_config_mtu_port,
2077 		(void *)&cmd_config_mtu_keyword,
2078 		(void *)&cmd_config_mtu_mtu,
2079 		(void *)&cmd_config_mtu_port_id,
2080 		(void *)&cmd_config_mtu_value,
2081 		NULL,
2082 	},
2083 };
2084 
2085 /* *** configure rx mode *** */
2086 struct cmd_config_rx_mode_flag {
2087 	cmdline_fixed_string_t port;
2088 	cmdline_fixed_string_t keyword;
2089 	cmdline_fixed_string_t all;
2090 	cmdline_fixed_string_t name;
2091 	cmdline_fixed_string_t value;
2092 };
2093 
2094 static void
2095 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2096 				__rte_unused struct cmdline *cl,
2097 				__rte_unused void *data)
2098 {
2099 	struct cmd_config_rx_mode_flag *res = parsed_result;
2100 
2101 	if (!all_ports_stopped()) {
2102 		fprintf(stderr, "Please stop all ports first\n");
2103 		return;
2104 	}
2105 
2106 	if (!strcmp(res->name, "drop-en")) {
2107 		if (!strcmp(res->value, "on"))
2108 			rx_drop_en = 1;
2109 		else if (!strcmp(res->value, "off"))
2110 			rx_drop_en = 0;
2111 		else {
2112 			fprintf(stderr, "Unknown parameter\n");
2113 			return;
2114 		}
2115 	} else {
2116 		fprintf(stderr, "Unknown parameter\n");
2117 		return;
2118 	}
2119 
2120 	init_port_config();
2121 
2122 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2123 }
2124 
2125 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2126 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2127 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2128 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2129 								"config");
2130 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2131 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2132 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2133 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2134 					"drop-en");
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2136 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2137 							"on#off");
2138 
2139 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2140 	.f = cmd_config_rx_mode_flag_parsed,
2141 	.data = NULL,
2142 	.help_str = "port config all drop-en on|off",
2143 	.tokens = {
2144 		(void *)&cmd_config_rx_mode_flag_port,
2145 		(void *)&cmd_config_rx_mode_flag_keyword,
2146 		(void *)&cmd_config_rx_mode_flag_all,
2147 		(void *)&cmd_config_rx_mode_flag_name,
2148 		(void *)&cmd_config_rx_mode_flag_value,
2149 		NULL,
2150 	},
2151 };
2152 
2153 /* *** configure rss *** */
2154 struct cmd_config_rss {
2155 	cmdline_fixed_string_t port;
2156 	cmdline_fixed_string_t keyword;
2157 	cmdline_fixed_string_t all;
2158 	cmdline_fixed_string_t name;
2159 	cmdline_fixed_string_t value;
2160 };
2161 
2162 static void
2163 cmd_config_rss_parsed(void *parsed_result,
2164 			__rte_unused struct cmdline *cl,
2165 			__rte_unused void *data)
2166 {
2167 	struct cmd_config_rss *res = parsed_result;
2168 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2169 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2170 	int use_default = 0;
2171 	int all_updated = 1;
2172 	int diag;
2173 	uint16_t i;
2174 	int ret;
2175 
2176 	if (!strcmp(res->value, "all"))
2177 		rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2178 			RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2179 			RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2180 			RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2181 			RTE_ETH_RSS_ECPRI;
2182 	else if (!strcmp(res->value, "eth"))
2183 		rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2184 	else if (!strcmp(res->value, "vlan"))
2185 		rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2186 	else if (!strcmp(res->value, "ip"))
2187 		rss_conf.rss_hf = RTE_ETH_RSS_IP;
2188 	else if (!strcmp(res->value, "udp"))
2189 		rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2190 	else if (!strcmp(res->value, "tcp"))
2191 		rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2192 	else if (!strcmp(res->value, "sctp"))
2193 		rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2194 	else if (!strcmp(res->value, "ether"))
2195 		rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2196 	else if (!strcmp(res->value, "port"))
2197 		rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2198 	else if (!strcmp(res->value, "vxlan"))
2199 		rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2200 	else if (!strcmp(res->value, "geneve"))
2201 		rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2202 	else if (!strcmp(res->value, "nvgre"))
2203 		rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2204 	else if (!strcmp(res->value, "l3-pre32"))
2205 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2206 	else if (!strcmp(res->value, "l3-pre40"))
2207 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2208 	else if (!strcmp(res->value, "l3-pre48"))
2209 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2210 	else if (!strcmp(res->value, "l3-pre56"))
2211 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2212 	else if (!strcmp(res->value, "l3-pre64"))
2213 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2214 	else if (!strcmp(res->value, "l3-pre96"))
2215 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2216 	else if (!strcmp(res->value, "l3-src-only"))
2217 		rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2218 	else if (!strcmp(res->value, "l3-dst-only"))
2219 		rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2220 	else if (!strcmp(res->value, "l4-src-only"))
2221 		rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2222 	else if (!strcmp(res->value, "l4-dst-only"))
2223 		rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2224 	else if (!strcmp(res->value, "l2-src-only"))
2225 		rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2226 	else if (!strcmp(res->value, "l2-dst-only"))
2227 		rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2228 	else if (!strcmp(res->value, "l2tpv3"))
2229 		rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2230 	else if (!strcmp(res->value, "esp"))
2231 		rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2232 	else if (!strcmp(res->value, "ah"))
2233 		rss_conf.rss_hf = RTE_ETH_RSS_AH;
2234 	else if (!strcmp(res->value, "pfcp"))
2235 		rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2236 	else if (!strcmp(res->value, "pppoe"))
2237 		rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2238 	else if (!strcmp(res->value, "gtpu"))
2239 		rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2240 	else if (!strcmp(res->value, "ecpri"))
2241 		rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2242 	else if (!strcmp(res->value, "mpls"))
2243 		rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2244 	else if (!strcmp(res->value, "ipv4-chksum"))
2245 		rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2246 	else if (!strcmp(res->value, "none"))
2247 		rss_conf.rss_hf = 0;
2248 	else if (!strcmp(res->value, "level-default")) {
2249 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2250 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2251 	} else if (!strcmp(res->value, "level-outer")) {
2252 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2253 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2254 	} else if (!strcmp(res->value, "level-inner")) {
2255 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2256 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2257 	} else if (!strcmp(res->value, "default"))
2258 		use_default = 1;
2259 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2260 						atoi(res->value) < 64)
2261 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2262 	else {
2263 		fprintf(stderr, "Unknown parameter\n");
2264 		return;
2265 	}
2266 	rss_conf.rss_key = NULL;
2267 	/* Update global configuration for RSS types. */
2268 	RTE_ETH_FOREACH_DEV(i) {
2269 		struct rte_eth_rss_conf local_rss_conf;
2270 
2271 		ret = eth_dev_info_get_print_err(i, &dev_info);
2272 		if (ret != 0)
2273 			return;
2274 
2275 		if (use_default)
2276 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2277 
2278 		local_rss_conf = rss_conf;
2279 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2280 			dev_info.flow_type_rss_offloads;
2281 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2282 			printf("Port %u modified RSS hash function based on hardware support,"
2283 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2284 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2285 		}
2286 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2287 		if (diag < 0) {
2288 			all_updated = 0;
2289 			fprintf(stderr,
2290 				"Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2291 				i, -diag, strerror(-diag));
2292 		}
2293 	}
2294 	if (all_updated && !use_default) {
2295 		rss_hf = rss_conf.rss_hf;
2296 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2297 	}
2298 }
2299 
2300 cmdline_parse_token_string_t cmd_config_rss_port =
2301 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2302 cmdline_parse_token_string_t cmd_config_rss_keyword =
2303 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2304 cmdline_parse_token_string_t cmd_config_rss_all =
2305 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2306 cmdline_parse_token_string_t cmd_config_rss_name =
2307 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2308 cmdline_parse_token_string_t cmd_config_rss_value =
2309 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2310 
2311 cmdline_parse_inst_t cmd_config_rss = {
2312 	.f = cmd_config_rss_parsed,
2313 	.data = NULL,
2314 	.help_str = "port config all rss "
2315 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2316 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2317 		"level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2318 	.tokens = {
2319 		(void *)&cmd_config_rss_port,
2320 		(void *)&cmd_config_rss_keyword,
2321 		(void *)&cmd_config_rss_all,
2322 		(void *)&cmd_config_rss_name,
2323 		(void *)&cmd_config_rss_value,
2324 		NULL,
2325 	},
2326 };
2327 
2328 /* *** configure rss hash key *** */
2329 struct cmd_config_rss_hash_key {
2330 	cmdline_fixed_string_t port;
2331 	cmdline_fixed_string_t config;
2332 	portid_t port_id;
2333 	cmdline_fixed_string_t rss_hash_key;
2334 	cmdline_fixed_string_t rss_type;
2335 	cmdline_fixed_string_t key;
2336 };
2337 
2338 static uint8_t
2339 hexa_digit_to_value(char hexa_digit)
2340 {
2341 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2342 		return (uint8_t) (hexa_digit - '0');
2343 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2344 		return (uint8_t) ((hexa_digit - 'a') + 10);
2345 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2346 		return (uint8_t) ((hexa_digit - 'A') + 10);
2347 	/* Invalid hexa digit */
2348 	return 0xFF;
2349 }
2350 
2351 static uint8_t
2352 parse_and_check_key_hexa_digit(char *key, int idx)
2353 {
2354 	uint8_t hexa_v;
2355 
2356 	hexa_v = hexa_digit_to_value(key[idx]);
2357 	if (hexa_v == 0xFF)
2358 		fprintf(stderr,
2359 			"invalid key: character %c at position %d is not a valid hexa digit\n",
2360 			key[idx], idx);
2361 	return hexa_v;
2362 }
2363 
2364 static void
2365 cmd_config_rss_hash_key_parsed(void *parsed_result,
2366 			       __rte_unused struct cmdline *cl,
2367 			       __rte_unused void *data)
2368 {
2369 	struct cmd_config_rss_hash_key *res = parsed_result;
2370 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2371 	uint8_t xdgt0;
2372 	uint8_t xdgt1;
2373 	int i;
2374 	struct rte_eth_dev_info dev_info;
2375 	uint8_t hash_key_size;
2376 	uint32_t key_len;
2377 	int ret;
2378 
2379 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2380 	if (ret != 0)
2381 		return;
2382 
2383 	if (dev_info.hash_key_size > 0 &&
2384 			dev_info.hash_key_size <= sizeof(hash_key))
2385 		hash_key_size = dev_info.hash_key_size;
2386 	else {
2387 		fprintf(stderr,
2388 			"dev_info did not provide a valid hash key size\n");
2389 		return;
2390 	}
2391 	/* Check the length of the RSS hash key */
2392 	key_len = strlen(res->key);
2393 	if (key_len != (hash_key_size * 2)) {
2394 		fprintf(stderr,
2395 			"key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2396 			(int)key_len, hash_key_size * 2);
2397 		return;
2398 	}
2399 	/* Translate RSS hash key into binary representation */
2400 	for (i = 0; i < hash_key_size; i++) {
2401 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2402 		if (xdgt0 == 0xFF)
2403 			return;
2404 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2405 		if (xdgt1 == 0xFF)
2406 			return;
2407 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2408 	}
2409 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2410 			hash_key_size);
2411 }
2412 
2413 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2414 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2415 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2416 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2417 				 "config");
2418 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2419 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2420 				 RTE_UINT16);
2421 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2422 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2423 				 rss_hash_key, "rss-hash-key");
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2425 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2426 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2427 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2428 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2429 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2430 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2431 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2432 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2433 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2434 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2435 
2436 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2437 	.f = cmd_config_rss_hash_key_parsed,
2438 	.data = NULL,
2439 	.help_str = "port config <port_id> rss-hash-key "
2440 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2441 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2442 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2443 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2444 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2445 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2446 		"<string of hex digits (variable length, NIC dependent)>",
2447 	.tokens = {
2448 		(void *)&cmd_config_rss_hash_key_port,
2449 		(void *)&cmd_config_rss_hash_key_config,
2450 		(void *)&cmd_config_rss_hash_key_port_id,
2451 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2452 		(void *)&cmd_config_rss_hash_key_rss_type,
2453 		(void *)&cmd_config_rss_hash_key_value,
2454 		NULL,
2455 	},
2456 };
2457 
2458 /* *** cleanup txq mbufs *** */
2459 struct cmd_cleanup_txq_mbufs_result {
2460 	cmdline_fixed_string_t port;
2461 	cmdline_fixed_string_t keyword;
2462 	cmdline_fixed_string_t name;
2463 	uint16_t port_id;
2464 	uint16_t queue_id;
2465 	uint32_t free_cnt;
2466 };
2467 
2468 static void
2469 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2470 			     __rte_unused struct cmdline *cl,
2471 			     __rte_unused void *data)
2472 {
2473 	struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2474 	uint16_t port_id = res->port_id;
2475 	uint16_t queue_id = res->queue_id;
2476 	uint32_t free_cnt = res->free_cnt;
2477 	struct rte_eth_txq_info qinfo;
2478 	int ret;
2479 
2480 	if (test_done == 0) {
2481 		fprintf(stderr, "Please stop forwarding first\n");
2482 		return;
2483 	}
2484 
2485 	if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2486 		fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2487 			port_id, queue_id);
2488 		return;
2489 	}
2490 
2491 	if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2492 		fprintf(stderr, "Tx queue %u not started\n", queue_id);
2493 		return;
2494 	}
2495 
2496 	ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2497 	if (ret < 0) {
2498 		fprintf(stderr,
2499 			"Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2500 			port_id, queue_id, strerror(-ret), ret);
2501 		return;
2502 	}
2503 
2504 	printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2505 	       port_id, queue_id, ret);
2506 }
2507 
2508 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2509 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2510 				 "port");
2511 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2512 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2513 				 "cleanup");
2514 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2515 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2516 			      RTE_UINT16);
2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2518 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2519 				 "txq");
2520 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2521 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2522 			      RTE_UINT16);
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2524 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2525 			      RTE_UINT32);
2526 
2527 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2528 	.f = cmd_cleanup_txq_mbufs_parsed,
2529 	.data = NULL,
2530 	.help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2531 	.tokens = {
2532 		(void *)&cmd_cleanup_txq_mbufs_port,
2533 		(void *)&cmd_cleanup_txq_mbufs_cleanup,
2534 		(void *)&cmd_cleanup_txq_mbufs_port_id,
2535 		(void *)&cmd_cleanup_txq_mbufs_txq,
2536 		(void *)&cmd_cleanup_txq_mbufs_queue_id,
2537 		(void *)&cmd_cleanup_txq_mbufs_free_cnt,
2538 		NULL,
2539 	},
2540 };
2541 
2542 /* *** configure port rxq/txq ring size *** */
2543 struct cmd_config_rxtx_ring_size {
2544 	cmdline_fixed_string_t port;
2545 	cmdline_fixed_string_t config;
2546 	portid_t portid;
2547 	cmdline_fixed_string_t rxtxq;
2548 	uint16_t qid;
2549 	cmdline_fixed_string_t rsize;
2550 	uint16_t size;
2551 };
2552 
2553 static void
2554 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2555 				 __rte_unused struct cmdline *cl,
2556 				 __rte_unused void *data)
2557 {
2558 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2559 	struct rte_port *port;
2560 	uint8_t isrx;
2561 
2562 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2563 		return;
2564 
2565 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2566 		fprintf(stderr, "Invalid port id\n");
2567 		return;
2568 	}
2569 
2570 	port = &ports[res->portid];
2571 
2572 	if (!strcmp(res->rxtxq, "rxq"))
2573 		isrx = 1;
2574 	else if (!strcmp(res->rxtxq, "txq"))
2575 		isrx = 0;
2576 	else {
2577 		fprintf(stderr, "Unknown parameter\n");
2578 		return;
2579 	}
2580 
2581 	if (isrx && rx_queue_id_is_invalid(res->qid))
2582 		return;
2583 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2584 		return;
2585 
2586 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2587 		fprintf(stderr,
2588 			"Invalid rx ring_size, must > rx_free_thresh: %d\n",
2589 			rx_free_thresh);
2590 		return;
2591 	}
2592 
2593 	if (isrx)
2594 		port->nb_rx_desc[res->qid] = res->size;
2595 	else
2596 		port->nb_tx_desc[res->qid] = res->size;
2597 
2598 	cmd_reconfig_device_queue(res->portid, 0, 1);
2599 }
2600 
2601 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2602 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2603 				 port, "port");
2604 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2605 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2606 				 config, "config");
2607 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2608 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 				 portid, RTE_UINT16);
2610 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2611 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 				 rxtxq, "rxq#txq");
2613 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2614 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 			      qid, RTE_UINT16);
2616 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2617 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2618 				 rsize, "ring_size");
2619 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2620 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 			      size, RTE_UINT16);
2622 
2623 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2624 	.f = cmd_config_rxtx_ring_size_parsed,
2625 	.data = NULL,
2626 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2627 	.tokens = {
2628 		(void *)&cmd_config_rxtx_ring_size_port,
2629 		(void *)&cmd_config_rxtx_ring_size_config,
2630 		(void *)&cmd_config_rxtx_ring_size_portid,
2631 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2632 		(void *)&cmd_config_rxtx_ring_size_qid,
2633 		(void *)&cmd_config_rxtx_ring_size_rsize,
2634 		(void *)&cmd_config_rxtx_ring_size_size,
2635 		NULL,
2636 	},
2637 };
2638 
2639 /* *** configure port rxq/txq start/stop *** */
2640 struct cmd_config_rxtx_queue {
2641 	cmdline_fixed_string_t port;
2642 	portid_t portid;
2643 	cmdline_fixed_string_t rxtxq;
2644 	uint16_t qid;
2645 	cmdline_fixed_string_t opname;
2646 };
2647 
2648 static void
2649 cmd_config_rxtx_queue_parsed(void *parsed_result,
2650 			__rte_unused struct cmdline *cl,
2651 			__rte_unused void *data)
2652 {
2653 	struct cmd_config_rxtx_queue *res = parsed_result;
2654 	uint8_t isrx;
2655 	uint8_t isstart;
2656 	int ret = 0;
2657 
2658 	if (test_done == 0) {
2659 		fprintf(stderr, "Please stop forwarding first\n");
2660 		return;
2661 	}
2662 
2663 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2664 		return;
2665 
2666 	if (port_is_started(res->portid) != 1) {
2667 		fprintf(stderr, "Please start port %u first\n", res->portid);
2668 		return;
2669 	}
2670 
2671 	if (!strcmp(res->rxtxq, "rxq"))
2672 		isrx = 1;
2673 	else if (!strcmp(res->rxtxq, "txq"))
2674 		isrx = 0;
2675 	else {
2676 		fprintf(stderr, "Unknown parameter\n");
2677 		return;
2678 	}
2679 
2680 	if (isrx && rx_queue_id_is_invalid(res->qid))
2681 		return;
2682 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2683 		return;
2684 
2685 	if (!strcmp(res->opname, "start"))
2686 		isstart = 1;
2687 	else if (!strcmp(res->opname, "stop"))
2688 		isstart = 0;
2689 	else {
2690 		fprintf(stderr, "Unknown parameter\n");
2691 		return;
2692 	}
2693 
2694 	if (isstart && isrx)
2695 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2696 	else if (!isstart && isrx)
2697 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2698 	else if (isstart && !isrx)
2699 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2700 	else
2701 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2702 
2703 	if (ret == -ENOTSUP)
2704 		fprintf(stderr, "Function not supported in PMD\n");
2705 }
2706 
2707 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2708 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2709 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2710 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2711 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2712 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2713 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2714 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2715 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2716 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2717 						"start#stop");
2718 
2719 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2720 	.f = cmd_config_rxtx_queue_parsed,
2721 	.data = NULL,
2722 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2723 	.tokens = {
2724 		(void *)&cmd_config_rxtx_queue_port,
2725 		(void *)&cmd_config_rxtx_queue_portid,
2726 		(void *)&cmd_config_rxtx_queue_rxtxq,
2727 		(void *)&cmd_config_rxtx_queue_qid,
2728 		(void *)&cmd_config_rxtx_queue_opname,
2729 		NULL,
2730 	},
2731 };
2732 
2733 /* *** configure port rxq/txq deferred start on/off *** */
2734 struct cmd_config_deferred_start_rxtx_queue {
2735 	cmdline_fixed_string_t port;
2736 	portid_t port_id;
2737 	cmdline_fixed_string_t rxtxq;
2738 	uint16_t qid;
2739 	cmdline_fixed_string_t opname;
2740 	cmdline_fixed_string_t state;
2741 };
2742 
2743 static void
2744 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2745 			__rte_unused struct cmdline *cl,
2746 			__rte_unused void *data)
2747 {
2748 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2749 	struct rte_port *port;
2750 	uint8_t isrx;
2751 	uint8_t ison;
2752 	uint8_t needreconfig = 0;
2753 
2754 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2755 		return;
2756 
2757 	if (port_is_started(res->port_id) != 0) {
2758 		fprintf(stderr, "Please stop port %u first\n", res->port_id);
2759 		return;
2760 	}
2761 
2762 	port = &ports[res->port_id];
2763 
2764 	isrx = !strcmp(res->rxtxq, "rxq");
2765 
2766 	if (isrx && rx_queue_id_is_invalid(res->qid))
2767 		return;
2768 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2769 		return;
2770 
2771 	ison = !strcmp(res->state, "on");
2772 
2773 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2774 		port->rx_conf[res->qid].rx_deferred_start = ison;
2775 		needreconfig = 1;
2776 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2777 		port->tx_conf[res->qid].tx_deferred_start = ison;
2778 		needreconfig = 1;
2779 	}
2780 
2781 	if (needreconfig)
2782 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2783 }
2784 
2785 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2786 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2787 						port, "port");
2788 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2789 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2790 						port_id, RTE_UINT16);
2791 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2792 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 						rxtxq, "rxq#txq");
2794 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2795 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2796 						qid, RTE_UINT16);
2797 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2798 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2799 						opname, "deferred_start");
2800 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2801 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 						state, "on#off");
2803 
2804 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2805 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2806 	.data = NULL,
2807 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2808 	.tokens = {
2809 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2810 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2811 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2812 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2813 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2814 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2815 		NULL,
2816 	},
2817 };
2818 
2819 /* *** configure port rxq/txq setup *** */
2820 struct cmd_setup_rxtx_queue {
2821 	cmdline_fixed_string_t port;
2822 	portid_t portid;
2823 	cmdline_fixed_string_t rxtxq;
2824 	uint16_t qid;
2825 	cmdline_fixed_string_t setup;
2826 };
2827 
2828 /* Common CLI fields for queue setup */
2829 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2830 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2831 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2832 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2833 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2834 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2835 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2836 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2837 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2838 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2839 
2840 static void
2841 cmd_setup_rxtx_queue_parsed(
2842 	void *parsed_result,
2843 	__rte_unused struct cmdline *cl,
2844 	__rte_unused void *data)
2845 {
2846 	struct cmd_setup_rxtx_queue *res = parsed_result;
2847 	struct rte_port *port;
2848 	struct rte_mempool *mp;
2849 	unsigned int socket_id;
2850 	uint8_t isrx = 0;
2851 	int ret;
2852 
2853 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2854 		return;
2855 
2856 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2857 		fprintf(stderr, "Invalid port id\n");
2858 		return;
2859 	}
2860 
2861 	if (!strcmp(res->rxtxq, "rxq"))
2862 		isrx = 1;
2863 	else if (!strcmp(res->rxtxq, "txq"))
2864 		isrx = 0;
2865 	else {
2866 		fprintf(stderr, "Unknown parameter\n");
2867 		return;
2868 	}
2869 
2870 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2871 		fprintf(stderr, "Invalid rx queue\n");
2872 		return;
2873 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2874 		fprintf(stderr, "Invalid tx queue\n");
2875 		return;
2876 	}
2877 
2878 	port = &ports[res->portid];
2879 	if (isrx) {
2880 		socket_id = rxring_numa[res->portid];
2881 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2882 			socket_id = port->socket_id;
2883 
2884 		mp = mbuf_pool_find(socket_id, 0);
2885 		if (mp == NULL) {
2886 			fprintf(stderr,
2887 				"Failed to setup RX queue: No mempool allocation on the socket %d\n",
2888 				rxring_numa[res->portid]);
2889 			return;
2890 		}
2891 		ret = rx_queue_setup(res->portid,
2892 				     res->qid,
2893 				     port->nb_rx_desc[res->qid],
2894 				     socket_id,
2895 				     &port->rx_conf[res->qid],
2896 				     mp);
2897 		if (ret)
2898 			fprintf(stderr, "Failed to setup RX queue\n");
2899 	} else {
2900 		socket_id = txring_numa[res->portid];
2901 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2902 			socket_id = port->socket_id;
2903 
2904 		if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2905 			fprintf(stderr,
2906 				"Failed to setup TX queue: not enough descriptors\n");
2907 			return;
2908 		}
2909 		ret = rte_eth_tx_queue_setup(res->portid,
2910 					     res->qid,
2911 					     port->nb_tx_desc[res->qid],
2912 					     socket_id,
2913 					     &port->tx_conf[res->qid]);
2914 		if (ret)
2915 			fprintf(stderr, "Failed to setup TX queue\n");
2916 	}
2917 }
2918 
2919 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2920 	.f = cmd_setup_rxtx_queue_parsed,
2921 	.data = NULL,
2922 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2923 	.tokens = {
2924 		(void *)&cmd_setup_rxtx_queue_port,
2925 		(void *)&cmd_setup_rxtx_queue_portid,
2926 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2927 		(void *)&cmd_setup_rxtx_queue_qid,
2928 		(void *)&cmd_setup_rxtx_queue_setup,
2929 		NULL,
2930 	},
2931 };
2932 
2933 
2934 /* *** Configure RSS RETA *** */
2935 struct cmd_config_rss_reta {
2936 	cmdline_fixed_string_t port;
2937 	cmdline_fixed_string_t keyword;
2938 	portid_t port_id;
2939 	cmdline_fixed_string_t name;
2940 	cmdline_fixed_string_t list_name;
2941 	cmdline_fixed_string_t list_of_items;
2942 };
2943 
2944 static int
2945 parse_reta_config(const char *str,
2946 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2947 		  uint16_t nb_entries)
2948 {
2949 	int i;
2950 	unsigned size;
2951 	uint16_t hash_index, idx, shift;
2952 	uint16_t nb_queue;
2953 	char s[256];
2954 	const char *p, *p0 = str;
2955 	char *end;
2956 	enum fieldnames {
2957 		FLD_HASH_INDEX = 0,
2958 		FLD_QUEUE,
2959 		_NUM_FLD
2960 	};
2961 	unsigned long int_fld[_NUM_FLD];
2962 	char *str_fld[_NUM_FLD];
2963 
2964 	while ((p = strchr(p0,'(')) != NULL) {
2965 		++p;
2966 		if((p0 = strchr(p,')')) == NULL)
2967 			return -1;
2968 
2969 		size = p0 - p;
2970 		if(size >= sizeof(s))
2971 			return -1;
2972 
2973 		snprintf(s, sizeof(s), "%.*s", size, p);
2974 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2975 			return -1;
2976 		for (i = 0; i < _NUM_FLD; i++) {
2977 			errno = 0;
2978 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2979 			if (errno != 0 || end == str_fld[i] ||
2980 					int_fld[i] > 65535)
2981 				return -1;
2982 		}
2983 
2984 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2985 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2986 
2987 		if (hash_index >= nb_entries) {
2988 			fprintf(stderr, "Invalid RETA hash index=%d\n",
2989 				hash_index);
2990 			return -1;
2991 		}
2992 
2993 		idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2994 		shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2995 		reta_conf[idx].mask |= (1ULL << shift);
2996 		reta_conf[idx].reta[shift] = nb_queue;
2997 	}
2998 
2999 	return 0;
3000 }
3001 
3002 static void
3003 cmd_set_rss_reta_parsed(void *parsed_result,
3004 			__rte_unused struct cmdline *cl,
3005 			__rte_unused void *data)
3006 {
3007 	int ret;
3008 	struct rte_eth_dev_info dev_info;
3009 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3010 	struct cmd_config_rss_reta *res = parsed_result;
3011 
3012 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3013 	if (ret != 0)
3014 		return;
3015 
3016 	if (dev_info.reta_size == 0) {
3017 		fprintf(stderr,
3018 			"Redirection table size is 0 which is invalid for RSS\n");
3019 		return;
3020 	} else
3021 		printf("The reta size of port %d is %u\n",
3022 			res->port_id, dev_info.reta_size);
3023 	if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3024 		fprintf(stderr,
3025 			"Currently do not support more than %u entries of redirection table\n",
3026 			RTE_ETH_RSS_RETA_SIZE_512);
3027 		return;
3028 	}
3029 
3030 	memset(reta_conf, 0, sizeof(reta_conf));
3031 	if (!strcmp(res->list_name, "reta")) {
3032 		if (parse_reta_config(res->list_of_items, reta_conf,
3033 						dev_info.reta_size)) {
3034 			fprintf(stderr,
3035 				"Invalid RSS Redirection Table config entered\n");
3036 			return;
3037 		}
3038 		ret = rte_eth_dev_rss_reta_update(res->port_id,
3039 				reta_conf, dev_info.reta_size);
3040 		if (ret != 0)
3041 			fprintf(stderr,
3042 				"Bad redirection table parameter, return code = %d\n",
3043 				ret);
3044 	}
3045 }
3046 
3047 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3048 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3049 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3050 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3051 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3052 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3053 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3054 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3055 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3056 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3057 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3058         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3059                                  NULL);
3060 cmdline_parse_inst_t cmd_config_rss_reta = {
3061 	.f = cmd_set_rss_reta_parsed,
3062 	.data = NULL,
3063 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3064 	.tokens = {
3065 		(void *)&cmd_config_rss_reta_port,
3066 		(void *)&cmd_config_rss_reta_keyword,
3067 		(void *)&cmd_config_rss_reta_port_id,
3068 		(void *)&cmd_config_rss_reta_name,
3069 		(void *)&cmd_config_rss_reta_list_name,
3070 		(void *)&cmd_config_rss_reta_list_of_items,
3071 		NULL,
3072 	},
3073 };
3074 
3075 /* *** SHOW PORT RETA INFO *** */
3076 struct cmd_showport_reta {
3077 	cmdline_fixed_string_t show;
3078 	cmdline_fixed_string_t port;
3079 	portid_t port_id;
3080 	cmdline_fixed_string_t rss;
3081 	cmdline_fixed_string_t reta;
3082 	uint16_t size;
3083 	cmdline_fixed_string_t list_of_items;
3084 };
3085 
3086 static int
3087 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3088 			   uint16_t nb_entries,
3089 			   char *str)
3090 {
3091 	uint32_t size;
3092 	const char *p, *p0 = str;
3093 	char s[256];
3094 	char *end;
3095 	char *str_fld[8];
3096 	uint16_t i;
3097 	uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3098 			RTE_ETH_RETA_GROUP_SIZE;
3099 	int ret;
3100 
3101 	p = strchr(p0, '(');
3102 	if (p == NULL)
3103 		return -1;
3104 	p++;
3105 	p0 = strchr(p, ')');
3106 	if (p0 == NULL)
3107 		return -1;
3108 	size = p0 - p;
3109 	if (size >= sizeof(s)) {
3110 		fprintf(stderr,
3111 			"The string size exceeds the internal buffer size\n");
3112 		return -1;
3113 	}
3114 	snprintf(s, sizeof(s), "%.*s", size, p);
3115 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3116 	if (ret <= 0 || ret != num) {
3117 		fprintf(stderr,
3118 			"The bits of masks do not match the number of reta entries: %u\n",
3119 			num);
3120 		return -1;
3121 	}
3122 	for (i = 0; i < ret; i++)
3123 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3124 
3125 	return 0;
3126 }
3127 
3128 static void
3129 cmd_showport_reta_parsed(void *parsed_result,
3130 			 __rte_unused struct cmdline *cl,
3131 			 __rte_unused void *data)
3132 {
3133 	struct cmd_showport_reta *res = parsed_result;
3134 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3135 	struct rte_eth_dev_info dev_info;
3136 	uint16_t max_reta_size;
3137 	int ret;
3138 
3139 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3140 	if (ret != 0)
3141 		return;
3142 
3143 	max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3144 	if (res->size == 0 || res->size > max_reta_size) {
3145 		fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3146 			res->size, max_reta_size);
3147 		return;
3148 	}
3149 
3150 	memset(reta_conf, 0, sizeof(reta_conf));
3151 	if (showport_parse_reta_config(reta_conf, res->size,
3152 				res->list_of_items) < 0) {
3153 		fprintf(stderr, "Invalid string: %s for reta masks\n",
3154 			res->list_of_items);
3155 		return;
3156 	}
3157 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3158 }
3159 
3160 cmdline_parse_token_string_t cmd_showport_reta_show =
3161 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3162 cmdline_parse_token_string_t cmd_showport_reta_port =
3163 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3164 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3165 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3166 cmdline_parse_token_string_t cmd_showport_reta_rss =
3167 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3168 cmdline_parse_token_string_t cmd_showport_reta_reta =
3169 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3170 cmdline_parse_token_num_t cmd_showport_reta_size =
3171 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3172 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3173 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3174 					list_of_items, NULL);
3175 
3176 cmdline_parse_inst_t cmd_showport_reta = {
3177 	.f = cmd_showport_reta_parsed,
3178 	.data = NULL,
3179 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3180 	.tokens = {
3181 		(void *)&cmd_showport_reta_show,
3182 		(void *)&cmd_showport_reta_port,
3183 		(void *)&cmd_showport_reta_port_id,
3184 		(void *)&cmd_showport_reta_rss,
3185 		(void *)&cmd_showport_reta_reta,
3186 		(void *)&cmd_showport_reta_size,
3187 		(void *)&cmd_showport_reta_list_of_items,
3188 		NULL,
3189 	},
3190 };
3191 
3192 /* *** Show RSS hash configuration *** */
3193 struct cmd_showport_rss_hash {
3194 	cmdline_fixed_string_t show;
3195 	cmdline_fixed_string_t port;
3196 	portid_t port_id;
3197 	cmdline_fixed_string_t rss_hash;
3198 	cmdline_fixed_string_t rss_type;
3199 	cmdline_fixed_string_t key; /* optional argument */
3200 };
3201 
3202 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3203 				__rte_unused struct cmdline *cl,
3204 				void *show_rss_key)
3205 {
3206 	struct cmd_showport_rss_hash *res = parsed_result;
3207 
3208 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3209 }
3210 
3211 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3212 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3213 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3214 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3215 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3216 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3217 				 RTE_UINT16);
3218 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3219 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3220 				 "rss-hash");
3221 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3222 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3223 
3224 cmdline_parse_inst_t cmd_showport_rss_hash = {
3225 	.f = cmd_showport_rss_hash_parsed,
3226 	.data = NULL,
3227 	.help_str = "show port <port_id> rss-hash",
3228 	.tokens = {
3229 		(void *)&cmd_showport_rss_hash_show,
3230 		(void *)&cmd_showport_rss_hash_port,
3231 		(void *)&cmd_showport_rss_hash_port_id,
3232 		(void *)&cmd_showport_rss_hash_rss_hash,
3233 		NULL,
3234 	},
3235 };
3236 
3237 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3238 	.f = cmd_showport_rss_hash_parsed,
3239 	.data = (void *)1,
3240 	.help_str = "show port <port_id> rss-hash key",
3241 	.tokens = {
3242 		(void *)&cmd_showport_rss_hash_show,
3243 		(void *)&cmd_showport_rss_hash_port,
3244 		(void *)&cmd_showport_rss_hash_port_id,
3245 		(void *)&cmd_showport_rss_hash_rss_hash,
3246 		(void *)&cmd_showport_rss_hash_rss_key,
3247 		NULL,
3248 	},
3249 };
3250 
3251 /* *** Configure DCB *** */
3252 struct cmd_config_dcb {
3253 	cmdline_fixed_string_t port;
3254 	cmdline_fixed_string_t config;
3255 	portid_t port_id;
3256 	cmdline_fixed_string_t dcb;
3257 	cmdline_fixed_string_t vt;
3258 	cmdline_fixed_string_t vt_en;
3259 	uint8_t num_tcs;
3260 	cmdline_fixed_string_t pfc;
3261 	cmdline_fixed_string_t pfc_en;
3262 };
3263 
3264 static void
3265 cmd_config_dcb_parsed(void *parsed_result,
3266                         __rte_unused struct cmdline *cl,
3267                         __rte_unused void *data)
3268 {
3269 	struct cmd_config_dcb *res = parsed_result;
3270 	struct rte_eth_dcb_info dcb_info;
3271 	portid_t port_id = res->port_id;
3272 	struct rte_port *port;
3273 	uint8_t pfc_en;
3274 	int ret;
3275 
3276 	port = &ports[port_id];
3277 	/** Check if the port is not started **/
3278 	if (port->port_status != RTE_PORT_STOPPED) {
3279 		fprintf(stderr, "Please stop port %d first\n", port_id);
3280 		return;
3281 	}
3282 
3283 	if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3284 		fprintf(stderr,
3285 			"The invalid number of traffic class, only 4 or 8 allowed.\n");
3286 		return;
3287 	}
3288 
3289 	if (nb_fwd_lcores < res->num_tcs) {
3290 		fprintf(stderr,
3291 			"nb_cores shouldn't be less than number of TCs.\n");
3292 		return;
3293 	}
3294 
3295 	/* Check whether the port supports the report of DCB info. */
3296 	ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3297 	if (ret == -ENOTSUP) {
3298 		fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3299 		return;
3300 	}
3301 
3302 	if (!strncmp(res->pfc_en, "on", 2))
3303 		pfc_en = 1;
3304 	else
3305 		pfc_en = 0;
3306 
3307 	/* DCB in VT mode */
3308 	if (!strncmp(res->vt_en, "on", 2))
3309 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3310 				(enum rte_eth_nb_tcs)res->num_tcs,
3311 				pfc_en);
3312 	else
3313 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3314 				(enum rte_eth_nb_tcs)res->num_tcs,
3315 				pfc_en);
3316 	if (ret != 0) {
3317 		fprintf(stderr, "Cannot initialize network ports.\n");
3318 		return;
3319 	}
3320 
3321 	fwd_config_setup();
3322 
3323 	cmd_reconfig_device_queue(port_id, 1, 1);
3324 }
3325 
3326 cmdline_parse_token_string_t cmd_config_dcb_port =
3327         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3328 cmdline_parse_token_string_t cmd_config_dcb_config =
3329         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3330 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3331 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3332 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3333         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3334 cmdline_parse_token_string_t cmd_config_dcb_vt =
3335         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3336 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3337         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3338 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3339 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3340 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3341         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3342 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3343         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3344 
3345 cmdline_parse_inst_t cmd_config_dcb = {
3346 	.f = cmd_config_dcb_parsed,
3347 	.data = NULL,
3348 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3349 	.tokens = {
3350 		(void *)&cmd_config_dcb_port,
3351 		(void *)&cmd_config_dcb_config,
3352 		(void *)&cmd_config_dcb_port_id,
3353 		(void *)&cmd_config_dcb_dcb,
3354 		(void *)&cmd_config_dcb_vt,
3355 		(void *)&cmd_config_dcb_vt_en,
3356 		(void *)&cmd_config_dcb_num_tcs,
3357 		(void *)&cmd_config_dcb_pfc,
3358 		(void *)&cmd_config_dcb_pfc_en,
3359                 NULL,
3360         },
3361 };
3362 
3363 /* *** configure number of packets per burst *** */
3364 struct cmd_config_burst {
3365 	cmdline_fixed_string_t port;
3366 	cmdline_fixed_string_t keyword;
3367 	cmdline_fixed_string_t all;
3368 	cmdline_fixed_string_t name;
3369 	uint16_t value;
3370 };
3371 
3372 static void
3373 cmd_config_burst_parsed(void *parsed_result,
3374 			__rte_unused struct cmdline *cl,
3375 			__rte_unused void *data)
3376 {
3377 	struct cmd_config_burst *res = parsed_result;
3378 	struct rte_eth_dev_info dev_info;
3379 	uint16_t rec_nb_pkts;
3380 	int ret;
3381 
3382 	if (!all_ports_stopped()) {
3383 		fprintf(stderr, "Please stop all ports first\n");
3384 		return;
3385 	}
3386 
3387 	if (!strcmp(res->name, "burst")) {
3388 		if (res->value == 0) {
3389 			/* If user gives a value of zero, query the PMD for
3390 			 * its recommended Rx burst size. Testpmd uses a single
3391 			 * size for all ports, so assume all ports are the same
3392 			 * NIC model and use the values from Port 0.
3393 			 */
3394 			ret = eth_dev_info_get_print_err(0, &dev_info);
3395 			if (ret != 0)
3396 				return;
3397 
3398 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3399 
3400 			if (rec_nb_pkts == 0) {
3401 				printf("PMD does not recommend a burst size.\n"
3402 					"User provided value must be between"
3403 					" 1 and %d\n", MAX_PKT_BURST);
3404 				return;
3405 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3406 				printf("PMD recommended burst size of %d"
3407 					" exceeds maximum value of %d\n",
3408 					rec_nb_pkts, MAX_PKT_BURST);
3409 				return;
3410 			}
3411 			printf("Using PMD-provided burst value of %d\n",
3412 				rec_nb_pkts);
3413 			nb_pkt_per_burst = rec_nb_pkts;
3414 		} else if (res->value > MAX_PKT_BURST) {
3415 			fprintf(stderr, "burst must be >= 1 && <= %d\n",
3416 				MAX_PKT_BURST);
3417 			return;
3418 		} else
3419 			nb_pkt_per_burst = res->value;
3420 	} else {
3421 		fprintf(stderr, "Unknown parameter\n");
3422 		return;
3423 	}
3424 
3425 	init_port_config();
3426 
3427 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3428 }
3429 
3430 cmdline_parse_token_string_t cmd_config_burst_port =
3431 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3432 cmdline_parse_token_string_t cmd_config_burst_keyword =
3433 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3434 cmdline_parse_token_string_t cmd_config_burst_all =
3435 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3436 cmdline_parse_token_string_t cmd_config_burst_name =
3437 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3438 cmdline_parse_token_num_t cmd_config_burst_value =
3439 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3440 
3441 cmdline_parse_inst_t cmd_config_burst = {
3442 	.f = cmd_config_burst_parsed,
3443 	.data = NULL,
3444 	.help_str = "port config all burst <value>",
3445 	.tokens = {
3446 		(void *)&cmd_config_burst_port,
3447 		(void *)&cmd_config_burst_keyword,
3448 		(void *)&cmd_config_burst_all,
3449 		(void *)&cmd_config_burst_name,
3450 		(void *)&cmd_config_burst_value,
3451 		NULL,
3452 	},
3453 };
3454 
3455 /* *** configure rx/tx queues *** */
3456 struct cmd_config_thresh {
3457 	cmdline_fixed_string_t port;
3458 	cmdline_fixed_string_t keyword;
3459 	cmdline_fixed_string_t all;
3460 	cmdline_fixed_string_t name;
3461 	uint8_t value;
3462 };
3463 
3464 static void
3465 cmd_config_thresh_parsed(void *parsed_result,
3466 			__rte_unused struct cmdline *cl,
3467 			__rte_unused void *data)
3468 {
3469 	struct cmd_config_thresh *res = parsed_result;
3470 
3471 	if (!all_ports_stopped()) {
3472 		fprintf(stderr, "Please stop all ports first\n");
3473 		return;
3474 	}
3475 
3476 	if (!strcmp(res->name, "txpt"))
3477 		tx_pthresh = res->value;
3478 	else if(!strcmp(res->name, "txht"))
3479 		tx_hthresh = res->value;
3480 	else if(!strcmp(res->name, "txwt"))
3481 		tx_wthresh = res->value;
3482 	else if(!strcmp(res->name, "rxpt"))
3483 		rx_pthresh = res->value;
3484 	else if(!strcmp(res->name, "rxht"))
3485 		rx_hthresh = res->value;
3486 	else if(!strcmp(res->name, "rxwt"))
3487 		rx_wthresh = res->value;
3488 	else {
3489 		fprintf(stderr, "Unknown parameter\n");
3490 		return;
3491 	}
3492 
3493 	init_port_config();
3494 
3495 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3496 }
3497 
3498 cmdline_parse_token_string_t cmd_config_thresh_port =
3499 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3500 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3501 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3502 cmdline_parse_token_string_t cmd_config_thresh_all =
3503 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3504 cmdline_parse_token_string_t cmd_config_thresh_name =
3505 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3506 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3507 cmdline_parse_token_num_t cmd_config_thresh_value =
3508 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3509 
3510 cmdline_parse_inst_t cmd_config_thresh = {
3511 	.f = cmd_config_thresh_parsed,
3512 	.data = NULL,
3513 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3514 	.tokens = {
3515 		(void *)&cmd_config_thresh_port,
3516 		(void *)&cmd_config_thresh_keyword,
3517 		(void *)&cmd_config_thresh_all,
3518 		(void *)&cmd_config_thresh_name,
3519 		(void *)&cmd_config_thresh_value,
3520 		NULL,
3521 	},
3522 };
3523 
3524 /* *** configure free/rs threshold *** */
3525 struct cmd_config_threshold {
3526 	cmdline_fixed_string_t port;
3527 	cmdline_fixed_string_t keyword;
3528 	cmdline_fixed_string_t all;
3529 	cmdline_fixed_string_t name;
3530 	uint16_t value;
3531 };
3532 
3533 static void
3534 cmd_config_threshold_parsed(void *parsed_result,
3535 			__rte_unused struct cmdline *cl,
3536 			__rte_unused void *data)
3537 {
3538 	struct cmd_config_threshold *res = parsed_result;
3539 
3540 	if (!all_ports_stopped()) {
3541 		fprintf(stderr, "Please stop all ports first\n");
3542 		return;
3543 	}
3544 
3545 	if (!strcmp(res->name, "txfreet"))
3546 		tx_free_thresh = res->value;
3547 	else if (!strcmp(res->name, "txrst"))
3548 		tx_rs_thresh = res->value;
3549 	else if (!strcmp(res->name, "rxfreet"))
3550 		rx_free_thresh = res->value;
3551 	else {
3552 		fprintf(stderr, "Unknown parameter\n");
3553 		return;
3554 	}
3555 
3556 	init_port_config();
3557 
3558 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3559 }
3560 
3561 cmdline_parse_token_string_t cmd_config_threshold_port =
3562 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3563 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3564 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3565 								"config");
3566 cmdline_parse_token_string_t cmd_config_threshold_all =
3567 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3568 cmdline_parse_token_string_t cmd_config_threshold_name =
3569 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3570 						"txfreet#txrst#rxfreet");
3571 cmdline_parse_token_num_t cmd_config_threshold_value =
3572 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3573 
3574 cmdline_parse_inst_t cmd_config_threshold = {
3575 	.f = cmd_config_threshold_parsed,
3576 	.data = NULL,
3577 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3578 	.tokens = {
3579 		(void *)&cmd_config_threshold_port,
3580 		(void *)&cmd_config_threshold_keyword,
3581 		(void *)&cmd_config_threshold_all,
3582 		(void *)&cmd_config_threshold_name,
3583 		(void *)&cmd_config_threshold_value,
3584 		NULL,
3585 	},
3586 };
3587 
3588 /* *** stop *** */
3589 struct cmd_stop_result {
3590 	cmdline_fixed_string_t stop;
3591 };
3592 
3593 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3594 			    __rte_unused struct cmdline *cl,
3595 			    __rte_unused void *data)
3596 {
3597 	stop_packet_forwarding();
3598 }
3599 
3600 cmdline_parse_token_string_t cmd_stop_stop =
3601 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3602 
3603 cmdline_parse_inst_t cmd_stop = {
3604 	.f = cmd_stop_parsed,
3605 	.data = NULL,
3606 	.help_str = "stop: Stop packet forwarding",
3607 	.tokens = {
3608 		(void *)&cmd_stop_stop,
3609 		NULL,
3610 	},
3611 };
3612 
3613 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3614 
3615 unsigned int
3616 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3617 		unsigned int *parsed_items, int check_unique_values)
3618 {
3619 	unsigned int nb_item;
3620 	unsigned int value;
3621 	unsigned int i;
3622 	unsigned int j;
3623 	int value_ok;
3624 	char c;
3625 
3626 	/*
3627 	 * First parse all items in the list and store their value.
3628 	 */
3629 	value = 0;
3630 	nb_item = 0;
3631 	value_ok = 0;
3632 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3633 		c = str[i];
3634 		if ((c >= '0') && (c <= '9')) {
3635 			value = (unsigned int) (value * 10 + (c - '0'));
3636 			value_ok = 1;
3637 			continue;
3638 		}
3639 		if (c != ',') {
3640 			fprintf(stderr, "character %c is not a decimal digit\n", c);
3641 			return 0;
3642 		}
3643 		if (! value_ok) {
3644 			fprintf(stderr, "No valid value before comma\n");
3645 			return 0;
3646 		}
3647 		if (nb_item < max_items) {
3648 			parsed_items[nb_item] = value;
3649 			value_ok = 0;
3650 			value = 0;
3651 		}
3652 		nb_item++;
3653 	}
3654 	if (nb_item >= max_items) {
3655 		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3656 			item_name, nb_item + 1, max_items);
3657 		return 0;
3658 	}
3659 	parsed_items[nb_item++] = value;
3660 	if (! check_unique_values)
3661 		return nb_item;
3662 
3663 	/*
3664 	 * Then, check that all values in the list are different.
3665 	 * No optimization here...
3666 	 */
3667 	for (i = 0; i < nb_item; i++) {
3668 		for (j = i + 1; j < nb_item; j++) {
3669 			if (parsed_items[j] == parsed_items[i]) {
3670 				fprintf(stderr,
3671 					"duplicated %s %u at index %u and %u\n",
3672 					item_name, parsed_items[i], i, j);
3673 				return 0;
3674 			}
3675 		}
3676 	}
3677 	return nb_item;
3678 }
3679 
3680 struct cmd_set_list_result {
3681 	cmdline_fixed_string_t cmd_keyword;
3682 	cmdline_fixed_string_t list_name;
3683 	cmdline_fixed_string_t list_of_items;
3684 };
3685 
3686 static void cmd_set_list_parsed(void *parsed_result,
3687 				__rte_unused struct cmdline *cl,
3688 				__rte_unused void *data)
3689 {
3690 	struct cmd_set_list_result *res;
3691 	union {
3692 		unsigned int lcorelist[RTE_MAX_LCORE];
3693 		unsigned int portlist[RTE_MAX_ETHPORTS];
3694 	} parsed_items;
3695 	unsigned int nb_item;
3696 
3697 	if (test_done == 0) {
3698 		fprintf(stderr, "Please stop forwarding first\n");
3699 		return;
3700 	}
3701 
3702 	res = parsed_result;
3703 	if (!strcmp(res->list_name, "corelist")) {
3704 		nb_item = parse_item_list(res->list_of_items, "core",
3705 					  RTE_MAX_LCORE,
3706 					  parsed_items.lcorelist, 1);
3707 		if (nb_item > 0) {
3708 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3709 			fwd_config_setup();
3710 		}
3711 		return;
3712 	}
3713 	if (!strcmp(res->list_name, "portlist")) {
3714 		nb_item = parse_item_list(res->list_of_items, "port",
3715 					  RTE_MAX_ETHPORTS,
3716 					  parsed_items.portlist, 1);
3717 		if (nb_item > 0) {
3718 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3719 			fwd_config_setup();
3720 		}
3721 	}
3722 }
3723 
3724 cmdline_parse_token_string_t cmd_set_list_keyword =
3725 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3726 				 "set");
3727 cmdline_parse_token_string_t cmd_set_list_name =
3728 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3729 				 "corelist#portlist");
3730 cmdline_parse_token_string_t cmd_set_list_of_items =
3731 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3732 				 NULL);
3733 
3734 cmdline_parse_inst_t cmd_set_fwd_list = {
3735 	.f = cmd_set_list_parsed,
3736 	.data = NULL,
3737 	.help_str = "set corelist|portlist <list0[,list1]*>",
3738 	.tokens = {
3739 		(void *)&cmd_set_list_keyword,
3740 		(void *)&cmd_set_list_name,
3741 		(void *)&cmd_set_list_of_items,
3742 		NULL,
3743 	},
3744 };
3745 
3746 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3747 
3748 struct cmd_setmask_result {
3749 	cmdline_fixed_string_t set;
3750 	cmdline_fixed_string_t mask;
3751 	uint64_t hexavalue;
3752 };
3753 
3754 static void cmd_set_mask_parsed(void *parsed_result,
3755 				__rte_unused struct cmdline *cl,
3756 				__rte_unused void *data)
3757 {
3758 	struct cmd_setmask_result *res = parsed_result;
3759 
3760 	if (test_done == 0) {
3761 		fprintf(stderr, "Please stop forwarding first\n");
3762 		return;
3763 	}
3764 	if (!strcmp(res->mask, "coremask")) {
3765 		set_fwd_lcores_mask(res->hexavalue);
3766 		fwd_config_setup();
3767 	} else if (!strcmp(res->mask, "portmask")) {
3768 		set_fwd_ports_mask(res->hexavalue);
3769 		fwd_config_setup();
3770 	}
3771 }
3772 
3773 cmdline_parse_token_string_t cmd_setmask_set =
3774 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3775 cmdline_parse_token_string_t cmd_setmask_mask =
3776 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3777 				 "coremask#portmask");
3778 cmdline_parse_token_num_t cmd_setmask_value =
3779 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3780 
3781 cmdline_parse_inst_t cmd_set_fwd_mask = {
3782 	.f = cmd_set_mask_parsed,
3783 	.data = NULL,
3784 	.help_str = "set coremask|portmask <hexadecimal value>",
3785 	.tokens = {
3786 		(void *)&cmd_setmask_set,
3787 		(void *)&cmd_setmask_mask,
3788 		(void *)&cmd_setmask_value,
3789 		NULL,
3790 	},
3791 };
3792 
3793 /*
3794  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3795  */
3796 struct cmd_set_result {
3797 	cmdline_fixed_string_t set;
3798 	cmdline_fixed_string_t what;
3799 	uint16_t value;
3800 };
3801 
3802 static void cmd_set_parsed(void *parsed_result,
3803 			   __rte_unused struct cmdline *cl,
3804 			   __rte_unused void *data)
3805 {
3806 	struct cmd_set_result *res = parsed_result;
3807 	if (!strcmp(res->what, "nbport")) {
3808 		set_fwd_ports_number(res->value);
3809 		fwd_config_setup();
3810 	} else if (!strcmp(res->what, "nbcore")) {
3811 		set_fwd_lcores_number(res->value);
3812 		fwd_config_setup();
3813 	} else if (!strcmp(res->what, "burst"))
3814 		set_nb_pkt_per_burst(res->value);
3815 	else if (!strcmp(res->what, "verbose"))
3816 		set_verbose_level(res->value);
3817 }
3818 
3819 cmdline_parse_token_string_t cmd_set_set =
3820 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3821 cmdline_parse_token_string_t cmd_set_what =
3822 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3823 				 "nbport#nbcore#burst#verbose");
3824 cmdline_parse_token_num_t cmd_set_value =
3825 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3826 
3827 cmdline_parse_inst_t cmd_set_numbers = {
3828 	.f = cmd_set_parsed,
3829 	.data = NULL,
3830 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3831 	.tokens = {
3832 		(void *)&cmd_set_set,
3833 		(void *)&cmd_set_what,
3834 		(void *)&cmd_set_value,
3835 		NULL,
3836 	},
3837 };
3838 
3839 /* *** SET LOG LEVEL CONFIGURATION *** */
3840 
3841 struct cmd_set_log_result {
3842 	cmdline_fixed_string_t set;
3843 	cmdline_fixed_string_t log;
3844 	cmdline_fixed_string_t type;
3845 	uint32_t level;
3846 };
3847 
3848 static void
3849 cmd_set_log_parsed(void *parsed_result,
3850 		   __rte_unused struct cmdline *cl,
3851 		   __rte_unused void *data)
3852 {
3853 	struct cmd_set_log_result *res;
3854 	int ret;
3855 
3856 	res = parsed_result;
3857 	if (!strcmp(res->type, "global"))
3858 		rte_log_set_global_level(res->level);
3859 	else {
3860 		ret = rte_log_set_level_regexp(res->type, res->level);
3861 		if (ret < 0)
3862 			fprintf(stderr, "Unable to set log level\n");
3863 	}
3864 }
3865 
3866 cmdline_parse_token_string_t cmd_set_log_set =
3867 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3868 cmdline_parse_token_string_t cmd_set_log_log =
3869 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3870 cmdline_parse_token_string_t cmd_set_log_type =
3871 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3872 cmdline_parse_token_num_t cmd_set_log_level =
3873 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3874 
3875 cmdline_parse_inst_t cmd_set_log = {
3876 	.f = cmd_set_log_parsed,
3877 	.data = NULL,
3878 	.help_str = "set log global|<type> <level>",
3879 	.tokens = {
3880 		(void *)&cmd_set_log_set,
3881 		(void *)&cmd_set_log_log,
3882 		(void *)&cmd_set_log_type,
3883 		(void *)&cmd_set_log_level,
3884 		NULL,
3885 	},
3886 };
3887 
3888 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3889 
3890 struct cmd_set_rxoffs_result {
3891 	cmdline_fixed_string_t cmd_keyword;
3892 	cmdline_fixed_string_t rxoffs;
3893 	cmdline_fixed_string_t seg_offsets;
3894 };
3895 
3896 static void
3897 cmd_set_rxoffs_parsed(void *parsed_result,
3898 		      __rte_unused struct cmdline *cl,
3899 		      __rte_unused void *data)
3900 {
3901 	struct cmd_set_rxoffs_result *res;
3902 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3903 	unsigned int nb_segs;
3904 
3905 	res = parsed_result;
3906 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3907 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3908 	if (nb_segs > 0)
3909 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3910 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3911 }
3912 
3913 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3914 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3915 				 cmd_keyword, "set");
3916 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3917 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3918 				 rxoffs, "rxoffs");
3919 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3920 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3921 				 seg_offsets, NULL);
3922 
3923 cmdline_parse_inst_t cmd_set_rxoffs = {
3924 	.f = cmd_set_rxoffs_parsed,
3925 	.data = NULL,
3926 	.help_str = "set rxoffs <len0[,len1]*>",
3927 	.tokens = {
3928 		(void *)&cmd_set_rxoffs_keyword,
3929 		(void *)&cmd_set_rxoffs_name,
3930 		(void *)&cmd_set_rxoffs_offsets,
3931 		NULL,
3932 	},
3933 };
3934 
3935 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3936 
3937 struct cmd_set_rxpkts_result {
3938 	cmdline_fixed_string_t cmd_keyword;
3939 	cmdline_fixed_string_t rxpkts;
3940 	cmdline_fixed_string_t seg_lengths;
3941 };
3942 
3943 static void
3944 cmd_set_rxpkts_parsed(void *parsed_result,
3945 		      __rte_unused struct cmdline *cl,
3946 		      __rte_unused void *data)
3947 {
3948 	struct cmd_set_rxpkts_result *res;
3949 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3950 	unsigned int nb_segs;
3951 
3952 	res = parsed_result;
3953 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3954 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3955 	if (nb_segs > 0)
3956 		set_rx_pkt_segments(seg_lengths, nb_segs);
3957 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3958 }
3959 
3960 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3961 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3962 				 cmd_keyword, "set");
3963 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3964 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3965 				 rxpkts, "rxpkts");
3966 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3967 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3968 				 seg_lengths, NULL);
3969 
3970 cmdline_parse_inst_t cmd_set_rxpkts = {
3971 	.f = cmd_set_rxpkts_parsed,
3972 	.data = NULL,
3973 	.help_str = "set rxpkts <len0[,len1]*>",
3974 	.tokens = {
3975 		(void *)&cmd_set_rxpkts_keyword,
3976 		(void *)&cmd_set_rxpkts_name,
3977 		(void *)&cmd_set_rxpkts_lengths,
3978 		NULL,
3979 	},
3980 };
3981 
3982 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3983 
3984 struct cmd_set_txpkts_result {
3985 	cmdline_fixed_string_t cmd_keyword;
3986 	cmdline_fixed_string_t txpkts;
3987 	cmdline_fixed_string_t seg_lengths;
3988 };
3989 
3990 static void
3991 cmd_set_txpkts_parsed(void *parsed_result,
3992 		      __rte_unused struct cmdline *cl,
3993 		      __rte_unused void *data)
3994 {
3995 	struct cmd_set_txpkts_result *res;
3996 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3997 	unsigned int nb_segs;
3998 
3999 	res = parsed_result;
4000 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4001 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4002 	if (nb_segs > 0)
4003 		set_tx_pkt_segments(seg_lengths, nb_segs);
4004 }
4005 
4006 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4007 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4008 				 cmd_keyword, "set");
4009 cmdline_parse_token_string_t cmd_set_txpkts_name =
4010 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4011 				 txpkts, "txpkts");
4012 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4013 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4014 				 seg_lengths, NULL);
4015 
4016 cmdline_parse_inst_t cmd_set_txpkts = {
4017 	.f = cmd_set_txpkts_parsed,
4018 	.data = NULL,
4019 	.help_str = "set txpkts <len0[,len1]*>",
4020 	.tokens = {
4021 		(void *)&cmd_set_txpkts_keyword,
4022 		(void *)&cmd_set_txpkts_name,
4023 		(void *)&cmd_set_txpkts_lengths,
4024 		NULL,
4025 	},
4026 };
4027 
4028 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4029 
4030 struct cmd_set_txsplit_result {
4031 	cmdline_fixed_string_t cmd_keyword;
4032 	cmdline_fixed_string_t txsplit;
4033 	cmdline_fixed_string_t mode;
4034 };
4035 
4036 static void
4037 cmd_set_txsplit_parsed(void *parsed_result,
4038 		      __rte_unused struct cmdline *cl,
4039 		      __rte_unused void *data)
4040 {
4041 	struct cmd_set_txsplit_result *res;
4042 
4043 	res = parsed_result;
4044 	set_tx_pkt_split(res->mode);
4045 }
4046 
4047 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4048 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4049 				 cmd_keyword, "set");
4050 cmdline_parse_token_string_t cmd_set_txsplit_name =
4051 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4052 				 txsplit, "txsplit");
4053 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4054 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4055 				 mode, NULL);
4056 
4057 cmdline_parse_inst_t cmd_set_txsplit = {
4058 	.f = cmd_set_txsplit_parsed,
4059 	.data = NULL,
4060 	.help_str = "set txsplit on|off|rand",
4061 	.tokens = {
4062 		(void *)&cmd_set_txsplit_keyword,
4063 		(void *)&cmd_set_txsplit_name,
4064 		(void *)&cmd_set_txsplit_mode,
4065 		NULL,
4066 	},
4067 };
4068 
4069 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4070 
4071 struct cmd_set_txtimes_result {
4072 	cmdline_fixed_string_t cmd_keyword;
4073 	cmdline_fixed_string_t txtimes;
4074 	cmdline_fixed_string_t tx_times;
4075 };
4076 
4077 static void
4078 cmd_set_txtimes_parsed(void *parsed_result,
4079 		       __rte_unused struct cmdline *cl,
4080 		       __rte_unused void *data)
4081 {
4082 	struct cmd_set_txtimes_result *res;
4083 	unsigned int tx_times[2] = {0, 0};
4084 	unsigned int n_times;
4085 
4086 	res = parsed_result;
4087 	n_times = parse_item_list(res->tx_times, "tx times",
4088 				  2, tx_times, 0);
4089 	if (n_times == 2)
4090 		set_tx_pkt_times(tx_times);
4091 }
4092 
4093 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4094 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4095 				 cmd_keyword, "set");
4096 cmdline_parse_token_string_t cmd_set_txtimes_name =
4097 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4098 				 txtimes, "txtimes");
4099 cmdline_parse_token_string_t cmd_set_txtimes_value =
4100 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4101 				 tx_times, NULL);
4102 
4103 cmdline_parse_inst_t cmd_set_txtimes = {
4104 	.f = cmd_set_txtimes_parsed,
4105 	.data = NULL,
4106 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
4107 	.tokens = {
4108 		(void *)&cmd_set_txtimes_keyword,
4109 		(void *)&cmd_set_txtimes_name,
4110 		(void *)&cmd_set_txtimes_value,
4111 		NULL,
4112 	},
4113 };
4114 
4115 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4116 struct cmd_rx_vlan_filter_all_result {
4117 	cmdline_fixed_string_t rx_vlan;
4118 	cmdline_fixed_string_t what;
4119 	cmdline_fixed_string_t all;
4120 	portid_t port_id;
4121 };
4122 
4123 static void
4124 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4125 			      __rte_unused struct cmdline *cl,
4126 			      __rte_unused void *data)
4127 {
4128 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4129 
4130 	if (!strcmp(res->what, "add"))
4131 		rx_vlan_all_filter_set(res->port_id, 1);
4132 	else
4133 		rx_vlan_all_filter_set(res->port_id, 0);
4134 }
4135 
4136 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4137 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 				 rx_vlan, "rx_vlan");
4139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4140 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4141 				 what, "add#rm");
4142 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4143 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4144 				 all, "all");
4145 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4146 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4147 			      port_id, RTE_UINT16);
4148 
4149 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4150 	.f = cmd_rx_vlan_filter_all_parsed,
4151 	.data = NULL,
4152 	.help_str = "rx_vlan add|rm all <port_id>: "
4153 		"Add/Remove all identifiers to/from the set of VLAN "
4154 		"identifiers filtered by a port",
4155 	.tokens = {
4156 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4157 		(void *)&cmd_rx_vlan_filter_all_what,
4158 		(void *)&cmd_rx_vlan_filter_all_all,
4159 		(void *)&cmd_rx_vlan_filter_all_portid,
4160 		NULL,
4161 	},
4162 };
4163 
4164 /* *** VLAN OFFLOAD SET ON A PORT *** */
4165 struct cmd_vlan_offload_result {
4166 	cmdline_fixed_string_t vlan;
4167 	cmdline_fixed_string_t set;
4168 	cmdline_fixed_string_t vlan_type;
4169 	cmdline_fixed_string_t what;
4170 	cmdline_fixed_string_t on;
4171 	cmdline_fixed_string_t port_id;
4172 };
4173 
4174 static void
4175 cmd_vlan_offload_parsed(void *parsed_result,
4176 			  __rte_unused struct cmdline *cl,
4177 			  __rte_unused void *data)
4178 {
4179 	int on;
4180 	struct cmd_vlan_offload_result *res = parsed_result;
4181 	char *str;
4182 	int i, len = 0;
4183 	portid_t port_id = 0;
4184 	unsigned int tmp;
4185 
4186 	str = res->port_id;
4187 	len = strnlen(str, STR_TOKEN_SIZE);
4188 	i = 0;
4189 	/* Get port_id first */
4190 	while(i < len){
4191 		if(str[i] == ',')
4192 			break;
4193 
4194 		i++;
4195 	}
4196 	str[i]='\0';
4197 	tmp = strtoul(str, NULL, 0);
4198 	/* If port_id greater that what portid_t can represent, return */
4199 	if(tmp >= RTE_MAX_ETHPORTS)
4200 		return;
4201 	port_id = (portid_t)tmp;
4202 
4203 	if (!strcmp(res->on, "on"))
4204 		on = 1;
4205 	else
4206 		on = 0;
4207 
4208 	if (!strcmp(res->what, "strip"))
4209 		rx_vlan_strip_set(port_id,  on);
4210 	else if(!strcmp(res->what, "stripq")){
4211 		uint16_t queue_id = 0;
4212 
4213 		/* No queue_id, return */
4214 		if(i + 1 >= len) {
4215 			fprintf(stderr, "must specify (port,queue_id)\n");
4216 			return;
4217 		}
4218 		tmp = strtoul(str + i + 1, NULL, 0);
4219 		/* If queue_id greater that what 16-bits can represent, return */
4220 		if(tmp > 0xffff)
4221 			return;
4222 
4223 		queue_id = (uint16_t)tmp;
4224 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4225 	}
4226 	else if (!strcmp(res->what, "filter"))
4227 		rx_vlan_filter_set(port_id, on);
4228 	else if (!strcmp(res->what, "qinq_strip"))
4229 		rx_vlan_qinq_strip_set(port_id, on);
4230 	else
4231 		vlan_extend_set(port_id, on);
4232 
4233 	return;
4234 }
4235 
4236 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4237 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4238 				 vlan, "vlan");
4239 cmdline_parse_token_string_t cmd_vlan_offload_set =
4240 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4241 				 set, "set");
4242 cmdline_parse_token_string_t cmd_vlan_offload_what =
4243 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4244 				what, "strip#filter#qinq_strip#extend#stripq");
4245 cmdline_parse_token_string_t cmd_vlan_offload_on =
4246 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4247 			      on, "on#off");
4248 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4249 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4250 			      port_id, NULL);
4251 
4252 cmdline_parse_inst_t cmd_vlan_offload = {
4253 	.f = cmd_vlan_offload_parsed,
4254 	.data = NULL,
4255 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4256 		"<port_id[,queue_id]>: "
4257 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4258 	.tokens = {
4259 		(void *)&cmd_vlan_offload_vlan,
4260 		(void *)&cmd_vlan_offload_set,
4261 		(void *)&cmd_vlan_offload_what,
4262 		(void *)&cmd_vlan_offload_on,
4263 		(void *)&cmd_vlan_offload_portid,
4264 		NULL,
4265 	},
4266 };
4267 
4268 /* *** VLAN TPID SET ON A PORT *** */
4269 struct cmd_vlan_tpid_result {
4270 	cmdline_fixed_string_t vlan;
4271 	cmdline_fixed_string_t set;
4272 	cmdline_fixed_string_t vlan_type;
4273 	cmdline_fixed_string_t what;
4274 	uint16_t tp_id;
4275 	portid_t port_id;
4276 };
4277 
4278 static void
4279 cmd_vlan_tpid_parsed(void *parsed_result,
4280 			  __rte_unused struct cmdline *cl,
4281 			  __rte_unused void *data)
4282 {
4283 	struct cmd_vlan_tpid_result *res = parsed_result;
4284 	enum rte_vlan_type vlan_type;
4285 
4286 	if (!strcmp(res->vlan_type, "inner"))
4287 		vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4288 	else if (!strcmp(res->vlan_type, "outer"))
4289 		vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4290 	else {
4291 		fprintf(stderr, "Unknown vlan type\n");
4292 		return;
4293 	}
4294 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4295 }
4296 
4297 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4298 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4299 				 vlan, "vlan");
4300 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4301 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4302 				 set, "set");
4303 cmdline_parse_token_string_t cmd_vlan_type =
4304 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4305 				 vlan_type, "inner#outer");
4306 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4307 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4308 				 what, "tpid");
4309 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4310 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4311 			      tp_id, RTE_UINT16);
4312 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4313 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4314 			      port_id, RTE_UINT16);
4315 
4316 cmdline_parse_inst_t cmd_vlan_tpid = {
4317 	.f = cmd_vlan_tpid_parsed,
4318 	.data = NULL,
4319 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4320 		"Set the VLAN Ether type",
4321 	.tokens = {
4322 		(void *)&cmd_vlan_tpid_vlan,
4323 		(void *)&cmd_vlan_tpid_set,
4324 		(void *)&cmd_vlan_type,
4325 		(void *)&cmd_vlan_tpid_what,
4326 		(void *)&cmd_vlan_tpid_tpid,
4327 		(void *)&cmd_vlan_tpid_portid,
4328 		NULL,
4329 	},
4330 };
4331 
4332 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4333 struct cmd_rx_vlan_filter_result {
4334 	cmdline_fixed_string_t rx_vlan;
4335 	cmdline_fixed_string_t what;
4336 	uint16_t vlan_id;
4337 	portid_t port_id;
4338 };
4339 
4340 static void
4341 cmd_rx_vlan_filter_parsed(void *parsed_result,
4342 			  __rte_unused struct cmdline *cl,
4343 			  __rte_unused void *data)
4344 {
4345 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4346 
4347 	if (!strcmp(res->what, "add"))
4348 		rx_vft_set(res->port_id, res->vlan_id, 1);
4349 	else
4350 		rx_vft_set(res->port_id, res->vlan_id, 0);
4351 }
4352 
4353 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4354 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4355 				 rx_vlan, "rx_vlan");
4356 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4357 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4358 				 what, "add#rm");
4359 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4360 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4361 			      vlan_id, RTE_UINT16);
4362 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4363 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4364 			      port_id, RTE_UINT16);
4365 
4366 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4367 	.f = cmd_rx_vlan_filter_parsed,
4368 	.data = NULL,
4369 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4370 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4371 		"identifiers filtered by a port",
4372 	.tokens = {
4373 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4374 		(void *)&cmd_rx_vlan_filter_what,
4375 		(void *)&cmd_rx_vlan_filter_vlanid,
4376 		(void *)&cmd_rx_vlan_filter_portid,
4377 		NULL,
4378 	},
4379 };
4380 
4381 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4382 struct cmd_tx_vlan_set_result {
4383 	cmdline_fixed_string_t tx_vlan;
4384 	cmdline_fixed_string_t set;
4385 	portid_t port_id;
4386 	uint16_t vlan_id;
4387 };
4388 
4389 static void
4390 cmd_tx_vlan_set_parsed(void *parsed_result,
4391 		       __rte_unused struct cmdline *cl,
4392 		       __rte_unused void *data)
4393 {
4394 	struct cmd_tx_vlan_set_result *res = parsed_result;
4395 
4396 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4397 		return;
4398 
4399 	if (!port_is_stopped(res->port_id)) {
4400 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4401 		return;
4402 	}
4403 
4404 	tx_vlan_set(res->port_id, res->vlan_id);
4405 
4406 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4407 }
4408 
4409 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4410 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4411 				 tx_vlan, "tx_vlan");
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4413 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4414 				 set, "set");
4415 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4416 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4417 			      port_id, RTE_UINT16);
4418 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4419 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4420 			      vlan_id, RTE_UINT16);
4421 
4422 cmdline_parse_inst_t cmd_tx_vlan_set = {
4423 	.f = cmd_tx_vlan_set_parsed,
4424 	.data = NULL,
4425 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4426 		"Enable hardware insertion of a single VLAN header "
4427 		"with a given TAG Identifier in packets sent on a port",
4428 	.tokens = {
4429 		(void *)&cmd_tx_vlan_set_tx_vlan,
4430 		(void *)&cmd_tx_vlan_set_set,
4431 		(void *)&cmd_tx_vlan_set_portid,
4432 		(void *)&cmd_tx_vlan_set_vlanid,
4433 		NULL,
4434 	},
4435 };
4436 
4437 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4438 struct cmd_tx_vlan_set_qinq_result {
4439 	cmdline_fixed_string_t tx_vlan;
4440 	cmdline_fixed_string_t set;
4441 	portid_t port_id;
4442 	uint16_t vlan_id;
4443 	uint16_t vlan_id_outer;
4444 };
4445 
4446 static void
4447 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4448 			    __rte_unused struct cmdline *cl,
4449 			    __rte_unused void *data)
4450 {
4451 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4452 
4453 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4454 		return;
4455 
4456 	if (!port_is_stopped(res->port_id)) {
4457 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4458 		return;
4459 	}
4460 
4461 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4462 
4463 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4464 }
4465 
4466 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4467 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 		tx_vlan, "tx_vlan");
4469 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4470 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4471 		set, "set");
4472 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4473 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4474 		port_id, RTE_UINT16);
4475 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4476 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 		vlan_id, RTE_UINT16);
4478 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4479 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4480 		vlan_id_outer, RTE_UINT16);
4481 
4482 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4483 	.f = cmd_tx_vlan_set_qinq_parsed,
4484 	.data = NULL,
4485 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4486 		"Enable hardware insertion of double VLAN header "
4487 		"with given TAG Identifiers in packets sent on a port",
4488 	.tokens = {
4489 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4490 		(void *)&cmd_tx_vlan_set_qinq_set,
4491 		(void *)&cmd_tx_vlan_set_qinq_portid,
4492 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4493 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4494 		NULL,
4495 	},
4496 };
4497 
4498 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4499 struct cmd_tx_vlan_set_pvid_result {
4500 	cmdline_fixed_string_t tx_vlan;
4501 	cmdline_fixed_string_t set;
4502 	cmdline_fixed_string_t pvid;
4503 	portid_t port_id;
4504 	uint16_t vlan_id;
4505 	cmdline_fixed_string_t mode;
4506 };
4507 
4508 static void
4509 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4510 			    __rte_unused struct cmdline *cl,
4511 			    __rte_unused void *data)
4512 {
4513 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4514 
4515 	if (strcmp(res->mode, "on") == 0)
4516 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4517 	else
4518 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4519 }
4520 
4521 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4522 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 				 tx_vlan, "tx_vlan");
4524 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4525 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 				 set, "set");
4527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4528 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4529 				 pvid, "pvid");
4530 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4531 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4532 			     port_id, RTE_UINT16);
4533 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4534 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4535 			      vlan_id, RTE_UINT16);
4536 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4537 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4538 				 mode, "on#off");
4539 
4540 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4541 	.f = cmd_tx_vlan_set_pvid_parsed,
4542 	.data = NULL,
4543 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4544 	.tokens = {
4545 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4546 		(void *)&cmd_tx_vlan_set_pvid_set,
4547 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4548 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4549 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4550 		(void *)&cmd_tx_vlan_set_pvid_mode,
4551 		NULL,
4552 	},
4553 };
4554 
4555 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4556 struct cmd_tx_vlan_reset_result {
4557 	cmdline_fixed_string_t tx_vlan;
4558 	cmdline_fixed_string_t reset;
4559 	portid_t port_id;
4560 };
4561 
4562 static void
4563 cmd_tx_vlan_reset_parsed(void *parsed_result,
4564 			 __rte_unused struct cmdline *cl,
4565 			 __rte_unused void *data)
4566 {
4567 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4568 
4569 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4570 		return;
4571 
4572 	if (!port_is_stopped(res->port_id)) {
4573 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4574 		return;
4575 	}
4576 
4577 	tx_vlan_reset(res->port_id);
4578 
4579 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4580 }
4581 
4582 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4583 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4584 				 tx_vlan, "tx_vlan");
4585 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4586 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4587 				 reset, "reset");
4588 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4589 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4590 			      port_id, RTE_UINT16);
4591 
4592 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4593 	.f = cmd_tx_vlan_reset_parsed,
4594 	.data = NULL,
4595 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4596 		"VLAN header in packets sent on a port",
4597 	.tokens = {
4598 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4599 		(void *)&cmd_tx_vlan_reset_reset,
4600 		(void *)&cmd_tx_vlan_reset_portid,
4601 		NULL,
4602 	},
4603 };
4604 
4605 
4606 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4607 struct cmd_csum_result {
4608 	cmdline_fixed_string_t csum;
4609 	cmdline_fixed_string_t mode;
4610 	cmdline_fixed_string_t proto;
4611 	cmdline_fixed_string_t hwsw;
4612 	portid_t port_id;
4613 };
4614 
4615 static void
4616 csum_show(int port_id)
4617 {
4618 	struct rte_eth_dev_info dev_info;
4619 	uint64_t tx_offloads;
4620 	int ret;
4621 
4622 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4623 	printf("Parse tunnel is %s\n",
4624 		(ports[port_id].parse_tunnel) ? "on" : "off");
4625 	printf("IP checksum offload is %s\n",
4626 		(tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4627 	printf("UDP checksum offload is %s\n",
4628 		(tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4629 	printf("TCP checksum offload is %s\n",
4630 		(tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4631 	printf("SCTP checksum offload is %s\n",
4632 		(tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4633 	printf("Outer-Ip checksum offload is %s\n",
4634 		(tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4635 	printf("Outer-Udp checksum offload is %s\n",
4636 		(tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4637 
4638 	/* display warnings if configuration is not supported by the NIC */
4639 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4640 	if (ret != 0)
4641 		return;
4642 
4643 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4644 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4645 		fprintf(stderr,
4646 			"Warning: hardware IP checksum enabled but not supported by port %d\n",
4647 			port_id);
4648 	}
4649 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4650 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4651 		fprintf(stderr,
4652 			"Warning: hardware UDP checksum enabled but not supported by port %d\n",
4653 			port_id);
4654 	}
4655 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4656 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4657 		fprintf(stderr,
4658 			"Warning: hardware TCP checksum enabled but not supported by port %d\n",
4659 			port_id);
4660 	}
4661 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4662 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4663 		fprintf(stderr,
4664 			"Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4665 			port_id);
4666 	}
4667 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4668 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4669 		fprintf(stderr,
4670 			"Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4671 			port_id);
4672 	}
4673 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4674 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4675 			== 0) {
4676 		fprintf(stderr,
4677 			"Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4678 			port_id);
4679 	}
4680 }
4681 
4682 static void
4683 cmd_config_queue_tx_offloads(struct rte_port *port)
4684 {
4685 	int k;
4686 
4687 	/* Apply queue tx offloads configuration */
4688 	for (k = 0; k < port->dev_info.max_tx_queues; k++)
4689 		port->tx_conf[k].offloads =
4690 			port->dev_conf.txmode.offloads;
4691 }
4692 
4693 static void
4694 cmd_csum_parsed(void *parsed_result,
4695 		       __rte_unused struct cmdline *cl,
4696 		       __rte_unused void *data)
4697 {
4698 	struct cmd_csum_result *res = parsed_result;
4699 	int hw = 0;
4700 	uint64_t csum_offloads = 0;
4701 	struct rte_eth_dev_info dev_info;
4702 	int ret;
4703 
4704 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4705 		fprintf(stderr, "invalid port %d\n", res->port_id);
4706 		return;
4707 	}
4708 	if (!port_is_stopped(res->port_id)) {
4709 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4710 		return;
4711 	}
4712 
4713 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4714 	if (ret != 0)
4715 		return;
4716 
4717 	if (!strcmp(res->mode, "set")) {
4718 
4719 		if (!strcmp(res->hwsw, "hw"))
4720 			hw = 1;
4721 
4722 		if (!strcmp(res->proto, "ip")) {
4723 			if (hw == 0 || (dev_info.tx_offload_capa &
4724 						RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4725 				csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4726 			} else {
4727 				fprintf(stderr,
4728 					"IP checksum offload is not supported by port %u\n",
4729 					res->port_id);
4730 			}
4731 		} else if (!strcmp(res->proto, "udp")) {
4732 			if (hw == 0 || (dev_info.tx_offload_capa &
4733 						RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4734 				csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4735 			} else {
4736 				fprintf(stderr,
4737 					"UDP checksum offload is not supported by port %u\n",
4738 					res->port_id);
4739 			}
4740 		} else if (!strcmp(res->proto, "tcp")) {
4741 			if (hw == 0 || (dev_info.tx_offload_capa &
4742 						RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4743 				csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4744 			} else {
4745 				fprintf(stderr,
4746 					"TCP checksum offload is not supported by port %u\n",
4747 					res->port_id);
4748 			}
4749 		} else if (!strcmp(res->proto, "sctp")) {
4750 			if (hw == 0 || (dev_info.tx_offload_capa &
4751 						RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4752 				csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4753 			} else {
4754 				fprintf(stderr,
4755 					"SCTP checksum offload is not supported by port %u\n",
4756 					res->port_id);
4757 			}
4758 		} else if (!strcmp(res->proto, "outer-ip")) {
4759 			if (hw == 0 || (dev_info.tx_offload_capa &
4760 					RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4761 				csum_offloads |=
4762 						RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4763 			} else {
4764 				fprintf(stderr,
4765 					"Outer IP checksum offload is not supported by port %u\n",
4766 					res->port_id);
4767 			}
4768 		} else if (!strcmp(res->proto, "outer-udp")) {
4769 			if (hw == 0 || (dev_info.tx_offload_capa &
4770 					RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4771 				csum_offloads |=
4772 						RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4773 			} else {
4774 				fprintf(stderr,
4775 					"Outer UDP checksum offload is not supported by port %u\n",
4776 					res->port_id);
4777 			}
4778 		}
4779 
4780 		if (hw) {
4781 			ports[res->port_id].dev_conf.txmode.offloads |=
4782 							csum_offloads;
4783 		} else {
4784 			ports[res->port_id].dev_conf.txmode.offloads &=
4785 							(~csum_offloads);
4786 		}
4787 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4788 	}
4789 	csum_show(res->port_id);
4790 
4791 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4792 }
4793 
4794 cmdline_parse_token_string_t cmd_csum_csum =
4795 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4796 				csum, "csum");
4797 cmdline_parse_token_string_t cmd_csum_mode =
4798 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4799 				mode, "set");
4800 cmdline_parse_token_string_t cmd_csum_proto =
4801 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4802 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4803 cmdline_parse_token_string_t cmd_csum_hwsw =
4804 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4805 				hwsw, "hw#sw");
4806 cmdline_parse_token_num_t cmd_csum_portid =
4807 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4808 				port_id, RTE_UINT16);
4809 
4810 cmdline_parse_inst_t cmd_csum_set = {
4811 	.f = cmd_csum_parsed,
4812 	.data = NULL,
4813 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4814 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4815 		"using csum forward engine",
4816 	.tokens = {
4817 		(void *)&cmd_csum_csum,
4818 		(void *)&cmd_csum_mode,
4819 		(void *)&cmd_csum_proto,
4820 		(void *)&cmd_csum_hwsw,
4821 		(void *)&cmd_csum_portid,
4822 		NULL,
4823 	},
4824 };
4825 
4826 cmdline_parse_token_string_t cmd_csum_mode_show =
4827 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4828 				mode, "show");
4829 
4830 cmdline_parse_inst_t cmd_csum_show = {
4831 	.f = cmd_csum_parsed,
4832 	.data = NULL,
4833 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4834 	.tokens = {
4835 		(void *)&cmd_csum_csum,
4836 		(void *)&cmd_csum_mode_show,
4837 		(void *)&cmd_csum_portid,
4838 		NULL,
4839 	},
4840 };
4841 
4842 /* Enable/disable tunnel parsing */
4843 struct cmd_csum_tunnel_result {
4844 	cmdline_fixed_string_t csum;
4845 	cmdline_fixed_string_t parse;
4846 	cmdline_fixed_string_t onoff;
4847 	portid_t port_id;
4848 };
4849 
4850 static void
4851 cmd_csum_tunnel_parsed(void *parsed_result,
4852 		       __rte_unused struct cmdline *cl,
4853 		       __rte_unused void *data)
4854 {
4855 	struct cmd_csum_tunnel_result *res = parsed_result;
4856 
4857 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4858 		return;
4859 
4860 	if (!strcmp(res->onoff, "on"))
4861 		ports[res->port_id].parse_tunnel = 1;
4862 	else
4863 		ports[res->port_id].parse_tunnel = 0;
4864 
4865 	csum_show(res->port_id);
4866 }
4867 
4868 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4869 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4870 				csum, "csum");
4871 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4872 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4873 				parse, "parse-tunnel");
4874 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4875 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4876 				onoff, "on#off");
4877 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4878 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4879 				port_id, RTE_UINT16);
4880 
4881 cmdline_parse_inst_t cmd_csum_tunnel = {
4882 	.f = cmd_csum_tunnel_parsed,
4883 	.data = NULL,
4884 	.help_str = "csum parse-tunnel on|off <port_id>: "
4885 		"Enable/Disable parsing of tunnels for csum engine",
4886 	.tokens = {
4887 		(void *)&cmd_csum_tunnel_csum,
4888 		(void *)&cmd_csum_tunnel_parse,
4889 		(void *)&cmd_csum_tunnel_onoff,
4890 		(void *)&cmd_csum_tunnel_portid,
4891 		NULL,
4892 	},
4893 };
4894 
4895 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4896 struct cmd_tso_set_result {
4897 	cmdline_fixed_string_t tso;
4898 	cmdline_fixed_string_t mode;
4899 	uint16_t tso_segsz;
4900 	portid_t port_id;
4901 };
4902 
4903 static void
4904 cmd_tso_set_parsed(void *parsed_result,
4905 		       __rte_unused struct cmdline *cl,
4906 		       __rte_unused void *data)
4907 {
4908 	struct cmd_tso_set_result *res = parsed_result;
4909 	struct rte_eth_dev_info dev_info;
4910 	int ret;
4911 
4912 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4913 		return;
4914 	if (!port_is_stopped(res->port_id)) {
4915 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4916 		return;
4917 	}
4918 
4919 	if (!strcmp(res->mode, "set"))
4920 		ports[res->port_id].tso_segsz = res->tso_segsz;
4921 
4922 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4923 	if (ret != 0)
4924 		return;
4925 
4926 	if ((ports[res->port_id].tso_segsz != 0) &&
4927 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4928 		fprintf(stderr, "Error: TSO is not supported by port %d\n",
4929 			res->port_id);
4930 		return;
4931 	}
4932 
4933 	if (ports[res->port_id].tso_segsz == 0) {
4934 		ports[res->port_id].dev_conf.txmode.offloads &=
4935 						~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4936 		printf("TSO for non-tunneled packets is disabled\n");
4937 	} else {
4938 		ports[res->port_id].dev_conf.txmode.offloads |=
4939 						RTE_ETH_TX_OFFLOAD_TCP_TSO;
4940 		printf("TSO segment size for non-tunneled packets is %d\n",
4941 			ports[res->port_id].tso_segsz);
4942 	}
4943 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4944 
4945 	/* display warnings if configuration is not supported by the NIC */
4946 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4947 	if (ret != 0)
4948 		return;
4949 
4950 	if ((ports[res->port_id].tso_segsz != 0) &&
4951 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4952 		fprintf(stderr,
4953 			"Warning: TSO enabled but not supported by port %d\n",
4954 			res->port_id);
4955 	}
4956 
4957 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4958 }
4959 
4960 cmdline_parse_token_string_t cmd_tso_set_tso =
4961 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4962 				tso, "tso");
4963 cmdline_parse_token_string_t cmd_tso_set_mode =
4964 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4965 				mode, "set");
4966 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4967 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4968 				tso_segsz, RTE_UINT16);
4969 cmdline_parse_token_num_t cmd_tso_set_portid =
4970 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4971 				port_id, RTE_UINT16);
4972 
4973 cmdline_parse_inst_t cmd_tso_set = {
4974 	.f = cmd_tso_set_parsed,
4975 	.data = NULL,
4976 	.help_str = "tso set <tso_segsz> <port_id>: "
4977 		"Set TSO segment size of non-tunneled packets for csum engine "
4978 		"(0 to disable)",
4979 	.tokens = {
4980 		(void *)&cmd_tso_set_tso,
4981 		(void *)&cmd_tso_set_mode,
4982 		(void *)&cmd_tso_set_tso_segsz,
4983 		(void *)&cmd_tso_set_portid,
4984 		NULL,
4985 	},
4986 };
4987 
4988 cmdline_parse_token_string_t cmd_tso_show_mode =
4989 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4990 				mode, "show");
4991 
4992 
4993 cmdline_parse_inst_t cmd_tso_show = {
4994 	.f = cmd_tso_set_parsed,
4995 	.data = NULL,
4996 	.help_str = "tso show <port_id>: "
4997 		"Show TSO segment size of non-tunneled packets for csum engine",
4998 	.tokens = {
4999 		(void *)&cmd_tso_set_tso,
5000 		(void *)&cmd_tso_show_mode,
5001 		(void *)&cmd_tso_set_portid,
5002 		NULL,
5003 	},
5004 };
5005 
5006 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5007 struct cmd_tunnel_tso_set_result {
5008 	cmdline_fixed_string_t tso;
5009 	cmdline_fixed_string_t mode;
5010 	uint16_t tso_segsz;
5011 	portid_t port_id;
5012 };
5013 
5014 static struct rte_eth_dev_info
5015 check_tunnel_tso_nic_support(portid_t port_id)
5016 {
5017 	struct rte_eth_dev_info dev_info;
5018 
5019 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5020 		return dev_info;
5021 
5022 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5023 		fprintf(stderr,
5024 			"Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5025 			port_id);
5026 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5027 		fprintf(stderr,
5028 			"Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5029 			port_id);
5030 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5031 		fprintf(stderr,
5032 			"Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5033 			port_id);
5034 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5035 		fprintf(stderr,
5036 			"Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5037 			port_id);
5038 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5039 		fprintf(stderr,
5040 			"Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5041 			port_id);
5042 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5043 		fprintf(stderr,
5044 			"Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5045 			port_id);
5046 	return dev_info;
5047 }
5048 
5049 static void
5050 cmd_tunnel_tso_set_parsed(void *parsed_result,
5051 			  __rte_unused struct cmdline *cl,
5052 			  __rte_unused void *data)
5053 {
5054 	struct cmd_tunnel_tso_set_result *res = parsed_result;
5055 	struct rte_eth_dev_info dev_info;
5056 
5057 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5058 		return;
5059 	if (!port_is_stopped(res->port_id)) {
5060 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
5061 		return;
5062 	}
5063 
5064 	if (!strcmp(res->mode, "set"))
5065 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5066 
5067 	dev_info = check_tunnel_tso_nic_support(res->port_id);
5068 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
5069 		ports[res->port_id].dev_conf.txmode.offloads &=
5070 			~(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 		printf("TSO for tunneled packets is disabled\n");
5077 	} else {
5078 		uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5079 					 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5080 					 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5081 					 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5082 					 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5083 					 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5084 
5085 		ports[res->port_id].dev_conf.txmode.offloads |=
5086 			(tso_offloads & dev_info.tx_offload_capa);
5087 		printf("TSO segment size for tunneled packets is %d\n",
5088 			ports[res->port_id].tunnel_tso_segsz);
5089 
5090 		/* Below conditions are needed to make it work:
5091 		 * (1) tunnel TSO is supported by the NIC;
5092 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5093 		 * are recognized;
5094 		 * (3) for tunneled pkts with outer L3 of IPv4,
5095 		 * "csum set outer-ip" must be set to hw, because after tso,
5096 		 * total_len of outer IP header is changed, and the checksum
5097 		 * of outer IP header calculated by sw should be wrong; that
5098 		 * is not necessary for IPv6 tunneled pkts because there's no
5099 		 * checksum in IP header anymore.
5100 		 */
5101 
5102 		if (!ports[res->port_id].parse_tunnel)
5103 			fprintf(stderr,
5104 				"Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5105 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
5106 		      RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5107 			fprintf(stderr,
5108 				"Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5109 	}
5110 
5111 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
5112 	cmd_reconfig_device_queue(res->port_id, 1, 1);
5113 }
5114 
5115 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5116 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5117 				tso, "tunnel_tso");
5118 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5119 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5120 				mode, "set");
5121 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5122 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5123 				tso_segsz, RTE_UINT16);
5124 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5125 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5126 				port_id, RTE_UINT16);
5127 
5128 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5129 	.f = cmd_tunnel_tso_set_parsed,
5130 	.data = NULL,
5131 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5132 		"Set TSO segment size of tunneled packets for csum engine "
5133 		"(0 to disable)",
5134 	.tokens = {
5135 		(void *)&cmd_tunnel_tso_set_tso,
5136 		(void *)&cmd_tunnel_tso_set_mode,
5137 		(void *)&cmd_tunnel_tso_set_tso_segsz,
5138 		(void *)&cmd_tunnel_tso_set_portid,
5139 		NULL,
5140 	},
5141 };
5142 
5143 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5144 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5145 				mode, "show");
5146 
5147 
5148 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5149 	.f = cmd_tunnel_tso_set_parsed,
5150 	.data = NULL,
5151 	.help_str = "tunnel_tso show <port_id> "
5152 		"Show TSO segment size of tunneled packets for csum engine",
5153 	.tokens = {
5154 		(void *)&cmd_tunnel_tso_set_tso,
5155 		(void *)&cmd_tunnel_tso_show_mode,
5156 		(void *)&cmd_tunnel_tso_set_portid,
5157 		NULL,
5158 	},
5159 };
5160 
5161 #ifdef RTE_LIB_GRO
5162 /* *** SET GRO FOR A PORT *** */
5163 struct cmd_gro_enable_result {
5164 	cmdline_fixed_string_t cmd_set;
5165 	cmdline_fixed_string_t cmd_port;
5166 	cmdline_fixed_string_t cmd_keyword;
5167 	cmdline_fixed_string_t cmd_onoff;
5168 	portid_t cmd_pid;
5169 };
5170 
5171 static void
5172 cmd_gro_enable_parsed(void *parsed_result,
5173 		__rte_unused struct cmdline *cl,
5174 		__rte_unused void *data)
5175 {
5176 	struct cmd_gro_enable_result *res;
5177 
5178 	res = parsed_result;
5179 	if (!strcmp(res->cmd_keyword, "gro"))
5180 		setup_gro(res->cmd_onoff, res->cmd_pid);
5181 }
5182 
5183 cmdline_parse_token_string_t cmd_gro_enable_set =
5184 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5185 			cmd_set, "set");
5186 cmdline_parse_token_string_t cmd_gro_enable_port =
5187 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5188 			cmd_keyword, "port");
5189 cmdline_parse_token_num_t cmd_gro_enable_pid =
5190 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5191 			cmd_pid, RTE_UINT16);
5192 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5193 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5194 			cmd_keyword, "gro");
5195 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5196 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5197 			cmd_onoff, "on#off");
5198 
5199 cmdline_parse_inst_t cmd_gro_enable = {
5200 	.f = cmd_gro_enable_parsed,
5201 	.data = NULL,
5202 	.help_str = "set port <port_id> gro on|off",
5203 	.tokens = {
5204 		(void *)&cmd_gro_enable_set,
5205 		(void *)&cmd_gro_enable_port,
5206 		(void *)&cmd_gro_enable_pid,
5207 		(void *)&cmd_gro_enable_keyword,
5208 		(void *)&cmd_gro_enable_onoff,
5209 		NULL,
5210 	},
5211 };
5212 
5213 /* *** DISPLAY GRO CONFIGURATION *** */
5214 struct cmd_gro_show_result {
5215 	cmdline_fixed_string_t cmd_show;
5216 	cmdline_fixed_string_t cmd_port;
5217 	cmdline_fixed_string_t cmd_keyword;
5218 	portid_t cmd_pid;
5219 };
5220 
5221 static void
5222 cmd_gro_show_parsed(void *parsed_result,
5223 		__rte_unused struct cmdline *cl,
5224 		__rte_unused void *data)
5225 {
5226 	struct cmd_gro_show_result *res;
5227 
5228 	res = parsed_result;
5229 	if (!strcmp(res->cmd_keyword, "gro"))
5230 		show_gro(res->cmd_pid);
5231 }
5232 
5233 cmdline_parse_token_string_t cmd_gro_show_show =
5234 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5235 			cmd_show, "show");
5236 cmdline_parse_token_string_t cmd_gro_show_port =
5237 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5238 			cmd_port, "port");
5239 cmdline_parse_token_num_t cmd_gro_show_pid =
5240 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5241 			cmd_pid, RTE_UINT16);
5242 cmdline_parse_token_string_t cmd_gro_show_keyword =
5243 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5244 			cmd_keyword, "gro");
5245 
5246 cmdline_parse_inst_t cmd_gro_show = {
5247 	.f = cmd_gro_show_parsed,
5248 	.data = NULL,
5249 	.help_str = "show port <port_id> gro",
5250 	.tokens = {
5251 		(void *)&cmd_gro_show_show,
5252 		(void *)&cmd_gro_show_port,
5253 		(void *)&cmd_gro_show_pid,
5254 		(void *)&cmd_gro_show_keyword,
5255 		NULL,
5256 	},
5257 };
5258 
5259 /* *** SET FLUSH CYCLES FOR GRO *** */
5260 struct cmd_gro_flush_result {
5261 	cmdline_fixed_string_t cmd_set;
5262 	cmdline_fixed_string_t cmd_keyword;
5263 	cmdline_fixed_string_t cmd_flush;
5264 	uint8_t cmd_cycles;
5265 };
5266 
5267 static void
5268 cmd_gro_flush_parsed(void *parsed_result,
5269 		__rte_unused struct cmdline *cl,
5270 		__rte_unused void *data)
5271 {
5272 	struct cmd_gro_flush_result *res;
5273 
5274 	res = parsed_result;
5275 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5276 			(!strcmp(res->cmd_flush, "flush")))
5277 		setup_gro_flush_cycles(res->cmd_cycles);
5278 }
5279 
5280 cmdline_parse_token_string_t cmd_gro_flush_set =
5281 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5282 			cmd_set, "set");
5283 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5284 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5285 			cmd_keyword, "gro");
5286 cmdline_parse_token_string_t cmd_gro_flush_flush =
5287 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5288 			cmd_flush, "flush");
5289 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5290 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5291 			cmd_cycles, RTE_UINT8);
5292 
5293 cmdline_parse_inst_t cmd_gro_flush = {
5294 	.f = cmd_gro_flush_parsed,
5295 	.data = NULL,
5296 	.help_str = "set gro flush <cycles>",
5297 	.tokens = {
5298 		(void *)&cmd_gro_flush_set,
5299 		(void *)&cmd_gro_flush_keyword,
5300 		(void *)&cmd_gro_flush_flush,
5301 		(void *)&cmd_gro_flush_cycles,
5302 		NULL,
5303 	},
5304 };
5305 #endif /* RTE_LIB_GRO */
5306 
5307 #ifdef RTE_LIB_GSO
5308 /* *** ENABLE/DISABLE GSO *** */
5309 struct cmd_gso_enable_result {
5310 	cmdline_fixed_string_t cmd_set;
5311 	cmdline_fixed_string_t cmd_port;
5312 	cmdline_fixed_string_t cmd_keyword;
5313 	cmdline_fixed_string_t cmd_mode;
5314 	portid_t cmd_pid;
5315 };
5316 
5317 static void
5318 cmd_gso_enable_parsed(void *parsed_result,
5319 		__rte_unused struct cmdline *cl,
5320 		__rte_unused void *data)
5321 {
5322 	struct cmd_gso_enable_result *res;
5323 
5324 	res = parsed_result;
5325 	if (!strcmp(res->cmd_keyword, "gso"))
5326 		setup_gso(res->cmd_mode, res->cmd_pid);
5327 }
5328 
5329 cmdline_parse_token_string_t cmd_gso_enable_set =
5330 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5331 			cmd_set, "set");
5332 cmdline_parse_token_string_t cmd_gso_enable_port =
5333 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5334 			cmd_port, "port");
5335 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5336 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5337 			cmd_keyword, "gso");
5338 cmdline_parse_token_string_t cmd_gso_enable_mode =
5339 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5340 			cmd_mode, "on#off");
5341 cmdline_parse_token_num_t cmd_gso_enable_pid =
5342 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5343 			cmd_pid, RTE_UINT16);
5344 
5345 cmdline_parse_inst_t cmd_gso_enable = {
5346 	.f = cmd_gso_enable_parsed,
5347 	.data = NULL,
5348 	.help_str = "set port <port_id> gso on|off",
5349 	.tokens = {
5350 		(void *)&cmd_gso_enable_set,
5351 		(void *)&cmd_gso_enable_port,
5352 		(void *)&cmd_gso_enable_pid,
5353 		(void *)&cmd_gso_enable_keyword,
5354 		(void *)&cmd_gso_enable_mode,
5355 		NULL,
5356 	},
5357 };
5358 
5359 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5360 struct cmd_gso_size_result {
5361 	cmdline_fixed_string_t cmd_set;
5362 	cmdline_fixed_string_t cmd_keyword;
5363 	cmdline_fixed_string_t cmd_segsz;
5364 	uint16_t cmd_size;
5365 };
5366 
5367 static void
5368 cmd_gso_size_parsed(void *parsed_result,
5369 		       __rte_unused struct cmdline *cl,
5370 		       __rte_unused void *data)
5371 {
5372 	struct cmd_gso_size_result *res = parsed_result;
5373 
5374 	if (test_done == 0) {
5375 		fprintf(stderr,
5376 			"Before setting GSO segsz, please first stop forwarding\n");
5377 		return;
5378 	}
5379 
5380 	if (!strcmp(res->cmd_keyword, "gso") &&
5381 			!strcmp(res->cmd_segsz, "segsz")) {
5382 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5383 			fprintf(stderr,
5384 				"gso_size should be larger than %zu. Please input a legal value\n",
5385 				RTE_GSO_SEG_SIZE_MIN);
5386 		else
5387 			gso_max_segment_size = res->cmd_size;
5388 	}
5389 }
5390 
5391 cmdline_parse_token_string_t cmd_gso_size_set =
5392 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5393 				cmd_set, "set");
5394 cmdline_parse_token_string_t cmd_gso_size_keyword =
5395 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5396 				cmd_keyword, "gso");
5397 cmdline_parse_token_string_t cmd_gso_size_segsz =
5398 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5399 				cmd_segsz, "segsz");
5400 cmdline_parse_token_num_t cmd_gso_size_size =
5401 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5402 				cmd_size, RTE_UINT16);
5403 
5404 cmdline_parse_inst_t cmd_gso_size = {
5405 	.f = cmd_gso_size_parsed,
5406 	.data = NULL,
5407 	.help_str = "set gso segsz <length>",
5408 	.tokens = {
5409 		(void *)&cmd_gso_size_set,
5410 		(void *)&cmd_gso_size_keyword,
5411 		(void *)&cmd_gso_size_segsz,
5412 		(void *)&cmd_gso_size_size,
5413 		NULL,
5414 	},
5415 };
5416 
5417 /* *** SHOW GSO CONFIGURATION *** */
5418 struct cmd_gso_show_result {
5419 	cmdline_fixed_string_t cmd_show;
5420 	cmdline_fixed_string_t cmd_port;
5421 	cmdline_fixed_string_t cmd_keyword;
5422 	portid_t cmd_pid;
5423 };
5424 
5425 static void
5426 cmd_gso_show_parsed(void *parsed_result,
5427 		       __rte_unused struct cmdline *cl,
5428 		       __rte_unused void *data)
5429 {
5430 	struct cmd_gso_show_result *res = parsed_result;
5431 
5432 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5433 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5434 		return;
5435 	}
5436 	if (!strcmp(res->cmd_keyword, "gso")) {
5437 		if (gso_ports[res->cmd_pid].enable) {
5438 			printf("Max GSO'd packet size: %uB\n"
5439 					"Supported GSO types: TCP/IPv4, "
5440 					"UDP/IPv4, VxLAN with inner "
5441 					"TCP/IPv4 packet, GRE with inner "
5442 					"TCP/IPv4 packet\n",
5443 					gso_max_segment_size);
5444 		} else
5445 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5446 	}
5447 }
5448 
5449 cmdline_parse_token_string_t cmd_gso_show_show =
5450 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5451 		cmd_show, "show");
5452 cmdline_parse_token_string_t cmd_gso_show_port =
5453 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5454 		cmd_port, "port");
5455 cmdline_parse_token_string_t cmd_gso_show_keyword =
5456 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5457 				cmd_keyword, "gso");
5458 cmdline_parse_token_num_t cmd_gso_show_pid =
5459 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5460 				cmd_pid, RTE_UINT16);
5461 
5462 cmdline_parse_inst_t cmd_gso_show = {
5463 	.f = cmd_gso_show_parsed,
5464 	.data = NULL,
5465 	.help_str = "show port <port_id> gso",
5466 	.tokens = {
5467 		(void *)&cmd_gso_show_show,
5468 		(void *)&cmd_gso_show_port,
5469 		(void *)&cmd_gso_show_pid,
5470 		(void *)&cmd_gso_show_keyword,
5471 		NULL,
5472 	},
5473 };
5474 #endif /* RTE_LIB_GSO */
5475 
5476 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5477 struct cmd_set_flush_rx {
5478 	cmdline_fixed_string_t set;
5479 	cmdline_fixed_string_t flush_rx;
5480 	cmdline_fixed_string_t mode;
5481 };
5482 
5483 static void
5484 cmd_set_flush_rx_parsed(void *parsed_result,
5485 		__rte_unused struct cmdline *cl,
5486 		__rte_unused void *data)
5487 {
5488 	struct cmd_set_flush_rx *res = parsed_result;
5489 
5490 	if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5491 		printf("multi-process doesn't support to flush Rx queues.\n");
5492 		return;
5493 	}
5494 
5495 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5496 }
5497 
5498 cmdline_parse_token_string_t cmd_setflushrx_set =
5499 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5500 			set, "set");
5501 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5502 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5503 			flush_rx, "flush_rx");
5504 cmdline_parse_token_string_t cmd_setflushrx_mode =
5505 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5506 			mode, "on#off");
5507 
5508 
5509 cmdline_parse_inst_t cmd_set_flush_rx = {
5510 	.f = cmd_set_flush_rx_parsed,
5511 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5512 	.data = NULL,
5513 	.tokens = {
5514 		(void *)&cmd_setflushrx_set,
5515 		(void *)&cmd_setflushrx_flush_rx,
5516 		(void *)&cmd_setflushrx_mode,
5517 		NULL,
5518 	},
5519 };
5520 
5521 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5522 struct cmd_set_link_check {
5523 	cmdline_fixed_string_t set;
5524 	cmdline_fixed_string_t link_check;
5525 	cmdline_fixed_string_t mode;
5526 };
5527 
5528 static void
5529 cmd_set_link_check_parsed(void *parsed_result,
5530 		__rte_unused struct cmdline *cl,
5531 		__rte_unused void *data)
5532 {
5533 	struct cmd_set_link_check *res = parsed_result;
5534 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5535 }
5536 
5537 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5538 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5539 			set, "set");
5540 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5541 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5542 			link_check, "link_check");
5543 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5544 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5545 			mode, "on#off");
5546 
5547 
5548 cmdline_parse_inst_t cmd_set_link_check = {
5549 	.f = cmd_set_link_check_parsed,
5550 	.help_str = "set link_check on|off: Enable/Disable link status check "
5551 	            "when starting/stopping a port",
5552 	.data = NULL,
5553 	.tokens = {
5554 		(void *)&cmd_setlinkcheck_set,
5555 		(void *)&cmd_setlinkcheck_link_check,
5556 		(void *)&cmd_setlinkcheck_mode,
5557 		NULL,
5558 	},
5559 };
5560 
5561 /* *** SET NIC BYPASS MODE *** */
5562 struct cmd_set_bypass_mode_result {
5563 	cmdline_fixed_string_t set;
5564 	cmdline_fixed_string_t bypass;
5565 	cmdline_fixed_string_t mode;
5566 	cmdline_fixed_string_t value;
5567 	portid_t port_id;
5568 };
5569 
5570 static void
5571 cmd_set_bypass_mode_parsed(void *parsed_result,
5572 		__rte_unused struct cmdline *cl,
5573 		__rte_unused void *data)
5574 {
5575 	struct cmd_set_bypass_mode_result *res = parsed_result;
5576 	portid_t port_id = res->port_id;
5577 	int32_t rc = -EINVAL;
5578 
5579 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5580 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5581 
5582 	if (!strcmp(res->value, "bypass"))
5583 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5584 	else if (!strcmp(res->value, "isolate"))
5585 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5586 	else
5587 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5588 
5589 	/* Set the bypass mode for the relevant port. */
5590 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5591 #endif
5592 	if (rc != 0)
5593 		fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5594 			port_id);
5595 }
5596 
5597 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5598 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5599 			set, "set");
5600 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5601 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5602 			bypass, "bypass");
5603 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5604 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5605 			mode, "mode");
5606 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5607 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5608 			value, "normal#bypass#isolate");
5609 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5610 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5611 				port_id, RTE_UINT16);
5612 
5613 cmdline_parse_inst_t cmd_set_bypass_mode = {
5614 	.f = cmd_set_bypass_mode_parsed,
5615 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5616 	            "Set the NIC bypass mode for port_id",
5617 	.data = NULL,
5618 	.tokens = {
5619 		(void *)&cmd_setbypass_mode_set,
5620 		(void *)&cmd_setbypass_mode_bypass,
5621 		(void *)&cmd_setbypass_mode_mode,
5622 		(void *)&cmd_setbypass_mode_value,
5623 		(void *)&cmd_setbypass_mode_port,
5624 		NULL,
5625 	},
5626 };
5627 
5628 /* *** SET NIC BYPASS EVENT *** */
5629 struct cmd_set_bypass_event_result {
5630 	cmdline_fixed_string_t set;
5631 	cmdline_fixed_string_t bypass;
5632 	cmdline_fixed_string_t event;
5633 	cmdline_fixed_string_t event_value;
5634 	cmdline_fixed_string_t mode;
5635 	cmdline_fixed_string_t mode_value;
5636 	portid_t port_id;
5637 };
5638 
5639 static void
5640 cmd_set_bypass_event_parsed(void *parsed_result,
5641 		__rte_unused struct cmdline *cl,
5642 		__rte_unused void *data)
5643 {
5644 	int32_t rc = -EINVAL;
5645 	struct cmd_set_bypass_event_result *res = parsed_result;
5646 	portid_t port_id = res->port_id;
5647 
5648 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5649 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5650 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5651 
5652 	if (!strcmp(res->event_value, "timeout"))
5653 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5654 	else if (!strcmp(res->event_value, "os_on"))
5655 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5656 	else if (!strcmp(res->event_value, "os_off"))
5657 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5658 	else if (!strcmp(res->event_value, "power_on"))
5659 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5660 	else if (!strcmp(res->event_value, "power_off"))
5661 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5662 	else
5663 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5664 
5665 	if (!strcmp(res->mode_value, "bypass"))
5666 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5667 	else if (!strcmp(res->mode_value, "isolate"))
5668 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5669 	else
5670 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5671 
5672 	/* Set the watchdog timeout. */
5673 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5674 
5675 		rc = -EINVAL;
5676 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5677 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5678 							   bypass_timeout);
5679 		}
5680 		if (rc != 0) {
5681 			fprintf(stderr,
5682 				"Failed to set timeout value %u for port %d, errto code: %d.\n",
5683 				bypass_timeout, port_id, rc);
5684 		}
5685 	}
5686 
5687 	/* Set the bypass event to transition to bypass mode. */
5688 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5689 					      bypass_mode);
5690 #endif
5691 
5692 	if (rc != 0)
5693 		fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5694 			port_id);
5695 }
5696 
5697 cmdline_parse_token_string_t cmd_setbypass_event_set =
5698 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5699 			set, "set");
5700 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5701 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5702 			bypass, "bypass");
5703 cmdline_parse_token_string_t cmd_setbypass_event_event =
5704 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5705 			event, "event");
5706 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5707 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5708 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5709 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5710 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5711 			mode, "mode");
5712 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5713 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5714 			mode_value, "normal#bypass#isolate");
5715 cmdline_parse_token_num_t cmd_setbypass_event_port =
5716 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5717 				port_id, RTE_UINT16);
5718 
5719 cmdline_parse_inst_t cmd_set_bypass_event = {
5720 	.f = cmd_set_bypass_event_parsed,
5721 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5722 		"power_off mode normal|bypass|isolate <port_id>: "
5723 		"Set the NIC bypass event mode for port_id",
5724 	.data = NULL,
5725 	.tokens = {
5726 		(void *)&cmd_setbypass_event_set,
5727 		(void *)&cmd_setbypass_event_bypass,
5728 		(void *)&cmd_setbypass_event_event,
5729 		(void *)&cmd_setbypass_event_event_value,
5730 		(void *)&cmd_setbypass_event_mode,
5731 		(void *)&cmd_setbypass_event_mode_value,
5732 		(void *)&cmd_setbypass_event_port,
5733 		NULL,
5734 	},
5735 };
5736 
5737 
5738 /* *** SET NIC BYPASS TIMEOUT *** */
5739 struct cmd_set_bypass_timeout_result {
5740 	cmdline_fixed_string_t set;
5741 	cmdline_fixed_string_t bypass;
5742 	cmdline_fixed_string_t timeout;
5743 	cmdline_fixed_string_t value;
5744 };
5745 
5746 static void
5747 cmd_set_bypass_timeout_parsed(void *parsed_result,
5748 		__rte_unused struct cmdline *cl,
5749 		__rte_unused void *data)
5750 {
5751 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5752 
5753 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5754 	if (!strcmp(res->value, "1.5"))
5755 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5756 	else if (!strcmp(res->value, "2"))
5757 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5758 	else if (!strcmp(res->value, "3"))
5759 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5760 	else if (!strcmp(res->value, "4"))
5761 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5762 	else if (!strcmp(res->value, "8"))
5763 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5764 	else if (!strcmp(res->value, "16"))
5765 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5766 	else if (!strcmp(res->value, "32"))
5767 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5768 	else
5769 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5770 #endif
5771 }
5772 
5773 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5774 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5775 			set, "set");
5776 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5777 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5778 			bypass, "bypass");
5779 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5780 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5781 			timeout, "timeout");
5782 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5783 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5784 			value, "0#1.5#2#3#4#8#16#32");
5785 
5786 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5787 	.f = cmd_set_bypass_timeout_parsed,
5788 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5789 		"Set the NIC bypass watchdog timeout in seconds",
5790 	.data = NULL,
5791 	.tokens = {
5792 		(void *)&cmd_setbypass_timeout_set,
5793 		(void *)&cmd_setbypass_timeout_bypass,
5794 		(void *)&cmd_setbypass_timeout_timeout,
5795 		(void *)&cmd_setbypass_timeout_value,
5796 		NULL,
5797 	},
5798 };
5799 
5800 /* *** SHOW NIC BYPASS MODE *** */
5801 struct cmd_show_bypass_config_result {
5802 	cmdline_fixed_string_t show;
5803 	cmdline_fixed_string_t bypass;
5804 	cmdline_fixed_string_t config;
5805 	portid_t port_id;
5806 };
5807 
5808 static void
5809 cmd_show_bypass_config_parsed(void *parsed_result,
5810 		__rte_unused struct cmdline *cl,
5811 		__rte_unused void *data)
5812 {
5813 	struct cmd_show_bypass_config_result *res = parsed_result;
5814 	portid_t port_id = res->port_id;
5815 	int rc = -EINVAL;
5816 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5817 	uint32_t event_mode;
5818 	uint32_t bypass_mode;
5819 	uint32_t timeout = bypass_timeout;
5820 	unsigned int i;
5821 
5822 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5823 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5824 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5825 		{"UNKNOWN", "normal", "bypass", "isolate"};
5826 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5827 		"NONE",
5828 		"OS/board on",
5829 		"power supply on",
5830 		"OS/board off",
5831 		"power supply off",
5832 		"timeout"};
5833 
5834 	/* Display the bypass mode.*/
5835 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5836 		fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5837 			port_id);
5838 		return;
5839 	}
5840 	else {
5841 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5842 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5843 
5844 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5845 	}
5846 
5847 	/* Display the bypass timeout.*/
5848 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5849 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5850 
5851 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5852 
5853 	/* Display the bypass events and associated modes. */
5854 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5855 
5856 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5857 			fprintf(stderr,
5858 				"\tFailed to get bypass mode for event = %s\n",
5859 				events[i]);
5860 		} else {
5861 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5862 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5863 
5864 			printf("\tbypass event: %-16s = %s\n", events[i],
5865 				modes[event_mode]);
5866 		}
5867 	}
5868 #endif
5869 	if (rc != 0)
5870 		fprintf(stderr,
5871 			"\tFailed to get bypass configuration for port = %d\n",
5872 		       port_id);
5873 }
5874 
5875 cmdline_parse_token_string_t cmd_showbypass_config_show =
5876 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5877 			show, "show");
5878 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5879 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5880 			bypass, "bypass");
5881 cmdline_parse_token_string_t cmd_showbypass_config_config =
5882 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5883 			config, "config");
5884 cmdline_parse_token_num_t cmd_showbypass_config_port =
5885 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5886 				port_id, RTE_UINT16);
5887 
5888 cmdline_parse_inst_t cmd_show_bypass_config = {
5889 	.f = cmd_show_bypass_config_parsed,
5890 	.help_str = "show bypass config <port_id>: "
5891 	            "Show the NIC bypass config for port_id",
5892 	.data = NULL,
5893 	.tokens = {
5894 		(void *)&cmd_showbypass_config_show,
5895 		(void *)&cmd_showbypass_config_bypass,
5896 		(void *)&cmd_showbypass_config_config,
5897 		(void *)&cmd_showbypass_config_port,
5898 		NULL,
5899 	},
5900 };
5901 
5902 #ifdef RTE_NET_BOND
5903 /* *** SET BONDING MODE *** */
5904 struct cmd_set_bonding_mode_result {
5905 	cmdline_fixed_string_t set;
5906 	cmdline_fixed_string_t bonding;
5907 	cmdline_fixed_string_t mode;
5908 	uint8_t value;
5909 	portid_t port_id;
5910 };
5911 
5912 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5913 		__rte_unused  struct cmdline *cl,
5914 		__rte_unused void *data)
5915 {
5916 	struct cmd_set_bonding_mode_result *res = parsed_result;
5917 	portid_t port_id = res->port_id;
5918 
5919 	/* Set the bonding mode for the relevant port. */
5920 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5921 		fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5922 			port_id);
5923 }
5924 
5925 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5927 		set, "set");
5928 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5930 		bonding, "bonding");
5931 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5933 		mode, "mode");
5934 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5935 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5936 		value, RTE_UINT8);
5937 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5938 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5939 		port_id, RTE_UINT16);
5940 
5941 cmdline_parse_inst_t cmd_set_bonding_mode = {
5942 		.f = cmd_set_bonding_mode_parsed,
5943 		.help_str = "set bonding mode <mode_value> <port_id>: "
5944 			"Set the bonding mode for port_id",
5945 		.data = NULL,
5946 		.tokens = {
5947 				(void *) &cmd_setbonding_mode_set,
5948 				(void *) &cmd_setbonding_mode_bonding,
5949 				(void *) &cmd_setbonding_mode_mode,
5950 				(void *) &cmd_setbonding_mode_value,
5951 				(void *) &cmd_setbonding_mode_port,
5952 				NULL
5953 		}
5954 };
5955 
5956 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5957 struct cmd_set_bonding_lacp_dedicated_queues_result {
5958 	cmdline_fixed_string_t set;
5959 	cmdline_fixed_string_t bonding;
5960 	cmdline_fixed_string_t lacp;
5961 	cmdline_fixed_string_t dedicated_queues;
5962 	portid_t port_id;
5963 	cmdline_fixed_string_t mode;
5964 };
5965 
5966 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5967 		__rte_unused  struct cmdline *cl,
5968 		__rte_unused void *data)
5969 {
5970 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5971 	portid_t port_id = res->port_id;
5972 	struct rte_port *port;
5973 
5974 	port = &ports[port_id];
5975 
5976 	/** Check if the port is not started **/
5977 	if (port->port_status != RTE_PORT_STOPPED) {
5978 		fprintf(stderr, "Please stop port %d first\n", port_id);
5979 		return;
5980 	}
5981 
5982 	if (!strcmp(res->mode, "enable")) {
5983 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5984 			printf("Dedicate queues for LACP control packets"
5985 					" enabled\n");
5986 		else
5987 			printf("Enabling dedicate queues for LACP control "
5988 					"packets on port %d failed\n", port_id);
5989 	} else if (!strcmp(res->mode, "disable")) {
5990 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5991 			printf("Dedicated queues for LACP control packets "
5992 					"disabled\n");
5993 		else
5994 			printf("Disabling dedicated queues for LACP control "
5995 					"traffic on port %d failed\n", port_id);
5996 	}
5997 }
5998 
5999 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6000 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6001 		set, "set");
6002 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6004 		bonding, "bonding");
6005 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6006 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6007 		lacp, "lacp");
6008 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6009 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6010 		dedicated_queues, "dedicated_queues");
6011 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6012 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6013 		port_id, RTE_UINT16);
6014 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6015 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6016 		mode, "enable#disable");
6017 
6018 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6019 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6020 		.help_str = "set bonding lacp dedicated_queues <port_id> "
6021 			"enable|disable: "
6022 			"Enable/disable dedicated queues for LACP control traffic for port_id",
6023 		.data = NULL,
6024 		.tokens = {
6025 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
6026 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6027 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6028 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6029 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6030 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6031 			NULL
6032 		}
6033 };
6034 
6035 /* *** SET BALANCE XMIT POLICY *** */
6036 struct cmd_set_bonding_balance_xmit_policy_result {
6037 	cmdline_fixed_string_t set;
6038 	cmdline_fixed_string_t bonding;
6039 	cmdline_fixed_string_t balance_xmit_policy;
6040 	portid_t port_id;
6041 	cmdline_fixed_string_t policy;
6042 };
6043 
6044 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6045 		__rte_unused  struct cmdline *cl,
6046 		__rte_unused void *data)
6047 {
6048 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6049 	portid_t port_id = res->port_id;
6050 	uint8_t policy;
6051 
6052 	if (!strcmp(res->policy, "l2")) {
6053 		policy = BALANCE_XMIT_POLICY_LAYER2;
6054 	} else if (!strcmp(res->policy, "l23")) {
6055 		policy = BALANCE_XMIT_POLICY_LAYER23;
6056 	} else if (!strcmp(res->policy, "l34")) {
6057 		policy = BALANCE_XMIT_POLICY_LAYER34;
6058 	} else {
6059 		fprintf(stderr, "\t Invalid xmit policy selection");
6060 		return;
6061 	}
6062 
6063 	/* Set the bonding mode for the relevant port. */
6064 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6065 		fprintf(stderr,
6066 			"\t Failed to set bonding balance xmit policy for port = %d.\n",
6067 			port_id);
6068 	}
6069 }
6070 
6071 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6073 		set, "set");
6074 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6076 		bonding, "bonding");
6077 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6078 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6079 		balance_xmit_policy, "balance_xmit_policy");
6080 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6081 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6082 		port_id, RTE_UINT16);
6083 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6084 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6085 		policy, "l2#l23#l34");
6086 
6087 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6088 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
6089 		.help_str = "set bonding balance_xmit_policy <port_id> "
6090 			"l2|l23|l34: "
6091 			"Set the bonding balance_xmit_policy for port_id",
6092 		.data = NULL,
6093 		.tokens = {
6094 				(void *)&cmd_setbonding_balance_xmit_policy_set,
6095 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
6096 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6097 				(void *)&cmd_setbonding_balance_xmit_policy_port,
6098 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
6099 				NULL
6100 		}
6101 };
6102 
6103 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6104 struct cmd_show_bonding_lacp_info_result {
6105 	cmdline_fixed_string_t show;
6106 	cmdline_fixed_string_t bonding;
6107 	cmdline_fixed_string_t lacp;
6108 	cmdline_fixed_string_t info;
6109 	portid_t port_id;
6110 };
6111 
6112 static void port_param_show(struct port_params *params)
6113 {
6114 	char buf[RTE_ETHER_ADDR_FMT_SIZE];
6115 
6116 	printf("\t\tsystem priority: %u\n", params->system_priority);
6117 	rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, &params->system);
6118 	printf("\t\tsystem mac address: %s\n", buf);
6119 	printf("\t\tport key: %u\n", params->key);
6120 	printf("\t\tport priority: %u\n", params->port_priority);
6121 	printf("\t\tport number: %u\n", params->port_number);
6122 }
6123 
6124 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6125 {
6126 	char a_state[256] = { 0 };
6127 	char p_state[256] = { 0 };
6128 	int a_len = 0;
6129 	int p_len = 0;
6130 	uint32_t i;
6131 
6132 	static const char * const state[] = {
6133 		"ACTIVE",
6134 		"TIMEOUT",
6135 		"AGGREGATION",
6136 		"SYNCHRONIZATION",
6137 		"COLLECTING",
6138 		"DISTRIBUTING",
6139 		"DEFAULTED",
6140 		"EXPIRED"
6141 	};
6142 	static const char * const selection[] = {
6143 		"UNSELECTED",
6144 		"STANDBY",
6145 		"SELECTED"
6146 	};
6147 
6148 	for (i = 0; i < RTE_DIM(state); i++) {
6149 		if ((info->actor_state >> i) & 1)
6150 			a_len += snprintf(&a_state[a_len],
6151 						RTE_DIM(a_state) - a_len, "%s ",
6152 						state[i]);
6153 
6154 		if ((info->partner_state >> i) & 1)
6155 			p_len += snprintf(&p_state[p_len],
6156 						RTE_DIM(p_state) - p_len, "%s ",
6157 						state[i]);
6158 	}
6159 	printf("\tAggregator port id: %u\n", info->agg_port_id);
6160 	printf("\tselection: %s\n", selection[info->selected]);
6161 	printf("\tActor detail info:\n");
6162 	port_param_show(&info->actor);
6163 	printf("\t\tport state: %s\n", a_state);
6164 	printf("\tPartner detail info:\n");
6165 	port_param_show(&info->partner);
6166 	printf("\t\tport state: %s\n", p_state);
6167 	printf("\n");
6168 }
6169 
6170 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6171 {
6172 	printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6173 	printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6174 	printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6175 	printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6176 	printf("\taggregate wait timeout: %u ms\n",
6177 			conf->aggregate_wait_timeout_ms);
6178 	printf("\ttx period: %u ms\n", conf->tx_period_ms);
6179 	printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6180 	printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6181 	switch (conf->agg_selection) {
6182 	case AGG_BANDWIDTH:
6183 		printf("\taggregation mode: bandwidth\n");
6184 		break;
6185 	case AGG_STABLE:
6186 		printf("\taggregation mode: stable\n");
6187 		break;
6188 	case AGG_COUNT:
6189 		printf("\taggregation mode: count\n");
6190 		break;
6191 	default:
6192 		printf("\taggregation mode: invalid\n");
6193 		break;
6194 	}
6195 
6196 	printf("\n");
6197 }
6198 
6199 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6200 		__rte_unused  struct cmdline *cl,
6201 		__rte_unused void *data)
6202 {
6203 	struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6204 	struct rte_eth_bond_8023ad_slave_info slave_info;
6205 	struct rte_eth_bond_8023ad_conf port_conf;
6206 	portid_t slaves[RTE_MAX_ETHPORTS];
6207 	portid_t port_id = res->port_id;
6208 	int num_active_slaves;
6209 	int bonding_mode;
6210 	int i;
6211 	int ret;
6212 
6213 	bonding_mode = rte_eth_bond_mode_get(port_id);
6214 	if (bonding_mode != BONDING_MODE_8023AD) {
6215 		fprintf(stderr, "\tBonding mode is not mode 4\n");
6216 		return;
6217 	}
6218 
6219 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6220 			RTE_MAX_ETHPORTS);
6221 	if (num_active_slaves < 0) {
6222 		fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6223 				port_id);
6224 		return;
6225 	}
6226 	if (num_active_slaves == 0)
6227 		fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6228 			port_id);
6229 
6230 	printf("\tIEEE802.3 port: %u\n", port_id);
6231 	ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6232 	if (ret) {
6233 		fprintf(stderr, "\tGet bonded device %u info failed\n",
6234 			port_id);
6235 		return;
6236 	}
6237 	lacp_conf_show(&port_conf);
6238 
6239 	for (i = 0; i < num_active_slaves; i++) {
6240 		ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6241 				&slave_info);
6242 		if (ret) {
6243 			fprintf(stderr, "\tGet slave device %u info failed\n",
6244 				slaves[i]);
6245 			return;
6246 		}
6247 		printf("\tSlave Port: %u\n", slaves[i]);
6248 		lacp_slave_info_show(&slave_info);
6249 	}
6250 }
6251 
6252 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6253 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6254 		show, "show");
6255 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6256 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6257 		bonding, "bonding");
6258 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6259 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6260 		bonding, "lacp");
6261 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6262 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6263 		info, "info");
6264 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6265 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6266 		port_id, RTE_UINT16);
6267 
6268 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6269 		.f = cmd_show_bonding_lacp_info_parsed,
6270 		.help_str = "show bonding lacp info <port_id> : "
6271 			"Show bonding IEEE802.3 information for port_id",
6272 		.data = NULL,
6273 		.tokens = {
6274 			(void *)&cmd_show_bonding_lacp_info_show,
6275 			(void *)&cmd_show_bonding_lacp_info_bonding,
6276 			(void *)&cmd_show_bonding_lacp_info_lacp,
6277 			(void *)&cmd_show_bonding_lacp_info_info,
6278 			(void *)&cmd_show_bonding_lacp_info_port_id,
6279 			NULL
6280 		}
6281 };
6282 
6283 /* *** SHOW NIC BONDING CONFIGURATION *** */
6284 struct cmd_show_bonding_config_result {
6285 	cmdline_fixed_string_t show;
6286 	cmdline_fixed_string_t bonding;
6287 	cmdline_fixed_string_t config;
6288 	portid_t port_id;
6289 };
6290 
6291 static void cmd_show_bonding_config_parsed(void *parsed_result,
6292 		__rte_unused  struct cmdline *cl,
6293 		__rte_unused void *data)
6294 {
6295 	struct cmd_show_bonding_config_result *res = parsed_result;
6296 	int bonding_mode, agg_mode;
6297 	portid_t slaves[RTE_MAX_ETHPORTS];
6298 	int num_slaves, num_active_slaves;
6299 	int primary_id;
6300 	int i;
6301 	portid_t port_id = res->port_id;
6302 
6303 	/* Display the bonding mode.*/
6304 	bonding_mode = rte_eth_bond_mode_get(port_id);
6305 	if (bonding_mode < 0) {
6306 		fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6307 			port_id);
6308 		return;
6309 	} else
6310 		printf("\tBonding mode: %d\n", bonding_mode);
6311 
6312 	if (bonding_mode == BONDING_MODE_BALANCE ||
6313 		bonding_mode == BONDING_MODE_8023AD) {
6314 		int balance_xmit_policy;
6315 
6316 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6317 		if (balance_xmit_policy < 0) {
6318 			fprintf(stderr,
6319 				"\tFailed to get balance xmit policy for port = %d\n",
6320 				port_id);
6321 			return;
6322 		} else {
6323 			printf("\tBalance Xmit Policy: ");
6324 
6325 			switch (balance_xmit_policy) {
6326 			case BALANCE_XMIT_POLICY_LAYER2:
6327 				printf("BALANCE_XMIT_POLICY_LAYER2");
6328 				break;
6329 			case BALANCE_XMIT_POLICY_LAYER23:
6330 				printf("BALANCE_XMIT_POLICY_LAYER23");
6331 				break;
6332 			case BALANCE_XMIT_POLICY_LAYER34:
6333 				printf("BALANCE_XMIT_POLICY_LAYER34");
6334 				break;
6335 			}
6336 			printf("\n");
6337 		}
6338 	}
6339 
6340 	if (bonding_mode == BONDING_MODE_8023AD) {
6341 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6342 		printf("\tIEEE802.3AD Aggregator Mode: ");
6343 		switch (agg_mode) {
6344 		case AGG_BANDWIDTH:
6345 			printf("bandwidth");
6346 			break;
6347 		case AGG_STABLE:
6348 			printf("stable");
6349 			break;
6350 		case AGG_COUNT:
6351 			printf("count");
6352 			break;
6353 		}
6354 		printf("\n");
6355 	}
6356 
6357 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6358 
6359 	if (num_slaves < 0) {
6360 		fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6361 			port_id);
6362 		return;
6363 	}
6364 	if (num_slaves > 0) {
6365 		printf("\tSlaves (%d): [", num_slaves);
6366 		for (i = 0; i < num_slaves - 1; i++)
6367 			printf("%d ", slaves[i]);
6368 
6369 		printf("%d]\n", slaves[num_slaves - 1]);
6370 	} else {
6371 		printf("\tSlaves: []\n");
6372 
6373 	}
6374 
6375 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6376 			RTE_MAX_ETHPORTS);
6377 
6378 	if (num_active_slaves < 0) {
6379 		fprintf(stderr,
6380 			"\tFailed to get active slave list for port = %d\n",
6381 			port_id);
6382 		return;
6383 	}
6384 	if (num_active_slaves > 0) {
6385 		printf("\tActive Slaves (%d): [", num_active_slaves);
6386 		for (i = 0; i < num_active_slaves - 1; i++)
6387 			printf("%d ", slaves[i]);
6388 
6389 		printf("%d]\n", slaves[num_active_slaves - 1]);
6390 
6391 	} else {
6392 		printf("\tActive Slaves: []\n");
6393 
6394 	}
6395 
6396 	primary_id = rte_eth_bond_primary_get(port_id);
6397 	if (primary_id < 0) {
6398 		fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6399 			port_id);
6400 		return;
6401 	} else
6402 		printf("\tPrimary: [%d]\n", primary_id);
6403 
6404 }
6405 
6406 cmdline_parse_token_string_t cmd_showbonding_config_show =
6407 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6408 		show, "show");
6409 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6410 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6411 		bonding, "bonding");
6412 cmdline_parse_token_string_t cmd_showbonding_config_config =
6413 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6414 		config, "config");
6415 cmdline_parse_token_num_t cmd_showbonding_config_port =
6416 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6417 		port_id, RTE_UINT16);
6418 
6419 cmdline_parse_inst_t cmd_show_bonding_config = {
6420 		.f = cmd_show_bonding_config_parsed,
6421 		.help_str = "show bonding config <port_id>: "
6422 			"Show the bonding config for port_id",
6423 		.data = NULL,
6424 		.tokens = {
6425 				(void *)&cmd_showbonding_config_show,
6426 				(void *)&cmd_showbonding_config_bonding,
6427 				(void *)&cmd_showbonding_config_config,
6428 				(void *)&cmd_showbonding_config_port,
6429 				NULL
6430 		}
6431 };
6432 
6433 /* *** SET BONDING PRIMARY *** */
6434 struct cmd_set_bonding_primary_result {
6435 	cmdline_fixed_string_t set;
6436 	cmdline_fixed_string_t bonding;
6437 	cmdline_fixed_string_t primary;
6438 	portid_t slave_id;
6439 	portid_t port_id;
6440 };
6441 
6442 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6443 		__rte_unused  struct cmdline *cl,
6444 		__rte_unused void *data)
6445 {
6446 	struct cmd_set_bonding_primary_result *res = parsed_result;
6447 	portid_t master_port_id = res->port_id;
6448 	portid_t slave_port_id = res->slave_id;
6449 
6450 	/* Set the primary slave for a bonded device. */
6451 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6452 		fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6453 			master_port_id);
6454 		return;
6455 	}
6456 	init_port_config();
6457 }
6458 
6459 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6461 		set, "set");
6462 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6464 		bonding, "bonding");
6465 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6467 		primary, "primary");
6468 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6469 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6470 		slave_id, RTE_UINT16);
6471 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6472 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6473 		port_id, RTE_UINT16);
6474 
6475 cmdline_parse_inst_t cmd_set_bonding_primary = {
6476 		.f = cmd_set_bonding_primary_parsed,
6477 		.help_str = "set bonding primary <slave_id> <port_id>: "
6478 			"Set the primary slave for port_id",
6479 		.data = NULL,
6480 		.tokens = {
6481 				(void *)&cmd_setbonding_primary_set,
6482 				(void *)&cmd_setbonding_primary_bonding,
6483 				(void *)&cmd_setbonding_primary_primary,
6484 				(void *)&cmd_setbonding_primary_slave,
6485 				(void *)&cmd_setbonding_primary_port,
6486 				NULL
6487 		}
6488 };
6489 
6490 /* *** ADD SLAVE *** */
6491 struct cmd_add_bonding_slave_result {
6492 	cmdline_fixed_string_t add;
6493 	cmdline_fixed_string_t bonding;
6494 	cmdline_fixed_string_t slave;
6495 	portid_t slave_id;
6496 	portid_t port_id;
6497 };
6498 
6499 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6500 		__rte_unused  struct cmdline *cl,
6501 		__rte_unused void *data)
6502 {
6503 	struct cmd_add_bonding_slave_result *res = parsed_result;
6504 	portid_t master_port_id = res->port_id;
6505 	portid_t slave_port_id = res->slave_id;
6506 
6507 	/* add the slave for a bonded device. */
6508 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6509 		fprintf(stderr,
6510 			"\t Failed to add slave %d to master port = %d.\n",
6511 			slave_port_id, master_port_id);
6512 		return;
6513 	}
6514 	init_port_config();
6515 	set_port_slave_flag(slave_port_id);
6516 }
6517 
6518 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6519 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6520 		add, "add");
6521 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6522 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6523 		bonding, "bonding");
6524 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6525 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6526 		slave, "slave");
6527 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6528 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6529 		slave_id, RTE_UINT16);
6530 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6531 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6532 		port_id, RTE_UINT16);
6533 
6534 cmdline_parse_inst_t cmd_add_bonding_slave = {
6535 		.f = cmd_add_bonding_slave_parsed,
6536 		.help_str = "add bonding slave <slave_id> <port_id>: "
6537 			"Add a slave device to a bonded device",
6538 		.data = NULL,
6539 		.tokens = {
6540 				(void *)&cmd_addbonding_slave_add,
6541 				(void *)&cmd_addbonding_slave_bonding,
6542 				(void *)&cmd_addbonding_slave_slave,
6543 				(void *)&cmd_addbonding_slave_slaveid,
6544 				(void *)&cmd_addbonding_slave_port,
6545 				NULL
6546 		}
6547 };
6548 
6549 /* *** REMOVE SLAVE *** */
6550 struct cmd_remove_bonding_slave_result {
6551 	cmdline_fixed_string_t remove;
6552 	cmdline_fixed_string_t bonding;
6553 	cmdline_fixed_string_t slave;
6554 	portid_t slave_id;
6555 	portid_t port_id;
6556 };
6557 
6558 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6559 		__rte_unused  struct cmdline *cl,
6560 		__rte_unused void *data)
6561 {
6562 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6563 	portid_t master_port_id = res->port_id;
6564 	portid_t slave_port_id = res->slave_id;
6565 
6566 	/* remove the slave from a bonded device. */
6567 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6568 		fprintf(stderr,
6569 			"\t Failed to remove slave %d from master port = %d.\n",
6570 			slave_port_id, master_port_id);
6571 		return;
6572 	}
6573 	init_port_config();
6574 	clear_port_slave_flag(slave_port_id);
6575 }
6576 
6577 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6578 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6579 				remove, "remove");
6580 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6581 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6582 				bonding, "bonding");
6583 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6584 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6585 				slave, "slave");
6586 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6587 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6588 				slave_id, RTE_UINT16);
6589 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6590 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6591 				port_id, RTE_UINT16);
6592 
6593 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6594 		.f = cmd_remove_bonding_slave_parsed,
6595 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6596 			"Remove a slave device from a bonded device",
6597 		.data = NULL,
6598 		.tokens = {
6599 				(void *)&cmd_removebonding_slave_remove,
6600 				(void *)&cmd_removebonding_slave_bonding,
6601 				(void *)&cmd_removebonding_slave_slave,
6602 				(void *)&cmd_removebonding_slave_slaveid,
6603 				(void *)&cmd_removebonding_slave_port,
6604 				NULL
6605 		}
6606 };
6607 
6608 /* *** CREATE BONDED DEVICE *** */
6609 struct cmd_create_bonded_device_result {
6610 	cmdline_fixed_string_t create;
6611 	cmdline_fixed_string_t bonded;
6612 	cmdline_fixed_string_t device;
6613 	uint8_t mode;
6614 	uint8_t socket;
6615 };
6616 
6617 static int bond_dev_num = 0;
6618 
6619 static void cmd_create_bonded_device_parsed(void *parsed_result,
6620 		__rte_unused  struct cmdline *cl,
6621 		__rte_unused void *data)
6622 {
6623 	struct cmd_create_bonded_device_result *res = parsed_result;
6624 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6625 	int port_id;
6626 	int ret;
6627 
6628 	if (test_done == 0) {
6629 		fprintf(stderr, "Please stop forwarding first\n");
6630 		return;
6631 	}
6632 
6633 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6634 			bond_dev_num++);
6635 
6636 	/* Create a new bonded device. */
6637 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6638 	if (port_id < 0) {
6639 		fprintf(stderr, "\t Failed to create bonded device.\n");
6640 		return;
6641 	} else {
6642 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6643 				port_id);
6644 
6645 		/* Update number of ports */
6646 		nb_ports = rte_eth_dev_count_avail();
6647 		reconfig(port_id, res->socket);
6648 		ret = rte_eth_promiscuous_enable(port_id);
6649 		if (ret != 0)
6650 			fprintf(stderr,
6651 				"Failed to enable promiscuous mode for port %u: %s - ignore\n",
6652 				port_id, rte_strerror(-ret));
6653 
6654 		ports[port_id].need_setup = 0;
6655 		ports[port_id].port_status = RTE_PORT_STOPPED;
6656 	}
6657 
6658 }
6659 
6660 cmdline_parse_token_string_t cmd_createbonded_device_create =
6661 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6662 				create, "create");
6663 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6664 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6665 				bonded, "bonded");
6666 cmdline_parse_token_string_t cmd_createbonded_device_device =
6667 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6668 				device, "device");
6669 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6670 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6671 				mode, RTE_UINT8);
6672 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6673 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6674 				socket, RTE_UINT8);
6675 
6676 cmdline_parse_inst_t cmd_create_bonded_device = {
6677 		.f = cmd_create_bonded_device_parsed,
6678 		.help_str = "create bonded device <mode> <socket>: "
6679 			"Create a new bonded device with specific bonding mode and socket",
6680 		.data = NULL,
6681 		.tokens = {
6682 				(void *)&cmd_createbonded_device_create,
6683 				(void *)&cmd_createbonded_device_bonded,
6684 				(void *)&cmd_createbonded_device_device,
6685 				(void *)&cmd_createbonded_device_mode,
6686 				(void *)&cmd_createbonded_device_socket,
6687 				NULL
6688 		}
6689 };
6690 
6691 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6692 struct cmd_set_bond_mac_addr_result {
6693 	cmdline_fixed_string_t set;
6694 	cmdline_fixed_string_t bonding;
6695 	cmdline_fixed_string_t mac_addr;
6696 	uint16_t port_num;
6697 	struct rte_ether_addr address;
6698 };
6699 
6700 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6701 		__rte_unused  struct cmdline *cl,
6702 		__rte_unused void *data)
6703 {
6704 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6705 	int ret;
6706 
6707 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6708 		return;
6709 
6710 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6711 
6712 	/* check the return value and print it if is < 0 */
6713 	if (ret < 0)
6714 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6715 			strerror(-ret));
6716 }
6717 
6718 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6719 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6720 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6721 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6722 				"bonding");
6723 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6724 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6725 				"mac_addr");
6726 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6727 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6728 				port_num, RTE_UINT16);
6729 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6730 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6731 
6732 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6733 		.f = cmd_set_bond_mac_addr_parsed,
6734 		.data = (void *) 0,
6735 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6736 		.tokens = {
6737 				(void *)&cmd_set_bond_mac_addr_set,
6738 				(void *)&cmd_set_bond_mac_addr_bonding,
6739 				(void *)&cmd_set_bond_mac_addr_mac,
6740 				(void *)&cmd_set_bond_mac_addr_portnum,
6741 				(void *)&cmd_set_bond_mac_addr_addr,
6742 				NULL
6743 		}
6744 };
6745 
6746 
6747 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6748 struct cmd_set_bond_mon_period_result {
6749 	cmdline_fixed_string_t set;
6750 	cmdline_fixed_string_t bonding;
6751 	cmdline_fixed_string_t mon_period;
6752 	uint16_t port_num;
6753 	uint32_t period_ms;
6754 };
6755 
6756 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6757 		__rte_unused  struct cmdline *cl,
6758 		__rte_unused void *data)
6759 {
6760 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6761 	int ret;
6762 
6763 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6764 
6765 	/* check the return value and print it if is < 0 */
6766 	if (ret < 0)
6767 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6768 			strerror(-ret));
6769 }
6770 
6771 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6772 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6773 				set, "set");
6774 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6775 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6776 				bonding, "bonding");
6777 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6778 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6779 				mon_period,	"mon_period");
6780 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6781 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6782 				port_num, RTE_UINT16);
6783 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6784 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6785 				period_ms, RTE_UINT32);
6786 
6787 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6788 		.f = cmd_set_bond_mon_period_parsed,
6789 		.data = (void *) 0,
6790 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6791 		.tokens = {
6792 				(void *)&cmd_set_bond_mon_period_set,
6793 				(void *)&cmd_set_bond_mon_period_bonding,
6794 				(void *)&cmd_set_bond_mon_period_mon_period,
6795 				(void *)&cmd_set_bond_mon_period_portnum,
6796 				(void *)&cmd_set_bond_mon_period_period_ms,
6797 				NULL
6798 		}
6799 };
6800 
6801 
6802 
6803 struct cmd_set_bonding_agg_mode_policy_result {
6804 	cmdline_fixed_string_t set;
6805 	cmdline_fixed_string_t bonding;
6806 	cmdline_fixed_string_t agg_mode;
6807 	uint16_t port_num;
6808 	cmdline_fixed_string_t policy;
6809 };
6810 
6811 
6812 static void
6813 cmd_set_bonding_agg_mode(void *parsed_result,
6814 		__rte_unused struct cmdline *cl,
6815 		__rte_unused void *data)
6816 {
6817 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6818 	uint8_t policy = AGG_BANDWIDTH;
6819 
6820 	if (!strcmp(res->policy, "bandwidth"))
6821 		policy = AGG_BANDWIDTH;
6822 	else if (!strcmp(res->policy, "stable"))
6823 		policy = AGG_STABLE;
6824 	else if (!strcmp(res->policy, "count"))
6825 		policy = AGG_COUNT;
6826 
6827 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6828 }
6829 
6830 
6831 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6832 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6833 				set, "set");
6834 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6835 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6836 				bonding, "bonding");
6837 
6838 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6839 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6840 				agg_mode, "agg_mode");
6841 
6842 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6843 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6844 				port_num, RTE_UINT16);
6845 
6846 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6847 	TOKEN_STRING_INITIALIZER(
6848 			struct cmd_set_bonding_balance_xmit_policy_result,
6849 		policy, "stable#bandwidth#count");
6850 
6851 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6852 	.f = cmd_set_bonding_agg_mode,
6853 	.data = (void *) 0,
6854 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6855 	.tokens = {
6856 			(void *)&cmd_set_bonding_agg_mode_set,
6857 			(void *)&cmd_set_bonding_agg_mode_bonding,
6858 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6859 			(void *)&cmd_set_bonding_agg_mode_portnum,
6860 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6861 			NULL
6862 		}
6863 };
6864 
6865 
6866 #endif /* RTE_NET_BOND */
6867 
6868 /* *** SET FORWARDING MODE *** */
6869 struct cmd_set_fwd_mode_result {
6870 	cmdline_fixed_string_t set;
6871 	cmdline_fixed_string_t fwd;
6872 	cmdline_fixed_string_t mode;
6873 };
6874 
6875 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6876 				    __rte_unused struct cmdline *cl,
6877 				    __rte_unused void *data)
6878 {
6879 	struct cmd_set_fwd_mode_result *res = parsed_result;
6880 
6881 	retry_enabled = 0;
6882 	set_pkt_forwarding_mode(res->mode);
6883 }
6884 
6885 cmdline_parse_token_string_t cmd_setfwd_set =
6886 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6887 cmdline_parse_token_string_t cmd_setfwd_fwd =
6888 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6889 cmdline_parse_token_string_t cmd_setfwd_mode =
6890 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6891 		"" /* defined at init */);
6892 
6893 cmdline_parse_inst_t cmd_set_fwd_mode = {
6894 	.f = cmd_set_fwd_mode_parsed,
6895 	.data = NULL,
6896 	.help_str = NULL, /* defined at init */
6897 	.tokens = {
6898 		(void *)&cmd_setfwd_set,
6899 		(void *)&cmd_setfwd_fwd,
6900 		(void *)&cmd_setfwd_mode,
6901 		NULL,
6902 	},
6903 };
6904 
6905 static void cmd_set_fwd_mode_init(void)
6906 {
6907 	char *modes, *c;
6908 	static char token[128];
6909 	static char help[256];
6910 	cmdline_parse_token_string_t *token_struct;
6911 
6912 	modes = list_pkt_forwarding_modes();
6913 	snprintf(help, sizeof(help), "set fwd %s: "
6914 		"Set packet forwarding mode", modes);
6915 	cmd_set_fwd_mode.help_str = help;
6916 
6917 	/* string token separator is # */
6918 	for (c = token; *modes != '\0'; modes++)
6919 		if (*modes == '|')
6920 			*c++ = '#';
6921 		else
6922 			*c++ = *modes;
6923 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6924 	token_struct->string_data.str = token;
6925 }
6926 
6927 /* *** SET RETRY FORWARDING MODE *** */
6928 struct cmd_set_fwd_retry_mode_result {
6929 	cmdline_fixed_string_t set;
6930 	cmdline_fixed_string_t fwd;
6931 	cmdline_fixed_string_t mode;
6932 	cmdline_fixed_string_t retry;
6933 };
6934 
6935 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6936 			    __rte_unused struct cmdline *cl,
6937 			    __rte_unused void *data)
6938 {
6939 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6940 
6941 	retry_enabled = 1;
6942 	set_pkt_forwarding_mode(res->mode);
6943 }
6944 
6945 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6946 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6947 			set, "set");
6948 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6949 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6950 			fwd, "fwd");
6951 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6952 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6953 			mode,
6954 		"" /* defined at init */);
6955 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6956 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6957 			retry, "retry");
6958 
6959 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6960 	.f = cmd_set_fwd_retry_mode_parsed,
6961 	.data = NULL,
6962 	.help_str = NULL, /* defined at init */
6963 	.tokens = {
6964 		(void *)&cmd_setfwd_retry_set,
6965 		(void *)&cmd_setfwd_retry_fwd,
6966 		(void *)&cmd_setfwd_retry_mode,
6967 		(void *)&cmd_setfwd_retry_retry,
6968 		NULL,
6969 	},
6970 };
6971 
6972 static void cmd_set_fwd_retry_mode_init(void)
6973 {
6974 	char *modes, *c;
6975 	static char token[128];
6976 	static char help[256];
6977 	cmdline_parse_token_string_t *token_struct;
6978 
6979 	modes = list_pkt_forwarding_retry_modes();
6980 	snprintf(help, sizeof(help), "set fwd %s retry: "
6981 		"Set packet forwarding mode with retry", modes);
6982 	cmd_set_fwd_retry_mode.help_str = help;
6983 
6984 	/* string token separator is # */
6985 	for (c = token; *modes != '\0'; modes++)
6986 		if (*modes == '|')
6987 			*c++ = '#';
6988 		else
6989 			*c++ = *modes;
6990 	token_struct = (cmdline_parse_token_string_t *)
6991 		cmd_set_fwd_retry_mode.tokens[2];
6992 	token_struct->string_data.str = token;
6993 }
6994 
6995 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6996 struct cmd_set_burst_tx_retry_result {
6997 	cmdline_fixed_string_t set;
6998 	cmdline_fixed_string_t burst;
6999 	cmdline_fixed_string_t tx;
7000 	cmdline_fixed_string_t delay;
7001 	uint32_t time;
7002 	cmdline_fixed_string_t retry;
7003 	uint32_t retry_num;
7004 };
7005 
7006 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7007 					__rte_unused struct cmdline *cl,
7008 					__rte_unused void *data)
7009 {
7010 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
7011 
7012 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7013 		&& !strcmp(res->tx, "tx")) {
7014 		if (!strcmp(res->delay, "delay"))
7015 			burst_tx_delay_time = res->time;
7016 		if (!strcmp(res->retry, "retry"))
7017 			burst_tx_retry_num = res->retry_num;
7018 	}
7019 
7020 }
7021 
7022 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7023 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7024 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7025 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7026 				 "burst");
7027 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7028 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7029 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7030 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7031 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7032 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7033 				 RTE_UINT32);
7034 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7035 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7036 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7037 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7038 				 RTE_UINT32);
7039 
7040 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7041 	.f = cmd_set_burst_tx_retry_parsed,
7042 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7043 	.tokens = {
7044 		(void *)&cmd_set_burst_tx_retry_set,
7045 		(void *)&cmd_set_burst_tx_retry_burst,
7046 		(void *)&cmd_set_burst_tx_retry_tx,
7047 		(void *)&cmd_set_burst_tx_retry_delay,
7048 		(void *)&cmd_set_burst_tx_retry_time,
7049 		(void *)&cmd_set_burst_tx_retry_retry,
7050 		(void *)&cmd_set_burst_tx_retry_retry_num,
7051 		NULL,
7052 	},
7053 };
7054 
7055 /* *** SET PROMISC MODE *** */
7056 struct cmd_set_promisc_mode_result {
7057 	cmdline_fixed_string_t set;
7058 	cmdline_fixed_string_t promisc;
7059 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7060 	uint16_t port_num;               /* valid if "allports" argument == 0 */
7061 	cmdline_fixed_string_t mode;
7062 };
7063 
7064 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7065 					__rte_unused struct cmdline *cl,
7066 					void *allports)
7067 {
7068 	struct cmd_set_promisc_mode_result *res = parsed_result;
7069 	int enable;
7070 	portid_t i;
7071 
7072 	if (!strcmp(res->mode, "on"))
7073 		enable = 1;
7074 	else
7075 		enable = 0;
7076 
7077 	/* all ports */
7078 	if (allports) {
7079 		RTE_ETH_FOREACH_DEV(i)
7080 			eth_set_promisc_mode(i, enable);
7081 	} else {
7082 		eth_set_promisc_mode(res->port_num, enable);
7083 	}
7084 }
7085 
7086 cmdline_parse_token_string_t cmd_setpromisc_set =
7087 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7088 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7089 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7090 				 "promisc");
7091 cmdline_parse_token_string_t cmd_setpromisc_portall =
7092 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7093 				 "all");
7094 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7095 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7096 			      RTE_UINT16);
7097 cmdline_parse_token_string_t cmd_setpromisc_mode =
7098 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7099 				 "on#off");
7100 
7101 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7102 	.f = cmd_set_promisc_mode_parsed,
7103 	.data = (void *)1,
7104 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
7105 	.tokens = {
7106 		(void *)&cmd_setpromisc_set,
7107 		(void *)&cmd_setpromisc_promisc,
7108 		(void *)&cmd_setpromisc_portall,
7109 		(void *)&cmd_setpromisc_mode,
7110 		NULL,
7111 	},
7112 };
7113 
7114 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7115 	.f = cmd_set_promisc_mode_parsed,
7116 	.data = (void *)0,
7117 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7118 	.tokens = {
7119 		(void *)&cmd_setpromisc_set,
7120 		(void *)&cmd_setpromisc_promisc,
7121 		(void *)&cmd_setpromisc_portnum,
7122 		(void *)&cmd_setpromisc_mode,
7123 		NULL,
7124 	},
7125 };
7126 
7127 /* *** SET ALLMULTI MODE *** */
7128 struct cmd_set_allmulti_mode_result {
7129 	cmdline_fixed_string_t set;
7130 	cmdline_fixed_string_t allmulti;
7131 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7132 	uint16_t port_num;               /* valid if "allports" argument == 0 */
7133 	cmdline_fixed_string_t mode;
7134 };
7135 
7136 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7137 					__rte_unused struct cmdline *cl,
7138 					void *allports)
7139 {
7140 	struct cmd_set_allmulti_mode_result *res = parsed_result;
7141 	int enable;
7142 	portid_t i;
7143 
7144 	if (!strcmp(res->mode, "on"))
7145 		enable = 1;
7146 	else
7147 		enable = 0;
7148 
7149 	/* all ports */
7150 	if (allports) {
7151 		RTE_ETH_FOREACH_DEV(i) {
7152 			eth_set_allmulticast_mode(i, enable);
7153 		}
7154 	}
7155 	else {
7156 		eth_set_allmulticast_mode(res->port_num, enable);
7157 	}
7158 }
7159 
7160 cmdline_parse_token_string_t cmd_setallmulti_set =
7161 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7162 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7163 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7164 				 "allmulti");
7165 cmdline_parse_token_string_t cmd_setallmulti_portall =
7166 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7167 				 "all");
7168 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7169 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7170 			      RTE_UINT16);
7171 cmdline_parse_token_string_t cmd_setallmulti_mode =
7172 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7173 				 "on#off");
7174 
7175 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7176 	.f = cmd_set_allmulti_mode_parsed,
7177 	.data = (void *)1,
7178 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7179 	.tokens = {
7180 		(void *)&cmd_setallmulti_set,
7181 		(void *)&cmd_setallmulti_allmulti,
7182 		(void *)&cmd_setallmulti_portall,
7183 		(void *)&cmd_setallmulti_mode,
7184 		NULL,
7185 	},
7186 };
7187 
7188 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7189 	.f = cmd_set_allmulti_mode_parsed,
7190 	.data = (void *)0,
7191 	.help_str = "set allmulti <port_id> on|off: "
7192 		"Set allmulti mode on port_id",
7193 	.tokens = {
7194 		(void *)&cmd_setallmulti_set,
7195 		(void *)&cmd_setallmulti_allmulti,
7196 		(void *)&cmd_setallmulti_portnum,
7197 		(void *)&cmd_setallmulti_mode,
7198 		NULL,
7199 	},
7200 };
7201 
7202 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7203 struct cmd_link_flow_ctrl_show {
7204 	cmdline_fixed_string_t show;
7205 	cmdline_fixed_string_t port;
7206 	portid_t port_id;
7207 	cmdline_fixed_string_t flow_ctrl;
7208 };
7209 
7210 cmdline_parse_token_string_t cmd_lfc_show_show =
7211 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7212 				show, "show");
7213 cmdline_parse_token_string_t cmd_lfc_show_port =
7214 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7215 				port, "port");
7216 cmdline_parse_token_num_t cmd_lfc_show_portid =
7217 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7218 				port_id, RTE_UINT16);
7219 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7220 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7221 				flow_ctrl, "flow_ctrl");
7222 
7223 static void
7224 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7225 			      __rte_unused struct cmdline *cl,
7226 			      __rte_unused void *data)
7227 {
7228 	struct cmd_link_flow_ctrl_show *res = parsed_result;
7229 	static const char *info_border = "*********************";
7230 	struct rte_eth_fc_conf fc_conf;
7231 	bool rx_fc_en = false;
7232 	bool tx_fc_en = false;
7233 	int ret;
7234 
7235 	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7236 	if (ret != 0) {
7237 		fprintf(stderr,
7238 			"Failed to get current flow ctrl information: err = %d\n",
7239 			ret);
7240 		return;
7241 	}
7242 
7243 	if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7244 		rx_fc_en = true;
7245 	if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7246 		tx_fc_en = true;
7247 
7248 	printf("\n%s Flow control infos for port %-2d %s\n",
7249 		info_border, res->port_id, info_border);
7250 	printf("FC mode:\n");
7251 	printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
7252 	printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
7253 	printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7254 	printf("Pause time: 0x%x\n", fc_conf.pause_time);
7255 	printf("High waterline: 0x%x\n", fc_conf.high_water);
7256 	printf("Low waterline: 0x%x\n", fc_conf.low_water);
7257 	printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7258 	printf("Forward MAC control frames: %s\n",
7259 		fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7260 	printf("\n%s**************   End  ***********%s\n",
7261 		info_border, info_border);
7262 }
7263 
7264 cmdline_parse_inst_t cmd_link_flow_control_show = {
7265 	.f = cmd_link_flow_ctrl_show_parsed,
7266 	.data = NULL,
7267 	.help_str = "show port <port_id> flow_ctrl",
7268 	.tokens = {
7269 		(void *)&cmd_lfc_show_show,
7270 		(void *)&cmd_lfc_show_port,
7271 		(void *)&cmd_lfc_show_portid,
7272 		(void *)&cmd_lfc_show_flow_ctrl,
7273 		NULL,
7274 	},
7275 };
7276 
7277 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7278 struct cmd_link_flow_ctrl_set_result {
7279 	cmdline_fixed_string_t set;
7280 	cmdline_fixed_string_t flow_ctrl;
7281 	cmdline_fixed_string_t rx;
7282 	cmdline_fixed_string_t rx_lfc_mode;
7283 	cmdline_fixed_string_t tx;
7284 	cmdline_fixed_string_t tx_lfc_mode;
7285 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
7286 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7287 	cmdline_fixed_string_t autoneg_str;
7288 	cmdline_fixed_string_t autoneg;
7289 	cmdline_fixed_string_t hw_str;
7290 	uint32_t high_water;
7291 	cmdline_fixed_string_t lw_str;
7292 	uint32_t low_water;
7293 	cmdline_fixed_string_t pt_str;
7294 	uint16_t pause_time;
7295 	cmdline_fixed_string_t xon_str;
7296 	uint16_t send_xon;
7297 	portid_t port_id;
7298 };
7299 
7300 cmdline_parse_token_string_t cmd_lfc_set_set =
7301 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7302 				set, "set");
7303 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7304 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7305 				flow_ctrl, "flow_ctrl");
7306 cmdline_parse_token_string_t cmd_lfc_set_rx =
7307 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7308 				rx, "rx");
7309 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7310 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7311 				rx_lfc_mode, "on#off");
7312 cmdline_parse_token_string_t cmd_lfc_set_tx =
7313 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7314 				tx, "tx");
7315 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7316 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7317 				tx_lfc_mode, "on#off");
7318 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7319 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7320 				hw_str, "high_water");
7321 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7322 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7323 				high_water, RTE_UINT32);
7324 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7325 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7326 				lw_str, "low_water");
7327 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7328 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 				low_water, RTE_UINT32);
7330 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7331 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7332 				pt_str, "pause_time");
7333 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7334 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 				pause_time, RTE_UINT16);
7336 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7337 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7338 				xon_str, "send_xon");
7339 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7340 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7341 				send_xon, RTE_UINT16);
7342 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7343 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7344 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7345 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7346 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7347 				mac_ctrl_frame_fwd_mode, "on#off");
7348 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7349 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7350 				autoneg_str, "autoneg");
7351 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7352 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7353 				autoneg, "on#off");
7354 cmdline_parse_token_num_t cmd_lfc_set_portid =
7355 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7356 				port_id, RTE_UINT16);
7357 
7358 /* forward declaration */
7359 static void
7360 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7361 			      void *data);
7362 
7363 cmdline_parse_inst_t cmd_link_flow_control_set = {
7364 	.f = cmd_link_flow_ctrl_set_parsed,
7365 	.data = NULL,
7366 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7367 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7368 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
7369 	.tokens = {
7370 		(void *)&cmd_lfc_set_set,
7371 		(void *)&cmd_lfc_set_flow_ctrl,
7372 		(void *)&cmd_lfc_set_rx,
7373 		(void *)&cmd_lfc_set_rx_mode,
7374 		(void *)&cmd_lfc_set_tx,
7375 		(void *)&cmd_lfc_set_tx_mode,
7376 		(void *)&cmd_lfc_set_high_water,
7377 		(void *)&cmd_lfc_set_low_water,
7378 		(void *)&cmd_lfc_set_pause_time,
7379 		(void *)&cmd_lfc_set_send_xon,
7380 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7381 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7382 		(void *)&cmd_lfc_set_autoneg_str,
7383 		(void *)&cmd_lfc_set_autoneg,
7384 		(void *)&cmd_lfc_set_portid,
7385 		NULL,
7386 	},
7387 };
7388 
7389 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7390 	.f = cmd_link_flow_ctrl_set_parsed,
7391 	.data = (void *)&cmd_link_flow_control_set_rx,
7392 	.help_str = "set flow_ctrl rx on|off <port_id>: "
7393 		"Change rx flow control parameter",
7394 	.tokens = {
7395 		(void *)&cmd_lfc_set_set,
7396 		(void *)&cmd_lfc_set_flow_ctrl,
7397 		(void *)&cmd_lfc_set_rx,
7398 		(void *)&cmd_lfc_set_rx_mode,
7399 		(void *)&cmd_lfc_set_portid,
7400 		NULL,
7401 	},
7402 };
7403 
7404 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7405 	.f = cmd_link_flow_ctrl_set_parsed,
7406 	.data = (void *)&cmd_link_flow_control_set_tx,
7407 	.help_str = "set flow_ctrl tx on|off <port_id>: "
7408 		"Change tx flow control parameter",
7409 	.tokens = {
7410 		(void *)&cmd_lfc_set_set,
7411 		(void *)&cmd_lfc_set_flow_ctrl,
7412 		(void *)&cmd_lfc_set_tx,
7413 		(void *)&cmd_lfc_set_tx_mode,
7414 		(void *)&cmd_lfc_set_portid,
7415 		NULL,
7416 	},
7417 };
7418 
7419 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7420 	.f = cmd_link_flow_ctrl_set_parsed,
7421 	.data = (void *)&cmd_link_flow_control_set_hw,
7422 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
7423 		"Change high water flow control parameter",
7424 	.tokens = {
7425 		(void *)&cmd_lfc_set_set,
7426 		(void *)&cmd_lfc_set_flow_ctrl,
7427 		(void *)&cmd_lfc_set_high_water_str,
7428 		(void *)&cmd_lfc_set_high_water,
7429 		(void *)&cmd_lfc_set_portid,
7430 		NULL,
7431 	},
7432 };
7433 
7434 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7435 	.f = cmd_link_flow_ctrl_set_parsed,
7436 	.data = (void *)&cmd_link_flow_control_set_lw,
7437 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7438 		"Change low water flow control parameter",
7439 	.tokens = {
7440 		(void *)&cmd_lfc_set_set,
7441 		(void *)&cmd_lfc_set_flow_ctrl,
7442 		(void *)&cmd_lfc_set_low_water_str,
7443 		(void *)&cmd_lfc_set_low_water,
7444 		(void *)&cmd_lfc_set_portid,
7445 		NULL,
7446 	},
7447 };
7448 
7449 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7450 	.f = cmd_link_flow_ctrl_set_parsed,
7451 	.data = (void *)&cmd_link_flow_control_set_pt,
7452 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7453 		"Change pause time flow control parameter",
7454 	.tokens = {
7455 		(void *)&cmd_lfc_set_set,
7456 		(void *)&cmd_lfc_set_flow_ctrl,
7457 		(void *)&cmd_lfc_set_pause_time_str,
7458 		(void *)&cmd_lfc_set_pause_time,
7459 		(void *)&cmd_lfc_set_portid,
7460 		NULL,
7461 	},
7462 };
7463 
7464 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7465 	.f = cmd_link_flow_ctrl_set_parsed,
7466 	.data = (void *)&cmd_link_flow_control_set_xon,
7467 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7468 		"Change send_xon flow control parameter",
7469 	.tokens = {
7470 		(void *)&cmd_lfc_set_set,
7471 		(void *)&cmd_lfc_set_flow_ctrl,
7472 		(void *)&cmd_lfc_set_send_xon_str,
7473 		(void *)&cmd_lfc_set_send_xon,
7474 		(void *)&cmd_lfc_set_portid,
7475 		NULL,
7476 	},
7477 };
7478 
7479 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7480 	.f = cmd_link_flow_ctrl_set_parsed,
7481 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7482 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7483 		"Change mac ctrl fwd flow control parameter",
7484 	.tokens = {
7485 		(void *)&cmd_lfc_set_set,
7486 		(void *)&cmd_lfc_set_flow_ctrl,
7487 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7488 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7489 		(void *)&cmd_lfc_set_portid,
7490 		NULL,
7491 	},
7492 };
7493 
7494 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7495 	.f = cmd_link_flow_ctrl_set_parsed,
7496 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7497 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7498 		"Change autoneg flow control parameter",
7499 	.tokens = {
7500 		(void *)&cmd_lfc_set_set,
7501 		(void *)&cmd_lfc_set_flow_ctrl,
7502 		(void *)&cmd_lfc_set_autoneg_str,
7503 		(void *)&cmd_lfc_set_autoneg,
7504 		(void *)&cmd_lfc_set_portid,
7505 		NULL,
7506 	},
7507 };
7508 
7509 static void
7510 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7511 			      __rte_unused struct cmdline *cl,
7512 			      void *data)
7513 {
7514 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7515 	cmdline_parse_inst_t *cmd = data;
7516 	struct rte_eth_fc_conf fc_conf;
7517 	int rx_fc_en = 0;
7518 	int tx_fc_en = 0;
7519 	int ret;
7520 
7521 	/*
7522 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7523 	 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7524 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7525 	 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7526 	 */
7527 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7528 			{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7529 	};
7530 
7531 	/* Partial command line, retrieve current configuration */
7532 	if (cmd) {
7533 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7534 		if (ret != 0) {
7535 			fprintf(stderr,
7536 				"cannot get current flow ctrl parameters, return code = %d\n",
7537 				ret);
7538 			return;
7539 		}
7540 
7541 		if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7542 		    (fc_conf.mode == RTE_ETH_FC_FULL))
7543 			rx_fc_en = 1;
7544 		if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7545 		    (fc_conf.mode == RTE_ETH_FC_FULL))
7546 			tx_fc_en = 1;
7547 	}
7548 
7549 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7550 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7551 
7552 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7553 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7554 
7555 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7556 
7557 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7558 		fc_conf.high_water = res->high_water;
7559 
7560 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7561 		fc_conf.low_water = res->low_water;
7562 
7563 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7564 		fc_conf.pause_time = res->pause_time;
7565 
7566 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7567 		fc_conf.send_xon = res->send_xon;
7568 
7569 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7570 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7571 			fc_conf.mac_ctrl_frame_fwd = 1;
7572 		else
7573 			fc_conf.mac_ctrl_frame_fwd = 0;
7574 	}
7575 
7576 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7577 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7578 
7579 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7580 	if (ret != 0)
7581 		fprintf(stderr,
7582 			"bad flow control parameter, return code = %d\n",
7583 			ret);
7584 }
7585 
7586 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7587 struct cmd_priority_flow_ctrl_set_result {
7588 	cmdline_fixed_string_t set;
7589 	cmdline_fixed_string_t pfc_ctrl;
7590 	cmdline_fixed_string_t rx;
7591 	cmdline_fixed_string_t rx_pfc_mode;
7592 	cmdline_fixed_string_t tx;
7593 	cmdline_fixed_string_t tx_pfc_mode;
7594 	uint32_t high_water;
7595 	uint32_t low_water;
7596 	uint16_t pause_time;
7597 	uint8_t  priority;
7598 	portid_t port_id;
7599 };
7600 
7601 static void
7602 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7603 		       __rte_unused struct cmdline *cl,
7604 		       __rte_unused void *data)
7605 {
7606 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7607 	struct rte_eth_pfc_conf pfc_conf;
7608 	int rx_fc_enable, tx_fc_enable;
7609 	int ret;
7610 
7611 	/*
7612 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7613 	 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7614 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7615 	 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7616 	 */
7617 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7618 		{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7619 	};
7620 
7621 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7622 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7623 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7624 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7625 	pfc_conf.fc.high_water = res->high_water;
7626 	pfc_conf.fc.low_water  = res->low_water;
7627 	pfc_conf.fc.pause_time = res->pause_time;
7628 	pfc_conf.priority      = res->priority;
7629 
7630 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7631 	if (ret != 0)
7632 		fprintf(stderr,
7633 			"bad priority flow control parameter, return code = %d\n",
7634 			ret);
7635 }
7636 
7637 cmdline_parse_token_string_t cmd_pfc_set_set =
7638 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7639 				set, "set");
7640 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7641 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7642 				pfc_ctrl, "pfc_ctrl");
7643 cmdline_parse_token_string_t cmd_pfc_set_rx =
7644 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7645 				rx, "rx");
7646 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7647 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7648 				rx_pfc_mode, "on#off");
7649 cmdline_parse_token_string_t cmd_pfc_set_tx =
7650 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7651 				tx, "tx");
7652 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7653 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7654 				tx_pfc_mode, "on#off");
7655 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7656 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7657 				high_water, RTE_UINT32);
7658 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7659 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7660 				low_water, RTE_UINT32);
7661 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7662 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7663 				pause_time, RTE_UINT16);
7664 cmdline_parse_token_num_t cmd_pfc_set_priority =
7665 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7666 				priority, RTE_UINT8);
7667 cmdline_parse_token_num_t cmd_pfc_set_portid =
7668 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7669 				port_id, RTE_UINT16);
7670 
7671 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7672 	.f = cmd_priority_flow_ctrl_set_parsed,
7673 	.data = NULL,
7674 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7675 		"<pause_time> <priority> <port_id>: "
7676 		"Configure the Ethernet priority flow control",
7677 	.tokens = {
7678 		(void *)&cmd_pfc_set_set,
7679 		(void *)&cmd_pfc_set_flow_ctrl,
7680 		(void *)&cmd_pfc_set_rx,
7681 		(void *)&cmd_pfc_set_rx_mode,
7682 		(void *)&cmd_pfc_set_tx,
7683 		(void *)&cmd_pfc_set_tx_mode,
7684 		(void *)&cmd_pfc_set_high_water,
7685 		(void *)&cmd_pfc_set_low_water,
7686 		(void *)&cmd_pfc_set_pause_time,
7687 		(void *)&cmd_pfc_set_priority,
7688 		(void *)&cmd_pfc_set_portid,
7689 		NULL,
7690 	},
7691 };
7692 
7693 /* *** RESET CONFIGURATION *** */
7694 struct cmd_reset_result {
7695 	cmdline_fixed_string_t reset;
7696 	cmdline_fixed_string_t def;
7697 };
7698 
7699 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7700 			     struct cmdline *cl,
7701 			     __rte_unused void *data)
7702 {
7703 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7704 	set_def_fwd_config();
7705 }
7706 
7707 cmdline_parse_token_string_t cmd_reset_set =
7708 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7709 cmdline_parse_token_string_t cmd_reset_def =
7710 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7711 				 "default");
7712 
7713 cmdline_parse_inst_t cmd_reset = {
7714 	.f = cmd_reset_parsed,
7715 	.data = NULL,
7716 	.help_str = "set default: Reset default forwarding configuration",
7717 	.tokens = {
7718 		(void *)&cmd_reset_set,
7719 		(void *)&cmd_reset_def,
7720 		NULL,
7721 	},
7722 };
7723 
7724 /* *** START FORWARDING *** */
7725 struct cmd_start_result {
7726 	cmdline_fixed_string_t start;
7727 };
7728 
7729 cmdline_parse_token_string_t cmd_start_start =
7730 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7731 
7732 static void cmd_start_parsed(__rte_unused void *parsed_result,
7733 			     __rte_unused struct cmdline *cl,
7734 			     __rte_unused void *data)
7735 {
7736 	start_packet_forwarding(0);
7737 }
7738 
7739 cmdline_parse_inst_t cmd_start = {
7740 	.f = cmd_start_parsed,
7741 	.data = NULL,
7742 	.help_str = "start: Start packet forwarding",
7743 	.tokens = {
7744 		(void *)&cmd_start_start,
7745 		NULL,
7746 	},
7747 };
7748 
7749 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7750 struct cmd_start_tx_first_result {
7751 	cmdline_fixed_string_t start;
7752 	cmdline_fixed_string_t tx_first;
7753 };
7754 
7755 static void
7756 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7757 			  __rte_unused struct cmdline *cl,
7758 			  __rte_unused void *data)
7759 {
7760 	start_packet_forwarding(1);
7761 }
7762 
7763 cmdline_parse_token_string_t cmd_start_tx_first_start =
7764 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7765 				 "start");
7766 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7767 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7768 				 tx_first, "tx_first");
7769 
7770 cmdline_parse_inst_t cmd_start_tx_first = {
7771 	.f = cmd_start_tx_first_parsed,
7772 	.data = NULL,
7773 	.help_str = "start tx_first: Start packet forwarding, "
7774 		"after sending 1 burst of packets",
7775 	.tokens = {
7776 		(void *)&cmd_start_tx_first_start,
7777 		(void *)&cmd_start_tx_first_tx_first,
7778 		NULL,
7779 	},
7780 };
7781 
7782 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7783 struct cmd_start_tx_first_n_result {
7784 	cmdline_fixed_string_t start;
7785 	cmdline_fixed_string_t tx_first;
7786 	uint32_t tx_num;
7787 };
7788 
7789 static void
7790 cmd_start_tx_first_n_parsed(void *parsed_result,
7791 			  __rte_unused struct cmdline *cl,
7792 			  __rte_unused void *data)
7793 {
7794 	struct cmd_start_tx_first_n_result *res = parsed_result;
7795 
7796 	start_packet_forwarding(res->tx_num);
7797 }
7798 
7799 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7800 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7801 			start, "start");
7802 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7803 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7804 			tx_first, "tx_first");
7805 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7806 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7807 			tx_num, RTE_UINT32);
7808 
7809 cmdline_parse_inst_t cmd_start_tx_first_n = {
7810 	.f = cmd_start_tx_first_n_parsed,
7811 	.data = NULL,
7812 	.help_str = "start tx_first <num>: "
7813 		"packet forwarding, after sending <num> bursts of packets",
7814 	.tokens = {
7815 		(void *)&cmd_start_tx_first_n_start,
7816 		(void *)&cmd_start_tx_first_n_tx_first,
7817 		(void *)&cmd_start_tx_first_n_tx_num,
7818 		NULL,
7819 	},
7820 };
7821 
7822 /* *** SET LINK UP *** */
7823 struct cmd_set_link_up_result {
7824 	cmdline_fixed_string_t set;
7825 	cmdline_fixed_string_t link_up;
7826 	cmdline_fixed_string_t port;
7827 	portid_t port_id;
7828 };
7829 
7830 cmdline_parse_token_string_t cmd_set_link_up_set =
7831 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7832 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7833 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7834 				"link-up");
7835 cmdline_parse_token_string_t cmd_set_link_up_port =
7836 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7837 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7838 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7839 				RTE_UINT16);
7840 
7841 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7842 			     __rte_unused struct cmdline *cl,
7843 			     __rte_unused void *data)
7844 {
7845 	struct cmd_set_link_up_result *res = parsed_result;
7846 	dev_set_link_up(res->port_id);
7847 }
7848 
7849 cmdline_parse_inst_t cmd_set_link_up = {
7850 	.f = cmd_set_link_up_parsed,
7851 	.data = NULL,
7852 	.help_str = "set link-up port <port id>",
7853 	.tokens = {
7854 		(void *)&cmd_set_link_up_set,
7855 		(void *)&cmd_set_link_up_link_up,
7856 		(void *)&cmd_set_link_up_port,
7857 		(void *)&cmd_set_link_up_port_id,
7858 		NULL,
7859 	},
7860 };
7861 
7862 /* *** SET LINK DOWN *** */
7863 struct cmd_set_link_down_result {
7864 	cmdline_fixed_string_t set;
7865 	cmdline_fixed_string_t link_down;
7866 	cmdline_fixed_string_t port;
7867 	portid_t port_id;
7868 };
7869 
7870 cmdline_parse_token_string_t cmd_set_link_down_set =
7871 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7872 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7873 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7874 				"link-down");
7875 cmdline_parse_token_string_t cmd_set_link_down_port =
7876 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7877 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7878 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7879 				RTE_UINT16);
7880 
7881 static void cmd_set_link_down_parsed(
7882 				__rte_unused void *parsed_result,
7883 				__rte_unused struct cmdline *cl,
7884 				__rte_unused void *data)
7885 {
7886 	struct cmd_set_link_down_result *res = parsed_result;
7887 	dev_set_link_down(res->port_id);
7888 }
7889 
7890 cmdline_parse_inst_t cmd_set_link_down = {
7891 	.f = cmd_set_link_down_parsed,
7892 	.data = NULL,
7893 	.help_str = "set link-down port <port id>",
7894 	.tokens = {
7895 		(void *)&cmd_set_link_down_set,
7896 		(void *)&cmd_set_link_down_link_down,
7897 		(void *)&cmd_set_link_down_port,
7898 		(void *)&cmd_set_link_down_port_id,
7899 		NULL,
7900 	},
7901 };
7902 
7903 /* *** SHOW CFG *** */
7904 struct cmd_showcfg_result {
7905 	cmdline_fixed_string_t show;
7906 	cmdline_fixed_string_t cfg;
7907 	cmdline_fixed_string_t what;
7908 };
7909 
7910 static void cmd_showcfg_parsed(void *parsed_result,
7911 			       __rte_unused struct cmdline *cl,
7912 			       __rte_unused void *data)
7913 {
7914 	struct cmd_showcfg_result *res = parsed_result;
7915 	if (!strcmp(res->what, "rxtx"))
7916 		rxtx_config_display();
7917 	else if (!strcmp(res->what, "cores"))
7918 		fwd_lcores_config_display();
7919 	else if (!strcmp(res->what, "fwd"))
7920 		pkt_fwd_config_display(&cur_fwd_config);
7921 	else if (!strcmp(res->what, "rxoffs"))
7922 		show_rx_pkt_offsets();
7923 	else if (!strcmp(res->what, "rxpkts"))
7924 		show_rx_pkt_segments();
7925 	else if (!strcmp(res->what, "txpkts"))
7926 		show_tx_pkt_segments();
7927 	else if (!strcmp(res->what, "txtimes"))
7928 		show_tx_pkt_times();
7929 }
7930 
7931 cmdline_parse_token_string_t cmd_showcfg_show =
7932 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7933 cmdline_parse_token_string_t cmd_showcfg_port =
7934 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7935 cmdline_parse_token_string_t cmd_showcfg_what =
7936 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7937 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7938 
7939 cmdline_parse_inst_t cmd_showcfg = {
7940 	.f = cmd_showcfg_parsed,
7941 	.data = NULL,
7942 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7943 	.tokens = {
7944 		(void *)&cmd_showcfg_show,
7945 		(void *)&cmd_showcfg_port,
7946 		(void *)&cmd_showcfg_what,
7947 		NULL,
7948 	},
7949 };
7950 
7951 /* *** SHOW ALL PORT INFO *** */
7952 struct cmd_showportall_result {
7953 	cmdline_fixed_string_t show;
7954 	cmdline_fixed_string_t port;
7955 	cmdline_fixed_string_t what;
7956 	cmdline_fixed_string_t all;
7957 };
7958 
7959 static void cmd_showportall_parsed(void *parsed_result,
7960 				__rte_unused struct cmdline *cl,
7961 				__rte_unused void *data)
7962 {
7963 	portid_t i;
7964 
7965 	struct cmd_showportall_result *res = parsed_result;
7966 	if (!strcmp(res->show, "clear")) {
7967 		if (!strcmp(res->what, "stats"))
7968 			RTE_ETH_FOREACH_DEV(i)
7969 				nic_stats_clear(i);
7970 		else if (!strcmp(res->what, "xstats"))
7971 			RTE_ETH_FOREACH_DEV(i)
7972 				nic_xstats_clear(i);
7973 	} else if (!strcmp(res->what, "info"))
7974 		RTE_ETH_FOREACH_DEV(i)
7975 			port_infos_display(i);
7976 	else if (!strcmp(res->what, "summary")) {
7977 		port_summary_header_display();
7978 		RTE_ETH_FOREACH_DEV(i)
7979 			port_summary_display(i);
7980 	}
7981 	else if (!strcmp(res->what, "stats"))
7982 		RTE_ETH_FOREACH_DEV(i)
7983 			nic_stats_display(i);
7984 	else if (!strcmp(res->what, "xstats"))
7985 		RTE_ETH_FOREACH_DEV(i)
7986 			nic_xstats_display(i);
7987 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7988 	else if (!strcmp(res->what, "fdir"))
7989 		RTE_ETH_FOREACH_DEV(i)
7990 			fdir_get_infos(i);
7991 #endif
7992 	else if (!strcmp(res->what, "dcb_tc"))
7993 		RTE_ETH_FOREACH_DEV(i)
7994 			port_dcb_info_display(i);
7995 }
7996 
7997 cmdline_parse_token_string_t cmd_showportall_show =
7998 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7999 				 "show#clear");
8000 cmdline_parse_token_string_t cmd_showportall_port =
8001 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8002 cmdline_parse_token_string_t cmd_showportall_what =
8003 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8004 				 "info#summary#stats#xstats#fdir#dcb_tc");
8005 cmdline_parse_token_string_t cmd_showportall_all =
8006 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8007 cmdline_parse_inst_t cmd_showportall = {
8008 	.f = cmd_showportall_parsed,
8009 	.data = NULL,
8010 	.help_str = "show|clear port "
8011 		"info|summary|stats|xstats|fdir|dcb_tc all",
8012 	.tokens = {
8013 		(void *)&cmd_showportall_show,
8014 		(void *)&cmd_showportall_port,
8015 		(void *)&cmd_showportall_what,
8016 		(void *)&cmd_showportall_all,
8017 		NULL,
8018 	},
8019 };
8020 
8021 /* *** SHOW PORT INFO *** */
8022 struct cmd_showport_result {
8023 	cmdline_fixed_string_t show;
8024 	cmdline_fixed_string_t port;
8025 	cmdline_fixed_string_t what;
8026 	uint16_t portnum;
8027 };
8028 
8029 static void cmd_showport_parsed(void *parsed_result,
8030 				__rte_unused struct cmdline *cl,
8031 				__rte_unused void *data)
8032 {
8033 	struct cmd_showport_result *res = parsed_result;
8034 	if (!strcmp(res->show, "clear")) {
8035 		if (!strcmp(res->what, "stats"))
8036 			nic_stats_clear(res->portnum);
8037 		else if (!strcmp(res->what, "xstats"))
8038 			nic_xstats_clear(res->portnum);
8039 	} else if (!strcmp(res->what, "info"))
8040 		port_infos_display(res->portnum);
8041 	else if (!strcmp(res->what, "summary")) {
8042 		port_summary_header_display();
8043 		port_summary_display(res->portnum);
8044 	}
8045 	else if (!strcmp(res->what, "stats"))
8046 		nic_stats_display(res->portnum);
8047 	else if (!strcmp(res->what, "xstats"))
8048 		nic_xstats_display(res->portnum);
8049 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8050 	else if (!strcmp(res->what, "fdir"))
8051 		 fdir_get_infos(res->portnum);
8052 #endif
8053 	else if (!strcmp(res->what, "dcb_tc"))
8054 		port_dcb_info_display(res->portnum);
8055 }
8056 
8057 cmdline_parse_token_string_t cmd_showport_show =
8058 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8059 				 "show#clear");
8060 cmdline_parse_token_string_t cmd_showport_port =
8061 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8062 cmdline_parse_token_string_t cmd_showport_what =
8063 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8064 				 "info#summary#stats#xstats#fdir#dcb_tc");
8065 cmdline_parse_token_num_t cmd_showport_portnum =
8066 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8067 
8068 cmdline_parse_inst_t cmd_showport = {
8069 	.f = cmd_showport_parsed,
8070 	.data = NULL,
8071 	.help_str = "show|clear port "
8072 		"info|summary|stats|xstats|fdir|dcb_tc "
8073 		"<port_id>",
8074 	.tokens = {
8075 		(void *)&cmd_showport_show,
8076 		(void *)&cmd_showport_port,
8077 		(void *)&cmd_showport_what,
8078 		(void *)&cmd_showport_portnum,
8079 		NULL,
8080 	},
8081 };
8082 
8083 /* *** show port representors information *** */
8084 struct cmd_representor_info_result {
8085 	cmdline_fixed_string_t cmd_show;
8086 	cmdline_fixed_string_t cmd_port;
8087 	cmdline_fixed_string_t cmd_info;
8088 	cmdline_fixed_string_t cmd_keyword;
8089 	portid_t cmd_pid;
8090 };
8091 
8092 static void
8093 cmd_representor_info_parsed(void *parsed_result,
8094 		__rte_unused struct cmdline *cl,
8095 		__rte_unused void *data)
8096 {
8097 	struct cmd_representor_info_result *res = parsed_result;
8098 	struct rte_eth_representor_info *info;
8099 	struct rte_eth_representor_range *range;
8100 	uint32_t range_diff;
8101 	uint32_t i;
8102 	int ret;
8103 	int num;
8104 
8105 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8106 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8107 		return;
8108 	}
8109 
8110 	ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8111 	if (ret < 0) {
8112 		fprintf(stderr,
8113 			"Failed to get the number of representor info ranges for port %hu: %s\n",
8114 			res->cmd_pid, rte_strerror(-ret));
8115 		return;
8116 	}
8117 	num = ret;
8118 
8119 	info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8120 	if (info == NULL) {
8121 		fprintf(stderr,
8122 			"Failed to allocate memory for representor info for port %hu\n",
8123 			res->cmd_pid);
8124 		return;
8125 	}
8126 	info->nb_ranges_alloc = num;
8127 
8128 	ret = rte_eth_representor_info_get(res->cmd_pid, info);
8129 	if (ret < 0) {
8130 		fprintf(stderr,
8131 			"Failed to get the representor info for port %hu: %s\n",
8132 			res->cmd_pid, rte_strerror(-ret));
8133 		free(info);
8134 		return;
8135 	}
8136 
8137 	printf("Port controller: %hu\n", info->controller);
8138 	printf("Port PF: %hu\n", info->pf);
8139 
8140 	printf("Ranges: %u\n", info->nb_ranges);
8141 	for (i = 0; i < info->nb_ranges; i++) {
8142 		range = &info->ranges[i];
8143 		range_diff = range->id_end - range->id_base;
8144 
8145 		printf("%u. ", i + 1);
8146 		printf("'%s' ", range->name);
8147 		if (range_diff > 0)
8148 			printf("[%u-%u]: ", range->id_base, range->id_end);
8149 		else
8150 			printf("[%u]: ", range->id_base);
8151 
8152 		printf("Controller %d, PF %d", range->controller, range->pf);
8153 
8154 		switch (range->type) {
8155 		case RTE_ETH_REPRESENTOR_NONE:
8156 			printf(", NONE\n");
8157 			break;
8158 		case RTE_ETH_REPRESENTOR_VF:
8159 			if (range_diff > 0)
8160 				printf(", VF %d..%d\n", range->vf,
8161 				       range->vf + range_diff);
8162 			else
8163 				printf(", VF %d\n", range->vf);
8164 			break;
8165 		case RTE_ETH_REPRESENTOR_SF:
8166 			printf(", SF %d\n", range->sf);
8167 			break;
8168 		case RTE_ETH_REPRESENTOR_PF:
8169 			if (range_diff > 0)
8170 				printf("..%d\n", range->pf + range_diff);
8171 			else
8172 				printf("\n");
8173 			break;
8174 		default:
8175 			printf(", UNKNOWN TYPE %d\n", range->type);
8176 			break;
8177 		}
8178 	}
8179 
8180 	free(info);
8181 }
8182 
8183 cmdline_parse_token_string_t cmd_representor_info_show =
8184 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8185 			cmd_show, "show");
8186 cmdline_parse_token_string_t cmd_representor_info_port =
8187 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8188 			cmd_port, "port");
8189 cmdline_parse_token_string_t cmd_representor_info_info =
8190 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8191 			cmd_info, "info");
8192 cmdline_parse_token_num_t cmd_representor_info_pid =
8193 	TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8194 			cmd_pid, RTE_UINT16);
8195 cmdline_parse_token_string_t cmd_representor_info_keyword =
8196 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8197 			cmd_keyword, "representor");
8198 
8199 cmdline_parse_inst_t cmd_representor_info = {
8200 	.f = cmd_representor_info_parsed,
8201 	.data = NULL,
8202 	.help_str = "show port info <port_id> representor",
8203 	.tokens = {
8204 		(void *)&cmd_representor_info_show,
8205 		(void *)&cmd_representor_info_port,
8206 		(void *)&cmd_representor_info_info,
8207 		(void *)&cmd_representor_info_pid,
8208 		(void *)&cmd_representor_info_keyword,
8209 		NULL,
8210 	},
8211 };
8212 
8213 
8214 /* *** SHOW DEVICE INFO *** */
8215 struct cmd_showdevice_result {
8216 	cmdline_fixed_string_t show;
8217 	cmdline_fixed_string_t device;
8218 	cmdline_fixed_string_t what;
8219 	cmdline_fixed_string_t identifier;
8220 };
8221 
8222 static void cmd_showdevice_parsed(void *parsed_result,
8223 				__rte_unused struct cmdline *cl,
8224 				__rte_unused void *data)
8225 {
8226 	struct cmd_showdevice_result *res = parsed_result;
8227 	if (!strcmp(res->what, "info")) {
8228 		if (!strcmp(res->identifier, "all"))
8229 			device_infos_display(NULL);
8230 		else
8231 			device_infos_display(res->identifier);
8232 	}
8233 }
8234 
8235 cmdline_parse_token_string_t cmd_showdevice_show =
8236 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8237 				 "show");
8238 cmdline_parse_token_string_t cmd_showdevice_device =
8239 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8240 cmdline_parse_token_string_t cmd_showdevice_what =
8241 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8242 				 "info");
8243 cmdline_parse_token_string_t cmd_showdevice_identifier =
8244 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8245 			identifier, NULL);
8246 
8247 cmdline_parse_inst_t cmd_showdevice = {
8248 	.f = cmd_showdevice_parsed,
8249 	.data = NULL,
8250 	.help_str = "show device info <identifier>|all",
8251 	.tokens = {
8252 		(void *)&cmd_showdevice_show,
8253 		(void *)&cmd_showdevice_device,
8254 		(void *)&cmd_showdevice_what,
8255 		(void *)&cmd_showdevice_identifier,
8256 		NULL,
8257 	},
8258 };
8259 
8260 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8261 struct cmd_showeeprom_result {
8262 	cmdline_fixed_string_t show;
8263 	cmdline_fixed_string_t port;
8264 	uint16_t portnum;
8265 	cmdline_fixed_string_t type;
8266 };
8267 
8268 static void cmd_showeeprom_parsed(void *parsed_result,
8269 		__rte_unused struct cmdline *cl,
8270 		__rte_unused void *data)
8271 {
8272 	struct cmd_showeeprom_result *res = parsed_result;
8273 
8274 	if (!strcmp(res->type, "eeprom"))
8275 		port_eeprom_display(res->portnum);
8276 	else if (!strcmp(res->type, "module_eeprom"))
8277 		port_module_eeprom_display(res->portnum);
8278 	else
8279 		fprintf(stderr, "Unknown argument\n");
8280 }
8281 
8282 cmdline_parse_token_string_t cmd_showeeprom_show =
8283 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8284 cmdline_parse_token_string_t cmd_showeeprom_port =
8285 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8286 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8287 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8288 			RTE_UINT16);
8289 cmdline_parse_token_string_t cmd_showeeprom_type =
8290 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8291 
8292 cmdline_parse_inst_t cmd_showeeprom = {
8293 	.f = cmd_showeeprom_parsed,
8294 	.data = NULL,
8295 	.help_str = "show port <port_id> module_eeprom|eeprom",
8296 	.tokens = {
8297 		(void *)&cmd_showeeprom_show,
8298 		(void *)&cmd_showeeprom_port,
8299 		(void *)&cmd_showeeprom_portnum,
8300 		(void *)&cmd_showeeprom_type,
8301 		NULL,
8302 	},
8303 };
8304 
8305 /* *** SHOW QUEUE INFO *** */
8306 struct cmd_showqueue_result {
8307 	cmdline_fixed_string_t show;
8308 	cmdline_fixed_string_t type;
8309 	cmdline_fixed_string_t what;
8310 	uint16_t portnum;
8311 	uint16_t queuenum;
8312 };
8313 
8314 static void
8315 cmd_showqueue_parsed(void *parsed_result,
8316 	__rte_unused struct cmdline *cl,
8317 	__rte_unused void *data)
8318 {
8319 	struct cmd_showqueue_result *res = parsed_result;
8320 
8321 	if (!strcmp(res->type, "rxq"))
8322 		rx_queue_infos_display(res->portnum, res->queuenum);
8323 	else if (!strcmp(res->type, "txq"))
8324 		tx_queue_infos_display(res->portnum, res->queuenum);
8325 }
8326 
8327 cmdline_parse_token_string_t cmd_showqueue_show =
8328 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8329 cmdline_parse_token_string_t cmd_showqueue_type =
8330 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8331 cmdline_parse_token_string_t cmd_showqueue_what =
8332 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8333 cmdline_parse_token_num_t cmd_showqueue_portnum =
8334 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8335 		RTE_UINT16);
8336 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8337 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8338 		RTE_UINT16);
8339 
8340 cmdline_parse_inst_t cmd_showqueue = {
8341 	.f = cmd_showqueue_parsed,
8342 	.data = NULL,
8343 	.help_str = "show rxq|txq info <port_id> <queue_id>",
8344 	.tokens = {
8345 		(void *)&cmd_showqueue_show,
8346 		(void *)&cmd_showqueue_type,
8347 		(void *)&cmd_showqueue_what,
8348 		(void *)&cmd_showqueue_portnum,
8349 		(void *)&cmd_showqueue_queuenum,
8350 		NULL,
8351 	},
8352 };
8353 
8354 /* show/clear fwd engine statistics */
8355 struct fwd_result {
8356 	cmdline_fixed_string_t action;
8357 	cmdline_fixed_string_t fwd;
8358 	cmdline_fixed_string_t stats;
8359 	cmdline_fixed_string_t all;
8360 };
8361 
8362 cmdline_parse_token_string_t cmd_fwd_action =
8363 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8364 cmdline_parse_token_string_t cmd_fwd_fwd =
8365 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8366 cmdline_parse_token_string_t cmd_fwd_stats =
8367 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8368 cmdline_parse_token_string_t cmd_fwd_all =
8369 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8370 
8371 static void
8372 cmd_showfwdall_parsed(void *parsed_result,
8373 		      __rte_unused struct cmdline *cl,
8374 		      __rte_unused void *data)
8375 {
8376 	struct fwd_result *res = parsed_result;
8377 
8378 	if (!strcmp(res->action, "show"))
8379 		fwd_stats_display();
8380 	else
8381 		fwd_stats_reset();
8382 }
8383 
8384 static cmdline_parse_inst_t cmd_showfwdall = {
8385 	.f = cmd_showfwdall_parsed,
8386 	.data = NULL,
8387 	.help_str = "show|clear fwd stats all",
8388 	.tokens = {
8389 		(void *)&cmd_fwd_action,
8390 		(void *)&cmd_fwd_fwd,
8391 		(void *)&cmd_fwd_stats,
8392 		(void *)&cmd_fwd_all,
8393 		NULL,
8394 	},
8395 };
8396 
8397 /* *** READ PORT REGISTER *** */
8398 struct cmd_read_reg_result {
8399 	cmdline_fixed_string_t read;
8400 	cmdline_fixed_string_t reg;
8401 	portid_t port_id;
8402 	uint32_t reg_off;
8403 };
8404 
8405 static void
8406 cmd_read_reg_parsed(void *parsed_result,
8407 		    __rte_unused struct cmdline *cl,
8408 		    __rte_unused void *data)
8409 {
8410 	struct cmd_read_reg_result *res = parsed_result;
8411 	port_reg_display(res->port_id, res->reg_off);
8412 }
8413 
8414 cmdline_parse_token_string_t cmd_read_reg_read =
8415 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8416 cmdline_parse_token_string_t cmd_read_reg_reg =
8417 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8418 cmdline_parse_token_num_t cmd_read_reg_port_id =
8419 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8420 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8421 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8422 
8423 cmdline_parse_inst_t cmd_read_reg = {
8424 	.f = cmd_read_reg_parsed,
8425 	.data = NULL,
8426 	.help_str = "read reg <port_id> <reg_off>",
8427 	.tokens = {
8428 		(void *)&cmd_read_reg_read,
8429 		(void *)&cmd_read_reg_reg,
8430 		(void *)&cmd_read_reg_port_id,
8431 		(void *)&cmd_read_reg_reg_off,
8432 		NULL,
8433 	},
8434 };
8435 
8436 /* *** READ PORT REGISTER BIT FIELD *** */
8437 struct cmd_read_reg_bit_field_result {
8438 	cmdline_fixed_string_t read;
8439 	cmdline_fixed_string_t regfield;
8440 	portid_t port_id;
8441 	uint32_t reg_off;
8442 	uint8_t bit1_pos;
8443 	uint8_t bit2_pos;
8444 };
8445 
8446 static void
8447 cmd_read_reg_bit_field_parsed(void *parsed_result,
8448 			      __rte_unused struct cmdline *cl,
8449 			      __rte_unused void *data)
8450 {
8451 	struct cmd_read_reg_bit_field_result *res = parsed_result;
8452 	port_reg_bit_field_display(res->port_id, res->reg_off,
8453 				   res->bit1_pos, res->bit2_pos);
8454 }
8455 
8456 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8457 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8458 				 "read");
8459 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8460 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8461 				 regfield, "regfield");
8462 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8463 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8464 			      RTE_UINT16);
8465 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8466 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8467 			      RTE_UINT32);
8468 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8469 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8470 			      RTE_UINT8);
8471 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8472 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8473 			      RTE_UINT8);
8474 
8475 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8476 	.f = cmd_read_reg_bit_field_parsed,
8477 	.data = NULL,
8478 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8479 	"Read register bit field between bit_x and bit_y included",
8480 	.tokens = {
8481 		(void *)&cmd_read_reg_bit_field_read,
8482 		(void *)&cmd_read_reg_bit_field_regfield,
8483 		(void *)&cmd_read_reg_bit_field_port_id,
8484 		(void *)&cmd_read_reg_bit_field_reg_off,
8485 		(void *)&cmd_read_reg_bit_field_bit1_pos,
8486 		(void *)&cmd_read_reg_bit_field_bit2_pos,
8487 		NULL,
8488 	},
8489 };
8490 
8491 /* *** READ PORT REGISTER BIT *** */
8492 struct cmd_read_reg_bit_result {
8493 	cmdline_fixed_string_t read;
8494 	cmdline_fixed_string_t regbit;
8495 	portid_t port_id;
8496 	uint32_t reg_off;
8497 	uint8_t bit_pos;
8498 };
8499 
8500 static void
8501 cmd_read_reg_bit_parsed(void *parsed_result,
8502 			__rte_unused struct cmdline *cl,
8503 			__rte_unused void *data)
8504 {
8505 	struct cmd_read_reg_bit_result *res = parsed_result;
8506 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8507 }
8508 
8509 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8510 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8511 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8512 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8513 				 regbit, "regbit");
8514 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8515 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8516 				 RTE_UINT16);
8517 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8518 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8519 				 RTE_UINT32);
8520 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8521 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8522 				 RTE_UINT8);
8523 
8524 cmdline_parse_inst_t cmd_read_reg_bit = {
8525 	.f = cmd_read_reg_bit_parsed,
8526 	.data = NULL,
8527 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8528 	.tokens = {
8529 		(void *)&cmd_read_reg_bit_read,
8530 		(void *)&cmd_read_reg_bit_regbit,
8531 		(void *)&cmd_read_reg_bit_port_id,
8532 		(void *)&cmd_read_reg_bit_reg_off,
8533 		(void *)&cmd_read_reg_bit_bit_pos,
8534 		NULL,
8535 	},
8536 };
8537 
8538 /* *** WRITE PORT REGISTER *** */
8539 struct cmd_write_reg_result {
8540 	cmdline_fixed_string_t write;
8541 	cmdline_fixed_string_t reg;
8542 	portid_t port_id;
8543 	uint32_t reg_off;
8544 	uint32_t value;
8545 };
8546 
8547 static void
8548 cmd_write_reg_parsed(void *parsed_result,
8549 		     __rte_unused struct cmdline *cl,
8550 		     __rte_unused void *data)
8551 {
8552 	struct cmd_write_reg_result *res = parsed_result;
8553 	port_reg_set(res->port_id, res->reg_off, res->value);
8554 }
8555 
8556 cmdline_parse_token_string_t cmd_write_reg_write =
8557 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8558 cmdline_parse_token_string_t cmd_write_reg_reg =
8559 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8560 cmdline_parse_token_num_t cmd_write_reg_port_id =
8561 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8562 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8563 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8564 cmdline_parse_token_num_t cmd_write_reg_value =
8565 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8566 
8567 cmdline_parse_inst_t cmd_write_reg = {
8568 	.f = cmd_write_reg_parsed,
8569 	.data = NULL,
8570 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8571 	.tokens = {
8572 		(void *)&cmd_write_reg_write,
8573 		(void *)&cmd_write_reg_reg,
8574 		(void *)&cmd_write_reg_port_id,
8575 		(void *)&cmd_write_reg_reg_off,
8576 		(void *)&cmd_write_reg_value,
8577 		NULL,
8578 	},
8579 };
8580 
8581 /* *** WRITE PORT REGISTER BIT FIELD *** */
8582 struct cmd_write_reg_bit_field_result {
8583 	cmdline_fixed_string_t write;
8584 	cmdline_fixed_string_t regfield;
8585 	portid_t port_id;
8586 	uint32_t reg_off;
8587 	uint8_t bit1_pos;
8588 	uint8_t bit2_pos;
8589 	uint32_t value;
8590 };
8591 
8592 static void
8593 cmd_write_reg_bit_field_parsed(void *parsed_result,
8594 			       __rte_unused struct cmdline *cl,
8595 			       __rte_unused void *data)
8596 {
8597 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8598 	port_reg_bit_field_set(res->port_id, res->reg_off,
8599 			  res->bit1_pos, res->bit2_pos, res->value);
8600 }
8601 
8602 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8603 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8604 				 "write");
8605 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8606 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8607 				 regfield, "regfield");
8608 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8609 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8610 			      RTE_UINT16);
8611 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8612 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8613 			      RTE_UINT32);
8614 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8615 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8616 			      RTE_UINT8);
8617 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8618 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8619 			      RTE_UINT8);
8620 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8621 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8622 			      RTE_UINT32);
8623 
8624 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8625 	.f = cmd_write_reg_bit_field_parsed,
8626 	.data = NULL,
8627 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8628 		"<reg_value>: "
8629 		"Set register bit field between bit_x and bit_y included",
8630 	.tokens = {
8631 		(void *)&cmd_write_reg_bit_field_write,
8632 		(void *)&cmd_write_reg_bit_field_regfield,
8633 		(void *)&cmd_write_reg_bit_field_port_id,
8634 		(void *)&cmd_write_reg_bit_field_reg_off,
8635 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8636 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8637 		(void *)&cmd_write_reg_bit_field_value,
8638 		NULL,
8639 	},
8640 };
8641 
8642 /* *** WRITE PORT REGISTER BIT *** */
8643 struct cmd_write_reg_bit_result {
8644 	cmdline_fixed_string_t write;
8645 	cmdline_fixed_string_t regbit;
8646 	portid_t port_id;
8647 	uint32_t reg_off;
8648 	uint8_t bit_pos;
8649 	uint8_t value;
8650 };
8651 
8652 static void
8653 cmd_write_reg_bit_parsed(void *parsed_result,
8654 			 __rte_unused struct cmdline *cl,
8655 			 __rte_unused void *data)
8656 {
8657 	struct cmd_write_reg_bit_result *res = parsed_result;
8658 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8659 }
8660 
8661 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8662 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8663 				 "write");
8664 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8665 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8666 				 regbit, "regbit");
8667 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8668 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8669 				 RTE_UINT16);
8670 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8671 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8672 				 RTE_UINT32);
8673 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8674 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8675 				 RTE_UINT8);
8676 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8677 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8678 				 RTE_UINT8);
8679 
8680 cmdline_parse_inst_t cmd_write_reg_bit = {
8681 	.f = cmd_write_reg_bit_parsed,
8682 	.data = NULL,
8683 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8684 		"0 <= bit_x <= 31",
8685 	.tokens = {
8686 		(void *)&cmd_write_reg_bit_write,
8687 		(void *)&cmd_write_reg_bit_regbit,
8688 		(void *)&cmd_write_reg_bit_port_id,
8689 		(void *)&cmd_write_reg_bit_reg_off,
8690 		(void *)&cmd_write_reg_bit_bit_pos,
8691 		(void *)&cmd_write_reg_bit_value,
8692 		NULL,
8693 	},
8694 };
8695 
8696 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8697 struct cmd_read_rxd_txd_result {
8698 	cmdline_fixed_string_t read;
8699 	cmdline_fixed_string_t rxd_txd;
8700 	portid_t port_id;
8701 	uint16_t queue_id;
8702 	uint16_t desc_id;
8703 };
8704 
8705 static void
8706 cmd_read_rxd_txd_parsed(void *parsed_result,
8707 			__rte_unused struct cmdline *cl,
8708 			__rte_unused void *data)
8709 {
8710 	struct cmd_read_rxd_txd_result *res = parsed_result;
8711 
8712 	if (!strcmp(res->rxd_txd, "rxd"))
8713 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8714 	else if (!strcmp(res->rxd_txd, "txd"))
8715 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8716 }
8717 
8718 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8719 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8720 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8721 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8722 				 "rxd#txd");
8723 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8724 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8725 				 RTE_UINT16);
8726 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8727 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8728 				 RTE_UINT16);
8729 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8730 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8731 				 RTE_UINT16);
8732 
8733 cmdline_parse_inst_t cmd_read_rxd_txd = {
8734 	.f = cmd_read_rxd_txd_parsed,
8735 	.data = NULL,
8736 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8737 	.tokens = {
8738 		(void *)&cmd_read_rxd_txd_read,
8739 		(void *)&cmd_read_rxd_txd_rxd_txd,
8740 		(void *)&cmd_read_rxd_txd_port_id,
8741 		(void *)&cmd_read_rxd_txd_queue_id,
8742 		(void *)&cmd_read_rxd_txd_desc_id,
8743 		NULL,
8744 	},
8745 };
8746 
8747 /* *** QUIT *** */
8748 struct cmd_quit_result {
8749 	cmdline_fixed_string_t quit;
8750 };
8751 
8752 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8753 			    struct cmdline *cl,
8754 			    __rte_unused void *data)
8755 {
8756 	cmdline_quit(cl);
8757 }
8758 
8759 cmdline_parse_token_string_t cmd_quit_quit =
8760 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8761 
8762 cmdline_parse_inst_t cmd_quit = {
8763 	.f = cmd_quit_parsed,
8764 	.data = NULL,
8765 	.help_str = "quit: Exit application",
8766 	.tokens = {
8767 		(void *)&cmd_quit_quit,
8768 		NULL,
8769 	},
8770 };
8771 
8772 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8773 struct cmd_mac_addr_result {
8774 	cmdline_fixed_string_t mac_addr_cmd;
8775 	cmdline_fixed_string_t what;
8776 	uint16_t port_num;
8777 	struct rte_ether_addr address;
8778 };
8779 
8780 static void cmd_mac_addr_parsed(void *parsed_result,
8781 		__rte_unused struct cmdline *cl,
8782 		__rte_unused void *data)
8783 {
8784 	struct cmd_mac_addr_result *res = parsed_result;
8785 	int ret;
8786 
8787 	if (strcmp(res->what, "add") == 0)
8788 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8789 	else if (strcmp(res->what, "set") == 0)
8790 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8791 						       &res->address);
8792 	else
8793 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8794 
8795 	/* check the return value and print it if is < 0 */
8796 	if(ret < 0)
8797 		fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8798 
8799 }
8800 
8801 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8802 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8803 				"mac_addr");
8804 cmdline_parse_token_string_t cmd_mac_addr_what =
8805 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8806 				"add#remove#set");
8807 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8808 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8809 					RTE_UINT16);
8810 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8811 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8812 
8813 cmdline_parse_inst_t cmd_mac_addr = {
8814 	.f = cmd_mac_addr_parsed,
8815 	.data = (void *)0,
8816 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8817 			"Add/Remove/Set MAC address on port_id",
8818 	.tokens = {
8819 		(void *)&cmd_mac_addr_cmd,
8820 		(void *)&cmd_mac_addr_what,
8821 		(void *)&cmd_mac_addr_portnum,
8822 		(void *)&cmd_mac_addr_addr,
8823 		NULL,
8824 	},
8825 };
8826 
8827 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8828 struct cmd_eth_peer_result {
8829 	cmdline_fixed_string_t set;
8830 	cmdline_fixed_string_t eth_peer;
8831 	portid_t port_id;
8832 	cmdline_fixed_string_t peer_addr;
8833 };
8834 
8835 static void cmd_set_eth_peer_parsed(void *parsed_result,
8836 			__rte_unused struct cmdline *cl,
8837 			__rte_unused void *data)
8838 {
8839 		struct cmd_eth_peer_result *res = parsed_result;
8840 
8841 		if (test_done == 0) {
8842 			fprintf(stderr, "Please stop forwarding first\n");
8843 			return;
8844 		}
8845 		if (!strcmp(res->eth_peer, "eth-peer")) {
8846 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8847 			fwd_config_setup();
8848 		}
8849 }
8850 cmdline_parse_token_string_t cmd_eth_peer_set =
8851 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8852 cmdline_parse_token_string_t cmd_eth_peer =
8853 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8854 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8855 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8856 		RTE_UINT16);
8857 cmdline_parse_token_string_t cmd_eth_peer_addr =
8858 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8859 
8860 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8861 	.f = cmd_set_eth_peer_parsed,
8862 	.data = NULL,
8863 	.help_str = "set eth-peer <port_id> <peer_mac>",
8864 	.tokens = {
8865 		(void *)&cmd_eth_peer_set,
8866 		(void *)&cmd_eth_peer,
8867 		(void *)&cmd_eth_peer_port_id,
8868 		(void *)&cmd_eth_peer_addr,
8869 		NULL,
8870 	},
8871 };
8872 
8873 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8874 struct cmd_set_qmap_result {
8875 	cmdline_fixed_string_t set;
8876 	cmdline_fixed_string_t qmap;
8877 	cmdline_fixed_string_t what;
8878 	portid_t port_id;
8879 	uint16_t queue_id;
8880 	uint8_t map_value;
8881 };
8882 
8883 static void
8884 cmd_set_qmap_parsed(void *parsed_result,
8885 		       __rte_unused struct cmdline *cl,
8886 		       __rte_unused void *data)
8887 {
8888 	struct cmd_set_qmap_result *res = parsed_result;
8889 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8890 
8891 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8892 }
8893 
8894 cmdline_parse_token_string_t cmd_setqmap_set =
8895 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8896 				 set, "set");
8897 cmdline_parse_token_string_t cmd_setqmap_qmap =
8898 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8899 				 qmap, "stat_qmap");
8900 cmdline_parse_token_string_t cmd_setqmap_what =
8901 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8902 				 what, "tx#rx");
8903 cmdline_parse_token_num_t cmd_setqmap_portid =
8904 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8905 			      port_id, RTE_UINT16);
8906 cmdline_parse_token_num_t cmd_setqmap_queueid =
8907 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8908 			      queue_id, RTE_UINT16);
8909 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8910 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8911 			      map_value, RTE_UINT8);
8912 
8913 cmdline_parse_inst_t cmd_set_qmap = {
8914 	.f = cmd_set_qmap_parsed,
8915 	.data = NULL,
8916 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8917 		"Set statistics mapping value on tx|rx queue_id of port_id",
8918 	.tokens = {
8919 		(void *)&cmd_setqmap_set,
8920 		(void *)&cmd_setqmap_qmap,
8921 		(void *)&cmd_setqmap_what,
8922 		(void *)&cmd_setqmap_portid,
8923 		(void *)&cmd_setqmap_queueid,
8924 		(void *)&cmd_setqmap_mapvalue,
8925 		NULL,
8926 	},
8927 };
8928 
8929 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8930 struct cmd_set_xstats_hide_zero_result {
8931 	cmdline_fixed_string_t keyword;
8932 	cmdline_fixed_string_t name;
8933 	cmdline_fixed_string_t on_off;
8934 };
8935 
8936 static void
8937 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8938 			__rte_unused struct cmdline *cl,
8939 			__rte_unused void *data)
8940 {
8941 	struct cmd_set_xstats_hide_zero_result *res;
8942 	uint16_t on_off = 0;
8943 
8944 	res = parsed_result;
8945 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8946 	set_xstats_hide_zero(on_off);
8947 }
8948 
8949 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8950 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8951 				 keyword, "set");
8952 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8953 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8954 				 name, "xstats-hide-zero");
8955 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8956 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8957 				 on_off, "on#off");
8958 
8959 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8960 	.f = cmd_set_xstats_hide_zero_parsed,
8961 	.data = NULL,
8962 	.help_str = "set xstats-hide-zero on|off",
8963 	.tokens = {
8964 		(void *)&cmd_set_xstats_hide_zero_keyword,
8965 		(void *)&cmd_set_xstats_hide_zero_name,
8966 		(void *)&cmd_set_xstats_hide_zero_on_off,
8967 		NULL,
8968 	},
8969 };
8970 
8971 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8972 struct cmd_set_record_core_cycles_result {
8973 	cmdline_fixed_string_t keyword;
8974 	cmdline_fixed_string_t name;
8975 	cmdline_fixed_string_t on_off;
8976 };
8977 
8978 static void
8979 cmd_set_record_core_cycles_parsed(void *parsed_result,
8980 			__rte_unused struct cmdline *cl,
8981 			__rte_unused void *data)
8982 {
8983 	struct cmd_set_record_core_cycles_result *res;
8984 	uint16_t on_off = 0;
8985 
8986 	res = parsed_result;
8987 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8988 	set_record_core_cycles(on_off);
8989 }
8990 
8991 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8992 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8993 				 keyword, "set");
8994 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8995 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8996 				 name, "record-core-cycles");
8997 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8998 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8999 				 on_off, "on#off");
9000 
9001 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9002 	.f = cmd_set_record_core_cycles_parsed,
9003 	.data = NULL,
9004 	.help_str = "set record-core-cycles on|off",
9005 	.tokens = {
9006 		(void *)&cmd_set_record_core_cycles_keyword,
9007 		(void *)&cmd_set_record_core_cycles_name,
9008 		(void *)&cmd_set_record_core_cycles_on_off,
9009 		NULL,
9010 	},
9011 };
9012 
9013 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9014 struct cmd_set_record_burst_stats_result {
9015 	cmdline_fixed_string_t keyword;
9016 	cmdline_fixed_string_t name;
9017 	cmdline_fixed_string_t on_off;
9018 };
9019 
9020 static void
9021 cmd_set_record_burst_stats_parsed(void *parsed_result,
9022 			__rte_unused struct cmdline *cl,
9023 			__rte_unused void *data)
9024 {
9025 	struct cmd_set_record_burst_stats_result *res;
9026 	uint16_t on_off = 0;
9027 
9028 	res = parsed_result;
9029 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9030 	set_record_burst_stats(on_off);
9031 }
9032 
9033 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9034 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9035 				 keyword, "set");
9036 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9037 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9038 				 name, "record-burst-stats");
9039 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9040 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9041 				 on_off, "on#off");
9042 
9043 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9044 	.f = cmd_set_record_burst_stats_parsed,
9045 	.data = NULL,
9046 	.help_str = "set record-burst-stats on|off",
9047 	.tokens = {
9048 		(void *)&cmd_set_record_burst_stats_keyword,
9049 		(void *)&cmd_set_record_burst_stats_name,
9050 		(void *)&cmd_set_record_burst_stats_on_off,
9051 		NULL,
9052 	},
9053 };
9054 
9055 /* *** CONFIGURE UNICAST HASH TABLE *** */
9056 struct cmd_set_uc_hash_table {
9057 	cmdline_fixed_string_t set;
9058 	cmdline_fixed_string_t port;
9059 	portid_t port_id;
9060 	cmdline_fixed_string_t what;
9061 	struct rte_ether_addr address;
9062 	cmdline_fixed_string_t mode;
9063 };
9064 
9065 static void
9066 cmd_set_uc_hash_parsed(void *parsed_result,
9067 		       __rte_unused struct cmdline *cl,
9068 		       __rte_unused void *data)
9069 {
9070 	int ret=0;
9071 	struct cmd_set_uc_hash_table *res = parsed_result;
9072 
9073 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9074 
9075 	if (strcmp(res->what, "uta") == 0)
9076 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9077 						&res->address,(uint8_t)is_on);
9078 	if (ret < 0)
9079 		fprintf(stderr,
9080 			"bad unicast hash table parameter, return code = %d\n",
9081 			ret);
9082 
9083 }
9084 
9085 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9086 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9087 				 set, "set");
9088 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9089 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9090 				 port, "port");
9091 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9092 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9093 			      port_id, RTE_UINT16);
9094 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9095 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9096 				 what, "uta");
9097 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9098 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9099 				address);
9100 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9101 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9102 				 mode, "on#off");
9103 
9104 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9105 	.f = cmd_set_uc_hash_parsed,
9106 	.data = NULL,
9107 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
9108 	.tokens = {
9109 		(void *)&cmd_set_uc_hash_set,
9110 		(void *)&cmd_set_uc_hash_port,
9111 		(void *)&cmd_set_uc_hash_portid,
9112 		(void *)&cmd_set_uc_hash_what,
9113 		(void *)&cmd_set_uc_hash_mac,
9114 		(void *)&cmd_set_uc_hash_mode,
9115 		NULL,
9116 	},
9117 };
9118 
9119 struct cmd_set_uc_all_hash_table {
9120 	cmdline_fixed_string_t set;
9121 	cmdline_fixed_string_t port;
9122 	portid_t port_id;
9123 	cmdline_fixed_string_t what;
9124 	cmdline_fixed_string_t value;
9125 	cmdline_fixed_string_t mode;
9126 };
9127 
9128 static void
9129 cmd_set_uc_all_hash_parsed(void *parsed_result,
9130 		       __rte_unused struct cmdline *cl,
9131 		       __rte_unused void *data)
9132 {
9133 	int ret=0;
9134 	struct cmd_set_uc_all_hash_table *res = parsed_result;
9135 
9136 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9137 
9138 	if ((strcmp(res->what, "uta") == 0) &&
9139 		(strcmp(res->value, "all") == 0))
9140 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9141 	if (ret < 0)
9142 		fprintf(stderr,
9143 			"bad unicast hash table parameter, return code = %d\n",
9144 			ret);
9145 }
9146 
9147 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9148 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9149 				 set, "set");
9150 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9151 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9152 				 port, "port");
9153 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9154 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9155 			      port_id, RTE_UINT16);
9156 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9157 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9158 				 what, "uta");
9159 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9160 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9161 				value,"all");
9162 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9163 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9164 				 mode, "on#off");
9165 
9166 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9167 	.f = cmd_set_uc_all_hash_parsed,
9168 	.data = NULL,
9169 	.help_str = "set port <port_id> uta all on|off",
9170 	.tokens = {
9171 		(void *)&cmd_set_uc_all_hash_set,
9172 		(void *)&cmd_set_uc_all_hash_port,
9173 		(void *)&cmd_set_uc_all_hash_portid,
9174 		(void *)&cmd_set_uc_all_hash_what,
9175 		(void *)&cmd_set_uc_all_hash_value,
9176 		(void *)&cmd_set_uc_all_hash_mode,
9177 		NULL,
9178 	},
9179 };
9180 
9181 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9182 struct cmd_set_vf_traffic {
9183 	cmdline_fixed_string_t set;
9184 	cmdline_fixed_string_t port;
9185 	portid_t port_id;
9186 	cmdline_fixed_string_t vf;
9187 	uint8_t vf_id;
9188 	cmdline_fixed_string_t what;
9189 	cmdline_fixed_string_t mode;
9190 };
9191 
9192 static void
9193 cmd_set_vf_traffic_parsed(void *parsed_result,
9194 		       __rte_unused struct cmdline *cl,
9195 		       __rte_unused void *data)
9196 {
9197 	struct cmd_set_vf_traffic *res = parsed_result;
9198 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9199 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9200 
9201 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9202 }
9203 
9204 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9205 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9206 				 set, "set");
9207 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9208 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9209 				 port, "port");
9210 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9211 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9212 			      port_id, RTE_UINT16);
9213 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9214 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9215 				 vf, "vf");
9216 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9217 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9218 			      vf_id, RTE_UINT8);
9219 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9220 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9221 				 what, "tx#rx");
9222 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9223 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9224 				 mode, "on#off");
9225 
9226 cmdline_parse_inst_t cmd_set_vf_traffic = {
9227 	.f = cmd_set_vf_traffic_parsed,
9228 	.data = NULL,
9229 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9230 	.tokens = {
9231 		(void *)&cmd_setvf_traffic_set,
9232 		(void *)&cmd_setvf_traffic_port,
9233 		(void *)&cmd_setvf_traffic_portid,
9234 		(void *)&cmd_setvf_traffic_vf,
9235 		(void *)&cmd_setvf_traffic_vfid,
9236 		(void *)&cmd_setvf_traffic_what,
9237 		(void *)&cmd_setvf_traffic_mode,
9238 		NULL,
9239 	},
9240 };
9241 
9242 /* *** CONFIGURE VF RECEIVE MODE *** */
9243 struct cmd_set_vf_rxmode {
9244 	cmdline_fixed_string_t set;
9245 	cmdline_fixed_string_t port;
9246 	portid_t port_id;
9247 	cmdline_fixed_string_t vf;
9248 	uint8_t vf_id;
9249 	cmdline_fixed_string_t what;
9250 	cmdline_fixed_string_t mode;
9251 	cmdline_fixed_string_t on;
9252 };
9253 
9254 static void
9255 cmd_set_vf_rxmode_parsed(void *parsed_result,
9256 		       __rte_unused struct cmdline *cl,
9257 		       __rte_unused void *data)
9258 {
9259 	int ret = -ENOTSUP;
9260 	uint16_t vf_rxmode = 0;
9261 	struct cmd_set_vf_rxmode *res = parsed_result;
9262 
9263 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9264 	if (!strcmp(res->what,"rxmode")) {
9265 		if (!strcmp(res->mode, "AUPE"))
9266 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9267 		else if (!strcmp(res->mode, "ROPE"))
9268 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9269 		else if (!strcmp(res->mode, "BAM"))
9270 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9271 		else if (!strncmp(res->mode, "MPE",3))
9272 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9273 	}
9274 
9275 	RTE_SET_USED(is_on);
9276 
9277 #ifdef RTE_NET_IXGBE
9278 	if (ret == -ENOTSUP)
9279 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9280 						  vf_rxmode, (uint8_t)is_on);
9281 #endif
9282 #ifdef RTE_NET_BNXT
9283 	if (ret == -ENOTSUP)
9284 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9285 						 vf_rxmode, (uint8_t)is_on);
9286 #endif
9287 	if (ret < 0)
9288 		fprintf(stderr,
9289 			"bad VF receive mode parameter, return code = %d\n",
9290 			ret);
9291 }
9292 
9293 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9294 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9295 				 set, "set");
9296 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9297 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9298 				 port, "port");
9299 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9300 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9301 			      port_id, RTE_UINT16);
9302 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9303 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9304 				 vf, "vf");
9305 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9306 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9307 			      vf_id, RTE_UINT8);
9308 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9309 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9310 				 what, "rxmode");
9311 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9312 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9313 				 mode, "AUPE#ROPE#BAM#MPE");
9314 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9315 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9316 				 on, "on#off");
9317 
9318 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9319 	.f = cmd_set_vf_rxmode_parsed,
9320 	.data = NULL,
9321 	.help_str = "set port <port_id> vf <vf_id> rxmode "
9322 		"AUPE|ROPE|BAM|MPE on|off",
9323 	.tokens = {
9324 		(void *)&cmd_set_vf_rxmode_set,
9325 		(void *)&cmd_set_vf_rxmode_port,
9326 		(void *)&cmd_set_vf_rxmode_portid,
9327 		(void *)&cmd_set_vf_rxmode_vf,
9328 		(void *)&cmd_set_vf_rxmode_vfid,
9329 		(void *)&cmd_set_vf_rxmode_what,
9330 		(void *)&cmd_set_vf_rxmode_mode,
9331 		(void *)&cmd_set_vf_rxmode_on,
9332 		NULL,
9333 	},
9334 };
9335 
9336 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9337 struct cmd_vf_mac_addr_result {
9338 	cmdline_fixed_string_t mac_addr_cmd;
9339 	cmdline_fixed_string_t what;
9340 	cmdline_fixed_string_t port;
9341 	uint16_t port_num;
9342 	cmdline_fixed_string_t vf;
9343 	uint8_t vf_num;
9344 	struct rte_ether_addr address;
9345 };
9346 
9347 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9348 		__rte_unused struct cmdline *cl,
9349 		__rte_unused void *data)
9350 {
9351 	struct cmd_vf_mac_addr_result *res = parsed_result;
9352 	int ret = -ENOTSUP;
9353 
9354 	if (strcmp(res->what, "add") != 0)
9355 		return;
9356 
9357 #ifdef RTE_NET_I40E
9358 	if (ret == -ENOTSUP)
9359 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9360 						   &res->address);
9361 #endif
9362 #ifdef RTE_NET_BNXT
9363 	if (ret == -ENOTSUP)
9364 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9365 						res->vf_num);
9366 #endif
9367 
9368 	if(ret < 0)
9369 		fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9370 
9371 }
9372 
9373 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9374 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9375 				mac_addr_cmd,"mac_addr");
9376 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9377 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9378 				what,"add");
9379 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9380 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9381 				port,"port");
9382 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9383 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9384 				port_num, RTE_UINT16);
9385 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9386 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9387 				vf,"vf");
9388 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9389 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9390 				vf_num, RTE_UINT8);
9391 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9392 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9393 				address);
9394 
9395 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9396 	.f = cmd_vf_mac_addr_parsed,
9397 	.data = (void *)0,
9398 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9399 		"Add MAC address filtering for a VF on port_id",
9400 	.tokens = {
9401 		(void *)&cmd_vf_mac_addr_cmd,
9402 		(void *)&cmd_vf_mac_addr_what,
9403 		(void *)&cmd_vf_mac_addr_port,
9404 		(void *)&cmd_vf_mac_addr_portnum,
9405 		(void *)&cmd_vf_mac_addr_vf,
9406 		(void *)&cmd_vf_mac_addr_vfnum,
9407 		(void *)&cmd_vf_mac_addr_addr,
9408 		NULL,
9409 	},
9410 };
9411 
9412 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9413 struct cmd_vf_rx_vlan_filter {
9414 	cmdline_fixed_string_t rx_vlan;
9415 	cmdline_fixed_string_t what;
9416 	uint16_t vlan_id;
9417 	cmdline_fixed_string_t port;
9418 	portid_t port_id;
9419 	cmdline_fixed_string_t vf;
9420 	uint64_t vf_mask;
9421 };
9422 
9423 static void
9424 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9425 			  __rte_unused struct cmdline *cl,
9426 			  __rte_unused void *data)
9427 {
9428 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
9429 	int ret = -ENOTSUP;
9430 
9431 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9432 
9433 #ifdef RTE_NET_IXGBE
9434 	if (ret == -ENOTSUP)
9435 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9436 				res->vlan_id, res->vf_mask, is_add);
9437 #endif
9438 #ifdef RTE_NET_I40E
9439 	if (ret == -ENOTSUP)
9440 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9441 				res->vlan_id, res->vf_mask, is_add);
9442 #endif
9443 #ifdef RTE_NET_BNXT
9444 	if (ret == -ENOTSUP)
9445 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9446 				res->vlan_id, res->vf_mask, is_add);
9447 #endif
9448 
9449 	switch (ret) {
9450 	case 0:
9451 		break;
9452 	case -EINVAL:
9453 		fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9454 			res->vlan_id, res->vf_mask);
9455 		break;
9456 	case -ENODEV:
9457 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
9458 		break;
9459 	case -ENOTSUP:
9460 		fprintf(stderr, "function not implemented or supported\n");
9461 		break;
9462 	default:
9463 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9464 	}
9465 }
9466 
9467 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9468 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9469 				 rx_vlan, "rx_vlan");
9470 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9471 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9472 				 what, "add#rm");
9473 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9474 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9475 			      vlan_id, RTE_UINT16);
9476 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9477 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9478 				 port, "port");
9479 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9480 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9481 			      port_id, RTE_UINT16);
9482 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9483 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9484 				 vf, "vf");
9485 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9486 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9487 			      vf_mask, RTE_UINT64);
9488 
9489 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9490 	.f = cmd_vf_rx_vlan_filter_parsed,
9491 	.data = NULL,
9492 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9493 		"(vf_mask = hexadecimal VF mask)",
9494 	.tokens = {
9495 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9496 		(void *)&cmd_vf_rx_vlan_filter_what,
9497 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
9498 		(void *)&cmd_vf_rx_vlan_filter_port,
9499 		(void *)&cmd_vf_rx_vlan_filter_portid,
9500 		(void *)&cmd_vf_rx_vlan_filter_vf,
9501 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
9502 		NULL,
9503 	},
9504 };
9505 
9506 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9507 struct cmd_queue_rate_limit_result {
9508 	cmdline_fixed_string_t set;
9509 	cmdline_fixed_string_t port;
9510 	uint16_t port_num;
9511 	cmdline_fixed_string_t queue;
9512 	uint8_t queue_num;
9513 	cmdline_fixed_string_t rate;
9514 	uint16_t rate_num;
9515 };
9516 
9517 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9518 		__rte_unused struct cmdline *cl,
9519 		__rte_unused void *data)
9520 {
9521 	struct cmd_queue_rate_limit_result *res = parsed_result;
9522 	int ret = 0;
9523 
9524 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9525 		&& (strcmp(res->queue, "queue") == 0)
9526 		&& (strcmp(res->rate, "rate") == 0))
9527 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
9528 					res->rate_num);
9529 	if (ret < 0)
9530 		fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9531 			strerror(-ret));
9532 
9533 }
9534 
9535 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9536 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9537 				set, "set");
9538 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9539 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9540 				port, "port");
9541 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9542 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9543 				port_num, RTE_UINT16);
9544 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9545 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9546 				queue, "queue");
9547 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9548 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9549 				queue_num, RTE_UINT8);
9550 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9551 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9552 				rate, "rate");
9553 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9554 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9555 				rate_num, RTE_UINT16);
9556 
9557 cmdline_parse_inst_t cmd_queue_rate_limit = {
9558 	.f = cmd_queue_rate_limit_parsed,
9559 	.data = (void *)0,
9560 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9561 		"Set rate limit for a queue on port_id",
9562 	.tokens = {
9563 		(void *)&cmd_queue_rate_limit_set,
9564 		(void *)&cmd_queue_rate_limit_port,
9565 		(void *)&cmd_queue_rate_limit_portnum,
9566 		(void *)&cmd_queue_rate_limit_queue,
9567 		(void *)&cmd_queue_rate_limit_queuenum,
9568 		(void *)&cmd_queue_rate_limit_rate,
9569 		(void *)&cmd_queue_rate_limit_ratenum,
9570 		NULL,
9571 	},
9572 };
9573 
9574 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9575 struct cmd_vf_rate_limit_result {
9576 	cmdline_fixed_string_t set;
9577 	cmdline_fixed_string_t port;
9578 	uint16_t port_num;
9579 	cmdline_fixed_string_t vf;
9580 	uint8_t vf_num;
9581 	cmdline_fixed_string_t rate;
9582 	uint16_t rate_num;
9583 	cmdline_fixed_string_t q_msk;
9584 	uint64_t q_msk_val;
9585 };
9586 
9587 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9588 		__rte_unused struct cmdline *cl,
9589 		__rte_unused void *data)
9590 {
9591 	struct cmd_vf_rate_limit_result *res = parsed_result;
9592 	int ret = 0;
9593 
9594 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9595 		&& (strcmp(res->vf, "vf") == 0)
9596 		&& (strcmp(res->rate, "rate") == 0)
9597 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9598 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9599 					res->rate_num, res->q_msk_val);
9600 	if (ret < 0)
9601 		fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9602 			strerror(-ret));
9603 
9604 }
9605 
9606 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9607 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9608 				set, "set");
9609 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9610 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9611 				port, "port");
9612 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9613 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9614 				port_num, RTE_UINT16);
9615 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9616 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9617 				vf, "vf");
9618 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9619 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9620 				vf_num, RTE_UINT8);
9621 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9622 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9623 				rate, "rate");
9624 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9625 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9626 				rate_num, RTE_UINT16);
9627 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9628 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9629 				q_msk, "queue_mask");
9630 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9631 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9632 				q_msk_val, RTE_UINT64);
9633 
9634 cmdline_parse_inst_t cmd_vf_rate_limit = {
9635 	.f = cmd_vf_rate_limit_parsed,
9636 	.data = (void *)0,
9637 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9638 		"queue_mask <queue_mask_value>: "
9639 		"Set rate limit for queues of VF on port_id",
9640 	.tokens = {
9641 		(void *)&cmd_vf_rate_limit_set,
9642 		(void *)&cmd_vf_rate_limit_port,
9643 		(void *)&cmd_vf_rate_limit_portnum,
9644 		(void *)&cmd_vf_rate_limit_vf,
9645 		(void *)&cmd_vf_rate_limit_vfnum,
9646 		(void *)&cmd_vf_rate_limit_rate,
9647 		(void *)&cmd_vf_rate_limit_ratenum,
9648 		(void *)&cmd_vf_rate_limit_q_msk,
9649 		(void *)&cmd_vf_rate_limit_q_msk_val,
9650 		NULL,
9651 	},
9652 };
9653 
9654 /* *** CONFIGURE TUNNEL UDP PORT *** */
9655 struct cmd_tunnel_udp_config {
9656 	cmdline_fixed_string_t rx_vxlan_port;
9657 	cmdline_fixed_string_t what;
9658 	uint16_t udp_port;
9659 	portid_t port_id;
9660 };
9661 
9662 static void
9663 cmd_tunnel_udp_config_parsed(void *parsed_result,
9664 			  __rte_unused struct cmdline *cl,
9665 			  __rte_unused void *data)
9666 {
9667 	struct cmd_tunnel_udp_config *res = parsed_result;
9668 	struct rte_eth_udp_tunnel tunnel_udp;
9669 	int ret;
9670 
9671 	tunnel_udp.udp_port = res->udp_port;
9672 	tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9673 
9674 	if (!strcmp(res->what, "add"))
9675 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9676 						      &tunnel_udp);
9677 	else
9678 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9679 							 &tunnel_udp);
9680 
9681 	if (ret < 0)
9682 		fprintf(stderr, "udp tunneling add error: (%s)\n",
9683 			strerror(-ret));
9684 }
9685 
9686 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9687 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9688 				rx_vxlan_port, "rx_vxlan_port");
9689 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9690 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9691 				what, "add#rm");
9692 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9693 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9694 				udp_port, RTE_UINT16);
9695 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9696 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9697 				port_id, RTE_UINT16);
9698 
9699 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9700 	.f = cmd_tunnel_udp_config_parsed,
9701 	.data = (void *)0,
9702 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9703 		"Add/Remove a tunneling UDP port filter",
9704 	.tokens = {
9705 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9706 		(void *)&cmd_tunnel_udp_config_what,
9707 		(void *)&cmd_tunnel_udp_config_udp_port,
9708 		(void *)&cmd_tunnel_udp_config_port_id,
9709 		NULL,
9710 	},
9711 };
9712 
9713 struct cmd_config_tunnel_udp_port {
9714 	cmdline_fixed_string_t port;
9715 	cmdline_fixed_string_t config;
9716 	portid_t port_id;
9717 	cmdline_fixed_string_t udp_tunnel_port;
9718 	cmdline_fixed_string_t action;
9719 	cmdline_fixed_string_t tunnel_type;
9720 	uint16_t udp_port;
9721 };
9722 
9723 static void
9724 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9725 			       __rte_unused struct cmdline *cl,
9726 			       __rte_unused void *data)
9727 {
9728 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9729 	struct rte_eth_udp_tunnel tunnel_udp;
9730 	int ret = 0;
9731 
9732 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9733 		return;
9734 
9735 	tunnel_udp.udp_port = res->udp_port;
9736 
9737 	if (!strcmp(res->tunnel_type, "vxlan")) {
9738 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9739 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9740 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9741 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9742 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9743 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9744 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9745 	} else {
9746 		fprintf(stderr, "Invalid tunnel type\n");
9747 		return;
9748 	}
9749 
9750 	if (!strcmp(res->action, "add"))
9751 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9752 						      &tunnel_udp);
9753 	else
9754 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9755 							 &tunnel_udp);
9756 
9757 	if (ret < 0)
9758 		fprintf(stderr, "udp tunneling port add error: (%s)\n",
9759 			strerror(-ret));
9760 }
9761 
9762 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9763 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9764 				 "port");
9765 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9766 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9767 				 "config");
9768 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9769 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9770 			      RTE_UINT16);
9771 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9772 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9773 				 udp_tunnel_port,
9774 				 "udp_tunnel_port");
9775 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9776 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9777 				 "add#rm");
9778 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9779 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9780 				 "vxlan#geneve#vxlan-gpe#ecpri");
9781 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9782 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9783 			      RTE_UINT16);
9784 
9785 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9786 	.f = cmd_cfg_tunnel_udp_port_parsed,
9787 	.data = NULL,
9788 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9789 		"geneve|vxlan-gpe|ecpri <udp_port>",
9790 	.tokens = {
9791 		(void *)&cmd_config_tunnel_udp_port_port,
9792 		(void *)&cmd_config_tunnel_udp_port_config,
9793 		(void *)&cmd_config_tunnel_udp_port_port_id,
9794 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9795 		(void *)&cmd_config_tunnel_udp_port_action,
9796 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9797 		(void *)&cmd_config_tunnel_udp_port_value,
9798 		NULL,
9799 	},
9800 };
9801 
9802 /* ******************************************************************************** */
9803 
9804 struct cmd_dump_result {
9805 	cmdline_fixed_string_t dump;
9806 };
9807 
9808 static void
9809 dump_struct_sizes(void)
9810 {
9811 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9812 	DUMP_SIZE(struct rte_mbuf);
9813 	DUMP_SIZE(struct rte_mempool);
9814 	DUMP_SIZE(struct rte_ring);
9815 #undef DUMP_SIZE
9816 }
9817 
9818 
9819 /* Dump the socket memory statistics on console */
9820 static void
9821 dump_socket_mem(FILE *f)
9822 {
9823 	struct rte_malloc_socket_stats socket_stats;
9824 	unsigned int i;
9825 	size_t total = 0;
9826 	size_t alloc = 0;
9827 	size_t free = 0;
9828 	unsigned int n_alloc = 0;
9829 	unsigned int n_free = 0;
9830 	static size_t last_allocs;
9831 	static size_t last_total;
9832 
9833 
9834 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9835 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9836 		    !socket_stats.heap_totalsz_bytes)
9837 			continue;
9838 		total += socket_stats.heap_totalsz_bytes;
9839 		alloc += socket_stats.heap_allocsz_bytes;
9840 		free += socket_stats.heap_freesz_bytes;
9841 		n_alloc += socket_stats.alloc_count;
9842 		n_free += socket_stats.free_count;
9843 		fprintf(f,
9844 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9845 			i,
9846 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9847 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9848 			(double)socket_stats.heap_allocsz_bytes * 100 /
9849 			(double)socket_stats.heap_totalsz_bytes,
9850 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9851 			socket_stats.alloc_count,
9852 			socket_stats.free_count);
9853 	}
9854 	fprintf(f,
9855 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9856 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9857 		total ? ((double)alloc * 100 / (double)total) : 0,
9858 		(double)free / (1024 * 1024),
9859 		n_alloc, n_free);
9860 	if (last_allocs)
9861 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9862 			((double)total - (double)last_total) / (1024 * 1024),
9863 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9864 	last_allocs = alloc;
9865 	last_total = total;
9866 }
9867 
9868 static void cmd_dump_parsed(void *parsed_result,
9869 			    __rte_unused struct cmdline *cl,
9870 			    __rte_unused void *data)
9871 {
9872 	struct cmd_dump_result *res = parsed_result;
9873 
9874 	if (!strcmp(res->dump, "dump_physmem"))
9875 		rte_dump_physmem_layout(stdout);
9876 	else if (!strcmp(res->dump, "dump_socket_mem"))
9877 		dump_socket_mem(stdout);
9878 	else if (!strcmp(res->dump, "dump_memzone"))
9879 		rte_memzone_dump(stdout);
9880 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9881 		dump_struct_sizes();
9882 	else if (!strcmp(res->dump, "dump_ring"))
9883 		rte_ring_list_dump(stdout);
9884 	else if (!strcmp(res->dump, "dump_mempool"))
9885 		rte_mempool_list_dump(stdout);
9886 	else if (!strcmp(res->dump, "dump_devargs"))
9887 		rte_devargs_dump(stdout);
9888 	else if (!strcmp(res->dump, "dump_log_types"))
9889 		rte_log_dump(stdout);
9890 }
9891 
9892 cmdline_parse_token_string_t cmd_dump_dump =
9893 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9894 		"dump_physmem#"
9895 		"dump_memzone#"
9896 		"dump_socket_mem#"
9897 		"dump_struct_sizes#"
9898 		"dump_ring#"
9899 		"dump_mempool#"
9900 		"dump_devargs#"
9901 		"dump_log_types");
9902 
9903 cmdline_parse_inst_t cmd_dump = {
9904 	.f = cmd_dump_parsed,  /* function to call */
9905 	.data = NULL,      /* 2nd arg of func */
9906 	.help_str = "Dump status",
9907 	.tokens = {        /* token list, NULL terminated */
9908 		(void *)&cmd_dump_dump,
9909 		NULL,
9910 	},
9911 };
9912 
9913 /* ******************************************************************************** */
9914 
9915 struct cmd_dump_one_result {
9916 	cmdline_fixed_string_t dump;
9917 	cmdline_fixed_string_t name;
9918 };
9919 
9920 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9921 				__rte_unused void *data)
9922 {
9923 	struct cmd_dump_one_result *res = parsed_result;
9924 
9925 	if (!strcmp(res->dump, "dump_ring")) {
9926 		struct rte_ring *r;
9927 		r = rte_ring_lookup(res->name);
9928 		if (r == NULL) {
9929 			cmdline_printf(cl, "Cannot find ring\n");
9930 			return;
9931 		}
9932 		rte_ring_dump(stdout, r);
9933 	} else if (!strcmp(res->dump, "dump_mempool")) {
9934 		struct rte_mempool *mp;
9935 		mp = rte_mempool_lookup(res->name);
9936 		if (mp == NULL) {
9937 			cmdline_printf(cl, "Cannot find mempool\n");
9938 			return;
9939 		}
9940 		rte_mempool_dump(stdout, mp);
9941 	}
9942 }
9943 
9944 cmdline_parse_token_string_t cmd_dump_one_dump =
9945 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9946 				 "dump_ring#dump_mempool");
9947 
9948 cmdline_parse_token_string_t cmd_dump_one_name =
9949 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9950 
9951 cmdline_parse_inst_t cmd_dump_one = {
9952 	.f = cmd_dump_one_parsed,  /* function to call */
9953 	.data = NULL,      /* 2nd arg of func */
9954 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9955 	.tokens = {        /* token list, NULL terminated */
9956 		(void *)&cmd_dump_one_dump,
9957 		(void *)&cmd_dump_one_name,
9958 		NULL,
9959 	},
9960 };
9961 
9962 /* *** queue region set *** */
9963 struct cmd_queue_region_result {
9964 	cmdline_fixed_string_t set;
9965 	cmdline_fixed_string_t port;
9966 	portid_t port_id;
9967 	cmdline_fixed_string_t cmd;
9968 	cmdline_fixed_string_t region;
9969 	uint8_t  region_id;
9970 	cmdline_fixed_string_t queue_start_index;
9971 	uint8_t  queue_id;
9972 	cmdline_fixed_string_t queue_num;
9973 	uint8_t  queue_num_value;
9974 };
9975 
9976 static void
9977 cmd_queue_region_parsed(void *parsed_result,
9978 			__rte_unused struct cmdline *cl,
9979 			__rte_unused void *data)
9980 {
9981 	struct cmd_queue_region_result *res = parsed_result;
9982 	int ret = -ENOTSUP;
9983 #ifdef RTE_NET_I40E
9984 	struct rte_pmd_i40e_queue_region_conf region_conf;
9985 	enum rte_pmd_i40e_queue_region_op op_type;
9986 #endif
9987 
9988 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9989 		return;
9990 
9991 #ifdef RTE_NET_I40E
9992 	memset(&region_conf, 0, sizeof(region_conf));
9993 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9994 	region_conf.region_id = res->region_id;
9995 	region_conf.queue_num = res->queue_num_value;
9996 	region_conf.queue_start_index = res->queue_id;
9997 
9998 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9999 				op_type, &region_conf);
10000 #endif
10001 
10002 	switch (ret) {
10003 	case 0:
10004 		break;
10005 	case -ENOTSUP:
10006 		fprintf(stderr, "function not implemented or supported\n");
10007 		break;
10008 	default:
10009 		fprintf(stderr, "queue region config error: (%s)\n",
10010 			strerror(-ret));
10011 	}
10012 }
10013 
10014 cmdline_parse_token_string_t cmd_queue_region_set =
10015 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10016 		set, "set");
10017 cmdline_parse_token_string_t cmd_queue_region_port =
10018 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10019 cmdline_parse_token_num_t cmd_queue_region_port_id =
10020 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10021 				port_id, RTE_UINT16);
10022 cmdline_parse_token_string_t cmd_queue_region_cmd =
10023 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10024 				 cmd, "queue-region");
10025 cmdline_parse_token_string_t cmd_queue_region_id =
10026 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10027 				region, "region_id");
10028 cmdline_parse_token_num_t cmd_queue_region_index =
10029 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10030 				region_id, RTE_UINT8);
10031 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10032 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10033 				queue_start_index, "queue_start_index");
10034 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10035 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10036 				queue_id, RTE_UINT8);
10037 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10038 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10039 				queue_num, "queue_num");
10040 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10041 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10042 				queue_num_value, RTE_UINT8);
10043 
10044 cmdline_parse_inst_t cmd_queue_region = {
10045 	.f = cmd_queue_region_parsed,
10046 	.data = NULL,
10047 	.help_str = "set port <port_id> queue-region region_id <value> "
10048 		"queue_start_index <value> queue_num <value>: Set a queue region",
10049 	.tokens = {
10050 		(void *)&cmd_queue_region_set,
10051 		(void *)&cmd_queue_region_port,
10052 		(void *)&cmd_queue_region_port_id,
10053 		(void *)&cmd_queue_region_cmd,
10054 		(void *)&cmd_queue_region_id,
10055 		(void *)&cmd_queue_region_index,
10056 		(void *)&cmd_queue_region_queue_start_index,
10057 		(void *)&cmd_queue_region_queue_id,
10058 		(void *)&cmd_queue_region_queue_num,
10059 		(void *)&cmd_queue_region_queue_num_value,
10060 		NULL,
10061 	},
10062 };
10063 
10064 /* *** queue region and flowtype set *** */
10065 struct cmd_region_flowtype_result {
10066 	cmdline_fixed_string_t set;
10067 	cmdline_fixed_string_t port;
10068 	portid_t port_id;
10069 	cmdline_fixed_string_t cmd;
10070 	cmdline_fixed_string_t region;
10071 	uint8_t  region_id;
10072 	cmdline_fixed_string_t flowtype;
10073 	uint8_t  flowtype_id;
10074 };
10075 
10076 static void
10077 cmd_region_flowtype_parsed(void *parsed_result,
10078 			__rte_unused struct cmdline *cl,
10079 			__rte_unused void *data)
10080 {
10081 	struct cmd_region_flowtype_result *res = parsed_result;
10082 	int ret = -ENOTSUP;
10083 #ifdef RTE_NET_I40E
10084 	struct rte_pmd_i40e_queue_region_conf region_conf;
10085 	enum rte_pmd_i40e_queue_region_op op_type;
10086 #endif
10087 
10088 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10089 		return;
10090 
10091 #ifdef RTE_NET_I40E
10092 	memset(&region_conf, 0, sizeof(region_conf));
10093 
10094 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10095 	region_conf.region_id = res->region_id;
10096 	region_conf.hw_flowtype = res->flowtype_id;
10097 
10098 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10099 			op_type, &region_conf);
10100 #endif
10101 
10102 	switch (ret) {
10103 	case 0:
10104 		break;
10105 	case -ENOTSUP:
10106 		fprintf(stderr, "function not implemented or supported\n");
10107 		break;
10108 	default:
10109 		fprintf(stderr, "region flowtype config error: (%s)\n",
10110 			strerror(-ret));
10111 	}
10112 }
10113 
10114 cmdline_parse_token_string_t cmd_region_flowtype_set =
10115 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10116 				set, "set");
10117 cmdline_parse_token_string_t cmd_region_flowtype_port =
10118 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10119 				port, "port");
10120 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10121 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10122 				port_id, RTE_UINT16);
10123 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10124 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10125 				cmd, "queue-region");
10126 cmdline_parse_token_string_t cmd_region_flowtype_index =
10127 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10128 				region, "region_id");
10129 cmdline_parse_token_num_t cmd_region_flowtype_id =
10130 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10131 				region_id, RTE_UINT8);
10132 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10133 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10134 				flowtype, "flowtype");
10135 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10136 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10137 				flowtype_id, RTE_UINT8);
10138 cmdline_parse_inst_t cmd_region_flowtype = {
10139 	.f = cmd_region_flowtype_parsed,
10140 	.data = NULL,
10141 	.help_str = "set port <port_id> queue-region region_id <value> "
10142 		"flowtype <value>: Set a flowtype region index",
10143 	.tokens = {
10144 		(void *)&cmd_region_flowtype_set,
10145 		(void *)&cmd_region_flowtype_port,
10146 		(void *)&cmd_region_flowtype_port_index,
10147 		(void *)&cmd_region_flowtype_cmd,
10148 		(void *)&cmd_region_flowtype_index,
10149 		(void *)&cmd_region_flowtype_id,
10150 		(void *)&cmd_region_flowtype_flow_index,
10151 		(void *)&cmd_region_flowtype_flow_id,
10152 		NULL,
10153 	},
10154 };
10155 
10156 /* *** User Priority (UP) to queue region (region_id) set *** */
10157 struct cmd_user_priority_region_result {
10158 	cmdline_fixed_string_t set;
10159 	cmdline_fixed_string_t port;
10160 	portid_t port_id;
10161 	cmdline_fixed_string_t cmd;
10162 	cmdline_fixed_string_t user_priority;
10163 	uint8_t  user_priority_id;
10164 	cmdline_fixed_string_t region;
10165 	uint8_t  region_id;
10166 };
10167 
10168 static void
10169 cmd_user_priority_region_parsed(void *parsed_result,
10170 			__rte_unused struct cmdline *cl,
10171 			__rte_unused void *data)
10172 {
10173 	struct cmd_user_priority_region_result *res = parsed_result;
10174 	int ret = -ENOTSUP;
10175 #ifdef RTE_NET_I40E
10176 	struct rte_pmd_i40e_queue_region_conf region_conf;
10177 	enum rte_pmd_i40e_queue_region_op op_type;
10178 #endif
10179 
10180 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10181 		return;
10182 
10183 #ifdef RTE_NET_I40E
10184 	memset(&region_conf, 0, sizeof(region_conf));
10185 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10186 	region_conf.user_priority = res->user_priority_id;
10187 	region_conf.region_id = res->region_id;
10188 
10189 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10190 				op_type, &region_conf);
10191 #endif
10192 
10193 	switch (ret) {
10194 	case 0:
10195 		break;
10196 	case -ENOTSUP:
10197 		fprintf(stderr, "function not implemented or supported\n");
10198 		break;
10199 	default:
10200 		fprintf(stderr, "user_priority region config error: (%s)\n",
10201 			strerror(-ret));
10202 	}
10203 }
10204 
10205 cmdline_parse_token_string_t cmd_user_priority_region_set =
10206 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10207 				set, "set");
10208 cmdline_parse_token_string_t cmd_user_priority_region_port =
10209 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10210 				port, "port");
10211 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10212 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10213 				port_id, RTE_UINT16);
10214 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10215 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10216 				cmd, "queue-region");
10217 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10218 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10219 				user_priority, "UP");
10220 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10221 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10222 				user_priority_id, RTE_UINT8);
10223 cmdline_parse_token_string_t cmd_user_priority_region_region =
10224 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10225 				region, "region_id");
10226 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10227 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10228 				region_id, RTE_UINT8);
10229 
10230 cmdline_parse_inst_t cmd_user_priority_region = {
10231 	.f = cmd_user_priority_region_parsed,
10232 	.data = NULL,
10233 	.help_str = "set port <port_id> queue-region UP <value> "
10234 		"region_id <value>: Set the mapping of User Priority (UP) "
10235 		"to queue region (region_id) ",
10236 	.tokens = {
10237 		(void *)&cmd_user_priority_region_set,
10238 		(void *)&cmd_user_priority_region_port,
10239 		(void *)&cmd_user_priority_region_port_index,
10240 		(void *)&cmd_user_priority_region_cmd,
10241 		(void *)&cmd_user_priority_region_UP,
10242 		(void *)&cmd_user_priority_region_UP_id,
10243 		(void *)&cmd_user_priority_region_region,
10244 		(void *)&cmd_user_priority_region_region_id,
10245 		NULL,
10246 	},
10247 };
10248 
10249 /* *** flush all queue region related configuration *** */
10250 struct cmd_flush_queue_region_result {
10251 	cmdline_fixed_string_t set;
10252 	cmdline_fixed_string_t port;
10253 	portid_t port_id;
10254 	cmdline_fixed_string_t cmd;
10255 	cmdline_fixed_string_t flush;
10256 	cmdline_fixed_string_t what;
10257 };
10258 
10259 static void
10260 cmd_flush_queue_region_parsed(void *parsed_result,
10261 			__rte_unused struct cmdline *cl,
10262 			__rte_unused void *data)
10263 {
10264 	struct cmd_flush_queue_region_result *res = parsed_result;
10265 	int ret = -ENOTSUP;
10266 #ifdef RTE_NET_I40E
10267 	struct rte_pmd_i40e_queue_region_conf region_conf;
10268 	enum rte_pmd_i40e_queue_region_op op_type;
10269 #endif
10270 
10271 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10272 		return;
10273 
10274 #ifdef RTE_NET_I40E
10275 	memset(&region_conf, 0, sizeof(region_conf));
10276 
10277 	if (strcmp(res->what, "on") == 0)
10278 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10279 	else
10280 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10281 
10282 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10283 				op_type, &region_conf);
10284 #endif
10285 
10286 	switch (ret) {
10287 	case 0:
10288 		break;
10289 	case -ENOTSUP:
10290 		fprintf(stderr, "function not implemented or supported\n");
10291 		break;
10292 	default:
10293 		fprintf(stderr, "queue region config flush error: (%s)\n",
10294 			strerror(-ret));
10295 	}
10296 }
10297 
10298 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10299 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10300 				set, "set");
10301 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10302 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10303 				port, "port");
10304 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10305 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10306 				port_id, RTE_UINT16);
10307 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10308 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10309 				cmd, "queue-region");
10310 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10311 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10312 				flush, "flush");
10313 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10314 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10315 				what, "on#off");
10316 
10317 cmdline_parse_inst_t cmd_flush_queue_region = {
10318 	.f = cmd_flush_queue_region_parsed,
10319 	.data = NULL,
10320 	.help_str = "set port <port_id> queue-region flush on|off"
10321 		": flush all queue region related configuration",
10322 	.tokens = {
10323 		(void *)&cmd_flush_queue_region_set,
10324 		(void *)&cmd_flush_queue_region_port,
10325 		(void *)&cmd_flush_queue_region_port_index,
10326 		(void *)&cmd_flush_queue_region_cmd,
10327 		(void *)&cmd_flush_queue_region_flush,
10328 		(void *)&cmd_flush_queue_region_what,
10329 		NULL,
10330 	},
10331 };
10332 
10333 /* *** get all queue region related configuration info *** */
10334 struct cmd_show_queue_region_info {
10335 	cmdline_fixed_string_t show;
10336 	cmdline_fixed_string_t port;
10337 	portid_t port_id;
10338 	cmdline_fixed_string_t cmd;
10339 };
10340 
10341 static void
10342 cmd_show_queue_region_info_parsed(void *parsed_result,
10343 			__rte_unused struct cmdline *cl,
10344 			__rte_unused void *data)
10345 {
10346 	struct cmd_show_queue_region_info *res = parsed_result;
10347 	int ret = -ENOTSUP;
10348 #ifdef RTE_NET_I40E
10349 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10350 	enum rte_pmd_i40e_queue_region_op op_type;
10351 #endif
10352 
10353 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10354 		return;
10355 
10356 #ifdef RTE_NET_I40E
10357 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10358 
10359 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10360 
10361 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10362 					op_type, &rte_pmd_regions);
10363 
10364 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10365 #endif
10366 
10367 	switch (ret) {
10368 	case 0:
10369 		break;
10370 	case -ENOTSUP:
10371 		fprintf(stderr, "function not implemented or supported\n");
10372 		break;
10373 	default:
10374 		fprintf(stderr, "queue region config info show error: (%s)\n",
10375 			strerror(-ret));
10376 	}
10377 }
10378 
10379 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10380 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10381 				show, "show");
10382 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10383 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10384 				port, "port");
10385 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10386 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10387 				port_id, RTE_UINT16);
10388 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10389 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10390 				cmd, "queue-region");
10391 
10392 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10393 	.f = cmd_show_queue_region_info_parsed,
10394 	.data = NULL,
10395 	.help_str = "show port <port_id> queue-region"
10396 		": show all queue region related configuration info",
10397 	.tokens = {
10398 		(void *)&cmd_show_queue_region_info_get,
10399 		(void *)&cmd_show_queue_region_info_port,
10400 		(void *)&cmd_show_queue_region_info_port_index,
10401 		(void *)&cmd_show_queue_region_info_cmd,
10402 		NULL,
10403 	},
10404 };
10405 
10406 /* *** Filters Control *** */
10407 
10408 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10409 do { \
10410 	if ((ip_addr).family == AF_INET) \
10411 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10412 	else { \
10413 		fprintf(stderr, "invalid parameter.\n"); \
10414 		return; \
10415 	} \
10416 } while (0)
10417 
10418 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10419 do { \
10420 	if ((ip_addr).family == AF_INET6) \
10421 		rte_memcpy(&(ip), \
10422 				 &((ip_addr).addr.ipv6), \
10423 				 sizeof(struct in6_addr)); \
10424 	else { \
10425 		fprintf(stderr, "invalid parameter.\n"); \
10426 		return; \
10427 	} \
10428 } while (0)
10429 
10430 #ifdef RTE_NET_I40E
10431 
10432 static uint16_t
10433 str2flowtype(char *string)
10434 {
10435 	uint8_t i = 0;
10436 	static const struct {
10437 		char str[32];
10438 		uint16_t type;
10439 	} flowtype_str[] = {
10440 		{"raw", RTE_ETH_FLOW_RAW},
10441 		{"ipv4", RTE_ETH_FLOW_IPV4},
10442 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10443 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10444 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10445 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10446 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10447 		{"ipv6", RTE_ETH_FLOW_IPV6},
10448 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10449 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10450 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10451 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10452 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10453 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10454 		{"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10455 		{"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10456 		{"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10457 		{"gtpu", RTE_ETH_FLOW_GTPU},
10458 	};
10459 
10460 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10461 		if (!strcmp(flowtype_str[i].str, string))
10462 			return flowtype_str[i].type;
10463 	}
10464 
10465 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10466 		return (uint16_t)atoi(string);
10467 
10468 	return RTE_ETH_FLOW_UNKNOWN;
10469 }
10470 
10471 /* *** deal with flow director filter *** */
10472 struct cmd_flow_director_result {
10473 	cmdline_fixed_string_t flow_director_filter;
10474 	portid_t port_id;
10475 	cmdline_fixed_string_t mode;
10476 	cmdline_fixed_string_t mode_value;
10477 	cmdline_fixed_string_t ops;
10478 	cmdline_fixed_string_t flow;
10479 	cmdline_fixed_string_t flow_type;
10480 	cmdline_fixed_string_t drop;
10481 	cmdline_fixed_string_t queue;
10482 	uint16_t  queue_id;
10483 	cmdline_fixed_string_t fd_id;
10484 	uint32_t  fd_id_value;
10485 	cmdline_fixed_string_t packet;
10486 	char filepath[];
10487 };
10488 
10489 static void
10490 cmd_flow_director_filter_parsed(void *parsed_result,
10491 			  __rte_unused struct cmdline *cl,
10492 			  __rte_unused void *data)
10493 {
10494 	struct cmd_flow_director_result *res = parsed_result;
10495 	int ret = 0;
10496 	struct rte_pmd_i40e_flow_type_mapping
10497 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10498 	struct rte_pmd_i40e_pkt_template_conf conf;
10499 	uint16_t flow_type = str2flowtype(res->flow_type);
10500 	uint16_t i, port = res->port_id;
10501 	uint8_t add;
10502 
10503 	memset(&conf, 0, sizeof(conf));
10504 
10505 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10506 		fprintf(stderr, "Invalid flow type specified.\n");
10507 		return;
10508 	}
10509 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10510 						 mapping);
10511 	if (ret)
10512 		return;
10513 	if (mapping[flow_type].pctype == 0ULL) {
10514 		fprintf(stderr, "Invalid flow type specified.\n");
10515 		return;
10516 	}
10517 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10518 		if (mapping[flow_type].pctype & (1ULL << i)) {
10519 			conf.input.pctype = i;
10520 			break;
10521 		}
10522 	}
10523 
10524 	conf.input.packet = open_file(res->filepath,
10525 				&conf.input.length);
10526 	if (!conf.input.packet)
10527 		return;
10528 	if (!strcmp(res->drop, "drop"))
10529 		conf.action.behavior =
10530 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10531 	else
10532 		conf.action.behavior =
10533 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10534 	conf.action.report_status =
10535 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10536 	conf.action.rx_queue = res->queue_id;
10537 	conf.soft_id = res->fd_id_value;
10538 	add  = strcmp(res->ops, "del") ? 1 : 0;
10539 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10540 							&conf,
10541 							add);
10542 	if (ret < 0)
10543 		fprintf(stderr, "flow director config error: (%s)\n",
10544 			strerror(-ret));
10545 	close_file(conf.input.packet);
10546 }
10547 
10548 cmdline_parse_token_string_t cmd_flow_director_filter =
10549 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10550 				 flow_director_filter, "flow_director_filter");
10551 cmdline_parse_token_num_t cmd_flow_director_port_id =
10552 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10553 			      port_id, RTE_UINT16);
10554 cmdline_parse_token_string_t cmd_flow_director_ops =
10555 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10556 				 ops, "add#del#update");
10557 cmdline_parse_token_string_t cmd_flow_director_flow =
10558 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10559 				 flow, "flow");
10560 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10561 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10562 		flow_type, NULL);
10563 cmdline_parse_token_string_t cmd_flow_director_drop =
10564 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10565 				 drop, "drop#fwd");
10566 cmdline_parse_token_string_t cmd_flow_director_queue =
10567 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10568 				 queue, "queue");
10569 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10570 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10571 			      queue_id, RTE_UINT16);
10572 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10573 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10574 				 fd_id, "fd_id");
10575 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10576 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10577 			      fd_id_value, RTE_UINT32);
10578 
10579 cmdline_parse_token_string_t cmd_flow_director_mode =
10580 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10581 				 mode, "mode");
10582 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10583 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10584 				 mode_value, "raw");
10585 cmdline_parse_token_string_t cmd_flow_director_packet =
10586 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10587 				 packet, "packet");
10588 cmdline_parse_token_string_t cmd_flow_director_filepath =
10589 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10590 				 filepath, NULL);
10591 
10592 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10593 	.f = cmd_flow_director_filter_parsed,
10594 	.data = NULL,
10595 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10596 		"director entry on NIC",
10597 	.tokens = {
10598 		(void *)&cmd_flow_director_filter,
10599 		(void *)&cmd_flow_director_port_id,
10600 		(void *)&cmd_flow_director_mode,
10601 		(void *)&cmd_flow_director_mode_raw,
10602 		(void *)&cmd_flow_director_ops,
10603 		(void *)&cmd_flow_director_flow,
10604 		(void *)&cmd_flow_director_flow_type,
10605 		(void *)&cmd_flow_director_drop,
10606 		(void *)&cmd_flow_director_queue,
10607 		(void *)&cmd_flow_director_queue_id,
10608 		(void *)&cmd_flow_director_fd_id,
10609 		(void *)&cmd_flow_director_fd_id_value,
10610 		(void *)&cmd_flow_director_packet,
10611 		(void *)&cmd_flow_director_filepath,
10612 		NULL,
10613 	},
10614 };
10615 
10616 #endif /* RTE_NET_I40E */
10617 
10618 /* *** deal with flow director mask *** */
10619 struct cmd_flow_director_mask_result {
10620 	cmdline_fixed_string_t flow_director_mask;
10621 	portid_t port_id;
10622 	cmdline_fixed_string_t mode;
10623 	cmdline_fixed_string_t mode_value;
10624 	cmdline_fixed_string_t vlan;
10625 	uint16_t vlan_mask;
10626 	cmdline_fixed_string_t src_mask;
10627 	cmdline_ipaddr_t ipv4_src;
10628 	cmdline_ipaddr_t ipv6_src;
10629 	uint16_t port_src;
10630 	cmdline_fixed_string_t dst_mask;
10631 	cmdline_ipaddr_t ipv4_dst;
10632 	cmdline_ipaddr_t ipv6_dst;
10633 	uint16_t port_dst;
10634 	cmdline_fixed_string_t mac;
10635 	uint8_t mac_addr_byte_mask;
10636 	cmdline_fixed_string_t tunnel_id;
10637 	uint32_t tunnel_id_mask;
10638 	cmdline_fixed_string_t tunnel_type;
10639 	uint8_t tunnel_type_mask;
10640 };
10641 
10642 static void
10643 cmd_flow_director_mask_parsed(void *parsed_result,
10644 			  __rte_unused struct cmdline *cl,
10645 			  __rte_unused void *data)
10646 {
10647 	struct cmd_flow_director_mask_result *res = parsed_result;
10648 	struct rte_eth_fdir_masks *mask;
10649 	struct rte_port *port;
10650 
10651 	port = &ports[res->port_id];
10652 	/** Check if the port is not started **/
10653 	if (port->port_status != RTE_PORT_STOPPED) {
10654 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
10655 		return;
10656 	}
10657 
10658 	mask = &port->dev_conf.fdir_conf.mask;
10659 
10660 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10661 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10662 			fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10663 			return;
10664 		}
10665 
10666 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10667 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10668 		if (strcmp(res->mode_value, "Tunnel")) {
10669 			fprintf(stderr, "Please set mode to Tunnel.\n");
10670 			return;
10671 		}
10672 
10673 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10674 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10675 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10676 		mask->tunnel_type_mask = res->tunnel_type_mask;
10677 	} else {
10678 		if (strcmp(res->mode_value, "IP")) {
10679 			fprintf(stderr, "Please set mode to IP.\n");
10680 			return;
10681 		}
10682 
10683 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10684 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10685 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10686 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10687 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10688 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10689 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10690 	}
10691 
10692 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10693 }
10694 
10695 cmdline_parse_token_string_t cmd_flow_director_mask =
10696 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10697 				 flow_director_mask, "flow_director_mask");
10698 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10699 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10700 			      port_id, RTE_UINT16);
10701 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10702 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10703 				 vlan, "vlan");
10704 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10705 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10706 			      vlan_mask, RTE_UINT16);
10707 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10708 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10709 				 src_mask, "src_mask");
10710 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10711 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10712 				 ipv4_src);
10713 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10714 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10715 				 ipv6_src);
10716 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10717 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10718 			      port_src, RTE_UINT16);
10719 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10720 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10721 				 dst_mask, "dst_mask");
10722 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10723 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10724 				 ipv4_dst);
10725 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10726 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10727 				 ipv6_dst);
10728 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10729 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10730 			      port_dst, RTE_UINT16);
10731 
10732 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10733 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10734 				 mode, "mode");
10735 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10736 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10737 				 mode_value, "IP");
10738 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10739 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10740 				 mode_value, "MAC-VLAN");
10741 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10742 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10743 				 mode_value, "Tunnel");
10744 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10745 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10746 				 mac, "mac");
10747 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10748 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10749 			      mac_addr_byte_mask, RTE_UINT8);
10750 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10751 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10752 				 tunnel_type, "tunnel-type");
10753 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10754 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10755 			      tunnel_type_mask, RTE_UINT8);
10756 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10757 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10758 				 tunnel_id, "tunnel-id");
10759 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10760 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10761 			      tunnel_id_mask, RTE_UINT32);
10762 
10763 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10764 	.f = cmd_flow_director_mask_parsed,
10765 	.data = NULL,
10766 	.help_str = "flow_director_mask ... : "
10767 		"Set IP mode flow director's mask on NIC",
10768 	.tokens = {
10769 		(void *)&cmd_flow_director_mask,
10770 		(void *)&cmd_flow_director_mask_port_id,
10771 		(void *)&cmd_flow_director_mask_mode,
10772 		(void *)&cmd_flow_director_mask_mode_ip,
10773 		(void *)&cmd_flow_director_mask_vlan,
10774 		(void *)&cmd_flow_director_mask_vlan_value,
10775 		(void *)&cmd_flow_director_mask_src,
10776 		(void *)&cmd_flow_director_mask_ipv4_src,
10777 		(void *)&cmd_flow_director_mask_ipv6_src,
10778 		(void *)&cmd_flow_director_mask_port_src,
10779 		(void *)&cmd_flow_director_mask_dst,
10780 		(void *)&cmd_flow_director_mask_ipv4_dst,
10781 		(void *)&cmd_flow_director_mask_ipv6_dst,
10782 		(void *)&cmd_flow_director_mask_port_dst,
10783 		NULL,
10784 	},
10785 };
10786 
10787 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10788 	.f = cmd_flow_director_mask_parsed,
10789 	.data = NULL,
10790 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10791 		"flow director's mask on NIC",
10792 	.tokens = {
10793 		(void *)&cmd_flow_director_mask,
10794 		(void *)&cmd_flow_director_mask_port_id,
10795 		(void *)&cmd_flow_director_mask_mode,
10796 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10797 		(void *)&cmd_flow_director_mask_vlan,
10798 		(void *)&cmd_flow_director_mask_vlan_value,
10799 		NULL,
10800 	},
10801 };
10802 
10803 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10804 	.f = cmd_flow_director_mask_parsed,
10805 	.data = NULL,
10806 	.help_str = "flow_director_mask ... : Set tunnel mode "
10807 		"flow director's mask on NIC",
10808 	.tokens = {
10809 		(void *)&cmd_flow_director_mask,
10810 		(void *)&cmd_flow_director_mask_port_id,
10811 		(void *)&cmd_flow_director_mask_mode,
10812 		(void *)&cmd_flow_director_mask_mode_tunnel,
10813 		(void *)&cmd_flow_director_mask_vlan,
10814 		(void *)&cmd_flow_director_mask_vlan_value,
10815 		(void *)&cmd_flow_director_mask_mac,
10816 		(void *)&cmd_flow_director_mask_mac_value,
10817 		(void *)&cmd_flow_director_mask_tunnel_type,
10818 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10819 		(void *)&cmd_flow_director_mask_tunnel_id,
10820 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10821 		NULL,
10822 	},
10823 };
10824 
10825 /* *** deal with flow director flexible payload configuration *** */
10826 struct cmd_flow_director_flexpayload_result {
10827 	cmdline_fixed_string_t flow_director_flexpayload;
10828 	portid_t port_id;
10829 	cmdline_fixed_string_t payload_layer;
10830 	cmdline_fixed_string_t payload_cfg;
10831 };
10832 
10833 static inline int
10834 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10835 {
10836 	char s[256];
10837 	const char *p, *p0 = q_arg;
10838 	char *end;
10839 	unsigned long int_fld;
10840 	char *str_fld[max_num];
10841 	int i;
10842 	unsigned size;
10843 	int ret = -1;
10844 
10845 	p = strchr(p0, '(');
10846 	if (p == NULL)
10847 		return -1;
10848 	++p;
10849 	p0 = strchr(p, ')');
10850 	if (p0 == NULL)
10851 		return -1;
10852 
10853 	size = p0 - p;
10854 	if (size >= sizeof(s))
10855 		return -1;
10856 
10857 	snprintf(s, sizeof(s), "%.*s", size, p);
10858 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10859 	if (ret < 0 || ret > max_num)
10860 		return -1;
10861 	for (i = 0; i < ret; i++) {
10862 		errno = 0;
10863 		int_fld = strtoul(str_fld[i], &end, 0);
10864 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10865 			return -1;
10866 		offsets[i] = (uint16_t)int_fld;
10867 	}
10868 	return ret;
10869 }
10870 
10871 static void
10872 cmd_flow_director_flxpld_parsed(void *parsed_result,
10873 			  __rte_unused struct cmdline *cl,
10874 			  __rte_unused void *data)
10875 {
10876 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
10877 	struct rte_eth_flex_payload_cfg flex_cfg;
10878 	struct rte_port *port;
10879 	int ret = 0;
10880 
10881 	port = &ports[res->port_id];
10882 	/** Check if the port is not started **/
10883 	if (port->port_status != RTE_PORT_STOPPED) {
10884 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
10885 		return;
10886 	}
10887 
10888 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10889 
10890 	if (!strcmp(res->payload_layer, "raw"))
10891 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10892 	else if (!strcmp(res->payload_layer, "l2"))
10893 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10894 	else if (!strcmp(res->payload_layer, "l3"))
10895 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10896 	else if (!strcmp(res->payload_layer, "l4"))
10897 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10898 
10899 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10900 			    RTE_ETH_FDIR_MAX_FLEXLEN);
10901 	if (ret < 0) {
10902 		fprintf(stderr, "error: Cannot parse flex payload input.\n");
10903 		return;
10904 	}
10905 
10906 	fdir_set_flex_payload(res->port_id, &flex_cfg);
10907 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10908 }
10909 
10910 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10911 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10912 				 flow_director_flexpayload,
10913 				 "flow_director_flex_payload");
10914 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10915 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10916 			      port_id, RTE_UINT16);
10917 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10918 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10919 				 payload_layer, "raw#l2#l3#l4");
10920 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10921 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10922 				 payload_cfg, NULL);
10923 
10924 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10925 	.f = cmd_flow_director_flxpld_parsed,
10926 	.data = NULL,
10927 	.help_str = "flow_director_flexpayload ... : "
10928 		"Set flow director's flex payload on NIC",
10929 	.tokens = {
10930 		(void *)&cmd_flow_director_flexpayload,
10931 		(void *)&cmd_flow_director_flexpayload_port_id,
10932 		(void *)&cmd_flow_director_flexpayload_payload_layer,
10933 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
10934 		NULL,
10935 	},
10936 };
10937 
10938 /* Generic flow interface command. */
10939 extern cmdline_parse_inst_t cmd_flow;
10940 
10941 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10942 struct cmd_mcast_addr_result {
10943 	cmdline_fixed_string_t mcast_addr_cmd;
10944 	cmdline_fixed_string_t what;
10945 	uint16_t port_num;
10946 	struct rte_ether_addr mc_addr;
10947 };
10948 
10949 static void cmd_mcast_addr_parsed(void *parsed_result,
10950 		__rte_unused struct cmdline *cl,
10951 		__rte_unused void *data)
10952 {
10953 	struct cmd_mcast_addr_result *res = parsed_result;
10954 
10955 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10956 		fprintf(stderr,
10957 			"Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10958 			RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10959 		return;
10960 	}
10961 	if (strcmp(res->what, "add") == 0)
10962 		mcast_addr_add(res->port_num, &res->mc_addr);
10963 	else
10964 		mcast_addr_remove(res->port_num, &res->mc_addr);
10965 }
10966 
10967 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10968 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10969 				 mcast_addr_cmd, "mcast_addr");
10970 cmdline_parse_token_string_t cmd_mcast_addr_what =
10971 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10972 				 "add#remove");
10973 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10974 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10975 				 RTE_UINT16);
10976 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10977 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10978 
10979 cmdline_parse_inst_t cmd_mcast_addr = {
10980 	.f = cmd_mcast_addr_parsed,
10981 	.data = (void *)0,
10982 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10983 		"Add/Remove multicast MAC address on port_id",
10984 	.tokens = {
10985 		(void *)&cmd_mcast_addr_cmd,
10986 		(void *)&cmd_mcast_addr_what,
10987 		(void *)&cmd_mcast_addr_portnum,
10988 		(void *)&cmd_mcast_addr_addr,
10989 		NULL,
10990 	},
10991 };
10992 
10993 /* vf vlan anti spoof configuration */
10994 
10995 /* Common result structure for vf vlan anti spoof */
10996 struct cmd_vf_vlan_anti_spoof_result {
10997 	cmdline_fixed_string_t set;
10998 	cmdline_fixed_string_t vf;
10999 	cmdline_fixed_string_t vlan;
11000 	cmdline_fixed_string_t antispoof;
11001 	portid_t port_id;
11002 	uint32_t vf_id;
11003 	cmdline_fixed_string_t on_off;
11004 };
11005 
11006 /* Common CLI fields for vf vlan anti spoof enable disable */
11007 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11008 	TOKEN_STRING_INITIALIZER
11009 		(struct cmd_vf_vlan_anti_spoof_result,
11010 		 set, "set");
11011 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11012 	TOKEN_STRING_INITIALIZER
11013 		(struct cmd_vf_vlan_anti_spoof_result,
11014 		 vf, "vf");
11015 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11016 	TOKEN_STRING_INITIALIZER
11017 		(struct cmd_vf_vlan_anti_spoof_result,
11018 		 vlan, "vlan");
11019 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11020 	TOKEN_STRING_INITIALIZER
11021 		(struct cmd_vf_vlan_anti_spoof_result,
11022 		 antispoof, "antispoof");
11023 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11024 	TOKEN_NUM_INITIALIZER
11025 		(struct cmd_vf_vlan_anti_spoof_result,
11026 		 port_id, RTE_UINT16);
11027 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11028 	TOKEN_NUM_INITIALIZER
11029 		(struct cmd_vf_vlan_anti_spoof_result,
11030 		 vf_id, RTE_UINT32);
11031 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11032 	TOKEN_STRING_INITIALIZER
11033 		(struct cmd_vf_vlan_anti_spoof_result,
11034 		 on_off, "on#off");
11035 
11036 static void
11037 cmd_set_vf_vlan_anti_spoof_parsed(
11038 	void *parsed_result,
11039 	__rte_unused struct cmdline *cl,
11040 	__rte_unused void *data)
11041 {
11042 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11043 	int ret = -ENOTSUP;
11044 
11045 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11046 
11047 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11048 		return;
11049 
11050 #ifdef RTE_NET_IXGBE
11051 	if (ret == -ENOTSUP)
11052 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11053 				res->vf_id, is_on);
11054 #endif
11055 #ifdef RTE_NET_I40E
11056 	if (ret == -ENOTSUP)
11057 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11058 				res->vf_id, is_on);
11059 #endif
11060 #ifdef RTE_NET_BNXT
11061 	if (ret == -ENOTSUP)
11062 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11063 				res->vf_id, is_on);
11064 #endif
11065 
11066 	switch (ret) {
11067 	case 0:
11068 		break;
11069 	case -EINVAL:
11070 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11071 		break;
11072 	case -ENODEV:
11073 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11074 		break;
11075 	case -ENOTSUP:
11076 		fprintf(stderr, "function not implemented\n");
11077 		break;
11078 	default:
11079 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11080 	}
11081 }
11082 
11083 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11084 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
11085 	.data = NULL,
11086 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11087 	.tokens = {
11088 		(void *)&cmd_vf_vlan_anti_spoof_set,
11089 		(void *)&cmd_vf_vlan_anti_spoof_vf,
11090 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
11091 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
11092 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
11093 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
11094 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
11095 		NULL,
11096 	},
11097 };
11098 
11099 /* vf mac anti spoof configuration */
11100 
11101 /* Common result structure for vf mac anti spoof */
11102 struct cmd_vf_mac_anti_spoof_result {
11103 	cmdline_fixed_string_t set;
11104 	cmdline_fixed_string_t vf;
11105 	cmdline_fixed_string_t mac;
11106 	cmdline_fixed_string_t antispoof;
11107 	portid_t port_id;
11108 	uint32_t vf_id;
11109 	cmdline_fixed_string_t on_off;
11110 };
11111 
11112 /* Common CLI fields for vf mac anti spoof enable disable */
11113 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11114 	TOKEN_STRING_INITIALIZER
11115 		(struct cmd_vf_mac_anti_spoof_result,
11116 		 set, "set");
11117 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11118 	TOKEN_STRING_INITIALIZER
11119 		(struct cmd_vf_mac_anti_spoof_result,
11120 		 vf, "vf");
11121 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11122 	TOKEN_STRING_INITIALIZER
11123 		(struct cmd_vf_mac_anti_spoof_result,
11124 		 mac, "mac");
11125 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11126 	TOKEN_STRING_INITIALIZER
11127 		(struct cmd_vf_mac_anti_spoof_result,
11128 		 antispoof, "antispoof");
11129 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11130 	TOKEN_NUM_INITIALIZER
11131 		(struct cmd_vf_mac_anti_spoof_result,
11132 		 port_id, RTE_UINT16);
11133 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11134 	TOKEN_NUM_INITIALIZER
11135 		(struct cmd_vf_mac_anti_spoof_result,
11136 		 vf_id, RTE_UINT32);
11137 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11138 	TOKEN_STRING_INITIALIZER
11139 		(struct cmd_vf_mac_anti_spoof_result,
11140 		 on_off, "on#off");
11141 
11142 static void
11143 cmd_set_vf_mac_anti_spoof_parsed(
11144 	void *parsed_result,
11145 	__rte_unused struct cmdline *cl,
11146 	__rte_unused void *data)
11147 {
11148 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11149 	int ret = -ENOTSUP;
11150 
11151 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11152 
11153 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11154 		return;
11155 
11156 #ifdef RTE_NET_IXGBE
11157 	if (ret == -ENOTSUP)
11158 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11159 			res->vf_id, is_on);
11160 #endif
11161 #ifdef RTE_NET_I40E
11162 	if (ret == -ENOTSUP)
11163 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11164 			res->vf_id, is_on);
11165 #endif
11166 #ifdef RTE_NET_BNXT
11167 	if (ret == -ENOTSUP)
11168 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11169 			res->vf_id, is_on);
11170 #endif
11171 
11172 	switch (ret) {
11173 	case 0:
11174 		break;
11175 	case -EINVAL:
11176 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11177 			res->vf_id, is_on);
11178 		break;
11179 	case -ENODEV:
11180 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11181 		break;
11182 	case -ENOTSUP:
11183 		fprintf(stderr, "function not implemented\n");
11184 		break;
11185 	default:
11186 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11187 	}
11188 }
11189 
11190 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11191 	.f = cmd_set_vf_mac_anti_spoof_parsed,
11192 	.data = NULL,
11193 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11194 	.tokens = {
11195 		(void *)&cmd_vf_mac_anti_spoof_set,
11196 		(void *)&cmd_vf_mac_anti_spoof_vf,
11197 		(void *)&cmd_vf_mac_anti_spoof_mac,
11198 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
11199 		(void *)&cmd_vf_mac_anti_spoof_port_id,
11200 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
11201 		(void *)&cmd_vf_mac_anti_spoof_on_off,
11202 		NULL,
11203 	},
11204 };
11205 
11206 /* vf vlan strip queue configuration */
11207 
11208 /* Common result structure for vf mac anti spoof */
11209 struct cmd_vf_vlan_stripq_result {
11210 	cmdline_fixed_string_t set;
11211 	cmdline_fixed_string_t vf;
11212 	cmdline_fixed_string_t vlan;
11213 	cmdline_fixed_string_t stripq;
11214 	portid_t port_id;
11215 	uint16_t vf_id;
11216 	cmdline_fixed_string_t on_off;
11217 };
11218 
11219 /* Common CLI fields for vf vlan strip enable disable */
11220 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11221 	TOKEN_STRING_INITIALIZER
11222 		(struct cmd_vf_vlan_stripq_result,
11223 		 set, "set");
11224 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11225 	TOKEN_STRING_INITIALIZER
11226 		(struct cmd_vf_vlan_stripq_result,
11227 		 vf, "vf");
11228 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11229 	TOKEN_STRING_INITIALIZER
11230 		(struct cmd_vf_vlan_stripq_result,
11231 		 vlan, "vlan");
11232 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11233 	TOKEN_STRING_INITIALIZER
11234 		(struct cmd_vf_vlan_stripq_result,
11235 		 stripq, "stripq");
11236 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11237 	TOKEN_NUM_INITIALIZER
11238 		(struct cmd_vf_vlan_stripq_result,
11239 		 port_id, RTE_UINT16);
11240 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11241 	TOKEN_NUM_INITIALIZER
11242 		(struct cmd_vf_vlan_stripq_result,
11243 		 vf_id, RTE_UINT16);
11244 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11245 	TOKEN_STRING_INITIALIZER
11246 		(struct cmd_vf_vlan_stripq_result,
11247 		 on_off, "on#off");
11248 
11249 static void
11250 cmd_set_vf_vlan_stripq_parsed(
11251 	void *parsed_result,
11252 	__rte_unused struct cmdline *cl,
11253 	__rte_unused void *data)
11254 {
11255 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
11256 	int ret = -ENOTSUP;
11257 
11258 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11259 
11260 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11261 		return;
11262 
11263 #ifdef RTE_NET_IXGBE
11264 	if (ret == -ENOTSUP)
11265 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11266 			res->vf_id, is_on);
11267 #endif
11268 #ifdef RTE_NET_I40E
11269 	if (ret == -ENOTSUP)
11270 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11271 			res->vf_id, is_on);
11272 #endif
11273 #ifdef RTE_NET_BNXT
11274 	if (ret == -ENOTSUP)
11275 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11276 			res->vf_id, is_on);
11277 #endif
11278 
11279 	switch (ret) {
11280 	case 0:
11281 		break;
11282 	case -EINVAL:
11283 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11284 			res->vf_id, is_on);
11285 		break;
11286 	case -ENODEV:
11287 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11288 		break;
11289 	case -ENOTSUP:
11290 		fprintf(stderr, "function not implemented\n");
11291 		break;
11292 	default:
11293 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11294 	}
11295 }
11296 
11297 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11298 	.f = cmd_set_vf_vlan_stripq_parsed,
11299 	.data = NULL,
11300 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11301 	.tokens = {
11302 		(void *)&cmd_vf_vlan_stripq_set,
11303 		(void *)&cmd_vf_vlan_stripq_vf,
11304 		(void *)&cmd_vf_vlan_stripq_vlan,
11305 		(void *)&cmd_vf_vlan_stripq_stripq,
11306 		(void *)&cmd_vf_vlan_stripq_port_id,
11307 		(void *)&cmd_vf_vlan_stripq_vf_id,
11308 		(void *)&cmd_vf_vlan_stripq_on_off,
11309 		NULL,
11310 	},
11311 };
11312 
11313 /* vf vlan insert configuration */
11314 
11315 /* Common result structure for vf vlan insert */
11316 struct cmd_vf_vlan_insert_result {
11317 	cmdline_fixed_string_t set;
11318 	cmdline_fixed_string_t vf;
11319 	cmdline_fixed_string_t vlan;
11320 	cmdline_fixed_string_t insert;
11321 	portid_t port_id;
11322 	uint16_t vf_id;
11323 	uint16_t vlan_id;
11324 };
11325 
11326 /* Common CLI fields for vf vlan insert enable disable */
11327 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11328 	TOKEN_STRING_INITIALIZER
11329 		(struct cmd_vf_vlan_insert_result,
11330 		 set, "set");
11331 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11332 	TOKEN_STRING_INITIALIZER
11333 		(struct cmd_vf_vlan_insert_result,
11334 		 vf, "vf");
11335 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11336 	TOKEN_STRING_INITIALIZER
11337 		(struct cmd_vf_vlan_insert_result,
11338 		 vlan, "vlan");
11339 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11340 	TOKEN_STRING_INITIALIZER
11341 		(struct cmd_vf_vlan_insert_result,
11342 		 insert, "insert");
11343 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11344 	TOKEN_NUM_INITIALIZER
11345 		(struct cmd_vf_vlan_insert_result,
11346 		 port_id, RTE_UINT16);
11347 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11348 	TOKEN_NUM_INITIALIZER
11349 		(struct cmd_vf_vlan_insert_result,
11350 		 vf_id, RTE_UINT16);
11351 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11352 	TOKEN_NUM_INITIALIZER
11353 		(struct cmd_vf_vlan_insert_result,
11354 		 vlan_id, RTE_UINT16);
11355 
11356 static void
11357 cmd_set_vf_vlan_insert_parsed(
11358 	void *parsed_result,
11359 	__rte_unused struct cmdline *cl,
11360 	__rte_unused void *data)
11361 {
11362 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11363 	int ret = -ENOTSUP;
11364 
11365 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11366 		return;
11367 
11368 #ifdef RTE_NET_IXGBE
11369 	if (ret == -ENOTSUP)
11370 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11371 			res->vlan_id);
11372 #endif
11373 #ifdef RTE_NET_I40E
11374 	if (ret == -ENOTSUP)
11375 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11376 			res->vlan_id);
11377 #endif
11378 #ifdef RTE_NET_BNXT
11379 	if (ret == -ENOTSUP)
11380 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11381 			res->vlan_id);
11382 #endif
11383 
11384 	switch (ret) {
11385 	case 0:
11386 		break;
11387 	case -EINVAL:
11388 		fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11389 			res->vf_id, res->vlan_id);
11390 		break;
11391 	case -ENODEV:
11392 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11393 		break;
11394 	case -ENOTSUP:
11395 		fprintf(stderr, "function not implemented\n");
11396 		break;
11397 	default:
11398 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11399 	}
11400 }
11401 
11402 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11403 	.f = cmd_set_vf_vlan_insert_parsed,
11404 	.data = NULL,
11405 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11406 	.tokens = {
11407 		(void *)&cmd_vf_vlan_insert_set,
11408 		(void *)&cmd_vf_vlan_insert_vf,
11409 		(void *)&cmd_vf_vlan_insert_vlan,
11410 		(void *)&cmd_vf_vlan_insert_insert,
11411 		(void *)&cmd_vf_vlan_insert_port_id,
11412 		(void *)&cmd_vf_vlan_insert_vf_id,
11413 		(void *)&cmd_vf_vlan_insert_vlan_id,
11414 		NULL,
11415 	},
11416 };
11417 
11418 /* tx loopback configuration */
11419 
11420 /* Common result structure for tx loopback */
11421 struct cmd_tx_loopback_result {
11422 	cmdline_fixed_string_t set;
11423 	cmdline_fixed_string_t tx;
11424 	cmdline_fixed_string_t loopback;
11425 	portid_t port_id;
11426 	cmdline_fixed_string_t on_off;
11427 };
11428 
11429 /* Common CLI fields for tx loopback enable disable */
11430 cmdline_parse_token_string_t cmd_tx_loopback_set =
11431 	TOKEN_STRING_INITIALIZER
11432 		(struct cmd_tx_loopback_result,
11433 		 set, "set");
11434 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11435 	TOKEN_STRING_INITIALIZER
11436 		(struct cmd_tx_loopback_result,
11437 		 tx, "tx");
11438 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11439 	TOKEN_STRING_INITIALIZER
11440 		(struct cmd_tx_loopback_result,
11441 		 loopback, "loopback");
11442 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11443 	TOKEN_NUM_INITIALIZER
11444 		(struct cmd_tx_loopback_result,
11445 		 port_id, RTE_UINT16);
11446 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11447 	TOKEN_STRING_INITIALIZER
11448 		(struct cmd_tx_loopback_result,
11449 		 on_off, "on#off");
11450 
11451 static void
11452 cmd_set_tx_loopback_parsed(
11453 	void *parsed_result,
11454 	__rte_unused struct cmdline *cl,
11455 	__rte_unused void *data)
11456 {
11457 	struct cmd_tx_loopback_result *res = parsed_result;
11458 	int ret = -ENOTSUP;
11459 
11460 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11461 
11462 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11463 		return;
11464 
11465 #ifdef RTE_NET_IXGBE
11466 	if (ret == -ENOTSUP)
11467 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11468 #endif
11469 #ifdef RTE_NET_I40E
11470 	if (ret == -ENOTSUP)
11471 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11472 #endif
11473 #ifdef RTE_NET_BNXT
11474 	if (ret == -ENOTSUP)
11475 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11476 #endif
11477 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11478 	if (ret == -ENOTSUP)
11479 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11480 #endif
11481 
11482 	switch (ret) {
11483 	case 0:
11484 		break;
11485 	case -EINVAL:
11486 		fprintf(stderr, "invalid is_on %d\n", is_on);
11487 		break;
11488 	case -ENODEV:
11489 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11490 		break;
11491 	case -ENOTSUP:
11492 		fprintf(stderr, "function not implemented\n");
11493 		break;
11494 	default:
11495 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11496 	}
11497 }
11498 
11499 cmdline_parse_inst_t cmd_set_tx_loopback = {
11500 	.f = cmd_set_tx_loopback_parsed,
11501 	.data = NULL,
11502 	.help_str = "set tx loopback <port_id> on|off",
11503 	.tokens = {
11504 		(void *)&cmd_tx_loopback_set,
11505 		(void *)&cmd_tx_loopback_tx,
11506 		(void *)&cmd_tx_loopback_loopback,
11507 		(void *)&cmd_tx_loopback_port_id,
11508 		(void *)&cmd_tx_loopback_on_off,
11509 		NULL,
11510 	},
11511 };
11512 
11513 /* all queues drop enable configuration */
11514 
11515 /* Common result structure for all queues drop enable */
11516 struct cmd_all_queues_drop_en_result {
11517 	cmdline_fixed_string_t set;
11518 	cmdline_fixed_string_t all;
11519 	cmdline_fixed_string_t queues;
11520 	cmdline_fixed_string_t drop;
11521 	portid_t port_id;
11522 	cmdline_fixed_string_t on_off;
11523 };
11524 
11525 /* Common CLI fields for tx loopback enable disable */
11526 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11527 	TOKEN_STRING_INITIALIZER
11528 		(struct cmd_all_queues_drop_en_result,
11529 		 set, "set");
11530 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11531 	TOKEN_STRING_INITIALIZER
11532 		(struct cmd_all_queues_drop_en_result,
11533 		 all, "all");
11534 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11535 	TOKEN_STRING_INITIALIZER
11536 		(struct cmd_all_queues_drop_en_result,
11537 		 queues, "queues");
11538 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11539 	TOKEN_STRING_INITIALIZER
11540 		(struct cmd_all_queues_drop_en_result,
11541 		 drop, "drop");
11542 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11543 	TOKEN_NUM_INITIALIZER
11544 		(struct cmd_all_queues_drop_en_result,
11545 		 port_id, RTE_UINT16);
11546 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11547 	TOKEN_STRING_INITIALIZER
11548 		(struct cmd_all_queues_drop_en_result,
11549 		 on_off, "on#off");
11550 
11551 static void
11552 cmd_set_all_queues_drop_en_parsed(
11553 	void *parsed_result,
11554 	__rte_unused struct cmdline *cl,
11555 	__rte_unused void *data)
11556 {
11557 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11558 	int ret = -ENOTSUP;
11559 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11560 
11561 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11562 		return;
11563 
11564 #ifdef RTE_NET_IXGBE
11565 	if (ret == -ENOTSUP)
11566 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11567 #endif
11568 #ifdef RTE_NET_BNXT
11569 	if (ret == -ENOTSUP)
11570 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11571 #endif
11572 	switch (ret) {
11573 	case 0:
11574 		break;
11575 	case -EINVAL:
11576 		fprintf(stderr, "invalid is_on %d\n", is_on);
11577 		break;
11578 	case -ENODEV:
11579 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11580 		break;
11581 	case -ENOTSUP:
11582 		fprintf(stderr, "function not implemented\n");
11583 		break;
11584 	default:
11585 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11586 	}
11587 }
11588 
11589 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11590 	.f = cmd_set_all_queues_drop_en_parsed,
11591 	.data = NULL,
11592 	.help_str = "set all queues drop <port_id> on|off",
11593 	.tokens = {
11594 		(void *)&cmd_all_queues_drop_en_set,
11595 		(void *)&cmd_all_queues_drop_en_all,
11596 		(void *)&cmd_all_queues_drop_en_queues,
11597 		(void *)&cmd_all_queues_drop_en_drop,
11598 		(void *)&cmd_all_queues_drop_en_port_id,
11599 		(void *)&cmd_all_queues_drop_en_on_off,
11600 		NULL,
11601 	},
11602 };
11603 
11604 /* vf split drop enable configuration */
11605 
11606 /* Common result structure for vf split drop enable */
11607 struct cmd_vf_split_drop_en_result {
11608 	cmdline_fixed_string_t set;
11609 	cmdline_fixed_string_t vf;
11610 	cmdline_fixed_string_t split;
11611 	cmdline_fixed_string_t drop;
11612 	portid_t port_id;
11613 	uint16_t vf_id;
11614 	cmdline_fixed_string_t on_off;
11615 };
11616 
11617 /* Common CLI fields for vf split drop enable disable */
11618 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11619 	TOKEN_STRING_INITIALIZER
11620 		(struct cmd_vf_split_drop_en_result,
11621 		 set, "set");
11622 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11623 	TOKEN_STRING_INITIALIZER
11624 		(struct cmd_vf_split_drop_en_result,
11625 		 vf, "vf");
11626 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11627 	TOKEN_STRING_INITIALIZER
11628 		(struct cmd_vf_split_drop_en_result,
11629 		 split, "split");
11630 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11631 	TOKEN_STRING_INITIALIZER
11632 		(struct cmd_vf_split_drop_en_result,
11633 		 drop, "drop");
11634 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11635 	TOKEN_NUM_INITIALIZER
11636 		(struct cmd_vf_split_drop_en_result,
11637 		 port_id, RTE_UINT16);
11638 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11639 	TOKEN_NUM_INITIALIZER
11640 		(struct cmd_vf_split_drop_en_result,
11641 		 vf_id, RTE_UINT16);
11642 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11643 	TOKEN_STRING_INITIALIZER
11644 		(struct cmd_vf_split_drop_en_result,
11645 		 on_off, "on#off");
11646 
11647 static void
11648 cmd_set_vf_split_drop_en_parsed(
11649 	void *parsed_result,
11650 	__rte_unused struct cmdline *cl,
11651 	__rte_unused void *data)
11652 {
11653 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11654 	int ret = -ENOTSUP;
11655 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11656 
11657 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11658 		return;
11659 
11660 #ifdef RTE_NET_IXGBE
11661 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11662 			is_on);
11663 #endif
11664 	switch (ret) {
11665 	case 0:
11666 		break;
11667 	case -EINVAL:
11668 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11669 			res->vf_id, is_on);
11670 		break;
11671 	case -ENODEV:
11672 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11673 		break;
11674 	case -ENOTSUP:
11675 		fprintf(stderr, "not supported on port %d\n", res->port_id);
11676 		break;
11677 	default:
11678 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11679 	}
11680 }
11681 
11682 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11683 	.f = cmd_set_vf_split_drop_en_parsed,
11684 	.data = NULL,
11685 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11686 	.tokens = {
11687 		(void *)&cmd_vf_split_drop_en_set,
11688 		(void *)&cmd_vf_split_drop_en_vf,
11689 		(void *)&cmd_vf_split_drop_en_split,
11690 		(void *)&cmd_vf_split_drop_en_drop,
11691 		(void *)&cmd_vf_split_drop_en_port_id,
11692 		(void *)&cmd_vf_split_drop_en_vf_id,
11693 		(void *)&cmd_vf_split_drop_en_on_off,
11694 		NULL,
11695 	},
11696 };
11697 
11698 /* vf mac address configuration */
11699 
11700 /* Common result structure for vf mac address */
11701 struct cmd_set_vf_mac_addr_result {
11702 	cmdline_fixed_string_t set;
11703 	cmdline_fixed_string_t vf;
11704 	cmdline_fixed_string_t mac;
11705 	cmdline_fixed_string_t addr;
11706 	portid_t port_id;
11707 	uint16_t vf_id;
11708 	struct rte_ether_addr mac_addr;
11709 
11710 };
11711 
11712 /* Common CLI fields for vf split drop enable disable */
11713 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11714 	TOKEN_STRING_INITIALIZER
11715 		(struct cmd_set_vf_mac_addr_result,
11716 		 set, "set");
11717 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11718 	TOKEN_STRING_INITIALIZER
11719 		(struct cmd_set_vf_mac_addr_result,
11720 		 vf, "vf");
11721 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11722 	TOKEN_STRING_INITIALIZER
11723 		(struct cmd_set_vf_mac_addr_result,
11724 		 mac, "mac");
11725 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11726 	TOKEN_STRING_INITIALIZER
11727 		(struct cmd_set_vf_mac_addr_result,
11728 		 addr, "addr");
11729 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11730 	TOKEN_NUM_INITIALIZER
11731 		(struct cmd_set_vf_mac_addr_result,
11732 		 port_id, RTE_UINT16);
11733 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11734 	TOKEN_NUM_INITIALIZER
11735 		(struct cmd_set_vf_mac_addr_result,
11736 		 vf_id, RTE_UINT16);
11737 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11738 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11739 		 mac_addr);
11740 
11741 static void
11742 cmd_set_vf_mac_addr_parsed(
11743 	void *parsed_result,
11744 	__rte_unused struct cmdline *cl,
11745 	__rte_unused void *data)
11746 {
11747 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11748 	int ret = -ENOTSUP;
11749 
11750 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11751 		return;
11752 
11753 #ifdef RTE_NET_IXGBE
11754 	if (ret == -ENOTSUP)
11755 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11756 				&res->mac_addr);
11757 #endif
11758 #ifdef RTE_NET_I40E
11759 	if (ret == -ENOTSUP)
11760 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11761 				&res->mac_addr);
11762 #endif
11763 #ifdef RTE_NET_BNXT
11764 	if (ret == -ENOTSUP)
11765 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11766 				&res->mac_addr);
11767 #endif
11768 
11769 	switch (ret) {
11770 	case 0:
11771 		break;
11772 	case -EINVAL:
11773 		fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11774 		break;
11775 	case -ENODEV:
11776 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11777 		break;
11778 	case -ENOTSUP:
11779 		fprintf(stderr, "function not implemented\n");
11780 		break;
11781 	default:
11782 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11783 	}
11784 }
11785 
11786 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11787 	.f = cmd_set_vf_mac_addr_parsed,
11788 	.data = NULL,
11789 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11790 	.tokens = {
11791 		(void *)&cmd_set_vf_mac_addr_set,
11792 		(void *)&cmd_set_vf_mac_addr_vf,
11793 		(void *)&cmd_set_vf_mac_addr_mac,
11794 		(void *)&cmd_set_vf_mac_addr_addr,
11795 		(void *)&cmd_set_vf_mac_addr_port_id,
11796 		(void *)&cmd_set_vf_mac_addr_vf_id,
11797 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11798 		NULL,
11799 	},
11800 };
11801 
11802 /* MACsec configuration */
11803 
11804 /* Common result structure for MACsec offload enable */
11805 struct cmd_macsec_offload_on_result {
11806 	cmdline_fixed_string_t set;
11807 	cmdline_fixed_string_t macsec;
11808 	cmdline_fixed_string_t offload;
11809 	portid_t port_id;
11810 	cmdline_fixed_string_t on;
11811 	cmdline_fixed_string_t encrypt;
11812 	cmdline_fixed_string_t en_on_off;
11813 	cmdline_fixed_string_t replay_protect;
11814 	cmdline_fixed_string_t rp_on_off;
11815 };
11816 
11817 /* Common CLI fields for MACsec offload disable */
11818 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11819 	TOKEN_STRING_INITIALIZER
11820 		(struct cmd_macsec_offload_on_result,
11821 		 set, "set");
11822 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11823 	TOKEN_STRING_INITIALIZER
11824 		(struct cmd_macsec_offload_on_result,
11825 		 macsec, "macsec");
11826 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11827 	TOKEN_STRING_INITIALIZER
11828 		(struct cmd_macsec_offload_on_result,
11829 		 offload, "offload");
11830 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11831 	TOKEN_NUM_INITIALIZER
11832 		(struct cmd_macsec_offload_on_result,
11833 		 port_id, RTE_UINT16);
11834 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11835 	TOKEN_STRING_INITIALIZER
11836 		(struct cmd_macsec_offload_on_result,
11837 		 on, "on");
11838 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11839 	TOKEN_STRING_INITIALIZER
11840 		(struct cmd_macsec_offload_on_result,
11841 		 encrypt, "encrypt");
11842 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11843 	TOKEN_STRING_INITIALIZER
11844 		(struct cmd_macsec_offload_on_result,
11845 		 en_on_off, "on#off");
11846 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11847 	TOKEN_STRING_INITIALIZER
11848 		(struct cmd_macsec_offload_on_result,
11849 		 replay_protect, "replay-protect");
11850 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11851 	TOKEN_STRING_INITIALIZER
11852 		(struct cmd_macsec_offload_on_result,
11853 		 rp_on_off, "on#off");
11854 
11855 static void
11856 cmd_set_macsec_offload_on_parsed(
11857 	void *parsed_result,
11858 	__rte_unused struct cmdline *cl,
11859 	__rte_unused void *data)
11860 {
11861 	struct cmd_macsec_offload_on_result *res = parsed_result;
11862 	int ret = -ENOTSUP;
11863 	portid_t port_id = res->port_id;
11864 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11865 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11866 	struct rte_eth_dev_info dev_info;
11867 
11868 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11869 		return;
11870 	if (!port_is_stopped(port_id)) {
11871 		fprintf(stderr, "Please stop port %d first\n", port_id);
11872 		return;
11873 	}
11874 
11875 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11876 	if (ret != 0)
11877 		return;
11878 
11879 	if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11880 #ifdef RTE_NET_IXGBE
11881 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11882 #endif
11883 	}
11884 	RTE_SET_USED(en);
11885 	RTE_SET_USED(rp);
11886 
11887 	switch (ret) {
11888 	case 0:
11889 		ports[port_id].dev_conf.txmode.offloads |=
11890 						RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11891 		cmd_reconfig_device_queue(port_id, 1, 1);
11892 		break;
11893 	case -ENODEV:
11894 		fprintf(stderr, "invalid port_id %d\n", port_id);
11895 		break;
11896 	case -ENOTSUP:
11897 		fprintf(stderr, "not supported on port %d\n", port_id);
11898 		break;
11899 	default:
11900 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11901 	}
11902 }
11903 
11904 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11905 	.f = cmd_set_macsec_offload_on_parsed,
11906 	.data = NULL,
11907 	.help_str = "set macsec offload <port_id> on "
11908 		"encrypt on|off replay-protect on|off",
11909 	.tokens = {
11910 		(void *)&cmd_macsec_offload_on_set,
11911 		(void *)&cmd_macsec_offload_on_macsec,
11912 		(void *)&cmd_macsec_offload_on_offload,
11913 		(void *)&cmd_macsec_offload_on_port_id,
11914 		(void *)&cmd_macsec_offload_on_on,
11915 		(void *)&cmd_macsec_offload_on_encrypt,
11916 		(void *)&cmd_macsec_offload_on_en_on_off,
11917 		(void *)&cmd_macsec_offload_on_replay_protect,
11918 		(void *)&cmd_macsec_offload_on_rp_on_off,
11919 		NULL,
11920 	},
11921 };
11922 
11923 /* Common result structure for MACsec offload disable */
11924 struct cmd_macsec_offload_off_result {
11925 	cmdline_fixed_string_t set;
11926 	cmdline_fixed_string_t macsec;
11927 	cmdline_fixed_string_t offload;
11928 	portid_t port_id;
11929 	cmdline_fixed_string_t off;
11930 };
11931 
11932 /* Common CLI fields for MACsec offload disable */
11933 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11934 	TOKEN_STRING_INITIALIZER
11935 		(struct cmd_macsec_offload_off_result,
11936 		 set, "set");
11937 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11938 	TOKEN_STRING_INITIALIZER
11939 		(struct cmd_macsec_offload_off_result,
11940 		 macsec, "macsec");
11941 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11942 	TOKEN_STRING_INITIALIZER
11943 		(struct cmd_macsec_offload_off_result,
11944 		 offload, "offload");
11945 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11946 	TOKEN_NUM_INITIALIZER
11947 		(struct cmd_macsec_offload_off_result,
11948 		 port_id, RTE_UINT16);
11949 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11950 	TOKEN_STRING_INITIALIZER
11951 		(struct cmd_macsec_offload_off_result,
11952 		 off, "off");
11953 
11954 static void
11955 cmd_set_macsec_offload_off_parsed(
11956 	void *parsed_result,
11957 	__rte_unused struct cmdline *cl,
11958 	__rte_unused void *data)
11959 {
11960 	struct cmd_macsec_offload_off_result *res = parsed_result;
11961 	int ret = -ENOTSUP;
11962 	struct rte_eth_dev_info dev_info;
11963 	portid_t port_id = res->port_id;
11964 
11965 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11966 		return;
11967 	if (!port_is_stopped(port_id)) {
11968 		fprintf(stderr, "Please stop port %d first\n", port_id);
11969 		return;
11970 	}
11971 
11972 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11973 	if (ret != 0)
11974 		return;
11975 
11976 	if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11977 #ifdef RTE_NET_IXGBE
11978 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
11979 #endif
11980 	}
11981 	switch (ret) {
11982 	case 0:
11983 		ports[port_id].dev_conf.txmode.offloads &=
11984 						~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11985 		cmd_reconfig_device_queue(port_id, 1, 1);
11986 		break;
11987 	case -ENODEV:
11988 		fprintf(stderr, "invalid port_id %d\n", port_id);
11989 		break;
11990 	case -ENOTSUP:
11991 		fprintf(stderr, "not supported on port %d\n", port_id);
11992 		break;
11993 	default:
11994 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11995 	}
11996 }
11997 
11998 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11999 	.f = cmd_set_macsec_offload_off_parsed,
12000 	.data = NULL,
12001 	.help_str = "set macsec offload <port_id> off",
12002 	.tokens = {
12003 		(void *)&cmd_macsec_offload_off_set,
12004 		(void *)&cmd_macsec_offload_off_macsec,
12005 		(void *)&cmd_macsec_offload_off_offload,
12006 		(void *)&cmd_macsec_offload_off_port_id,
12007 		(void *)&cmd_macsec_offload_off_off,
12008 		NULL,
12009 	},
12010 };
12011 
12012 /* Common result structure for MACsec secure connection configure */
12013 struct cmd_macsec_sc_result {
12014 	cmdline_fixed_string_t set;
12015 	cmdline_fixed_string_t macsec;
12016 	cmdline_fixed_string_t sc;
12017 	cmdline_fixed_string_t tx_rx;
12018 	portid_t port_id;
12019 	struct rte_ether_addr mac;
12020 	uint16_t pi;
12021 };
12022 
12023 /* Common CLI fields for MACsec secure connection configure */
12024 cmdline_parse_token_string_t cmd_macsec_sc_set =
12025 	TOKEN_STRING_INITIALIZER
12026 		(struct cmd_macsec_sc_result,
12027 		 set, "set");
12028 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12029 	TOKEN_STRING_INITIALIZER
12030 		(struct cmd_macsec_sc_result,
12031 		 macsec, "macsec");
12032 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12033 	TOKEN_STRING_INITIALIZER
12034 		(struct cmd_macsec_sc_result,
12035 		 sc, "sc");
12036 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12037 	TOKEN_STRING_INITIALIZER
12038 		(struct cmd_macsec_sc_result,
12039 		 tx_rx, "tx#rx");
12040 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12041 	TOKEN_NUM_INITIALIZER
12042 		(struct cmd_macsec_sc_result,
12043 		 port_id, RTE_UINT16);
12044 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12045 	TOKEN_ETHERADDR_INITIALIZER
12046 		(struct cmd_macsec_sc_result,
12047 		 mac);
12048 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12049 	TOKEN_NUM_INITIALIZER
12050 		(struct cmd_macsec_sc_result,
12051 		 pi, RTE_UINT16);
12052 
12053 static void
12054 cmd_set_macsec_sc_parsed(
12055 	void *parsed_result,
12056 	__rte_unused struct cmdline *cl,
12057 	__rte_unused void *data)
12058 {
12059 	struct cmd_macsec_sc_result *res = parsed_result;
12060 	int ret = -ENOTSUP;
12061 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12062 
12063 #ifdef RTE_NET_IXGBE
12064 	ret = is_tx ?
12065 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12066 				res->mac.addr_bytes) :
12067 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12068 				res->mac.addr_bytes, res->pi);
12069 #endif
12070 	RTE_SET_USED(is_tx);
12071 
12072 	switch (ret) {
12073 	case 0:
12074 		break;
12075 	case -ENODEV:
12076 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12077 		break;
12078 	case -ENOTSUP:
12079 		fprintf(stderr, "not supported on port %d\n", res->port_id);
12080 		break;
12081 	default:
12082 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12083 	}
12084 }
12085 
12086 cmdline_parse_inst_t cmd_set_macsec_sc = {
12087 	.f = cmd_set_macsec_sc_parsed,
12088 	.data = NULL,
12089 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12090 	.tokens = {
12091 		(void *)&cmd_macsec_sc_set,
12092 		(void *)&cmd_macsec_sc_macsec,
12093 		(void *)&cmd_macsec_sc_sc,
12094 		(void *)&cmd_macsec_sc_tx_rx,
12095 		(void *)&cmd_macsec_sc_port_id,
12096 		(void *)&cmd_macsec_sc_mac,
12097 		(void *)&cmd_macsec_sc_pi,
12098 		NULL,
12099 	},
12100 };
12101 
12102 /* Common result structure for MACsec secure connection configure */
12103 struct cmd_macsec_sa_result {
12104 	cmdline_fixed_string_t set;
12105 	cmdline_fixed_string_t macsec;
12106 	cmdline_fixed_string_t sa;
12107 	cmdline_fixed_string_t tx_rx;
12108 	portid_t port_id;
12109 	uint8_t idx;
12110 	uint8_t an;
12111 	uint32_t pn;
12112 	cmdline_fixed_string_t key;
12113 };
12114 
12115 /* Common CLI fields for MACsec secure connection configure */
12116 cmdline_parse_token_string_t cmd_macsec_sa_set =
12117 	TOKEN_STRING_INITIALIZER
12118 		(struct cmd_macsec_sa_result,
12119 		 set, "set");
12120 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12121 	TOKEN_STRING_INITIALIZER
12122 		(struct cmd_macsec_sa_result,
12123 		 macsec, "macsec");
12124 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12125 	TOKEN_STRING_INITIALIZER
12126 		(struct cmd_macsec_sa_result,
12127 		 sa, "sa");
12128 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12129 	TOKEN_STRING_INITIALIZER
12130 		(struct cmd_macsec_sa_result,
12131 		 tx_rx, "tx#rx");
12132 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12133 	TOKEN_NUM_INITIALIZER
12134 		(struct cmd_macsec_sa_result,
12135 		 port_id, RTE_UINT16);
12136 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12137 	TOKEN_NUM_INITIALIZER
12138 		(struct cmd_macsec_sa_result,
12139 		 idx, RTE_UINT8);
12140 cmdline_parse_token_num_t cmd_macsec_sa_an =
12141 	TOKEN_NUM_INITIALIZER
12142 		(struct cmd_macsec_sa_result,
12143 		 an, RTE_UINT8);
12144 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12145 	TOKEN_NUM_INITIALIZER
12146 		(struct cmd_macsec_sa_result,
12147 		 pn, RTE_UINT32);
12148 cmdline_parse_token_string_t cmd_macsec_sa_key =
12149 	TOKEN_STRING_INITIALIZER
12150 		(struct cmd_macsec_sa_result,
12151 		 key, NULL);
12152 
12153 static void
12154 cmd_set_macsec_sa_parsed(
12155 	void *parsed_result,
12156 	__rte_unused struct cmdline *cl,
12157 	__rte_unused void *data)
12158 {
12159 	struct cmd_macsec_sa_result *res = parsed_result;
12160 	int ret = -ENOTSUP;
12161 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12162 	uint8_t key[16] = { 0 };
12163 	uint8_t xdgt0;
12164 	uint8_t xdgt1;
12165 	int key_len;
12166 	int i;
12167 
12168 	key_len = strlen(res->key) / 2;
12169 	if (key_len > 16)
12170 		key_len = 16;
12171 
12172 	for (i = 0; i < key_len; i++) {
12173 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12174 		if (xdgt0 == 0xFF)
12175 			return;
12176 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12177 		if (xdgt1 == 0xFF)
12178 			return;
12179 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12180 	}
12181 
12182 #ifdef RTE_NET_IXGBE
12183 	ret = is_tx ?
12184 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12185 			res->idx, res->an, res->pn, key) :
12186 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12187 			res->idx, res->an, res->pn, key);
12188 #endif
12189 	RTE_SET_USED(is_tx);
12190 	RTE_SET_USED(key);
12191 
12192 	switch (ret) {
12193 	case 0:
12194 		break;
12195 	case -EINVAL:
12196 		fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12197 		break;
12198 	case -ENODEV:
12199 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12200 		break;
12201 	case -ENOTSUP:
12202 		fprintf(stderr, "not supported on port %d\n", res->port_id);
12203 		break;
12204 	default:
12205 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12206 	}
12207 }
12208 
12209 cmdline_parse_inst_t cmd_set_macsec_sa = {
12210 	.f = cmd_set_macsec_sa_parsed,
12211 	.data = NULL,
12212 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12213 	.tokens = {
12214 		(void *)&cmd_macsec_sa_set,
12215 		(void *)&cmd_macsec_sa_macsec,
12216 		(void *)&cmd_macsec_sa_sa,
12217 		(void *)&cmd_macsec_sa_tx_rx,
12218 		(void *)&cmd_macsec_sa_port_id,
12219 		(void *)&cmd_macsec_sa_idx,
12220 		(void *)&cmd_macsec_sa_an,
12221 		(void *)&cmd_macsec_sa_pn,
12222 		(void *)&cmd_macsec_sa_key,
12223 		NULL,
12224 	},
12225 };
12226 
12227 /* VF unicast promiscuous mode configuration */
12228 
12229 /* Common result structure for VF unicast promiscuous mode */
12230 struct cmd_vf_promisc_result {
12231 	cmdline_fixed_string_t set;
12232 	cmdline_fixed_string_t vf;
12233 	cmdline_fixed_string_t promisc;
12234 	portid_t port_id;
12235 	uint32_t vf_id;
12236 	cmdline_fixed_string_t on_off;
12237 };
12238 
12239 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12240 cmdline_parse_token_string_t cmd_vf_promisc_set =
12241 	TOKEN_STRING_INITIALIZER
12242 		(struct cmd_vf_promisc_result,
12243 		 set, "set");
12244 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12245 	TOKEN_STRING_INITIALIZER
12246 		(struct cmd_vf_promisc_result,
12247 		 vf, "vf");
12248 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12249 	TOKEN_STRING_INITIALIZER
12250 		(struct cmd_vf_promisc_result,
12251 		 promisc, "promisc");
12252 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12253 	TOKEN_NUM_INITIALIZER
12254 		(struct cmd_vf_promisc_result,
12255 		 port_id, RTE_UINT16);
12256 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12257 	TOKEN_NUM_INITIALIZER
12258 		(struct cmd_vf_promisc_result,
12259 		 vf_id, RTE_UINT32);
12260 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12261 	TOKEN_STRING_INITIALIZER
12262 		(struct cmd_vf_promisc_result,
12263 		 on_off, "on#off");
12264 
12265 static void
12266 cmd_set_vf_promisc_parsed(
12267 	void *parsed_result,
12268 	__rte_unused struct cmdline *cl,
12269 	__rte_unused void *data)
12270 {
12271 	struct cmd_vf_promisc_result *res = parsed_result;
12272 	int ret = -ENOTSUP;
12273 
12274 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12275 
12276 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12277 		return;
12278 
12279 #ifdef RTE_NET_I40E
12280 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12281 						  res->vf_id, is_on);
12282 #endif
12283 
12284 	switch (ret) {
12285 	case 0:
12286 		break;
12287 	case -EINVAL:
12288 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12289 		break;
12290 	case -ENODEV:
12291 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12292 		break;
12293 	case -ENOTSUP:
12294 		fprintf(stderr, "function not implemented\n");
12295 		break;
12296 	default:
12297 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12298 	}
12299 }
12300 
12301 cmdline_parse_inst_t cmd_set_vf_promisc = {
12302 	.f = cmd_set_vf_promisc_parsed,
12303 	.data = NULL,
12304 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
12305 		"Set unicast promiscuous mode for a VF from the PF",
12306 	.tokens = {
12307 		(void *)&cmd_vf_promisc_set,
12308 		(void *)&cmd_vf_promisc_vf,
12309 		(void *)&cmd_vf_promisc_promisc,
12310 		(void *)&cmd_vf_promisc_port_id,
12311 		(void *)&cmd_vf_promisc_vf_id,
12312 		(void *)&cmd_vf_promisc_on_off,
12313 		NULL,
12314 	},
12315 };
12316 
12317 /* VF multicast promiscuous mode configuration */
12318 
12319 /* Common result structure for VF multicast promiscuous mode */
12320 struct cmd_vf_allmulti_result {
12321 	cmdline_fixed_string_t set;
12322 	cmdline_fixed_string_t vf;
12323 	cmdline_fixed_string_t allmulti;
12324 	portid_t port_id;
12325 	uint32_t vf_id;
12326 	cmdline_fixed_string_t on_off;
12327 };
12328 
12329 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12330 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12331 	TOKEN_STRING_INITIALIZER
12332 		(struct cmd_vf_allmulti_result,
12333 		 set, "set");
12334 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12335 	TOKEN_STRING_INITIALIZER
12336 		(struct cmd_vf_allmulti_result,
12337 		 vf, "vf");
12338 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12339 	TOKEN_STRING_INITIALIZER
12340 		(struct cmd_vf_allmulti_result,
12341 		 allmulti, "allmulti");
12342 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12343 	TOKEN_NUM_INITIALIZER
12344 		(struct cmd_vf_allmulti_result,
12345 		 port_id, RTE_UINT16);
12346 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12347 	TOKEN_NUM_INITIALIZER
12348 		(struct cmd_vf_allmulti_result,
12349 		 vf_id, RTE_UINT32);
12350 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12351 	TOKEN_STRING_INITIALIZER
12352 		(struct cmd_vf_allmulti_result,
12353 		 on_off, "on#off");
12354 
12355 static void
12356 cmd_set_vf_allmulti_parsed(
12357 	void *parsed_result,
12358 	__rte_unused struct cmdline *cl,
12359 	__rte_unused void *data)
12360 {
12361 	struct cmd_vf_allmulti_result *res = parsed_result;
12362 	int ret = -ENOTSUP;
12363 
12364 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12365 
12366 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12367 		return;
12368 
12369 #ifdef RTE_NET_I40E
12370 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12371 						    res->vf_id, is_on);
12372 #endif
12373 
12374 	switch (ret) {
12375 	case 0:
12376 		break;
12377 	case -EINVAL:
12378 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12379 		break;
12380 	case -ENODEV:
12381 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12382 		break;
12383 	case -ENOTSUP:
12384 		fprintf(stderr, "function not implemented\n");
12385 		break;
12386 	default:
12387 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12388 	}
12389 }
12390 
12391 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12392 	.f = cmd_set_vf_allmulti_parsed,
12393 	.data = NULL,
12394 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12395 		"Set multicast promiscuous mode for a VF from the PF",
12396 	.tokens = {
12397 		(void *)&cmd_vf_allmulti_set,
12398 		(void *)&cmd_vf_allmulti_vf,
12399 		(void *)&cmd_vf_allmulti_allmulti,
12400 		(void *)&cmd_vf_allmulti_port_id,
12401 		(void *)&cmd_vf_allmulti_vf_id,
12402 		(void *)&cmd_vf_allmulti_on_off,
12403 		NULL,
12404 	},
12405 };
12406 
12407 /* vf broadcast mode configuration */
12408 
12409 /* Common result structure for vf broadcast */
12410 struct cmd_set_vf_broadcast_result {
12411 	cmdline_fixed_string_t set;
12412 	cmdline_fixed_string_t vf;
12413 	cmdline_fixed_string_t broadcast;
12414 	portid_t port_id;
12415 	uint16_t vf_id;
12416 	cmdline_fixed_string_t on_off;
12417 };
12418 
12419 /* Common CLI fields for vf broadcast enable disable */
12420 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12421 	TOKEN_STRING_INITIALIZER
12422 		(struct cmd_set_vf_broadcast_result,
12423 		 set, "set");
12424 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12425 	TOKEN_STRING_INITIALIZER
12426 		(struct cmd_set_vf_broadcast_result,
12427 		 vf, "vf");
12428 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12429 	TOKEN_STRING_INITIALIZER
12430 		(struct cmd_set_vf_broadcast_result,
12431 		 broadcast, "broadcast");
12432 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12433 	TOKEN_NUM_INITIALIZER
12434 		(struct cmd_set_vf_broadcast_result,
12435 		 port_id, RTE_UINT16);
12436 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12437 	TOKEN_NUM_INITIALIZER
12438 		(struct cmd_set_vf_broadcast_result,
12439 		 vf_id, RTE_UINT16);
12440 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12441 	TOKEN_STRING_INITIALIZER
12442 		(struct cmd_set_vf_broadcast_result,
12443 		 on_off, "on#off");
12444 
12445 static void
12446 cmd_set_vf_broadcast_parsed(
12447 	void *parsed_result,
12448 	__rte_unused struct cmdline *cl,
12449 	__rte_unused void *data)
12450 {
12451 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12452 	int ret = -ENOTSUP;
12453 
12454 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12455 
12456 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12457 		return;
12458 
12459 #ifdef RTE_NET_I40E
12460 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12461 					    res->vf_id, is_on);
12462 #endif
12463 
12464 	switch (ret) {
12465 	case 0:
12466 		break;
12467 	case -EINVAL:
12468 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12469 			res->vf_id, is_on);
12470 		break;
12471 	case -ENODEV:
12472 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12473 		break;
12474 	case -ENOTSUP:
12475 		fprintf(stderr, "function not implemented\n");
12476 		break;
12477 	default:
12478 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12479 	}
12480 }
12481 
12482 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12483 	.f = cmd_set_vf_broadcast_parsed,
12484 	.data = NULL,
12485 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12486 	.tokens = {
12487 		(void *)&cmd_set_vf_broadcast_set,
12488 		(void *)&cmd_set_vf_broadcast_vf,
12489 		(void *)&cmd_set_vf_broadcast_broadcast,
12490 		(void *)&cmd_set_vf_broadcast_port_id,
12491 		(void *)&cmd_set_vf_broadcast_vf_id,
12492 		(void *)&cmd_set_vf_broadcast_on_off,
12493 		NULL,
12494 	},
12495 };
12496 
12497 /* vf vlan tag configuration */
12498 
12499 /* Common result structure for vf vlan tag */
12500 struct cmd_set_vf_vlan_tag_result {
12501 	cmdline_fixed_string_t set;
12502 	cmdline_fixed_string_t vf;
12503 	cmdline_fixed_string_t vlan;
12504 	cmdline_fixed_string_t tag;
12505 	portid_t port_id;
12506 	uint16_t vf_id;
12507 	cmdline_fixed_string_t on_off;
12508 };
12509 
12510 /* Common CLI fields for vf vlan tag enable disable */
12511 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12512 	TOKEN_STRING_INITIALIZER
12513 		(struct cmd_set_vf_vlan_tag_result,
12514 		 set, "set");
12515 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12516 	TOKEN_STRING_INITIALIZER
12517 		(struct cmd_set_vf_vlan_tag_result,
12518 		 vf, "vf");
12519 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12520 	TOKEN_STRING_INITIALIZER
12521 		(struct cmd_set_vf_vlan_tag_result,
12522 		 vlan, "vlan");
12523 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12524 	TOKEN_STRING_INITIALIZER
12525 		(struct cmd_set_vf_vlan_tag_result,
12526 		 tag, "tag");
12527 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12528 	TOKEN_NUM_INITIALIZER
12529 		(struct cmd_set_vf_vlan_tag_result,
12530 		 port_id, RTE_UINT16);
12531 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12532 	TOKEN_NUM_INITIALIZER
12533 		(struct cmd_set_vf_vlan_tag_result,
12534 		 vf_id, RTE_UINT16);
12535 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12536 	TOKEN_STRING_INITIALIZER
12537 		(struct cmd_set_vf_vlan_tag_result,
12538 		 on_off, "on#off");
12539 
12540 static void
12541 cmd_set_vf_vlan_tag_parsed(
12542 	void *parsed_result,
12543 	__rte_unused struct cmdline *cl,
12544 	__rte_unused void *data)
12545 {
12546 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12547 	int ret = -ENOTSUP;
12548 
12549 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12550 
12551 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12552 		return;
12553 
12554 #ifdef RTE_NET_I40E
12555 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12556 					   res->vf_id, is_on);
12557 #endif
12558 
12559 	switch (ret) {
12560 	case 0:
12561 		break;
12562 	case -EINVAL:
12563 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12564 			res->vf_id, is_on);
12565 		break;
12566 	case -ENODEV:
12567 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12568 		break;
12569 	case -ENOTSUP:
12570 		fprintf(stderr, "function not implemented\n");
12571 		break;
12572 	default:
12573 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12574 	}
12575 }
12576 
12577 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12578 	.f = cmd_set_vf_vlan_tag_parsed,
12579 	.data = NULL,
12580 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12581 	.tokens = {
12582 		(void *)&cmd_set_vf_vlan_tag_set,
12583 		(void *)&cmd_set_vf_vlan_tag_vf,
12584 		(void *)&cmd_set_vf_vlan_tag_vlan,
12585 		(void *)&cmd_set_vf_vlan_tag_tag,
12586 		(void *)&cmd_set_vf_vlan_tag_port_id,
12587 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12588 		(void *)&cmd_set_vf_vlan_tag_on_off,
12589 		NULL,
12590 	},
12591 };
12592 
12593 /* Common definition of VF and TC TX bandwidth configuration */
12594 struct cmd_vf_tc_bw_result {
12595 	cmdline_fixed_string_t set;
12596 	cmdline_fixed_string_t vf;
12597 	cmdline_fixed_string_t tc;
12598 	cmdline_fixed_string_t tx;
12599 	cmdline_fixed_string_t min_bw;
12600 	cmdline_fixed_string_t max_bw;
12601 	cmdline_fixed_string_t strict_link_prio;
12602 	portid_t port_id;
12603 	uint16_t vf_id;
12604 	uint8_t tc_no;
12605 	uint32_t bw;
12606 	cmdline_fixed_string_t bw_list;
12607 	uint8_t tc_map;
12608 };
12609 
12610 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12611 	TOKEN_STRING_INITIALIZER
12612 		(struct cmd_vf_tc_bw_result,
12613 		 set, "set");
12614 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12615 	TOKEN_STRING_INITIALIZER
12616 		(struct cmd_vf_tc_bw_result,
12617 		 vf, "vf");
12618 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12619 	TOKEN_STRING_INITIALIZER
12620 		(struct cmd_vf_tc_bw_result,
12621 		 tc, "tc");
12622 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12623 	TOKEN_STRING_INITIALIZER
12624 		(struct cmd_vf_tc_bw_result,
12625 		 tx, "tx");
12626 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12627 	TOKEN_STRING_INITIALIZER
12628 		(struct cmd_vf_tc_bw_result,
12629 		 strict_link_prio, "strict-link-priority");
12630 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12631 	TOKEN_STRING_INITIALIZER
12632 		(struct cmd_vf_tc_bw_result,
12633 		 min_bw, "min-bandwidth");
12634 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12635 	TOKEN_STRING_INITIALIZER
12636 		(struct cmd_vf_tc_bw_result,
12637 		 max_bw, "max-bandwidth");
12638 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12639 	TOKEN_NUM_INITIALIZER
12640 		(struct cmd_vf_tc_bw_result,
12641 		 port_id, RTE_UINT16);
12642 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12643 	TOKEN_NUM_INITIALIZER
12644 		(struct cmd_vf_tc_bw_result,
12645 		 vf_id, RTE_UINT16);
12646 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12647 	TOKEN_NUM_INITIALIZER
12648 		(struct cmd_vf_tc_bw_result,
12649 		 tc_no, RTE_UINT8);
12650 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12651 	TOKEN_NUM_INITIALIZER
12652 		(struct cmd_vf_tc_bw_result,
12653 		 bw, RTE_UINT32);
12654 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12655 	TOKEN_STRING_INITIALIZER
12656 		(struct cmd_vf_tc_bw_result,
12657 		 bw_list, NULL);
12658 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12659 	TOKEN_NUM_INITIALIZER
12660 		(struct cmd_vf_tc_bw_result,
12661 		 tc_map, RTE_UINT8);
12662 
12663 /* VF max bandwidth setting */
12664 static void
12665 cmd_vf_max_bw_parsed(
12666 	void *parsed_result,
12667 	__rte_unused struct cmdline *cl,
12668 	__rte_unused void *data)
12669 {
12670 	struct cmd_vf_tc_bw_result *res = parsed_result;
12671 	int ret = -ENOTSUP;
12672 
12673 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12674 		return;
12675 
12676 #ifdef RTE_NET_I40E
12677 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12678 					 res->vf_id, res->bw);
12679 #endif
12680 
12681 	switch (ret) {
12682 	case 0:
12683 		break;
12684 	case -EINVAL:
12685 		fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12686 			res->vf_id, res->bw);
12687 		break;
12688 	case -ENODEV:
12689 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12690 		break;
12691 	case -ENOTSUP:
12692 		fprintf(stderr, "function not implemented\n");
12693 		break;
12694 	default:
12695 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12696 	}
12697 }
12698 
12699 cmdline_parse_inst_t cmd_vf_max_bw = {
12700 	.f = cmd_vf_max_bw_parsed,
12701 	.data = NULL,
12702 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12703 	.tokens = {
12704 		(void *)&cmd_vf_tc_bw_set,
12705 		(void *)&cmd_vf_tc_bw_vf,
12706 		(void *)&cmd_vf_tc_bw_tx,
12707 		(void *)&cmd_vf_tc_bw_max_bw,
12708 		(void *)&cmd_vf_tc_bw_port_id,
12709 		(void *)&cmd_vf_tc_bw_vf_id,
12710 		(void *)&cmd_vf_tc_bw_bw,
12711 		NULL,
12712 	},
12713 };
12714 
12715 static int
12716 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12717 			   uint8_t *tc_num,
12718 			   char *str)
12719 {
12720 	uint32_t size;
12721 	const char *p, *p0 = str;
12722 	char s[256];
12723 	char *end;
12724 	char *str_fld[16];
12725 	uint16_t i;
12726 	int ret;
12727 
12728 	p = strchr(p0, '(');
12729 	if (p == NULL) {
12730 		fprintf(stderr,
12731 			"The bandwidth-list should be '(bw1, bw2, ...)'\n");
12732 		return -1;
12733 	}
12734 	p++;
12735 	p0 = strchr(p, ')');
12736 	if (p0 == NULL) {
12737 		fprintf(stderr,
12738 			"The bandwidth-list should be '(bw1, bw2, ...)'\n");
12739 		return -1;
12740 	}
12741 	size = p0 - p;
12742 	if (size >= sizeof(s)) {
12743 		fprintf(stderr,
12744 			"The string size exceeds the internal buffer size\n");
12745 		return -1;
12746 	}
12747 	snprintf(s, sizeof(s), "%.*s", size, p);
12748 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12749 	if (ret <= 0) {
12750 		fprintf(stderr, "Failed to get the bandwidth list.\n");
12751 		return -1;
12752 	}
12753 	*tc_num = ret;
12754 	for (i = 0; i < ret; i++)
12755 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12756 
12757 	return 0;
12758 }
12759 
12760 /* TC min bandwidth setting */
12761 static void
12762 cmd_vf_tc_min_bw_parsed(
12763 	void *parsed_result,
12764 	__rte_unused struct cmdline *cl,
12765 	__rte_unused void *data)
12766 {
12767 	struct cmd_vf_tc_bw_result *res = parsed_result;
12768 	uint8_t tc_num;
12769 	uint8_t bw[16];
12770 	int ret = -ENOTSUP;
12771 
12772 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12773 		return;
12774 
12775 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12776 	if (ret)
12777 		return;
12778 
12779 #ifdef RTE_NET_I40E
12780 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12781 					      tc_num, bw);
12782 #endif
12783 
12784 	switch (ret) {
12785 	case 0:
12786 		break;
12787 	case -EINVAL:
12788 		fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12789 		break;
12790 	case -ENODEV:
12791 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12792 		break;
12793 	case -ENOTSUP:
12794 		fprintf(stderr, "function not implemented\n");
12795 		break;
12796 	default:
12797 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12798 	}
12799 }
12800 
12801 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12802 	.f = cmd_vf_tc_min_bw_parsed,
12803 	.data = NULL,
12804 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12805 		    " <bw1, bw2, ...>",
12806 	.tokens = {
12807 		(void *)&cmd_vf_tc_bw_set,
12808 		(void *)&cmd_vf_tc_bw_vf,
12809 		(void *)&cmd_vf_tc_bw_tc,
12810 		(void *)&cmd_vf_tc_bw_tx,
12811 		(void *)&cmd_vf_tc_bw_min_bw,
12812 		(void *)&cmd_vf_tc_bw_port_id,
12813 		(void *)&cmd_vf_tc_bw_vf_id,
12814 		(void *)&cmd_vf_tc_bw_bw_list,
12815 		NULL,
12816 	},
12817 };
12818 
12819 static void
12820 cmd_tc_min_bw_parsed(
12821 	void *parsed_result,
12822 	__rte_unused struct cmdline *cl,
12823 	__rte_unused void *data)
12824 {
12825 	struct cmd_vf_tc_bw_result *res = parsed_result;
12826 	struct rte_port *port;
12827 	uint8_t tc_num;
12828 	uint8_t bw[16];
12829 	int ret = -ENOTSUP;
12830 
12831 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12832 		return;
12833 
12834 	port = &ports[res->port_id];
12835 	/** Check if the port is not started **/
12836 	if (port->port_status != RTE_PORT_STOPPED) {
12837 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
12838 		return;
12839 	}
12840 
12841 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12842 	if (ret)
12843 		return;
12844 
12845 #ifdef RTE_NET_IXGBE
12846 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12847 #endif
12848 
12849 	switch (ret) {
12850 	case 0:
12851 		break;
12852 	case -EINVAL:
12853 		fprintf(stderr, "invalid bandwidth\n");
12854 		break;
12855 	case -ENODEV:
12856 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12857 		break;
12858 	case -ENOTSUP:
12859 		fprintf(stderr, "function not implemented\n");
12860 		break;
12861 	default:
12862 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12863 	}
12864 }
12865 
12866 cmdline_parse_inst_t cmd_tc_min_bw = {
12867 	.f = cmd_tc_min_bw_parsed,
12868 	.data = NULL,
12869 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12870 	.tokens = {
12871 		(void *)&cmd_vf_tc_bw_set,
12872 		(void *)&cmd_vf_tc_bw_tc,
12873 		(void *)&cmd_vf_tc_bw_tx,
12874 		(void *)&cmd_vf_tc_bw_min_bw,
12875 		(void *)&cmd_vf_tc_bw_port_id,
12876 		(void *)&cmd_vf_tc_bw_bw_list,
12877 		NULL,
12878 	},
12879 };
12880 
12881 /* TC max bandwidth setting */
12882 static void
12883 cmd_vf_tc_max_bw_parsed(
12884 	void *parsed_result,
12885 	__rte_unused struct cmdline *cl,
12886 	__rte_unused void *data)
12887 {
12888 	struct cmd_vf_tc_bw_result *res = parsed_result;
12889 	int ret = -ENOTSUP;
12890 
12891 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12892 		return;
12893 
12894 #ifdef RTE_NET_I40E
12895 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12896 					    res->tc_no, res->bw);
12897 #endif
12898 
12899 	switch (ret) {
12900 	case 0:
12901 		break;
12902 	case -EINVAL:
12903 		fprintf(stderr,
12904 			"invalid vf_id %d, tc_no %d or bandwidth %d\n",
12905 			res->vf_id, res->tc_no, res->bw);
12906 		break;
12907 	case -ENODEV:
12908 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12909 		break;
12910 	case -ENOTSUP:
12911 		fprintf(stderr, "function not implemented\n");
12912 		break;
12913 	default:
12914 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12915 	}
12916 }
12917 
12918 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12919 	.f = cmd_vf_tc_max_bw_parsed,
12920 	.data = NULL,
12921 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12922 		    " <bandwidth>",
12923 	.tokens = {
12924 		(void *)&cmd_vf_tc_bw_set,
12925 		(void *)&cmd_vf_tc_bw_vf,
12926 		(void *)&cmd_vf_tc_bw_tc,
12927 		(void *)&cmd_vf_tc_bw_tx,
12928 		(void *)&cmd_vf_tc_bw_max_bw,
12929 		(void *)&cmd_vf_tc_bw_port_id,
12930 		(void *)&cmd_vf_tc_bw_vf_id,
12931 		(void *)&cmd_vf_tc_bw_tc_no,
12932 		(void *)&cmd_vf_tc_bw_bw,
12933 		NULL,
12934 	},
12935 };
12936 
12937 /** Set VXLAN encapsulation details */
12938 struct cmd_set_vxlan_result {
12939 	cmdline_fixed_string_t set;
12940 	cmdline_fixed_string_t vxlan;
12941 	cmdline_fixed_string_t pos_token;
12942 	cmdline_fixed_string_t ip_version;
12943 	uint32_t vlan_present:1;
12944 	uint32_t vni;
12945 	uint16_t udp_src;
12946 	uint16_t udp_dst;
12947 	cmdline_ipaddr_t ip_src;
12948 	cmdline_ipaddr_t ip_dst;
12949 	uint16_t tci;
12950 	uint8_t tos;
12951 	uint8_t ttl;
12952 	struct rte_ether_addr eth_src;
12953 	struct rte_ether_addr eth_dst;
12954 };
12955 
12956 cmdline_parse_token_string_t cmd_set_vxlan_set =
12957 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12958 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12959 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12960 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12961 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12962 				 "vxlan-tos-ttl");
12963 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12964 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12965 				 "vxlan-with-vlan");
12966 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12967 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12968 				 "ip-version");
12969 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12970 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12971 				 "ipv4#ipv6");
12972 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12973 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12974 				 "vni");
12975 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12976 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12977 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12978 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12979 				 "udp-src");
12980 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12981 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12982 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12983 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12984 				 "udp-dst");
12985 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12986 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12987 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12988 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12989 				 "ip-tos");
12990 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12991 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12992 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12993 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12994 				 "ip-ttl");
12995 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12996 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12997 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12998 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12999 				 "ip-src");
13000 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13001 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13002 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13003 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13004 				 "ip-dst");
13005 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13006 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13007 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13008 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13009 				 "vlan-tci");
13010 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13011 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13012 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13013 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13014 				 "eth-src");
13015 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13016 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13017 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13018 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13019 				 "eth-dst");
13020 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13021 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13022 
13023 static void cmd_set_vxlan_parsed(void *parsed_result,
13024 	__rte_unused struct cmdline *cl,
13025 	__rte_unused void *data)
13026 {
13027 	struct cmd_set_vxlan_result *res = parsed_result;
13028 	union {
13029 		uint32_t vxlan_id;
13030 		uint8_t vni[4];
13031 	} id = {
13032 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13033 	};
13034 
13035 	vxlan_encap_conf.select_tos_ttl = 0;
13036 	if (strcmp(res->vxlan, "vxlan") == 0)
13037 		vxlan_encap_conf.select_vlan = 0;
13038 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13039 		vxlan_encap_conf.select_vlan = 1;
13040 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13041 		vxlan_encap_conf.select_vlan = 0;
13042 		vxlan_encap_conf.select_tos_ttl = 1;
13043 	}
13044 	if (strcmp(res->ip_version, "ipv4") == 0)
13045 		vxlan_encap_conf.select_ipv4 = 1;
13046 	else if (strcmp(res->ip_version, "ipv6") == 0)
13047 		vxlan_encap_conf.select_ipv4 = 0;
13048 	else
13049 		return;
13050 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13051 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13052 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13053 	vxlan_encap_conf.ip_tos = res->tos;
13054 	vxlan_encap_conf.ip_ttl = res->ttl;
13055 	if (vxlan_encap_conf.select_ipv4) {
13056 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13057 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13058 	} else {
13059 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13060 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13061 	}
13062 	if (vxlan_encap_conf.select_vlan)
13063 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13064 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13065 		   RTE_ETHER_ADDR_LEN);
13066 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13067 		   RTE_ETHER_ADDR_LEN);
13068 }
13069 
13070 cmdline_parse_inst_t cmd_set_vxlan = {
13071 	.f = cmd_set_vxlan_parsed,
13072 	.data = NULL,
13073 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13074 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13075 		" eth-src <eth-src> eth-dst <eth-dst>",
13076 	.tokens = {
13077 		(void *)&cmd_set_vxlan_set,
13078 		(void *)&cmd_set_vxlan_vxlan,
13079 		(void *)&cmd_set_vxlan_ip_version,
13080 		(void *)&cmd_set_vxlan_ip_version_value,
13081 		(void *)&cmd_set_vxlan_vni,
13082 		(void *)&cmd_set_vxlan_vni_value,
13083 		(void *)&cmd_set_vxlan_udp_src,
13084 		(void *)&cmd_set_vxlan_udp_src_value,
13085 		(void *)&cmd_set_vxlan_udp_dst,
13086 		(void *)&cmd_set_vxlan_udp_dst_value,
13087 		(void *)&cmd_set_vxlan_ip_src,
13088 		(void *)&cmd_set_vxlan_ip_src_value,
13089 		(void *)&cmd_set_vxlan_ip_dst,
13090 		(void *)&cmd_set_vxlan_ip_dst_value,
13091 		(void *)&cmd_set_vxlan_eth_src,
13092 		(void *)&cmd_set_vxlan_eth_src_value,
13093 		(void *)&cmd_set_vxlan_eth_dst,
13094 		(void *)&cmd_set_vxlan_eth_dst_value,
13095 		NULL,
13096 	},
13097 };
13098 
13099 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13100 	.f = cmd_set_vxlan_parsed,
13101 	.data = NULL,
13102 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13103 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13104 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13105 		" eth-dst <eth-dst>",
13106 	.tokens = {
13107 		(void *)&cmd_set_vxlan_set,
13108 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
13109 		(void *)&cmd_set_vxlan_ip_version,
13110 		(void *)&cmd_set_vxlan_ip_version_value,
13111 		(void *)&cmd_set_vxlan_vni,
13112 		(void *)&cmd_set_vxlan_vni_value,
13113 		(void *)&cmd_set_vxlan_udp_src,
13114 		(void *)&cmd_set_vxlan_udp_src_value,
13115 		(void *)&cmd_set_vxlan_udp_dst,
13116 		(void *)&cmd_set_vxlan_udp_dst_value,
13117 		(void *)&cmd_set_vxlan_ip_tos,
13118 		(void *)&cmd_set_vxlan_ip_tos_value,
13119 		(void *)&cmd_set_vxlan_ip_ttl,
13120 		(void *)&cmd_set_vxlan_ip_ttl_value,
13121 		(void *)&cmd_set_vxlan_ip_src,
13122 		(void *)&cmd_set_vxlan_ip_src_value,
13123 		(void *)&cmd_set_vxlan_ip_dst,
13124 		(void *)&cmd_set_vxlan_ip_dst_value,
13125 		(void *)&cmd_set_vxlan_eth_src,
13126 		(void *)&cmd_set_vxlan_eth_src_value,
13127 		(void *)&cmd_set_vxlan_eth_dst,
13128 		(void *)&cmd_set_vxlan_eth_dst_value,
13129 		NULL,
13130 	},
13131 };
13132 
13133 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13134 	.f = cmd_set_vxlan_parsed,
13135 	.data = NULL,
13136 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13137 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13138 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13139 		" <eth-dst>",
13140 	.tokens = {
13141 		(void *)&cmd_set_vxlan_set,
13142 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
13143 		(void *)&cmd_set_vxlan_ip_version,
13144 		(void *)&cmd_set_vxlan_ip_version_value,
13145 		(void *)&cmd_set_vxlan_vni,
13146 		(void *)&cmd_set_vxlan_vni_value,
13147 		(void *)&cmd_set_vxlan_udp_src,
13148 		(void *)&cmd_set_vxlan_udp_src_value,
13149 		(void *)&cmd_set_vxlan_udp_dst,
13150 		(void *)&cmd_set_vxlan_udp_dst_value,
13151 		(void *)&cmd_set_vxlan_ip_src,
13152 		(void *)&cmd_set_vxlan_ip_src_value,
13153 		(void *)&cmd_set_vxlan_ip_dst,
13154 		(void *)&cmd_set_vxlan_ip_dst_value,
13155 		(void *)&cmd_set_vxlan_vlan,
13156 		(void *)&cmd_set_vxlan_vlan_value,
13157 		(void *)&cmd_set_vxlan_eth_src,
13158 		(void *)&cmd_set_vxlan_eth_src_value,
13159 		(void *)&cmd_set_vxlan_eth_dst,
13160 		(void *)&cmd_set_vxlan_eth_dst_value,
13161 		NULL,
13162 	},
13163 };
13164 
13165 /** Set NVGRE encapsulation details */
13166 struct cmd_set_nvgre_result {
13167 	cmdline_fixed_string_t set;
13168 	cmdline_fixed_string_t nvgre;
13169 	cmdline_fixed_string_t pos_token;
13170 	cmdline_fixed_string_t ip_version;
13171 	uint32_t tni;
13172 	cmdline_ipaddr_t ip_src;
13173 	cmdline_ipaddr_t ip_dst;
13174 	uint16_t tci;
13175 	struct rte_ether_addr eth_src;
13176 	struct rte_ether_addr eth_dst;
13177 };
13178 
13179 cmdline_parse_token_string_t cmd_set_nvgre_set =
13180 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13181 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13182 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13183 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13184 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13185 				 "nvgre-with-vlan");
13186 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13187 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13188 				 "ip-version");
13189 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13190 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13191 				 "ipv4#ipv6");
13192 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13193 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13194 				 "tni");
13195 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13196 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13197 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13198 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13199 				 "ip-src");
13200 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13201 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13202 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13203 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13204 				 "ip-dst");
13205 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13206 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13207 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13208 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13209 				 "vlan-tci");
13210 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13211 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13212 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13213 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13214 				 "eth-src");
13215 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13216 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13217 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13218 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13219 				 "eth-dst");
13220 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13221 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13222 
13223 static void cmd_set_nvgre_parsed(void *parsed_result,
13224 	__rte_unused struct cmdline *cl,
13225 	__rte_unused void *data)
13226 {
13227 	struct cmd_set_nvgre_result *res = parsed_result;
13228 	union {
13229 		uint32_t nvgre_tni;
13230 		uint8_t tni[4];
13231 	} id = {
13232 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13233 	};
13234 
13235 	if (strcmp(res->nvgre, "nvgre") == 0)
13236 		nvgre_encap_conf.select_vlan = 0;
13237 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13238 		nvgre_encap_conf.select_vlan = 1;
13239 	if (strcmp(res->ip_version, "ipv4") == 0)
13240 		nvgre_encap_conf.select_ipv4 = 1;
13241 	else if (strcmp(res->ip_version, "ipv6") == 0)
13242 		nvgre_encap_conf.select_ipv4 = 0;
13243 	else
13244 		return;
13245 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13246 	if (nvgre_encap_conf.select_ipv4) {
13247 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13248 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13249 	} else {
13250 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13251 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13252 	}
13253 	if (nvgre_encap_conf.select_vlan)
13254 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13255 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13256 		   RTE_ETHER_ADDR_LEN);
13257 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13258 		   RTE_ETHER_ADDR_LEN);
13259 }
13260 
13261 cmdline_parse_inst_t cmd_set_nvgre = {
13262 	.f = cmd_set_nvgre_parsed,
13263 	.data = NULL,
13264 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13265 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13266 		" eth-dst <eth-dst>",
13267 	.tokens = {
13268 		(void *)&cmd_set_nvgre_set,
13269 		(void *)&cmd_set_nvgre_nvgre,
13270 		(void *)&cmd_set_nvgre_ip_version,
13271 		(void *)&cmd_set_nvgre_ip_version_value,
13272 		(void *)&cmd_set_nvgre_tni,
13273 		(void *)&cmd_set_nvgre_tni_value,
13274 		(void *)&cmd_set_nvgre_ip_src,
13275 		(void *)&cmd_set_nvgre_ip_src_value,
13276 		(void *)&cmd_set_nvgre_ip_dst,
13277 		(void *)&cmd_set_nvgre_ip_dst_value,
13278 		(void *)&cmd_set_nvgre_eth_src,
13279 		(void *)&cmd_set_nvgre_eth_src_value,
13280 		(void *)&cmd_set_nvgre_eth_dst,
13281 		(void *)&cmd_set_nvgre_eth_dst_value,
13282 		NULL,
13283 	},
13284 };
13285 
13286 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13287 	.f = cmd_set_nvgre_parsed,
13288 	.data = NULL,
13289 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13290 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13291 		" eth-src <eth-src> eth-dst <eth-dst>",
13292 	.tokens = {
13293 		(void *)&cmd_set_nvgre_set,
13294 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
13295 		(void *)&cmd_set_nvgre_ip_version,
13296 		(void *)&cmd_set_nvgre_ip_version_value,
13297 		(void *)&cmd_set_nvgre_tni,
13298 		(void *)&cmd_set_nvgre_tni_value,
13299 		(void *)&cmd_set_nvgre_ip_src,
13300 		(void *)&cmd_set_nvgre_ip_src_value,
13301 		(void *)&cmd_set_nvgre_ip_dst,
13302 		(void *)&cmd_set_nvgre_ip_dst_value,
13303 		(void *)&cmd_set_nvgre_vlan,
13304 		(void *)&cmd_set_nvgre_vlan_value,
13305 		(void *)&cmd_set_nvgre_eth_src,
13306 		(void *)&cmd_set_nvgre_eth_src_value,
13307 		(void *)&cmd_set_nvgre_eth_dst,
13308 		(void *)&cmd_set_nvgre_eth_dst_value,
13309 		NULL,
13310 	},
13311 };
13312 
13313 /** Set L2 encapsulation details */
13314 struct cmd_set_l2_encap_result {
13315 	cmdline_fixed_string_t set;
13316 	cmdline_fixed_string_t l2_encap;
13317 	cmdline_fixed_string_t pos_token;
13318 	cmdline_fixed_string_t ip_version;
13319 	uint32_t vlan_present:1;
13320 	uint16_t tci;
13321 	struct rte_ether_addr eth_src;
13322 	struct rte_ether_addr eth_dst;
13323 };
13324 
13325 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13326 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13327 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13328 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13329 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13330 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13331 				 "l2_encap-with-vlan");
13332 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13333 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13334 				 "ip-version");
13335 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13336 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13337 				 "ipv4#ipv6");
13338 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13339 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13340 				 "vlan-tci");
13341 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13342 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13343 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13344 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13345 				 "eth-src");
13346 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13347 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13348 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13349 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13350 				 "eth-dst");
13351 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13352 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13353 
13354 static void cmd_set_l2_encap_parsed(void *parsed_result,
13355 	__rte_unused struct cmdline *cl,
13356 	__rte_unused void *data)
13357 {
13358 	struct cmd_set_l2_encap_result *res = parsed_result;
13359 
13360 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13361 		l2_encap_conf.select_vlan = 0;
13362 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13363 		l2_encap_conf.select_vlan = 1;
13364 	if (strcmp(res->ip_version, "ipv4") == 0)
13365 		l2_encap_conf.select_ipv4 = 1;
13366 	else if (strcmp(res->ip_version, "ipv6") == 0)
13367 		l2_encap_conf.select_ipv4 = 0;
13368 	else
13369 		return;
13370 	if (l2_encap_conf.select_vlan)
13371 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13372 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13373 		   RTE_ETHER_ADDR_LEN);
13374 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13375 		   RTE_ETHER_ADDR_LEN);
13376 }
13377 
13378 cmdline_parse_inst_t cmd_set_l2_encap = {
13379 	.f = cmd_set_l2_encap_parsed,
13380 	.data = NULL,
13381 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13382 		" eth-src <eth-src> eth-dst <eth-dst>",
13383 	.tokens = {
13384 		(void *)&cmd_set_l2_encap_set,
13385 		(void *)&cmd_set_l2_encap_l2_encap,
13386 		(void *)&cmd_set_l2_encap_ip_version,
13387 		(void *)&cmd_set_l2_encap_ip_version_value,
13388 		(void *)&cmd_set_l2_encap_eth_src,
13389 		(void *)&cmd_set_l2_encap_eth_src_value,
13390 		(void *)&cmd_set_l2_encap_eth_dst,
13391 		(void *)&cmd_set_l2_encap_eth_dst_value,
13392 		NULL,
13393 	},
13394 };
13395 
13396 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13397 	.f = cmd_set_l2_encap_parsed,
13398 	.data = NULL,
13399 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13400 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13401 	.tokens = {
13402 		(void *)&cmd_set_l2_encap_set,
13403 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13404 		(void *)&cmd_set_l2_encap_ip_version,
13405 		(void *)&cmd_set_l2_encap_ip_version_value,
13406 		(void *)&cmd_set_l2_encap_vlan,
13407 		(void *)&cmd_set_l2_encap_vlan_value,
13408 		(void *)&cmd_set_l2_encap_eth_src,
13409 		(void *)&cmd_set_l2_encap_eth_src_value,
13410 		(void *)&cmd_set_l2_encap_eth_dst,
13411 		(void *)&cmd_set_l2_encap_eth_dst_value,
13412 		NULL,
13413 	},
13414 };
13415 
13416 /** Set L2 decapsulation details */
13417 struct cmd_set_l2_decap_result {
13418 	cmdline_fixed_string_t set;
13419 	cmdline_fixed_string_t l2_decap;
13420 	cmdline_fixed_string_t pos_token;
13421 	uint32_t vlan_present:1;
13422 };
13423 
13424 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13425 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13426 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13427 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13428 				 "l2_decap");
13429 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13430 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13431 				 "l2_decap-with-vlan");
13432 
13433 static void cmd_set_l2_decap_parsed(void *parsed_result,
13434 	__rte_unused struct cmdline *cl,
13435 	__rte_unused void *data)
13436 {
13437 	struct cmd_set_l2_decap_result *res = parsed_result;
13438 
13439 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13440 		l2_decap_conf.select_vlan = 0;
13441 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13442 		l2_decap_conf.select_vlan = 1;
13443 }
13444 
13445 cmdline_parse_inst_t cmd_set_l2_decap = {
13446 	.f = cmd_set_l2_decap_parsed,
13447 	.data = NULL,
13448 	.help_str = "set l2_decap",
13449 	.tokens = {
13450 		(void *)&cmd_set_l2_decap_set,
13451 		(void *)&cmd_set_l2_decap_l2_decap,
13452 		NULL,
13453 	},
13454 };
13455 
13456 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13457 	.f = cmd_set_l2_decap_parsed,
13458 	.data = NULL,
13459 	.help_str = "set l2_decap-with-vlan",
13460 	.tokens = {
13461 		(void *)&cmd_set_l2_decap_set,
13462 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13463 		NULL,
13464 	},
13465 };
13466 
13467 /** Set MPLSoGRE encapsulation details */
13468 struct cmd_set_mplsogre_encap_result {
13469 	cmdline_fixed_string_t set;
13470 	cmdline_fixed_string_t mplsogre;
13471 	cmdline_fixed_string_t pos_token;
13472 	cmdline_fixed_string_t ip_version;
13473 	uint32_t vlan_present:1;
13474 	uint32_t label;
13475 	cmdline_ipaddr_t ip_src;
13476 	cmdline_ipaddr_t ip_dst;
13477 	uint16_t tci;
13478 	struct rte_ether_addr eth_src;
13479 	struct rte_ether_addr eth_dst;
13480 };
13481 
13482 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13483 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13484 				 "set");
13485 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13486 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13487 				 "mplsogre_encap");
13488 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13489 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13490 				 mplsogre, "mplsogre_encap-with-vlan");
13491 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13492 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13493 				 pos_token, "ip-version");
13494 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13495 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13496 				 ip_version, "ipv4#ipv6");
13497 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13498 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13499 				 pos_token, "label");
13500 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13501 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13502 			      RTE_UINT32);
13503 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13504 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13505 				 pos_token, "ip-src");
13506 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13507 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13508 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13509 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13510 				 pos_token, "ip-dst");
13511 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13512 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13513 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13514 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13515 				 pos_token, "vlan-tci");
13516 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13517 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13518 			      RTE_UINT16);
13519 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13520 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13521 				 pos_token, "eth-src");
13522 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13523 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13524 				    eth_src);
13525 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13526 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13527 				 pos_token, "eth-dst");
13528 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13529 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13530 				    eth_dst);
13531 
13532 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13533 	__rte_unused struct cmdline *cl,
13534 	__rte_unused void *data)
13535 {
13536 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13537 	union {
13538 		uint32_t mplsogre_label;
13539 		uint8_t label[4];
13540 	} id = {
13541 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13542 	};
13543 
13544 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13545 		mplsogre_encap_conf.select_vlan = 0;
13546 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13547 		mplsogre_encap_conf.select_vlan = 1;
13548 	if (strcmp(res->ip_version, "ipv4") == 0)
13549 		mplsogre_encap_conf.select_ipv4 = 1;
13550 	else if (strcmp(res->ip_version, "ipv6") == 0)
13551 		mplsogre_encap_conf.select_ipv4 = 0;
13552 	else
13553 		return;
13554 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13555 	if (mplsogre_encap_conf.select_ipv4) {
13556 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13557 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13558 	} else {
13559 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13560 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13561 	}
13562 	if (mplsogre_encap_conf.select_vlan)
13563 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13564 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13565 		   RTE_ETHER_ADDR_LEN);
13566 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13567 		   RTE_ETHER_ADDR_LEN);
13568 }
13569 
13570 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13571 	.f = cmd_set_mplsogre_encap_parsed,
13572 	.data = NULL,
13573 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13574 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13575 		" eth-dst <eth-dst>",
13576 	.tokens = {
13577 		(void *)&cmd_set_mplsogre_encap_set,
13578 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13579 		(void *)&cmd_set_mplsogre_encap_ip_version,
13580 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13581 		(void *)&cmd_set_mplsogre_encap_label,
13582 		(void *)&cmd_set_mplsogre_encap_label_value,
13583 		(void *)&cmd_set_mplsogre_encap_ip_src,
13584 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13585 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13586 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13587 		(void *)&cmd_set_mplsogre_encap_eth_src,
13588 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13589 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13590 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13591 		NULL,
13592 	},
13593 };
13594 
13595 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13596 	.f = cmd_set_mplsogre_encap_parsed,
13597 	.data = NULL,
13598 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13599 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13600 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13601 	.tokens = {
13602 		(void *)&cmd_set_mplsogre_encap_set,
13603 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13604 		(void *)&cmd_set_mplsogre_encap_ip_version,
13605 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13606 		(void *)&cmd_set_mplsogre_encap_label,
13607 		(void *)&cmd_set_mplsogre_encap_label_value,
13608 		(void *)&cmd_set_mplsogre_encap_ip_src,
13609 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13610 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13611 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13612 		(void *)&cmd_set_mplsogre_encap_vlan,
13613 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13614 		(void *)&cmd_set_mplsogre_encap_eth_src,
13615 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13616 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13617 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13618 		NULL,
13619 	},
13620 };
13621 
13622 /** Set MPLSoGRE decapsulation details */
13623 struct cmd_set_mplsogre_decap_result {
13624 	cmdline_fixed_string_t set;
13625 	cmdline_fixed_string_t mplsogre;
13626 	cmdline_fixed_string_t pos_token;
13627 	cmdline_fixed_string_t ip_version;
13628 	uint32_t vlan_present:1;
13629 };
13630 
13631 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13632 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13633 				 "set");
13634 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13635 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13636 				 "mplsogre_decap");
13637 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13638 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13639 				 mplsogre, "mplsogre_decap-with-vlan");
13640 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13641 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13642 				 pos_token, "ip-version");
13643 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13644 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13645 				 ip_version, "ipv4#ipv6");
13646 
13647 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13648 	__rte_unused struct cmdline *cl,
13649 	__rte_unused void *data)
13650 {
13651 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13652 
13653 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13654 		mplsogre_decap_conf.select_vlan = 0;
13655 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13656 		mplsogre_decap_conf.select_vlan = 1;
13657 	if (strcmp(res->ip_version, "ipv4") == 0)
13658 		mplsogre_decap_conf.select_ipv4 = 1;
13659 	else if (strcmp(res->ip_version, "ipv6") == 0)
13660 		mplsogre_decap_conf.select_ipv4 = 0;
13661 }
13662 
13663 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13664 	.f = cmd_set_mplsogre_decap_parsed,
13665 	.data = NULL,
13666 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13667 	.tokens = {
13668 		(void *)&cmd_set_mplsogre_decap_set,
13669 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13670 		(void *)&cmd_set_mplsogre_decap_ip_version,
13671 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13672 		NULL,
13673 	},
13674 };
13675 
13676 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13677 	.f = cmd_set_mplsogre_decap_parsed,
13678 	.data = NULL,
13679 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13680 	.tokens = {
13681 		(void *)&cmd_set_mplsogre_decap_set,
13682 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13683 		(void *)&cmd_set_mplsogre_decap_ip_version,
13684 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13685 		NULL,
13686 	},
13687 };
13688 
13689 /** Set MPLSoUDP encapsulation details */
13690 struct cmd_set_mplsoudp_encap_result {
13691 	cmdline_fixed_string_t set;
13692 	cmdline_fixed_string_t mplsoudp;
13693 	cmdline_fixed_string_t pos_token;
13694 	cmdline_fixed_string_t ip_version;
13695 	uint32_t vlan_present:1;
13696 	uint32_t label;
13697 	uint16_t udp_src;
13698 	uint16_t udp_dst;
13699 	cmdline_ipaddr_t ip_src;
13700 	cmdline_ipaddr_t ip_dst;
13701 	uint16_t tci;
13702 	struct rte_ether_addr eth_src;
13703 	struct rte_ether_addr eth_dst;
13704 };
13705 
13706 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13707 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13708 				 "set");
13709 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13710 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13711 				 "mplsoudp_encap");
13712 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13713 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13714 				 mplsoudp, "mplsoudp_encap-with-vlan");
13715 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13716 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13717 				 pos_token, "ip-version");
13718 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13719 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13720 				 ip_version, "ipv4#ipv6");
13721 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13722 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13723 				 pos_token, "label");
13724 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13725 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13726 			      RTE_UINT32);
13727 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13728 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13729 				 pos_token, "udp-src");
13730 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13731 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13732 			      RTE_UINT16);
13733 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13734 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13735 				 pos_token, "udp-dst");
13736 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13737 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13738 			      RTE_UINT16);
13739 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13740 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13741 				 pos_token, "ip-src");
13742 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13743 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13744 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13745 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13746 				 pos_token, "ip-dst");
13747 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13748 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13749 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13750 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13751 				 pos_token, "vlan-tci");
13752 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13753 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13754 			      RTE_UINT16);
13755 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13756 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13757 				 pos_token, "eth-src");
13758 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13759 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13760 				    eth_src);
13761 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13762 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13763 				 pos_token, "eth-dst");
13764 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13765 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13766 				    eth_dst);
13767 
13768 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13769 	__rte_unused struct cmdline *cl,
13770 	__rte_unused void *data)
13771 {
13772 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13773 	union {
13774 		uint32_t mplsoudp_label;
13775 		uint8_t label[4];
13776 	} id = {
13777 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13778 	};
13779 
13780 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13781 		mplsoudp_encap_conf.select_vlan = 0;
13782 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13783 		mplsoudp_encap_conf.select_vlan = 1;
13784 	if (strcmp(res->ip_version, "ipv4") == 0)
13785 		mplsoudp_encap_conf.select_ipv4 = 1;
13786 	else if (strcmp(res->ip_version, "ipv6") == 0)
13787 		mplsoudp_encap_conf.select_ipv4 = 0;
13788 	else
13789 		return;
13790 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13791 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13792 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13793 	if (mplsoudp_encap_conf.select_ipv4) {
13794 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13795 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13796 	} else {
13797 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13798 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13799 	}
13800 	if (mplsoudp_encap_conf.select_vlan)
13801 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13802 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13803 		   RTE_ETHER_ADDR_LEN);
13804 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13805 		   RTE_ETHER_ADDR_LEN);
13806 }
13807 
13808 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13809 	.f = cmd_set_mplsoudp_encap_parsed,
13810 	.data = NULL,
13811 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13812 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13813 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13814 	.tokens = {
13815 		(void *)&cmd_set_mplsoudp_encap_set,
13816 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13817 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13818 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13819 		(void *)&cmd_set_mplsoudp_encap_label,
13820 		(void *)&cmd_set_mplsoudp_encap_label_value,
13821 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13822 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13823 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13824 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13825 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13826 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13827 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13828 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13829 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13830 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13831 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13832 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13833 		NULL,
13834 	},
13835 };
13836 
13837 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13838 	.f = cmd_set_mplsoudp_encap_parsed,
13839 	.data = NULL,
13840 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13841 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13842 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13843 		" eth-src <eth-src> eth-dst <eth-dst>",
13844 	.tokens = {
13845 		(void *)&cmd_set_mplsoudp_encap_set,
13846 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13847 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13848 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13849 		(void *)&cmd_set_mplsoudp_encap_label,
13850 		(void *)&cmd_set_mplsoudp_encap_label_value,
13851 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13852 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13853 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13854 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13855 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13856 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13857 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13858 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13859 		(void *)&cmd_set_mplsoudp_encap_vlan,
13860 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13861 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13862 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13863 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13864 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13865 		NULL,
13866 	},
13867 };
13868 
13869 /** Set MPLSoUDP decapsulation details */
13870 struct cmd_set_mplsoudp_decap_result {
13871 	cmdline_fixed_string_t set;
13872 	cmdline_fixed_string_t mplsoudp;
13873 	cmdline_fixed_string_t pos_token;
13874 	cmdline_fixed_string_t ip_version;
13875 	uint32_t vlan_present:1;
13876 };
13877 
13878 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13879 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13880 				 "set");
13881 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13882 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13883 				 "mplsoudp_decap");
13884 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13885 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13886 				 mplsoudp, "mplsoudp_decap-with-vlan");
13887 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13888 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13889 				 pos_token, "ip-version");
13890 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13891 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13892 				 ip_version, "ipv4#ipv6");
13893 
13894 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13895 	__rte_unused struct cmdline *cl,
13896 	__rte_unused void *data)
13897 {
13898 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13899 
13900 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13901 		mplsoudp_decap_conf.select_vlan = 0;
13902 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13903 		mplsoudp_decap_conf.select_vlan = 1;
13904 	if (strcmp(res->ip_version, "ipv4") == 0)
13905 		mplsoudp_decap_conf.select_ipv4 = 1;
13906 	else if (strcmp(res->ip_version, "ipv6") == 0)
13907 		mplsoudp_decap_conf.select_ipv4 = 0;
13908 }
13909 
13910 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13911 	.f = cmd_set_mplsoudp_decap_parsed,
13912 	.data = NULL,
13913 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13914 	.tokens = {
13915 		(void *)&cmd_set_mplsoudp_decap_set,
13916 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13917 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13918 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13919 		NULL,
13920 	},
13921 };
13922 
13923 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13924 	.f = cmd_set_mplsoudp_decap_parsed,
13925 	.data = NULL,
13926 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13927 	.tokens = {
13928 		(void *)&cmd_set_mplsoudp_decap_set,
13929 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13930 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13931 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13932 		NULL,
13933 	},
13934 };
13935 
13936 /** Set connection tracking object common details */
13937 struct cmd_set_conntrack_common_result {
13938 	cmdline_fixed_string_t set;
13939 	cmdline_fixed_string_t conntrack;
13940 	cmdline_fixed_string_t common;
13941 	cmdline_fixed_string_t peer;
13942 	cmdline_fixed_string_t is_orig;
13943 	cmdline_fixed_string_t enable;
13944 	cmdline_fixed_string_t live;
13945 	cmdline_fixed_string_t sack;
13946 	cmdline_fixed_string_t cack;
13947 	cmdline_fixed_string_t last_dir;
13948 	cmdline_fixed_string_t liberal;
13949 	cmdline_fixed_string_t state;
13950 	cmdline_fixed_string_t max_ack_win;
13951 	cmdline_fixed_string_t retrans;
13952 	cmdline_fixed_string_t last_win;
13953 	cmdline_fixed_string_t last_seq;
13954 	cmdline_fixed_string_t last_ack;
13955 	cmdline_fixed_string_t last_end;
13956 	cmdline_fixed_string_t last_index;
13957 	uint8_t stat;
13958 	uint8_t factor;
13959 	uint16_t peer_port;
13960 	uint32_t is_original;
13961 	uint32_t en;
13962 	uint32_t is_live;
13963 	uint32_t s_ack;
13964 	uint32_t c_ack;
13965 	uint32_t ld;
13966 	uint32_t lb;
13967 	uint8_t re_num;
13968 	uint8_t li;
13969 	uint16_t lw;
13970 	uint32_t ls;
13971 	uint32_t la;
13972 	uint32_t le;
13973 };
13974 
13975 cmdline_parse_token_string_t cmd_set_conntrack_set =
13976 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13977 				 set, "set");
13978 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13979 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13980 				 conntrack, "conntrack");
13981 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13982 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13983 				 common, "com");
13984 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13985 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13986 				 peer, "peer");
13987 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13988 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13989 			      peer_port, RTE_UINT16);
13990 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13991 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13992 				 is_orig, "is_orig");
13993 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13994 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13995 			      is_original, RTE_UINT32);
13996 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13997 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13998 				 enable, "enable");
13999 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14000 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14001 			      en, RTE_UINT32);
14002 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14003 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14004 				 live, "live");
14005 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14006 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14007 			      is_live, RTE_UINT32);
14008 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14009 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14010 				 sack, "sack");
14011 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14012 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14013 			      s_ack, RTE_UINT32);
14014 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14015 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14016 				 cack, "cack");
14017 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14018 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14019 			      c_ack, RTE_UINT32);
14020 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14021 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14022 				 last_dir, "last_dir");
14023 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14024 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14025 			      ld, RTE_UINT32);
14026 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14027 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14028 				 liberal, "liberal");
14029 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14030 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14031 			      lb, RTE_UINT32);
14032 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14033 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14034 				 state, "state");
14035 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14036 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14037 			      stat, RTE_UINT8);
14038 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14039 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14040 				 max_ack_win, "max_ack_win");
14041 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14042 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14043 			      factor, RTE_UINT8);
14044 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14045 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14046 				 retrans, "r_lim");
14047 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14048 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14049 			      re_num, RTE_UINT8);
14050 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14051 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14052 				 last_win, "last_win");
14053 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14054 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14055 			      lw, RTE_UINT16);
14056 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14057 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14058 				 last_seq, "last_seq");
14059 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14060 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14061 			      ls, RTE_UINT32);
14062 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14063 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14064 				 last_ack, "last_ack");
14065 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14066 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14067 			      la, RTE_UINT32);
14068 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14069 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14070 				 last_end, "last_end");
14071 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14072 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14073 			      le, RTE_UINT32);
14074 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14075 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14076 				 last_index, "last_index");
14077 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14078 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14079 			      li, RTE_UINT8);
14080 
14081 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14082 	__rte_unused struct cmdline *cl,
14083 	__rte_unused void *data)
14084 {
14085 	struct cmd_set_conntrack_common_result *res = parsed_result;
14086 
14087 	/* No need to swap to big endian. */
14088 	conntrack_context.peer_port = res->peer_port;
14089 	conntrack_context.is_original_dir = res->is_original;
14090 	conntrack_context.enable = res->en;
14091 	conntrack_context.live_connection = res->is_live;
14092 	conntrack_context.selective_ack = res->s_ack;
14093 	conntrack_context.challenge_ack_passed = res->c_ack;
14094 	conntrack_context.last_direction = res->ld;
14095 	conntrack_context.liberal_mode = res->lb;
14096 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14097 	conntrack_context.max_ack_window = res->factor;
14098 	conntrack_context.retransmission_limit = res->re_num;
14099 	conntrack_context.last_window = res->lw;
14100 	conntrack_context.last_index =
14101 		(enum rte_flow_conntrack_tcp_last_index)res->li;
14102 	conntrack_context.last_seq = res->ls;
14103 	conntrack_context.last_ack = res->la;
14104 	conntrack_context.last_end = res->le;
14105 }
14106 
14107 cmdline_parse_inst_t cmd_set_conntrack_common = {
14108 	.f = cmd_set_conntrack_common_parsed,
14109 	.data = NULL,
14110 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14111 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14112 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14113 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14114 		" last_index <flag>",
14115 	.tokens = {
14116 		(void *)&cmd_set_conntrack_set,
14117 		(void *)&cmd_set_conntrack_conntrack,
14118 		(void *)&cmd_set_conntrack_common_com,
14119 		(void *)&cmd_set_conntrack_common_peer,
14120 		(void *)&cmd_set_conntrack_common_peer_value,
14121 		(void *)&cmd_set_conntrack_common_is_orig,
14122 		(void *)&cmd_set_conntrack_common_is_orig_value,
14123 		(void *)&cmd_set_conntrack_common_enable,
14124 		(void *)&cmd_set_conntrack_common_enable_value,
14125 		(void *)&cmd_set_conntrack_common_live,
14126 		(void *)&cmd_set_conntrack_common_live_value,
14127 		(void *)&cmd_set_conntrack_common_sack,
14128 		(void *)&cmd_set_conntrack_common_sack_value,
14129 		(void *)&cmd_set_conntrack_common_cack,
14130 		(void *)&cmd_set_conntrack_common_cack_value,
14131 		(void *)&cmd_set_conntrack_common_last_dir,
14132 		(void *)&cmd_set_conntrack_common_last_dir_value,
14133 		(void *)&cmd_set_conntrack_common_liberal,
14134 		(void *)&cmd_set_conntrack_common_liberal_value,
14135 		(void *)&cmd_set_conntrack_common_state,
14136 		(void *)&cmd_set_conntrack_common_state_value,
14137 		(void *)&cmd_set_conntrack_common_max_ackwin,
14138 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
14139 		(void *)&cmd_set_conntrack_common_retrans,
14140 		(void *)&cmd_set_conntrack_common_retrans_value,
14141 		(void *)&cmd_set_conntrack_common_last_win,
14142 		(void *)&cmd_set_conntrack_common_last_win_value,
14143 		(void *)&cmd_set_conntrack_common_last_seq,
14144 		(void *)&cmd_set_conntrack_common_last_seq_value,
14145 		(void *)&cmd_set_conntrack_common_last_ack,
14146 		(void *)&cmd_set_conntrack_common_last_ack_value,
14147 		(void *)&cmd_set_conntrack_common_last_end,
14148 		(void *)&cmd_set_conntrack_common_last_end_value,
14149 		(void *)&cmd_set_conntrack_common_last_index,
14150 		(void *)&cmd_set_conntrack_common_last_index_value,
14151 		NULL,
14152 	},
14153 };
14154 
14155 /** Set connection tracking object both directions' details */
14156 struct cmd_set_conntrack_dir_result {
14157 	cmdline_fixed_string_t set;
14158 	cmdline_fixed_string_t conntrack;
14159 	cmdline_fixed_string_t dir;
14160 	cmdline_fixed_string_t scale;
14161 	cmdline_fixed_string_t fin;
14162 	cmdline_fixed_string_t ack_seen;
14163 	cmdline_fixed_string_t unack;
14164 	cmdline_fixed_string_t sent_end;
14165 	cmdline_fixed_string_t reply_end;
14166 	cmdline_fixed_string_t max_win;
14167 	cmdline_fixed_string_t max_ack;
14168 	uint32_t factor;
14169 	uint32_t f;
14170 	uint32_t as;
14171 	uint32_t un;
14172 	uint32_t se;
14173 	uint32_t re;
14174 	uint32_t mw;
14175 	uint32_t ma;
14176 };
14177 
14178 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14179 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14180 				 set, "set");
14181 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14182 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14183 				 conntrack, "conntrack");
14184 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14185 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14186 				 dir, "orig#rply");
14187 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14188 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14189 				 scale, "scale");
14190 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14191 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14192 			      factor, RTE_UINT32);
14193 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14194 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14195 				 fin, "fin");
14196 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14197 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14198 			      f, RTE_UINT32);
14199 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14200 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14201 				 ack_seen, "acked");
14202 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14203 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14204 			      as, RTE_UINT32);
14205 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14206 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14207 				 unack, "unack_data");
14208 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14209 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14210 			      un, RTE_UINT32);
14211 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14212 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14213 				 sent_end, "sent_end");
14214 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14215 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14216 			      se, RTE_UINT32);
14217 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14218 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14219 				 reply_end, "reply_end");
14220 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14221 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14222 			      re, RTE_UINT32);
14223 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14224 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14225 				 max_win, "max_win");
14226 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14227 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14228 			      mw, RTE_UINT32);
14229 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14230 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14231 				 max_ack, "max_ack");
14232 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14233 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14234 			      ma, RTE_UINT32);
14235 
14236 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14237 	__rte_unused struct cmdline *cl,
14238 	__rte_unused void *data)
14239 {
14240 	struct cmd_set_conntrack_dir_result *res = parsed_result;
14241 	struct rte_flow_tcp_dir_param *dir = NULL;
14242 
14243 	if (strcmp(res->dir, "orig") == 0)
14244 		dir = &conntrack_context.original_dir;
14245 	else if (strcmp(res->dir, "rply") == 0)
14246 		dir = &conntrack_context.reply_dir;
14247 	else
14248 		return;
14249 	dir->scale = res->factor;
14250 	dir->close_initiated = res->f;
14251 	dir->last_ack_seen = res->as;
14252 	dir->data_unacked = res->un;
14253 	dir->sent_end = res->se;
14254 	dir->reply_end = res->re;
14255 	dir->max_ack = res->ma;
14256 	dir->max_win = res->mw;
14257 }
14258 
14259 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14260 	.f = cmd_set_conntrack_dir_parsed,
14261 	.data = NULL,
14262 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14263 		    " acked <seen> unack_data <unack> sent_end <sent>"
14264 		    " reply_end <reply> max_win <win> max_ack <ack>",
14265 	.tokens = {
14266 		(void *)&cmd_set_conntrack_set,
14267 		(void *)&cmd_set_conntrack_conntrack,
14268 		(void *)&cmd_set_conntrack_dir_dir,
14269 		(void *)&cmd_set_conntrack_dir_scale,
14270 		(void *)&cmd_set_conntrack_dir_scale_value,
14271 		(void *)&cmd_set_conntrack_dir_fin,
14272 		(void *)&cmd_set_conntrack_dir_fin_value,
14273 		(void *)&cmd_set_conntrack_dir_ack,
14274 		(void *)&cmd_set_conntrack_dir_ack_value,
14275 		(void *)&cmd_set_conntrack_dir_unack_data,
14276 		(void *)&cmd_set_conntrack_dir_unack_data_value,
14277 		(void *)&cmd_set_conntrack_dir_sent_end,
14278 		(void *)&cmd_set_conntrack_dir_sent_end_value,
14279 		(void *)&cmd_set_conntrack_dir_reply_end,
14280 		(void *)&cmd_set_conntrack_dir_reply_end_value,
14281 		(void *)&cmd_set_conntrack_dir_max_win,
14282 		(void *)&cmd_set_conntrack_dir_max_win_value,
14283 		(void *)&cmd_set_conntrack_dir_max_ack,
14284 		(void *)&cmd_set_conntrack_dir_max_ack_value,
14285 		NULL,
14286 	},
14287 };
14288 
14289 /* Strict link priority scheduling mode setting */
14290 static void
14291 cmd_strict_link_prio_parsed(
14292 	void *parsed_result,
14293 	__rte_unused struct cmdline *cl,
14294 	__rte_unused void *data)
14295 {
14296 	struct cmd_vf_tc_bw_result *res = parsed_result;
14297 	int ret = -ENOTSUP;
14298 
14299 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14300 		return;
14301 
14302 #ifdef RTE_NET_I40E
14303 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14304 #endif
14305 
14306 	switch (ret) {
14307 	case 0:
14308 		break;
14309 	case -EINVAL:
14310 		fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14311 		break;
14312 	case -ENODEV:
14313 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
14314 		break;
14315 	case -ENOTSUP:
14316 		fprintf(stderr, "function not implemented\n");
14317 		break;
14318 	default:
14319 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14320 	}
14321 }
14322 
14323 cmdline_parse_inst_t cmd_strict_link_prio = {
14324 	.f = cmd_strict_link_prio_parsed,
14325 	.data = NULL,
14326 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14327 	.tokens = {
14328 		(void *)&cmd_vf_tc_bw_set,
14329 		(void *)&cmd_vf_tc_bw_tx,
14330 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14331 		(void *)&cmd_vf_tc_bw_port_id,
14332 		(void *)&cmd_vf_tc_bw_tc_map,
14333 		NULL,
14334 	},
14335 };
14336 
14337 /* Load dynamic device personalization*/
14338 struct cmd_ddp_add_result {
14339 	cmdline_fixed_string_t ddp;
14340 	cmdline_fixed_string_t add;
14341 	portid_t port_id;
14342 	char filepath[];
14343 };
14344 
14345 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14346 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14347 cmdline_parse_token_string_t cmd_ddp_add_add =
14348 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14349 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14350 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14351 		RTE_UINT16);
14352 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14353 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14354 
14355 static void
14356 cmd_ddp_add_parsed(
14357 	void *parsed_result,
14358 	__rte_unused struct cmdline *cl,
14359 	__rte_unused void *data)
14360 {
14361 	struct cmd_ddp_add_result *res = parsed_result;
14362 	uint8_t *buff;
14363 	uint32_t size;
14364 	char *filepath;
14365 	char *file_fld[2];
14366 	int file_num;
14367 	int ret = -ENOTSUP;
14368 
14369 	if (!all_ports_stopped()) {
14370 		fprintf(stderr, "Please stop all ports first\n");
14371 		return;
14372 	}
14373 
14374 	filepath = strdup(res->filepath);
14375 	if (filepath == NULL) {
14376 		fprintf(stderr, "Failed to allocate memory\n");
14377 		return;
14378 	}
14379 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14380 
14381 	buff = open_file(file_fld[0], &size);
14382 	if (!buff) {
14383 		free((void *)filepath);
14384 		return;
14385 	}
14386 
14387 #ifdef RTE_NET_I40E
14388 	if (ret == -ENOTSUP)
14389 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14390 					       buff, size,
14391 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14392 #endif
14393 
14394 	if (ret == -EEXIST)
14395 		fprintf(stderr, "Profile has already existed.\n");
14396 	else if (ret < 0)
14397 		fprintf(stderr, "Failed to load profile.\n");
14398 	else if (file_num == 2)
14399 		save_file(file_fld[1], buff, size);
14400 
14401 	close_file(buff);
14402 	free((void *)filepath);
14403 }
14404 
14405 cmdline_parse_inst_t cmd_ddp_add = {
14406 	.f = cmd_ddp_add_parsed,
14407 	.data = NULL,
14408 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14409 	.tokens = {
14410 		(void *)&cmd_ddp_add_ddp,
14411 		(void *)&cmd_ddp_add_add,
14412 		(void *)&cmd_ddp_add_port_id,
14413 		(void *)&cmd_ddp_add_filepath,
14414 		NULL,
14415 	},
14416 };
14417 
14418 /* Delete dynamic device personalization*/
14419 struct cmd_ddp_del_result {
14420 	cmdline_fixed_string_t ddp;
14421 	cmdline_fixed_string_t del;
14422 	portid_t port_id;
14423 	char filepath[];
14424 };
14425 
14426 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14427 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14428 cmdline_parse_token_string_t cmd_ddp_del_del =
14429 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14430 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14431 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14432 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14433 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14434 
14435 static void
14436 cmd_ddp_del_parsed(
14437 	void *parsed_result,
14438 	__rte_unused struct cmdline *cl,
14439 	__rte_unused void *data)
14440 {
14441 	struct cmd_ddp_del_result *res = parsed_result;
14442 	uint8_t *buff;
14443 	uint32_t size;
14444 	int ret = -ENOTSUP;
14445 
14446 	if (!all_ports_stopped()) {
14447 		fprintf(stderr, "Please stop all ports first\n");
14448 		return;
14449 	}
14450 
14451 	buff = open_file(res->filepath, &size);
14452 	if (!buff)
14453 		return;
14454 
14455 #ifdef RTE_NET_I40E
14456 	if (ret == -ENOTSUP)
14457 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14458 					       buff, size,
14459 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14460 #endif
14461 
14462 	if (ret == -EACCES)
14463 		fprintf(stderr, "Profile does not exist.\n");
14464 	else if (ret < 0)
14465 		fprintf(stderr, "Failed to delete profile.\n");
14466 
14467 	close_file(buff);
14468 }
14469 
14470 cmdline_parse_inst_t cmd_ddp_del = {
14471 	.f = cmd_ddp_del_parsed,
14472 	.data = NULL,
14473 	.help_str = "ddp del <port_id> <backup_profile_path>",
14474 	.tokens = {
14475 		(void *)&cmd_ddp_del_ddp,
14476 		(void *)&cmd_ddp_del_del,
14477 		(void *)&cmd_ddp_del_port_id,
14478 		(void *)&cmd_ddp_del_filepath,
14479 		NULL,
14480 	},
14481 };
14482 
14483 /* Get dynamic device personalization profile info */
14484 struct cmd_ddp_info_result {
14485 	cmdline_fixed_string_t ddp;
14486 	cmdline_fixed_string_t get;
14487 	cmdline_fixed_string_t info;
14488 	char filepath[];
14489 };
14490 
14491 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14492 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14493 cmdline_parse_token_string_t cmd_ddp_info_get =
14494 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14495 cmdline_parse_token_string_t cmd_ddp_info_info =
14496 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14497 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14498 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14499 
14500 static void
14501 cmd_ddp_info_parsed(
14502 	void *parsed_result,
14503 	__rte_unused struct cmdline *cl,
14504 	__rte_unused void *data)
14505 {
14506 	struct cmd_ddp_info_result *res = parsed_result;
14507 	uint8_t *pkg;
14508 	uint32_t pkg_size;
14509 	int ret = -ENOTSUP;
14510 #ifdef RTE_NET_I40E
14511 	uint32_t i, j, n;
14512 	uint8_t *buff;
14513 	uint32_t buff_size = 0;
14514 	struct rte_pmd_i40e_profile_info info;
14515 	uint32_t dev_num = 0;
14516 	struct rte_pmd_i40e_ddp_device_id *devs;
14517 	uint32_t proto_num = 0;
14518 	struct rte_pmd_i40e_proto_info *proto = NULL;
14519 	uint32_t pctype_num = 0;
14520 	struct rte_pmd_i40e_ptype_info *pctype;
14521 	uint32_t ptype_num = 0;
14522 	struct rte_pmd_i40e_ptype_info *ptype;
14523 	uint8_t proto_id;
14524 
14525 #endif
14526 
14527 	pkg = open_file(res->filepath, &pkg_size);
14528 	if (!pkg)
14529 		return;
14530 
14531 #ifdef RTE_NET_I40E
14532 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14533 				(uint8_t *)&info, sizeof(info),
14534 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14535 	if (!ret) {
14536 		printf("Global Track id:       0x%x\n", info.track_id);
14537 		printf("Global Version:        %d.%d.%d.%d\n",
14538 			info.version.major,
14539 			info.version.minor,
14540 			info.version.update,
14541 			info.version.draft);
14542 		printf("Global Package name:   %s\n\n", info.name);
14543 	}
14544 
14545 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14546 				(uint8_t *)&info, sizeof(info),
14547 				RTE_PMD_I40E_PKG_INFO_HEADER);
14548 	if (!ret) {
14549 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14550 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14551 			info.version.major,
14552 			info.version.minor,
14553 			info.version.update,
14554 			info.version.draft);
14555 		printf("i40e Profile name:     %s\n\n", info.name);
14556 	}
14557 
14558 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14559 				(uint8_t *)&buff_size, sizeof(buff_size),
14560 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14561 	if (!ret && buff_size) {
14562 		buff = (uint8_t *)malloc(buff_size);
14563 		if (buff) {
14564 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14565 						buff, buff_size,
14566 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14567 			if (!ret)
14568 				printf("Package Notes:\n%s\n\n", buff);
14569 			free(buff);
14570 		}
14571 	}
14572 
14573 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14574 				(uint8_t *)&dev_num, sizeof(dev_num),
14575 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14576 	if (!ret && dev_num) {
14577 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14578 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14579 		if (devs) {
14580 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14581 						(uint8_t *)devs, buff_size,
14582 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14583 			if (!ret) {
14584 				printf("List of supported devices:\n");
14585 				for (i = 0; i < dev_num; i++) {
14586 					printf("  %04X:%04X %04X:%04X\n",
14587 						devs[i].vendor_dev_id >> 16,
14588 						devs[i].vendor_dev_id & 0xFFFF,
14589 						devs[i].sub_vendor_dev_id >> 16,
14590 						devs[i].sub_vendor_dev_id & 0xFFFF);
14591 				}
14592 				printf("\n");
14593 			}
14594 			free(devs);
14595 		}
14596 	}
14597 
14598 	/* get information about protocols and packet types */
14599 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14600 		(uint8_t *)&proto_num, sizeof(proto_num),
14601 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14602 	if (ret || !proto_num)
14603 		goto no_print_return;
14604 
14605 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14606 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14607 	if (!proto)
14608 		goto no_print_return;
14609 
14610 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14611 					buff_size,
14612 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14613 	if (!ret) {
14614 		printf("List of used protocols:\n");
14615 		for (i = 0; i < proto_num; i++)
14616 			printf("  %2u: %s\n", proto[i].proto_id,
14617 			       proto[i].name);
14618 		printf("\n");
14619 	}
14620 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14621 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14622 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14623 	if (ret || !pctype_num)
14624 		goto no_print_pctypes;
14625 
14626 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14627 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14628 	if (!pctype)
14629 		goto no_print_pctypes;
14630 
14631 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14632 					buff_size,
14633 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14634 	if (ret) {
14635 		free(pctype);
14636 		goto no_print_pctypes;
14637 	}
14638 
14639 	printf("List of defined packet classification types:\n");
14640 	for (i = 0; i < pctype_num; i++) {
14641 		printf("  %2u:", pctype[i].ptype_id);
14642 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14643 			proto_id = pctype[i].protocols[j];
14644 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14645 				for (n = 0; n < proto_num; n++) {
14646 					if (proto[n].proto_id == proto_id) {
14647 						printf(" %s", proto[n].name);
14648 						break;
14649 					}
14650 				}
14651 			}
14652 		}
14653 		printf("\n");
14654 	}
14655 	printf("\n");
14656 	free(pctype);
14657 
14658 no_print_pctypes:
14659 
14660 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14661 					sizeof(ptype_num),
14662 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14663 	if (ret || !ptype_num)
14664 		goto no_print_return;
14665 
14666 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14667 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14668 	if (!ptype)
14669 		goto no_print_return;
14670 
14671 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14672 					buff_size,
14673 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14674 	if (ret) {
14675 		free(ptype);
14676 		goto no_print_return;
14677 	}
14678 	printf("List of defined packet types:\n");
14679 	for (i = 0; i < ptype_num; i++) {
14680 		printf("  %2u:", ptype[i].ptype_id);
14681 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14682 			proto_id = ptype[i].protocols[j];
14683 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14684 				for (n = 0; n < proto_num; n++) {
14685 					if (proto[n].proto_id == proto_id) {
14686 						printf(" %s", proto[n].name);
14687 						break;
14688 					}
14689 				}
14690 			}
14691 		}
14692 		printf("\n");
14693 	}
14694 	free(ptype);
14695 	printf("\n");
14696 
14697 	ret = 0;
14698 no_print_return:
14699 	if (proto)
14700 		free(proto);
14701 #endif
14702 	if (ret == -ENOTSUP)
14703 		fprintf(stderr, "Function not supported in PMD\n");
14704 	close_file(pkg);
14705 }
14706 
14707 cmdline_parse_inst_t cmd_ddp_get_info = {
14708 	.f = cmd_ddp_info_parsed,
14709 	.data = NULL,
14710 	.help_str = "ddp get info <profile_path>",
14711 	.tokens = {
14712 		(void *)&cmd_ddp_info_ddp,
14713 		(void *)&cmd_ddp_info_get,
14714 		(void *)&cmd_ddp_info_info,
14715 		(void *)&cmd_ddp_info_filepath,
14716 		NULL,
14717 	},
14718 };
14719 
14720 /* Get dynamic device personalization profile info list*/
14721 #define PROFILE_INFO_SIZE 48
14722 #define MAX_PROFILE_NUM 16
14723 
14724 struct cmd_ddp_get_list_result {
14725 	cmdline_fixed_string_t ddp;
14726 	cmdline_fixed_string_t get;
14727 	cmdline_fixed_string_t list;
14728 	portid_t port_id;
14729 };
14730 
14731 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14732 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14733 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14734 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14735 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14736 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14737 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14738 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14739 		RTE_UINT16);
14740 
14741 static void
14742 cmd_ddp_get_list_parsed(
14743 	__rte_unused void *parsed_result,
14744 	__rte_unused struct cmdline *cl,
14745 	__rte_unused void *data)
14746 {
14747 #ifdef RTE_NET_I40E
14748 	struct cmd_ddp_get_list_result *res = parsed_result;
14749 	struct rte_pmd_i40e_profile_list *p_list;
14750 	struct rte_pmd_i40e_profile_info *p_info;
14751 	uint32_t p_num;
14752 	uint32_t size;
14753 	uint32_t i;
14754 #endif
14755 	int ret = -ENOTSUP;
14756 
14757 #ifdef RTE_NET_I40E
14758 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14759 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14760 	if (!p_list) {
14761 		fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14762 		return;
14763 	}
14764 
14765 	if (ret == -ENOTSUP)
14766 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14767 						(uint8_t *)p_list, size);
14768 
14769 	if (!ret) {
14770 		p_num = p_list->p_count;
14771 		printf("Profile number is: %d\n\n", p_num);
14772 
14773 		for (i = 0; i < p_num; i++) {
14774 			p_info = &p_list->p_info[i];
14775 			printf("Profile %d:\n", i);
14776 			printf("Track id:     0x%x\n", p_info->track_id);
14777 			printf("Version:      %d.%d.%d.%d\n",
14778 			       p_info->version.major,
14779 			       p_info->version.minor,
14780 			       p_info->version.update,
14781 			       p_info->version.draft);
14782 			printf("Profile name: %s\n\n", p_info->name);
14783 		}
14784 	}
14785 
14786 	free(p_list);
14787 #endif
14788 
14789 	if (ret < 0)
14790 		fprintf(stderr, "Failed to get ddp list\n");
14791 }
14792 
14793 cmdline_parse_inst_t cmd_ddp_get_list = {
14794 	.f = cmd_ddp_get_list_parsed,
14795 	.data = NULL,
14796 	.help_str = "ddp get list <port_id>",
14797 	.tokens = {
14798 		(void *)&cmd_ddp_get_list_ddp,
14799 		(void *)&cmd_ddp_get_list_get,
14800 		(void *)&cmd_ddp_get_list_list,
14801 		(void *)&cmd_ddp_get_list_port_id,
14802 		NULL,
14803 	},
14804 };
14805 
14806 /* Configure input set */
14807 struct cmd_cfg_input_set_result {
14808 	cmdline_fixed_string_t port;
14809 	cmdline_fixed_string_t cfg;
14810 	portid_t port_id;
14811 	cmdline_fixed_string_t pctype;
14812 	uint8_t pctype_id;
14813 	cmdline_fixed_string_t inset_type;
14814 	cmdline_fixed_string_t opt;
14815 	cmdline_fixed_string_t field;
14816 	uint8_t field_idx;
14817 };
14818 
14819 static void
14820 cmd_cfg_input_set_parsed(
14821 	__rte_unused void *parsed_result,
14822 	__rte_unused struct cmdline *cl,
14823 	__rte_unused void *data)
14824 {
14825 #ifdef RTE_NET_I40E
14826 	struct cmd_cfg_input_set_result *res = parsed_result;
14827 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14828 	struct rte_pmd_i40e_inset inset;
14829 #endif
14830 	int ret = -ENOTSUP;
14831 
14832 	if (!all_ports_stopped()) {
14833 		fprintf(stderr, "Please stop all ports first\n");
14834 		return;
14835 	}
14836 
14837 #ifdef RTE_NET_I40E
14838 	if (!strcmp(res->inset_type, "hash_inset"))
14839 		inset_type = INSET_HASH;
14840 	else if (!strcmp(res->inset_type, "fdir_inset"))
14841 		inset_type = INSET_FDIR;
14842 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14843 		inset_type = INSET_FDIR_FLX;
14844 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14845 				     &inset, inset_type);
14846 	if (ret) {
14847 		fprintf(stderr, "Failed to get input set.\n");
14848 		return;
14849 	}
14850 
14851 	if (!strcmp(res->opt, "get")) {
14852 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14853 						   res->field_idx);
14854 		if (ret)
14855 			printf("Field index %d is enabled.\n", res->field_idx);
14856 		else
14857 			printf("Field index %d is disabled.\n", res->field_idx);
14858 		return;
14859 	} else if (!strcmp(res->opt, "set"))
14860 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14861 						   res->field_idx);
14862 	else if (!strcmp(res->opt, "clear"))
14863 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14864 						     res->field_idx);
14865 	if (ret) {
14866 		fprintf(stderr, "Failed to configure input set field.\n");
14867 		return;
14868 	}
14869 
14870 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14871 				     &inset, inset_type);
14872 	if (ret) {
14873 		fprintf(stderr, "Failed to set input set.\n");
14874 		return;
14875 	}
14876 #endif
14877 
14878 	if (ret == -ENOTSUP)
14879 		fprintf(stderr, "Function not supported\n");
14880 }
14881 
14882 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14883 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14884 				 port, "port");
14885 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14886 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14887 				 cfg, "config");
14888 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14889 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14890 			      port_id, RTE_UINT16);
14891 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14892 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14893 				 pctype, "pctype");
14894 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14895 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14896 			      pctype_id, RTE_UINT8);
14897 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14898 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14899 				 inset_type,
14900 				 "hash_inset#fdir_inset#fdir_flx_inset");
14901 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14902 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14903 				 opt, "get#set#clear");
14904 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14905 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14906 				 field, "field");
14907 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14908 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14909 			      field_idx, RTE_UINT8);
14910 
14911 cmdline_parse_inst_t cmd_cfg_input_set = {
14912 	.f = cmd_cfg_input_set_parsed,
14913 	.data = NULL,
14914 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14915 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14916 	.tokens = {
14917 		(void *)&cmd_cfg_input_set_port,
14918 		(void *)&cmd_cfg_input_set_cfg,
14919 		(void *)&cmd_cfg_input_set_port_id,
14920 		(void *)&cmd_cfg_input_set_pctype,
14921 		(void *)&cmd_cfg_input_set_pctype_id,
14922 		(void *)&cmd_cfg_input_set_inset_type,
14923 		(void *)&cmd_cfg_input_set_opt,
14924 		(void *)&cmd_cfg_input_set_field,
14925 		(void *)&cmd_cfg_input_set_field_idx,
14926 		NULL,
14927 	},
14928 };
14929 
14930 /* Clear input set */
14931 struct cmd_clear_input_set_result {
14932 	cmdline_fixed_string_t port;
14933 	cmdline_fixed_string_t cfg;
14934 	portid_t port_id;
14935 	cmdline_fixed_string_t pctype;
14936 	uint8_t pctype_id;
14937 	cmdline_fixed_string_t inset_type;
14938 	cmdline_fixed_string_t clear;
14939 	cmdline_fixed_string_t all;
14940 };
14941 
14942 static void
14943 cmd_clear_input_set_parsed(
14944 	__rte_unused void *parsed_result,
14945 	__rte_unused struct cmdline *cl,
14946 	__rte_unused void *data)
14947 {
14948 #ifdef RTE_NET_I40E
14949 	struct cmd_clear_input_set_result *res = parsed_result;
14950 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14951 	struct rte_pmd_i40e_inset inset;
14952 #endif
14953 	int ret = -ENOTSUP;
14954 
14955 	if (!all_ports_stopped()) {
14956 		fprintf(stderr, "Please stop all ports first\n");
14957 		return;
14958 	}
14959 
14960 #ifdef RTE_NET_I40E
14961 	if (!strcmp(res->inset_type, "hash_inset"))
14962 		inset_type = INSET_HASH;
14963 	else if (!strcmp(res->inset_type, "fdir_inset"))
14964 		inset_type = INSET_FDIR;
14965 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14966 		inset_type = INSET_FDIR_FLX;
14967 
14968 	memset(&inset, 0, sizeof(inset));
14969 
14970 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14971 				     &inset, inset_type);
14972 	if (ret) {
14973 		fprintf(stderr, "Failed to clear input set.\n");
14974 		return;
14975 	}
14976 
14977 #endif
14978 
14979 	if (ret == -ENOTSUP)
14980 		fprintf(stderr, "Function not supported\n");
14981 }
14982 
14983 cmdline_parse_token_string_t cmd_clear_input_set_port =
14984 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14985 				 port, "port");
14986 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14987 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14988 				 cfg, "config");
14989 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14990 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14991 			      port_id, RTE_UINT16);
14992 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14993 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14994 				 pctype, "pctype");
14995 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14996 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14997 			      pctype_id, RTE_UINT8);
14998 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14999 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15000 				 inset_type,
15001 				 "hash_inset#fdir_inset#fdir_flx_inset");
15002 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15003 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15004 				 clear, "clear");
15005 cmdline_parse_token_string_t cmd_clear_input_set_all =
15006 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15007 				 all, "all");
15008 
15009 cmdline_parse_inst_t cmd_clear_input_set = {
15010 	.f = cmd_clear_input_set_parsed,
15011 	.data = NULL,
15012 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15013 		    "fdir_inset|fdir_flx_inset clear all",
15014 	.tokens = {
15015 		(void *)&cmd_clear_input_set_port,
15016 		(void *)&cmd_clear_input_set_cfg,
15017 		(void *)&cmd_clear_input_set_port_id,
15018 		(void *)&cmd_clear_input_set_pctype,
15019 		(void *)&cmd_clear_input_set_pctype_id,
15020 		(void *)&cmd_clear_input_set_inset_type,
15021 		(void *)&cmd_clear_input_set_clear,
15022 		(void *)&cmd_clear_input_set_all,
15023 		NULL,
15024 	},
15025 };
15026 
15027 /* show vf stats */
15028 
15029 /* Common result structure for show vf stats */
15030 struct cmd_show_vf_stats_result {
15031 	cmdline_fixed_string_t show;
15032 	cmdline_fixed_string_t vf;
15033 	cmdline_fixed_string_t stats;
15034 	portid_t port_id;
15035 	uint16_t vf_id;
15036 };
15037 
15038 /* Common CLI fields show vf stats*/
15039 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15040 	TOKEN_STRING_INITIALIZER
15041 		(struct cmd_show_vf_stats_result,
15042 		 show, "show");
15043 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15044 	TOKEN_STRING_INITIALIZER
15045 		(struct cmd_show_vf_stats_result,
15046 		 vf, "vf");
15047 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15048 	TOKEN_STRING_INITIALIZER
15049 		(struct cmd_show_vf_stats_result,
15050 		 stats, "stats");
15051 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15052 	TOKEN_NUM_INITIALIZER
15053 		(struct cmd_show_vf_stats_result,
15054 		 port_id, RTE_UINT16);
15055 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15056 	TOKEN_NUM_INITIALIZER
15057 		(struct cmd_show_vf_stats_result,
15058 		 vf_id, RTE_UINT16);
15059 
15060 static void
15061 cmd_show_vf_stats_parsed(
15062 	void *parsed_result,
15063 	__rte_unused struct cmdline *cl,
15064 	__rte_unused void *data)
15065 {
15066 	struct cmd_show_vf_stats_result *res = parsed_result;
15067 	struct rte_eth_stats stats;
15068 	int ret = -ENOTSUP;
15069 	static const char *nic_stats_border = "########################";
15070 
15071 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15072 		return;
15073 
15074 	memset(&stats, 0, sizeof(stats));
15075 
15076 #ifdef RTE_NET_I40E
15077 	if (ret == -ENOTSUP)
15078 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15079 						res->vf_id,
15080 						&stats);
15081 #endif
15082 #ifdef RTE_NET_BNXT
15083 	if (ret == -ENOTSUP)
15084 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15085 						res->vf_id,
15086 						&stats);
15087 #endif
15088 
15089 	switch (ret) {
15090 	case 0:
15091 		break;
15092 	case -EINVAL:
15093 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15094 		break;
15095 	case -ENODEV:
15096 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15097 		break;
15098 	case -ENOTSUP:
15099 		fprintf(stderr, "function not implemented\n");
15100 		break;
15101 	default:
15102 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15103 	}
15104 
15105 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
15106 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15107 
15108 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
15109 	       "%-"PRIu64"\n",
15110 	       stats.ipackets, stats.imissed, stats.ibytes);
15111 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
15112 	printf("  RX-nombuf:  %-10"PRIu64"\n",
15113 	       stats.rx_nombuf);
15114 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
15115 	       "%-"PRIu64"\n",
15116 	       stats.opackets, stats.oerrors, stats.obytes);
15117 
15118 	printf("  %s############################%s\n",
15119 			       nic_stats_border, nic_stats_border);
15120 }
15121 
15122 cmdline_parse_inst_t cmd_show_vf_stats = {
15123 	.f = cmd_show_vf_stats_parsed,
15124 	.data = NULL,
15125 	.help_str = "show vf stats <port_id> <vf_id>",
15126 	.tokens = {
15127 		(void *)&cmd_show_vf_stats_show,
15128 		(void *)&cmd_show_vf_stats_vf,
15129 		(void *)&cmd_show_vf_stats_stats,
15130 		(void *)&cmd_show_vf_stats_port_id,
15131 		(void *)&cmd_show_vf_stats_vf_id,
15132 		NULL,
15133 	},
15134 };
15135 
15136 /* clear vf stats */
15137 
15138 /* Common result structure for clear vf stats */
15139 struct cmd_clear_vf_stats_result {
15140 	cmdline_fixed_string_t clear;
15141 	cmdline_fixed_string_t vf;
15142 	cmdline_fixed_string_t stats;
15143 	portid_t port_id;
15144 	uint16_t vf_id;
15145 };
15146 
15147 /* Common CLI fields clear vf stats*/
15148 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15149 	TOKEN_STRING_INITIALIZER
15150 		(struct cmd_clear_vf_stats_result,
15151 		 clear, "clear");
15152 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15153 	TOKEN_STRING_INITIALIZER
15154 		(struct cmd_clear_vf_stats_result,
15155 		 vf, "vf");
15156 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15157 	TOKEN_STRING_INITIALIZER
15158 		(struct cmd_clear_vf_stats_result,
15159 		 stats, "stats");
15160 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15161 	TOKEN_NUM_INITIALIZER
15162 		(struct cmd_clear_vf_stats_result,
15163 		 port_id, RTE_UINT16);
15164 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15165 	TOKEN_NUM_INITIALIZER
15166 		(struct cmd_clear_vf_stats_result,
15167 		 vf_id, RTE_UINT16);
15168 
15169 static void
15170 cmd_clear_vf_stats_parsed(
15171 	void *parsed_result,
15172 	__rte_unused struct cmdline *cl,
15173 	__rte_unused void *data)
15174 {
15175 	struct cmd_clear_vf_stats_result *res = parsed_result;
15176 	int ret = -ENOTSUP;
15177 
15178 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15179 		return;
15180 
15181 #ifdef RTE_NET_I40E
15182 	if (ret == -ENOTSUP)
15183 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15184 						  res->vf_id);
15185 #endif
15186 #ifdef RTE_NET_BNXT
15187 	if (ret == -ENOTSUP)
15188 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15189 						  res->vf_id);
15190 #endif
15191 
15192 	switch (ret) {
15193 	case 0:
15194 		break;
15195 	case -EINVAL:
15196 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15197 		break;
15198 	case -ENODEV:
15199 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15200 		break;
15201 	case -ENOTSUP:
15202 		fprintf(stderr, "function not implemented\n");
15203 		break;
15204 	default:
15205 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15206 	}
15207 }
15208 
15209 cmdline_parse_inst_t cmd_clear_vf_stats = {
15210 	.f = cmd_clear_vf_stats_parsed,
15211 	.data = NULL,
15212 	.help_str = "clear vf stats <port_id> <vf_id>",
15213 	.tokens = {
15214 		(void *)&cmd_clear_vf_stats_clear,
15215 		(void *)&cmd_clear_vf_stats_vf,
15216 		(void *)&cmd_clear_vf_stats_stats,
15217 		(void *)&cmd_clear_vf_stats_port_id,
15218 		(void *)&cmd_clear_vf_stats_vf_id,
15219 		NULL,
15220 	},
15221 };
15222 
15223 /* port config pctype mapping reset */
15224 
15225 /* Common result structure for port config pctype mapping reset */
15226 struct cmd_pctype_mapping_reset_result {
15227 	cmdline_fixed_string_t port;
15228 	cmdline_fixed_string_t config;
15229 	portid_t port_id;
15230 	cmdline_fixed_string_t pctype;
15231 	cmdline_fixed_string_t mapping;
15232 	cmdline_fixed_string_t reset;
15233 };
15234 
15235 /* Common CLI fields for port config pctype mapping reset*/
15236 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15237 	TOKEN_STRING_INITIALIZER
15238 		(struct cmd_pctype_mapping_reset_result,
15239 		 port, "port");
15240 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15241 	TOKEN_STRING_INITIALIZER
15242 		(struct cmd_pctype_mapping_reset_result,
15243 		 config, "config");
15244 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15245 	TOKEN_NUM_INITIALIZER
15246 		(struct cmd_pctype_mapping_reset_result,
15247 		 port_id, RTE_UINT16);
15248 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15249 	TOKEN_STRING_INITIALIZER
15250 		(struct cmd_pctype_mapping_reset_result,
15251 		 pctype, "pctype");
15252 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15253 	TOKEN_STRING_INITIALIZER
15254 		(struct cmd_pctype_mapping_reset_result,
15255 		 mapping, "mapping");
15256 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15257 	TOKEN_STRING_INITIALIZER
15258 		(struct cmd_pctype_mapping_reset_result,
15259 		 reset, "reset");
15260 
15261 static void
15262 cmd_pctype_mapping_reset_parsed(
15263 	void *parsed_result,
15264 	__rte_unused struct cmdline *cl,
15265 	__rte_unused void *data)
15266 {
15267 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15268 	int ret = -ENOTSUP;
15269 
15270 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15271 		return;
15272 
15273 #ifdef RTE_NET_I40E
15274 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15275 #endif
15276 
15277 	switch (ret) {
15278 	case 0:
15279 		break;
15280 	case -ENODEV:
15281 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15282 		break;
15283 	case -ENOTSUP:
15284 		fprintf(stderr, "function not implemented\n");
15285 		break;
15286 	default:
15287 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15288 	}
15289 }
15290 
15291 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15292 	.f = cmd_pctype_mapping_reset_parsed,
15293 	.data = NULL,
15294 	.help_str = "port config <port_id> pctype mapping reset",
15295 	.tokens = {
15296 		(void *)&cmd_pctype_mapping_reset_port,
15297 		(void *)&cmd_pctype_mapping_reset_config,
15298 		(void *)&cmd_pctype_mapping_reset_port_id,
15299 		(void *)&cmd_pctype_mapping_reset_pctype,
15300 		(void *)&cmd_pctype_mapping_reset_mapping,
15301 		(void *)&cmd_pctype_mapping_reset_reset,
15302 		NULL,
15303 	},
15304 };
15305 
15306 /* show port pctype mapping */
15307 
15308 /* Common result structure for show port pctype mapping */
15309 struct cmd_pctype_mapping_get_result {
15310 	cmdline_fixed_string_t show;
15311 	cmdline_fixed_string_t port;
15312 	portid_t port_id;
15313 	cmdline_fixed_string_t pctype;
15314 	cmdline_fixed_string_t mapping;
15315 };
15316 
15317 /* Common CLI fields for pctype mapping get */
15318 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15319 	TOKEN_STRING_INITIALIZER
15320 		(struct cmd_pctype_mapping_get_result,
15321 		 show, "show");
15322 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15323 	TOKEN_STRING_INITIALIZER
15324 		(struct cmd_pctype_mapping_get_result,
15325 		 port, "port");
15326 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15327 	TOKEN_NUM_INITIALIZER
15328 		(struct cmd_pctype_mapping_get_result,
15329 		 port_id, RTE_UINT16);
15330 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15331 	TOKEN_STRING_INITIALIZER
15332 		(struct cmd_pctype_mapping_get_result,
15333 		 pctype, "pctype");
15334 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15335 	TOKEN_STRING_INITIALIZER
15336 		(struct cmd_pctype_mapping_get_result,
15337 		 mapping, "mapping");
15338 
15339 static void
15340 cmd_pctype_mapping_get_parsed(
15341 	void *parsed_result,
15342 	__rte_unused struct cmdline *cl,
15343 	__rte_unused void *data)
15344 {
15345 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15346 	int ret = -ENOTSUP;
15347 #ifdef RTE_NET_I40E
15348 	struct rte_pmd_i40e_flow_type_mapping
15349 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15350 	int i, j, first_pctype;
15351 #endif
15352 
15353 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15354 		return;
15355 
15356 #ifdef RTE_NET_I40E
15357 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15358 #endif
15359 
15360 	switch (ret) {
15361 	case 0:
15362 		break;
15363 	case -ENODEV:
15364 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15365 		return;
15366 	case -ENOTSUP:
15367 		fprintf(stderr, "function not implemented\n");
15368 		return;
15369 	default:
15370 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15371 		return;
15372 	}
15373 
15374 #ifdef RTE_NET_I40E
15375 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15376 		if (mapping[i].pctype != 0ULL) {
15377 			first_pctype = 1;
15378 
15379 			printf("pctype: ");
15380 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15381 				if (mapping[i].pctype & (1ULL << j)) {
15382 					printf(first_pctype ?
15383 					       "%02d" : ",%02d", j);
15384 					first_pctype = 0;
15385 				}
15386 			}
15387 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15388 		}
15389 	}
15390 #endif
15391 }
15392 
15393 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15394 	.f = cmd_pctype_mapping_get_parsed,
15395 	.data = NULL,
15396 	.help_str = "show port <port_id> pctype mapping",
15397 	.tokens = {
15398 		(void *)&cmd_pctype_mapping_get_show,
15399 		(void *)&cmd_pctype_mapping_get_port,
15400 		(void *)&cmd_pctype_mapping_get_port_id,
15401 		(void *)&cmd_pctype_mapping_get_pctype,
15402 		(void *)&cmd_pctype_mapping_get_mapping,
15403 		NULL,
15404 	},
15405 };
15406 
15407 /* port config pctype mapping update */
15408 
15409 /* Common result structure for port config pctype mapping update */
15410 struct cmd_pctype_mapping_update_result {
15411 	cmdline_fixed_string_t port;
15412 	cmdline_fixed_string_t config;
15413 	portid_t port_id;
15414 	cmdline_fixed_string_t pctype;
15415 	cmdline_fixed_string_t mapping;
15416 	cmdline_fixed_string_t update;
15417 	cmdline_fixed_string_t pctype_list;
15418 	uint16_t flow_type;
15419 };
15420 
15421 /* Common CLI fields for pctype mapping update*/
15422 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15423 	TOKEN_STRING_INITIALIZER
15424 		(struct cmd_pctype_mapping_update_result,
15425 		 port, "port");
15426 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15427 	TOKEN_STRING_INITIALIZER
15428 		(struct cmd_pctype_mapping_update_result,
15429 		 config, "config");
15430 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15431 	TOKEN_NUM_INITIALIZER
15432 		(struct cmd_pctype_mapping_update_result,
15433 		 port_id, RTE_UINT16);
15434 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15435 	TOKEN_STRING_INITIALIZER
15436 		(struct cmd_pctype_mapping_update_result,
15437 		 pctype, "pctype");
15438 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15439 	TOKEN_STRING_INITIALIZER
15440 		(struct cmd_pctype_mapping_update_result,
15441 		 mapping, "mapping");
15442 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15443 	TOKEN_STRING_INITIALIZER
15444 		(struct cmd_pctype_mapping_update_result,
15445 		 update, "update");
15446 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15447 	TOKEN_STRING_INITIALIZER
15448 		(struct cmd_pctype_mapping_update_result,
15449 		 pctype_list, NULL);
15450 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15451 	TOKEN_NUM_INITIALIZER
15452 		(struct cmd_pctype_mapping_update_result,
15453 		 flow_type, RTE_UINT16);
15454 
15455 static void
15456 cmd_pctype_mapping_update_parsed(
15457 	void *parsed_result,
15458 	__rte_unused struct cmdline *cl,
15459 	__rte_unused void *data)
15460 {
15461 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15462 	int ret = -ENOTSUP;
15463 #ifdef RTE_NET_I40E
15464 	struct rte_pmd_i40e_flow_type_mapping mapping;
15465 	unsigned int i;
15466 	unsigned int nb_item;
15467 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15468 #endif
15469 
15470 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15471 		return;
15472 
15473 #ifdef RTE_NET_I40E
15474 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15475 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15476 	mapping.flow_type = res->flow_type;
15477 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15478 		mapping.pctype |= (1ULL << pctype_list[i]);
15479 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15480 						&mapping,
15481 						1,
15482 						0);
15483 #endif
15484 
15485 	switch (ret) {
15486 	case 0:
15487 		break;
15488 	case -EINVAL:
15489 		fprintf(stderr, "invalid pctype or flow type\n");
15490 		break;
15491 	case -ENODEV:
15492 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15493 		break;
15494 	case -ENOTSUP:
15495 		fprintf(stderr, "function not implemented\n");
15496 		break;
15497 	default:
15498 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15499 	}
15500 }
15501 
15502 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15503 	.f = cmd_pctype_mapping_update_parsed,
15504 	.data = NULL,
15505 	.help_str = "port config <port_id> pctype mapping update"
15506 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15507 	.tokens = {
15508 		(void *)&cmd_pctype_mapping_update_port,
15509 		(void *)&cmd_pctype_mapping_update_config,
15510 		(void *)&cmd_pctype_mapping_update_port_id,
15511 		(void *)&cmd_pctype_mapping_update_pctype,
15512 		(void *)&cmd_pctype_mapping_update_mapping,
15513 		(void *)&cmd_pctype_mapping_update_update,
15514 		(void *)&cmd_pctype_mapping_update_pc_type,
15515 		(void *)&cmd_pctype_mapping_update_flow_type,
15516 		NULL,
15517 	},
15518 };
15519 
15520 /* ptype mapping get */
15521 
15522 /* Common result structure for ptype mapping get */
15523 struct cmd_ptype_mapping_get_result {
15524 	cmdline_fixed_string_t ptype;
15525 	cmdline_fixed_string_t mapping;
15526 	cmdline_fixed_string_t get;
15527 	portid_t port_id;
15528 	uint8_t valid_only;
15529 };
15530 
15531 /* Common CLI fields for ptype mapping get */
15532 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15533 	TOKEN_STRING_INITIALIZER
15534 		(struct cmd_ptype_mapping_get_result,
15535 		 ptype, "ptype");
15536 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15537 	TOKEN_STRING_INITIALIZER
15538 		(struct cmd_ptype_mapping_get_result,
15539 		 mapping, "mapping");
15540 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15541 	TOKEN_STRING_INITIALIZER
15542 		(struct cmd_ptype_mapping_get_result,
15543 		 get, "get");
15544 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15545 	TOKEN_NUM_INITIALIZER
15546 		(struct cmd_ptype_mapping_get_result,
15547 		 port_id, RTE_UINT16);
15548 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15549 	TOKEN_NUM_INITIALIZER
15550 		(struct cmd_ptype_mapping_get_result,
15551 		 valid_only, RTE_UINT8);
15552 
15553 static void
15554 cmd_ptype_mapping_get_parsed(
15555 	void *parsed_result,
15556 	__rte_unused struct cmdline *cl,
15557 	__rte_unused void *data)
15558 {
15559 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15560 	int ret = -ENOTSUP;
15561 #ifdef RTE_NET_I40E
15562 	int max_ptype_num = 256;
15563 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15564 	uint16_t count;
15565 	int i;
15566 #endif
15567 
15568 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15569 		return;
15570 
15571 #ifdef RTE_NET_I40E
15572 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15573 					mapping,
15574 					max_ptype_num,
15575 					&count,
15576 					res->valid_only);
15577 #endif
15578 
15579 	switch (ret) {
15580 	case 0:
15581 		break;
15582 	case -ENODEV:
15583 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15584 		break;
15585 	case -ENOTSUP:
15586 		fprintf(stderr, "function not implemented\n");
15587 		break;
15588 	default:
15589 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15590 	}
15591 
15592 #ifdef RTE_NET_I40E
15593 	if (!ret) {
15594 		for (i = 0; i < count; i++)
15595 			printf("%3d\t0x%08x\n",
15596 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15597 	}
15598 #endif
15599 }
15600 
15601 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15602 	.f = cmd_ptype_mapping_get_parsed,
15603 	.data = NULL,
15604 	.help_str = "ptype mapping get <port_id> <valid_only>",
15605 	.tokens = {
15606 		(void *)&cmd_ptype_mapping_get_ptype,
15607 		(void *)&cmd_ptype_mapping_get_mapping,
15608 		(void *)&cmd_ptype_mapping_get_get,
15609 		(void *)&cmd_ptype_mapping_get_port_id,
15610 		(void *)&cmd_ptype_mapping_get_valid_only,
15611 		NULL,
15612 	},
15613 };
15614 
15615 /* ptype mapping replace */
15616 
15617 /* Common result structure for ptype mapping replace */
15618 struct cmd_ptype_mapping_replace_result {
15619 	cmdline_fixed_string_t ptype;
15620 	cmdline_fixed_string_t mapping;
15621 	cmdline_fixed_string_t replace;
15622 	portid_t port_id;
15623 	uint32_t target;
15624 	uint8_t mask;
15625 	uint32_t pkt_type;
15626 };
15627 
15628 /* Common CLI fields for ptype mapping replace */
15629 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15630 	TOKEN_STRING_INITIALIZER
15631 		(struct cmd_ptype_mapping_replace_result,
15632 		 ptype, "ptype");
15633 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15634 	TOKEN_STRING_INITIALIZER
15635 		(struct cmd_ptype_mapping_replace_result,
15636 		 mapping, "mapping");
15637 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15638 	TOKEN_STRING_INITIALIZER
15639 		(struct cmd_ptype_mapping_replace_result,
15640 		 replace, "replace");
15641 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15642 	TOKEN_NUM_INITIALIZER
15643 		(struct cmd_ptype_mapping_replace_result,
15644 		 port_id, RTE_UINT16);
15645 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15646 	TOKEN_NUM_INITIALIZER
15647 		(struct cmd_ptype_mapping_replace_result,
15648 		 target, RTE_UINT32);
15649 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15650 	TOKEN_NUM_INITIALIZER
15651 		(struct cmd_ptype_mapping_replace_result,
15652 		 mask, RTE_UINT8);
15653 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15654 	TOKEN_NUM_INITIALIZER
15655 		(struct cmd_ptype_mapping_replace_result,
15656 		 pkt_type, RTE_UINT32);
15657 
15658 static void
15659 cmd_ptype_mapping_replace_parsed(
15660 	void *parsed_result,
15661 	__rte_unused struct cmdline *cl,
15662 	__rte_unused void *data)
15663 {
15664 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15665 	int ret = -ENOTSUP;
15666 
15667 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15668 		return;
15669 
15670 #ifdef RTE_NET_I40E
15671 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15672 					res->target,
15673 					res->mask,
15674 					res->pkt_type);
15675 #endif
15676 
15677 	switch (ret) {
15678 	case 0:
15679 		break;
15680 	case -EINVAL:
15681 		fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15682 			res->target, res->pkt_type);
15683 		break;
15684 	case -ENODEV:
15685 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15686 		break;
15687 	case -ENOTSUP:
15688 		fprintf(stderr, "function not implemented\n");
15689 		break;
15690 	default:
15691 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15692 	}
15693 }
15694 
15695 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15696 	.f = cmd_ptype_mapping_replace_parsed,
15697 	.data = NULL,
15698 	.help_str =
15699 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15700 	.tokens = {
15701 		(void *)&cmd_ptype_mapping_replace_ptype,
15702 		(void *)&cmd_ptype_mapping_replace_mapping,
15703 		(void *)&cmd_ptype_mapping_replace_replace,
15704 		(void *)&cmd_ptype_mapping_replace_port_id,
15705 		(void *)&cmd_ptype_mapping_replace_target,
15706 		(void *)&cmd_ptype_mapping_replace_mask,
15707 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15708 		NULL,
15709 	},
15710 };
15711 
15712 /* ptype mapping reset */
15713 
15714 /* Common result structure for ptype mapping reset */
15715 struct cmd_ptype_mapping_reset_result {
15716 	cmdline_fixed_string_t ptype;
15717 	cmdline_fixed_string_t mapping;
15718 	cmdline_fixed_string_t reset;
15719 	portid_t port_id;
15720 };
15721 
15722 /* Common CLI fields for ptype mapping reset*/
15723 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15724 	TOKEN_STRING_INITIALIZER
15725 		(struct cmd_ptype_mapping_reset_result,
15726 		 ptype, "ptype");
15727 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15728 	TOKEN_STRING_INITIALIZER
15729 		(struct cmd_ptype_mapping_reset_result,
15730 		 mapping, "mapping");
15731 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15732 	TOKEN_STRING_INITIALIZER
15733 		(struct cmd_ptype_mapping_reset_result,
15734 		 reset, "reset");
15735 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15736 	TOKEN_NUM_INITIALIZER
15737 		(struct cmd_ptype_mapping_reset_result,
15738 		 port_id, RTE_UINT16);
15739 
15740 static void
15741 cmd_ptype_mapping_reset_parsed(
15742 	void *parsed_result,
15743 	__rte_unused struct cmdline *cl,
15744 	__rte_unused void *data)
15745 {
15746 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15747 	int ret = -ENOTSUP;
15748 
15749 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15750 		return;
15751 
15752 #ifdef RTE_NET_I40E
15753 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15754 #endif
15755 
15756 	switch (ret) {
15757 	case 0:
15758 		break;
15759 	case -ENODEV:
15760 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15761 		break;
15762 	case -ENOTSUP:
15763 		fprintf(stderr, "function not implemented\n");
15764 		break;
15765 	default:
15766 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15767 	}
15768 }
15769 
15770 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15771 	.f = cmd_ptype_mapping_reset_parsed,
15772 	.data = NULL,
15773 	.help_str = "ptype mapping reset <port_id>",
15774 	.tokens = {
15775 		(void *)&cmd_ptype_mapping_reset_ptype,
15776 		(void *)&cmd_ptype_mapping_reset_mapping,
15777 		(void *)&cmd_ptype_mapping_reset_reset,
15778 		(void *)&cmd_ptype_mapping_reset_port_id,
15779 		NULL,
15780 	},
15781 };
15782 
15783 /* ptype mapping update */
15784 
15785 /* Common result structure for ptype mapping update */
15786 struct cmd_ptype_mapping_update_result {
15787 	cmdline_fixed_string_t ptype;
15788 	cmdline_fixed_string_t mapping;
15789 	cmdline_fixed_string_t reset;
15790 	portid_t port_id;
15791 	uint8_t hw_ptype;
15792 	uint32_t sw_ptype;
15793 };
15794 
15795 /* Common CLI fields for ptype mapping update*/
15796 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15797 	TOKEN_STRING_INITIALIZER
15798 		(struct cmd_ptype_mapping_update_result,
15799 		 ptype, "ptype");
15800 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15801 	TOKEN_STRING_INITIALIZER
15802 		(struct cmd_ptype_mapping_update_result,
15803 		 mapping, "mapping");
15804 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15805 	TOKEN_STRING_INITIALIZER
15806 		(struct cmd_ptype_mapping_update_result,
15807 		 reset, "update");
15808 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15809 	TOKEN_NUM_INITIALIZER
15810 		(struct cmd_ptype_mapping_update_result,
15811 		 port_id, RTE_UINT16);
15812 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15813 	TOKEN_NUM_INITIALIZER
15814 		(struct cmd_ptype_mapping_update_result,
15815 		 hw_ptype, RTE_UINT8);
15816 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15817 	TOKEN_NUM_INITIALIZER
15818 		(struct cmd_ptype_mapping_update_result,
15819 		 sw_ptype, RTE_UINT32);
15820 
15821 static void
15822 cmd_ptype_mapping_update_parsed(
15823 	void *parsed_result,
15824 	__rte_unused struct cmdline *cl,
15825 	__rte_unused void *data)
15826 {
15827 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15828 	int ret = -ENOTSUP;
15829 #ifdef RTE_NET_I40E
15830 	struct rte_pmd_i40e_ptype_mapping mapping;
15831 #endif
15832 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15833 		return;
15834 
15835 #ifdef RTE_NET_I40E
15836 	mapping.hw_ptype = res->hw_ptype;
15837 	mapping.sw_ptype = res->sw_ptype;
15838 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15839 						&mapping,
15840 						1,
15841 						0);
15842 #endif
15843 
15844 	switch (ret) {
15845 	case 0:
15846 		break;
15847 	case -EINVAL:
15848 		fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15849 		break;
15850 	case -ENODEV:
15851 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15852 		break;
15853 	case -ENOTSUP:
15854 		fprintf(stderr, "function not implemented\n");
15855 		break;
15856 	default:
15857 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15858 	}
15859 }
15860 
15861 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15862 	.f = cmd_ptype_mapping_update_parsed,
15863 	.data = NULL,
15864 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15865 	.tokens = {
15866 		(void *)&cmd_ptype_mapping_update_ptype,
15867 		(void *)&cmd_ptype_mapping_update_mapping,
15868 		(void *)&cmd_ptype_mapping_update_update,
15869 		(void *)&cmd_ptype_mapping_update_port_id,
15870 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15871 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15872 		NULL,
15873 	},
15874 };
15875 
15876 /* Common result structure for file commands */
15877 struct cmd_cmdfile_result {
15878 	cmdline_fixed_string_t load;
15879 	cmdline_fixed_string_t filename;
15880 };
15881 
15882 /* Common CLI fields for file commands */
15883 cmdline_parse_token_string_t cmd_load_cmdfile =
15884 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15885 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15886 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15887 
15888 static void
15889 cmd_load_from_file_parsed(
15890 	void *parsed_result,
15891 	__rte_unused struct cmdline *cl,
15892 	__rte_unused void *data)
15893 {
15894 	struct cmd_cmdfile_result *res = parsed_result;
15895 
15896 	cmdline_read_from_file(res->filename);
15897 }
15898 
15899 cmdline_parse_inst_t cmd_load_from_file = {
15900 	.f = cmd_load_from_file_parsed,
15901 	.data = NULL,
15902 	.help_str = "load <filename>",
15903 	.tokens = {
15904 		(void *)&cmd_load_cmdfile,
15905 		(void *)&cmd_load_cmdfile_filename,
15906 		NULL,
15907 	},
15908 };
15909 
15910 /* Get Rx offloads capabilities */
15911 struct cmd_rx_offload_get_capa_result {
15912 	cmdline_fixed_string_t show;
15913 	cmdline_fixed_string_t port;
15914 	portid_t port_id;
15915 	cmdline_fixed_string_t rx_offload;
15916 	cmdline_fixed_string_t capabilities;
15917 };
15918 
15919 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15920 	TOKEN_STRING_INITIALIZER
15921 		(struct cmd_rx_offload_get_capa_result,
15922 		 show, "show");
15923 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15924 	TOKEN_STRING_INITIALIZER
15925 		(struct cmd_rx_offload_get_capa_result,
15926 		 port, "port");
15927 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15928 	TOKEN_NUM_INITIALIZER
15929 		(struct cmd_rx_offload_get_capa_result,
15930 		 port_id, RTE_UINT16);
15931 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15932 	TOKEN_STRING_INITIALIZER
15933 		(struct cmd_rx_offload_get_capa_result,
15934 		 rx_offload, "rx_offload");
15935 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15936 	TOKEN_STRING_INITIALIZER
15937 		(struct cmd_rx_offload_get_capa_result,
15938 		 capabilities, "capabilities");
15939 
15940 static void
15941 print_rx_offloads(uint64_t offloads)
15942 {
15943 	uint64_t single_offload;
15944 	int begin;
15945 	int end;
15946 	int bit;
15947 
15948 	if (offloads == 0)
15949 		return;
15950 
15951 	begin = __builtin_ctzll(offloads);
15952 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15953 
15954 	single_offload = 1ULL << begin;
15955 	for (bit = begin; bit < end; bit++) {
15956 		if (offloads & single_offload)
15957 			printf(" %s",
15958 			       rte_eth_dev_rx_offload_name(single_offload));
15959 		single_offload <<= 1;
15960 	}
15961 }
15962 
15963 static void
15964 cmd_rx_offload_get_capa_parsed(
15965 	void *parsed_result,
15966 	__rte_unused struct cmdline *cl,
15967 	__rte_unused void *data)
15968 {
15969 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
15970 	struct rte_eth_dev_info dev_info;
15971 	portid_t port_id = res->port_id;
15972 	uint64_t queue_offloads;
15973 	uint64_t port_offloads;
15974 	int ret;
15975 
15976 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15977 	if (ret != 0)
15978 		return;
15979 
15980 	queue_offloads = dev_info.rx_queue_offload_capa;
15981 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15982 
15983 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
15984 	printf("  Per Queue :");
15985 	print_rx_offloads(queue_offloads);
15986 
15987 	printf("\n");
15988 	printf("  Per Port  :");
15989 	print_rx_offloads(port_offloads);
15990 	printf("\n\n");
15991 }
15992 
15993 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15994 	.f = cmd_rx_offload_get_capa_parsed,
15995 	.data = NULL,
15996 	.help_str = "show port <port_id> rx_offload capabilities",
15997 	.tokens = {
15998 		(void *)&cmd_rx_offload_get_capa_show,
15999 		(void *)&cmd_rx_offload_get_capa_port,
16000 		(void *)&cmd_rx_offload_get_capa_port_id,
16001 		(void *)&cmd_rx_offload_get_capa_rx_offload,
16002 		(void *)&cmd_rx_offload_get_capa_capabilities,
16003 		NULL,
16004 	}
16005 };
16006 
16007 /* Get Rx offloads configuration */
16008 struct cmd_rx_offload_get_configuration_result {
16009 	cmdline_fixed_string_t show;
16010 	cmdline_fixed_string_t port;
16011 	portid_t port_id;
16012 	cmdline_fixed_string_t rx_offload;
16013 	cmdline_fixed_string_t configuration;
16014 };
16015 
16016 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16017 	TOKEN_STRING_INITIALIZER
16018 		(struct cmd_rx_offload_get_configuration_result,
16019 		 show, "show");
16020 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16021 	TOKEN_STRING_INITIALIZER
16022 		(struct cmd_rx_offload_get_configuration_result,
16023 		 port, "port");
16024 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16025 	TOKEN_NUM_INITIALIZER
16026 		(struct cmd_rx_offload_get_configuration_result,
16027 		 port_id, RTE_UINT16);
16028 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16029 	TOKEN_STRING_INITIALIZER
16030 		(struct cmd_rx_offload_get_configuration_result,
16031 		 rx_offload, "rx_offload");
16032 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16033 	TOKEN_STRING_INITIALIZER
16034 		(struct cmd_rx_offload_get_configuration_result,
16035 		 configuration, "configuration");
16036 
16037 static void
16038 cmd_rx_offload_get_configuration_parsed(
16039 	void *parsed_result,
16040 	__rte_unused struct cmdline *cl,
16041 	__rte_unused void *data)
16042 {
16043 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16044 	struct rte_eth_dev_info dev_info;
16045 	portid_t port_id = res->port_id;
16046 	struct rte_port *port = &ports[port_id];
16047 	struct rte_eth_conf dev_conf;
16048 	uint64_t port_offloads;
16049 	uint64_t queue_offloads;
16050 	uint16_t nb_rx_queues;
16051 	int q;
16052 	int ret;
16053 
16054 	printf("Rx Offloading Configuration of port %d :\n", port_id);
16055 
16056 	ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16057 	if (ret != 0)
16058 		return;
16059 
16060 	port_offloads = dev_conf.rxmode.offloads;
16061 	printf("  Port :");
16062 	print_rx_offloads(port_offloads);
16063 	printf("\n");
16064 
16065 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16066 	if (ret != 0)
16067 		return;
16068 
16069 	nb_rx_queues = dev_info.nb_rx_queues;
16070 	for (q = 0; q < nb_rx_queues; q++) {
16071 		queue_offloads = port->rx_conf[q].offloads;
16072 		printf("  Queue[%2d] :", q);
16073 		print_rx_offloads(queue_offloads);
16074 		printf("\n");
16075 	}
16076 	printf("\n");
16077 }
16078 
16079 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16080 	.f = cmd_rx_offload_get_configuration_parsed,
16081 	.data = NULL,
16082 	.help_str = "show port <port_id> rx_offload configuration",
16083 	.tokens = {
16084 		(void *)&cmd_rx_offload_get_configuration_show,
16085 		(void *)&cmd_rx_offload_get_configuration_port,
16086 		(void *)&cmd_rx_offload_get_configuration_port_id,
16087 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
16088 		(void *)&cmd_rx_offload_get_configuration_configuration,
16089 		NULL,
16090 	}
16091 };
16092 
16093 /* Enable/Disable a per port offloading */
16094 struct cmd_config_per_port_rx_offload_result {
16095 	cmdline_fixed_string_t port;
16096 	cmdline_fixed_string_t config;
16097 	portid_t port_id;
16098 	cmdline_fixed_string_t rx_offload;
16099 	cmdline_fixed_string_t offload;
16100 	cmdline_fixed_string_t on_off;
16101 };
16102 
16103 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16104 	TOKEN_STRING_INITIALIZER
16105 		(struct cmd_config_per_port_rx_offload_result,
16106 		 port, "port");
16107 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16108 	TOKEN_STRING_INITIALIZER
16109 		(struct cmd_config_per_port_rx_offload_result,
16110 		 config, "config");
16111 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16112 	TOKEN_NUM_INITIALIZER
16113 		(struct cmd_config_per_port_rx_offload_result,
16114 		 port_id, RTE_UINT16);
16115 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16116 	TOKEN_STRING_INITIALIZER
16117 		(struct cmd_config_per_port_rx_offload_result,
16118 		 rx_offload, "rx_offload");
16119 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16120 	TOKEN_STRING_INITIALIZER
16121 		(struct cmd_config_per_port_rx_offload_result,
16122 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16123 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16124 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16125 			   "scatter#buffer_split#timestamp#security#"
16126 			   "keep_crc#rss_hash");
16127 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16128 	TOKEN_STRING_INITIALIZER
16129 		(struct cmd_config_per_port_rx_offload_result,
16130 		 on_off, "on#off");
16131 
16132 static uint64_t
16133 search_rx_offload(const char *name)
16134 {
16135 	uint64_t single_offload;
16136 	const char *single_name;
16137 	int found = 0;
16138 	unsigned int bit;
16139 
16140 	single_offload = 1;
16141 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16142 		single_name = rte_eth_dev_rx_offload_name(single_offload);
16143 		if (!strcasecmp(single_name, name)) {
16144 			found = 1;
16145 			break;
16146 		}
16147 		single_offload <<= 1;
16148 	}
16149 
16150 	if (found)
16151 		return single_offload;
16152 
16153 	return 0;
16154 }
16155 
16156 static void
16157 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16158 				__rte_unused struct cmdline *cl,
16159 				__rte_unused void *data)
16160 {
16161 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16162 	portid_t port_id = res->port_id;
16163 	struct rte_eth_dev_info dev_info;
16164 	struct rte_port *port = &ports[port_id];
16165 	uint64_t single_offload;
16166 	uint16_t nb_rx_queues;
16167 	int q;
16168 	int ret;
16169 
16170 	if (port->port_status != RTE_PORT_STOPPED) {
16171 		fprintf(stderr,
16172 			"Error: Can't config offload when Port %d is not stopped\n",
16173 			port_id);
16174 		return;
16175 	}
16176 
16177 	single_offload = search_rx_offload(res->offload);
16178 	if (single_offload == 0) {
16179 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16180 		return;
16181 	}
16182 
16183 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16184 	if (ret != 0)
16185 		return;
16186 
16187 	nb_rx_queues = dev_info.nb_rx_queues;
16188 	if (!strcmp(res->on_off, "on")) {
16189 		port->dev_conf.rxmode.offloads |= single_offload;
16190 		for (q = 0; q < nb_rx_queues; q++)
16191 			port->rx_conf[q].offloads |= single_offload;
16192 	} else {
16193 		port->dev_conf.rxmode.offloads &= ~single_offload;
16194 		for (q = 0; q < nb_rx_queues; q++)
16195 			port->rx_conf[q].offloads &= ~single_offload;
16196 	}
16197 
16198 	cmd_reconfig_device_queue(port_id, 1, 1);
16199 }
16200 
16201 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16202 	.f = cmd_config_per_port_rx_offload_parsed,
16203 	.data = NULL,
16204 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16205 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16206 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16207 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16208 		    "keep_crc|rss_hash on|off",
16209 	.tokens = {
16210 		(void *)&cmd_config_per_port_rx_offload_result_port,
16211 		(void *)&cmd_config_per_port_rx_offload_result_config,
16212 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
16213 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16214 		(void *)&cmd_config_per_port_rx_offload_result_offload,
16215 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
16216 		NULL,
16217 	}
16218 };
16219 
16220 /* Enable/Disable a per queue offloading */
16221 struct cmd_config_per_queue_rx_offload_result {
16222 	cmdline_fixed_string_t port;
16223 	portid_t port_id;
16224 	cmdline_fixed_string_t rxq;
16225 	uint16_t queue_id;
16226 	cmdline_fixed_string_t rx_offload;
16227 	cmdline_fixed_string_t offload;
16228 	cmdline_fixed_string_t on_off;
16229 };
16230 
16231 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16232 	TOKEN_STRING_INITIALIZER
16233 		(struct cmd_config_per_queue_rx_offload_result,
16234 		 port, "port");
16235 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16236 	TOKEN_NUM_INITIALIZER
16237 		(struct cmd_config_per_queue_rx_offload_result,
16238 		 port_id, RTE_UINT16);
16239 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16240 	TOKEN_STRING_INITIALIZER
16241 		(struct cmd_config_per_queue_rx_offload_result,
16242 		 rxq, "rxq");
16243 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16244 	TOKEN_NUM_INITIALIZER
16245 		(struct cmd_config_per_queue_rx_offload_result,
16246 		 queue_id, RTE_UINT16);
16247 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16248 	TOKEN_STRING_INITIALIZER
16249 		(struct cmd_config_per_queue_rx_offload_result,
16250 		 rx_offload, "rx_offload");
16251 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16252 	TOKEN_STRING_INITIALIZER
16253 		(struct cmd_config_per_queue_rx_offload_result,
16254 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16255 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16256 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16257 			   "scatter#buffer_split#timestamp#security#keep_crc");
16258 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16259 	TOKEN_STRING_INITIALIZER
16260 		(struct cmd_config_per_queue_rx_offload_result,
16261 		 on_off, "on#off");
16262 
16263 static void
16264 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16265 				__rte_unused struct cmdline *cl,
16266 				__rte_unused void *data)
16267 {
16268 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16269 	struct rte_eth_dev_info dev_info;
16270 	portid_t port_id = res->port_id;
16271 	uint16_t queue_id = res->queue_id;
16272 	struct rte_port *port = &ports[port_id];
16273 	uint64_t single_offload;
16274 	int ret;
16275 
16276 	if (port->port_status != RTE_PORT_STOPPED) {
16277 		fprintf(stderr,
16278 			"Error: Can't config offload when Port %d is not stopped\n",
16279 			port_id);
16280 		return;
16281 	}
16282 
16283 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16284 	if (ret != 0)
16285 		return;
16286 
16287 	if (queue_id >= dev_info.nb_rx_queues) {
16288 		fprintf(stderr,
16289 			"Error: input queue_id should be 0 ... %d\n",
16290 			dev_info.nb_rx_queues - 1);
16291 		return;
16292 	}
16293 
16294 	single_offload = search_rx_offload(res->offload);
16295 	if (single_offload == 0) {
16296 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16297 		return;
16298 	}
16299 
16300 	if (!strcmp(res->on_off, "on"))
16301 		port->rx_conf[queue_id].offloads |= single_offload;
16302 	else
16303 		port->rx_conf[queue_id].offloads &= ~single_offload;
16304 
16305 	cmd_reconfig_device_queue(port_id, 1, 1);
16306 }
16307 
16308 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16309 	.f = cmd_config_per_queue_rx_offload_parsed,
16310 	.data = NULL,
16311 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
16312 		    "vlan_strip|ipv4_cksum|"
16313 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16314 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16315 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16316 		    "keep_crc on|off",
16317 	.tokens = {
16318 		(void *)&cmd_config_per_queue_rx_offload_result_port,
16319 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
16320 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
16321 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16322 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16323 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
16324 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
16325 		NULL,
16326 	}
16327 };
16328 
16329 /* Get Tx offloads capabilities */
16330 struct cmd_tx_offload_get_capa_result {
16331 	cmdline_fixed_string_t show;
16332 	cmdline_fixed_string_t port;
16333 	portid_t port_id;
16334 	cmdline_fixed_string_t tx_offload;
16335 	cmdline_fixed_string_t capabilities;
16336 };
16337 
16338 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16339 	TOKEN_STRING_INITIALIZER
16340 		(struct cmd_tx_offload_get_capa_result,
16341 		 show, "show");
16342 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16343 	TOKEN_STRING_INITIALIZER
16344 		(struct cmd_tx_offload_get_capa_result,
16345 		 port, "port");
16346 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16347 	TOKEN_NUM_INITIALIZER
16348 		(struct cmd_tx_offload_get_capa_result,
16349 		 port_id, RTE_UINT16);
16350 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16351 	TOKEN_STRING_INITIALIZER
16352 		(struct cmd_tx_offload_get_capa_result,
16353 		 tx_offload, "tx_offload");
16354 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16355 	TOKEN_STRING_INITIALIZER
16356 		(struct cmd_tx_offload_get_capa_result,
16357 		 capabilities, "capabilities");
16358 
16359 static void
16360 print_tx_offloads(uint64_t offloads)
16361 {
16362 	uint64_t single_offload;
16363 	int begin;
16364 	int end;
16365 	int bit;
16366 
16367 	if (offloads == 0)
16368 		return;
16369 
16370 	begin = __builtin_ctzll(offloads);
16371 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16372 
16373 	single_offload = 1ULL << begin;
16374 	for (bit = begin; bit < end; bit++) {
16375 		if (offloads & single_offload)
16376 			printf(" %s",
16377 			       rte_eth_dev_tx_offload_name(single_offload));
16378 		single_offload <<= 1;
16379 	}
16380 }
16381 
16382 static void
16383 cmd_tx_offload_get_capa_parsed(
16384 	void *parsed_result,
16385 	__rte_unused struct cmdline *cl,
16386 	__rte_unused void *data)
16387 {
16388 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
16389 	struct rte_eth_dev_info dev_info;
16390 	portid_t port_id = res->port_id;
16391 	uint64_t queue_offloads;
16392 	uint64_t port_offloads;
16393 	int ret;
16394 
16395 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16396 	if (ret != 0)
16397 		return;
16398 
16399 	queue_offloads = dev_info.tx_queue_offload_capa;
16400 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16401 
16402 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
16403 	printf("  Per Queue :");
16404 	print_tx_offloads(queue_offloads);
16405 
16406 	printf("\n");
16407 	printf("  Per Port  :");
16408 	print_tx_offloads(port_offloads);
16409 	printf("\n\n");
16410 }
16411 
16412 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16413 	.f = cmd_tx_offload_get_capa_parsed,
16414 	.data = NULL,
16415 	.help_str = "show port <port_id> tx_offload capabilities",
16416 	.tokens = {
16417 		(void *)&cmd_tx_offload_get_capa_show,
16418 		(void *)&cmd_tx_offload_get_capa_port,
16419 		(void *)&cmd_tx_offload_get_capa_port_id,
16420 		(void *)&cmd_tx_offload_get_capa_tx_offload,
16421 		(void *)&cmd_tx_offload_get_capa_capabilities,
16422 		NULL,
16423 	}
16424 };
16425 
16426 /* Get Tx offloads configuration */
16427 struct cmd_tx_offload_get_configuration_result {
16428 	cmdline_fixed_string_t show;
16429 	cmdline_fixed_string_t port;
16430 	portid_t port_id;
16431 	cmdline_fixed_string_t tx_offload;
16432 	cmdline_fixed_string_t configuration;
16433 };
16434 
16435 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16436 	TOKEN_STRING_INITIALIZER
16437 		(struct cmd_tx_offload_get_configuration_result,
16438 		 show, "show");
16439 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16440 	TOKEN_STRING_INITIALIZER
16441 		(struct cmd_tx_offload_get_configuration_result,
16442 		 port, "port");
16443 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16444 	TOKEN_NUM_INITIALIZER
16445 		(struct cmd_tx_offload_get_configuration_result,
16446 		 port_id, RTE_UINT16);
16447 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16448 	TOKEN_STRING_INITIALIZER
16449 		(struct cmd_tx_offload_get_configuration_result,
16450 		 tx_offload, "tx_offload");
16451 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16452 	TOKEN_STRING_INITIALIZER
16453 		(struct cmd_tx_offload_get_configuration_result,
16454 		 configuration, "configuration");
16455 
16456 static void
16457 cmd_tx_offload_get_configuration_parsed(
16458 	void *parsed_result,
16459 	__rte_unused struct cmdline *cl,
16460 	__rte_unused void *data)
16461 {
16462 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16463 	struct rte_eth_dev_info dev_info;
16464 	portid_t port_id = res->port_id;
16465 	struct rte_port *port = &ports[port_id];
16466 	struct rte_eth_conf dev_conf;
16467 	uint64_t port_offloads;
16468 	uint64_t queue_offloads;
16469 	uint16_t nb_tx_queues;
16470 	int q;
16471 	int ret;
16472 
16473 	printf("Tx Offloading Configuration of port %d :\n", port_id);
16474 
16475 	ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16476 	if (ret != 0)
16477 		return;
16478 
16479 	port_offloads = dev_conf.txmode.offloads;
16480 	printf("  Port :");
16481 	print_tx_offloads(port_offloads);
16482 	printf("\n");
16483 
16484 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16485 	if (ret != 0)
16486 		return;
16487 
16488 	nb_tx_queues = dev_info.nb_tx_queues;
16489 	for (q = 0; q < nb_tx_queues; q++) {
16490 		queue_offloads = port->tx_conf[q].offloads;
16491 		printf("  Queue[%2d] :", q);
16492 		print_tx_offloads(queue_offloads);
16493 		printf("\n");
16494 	}
16495 	printf("\n");
16496 }
16497 
16498 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16499 	.f = cmd_tx_offload_get_configuration_parsed,
16500 	.data = NULL,
16501 	.help_str = "show port <port_id> tx_offload configuration",
16502 	.tokens = {
16503 		(void *)&cmd_tx_offload_get_configuration_show,
16504 		(void *)&cmd_tx_offload_get_configuration_port,
16505 		(void *)&cmd_tx_offload_get_configuration_port_id,
16506 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
16507 		(void *)&cmd_tx_offload_get_configuration_configuration,
16508 		NULL,
16509 	}
16510 };
16511 
16512 /* Enable/Disable a per port offloading */
16513 struct cmd_config_per_port_tx_offload_result {
16514 	cmdline_fixed_string_t port;
16515 	cmdline_fixed_string_t config;
16516 	portid_t port_id;
16517 	cmdline_fixed_string_t tx_offload;
16518 	cmdline_fixed_string_t offload;
16519 	cmdline_fixed_string_t on_off;
16520 };
16521 
16522 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16523 	TOKEN_STRING_INITIALIZER
16524 		(struct cmd_config_per_port_tx_offload_result,
16525 		 port, "port");
16526 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16527 	TOKEN_STRING_INITIALIZER
16528 		(struct cmd_config_per_port_tx_offload_result,
16529 		 config, "config");
16530 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16531 	TOKEN_NUM_INITIALIZER
16532 		(struct cmd_config_per_port_tx_offload_result,
16533 		 port_id, RTE_UINT16);
16534 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16535 	TOKEN_STRING_INITIALIZER
16536 		(struct cmd_config_per_port_tx_offload_result,
16537 		 tx_offload, "tx_offload");
16538 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16539 	TOKEN_STRING_INITIALIZER
16540 		(struct cmd_config_per_port_tx_offload_result,
16541 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16542 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16543 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16544 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16545 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16546 			  "send_on_timestamp");
16547 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16548 	TOKEN_STRING_INITIALIZER
16549 		(struct cmd_config_per_port_tx_offload_result,
16550 		 on_off, "on#off");
16551 
16552 static uint64_t
16553 search_tx_offload(const char *name)
16554 {
16555 	uint64_t single_offload;
16556 	const char *single_name;
16557 	int found = 0;
16558 	unsigned int bit;
16559 
16560 	single_offload = 1;
16561 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16562 		single_name = rte_eth_dev_tx_offload_name(single_offload);
16563 		if (single_name == NULL)
16564 			break;
16565 		if (!strcasecmp(single_name, name)) {
16566 			found = 1;
16567 			break;
16568 		} else if (!strcasecmp(single_name, "UNKNOWN"))
16569 			break;
16570 		single_offload <<= 1;
16571 	}
16572 
16573 	if (found)
16574 		return single_offload;
16575 
16576 	return 0;
16577 }
16578 
16579 static void
16580 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16581 				__rte_unused struct cmdline *cl,
16582 				__rte_unused void *data)
16583 {
16584 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16585 	portid_t port_id = res->port_id;
16586 	struct rte_eth_dev_info dev_info;
16587 	struct rte_port *port = &ports[port_id];
16588 	uint64_t single_offload;
16589 	uint16_t nb_tx_queues;
16590 	int q;
16591 	int ret;
16592 
16593 	if (port->port_status != RTE_PORT_STOPPED) {
16594 		fprintf(stderr,
16595 			"Error: Can't config offload when Port %d is not stopped\n",
16596 			port_id);
16597 		return;
16598 	}
16599 
16600 	single_offload = search_tx_offload(res->offload);
16601 	if (single_offload == 0) {
16602 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16603 		return;
16604 	}
16605 
16606 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16607 	if (ret != 0)
16608 		return;
16609 
16610 	nb_tx_queues = dev_info.nb_tx_queues;
16611 	if (!strcmp(res->on_off, "on")) {
16612 		port->dev_conf.txmode.offloads |= single_offload;
16613 		for (q = 0; q < nb_tx_queues; q++)
16614 			port->tx_conf[q].offloads |= single_offload;
16615 	} else {
16616 		port->dev_conf.txmode.offloads &= ~single_offload;
16617 		for (q = 0; q < nb_tx_queues; q++)
16618 			port->tx_conf[q].offloads &= ~single_offload;
16619 	}
16620 
16621 	cmd_reconfig_device_queue(port_id, 1, 1);
16622 }
16623 
16624 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16625 	.f = cmd_config_per_port_tx_offload_parsed,
16626 	.data = NULL,
16627 	.help_str = "port config <port_id> tx_offload "
16628 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16629 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16630 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16631 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16632 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16633 		    "send_on_timestamp on|off",
16634 	.tokens = {
16635 		(void *)&cmd_config_per_port_tx_offload_result_port,
16636 		(void *)&cmd_config_per_port_tx_offload_result_config,
16637 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
16638 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16639 		(void *)&cmd_config_per_port_tx_offload_result_offload,
16640 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
16641 		NULL,
16642 	}
16643 };
16644 
16645 /* Enable/Disable a per queue offloading */
16646 struct cmd_config_per_queue_tx_offload_result {
16647 	cmdline_fixed_string_t port;
16648 	portid_t port_id;
16649 	cmdline_fixed_string_t txq;
16650 	uint16_t queue_id;
16651 	cmdline_fixed_string_t tx_offload;
16652 	cmdline_fixed_string_t offload;
16653 	cmdline_fixed_string_t on_off;
16654 };
16655 
16656 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16657 	TOKEN_STRING_INITIALIZER
16658 		(struct cmd_config_per_queue_tx_offload_result,
16659 		 port, "port");
16660 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16661 	TOKEN_NUM_INITIALIZER
16662 		(struct cmd_config_per_queue_tx_offload_result,
16663 		 port_id, RTE_UINT16);
16664 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16665 	TOKEN_STRING_INITIALIZER
16666 		(struct cmd_config_per_queue_tx_offload_result,
16667 		 txq, "txq");
16668 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16669 	TOKEN_NUM_INITIALIZER
16670 		(struct cmd_config_per_queue_tx_offload_result,
16671 		 queue_id, RTE_UINT16);
16672 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16673 	TOKEN_STRING_INITIALIZER
16674 		(struct cmd_config_per_queue_tx_offload_result,
16675 		 tx_offload, "tx_offload");
16676 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16677 	TOKEN_STRING_INITIALIZER
16678 		(struct cmd_config_per_queue_tx_offload_result,
16679 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16680 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16681 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16682 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16683 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
16684 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16685 	TOKEN_STRING_INITIALIZER
16686 		(struct cmd_config_per_queue_tx_offload_result,
16687 		 on_off, "on#off");
16688 
16689 static void
16690 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16691 				__rte_unused struct cmdline *cl,
16692 				__rte_unused void *data)
16693 {
16694 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16695 	struct rte_eth_dev_info dev_info;
16696 	portid_t port_id = res->port_id;
16697 	uint16_t queue_id = res->queue_id;
16698 	struct rte_port *port = &ports[port_id];
16699 	uint64_t single_offload;
16700 	int ret;
16701 
16702 	if (port->port_status != RTE_PORT_STOPPED) {
16703 		fprintf(stderr,
16704 			"Error: Can't config offload when Port %d is not stopped\n",
16705 			port_id);
16706 		return;
16707 	}
16708 
16709 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16710 	if (ret != 0)
16711 		return;
16712 
16713 	if (queue_id >= dev_info.nb_tx_queues) {
16714 		fprintf(stderr,
16715 			"Error: input queue_id should be 0 ... %d\n",
16716 			dev_info.nb_tx_queues - 1);
16717 		return;
16718 	}
16719 
16720 	single_offload = search_tx_offload(res->offload);
16721 	if (single_offload == 0) {
16722 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16723 		return;
16724 	}
16725 
16726 	if (!strcmp(res->on_off, "on"))
16727 		port->tx_conf[queue_id].offloads |= single_offload;
16728 	else
16729 		port->tx_conf[queue_id].offloads &= ~single_offload;
16730 
16731 	cmd_reconfig_device_queue(port_id, 1, 1);
16732 }
16733 
16734 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16735 	.f = cmd_config_per_queue_tx_offload_parsed,
16736 	.data = NULL,
16737 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16738 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16739 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16740 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16741 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16742 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16743 		    "on|off",
16744 	.tokens = {
16745 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16746 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16747 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16748 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16749 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16750 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16751 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16752 		NULL,
16753 	}
16754 };
16755 
16756 /* *** configure tx_metadata for specific port *** */
16757 struct cmd_config_tx_metadata_specific_result {
16758 	cmdline_fixed_string_t port;
16759 	cmdline_fixed_string_t keyword;
16760 	uint16_t port_id;
16761 	cmdline_fixed_string_t item;
16762 	uint32_t value;
16763 };
16764 
16765 static void
16766 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16767 				__rte_unused struct cmdline *cl,
16768 				__rte_unused void *data)
16769 {
16770 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16771 
16772 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16773 		return;
16774 	ports[res->port_id].tx_metadata = res->value;
16775 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16776 	if (ports[res->port_id].tx_metadata)
16777 		add_tx_md_callback(res->port_id);
16778 	else
16779 		remove_tx_md_callback(res->port_id);
16780 	rte_flow_dynf_metadata_register();
16781 }
16782 
16783 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16784 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16785 			port, "port");
16786 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16787 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16788 			keyword, "config");
16789 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16790 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16791 			port_id, RTE_UINT16);
16792 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16793 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16794 			item, "tx_metadata");
16795 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16796 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16797 			value, RTE_UINT32);
16798 
16799 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16800 	.f = cmd_config_tx_metadata_specific_parsed,
16801 	.data = NULL,
16802 	.help_str = "port config <port_id> tx_metadata <value>",
16803 	.tokens = {
16804 		(void *)&cmd_config_tx_metadata_specific_port,
16805 		(void *)&cmd_config_tx_metadata_specific_keyword,
16806 		(void *)&cmd_config_tx_metadata_specific_id,
16807 		(void *)&cmd_config_tx_metadata_specific_item,
16808 		(void *)&cmd_config_tx_metadata_specific_value,
16809 		NULL,
16810 	},
16811 };
16812 
16813 /* *** set dynf *** */
16814 struct cmd_config_tx_dynf_specific_result {
16815 	cmdline_fixed_string_t port;
16816 	cmdline_fixed_string_t keyword;
16817 	uint16_t port_id;
16818 	cmdline_fixed_string_t item;
16819 	cmdline_fixed_string_t name;
16820 	cmdline_fixed_string_t value;
16821 };
16822 
16823 static void
16824 cmd_config_dynf_specific_parsed(void *parsed_result,
16825 				__rte_unused struct cmdline *cl,
16826 				__rte_unused void *data)
16827 {
16828 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16829 	struct rte_mbuf_dynflag desc_flag;
16830 	int flag;
16831 	uint64_t old_port_flags;
16832 
16833 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16834 		return;
16835 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16836 	if (flag <= 0) {
16837 		if (strlcpy(desc_flag.name, res->name,
16838 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16839 			fprintf(stderr, "Flag name too long\n");
16840 			return;
16841 		}
16842 		desc_flag.flags = 0;
16843 		flag = rte_mbuf_dynflag_register(&desc_flag);
16844 		if (flag < 0) {
16845 			fprintf(stderr, "Can't register flag\n");
16846 			return;
16847 		}
16848 		strcpy(dynf_names[flag], desc_flag.name);
16849 	}
16850 	old_port_flags = ports[res->port_id].mbuf_dynf;
16851 	if (!strcmp(res->value, "set")) {
16852 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16853 		if (old_port_flags == 0)
16854 			add_tx_dynf_callback(res->port_id);
16855 	} else {
16856 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16857 		if (ports[res->port_id].mbuf_dynf == 0)
16858 			remove_tx_dynf_callback(res->port_id);
16859 	}
16860 }
16861 
16862 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16863 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16864 			keyword, "port");
16865 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16866 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16867 			keyword, "config");
16868 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16869 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16870 			port_id, RTE_UINT16);
16871 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16872 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16873 			item, "dynf");
16874 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16875 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16876 			name, NULL);
16877 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16878 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16879 			value, "set#clear");
16880 
16881 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16882 	.f = cmd_config_dynf_specific_parsed,
16883 	.data = NULL,
16884 	.help_str = "port config <port id> dynf <name> set|clear",
16885 	.tokens = {
16886 		(void *)&cmd_config_tx_dynf_specific_port,
16887 		(void *)&cmd_config_tx_dynf_specific_keyword,
16888 		(void *)&cmd_config_tx_dynf_specific_port_id,
16889 		(void *)&cmd_config_tx_dynf_specific_item,
16890 		(void *)&cmd_config_tx_dynf_specific_name,
16891 		(void *)&cmd_config_tx_dynf_specific_value,
16892 		NULL,
16893 	},
16894 };
16895 
16896 /* *** display tx_metadata per port configuration *** */
16897 struct cmd_show_tx_metadata_result {
16898 	cmdline_fixed_string_t cmd_show;
16899 	cmdline_fixed_string_t cmd_port;
16900 	cmdline_fixed_string_t cmd_keyword;
16901 	portid_t cmd_pid;
16902 };
16903 
16904 static void
16905 cmd_show_tx_metadata_parsed(void *parsed_result,
16906 		__rte_unused struct cmdline *cl,
16907 		__rte_unused void *data)
16908 {
16909 	struct cmd_show_tx_metadata_result *res = parsed_result;
16910 
16911 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16912 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16913 		return;
16914 	}
16915 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16916 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16917 		       ports[res->cmd_pid].tx_metadata);
16918 	}
16919 }
16920 
16921 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16922 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16923 			cmd_show, "show");
16924 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16925 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16926 			cmd_port, "port");
16927 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16928 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16929 			cmd_pid, RTE_UINT16);
16930 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16931 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16932 			cmd_keyword, "tx_metadata");
16933 
16934 cmdline_parse_inst_t cmd_show_tx_metadata = {
16935 	.f = cmd_show_tx_metadata_parsed,
16936 	.data = NULL,
16937 	.help_str = "show port <port_id> tx_metadata",
16938 	.tokens = {
16939 		(void *)&cmd_show_tx_metadata_show,
16940 		(void *)&cmd_show_tx_metadata_port,
16941 		(void *)&cmd_show_tx_metadata_pid,
16942 		(void *)&cmd_show_tx_metadata_keyword,
16943 		NULL,
16944 	},
16945 };
16946 
16947 /* *** show fec capability per port configuration *** */
16948 struct cmd_show_fec_capability_result {
16949 	cmdline_fixed_string_t cmd_show;
16950 	cmdline_fixed_string_t cmd_port;
16951 	cmdline_fixed_string_t cmd_fec;
16952 	cmdline_fixed_string_t cmd_keyword;
16953 	portid_t cmd_pid;
16954 };
16955 
16956 static void
16957 cmd_show_fec_capability_parsed(void *parsed_result,
16958 		__rte_unused struct cmdline *cl,
16959 		__rte_unused void *data)
16960 {
16961 	struct cmd_show_fec_capability_result *res = parsed_result;
16962 	struct rte_eth_fec_capa *speed_fec_capa;
16963 	unsigned int num;
16964 	int ret;
16965 
16966 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16967 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16968 		return;
16969 	}
16970 
16971 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16972 	if (ret == -ENOTSUP) {
16973 		fprintf(stderr, "Function not implemented\n");
16974 		return;
16975 	} else if (ret < 0) {
16976 		fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16977 		return;
16978 	}
16979 
16980 	num = (unsigned int)ret;
16981 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16982 	if (speed_fec_capa == NULL) {
16983 		fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16984 		return;
16985 	}
16986 
16987 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16988 	if (ret < 0) {
16989 		fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16990 		goto out;
16991 	}
16992 
16993 	show_fec_capability(num, speed_fec_capa);
16994 out:
16995 	free(speed_fec_capa);
16996 }
16997 
16998 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16999 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17000 			cmd_show, "show");
17001 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17002 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17003 			cmd_port, "port");
17004 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17005 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17006 			cmd_pid, RTE_UINT16);
17007 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17008 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17009 			cmd_fec, "fec");
17010 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17011 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17012 			cmd_keyword, "capabilities");
17013 
17014 cmdline_parse_inst_t cmd_show_capability = {
17015 	.f = cmd_show_fec_capability_parsed,
17016 	.data = NULL,
17017 	.help_str = "show port <port_id> fec capabilities",
17018 	.tokens = {
17019 		(void *)&cmd_show_fec_capability_show,
17020 		(void *)&cmd_show_fec_capability_port,
17021 		(void *)&cmd_show_fec_capability_pid,
17022 		(void *)&cmd_show_fec_capability_fec,
17023 		(void *)&cmd_show_fec_capability_keyword,
17024 		NULL,
17025 	},
17026 };
17027 
17028 /* *** show fec mode per port configuration *** */
17029 struct cmd_show_fec_metadata_result {
17030 	cmdline_fixed_string_t cmd_show;
17031 	cmdline_fixed_string_t cmd_port;
17032 	cmdline_fixed_string_t cmd_keyword;
17033 	portid_t cmd_pid;
17034 };
17035 
17036 static void
17037 cmd_show_fec_mode_parsed(void *parsed_result,
17038 		__rte_unused struct cmdline *cl,
17039 		__rte_unused void *data)
17040 {
17041 #define FEC_NAME_SIZE 16
17042 	struct cmd_show_fec_metadata_result *res = parsed_result;
17043 	uint32_t mode;
17044 	char buf[FEC_NAME_SIZE];
17045 	int ret;
17046 
17047 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17048 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17049 		return;
17050 	}
17051 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
17052 	if (ret == -ENOTSUP) {
17053 		fprintf(stderr, "Function not implemented\n");
17054 		return;
17055 	} else if (ret < 0) {
17056 		fprintf(stderr, "Get FEC mode failed\n");
17057 		return;
17058 	}
17059 
17060 	switch (mode) {
17061 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17062 		strlcpy(buf, "off", sizeof(buf));
17063 		break;
17064 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17065 		strlcpy(buf, "auto", sizeof(buf));
17066 		break;
17067 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17068 		strlcpy(buf, "baser", sizeof(buf));
17069 		break;
17070 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17071 		strlcpy(buf, "rs", sizeof(buf));
17072 		break;
17073 	default:
17074 		return;
17075 	}
17076 
17077 	printf("%s\n", buf);
17078 }
17079 
17080 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17081 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17082 			cmd_show, "show");
17083 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17084 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17085 			cmd_port, "port");
17086 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17087 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17088 			cmd_pid, RTE_UINT16);
17089 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17090 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17091 			cmd_keyword, "fec_mode");
17092 
17093 cmdline_parse_inst_t cmd_show_fec_mode = {
17094 	.f = cmd_show_fec_mode_parsed,
17095 	.data = NULL,
17096 	.help_str = "show port <port_id> fec_mode",
17097 	.tokens = {
17098 		(void *)&cmd_show_fec_mode_show,
17099 		(void *)&cmd_show_fec_mode_port,
17100 		(void *)&cmd_show_fec_mode_pid,
17101 		(void *)&cmd_show_fec_mode_keyword,
17102 		NULL,
17103 	},
17104 };
17105 
17106 /* *** set fec mode per port configuration *** */
17107 struct cmd_set_port_fec_mode {
17108 	cmdline_fixed_string_t set;
17109 	cmdline_fixed_string_t port;
17110 	portid_t port_id;
17111 	cmdline_fixed_string_t fec_mode;
17112 	cmdline_fixed_string_t fec_value;
17113 };
17114 
17115 /* Common CLI fields for set fec mode */
17116 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17117 	TOKEN_STRING_INITIALIZER
17118 		(struct cmd_set_port_fec_mode,
17119 		 set, "set");
17120 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17121 	TOKEN_STRING_INITIALIZER
17122 		(struct cmd_set_port_fec_mode,
17123 		 port, "port");
17124 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17125 	TOKEN_NUM_INITIALIZER
17126 		(struct cmd_set_port_fec_mode,
17127 		 port_id, RTE_UINT16);
17128 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17129 	TOKEN_STRING_INITIALIZER
17130 		(struct cmd_set_port_fec_mode,
17131 		 fec_mode, "fec_mode");
17132 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17133 	TOKEN_STRING_INITIALIZER
17134 		(struct cmd_set_port_fec_mode,
17135 		 fec_value, NULL);
17136 
17137 static void
17138 cmd_set_port_fec_mode_parsed(
17139 	void *parsed_result,
17140 	__rte_unused struct cmdline *cl,
17141 	__rte_unused void *data)
17142 {
17143 	struct cmd_set_port_fec_mode *res = parsed_result;
17144 	uint16_t port_id = res->port_id;
17145 	uint32_t fec_capa;
17146 	int ret;
17147 
17148 	ret = parse_fec_mode(res->fec_value, &fec_capa);
17149 	if (ret < 0) {
17150 		fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17151 				res->fec_value,	port_id);
17152 		return;
17153 	}
17154 
17155 	ret = rte_eth_fec_set(port_id, fec_capa);
17156 	if (ret == -ENOTSUP) {
17157 		fprintf(stderr, "Function not implemented\n");
17158 		return;
17159 	} else if (ret < 0) {
17160 		fprintf(stderr, "Set FEC mode failed\n");
17161 		return;
17162 	}
17163 }
17164 
17165 cmdline_parse_inst_t cmd_set_fec_mode = {
17166 	.f = cmd_set_port_fec_mode_parsed,
17167 	.data = NULL,
17168 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17169 	.tokens = {
17170 		(void *)&cmd_set_port_fec_mode_set,
17171 		(void *)&cmd_set_port_fec_mode_port,
17172 		(void *)&cmd_set_port_fec_mode_port_id,
17173 		(void *)&cmd_set_port_fec_mode_str,
17174 		(void *)&cmd_set_port_fec_mode_value,
17175 		NULL,
17176 	},
17177 };
17178 
17179 /* show port supported ptypes */
17180 
17181 /* Common result structure for show port ptypes */
17182 struct cmd_show_port_supported_ptypes_result {
17183 	cmdline_fixed_string_t show;
17184 	cmdline_fixed_string_t port;
17185 	portid_t port_id;
17186 	cmdline_fixed_string_t ptypes;
17187 };
17188 
17189 /* Common CLI fields for show port ptypes */
17190 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17191 	TOKEN_STRING_INITIALIZER
17192 		(struct cmd_show_port_supported_ptypes_result,
17193 		 show, "show");
17194 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17195 	TOKEN_STRING_INITIALIZER
17196 		(struct cmd_show_port_supported_ptypes_result,
17197 		 port, "port");
17198 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17199 	TOKEN_NUM_INITIALIZER
17200 		(struct cmd_show_port_supported_ptypes_result,
17201 		 port_id, RTE_UINT16);
17202 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17203 	TOKEN_STRING_INITIALIZER
17204 		(struct cmd_show_port_supported_ptypes_result,
17205 		 ptypes, "ptypes");
17206 
17207 static void
17208 cmd_show_port_supported_ptypes_parsed(
17209 	void *parsed_result,
17210 	__rte_unused struct cmdline *cl,
17211 	__rte_unused void *data)
17212 {
17213 #define RSVD_PTYPE_MASK       0xf0000000
17214 #define MAX_PTYPES_PER_LAYER  16
17215 #define LTYPE_NAMESIZE        32
17216 #define PTYPE_NAMESIZE        256
17217 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17218 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17219 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17220 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17221 	uint16_t port_id = res->port_id;
17222 	int ret, i;
17223 
17224 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17225 	if (ret < 0)
17226 		return;
17227 
17228 	while (ptype_mask != RSVD_PTYPE_MASK) {
17229 
17230 		switch (ptype_mask) {
17231 		case RTE_PTYPE_L2_MASK:
17232 			strlcpy(ltype, "L2", sizeof(ltype));
17233 			break;
17234 		case RTE_PTYPE_L3_MASK:
17235 			strlcpy(ltype, "L3", sizeof(ltype));
17236 			break;
17237 		case RTE_PTYPE_L4_MASK:
17238 			strlcpy(ltype, "L4", sizeof(ltype));
17239 			break;
17240 		case RTE_PTYPE_TUNNEL_MASK:
17241 			strlcpy(ltype, "Tunnel", sizeof(ltype));
17242 			break;
17243 		case RTE_PTYPE_INNER_L2_MASK:
17244 			strlcpy(ltype, "Inner L2", sizeof(ltype));
17245 			break;
17246 		case RTE_PTYPE_INNER_L3_MASK:
17247 			strlcpy(ltype, "Inner L3", sizeof(ltype));
17248 			break;
17249 		case RTE_PTYPE_INNER_L4_MASK:
17250 			strlcpy(ltype, "Inner L4", sizeof(ltype));
17251 			break;
17252 		default:
17253 			return;
17254 		}
17255 
17256 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17257 						       ptype_mask, ptypes,
17258 						       MAX_PTYPES_PER_LAYER);
17259 
17260 		if (ret > 0)
17261 			printf("Supported %s ptypes:\n", ltype);
17262 		else
17263 			printf("%s ptypes unsupported\n", ltype);
17264 
17265 		for (i = 0; i < ret; ++i) {
17266 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17267 			printf("%s\n", buf);
17268 		}
17269 
17270 		ptype_mask <<= 4;
17271 	}
17272 }
17273 
17274 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17275 	.f = cmd_show_port_supported_ptypes_parsed,
17276 	.data = NULL,
17277 	.help_str = "show port <port_id> ptypes",
17278 	.tokens = {
17279 		(void *)&cmd_show_port_supported_ptypes_show,
17280 		(void *)&cmd_show_port_supported_ptypes_port,
17281 		(void *)&cmd_show_port_supported_ptypes_port_id,
17282 		(void *)&cmd_show_port_supported_ptypes_ptypes,
17283 		NULL,
17284 	},
17285 };
17286 
17287 /* *** display rx/tx descriptor status *** */
17288 struct cmd_show_rx_tx_desc_status_result {
17289 	cmdline_fixed_string_t cmd_show;
17290 	cmdline_fixed_string_t cmd_port;
17291 	cmdline_fixed_string_t cmd_keyword;
17292 	cmdline_fixed_string_t cmd_desc;
17293 	cmdline_fixed_string_t cmd_status;
17294 	portid_t cmd_pid;
17295 	portid_t cmd_qid;
17296 	portid_t cmd_did;
17297 };
17298 
17299 static void
17300 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17301 		__rte_unused struct cmdline *cl,
17302 		__rte_unused void *data)
17303 {
17304 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17305 	int rc;
17306 
17307 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17308 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17309 		return;
17310 	}
17311 
17312 	if (!strcmp(res->cmd_keyword, "rxq")) {
17313 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17314 					     res->cmd_did);
17315 		if (rc < 0) {
17316 			fprintf(stderr,
17317 				"Invalid input: queue id = %d, desc id = %d\n",
17318 				res->cmd_qid, res->cmd_did);
17319 			return;
17320 		}
17321 		if (rc == RTE_ETH_RX_DESC_AVAIL)
17322 			printf("Desc status = AVAILABLE\n");
17323 		else if (rc == RTE_ETH_RX_DESC_DONE)
17324 			printf("Desc status = DONE\n");
17325 		else
17326 			printf("Desc status = UNAVAILABLE\n");
17327 	} else if (!strcmp(res->cmd_keyword, "txq")) {
17328 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17329 					     res->cmd_did);
17330 		if (rc < 0) {
17331 			fprintf(stderr,
17332 				"Invalid input: queue id = %d, desc id = %d\n",
17333 				res->cmd_qid, res->cmd_did);
17334 			return;
17335 		}
17336 		if (rc == RTE_ETH_TX_DESC_FULL)
17337 			printf("Desc status = FULL\n");
17338 		else if (rc == RTE_ETH_TX_DESC_DONE)
17339 			printf("Desc status = DONE\n");
17340 		else
17341 			printf("Desc status = UNAVAILABLE\n");
17342 	}
17343 }
17344 
17345 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17346 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17347 			cmd_show, "show");
17348 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17349 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17350 			cmd_port, "port");
17351 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17352 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17353 			cmd_pid, RTE_UINT16);
17354 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17355 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17356 			cmd_keyword, "rxq#txq");
17357 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17358 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17359 			cmd_qid, RTE_UINT16);
17360 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17361 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17362 			cmd_desc, "desc");
17363 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17364 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17365 			cmd_did, RTE_UINT16);
17366 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17367 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17368 			cmd_status, "status");
17369 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17370 	.f = cmd_show_rx_tx_desc_status_parsed,
17371 	.data = NULL,
17372 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17373 		"status",
17374 	.tokens = {
17375 		(void *)&cmd_show_rx_tx_desc_status_show,
17376 		(void *)&cmd_show_rx_tx_desc_status_port,
17377 		(void *)&cmd_show_rx_tx_desc_status_pid,
17378 		(void *)&cmd_show_rx_tx_desc_status_keyword,
17379 		(void *)&cmd_show_rx_tx_desc_status_qid,
17380 		(void *)&cmd_show_rx_tx_desc_status_desc,
17381 		(void *)&cmd_show_rx_tx_desc_status_did,
17382 		(void *)&cmd_show_rx_tx_desc_status_status,
17383 		NULL,
17384 	},
17385 };
17386 
17387 /* *** display rx queue desc used count *** */
17388 struct cmd_show_rx_queue_desc_used_count_result {
17389 	cmdline_fixed_string_t cmd_show;
17390 	cmdline_fixed_string_t cmd_port;
17391 	cmdline_fixed_string_t cmd_rxq;
17392 	cmdline_fixed_string_t cmd_desc;
17393 	cmdline_fixed_string_t cmd_used;
17394 	cmdline_fixed_string_t cmd_count;
17395 	portid_t cmd_pid;
17396 	portid_t cmd_qid;
17397 };
17398 
17399 static void
17400 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17401 		__rte_unused struct cmdline *cl,
17402 		__rte_unused void *data)
17403 {
17404 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17405 	int rc;
17406 
17407 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17408 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17409 		return;
17410 	}
17411 
17412 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17413 	if (rc < 0) {
17414 		fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17415 		return;
17416 	}
17417 	printf("Used desc count = %d\n", rc);
17418 }
17419 
17420 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17421 	TOKEN_STRING_INITIALIZER
17422 		(struct cmd_show_rx_queue_desc_used_count_result,
17423 		 cmd_show, "show");
17424 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17425 	TOKEN_STRING_INITIALIZER
17426 		(struct cmd_show_rx_queue_desc_used_count_result,
17427 		 cmd_port, "port");
17428 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17429 	TOKEN_NUM_INITIALIZER
17430 		(struct cmd_show_rx_queue_desc_used_count_result,
17431 		 cmd_pid, RTE_UINT16);
17432 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17433 	TOKEN_STRING_INITIALIZER
17434 		(struct cmd_show_rx_queue_desc_used_count_result,
17435 		 cmd_rxq, "rxq");
17436 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17437 	TOKEN_NUM_INITIALIZER
17438 		(struct cmd_show_rx_queue_desc_used_count_result,
17439 		 cmd_qid, RTE_UINT16);
17440 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17441 	TOKEN_STRING_INITIALIZER
17442 		(struct cmd_show_rx_queue_desc_used_count_result,
17443 		 cmd_count, "desc");
17444 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17445 	TOKEN_STRING_INITIALIZER
17446 		(struct cmd_show_rx_queue_desc_used_count_result,
17447 		 cmd_count, "used");
17448 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17449 	TOKEN_STRING_INITIALIZER
17450 		(struct cmd_show_rx_queue_desc_used_count_result,
17451 		 cmd_count, "count");
17452 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17453 	.f = cmd_show_rx_queue_desc_used_count_parsed,
17454 	.data = NULL,
17455 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
17456 	.tokens = {
17457 		(void *)&cmd_show_rx_queue_desc_used_count_show,
17458 		(void *)&cmd_show_rx_queue_desc_used_count_port,
17459 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
17460 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
17461 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
17462 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
17463 		(void *)&cmd_show_rx_queue_desc_used_count_used,
17464 		(void *)&cmd_show_rx_queue_desc_used_count_count,
17465 		NULL,
17466 	},
17467 };
17468 
17469 /* Common result structure for set port ptypes */
17470 struct cmd_set_port_ptypes_result {
17471 	cmdline_fixed_string_t set;
17472 	cmdline_fixed_string_t port;
17473 	portid_t port_id;
17474 	cmdline_fixed_string_t ptype_mask;
17475 	uint32_t mask;
17476 };
17477 
17478 /* Common CLI fields for set port ptypes */
17479 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17480 	TOKEN_STRING_INITIALIZER
17481 		(struct cmd_set_port_ptypes_result,
17482 		 set, "set");
17483 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17484 	TOKEN_STRING_INITIALIZER
17485 		(struct cmd_set_port_ptypes_result,
17486 		 port, "port");
17487 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17488 	TOKEN_NUM_INITIALIZER
17489 		(struct cmd_set_port_ptypes_result,
17490 		 port_id, RTE_UINT16);
17491 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17492 	TOKEN_STRING_INITIALIZER
17493 		(struct cmd_set_port_ptypes_result,
17494 		 ptype_mask, "ptype_mask");
17495 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17496 	TOKEN_NUM_INITIALIZER
17497 		(struct cmd_set_port_ptypes_result,
17498 		 mask, RTE_UINT32);
17499 
17500 static void
17501 cmd_set_port_ptypes_parsed(
17502 	void *parsed_result,
17503 	__rte_unused struct cmdline *cl,
17504 	__rte_unused void *data)
17505 {
17506 	struct cmd_set_port_ptypes_result *res = parsed_result;
17507 #define PTYPE_NAMESIZE        256
17508 	char ptype_name[PTYPE_NAMESIZE];
17509 	uint16_t port_id = res->port_id;
17510 	uint32_t ptype_mask = res->mask;
17511 	int ret, i;
17512 
17513 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17514 					       NULL, 0);
17515 	if (ret <= 0) {
17516 		fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17517 			port_id);
17518 		return;
17519 	}
17520 
17521 	uint32_t ptypes[ret];
17522 
17523 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17524 	if (ret < 0) {
17525 		fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17526 			port_id);
17527 		return;
17528 	}
17529 
17530 	printf("Successfully set following ptypes for Port %d\n", port_id);
17531 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17532 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17533 		printf("%s\n", ptype_name);
17534 	}
17535 
17536 	clear_ptypes = false;
17537 }
17538 
17539 cmdline_parse_inst_t cmd_set_port_ptypes = {
17540 	.f = cmd_set_port_ptypes_parsed,
17541 	.data = NULL,
17542 	.help_str = "set port <port_id> ptype_mask <mask>",
17543 	.tokens = {
17544 		(void *)&cmd_set_port_ptypes_set,
17545 		(void *)&cmd_set_port_ptypes_port,
17546 		(void *)&cmd_set_port_ptypes_port_id,
17547 		(void *)&cmd_set_port_ptypes_mask_str,
17548 		(void *)&cmd_set_port_ptypes_mask_u32,
17549 		NULL,
17550 	},
17551 };
17552 
17553 /* *** display mac addresses added to a port *** */
17554 struct cmd_showport_macs_result {
17555 	cmdline_fixed_string_t cmd_show;
17556 	cmdline_fixed_string_t cmd_port;
17557 	cmdline_fixed_string_t cmd_keyword;
17558 	portid_t cmd_pid;
17559 };
17560 
17561 static void
17562 cmd_showport_macs_parsed(void *parsed_result,
17563 		__rte_unused struct cmdline *cl,
17564 		__rte_unused void *data)
17565 {
17566 	struct cmd_showport_macs_result *res = parsed_result;
17567 
17568 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17569 		return;
17570 
17571 	if (!strcmp(res->cmd_keyword, "macs"))
17572 		show_macs(res->cmd_pid);
17573 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17574 		show_mcast_macs(res->cmd_pid);
17575 }
17576 
17577 cmdline_parse_token_string_t cmd_showport_macs_show =
17578 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17579 			cmd_show, "show");
17580 cmdline_parse_token_string_t cmd_showport_macs_port =
17581 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17582 			cmd_port, "port");
17583 cmdline_parse_token_num_t cmd_showport_macs_pid =
17584 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17585 			cmd_pid, RTE_UINT16);
17586 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17587 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17588 			cmd_keyword, "macs#mcast_macs");
17589 
17590 cmdline_parse_inst_t cmd_showport_macs = {
17591 	.f = cmd_showport_macs_parsed,
17592 	.data = NULL,
17593 	.help_str = "show port <port_id> macs|mcast_macs",
17594 	.tokens = {
17595 		(void *)&cmd_showport_macs_show,
17596 		(void *)&cmd_showport_macs_port,
17597 		(void *)&cmd_showport_macs_pid,
17598 		(void *)&cmd_showport_macs_keyword,
17599 		NULL,
17600 	},
17601 };
17602 
17603 /* *** show flow transfer proxy port ID for the given port *** */
17604 struct cmd_show_port_flow_transfer_proxy_result {
17605 	cmdline_fixed_string_t show;
17606 	cmdline_fixed_string_t port;
17607 	portid_t port_id;
17608 	cmdline_fixed_string_t flow;
17609 	cmdline_fixed_string_t transfer;
17610 	cmdline_fixed_string_t proxy;
17611 };
17612 
17613 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17614 	TOKEN_STRING_INITIALIZER
17615 		(struct cmd_show_port_flow_transfer_proxy_result,
17616 		 show, "show");
17617 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17618 	TOKEN_STRING_INITIALIZER
17619 		(struct cmd_show_port_flow_transfer_proxy_result,
17620 		 port, "port");
17621 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17622 	TOKEN_NUM_INITIALIZER
17623 		(struct cmd_show_port_flow_transfer_proxy_result,
17624 		 port_id, RTE_UINT16);
17625 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17626 	TOKEN_STRING_INITIALIZER
17627 		(struct cmd_show_port_flow_transfer_proxy_result,
17628 		 flow, "flow");
17629 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17630 	TOKEN_STRING_INITIALIZER
17631 		(struct cmd_show_port_flow_transfer_proxy_result,
17632 		 transfer, "transfer");
17633 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17634 	TOKEN_STRING_INITIALIZER
17635 		(struct cmd_show_port_flow_transfer_proxy_result,
17636 		 proxy, "proxy");
17637 
17638 static void
17639 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17640 					 __rte_unused struct cmdline *cl,
17641 					 __rte_unused void *data)
17642 {
17643 	struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17644 	portid_t proxy_port_id;
17645 	int ret;
17646 
17647 	printf("\n");
17648 
17649 	ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17650 	if (ret != 0) {
17651 		fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17652 			rte_strerror(-ret));
17653 		return;
17654 	}
17655 
17656 	printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17657 }
17658 
17659 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17660 	.f = cmd_show_port_flow_transfer_proxy_parsed,
17661 	.data = NULL,
17662 	.help_str = "show port <port_id> flow transfer proxy",
17663 	.tokens = {
17664 		(void *)&cmd_show_port_flow_transfer_proxy_show,
17665 		(void *)&cmd_show_port_flow_transfer_proxy_port,
17666 		(void *)&cmd_show_port_flow_transfer_proxy_port_id,
17667 		(void *)&cmd_show_port_flow_transfer_proxy_flow,
17668 		(void *)&cmd_show_port_flow_transfer_proxy_transfer,
17669 		(void *)&cmd_show_port_flow_transfer_proxy_proxy,
17670 		NULL,
17671 	}
17672 };
17673 
17674 /* ******************************************************************************** */
17675 
17676 /* list of instructions */
17677 cmdline_parse_ctx_t main_ctx[] = {
17678 	(cmdline_parse_inst_t *)&cmd_help_brief,
17679 	(cmdline_parse_inst_t *)&cmd_help_long,
17680 	(cmdline_parse_inst_t *)&cmd_quit,
17681 	(cmdline_parse_inst_t *)&cmd_load_from_file,
17682 	(cmdline_parse_inst_t *)&cmd_showport,
17683 	(cmdline_parse_inst_t *)&cmd_showqueue,
17684 	(cmdline_parse_inst_t *)&cmd_showeeprom,
17685 	(cmdline_parse_inst_t *)&cmd_showportall,
17686 	(cmdline_parse_inst_t *)&cmd_representor_info,
17687 	(cmdline_parse_inst_t *)&cmd_showdevice,
17688 	(cmdline_parse_inst_t *)&cmd_showcfg,
17689 	(cmdline_parse_inst_t *)&cmd_showfwdall,
17690 	(cmdline_parse_inst_t *)&cmd_start,
17691 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
17692 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17693 	(cmdline_parse_inst_t *)&cmd_set_link_up,
17694 	(cmdline_parse_inst_t *)&cmd_set_link_down,
17695 	(cmdline_parse_inst_t *)&cmd_reset,
17696 	(cmdline_parse_inst_t *)&cmd_set_numbers,
17697 	(cmdline_parse_inst_t *)&cmd_set_log,
17698 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
17699 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
17700 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
17701 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
17702 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
17703 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
17704 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17705 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17706 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17707 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17708 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17709 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17710 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17711 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17712 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
17713 	(cmdline_parse_inst_t *)&cmd_set_link_check,
17714 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17715 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
17716 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17717 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
17718 #ifdef RTE_NET_BOND
17719 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17720 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
17721 	(cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17722 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17723 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17724 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17725 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
17726 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17727 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17728 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17729 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17730 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17731 #endif
17732 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
17733 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
17734 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17735 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17736 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17737 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17738 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17739 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17740 	(cmdline_parse_inst_t *)&cmd_csum_set,
17741 	(cmdline_parse_inst_t *)&cmd_csum_show,
17742 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
17743 	(cmdline_parse_inst_t *)&cmd_tso_set,
17744 	(cmdline_parse_inst_t *)&cmd_tso_show,
17745 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17746 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17747 #ifdef RTE_LIB_GRO
17748 	(cmdline_parse_inst_t *)&cmd_gro_enable,
17749 	(cmdline_parse_inst_t *)&cmd_gro_flush,
17750 	(cmdline_parse_inst_t *)&cmd_gro_show,
17751 #endif
17752 #ifdef RTE_LIB_GSO
17753 	(cmdline_parse_inst_t *)&cmd_gso_enable,
17754 	(cmdline_parse_inst_t *)&cmd_gso_size,
17755 	(cmdline_parse_inst_t *)&cmd_gso_show,
17756 #endif
17757 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17758 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17759 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17760 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17761 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17762 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17763 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17764 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17765 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17766 	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17767 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17768 	(cmdline_parse_inst_t *)&cmd_config_dcb,
17769 	(cmdline_parse_inst_t *)&cmd_read_reg,
17770 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17771 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
17772 	(cmdline_parse_inst_t *)&cmd_write_reg,
17773 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17774 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
17775 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17776 	(cmdline_parse_inst_t *)&cmd_stop,
17777 	(cmdline_parse_inst_t *)&cmd_mac_addr,
17778 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17779 	(cmdline_parse_inst_t *)&cmd_set_qmap,
17780 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17781 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17782 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17783 	(cmdline_parse_inst_t *)&cmd_operate_port,
17784 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
17785 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
17786 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
17787 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
17788 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17789 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
17790 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
17791 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
17792 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17793 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
17794 	(cmdline_parse_inst_t *)&cmd_config_mtu,
17795 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17796 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17797 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17798 	(cmdline_parse_inst_t *)&cmd_config_rss,
17799 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17800 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17801 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17802 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17803 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
17804 	(cmdline_parse_inst_t *)&cmd_showport_reta,
17805 	(cmdline_parse_inst_t *)&cmd_showport_macs,
17806 	(cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17807 	(cmdline_parse_inst_t *)&cmd_config_burst,
17808 	(cmdline_parse_inst_t *)&cmd_config_thresh,
17809 	(cmdline_parse_inst_t *)&cmd_config_threshold,
17810 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17811 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17812 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17813 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17814 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17815 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17816 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17817 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17818 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17819 	(cmdline_parse_inst_t *)&cmd_dump,
17820 	(cmdline_parse_inst_t *)&cmd_dump_one,
17821 #ifdef RTE_NET_I40E
17822 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17823 #endif
17824 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17825 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17826 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17827 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17828 	(cmdline_parse_inst_t *)&cmd_flow,
17829 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17830 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17831 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17832 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17833 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
17834 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
17835 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
17836 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
17837 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17838 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17839 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17840 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17841 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17842 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
17843 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17844 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17845 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17846 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17847 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17848 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17849 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17850 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17851 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17852 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17853 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17854 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17855 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17856 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17857 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17858 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17859 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17860 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17861 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17862 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17863 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
17864 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17865 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17866 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
17867 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
17868 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
17869 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17870 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17871 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
17872 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17873 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
17874 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17875 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
17876 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17877 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17878 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17879 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17880 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17881 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17882 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17883 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17884 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17885 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17886 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17887 	(cmdline_parse_inst_t *)&cmd_ddp_add,
17888 	(cmdline_parse_inst_t *)&cmd_ddp_del,
17889 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
17890 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
17891 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
17892 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
17893 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
17894 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17895 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17896 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17897 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17898 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17899 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17900 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17901 
17902 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17903 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17904 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17905 	(cmdline_parse_inst_t *)&cmd_queue_region,
17906 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
17907 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
17908 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
17909 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17910 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17911 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17912 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17913 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17914 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17915 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17916 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17917 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17918 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17919 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17920 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17921 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17922 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17923 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17924 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17925 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17926 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17927 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17928 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17929 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17930 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17931 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17932 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17933 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17934 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17935 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17936 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17937 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17938 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17939 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17940 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17941 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17942 #ifdef RTE_LIB_BPF
17943 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17944 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17945 #endif
17946 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17947 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17948 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17949 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17950 	(cmdline_parse_inst_t *)&cmd_set_raw,
17951 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
17952 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17953 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17954 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
17955 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
17956 	(cmdline_parse_inst_t *)&cmd_show_capability,
17957 	(cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
17958 	(cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
17959 	NULL,
17960 };
17961 
17962 /* read cmdline commands from file */
17963 void
17964 cmdline_read_from_file(const char *filename)
17965 {
17966 	struct cmdline *cl;
17967 
17968 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17969 	if (cl == NULL) {
17970 		fprintf(stderr,
17971 			"Failed to create file based cmdline context: %s\n",
17972 			filename);
17973 		return;
17974 	}
17975 
17976 	cmdline_interact(cl);
17977 	cmdline_quit(cl);
17978 
17979 	cmdline_free(cl);
17980 
17981 	printf("Read CLI commands from %s\n", filename);
17982 }
17983 
17984 /* prompt function, called from main on MAIN lcore */
17985 void
17986 prompt(void)
17987 {
17988 	int ret;
17989 	/* initialize non-constant commands */
17990 	cmd_set_fwd_mode_init();
17991 	cmd_set_fwd_retry_mode_init();
17992 
17993 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17994 	if (testpmd_cl == NULL)
17995 		return;
17996 
17997 	ret = atexit(prompt_exit);
17998 	if (ret != 0)
17999 		fprintf(stderr, "Cannot set exit function for cmdline\n");
18000 
18001 	cmdline_interact(testpmd_cl);
18002 	if (ret != 0)
18003 		cmdline_stdin_exit(testpmd_cl);
18004 }
18005 
18006 void
18007 prompt_exit(void)
18008 {
18009 	if (testpmd_cl != NULL) {
18010 		cmdline_quit(testpmd_cl);
18011 		cmdline_stdin_exit(testpmd_cl);
18012 	}
18013 }
18014 
18015 static void
18016 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18017 {
18018 	if (id == (portid_t)RTE_PORT_ALL) {
18019 		portid_t pid;
18020 
18021 		RTE_ETH_FOREACH_DEV(pid) {
18022 			/* check if need_reconfig has been set to 1 */
18023 			if (ports[pid].need_reconfig == 0)
18024 				ports[pid].need_reconfig = dev;
18025 			/* check if need_reconfig_queues has been set to 1 */
18026 			if (ports[pid].need_reconfig_queues == 0)
18027 				ports[pid].need_reconfig_queues = queue;
18028 		}
18029 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18030 		/* check if need_reconfig has been set to 1 */
18031 		if (ports[id].need_reconfig == 0)
18032 			ports[id].need_reconfig = dev;
18033 		/* check if need_reconfig_queues has been set to 1 */
18034 		if (ports[id].need_reconfig_queues == 0)
18035 			ports[id].need_reconfig_queues = queue;
18036 	}
18037 }
18038