xref: /dpdk/app/test-pmd/cmdline.c (revision fa4dfda5)
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/transmit 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 	struct rte_port *port = &ports[port_id];
5919 
5920 	/*
5921 	 * Bonding mode changed means resources of device changed, like whether
5922 	 * started rte timer or not. Device should be restarted when resources
5923 	 * of device changed.
5924 	 */
5925 	if (port->port_status != RTE_PORT_STOPPED) {
5926 		fprintf(stderr,
5927 			"\t Error: Can't set bonding mode when port %d is not stopped\n",
5928 			port_id);
5929 		return;
5930 	}
5931 
5932 	/* Set the bonding mode for the relevant port. */
5933 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5934 		fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5935 			port_id);
5936 }
5937 
5938 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5940 		set, "set");
5941 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5942 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5943 		bonding, "bonding");
5944 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5946 		mode, "mode");
5947 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5948 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5949 		value, RTE_UINT8);
5950 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5951 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5952 		port_id, RTE_UINT16);
5953 
5954 cmdline_parse_inst_t cmd_set_bonding_mode = {
5955 		.f = cmd_set_bonding_mode_parsed,
5956 		.help_str = "set bonding mode <mode_value> <port_id>: "
5957 			"Set the bonding mode for port_id",
5958 		.data = NULL,
5959 		.tokens = {
5960 				(void *) &cmd_setbonding_mode_set,
5961 				(void *) &cmd_setbonding_mode_bonding,
5962 				(void *) &cmd_setbonding_mode_mode,
5963 				(void *) &cmd_setbonding_mode_value,
5964 				(void *) &cmd_setbonding_mode_port,
5965 				NULL
5966 		}
5967 };
5968 
5969 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5970 struct cmd_set_bonding_lacp_dedicated_queues_result {
5971 	cmdline_fixed_string_t set;
5972 	cmdline_fixed_string_t bonding;
5973 	cmdline_fixed_string_t lacp;
5974 	cmdline_fixed_string_t dedicated_queues;
5975 	portid_t port_id;
5976 	cmdline_fixed_string_t mode;
5977 };
5978 
5979 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5980 		__rte_unused  struct cmdline *cl,
5981 		__rte_unused void *data)
5982 {
5983 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5984 	portid_t port_id = res->port_id;
5985 	struct rte_port *port;
5986 
5987 	port = &ports[port_id];
5988 
5989 	/** Check if the port is not started **/
5990 	if (port->port_status != RTE_PORT_STOPPED) {
5991 		fprintf(stderr, "Please stop port %d first\n", port_id);
5992 		return;
5993 	}
5994 
5995 	if (!strcmp(res->mode, "enable")) {
5996 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5997 			printf("Dedicate queues for LACP control packets"
5998 					" enabled\n");
5999 		else
6000 			printf("Enabling dedicate queues for LACP control "
6001 					"packets on port %d failed\n", port_id);
6002 	} else if (!strcmp(res->mode, "disable")) {
6003 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6004 			printf("Dedicated queues for LACP control packets "
6005 					"disabled\n");
6006 		else
6007 			printf("Disabling dedicated queues for LACP control "
6008 					"traffic on port %d failed\n", port_id);
6009 	}
6010 }
6011 
6012 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6014 		set, "set");
6015 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6017 		bonding, "bonding");
6018 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6020 		lacp, "lacp");
6021 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6023 		dedicated_queues, "dedicated_queues");
6024 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6025 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6026 		port_id, RTE_UINT16);
6027 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6028 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6029 		mode, "enable#disable");
6030 
6031 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6032 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6033 		.help_str = "set bonding lacp dedicated_queues <port_id> "
6034 			"enable|disable: "
6035 			"Enable/disable dedicated queues for LACP control traffic for port_id",
6036 		.data = NULL,
6037 		.tokens = {
6038 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
6039 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6040 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6041 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6042 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6043 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6044 			NULL
6045 		}
6046 };
6047 
6048 /* *** SET BALANCE XMIT POLICY *** */
6049 struct cmd_set_bonding_balance_xmit_policy_result {
6050 	cmdline_fixed_string_t set;
6051 	cmdline_fixed_string_t bonding;
6052 	cmdline_fixed_string_t balance_xmit_policy;
6053 	portid_t port_id;
6054 	cmdline_fixed_string_t policy;
6055 };
6056 
6057 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6058 		__rte_unused  struct cmdline *cl,
6059 		__rte_unused void *data)
6060 {
6061 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6062 	portid_t port_id = res->port_id;
6063 	uint8_t policy;
6064 
6065 	if (!strcmp(res->policy, "l2")) {
6066 		policy = BALANCE_XMIT_POLICY_LAYER2;
6067 	} else if (!strcmp(res->policy, "l23")) {
6068 		policy = BALANCE_XMIT_POLICY_LAYER23;
6069 	} else if (!strcmp(res->policy, "l34")) {
6070 		policy = BALANCE_XMIT_POLICY_LAYER34;
6071 	} else {
6072 		fprintf(stderr, "\t Invalid xmit policy selection");
6073 		return;
6074 	}
6075 
6076 	/* Set the bonding mode for the relevant port. */
6077 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6078 		fprintf(stderr,
6079 			"\t Failed to set bonding balance xmit policy for port = %d.\n",
6080 			port_id);
6081 	}
6082 }
6083 
6084 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6086 		set, "set");
6087 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6088 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6089 		bonding, "bonding");
6090 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6092 		balance_xmit_policy, "balance_xmit_policy");
6093 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6094 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6095 		port_id, RTE_UINT16);
6096 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6097 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6098 		policy, "l2#l23#l34");
6099 
6100 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6101 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
6102 		.help_str = "set bonding balance_xmit_policy <port_id> "
6103 			"l2|l23|l34: "
6104 			"Set the bonding balance_xmit_policy for port_id",
6105 		.data = NULL,
6106 		.tokens = {
6107 				(void *)&cmd_setbonding_balance_xmit_policy_set,
6108 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
6109 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6110 				(void *)&cmd_setbonding_balance_xmit_policy_port,
6111 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
6112 				NULL
6113 		}
6114 };
6115 
6116 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6117 struct cmd_show_bonding_lacp_info_result {
6118 	cmdline_fixed_string_t show;
6119 	cmdline_fixed_string_t bonding;
6120 	cmdline_fixed_string_t lacp;
6121 	cmdline_fixed_string_t info;
6122 	portid_t port_id;
6123 };
6124 
6125 static void port_param_show(struct port_params *params)
6126 {
6127 	char buf[RTE_ETHER_ADDR_FMT_SIZE];
6128 
6129 	printf("\t\tsystem priority: %u\n", params->system_priority);
6130 	rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, &params->system);
6131 	printf("\t\tsystem mac address: %s\n", buf);
6132 	printf("\t\tport key: %u\n", params->key);
6133 	printf("\t\tport priority: %u\n", params->port_priority);
6134 	printf("\t\tport number: %u\n", params->port_number);
6135 }
6136 
6137 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6138 {
6139 	char a_state[256] = { 0 };
6140 	char p_state[256] = { 0 };
6141 	int a_len = 0;
6142 	int p_len = 0;
6143 	uint32_t i;
6144 
6145 	static const char * const state[] = {
6146 		"ACTIVE",
6147 		"TIMEOUT",
6148 		"AGGREGATION",
6149 		"SYNCHRONIZATION",
6150 		"COLLECTING",
6151 		"DISTRIBUTING",
6152 		"DEFAULTED",
6153 		"EXPIRED"
6154 	};
6155 	static const char * const selection[] = {
6156 		"UNSELECTED",
6157 		"STANDBY",
6158 		"SELECTED"
6159 	};
6160 
6161 	for (i = 0; i < RTE_DIM(state); i++) {
6162 		if ((info->actor_state >> i) & 1)
6163 			a_len += snprintf(&a_state[a_len],
6164 						RTE_DIM(a_state) - a_len, "%s ",
6165 						state[i]);
6166 
6167 		if ((info->partner_state >> i) & 1)
6168 			p_len += snprintf(&p_state[p_len],
6169 						RTE_DIM(p_state) - p_len, "%s ",
6170 						state[i]);
6171 	}
6172 	printf("\tAggregator port id: %u\n", info->agg_port_id);
6173 	printf("\tselection: %s\n", selection[info->selected]);
6174 	printf("\tActor detail info:\n");
6175 	port_param_show(&info->actor);
6176 	printf("\t\tport state: %s\n", a_state);
6177 	printf("\tPartner detail info:\n");
6178 	port_param_show(&info->partner);
6179 	printf("\t\tport state: %s\n", p_state);
6180 	printf("\n");
6181 }
6182 
6183 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6184 {
6185 	printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6186 	printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6187 	printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6188 	printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6189 	printf("\taggregate wait timeout: %u ms\n",
6190 			conf->aggregate_wait_timeout_ms);
6191 	printf("\ttx period: %u ms\n", conf->tx_period_ms);
6192 	printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6193 	printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6194 	switch (conf->agg_selection) {
6195 	case AGG_BANDWIDTH:
6196 		printf("\taggregation mode: bandwidth\n");
6197 		break;
6198 	case AGG_STABLE:
6199 		printf("\taggregation mode: stable\n");
6200 		break;
6201 	case AGG_COUNT:
6202 		printf("\taggregation mode: count\n");
6203 		break;
6204 	default:
6205 		printf("\taggregation mode: invalid\n");
6206 		break;
6207 	}
6208 
6209 	printf("\n");
6210 }
6211 
6212 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6213 		__rte_unused  struct cmdline *cl,
6214 		__rte_unused void *data)
6215 {
6216 	struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6217 	struct rte_eth_bond_8023ad_slave_info slave_info;
6218 	struct rte_eth_bond_8023ad_conf port_conf;
6219 	portid_t slaves[RTE_MAX_ETHPORTS];
6220 	portid_t port_id = res->port_id;
6221 	int num_active_slaves;
6222 	int bonding_mode;
6223 	int i;
6224 	int ret;
6225 
6226 	bonding_mode = rte_eth_bond_mode_get(port_id);
6227 	if (bonding_mode != BONDING_MODE_8023AD) {
6228 		fprintf(stderr, "\tBonding mode is not mode 4\n");
6229 		return;
6230 	}
6231 
6232 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6233 			RTE_MAX_ETHPORTS);
6234 	if (num_active_slaves < 0) {
6235 		fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6236 				port_id);
6237 		return;
6238 	}
6239 	if (num_active_slaves == 0)
6240 		fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6241 			port_id);
6242 
6243 	printf("\tIEEE802.3 port: %u\n", port_id);
6244 	ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6245 	if (ret) {
6246 		fprintf(stderr, "\tGet bonded device %u info failed\n",
6247 			port_id);
6248 		return;
6249 	}
6250 	lacp_conf_show(&port_conf);
6251 
6252 	for (i = 0; i < num_active_slaves; i++) {
6253 		ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6254 				&slave_info);
6255 		if (ret) {
6256 			fprintf(stderr, "\tGet slave device %u info failed\n",
6257 				slaves[i]);
6258 			return;
6259 		}
6260 		printf("\tSlave Port: %u\n", slaves[i]);
6261 		lacp_slave_info_show(&slave_info);
6262 	}
6263 }
6264 
6265 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6266 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6267 		show, "show");
6268 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6269 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6270 		bonding, "bonding");
6271 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6272 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6273 		bonding, "lacp");
6274 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6275 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6276 		info, "info");
6277 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6278 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6279 		port_id, RTE_UINT16);
6280 
6281 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6282 		.f = cmd_show_bonding_lacp_info_parsed,
6283 		.help_str = "show bonding lacp info <port_id> : "
6284 			"Show bonding IEEE802.3 information for port_id",
6285 		.data = NULL,
6286 		.tokens = {
6287 			(void *)&cmd_show_bonding_lacp_info_show,
6288 			(void *)&cmd_show_bonding_lacp_info_bonding,
6289 			(void *)&cmd_show_bonding_lacp_info_lacp,
6290 			(void *)&cmd_show_bonding_lacp_info_info,
6291 			(void *)&cmd_show_bonding_lacp_info_port_id,
6292 			NULL
6293 		}
6294 };
6295 
6296 /* *** SHOW NIC BONDING CONFIGURATION *** */
6297 struct cmd_show_bonding_config_result {
6298 	cmdline_fixed_string_t show;
6299 	cmdline_fixed_string_t bonding;
6300 	cmdline_fixed_string_t config;
6301 	portid_t port_id;
6302 };
6303 
6304 static void cmd_show_bonding_config_parsed(void *parsed_result,
6305 		__rte_unused  struct cmdline *cl,
6306 		__rte_unused void *data)
6307 {
6308 	struct cmd_show_bonding_config_result *res = parsed_result;
6309 	int bonding_mode, agg_mode;
6310 	portid_t slaves[RTE_MAX_ETHPORTS];
6311 	int num_slaves, num_active_slaves;
6312 	int primary_id;
6313 	int i;
6314 	portid_t port_id = res->port_id;
6315 
6316 	/* Display the bonding mode.*/
6317 	bonding_mode = rte_eth_bond_mode_get(port_id);
6318 	if (bonding_mode < 0) {
6319 		fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6320 			port_id);
6321 		return;
6322 	} else
6323 		printf("\tBonding mode: %d\n", bonding_mode);
6324 
6325 	if (bonding_mode == BONDING_MODE_BALANCE ||
6326 		bonding_mode == BONDING_MODE_8023AD) {
6327 		int balance_xmit_policy;
6328 
6329 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6330 		if (balance_xmit_policy < 0) {
6331 			fprintf(stderr,
6332 				"\tFailed to get balance xmit policy for port = %d\n",
6333 				port_id);
6334 			return;
6335 		} else {
6336 			printf("\tBalance Xmit Policy: ");
6337 
6338 			switch (balance_xmit_policy) {
6339 			case BALANCE_XMIT_POLICY_LAYER2:
6340 				printf("BALANCE_XMIT_POLICY_LAYER2");
6341 				break;
6342 			case BALANCE_XMIT_POLICY_LAYER23:
6343 				printf("BALANCE_XMIT_POLICY_LAYER23");
6344 				break;
6345 			case BALANCE_XMIT_POLICY_LAYER34:
6346 				printf("BALANCE_XMIT_POLICY_LAYER34");
6347 				break;
6348 			}
6349 			printf("\n");
6350 		}
6351 	}
6352 
6353 	if (bonding_mode == BONDING_MODE_8023AD) {
6354 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6355 		printf("\tIEEE802.3AD Aggregator Mode: ");
6356 		switch (agg_mode) {
6357 		case AGG_BANDWIDTH:
6358 			printf("bandwidth");
6359 			break;
6360 		case AGG_STABLE:
6361 			printf("stable");
6362 			break;
6363 		case AGG_COUNT:
6364 			printf("count");
6365 			break;
6366 		}
6367 		printf("\n");
6368 	}
6369 
6370 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6371 
6372 	if (num_slaves < 0) {
6373 		fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6374 			port_id);
6375 		return;
6376 	}
6377 	if (num_slaves > 0) {
6378 		printf("\tSlaves (%d): [", num_slaves);
6379 		for (i = 0; i < num_slaves - 1; i++)
6380 			printf("%d ", slaves[i]);
6381 
6382 		printf("%d]\n", slaves[num_slaves - 1]);
6383 	} else {
6384 		printf("\tSlaves: []\n");
6385 
6386 	}
6387 
6388 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6389 			RTE_MAX_ETHPORTS);
6390 
6391 	if (num_active_slaves < 0) {
6392 		fprintf(stderr,
6393 			"\tFailed to get active slave list for port = %d\n",
6394 			port_id);
6395 		return;
6396 	}
6397 	if (num_active_slaves > 0) {
6398 		printf("\tActive Slaves (%d): [", num_active_slaves);
6399 		for (i = 0; i < num_active_slaves - 1; i++)
6400 			printf("%d ", slaves[i]);
6401 
6402 		printf("%d]\n", slaves[num_active_slaves - 1]);
6403 
6404 	} else {
6405 		printf("\tActive Slaves: []\n");
6406 
6407 	}
6408 
6409 	primary_id = rte_eth_bond_primary_get(port_id);
6410 	if (primary_id < 0) {
6411 		fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6412 			port_id);
6413 		return;
6414 	} else
6415 		printf("\tPrimary: [%d]\n", primary_id);
6416 
6417 }
6418 
6419 cmdline_parse_token_string_t cmd_showbonding_config_show =
6420 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6421 		show, "show");
6422 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6423 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6424 		bonding, "bonding");
6425 cmdline_parse_token_string_t cmd_showbonding_config_config =
6426 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6427 		config, "config");
6428 cmdline_parse_token_num_t cmd_showbonding_config_port =
6429 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6430 		port_id, RTE_UINT16);
6431 
6432 cmdline_parse_inst_t cmd_show_bonding_config = {
6433 		.f = cmd_show_bonding_config_parsed,
6434 		.help_str = "show bonding config <port_id>: "
6435 			"Show the bonding config for port_id",
6436 		.data = NULL,
6437 		.tokens = {
6438 				(void *)&cmd_showbonding_config_show,
6439 				(void *)&cmd_showbonding_config_bonding,
6440 				(void *)&cmd_showbonding_config_config,
6441 				(void *)&cmd_showbonding_config_port,
6442 				NULL
6443 		}
6444 };
6445 
6446 /* *** SET BONDING PRIMARY *** */
6447 struct cmd_set_bonding_primary_result {
6448 	cmdline_fixed_string_t set;
6449 	cmdline_fixed_string_t bonding;
6450 	cmdline_fixed_string_t primary;
6451 	portid_t slave_id;
6452 	portid_t port_id;
6453 };
6454 
6455 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6456 		__rte_unused  struct cmdline *cl,
6457 		__rte_unused void *data)
6458 {
6459 	struct cmd_set_bonding_primary_result *res = parsed_result;
6460 	portid_t master_port_id = res->port_id;
6461 	portid_t slave_port_id = res->slave_id;
6462 
6463 	/* Set the primary slave for a bonded device. */
6464 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6465 		fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6466 			master_port_id);
6467 		return;
6468 	}
6469 	init_port_config();
6470 }
6471 
6472 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6473 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6474 		set, "set");
6475 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6477 		bonding, "bonding");
6478 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6480 		primary, "primary");
6481 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6482 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6483 		slave_id, RTE_UINT16);
6484 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6486 		port_id, RTE_UINT16);
6487 
6488 cmdline_parse_inst_t cmd_set_bonding_primary = {
6489 		.f = cmd_set_bonding_primary_parsed,
6490 		.help_str = "set bonding primary <slave_id> <port_id>: "
6491 			"Set the primary slave for port_id",
6492 		.data = NULL,
6493 		.tokens = {
6494 				(void *)&cmd_setbonding_primary_set,
6495 				(void *)&cmd_setbonding_primary_bonding,
6496 				(void *)&cmd_setbonding_primary_primary,
6497 				(void *)&cmd_setbonding_primary_slave,
6498 				(void *)&cmd_setbonding_primary_port,
6499 				NULL
6500 		}
6501 };
6502 
6503 /* *** ADD SLAVE *** */
6504 struct cmd_add_bonding_slave_result {
6505 	cmdline_fixed_string_t add;
6506 	cmdline_fixed_string_t bonding;
6507 	cmdline_fixed_string_t slave;
6508 	portid_t slave_id;
6509 	portid_t port_id;
6510 };
6511 
6512 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6513 		__rte_unused  struct cmdline *cl,
6514 		__rte_unused void *data)
6515 {
6516 	struct cmd_add_bonding_slave_result *res = parsed_result;
6517 	portid_t master_port_id = res->port_id;
6518 	portid_t slave_port_id = res->slave_id;
6519 
6520 	/* add the slave for a bonded device. */
6521 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6522 		fprintf(stderr,
6523 			"\t Failed to add slave %d to master port = %d.\n",
6524 			slave_port_id, master_port_id);
6525 		return;
6526 	}
6527 	init_port_config();
6528 	set_port_slave_flag(slave_port_id);
6529 }
6530 
6531 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6532 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6533 		add, "add");
6534 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6535 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6536 		bonding, "bonding");
6537 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6538 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6539 		slave, "slave");
6540 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6541 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6542 		slave_id, RTE_UINT16);
6543 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6544 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6545 		port_id, RTE_UINT16);
6546 
6547 cmdline_parse_inst_t cmd_add_bonding_slave = {
6548 		.f = cmd_add_bonding_slave_parsed,
6549 		.help_str = "add bonding slave <slave_id> <port_id>: "
6550 			"Add a slave device to a bonded device",
6551 		.data = NULL,
6552 		.tokens = {
6553 				(void *)&cmd_addbonding_slave_add,
6554 				(void *)&cmd_addbonding_slave_bonding,
6555 				(void *)&cmd_addbonding_slave_slave,
6556 				(void *)&cmd_addbonding_slave_slaveid,
6557 				(void *)&cmd_addbonding_slave_port,
6558 				NULL
6559 		}
6560 };
6561 
6562 /* *** REMOVE SLAVE *** */
6563 struct cmd_remove_bonding_slave_result {
6564 	cmdline_fixed_string_t remove;
6565 	cmdline_fixed_string_t bonding;
6566 	cmdline_fixed_string_t slave;
6567 	portid_t slave_id;
6568 	portid_t port_id;
6569 };
6570 
6571 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6572 		__rte_unused  struct cmdline *cl,
6573 		__rte_unused void *data)
6574 {
6575 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6576 	portid_t master_port_id = res->port_id;
6577 	portid_t slave_port_id = res->slave_id;
6578 
6579 	/* remove the slave from a bonded device. */
6580 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6581 		fprintf(stderr,
6582 			"\t Failed to remove slave %d from master port = %d.\n",
6583 			slave_port_id, master_port_id);
6584 		return;
6585 	}
6586 	init_port_config();
6587 	clear_port_slave_flag(slave_port_id);
6588 }
6589 
6590 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6591 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6592 				remove, "remove");
6593 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6594 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6595 				bonding, "bonding");
6596 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6597 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6598 				slave, "slave");
6599 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6600 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6601 				slave_id, RTE_UINT16);
6602 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6603 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6604 				port_id, RTE_UINT16);
6605 
6606 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6607 		.f = cmd_remove_bonding_slave_parsed,
6608 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6609 			"Remove a slave device from a bonded device",
6610 		.data = NULL,
6611 		.tokens = {
6612 				(void *)&cmd_removebonding_slave_remove,
6613 				(void *)&cmd_removebonding_slave_bonding,
6614 				(void *)&cmd_removebonding_slave_slave,
6615 				(void *)&cmd_removebonding_slave_slaveid,
6616 				(void *)&cmd_removebonding_slave_port,
6617 				NULL
6618 		}
6619 };
6620 
6621 /* *** CREATE BONDED DEVICE *** */
6622 struct cmd_create_bonded_device_result {
6623 	cmdline_fixed_string_t create;
6624 	cmdline_fixed_string_t bonded;
6625 	cmdline_fixed_string_t device;
6626 	uint8_t mode;
6627 	uint8_t socket;
6628 };
6629 
6630 static int bond_dev_num = 0;
6631 
6632 static void cmd_create_bonded_device_parsed(void *parsed_result,
6633 		__rte_unused  struct cmdline *cl,
6634 		__rte_unused void *data)
6635 {
6636 	struct cmd_create_bonded_device_result *res = parsed_result;
6637 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6638 	int port_id;
6639 	int ret;
6640 
6641 	if (test_done == 0) {
6642 		fprintf(stderr, "Please stop forwarding first\n");
6643 		return;
6644 	}
6645 
6646 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6647 			bond_dev_num++);
6648 
6649 	/* Create a new bonded device. */
6650 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6651 	if (port_id < 0) {
6652 		fprintf(stderr, "\t Failed to create bonded device.\n");
6653 		return;
6654 	} else {
6655 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6656 				port_id);
6657 
6658 		/* Update number of ports */
6659 		nb_ports = rte_eth_dev_count_avail();
6660 		reconfig(port_id, res->socket);
6661 		ret = rte_eth_promiscuous_enable(port_id);
6662 		if (ret != 0)
6663 			fprintf(stderr,
6664 				"Failed to enable promiscuous mode for port %u: %s - ignore\n",
6665 				port_id, rte_strerror(-ret));
6666 
6667 		ports[port_id].need_setup = 0;
6668 		ports[port_id].port_status = RTE_PORT_STOPPED;
6669 	}
6670 
6671 }
6672 
6673 cmdline_parse_token_string_t cmd_createbonded_device_create =
6674 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6675 				create, "create");
6676 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6677 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6678 				bonded, "bonded");
6679 cmdline_parse_token_string_t cmd_createbonded_device_device =
6680 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6681 				device, "device");
6682 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6683 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6684 				mode, RTE_UINT8);
6685 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6686 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6687 				socket, RTE_UINT8);
6688 
6689 cmdline_parse_inst_t cmd_create_bonded_device = {
6690 		.f = cmd_create_bonded_device_parsed,
6691 		.help_str = "create bonded device <mode> <socket>: "
6692 			"Create a new bonded device with specific bonding mode and socket",
6693 		.data = NULL,
6694 		.tokens = {
6695 				(void *)&cmd_createbonded_device_create,
6696 				(void *)&cmd_createbonded_device_bonded,
6697 				(void *)&cmd_createbonded_device_device,
6698 				(void *)&cmd_createbonded_device_mode,
6699 				(void *)&cmd_createbonded_device_socket,
6700 				NULL
6701 		}
6702 };
6703 
6704 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6705 struct cmd_set_bond_mac_addr_result {
6706 	cmdline_fixed_string_t set;
6707 	cmdline_fixed_string_t bonding;
6708 	cmdline_fixed_string_t mac_addr;
6709 	uint16_t port_num;
6710 	struct rte_ether_addr address;
6711 };
6712 
6713 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6714 		__rte_unused  struct cmdline *cl,
6715 		__rte_unused void *data)
6716 {
6717 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6718 	int ret;
6719 
6720 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6721 		return;
6722 
6723 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6724 
6725 	/* check the return value and print it if is < 0 */
6726 	if (ret < 0)
6727 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6728 			strerror(-ret));
6729 }
6730 
6731 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6732 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6733 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6734 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6735 				"bonding");
6736 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6737 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6738 				"mac_addr");
6739 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6740 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6741 				port_num, RTE_UINT16);
6742 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6743 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6744 
6745 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6746 		.f = cmd_set_bond_mac_addr_parsed,
6747 		.data = (void *) 0,
6748 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6749 		.tokens = {
6750 				(void *)&cmd_set_bond_mac_addr_set,
6751 				(void *)&cmd_set_bond_mac_addr_bonding,
6752 				(void *)&cmd_set_bond_mac_addr_mac,
6753 				(void *)&cmd_set_bond_mac_addr_portnum,
6754 				(void *)&cmd_set_bond_mac_addr_addr,
6755 				NULL
6756 		}
6757 };
6758 
6759 
6760 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6761 struct cmd_set_bond_mon_period_result {
6762 	cmdline_fixed_string_t set;
6763 	cmdline_fixed_string_t bonding;
6764 	cmdline_fixed_string_t mon_period;
6765 	uint16_t port_num;
6766 	uint32_t period_ms;
6767 };
6768 
6769 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6770 		__rte_unused  struct cmdline *cl,
6771 		__rte_unused void *data)
6772 {
6773 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6774 	int ret;
6775 
6776 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6777 
6778 	/* check the return value and print it if is < 0 */
6779 	if (ret < 0)
6780 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6781 			strerror(-ret));
6782 }
6783 
6784 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6785 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6786 				set, "set");
6787 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6788 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6789 				bonding, "bonding");
6790 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6791 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6792 				mon_period,	"mon_period");
6793 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6794 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6795 				port_num, RTE_UINT16);
6796 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6797 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6798 				period_ms, RTE_UINT32);
6799 
6800 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6801 		.f = cmd_set_bond_mon_period_parsed,
6802 		.data = (void *) 0,
6803 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6804 		.tokens = {
6805 				(void *)&cmd_set_bond_mon_period_set,
6806 				(void *)&cmd_set_bond_mon_period_bonding,
6807 				(void *)&cmd_set_bond_mon_period_mon_period,
6808 				(void *)&cmd_set_bond_mon_period_portnum,
6809 				(void *)&cmd_set_bond_mon_period_period_ms,
6810 				NULL
6811 		}
6812 };
6813 
6814 
6815 
6816 struct cmd_set_bonding_agg_mode_policy_result {
6817 	cmdline_fixed_string_t set;
6818 	cmdline_fixed_string_t bonding;
6819 	cmdline_fixed_string_t agg_mode;
6820 	uint16_t port_num;
6821 	cmdline_fixed_string_t policy;
6822 };
6823 
6824 
6825 static void
6826 cmd_set_bonding_agg_mode(void *parsed_result,
6827 		__rte_unused struct cmdline *cl,
6828 		__rte_unused void *data)
6829 {
6830 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6831 	uint8_t policy = AGG_BANDWIDTH;
6832 
6833 	if (!strcmp(res->policy, "bandwidth"))
6834 		policy = AGG_BANDWIDTH;
6835 	else if (!strcmp(res->policy, "stable"))
6836 		policy = AGG_STABLE;
6837 	else if (!strcmp(res->policy, "count"))
6838 		policy = AGG_COUNT;
6839 
6840 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6841 }
6842 
6843 
6844 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6845 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6846 				set, "set");
6847 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6848 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6849 				bonding, "bonding");
6850 
6851 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6852 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6853 				agg_mode, "agg_mode");
6854 
6855 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6856 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6857 				port_num, RTE_UINT16);
6858 
6859 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6860 	TOKEN_STRING_INITIALIZER(
6861 			struct cmd_set_bonding_balance_xmit_policy_result,
6862 		policy, "stable#bandwidth#count");
6863 
6864 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6865 	.f = cmd_set_bonding_agg_mode,
6866 	.data = (void *) 0,
6867 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6868 	.tokens = {
6869 			(void *)&cmd_set_bonding_agg_mode_set,
6870 			(void *)&cmd_set_bonding_agg_mode_bonding,
6871 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6872 			(void *)&cmd_set_bonding_agg_mode_portnum,
6873 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6874 			NULL
6875 		}
6876 };
6877 
6878 
6879 #endif /* RTE_NET_BOND */
6880 
6881 /* *** SET FORWARDING MODE *** */
6882 struct cmd_set_fwd_mode_result {
6883 	cmdline_fixed_string_t set;
6884 	cmdline_fixed_string_t fwd;
6885 	cmdline_fixed_string_t mode;
6886 };
6887 
6888 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6889 				    __rte_unused struct cmdline *cl,
6890 				    __rte_unused void *data)
6891 {
6892 	struct cmd_set_fwd_mode_result *res = parsed_result;
6893 
6894 	retry_enabled = 0;
6895 	set_pkt_forwarding_mode(res->mode);
6896 }
6897 
6898 cmdline_parse_token_string_t cmd_setfwd_set =
6899 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6900 cmdline_parse_token_string_t cmd_setfwd_fwd =
6901 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6902 cmdline_parse_token_string_t cmd_setfwd_mode =
6903 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6904 		"" /* defined at init */);
6905 
6906 cmdline_parse_inst_t cmd_set_fwd_mode = {
6907 	.f = cmd_set_fwd_mode_parsed,
6908 	.data = NULL,
6909 	.help_str = NULL, /* defined at init */
6910 	.tokens = {
6911 		(void *)&cmd_setfwd_set,
6912 		(void *)&cmd_setfwd_fwd,
6913 		(void *)&cmd_setfwd_mode,
6914 		NULL,
6915 	},
6916 };
6917 
6918 static void cmd_set_fwd_mode_init(void)
6919 {
6920 	char *modes, *c;
6921 	static char token[128];
6922 	static char help[256];
6923 	cmdline_parse_token_string_t *token_struct;
6924 
6925 	modes = list_pkt_forwarding_modes();
6926 	snprintf(help, sizeof(help), "set fwd %s: "
6927 		"Set packet forwarding mode", modes);
6928 	cmd_set_fwd_mode.help_str = help;
6929 
6930 	/* string token separator is # */
6931 	for (c = token; *modes != '\0'; modes++)
6932 		if (*modes == '|')
6933 			*c++ = '#';
6934 		else
6935 			*c++ = *modes;
6936 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6937 	token_struct->string_data.str = token;
6938 }
6939 
6940 /* *** SET RETRY FORWARDING MODE *** */
6941 struct cmd_set_fwd_retry_mode_result {
6942 	cmdline_fixed_string_t set;
6943 	cmdline_fixed_string_t fwd;
6944 	cmdline_fixed_string_t mode;
6945 	cmdline_fixed_string_t retry;
6946 };
6947 
6948 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6949 			    __rte_unused struct cmdline *cl,
6950 			    __rte_unused void *data)
6951 {
6952 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6953 
6954 	retry_enabled = 1;
6955 	set_pkt_forwarding_mode(res->mode);
6956 }
6957 
6958 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6959 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6960 			set, "set");
6961 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6962 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6963 			fwd, "fwd");
6964 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6965 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6966 			mode,
6967 		"" /* defined at init */);
6968 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6969 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6970 			retry, "retry");
6971 
6972 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6973 	.f = cmd_set_fwd_retry_mode_parsed,
6974 	.data = NULL,
6975 	.help_str = NULL, /* defined at init */
6976 	.tokens = {
6977 		(void *)&cmd_setfwd_retry_set,
6978 		(void *)&cmd_setfwd_retry_fwd,
6979 		(void *)&cmd_setfwd_retry_mode,
6980 		(void *)&cmd_setfwd_retry_retry,
6981 		NULL,
6982 	},
6983 };
6984 
6985 static void cmd_set_fwd_retry_mode_init(void)
6986 {
6987 	char *modes, *c;
6988 	static char token[128];
6989 	static char help[256];
6990 	cmdline_parse_token_string_t *token_struct;
6991 
6992 	modes = list_pkt_forwarding_retry_modes();
6993 	snprintf(help, sizeof(help), "set fwd %s retry: "
6994 		"Set packet forwarding mode with retry", modes);
6995 	cmd_set_fwd_retry_mode.help_str = help;
6996 
6997 	/* string token separator is # */
6998 	for (c = token; *modes != '\0'; modes++)
6999 		if (*modes == '|')
7000 			*c++ = '#';
7001 		else
7002 			*c++ = *modes;
7003 	token_struct = (cmdline_parse_token_string_t *)
7004 		cmd_set_fwd_retry_mode.tokens[2];
7005 	token_struct->string_data.str = token;
7006 }
7007 
7008 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7009 struct cmd_set_burst_tx_retry_result {
7010 	cmdline_fixed_string_t set;
7011 	cmdline_fixed_string_t burst;
7012 	cmdline_fixed_string_t tx;
7013 	cmdline_fixed_string_t delay;
7014 	uint32_t time;
7015 	cmdline_fixed_string_t retry;
7016 	uint32_t retry_num;
7017 };
7018 
7019 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7020 					__rte_unused struct cmdline *cl,
7021 					__rte_unused void *data)
7022 {
7023 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
7024 
7025 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7026 		&& !strcmp(res->tx, "tx")) {
7027 		if (!strcmp(res->delay, "delay"))
7028 			burst_tx_delay_time = res->time;
7029 		if (!strcmp(res->retry, "retry"))
7030 			burst_tx_retry_num = res->retry_num;
7031 	}
7032 
7033 }
7034 
7035 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7036 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7037 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7038 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7039 				 "burst");
7040 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7041 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7042 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7043 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7044 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7045 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7046 				 RTE_UINT32);
7047 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7048 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7049 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7050 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7051 				 RTE_UINT32);
7052 
7053 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7054 	.f = cmd_set_burst_tx_retry_parsed,
7055 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7056 	.tokens = {
7057 		(void *)&cmd_set_burst_tx_retry_set,
7058 		(void *)&cmd_set_burst_tx_retry_burst,
7059 		(void *)&cmd_set_burst_tx_retry_tx,
7060 		(void *)&cmd_set_burst_tx_retry_delay,
7061 		(void *)&cmd_set_burst_tx_retry_time,
7062 		(void *)&cmd_set_burst_tx_retry_retry,
7063 		(void *)&cmd_set_burst_tx_retry_retry_num,
7064 		NULL,
7065 	},
7066 };
7067 
7068 /* *** SET PROMISC MODE *** */
7069 struct cmd_set_promisc_mode_result {
7070 	cmdline_fixed_string_t set;
7071 	cmdline_fixed_string_t promisc;
7072 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7073 	uint16_t port_num;               /* valid if "allports" argument == 0 */
7074 	cmdline_fixed_string_t mode;
7075 };
7076 
7077 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7078 					__rte_unused struct cmdline *cl,
7079 					void *allports)
7080 {
7081 	struct cmd_set_promisc_mode_result *res = parsed_result;
7082 	int enable;
7083 	portid_t i;
7084 
7085 	if (!strcmp(res->mode, "on"))
7086 		enable = 1;
7087 	else
7088 		enable = 0;
7089 
7090 	/* all ports */
7091 	if (allports) {
7092 		RTE_ETH_FOREACH_DEV(i)
7093 			eth_set_promisc_mode(i, enable);
7094 	} else {
7095 		eth_set_promisc_mode(res->port_num, enable);
7096 	}
7097 }
7098 
7099 cmdline_parse_token_string_t cmd_setpromisc_set =
7100 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7101 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7102 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7103 				 "promisc");
7104 cmdline_parse_token_string_t cmd_setpromisc_portall =
7105 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7106 				 "all");
7107 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7108 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7109 			      RTE_UINT16);
7110 cmdline_parse_token_string_t cmd_setpromisc_mode =
7111 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7112 				 "on#off");
7113 
7114 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7115 	.f = cmd_set_promisc_mode_parsed,
7116 	.data = (void *)1,
7117 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
7118 	.tokens = {
7119 		(void *)&cmd_setpromisc_set,
7120 		(void *)&cmd_setpromisc_promisc,
7121 		(void *)&cmd_setpromisc_portall,
7122 		(void *)&cmd_setpromisc_mode,
7123 		NULL,
7124 	},
7125 };
7126 
7127 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7128 	.f = cmd_set_promisc_mode_parsed,
7129 	.data = (void *)0,
7130 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7131 	.tokens = {
7132 		(void *)&cmd_setpromisc_set,
7133 		(void *)&cmd_setpromisc_promisc,
7134 		(void *)&cmd_setpromisc_portnum,
7135 		(void *)&cmd_setpromisc_mode,
7136 		NULL,
7137 	},
7138 };
7139 
7140 /* *** SET ALLMULTI MODE *** */
7141 struct cmd_set_allmulti_mode_result {
7142 	cmdline_fixed_string_t set;
7143 	cmdline_fixed_string_t allmulti;
7144 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7145 	uint16_t port_num;               /* valid if "allports" argument == 0 */
7146 	cmdline_fixed_string_t mode;
7147 };
7148 
7149 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7150 					__rte_unused struct cmdline *cl,
7151 					void *allports)
7152 {
7153 	struct cmd_set_allmulti_mode_result *res = parsed_result;
7154 	int enable;
7155 	portid_t i;
7156 
7157 	if (!strcmp(res->mode, "on"))
7158 		enable = 1;
7159 	else
7160 		enable = 0;
7161 
7162 	/* all ports */
7163 	if (allports) {
7164 		RTE_ETH_FOREACH_DEV(i) {
7165 			eth_set_allmulticast_mode(i, enable);
7166 		}
7167 	}
7168 	else {
7169 		eth_set_allmulticast_mode(res->port_num, enable);
7170 	}
7171 }
7172 
7173 cmdline_parse_token_string_t cmd_setallmulti_set =
7174 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7175 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7176 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7177 				 "allmulti");
7178 cmdline_parse_token_string_t cmd_setallmulti_portall =
7179 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7180 				 "all");
7181 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7182 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7183 			      RTE_UINT16);
7184 cmdline_parse_token_string_t cmd_setallmulti_mode =
7185 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7186 				 "on#off");
7187 
7188 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7189 	.f = cmd_set_allmulti_mode_parsed,
7190 	.data = (void *)1,
7191 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7192 	.tokens = {
7193 		(void *)&cmd_setallmulti_set,
7194 		(void *)&cmd_setallmulti_allmulti,
7195 		(void *)&cmd_setallmulti_portall,
7196 		(void *)&cmd_setallmulti_mode,
7197 		NULL,
7198 	},
7199 };
7200 
7201 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7202 	.f = cmd_set_allmulti_mode_parsed,
7203 	.data = (void *)0,
7204 	.help_str = "set allmulti <port_id> on|off: "
7205 		"Set allmulti mode on port_id",
7206 	.tokens = {
7207 		(void *)&cmd_setallmulti_set,
7208 		(void *)&cmd_setallmulti_allmulti,
7209 		(void *)&cmd_setallmulti_portnum,
7210 		(void *)&cmd_setallmulti_mode,
7211 		NULL,
7212 	},
7213 };
7214 
7215 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7216 struct cmd_link_flow_ctrl_show {
7217 	cmdline_fixed_string_t show;
7218 	cmdline_fixed_string_t port;
7219 	portid_t port_id;
7220 	cmdline_fixed_string_t flow_ctrl;
7221 };
7222 
7223 cmdline_parse_token_string_t cmd_lfc_show_show =
7224 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7225 				show, "show");
7226 cmdline_parse_token_string_t cmd_lfc_show_port =
7227 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7228 				port, "port");
7229 cmdline_parse_token_num_t cmd_lfc_show_portid =
7230 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7231 				port_id, RTE_UINT16);
7232 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7233 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7234 				flow_ctrl, "flow_ctrl");
7235 
7236 static void
7237 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7238 			      __rte_unused struct cmdline *cl,
7239 			      __rte_unused void *data)
7240 {
7241 	struct cmd_link_flow_ctrl_show *res = parsed_result;
7242 	static const char *info_border = "*********************";
7243 	struct rte_eth_fc_conf fc_conf;
7244 	bool rx_fc_en = false;
7245 	bool tx_fc_en = false;
7246 	int ret;
7247 
7248 	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7249 	if (ret != 0) {
7250 		fprintf(stderr,
7251 			"Failed to get current flow ctrl information: err = %d\n",
7252 			ret);
7253 		return;
7254 	}
7255 
7256 	if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7257 		rx_fc_en = true;
7258 	if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7259 		tx_fc_en = true;
7260 
7261 	printf("\n%s Flow control infos for port %-2d %s\n",
7262 		info_border, res->port_id, info_border);
7263 	printf("FC mode:\n");
7264 	printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
7265 	printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
7266 	printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7267 	printf("Pause time: 0x%x\n", fc_conf.pause_time);
7268 	printf("High waterline: 0x%x\n", fc_conf.high_water);
7269 	printf("Low waterline: 0x%x\n", fc_conf.low_water);
7270 	printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7271 	printf("Forward MAC control frames: %s\n",
7272 		fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7273 	printf("\n%s**************   End  ***********%s\n",
7274 		info_border, info_border);
7275 }
7276 
7277 cmdline_parse_inst_t cmd_link_flow_control_show = {
7278 	.f = cmd_link_flow_ctrl_show_parsed,
7279 	.data = NULL,
7280 	.help_str = "show port <port_id> flow_ctrl",
7281 	.tokens = {
7282 		(void *)&cmd_lfc_show_show,
7283 		(void *)&cmd_lfc_show_port,
7284 		(void *)&cmd_lfc_show_portid,
7285 		(void *)&cmd_lfc_show_flow_ctrl,
7286 		NULL,
7287 	},
7288 };
7289 
7290 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7291 struct cmd_link_flow_ctrl_set_result {
7292 	cmdline_fixed_string_t set;
7293 	cmdline_fixed_string_t flow_ctrl;
7294 	cmdline_fixed_string_t rx;
7295 	cmdline_fixed_string_t rx_lfc_mode;
7296 	cmdline_fixed_string_t tx;
7297 	cmdline_fixed_string_t tx_lfc_mode;
7298 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
7299 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7300 	cmdline_fixed_string_t autoneg_str;
7301 	cmdline_fixed_string_t autoneg;
7302 	cmdline_fixed_string_t hw_str;
7303 	uint32_t high_water;
7304 	cmdline_fixed_string_t lw_str;
7305 	uint32_t low_water;
7306 	cmdline_fixed_string_t pt_str;
7307 	uint16_t pause_time;
7308 	cmdline_fixed_string_t xon_str;
7309 	uint16_t send_xon;
7310 	portid_t port_id;
7311 };
7312 
7313 cmdline_parse_token_string_t cmd_lfc_set_set =
7314 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7315 				set, "set");
7316 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7317 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7318 				flow_ctrl, "flow_ctrl");
7319 cmdline_parse_token_string_t cmd_lfc_set_rx =
7320 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7321 				rx, "rx");
7322 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7323 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7324 				rx_lfc_mode, "on#off");
7325 cmdline_parse_token_string_t cmd_lfc_set_tx =
7326 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7327 				tx, "tx");
7328 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7329 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7330 				tx_lfc_mode, "on#off");
7331 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7332 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7333 				hw_str, "high_water");
7334 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7335 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7336 				high_water, RTE_UINT32);
7337 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7338 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7339 				lw_str, "low_water");
7340 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7341 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7342 				low_water, RTE_UINT32);
7343 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7344 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7345 				pt_str, "pause_time");
7346 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7347 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7348 				pause_time, RTE_UINT16);
7349 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7350 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7351 				xon_str, "send_xon");
7352 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7353 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7354 				send_xon, RTE_UINT16);
7355 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7356 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7357 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7358 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7359 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7360 				mac_ctrl_frame_fwd_mode, "on#off");
7361 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7362 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7363 				autoneg_str, "autoneg");
7364 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7365 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7366 				autoneg, "on#off");
7367 cmdline_parse_token_num_t cmd_lfc_set_portid =
7368 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7369 				port_id, RTE_UINT16);
7370 
7371 /* forward declaration */
7372 static void
7373 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7374 			      void *data);
7375 
7376 cmdline_parse_inst_t cmd_link_flow_control_set = {
7377 	.f = cmd_link_flow_ctrl_set_parsed,
7378 	.data = NULL,
7379 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7380 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7381 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
7382 	.tokens = {
7383 		(void *)&cmd_lfc_set_set,
7384 		(void *)&cmd_lfc_set_flow_ctrl,
7385 		(void *)&cmd_lfc_set_rx,
7386 		(void *)&cmd_lfc_set_rx_mode,
7387 		(void *)&cmd_lfc_set_tx,
7388 		(void *)&cmd_lfc_set_tx_mode,
7389 		(void *)&cmd_lfc_set_high_water,
7390 		(void *)&cmd_lfc_set_low_water,
7391 		(void *)&cmd_lfc_set_pause_time,
7392 		(void *)&cmd_lfc_set_send_xon,
7393 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7394 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7395 		(void *)&cmd_lfc_set_autoneg_str,
7396 		(void *)&cmd_lfc_set_autoneg,
7397 		(void *)&cmd_lfc_set_portid,
7398 		NULL,
7399 	},
7400 };
7401 
7402 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7403 	.f = cmd_link_flow_ctrl_set_parsed,
7404 	.data = (void *)&cmd_link_flow_control_set_rx,
7405 	.help_str = "set flow_ctrl rx on|off <port_id>: "
7406 		"Change rx flow control parameter",
7407 	.tokens = {
7408 		(void *)&cmd_lfc_set_set,
7409 		(void *)&cmd_lfc_set_flow_ctrl,
7410 		(void *)&cmd_lfc_set_rx,
7411 		(void *)&cmd_lfc_set_rx_mode,
7412 		(void *)&cmd_lfc_set_portid,
7413 		NULL,
7414 	},
7415 };
7416 
7417 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7418 	.f = cmd_link_flow_ctrl_set_parsed,
7419 	.data = (void *)&cmd_link_flow_control_set_tx,
7420 	.help_str = "set flow_ctrl tx on|off <port_id>: "
7421 		"Change tx flow control parameter",
7422 	.tokens = {
7423 		(void *)&cmd_lfc_set_set,
7424 		(void *)&cmd_lfc_set_flow_ctrl,
7425 		(void *)&cmd_lfc_set_tx,
7426 		(void *)&cmd_lfc_set_tx_mode,
7427 		(void *)&cmd_lfc_set_portid,
7428 		NULL,
7429 	},
7430 };
7431 
7432 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7433 	.f = cmd_link_flow_ctrl_set_parsed,
7434 	.data = (void *)&cmd_link_flow_control_set_hw,
7435 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
7436 		"Change high water flow control parameter",
7437 	.tokens = {
7438 		(void *)&cmd_lfc_set_set,
7439 		(void *)&cmd_lfc_set_flow_ctrl,
7440 		(void *)&cmd_lfc_set_high_water_str,
7441 		(void *)&cmd_lfc_set_high_water,
7442 		(void *)&cmd_lfc_set_portid,
7443 		NULL,
7444 	},
7445 };
7446 
7447 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7448 	.f = cmd_link_flow_ctrl_set_parsed,
7449 	.data = (void *)&cmd_link_flow_control_set_lw,
7450 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7451 		"Change low water flow control parameter",
7452 	.tokens = {
7453 		(void *)&cmd_lfc_set_set,
7454 		(void *)&cmd_lfc_set_flow_ctrl,
7455 		(void *)&cmd_lfc_set_low_water_str,
7456 		(void *)&cmd_lfc_set_low_water,
7457 		(void *)&cmd_lfc_set_portid,
7458 		NULL,
7459 	},
7460 };
7461 
7462 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7463 	.f = cmd_link_flow_ctrl_set_parsed,
7464 	.data = (void *)&cmd_link_flow_control_set_pt,
7465 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7466 		"Change pause time flow control parameter",
7467 	.tokens = {
7468 		(void *)&cmd_lfc_set_set,
7469 		(void *)&cmd_lfc_set_flow_ctrl,
7470 		(void *)&cmd_lfc_set_pause_time_str,
7471 		(void *)&cmd_lfc_set_pause_time,
7472 		(void *)&cmd_lfc_set_portid,
7473 		NULL,
7474 	},
7475 };
7476 
7477 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7478 	.f = cmd_link_flow_ctrl_set_parsed,
7479 	.data = (void *)&cmd_link_flow_control_set_xon,
7480 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7481 		"Change send_xon flow control parameter",
7482 	.tokens = {
7483 		(void *)&cmd_lfc_set_set,
7484 		(void *)&cmd_lfc_set_flow_ctrl,
7485 		(void *)&cmd_lfc_set_send_xon_str,
7486 		(void *)&cmd_lfc_set_send_xon,
7487 		(void *)&cmd_lfc_set_portid,
7488 		NULL,
7489 	},
7490 };
7491 
7492 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7493 	.f = cmd_link_flow_ctrl_set_parsed,
7494 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7495 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7496 		"Change mac ctrl fwd flow control parameter",
7497 	.tokens = {
7498 		(void *)&cmd_lfc_set_set,
7499 		(void *)&cmd_lfc_set_flow_ctrl,
7500 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7501 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7502 		(void *)&cmd_lfc_set_portid,
7503 		NULL,
7504 	},
7505 };
7506 
7507 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7508 	.f = cmd_link_flow_ctrl_set_parsed,
7509 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7510 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7511 		"Change autoneg flow control parameter",
7512 	.tokens = {
7513 		(void *)&cmd_lfc_set_set,
7514 		(void *)&cmd_lfc_set_flow_ctrl,
7515 		(void *)&cmd_lfc_set_autoneg_str,
7516 		(void *)&cmd_lfc_set_autoneg,
7517 		(void *)&cmd_lfc_set_portid,
7518 		NULL,
7519 	},
7520 };
7521 
7522 static void
7523 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7524 			      __rte_unused struct cmdline *cl,
7525 			      void *data)
7526 {
7527 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7528 	cmdline_parse_inst_t *cmd = data;
7529 	struct rte_eth_fc_conf fc_conf;
7530 	int rx_fc_en = 0;
7531 	int tx_fc_en = 0;
7532 	int ret;
7533 
7534 	/*
7535 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7536 	 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7537 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7538 	 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7539 	 */
7540 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7541 			{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7542 	};
7543 
7544 	/* Partial command line, retrieve current configuration */
7545 	if (cmd) {
7546 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7547 		if (ret != 0) {
7548 			fprintf(stderr,
7549 				"cannot get current flow ctrl parameters, return code = %d\n",
7550 				ret);
7551 			return;
7552 		}
7553 
7554 		if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7555 		    (fc_conf.mode == RTE_ETH_FC_FULL))
7556 			rx_fc_en = 1;
7557 		if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7558 		    (fc_conf.mode == RTE_ETH_FC_FULL))
7559 			tx_fc_en = 1;
7560 	}
7561 
7562 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7563 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7564 
7565 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7566 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7567 
7568 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7569 
7570 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7571 		fc_conf.high_water = res->high_water;
7572 
7573 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7574 		fc_conf.low_water = res->low_water;
7575 
7576 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7577 		fc_conf.pause_time = res->pause_time;
7578 
7579 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7580 		fc_conf.send_xon = res->send_xon;
7581 
7582 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7583 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7584 			fc_conf.mac_ctrl_frame_fwd = 1;
7585 		else
7586 			fc_conf.mac_ctrl_frame_fwd = 0;
7587 	}
7588 
7589 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7590 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7591 
7592 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7593 	if (ret != 0)
7594 		fprintf(stderr,
7595 			"bad flow control parameter, return code = %d\n",
7596 			ret);
7597 }
7598 
7599 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7600 struct cmd_priority_flow_ctrl_set_result {
7601 	cmdline_fixed_string_t set;
7602 	cmdline_fixed_string_t pfc_ctrl;
7603 	cmdline_fixed_string_t rx;
7604 	cmdline_fixed_string_t rx_pfc_mode;
7605 	cmdline_fixed_string_t tx;
7606 	cmdline_fixed_string_t tx_pfc_mode;
7607 	uint32_t high_water;
7608 	uint32_t low_water;
7609 	uint16_t pause_time;
7610 	uint8_t  priority;
7611 	portid_t port_id;
7612 };
7613 
7614 static void
7615 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7616 		       __rte_unused struct cmdline *cl,
7617 		       __rte_unused void *data)
7618 {
7619 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7620 	struct rte_eth_pfc_conf pfc_conf;
7621 	int rx_fc_enable, tx_fc_enable;
7622 	int ret;
7623 
7624 	/*
7625 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7626 	 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7627 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7628 	 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7629 	 */
7630 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7631 		{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7632 	};
7633 
7634 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7635 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7636 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7637 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7638 	pfc_conf.fc.high_water = res->high_water;
7639 	pfc_conf.fc.low_water  = res->low_water;
7640 	pfc_conf.fc.pause_time = res->pause_time;
7641 	pfc_conf.priority      = res->priority;
7642 
7643 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7644 	if (ret != 0)
7645 		fprintf(stderr,
7646 			"bad priority flow control parameter, return code = %d\n",
7647 			ret);
7648 }
7649 
7650 cmdline_parse_token_string_t cmd_pfc_set_set =
7651 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7652 				set, "set");
7653 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7654 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7655 				pfc_ctrl, "pfc_ctrl");
7656 cmdline_parse_token_string_t cmd_pfc_set_rx =
7657 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7658 				rx, "rx");
7659 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7660 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7661 				rx_pfc_mode, "on#off");
7662 cmdline_parse_token_string_t cmd_pfc_set_tx =
7663 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7664 				tx, "tx");
7665 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7666 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7667 				tx_pfc_mode, "on#off");
7668 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7669 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7670 				high_water, RTE_UINT32);
7671 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7672 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7673 				low_water, RTE_UINT32);
7674 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7675 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7676 				pause_time, RTE_UINT16);
7677 cmdline_parse_token_num_t cmd_pfc_set_priority =
7678 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7679 				priority, RTE_UINT8);
7680 cmdline_parse_token_num_t cmd_pfc_set_portid =
7681 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7682 				port_id, RTE_UINT16);
7683 
7684 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7685 	.f = cmd_priority_flow_ctrl_set_parsed,
7686 	.data = NULL,
7687 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7688 		"<pause_time> <priority> <port_id>: "
7689 		"Configure the Ethernet priority flow control",
7690 	.tokens = {
7691 		(void *)&cmd_pfc_set_set,
7692 		(void *)&cmd_pfc_set_flow_ctrl,
7693 		(void *)&cmd_pfc_set_rx,
7694 		(void *)&cmd_pfc_set_rx_mode,
7695 		(void *)&cmd_pfc_set_tx,
7696 		(void *)&cmd_pfc_set_tx_mode,
7697 		(void *)&cmd_pfc_set_high_water,
7698 		(void *)&cmd_pfc_set_low_water,
7699 		(void *)&cmd_pfc_set_pause_time,
7700 		(void *)&cmd_pfc_set_priority,
7701 		(void *)&cmd_pfc_set_portid,
7702 		NULL,
7703 	},
7704 };
7705 
7706 /* *** RESET CONFIGURATION *** */
7707 struct cmd_reset_result {
7708 	cmdline_fixed_string_t reset;
7709 	cmdline_fixed_string_t def;
7710 };
7711 
7712 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7713 			     struct cmdline *cl,
7714 			     __rte_unused void *data)
7715 {
7716 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7717 	set_def_fwd_config();
7718 }
7719 
7720 cmdline_parse_token_string_t cmd_reset_set =
7721 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7722 cmdline_parse_token_string_t cmd_reset_def =
7723 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7724 				 "default");
7725 
7726 cmdline_parse_inst_t cmd_reset = {
7727 	.f = cmd_reset_parsed,
7728 	.data = NULL,
7729 	.help_str = "set default: Reset default forwarding configuration",
7730 	.tokens = {
7731 		(void *)&cmd_reset_set,
7732 		(void *)&cmd_reset_def,
7733 		NULL,
7734 	},
7735 };
7736 
7737 /* *** START FORWARDING *** */
7738 struct cmd_start_result {
7739 	cmdline_fixed_string_t start;
7740 };
7741 
7742 cmdline_parse_token_string_t cmd_start_start =
7743 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7744 
7745 static void cmd_start_parsed(__rte_unused void *parsed_result,
7746 			     __rte_unused struct cmdline *cl,
7747 			     __rte_unused void *data)
7748 {
7749 	start_packet_forwarding(0);
7750 }
7751 
7752 cmdline_parse_inst_t cmd_start = {
7753 	.f = cmd_start_parsed,
7754 	.data = NULL,
7755 	.help_str = "start: Start packet forwarding",
7756 	.tokens = {
7757 		(void *)&cmd_start_start,
7758 		NULL,
7759 	},
7760 };
7761 
7762 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7763 struct cmd_start_tx_first_result {
7764 	cmdline_fixed_string_t start;
7765 	cmdline_fixed_string_t tx_first;
7766 };
7767 
7768 static void
7769 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7770 			  __rte_unused struct cmdline *cl,
7771 			  __rte_unused void *data)
7772 {
7773 	start_packet_forwarding(1);
7774 }
7775 
7776 cmdline_parse_token_string_t cmd_start_tx_first_start =
7777 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7778 				 "start");
7779 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7780 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7781 				 tx_first, "tx_first");
7782 
7783 cmdline_parse_inst_t cmd_start_tx_first = {
7784 	.f = cmd_start_tx_first_parsed,
7785 	.data = NULL,
7786 	.help_str = "start tx_first: Start packet forwarding, "
7787 		"after sending 1 burst of packets",
7788 	.tokens = {
7789 		(void *)&cmd_start_tx_first_start,
7790 		(void *)&cmd_start_tx_first_tx_first,
7791 		NULL,
7792 	},
7793 };
7794 
7795 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7796 struct cmd_start_tx_first_n_result {
7797 	cmdline_fixed_string_t start;
7798 	cmdline_fixed_string_t tx_first;
7799 	uint32_t tx_num;
7800 };
7801 
7802 static void
7803 cmd_start_tx_first_n_parsed(void *parsed_result,
7804 			  __rte_unused struct cmdline *cl,
7805 			  __rte_unused void *data)
7806 {
7807 	struct cmd_start_tx_first_n_result *res = parsed_result;
7808 
7809 	start_packet_forwarding(res->tx_num);
7810 }
7811 
7812 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7813 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7814 			start, "start");
7815 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7816 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7817 			tx_first, "tx_first");
7818 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7819 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7820 			tx_num, RTE_UINT32);
7821 
7822 cmdline_parse_inst_t cmd_start_tx_first_n = {
7823 	.f = cmd_start_tx_first_n_parsed,
7824 	.data = NULL,
7825 	.help_str = "start tx_first <num>: "
7826 		"packet forwarding, after sending <num> bursts of packets",
7827 	.tokens = {
7828 		(void *)&cmd_start_tx_first_n_start,
7829 		(void *)&cmd_start_tx_first_n_tx_first,
7830 		(void *)&cmd_start_tx_first_n_tx_num,
7831 		NULL,
7832 	},
7833 };
7834 
7835 /* *** SET LINK UP *** */
7836 struct cmd_set_link_up_result {
7837 	cmdline_fixed_string_t set;
7838 	cmdline_fixed_string_t link_up;
7839 	cmdline_fixed_string_t port;
7840 	portid_t port_id;
7841 };
7842 
7843 cmdline_parse_token_string_t cmd_set_link_up_set =
7844 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7845 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7846 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7847 				"link-up");
7848 cmdline_parse_token_string_t cmd_set_link_up_port =
7849 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7850 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7851 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7852 				RTE_UINT16);
7853 
7854 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7855 			     __rte_unused struct cmdline *cl,
7856 			     __rte_unused void *data)
7857 {
7858 	struct cmd_set_link_up_result *res = parsed_result;
7859 	dev_set_link_up(res->port_id);
7860 }
7861 
7862 cmdline_parse_inst_t cmd_set_link_up = {
7863 	.f = cmd_set_link_up_parsed,
7864 	.data = NULL,
7865 	.help_str = "set link-up port <port id>",
7866 	.tokens = {
7867 		(void *)&cmd_set_link_up_set,
7868 		(void *)&cmd_set_link_up_link_up,
7869 		(void *)&cmd_set_link_up_port,
7870 		(void *)&cmd_set_link_up_port_id,
7871 		NULL,
7872 	},
7873 };
7874 
7875 /* *** SET LINK DOWN *** */
7876 struct cmd_set_link_down_result {
7877 	cmdline_fixed_string_t set;
7878 	cmdline_fixed_string_t link_down;
7879 	cmdline_fixed_string_t port;
7880 	portid_t port_id;
7881 };
7882 
7883 cmdline_parse_token_string_t cmd_set_link_down_set =
7884 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7885 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7886 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7887 				"link-down");
7888 cmdline_parse_token_string_t cmd_set_link_down_port =
7889 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7890 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7891 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7892 				RTE_UINT16);
7893 
7894 static void cmd_set_link_down_parsed(
7895 				__rte_unused void *parsed_result,
7896 				__rte_unused struct cmdline *cl,
7897 				__rte_unused void *data)
7898 {
7899 	struct cmd_set_link_down_result *res = parsed_result;
7900 	dev_set_link_down(res->port_id);
7901 }
7902 
7903 cmdline_parse_inst_t cmd_set_link_down = {
7904 	.f = cmd_set_link_down_parsed,
7905 	.data = NULL,
7906 	.help_str = "set link-down port <port id>",
7907 	.tokens = {
7908 		(void *)&cmd_set_link_down_set,
7909 		(void *)&cmd_set_link_down_link_down,
7910 		(void *)&cmd_set_link_down_port,
7911 		(void *)&cmd_set_link_down_port_id,
7912 		NULL,
7913 	},
7914 };
7915 
7916 /* *** SHOW CFG *** */
7917 struct cmd_showcfg_result {
7918 	cmdline_fixed_string_t show;
7919 	cmdline_fixed_string_t cfg;
7920 	cmdline_fixed_string_t what;
7921 };
7922 
7923 static void cmd_showcfg_parsed(void *parsed_result,
7924 			       __rte_unused struct cmdline *cl,
7925 			       __rte_unused void *data)
7926 {
7927 	struct cmd_showcfg_result *res = parsed_result;
7928 	if (!strcmp(res->what, "rxtx"))
7929 		rxtx_config_display();
7930 	else if (!strcmp(res->what, "cores"))
7931 		fwd_lcores_config_display();
7932 	else if (!strcmp(res->what, "fwd"))
7933 		pkt_fwd_config_display(&cur_fwd_config);
7934 	else if (!strcmp(res->what, "rxoffs"))
7935 		show_rx_pkt_offsets();
7936 	else if (!strcmp(res->what, "rxpkts"))
7937 		show_rx_pkt_segments();
7938 	else if (!strcmp(res->what, "txpkts"))
7939 		show_tx_pkt_segments();
7940 	else if (!strcmp(res->what, "txtimes"))
7941 		show_tx_pkt_times();
7942 }
7943 
7944 cmdline_parse_token_string_t cmd_showcfg_show =
7945 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7946 cmdline_parse_token_string_t cmd_showcfg_port =
7947 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7948 cmdline_parse_token_string_t cmd_showcfg_what =
7949 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7950 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7951 
7952 cmdline_parse_inst_t cmd_showcfg = {
7953 	.f = cmd_showcfg_parsed,
7954 	.data = NULL,
7955 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7956 	.tokens = {
7957 		(void *)&cmd_showcfg_show,
7958 		(void *)&cmd_showcfg_port,
7959 		(void *)&cmd_showcfg_what,
7960 		NULL,
7961 	},
7962 };
7963 
7964 /* *** SHOW ALL PORT INFO *** */
7965 struct cmd_showportall_result {
7966 	cmdline_fixed_string_t show;
7967 	cmdline_fixed_string_t port;
7968 	cmdline_fixed_string_t what;
7969 	cmdline_fixed_string_t all;
7970 };
7971 
7972 static void cmd_showportall_parsed(void *parsed_result,
7973 				__rte_unused struct cmdline *cl,
7974 				__rte_unused void *data)
7975 {
7976 	portid_t i;
7977 
7978 	struct cmd_showportall_result *res = parsed_result;
7979 	if (!strcmp(res->show, "clear")) {
7980 		if (!strcmp(res->what, "stats"))
7981 			RTE_ETH_FOREACH_DEV(i)
7982 				nic_stats_clear(i);
7983 		else if (!strcmp(res->what, "xstats"))
7984 			RTE_ETH_FOREACH_DEV(i)
7985 				nic_xstats_clear(i);
7986 	} else if (!strcmp(res->what, "info"))
7987 		RTE_ETH_FOREACH_DEV(i)
7988 			port_infos_display(i);
7989 	else if (!strcmp(res->what, "summary")) {
7990 		port_summary_header_display();
7991 		RTE_ETH_FOREACH_DEV(i)
7992 			port_summary_display(i);
7993 	}
7994 	else if (!strcmp(res->what, "stats"))
7995 		RTE_ETH_FOREACH_DEV(i)
7996 			nic_stats_display(i);
7997 	else if (!strcmp(res->what, "xstats"))
7998 		RTE_ETH_FOREACH_DEV(i)
7999 			nic_xstats_display(i);
8000 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8001 	else if (!strcmp(res->what, "fdir"))
8002 		RTE_ETH_FOREACH_DEV(i)
8003 			fdir_get_infos(i);
8004 #endif
8005 	else if (!strcmp(res->what, "dcb_tc"))
8006 		RTE_ETH_FOREACH_DEV(i)
8007 			port_dcb_info_display(i);
8008 }
8009 
8010 cmdline_parse_token_string_t cmd_showportall_show =
8011 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8012 				 "show#clear");
8013 cmdline_parse_token_string_t cmd_showportall_port =
8014 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8015 cmdline_parse_token_string_t cmd_showportall_what =
8016 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8017 				 "info#summary#stats#xstats#fdir#dcb_tc");
8018 cmdline_parse_token_string_t cmd_showportall_all =
8019 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8020 cmdline_parse_inst_t cmd_showportall = {
8021 	.f = cmd_showportall_parsed,
8022 	.data = NULL,
8023 	.help_str = "show|clear port "
8024 		"info|summary|stats|xstats|fdir|dcb_tc all",
8025 	.tokens = {
8026 		(void *)&cmd_showportall_show,
8027 		(void *)&cmd_showportall_port,
8028 		(void *)&cmd_showportall_what,
8029 		(void *)&cmd_showportall_all,
8030 		NULL,
8031 	},
8032 };
8033 
8034 /* *** SHOW PORT INFO *** */
8035 struct cmd_showport_result {
8036 	cmdline_fixed_string_t show;
8037 	cmdline_fixed_string_t port;
8038 	cmdline_fixed_string_t what;
8039 	uint16_t portnum;
8040 };
8041 
8042 static void cmd_showport_parsed(void *parsed_result,
8043 				__rte_unused struct cmdline *cl,
8044 				__rte_unused void *data)
8045 {
8046 	struct cmd_showport_result *res = parsed_result;
8047 	if (!strcmp(res->show, "clear")) {
8048 		if (!strcmp(res->what, "stats"))
8049 			nic_stats_clear(res->portnum);
8050 		else if (!strcmp(res->what, "xstats"))
8051 			nic_xstats_clear(res->portnum);
8052 	} else if (!strcmp(res->what, "info"))
8053 		port_infos_display(res->portnum);
8054 	else if (!strcmp(res->what, "summary")) {
8055 		port_summary_header_display();
8056 		port_summary_display(res->portnum);
8057 	}
8058 	else if (!strcmp(res->what, "stats"))
8059 		nic_stats_display(res->portnum);
8060 	else if (!strcmp(res->what, "xstats"))
8061 		nic_xstats_display(res->portnum);
8062 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8063 	else if (!strcmp(res->what, "fdir"))
8064 		 fdir_get_infos(res->portnum);
8065 #endif
8066 	else if (!strcmp(res->what, "dcb_tc"))
8067 		port_dcb_info_display(res->portnum);
8068 }
8069 
8070 cmdline_parse_token_string_t cmd_showport_show =
8071 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8072 				 "show#clear");
8073 cmdline_parse_token_string_t cmd_showport_port =
8074 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8075 cmdline_parse_token_string_t cmd_showport_what =
8076 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8077 				 "info#summary#stats#xstats#fdir#dcb_tc");
8078 cmdline_parse_token_num_t cmd_showport_portnum =
8079 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8080 
8081 cmdline_parse_inst_t cmd_showport = {
8082 	.f = cmd_showport_parsed,
8083 	.data = NULL,
8084 	.help_str = "show|clear port "
8085 		"info|summary|stats|xstats|fdir|dcb_tc "
8086 		"<port_id>",
8087 	.tokens = {
8088 		(void *)&cmd_showport_show,
8089 		(void *)&cmd_showport_port,
8090 		(void *)&cmd_showport_what,
8091 		(void *)&cmd_showport_portnum,
8092 		NULL,
8093 	},
8094 };
8095 
8096 /* *** show port representors information *** */
8097 struct cmd_representor_info_result {
8098 	cmdline_fixed_string_t cmd_show;
8099 	cmdline_fixed_string_t cmd_port;
8100 	cmdline_fixed_string_t cmd_info;
8101 	cmdline_fixed_string_t cmd_keyword;
8102 	portid_t cmd_pid;
8103 };
8104 
8105 static void
8106 cmd_representor_info_parsed(void *parsed_result,
8107 		__rte_unused struct cmdline *cl,
8108 		__rte_unused void *data)
8109 {
8110 	struct cmd_representor_info_result *res = parsed_result;
8111 	struct rte_eth_representor_info *info;
8112 	struct rte_eth_representor_range *range;
8113 	uint32_t range_diff;
8114 	uint32_t i;
8115 	int ret;
8116 	int num;
8117 
8118 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8119 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8120 		return;
8121 	}
8122 
8123 	ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8124 	if (ret < 0) {
8125 		fprintf(stderr,
8126 			"Failed to get the number of representor info ranges for port %hu: %s\n",
8127 			res->cmd_pid, rte_strerror(-ret));
8128 		return;
8129 	}
8130 	num = ret;
8131 
8132 	info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8133 	if (info == NULL) {
8134 		fprintf(stderr,
8135 			"Failed to allocate memory for representor info for port %hu\n",
8136 			res->cmd_pid);
8137 		return;
8138 	}
8139 	info->nb_ranges_alloc = num;
8140 
8141 	ret = rte_eth_representor_info_get(res->cmd_pid, info);
8142 	if (ret < 0) {
8143 		fprintf(stderr,
8144 			"Failed to get the representor info for port %hu: %s\n",
8145 			res->cmd_pid, rte_strerror(-ret));
8146 		free(info);
8147 		return;
8148 	}
8149 
8150 	printf("Port controller: %hu\n", info->controller);
8151 	printf("Port PF: %hu\n", info->pf);
8152 
8153 	printf("Ranges: %u\n", info->nb_ranges);
8154 	for (i = 0; i < info->nb_ranges; i++) {
8155 		range = &info->ranges[i];
8156 		range_diff = range->id_end - range->id_base;
8157 
8158 		printf("%u. ", i + 1);
8159 		printf("'%s' ", range->name);
8160 		if (range_diff > 0)
8161 			printf("[%u-%u]: ", range->id_base, range->id_end);
8162 		else
8163 			printf("[%u]: ", range->id_base);
8164 
8165 		printf("Controller %d, PF %d", range->controller, range->pf);
8166 
8167 		switch (range->type) {
8168 		case RTE_ETH_REPRESENTOR_NONE:
8169 			printf(", NONE\n");
8170 			break;
8171 		case RTE_ETH_REPRESENTOR_VF:
8172 			if (range_diff > 0)
8173 				printf(", VF %d..%d\n", range->vf,
8174 				       range->vf + range_diff);
8175 			else
8176 				printf(", VF %d\n", range->vf);
8177 			break;
8178 		case RTE_ETH_REPRESENTOR_SF:
8179 			printf(", SF %d\n", range->sf);
8180 			break;
8181 		case RTE_ETH_REPRESENTOR_PF:
8182 			if (range_diff > 0)
8183 				printf("..%d\n", range->pf + range_diff);
8184 			else
8185 				printf("\n");
8186 			break;
8187 		default:
8188 			printf(", UNKNOWN TYPE %d\n", range->type);
8189 			break;
8190 		}
8191 	}
8192 
8193 	free(info);
8194 }
8195 
8196 cmdline_parse_token_string_t cmd_representor_info_show =
8197 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8198 			cmd_show, "show");
8199 cmdline_parse_token_string_t cmd_representor_info_port =
8200 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8201 			cmd_port, "port");
8202 cmdline_parse_token_string_t cmd_representor_info_info =
8203 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8204 			cmd_info, "info");
8205 cmdline_parse_token_num_t cmd_representor_info_pid =
8206 	TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8207 			cmd_pid, RTE_UINT16);
8208 cmdline_parse_token_string_t cmd_representor_info_keyword =
8209 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8210 			cmd_keyword, "representor");
8211 
8212 cmdline_parse_inst_t cmd_representor_info = {
8213 	.f = cmd_representor_info_parsed,
8214 	.data = NULL,
8215 	.help_str = "show port info <port_id> representor",
8216 	.tokens = {
8217 		(void *)&cmd_representor_info_show,
8218 		(void *)&cmd_representor_info_port,
8219 		(void *)&cmd_representor_info_info,
8220 		(void *)&cmd_representor_info_pid,
8221 		(void *)&cmd_representor_info_keyword,
8222 		NULL,
8223 	},
8224 };
8225 
8226 
8227 /* *** SHOW DEVICE INFO *** */
8228 struct cmd_showdevice_result {
8229 	cmdline_fixed_string_t show;
8230 	cmdline_fixed_string_t device;
8231 	cmdline_fixed_string_t what;
8232 	cmdline_fixed_string_t identifier;
8233 };
8234 
8235 static void cmd_showdevice_parsed(void *parsed_result,
8236 				__rte_unused struct cmdline *cl,
8237 				__rte_unused void *data)
8238 {
8239 	struct cmd_showdevice_result *res = parsed_result;
8240 	if (!strcmp(res->what, "info")) {
8241 		if (!strcmp(res->identifier, "all"))
8242 			device_infos_display(NULL);
8243 		else
8244 			device_infos_display(res->identifier);
8245 	}
8246 }
8247 
8248 cmdline_parse_token_string_t cmd_showdevice_show =
8249 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8250 				 "show");
8251 cmdline_parse_token_string_t cmd_showdevice_device =
8252 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8253 cmdline_parse_token_string_t cmd_showdevice_what =
8254 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8255 				 "info");
8256 cmdline_parse_token_string_t cmd_showdevice_identifier =
8257 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8258 			identifier, NULL);
8259 
8260 cmdline_parse_inst_t cmd_showdevice = {
8261 	.f = cmd_showdevice_parsed,
8262 	.data = NULL,
8263 	.help_str = "show device info <identifier>|all",
8264 	.tokens = {
8265 		(void *)&cmd_showdevice_show,
8266 		(void *)&cmd_showdevice_device,
8267 		(void *)&cmd_showdevice_what,
8268 		(void *)&cmd_showdevice_identifier,
8269 		NULL,
8270 	},
8271 };
8272 
8273 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8274 struct cmd_showeeprom_result {
8275 	cmdline_fixed_string_t show;
8276 	cmdline_fixed_string_t port;
8277 	uint16_t portnum;
8278 	cmdline_fixed_string_t type;
8279 };
8280 
8281 static void cmd_showeeprom_parsed(void *parsed_result,
8282 		__rte_unused struct cmdline *cl,
8283 		__rte_unused void *data)
8284 {
8285 	struct cmd_showeeprom_result *res = parsed_result;
8286 
8287 	if (!strcmp(res->type, "eeprom"))
8288 		port_eeprom_display(res->portnum);
8289 	else if (!strcmp(res->type, "module_eeprom"))
8290 		port_module_eeprom_display(res->portnum);
8291 	else
8292 		fprintf(stderr, "Unknown argument\n");
8293 }
8294 
8295 cmdline_parse_token_string_t cmd_showeeprom_show =
8296 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8297 cmdline_parse_token_string_t cmd_showeeprom_port =
8298 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8299 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8300 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8301 			RTE_UINT16);
8302 cmdline_parse_token_string_t cmd_showeeprom_type =
8303 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8304 
8305 cmdline_parse_inst_t cmd_showeeprom = {
8306 	.f = cmd_showeeprom_parsed,
8307 	.data = NULL,
8308 	.help_str = "show port <port_id> module_eeprom|eeprom",
8309 	.tokens = {
8310 		(void *)&cmd_showeeprom_show,
8311 		(void *)&cmd_showeeprom_port,
8312 		(void *)&cmd_showeeprom_portnum,
8313 		(void *)&cmd_showeeprom_type,
8314 		NULL,
8315 	},
8316 };
8317 
8318 /* *** SHOW QUEUE INFO *** */
8319 struct cmd_showqueue_result {
8320 	cmdline_fixed_string_t show;
8321 	cmdline_fixed_string_t type;
8322 	cmdline_fixed_string_t what;
8323 	uint16_t portnum;
8324 	uint16_t queuenum;
8325 };
8326 
8327 static void
8328 cmd_showqueue_parsed(void *parsed_result,
8329 	__rte_unused struct cmdline *cl,
8330 	__rte_unused void *data)
8331 {
8332 	struct cmd_showqueue_result *res = parsed_result;
8333 
8334 	if (!strcmp(res->type, "rxq"))
8335 		rx_queue_infos_display(res->portnum, res->queuenum);
8336 	else if (!strcmp(res->type, "txq"))
8337 		tx_queue_infos_display(res->portnum, res->queuenum);
8338 }
8339 
8340 cmdline_parse_token_string_t cmd_showqueue_show =
8341 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8342 cmdline_parse_token_string_t cmd_showqueue_type =
8343 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8344 cmdline_parse_token_string_t cmd_showqueue_what =
8345 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8346 cmdline_parse_token_num_t cmd_showqueue_portnum =
8347 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8348 		RTE_UINT16);
8349 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8350 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8351 		RTE_UINT16);
8352 
8353 cmdline_parse_inst_t cmd_showqueue = {
8354 	.f = cmd_showqueue_parsed,
8355 	.data = NULL,
8356 	.help_str = "show rxq|txq info <port_id> <queue_id>",
8357 	.tokens = {
8358 		(void *)&cmd_showqueue_show,
8359 		(void *)&cmd_showqueue_type,
8360 		(void *)&cmd_showqueue_what,
8361 		(void *)&cmd_showqueue_portnum,
8362 		(void *)&cmd_showqueue_queuenum,
8363 		NULL,
8364 	},
8365 };
8366 
8367 /* show/clear fwd engine statistics */
8368 struct fwd_result {
8369 	cmdline_fixed_string_t action;
8370 	cmdline_fixed_string_t fwd;
8371 	cmdline_fixed_string_t stats;
8372 	cmdline_fixed_string_t all;
8373 };
8374 
8375 cmdline_parse_token_string_t cmd_fwd_action =
8376 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8377 cmdline_parse_token_string_t cmd_fwd_fwd =
8378 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8379 cmdline_parse_token_string_t cmd_fwd_stats =
8380 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8381 cmdline_parse_token_string_t cmd_fwd_all =
8382 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8383 
8384 static void
8385 cmd_showfwdall_parsed(void *parsed_result,
8386 		      __rte_unused struct cmdline *cl,
8387 		      __rte_unused void *data)
8388 {
8389 	struct fwd_result *res = parsed_result;
8390 
8391 	if (!strcmp(res->action, "show"))
8392 		fwd_stats_display();
8393 	else
8394 		fwd_stats_reset();
8395 }
8396 
8397 static cmdline_parse_inst_t cmd_showfwdall = {
8398 	.f = cmd_showfwdall_parsed,
8399 	.data = NULL,
8400 	.help_str = "show|clear fwd stats all",
8401 	.tokens = {
8402 		(void *)&cmd_fwd_action,
8403 		(void *)&cmd_fwd_fwd,
8404 		(void *)&cmd_fwd_stats,
8405 		(void *)&cmd_fwd_all,
8406 		NULL,
8407 	},
8408 };
8409 
8410 /* *** READ PORT REGISTER *** */
8411 struct cmd_read_reg_result {
8412 	cmdline_fixed_string_t read;
8413 	cmdline_fixed_string_t reg;
8414 	portid_t port_id;
8415 	uint32_t reg_off;
8416 };
8417 
8418 static void
8419 cmd_read_reg_parsed(void *parsed_result,
8420 		    __rte_unused struct cmdline *cl,
8421 		    __rte_unused void *data)
8422 {
8423 	struct cmd_read_reg_result *res = parsed_result;
8424 	port_reg_display(res->port_id, res->reg_off);
8425 }
8426 
8427 cmdline_parse_token_string_t cmd_read_reg_read =
8428 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8429 cmdline_parse_token_string_t cmd_read_reg_reg =
8430 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8431 cmdline_parse_token_num_t cmd_read_reg_port_id =
8432 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8433 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8434 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8435 
8436 cmdline_parse_inst_t cmd_read_reg = {
8437 	.f = cmd_read_reg_parsed,
8438 	.data = NULL,
8439 	.help_str = "read reg <port_id> <reg_off>",
8440 	.tokens = {
8441 		(void *)&cmd_read_reg_read,
8442 		(void *)&cmd_read_reg_reg,
8443 		(void *)&cmd_read_reg_port_id,
8444 		(void *)&cmd_read_reg_reg_off,
8445 		NULL,
8446 	},
8447 };
8448 
8449 /* *** READ PORT REGISTER BIT FIELD *** */
8450 struct cmd_read_reg_bit_field_result {
8451 	cmdline_fixed_string_t read;
8452 	cmdline_fixed_string_t regfield;
8453 	portid_t port_id;
8454 	uint32_t reg_off;
8455 	uint8_t bit1_pos;
8456 	uint8_t bit2_pos;
8457 };
8458 
8459 static void
8460 cmd_read_reg_bit_field_parsed(void *parsed_result,
8461 			      __rte_unused struct cmdline *cl,
8462 			      __rte_unused void *data)
8463 {
8464 	struct cmd_read_reg_bit_field_result *res = parsed_result;
8465 	port_reg_bit_field_display(res->port_id, res->reg_off,
8466 				   res->bit1_pos, res->bit2_pos);
8467 }
8468 
8469 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8470 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8471 				 "read");
8472 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8473 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8474 				 regfield, "regfield");
8475 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8476 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8477 			      RTE_UINT16);
8478 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8479 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8480 			      RTE_UINT32);
8481 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8482 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8483 			      RTE_UINT8);
8484 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8485 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8486 			      RTE_UINT8);
8487 
8488 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8489 	.f = cmd_read_reg_bit_field_parsed,
8490 	.data = NULL,
8491 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8492 	"Read register bit field between bit_x and bit_y included",
8493 	.tokens = {
8494 		(void *)&cmd_read_reg_bit_field_read,
8495 		(void *)&cmd_read_reg_bit_field_regfield,
8496 		(void *)&cmd_read_reg_bit_field_port_id,
8497 		(void *)&cmd_read_reg_bit_field_reg_off,
8498 		(void *)&cmd_read_reg_bit_field_bit1_pos,
8499 		(void *)&cmd_read_reg_bit_field_bit2_pos,
8500 		NULL,
8501 	},
8502 };
8503 
8504 /* *** READ PORT REGISTER BIT *** */
8505 struct cmd_read_reg_bit_result {
8506 	cmdline_fixed_string_t read;
8507 	cmdline_fixed_string_t regbit;
8508 	portid_t port_id;
8509 	uint32_t reg_off;
8510 	uint8_t bit_pos;
8511 };
8512 
8513 static void
8514 cmd_read_reg_bit_parsed(void *parsed_result,
8515 			__rte_unused struct cmdline *cl,
8516 			__rte_unused void *data)
8517 {
8518 	struct cmd_read_reg_bit_result *res = parsed_result;
8519 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8520 }
8521 
8522 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8523 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8524 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8525 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8526 				 regbit, "regbit");
8527 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8528 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8529 				 RTE_UINT16);
8530 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8531 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8532 				 RTE_UINT32);
8533 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8534 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8535 				 RTE_UINT8);
8536 
8537 cmdline_parse_inst_t cmd_read_reg_bit = {
8538 	.f = cmd_read_reg_bit_parsed,
8539 	.data = NULL,
8540 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8541 	.tokens = {
8542 		(void *)&cmd_read_reg_bit_read,
8543 		(void *)&cmd_read_reg_bit_regbit,
8544 		(void *)&cmd_read_reg_bit_port_id,
8545 		(void *)&cmd_read_reg_bit_reg_off,
8546 		(void *)&cmd_read_reg_bit_bit_pos,
8547 		NULL,
8548 	},
8549 };
8550 
8551 /* *** WRITE PORT REGISTER *** */
8552 struct cmd_write_reg_result {
8553 	cmdline_fixed_string_t write;
8554 	cmdline_fixed_string_t reg;
8555 	portid_t port_id;
8556 	uint32_t reg_off;
8557 	uint32_t value;
8558 };
8559 
8560 static void
8561 cmd_write_reg_parsed(void *parsed_result,
8562 		     __rte_unused struct cmdline *cl,
8563 		     __rte_unused void *data)
8564 {
8565 	struct cmd_write_reg_result *res = parsed_result;
8566 	port_reg_set(res->port_id, res->reg_off, res->value);
8567 }
8568 
8569 cmdline_parse_token_string_t cmd_write_reg_write =
8570 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8571 cmdline_parse_token_string_t cmd_write_reg_reg =
8572 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8573 cmdline_parse_token_num_t cmd_write_reg_port_id =
8574 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8575 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8576 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8577 cmdline_parse_token_num_t cmd_write_reg_value =
8578 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8579 
8580 cmdline_parse_inst_t cmd_write_reg = {
8581 	.f = cmd_write_reg_parsed,
8582 	.data = NULL,
8583 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8584 	.tokens = {
8585 		(void *)&cmd_write_reg_write,
8586 		(void *)&cmd_write_reg_reg,
8587 		(void *)&cmd_write_reg_port_id,
8588 		(void *)&cmd_write_reg_reg_off,
8589 		(void *)&cmd_write_reg_value,
8590 		NULL,
8591 	},
8592 };
8593 
8594 /* *** WRITE PORT REGISTER BIT FIELD *** */
8595 struct cmd_write_reg_bit_field_result {
8596 	cmdline_fixed_string_t write;
8597 	cmdline_fixed_string_t regfield;
8598 	portid_t port_id;
8599 	uint32_t reg_off;
8600 	uint8_t bit1_pos;
8601 	uint8_t bit2_pos;
8602 	uint32_t value;
8603 };
8604 
8605 static void
8606 cmd_write_reg_bit_field_parsed(void *parsed_result,
8607 			       __rte_unused struct cmdline *cl,
8608 			       __rte_unused void *data)
8609 {
8610 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8611 	port_reg_bit_field_set(res->port_id, res->reg_off,
8612 			  res->bit1_pos, res->bit2_pos, res->value);
8613 }
8614 
8615 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8616 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8617 				 "write");
8618 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8619 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8620 				 regfield, "regfield");
8621 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8622 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8623 			      RTE_UINT16);
8624 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8625 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8626 			      RTE_UINT32);
8627 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8628 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8629 			      RTE_UINT8);
8630 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8631 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8632 			      RTE_UINT8);
8633 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8634 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8635 			      RTE_UINT32);
8636 
8637 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8638 	.f = cmd_write_reg_bit_field_parsed,
8639 	.data = NULL,
8640 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8641 		"<reg_value>: "
8642 		"Set register bit field between bit_x and bit_y included",
8643 	.tokens = {
8644 		(void *)&cmd_write_reg_bit_field_write,
8645 		(void *)&cmd_write_reg_bit_field_regfield,
8646 		(void *)&cmd_write_reg_bit_field_port_id,
8647 		(void *)&cmd_write_reg_bit_field_reg_off,
8648 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8649 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8650 		(void *)&cmd_write_reg_bit_field_value,
8651 		NULL,
8652 	},
8653 };
8654 
8655 /* *** WRITE PORT REGISTER BIT *** */
8656 struct cmd_write_reg_bit_result {
8657 	cmdline_fixed_string_t write;
8658 	cmdline_fixed_string_t regbit;
8659 	portid_t port_id;
8660 	uint32_t reg_off;
8661 	uint8_t bit_pos;
8662 	uint8_t value;
8663 };
8664 
8665 static void
8666 cmd_write_reg_bit_parsed(void *parsed_result,
8667 			 __rte_unused struct cmdline *cl,
8668 			 __rte_unused void *data)
8669 {
8670 	struct cmd_write_reg_bit_result *res = parsed_result;
8671 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8672 }
8673 
8674 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8675 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8676 				 "write");
8677 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8678 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8679 				 regbit, "regbit");
8680 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8681 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8682 				 RTE_UINT16);
8683 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8684 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8685 				 RTE_UINT32);
8686 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8687 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8688 				 RTE_UINT8);
8689 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8690 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8691 				 RTE_UINT8);
8692 
8693 cmdline_parse_inst_t cmd_write_reg_bit = {
8694 	.f = cmd_write_reg_bit_parsed,
8695 	.data = NULL,
8696 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8697 		"0 <= bit_x <= 31",
8698 	.tokens = {
8699 		(void *)&cmd_write_reg_bit_write,
8700 		(void *)&cmd_write_reg_bit_regbit,
8701 		(void *)&cmd_write_reg_bit_port_id,
8702 		(void *)&cmd_write_reg_bit_reg_off,
8703 		(void *)&cmd_write_reg_bit_bit_pos,
8704 		(void *)&cmd_write_reg_bit_value,
8705 		NULL,
8706 	},
8707 };
8708 
8709 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8710 struct cmd_read_rxd_txd_result {
8711 	cmdline_fixed_string_t read;
8712 	cmdline_fixed_string_t rxd_txd;
8713 	portid_t port_id;
8714 	uint16_t queue_id;
8715 	uint16_t desc_id;
8716 };
8717 
8718 static void
8719 cmd_read_rxd_txd_parsed(void *parsed_result,
8720 			__rte_unused struct cmdline *cl,
8721 			__rte_unused void *data)
8722 {
8723 	struct cmd_read_rxd_txd_result *res = parsed_result;
8724 
8725 	if (!strcmp(res->rxd_txd, "rxd"))
8726 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8727 	else if (!strcmp(res->rxd_txd, "txd"))
8728 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8729 }
8730 
8731 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8732 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8733 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8734 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8735 				 "rxd#txd");
8736 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8737 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8738 				 RTE_UINT16);
8739 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8740 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8741 				 RTE_UINT16);
8742 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8743 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8744 				 RTE_UINT16);
8745 
8746 cmdline_parse_inst_t cmd_read_rxd_txd = {
8747 	.f = cmd_read_rxd_txd_parsed,
8748 	.data = NULL,
8749 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8750 	.tokens = {
8751 		(void *)&cmd_read_rxd_txd_read,
8752 		(void *)&cmd_read_rxd_txd_rxd_txd,
8753 		(void *)&cmd_read_rxd_txd_port_id,
8754 		(void *)&cmd_read_rxd_txd_queue_id,
8755 		(void *)&cmd_read_rxd_txd_desc_id,
8756 		NULL,
8757 	},
8758 };
8759 
8760 /* *** QUIT *** */
8761 struct cmd_quit_result {
8762 	cmdline_fixed_string_t quit;
8763 };
8764 
8765 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8766 			    struct cmdline *cl,
8767 			    __rte_unused void *data)
8768 {
8769 	cmdline_quit(cl);
8770 }
8771 
8772 cmdline_parse_token_string_t cmd_quit_quit =
8773 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8774 
8775 cmdline_parse_inst_t cmd_quit = {
8776 	.f = cmd_quit_parsed,
8777 	.data = NULL,
8778 	.help_str = "quit: Exit application",
8779 	.tokens = {
8780 		(void *)&cmd_quit_quit,
8781 		NULL,
8782 	},
8783 };
8784 
8785 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8786 struct cmd_mac_addr_result {
8787 	cmdline_fixed_string_t mac_addr_cmd;
8788 	cmdline_fixed_string_t what;
8789 	uint16_t port_num;
8790 	struct rte_ether_addr address;
8791 };
8792 
8793 static void cmd_mac_addr_parsed(void *parsed_result,
8794 		__rte_unused struct cmdline *cl,
8795 		__rte_unused void *data)
8796 {
8797 	struct cmd_mac_addr_result *res = parsed_result;
8798 	int ret;
8799 
8800 	if (strcmp(res->what, "add") == 0)
8801 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8802 	else if (strcmp(res->what, "set") == 0)
8803 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8804 						       &res->address);
8805 	else
8806 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8807 
8808 	/* check the return value and print it if is < 0 */
8809 	if(ret < 0)
8810 		fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8811 
8812 }
8813 
8814 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8815 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8816 				"mac_addr");
8817 cmdline_parse_token_string_t cmd_mac_addr_what =
8818 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8819 				"add#remove#set");
8820 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8821 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8822 					RTE_UINT16);
8823 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8824 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8825 
8826 cmdline_parse_inst_t cmd_mac_addr = {
8827 	.f = cmd_mac_addr_parsed,
8828 	.data = (void *)0,
8829 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8830 			"Add/Remove/Set MAC address on port_id",
8831 	.tokens = {
8832 		(void *)&cmd_mac_addr_cmd,
8833 		(void *)&cmd_mac_addr_what,
8834 		(void *)&cmd_mac_addr_portnum,
8835 		(void *)&cmd_mac_addr_addr,
8836 		NULL,
8837 	},
8838 };
8839 
8840 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8841 struct cmd_eth_peer_result {
8842 	cmdline_fixed_string_t set;
8843 	cmdline_fixed_string_t eth_peer;
8844 	portid_t port_id;
8845 	cmdline_fixed_string_t peer_addr;
8846 };
8847 
8848 static void cmd_set_eth_peer_parsed(void *parsed_result,
8849 			__rte_unused struct cmdline *cl,
8850 			__rte_unused void *data)
8851 {
8852 		struct cmd_eth_peer_result *res = parsed_result;
8853 
8854 		if (test_done == 0) {
8855 			fprintf(stderr, "Please stop forwarding first\n");
8856 			return;
8857 		}
8858 		if (!strcmp(res->eth_peer, "eth-peer")) {
8859 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8860 			fwd_config_setup();
8861 		}
8862 }
8863 cmdline_parse_token_string_t cmd_eth_peer_set =
8864 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8865 cmdline_parse_token_string_t cmd_eth_peer =
8866 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8867 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8868 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8869 		RTE_UINT16);
8870 cmdline_parse_token_string_t cmd_eth_peer_addr =
8871 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8872 
8873 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8874 	.f = cmd_set_eth_peer_parsed,
8875 	.data = NULL,
8876 	.help_str = "set eth-peer <port_id> <peer_mac>",
8877 	.tokens = {
8878 		(void *)&cmd_eth_peer_set,
8879 		(void *)&cmd_eth_peer,
8880 		(void *)&cmd_eth_peer_port_id,
8881 		(void *)&cmd_eth_peer_addr,
8882 		NULL,
8883 	},
8884 };
8885 
8886 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8887 struct cmd_set_qmap_result {
8888 	cmdline_fixed_string_t set;
8889 	cmdline_fixed_string_t qmap;
8890 	cmdline_fixed_string_t what;
8891 	portid_t port_id;
8892 	uint16_t queue_id;
8893 	uint8_t map_value;
8894 };
8895 
8896 static void
8897 cmd_set_qmap_parsed(void *parsed_result,
8898 		       __rte_unused struct cmdline *cl,
8899 		       __rte_unused void *data)
8900 {
8901 	struct cmd_set_qmap_result *res = parsed_result;
8902 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8903 
8904 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8905 }
8906 
8907 cmdline_parse_token_string_t cmd_setqmap_set =
8908 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8909 				 set, "set");
8910 cmdline_parse_token_string_t cmd_setqmap_qmap =
8911 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8912 				 qmap, "stat_qmap");
8913 cmdline_parse_token_string_t cmd_setqmap_what =
8914 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8915 				 what, "tx#rx");
8916 cmdline_parse_token_num_t cmd_setqmap_portid =
8917 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8918 			      port_id, RTE_UINT16);
8919 cmdline_parse_token_num_t cmd_setqmap_queueid =
8920 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8921 			      queue_id, RTE_UINT16);
8922 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8923 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8924 			      map_value, RTE_UINT8);
8925 
8926 cmdline_parse_inst_t cmd_set_qmap = {
8927 	.f = cmd_set_qmap_parsed,
8928 	.data = NULL,
8929 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8930 		"Set statistics mapping value on tx|rx queue_id of port_id",
8931 	.tokens = {
8932 		(void *)&cmd_setqmap_set,
8933 		(void *)&cmd_setqmap_qmap,
8934 		(void *)&cmd_setqmap_what,
8935 		(void *)&cmd_setqmap_portid,
8936 		(void *)&cmd_setqmap_queueid,
8937 		(void *)&cmd_setqmap_mapvalue,
8938 		NULL,
8939 	},
8940 };
8941 
8942 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8943 struct cmd_set_xstats_hide_zero_result {
8944 	cmdline_fixed_string_t keyword;
8945 	cmdline_fixed_string_t name;
8946 	cmdline_fixed_string_t on_off;
8947 };
8948 
8949 static void
8950 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8951 			__rte_unused struct cmdline *cl,
8952 			__rte_unused void *data)
8953 {
8954 	struct cmd_set_xstats_hide_zero_result *res;
8955 	uint16_t on_off = 0;
8956 
8957 	res = parsed_result;
8958 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8959 	set_xstats_hide_zero(on_off);
8960 }
8961 
8962 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8963 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8964 				 keyword, "set");
8965 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8966 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8967 				 name, "xstats-hide-zero");
8968 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8969 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8970 				 on_off, "on#off");
8971 
8972 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8973 	.f = cmd_set_xstats_hide_zero_parsed,
8974 	.data = NULL,
8975 	.help_str = "set xstats-hide-zero on|off",
8976 	.tokens = {
8977 		(void *)&cmd_set_xstats_hide_zero_keyword,
8978 		(void *)&cmd_set_xstats_hide_zero_name,
8979 		(void *)&cmd_set_xstats_hide_zero_on_off,
8980 		NULL,
8981 	},
8982 };
8983 
8984 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8985 struct cmd_set_record_core_cycles_result {
8986 	cmdline_fixed_string_t keyword;
8987 	cmdline_fixed_string_t name;
8988 	cmdline_fixed_string_t on_off;
8989 };
8990 
8991 static void
8992 cmd_set_record_core_cycles_parsed(void *parsed_result,
8993 			__rte_unused struct cmdline *cl,
8994 			__rte_unused void *data)
8995 {
8996 	struct cmd_set_record_core_cycles_result *res;
8997 	uint16_t on_off = 0;
8998 
8999 	res = parsed_result;
9000 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9001 	set_record_core_cycles(on_off);
9002 }
9003 
9004 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9005 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9006 				 keyword, "set");
9007 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9008 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9009 				 name, "record-core-cycles");
9010 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9011 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9012 				 on_off, "on#off");
9013 
9014 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9015 	.f = cmd_set_record_core_cycles_parsed,
9016 	.data = NULL,
9017 	.help_str = "set record-core-cycles on|off",
9018 	.tokens = {
9019 		(void *)&cmd_set_record_core_cycles_keyword,
9020 		(void *)&cmd_set_record_core_cycles_name,
9021 		(void *)&cmd_set_record_core_cycles_on_off,
9022 		NULL,
9023 	},
9024 };
9025 
9026 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9027 struct cmd_set_record_burst_stats_result {
9028 	cmdline_fixed_string_t keyword;
9029 	cmdline_fixed_string_t name;
9030 	cmdline_fixed_string_t on_off;
9031 };
9032 
9033 static void
9034 cmd_set_record_burst_stats_parsed(void *parsed_result,
9035 			__rte_unused struct cmdline *cl,
9036 			__rte_unused void *data)
9037 {
9038 	struct cmd_set_record_burst_stats_result *res;
9039 	uint16_t on_off = 0;
9040 
9041 	res = parsed_result;
9042 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9043 	set_record_burst_stats(on_off);
9044 }
9045 
9046 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9047 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9048 				 keyword, "set");
9049 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9050 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9051 				 name, "record-burst-stats");
9052 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9053 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9054 				 on_off, "on#off");
9055 
9056 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9057 	.f = cmd_set_record_burst_stats_parsed,
9058 	.data = NULL,
9059 	.help_str = "set record-burst-stats on|off",
9060 	.tokens = {
9061 		(void *)&cmd_set_record_burst_stats_keyword,
9062 		(void *)&cmd_set_record_burst_stats_name,
9063 		(void *)&cmd_set_record_burst_stats_on_off,
9064 		NULL,
9065 	},
9066 };
9067 
9068 /* *** CONFIGURE UNICAST HASH TABLE *** */
9069 struct cmd_set_uc_hash_table {
9070 	cmdline_fixed_string_t set;
9071 	cmdline_fixed_string_t port;
9072 	portid_t port_id;
9073 	cmdline_fixed_string_t what;
9074 	struct rte_ether_addr address;
9075 	cmdline_fixed_string_t mode;
9076 };
9077 
9078 static void
9079 cmd_set_uc_hash_parsed(void *parsed_result,
9080 		       __rte_unused struct cmdline *cl,
9081 		       __rte_unused void *data)
9082 {
9083 	int ret=0;
9084 	struct cmd_set_uc_hash_table *res = parsed_result;
9085 
9086 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9087 
9088 	if (strcmp(res->what, "uta") == 0)
9089 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9090 						&res->address,(uint8_t)is_on);
9091 	if (ret < 0)
9092 		fprintf(stderr,
9093 			"bad unicast hash table parameter, return code = %d\n",
9094 			ret);
9095 
9096 }
9097 
9098 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9099 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9100 				 set, "set");
9101 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9102 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9103 				 port, "port");
9104 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9105 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9106 			      port_id, RTE_UINT16);
9107 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9108 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9109 				 what, "uta");
9110 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9111 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9112 				address);
9113 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9114 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9115 				 mode, "on#off");
9116 
9117 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9118 	.f = cmd_set_uc_hash_parsed,
9119 	.data = NULL,
9120 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
9121 	.tokens = {
9122 		(void *)&cmd_set_uc_hash_set,
9123 		(void *)&cmd_set_uc_hash_port,
9124 		(void *)&cmd_set_uc_hash_portid,
9125 		(void *)&cmd_set_uc_hash_what,
9126 		(void *)&cmd_set_uc_hash_mac,
9127 		(void *)&cmd_set_uc_hash_mode,
9128 		NULL,
9129 	},
9130 };
9131 
9132 struct cmd_set_uc_all_hash_table {
9133 	cmdline_fixed_string_t set;
9134 	cmdline_fixed_string_t port;
9135 	portid_t port_id;
9136 	cmdline_fixed_string_t what;
9137 	cmdline_fixed_string_t value;
9138 	cmdline_fixed_string_t mode;
9139 };
9140 
9141 static void
9142 cmd_set_uc_all_hash_parsed(void *parsed_result,
9143 		       __rte_unused struct cmdline *cl,
9144 		       __rte_unused void *data)
9145 {
9146 	int ret=0;
9147 	struct cmd_set_uc_all_hash_table *res = parsed_result;
9148 
9149 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9150 
9151 	if ((strcmp(res->what, "uta") == 0) &&
9152 		(strcmp(res->value, "all") == 0))
9153 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9154 	if (ret < 0)
9155 		fprintf(stderr,
9156 			"bad unicast hash table parameter, return code = %d\n",
9157 			ret);
9158 }
9159 
9160 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9161 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9162 				 set, "set");
9163 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9164 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9165 				 port, "port");
9166 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9167 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9168 			      port_id, RTE_UINT16);
9169 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9170 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9171 				 what, "uta");
9172 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9173 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9174 				value,"all");
9175 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9176 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9177 				 mode, "on#off");
9178 
9179 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9180 	.f = cmd_set_uc_all_hash_parsed,
9181 	.data = NULL,
9182 	.help_str = "set port <port_id> uta all on|off",
9183 	.tokens = {
9184 		(void *)&cmd_set_uc_all_hash_set,
9185 		(void *)&cmd_set_uc_all_hash_port,
9186 		(void *)&cmd_set_uc_all_hash_portid,
9187 		(void *)&cmd_set_uc_all_hash_what,
9188 		(void *)&cmd_set_uc_all_hash_value,
9189 		(void *)&cmd_set_uc_all_hash_mode,
9190 		NULL,
9191 	},
9192 };
9193 
9194 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9195 struct cmd_set_vf_traffic {
9196 	cmdline_fixed_string_t set;
9197 	cmdline_fixed_string_t port;
9198 	portid_t port_id;
9199 	cmdline_fixed_string_t vf;
9200 	uint8_t vf_id;
9201 	cmdline_fixed_string_t what;
9202 	cmdline_fixed_string_t mode;
9203 };
9204 
9205 static void
9206 cmd_set_vf_traffic_parsed(void *parsed_result,
9207 		       __rte_unused struct cmdline *cl,
9208 		       __rte_unused void *data)
9209 {
9210 	struct cmd_set_vf_traffic *res = parsed_result;
9211 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9212 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9213 
9214 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9215 }
9216 
9217 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9218 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9219 				 set, "set");
9220 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9221 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9222 				 port, "port");
9223 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9224 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9225 			      port_id, RTE_UINT16);
9226 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9227 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9228 				 vf, "vf");
9229 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9230 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9231 			      vf_id, RTE_UINT8);
9232 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9233 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9234 				 what, "tx#rx");
9235 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9236 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9237 				 mode, "on#off");
9238 
9239 cmdline_parse_inst_t cmd_set_vf_traffic = {
9240 	.f = cmd_set_vf_traffic_parsed,
9241 	.data = NULL,
9242 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9243 	.tokens = {
9244 		(void *)&cmd_setvf_traffic_set,
9245 		(void *)&cmd_setvf_traffic_port,
9246 		(void *)&cmd_setvf_traffic_portid,
9247 		(void *)&cmd_setvf_traffic_vf,
9248 		(void *)&cmd_setvf_traffic_vfid,
9249 		(void *)&cmd_setvf_traffic_what,
9250 		(void *)&cmd_setvf_traffic_mode,
9251 		NULL,
9252 	},
9253 };
9254 
9255 /* *** CONFIGURE VF RECEIVE MODE *** */
9256 struct cmd_set_vf_rxmode {
9257 	cmdline_fixed_string_t set;
9258 	cmdline_fixed_string_t port;
9259 	portid_t port_id;
9260 	cmdline_fixed_string_t vf;
9261 	uint8_t vf_id;
9262 	cmdline_fixed_string_t what;
9263 	cmdline_fixed_string_t mode;
9264 	cmdline_fixed_string_t on;
9265 };
9266 
9267 static void
9268 cmd_set_vf_rxmode_parsed(void *parsed_result,
9269 		       __rte_unused struct cmdline *cl,
9270 		       __rte_unused void *data)
9271 {
9272 	int ret = -ENOTSUP;
9273 	uint16_t vf_rxmode = 0;
9274 	struct cmd_set_vf_rxmode *res = parsed_result;
9275 
9276 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9277 	if (!strcmp(res->what,"rxmode")) {
9278 		if (!strcmp(res->mode, "AUPE"))
9279 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9280 		else if (!strcmp(res->mode, "ROPE"))
9281 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9282 		else if (!strcmp(res->mode, "BAM"))
9283 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9284 		else if (!strncmp(res->mode, "MPE",3))
9285 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9286 	}
9287 
9288 	RTE_SET_USED(is_on);
9289 
9290 #ifdef RTE_NET_IXGBE
9291 	if (ret == -ENOTSUP)
9292 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9293 						  vf_rxmode, (uint8_t)is_on);
9294 #endif
9295 #ifdef RTE_NET_BNXT
9296 	if (ret == -ENOTSUP)
9297 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9298 						 vf_rxmode, (uint8_t)is_on);
9299 #endif
9300 	if (ret < 0)
9301 		fprintf(stderr,
9302 			"bad VF receive mode parameter, return code = %d\n",
9303 			ret);
9304 }
9305 
9306 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9307 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9308 				 set, "set");
9309 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9310 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9311 				 port, "port");
9312 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9313 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9314 			      port_id, RTE_UINT16);
9315 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9316 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9317 				 vf, "vf");
9318 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9319 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9320 			      vf_id, RTE_UINT8);
9321 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9322 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9323 				 what, "rxmode");
9324 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9325 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9326 				 mode, "AUPE#ROPE#BAM#MPE");
9327 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9328 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9329 				 on, "on#off");
9330 
9331 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9332 	.f = cmd_set_vf_rxmode_parsed,
9333 	.data = NULL,
9334 	.help_str = "set port <port_id> vf <vf_id> rxmode "
9335 		"AUPE|ROPE|BAM|MPE on|off",
9336 	.tokens = {
9337 		(void *)&cmd_set_vf_rxmode_set,
9338 		(void *)&cmd_set_vf_rxmode_port,
9339 		(void *)&cmd_set_vf_rxmode_portid,
9340 		(void *)&cmd_set_vf_rxmode_vf,
9341 		(void *)&cmd_set_vf_rxmode_vfid,
9342 		(void *)&cmd_set_vf_rxmode_what,
9343 		(void *)&cmd_set_vf_rxmode_mode,
9344 		(void *)&cmd_set_vf_rxmode_on,
9345 		NULL,
9346 	},
9347 };
9348 
9349 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9350 struct cmd_vf_mac_addr_result {
9351 	cmdline_fixed_string_t mac_addr_cmd;
9352 	cmdline_fixed_string_t what;
9353 	cmdline_fixed_string_t port;
9354 	uint16_t port_num;
9355 	cmdline_fixed_string_t vf;
9356 	uint8_t vf_num;
9357 	struct rte_ether_addr address;
9358 };
9359 
9360 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9361 		__rte_unused struct cmdline *cl,
9362 		__rte_unused void *data)
9363 {
9364 	struct cmd_vf_mac_addr_result *res = parsed_result;
9365 	int ret = -ENOTSUP;
9366 
9367 	if (strcmp(res->what, "add") != 0)
9368 		return;
9369 
9370 #ifdef RTE_NET_I40E
9371 	if (ret == -ENOTSUP)
9372 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9373 						   &res->address);
9374 #endif
9375 #ifdef RTE_NET_BNXT
9376 	if (ret == -ENOTSUP)
9377 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9378 						res->vf_num);
9379 #endif
9380 
9381 	if(ret < 0)
9382 		fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9383 
9384 }
9385 
9386 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9387 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9388 				mac_addr_cmd,"mac_addr");
9389 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9390 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9391 				what,"add");
9392 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9393 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9394 				port,"port");
9395 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9396 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9397 				port_num, RTE_UINT16);
9398 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9399 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9400 				vf,"vf");
9401 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9402 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9403 				vf_num, RTE_UINT8);
9404 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9405 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9406 				address);
9407 
9408 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9409 	.f = cmd_vf_mac_addr_parsed,
9410 	.data = (void *)0,
9411 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9412 		"Add MAC address filtering for a VF on port_id",
9413 	.tokens = {
9414 		(void *)&cmd_vf_mac_addr_cmd,
9415 		(void *)&cmd_vf_mac_addr_what,
9416 		(void *)&cmd_vf_mac_addr_port,
9417 		(void *)&cmd_vf_mac_addr_portnum,
9418 		(void *)&cmd_vf_mac_addr_vf,
9419 		(void *)&cmd_vf_mac_addr_vfnum,
9420 		(void *)&cmd_vf_mac_addr_addr,
9421 		NULL,
9422 	},
9423 };
9424 
9425 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9426 struct cmd_vf_rx_vlan_filter {
9427 	cmdline_fixed_string_t rx_vlan;
9428 	cmdline_fixed_string_t what;
9429 	uint16_t vlan_id;
9430 	cmdline_fixed_string_t port;
9431 	portid_t port_id;
9432 	cmdline_fixed_string_t vf;
9433 	uint64_t vf_mask;
9434 };
9435 
9436 static void
9437 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9438 			  __rte_unused struct cmdline *cl,
9439 			  __rte_unused void *data)
9440 {
9441 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
9442 	int ret = -ENOTSUP;
9443 
9444 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9445 
9446 #ifdef RTE_NET_IXGBE
9447 	if (ret == -ENOTSUP)
9448 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9449 				res->vlan_id, res->vf_mask, is_add);
9450 #endif
9451 #ifdef RTE_NET_I40E
9452 	if (ret == -ENOTSUP)
9453 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9454 				res->vlan_id, res->vf_mask, is_add);
9455 #endif
9456 #ifdef RTE_NET_BNXT
9457 	if (ret == -ENOTSUP)
9458 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9459 				res->vlan_id, res->vf_mask, is_add);
9460 #endif
9461 
9462 	switch (ret) {
9463 	case 0:
9464 		break;
9465 	case -EINVAL:
9466 		fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9467 			res->vlan_id, res->vf_mask);
9468 		break;
9469 	case -ENODEV:
9470 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
9471 		break;
9472 	case -ENOTSUP:
9473 		fprintf(stderr, "function not implemented or supported\n");
9474 		break;
9475 	default:
9476 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9477 	}
9478 }
9479 
9480 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9481 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9482 				 rx_vlan, "rx_vlan");
9483 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9484 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9485 				 what, "add#rm");
9486 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9487 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9488 			      vlan_id, RTE_UINT16);
9489 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9490 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9491 				 port, "port");
9492 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9493 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9494 			      port_id, RTE_UINT16);
9495 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9496 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9497 				 vf, "vf");
9498 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9499 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9500 			      vf_mask, RTE_UINT64);
9501 
9502 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9503 	.f = cmd_vf_rx_vlan_filter_parsed,
9504 	.data = NULL,
9505 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9506 		"(vf_mask = hexadecimal VF mask)",
9507 	.tokens = {
9508 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9509 		(void *)&cmd_vf_rx_vlan_filter_what,
9510 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
9511 		(void *)&cmd_vf_rx_vlan_filter_port,
9512 		(void *)&cmd_vf_rx_vlan_filter_portid,
9513 		(void *)&cmd_vf_rx_vlan_filter_vf,
9514 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
9515 		NULL,
9516 	},
9517 };
9518 
9519 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9520 struct cmd_queue_rate_limit_result {
9521 	cmdline_fixed_string_t set;
9522 	cmdline_fixed_string_t port;
9523 	uint16_t port_num;
9524 	cmdline_fixed_string_t queue;
9525 	uint8_t queue_num;
9526 	cmdline_fixed_string_t rate;
9527 	uint16_t rate_num;
9528 };
9529 
9530 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9531 		__rte_unused struct cmdline *cl,
9532 		__rte_unused void *data)
9533 {
9534 	struct cmd_queue_rate_limit_result *res = parsed_result;
9535 	int ret = 0;
9536 
9537 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9538 		&& (strcmp(res->queue, "queue") == 0)
9539 		&& (strcmp(res->rate, "rate") == 0))
9540 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
9541 					res->rate_num);
9542 	if (ret < 0)
9543 		fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9544 			strerror(-ret));
9545 
9546 }
9547 
9548 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9549 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9550 				set, "set");
9551 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9552 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9553 				port, "port");
9554 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9555 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9556 				port_num, RTE_UINT16);
9557 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9558 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9559 				queue, "queue");
9560 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9561 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9562 				queue_num, RTE_UINT8);
9563 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9564 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9565 				rate, "rate");
9566 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9567 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9568 				rate_num, RTE_UINT16);
9569 
9570 cmdline_parse_inst_t cmd_queue_rate_limit = {
9571 	.f = cmd_queue_rate_limit_parsed,
9572 	.data = (void *)0,
9573 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9574 		"Set rate limit for a queue on port_id",
9575 	.tokens = {
9576 		(void *)&cmd_queue_rate_limit_set,
9577 		(void *)&cmd_queue_rate_limit_port,
9578 		(void *)&cmd_queue_rate_limit_portnum,
9579 		(void *)&cmd_queue_rate_limit_queue,
9580 		(void *)&cmd_queue_rate_limit_queuenum,
9581 		(void *)&cmd_queue_rate_limit_rate,
9582 		(void *)&cmd_queue_rate_limit_ratenum,
9583 		NULL,
9584 	},
9585 };
9586 
9587 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9588 struct cmd_vf_rate_limit_result {
9589 	cmdline_fixed_string_t set;
9590 	cmdline_fixed_string_t port;
9591 	uint16_t port_num;
9592 	cmdline_fixed_string_t vf;
9593 	uint8_t vf_num;
9594 	cmdline_fixed_string_t rate;
9595 	uint16_t rate_num;
9596 	cmdline_fixed_string_t q_msk;
9597 	uint64_t q_msk_val;
9598 };
9599 
9600 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9601 		__rte_unused struct cmdline *cl,
9602 		__rte_unused void *data)
9603 {
9604 	struct cmd_vf_rate_limit_result *res = parsed_result;
9605 	int ret = 0;
9606 
9607 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9608 		&& (strcmp(res->vf, "vf") == 0)
9609 		&& (strcmp(res->rate, "rate") == 0)
9610 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9611 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9612 					res->rate_num, res->q_msk_val);
9613 	if (ret < 0)
9614 		fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9615 			strerror(-ret));
9616 
9617 }
9618 
9619 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9620 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9621 				set, "set");
9622 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9623 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9624 				port, "port");
9625 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9626 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9627 				port_num, RTE_UINT16);
9628 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9629 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9630 				vf, "vf");
9631 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9632 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9633 				vf_num, RTE_UINT8);
9634 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9635 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9636 				rate, "rate");
9637 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9638 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9639 				rate_num, RTE_UINT16);
9640 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9641 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9642 				q_msk, "queue_mask");
9643 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9644 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9645 				q_msk_val, RTE_UINT64);
9646 
9647 cmdline_parse_inst_t cmd_vf_rate_limit = {
9648 	.f = cmd_vf_rate_limit_parsed,
9649 	.data = (void *)0,
9650 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9651 		"queue_mask <queue_mask_value>: "
9652 		"Set rate limit for queues of VF on port_id",
9653 	.tokens = {
9654 		(void *)&cmd_vf_rate_limit_set,
9655 		(void *)&cmd_vf_rate_limit_port,
9656 		(void *)&cmd_vf_rate_limit_portnum,
9657 		(void *)&cmd_vf_rate_limit_vf,
9658 		(void *)&cmd_vf_rate_limit_vfnum,
9659 		(void *)&cmd_vf_rate_limit_rate,
9660 		(void *)&cmd_vf_rate_limit_ratenum,
9661 		(void *)&cmd_vf_rate_limit_q_msk,
9662 		(void *)&cmd_vf_rate_limit_q_msk_val,
9663 		NULL,
9664 	},
9665 };
9666 
9667 /* *** CONFIGURE TUNNEL UDP PORT *** */
9668 struct cmd_tunnel_udp_config {
9669 	cmdline_fixed_string_t rx_vxlan_port;
9670 	cmdline_fixed_string_t what;
9671 	uint16_t udp_port;
9672 	portid_t port_id;
9673 };
9674 
9675 static void
9676 cmd_tunnel_udp_config_parsed(void *parsed_result,
9677 			  __rte_unused struct cmdline *cl,
9678 			  __rte_unused void *data)
9679 {
9680 	struct cmd_tunnel_udp_config *res = parsed_result;
9681 	struct rte_eth_udp_tunnel tunnel_udp;
9682 	int ret;
9683 
9684 	tunnel_udp.udp_port = res->udp_port;
9685 	tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9686 
9687 	if (!strcmp(res->what, "add"))
9688 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9689 						      &tunnel_udp);
9690 	else
9691 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9692 							 &tunnel_udp);
9693 
9694 	if (ret < 0)
9695 		fprintf(stderr, "udp tunneling add error: (%s)\n",
9696 			strerror(-ret));
9697 }
9698 
9699 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9700 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9701 				rx_vxlan_port, "rx_vxlan_port");
9702 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9703 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9704 				what, "add#rm");
9705 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9706 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9707 				udp_port, RTE_UINT16);
9708 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9709 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9710 				port_id, RTE_UINT16);
9711 
9712 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9713 	.f = cmd_tunnel_udp_config_parsed,
9714 	.data = (void *)0,
9715 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9716 		"Add/Remove a tunneling UDP port filter",
9717 	.tokens = {
9718 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9719 		(void *)&cmd_tunnel_udp_config_what,
9720 		(void *)&cmd_tunnel_udp_config_udp_port,
9721 		(void *)&cmd_tunnel_udp_config_port_id,
9722 		NULL,
9723 	},
9724 };
9725 
9726 struct cmd_config_tunnel_udp_port {
9727 	cmdline_fixed_string_t port;
9728 	cmdline_fixed_string_t config;
9729 	portid_t port_id;
9730 	cmdline_fixed_string_t udp_tunnel_port;
9731 	cmdline_fixed_string_t action;
9732 	cmdline_fixed_string_t tunnel_type;
9733 	uint16_t udp_port;
9734 };
9735 
9736 static void
9737 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9738 			       __rte_unused struct cmdline *cl,
9739 			       __rte_unused void *data)
9740 {
9741 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9742 	struct rte_eth_udp_tunnel tunnel_udp;
9743 	int ret = 0;
9744 
9745 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9746 		return;
9747 
9748 	tunnel_udp.udp_port = res->udp_port;
9749 
9750 	if (!strcmp(res->tunnel_type, "vxlan")) {
9751 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9752 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9753 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9754 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9755 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9756 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9757 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9758 	} else {
9759 		fprintf(stderr, "Invalid tunnel type\n");
9760 		return;
9761 	}
9762 
9763 	if (!strcmp(res->action, "add"))
9764 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9765 						      &tunnel_udp);
9766 	else
9767 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9768 							 &tunnel_udp);
9769 
9770 	if (ret < 0)
9771 		fprintf(stderr, "udp tunneling port add error: (%s)\n",
9772 			strerror(-ret));
9773 }
9774 
9775 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9776 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9777 				 "port");
9778 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9779 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9780 				 "config");
9781 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9782 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9783 			      RTE_UINT16);
9784 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9785 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9786 				 udp_tunnel_port,
9787 				 "udp_tunnel_port");
9788 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9789 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9790 				 "add#rm");
9791 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9792 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9793 				 "vxlan#geneve#vxlan-gpe#ecpri");
9794 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9795 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9796 			      RTE_UINT16);
9797 
9798 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9799 	.f = cmd_cfg_tunnel_udp_port_parsed,
9800 	.data = NULL,
9801 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9802 		"geneve|vxlan-gpe|ecpri <udp_port>",
9803 	.tokens = {
9804 		(void *)&cmd_config_tunnel_udp_port_port,
9805 		(void *)&cmd_config_tunnel_udp_port_config,
9806 		(void *)&cmd_config_tunnel_udp_port_port_id,
9807 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9808 		(void *)&cmd_config_tunnel_udp_port_action,
9809 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9810 		(void *)&cmd_config_tunnel_udp_port_value,
9811 		NULL,
9812 	},
9813 };
9814 
9815 /* ******************************************************************************** */
9816 
9817 struct cmd_dump_result {
9818 	cmdline_fixed_string_t dump;
9819 };
9820 
9821 static void
9822 dump_struct_sizes(void)
9823 {
9824 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9825 	DUMP_SIZE(struct rte_mbuf);
9826 	DUMP_SIZE(struct rte_mempool);
9827 	DUMP_SIZE(struct rte_ring);
9828 #undef DUMP_SIZE
9829 }
9830 
9831 
9832 /* Dump the socket memory statistics on console */
9833 static void
9834 dump_socket_mem(FILE *f)
9835 {
9836 	struct rte_malloc_socket_stats socket_stats;
9837 	unsigned int i;
9838 	size_t total = 0;
9839 	size_t alloc = 0;
9840 	size_t free = 0;
9841 	unsigned int n_alloc = 0;
9842 	unsigned int n_free = 0;
9843 	static size_t last_allocs;
9844 	static size_t last_total;
9845 
9846 
9847 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9848 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9849 		    !socket_stats.heap_totalsz_bytes)
9850 			continue;
9851 		total += socket_stats.heap_totalsz_bytes;
9852 		alloc += socket_stats.heap_allocsz_bytes;
9853 		free += socket_stats.heap_freesz_bytes;
9854 		n_alloc += socket_stats.alloc_count;
9855 		n_free += socket_stats.free_count;
9856 		fprintf(f,
9857 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9858 			i,
9859 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9860 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9861 			(double)socket_stats.heap_allocsz_bytes * 100 /
9862 			(double)socket_stats.heap_totalsz_bytes,
9863 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9864 			socket_stats.alloc_count,
9865 			socket_stats.free_count);
9866 	}
9867 	fprintf(f,
9868 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9869 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9870 		total ? ((double)alloc * 100 / (double)total) : 0,
9871 		(double)free / (1024 * 1024),
9872 		n_alloc, n_free);
9873 	if (last_allocs)
9874 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9875 			((double)total - (double)last_total) / (1024 * 1024),
9876 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9877 	last_allocs = alloc;
9878 	last_total = total;
9879 }
9880 
9881 static void cmd_dump_parsed(void *parsed_result,
9882 			    __rte_unused struct cmdline *cl,
9883 			    __rte_unused void *data)
9884 {
9885 	struct cmd_dump_result *res = parsed_result;
9886 
9887 	if (!strcmp(res->dump, "dump_physmem"))
9888 		rte_dump_physmem_layout(stdout);
9889 	else if (!strcmp(res->dump, "dump_socket_mem"))
9890 		dump_socket_mem(stdout);
9891 	else if (!strcmp(res->dump, "dump_memzone"))
9892 		rte_memzone_dump(stdout);
9893 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9894 		dump_struct_sizes();
9895 	else if (!strcmp(res->dump, "dump_ring"))
9896 		rte_ring_list_dump(stdout);
9897 	else if (!strcmp(res->dump, "dump_mempool"))
9898 		rte_mempool_list_dump(stdout);
9899 	else if (!strcmp(res->dump, "dump_devargs"))
9900 		rte_devargs_dump(stdout);
9901 	else if (!strcmp(res->dump, "dump_log_types"))
9902 		rte_log_dump(stdout);
9903 }
9904 
9905 cmdline_parse_token_string_t cmd_dump_dump =
9906 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9907 		"dump_physmem#"
9908 		"dump_memzone#"
9909 		"dump_socket_mem#"
9910 		"dump_struct_sizes#"
9911 		"dump_ring#"
9912 		"dump_mempool#"
9913 		"dump_devargs#"
9914 		"dump_log_types");
9915 
9916 cmdline_parse_inst_t cmd_dump = {
9917 	.f = cmd_dump_parsed,  /* function to call */
9918 	.data = NULL,      /* 2nd arg of func */
9919 	.help_str = "Dump status",
9920 	.tokens = {        /* token list, NULL terminated */
9921 		(void *)&cmd_dump_dump,
9922 		NULL,
9923 	},
9924 };
9925 
9926 /* ******************************************************************************** */
9927 
9928 struct cmd_dump_one_result {
9929 	cmdline_fixed_string_t dump;
9930 	cmdline_fixed_string_t name;
9931 };
9932 
9933 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9934 				__rte_unused void *data)
9935 {
9936 	struct cmd_dump_one_result *res = parsed_result;
9937 
9938 	if (!strcmp(res->dump, "dump_ring")) {
9939 		struct rte_ring *r;
9940 		r = rte_ring_lookup(res->name);
9941 		if (r == NULL) {
9942 			cmdline_printf(cl, "Cannot find ring\n");
9943 			return;
9944 		}
9945 		rte_ring_dump(stdout, r);
9946 	} else if (!strcmp(res->dump, "dump_mempool")) {
9947 		struct rte_mempool *mp;
9948 		mp = rte_mempool_lookup(res->name);
9949 		if (mp == NULL) {
9950 			cmdline_printf(cl, "Cannot find mempool\n");
9951 			return;
9952 		}
9953 		rte_mempool_dump(stdout, mp);
9954 	}
9955 }
9956 
9957 cmdline_parse_token_string_t cmd_dump_one_dump =
9958 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9959 				 "dump_ring#dump_mempool");
9960 
9961 cmdline_parse_token_string_t cmd_dump_one_name =
9962 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9963 
9964 cmdline_parse_inst_t cmd_dump_one = {
9965 	.f = cmd_dump_one_parsed,  /* function to call */
9966 	.data = NULL,      /* 2nd arg of func */
9967 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9968 	.tokens = {        /* token list, NULL terminated */
9969 		(void *)&cmd_dump_one_dump,
9970 		(void *)&cmd_dump_one_name,
9971 		NULL,
9972 	},
9973 };
9974 
9975 /* *** queue region set *** */
9976 struct cmd_queue_region_result {
9977 	cmdline_fixed_string_t set;
9978 	cmdline_fixed_string_t port;
9979 	portid_t port_id;
9980 	cmdline_fixed_string_t cmd;
9981 	cmdline_fixed_string_t region;
9982 	uint8_t  region_id;
9983 	cmdline_fixed_string_t queue_start_index;
9984 	uint8_t  queue_id;
9985 	cmdline_fixed_string_t queue_num;
9986 	uint8_t  queue_num_value;
9987 };
9988 
9989 static void
9990 cmd_queue_region_parsed(void *parsed_result,
9991 			__rte_unused struct cmdline *cl,
9992 			__rte_unused void *data)
9993 {
9994 	struct cmd_queue_region_result *res = parsed_result;
9995 	int ret = -ENOTSUP;
9996 #ifdef RTE_NET_I40E
9997 	struct rte_pmd_i40e_queue_region_conf region_conf;
9998 	enum rte_pmd_i40e_queue_region_op op_type;
9999 #endif
10000 
10001 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10002 		return;
10003 
10004 #ifdef RTE_NET_I40E
10005 	memset(&region_conf, 0, sizeof(region_conf));
10006 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10007 	region_conf.region_id = res->region_id;
10008 	region_conf.queue_num = res->queue_num_value;
10009 	region_conf.queue_start_index = res->queue_id;
10010 
10011 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10012 				op_type, &region_conf);
10013 #endif
10014 
10015 	switch (ret) {
10016 	case 0:
10017 		break;
10018 	case -ENOTSUP:
10019 		fprintf(stderr, "function not implemented or supported\n");
10020 		break;
10021 	default:
10022 		fprintf(stderr, "queue region config error: (%s)\n",
10023 			strerror(-ret));
10024 	}
10025 }
10026 
10027 cmdline_parse_token_string_t cmd_queue_region_set =
10028 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10029 		set, "set");
10030 cmdline_parse_token_string_t cmd_queue_region_port =
10031 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10032 cmdline_parse_token_num_t cmd_queue_region_port_id =
10033 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10034 				port_id, RTE_UINT16);
10035 cmdline_parse_token_string_t cmd_queue_region_cmd =
10036 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10037 				 cmd, "queue-region");
10038 cmdline_parse_token_string_t cmd_queue_region_id =
10039 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10040 				region, "region_id");
10041 cmdline_parse_token_num_t cmd_queue_region_index =
10042 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10043 				region_id, RTE_UINT8);
10044 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10045 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10046 				queue_start_index, "queue_start_index");
10047 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10048 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10049 				queue_id, RTE_UINT8);
10050 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10051 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10052 				queue_num, "queue_num");
10053 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10054 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10055 				queue_num_value, RTE_UINT8);
10056 
10057 cmdline_parse_inst_t cmd_queue_region = {
10058 	.f = cmd_queue_region_parsed,
10059 	.data = NULL,
10060 	.help_str = "set port <port_id> queue-region region_id <value> "
10061 		"queue_start_index <value> queue_num <value>: Set a queue region",
10062 	.tokens = {
10063 		(void *)&cmd_queue_region_set,
10064 		(void *)&cmd_queue_region_port,
10065 		(void *)&cmd_queue_region_port_id,
10066 		(void *)&cmd_queue_region_cmd,
10067 		(void *)&cmd_queue_region_id,
10068 		(void *)&cmd_queue_region_index,
10069 		(void *)&cmd_queue_region_queue_start_index,
10070 		(void *)&cmd_queue_region_queue_id,
10071 		(void *)&cmd_queue_region_queue_num,
10072 		(void *)&cmd_queue_region_queue_num_value,
10073 		NULL,
10074 	},
10075 };
10076 
10077 /* *** queue region and flowtype set *** */
10078 struct cmd_region_flowtype_result {
10079 	cmdline_fixed_string_t set;
10080 	cmdline_fixed_string_t port;
10081 	portid_t port_id;
10082 	cmdline_fixed_string_t cmd;
10083 	cmdline_fixed_string_t region;
10084 	uint8_t  region_id;
10085 	cmdline_fixed_string_t flowtype;
10086 	uint8_t  flowtype_id;
10087 };
10088 
10089 static void
10090 cmd_region_flowtype_parsed(void *parsed_result,
10091 			__rte_unused struct cmdline *cl,
10092 			__rte_unused void *data)
10093 {
10094 	struct cmd_region_flowtype_result *res = parsed_result;
10095 	int ret = -ENOTSUP;
10096 #ifdef RTE_NET_I40E
10097 	struct rte_pmd_i40e_queue_region_conf region_conf;
10098 	enum rte_pmd_i40e_queue_region_op op_type;
10099 #endif
10100 
10101 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10102 		return;
10103 
10104 #ifdef RTE_NET_I40E
10105 	memset(&region_conf, 0, sizeof(region_conf));
10106 
10107 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10108 	region_conf.region_id = res->region_id;
10109 	region_conf.hw_flowtype = res->flowtype_id;
10110 
10111 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10112 			op_type, &region_conf);
10113 #endif
10114 
10115 	switch (ret) {
10116 	case 0:
10117 		break;
10118 	case -ENOTSUP:
10119 		fprintf(stderr, "function not implemented or supported\n");
10120 		break;
10121 	default:
10122 		fprintf(stderr, "region flowtype config error: (%s)\n",
10123 			strerror(-ret));
10124 	}
10125 }
10126 
10127 cmdline_parse_token_string_t cmd_region_flowtype_set =
10128 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10129 				set, "set");
10130 cmdline_parse_token_string_t cmd_region_flowtype_port =
10131 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10132 				port, "port");
10133 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10134 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10135 				port_id, RTE_UINT16);
10136 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10137 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10138 				cmd, "queue-region");
10139 cmdline_parse_token_string_t cmd_region_flowtype_index =
10140 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10141 				region, "region_id");
10142 cmdline_parse_token_num_t cmd_region_flowtype_id =
10143 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10144 				region_id, RTE_UINT8);
10145 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10146 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10147 				flowtype, "flowtype");
10148 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10149 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10150 				flowtype_id, RTE_UINT8);
10151 cmdline_parse_inst_t cmd_region_flowtype = {
10152 	.f = cmd_region_flowtype_parsed,
10153 	.data = NULL,
10154 	.help_str = "set port <port_id> queue-region region_id <value> "
10155 		"flowtype <value>: Set a flowtype region index",
10156 	.tokens = {
10157 		(void *)&cmd_region_flowtype_set,
10158 		(void *)&cmd_region_flowtype_port,
10159 		(void *)&cmd_region_flowtype_port_index,
10160 		(void *)&cmd_region_flowtype_cmd,
10161 		(void *)&cmd_region_flowtype_index,
10162 		(void *)&cmd_region_flowtype_id,
10163 		(void *)&cmd_region_flowtype_flow_index,
10164 		(void *)&cmd_region_flowtype_flow_id,
10165 		NULL,
10166 	},
10167 };
10168 
10169 /* *** User Priority (UP) to queue region (region_id) set *** */
10170 struct cmd_user_priority_region_result {
10171 	cmdline_fixed_string_t set;
10172 	cmdline_fixed_string_t port;
10173 	portid_t port_id;
10174 	cmdline_fixed_string_t cmd;
10175 	cmdline_fixed_string_t user_priority;
10176 	uint8_t  user_priority_id;
10177 	cmdline_fixed_string_t region;
10178 	uint8_t  region_id;
10179 };
10180 
10181 static void
10182 cmd_user_priority_region_parsed(void *parsed_result,
10183 			__rte_unused struct cmdline *cl,
10184 			__rte_unused void *data)
10185 {
10186 	struct cmd_user_priority_region_result *res = parsed_result;
10187 	int ret = -ENOTSUP;
10188 #ifdef RTE_NET_I40E
10189 	struct rte_pmd_i40e_queue_region_conf region_conf;
10190 	enum rte_pmd_i40e_queue_region_op op_type;
10191 #endif
10192 
10193 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10194 		return;
10195 
10196 #ifdef RTE_NET_I40E
10197 	memset(&region_conf, 0, sizeof(region_conf));
10198 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10199 	region_conf.user_priority = res->user_priority_id;
10200 	region_conf.region_id = res->region_id;
10201 
10202 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10203 				op_type, &region_conf);
10204 #endif
10205 
10206 	switch (ret) {
10207 	case 0:
10208 		break;
10209 	case -ENOTSUP:
10210 		fprintf(stderr, "function not implemented or supported\n");
10211 		break;
10212 	default:
10213 		fprintf(stderr, "user_priority region config error: (%s)\n",
10214 			strerror(-ret));
10215 	}
10216 }
10217 
10218 cmdline_parse_token_string_t cmd_user_priority_region_set =
10219 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10220 				set, "set");
10221 cmdline_parse_token_string_t cmd_user_priority_region_port =
10222 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10223 				port, "port");
10224 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10225 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10226 				port_id, RTE_UINT16);
10227 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10228 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10229 				cmd, "queue-region");
10230 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10231 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10232 				user_priority, "UP");
10233 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10234 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10235 				user_priority_id, RTE_UINT8);
10236 cmdline_parse_token_string_t cmd_user_priority_region_region =
10237 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10238 				region, "region_id");
10239 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10240 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10241 				region_id, RTE_UINT8);
10242 
10243 cmdline_parse_inst_t cmd_user_priority_region = {
10244 	.f = cmd_user_priority_region_parsed,
10245 	.data = NULL,
10246 	.help_str = "set port <port_id> queue-region UP <value> "
10247 		"region_id <value>: Set the mapping of User Priority (UP) "
10248 		"to queue region (region_id) ",
10249 	.tokens = {
10250 		(void *)&cmd_user_priority_region_set,
10251 		(void *)&cmd_user_priority_region_port,
10252 		(void *)&cmd_user_priority_region_port_index,
10253 		(void *)&cmd_user_priority_region_cmd,
10254 		(void *)&cmd_user_priority_region_UP,
10255 		(void *)&cmd_user_priority_region_UP_id,
10256 		(void *)&cmd_user_priority_region_region,
10257 		(void *)&cmd_user_priority_region_region_id,
10258 		NULL,
10259 	},
10260 };
10261 
10262 /* *** flush all queue region related configuration *** */
10263 struct cmd_flush_queue_region_result {
10264 	cmdline_fixed_string_t set;
10265 	cmdline_fixed_string_t port;
10266 	portid_t port_id;
10267 	cmdline_fixed_string_t cmd;
10268 	cmdline_fixed_string_t flush;
10269 	cmdline_fixed_string_t what;
10270 };
10271 
10272 static void
10273 cmd_flush_queue_region_parsed(void *parsed_result,
10274 			__rte_unused struct cmdline *cl,
10275 			__rte_unused void *data)
10276 {
10277 	struct cmd_flush_queue_region_result *res = parsed_result;
10278 	int ret = -ENOTSUP;
10279 #ifdef RTE_NET_I40E
10280 	struct rte_pmd_i40e_queue_region_conf region_conf;
10281 	enum rte_pmd_i40e_queue_region_op op_type;
10282 #endif
10283 
10284 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10285 		return;
10286 
10287 #ifdef RTE_NET_I40E
10288 	memset(&region_conf, 0, sizeof(region_conf));
10289 
10290 	if (strcmp(res->what, "on") == 0)
10291 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10292 	else
10293 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10294 
10295 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10296 				op_type, &region_conf);
10297 #endif
10298 
10299 	switch (ret) {
10300 	case 0:
10301 		break;
10302 	case -ENOTSUP:
10303 		fprintf(stderr, "function not implemented or supported\n");
10304 		break;
10305 	default:
10306 		fprintf(stderr, "queue region config flush error: (%s)\n",
10307 			strerror(-ret));
10308 	}
10309 }
10310 
10311 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10312 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10313 				set, "set");
10314 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10315 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10316 				port, "port");
10317 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10318 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10319 				port_id, RTE_UINT16);
10320 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10321 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10322 				cmd, "queue-region");
10323 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10324 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10325 				flush, "flush");
10326 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10327 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10328 				what, "on#off");
10329 
10330 cmdline_parse_inst_t cmd_flush_queue_region = {
10331 	.f = cmd_flush_queue_region_parsed,
10332 	.data = NULL,
10333 	.help_str = "set port <port_id> queue-region flush on|off"
10334 		": flush all queue region related configuration",
10335 	.tokens = {
10336 		(void *)&cmd_flush_queue_region_set,
10337 		(void *)&cmd_flush_queue_region_port,
10338 		(void *)&cmd_flush_queue_region_port_index,
10339 		(void *)&cmd_flush_queue_region_cmd,
10340 		(void *)&cmd_flush_queue_region_flush,
10341 		(void *)&cmd_flush_queue_region_what,
10342 		NULL,
10343 	},
10344 };
10345 
10346 /* *** get all queue region related configuration info *** */
10347 struct cmd_show_queue_region_info {
10348 	cmdline_fixed_string_t show;
10349 	cmdline_fixed_string_t port;
10350 	portid_t port_id;
10351 	cmdline_fixed_string_t cmd;
10352 };
10353 
10354 static void
10355 cmd_show_queue_region_info_parsed(void *parsed_result,
10356 			__rte_unused struct cmdline *cl,
10357 			__rte_unused void *data)
10358 {
10359 	struct cmd_show_queue_region_info *res = parsed_result;
10360 	int ret = -ENOTSUP;
10361 #ifdef RTE_NET_I40E
10362 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10363 	enum rte_pmd_i40e_queue_region_op op_type;
10364 #endif
10365 
10366 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10367 		return;
10368 
10369 #ifdef RTE_NET_I40E
10370 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10371 
10372 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10373 
10374 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10375 					op_type, &rte_pmd_regions);
10376 
10377 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10378 #endif
10379 
10380 	switch (ret) {
10381 	case 0:
10382 		break;
10383 	case -ENOTSUP:
10384 		fprintf(stderr, "function not implemented or supported\n");
10385 		break;
10386 	default:
10387 		fprintf(stderr, "queue region config info show error: (%s)\n",
10388 			strerror(-ret));
10389 	}
10390 }
10391 
10392 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10393 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10394 				show, "show");
10395 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10396 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10397 				port, "port");
10398 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10399 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10400 				port_id, RTE_UINT16);
10401 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10402 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10403 				cmd, "queue-region");
10404 
10405 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10406 	.f = cmd_show_queue_region_info_parsed,
10407 	.data = NULL,
10408 	.help_str = "show port <port_id> queue-region"
10409 		": show all queue region related configuration info",
10410 	.tokens = {
10411 		(void *)&cmd_show_queue_region_info_get,
10412 		(void *)&cmd_show_queue_region_info_port,
10413 		(void *)&cmd_show_queue_region_info_port_index,
10414 		(void *)&cmd_show_queue_region_info_cmd,
10415 		NULL,
10416 	},
10417 };
10418 
10419 /* *** Filters Control *** */
10420 
10421 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10422 do { \
10423 	if ((ip_addr).family == AF_INET) \
10424 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10425 	else { \
10426 		fprintf(stderr, "invalid parameter.\n"); \
10427 		return; \
10428 	} \
10429 } while (0)
10430 
10431 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10432 do { \
10433 	if ((ip_addr).family == AF_INET6) \
10434 		rte_memcpy(&(ip), \
10435 				 &((ip_addr).addr.ipv6), \
10436 				 sizeof(struct in6_addr)); \
10437 	else { \
10438 		fprintf(stderr, "invalid parameter.\n"); \
10439 		return; \
10440 	} \
10441 } while (0)
10442 
10443 #ifdef RTE_NET_I40E
10444 
10445 static uint16_t
10446 str2flowtype(char *string)
10447 {
10448 	uint8_t i = 0;
10449 	static const struct {
10450 		char str[32];
10451 		uint16_t type;
10452 	} flowtype_str[] = {
10453 		{"raw", RTE_ETH_FLOW_RAW},
10454 		{"ipv4", RTE_ETH_FLOW_IPV4},
10455 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10456 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10457 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10458 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10459 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10460 		{"ipv6", RTE_ETH_FLOW_IPV6},
10461 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10462 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10463 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10464 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10465 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10466 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10467 		{"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10468 		{"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10469 		{"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10470 		{"gtpu", RTE_ETH_FLOW_GTPU},
10471 	};
10472 
10473 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10474 		if (!strcmp(flowtype_str[i].str, string))
10475 			return flowtype_str[i].type;
10476 	}
10477 
10478 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10479 		return (uint16_t)atoi(string);
10480 
10481 	return RTE_ETH_FLOW_UNKNOWN;
10482 }
10483 
10484 /* *** deal with flow director filter *** */
10485 struct cmd_flow_director_result {
10486 	cmdline_fixed_string_t flow_director_filter;
10487 	portid_t port_id;
10488 	cmdline_fixed_string_t mode;
10489 	cmdline_fixed_string_t mode_value;
10490 	cmdline_fixed_string_t ops;
10491 	cmdline_fixed_string_t flow;
10492 	cmdline_fixed_string_t flow_type;
10493 	cmdline_fixed_string_t drop;
10494 	cmdline_fixed_string_t queue;
10495 	uint16_t  queue_id;
10496 	cmdline_fixed_string_t fd_id;
10497 	uint32_t  fd_id_value;
10498 	cmdline_fixed_string_t packet;
10499 	char filepath[];
10500 };
10501 
10502 static void
10503 cmd_flow_director_filter_parsed(void *parsed_result,
10504 			  __rte_unused struct cmdline *cl,
10505 			  __rte_unused void *data)
10506 {
10507 	struct cmd_flow_director_result *res = parsed_result;
10508 	int ret = 0;
10509 	struct rte_pmd_i40e_flow_type_mapping
10510 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10511 	struct rte_pmd_i40e_pkt_template_conf conf;
10512 	uint16_t flow_type = str2flowtype(res->flow_type);
10513 	uint16_t i, port = res->port_id;
10514 	uint8_t add;
10515 
10516 	memset(&conf, 0, sizeof(conf));
10517 
10518 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10519 		fprintf(stderr, "Invalid flow type specified.\n");
10520 		return;
10521 	}
10522 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10523 						 mapping);
10524 	if (ret)
10525 		return;
10526 	if (mapping[flow_type].pctype == 0ULL) {
10527 		fprintf(stderr, "Invalid flow type specified.\n");
10528 		return;
10529 	}
10530 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10531 		if (mapping[flow_type].pctype & (1ULL << i)) {
10532 			conf.input.pctype = i;
10533 			break;
10534 		}
10535 	}
10536 
10537 	conf.input.packet = open_file(res->filepath,
10538 				&conf.input.length);
10539 	if (!conf.input.packet)
10540 		return;
10541 	if (!strcmp(res->drop, "drop"))
10542 		conf.action.behavior =
10543 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10544 	else
10545 		conf.action.behavior =
10546 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10547 	conf.action.report_status =
10548 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10549 	conf.action.rx_queue = res->queue_id;
10550 	conf.soft_id = res->fd_id_value;
10551 	add  = strcmp(res->ops, "del") ? 1 : 0;
10552 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10553 							&conf,
10554 							add);
10555 	if (ret < 0)
10556 		fprintf(stderr, "flow director config error: (%s)\n",
10557 			strerror(-ret));
10558 	close_file(conf.input.packet);
10559 }
10560 
10561 cmdline_parse_token_string_t cmd_flow_director_filter =
10562 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10563 				 flow_director_filter, "flow_director_filter");
10564 cmdline_parse_token_num_t cmd_flow_director_port_id =
10565 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10566 			      port_id, RTE_UINT16);
10567 cmdline_parse_token_string_t cmd_flow_director_ops =
10568 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10569 				 ops, "add#del#update");
10570 cmdline_parse_token_string_t cmd_flow_director_flow =
10571 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10572 				 flow, "flow");
10573 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10574 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10575 		flow_type, NULL);
10576 cmdline_parse_token_string_t cmd_flow_director_drop =
10577 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10578 				 drop, "drop#fwd");
10579 cmdline_parse_token_string_t cmd_flow_director_queue =
10580 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10581 				 queue, "queue");
10582 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10583 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10584 			      queue_id, RTE_UINT16);
10585 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10586 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10587 				 fd_id, "fd_id");
10588 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10589 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10590 			      fd_id_value, RTE_UINT32);
10591 
10592 cmdline_parse_token_string_t cmd_flow_director_mode =
10593 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10594 				 mode, "mode");
10595 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10596 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10597 				 mode_value, "raw");
10598 cmdline_parse_token_string_t cmd_flow_director_packet =
10599 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10600 				 packet, "packet");
10601 cmdline_parse_token_string_t cmd_flow_director_filepath =
10602 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10603 				 filepath, NULL);
10604 
10605 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10606 	.f = cmd_flow_director_filter_parsed,
10607 	.data = NULL,
10608 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10609 		"director entry on NIC",
10610 	.tokens = {
10611 		(void *)&cmd_flow_director_filter,
10612 		(void *)&cmd_flow_director_port_id,
10613 		(void *)&cmd_flow_director_mode,
10614 		(void *)&cmd_flow_director_mode_raw,
10615 		(void *)&cmd_flow_director_ops,
10616 		(void *)&cmd_flow_director_flow,
10617 		(void *)&cmd_flow_director_flow_type,
10618 		(void *)&cmd_flow_director_drop,
10619 		(void *)&cmd_flow_director_queue,
10620 		(void *)&cmd_flow_director_queue_id,
10621 		(void *)&cmd_flow_director_fd_id,
10622 		(void *)&cmd_flow_director_fd_id_value,
10623 		(void *)&cmd_flow_director_packet,
10624 		(void *)&cmd_flow_director_filepath,
10625 		NULL,
10626 	},
10627 };
10628 
10629 #endif /* RTE_NET_I40E */
10630 
10631 /* *** deal with flow director mask *** */
10632 struct cmd_flow_director_mask_result {
10633 	cmdline_fixed_string_t flow_director_mask;
10634 	portid_t port_id;
10635 	cmdline_fixed_string_t mode;
10636 	cmdline_fixed_string_t mode_value;
10637 	cmdline_fixed_string_t vlan;
10638 	uint16_t vlan_mask;
10639 	cmdline_fixed_string_t src_mask;
10640 	cmdline_ipaddr_t ipv4_src;
10641 	cmdline_ipaddr_t ipv6_src;
10642 	uint16_t port_src;
10643 	cmdline_fixed_string_t dst_mask;
10644 	cmdline_ipaddr_t ipv4_dst;
10645 	cmdline_ipaddr_t ipv6_dst;
10646 	uint16_t port_dst;
10647 	cmdline_fixed_string_t mac;
10648 	uint8_t mac_addr_byte_mask;
10649 	cmdline_fixed_string_t tunnel_id;
10650 	uint32_t tunnel_id_mask;
10651 	cmdline_fixed_string_t tunnel_type;
10652 	uint8_t tunnel_type_mask;
10653 };
10654 
10655 static void
10656 cmd_flow_director_mask_parsed(void *parsed_result,
10657 			  __rte_unused struct cmdline *cl,
10658 			  __rte_unused void *data)
10659 {
10660 	struct cmd_flow_director_mask_result *res = parsed_result;
10661 	struct rte_eth_fdir_masks *mask;
10662 	struct rte_port *port;
10663 
10664 	port = &ports[res->port_id];
10665 	/** Check if the port is not started **/
10666 	if (port->port_status != RTE_PORT_STOPPED) {
10667 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
10668 		return;
10669 	}
10670 
10671 	mask = &port->dev_conf.fdir_conf.mask;
10672 
10673 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10674 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10675 			fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10676 			return;
10677 		}
10678 
10679 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10680 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10681 		if (strcmp(res->mode_value, "Tunnel")) {
10682 			fprintf(stderr, "Please set mode to Tunnel.\n");
10683 			return;
10684 		}
10685 
10686 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10687 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10688 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10689 		mask->tunnel_type_mask = res->tunnel_type_mask;
10690 	} else {
10691 		if (strcmp(res->mode_value, "IP")) {
10692 			fprintf(stderr, "Please set mode to IP.\n");
10693 			return;
10694 		}
10695 
10696 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10697 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10698 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10699 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10700 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10701 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10702 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10703 	}
10704 
10705 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10706 }
10707 
10708 cmdline_parse_token_string_t cmd_flow_director_mask =
10709 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10710 				 flow_director_mask, "flow_director_mask");
10711 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10712 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10713 			      port_id, RTE_UINT16);
10714 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10715 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10716 				 vlan, "vlan");
10717 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10718 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10719 			      vlan_mask, RTE_UINT16);
10720 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10721 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10722 				 src_mask, "src_mask");
10723 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10724 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10725 				 ipv4_src);
10726 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10727 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10728 				 ipv6_src);
10729 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10730 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10731 			      port_src, RTE_UINT16);
10732 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10733 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10734 				 dst_mask, "dst_mask");
10735 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10736 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10737 				 ipv4_dst);
10738 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10739 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10740 				 ipv6_dst);
10741 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10742 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10743 			      port_dst, RTE_UINT16);
10744 
10745 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10746 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10747 				 mode, "mode");
10748 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10749 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10750 				 mode_value, "IP");
10751 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10752 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10753 				 mode_value, "MAC-VLAN");
10754 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10755 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10756 				 mode_value, "Tunnel");
10757 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10758 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10759 				 mac, "mac");
10760 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10761 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10762 			      mac_addr_byte_mask, RTE_UINT8);
10763 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10764 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10765 				 tunnel_type, "tunnel-type");
10766 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10767 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10768 			      tunnel_type_mask, RTE_UINT8);
10769 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10770 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10771 				 tunnel_id, "tunnel-id");
10772 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10773 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10774 			      tunnel_id_mask, RTE_UINT32);
10775 
10776 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10777 	.f = cmd_flow_director_mask_parsed,
10778 	.data = NULL,
10779 	.help_str = "flow_director_mask ... : "
10780 		"Set IP mode flow director's mask on NIC",
10781 	.tokens = {
10782 		(void *)&cmd_flow_director_mask,
10783 		(void *)&cmd_flow_director_mask_port_id,
10784 		(void *)&cmd_flow_director_mask_mode,
10785 		(void *)&cmd_flow_director_mask_mode_ip,
10786 		(void *)&cmd_flow_director_mask_vlan,
10787 		(void *)&cmd_flow_director_mask_vlan_value,
10788 		(void *)&cmd_flow_director_mask_src,
10789 		(void *)&cmd_flow_director_mask_ipv4_src,
10790 		(void *)&cmd_flow_director_mask_ipv6_src,
10791 		(void *)&cmd_flow_director_mask_port_src,
10792 		(void *)&cmd_flow_director_mask_dst,
10793 		(void *)&cmd_flow_director_mask_ipv4_dst,
10794 		(void *)&cmd_flow_director_mask_ipv6_dst,
10795 		(void *)&cmd_flow_director_mask_port_dst,
10796 		NULL,
10797 	},
10798 };
10799 
10800 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10801 	.f = cmd_flow_director_mask_parsed,
10802 	.data = NULL,
10803 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10804 		"flow director's mask on NIC",
10805 	.tokens = {
10806 		(void *)&cmd_flow_director_mask,
10807 		(void *)&cmd_flow_director_mask_port_id,
10808 		(void *)&cmd_flow_director_mask_mode,
10809 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10810 		(void *)&cmd_flow_director_mask_vlan,
10811 		(void *)&cmd_flow_director_mask_vlan_value,
10812 		NULL,
10813 	},
10814 };
10815 
10816 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10817 	.f = cmd_flow_director_mask_parsed,
10818 	.data = NULL,
10819 	.help_str = "flow_director_mask ... : Set tunnel mode "
10820 		"flow director's mask on NIC",
10821 	.tokens = {
10822 		(void *)&cmd_flow_director_mask,
10823 		(void *)&cmd_flow_director_mask_port_id,
10824 		(void *)&cmd_flow_director_mask_mode,
10825 		(void *)&cmd_flow_director_mask_mode_tunnel,
10826 		(void *)&cmd_flow_director_mask_vlan,
10827 		(void *)&cmd_flow_director_mask_vlan_value,
10828 		(void *)&cmd_flow_director_mask_mac,
10829 		(void *)&cmd_flow_director_mask_mac_value,
10830 		(void *)&cmd_flow_director_mask_tunnel_type,
10831 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10832 		(void *)&cmd_flow_director_mask_tunnel_id,
10833 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10834 		NULL,
10835 	},
10836 };
10837 
10838 /* *** deal with flow director flexible payload configuration *** */
10839 struct cmd_flow_director_flexpayload_result {
10840 	cmdline_fixed_string_t flow_director_flexpayload;
10841 	portid_t port_id;
10842 	cmdline_fixed_string_t payload_layer;
10843 	cmdline_fixed_string_t payload_cfg;
10844 };
10845 
10846 static inline int
10847 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10848 {
10849 	char s[256];
10850 	const char *p, *p0 = q_arg;
10851 	char *end;
10852 	unsigned long int_fld;
10853 	char *str_fld[max_num];
10854 	int i;
10855 	unsigned size;
10856 	int ret = -1;
10857 
10858 	p = strchr(p0, '(');
10859 	if (p == NULL)
10860 		return -1;
10861 	++p;
10862 	p0 = strchr(p, ')');
10863 	if (p0 == NULL)
10864 		return -1;
10865 
10866 	size = p0 - p;
10867 	if (size >= sizeof(s))
10868 		return -1;
10869 
10870 	snprintf(s, sizeof(s), "%.*s", size, p);
10871 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10872 	if (ret < 0 || ret > max_num)
10873 		return -1;
10874 	for (i = 0; i < ret; i++) {
10875 		errno = 0;
10876 		int_fld = strtoul(str_fld[i], &end, 0);
10877 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10878 			return -1;
10879 		offsets[i] = (uint16_t)int_fld;
10880 	}
10881 	return ret;
10882 }
10883 
10884 static void
10885 cmd_flow_director_flxpld_parsed(void *parsed_result,
10886 			  __rte_unused struct cmdline *cl,
10887 			  __rte_unused void *data)
10888 {
10889 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
10890 	struct rte_eth_flex_payload_cfg flex_cfg;
10891 	struct rte_port *port;
10892 	int ret = 0;
10893 
10894 	port = &ports[res->port_id];
10895 	/** Check if the port is not started **/
10896 	if (port->port_status != RTE_PORT_STOPPED) {
10897 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
10898 		return;
10899 	}
10900 
10901 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10902 
10903 	if (!strcmp(res->payload_layer, "raw"))
10904 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10905 	else if (!strcmp(res->payload_layer, "l2"))
10906 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10907 	else if (!strcmp(res->payload_layer, "l3"))
10908 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10909 	else if (!strcmp(res->payload_layer, "l4"))
10910 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10911 
10912 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10913 			    RTE_ETH_FDIR_MAX_FLEXLEN);
10914 	if (ret < 0) {
10915 		fprintf(stderr, "error: Cannot parse flex payload input.\n");
10916 		return;
10917 	}
10918 
10919 	fdir_set_flex_payload(res->port_id, &flex_cfg);
10920 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10921 }
10922 
10923 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10924 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10925 				 flow_director_flexpayload,
10926 				 "flow_director_flex_payload");
10927 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10928 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10929 			      port_id, RTE_UINT16);
10930 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10931 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10932 				 payload_layer, "raw#l2#l3#l4");
10933 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10934 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10935 				 payload_cfg, NULL);
10936 
10937 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10938 	.f = cmd_flow_director_flxpld_parsed,
10939 	.data = NULL,
10940 	.help_str = "flow_director_flexpayload ... : "
10941 		"Set flow director's flex payload on NIC",
10942 	.tokens = {
10943 		(void *)&cmd_flow_director_flexpayload,
10944 		(void *)&cmd_flow_director_flexpayload_port_id,
10945 		(void *)&cmd_flow_director_flexpayload_payload_layer,
10946 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
10947 		NULL,
10948 	},
10949 };
10950 
10951 /* Generic flow interface command. */
10952 extern cmdline_parse_inst_t cmd_flow;
10953 
10954 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10955 struct cmd_mcast_addr_result {
10956 	cmdline_fixed_string_t mcast_addr_cmd;
10957 	cmdline_fixed_string_t what;
10958 	uint16_t port_num;
10959 	struct rte_ether_addr mc_addr;
10960 };
10961 
10962 static void cmd_mcast_addr_parsed(void *parsed_result,
10963 		__rte_unused struct cmdline *cl,
10964 		__rte_unused void *data)
10965 {
10966 	struct cmd_mcast_addr_result *res = parsed_result;
10967 
10968 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10969 		fprintf(stderr,
10970 			"Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10971 			RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10972 		return;
10973 	}
10974 	if (strcmp(res->what, "add") == 0)
10975 		mcast_addr_add(res->port_num, &res->mc_addr);
10976 	else
10977 		mcast_addr_remove(res->port_num, &res->mc_addr);
10978 }
10979 
10980 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10981 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10982 				 mcast_addr_cmd, "mcast_addr");
10983 cmdline_parse_token_string_t cmd_mcast_addr_what =
10984 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10985 				 "add#remove");
10986 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10987 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10988 				 RTE_UINT16);
10989 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10990 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10991 
10992 cmdline_parse_inst_t cmd_mcast_addr = {
10993 	.f = cmd_mcast_addr_parsed,
10994 	.data = (void *)0,
10995 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10996 		"Add/Remove multicast MAC address on port_id",
10997 	.tokens = {
10998 		(void *)&cmd_mcast_addr_cmd,
10999 		(void *)&cmd_mcast_addr_what,
11000 		(void *)&cmd_mcast_addr_portnum,
11001 		(void *)&cmd_mcast_addr_addr,
11002 		NULL,
11003 	},
11004 };
11005 
11006 /* vf vlan anti spoof configuration */
11007 
11008 /* Common result structure for vf vlan anti spoof */
11009 struct cmd_vf_vlan_anti_spoof_result {
11010 	cmdline_fixed_string_t set;
11011 	cmdline_fixed_string_t vf;
11012 	cmdline_fixed_string_t vlan;
11013 	cmdline_fixed_string_t antispoof;
11014 	portid_t port_id;
11015 	uint32_t vf_id;
11016 	cmdline_fixed_string_t on_off;
11017 };
11018 
11019 /* Common CLI fields for vf vlan anti spoof enable disable */
11020 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11021 	TOKEN_STRING_INITIALIZER
11022 		(struct cmd_vf_vlan_anti_spoof_result,
11023 		 set, "set");
11024 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11025 	TOKEN_STRING_INITIALIZER
11026 		(struct cmd_vf_vlan_anti_spoof_result,
11027 		 vf, "vf");
11028 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11029 	TOKEN_STRING_INITIALIZER
11030 		(struct cmd_vf_vlan_anti_spoof_result,
11031 		 vlan, "vlan");
11032 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11033 	TOKEN_STRING_INITIALIZER
11034 		(struct cmd_vf_vlan_anti_spoof_result,
11035 		 antispoof, "antispoof");
11036 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11037 	TOKEN_NUM_INITIALIZER
11038 		(struct cmd_vf_vlan_anti_spoof_result,
11039 		 port_id, RTE_UINT16);
11040 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11041 	TOKEN_NUM_INITIALIZER
11042 		(struct cmd_vf_vlan_anti_spoof_result,
11043 		 vf_id, RTE_UINT32);
11044 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11045 	TOKEN_STRING_INITIALIZER
11046 		(struct cmd_vf_vlan_anti_spoof_result,
11047 		 on_off, "on#off");
11048 
11049 static void
11050 cmd_set_vf_vlan_anti_spoof_parsed(
11051 	void *parsed_result,
11052 	__rte_unused struct cmdline *cl,
11053 	__rte_unused void *data)
11054 {
11055 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11056 	int ret = -ENOTSUP;
11057 
11058 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11059 
11060 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11061 		return;
11062 
11063 #ifdef RTE_NET_IXGBE
11064 	if (ret == -ENOTSUP)
11065 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11066 				res->vf_id, is_on);
11067 #endif
11068 #ifdef RTE_NET_I40E
11069 	if (ret == -ENOTSUP)
11070 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11071 				res->vf_id, is_on);
11072 #endif
11073 #ifdef RTE_NET_BNXT
11074 	if (ret == -ENOTSUP)
11075 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11076 				res->vf_id, is_on);
11077 #endif
11078 
11079 	switch (ret) {
11080 	case 0:
11081 		break;
11082 	case -EINVAL:
11083 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11084 		break;
11085 	case -ENODEV:
11086 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11087 		break;
11088 	case -ENOTSUP:
11089 		fprintf(stderr, "function not implemented\n");
11090 		break;
11091 	default:
11092 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11093 	}
11094 }
11095 
11096 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11097 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
11098 	.data = NULL,
11099 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11100 	.tokens = {
11101 		(void *)&cmd_vf_vlan_anti_spoof_set,
11102 		(void *)&cmd_vf_vlan_anti_spoof_vf,
11103 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
11104 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
11105 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
11106 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
11107 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
11108 		NULL,
11109 	},
11110 };
11111 
11112 /* vf mac anti spoof configuration */
11113 
11114 /* Common result structure for vf mac anti spoof */
11115 struct cmd_vf_mac_anti_spoof_result {
11116 	cmdline_fixed_string_t set;
11117 	cmdline_fixed_string_t vf;
11118 	cmdline_fixed_string_t mac;
11119 	cmdline_fixed_string_t antispoof;
11120 	portid_t port_id;
11121 	uint32_t vf_id;
11122 	cmdline_fixed_string_t on_off;
11123 };
11124 
11125 /* Common CLI fields for vf mac anti spoof enable disable */
11126 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11127 	TOKEN_STRING_INITIALIZER
11128 		(struct cmd_vf_mac_anti_spoof_result,
11129 		 set, "set");
11130 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11131 	TOKEN_STRING_INITIALIZER
11132 		(struct cmd_vf_mac_anti_spoof_result,
11133 		 vf, "vf");
11134 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11135 	TOKEN_STRING_INITIALIZER
11136 		(struct cmd_vf_mac_anti_spoof_result,
11137 		 mac, "mac");
11138 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11139 	TOKEN_STRING_INITIALIZER
11140 		(struct cmd_vf_mac_anti_spoof_result,
11141 		 antispoof, "antispoof");
11142 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11143 	TOKEN_NUM_INITIALIZER
11144 		(struct cmd_vf_mac_anti_spoof_result,
11145 		 port_id, RTE_UINT16);
11146 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11147 	TOKEN_NUM_INITIALIZER
11148 		(struct cmd_vf_mac_anti_spoof_result,
11149 		 vf_id, RTE_UINT32);
11150 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11151 	TOKEN_STRING_INITIALIZER
11152 		(struct cmd_vf_mac_anti_spoof_result,
11153 		 on_off, "on#off");
11154 
11155 static void
11156 cmd_set_vf_mac_anti_spoof_parsed(
11157 	void *parsed_result,
11158 	__rte_unused struct cmdline *cl,
11159 	__rte_unused void *data)
11160 {
11161 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11162 	int ret = -ENOTSUP;
11163 
11164 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11165 
11166 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11167 		return;
11168 
11169 #ifdef RTE_NET_IXGBE
11170 	if (ret == -ENOTSUP)
11171 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11172 			res->vf_id, is_on);
11173 #endif
11174 #ifdef RTE_NET_I40E
11175 	if (ret == -ENOTSUP)
11176 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11177 			res->vf_id, is_on);
11178 #endif
11179 #ifdef RTE_NET_BNXT
11180 	if (ret == -ENOTSUP)
11181 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11182 			res->vf_id, is_on);
11183 #endif
11184 
11185 	switch (ret) {
11186 	case 0:
11187 		break;
11188 	case -EINVAL:
11189 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11190 			res->vf_id, is_on);
11191 		break;
11192 	case -ENODEV:
11193 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11194 		break;
11195 	case -ENOTSUP:
11196 		fprintf(stderr, "function not implemented\n");
11197 		break;
11198 	default:
11199 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11200 	}
11201 }
11202 
11203 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11204 	.f = cmd_set_vf_mac_anti_spoof_parsed,
11205 	.data = NULL,
11206 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11207 	.tokens = {
11208 		(void *)&cmd_vf_mac_anti_spoof_set,
11209 		(void *)&cmd_vf_mac_anti_spoof_vf,
11210 		(void *)&cmd_vf_mac_anti_spoof_mac,
11211 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
11212 		(void *)&cmd_vf_mac_anti_spoof_port_id,
11213 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
11214 		(void *)&cmd_vf_mac_anti_spoof_on_off,
11215 		NULL,
11216 	},
11217 };
11218 
11219 /* vf vlan strip queue configuration */
11220 
11221 /* Common result structure for vf mac anti spoof */
11222 struct cmd_vf_vlan_stripq_result {
11223 	cmdline_fixed_string_t set;
11224 	cmdline_fixed_string_t vf;
11225 	cmdline_fixed_string_t vlan;
11226 	cmdline_fixed_string_t stripq;
11227 	portid_t port_id;
11228 	uint16_t vf_id;
11229 	cmdline_fixed_string_t on_off;
11230 };
11231 
11232 /* Common CLI fields for vf vlan strip enable disable */
11233 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11234 	TOKEN_STRING_INITIALIZER
11235 		(struct cmd_vf_vlan_stripq_result,
11236 		 set, "set");
11237 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11238 	TOKEN_STRING_INITIALIZER
11239 		(struct cmd_vf_vlan_stripq_result,
11240 		 vf, "vf");
11241 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11242 	TOKEN_STRING_INITIALIZER
11243 		(struct cmd_vf_vlan_stripq_result,
11244 		 vlan, "vlan");
11245 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11246 	TOKEN_STRING_INITIALIZER
11247 		(struct cmd_vf_vlan_stripq_result,
11248 		 stripq, "stripq");
11249 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11250 	TOKEN_NUM_INITIALIZER
11251 		(struct cmd_vf_vlan_stripq_result,
11252 		 port_id, RTE_UINT16);
11253 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11254 	TOKEN_NUM_INITIALIZER
11255 		(struct cmd_vf_vlan_stripq_result,
11256 		 vf_id, RTE_UINT16);
11257 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11258 	TOKEN_STRING_INITIALIZER
11259 		(struct cmd_vf_vlan_stripq_result,
11260 		 on_off, "on#off");
11261 
11262 static void
11263 cmd_set_vf_vlan_stripq_parsed(
11264 	void *parsed_result,
11265 	__rte_unused struct cmdline *cl,
11266 	__rte_unused void *data)
11267 {
11268 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
11269 	int ret = -ENOTSUP;
11270 
11271 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11272 
11273 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11274 		return;
11275 
11276 #ifdef RTE_NET_IXGBE
11277 	if (ret == -ENOTSUP)
11278 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11279 			res->vf_id, is_on);
11280 #endif
11281 #ifdef RTE_NET_I40E
11282 	if (ret == -ENOTSUP)
11283 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11284 			res->vf_id, is_on);
11285 #endif
11286 #ifdef RTE_NET_BNXT
11287 	if (ret == -ENOTSUP)
11288 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11289 			res->vf_id, is_on);
11290 #endif
11291 
11292 	switch (ret) {
11293 	case 0:
11294 		break;
11295 	case -EINVAL:
11296 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11297 			res->vf_id, is_on);
11298 		break;
11299 	case -ENODEV:
11300 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11301 		break;
11302 	case -ENOTSUP:
11303 		fprintf(stderr, "function not implemented\n");
11304 		break;
11305 	default:
11306 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11307 	}
11308 }
11309 
11310 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11311 	.f = cmd_set_vf_vlan_stripq_parsed,
11312 	.data = NULL,
11313 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11314 	.tokens = {
11315 		(void *)&cmd_vf_vlan_stripq_set,
11316 		(void *)&cmd_vf_vlan_stripq_vf,
11317 		(void *)&cmd_vf_vlan_stripq_vlan,
11318 		(void *)&cmd_vf_vlan_stripq_stripq,
11319 		(void *)&cmd_vf_vlan_stripq_port_id,
11320 		(void *)&cmd_vf_vlan_stripq_vf_id,
11321 		(void *)&cmd_vf_vlan_stripq_on_off,
11322 		NULL,
11323 	},
11324 };
11325 
11326 /* vf vlan insert configuration */
11327 
11328 /* Common result structure for vf vlan insert */
11329 struct cmd_vf_vlan_insert_result {
11330 	cmdline_fixed_string_t set;
11331 	cmdline_fixed_string_t vf;
11332 	cmdline_fixed_string_t vlan;
11333 	cmdline_fixed_string_t insert;
11334 	portid_t port_id;
11335 	uint16_t vf_id;
11336 	uint16_t vlan_id;
11337 };
11338 
11339 /* Common CLI fields for vf vlan insert enable disable */
11340 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11341 	TOKEN_STRING_INITIALIZER
11342 		(struct cmd_vf_vlan_insert_result,
11343 		 set, "set");
11344 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11345 	TOKEN_STRING_INITIALIZER
11346 		(struct cmd_vf_vlan_insert_result,
11347 		 vf, "vf");
11348 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11349 	TOKEN_STRING_INITIALIZER
11350 		(struct cmd_vf_vlan_insert_result,
11351 		 vlan, "vlan");
11352 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11353 	TOKEN_STRING_INITIALIZER
11354 		(struct cmd_vf_vlan_insert_result,
11355 		 insert, "insert");
11356 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11357 	TOKEN_NUM_INITIALIZER
11358 		(struct cmd_vf_vlan_insert_result,
11359 		 port_id, RTE_UINT16);
11360 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11361 	TOKEN_NUM_INITIALIZER
11362 		(struct cmd_vf_vlan_insert_result,
11363 		 vf_id, RTE_UINT16);
11364 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11365 	TOKEN_NUM_INITIALIZER
11366 		(struct cmd_vf_vlan_insert_result,
11367 		 vlan_id, RTE_UINT16);
11368 
11369 static void
11370 cmd_set_vf_vlan_insert_parsed(
11371 	void *parsed_result,
11372 	__rte_unused struct cmdline *cl,
11373 	__rte_unused void *data)
11374 {
11375 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11376 	int ret = -ENOTSUP;
11377 
11378 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11379 		return;
11380 
11381 #ifdef RTE_NET_IXGBE
11382 	if (ret == -ENOTSUP)
11383 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11384 			res->vlan_id);
11385 #endif
11386 #ifdef RTE_NET_I40E
11387 	if (ret == -ENOTSUP)
11388 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11389 			res->vlan_id);
11390 #endif
11391 #ifdef RTE_NET_BNXT
11392 	if (ret == -ENOTSUP)
11393 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11394 			res->vlan_id);
11395 #endif
11396 
11397 	switch (ret) {
11398 	case 0:
11399 		break;
11400 	case -EINVAL:
11401 		fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11402 			res->vf_id, res->vlan_id);
11403 		break;
11404 	case -ENODEV:
11405 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11406 		break;
11407 	case -ENOTSUP:
11408 		fprintf(stderr, "function not implemented\n");
11409 		break;
11410 	default:
11411 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11412 	}
11413 }
11414 
11415 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11416 	.f = cmd_set_vf_vlan_insert_parsed,
11417 	.data = NULL,
11418 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11419 	.tokens = {
11420 		(void *)&cmd_vf_vlan_insert_set,
11421 		(void *)&cmd_vf_vlan_insert_vf,
11422 		(void *)&cmd_vf_vlan_insert_vlan,
11423 		(void *)&cmd_vf_vlan_insert_insert,
11424 		(void *)&cmd_vf_vlan_insert_port_id,
11425 		(void *)&cmd_vf_vlan_insert_vf_id,
11426 		(void *)&cmd_vf_vlan_insert_vlan_id,
11427 		NULL,
11428 	},
11429 };
11430 
11431 /* tx loopback configuration */
11432 
11433 /* Common result structure for tx loopback */
11434 struct cmd_tx_loopback_result {
11435 	cmdline_fixed_string_t set;
11436 	cmdline_fixed_string_t tx;
11437 	cmdline_fixed_string_t loopback;
11438 	portid_t port_id;
11439 	cmdline_fixed_string_t on_off;
11440 };
11441 
11442 /* Common CLI fields for tx loopback enable disable */
11443 cmdline_parse_token_string_t cmd_tx_loopback_set =
11444 	TOKEN_STRING_INITIALIZER
11445 		(struct cmd_tx_loopback_result,
11446 		 set, "set");
11447 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11448 	TOKEN_STRING_INITIALIZER
11449 		(struct cmd_tx_loopback_result,
11450 		 tx, "tx");
11451 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11452 	TOKEN_STRING_INITIALIZER
11453 		(struct cmd_tx_loopback_result,
11454 		 loopback, "loopback");
11455 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11456 	TOKEN_NUM_INITIALIZER
11457 		(struct cmd_tx_loopback_result,
11458 		 port_id, RTE_UINT16);
11459 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11460 	TOKEN_STRING_INITIALIZER
11461 		(struct cmd_tx_loopback_result,
11462 		 on_off, "on#off");
11463 
11464 static void
11465 cmd_set_tx_loopback_parsed(
11466 	void *parsed_result,
11467 	__rte_unused struct cmdline *cl,
11468 	__rte_unused void *data)
11469 {
11470 	struct cmd_tx_loopback_result *res = parsed_result;
11471 	int ret = -ENOTSUP;
11472 
11473 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11474 
11475 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11476 		return;
11477 
11478 #ifdef RTE_NET_IXGBE
11479 	if (ret == -ENOTSUP)
11480 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11481 #endif
11482 #ifdef RTE_NET_I40E
11483 	if (ret == -ENOTSUP)
11484 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11485 #endif
11486 #ifdef RTE_NET_BNXT
11487 	if (ret == -ENOTSUP)
11488 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11489 #endif
11490 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11491 	if (ret == -ENOTSUP)
11492 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11493 #endif
11494 
11495 	switch (ret) {
11496 	case 0:
11497 		break;
11498 	case -EINVAL:
11499 		fprintf(stderr, "invalid is_on %d\n", is_on);
11500 		break;
11501 	case -ENODEV:
11502 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11503 		break;
11504 	case -ENOTSUP:
11505 		fprintf(stderr, "function not implemented\n");
11506 		break;
11507 	default:
11508 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11509 	}
11510 }
11511 
11512 cmdline_parse_inst_t cmd_set_tx_loopback = {
11513 	.f = cmd_set_tx_loopback_parsed,
11514 	.data = NULL,
11515 	.help_str = "set tx loopback <port_id> on|off",
11516 	.tokens = {
11517 		(void *)&cmd_tx_loopback_set,
11518 		(void *)&cmd_tx_loopback_tx,
11519 		(void *)&cmd_tx_loopback_loopback,
11520 		(void *)&cmd_tx_loopback_port_id,
11521 		(void *)&cmd_tx_loopback_on_off,
11522 		NULL,
11523 	},
11524 };
11525 
11526 /* all queues drop enable configuration */
11527 
11528 /* Common result structure for all queues drop enable */
11529 struct cmd_all_queues_drop_en_result {
11530 	cmdline_fixed_string_t set;
11531 	cmdline_fixed_string_t all;
11532 	cmdline_fixed_string_t queues;
11533 	cmdline_fixed_string_t drop;
11534 	portid_t port_id;
11535 	cmdline_fixed_string_t on_off;
11536 };
11537 
11538 /* Common CLI fields for tx loopback enable disable */
11539 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11540 	TOKEN_STRING_INITIALIZER
11541 		(struct cmd_all_queues_drop_en_result,
11542 		 set, "set");
11543 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11544 	TOKEN_STRING_INITIALIZER
11545 		(struct cmd_all_queues_drop_en_result,
11546 		 all, "all");
11547 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11548 	TOKEN_STRING_INITIALIZER
11549 		(struct cmd_all_queues_drop_en_result,
11550 		 queues, "queues");
11551 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11552 	TOKEN_STRING_INITIALIZER
11553 		(struct cmd_all_queues_drop_en_result,
11554 		 drop, "drop");
11555 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11556 	TOKEN_NUM_INITIALIZER
11557 		(struct cmd_all_queues_drop_en_result,
11558 		 port_id, RTE_UINT16);
11559 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11560 	TOKEN_STRING_INITIALIZER
11561 		(struct cmd_all_queues_drop_en_result,
11562 		 on_off, "on#off");
11563 
11564 static void
11565 cmd_set_all_queues_drop_en_parsed(
11566 	void *parsed_result,
11567 	__rte_unused struct cmdline *cl,
11568 	__rte_unused void *data)
11569 {
11570 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11571 	int ret = -ENOTSUP;
11572 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11573 
11574 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11575 		return;
11576 
11577 #ifdef RTE_NET_IXGBE
11578 	if (ret == -ENOTSUP)
11579 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11580 #endif
11581 #ifdef RTE_NET_BNXT
11582 	if (ret == -ENOTSUP)
11583 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11584 #endif
11585 	switch (ret) {
11586 	case 0:
11587 		break;
11588 	case -EINVAL:
11589 		fprintf(stderr, "invalid is_on %d\n", is_on);
11590 		break;
11591 	case -ENODEV:
11592 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11593 		break;
11594 	case -ENOTSUP:
11595 		fprintf(stderr, "function not implemented\n");
11596 		break;
11597 	default:
11598 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11599 	}
11600 }
11601 
11602 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11603 	.f = cmd_set_all_queues_drop_en_parsed,
11604 	.data = NULL,
11605 	.help_str = "set all queues drop <port_id> on|off",
11606 	.tokens = {
11607 		(void *)&cmd_all_queues_drop_en_set,
11608 		(void *)&cmd_all_queues_drop_en_all,
11609 		(void *)&cmd_all_queues_drop_en_queues,
11610 		(void *)&cmd_all_queues_drop_en_drop,
11611 		(void *)&cmd_all_queues_drop_en_port_id,
11612 		(void *)&cmd_all_queues_drop_en_on_off,
11613 		NULL,
11614 	},
11615 };
11616 
11617 /* vf split drop enable configuration */
11618 
11619 /* Common result structure for vf split drop enable */
11620 struct cmd_vf_split_drop_en_result {
11621 	cmdline_fixed_string_t set;
11622 	cmdline_fixed_string_t vf;
11623 	cmdline_fixed_string_t split;
11624 	cmdline_fixed_string_t drop;
11625 	portid_t port_id;
11626 	uint16_t vf_id;
11627 	cmdline_fixed_string_t on_off;
11628 };
11629 
11630 /* Common CLI fields for vf split drop enable disable */
11631 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11632 	TOKEN_STRING_INITIALIZER
11633 		(struct cmd_vf_split_drop_en_result,
11634 		 set, "set");
11635 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11636 	TOKEN_STRING_INITIALIZER
11637 		(struct cmd_vf_split_drop_en_result,
11638 		 vf, "vf");
11639 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11640 	TOKEN_STRING_INITIALIZER
11641 		(struct cmd_vf_split_drop_en_result,
11642 		 split, "split");
11643 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11644 	TOKEN_STRING_INITIALIZER
11645 		(struct cmd_vf_split_drop_en_result,
11646 		 drop, "drop");
11647 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11648 	TOKEN_NUM_INITIALIZER
11649 		(struct cmd_vf_split_drop_en_result,
11650 		 port_id, RTE_UINT16);
11651 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11652 	TOKEN_NUM_INITIALIZER
11653 		(struct cmd_vf_split_drop_en_result,
11654 		 vf_id, RTE_UINT16);
11655 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11656 	TOKEN_STRING_INITIALIZER
11657 		(struct cmd_vf_split_drop_en_result,
11658 		 on_off, "on#off");
11659 
11660 static void
11661 cmd_set_vf_split_drop_en_parsed(
11662 	void *parsed_result,
11663 	__rte_unused struct cmdline *cl,
11664 	__rte_unused void *data)
11665 {
11666 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11667 	int ret = -ENOTSUP;
11668 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11669 
11670 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11671 		return;
11672 
11673 #ifdef RTE_NET_IXGBE
11674 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11675 			is_on);
11676 #endif
11677 	switch (ret) {
11678 	case 0:
11679 		break;
11680 	case -EINVAL:
11681 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11682 			res->vf_id, is_on);
11683 		break;
11684 	case -ENODEV:
11685 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11686 		break;
11687 	case -ENOTSUP:
11688 		fprintf(stderr, "not supported on port %d\n", res->port_id);
11689 		break;
11690 	default:
11691 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11692 	}
11693 }
11694 
11695 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11696 	.f = cmd_set_vf_split_drop_en_parsed,
11697 	.data = NULL,
11698 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11699 	.tokens = {
11700 		(void *)&cmd_vf_split_drop_en_set,
11701 		(void *)&cmd_vf_split_drop_en_vf,
11702 		(void *)&cmd_vf_split_drop_en_split,
11703 		(void *)&cmd_vf_split_drop_en_drop,
11704 		(void *)&cmd_vf_split_drop_en_port_id,
11705 		(void *)&cmd_vf_split_drop_en_vf_id,
11706 		(void *)&cmd_vf_split_drop_en_on_off,
11707 		NULL,
11708 	},
11709 };
11710 
11711 /* vf mac address configuration */
11712 
11713 /* Common result structure for vf mac address */
11714 struct cmd_set_vf_mac_addr_result {
11715 	cmdline_fixed_string_t set;
11716 	cmdline_fixed_string_t vf;
11717 	cmdline_fixed_string_t mac;
11718 	cmdline_fixed_string_t addr;
11719 	portid_t port_id;
11720 	uint16_t vf_id;
11721 	struct rte_ether_addr mac_addr;
11722 
11723 };
11724 
11725 /* Common CLI fields for vf split drop enable disable */
11726 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11727 	TOKEN_STRING_INITIALIZER
11728 		(struct cmd_set_vf_mac_addr_result,
11729 		 set, "set");
11730 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11731 	TOKEN_STRING_INITIALIZER
11732 		(struct cmd_set_vf_mac_addr_result,
11733 		 vf, "vf");
11734 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11735 	TOKEN_STRING_INITIALIZER
11736 		(struct cmd_set_vf_mac_addr_result,
11737 		 mac, "mac");
11738 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11739 	TOKEN_STRING_INITIALIZER
11740 		(struct cmd_set_vf_mac_addr_result,
11741 		 addr, "addr");
11742 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11743 	TOKEN_NUM_INITIALIZER
11744 		(struct cmd_set_vf_mac_addr_result,
11745 		 port_id, RTE_UINT16);
11746 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11747 	TOKEN_NUM_INITIALIZER
11748 		(struct cmd_set_vf_mac_addr_result,
11749 		 vf_id, RTE_UINT16);
11750 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11751 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11752 		 mac_addr);
11753 
11754 static void
11755 cmd_set_vf_mac_addr_parsed(
11756 	void *parsed_result,
11757 	__rte_unused struct cmdline *cl,
11758 	__rte_unused void *data)
11759 {
11760 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11761 	int ret = -ENOTSUP;
11762 
11763 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11764 		return;
11765 
11766 #ifdef RTE_NET_IXGBE
11767 	if (ret == -ENOTSUP)
11768 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11769 				&res->mac_addr);
11770 #endif
11771 #ifdef RTE_NET_I40E
11772 	if (ret == -ENOTSUP)
11773 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11774 				&res->mac_addr);
11775 #endif
11776 #ifdef RTE_NET_BNXT
11777 	if (ret == -ENOTSUP)
11778 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11779 				&res->mac_addr);
11780 #endif
11781 
11782 	switch (ret) {
11783 	case 0:
11784 		break;
11785 	case -EINVAL:
11786 		fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11787 		break;
11788 	case -ENODEV:
11789 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11790 		break;
11791 	case -ENOTSUP:
11792 		fprintf(stderr, "function not implemented\n");
11793 		break;
11794 	default:
11795 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11796 	}
11797 }
11798 
11799 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11800 	.f = cmd_set_vf_mac_addr_parsed,
11801 	.data = NULL,
11802 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11803 	.tokens = {
11804 		(void *)&cmd_set_vf_mac_addr_set,
11805 		(void *)&cmd_set_vf_mac_addr_vf,
11806 		(void *)&cmd_set_vf_mac_addr_mac,
11807 		(void *)&cmd_set_vf_mac_addr_addr,
11808 		(void *)&cmd_set_vf_mac_addr_port_id,
11809 		(void *)&cmd_set_vf_mac_addr_vf_id,
11810 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11811 		NULL,
11812 	},
11813 };
11814 
11815 /* MACsec configuration */
11816 
11817 /* Common result structure for MACsec offload enable */
11818 struct cmd_macsec_offload_on_result {
11819 	cmdline_fixed_string_t set;
11820 	cmdline_fixed_string_t macsec;
11821 	cmdline_fixed_string_t offload;
11822 	portid_t port_id;
11823 	cmdline_fixed_string_t on;
11824 	cmdline_fixed_string_t encrypt;
11825 	cmdline_fixed_string_t en_on_off;
11826 	cmdline_fixed_string_t replay_protect;
11827 	cmdline_fixed_string_t rp_on_off;
11828 };
11829 
11830 /* Common CLI fields for MACsec offload disable */
11831 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11832 	TOKEN_STRING_INITIALIZER
11833 		(struct cmd_macsec_offload_on_result,
11834 		 set, "set");
11835 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11836 	TOKEN_STRING_INITIALIZER
11837 		(struct cmd_macsec_offload_on_result,
11838 		 macsec, "macsec");
11839 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11840 	TOKEN_STRING_INITIALIZER
11841 		(struct cmd_macsec_offload_on_result,
11842 		 offload, "offload");
11843 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11844 	TOKEN_NUM_INITIALIZER
11845 		(struct cmd_macsec_offload_on_result,
11846 		 port_id, RTE_UINT16);
11847 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11848 	TOKEN_STRING_INITIALIZER
11849 		(struct cmd_macsec_offload_on_result,
11850 		 on, "on");
11851 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11852 	TOKEN_STRING_INITIALIZER
11853 		(struct cmd_macsec_offload_on_result,
11854 		 encrypt, "encrypt");
11855 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11856 	TOKEN_STRING_INITIALIZER
11857 		(struct cmd_macsec_offload_on_result,
11858 		 en_on_off, "on#off");
11859 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11860 	TOKEN_STRING_INITIALIZER
11861 		(struct cmd_macsec_offload_on_result,
11862 		 replay_protect, "replay-protect");
11863 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11864 	TOKEN_STRING_INITIALIZER
11865 		(struct cmd_macsec_offload_on_result,
11866 		 rp_on_off, "on#off");
11867 
11868 static void
11869 cmd_set_macsec_offload_on_parsed(
11870 	void *parsed_result,
11871 	__rte_unused struct cmdline *cl,
11872 	__rte_unused void *data)
11873 {
11874 	struct cmd_macsec_offload_on_result *res = parsed_result;
11875 	int ret = -ENOTSUP;
11876 	portid_t port_id = res->port_id;
11877 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11878 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11879 	struct rte_eth_dev_info dev_info;
11880 
11881 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11882 		return;
11883 	if (!port_is_stopped(port_id)) {
11884 		fprintf(stderr, "Please stop port %d first\n", port_id);
11885 		return;
11886 	}
11887 
11888 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11889 	if (ret != 0)
11890 		return;
11891 
11892 	if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11893 #ifdef RTE_NET_IXGBE
11894 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11895 #endif
11896 	}
11897 	RTE_SET_USED(en);
11898 	RTE_SET_USED(rp);
11899 
11900 	switch (ret) {
11901 	case 0:
11902 		ports[port_id].dev_conf.txmode.offloads |=
11903 						RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11904 		cmd_reconfig_device_queue(port_id, 1, 1);
11905 		break;
11906 	case -ENODEV:
11907 		fprintf(stderr, "invalid port_id %d\n", port_id);
11908 		break;
11909 	case -ENOTSUP:
11910 		fprintf(stderr, "not supported on port %d\n", port_id);
11911 		break;
11912 	default:
11913 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11914 	}
11915 }
11916 
11917 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11918 	.f = cmd_set_macsec_offload_on_parsed,
11919 	.data = NULL,
11920 	.help_str = "set macsec offload <port_id> on "
11921 		"encrypt on|off replay-protect on|off",
11922 	.tokens = {
11923 		(void *)&cmd_macsec_offload_on_set,
11924 		(void *)&cmd_macsec_offload_on_macsec,
11925 		(void *)&cmd_macsec_offload_on_offload,
11926 		(void *)&cmd_macsec_offload_on_port_id,
11927 		(void *)&cmd_macsec_offload_on_on,
11928 		(void *)&cmd_macsec_offload_on_encrypt,
11929 		(void *)&cmd_macsec_offload_on_en_on_off,
11930 		(void *)&cmd_macsec_offload_on_replay_protect,
11931 		(void *)&cmd_macsec_offload_on_rp_on_off,
11932 		NULL,
11933 	},
11934 };
11935 
11936 /* Common result structure for MACsec offload disable */
11937 struct cmd_macsec_offload_off_result {
11938 	cmdline_fixed_string_t set;
11939 	cmdline_fixed_string_t macsec;
11940 	cmdline_fixed_string_t offload;
11941 	portid_t port_id;
11942 	cmdline_fixed_string_t off;
11943 };
11944 
11945 /* Common CLI fields for MACsec offload disable */
11946 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11947 	TOKEN_STRING_INITIALIZER
11948 		(struct cmd_macsec_offload_off_result,
11949 		 set, "set");
11950 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11951 	TOKEN_STRING_INITIALIZER
11952 		(struct cmd_macsec_offload_off_result,
11953 		 macsec, "macsec");
11954 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11955 	TOKEN_STRING_INITIALIZER
11956 		(struct cmd_macsec_offload_off_result,
11957 		 offload, "offload");
11958 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11959 	TOKEN_NUM_INITIALIZER
11960 		(struct cmd_macsec_offload_off_result,
11961 		 port_id, RTE_UINT16);
11962 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11963 	TOKEN_STRING_INITIALIZER
11964 		(struct cmd_macsec_offload_off_result,
11965 		 off, "off");
11966 
11967 static void
11968 cmd_set_macsec_offload_off_parsed(
11969 	void *parsed_result,
11970 	__rte_unused struct cmdline *cl,
11971 	__rte_unused void *data)
11972 {
11973 	struct cmd_macsec_offload_off_result *res = parsed_result;
11974 	int ret = -ENOTSUP;
11975 	struct rte_eth_dev_info dev_info;
11976 	portid_t port_id = res->port_id;
11977 
11978 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11979 		return;
11980 	if (!port_is_stopped(port_id)) {
11981 		fprintf(stderr, "Please stop port %d first\n", port_id);
11982 		return;
11983 	}
11984 
11985 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11986 	if (ret != 0)
11987 		return;
11988 
11989 	if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11990 #ifdef RTE_NET_IXGBE
11991 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
11992 #endif
11993 	}
11994 	switch (ret) {
11995 	case 0:
11996 		ports[port_id].dev_conf.txmode.offloads &=
11997 						~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11998 		cmd_reconfig_device_queue(port_id, 1, 1);
11999 		break;
12000 	case -ENODEV:
12001 		fprintf(stderr, "invalid port_id %d\n", port_id);
12002 		break;
12003 	case -ENOTSUP:
12004 		fprintf(stderr, "not supported on port %d\n", port_id);
12005 		break;
12006 	default:
12007 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12008 	}
12009 }
12010 
12011 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12012 	.f = cmd_set_macsec_offload_off_parsed,
12013 	.data = NULL,
12014 	.help_str = "set macsec offload <port_id> off",
12015 	.tokens = {
12016 		(void *)&cmd_macsec_offload_off_set,
12017 		(void *)&cmd_macsec_offload_off_macsec,
12018 		(void *)&cmd_macsec_offload_off_offload,
12019 		(void *)&cmd_macsec_offload_off_port_id,
12020 		(void *)&cmd_macsec_offload_off_off,
12021 		NULL,
12022 	},
12023 };
12024 
12025 /* Common result structure for MACsec secure connection configure */
12026 struct cmd_macsec_sc_result {
12027 	cmdline_fixed_string_t set;
12028 	cmdline_fixed_string_t macsec;
12029 	cmdline_fixed_string_t sc;
12030 	cmdline_fixed_string_t tx_rx;
12031 	portid_t port_id;
12032 	struct rte_ether_addr mac;
12033 	uint16_t pi;
12034 };
12035 
12036 /* Common CLI fields for MACsec secure connection configure */
12037 cmdline_parse_token_string_t cmd_macsec_sc_set =
12038 	TOKEN_STRING_INITIALIZER
12039 		(struct cmd_macsec_sc_result,
12040 		 set, "set");
12041 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12042 	TOKEN_STRING_INITIALIZER
12043 		(struct cmd_macsec_sc_result,
12044 		 macsec, "macsec");
12045 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12046 	TOKEN_STRING_INITIALIZER
12047 		(struct cmd_macsec_sc_result,
12048 		 sc, "sc");
12049 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12050 	TOKEN_STRING_INITIALIZER
12051 		(struct cmd_macsec_sc_result,
12052 		 tx_rx, "tx#rx");
12053 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12054 	TOKEN_NUM_INITIALIZER
12055 		(struct cmd_macsec_sc_result,
12056 		 port_id, RTE_UINT16);
12057 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12058 	TOKEN_ETHERADDR_INITIALIZER
12059 		(struct cmd_macsec_sc_result,
12060 		 mac);
12061 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12062 	TOKEN_NUM_INITIALIZER
12063 		(struct cmd_macsec_sc_result,
12064 		 pi, RTE_UINT16);
12065 
12066 static void
12067 cmd_set_macsec_sc_parsed(
12068 	void *parsed_result,
12069 	__rte_unused struct cmdline *cl,
12070 	__rte_unused void *data)
12071 {
12072 	struct cmd_macsec_sc_result *res = parsed_result;
12073 	int ret = -ENOTSUP;
12074 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12075 
12076 #ifdef RTE_NET_IXGBE
12077 	ret = is_tx ?
12078 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12079 				res->mac.addr_bytes) :
12080 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12081 				res->mac.addr_bytes, res->pi);
12082 #endif
12083 	RTE_SET_USED(is_tx);
12084 
12085 	switch (ret) {
12086 	case 0:
12087 		break;
12088 	case -ENODEV:
12089 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12090 		break;
12091 	case -ENOTSUP:
12092 		fprintf(stderr, "not supported on port %d\n", res->port_id);
12093 		break;
12094 	default:
12095 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12096 	}
12097 }
12098 
12099 cmdline_parse_inst_t cmd_set_macsec_sc = {
12100 	.f = cmd_set_macsec_sc_parsed,
12101 	.data = NULL,
12102 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12103 	.tokens = {
12104 		(void *)&cmd_macsec_sc_set,
12105 		(void *)&cmd_macsec_sc_macsec,
12106 		(void *)&cmd_macsec_sc_sc,
12107 		(void *)&cmd_macsec_sc_tx_rx,
12108 		(void *)&cmd_macsec_sc_port_id,
12109 		(void *)&cmd_macsec_sc_mac,
12110 		(void *)&cmd_macsec_sc_pi,
12111 		NULL,
12112 	},
12113 };
12114 
12115 /* Common result structure for MACsec secure connection configure */
12116 struct cmd_macsec_sa_result {
12117 	cmdline_fixed_string_t set;
12118 	cmdline_fixed_string_t macsec;
12119 	cmdline_fixed_string_t sa;
12120 	cmdline_fixed_string_t tx_rx;
12121 	portid_t port_id;
12122 	uint8_t idx;
12123 	uint8_t an;
12124 	uint32_t pn;
12125 	cmdline_fixed_string_t key;
12126 };
12127 
12128 /* Common CLI fields for MACsec secure connection configure */
12129 cmdline_parse_token_string_t cmd_macsec_sa_set =
12130 	TOKEN_STRING_INITIALIZER
12131 		(struct cmd_macsec_sa_result,
12132 		 set, "set");
12133 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12134 	TOKEN_STRING_INITIALIZER
12135 		(struct cmd_macsec_sa_result,
12136 		 macsec, "macsec");
12137 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12138 	TOKEN_STRING_INITIALIZER
12139 		(struct cmd_macsec_sa_result,
12140 		 sa, "sa");
12141 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12142 	TOKEN_STRING_INITIALIZER
12143 		(struct cmd_macsec_sa_result,
12144 		 tx_rx, "tx#rx");
12145 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12146 	TOKEN_NUM_INITIALIZER
12147 		(struct cmd_macsec_sa_result,
12148 		 port_id, RTE_UINT16);
12149 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12150 	TOKEN_NUM_INITIALIZER
12151 		(struct cmd_macsec_sa_result,
12152 		 idx, RTE_UINT8);
12153 cmdline_parse_token_num_t cmd_macsec_sa_an =
12154 	TOKEN_NUM_INITIALIZER
12155 		(struct cmd_macsec_sa_result,
12156 		 an, RTE_UINT8);
12157 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12158 	TOKEN_NUM_INITIALIZER
12159 		(struct cmd_macsec_sa_result,
12160 		 pn, RTE_UINT32);
12161 cmdline_parse_token_string_t cmd_macsec_sa_key =
12162 	TOKEN_STRING_INITIALIZER
12163 		(struct cmd_macsec_sa_result,
12164 		 key, NULL);
12165 
12166 static void
12167 cmd_set_macsec_sa_parsed(
12168 	void *parsed_result,
12169 	__rte_unused struct cmdline *cl,
12170 	__rte_unused void *data)
12171 {
12172 	struct cmd_macsec_sa_result *res = parsed_result;
12173 	int ret = -ENOTSUP;
12174 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12175 	uint8_t key[16] = { 0 };
12176 	uint8_t xdgt0;
12177 	uint8_t xdgt1;
12178 	int key_len;
12179 	int i;
12180 
12181 	key_len = strlen(res->key) / 2;
12182 	if (key_len > 16)
12183 		key_len = 16;
12184 
12185 	for (i = 0; i < key_len; i++) {
12186 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12187 		if (xdgt0 == 0xFF)
12188 			return;
12189 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12190 		if (xdgt1 == 0xFF)
12191 			return;
12192 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12193 	}
12194 
12195 #ifdef RTE_NET_IXGBE
12196 	ret = is_tx ?
12197 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12198 			res->idx, res->an, res->pn, key) :
12199 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12200 			res->idx, res->an, res->pn, key);
12201 #endif
12202 	RTE_SET_USED(is_tx);
12203 	RTE_SET_USED(key);
12204 
12205 	switch (ret) {
12206 	case 0:
12207 		break;
12208 	case -EINVAL:
12209 		fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12210 		break;
12211 	case -ENODEV:
12212 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12213 		break;
12214 	case -ENOTSUP:
12215 		fprintf(stderr, "not supported on port %d\n", res->port_id);
12216 		break;
12217 	default:
12218 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12219 	}
12220 }
12221 
12222 cmdline_parse_inst_t cmd_set_macsec_sa = {
12223 	.f = cmd_set_macsec_sa_parsed,
12224 	.data = NULL,
12225 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12226 	.tokens = {
12227 		(void *)&cmd_macsec_sa_set,
12228 		(void *)&cmd_macsec_sa_macsec,
12229 		(void *)&cmd_macsec_sa_sa,
12230 		(void *)&cmd_macsec_sa_tx_rx,
12231 		(void *)&cmd_macsec_sa_port_id,
12232 		(void *)&cmd_macsec_sa_idx,
12233 		(void *)&cmd_macsec_sa_an,
12234 		(void *)&cmd_macsec_sa_pn,
12235 		(void *)&cmd_macsec_sa_key,
12236 		NULL,
12237 	},
12238 };
12239 
12240 /* VF unicast promiscuous mode configuration */
12241 
12242 /* Common result structure for VF unicast promiscuous mode */
12243 struct cmd_vf_promisc_result {
12244 	cmdline_fixed_string_t set;
12245 	cmdline_fixed_string_t vf;
12246 	cmdline_fixed_string_t promisc;
12247 	portid_t port_id;
12248 	uint32_t vf_id;
12249 	cmdline_fixed_string_t on_off;
12250 };
12251 
12252 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12253 cmdline_parse_token_string_t cmd_vf_promisc_set =
12254 	TOKEN_STRING_INITIALIZER
12255 		(struct cmd_vf_promisc_result,
12256 		 set, "set");
12257 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12258 	TOKEN_STRING_INITIALIZER
12259 		(struct cmd_vf_promisc_result,
12260 		 vf, "vf");
12261 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12262 	TOKEN_STRING_INITIALIZER
12263 		(struct cmd_vf_promisc_result,
12264 		 promisc, "promisc");
12265 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12266 	TOKEN_NUM_INITIALIZER
12267 		(struct cmd_vf_promisc_result,
12268 		 port_id, RTE_UINT16);
12269 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12270 	TOKEN_NUM_INITIALIZER
12271 		(struct cmd_vf_promisc_result,
12272 		 vf_id, RTE_UINT32);
12273 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12274 	TOKEN_STRING_INITIALIZER
12275 		(struct cmd_vf_promisc_result,
12276 		 on_off, "on#off");
12277 
12278 static void
12279 cmd_set_vf_promisc_parsed(
12280 	void *parsed_result,
12281 	__rte_unused struct cmdline *cl,
12282 	__rte_unused void *data)
12283 {
12284 	struct cmd_vf_promisc_result *res = parsed_result;
12285 	int ret = -ENOTSUP;
12286 
12287 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12288 
12289 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12290 		return;
12291 
12292 #ifdef RTE_NET_I40E
12293 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12294 						  res->vf_id, is_on);
12295 #endif
12296 
12297 	switch (ret) {
12298 	case 0:
12299 		break;
12300 	case -EINVAL:
12301 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12302 		break;
12303 	case -ENODEV:
12304 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12305 		break;
12306 	case -ENOTSUP:
12307 		fprintf(stderr, "function not implemented\n");
12308 		break;
12309 	default:
12310 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12311 	}
12312 }
12313 
12314 cmdline_parse_inst_t cmd_set_vf_promisc = {
12315 	.f = cmd_set_vf_promisc_parsed,
12316 	.data = NULL,
12317 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
12318 		"Set unicast promiscuous mode for a VF from the PF",
12319 	.tokens = {
12320 		(void *)&cmd_vf_promisc_set,
12321 		(void *)&cmd_vf_promisc_vf,
12322 		(void *)&cmd_vf_promisc_promisc,
12323 		(void *)&cmd_vf_promisc_port_id,
12324 		(void *)&cmd_vf_promisc_vf_id,
12325 		(void *)&cmd_vf_promisc_on_off,
12326 		NULL,
12327 	},
12328 };
12329 
12330 /* VF multicast promiscuous mode configuration */
12331 
12332 /* Common result structure for VF multicast promiscuous mode */
12333 struct cmd_vf_allmulti_result {
12334 	cmdline_fixed_string_t set;
12335 	cmdline_fixed_string_t vf;
12336 	cmdline_fixed_string_t allmulti;
12337 	portid_t port_id;
12338 	uint32_t vf_id;
12339 	cmdline_fixed_string_t on_off;
12340 };
12341 
12342 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12343 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12344 	TOKEN_STRING_INITIALIZER
12345 		(struct cmd_vf_allmulti_result,
12346 		 set, "set");
12347 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12348 	TOKEN_STRING_INITIALIZER
12349 		(struct cmd_vf_allmulti_result,
12350 		 vf, "vf");
12351 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12352 	TOKEN_STRING_INITIALIZER
12353 		(struct cmd_vf_allmulti_result,
12354 		 allmulti, "allmulti");
12355 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12356 	TOKEN_NUM_INITIALIZER
12357 		(struct cmd_vf_allmulti_result,
12358 		 port_id, RTE_UINT16);
12359 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12360 	TOKEN_NUM_INITIALIZER
12361 		(struct cmd_vf_allmulti_result,
12362 		 vf_id, RTE_UINT32);
12363 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12364 	TOKEN_STRING_INITIALIZER
12365 		(struct cmd_vf_allmulti_result,
12366 		 on_off, "on#off");
12367 
12368 static void
12369 cmd_set_vf_allmulti_parsed(
12370 	void *parsed_result,
12371 	__rte_unused struct cmdline *cl,
12372 	__rte_unused void *data)
12373 {
12374 	struct cmd_vf_allmulti_result *res = parsed_result;
12375 	int ret = -ENOTSUP;
12376 
12377 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12378 
12379 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12380 		return;
12381 
12382 #ifdef RTE_NET_I40E
12383 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12384 						    res->vf_id, is_on);
12385 #endif
12386 
12387 	switch (ret) {
12388 	case 0:
12389 		break;
12390 	case -EINVAL:
12391 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12392 		break;
12393 	case -ENODEV:
12394 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12395 		break;
12396 	case -ENOTSUP:
12397 		fprintf(stderr, "function not implemented\n");
12398 		break;
12399 	default:
12400 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12401 	}
12402 }
12403 
12404 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12405 	.f = cmd_set_vf_allmulti_parsed,
12406 	.data = NULL,
12407 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12408 		"Set multicast promiscuous mode for a VF from the PF",
12409 	.tokens = {
12410 		(void *)&cmd_vf_allmulti_set,
12411 		(void *)&cmd_vf_allmulti_vf,
12412 		(void *)&cmd_vf_allmulti_allmulti,
12413 		(void *)&cmd_vf_allmulti_port_id,
12414 		(void *)&cmd_vf_allmulti_vf_id,
12415 		(void *)&cmd_vf_allmulti_on_off,
12416 		NULL,
12417 	},
12418 };
12419 
12420 /* vf broadcast mode configuration */
12421 
12422 /* Common result structure for vf broadcast */
12423 struct cmd_set_vf_broadcast_result {
12424 	cmdline_fixed_string_t set;
12425 	cmdline_fixed_string_t vf;
12426 	cmdline_fixed_string_t broadcast;
12427 	portid_t port_id;
12428 	uint16_t vf_id;
12429 	cmdline_fixed_string_t on_off;
12430 };
12431 
12432 /* Common CLI fields for vf broadcast enable disable */
12433 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12434 	TOKEN_STRING_INITIALIZER
12435 		(struct cmd_set_vf_broadcast_result,
12436 		 set, "set");
12437 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12438 	TOKEN_STRING_INITIALIZER
12439 		(struct cmd_set_vf_broadcast_result,
12440 		 vf, "vf");
12441 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12442 	TOKEN_STRING_INITIALIZER
12443 		(struct cmd_set_vf_broadcast_result,
12444 		 broadcast, "broadcast");
12445 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12446 	TOKEN_NUM_INITIALIZER
12447 		(struct cmd_set_vf_broadcast_result,
12448 		 port_id, RTE_UINT16);
12449 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12450 	TOKEN_NUM_INITIALIZER
12451 		(struct cmd_set_vf_broadcast_result,
12452 		 vf_id, RTE_UINT16);
12453 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12454 	TOKEN_STRING_INITIALIZER
12455 		(struct cmd_set_vf_broadcast_result,
12456 		 on_off, "on#off");
12457 
12458 static void
12459 cmd_set_vf_broadcast_parsed(
12460 	void *parsed_result,
12461 	__rte_unused struct cmdline *cl,
12462 	__rte_unused void *data)
12463 {
12464 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12465 	int ret = -ENOTSUP;
12466 
12467 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12468 
12469 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12470 		return;
12471 
12472 #ifdef RTE_NET_I40E
12473 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12474 					    res->vf_id, is_on);
12475 #endif
12476 
12477 	switch (ret) {
12478 	case 0:
12479 		break;
12480 	case -EINVAL:
12481 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12482 			res->vf_id, is_on);
12483 		break;
12484 	case -ENODEV:
12485 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12486 		break;
12487 	case -ENOTSUP:
12488 		fprintf(stderr, "function not implemented\n");
12489 		break;
12490 	default:
12491 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12492 	}
12493 }
12494 
12495 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12496 	.f = cmd_set_vf_broadcast_parsed,
12497 	.data = NULL,
12498 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12499 	.tokens = {
12500 		(void *)&cmd_set_vf_broadcast_set,
12501 		(void *)&cmd_set_vf_broadcast_vf,
12502 		(void *)&cmd_set_vf_broadcast_broadcast,
12503 		(void *)&cmd_set_vf_broadcast_port_id,
12504 		(void *)&cmd_set_vf_broadcast_vf_id,
12505 		(void *)&cmd_set_vf_broadcast_on_off,
12506 		NULL,
12507 	},
12508 };
12509 
12510 /* vf vlan tag configuration */
12511 
12512 /* Common result structure for vf vlan tag */
12513 struct cmd_set_vf_vlan_tag_result {
12514 	cmdline_fixed_string_t set;
12515 	cmdline_fixed_string_t vf;
12516 	cmdline_fixed_string_t vlan;
12517 	cmdline_fixed_string_t tag;
12518 	portid_t port_id;
12519 	uint16_t vf_id;
12520 	cmdline_fixed_string_t on_off;
12521 };
12522 
12523 /* Common CLI fields for vf vlan tag enable disable */
12524 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12525 	TOKEN_STRING_INITIALIZER
12526 		(struct cmd_set_vf_vlan_tag_result,
12527 		 set, "set");
12528 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12529 	TOKEN_STRING_INITIALIZER
12530 		(struct cmd_set_vf_vlan_tag_result,
12531 		 vf, "vf");
12532 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12533 	TOKEN_STRING_INITIALIZER
12534 		(struct cmd_set_vf_vlan_tag_result,
12535 		 vlan, "vlan");
12536 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12537 	TOKEN_STRING_INITIALIZER
12538 		(struct cmd_set_vf_vlan_tag_result,
12539 		 tag, "tag");
12540 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12541 	TOKEN_NUM_INITIALIZER
12542 		(struct cmd_set_vf_vlan_tag_result,
12543 		 port_id, RTE_UINT16);
12544 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12545 	TOKEN_NUM_INITIALIZER
12546 		(struct cmd_set_vf_vlan_tag_result,
12547 		 vf_id, RTE_UINT16);
12548 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12549 	TOKEN_STRING_INITIALIZER
12550 		(struct cmd_set_vf_vlan_tag_result,
12551 		 on_off, "on#off");
12552 
12553 static void
12554 cmd_set_vf_vlan_tag_parsed(
12555 	void *parsed_result,
12556 	__rte_unused struct cmdline *cl,
12557 	__rte_unused void *data)
12558 {
12559 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12560 	int ret = -ENOTSUP;
12561 
12562 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12563 
12564 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12565 		return;
12566 
12567 #ifdef RTE_NET_I40E
12568 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12569 					   res->vf_id, is_on);
12570 #endif
12571 
12572 	switch (ret) {
12573 	case 0:
12574 		break;
12575 	case -EINVAL:
12576 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12577 			res->vf_id, is_on);
12578 		break;
12579 	case -ENODEV:
12580 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12581 		break;
12582 	case -ENOTSUP:
12583 		fprintf(stderr, "function not implemented\n");
12584 		break;
12585 	default:
12586 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12587 	}
12588 }
12589 
12590 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12591 	.f = cmd_set_vf_vlan_tag_parsed,
12592 	.data = NULL,
12593 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12594 	.tokens = {
12595 		(void *)&cmd_set_vf_vlan_tag_set,
12596 		(void *)&cmd_set_vf_vlan_tag_vf,
12597 		(void *)&cmd_set_vf_vlan_tag_vlan,
12598 		(void *)&cmd_set_vf_vlan_tag_tag,
12599 		(void *)&cmd_set_vf_vlan_tag_port_id,
12600 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12601 		(void *)&cmd_set_vf_vlan_tag_on_off,
12602 		NULL,
12603 	},
12604 };
12605 
12606 /* Common definition of VF and TC TX bandwidth configuration */
12607 struct cmd_vf_tc_bw_result {
12608 	cmdline_fixed_string_t set;
12609 	cmdline_fixed_string_t vf;
12610 	cmdline_fixed_string_t tc;
12611 	cmdline_fixed_string_t tx;
12612 	cmdline_fixed_string_t min_bw;
12613 	cmdline_fixed_string_t max_bw;
12614 	cmdline_fixed_string_t strict_link_prio;
12615 	portid_t port_id;
12616 	uint16_t vf_id;
12617 	uint8_t tc_no;
12618 	uint32_t bw;
12619 	cmdline_fixed_string_t bw_list;
12620 	uint8_t tc_map;
12621 };
12622 
12623 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12624 	TOKEN_STRING_INITIALIZER
12625 		(struct cmd_vf_tc_bw_result,
12626 		 set, "set");
12627 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12628 	TOKEN_STRING_INITIALIZER
12629 		(struct cmd_vf_tc_bw_result,
12630 		 vf, "vf");
12631 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12632 	TOKEN_STRING_INITIALIZER
12633 		(struct cmd_vf_tc_bw_result,
12634 		 tc, "tc");
12635 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12636 	TOKEN_STRING_INITIALIZER
12637 		(struct cmd_vf_tc_bw_result,
12638 		 tx, "tx");
12639 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12640 	TOKEN_STRING_INITIALIZER
12641 		(struct cmd_vf_tc_bw_result,
12642 		 strict_link_prio, "strict-link-priority");
12643 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12644 	TOKEN_STRING_INITIALIZER
12645 		(struct cmd_vf_tc_bw_result,
12646 		 min_bw, "min-bandwidth");
12647 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12648 	TOKEN_STRING_INITIALIZER
12649 		(struct cmd_vf_tc_bw_result,
12650 		 max_bw, "max-bandwidth");
12651 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12652 	TOKEN_NUM_INITIALIZER
12653 		(struct cmd_vf_tc_bw_result,
12654 		 port_id, RTE_UINT16);
12655 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12656 	TOKEN_NUM_INITIALIZER
12657 		(struct cmd_vf_tc_bw_result,
12658 		 vf_id, RTE_UINT16);
12659 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12660 	TOKEN_NUM_INITIALIZER
12661 		(struct cmd_vf_tc_bw_result,
12662 		 tc_no, RTE_UINT8);
12663 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12664 	TOKEN_NUM_INITIALIZER
12665 		(struct cmd_vf_tc_bw_result,
12666 		 bw, RTE_UINT32);
12667 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12668 	TOKEN_STRING_INITIALIZER
12669 		(struct cmd_vf_tc_bw_result,
12670 		 bw_list, NULL);
12671 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12672 	TOKEN_NUM_INITIALIZER
12673 		(struct cmd_vf_tc_bw_result,
12674 		 tc_map, RTE_UINT8);
12675 
12676 /* VF max bandwidth setting */
12677 static void
12678 cmd_vf_max_bw_parsed(
12679 	void *parsed_result,
12680 	__rte_unused struct cmdline *cl,
12681 	__rte_unused void *data)
12682 {
12683 	struct cmd_vf_tc_bw_result *res = parsed_result;
12684 	int ret = -ENOTSUP;
12685 
12686 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12687 		return;
12688 
12689 #ifdef RTE_NET_I40E
12690 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12691 					 res->vf_id, res->bw);
12692 #endif
12693 
12694 	switch (ret) {
12695 	case 0:
12696 		break;
12697 	case -EINVAL:
12698 		fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12699 			res->vf_id, res->bw);
12700 		break;
12701 	case -ENODEV:
12702 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12703 		break;
12704 	case -ENOTSUP:
12705 		fprintf(stderr, "function not implemented\n");
12706 		break;
12707 	default:
12708 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12709 	}
12710 }
12711 
12712 cmdline_parse_inst_t cmd_vf_max_bw = {
12713 	.f = cmd_vf_max_bw_parsed,
12714 	.data = NULL,
12715 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12716 	.tokens = {
12717 		(void *)&cmd_vf_tc_bw_set,
12718 		(void *)&cmd_vf_tc_bw_vf,
12719 		(void *)&cmd_vf_tc_bw_tx,
12720 		(void *)&cmd_vf_tc_bw_max_bw,
12721 		(void *)&cmd_vf_tc_bw_port_id,
12722 		(void *)&cmd_vf_tc_bw_vf_id,
12723 		(void *)&cmd_vf_tc_bw_bw,
12724 		NULL,
12725 	},
12726 };
12727 
12728 static int
12729 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12730 			   uint8_t *tc_num,
12731 			   char *str)
12732 {
12733 	uint32_t size;
12734 	const char *p, *p0 = str;
12735 	char s[256];
12736 	char *end;
12737 	char *str_fld[16];
12738 	uint16_t i;
12739 	int ret;
12740 
12741 	p = strchr(p0, '(');
12742 	if (p == NULL) {
12743 		fprintf(stderr,
12744 			"The bandwidth-list should be '(bw1, bw2, ...)'\n");
12745 		return -1;
12746 	}
12747 	p++;
12748 	p0 = strchr(p, ')');
12749 	if (p0 == NULL) {
12750 		fprintf(stderr,
12751 			"The bandwidth-list should be '(bw1, bw2, ...)'\n");
12752 		return -1;
12753 	}
12754 	size = p0 - p;
12755 	if (size >= sizeof(s)) {
12756 		fprintf(stderr,
12757 			"The string size exceeds the internal buffer size\n");
12758 		return -1;
12759 	}
12760 	snprintf(s, sizeof(s), "%.*s", size, p);
12761 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12762 	if (ret <= 0) {
12763 		fprintf(stderr, "Failed to get the bandwidth list.\n");
12764 		return -1;
12765 	}
12766 	*tc_num = ret;
12767 	for (i = 0; i < ret; i++)
12768 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12769 
12770 	return 0;
12771 }
12772 
12773 /* TC min bandwidth setting */
12774 static void
12775 cmd_vf_tc_min_bw_parsed(
12776 	void *parsed_result,
12777 	__rte_unused struct cmdline *cl,
12778 	__rte_unused void *data)
12779 {
12780 	struct cmd_vf_tc_bw_result *res = parsed_result;
12781 	uint8_t tc_num;
12782 	uint8_t bw[16];
12783 	int ret = -ENOTSUP;
12784 
12785 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12786 		return;
12787 
12788 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12789 	if (ret)
12790 		return;
12791 
12792 #ifdef RTE_NET_I40E
12793 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12794 					      tc_num, bw);
12795 #endif
12796 
12797 	switch (ret) {
12798 	case 0:
12799 		break;
12800 	case -EINVAL:
12801 		fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12802 		break;
12803 	case -ENODEV:
12804 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12805 		break;
12806 	case -ENOTSUP:
12807 		fprintf(stderr, "function not implemented\n");
12808 		break;
12809 	default:
12810 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12811 	}
12812 }
12813 
12814 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12815 	.f = cmd_vf_tc_min_bw_parsed,
12816 	.data = NULL,
12817 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12818 		    " <bw1, bw2, ...>",
12819 	.tokens = {
12820 		(void *)&cmd_vf_tc_bw_set,
12821 		(void *)&cmd_vf_tc_bw_vf,
12822 		(void *)&cmd_vf_tc_bw_tc,
12823 		(void *)&cmd_vf_tc_bw_tx,
12824 		(void *)&cmd_vf_tc_bw_min_bw,
12825 		(void *)&cmd_vf_tc_bw_port_id,
12826 		(void *)&cmd_vf_tc_bw_vf_id,
12827 		(void *)&cmd_vf_tc_bw_bw_list,
12828 		NULL,
12829 	},
12830 };
12831 
12832 static void
12833 cmd_tc_min_bw_parsed(
12834 	void *parsed_result,
12835 	__rte_unused struct cmdline *cl,
12836 	__rte_unused void *data)
12837 {
12838 	struct cmd_vf_tc_bw_result *res = parsed_result;
12839 	struct rte_port *port;
12840 	uint8_t tc_num;
12841 	uint8_t bw[16];
12842 	int ret = -ENOTSUP;
12843 
12844 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12845 		return;
12846 
12847 	port = &ports[res->port_id];
12848 	/** Check if the port is not started **/
12849 	if (port->port_status != RTE_PORT_STOPPED) {
12850 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
12851 		return;
12852 	}
12853 
12854 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12855 	if (ret)
12856 		return;
12857 
12858 #ifdef RTE_NET_IXGBE
12859 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12860 #endif
12861 
12862 	switch (ret) {
12863 	case 0:
12864 		break;
12865 	case -EINVAL:
12866 		fprintf(stderr, "invalid bandwidth\n");
12867 		break;
12868 	case -ENODEV:
12869 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12870 		break;
12871 	case -ENOTSUP:
12872 		fprintf(stderr, "function not implemented\n");
12873 		break;
12874 	default:
12875 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12876 	}
12877 }
12878 
12879 cmdline_parse_inst_t cmd_tc_min_bw = {
12880 	.f = cmd_tc_min_bw_parsed,
12881 	.data = NULL,
12882 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12883 	.tokens = {
12884 		(void *)&cmd_vf_tc_bw_set,
12885 		(void *)&cmd_vf_tc_bw_tc,
12886 		(void *)&cmd_vf_tc_bw_tx,
12887 		(void *)&cmd_vf_tc_bw_min_bw,
12888 		(void *)&cmd_vf_tc_bw_port_id,
12889 		(void *)&cmd_vf_tc_bw_bw_list,
12890 		NULL,
12891 	},
12892 };
12893 
12894 /* TC max bandwidth setting */
12895 static void
12896 cmd_vf_tc_max_bw_parsed(
12897 	void *parsed_result,
12898 	__rte_unused struct cmdline *cl,
12899 	__rte_unused void *data)
12900 {
12901 	struct cmd_vf_tc_bw_result *res = parsed_result;
12902 	int ret = -ENOTSUP;
12903 
12904 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12905 		return;
12906 
12907 #ifdef RTE_NET_I40E
12908 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12909 					    res->tc_no, res->bw);
12910 #endif
12911 
12912 	switch (ret) {
12913 	case 0:
12914 		break;
12915 	case -EINVAL:
12916 		fprintf(stderr,
12917 			"invalid vf_id %d, tc_no %d or bandwidth %d\n",
12918 			res->vf_id, res->tc_no, res->bw);
12919 		break;
12920 	case -ENODEV:
12921 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12922 		break;
12923 	case -ENOTSUP:
12924 		fprintf(stderr, "function not implemented\n");
12925 		break;
12926 	default:
12927 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12928 	}
12929 }
12930 
12931 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12932 	.f = cmd_vf_tc_max_bw_parsed,
12933 	.data = NULL,
12934 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12935 		    " <bandwidth>",
12936 	.tokens = {
12937 		(void *)&cmd_vf_tc_bw_set,
12938 		(void *)&cmd_vf_tc_bw_vf,
12939 		(void *)&cmd_vf_tc_bw_tc,
12940 		(void *)&cmd_vf_tc_bw_tx,
12941 		(void *)&cmd_vf_tc_bw_max_bw,
12942 		(void *)&cmd_vf_tc_bw_port_id,
12943 		(void *)&cmd_vf_tc_bw_vf_id,
12944 		(void *)&cmd_vf_tc_bw_tc_no,
12945 		(void *)&cmd_vf_tc_bw_bw,
12946 		NULL,
12947 	},
12948 };
12949 
12950 /** Set VXLAN encapsulation details */
12951 struct cmd_set_vxlan_result {
12952 	cmdline_fixed_string_t set;
12953 	cmdline_fixed_string_t vxlan;
12954 	cmdline_fixed_string_t pos_token;
12955 	cmdline_fixed_string_t ip_version;
12956 	uint32_t vlan_present:1;
12957 	uint32_t vni;
12958 	uint16_t udp_src;
12959 	uint16_t udp_dst;
12960 	cmdline_ipaddr_t ip_src;
12961 	cmdline_ipaddr_t ip_dst;
12962 	uint16_t tci;
12963 	uint8_t tos;
12964 	uint8_t ttl;
12965 	struct rte_ether_addr eth_src;
12966 	struct rte_ether_addr eth_dst;
12967 };
12968 
12969 cmdline_parse_token_string_t cmd_set_vxlan_set =
12970 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12971 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12972 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12973 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12974 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12975 				 "vxlan-tos-ttl");
12976 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12977 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12978 				 "vxlan-with-vlan");
12979 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12980 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12981 				 "ip-version");
12982 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12983 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12984 				 "ipv4#ipv6");
12985 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12986 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12987 				 "vni");
12988 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12989 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12990 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12991 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12992 				 "udp-src");
12993 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12994 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12995 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12996 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12997 				 "udp-dst");
12998 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12999 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13000 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13001 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13002 				 "ip-tos");
13003 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13004 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13005 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13006 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13007 				 "ip-ttl");
13008 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13009 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13010 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13011 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13012 				 "ip-src");
13013 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13014 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13015 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13016 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13017 				 "ip-dst");
13018 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13019 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13020 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13021 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13022 				 "vlan-tci");
13023 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13024 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13025 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13026 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13027 				 "eth-src");
13028 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13029 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13030 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13031 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13032 				 "eth-dst");
13033 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13034 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13035 
13036 static void cmd_set_vxlan_parsed(void *parsed_result,
13037 	__rte_unused struct cmdline *cl,
13038 	__rte_unused void *data)
13039 {
13040 	struct cmd_set_vxlan_result *res = parsed_result;
13041 	union {
13042 		uint32_t vxlan_id;
13043 		uint8_t vni[4];
13044 	} id = {
13045 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13046 	};
13047 
13048 	vxlan_encap_conf.select_tos_ttl = 0;
13049 	if (strcmp(res->vxlan, "vxlan") == 0)
13050 		vxlan_encap_conf.select_vlan = 0;
13051 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13052 		vxlan_encap_conf.select_vlan = 1;
13053 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13054 		vxlan_encap_conf.select_vlan = 0;
13055 		vxlan_encap_conf.select_tos_ttl = 1;
13056 	}
13057 	if (strcmp(res->ip_version, "ipv4") == 0)
13058 		vxlan_encap_conf.select_ipv4 = 1;
13059 	else if (strcmp(res->ip_version, "ipv6") == 0)
13060 		vxlan_encap_conf.select_ipv4 = 0;
13061 	else
13062 		return;
13063 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13064 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13065 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13066 	vxlan_encap_conf.ip_tos = res->tos;
13067 	vxlan_encap_conf.ip_ttl = res->ttl;
13068 	if (vxlan_encap_conf.select_ipv4) {
13069 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13070 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13071 	} else {
13072 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13073 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13074 	}
13075 	if (vxlan_encap_conf.select_vlan)
13076 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13077 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13078 		   RTE_ETHER_ADDR_LEN);
13079 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13080 		   RTE_ETHER_ADDR_LEN);
13081 }
13082 
13083 cmdline_parse_inst_t cmd_set_vxlan = {
13084 	.f = cmd_set_vxlan_parsed,
13085 	.data = NULL,
13086 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13087 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13088 		" eth-src <eth-src> eth-dst <eth-dst>",
13089 	.tokens = {
13090 		(void *)&cmd_set_vxlan_set,
13091 		(void *)&cmd_set_vxlan_vxlan,
13092 		(void *)&cmd_set_vxlan_ip_version,
13093 		(void *)&cmd_set_vxlan_ip_version_value,
13094 		(void *)&cmd_set_vxlan_vni,
13095 		(void *)&cmd_set_vxlan_vni_value,
13096 		(void *)&cmd_set_vxlan_udp_src,
13097 		(void *)&cmd_set_vxlan_udp_src_value,
13098 		(void *)&cmd_set_vxlan_udp_dst,
13099 		(void *)&cmd_set_vxlan_udp_dst_value,
13100 		(void *)&cmd_set_vxlan_ip_src,
13101 		(void *)&cmd_set_vxlan_ip_src_value,
13102 		(void *)&cmd_set_vxlan_ip_dst,
13103 		(void *)&cmd_set_vxlan_ip_dst_value,
13104 		(void *)&cmd_set_vxlan_eth_src,
13105 		(void *)&cmd_set_vxlan_eth_src_value,
13106 		(void *)&cmd_set_vxlan_eth_dst,
13107 		(void *)&cmd_set_vxlan_eth_dst_value,
13108 		NULL,
13109 	},
13110 };
13111 
13112 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13113 	.f = cmd_set_vxlan_parsed,
13114 	.data = NULL,
13115 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13116 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13117 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13118 		" eth-dst <eth-dst>",
13119 	.tokens = {
13120 		(void *)&cmd_set_vxlan_set,
13121 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
13122 		(void *)&cmd_set_vxlan_ip_version,
13123 		(void *)&cmd_set_vxlan_ip_version_value,
13124 		(void *)&cmd_set_vxlan_vni,
13125 		(void *)&cmd_set_vxlan_vni_value,
13126 		(void *)&cmd_set_vxlan_udp_src,
13127 		(void *)&cmd_set_vxlan_udp_src_value,
13128 		(void *)&cmd_set_vxlan_udp_dst,
13129 		(void *)&cmd_set_vxlan_udp_dst_value,
13130 		(void *)&cmd_set_vxlan_ip_tos,
13131 		(void *)&cmd_set_vxlan_ip_tos_value,
13132 		(void *)&cmd_set_vxlan_ip_ttl,
13133 		(void *)&cmd_set_vxlan_ip_ttl_value,
13134 		(void *)&cmd_set_vxlan_ip_src,
13135 		(void *)&cmd_set_vxlan_ip_src_value,
13136 		(void *)&cmd_set_vxlan_ip_dst,
13137 		(void *)&cmd_set_vxlan_ip_dst_value,
13138 		(void *)&cmd_set_vxlan_eth_src,
13139 		(void *)&cmd_set_vxlan_eth_src_value,
13140 		(void *)&cmd_set_vxlan_eth_dst,
13141 		(void *)&cmd_set_vxlan_eth_dst_value,
13142 		NULL,
13143 	},
13144 };
13145 
13146 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13147 	.f = cmd_set_vxlan_parsed,
13148 	.data = NULL,
13149 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13150 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13151 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13152 		" <eth-dst>",
13153 	.tokens = {
13154 		(void *)&cmd_set_vxlan_set,
13155 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
13156 		(void *)&cmd_set_vxlan_ip_version,
13157 		(void *)&cmd_set_vxlan_ip_version_value,
13158 		(void *)&cmd_set_vxlan_vni,
13159 		(void *)&cmd_set_vxlan_vni_value,
13160 		(void *)&cmd_set_vxlan_udp_src,
13161 		(void *)&cmd_set_vxlan_udp_src_value,
13162 		(void *)&cmd_set_vxlan_udp_dst,
13163 		(void *)&cmd_set_vxlan_udp_dst_value,
13164 		(void *)&cmd_set_vxlan_ip_src,
13165 		(void *)&cmd_set_vxlan_ip_src_value,
13166 		(void *)&cmd_set_vxlan_ip_dst,
13167 		(void *)&cmd_set_vxlan_ip_dst_value,
13168 		(void *)&cmd_set_vxlan_vlan,
13169 		(void *)&cmd_set_vxlan_vlan_value,
13170 		(void *)&cmd_set_vxlan_eth_src,
13171 		(void *)&cmd_set_vxlan_eth_src_value,
13172 		(void *)&cmd_set_vxlan_eth_dst,
13173 		(void *)&cmd_set_vxlan_eth_dst_value,
13174 		NULL,
13175 	},
13176 };
13177 
13178 /** Set NVGRE encapsulation details */
13179 struct cmd_set_nvgre_result {
13180 	cmdline_fixed_string_t set;
13181 	cmdline_fixed_string_t nvgre;
13182 	cmdline_fixed_string_t pos_token;
13183 	cmdline_fixed_string_t ip_version;
13184 	uint32_t tni;
13185 	cmdline_ipaddr_t ip_src;
13186 	cmdline_ipaddr_t ip_dst;
13187 	uint16_t tci;
13188 	struct rte_ether_addr eth_src;
13189 	struct rte_ether_addr eth_dst;
13190 };
13191 
13192 cmdline_parse_token_string_t cmd_set_nvgre_set =
13193 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13194 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13195 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13196 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13197 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13198 				 "nvgre-with-vlan");
13199 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13200 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13201 				 "ip-version");
13202 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13203 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13204 				 "ipv4#ipv6");
13205 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13206 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13207 				 "tni");
13208 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13209 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13210 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13211 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13212 				 "ip-src");
13213 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13214 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13215 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13216 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13217 				 "ip-dst");
13218 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13219 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13220 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13221 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13222 				 "vlan-tci");
13223 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13224 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13225 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13226 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13227 				 "eth-src");
13228 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13229 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13230 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13231 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13232 				 "eth-dst");
13233 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13234 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13235 
13236 static void cmd_set_nvgre_parsed(void *parsed_result,
13237 	__rte_unused struct cmdline *cl,
13238 	__rte_unused void *data)
13239 {
13240 	struct cmd_set_nvgre_result *res = parsed_result;
13241 	union {
13242 		uint32_t nvgre_tni;
13243 		uint8_t tni[4];
13244 	} id = {
13245 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13246 	};
13247 
13248 	if (strcmp(res->nvgre, "nvgre") == 0)
13249 		nvgre_encap_conf.select_vlan = 0;
13250 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13251 		nvgre_encap_conf.select_vlan = 1;
13252 	if (strcmp(res->ip_version, "ipv4") == 0)
13253 		nvgre_encap_conf.select_ipv4 = 1;
13254 	else if (strcmp(res->ip_version, "ipv6") == 0)
13255 		nvgre_encap_conf.select_ipv4 = 0;
13256 	else
13257 		return;
13258 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13259 	if (nvgre_encap_conf.select_ipv4) {
13260 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13261 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13262 	} else {
13263 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13264 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13265 	}
13266 	if (nvgre_encap_conf.select_vlan)
13267 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13268 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13269 		   RTE_ETHER_ADDR_LEN);
13270 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13271 		   RTE_ETHER_ADDR_LEN);
13272 }
13273 
13274 cmdline_parse_inst_t cmd_set_nvgre = {
13275 	.f = cmd_set_nvgre_parsed,
13276 	.data = NULL,
13277 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13278 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13279 		" eth-dst <eth-dst>",
13280 	.tokens = {
13281 		(void *)&cmd_set_nvgre_set,
13282 		(void *)&cmd_set_nvgre_nvgre,
13283 		(void *)&cmd_set_nvgre_ip_version,
13284 		(void *)&cmd_set_nvgre_ip_version_value,
13285 		(void *)&cmd_set_nvgre_tni,
13286 		(void *)&cmd_set_nvgre_tni_value,
13287 		(void *)&cmd_set_nvgre_ip_src,
13288 		(void *)&cmd_set_nvgre_ip_src_value,
13289 		(void *)&cmd_set_nvgre_ip_dst,
13290 		(void *)&cmd_set_nvgre_ip_dst_value,
13291 		(void *)&cmd_set_nvgre_eth_src,
13292 		(void *)&cmd_set_nvgre_eth_src_value,
13293 		(void *)&cmd_set_nvgre_eth_dst,
13294 		(void *)&cmd_set_nvgre_eth_dst_value,
13295 		NULL,
13296 	},
13297 };
13298 
13299 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13300 	.f = cmd_set_nvgre_parsed,
13301 	.data = NULL,
13302 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13303 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13304 		" eth-src <eth-src> eth-dst <eth-dst>",
13305 	.tokens = {
13306 		(void *)&cmd_set_nvgre_set,
13307 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
13308 		(void *)&cmd_set_nvgre_ip_version,
13309 		(void *)&cmd_set_nvgre_ip_version_value,
13310 		(void *)&cmd_set_nvgre_tni,
13311 		(void *)&cmd_set_nvgre_tni_value,
13312 		(void *)&cmd_set_nvgre_ip_src,
13313 		(void *)&cmd_set_nvgre_ip_src_value,
13314 		(void *)&cmd_set_nvgre_ip_dst,
13315 		(void *)&cmd_set_nvgre_ip_dst_value,
13316 		(void *)&cmd_set_nvgre_vlan,
13317 		(void *)&cmd_set_nvgre_vlan_value,
13318 		(void *)&cmd_set_nvgre_eth_src,
13319 		(void *)&cmd_set_nvgre_eth_src_value,
13320 		(void *)&cmd_set_nvgre_eth_dst,
13321 		(void *)&cmd_set_nvgre_eth_dst_value,
13322 		NULL,
13323 	},
13324 };
13325 
13326 /** Set L2 encapsulation details */
13327 struct cmd_set_l2_encap_result {
13328 	cmdline_fixed_string_t set;
13329 	cmdline_fixed_string_t l2_encap;
13330 	cmdline_fixed_string_t pos_token;
13331 	cmdline_fixed_string_t ip_version;
13332 	uint32_t vlan_present:1;
13333 	uint16_t tci;
13334 	struct rte_ether_addr eth_src;
13335 	struct rte_ether_addr eth_dst;
13336 };
13337 
13338 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13339 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13340 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13341 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13342 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13343 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13344 				 "l2_encap-with-vlan");
13345 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13346 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13347 				 "ip-version");
13348 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13349 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13350 				 "ipv4#ipv6");
13351 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13352 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13353 				 "vlan-tci");
13354 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13355 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13356 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13357 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13358 				 "eth-src");
13359 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13360 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13361 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13362 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13363 				 "eth-dst");
13364 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13365 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13366 
13367 static void cmd_set_l2_encap_parsed(void *parsed_result,
13368 	__rte_unused struct cmdline *cl,
13369 	__rte_unused void *data)
13370 {
13371 	struct cmd_set_l2_encap_result *res = parsed_result;
13372 
13373 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13374 		l2_encap_conf.select_vlan = 0;
13375 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13376 		l2_encap_conf.select_vlan = 1;
13377 	if (strcmp(res->ip_version, "ipv4") == 0)
13378 		l2_encap_conf.select_ipv4 = 1;
13379 	else if (strcmp(res->ip_version, "ipv6") == 0)
13380 		l2_encap_conf.select_ipv4 = 0;
13381 	else
13382 		return;
13383 	if (l2_encap_conf.select_vlan)
13384 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13385 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13386 		   RTE_ETHER_ADDR_LEN);
13387 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13388 		   RTE_ETHER_ADDR_LEN);
13389 }
13390 
13391 cmdline_parse_inst_t cmd_set_l2_encap = {
13392 	.f = cmd_set_l2_encap_parsed,
13393 	.data = NULL,
13394 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13395 		" eth-src <eth-src> eth-dst <eth-dst>",
13396 	.tokens = {
13397 		(void *)&cmd_set_l2_encap_set,
13398 		(void *)&cmd_set_l2_encap_l2_encap,
13399 		(void *)&cmd_set_l2_encap_ip_version,
13400 		(void *)&cmd_set_l2_encap_ip_version_value,
13401 		(void *)&cmd_set_l2_encap_eth_src,
13402 		(void *)&cmd_set_l2_encap_eth_src_value,
13403 		(void *)&cmd_set_l2_encap_eth_dst,
13404 		(void *)&cmd_set_l2_encap_eth_dst_value,
13405 		NULL,
13406 	},
13407 };
13408 
13409 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13410 	.f = cmd_set_l2_encap_parsed,
13411 	.data = NULL,
13412 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13413 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13414 	.tokens = {
13415 		(void *)&cmd_set_l2_encap_set,
13416 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13417 		(void *)&cmd_set_l2_encap_ip_version,
13418 		(void *)&cmd_set_l2_encap_ip_version_value,
13419 		(void *)&cmd_set_l2_encap_vlan,
13420 		(void *)&cmd_set_l2_encap_vlan_value,
13421 		(void *)&cmd_set_l2_encap_eth_src,
13422 		(void *)&cmd_set_l2_encap_eth_src_value,
13423 		(void *)&cmd_set_l2_encap_eth_dst,
13424 		(void *)&cmd_set_l2_encap_eth_dst_value,
13425 		NULL,
13426 	},
13427 };
13428 
13429 /** Set L2 decapsulation details */
13430 struct cmd_set_l2_decap_result {
13431 	cmdline_fixed_string_t set;
13432 	cmdline_fixed_string_t l2_decap;
13433 	cmdline_fixed_string_t pos_token;
13434 	uint32_t vlan_present:1;
13435 };
13436 
13437 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13438 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13439 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13440 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13441 				 "l2_decap");
13442 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13443 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13444 				 "l2_decap-with-vlan");
13445 
13446 static void cmd_set_l2_decap_parsed(void *parsed_result,
13447 	__rte_unused struct cmdline *cl,
13448 	__rte_unused void *data)
13449 {
13450 	struct cmd_set_l2_decap_result *res = parsed_result;
13451 
13452 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13453 		l2_decap_conf.select_vlan = 0;
13454 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13455 		l2_decap_conf.select_vlan = 1;
13456 }
13457 
13458 cmdline_parse_inst_t cmd_set_l2_decap = {
13459 	.f = cmd_set_l2_decap_parsed,
13460 	.data = NULL,
13461 	.help_str = "set l2_decap",
13462 	.tokens = {
13463 		(void *)&cmd_set_l2_decap_set,
13464 		(void *)&cmd_set_l2_decap_l2_decap,
13465 		NULL,
13466 	},
13467 };
13468 
13469 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13470 	.f = cmd_set_l2_decap_parsed,
13471 	.data = NULL,
13472 	.help_str = "set l2_decap-with-vlan",
13473 	.tokens = {
13474 		(void *)&cmd_set_l2_decap_set,
13475 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13476 		NULL,
13477 	},
13478 };
13479 
13480 /** Set MPLSoGRE encapsulation details */
13481 struct cmd_set_mplsogre_encap_result {
13482 	cmdline_fixed_string_t set;
13483 	cmdline_fixed_string_t mplsogre;
13484 	cmdline_fixed_string_t pos_token;
13485 	cmdline_fixed_string_t ip_version;
13486 	uint32_t vlan_present:1;
13487 	uint32_t label;
13488 	cmdline_ipaddr_t ip_src;
13489 	cmdline_ipaddr_t ip_dst;
13490 	uint16_t tci;
13491 	struct rte_ether_addr eth_src;
13492 	struct rte_ether_addr eth_dst;
13493 };
13494 
13495 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13496 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13497 				 "set");
13498 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13499 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13500 				 "mplsogre_encap");
13501 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13502 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13503 				 mplsogre, "mplsogre_encap-with-vlan");
13504 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13505 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13506 				 pos_token, "ip-version");
13507 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13508 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13509 				 ip_version, "ipv4#ipv6");
13510 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13511 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13512 				 pos_token, "label");
13513 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13514 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13515 			      RTE_UINT32);
13516 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13517 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13518 				 pos_token, "ip-src");
13519 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13520 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13521 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13522 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13523 				 pos_token, "ip-dst");
13524 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13525 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13526 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13527 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13528 				 pos_token, "vlan-tci");
13529 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13530 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13531 			      RTE_UINT16);
13532 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13533 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13534 				 pos_token, "eth-src");
13535 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13536 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13537 				    eth_src);
13538 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13539 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13540 				 pos_token, "eth-dst");
13541 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13542 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13543 				    eth_dst);
13544 
13545 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13546 	__rte_unused struct cmdline *cl,
13547 	__rte_unused void *data)
13548 {
13549 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13550 	union {
13551 		uint32_t mplsogre_label;
13552 		uint8_t label[4];
13553 	} id = {
13554 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13555 	};
13556 
13557 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13558 		mplsogre_encap_conf.select_vlan = 0;
13559 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13560 		mplsogre_encap_conf.select_vlan = 1;
13561 	if (strcmp(res->ip_version, "ipv4") == 0)
13562 		mplsogre_encap_conf.select_ipv4 = 1;
13563 	else if (strcmp(res->ip_version, "ipv6") == 0)
13564 		mplsogre_encap_conf.select_ipv4 = 0;
13565 	else
13566 		return;
13567 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13568 	if (mplsogre_encap_conf.select_ipv4) {
13569 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13570 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13571 	} else {
13572 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13573 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13574 	}
13575 	if (mplsogre_encap_conf.select_vlan)
13576 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13577 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13578 		   RTE_ETHER_ADDR_LEN);
13579 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13580 		   RTE_ETHER_ADDR_LEN);
13581 }
13582 
13583 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13584 	.f = cmd_set_mplsogre_encap_parsed,
13585 	.data = NULL,
13586 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13587 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13588 		" eth-dst <eth-dst>",
13589 	.tokens = {
13590 		(void *)&cmd_set_mplsogre_encap_set,
13591 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13592 		(void *)&cmd_set_mplsogre_encap_ip_version,
13593 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13594 		(void *)&cmd_set_mplsogre_encap_label,
13595 		(void *)&cmd_set_mplsogre_encap_label_value,
13596 		(void *)&cmd_set_mplsogre_encap_ip_src,
13597 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13598 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13599 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13600 		(void *)&cmd_set_mplsogre_encap_eth_src,
13601 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13602 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13603 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13604 		NULL,
13605 	},
13606 };
13607 
13608 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13609 	.f = cmd_set_mplsogre_encap_parsed,
13610 	.data = NULL,
13611 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13612 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13613 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13614 	.tokens = {
13615 		(void *)&cmd_set_mplsogre_encap_set,
13616 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13617 		(void *)&cmd_set_mplsogre_encap_ip_version,
13618 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13619 		(void *)&cmd_set_mplsogre_encap_label,
13620 		(void *)&cmd_set_mplsogre_encap_label_value,
13621 		(void *)&cmd_set_mplsogre_encap_ip_src,
13622 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13623 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13624 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13625 		(void *)&cmd_set_mplsogre_encap_vlan,
13626 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13627 		(void *)&cmd_set_mplsogre_encap_eth_src,
13628 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13629 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13630 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13631 		NULL,
13632 	},
13633 };
13634 
13635 /** Set MPLSoGRE decapsulation details */
13636 struct cmd_set_mplsogre_decap_result {
13637 	cmdline_fixed_string_t set;
13638 	cmdline_fixed_string_t mplsogre;
13639 	cmdline_fixed_string_t pos_token;
13640 	cmdline_fixed_string_t ip_version;
13641 	uint32_t vlan_present:1;
13642 };
13643 
13644 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13645 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13646 				 "set");
13647 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13648 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13649 				 "mplsogre_decap");
13650 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13651 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13652 				 mplsogre, "mplsogre_decap-with-vlan");
13653 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13654 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13655 				 pos_token, "ip-version");
13656 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13657 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13658 				 ip_version, "ipv4#ipv6");
13659 
13660 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13661 	__rte_unused struct cmdline *cl,
13662 	__rte_unused void *data)
13663 {
13664 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13665 
13666 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13667 		mplsogre_decap_conf.select_vlan = 0;
13668 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13669 		mplsogre_decap_conf.select_vlan = 1;
13670 	if (strcmp(res->ip_version, "ipv4") == 0)
13671 		mplsogre_decap_conf.select_ipv4 = 1;
13672 	else if (strcmp(res->ip_version, "ipv6") == 0)
13673 		mplsogre_decap_conf.select_ipv4 = 0;
13674 }
13675 
13676 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13677 	.f = cmd_set_mplsogre_decap_parsed,
13678 	.data = NULL,
13679 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13680 	.tokens = {
13681 		(void *)&cmd_set_mplsogre_decap_set,
13682 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13683 		(void *)&cmd_set_mplsogre_decap_ip_version,
13684 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13685 		NULL,
13686 	},
13687 };
13688 
13689 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13690 	.f = cmd_set_mplsogre_decap_parsed,
13691 	.data = NULL,
13692 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13693 	.tokens = {
13694 		(void *)&cmd_set_mplsogre_decap_set,
13695 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13696 		(void *)&cmd_set_mplsogre_decap_ip_version,
13697 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13698 		NULL,
13699 	},
13700 };
13701 
13702 /** Set MPLSoUDP encapsulation details */
13703 struct cmd_set_mplsoudp_encap_result {
13704 	cmdline_fixed_string_t set;
13705 	cmdline_fixed_string_t mplsoudp;
13706 	cmdline_fixed_string_t pos_token;
13707 	cmdline_fixed_string_t ip_version;
13708 	uint32_t vlan_present:1;
13709 	uint32_t label;
13710 	uint16_t udp_src;
13711 	uint16_t udp_dst;
13712 	cmdline_ipaddr_t ip_src;
13713 	cmdline_ipaddr_t ip_dst;
13714 	uint16_t tci;
13715 	struct rte_ether_addr eth_src;
13716 	struct rte_ether_addr eth_dst;
13717 };
13718 
13719 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13720 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13721 				 "set");
13722 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13723 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13724 				 "mplsoudp_encap");
13725 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13726 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13727 				 mplsoudp, "mplsoudp_encap-with-vlan");
13728 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13729 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13730 				 pos_token, "ip-version");
13731 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13732 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13733 				 ip_version, "ipv4#ipv6");
13734 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13735 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13736 				 pos_token, "label");
13737 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13738 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13739 			      RTE_UINT32);
13740 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13741 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13742 				 pos_token, "udp-src");
13743 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13744 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13745 			      RTE_UINT16);
13746 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13747 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13748 				 pos_token, "udp-dst");
13749 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13750 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13751 			      RTE_UINT16);
13752 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13753 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13754 				 pos_token, "ip-src");
13755 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13756 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13757 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13758 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13759 				 pos_token, "ip-dst");
13760 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13761 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13762 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13763 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13764 				 pos_token, "vlan-tci");
13765 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13766 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13767 			      RTE_UINT16);
13768 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13769 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13770 				 pos_token, "eth-src");
13771 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13772 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13773 				    eth_src);
13774 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13775 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13776 				 pos_token, "eth-dst");
13777 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13778 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13779 				    eth_dst);
13780 
13781 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13782 	__rte_unused struct cmdline *cl,
13783 	__rte_unused void *data)
13784 {
13785 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13786 	union {
13787 		uint32_t mplsoudp_label;
13788 		uint8_t label[4];
13789 	} id = {
13790 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13791 	};
13792 
13793 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13794 		mplsoudp_encap_conf.select_vlan = 0;
13795 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13796 		mplsoudp_encap_conf.select_vlan = 1;
13797 	if (strcmp(res->ip_version, "ipv4") == 0)
13798 		mplsoudp_encap_conf.select_ipv4 = 1;
13799 	else if (strcmp(res->ip_version, "ipv6") == 0)
13800 		mplsoudp_encap_conf.select_ipv4 = 0;
13801 	else
13802 		return;
13803 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13804 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13805 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13806 	if (mplsoudp_encap_conf.select_ipv4) {
13807 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13808 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13809 	} else {
13810 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13811 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13812 	}
13813 	if (mplsoudp_encap_conf.select_vlan)
13814 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13815 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13816 		   RTE_ETHER_ADDR_LEN);
13817 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13818 		   RTE_ETHER_ADDR_LEN);
13819 }
13820 
13821 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13822 	.f = cmd_set_mplsoudp_encap_parsed,
13823 	.data = NULL,
13824 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13825 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13826 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13827 	.tokens = {
13828 		(void *)&cmd_set_mplsoudp_encap_set,
13829 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13830 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13831 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13832 		(void *)&cmd_set_mplsoudp_encap_label,
13833 		(void *)&cmd_set_mplsoudp_encap_label_value,
13834 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13835 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13836 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13837 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13838 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13839 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13840 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13841 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13842 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13843 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13844 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13845 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13846 		NULL,
13847 	},
13848 };
13849 
13850 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13851 	.f = cmd_set_mplsoudp_encap_parsed,
13852 	.data = NULL,
13853 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13854 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13855 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13856 		" eth-src <eth-src> eth-dst <eth-dst>",
13857 	.tokens = {
13858 		(void *)&cmd_set_mplsoudp_encap_set,
13859 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13860 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13861 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13862 		(void *)&cmd_set_mplsoudp_encap_label,
13863 		(void *)&cmd_set_mplsoudp_encap_label_value,
13864 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13865 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13866 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13867 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13868 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13869 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13870 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13871 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13872 		(void *)&cmd_set_mplsoudp_encap_vlan,
13873 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13874 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13875 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13876 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13877 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13878 		NULL,
13879 	},
13880 };
13881 
13882 /** Set MPLSoUDP decapsulation details */
13883 struct cmd_set_mplsoudp_decap_result {
13884 	cmdline_fixed_string_t set;
13885 	cmdline_fixed_string_t mplsoudp;
13886 	cmdline_fixed_string_t pos_token;
13887 	cmdline_fixed_string_t ip_version;
13888 	uint32_t vlan_present:1;
13889 };
13890 
13891 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13892 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13893 				 "set");
13894 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13895 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13896 				 "mplsoudp_decap");
13897 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13898 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13899 				 mplsoudp, "mplsoudp_decap-with-vlan");
13900 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13901 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13902 				 pos_token, "ip-version");
13903 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13904 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13905 				 ip_version, "ipv4#ipv6");
13906 
13907 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13908 	__rte_unused struct cmdline *cl,
13909 	__rte_unused void *data)
13910 {
13911 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13912 
13913 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13914 		mplsoudp_decap_conf.select_vlan = 0;
13915 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13916 		mplsoudp_decap_conf.select_vlan = 1;
13917 	if (strcmp(res->ip_version, "ipv4") == 0)
13918 		mplsoudp_decap_conf.select_ipv4 = 1;
13919 	else if (strcmp(res->ip_version, "ipv6") == 0)
13920 		mplsoudp_decap_conf.select_ipv4 = 0;
13921 }
13922 
13923 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13924 	.f = cmd_set_mplsoudp_decap_parsed,
13925 	.data = NULL,
13926 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13927 	.tokens = {
13928 		(void *)&cmd_set_mplsoudp_decap_set,
13929 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13930 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13931 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13932 		NULL,
13933 	},
13934 };
13935 
13936 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13937 	.f = cmd_set_mplsoudp_decap_parsed,
13938 	.data = NULL,
13939 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13940 	.tokens = {
13941 		(void *)&cmd_set_mplsoudp_decap_set,
13942 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13943 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13944 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13945 		NULL,
13946 	},
13947 };
13948 
13949 /** Set connection tracking object common details */
13950 struct cmd_set_conntrack_common_result {
13951 	cmdline_fixed_string_t set;
13952 	cmdline_fixed_string_t conntrack;
13953 	cmdline_fixed_string_t common;
13954 	cmdline_fixed_string_t peer;
13955 	cmdline_fixed_string_t is_orig;
13956 	cmdline_fixed_string_t enable;
13957 	cmdline_fixed_string_t live;
13958 	cmdline_fixed_string_t sack;
13959 	cmdline_fixed_string_t cack;
13960 	cmdline_fixed_string_t last_dir;
13961 	cmdline_fixed_string_t liberal;
13962 	cmdline_fixed_string_t state;
13963 	cmdline_fixed_string_t max_ack_win;
13964 	cmdline_fixed_string_t retrans;
13965 	cmdline_fixed_string_t last_win;
13966 	cmdline_fixed_string_t last_seq;
13967 	cmdline_fixed_string_t last_ack;
13968 	cmdline_fixed_string_t last_end;
13969 	cmdline_fixed_string_t last_index;
13970 	uint8_t stat;
13971 	uint8_t factor;
13972 	uint16_t peer_port;
13973 	uint32_t is_original;
13974 	uint32_t en;
13975 	uint32_t is_live;
13976 	uint32_t s_ack;
13977 	uint32_t c_ack;
13978 	uint32_t ld;
13979 	uint32_t lb;
13980 	uint8_t re_num;
13981 	uint8_t li;
13982 	uint16_t lw;
13983 	uint32_t ls;
13984 	uint32_t la;
13985 	uint32_t le;
13986 };
13987 
13988 cmdline_parse_token_string_t cmd_set_conntrack_set =
13989 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13990 				 set, "set");
13991 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13992 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13993 				 conntrack, "conntrack");
13994 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13995 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13996 				 common, "com");
13997 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13998 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13999 				 peer, "peer");
14000 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14001 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14002 			      peer_port, RTE_UINT16);
14003 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14004 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14005 				 is_orig, "is_orig");
14006 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14007 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14008 			      is_original, RTE_UINT32);
14009 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14010 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14011 				 enable, "enable");
14012 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14013 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14014 			      en, RTE_UINT32);
14015 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14016 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14017 				 live, "live");
14018 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14019 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14020 			      is_live, RTE_UINT32);
14021 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14022 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14023 				 sack, "sack");
14024 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14025 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14026 			      s_ack, RTE_UINT32);
14027 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14028 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14029 				 cack, "cack");
14030 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14031 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14032 			      c_ack, RTE_UINT32);
14033 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14034 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14035 				 last_dir, "last_dir");
14036 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14037 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14038 			      ld, RTE_UINT32);
14039 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14040 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14041 				 liberal, "liberal");
14042 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14043 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14044 			      lb, RTE_UINT32);
14045 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14046 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14047 				 state, "state");
14048 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14049 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14050 			      stat, RTE_UINT8);
14051 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14052 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14053 				 max_ack_win, "max_ack_win");
14054 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14055 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14056 			      factor, RTE_UINT8);
14057 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14058 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14059 				 retrans, "r_lim");
14060 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14061 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14062 			      re_num, RTE_UINT8);
14063 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14064 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14065 				 last_win, "last_win");
14066 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14067 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14068 			      lw, RTE_UINT16);
14069 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14070 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14071 				 last_seq, "last_seq");
14072 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14073 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14074 			      ls, RTE_UINT32);
14075 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14076 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14077 				 last_ack, "last_ack");
14078 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14079 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14080 			      la, RTE_UINT32);
14081 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14082 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14083 				 last_end, "last_end");
14084 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14085 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14086 			      le, RTE_UINT32);
14087 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14088 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14089 				 last_index, "last_index");
14090 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14091 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14092 			      li, RTE_UINT8);
14093 
14094 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14095 	__rte_unused struct cmdline *cl,
14096 	__rte_unused void *data)
14097 {
14098 	struct cmd_set_conntrack_common_result *res = parsed_result;
14099 
14100 	/* No need to swap to big endian. */
14101 	conntrack_context.peer_port = res->peer_port;
14102 	conntrack_context.is_original_dir = res->is_original;
14103 	conntrack_context.enable = res->en;
14104 	conntrack_context.live_connection = res->is_live;
14105 	conntrack_context.selective_ack = res->s_ack;
14106 	conntrack_context.challenge_ack_passed = res->c_ack;
14107 	conntrack_context.last_direction = res->ld;
14108 	conntrack_context.liberal_mode = res->lb;
14109 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14110 	conntrack_context.max_ack_window = res->factor;
14111 	conntrack_context.retransmission_limit = res->re_num;
14112 	conntrack_context.last_window = res->lw;
14113 	conntrack_context.last_index =
14114 		(enum rte_flow_conntrack_tcp_last_index)res->li;
14115 	conntrack_context.last_seq = res->ls;
14116 	conntrack_context.last_ack = res->la;
14117 	conntrack_context.last_end = res->le;
14118 }
14119 
14120 cmdline_parse_inst_t cmd_set_conntrack_common = {
14121 	.f = cmd_set_conntrack_common_parsed,
14122 	.data = NULL,
14123 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14124 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14125 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14126 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14127 		" last_index <flag>",
14128 	.tokens = {
14129 		(void *)&cmd_set_conntrack_set,
14130 		(void *)&cmd_set_conntrack_conntrack,
14131 		(void *)&cmd_set_conntrack_common_com,
14132 		(void *)&cmd_set_conntrack_common_peer,
14133 		(void *)&cmd_set_conntrack_common_peer_value,
14134 		(void *)&cmd_set_conntrack_common_is_orig,
14135 		(void *)&cmd_set_conntrack_common_is_orig_value,
14136 		(void *)&cmd_set_conntrack_common_enable,
14137 		(void *)&cmd_set_conntrack_common_enable_value,
14138 		(void *)&cmd_set_conntrack_common_live,
14139 		(void *)&cmd_set_conntrack_common_live_value,
14140 		(void *)&cmd_set_conntrack_common_sack,
14141 		(void *)&cmd_set_conntrack_common_sack_value,
14142 		(void *)&cmd_set_conntrack_common_cack,
14143 		(void *)&cmd_set_conntrack_common_cack_value,
14144 		(void *)&cmd_set_conntrack_common_last_dir,
14145 		(void *)&cmd_set_conntrack_common_last_dir_value,
14146 		(void *)&cmd_set_conntrack_common_liberal,
14147 		(void *)&cmd_set_conntrack_common_liberal_value,
14148 		(void *)&cmd_set_conntrack_common_state,
14149 		(void *)&cmd_set_conntrack_common_state_value,
14150 		(void *)&cmd_set_conntrack_common_max_ackwin,
14151 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
14152 		(void *)&cmd_set_conntrack_common_retrans,
14153 		(void *)&cmd_set_conntrack_common_retrans_value,
14154 		(void *)&cmd_set_conntrack_common_last_win,
14155 		(void *)&cmd_set_conntrack_common_last_win_value,
14156 		(void *)&cmd_set_conntrack_common_last_seq,
14157 		(void *)&cmd_set_conntrack_common_last_seq_value,
14158 		(void *)&cmd_set_conntrack_common_last_ack,
14159 		(void *)&cmd_set_conntrack_common_last_ack_value,
14160 		(void *)&cmd_set_conntrack_common_last_end,
14161 		(void *)&cmd_set_conntrack_common_last_end_value,
14162 		(void *)&cmd_set_conntrack_common_last_index,
14163 		(void *)&cmd_set_conntrack_common_last_index_value,
14164 		NULL,
14165 	},
14166 };
14167 
14168 /** Set connection tracking object both directions' details */
14169 struct cmd_set_conntrack_dir_result {
14170 	cmdline_fixed_string_t set;
14171 	cmdline_fixed_string_t conntrack;
14172 	cmdline_fixed_string_t dir;
14173 	cmdline_fixed_string_t scale;
14174 	cmdline_fixed_string_t fin;
14175 	cmdline_fixed_string_t ack_seen;
14176 	cmdline_fixed_string_t unack;
14177 	cmdline_fixed_string_t sent_end;
14178 	cmdline_fixed_string_t reply_end;
14179 	cmdline_fixed_string_t max_win;
14180 	cmdline_fixed_string_t max_ack;
14181 	uint32_t factor;
14182 	uint32_t f;
14183 	uint32_t as;
14184 	uint32_t un;
14185 	uint32_t se;
14186 	uint32_t re;
14187 	uint32_t mw;
14188 	uint32_t ma;
14189 };
14190 
14191 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14192 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14193 				 set, "set");
14194 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14195 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14196 				 conntrack, "conntrack");
14197 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14198 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14199 				 dir, "orig#rply");
14200 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14201 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14202 				 scale, "scale");
14203 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14204 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14205 			      factor, RTE_UINT32);
14206 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14207 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14208 				 fin, "fin");
14209 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14210 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14211 			      f, RTE_UINT32);
14212 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14213 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14214 				 ack_seen, "acked");
14215 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14216 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14217 			      as, RTE_UINT32);
14218 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14219 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14220 				 unack, "unack_data");
14221 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14222 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14223 			      un, RTE_UINT32);
14224 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14225 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14226 				 sent_end, "sent_end");
14227 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14228 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14229 			      se, RTE_UINT32);
14230 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14231 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14232 				 reply_end, "reply_end");
14233 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14234 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14235 			      re, RTE_UINT32);
14236 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14237 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14238 				 max_win, "max_win");
14239 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14240 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14241 			      mw, RTE_UINT32);
14242 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14243 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14244 				 max_ack, "max_ack");
14245 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14246 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14247 			      ma, RTE_UINT32);
14248 
14249 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14250 	__rte_unused struct cmdline *cl,
14251 	__rte_unused void *data)
14252 {
14253 	struct cmd_set_conntrack_dir_result *res = parsed_result;
14254 	struct rte_flow_tcp_dir_param *dir = NULL;
14255 
14256 	if (strcmp(res->dir, "orig") == 0)
14257 		dir = &conntrack_context.original_dir;
14258 	else if (strcmp(res->dir, "rply") == 0)
14259 		dir = &conntrack_context.reply_dir;
14260 	else
14261 		return;
14262 	dir->scale = res->factor;
14263 	dir->close_initiated = res->f;
14264 	dir->last_ack_seen = res->as;
14265 	dir->data_unacked = res->un;
14266 	dir->sent_end = res->se;
14267 	dir->reply_end = res->re;
14268 	dir->max_ack = res->ma;
14269 	dir->max_win = res->mw;
14270 }
14271 
14272 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14273 	.f = cmd_set_conntrack_dir_parsed,
14274 	.data = NULL,
14275 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14276 		    " acked <seen> unack_data <unack> sent_end <sent>"
14277 		    " reply_end <reply> max_win <win> max_ack <ack>",
14278 	.tokens = {
14279 		(void *)&cmd_set_conntrack_set,
14280 		(void *)&cmd_set_conntrack_conntrack,
14281 		(void *)&cmd_set_conntrack_dir_dir,
14282 		(void *)&cmd_set_conntrack_dir_scale,
14283 		(void *)&cmd_set_conntrack_dir_scale_value,
14284 		(void *)&cmd_set_conntrack_dir_fin,
14285 		(void *)&cmd_set_conntrack_dir_fin_value,
14286 		(void *)&cmd_set_conntrack_dir_ack,
14287 		(void *)&cmd_set_conntrack_dir_ack_value,
14288 		(void *)&cmd_set_conntrack_dir_unack_data,
14289 		(void *)&cmd_set_conntrack_dir_unack_data_value,
14290 		(void *)&cmd_set_conntrack_dir_sent_end,
14291 		(void *)&cmd_set_conntrack_dir_sent_end_value,
14292 		(void *)&cmd_set_conntrack_dir_reply_end,
14293 		(void *)&cmd_set_conntrack_dir_reply_end_value,
14294 		(void *)&cmd_set_conntrack_dir_max_win,
14295 		(void *)&cmd_set_conntrack_dir_max_win_value,
14296 		(void *)&cmd_set_conntrack_dir_max_ack,
14297 		(void *)&cmd_set_conntrack_dir_max_ack_value,
14298 		NULL,
14299 	},
14300 };
14301 
14302 /* Strict link priority scheduling mode setting */
14303 static void
14304 cmd_strict_link_prio_parsed(
14305 	void *parsed_result,
14306 	__rte_unused struct cmdline *cl,
14307 	__rte_unused void *data)
14308 {
14309 	struct cmd_vf_tc_bw_result *res = parsed_result;
14310 	int ret = -ENOTSUP;
14311 
14312 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14313 		return;
14314 
14315 #ifdef RTE_NET_I40E
14316 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14317 #endif
14318 
14319 	switch (ret) {
14320 	case 0:
14321 		break;
14322 	case -EINVAL:
14323 		fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14324 		break;
14325 	case -ENODEV:
14326 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
14327 		break;
14328 	case -ENOTSUP:
14329 		fprintf(stderr, "function not implemented\n");
14330 		break;
14331 	default:
14332 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14333 	}
14334 }
14335 
14336 cmdline_parse_inst_t cmd_strict_link_prio = {
14337 	.f = cmd_strict_link_prio_parsed,
14338 	.data = NULL,
14339 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14340 	.tokens = {
14341 		(void *)&cmd_vf_tc_bw_set,
14342 		(void *)&cmd_vf_tc_bw_tx,
14343 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14344 		(void *)&cmd_vf_tc_bw_port_id,
14345 		(void *)&cmd_vf_tc_bw_tc_map,
14346 		NULL,
14347 	},
14348 };
14349 
14350 /* Load dynamic device personalization*/
14351 struct cmd_ddp_add_result {
14352 	cmdline_fixed_string_t ddp;
14353 	cmdline_fixed_string_t add;
14354 	portid_t port_id;
14355 	char filepath[];
14356 };
14357 
14358 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14359 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14360 cmdline_parse_token_string_t cmd_ddp_add_add =
14361 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14362 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14363 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14364 		RTE_UINT16);
14365 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14366 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14367 
14368 static void
14369 cmd_ddp_add_parsed(
14370 	void *parsed_result,
14371 	__rte_unused struct cmdline *cl,
14372 	__rte_unused void *data)
14373 {
14374 	struct cmd_ddp_add_result *res = parsed_result;
14375 	uint8_t *buff;
14376 	uint32_t size;
14377 	char *filepath;
14378 	char *file_fld[2];
14379 	int file_num;
14380 	int ret = -ENOTSUP;
14381 
14382 	if (!all_ports_stopped()) {
14383 		fprintf(stderr, "Please stop all ports first\n");
14384 		return;
14385 	}
14386 
14387 	filepath = strdup(res->filepath);
14388 	if (filepath == NULL) {
14389 		fprintf(stderr, "Failed to allocate memory\n");
14390 		return;
14391 	}
14392 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14393 
14394 	buff = open_file(file_fld[0], &size);
14395 	if (!buff) {
14396 		free((void *)filepath);
14397 		return;
14398 	}
14399 
14400 #ifdef RTE_NET_I40E
14401 	if (ret == -ENOTSUP)
14402 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14403 					       buff, size,
14404 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14405 #endif
14406 
14407 	if (ret == -EEXIST)
14408 		fprintf(stderr, "Profile has already existed.\n");
14409 	else if (ret < 0)
14410 		fprintf(stderr, "Failed to load profile.\n");
14411 	else if (file_num == 2)
14412 		save_file(file_fld[1], buff, size);
14413 
14414 	close_file(buff);
14415 	free((void *)filepath);
14416 }
14417 
14418 cmdline_parse_inst_t cmd_ddp_add = {
14419 	.f = cmd_ddp_add_parsed,
14420 	.data = NULL,
14421 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14422 	.tokens = {
14423 		(void *)&cmd_ddp_add_ddp,
14424 		(void *)&cmd_ddp_add_add,
14425 		(void *)&cmd_ddp_add_port_id,
14426 		(void *)&cmd_ddp_add_filepath,
14427 		NULL,
14428 	},
14429 };
14430 
14431 /* Delete dynamic device personalization*/
14432 struct cmd_ddp_del_result {
14433 	cmdline_fixed_string_t ddp;
14434 	cmdline_fixed_string_t del;
14435 	portid_t port_id;
14436 	char filepath[];
14437 };
14438 
14439 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14440 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14441 cmdline_parse_token_string_t cmd_ddp_del_del =
14442 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14443 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14444 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14445 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14446 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14447 
14448 static void
14449 cmd_ddp_del_parsed(
14450 	void *parsed_result,
14451 	__rte_unused struct cmdline *cl,
14452 	__rte_unused void *data)
14453 {
14454 	struct cmd_ddp_del_result *res = parsed_result;
14455 	uint8_t *buff;
14456 	uint32_t size;
14457 	int ret = -ENOTSUP;
14458 
14459 	if (!all_ports_stopped()) {
14460 		fprintf(stderr, "Please stop all ports first\n");
14461 		return;
14462 	}
14463 
14464 	buff = open_file(res->filepath, &size);
14465 	if (!buff)
14466 		return;
14467 
14468 #ifdef RTE_NET_I40E
14469 	if (ret == -ENOTSUP)
14470 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14471 					       buff, size,
14472 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14473 #endif
14474 
14475 	if (ret == -EACCES)
14476 		fprintf(stderr, "Profile does not exist.\n");
14477 	else if (ret < 0)
14478 		fprintf(stderr, "Failed to delete profile.\n");
14479 
14480 	close_file(buff);
14481 }
14482 
14483 cmdline_parse_inst_t cmd_ddp_del = {
14484 	.f = cmd_ddp_del_parsed,
14485 	.data = NULL,
14486 	.help_str = "ddp del <port_id> <backup_profile_path>",
14487 	.tokens = {
14488 		(void *)&cmd_ddp_del_ddp,
14489 		(void *)&cmd_ddp_del_del,
14490 		(void *)&cmd_ddp_del_port_id,
14491 		(void *)&cmd_ddp_del_filepath,
14492 		NULL,
14493 	},
14494 };
14495 
14496 /* Get dynamic device personalization profile info */
14497 struct cmd_ddp_info_result {
14498 	cmdline_fixed_string_t ddp;
14499 	cmdline_fixed_string_t get;
14500 	cmdline_fixed_string_t info;
14501 	char filepath[];
14502 };
14503 
14504 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14505 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14506 cmdline_parse_token_string_t cmd_ddp_info_get =
14507 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14508 cmdline_parse_token_string_t cmd_ddp_info_info =
14509 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14510 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14511 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14512 
14513 static void
14514 cmd_ddp_info_parsed(
14515 	void *parsed_result,
14516 	__rte_unused struct cmdline *cl,
14517 	__rte_unused void *data)
14518 {
14519 	struct cmd_ddp_info_result *res = parsed_result;
14520 	uint8_t *pkg;
14521 	uint32_t pkg_size;
14522 	int ret = -ENOTSUP;
14523 #ifdef RTE_NET_I40E
14524 	uint32_t i, j, n;
14525 	uint8_t *buff;
14526 	uint32_t buff_size = 0;
14527 	struct rte_pmd_i40e_profile_info info;
14528 	uint32_t dev_num = 0;
14529 	struct rte_pmd_i40e_ddp_device_id *devs;
14530 	uint32_t proto_num = 0;
14531 	struct rte_pmd_i40e_proto_info *proto = NULL;
14532 	uint32_t pctype_num = 0;
14533 	struct rte_pmd_i40e_ptype_info *pctype;
14534 	uint32_t ptype_num = 0;
14535 	struct rte_pmd_i40e_ptype_info *ptype;
14536 	uint8_t proto_id;
14537 
14538 #endif
14539 
14540 	pkg = open_file(res->filepath, &pkg_size);
14541 	if (!pkg)
14542 		return;
14543 
14544 #ifdef RTE_NET_I40E
14545 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14546 				(uint8_t *)&info, sizeof(info),
14547 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14548 	if (!ret) {
14549 		printf("Global Track id:       0x%x\n", info.track_id);
14550 		printf("Global Version:        %d.%d.%d.%d\n",
14551 			info.version.major,
14552 			info.version.minor,
14553 			info.version.update,
14554 			info.version.draft);
14555 		printf("Global Package name:   %s\n\n", info.name);
14556 	}
14557 
14558 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14559 				(uint8_t *)&info, sizeof(info),
14560 				RTE_PMD_I40E_PKG_INFO_HEADER);
14561 	if (!ret) {
14562 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14563 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14564 			info.version.major,
14565 			info.version.minor,
14566 			info.version.update,
14567 			info.version.draft);
14568 		printf("i40e Profile name:     %s\n\n", info.name);
14569 	}
14570 
14571 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14572 				(uint8_t *)&buff_size, sizeof(buff_size),
14573 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14574 	if (!ret && buff_size) {
14575 		buff = (uint8_t *)malloc(buff_size);
14576 		if (buff) {
14577 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14578 						buff, buff_size,
14579 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14580 			if (!ret)
14581 				printf("Package Notes:\n%s\n\n", buff);
14582 			free(buff);
14583 		}
14584 	}
14585 
14586 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14587 				(uint8_t *)&dev_num, sizeof(dev_num),
14588 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14589 	if (!ret && dev_num) {
14590 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14591 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14592 		if (devs) {
14593 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14594 						(uint8_t *)devs, buff_size,
14595 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14596 			if (!ret) {
14597 				printf("List of supported devices:\n");
14598 				for (i = 0; i < dev_num; i++) {
14599 					printf("  %04X:%04X %04X:%04X\n",
14600 						devs[i].vendor_dev_id >> 16,
14601 						devs[i].vendor_dev_id & 0xFFFF,
14602 						devs[i].sub_vendor_dev_id >> 16,
14603 						devs[i].sub_vendor_dev_id & 0xFFFF);
14604 				}
14605 				printf("\n");
14606 			}
14607 			free(devs);
14608 		}
14609 	}
14610 
14611 	/* get information about protocols and packet types */
14612 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14613 		(uint8_t *)&proto_num, sizeof(proto_num),
14614 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14615 	if (ret || !proto_num)
14616 		goto no_print_return;
14617 
14618 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14619 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14620 	if (!proto)
14621 		goto no_print_return;
14622 
14623 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14624 					buff_size,
14625 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14626 	if (!ret) {
14627 		printf("List of used protocols:\n");
14628 		for (i = 0; i < proto_num; i++)
14629 			printf("  %2u: %s\n", proto[i].proto_id,
14630 			       proto[i].name);
14631 		printf("\n");
14632 	}
14633 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14634 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14635 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14636 	if (ret || !pctype_num)
14637 		goto no_print_pctypes;
14638 
14639 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14640 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14641 	if (!pctype)
14642 		goto no_print_pctypes;
14643 
14644 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14645 					buff_size,
14646 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14647 	if (ret) {
14648 		free(pctype);
14649 		goto no_print_pctypes;
14650 	}
14651 
14652 	printf("List of defined packet classification types:\n");
14653 	for (i = 0; i < pctype_num; i++) {
14654 		printf("  %2u:", pctype[i].ptype_id);
14655 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14656 			proto_id = pctype[i].protocols[j];
14657 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14658 				for (n = 0; n < proto_num; n++) {
14659 					if (proto[n].proto_id == proto_id) {
14660 						printf(" %s", proto[n].name);
14661 						break;
14662 					}
14663 				}
14664 			}
14665 		}
14666 		printf("\n");
14667 	}
14668 	printf("\n");
14669 	free(pctype);
14670 
14671 no_print_pctypes:
14672 
14673 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14674 					sizeof(ptype_num),
14675 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14676 	if (ret || !ptype_num)
14677 		goto no_print_return;
14678 
14679 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14680 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14681 	if (!ptype)
14682 		goto no_print_return;
14683 
14684 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14685 					buff_size,
14686 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14687 	if (ret) {
14688 		free(ptype);
14689 		goto no_print_return;
14690 	}
14691 	printf("List of defined packet types:\n");
14692 	for (i = 0; i < ptype_num; i++) {
14693 		printf("  %2u:", ptype[i].ptype_id);
14694 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14695 			proto_id = ptype[i].protocols[j];
14696 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14697 				for (n = 0; n < proto_num; n++) {
14698 					if (proto[n].proto_id == proto_id) {
14699 						printf(" %s", proto[n].name);
14700 						break;
14701 					}
14702 				}
14703 			}
14704 		}
14705 		printf("\n");
14706 	}
14707 	free(ptype);
14708 	printf("\n");
14709 
14710 	ret = 0;
14711 no_print_return:
14712 	if (proto)
14713 		free(proto);
14714 #endif
14715 	if (ret == -ENOTSUP)
14716 		fprintf(stderr, "Function not supported in PMD\n");
14717 	close_file(pkg);
14718 }
14719 
14720 cmdline_parse_inst_t cmd_ddp_get_info = {
14721 	.f = cmd_ddp_info_parsed,
14722 	.data = NULL,
14723 	.help_str = "ddp get info <profile_path>",
14724 	.tokens = {
14725 		(void *)&cmd_ddp_info_ddp,
14726 		(void *)&cmd_ddp_info_get,
14727 		(void *)&cmd_ddp_info_info,
14728 		(void *)&cmd_ddp_info_filepath,
14729 		NULL,
14730 	},
14731 };
14732 
14733 /* Get dynamic device personalization profile info list*/
14734 #define PROFILE_INFO_SIZE 48
14735 #define MAX_PROFILE_NUM 16
14736 
14737 struct cmd_ddp_get_list_result {
14738 	cmdline_fixed_string_t ddp;
14739 	cmdline_fixed_string_t get;
14740 	cmdline_fixed_string_t list;
14741 	portid_t port_id;
14742 };
14743 
14744 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14745 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14746 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14747 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14748 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14749 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14750 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14751 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14752 		RTE_UINT16);
14753 
14754 static void
14755 cmd_ddp_get_list_parsed(
14756 	__rte_unused void *parsed_result,
14757 	__rte_unused struct cmdline *cl,
14758 	__rte_unused void *data)
14759 {
14760 #ifdef RTE_NET_I40E
14761 	struct cmd_ddp_get_list_result *res = parsed_result;
14762 	struct rte_pmd_i40e_profile_list *p_list;
14763 	struct rte_pmd_i40e_profile_info *p_info;
14764 	uint32_t p_num;
14765 	uint32_t size;
14766 	uint32_t i;
14767 #endif
14768 	int ret = -ENOTSUP;
14769 
14770 #ifdef RTE_NET_I40E
14771 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14772 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14773 	if (!p_list) {
14774 		fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14775 		return;
14776 	}
14777 
14778 	if (ret == -ENOTSUP)
14779 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14780 						(uint8_t *)p_list, size);
14781 
14782 	if (!ret) {
14783 		p_num = p_list->p_count;
14784 		printf("Profile number is: %d\n\n", p_num);
14785 
14786 		for (i = 0; i < p_num; i++) {
14787 			p_info = &p_list->p_info[i];
14788 			printf("Profile %d:\n", i);
14789 			printf("Track id:     0x%x\n", p_info->track_id);
14790 			printf("Version:      %d.%d.%d.%d\n",
14791 			       p_info->version.major,
14792 			       p_info->version.minor,
14793 			       p_info->version.update,
14794 			       p_info->version.draft);
14795 			printf("Profile name: %s\n\n", p_info->name);
14796 		}
14797 	}
14798 
14799 	free(p_list);
14800 #endif
14801 
14802 	if (ret < 0)
14803 		fprintf(stderr, "Failed to get ddp list\n");
14804 }
14805 
14806 cmdline_parse_inst_t cmd_ddp_get_list = {
14807 	.f = cmd_ddp_get_list_parsed,
14808 	.data = NULL,
14809 	.help_str = "ddp get list <port_id>",
14810 	.tokens = {
14811 		(void *)&cmd_ddp_get_list_ddp,
14812 		(void *)&cmd_ddp_get_list_get,
14813 		(void *)&cmd_ddp_get_list_list,
14814 		(void *)&cmd_ddp_get_list_port_id,
14815 		NULL,
14816 	},
14817 };
14818 
14819 /* Configure input set */
14820 struct cmd_cfg_input_set_result {
14821 	cmdline_fixed_string_t port;
14822 	cmdline_fixed_string_t cfg;
14823 	portid_t port_id;
14824 	cmdline_fixed_string_t pctype;
14825 	uint8_t pctype_id;
14826 	cmdline_fixed_string_t inset_type;
14827 	cmdline_fixed_string_t opt;
14828 	cmdline_fixed_string_t field;
14829 	uint8_t field_idx;
14830 };
14831 
14832 static void
14833 cmd_cfg_input_set_parsed(
14834 	__rte_unused void *parsed_result,
14835 	__rte_unused struct cmdline *cl,
14836 	__rte_unused void *data)
14837 {
14838 #ifdef RTE_NET_I40E
14839 	struct cmd_cfg_input_set_result *res = parsed_result;
14840 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14841 	struct rte_pmd_i40e_inset inset;
14842 #endif
14843 	int ret = -ENOTSUP;
14844 
14845 	if (!all_ports_stopped()) {
14846 		fprintf(stderr, "Please stop all ports first\n");
14847 		return;
14848 	}
14849 
14850 #ifdef RTE_NET_I40E
14851 	if (!strcmp(res->inset_type, "hash_inset"))
14852 		inset_type = INSET_HASH;
14853 	else if (!strcmp(res->inset_type, "fdir_inset"))
14854 		inset_type = INSET_FDIR;
14855 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14856 		inset_type = INSET_FDIR_FLX;
14857 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14858 				     &inset, inset_type);
14859 	if (ret) {
14860 		fprintf(stderr, "Failed to get input set.\n");
14861 		return;
14862 	}
14863 
14864 	if (!strcmp(res->opt, "get")) {
14865 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14866 						   res->field_idx);
14867 		if (ret)
14868 			printf("Field index %d is enabled.\n", res->field_idx);
14869 		else
14870 			printf("Field index %d is disabled.\n", res->field_idx);
14871 		return;
14872 	} else if (!strcmp(res->opt, "set"))
14873 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14874 						   res->field_idx);
14875 	else if (!strcmp(res->opt, "clear"))
14876 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14877 						     res->field_idx);
14878 	if (ret) {
14879 		fprintf(stderr, "Failed to configure input set field.\n");
14880 		return;
14881 	}
14882 
14883 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14884 				     &inset, inset_type);
14885 	if (ret) {
14886 		fprintf(stderr, "Failed to set input set.\n");
14887 		return;
14888 	}
14889 #endif
14890 
14891 	if (ret == -ENOTSUP)
14892 		fprintf(stderr, "Function not supported\n");
14893 }
14894 
14895 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14896 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14897 				 port, "port");
14898 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14899 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14900 				 cfg, "config");
14901 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14902 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14903 			      port_id, RTE_UINT16);
14904 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14905 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14906 				 pctype, "pctype");
14907 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14908 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14909 			      pctype_id, RTE_UINT8);
14910 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14911 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14912 				 inset_type,
14913 				 "hash_inset#fdir_inset#fdir_flx_inset");
14914 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14915 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14916 				 opt, "get#set#clear");
14917 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14918 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14919 				 field, "field");
14920 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14921 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14922 			      field_idx, RTE_UINT8);
14923 
14924 cmdline_parse_inst_t cmd_cfg_input_set = {
14925 	.f = cmd_cfg_input_set_parsed,
14926 	.data = NULL,
14927 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14928 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14929 	.tokens = {
14930 		(void *)&cmd_cfg_input_set_port,
14931 		(void *)&cmd_cfg_input_set_cfg,
14932 		(void *)&cmd_cfg_input_set_port_id,
14933 		(void *)&cmd_cfg_input_set_pctype,
14934 		(void *)&cmd_cfg_input_set_pctype_id,
14935 		(void *)&cmd_cfg_input_set_inset_type,
14936 		(void *)&cmd_cfg_input_set_opt,
14937 		(void *)&cmd_cfg_input_set_field,
14938 		(void *)&cmd_cfg_input_set_field_idx,
14939 		NULL,
14940 	},
14941 };
14942 
14943 /* Clear input set */
14944 struct cmd_clear_input_set_result {
14945 	cmdline_fixed_string_t port;
14946 	cmdline_fixed_string_t cfg;
14947 	portid_t port_id;
14948 	cmdline_fixed_string_t pctype;
14949 	uint8_t pctype_id;
14950 	cmdline_fixed_string_t inset_type;
14951 	cmdline_fixed_string_t clear;
14952 	cmdline_fixed_string_t all;
14953 };
14954 
14955 static void
14956 cmd_clear_input_set_parsed(
14957 	__rte_unused void *parsed_result,
14958 	__rte_unused struct cmdline *cl,
14959 	__rte_unused void *data)
14960 {
14961 #ifdef RTE_NET_I40E
14962 	struct cmd_clear_input_set_result *res = parsed_result;
14963 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14964 	struct rte_pmd_i40e_inset inset;
14965 #endif
14966 	int ret = -ENOTSUP;
14967 
14968 	if (!all_ports_stopped()) {
14969 		fprintf(stderr, "Please stop all ports first\n");
14970 		return;
14971 	}
14972 
14973 #ifdef RTE_NET_I40E
14974 	if (!strcmp(res->inset_type, "hash_inset"))
14975 		inset_type = INSET_HASH;
14976 	else if (!strcmp(res->inset_type, "fdir_inset"))
14977 		inset_type = INSET_FDIR;
14978 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14979 		inset_type = INSET_FDIR_FLX;
14980 
14981 	memset(&inset, 0, sizeof(inset));
14982 
14983 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14984 				     &inset, inset_type);
14985 	if (ret) {
14986 		fprintf(stderr, "Failed to clear input set.\n");
14987 		return;
14988 	}
14989 
14990 #endif
14991 
14992 	if (ret == -ENOTSUP)
14993 		fprintf(stderr, "Function not supported\n");
14994 }
14995 
14996 cmdline_parse_token_string_t cmd_clear_input_set_port =
14997 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14998 				 port, "port");
14999 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15000 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15001 				 cfg, "config");
15002 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15003 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15004 			      port_id, RTE_UINT16);
15005 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15006 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15007 				 pctype, "pctype");
15008 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15009 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15010 			      pctype_id, RTE_UINT8);
15011 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15012 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15013 				 inset_type,
15014 				 "hash_inset#fdir_inset#fdir_flx_inset");
15015 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15016 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15017 				 clear, "clear");
15018 cmdline_parse_token_string_t cmd_clear_input_set_all =
15019 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15020 				 all, "all");
15021 
15022 cmdline_parse_inst_t cmd_clear_input_set = {
15023 	.f = cmd_clear_input_set_parsed,
15024 	.data = NULL,
15025 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15026 		    "fdir_inset|fdir_flx_inset clear all",
15027 	.tokens = {
15028 		(void *)&cmd_clear_input_set_port,
15029 		(void *)&cmd_clear_input_set_cfg,
15030 		(void *)&cmd_clear_input_set_port_id,
15031 		(void *)&cmd_clear_input_set_pctype,
15032 		(void *)&cmd_clear_input_set_pctype_id,
15033 		(void *)&cmd_clear_input_set_inset_type,
15034 		(void *)&cmd_clear_input_set_clear,
15035 		(void *)&cmd_clear_input_set_all,
15036 		NULL,
15037 	},
15038 };
15039 
15040 /* show vf stats */
15041 
15042 /* Common result structure for show vf stats */
15043 struct cmd_show_vf_stats_result {
15044 	cmdline_fixed_string_t show;
15045 	cmdline_fixed_string_t vf;
15046 	cmdline_fixed_string_t stats;
15047 	portid_t port_id;
15048 	uint16_t vf_id;
15049 };
15050 
15051 /* Common CLI fields show vf stats*/
15052 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15053 	TOKEN_STRING_INITIALIZER
15054 		(struct cmd_show_vf_stats_result,
15055 		 show, "show");
15056 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15057 	TOKEN_STRING_INITIALIZER
15058 		(struct cmd_show_vf_stats_result,
15059 		 vf, "vf");
15060 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15061 	TOKEN_STRING_INITIALIZER
15062 		(struct cmd_show_vf_stats_result,
15063 		 stats, "stats");
15064 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15065 	TOKEN_NUM_INITIALIZER
15066 		(struct cmd_show_vf_stats_result,
15067 		 port_id, RTE_UINT16);
15068 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15069 	TOKEN_NUM_INITIALIZER
15070 		(struct cmd_show_vf_stats_result,
15071 		 vf_id, RTE_UINT16);
15072 
15073 static void
15074 cmd_show_vf_stats_parsed(
15075 	void *parsed_result,
15076 	__rte_unused struct cmdline *cl,
15077 	__rte_unused void *data)
15078 {
15079 	struct cmd_show_vf_stats_result *res = parsed_result;
15080 	struct rte_eth_stats stats;
15081 	int ret = -ENOTSUP;
15082 	static const char *nic_stats_border = "########################";
15083 
15084 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15085 		return;
15086 
15087 	memset(&stats, 0, sizeof(stats));
15088 
15089 #ifdef RTE_NET_I40E
15090 	if (ret == -ENOTSUP)
15091 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15092 						res->vf_id,
15093 						&stats);
15094 #endif
15095 #ifdef RTE_NET_BNXT
15096 	if (ret == -ENOTSUP)
15097 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15098 						res->vf_id,
15099 						&stats);
15100 #endif
15101 
15102 	switch (ret) {
15103 	case 0:
15104 		break;
15105 	case -EINVAL:
15106 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15107 		break;
15108 	case -ENODEV:
15109 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15110 		break;
15111 	case -ENOTSUP:
15112 		fprintf(stderr, "function not implemented\n");
15113 		break;
15114 	default:
15115 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15116 	}
15117 
15118 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
15119 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15120 
15121 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
15122 	       "%-"PRIu64"\n",
15123 	       stats.ipackets, stats.imissed, stats.ibytes);
15124 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
15125 	printf("  RX-nombuf:  %-10"PRIu64"\n",
15126 	       stats.rx_nombuf);
15127 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
15128 	       "%-"PRIu64"\n",
15129 	       stats.opackets, stats.oerrors, stats.obytes);
15130 
15131 	printf("  %s############################%s\n",
15132 			       nic_stats_border, nic_stats_border);
15133 }
15134 
15135 cmdline_parse_inst_t cmd_show_vf_stats = {
15136 	.f = cmd_show_vf_stats_parsed,
15137 	.data = NULL,
15138 	.help_str = "show vf stats <port_id> <vf_id>",
15139 	.tokens = {
15140 		(void *)&cmd_show_vf_stats_show,
15141 		(void *)&cmd_show_vf_stats_vf,
15142 		(void *)&cmd_show_vf_stats_stats,
15143 		(void *)&cmd_show_vf_stats_port_id,
15144 		(void *)&cmd_show_vf_stats_vf_id,
15145 		NULL,
15146 	},
15147 };
15148 
15149 /* clear vf stats */
15150 
15151 /* Common result structure for clear vf stats */
15152 struct cmd_clear_vf_stats_result {
15153 	cmdline_fixed_string_t clear;
15154 	cmdline_fixed_string_t vf;
15155 	cmdline_fixed_string_t stats;
15156 	portid_t port_id;
15157 	uint16_t vf_id;
15158 };
15159 
15160 /* Common CLI fields clear vf stats*/
15161 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15162 	TOKEN_STRING_INITIALIZER
15163 		(struct cmd_clear_vf_stats_result,
15164 		 clear, "clear");
15165 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15166 	TOKEN_STRING_INITIALIZER
15167 		(struct cmd_clear_vf_stats_result,
15168 		 vf, "vf");
15169 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15170 	TOKEN_STRING_INITIALIZER
15171 		(struct cmd_clear_vf_stats_result,
15172 		 stats, "stats");
15173 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15174 	TOKEN_NUM_INITIALIZER
15175 		(struct cmd_clear_vf_stats_result,
15176 		 port_id, RTE_UINT16);
15177 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15178 	TOKEN_NUM_INITIALIZER
15179 		(struct cmd_clear_vf_stats_result,
15180 		 vf_id, RTE_UINT16);
15181 
15182 static void
15183 cmd_clear_vf_stats_parsed(
15184 	void *parsed_result,
15185 	__rte_unused struct cmdline *cl,
15186 	__rte_unused void *data)
15187 {
15188 	struct cmd_clear_vf_stats_result *res = parsed_result;
15189 	int ret = -ENOTSUP;
15190 
15191 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15192 		return;
15193 
15194 #ifdef RTE_NET_I40E
15195 	if (ret == -ENOTSUP)
15196 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15197 						  res->vf_id);
15198 #endif
15199 #ifdef RTE_NET_BNXT
15200 	if (ret == -ENOTSUP)
15201 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15202 						  res->vf_id);
15203 #endif
15204 
15205 	switch (ret) {
15206 	case 0:
15207 		break;
15208 	case -EINVAL:
15209 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15210 		break;
15211 	case -ENODEV:
15212 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15213 		break;
15214 	case -ENOTSUP:
15215 		fprintf(stderr, "function not implemented\n");
15216 		break;
15217 	default:
15218 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15219 	}
15220 }
15221 
15222 cmdline_parse_inst_t cmd_clear_vf_stats = {
15223 	.f = cmd_clear_vf_stats_parsed,
15224 	.data = NULL,
15225 	.help_str = "clear vf stats <port_id> <vf_id>",
15226 	.tokens = {
15227 		(void *)&cmd_clear_vf_stats_clear,
15228 		(void *)&cmd_clear_vf_stats_vf,
15229 		(void *)&cmd_clear_vf_stats_stats,
15230 		(void *)&cmd_clear_vf_stats_port_id,
15231 		(void *)&cmd_clear_vf_stats_vf_id,
15232 		NULL,
15233 	},
15234 };
15235 
15236 /* port config pctype mapping reset */
15237 
15238 /* Common result structure for port config pctype mapping reset */
15239 struct cmd_pctype_mapping_reset_result {
15240 	cmdline_fixed_string_t port;
15241 	cmdline_fixed_string_t config;
15242 	portid_t port_id;
15243 	cmdline_fixed_string_t pctype;
15244 	cmdline_fixed_string_t mapping;
15245 	cmdline_fixed_string_t reset;
15246 };
15247 
15248 /* Common CLI fields for port config pctype mapping reset*/
15249 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15250 	TOKEN_STRING_INITIALIZER
15251 		(struct cmd_pctype_mapping_reset_result,
15252 		 port, "port");
15253 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15254 	TOKEN_STRING_INITIALIZER
15255 		(struct cmd_pctype_mapping_reset_result,
15256 		 config, "config");
15257 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15258 	TOKEN_NUM_INITIALIZER
15259 		(struct cmd_pctype_mapping_reset_result,
15260 		 port_id, RTE_UINT16);
15261 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15262 	TOKEN_STRING_INITIALIZER
15263 		(struct cmd_pctype_mapping_reset_result,
15264 		 pctype, "pctype");
15265 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15266 	TOKEN_STRING_INITIALIZER
15267 		(struct cmd_pctype_mapping_reset_result,
15268 		 mapping, "mapping");
15269 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15270 	TOKEN_STRING_INITIALIZER
15271 		(struct cmd_pctype_mapping_reset_result,
15272 		 reset, "reset");
15273 
15274 static void
15275 cmd_pctype_mapping_reset_parsed(
15276 	void *parsed_result,
15277 	__rte_unused struct cmdline *cl,
15278 	__rte_unused void *data)
15279 {
15280 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15281 	int ret = -ENOTSUP;
15282 
15283 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15284 		return;
15285 
15286 #ifdef RTE_NET_I40E
15287 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15288 #endif
15289 
15290 	switch (ret) {
15291 	case 0:
15292 		break;
15293 	case -ENODEV:
15294 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15295 		break;
15296 	case -ENOTSUP:
15297 		fprintf(stderr, "function not implemented\n");
15298 		break;
15299 	default:
15300 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15301 	}
15302 }
15303 
15304 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15305 	.f = cmd_pctype_mapping_reset_parsed,
15306 	.data = NULL,
15307 	.help_str = "port config <port_id> pctype mapping reset",
15308 	.tokens = {
15309 		(void *)&cmd_pctype_mapping_reset_port,
15310 		(void *)&cmd_pctype_mapping_reset_config,
15311 		(void *)&cmd_pctype_mapping_reset_port_id,
15312 		(void *)&cmd_pctype_mapping_reset_pctype,
15313 		(void *)&cmd_pctype_mapping_reset_mapping,
15314 		(void *)&cmd_pctype_mapping_reset_reset,
15315 		NULL,
15316 	},
15317 };
15318 
15319 /* show port pctype mapping */
15320 
15321 /* Common result structure for show port pctype mapping */
15322 struct cmd_pctype_mapping_get_result {
15323 	cmdline_fixed_string_t show;
15324 	cmdline_fixed_string_t port;
15325 	portid_t port_id;
15326 	cmdline_fixed_string_t pctype;
15327 	cmdline_fixed_string_t mapping;
15328 };
15329 
15330 /* Common CLI fields for pctype mapping get */
15331 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15332 	TOKEN_STRING_INITIALIZER
15333 		(struct cmd_pctype_mapping_get_result,
15334 		 show, "show");
15335 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15336 	TOKEN_STRING_INITIALIZER
15337 		(struct cmd_pctype_mapping_get_result,
15338 		 port, "port");
15339 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15340 	TOKEN_NUM_INITIALIZER
15341 		(struct cmd_pctype_mapping_get_result,
15342 		 port_id, RTE_UINT16);
15343 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15344 	TOKEN_STRING_INITIALIZER
15345 		(struct cmd_pctype_mapping_get_result,
15346 		 pctype, "pctype");
15347 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15348 	TOKEN_STRING_INITIALIZER
15349 		(struct cmd_pctype_mapping_get_result,
15350 		 mapping, "mapping");
15351 
15352 static void
15353 cmd_pctype_mapping_get_parsed(
15354 	void *parsed_result,
15355 	__rte_unused struct cmdline *cl,
15356 	__rte_unused void *data)
15357 {
15358 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15359 	int ret = -ENOTSUP;
15360 #ifdef RTE_NET_I40E
15361 	struct rte_pmd_i40e_flow_type_mapping
15362 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15363 	int i, j, first_pctype;
15364 #endif
15365 
15366 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15367 		return;
15368 
15369 #ifdef RTE_NET_I40E
15370 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15371 #endif
15372 
15373 	switch (ret) {
15374 	case 0:
15375 		break;
15376 	case -ENODEV:
15377 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15378 		return;
15379 	case -ENOTSUP:
15380 		fprintf(stderr, "function not implemented\n");
15381 		return;
15382 	default:
15383 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15384 		return;
15385 	}
15386 
15387 #ifdef RTE_NET_I40E
15388 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15389 		if (mapping[i].pctype != 0ULL) {
15390 			first_pctype = 1;
15391 
15392 			printf("pctype: ");
15393 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15394 				if (mapping[i].pctype & (1ULL << j)) {
15395 					printf(first_pctype ?
15396 					       "%02d" : ",%02d", j);
15397 					first_pctype = 0;
15398 				}
15399 			}
15400 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15401 		}
15402 	}
15403 #endif
15404 }
15405 
15406 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15407 	.f = cmd_pctype_mapping_get_parsed,
15408 	.data = NULL,
15409 	.help_str = "show port <port_id> pctype mapping",
15410 	.tokens = {
15411 		(void *)&cmd_pctype_mapping_get_show,
15412 		(void *)&cmd_pctype_mapping_get_port,
15413 		(void *)&cmd_pctype_mapping_get_port_id,
15414 		(void *)&cmd_pctype_mapping_get_pctype,
15415 		(void *)&cmd_pctype_mapping_get_mapping,
15416 		NULL,
15417 	},
15418 };
15419 
15420 /* port config pctype mapping update */
15421 
15422 /* Common result structure for port config pctype mapping update */
15423 struct cmd_pctype_mapping_update_result {
15424 	cmdline_fixed_string_t port;
15425 	cmdline_fixed_string_t config;
15426 	portid_t port_id;
15427 	cmdline_fixed_string_t pctype;
15428 	cmdline_fixed_string_t mapping;
15429 	cmdline_fixed_string_t update;
15430 	cmdline_fixed_string_t pctype_list;
15431 	uint16_t flow_type;
15432 };
15433 
15434 /* Common CLI fields for pctype mapping update*/
15435 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15436 	TOKEN_STRING_INITIALIZER
15437 		(struct cmd_pctype_mapping_update_result,
15438 		 port, "port");
15439 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15440 	TOKEN_STRING_INITIALIZER
15441 		(struct cmd_pctype_mapping_update_result,
15442 		 config, "config");
15443 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15444 	TOKEN_NUM_INITIALIZER
15445 		(struct cmd_pctype_mapping_update_result,
15446 		 port_id, RTE_UINT16);
15447 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15448 	TOKEN_STRING_INITIALIZER
15449 		(struct cmd_pctype_mapping_update_result,
15450 		 pctype, "pctype");
15451 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15452 	TOKEN_STRING_INITIALIZER
15453 		(struct cmd_pctype_mapping_update_result,
15454 		 mapping, "mapping");
15455 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15456 	TOKEN_STRING_INITIALIZER
15457 		(struct cmd_pctype_mapping_update_result,
15458 		 update, "update");
15459 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15460 	TOKEN_STRING_INITIALIZER
15461 		(struct cmd_pctype_mapping_update_result,
15462 		 pctype_list, NULL);
15463 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15464 	TOKEN_NUM_INITIALIZER
15465 		(struct cmd_pctype_mapping_update_result,
15466 		 flow_type, RTE_UINT16);
15467 
15468 static void
15469 cmd_pctype_mapping_update_parsed(
15470 	void *parsed_result,
15471 	__rte_unused struct cmdline *cl,
15472 	__rte_unused void *data)
15473 {
15474 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15475 	int ret = -ENOTSUP;
15476 #ifdef RTE_NET_I40E
15477 	struct rte_pmd_i40e_flow_type_mapping mapping;
15478 	unsigned int i;
15479 	unsigned int nb_item;
15480 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15481 #endif
15482 
15483 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15484 		return;
15485 
15486 #ifdef RTE_NET_I40E
15487 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15488 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15489 	mapping.flow_type = res->flow_type;
15490 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15491 		mapping.pctype |= (1ULL << pctype_list[i]);
15492 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15493 						&mapping,
15494 						1,
15495 						0);
15496 #endif
15497 
15498 	switch (ret) {
15499 	case 0:
15500 		break;
15501 	case -EINVAL:
15502 		fprintf(stderr, "invalid pctype or flow type\n");
15503 		break;
15504 	case -ENODEV:
15505 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15506 		break;
15507 	case -ENOTSUP:
15508 		fprintf(stderr, "function not implemented\n");
15509 		break;
15510 	default:
15511 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15512 	}
15513 }
15514 
15515 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15516 	.f = cmd_pctype_mapping_update_parsed,
15517 	.data = NULL,
15518 	.help_str = "port config <port_id> pctype mapping update"
15519 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15520 	.tokens = {
15521 		(void *)&cmd_pctype_mapping_update_port,
15522 		(void *)&cmd_pctype_mapping_update_config,
15523 		(void *)&cmd_pctype_mapping_update_port_id,
15524 		(void *)&cmd_pctype_mapping_update_pctype,
15525 		(void *)&cmd_pctype_mapping_update_mapping,
15526 		(void *)&cmd_pctype_mapping_update_update,
15527 		(void *)&cmd_pctype_mapping_update_pc_type,
15528 		(void *)&cmd_pctype_mapping_update_flow_type,
15529 		NULL,
15530 	},
15531 };
15532 
15533 /* ptype mapping get */
15534 
15535 /* Common result structure for ptype mapping get */
15536 struct cmd_ptype_mapping_get_result {
15537 	cmdline_fixed_string_t ptype;
15538 	cmdline_fixed_string_t mapping;
15539 	cmdline_fixed_string_t get;
15540 	portid_t port_id;
15541 	uint8_t valid_only;
15542 };
15543 
15544 /* Common CLI fields for ptype mapping get */
15545 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15546 	TOKEN_STRING_INITIALIZER
15547 		(struct cmd_ptype_mapping_get_result,
15548 		 ptype, "ptype");
15549 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15550 	TOKEN_STRING_INITIALIZER
15551 		(struct cmd_ptype_mapping_get_result,
15552 		 mapping, "mapping");
15553 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15554 	TOKEN_STRING_INITIALIZER
15555 		(struct cmd_ptype_mapping_get_result,
15556 		 get, "get");
15557 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15558 	TOKEN_NUM_INITIALIZER
15559 		(struct cmd_ptype_mapping_get_result,
15560 		 port_id, RTE_UINT16);
15561 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15562 	TOKEN_NUM_INITIALIZER
15563 		(struct cmd_ptype_mapping_get_result,
15564 		 valid_only, RTE_UINT8);
15565 
15566 static void
15567 cmd_ptype_mapping_get_parsed(
15568 	void *parsed_result,
15569 	__rte_unused struct cmdline *cl,
15570 	__rte_unused void *data)
15571 {
15572 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15573 	int ret = -ENOTSUP;
15574 #ifdef RTE_NET_I40E
15575 	int max_ptype_num = 256;
15576 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15577 	uint16_t count;
15578 	int i;
15579 #endif
15580 
15581 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15582 		return;
15583 
15584 #ifdef RTE_NET_I40E
15585 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15586 					mapping,
15587 					max_ptype_num,
15588 					&count,
15589 					res->valid_only);
15590 #endif
15591 
15592 	switch (ret) {
15593 	case 0:
15594 		break;
15595 	case -ENODEV:
15596 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15597 		break;
15598 	case -ENOTSUP:
15599 		fprintf(stderr, "function not implemented\n");
15600 		break;
15601 	default:
15602 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15603 	}
15604 
15605 #ifdef RTE_NET_I40E
15606 	if (!ret) {
15607 		for (i = 0; i < count; i++)
15608 			printf("%3d\t0x%08x\n",
15609 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15610 	}
15611 #endif
15612 }
15613 
15614 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15615 	.f = cmd_ptype_mapping_get_parsed,
15616 	.data = NULL,
15617 	.help_str = "ptype mapping get <port_id> <valid_only>",
15618 	.tokens = {
15619 		(void *)&cmd_ptype_mapping_get_ptype,
15620 		(void *)&cmd_ptype_mapping_get_mapping,
15621 		(void *)&cmd_ptype_mapping_get_get,
15622 		(void *)&cmd_ptype_mapping_get_port_id,
15623 		(void *)&cmd_ptype_mapping_get_valid_only,
15624 		NULL,
15625 	},
15626 };
15627 
15628 /* ptype mapping replace */
15629 
15630 /* Common result structure for ptype mapping replace */
15631 struct cmd_ptype_mapping_replace_result {
15632 	cmdline_fixed_string_t ptype;
15633 	cmdline_fixed_string_t mapping;
15634 	cmdline_fixed_string_t replace;
15635 	portid_t port_id;
15636 	uint32_t target;
15637 	uint8_t mask;
15638 	uint32_t pkt_type;
15639 };
15640 
15641 /* Common CLI fields for ptype mapping replace */
15642 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15643 	TOKEN_STRING_INITIALIZER
15644 		(struct cmd_ptype_mapping_replace_result,
15645 		 ptype, "ptype");
15646 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15647 	TOKEN_STRING_INITIALIZER
15648 		(struct cmd_ptype_mapping_replace_result,
15649 		 mapping, "mapping");
15650 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15651 	TOKEN_STRING_INITIALIZER
15652 		(struct cmd_ptype_mapping_replace_result,
15653 		 replace, "replace");
15654 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15655 	TOKEN_NUM_INITIALIZER
15656 		(struct cmd_ptype_mapping_replace_result,
15657 		 port_id, RTE_UINT16);
15658 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15659 	TOKEN_NUM_INITIALIZER
15660 		(struct cmd_ptype_mapping_replace_result,
15661 		 target, RTE_UINT32);
15662 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15663 	TOKEN_NUM_INITIALIZER
15664 		(struct cmd_ptype_mapping_replace_result,
15665 		 mask, RTE_UINT8);
15666 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15667 	TOKEN_NUM_INITIALIZER
15668 		(struct cmd_ptype_mapping_replace_result,
15669 		 pkt_type, RTE_UINT32);
15670 
15671 static void
15672 cmd_ptype_mapping_replace_parsed(
15673 	void *parsed_result,
15674 	__rte_unused struct cmdline *cl,
15675 	__rte_unused void *data)
15676 {
15677 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15678 	int ret = -ENOTSUP;
15679 
15680 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15681 		return;
15682 
15683 #ifdef RTE_NET_I40E
15684 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15685 					res->target,
15686 					res->mask,
15687 					res->pkt_type);
15688 #endif
15689 
15690 	switch (ret) {
15691 	case 0:
15692 		break;
15693 	case -EINVAL:
15694 		fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15695 			res->target, res->pkt_type);
15696 		break;
15697 	case -ENODEV:
15698 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15699 		break;
15700 	case -ENOTSUP:
15701 		fprintf(stderr, "function not implemented\n");
15702 		break;
15703 	default:
15704 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15705 	}
15706 }
15707 
15708 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15709 	.f = cmd_ptype_mapping_replace_parsed,
15710 	.data = NULL,
15711 	.help_str =
15712 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15713 	.tokens = {
15714 		(void *)&cmd_ptype_mapping_replace_ptype,
15715 		(void *)&cmd_ptype_mapping_replace_mapping,
15716 		(void *)&cmd_ptype_mapping_replace_replace,
15717 		(void *)&cmd_ptype_mapping_replace_port_id,
15718 		(void *)&cmd_ptype_mapping_replace_target,
15719 		(void *)&cmd_ptype_mapping_replace_mask,
15720 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15721 		NULL,
15722 	},
15723 };
15724 
15725 /* ptype mapping reset */
15726 
15727 /* Common result structure for ptype mapping reset */
15728 struct cmd_ptype_mapping_reset_result {
15729 	cmdline_fixed_string_t ptype;
15730 	cmdline_fixed_string_t mapping;
15731 	cmdline_fixed_string_t reset;
15732 	portid_t port_id;
15733 };
15734 
15735 /* Common CLI fields for ptype mapping reset*/
15736 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15737 	TOKEN_STRING_INITIALIZER
15738 		(struct cmd_ptype_mapping_reset_result,
15739 		 ptype, "ptype");
15740 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15741 	TOKEN_STRING_INITIALIZER
15742 		(struct cmd_ptype_mapping_reset_result,
15743 		 mapping, "mapping");
15744 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15745 	TOKEN_STRING_INITIALIZER
15746 		(struct cmd_ptype_mapping_reset_result,
15747 		 reset, "reset");
15748 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15749 	TOKEN_NUM_INITIALIZER
15750 		(struct cmd_ptype_mapping_reset_result,
15751 		 port_id, RTE_UINT16);
15752 
15753 static void
15754 cmd_ptype_mapping_reset_parsed(
15755 	void *parsed_result,
15756 	__rte_unused struct cmdline *cl,
15757 	__rte_unused void *data)
15758 {
15759 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15760 	int ret = -ENOTSUP;
15761 
15762 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15763 		return;
15764 
15765 #ifdef RTE_NET_I40E
15766 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15767 #endif
15768 
15769 	switch (ret) {
15770 	case 0:
15771 		break;
15772 	case -ENODEV:
15773 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15774 		break;
15775 	case -ENOTSUP:
15776 		fprintf(stderr, "function not implemented\n");
15777 		break;
15778 	default:
15779 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15780 	}
15781 }
15782 
15783 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15784 	.f = cmd_ptype_mapping_reset_parsed,
15785 	.data = NULL,
15786 	.help_str = "ptype mapping reset <port_id>",
15787 	.tokens = {
15788 		(void *)&cmd_ptype_mapping_reset_ptype,
15789 		(void *)&cmd_ptype_mapping_reset_mapping,
15790 		(void *)&cmd_ptype_mapping_reset_reset,
15791 		(void *)&cmd_ptype_mapping_reset_port_id,
15792 		NULL,
15793 	},
15794 };
15795 
15796 /* ptype mapping update */
15797 
15798 /* Common result structure for ptype mapping update */
15799 struct cmd_ptype_mapping_update_result {
15800 	cmdline_fixed_string_t ptype;
15801 	cmdline_fixed_string_t mapping;
15802 	cmdline_fixed_string_t reset;
15803 	portid_t port_id;
15804 	uint8_t hw_ptype;
15805 	uint32_t sw_ptype;
15806 };
15807 
15808 /* Common CLI fields for ptype mapping update*/
15809 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15810 	TOKEN_STRING_INITIALIZER
15811 		(struct cmd_ptype_mapping_update_result,
15812 		 ptype, "ptype");
15813 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15814 	TOKEN_STRING_INITIALIZER
15815 		(struct cmd_ptype_mapping_update_result,
15816 		 mapping, "mapping");
15817 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15818 	TOKEN_STRING_INITIALIZER
15819 		(struct cmd_ptype_mapping_update_result,
15820 		 reset, "update");
15821 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15822 	TOKEN_NUM_INITIALIZER
15823 		(struct cmd_ptype_mapping_update_result,
15824 		 port_id, RTE_UINT16);
15825 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15826 	TOKEN_NUM_INITIALIZER
15827 		(struct cmd_ptype_mapping_update_result,
15828 		 hw_ptype, RTE_UINT8);
15829 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15830 	TOKEN_NUM_INITIALIZER
15831 		(struct cmd_ptype_mapping_update_result,
15832 		 sw_ptype, RTE_UINT32);
15833 
15834 static void
15835 cmd_ptype_mapping_update_parsed(
15836 	void *parsed_result,
15837 	__rte_unused struct cmdline *cl,
15838 	__rte_unused void *data)
15839 {
15840 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15841 	int ret = -ENOTSUP;
15842 #ifdef RTE_NET_I40E
15843 	struct rte_pmd_i40e_ptype_mapping mapping;
15844 #endif
15845 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15846 		return;
15847 
15848 #ifdef RTE_NET_I40E
15849 	mapping.hw_ptype = res->hw_ptype;
15850 	mapping.sw_ptype = res->sw_ptype;
15851 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15852 						&mapping,
15853 						1,
15854 						0);
15855 #endif
15856 
15857 	switch (ret) {
15858 	case 0:
15859 		break;
15860 	case -EINVAL:
15861 		fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15862 		break;
15863 	case -ENODEV:
15864 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15865 		break;
15866 	case -ENOTSUP:
15867 		fprintf(stderr, "function not implemented\n");
15868 		break;
15869 	default:
15870 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15871 	}
15872 }
15873 
15874 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15875 	.f = cmd_ptype_mapping_update_parsed,
15876 	.data = NULL,
15877 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15878 	.tokens = {
15879 		(void *)&cmd_ptype_mapping_update_ptype,
15880 		(void *)&cmd_ptype_mapping_update_mapping,
15881 		(void *)&cmd_ptype_mapping_update_update,
15882 		(void *)&cmd_ptype_mapping_update_port_id,
15883 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15884 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15885 		NULL,
15886 	},
15887 };
15888 
15889 /* Common result structure for file commands */
15890 struct cmd_cmdfile_result {
15891 	cmdline_fixed_string_t load;
15892 	cmdline_fixed_string_t filename;
15893 };
15894 
15895 /* Common CLI fields for file commands */
15896 cmdline_parse_token_string_t cmd_load_cmdfile =
15897 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15898 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15899 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15900 
15901 static void
15902 cmd_load_from_file_parsed(
15903 	void *parsed_result,
15904 	__rte_unused struct cmdline *cl,
15905 	__rte_unused void *data)
15906 {
15907 	struct cmd_cmdfile_result *res = parsed_result;
15908 
15909 	cmdline_read_from_file(res->filename);
15910 }
15911 
15912 cmdline_parse_inst_t cmd_load_from_file = {
15913 	.f = cmd_load_from_file_parsed,
15914 	.data = NULL,
15915 	.help_str = "load <filename>",
15916 	.tokens = {
15917 		(void *)&cmd_load_cmdfile,
15918 		(void *)&cmd_load_cmdfile_filename,
15919 		NULL,
15920 	},
15921 };
15922 
15923 /* Get Rx offloads capabilities */
15924 struct cmd_rx_offload_get_capa_result {
15925 	cmdline_fixed_string_t show;
15926 	cmdline_fixed_string_t port;
15927 	portid_t port_id;
15928 	cmdline_fixed_string_t rx_offload;
15929 	cmdline_fixed_string_t capabilities;
15930 };
15931 
15932 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15933 	TOKEN_STRING_INITIALIZER
15934 		(struct cmd_rx_offload_get_capa_result,
15935 		 show, "show");
15936 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15937 	TOKEN_STRING_INITIALIZER
15938 		(struct cmd_rx_offload_get_capa_result,
15939 		 port, "port");
15940 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15941 	TOKEN_NUM_INITIALIZER
15942 		(struct cmd_rx_offload_get_capa_result,
15943 		 port_id, RTE_UINT16);
15944 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15945 	TOKEN_STRING_INITIALIZER
15946 		(struct cmd_rx_offload_get_capa_result,
15947 		 rx_offload, "rx_offload");
15948 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15949 	TOKEN_STRING_INITIALIZER
15950 		(struct cmd_rx_offload_get_capa_result,
15951 		 capabilities, "capabilities");
15952 
15953 static void
15954 print_rx_offloads(uint64_t offloads)
15955 {
15956 	uint64_t single_offload;
15957 	int begin;
15958 	int end;
15959 	int bit;
15960 
15961 	if (offloads == 0)
15962 		return;
15963 
15964 	begin = __builtin_ctzll(offloads);
15965 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15966 
15967 	single_offload = 1ULL << begin;
15968 	for (bit = begin; bit < end; bit++) {
15969 		if (offloads & single_offload)
15970 			printf(" %s",
15971 			       rte_eth_dev_rx_offload_name(single_offload));
15972 		single_offload <<= 1;
15973 	}
15974 }
15975 
15976 static void
15977 cmd_rx_offload_get_capa_parsed(
15978 	void *parsed_result,
15979 	__rte_unused struct cmdline *cl,
15980 	__rte_unused void *data)
15981 {
15982 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
15983 	struct rte_eth_dev_info dev_info;
15984 	portid_t port_id = res->port_id;
15985 	uint64_t queue_offloads;
15986 	uint64_t port_offloads;
15987 	int ret;
15988 
15989 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15990 	if (ret != 0)
15991 		return;
15992 
15993 	queue_offloads = dev_info.rx_queue_offload_capa;
15994 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15995 
15996 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
15997 	printf("  Per Queue :");
15998 	print_rx_offloads(queue_offloads);
15999 
16000 	printf("\n");
16001 	printf("  Per Port  :");
16002 	print_rx_offloads(port_offloads);
16003 	printf("\n\n");
16004 }
16005 
16006 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16007 	.f = cmd_rx_offload_get_capa_parsed,
16008 	.data = NULL,
16009 	.help_str = "show port <port_id> rx_offload capabilities",
16010 	.tokens = {
16011 		(void *)&cmd_rx_offload_get_capa_show,
16012 		(void *)&cmd_rx_offload_get_capa_port,
16013 		(void *)&cmd_rx_offload_get_capa_port_id,
16014 		(void *)&cmd_rx_offload_get_capa_rx_offload,
16015 		(void *)&cmd_rx_offload_get_capa_capabilities,
16016 		NULL,
16017 	}
16018 };
16019 
16020 /* Get Rx offloads configuration */
16021 struct cmd_rx_offload_get_configuration_result {
16022 	cmdline_fixed_string_t show;
16023 	cmdline_fixed_string_t port;
16024 	portid_t port_id;
16025 	cmdline_fixed_string_t rx_offload;
16026 	cmdline_fixed_string_t configuration;
16027 };
16028 
16029 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16030 	TOKEN_STRING_INITIALIZER
16031 		(struct cmd_rx_offload_get_configuration_result,
16032 		 show, "show");
16033 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16034 	TOKEN_STRING_INITIALIZER
16035 		(struct cmd_rx_offload_get_configuration_result,
16036 		 port, "port");
16037 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16038 	TOKEN_NUM_INITIALIZER
16039 		(struct cmd_rx_offload_get_configuration_result,
16040 		 port_id, RTE_UINT16);
16041 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16042 	TOKEN_STRING_INITIALIZER
16043 		(struct cmd_rx_offload_get_configuration_result,
16044 		 rx_offload, "rx_offload");
16045 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16046 	TOKEN_STRING_INITIALIZER
16047 		(struct cmd_rx_offload_get_configuration_result,
16048 		 configuration, "configuration");
16049 
16050 static void
16051 cmd_rx_offload_get_configuration_parsed(
16052 	void *parsed_result,
16053 	__rte_unused struct cmdline *cl,
16054 	__rte_unused void *data)
16055 {
16056 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16057 	struct rte_eth_dev_info dev_info;
16058 	portid_t port_id = res->port_id;
16059 	struct rte_port *port = &ports[port_id];
16060 	struct rte_eth_conf dev_conf;
16061 	uint64_t port_offloads;
16062 	uint64_t queue_offloads;
16063 	uint16_t nb_rx_queues;
16064 	int q;
16065 	int ret;
16066 
16067 	printf("Rx Offloading Configuration of port %d :\n", port_id);
16068 
16069 	ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16070 	if (ret != 0)
16071 		return;
16072 
16073 	port_offloads = dev_conf.rxmode.offloads;
16074 	printf("  Port :");
16075 	print_rx_offloads(port_offloads);
16076 	printf("\n");
16077 
16078 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16079 	if (ret != 0)
16080 		return;
16081 
16082 	nb_rx_queues = dev_info.nb_rx_queues;
16083 	for (q = 0; q < nb_rx_queues; q++) {
16084 		queue_offloads = port->rx_conf[q].offloads;
16085 		printf("  Queue[%2d] :", q);
16086 		print_rx_offloads(queue_offloads);
16087 		printf("\n");
16088 	}
16089 	printf("\n");
16090 }
16091 
16092 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16093 	.f = cmd_rx_offload_get_configuration_parsed,
16094 	.data = NULL,
16095 	.help_str = "show port <port_id> rx_offload configuration",
16096 	.tokens = {
16097 		(void *)&cmd_rx_offload_get_configuration_show,
16098 		(void *)&cmd_rx_offload_get_configuration_port,
16099 		(void *)&cmd_rx_offload_get_configuration_port_id,
16100 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
16101 		(void *)&cmd_rx_offload_get_configuration_configuration,
16102 		NULL,
16103 	}
16104 };
16105 
16106 /* Enable/Disable a per port offloading */
16107 struct cmd_config_per_port_rx_offload_result {
16108 	cmdline_fixed_string_t port;
16109 	cmdline_fixed_string_t config;
16110 	portid_t port_id;
16111 	cmdline_fixed_string_t rx_offload;
16112 	cmdline_fixed_string_t offload;
16113 	cmdline_fixed_string_t on_off;
16114 };
16115 
16116 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16117 	TOKEN_STRING_INITIALIZER
16118 		(struct cmd_config_per_port_rx_offload_result,
16119 		 port, "port");
16120 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16121 	TOKEN_STRING_INITIALIZER
16122 		(struct cmd_config_per_port_rx_offload_result,
16123 		 config, "config");
16124 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16125 	TOKEN_NUM_INITIALIZER
16126 		(struct cmd_config_per_port_rx_offload_result,
16127 		 port_id, RTE_UINT16);
16128 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16129 	TOKEN_STRING_INITIALIZER
16130 		(struct cmd_config_per_port_rx_offload_result,
16131 		 rx_offload, "rx_offload");
16132 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16133 	TOKEN_STRING_INITIALIZER
16134 		(struct cmd_config_per_port_rx_offload_result,
16135 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16136 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16137 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16138 			   "scatter#buffer_split#timestamp#security#"
16139 			   "keep_crc#rss_hash");
16140 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16141 	TOKEN_STRING_INITIALIZER
16142 		(struct cmd_config_per_port_rx_offload_result,
16143 		 on_off, "on#off");
16144 
16145 static uint64_t
16146 search_rx_offload(const char *name)
16147 {
16148 	uint64_t single_offload;
16149 	const char *single_name;
16150 	int found = 0;
16151 	unsigned int bit;
16152 
16153 	single_offload = 1;
16154 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16155 		single_name = rte_eth_dev_rx_offload_name(single_offload);
16156 		if (!strcasecmp(single_name, name)) {
16157 			found = 1;
16158 			break;
16159 		}
16160 		single_offload <<= 1;
16161 	}
16162 
16163 	if (found)
16164 		return single_offload;
16165 
16166 	return 0;
16167 }
16168 
16169 static void
16170 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16171 				__rte_unused struct cmdline *cl,
16172 				__rte_unused void *data)
16173 {
16174 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16175 	portid_t port_id = res->port_id;
16176 	struct rte_eth_dev_info dev_info;
16177 	struct rte_port *port = &ports[port_id];
16178 	uint64_t single_offload;
16179 	uint16_t nb_rx_queues;
16180 	int q;
16181 	int ret;
16182 
16183 	if (port->port_status != RTE_PORT_STOPPED) {
16184 		fprintf(stderr,
16185 			"Error: Can't config offload when Port %d is not stopped\n",
16186 			port_id);
16187 		return;
16188 	}
16189 
16190 	single_offload = search_rx_offload(res->offload);
16191 	if (single_offload == 0) {
16192 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16193 		return;
16194 	}
16195 
16196 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16197 	if (ret != 0)
16198 		return;
16199 
16200 	nb_rx_queues = dev_info.nb_rx_queues;
16201 	if (!strcmp(res->on_off, "on")) {
16202 		port->dev_conf.rxmode.offloads |= single_offload;
16203 		for (q = 0; q < nb_rx_queues; q++)
16204 			port->rx_conf[q].offloads |= single_offload;
16205 	} else {
16206 		port->dev_conf.rxmode.offloads &= ~single_offload;
16207 		for (q = 0; q < nb_rx_queues; q++)
16208 			port->rx_conf[q].offloads &= ~single_offload;
16209 	}
16210 
16211 	cmd_reconfig_device_queue(port_id, 1, 1);
16212 }
16213 
16214 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16215 	.f = cmd_config_per_port_rx_offload_parsed,
16216 	.data = NULL,
16217 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16218 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16219 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16220 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16221 		    "keep_crc|rss_hash on|off",
16222 	.tokens = {
16223 		(void *)&cmd_config_per_port_rx_offload_result_port,
16224 		(void *)&cmd_config_per_port_rx_offload_result_config,
16225 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
16226 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16227 		(void *)&cmd_config_per_port_rx_offload_result_offload,
16228 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
16229 		NULL,
16230 	}
16231 };
16232 
16233 /* Enable/Disable a per queue offloading */
16234 struct cmd_config_per_queue_rx_offload_result {
16235 	cmdline_fixed_string_t port;
16236 	portid_t port_id;
16237 	cmdline_fixed_string_t rxq;
16238 	uint16_t queue_id;
16239 	cmdline_fixed_string_t rx_offload;
16240 	cmdline_fixed_string_t offload;
16241 	cmdline_fixed_string_t on_off;
16242 };
16243 
16244 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16245 	TOKEN_STRING_INITIALIZER
16246 		(struct cmd_config_per_queue_rx_offload_result,
16247 		 port, "port");
16248 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16249 	TOKEN_NUM_INITIALIZER
16250 		(struct cmd_config_per_queue_rx_offload_result,
16251 		 port_id, RTE_UINT16);
16252 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16253 	TOKEN_STRING_INITIALIZER
16254 		(struct cmd_config_per_queue_rx_offload_result,
16255 		 rxq, "rxq");
16256 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16257 	TOKEN_NUM_INITIALIZER
16258 		(struct cmd_config_per_queue_rx_offload_result,
16259 		 queue_id, RTE_UINT16);
16260 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16261 	TOKEN_STRING_INITIALIZER
16262 		(struct cmd_config_per_queue_rx_offload_result,
16263 		 rx_offload, "rx_offload");
16264 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16265 	TOKEN_STRING_INITIALIZER
16266 		(struct cmd_config_per_queue_rx_offload_result,
16267 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16268 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16269 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16270 			   "scatter#buffer_split#timestamp#security#keep_crc");
16271 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16272 	TOKEN_STRING_INITIALIZER
16273 		(struct cmd_config_per_queue_rx_offload_result,
16274 		 on_off, "on#off");
16275 
16276 static void
16277 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16278 				__rte_unused struct cmdline *cl,
16279 				__rte_unused void *data)
16280 {
16281 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16282 	struct rte_eth_dev_info dev_info;
16283 	portid_t port_id = res->port_id;
16284 	uint16_t queue_id = res->queue_id;
16285 	struct rte_port *port = &ports[port_id];
16286 	uint64_t single_offload;
16287 	int ret;
16288 
16289 	if (port->port_status != RTE_PORT_STOPPED) {
16290 		fprintf(stderr,
16291 			"Error: Can't config offload when Port %d is not stopped\n",
16292 			port_id);
16293 		return;
16294 	}
16295 
16296 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16297 	if (ret != 0)
16298 		return;
16299 
16300 	if (queue_id >= dev_info.nb_rx_queues) {
16301 		fprintf(stderr,
16302 			"Error: input queue_id should be 0 ... %d\n",
16303 			dev_info.nb_rx_queues - 1);
16304 		return;
16305 	}
16306 
16307 	single_offload = search_rx_offload(res->offload);
16308 	if (single_offload == 0) {
16309 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16310 		return;
16311 	}
16312 
16313 	if (!strcmp(res->on_off, "on"))
16314 		port->rx_conf[queue_id].offloads |= single_offload;
16315 	else
16316 		port->rx_conf[queue_id].offloads &= ~single_offload;
16317 
16318 	cmd_reconfig_device_queue(port_id, 1, 1);
16319 }
16320 
16321 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16322 	.f = cmd_config_per_queue_rx_offload_parsed,
16323 	.data = NULL,
16324 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
16325 		    "vlan_strip|ipv4_cksum|"
16326 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16327 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16328 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16329 		    "keep_crc on|off",
16330 	.tokens = {
16331 		(void *)&cmd_config_per_queue_rx_offload_result_port,
16332 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
16333 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
16334 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16335 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16336 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
16337 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
16338 		NULL,
16339 	}
16340 };
16341 
16342 /* Get Tx offloads capabilities */
16343 struct cmd_tx_offload_get_capa_result {
16344 	cmdline_fixed_string_t show;
16345 	cmdline_fixed_string_t port;
16346 	portid_t port_id;
16347 	cmdline_fixed_string_t tx_offload;
16348 	cmdline_fixed_string_t capabilities;
16349 };
16350 
16351 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16352 	TOKEN_STRING_INITIALIZER
16353 		(struct cmd_tx_offload_get_capa_result,
16354 		 show, "show");
16355 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16356 	TOKEN_STRING_INITIALIZER
16357 		(struct cmd_tx_offload_get_capa_result,
16358 		 port, "port");
16359 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16360 	TOKEN_NUM_INITIALIZER
16361 		(struct cmd_tx_offload_get_capa_result,
16362 		 port_id, RTE_UINT16);
16363 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16364 	TOKEN_STRING_INITIALIZER
16365 		(struct cmd_tx_offload_get_capa_result,
16366 		 tx_offload, "tx_offload");
16367 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16368 	TOKEN_STRING_INITIALIZER
16369 		(struct cmd_tx_offload_get_capa_result,
16370 		 capabilities, "capabilities");
16371 
16372 static void
16373 print_tx_offloads(uint64_t offloads)
16374 {
16375 	uint64_t single_offload;
16376 	int begin;
16377 	int end;
16378 	int bit;
16379 
16380 	if (offloads == 0)
16381 		return;
16382 
16383 	begin = __builtin_ctzll(offloads);
16384 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16385 
16386 	single_offload = 1ULL << begin;
16387 	for (bit = begin; bit < end; bit++) {
16388 		if (offloads & single_offload)
16389 			printf(" %s",
16390 			       rte_eth_dev_tx_offload_name(single_offload));
16391 		single_offload <<= 1;
16392 	}
16393 }
16394 
16395 static void
16396 cmd_tx_offload_get_capa_parsed(
16397 	void *parsed_result,
16398 	__rte_unused struct cmdline *cl,
16399 	__rte_unused void *data)
16400 {
16401 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
16402 	struct rte_eth_dev_info dev_info;
16403 	portid_t port_id = res->port_id;
16404 	uint64_t queue_offloads;
16405 	uint64_t port_offloads;
16406 	int ret;
16407 
16408 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16409 	if (ret != 0)
16410 		return;
16411 
16412 	queue_offloads = dev_info.tx_queue_offload_capa;
16413 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16414 
16415 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
16416 	printf("  Per Queue :");
16417 	print_tx_offloads(queue_offloads);
16418 
16419 	printf("\n");
16420 	printf("  Per Port  :");
16421 	print_tx_offloads(port_offloads);
16422 	printf("\n\n");
16423 }
16424 
16425 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16426 	.f = cmd_tx_offload_get_capa_parsed,
16427 	.data = NULL,
16428 	.help_str = "show port <port_id> tx_offload capabilities",
16429 	.tokens = {
16430 		(void *)&cmd_tx_offload_get_capa_show,
16431 		(void *)&cmd_tx_offload_get_capa_port,
16432 		(void *)&cmd_tx_offload_get_capa_port_id,
16433 		(void *)&cmd_tx_offload_get_capa_tx_offload,
16434 		(void *)&cmd_tx_offload_get_capa_capabilities,
16435 		NULL,
16436 	}
16437 };
16438 
16439 /* Get Tx offloads configuration */
16440 struct cmd_tx_offload_get_configuration_result {
16441 	cmdline_fixed_string_t show;
16442 	cmdline_fixed_string_t port;
16443 	portid_t port_id;
16444 	cmdline_fixed_string_t tx_offload;
16445 	cmdline_fixed_string_t configuration;
16446 };
16447 
16448 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16449 	TOKEN_STRING_INITIALIZER
16450 		(struct cmd_tx_offload_get_configuration_result,
16451 		 show, "show");
16452 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16453 	TOKEN_STRING_INITIALIZER
16454 		(struct cmd_tx_offload_get_configuration_result,
16455 		 port, "port");
16456 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16457 	TOKEN_NUM_INITIALIZER
16458 		(struct cmd_tx_offload_get_configuration_result,
16459 		 port_id, RTE_UINT16);
16460 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16461 	TOKEN_STRING_INITIALIZER
16462 		(struct cmd_tx_offload_get_configuration_result,
16463 		 tx_offload, "tx_offload");
16464 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16465 	TOKEN_STRING_INITIALIZER
16466 		(struct cmd_tx_offload_get_configuration_result,
16467 		 configuration, "configuration");
16468 
16469 static void
16470 cmd_tx_offload_get_configuration_parsed(
16471 	void *parsed_result,
16472 	__rte_unused struct cmdline *cl,
16473 	__rte_unused void *data)
16474 {
16475 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16476 	struct rte_eth_dev_info dev_info;
16477 	portid_t port_id = res->port_id;
16478 	struct rte_port *port = &ports[port_id];
16479 	struct rte_eth_conf dev_conf;
16480 	uint64_t port_offloads;
16481 	uint64_t queue_offloads;
16482 	uint16_t nb_tx_queues;
16483 	int q;
16484 	int ret;
16485 
16486 	printf("Tx Offloading Configuration of port %d :\n", port_id);
16487 
16488 	ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16489 	if (ret != 0)
16490 		return;
16491 
16492 	port_offloads = dev_conf.txmode.offloads;
16493 	printf("  Port :");
16494 	print_tx_offloads(port_offloads);
16495 	printf("\n");
16496 
16497 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16498 	if (ret != 0)
16499 		return;
16500 
16501 	nb_tx_queues = dev_info.nb_tx_queues;
16502 	for (q = 0; q < nb_tx_queues; q++) {
16503 		queue_offloads = port->tx_conf[q].offloads;
16504 		printf("  Queue[%2d] :", q);
16505 		print_tx_offloads(queue_offloads);
16506 		printf("\n");
16507 	}
16508 	printf("\n");
16509 }
16510 
16511 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16512 	.f = cmd_tx_offload_get_configuration_parsed,
16513 	.data = NULL,
16514 	.help_str = "show port <port_id> tx_offload configuration",
16515 	.tokens = {
16516 		(void *)&cmd_tx_offload_get_configuration_show,
16517 		(void *)&cmd_tx_offload_get_configuration_port,
16518 		(void *)&cmd_tx_offload_get_configuration_port_id,
16519 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
16520 		(void *)&cmd_tx_offload_get_configuration_configuration,
16521 		NULL,
16522 	}
16523 };
16524 
16525 /* Enable/Disable a per port offloading */
16526 struct cmd_config_per_port_tx_offload_result {
16527 	cmdline_fixed_string_t port;
16528 	cmdline_fixed_string_t config;
16529 	portid_t port_id;
16530 	cmdline_fixed_string_t tx_offload;
16531 	cmdline_fixed_string_t offload;
16532 	cmdline_fixed_string_t on_off;
16533 };
16534 
16535 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16536 	TOKEN_STRING_INITIALIZER
16537 		(struct cmd_config_per_port_tx_offload_result,
16538 		 port, "port");
16539 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16540 	TOKEN_STRING_INITIALIZER
16541 		(struct cmd_config_per_port_tx_offload_result,
16542 		 config, "config");
16543 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16544 	TOKEN_NUM_INITIALIZER
16545 		(struct cmd_config_per_port_tx_offload_result,
16546 		 port_id, RTE_UINT16);
16547 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16548 	TOKEN_STRING_INITIALIZER
16549 		(struct cmd_config_per_port_tx_offload_result,
16550 		 tx_offload, "tx_offload");
16551 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16552 	TOKEN_STRING_INITIALIZER
16553 		(struct cmd_config_per_port_tx_offload_result,
16554 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16555 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16556 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16557 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16558 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16559 			  "send_on_timestamp");
16560 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16561 	TOKEN_STRING_INITIALIZER
16562 		(struct cmd_config_per_port_tx_offload_result,
16563 		 on_off, "on#off");
16564 
16565 static uint64_t
16566 search_tx_offload(const char *name)
16567 {
16568 	uint64_t single_offload;
16569 	const char *single_name;
16570 	int found = 0;
16571 	unsigned int bit;
16572 
16573 	single_offload = 1;
16574 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16575 		single_name = rte_eth_dev_tx_offload_name(single_offload);
16576 		if (single_name == NULL)
16577 			break;
16578 		if (!strcasecmp(single_name, name)) {
16579 			found = 1;
16580 			break;
16581 		} else if (!strcasecmp(single_name, "UNKNOWN"))
16582 			break;
16583 		single_offload <<= 1;
16584 	}
16585 
16586 	if (found)
16587 		return single_offload;
16588 
16589 	return 0;
16590 }
16591 
16592 static void
16593 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16594 				__rte_unused struct cmdline *cl,
16595 				__rte_unused void *data)
16596 {
16597 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16598 	portid_t port_id = res->port_id;
16599 	struct rte_eth_dev_info dev_info;
16600 	struct rte_port *port = &ports[port_id];
16601 	uint64_t single_offload;
16602 	uint16_t nb_tx_queues;
16603 	int q;
16604 	int ret;
16605 
16606 	if (port->port_status != RTE_PORT_STOPPED) {
16607 		fprintf(stderr,
16608 			"Error: Can't config offload when Port %d is not stopped\n",
16609 			port_id);
16610 		return;
16611 	}
16612 
16613 	single_offload = search_tx_offload(res->offload);
16614 	if (single_offload == 0) {
16615 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16616 		return;
16617 	}
16618 
16619 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16620 	if (ret != 0)
16621 		return;
16622 
16623 	nb_tx_queues = dev_info.nb_tx_queues;
16624 	if (!strcmp(res->on_off, "on")) {
16625 		port->dev_conf.txmode.offloads |= single_offload;
16626 		for (q = 0; q < nb_tx_queues; q++)
16627 			port->tx_conf[q].offloads |= single_offload;
16628 	} else {
16629 		port->dev_conf.txmode.offloads &= ~single_offload;
16630 		for (q = 0; q < nb_tx_queues; q++)
16631 			port->tx_conf[q].offloads &= ~single_offload;
16632 	}
16633 
16634 	cmd_reconfig_device_queue(port_id, 1, 1);
16635 }
16636 
16637 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16638 	.f = cmd_config_per_port_tx_offload_parsed,
16639 	.data = NULL,
16640 	.help_str = "port config <port_id> tx_offload "
16641 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16642 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16643 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16644 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16645 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16646 		    "send_on_timestamp on|off",
16647 	.tokens = {
16648 		(void *)&cmd_config_per_port_tx_offload_result_port,
16649 		(void *)&cmd_config_per_port_tx_offload_result_config,
16650 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
16651 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16652 		(void *)&cmd_config_per_port_tx_offload_result_offload,
16653 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
16654 		NULL,
16655 	}
16656 };
16657 
16658 /* Enable/Disable a per queue offloading */
16659 struct cmd_config_per_queue_tx_offload_result {
16660 	cmdline_fixed_string_t port;
16661 	portid_t port_id;
16662 	cmdline_fixed_string_t txq;
16663 	uint16_t queue_id;
16664 	cmdline_fixed_string_t tx_offload;
16665 	cmdline_fixed_string_t offload;
16666 	cmdline_fixed_string_t on_off;
16667 };
16668 
16669 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16670 	TOKEN_STRING_INITIALIZER
16671 		(struct cmd_config_per_queue_tx_offload_result,
16672 		 port, "port");
16673 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16674 	TOKEN_NUM_INITIALIZER
16675 		(struct cmd_config_per_queue_tx_offload_result,
16676 		 port_id, RTE_UINT16);
16677 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16678 	TOKEN_STRING_INITIALIZER
16679 		(struct cmd_config_per_queue_tx_offload_result,
16680 		 txq, "txq");
16681 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16682 	TOKEN_NUM_INITIALIZER
16683 		(struct cmd_config_per_queue_tx_offload_result,
16684 		 queue_id, RTE_UINT16);
16685 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16686 	TOKEN_STRING_INITIALIZER
16687 		(struct cmd_config_per_queue_tx_offload_result,
16688 		 tx_offload, "tx_offload");
16689 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16690 	TOKEN_STRING_INITIALIZER
16691 		(struct cmd_config_per_queue_tx_offload_result,
16692 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16693 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16694 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16695 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16696 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
16697 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16698 	TOKEN_STRING_INITIALIZER
16699 		(struct cmd_config_per_queue_tx_offload_result,
16700 		 on_off, "on#off");
16701 
16702 static void
16703 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16704 				__rte_unused struct cmdline *cl,
16705 				__rte_unused void *data)
16706 {
16707 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16708 	struct rte_eth_dev_info dev_info;
16709 	portid_t port_id = res->port_id;
16710 	uint16_t queue_id = res->queue_id;
16711 	struct rte_port *port = &ports[port_id];
16712 	uint64_t single_offload;
16713 	int ret;
16714 
16715 	if (port->port_status != RTE_PORT_STOPPED) {
16716 		fprintf(stderr,
16717 			"Error: Can't config offload when Port %d is not stopped\n",
16718 			port_id);
16719 		return;
16720 	}
16721 
16722 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16723 	if (ret != 0)
16724 		return;
16725 
16726 	if (queue_id >= dev_info.nb_tx_queues) {
16727 		fprintf(stderr,
16728 			"Error: input queue_id should be 0 ... %d\n",
16729 			dev_info.nb_tx_queues - 1);
16730 		return;
16731 	}
16732 
16733 	single_offload = search_tx_offload(res->offload);
16734 	if (single_offload == 0) {
16735 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16736 		return;
16737 	}
16738 
16739 	if (!strcmp(res->on_off, "on"))
16740 		port->tx_conf[queue_id].offloads |= single_offload;
16741 	else
16742 		port->tx_conf[queue_id].offloads &= ~single_offload;
16743 
16744 	cmd_reconfig_device_queue(port_id, 1, 1);
16745 }
16746 
16747 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16748 	.f = cmd_config_per_queue_tx_offload_parsed,
16749 	.data = NULL,
16750 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16751 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16752 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16753 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16754 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16755 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16756 		    "on|off",
16757 	.tokens = {
16758 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16759 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16760 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16761 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16762 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16763 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16764 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16765 		NULL,
16766 	}
16767 };
16768 
16769 /* *** configure tx_metadata for specific port *** */
16770 struct cmd_config_tx_metadata_specific_result {
16771 	cmdline_fixed_string_t port;
16772 	cmdline_fixed_string_t keyword;
16773 	uint16_t port_id;
16774 	cmdline_fixed_string_t item;
16775 	uint32_t value;
16776 };
16777 
16778 static void
16779 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16780 				__rte_unused struct cmdline *cl,
16781 				__rte_unused void *data)
16782 {
16783 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16784 
16785 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16786 		return;
16787 	ports[res->port_id].tx_metadata = res->value;
16788 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16789 	if (ports[res->port_id].tx_metadata)
16790 		add_tx_md_callback(res->port_id);
16791 	else
16792 		remove_tx_md_callback(res->port_id);
16793 	rte_flow_dynf_metadata_register();
16794 }
16795 
16796 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16797 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16798 			port, "port");
16799 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16800 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16801 			keyword, "config");
16802 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16803 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16804 			port_id, RTE_UINT16);
16805 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16806 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16807 			item, "tx_metadata");
16808 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16809 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16810 			value, RTE_UINT32);
16811 
16812 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16813 	.f = cmd_config_tx_metadata_specific_parsed,
16814 	.data = NULL,
16815 	.help_str = "port config <port_id> tx_metadata <value>",
16816 	.tokens = {
16817 		(void *)&cmd_config_tx_metadata_specific_port,
16818 		(void *)&cmd_config_tx_metadata_specific_keyword,
16819 		(void *)&cmd_config_tx_metadata_specific_id,
16820 		(void *)&cmd_config_tx_metadata_specific_item,
16821 		(void *)&cmd_config_tx_metadata_specific_value,
16822 		NULL,
16823 	},
16824 };
16825 
16826 /* *** set dynf *** */
16827 struct cmd_config_tx_dynf_specific_result {
16828 	cmdline_fixed_string_t port;
16829 	cmdline_fixed_string_t keyword;
16830 	uint16_t port_id;
16831 	cmdline_fixed_string_t item;
16832 	cmdline_fixed_string_t name;
16833 	cmdline_fixed_string_t value;
16834 };
16835 
16836 static void
16837 cmd_config_dynf_specific_parsed(void *parsed_result,
16838 				__rte_unused struct cmdline *cl,
16839 				__rte_unused void *data)
16840 {
16841 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16842 	struct rte_mbuf_dynflag desc_flag;
16843 	int flag;
16844 	uint64_t old_port_flags;
16845 
16846 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16847 		return;
16848 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16849 	if (flag <= 0) {
16850 		if (strlcpy(desc_flag.name, res->name,
16851 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16852 			fprintf(stderr, "Flag name too long\n");
16853 			return;
16854 		}
16855 		desc_flag.flags = 0;
16856 		flag = rte_mbuf_dynflag_register(&desc_flag);
16857 		if (flag < 0) {
16858 			fprintf(stderr, "Can't register flag\n");
16859 			return;
16860 		}
16861 		strcpy(dynf_names[flag], desc_flag.name);
16862 	}
16863 	old_port_flags = ports[res->port_id].mbuf_dynf;
16864 	if (!strcmp(res->value, "set")) {
16865 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16866 		if (old_port_flags == 0)
16867 			add_tx_dynf_callback(res->port_id);
16868 	} else {
16869 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16870 		if (ports[res->port_id].mbuf_dynf == 0)
16871 			remove_tx_dynf_callback(res->port_id);
16872 	}
16873 }
16874 
16875 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16876 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16877 			keyword, "port");
16878 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16879 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16880 			keyword, "config");
16881 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16882 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16883 			port_id, RTE_UINT16);
16884 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16885 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16886 			item, "dynf");
16887 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16888 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16889 			name, NULL);
16890 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16891 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16892 			value, "set#clear");
16893 
16894 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16895 	.f = cmd_config_dynf_specific_parsed,
16896 	.data = NULL,
16897 	.help_str = "port config <port id> dynf <name> set|clear",
16898 	.tokens = {
16899 		(void *)&cmd_config_tx_dynf_specific_port,
16900 		(void *)&cmd_config_tx_dynf_specific_keyword,
16901 		(void *)&cmd_config_tx_dynf_specific_port_id,
16902 		(void *)&cmd_config_tx_dynf_specific_item,
16903 		(void *)&cmd_config_tx_dynf_specific_name,
16904 		(void *)&cmd_config_tx_dynf_specific_value,
16905 		NULL,
16906 	},
16907 };
16908 
16909 /* *** display tx_metadata per port configuration *** */
16910 struct cmd_show_tx_metadata_result {
16911 	cmdline_fixed_string_t cmd_show;
16912 	cmdline_fixed_string_t cmd_port;
16913 	cmdline_fixed_string_t cmd_keyword;
16914 	portid_t cmd_pid;
16915 };
16916 
16917 static void
16918 cmd_show_tx_metadata_parsed(void *parsed_result,
16919 		__rte_unused struct cmdline *cl,
16920 		__rte_unused void *data)
16921 {
16922 	struct cmd_show_tx_metadata_result *res = parsed_result;
16923 
16924 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16925 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16926 		return;
16927 	}
16928 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16929 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16930 		       ports[res->cmd_pid].tx_metadata);
16931 	}
16932 }
16933 
16934 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16935 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16936 			cmd_show, "show");
16937 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16938 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16939 			cmd_port, "port");
16940 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16941 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16942 			cmd_pid, RTE_UINT16);
16943 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16944 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16945 			cmd_keyword, "tx_metadata");
16946 
16947 cmdline_parse_inst_t cmd_show_tx_metadata = {
16948 	.f = cmd_show_tx_metadata_parsed,
16949 	.data = NULL,
16950 	.help_str = "show port <port_id> tx_metadata",
16951 	.tokens = {
16952 		(void *)&cmd_show_tx_metadata_show,
16953 		(void *)&cmd_show_tx_metadata_port,
16954 		(void *)&cmd_show_tx_metadata_pid,
16955 		(void *)&cmd_show_tx_metadata_keyword,
16956 		NULL,
16957 	},
16958 };
16959 
16960 /* *** show fec capability per port configuration *** */
16961 struct cmd_show_fec_capability_result {
16962 	cmdline_fixed_string_t cmd_show;
16963 	cmdline_fixed_string_t cmd_port;
16964 	cmdline_fixed_string_t cmd_fec;
16965 	cmdline_fixed_string_t cmd_keyword;
16966 	portid_t cmd_pid;
16967 };
16968 
16969 static void
16970 cmd_show_fec_capability_parsed(void *parsed_result,
16971 		__rte_unused struct cmdline *cl,
16972 		__rte_unused void *data)
16973 {
16974 	struct cmd_show_fec_capability_result *res = parsed_result;
16975 	struct rte_eth_fec_capa *speed_fec_capa;
16976 	unsigned int num;
16977 	int ret;
16978 
16979 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16980 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16981 		return;
16982 	}
16983 
16984 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16985 	if (ret == -ENOTSUP) {
16986 		fprintf(stderr, "Function not implemented\n");
16987 		return;
16988 	} else if (ret < 0) {
16989 		fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16990 		return;
16991 	}
16992 
16993 	num = (unsigned int)ret;
16994 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16995 	if (speed_fec_capa == NULL) {
16996 		fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16997 		return;
16998 	}
16999 
17000 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17001 	if (ret < 0) {
17002 		fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17003 		goto out;
17004 	}
17005 
17006 	show_fec_capability(num, speed_fec_capa);
17007 out:
17008 	free(speed_fec_capa);
17009 }
17010 
17011 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17012 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17013 			cmd_show, "show");
17014 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17015 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17016 			cmd_port, "port");
17017 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17018 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17019 			cmd_pid, RTE_UINT16);
17020 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17021 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17022 			cmd_fec, "fec");
17023 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17024 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17025 			cmd_keyword, "capabilities");
17026 
17027 cmdline_parse_inst_t cmd_show_capability = {
17028 	.f = cmd_show_fec_capability_parsed,
17029 	.data = NULL,
17030 	.help_str = "show port <port_id> fec capabilities",
17031 	.tokens = {
17032 		(void *)&cmd_show_fec_capability_show,
17033 		(void *)&cmd_show_fec_capability_port,
17034 		(void *)&cmd_show_fec_capability_pid,
17035 		(void *)&cmd_show_fec_capability_fec,
17036 		(void *)&cmd_show_fec_capability_keyword,
17037 		NULL,
17038 	},
17039 };
17040 
17041 /* *** show fec mode per port configuration *** */
17042 struct cmd_show_fec_metadata_result {
17043 	cmdline_fixed_string_t cmd_show;
17044 	cmdline_fixed_string_t cmd_port;
17045 	cmdline_fixed_string_t cmd_keyword;
17046 	portid_t cmd_pid;
17047 };
17048 
17049 static void
17050 cmd_show_fec_mode_parsed(void *parsed_result,
17051 		__rte_unused struct cmdline *cl,
17052 		__rte_unused void *data)
17053 {
17054 #define FEC_NAME_SIZE 16
17055 	struct cmd_show_fec_metadata_result *res = parsed_result;
17056 	uint32_t mode;
17057 	char buf[FEC_NAME_SIZE];
17058 	int ret;
17059 
17060 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17061 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17062 		return;
17063 	}
17064 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
17065 	if (ret == -ENOTSUP) {
17066 		fprintf(stderr, "Function not implemented\n");
17067 		return;
17068 	} else if (ret < 0) {
17069 		fprintf(stderr, "Get FEC mode failed\n");
17070 		return;
17071 	}
17072 
17073 	switch (mode) {
17074 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17075 		strlcpy(buf, "off", sizeof(buf));
17076 		break;
17077 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17078 		strlcpy(buf, "auto", sizeof(buf));
17079 		break;
17080 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17081 		strlcpy(buf, "baser", sizeof(buf));
17082 		break;
17083 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17084 		strlcpy(buf, "rs", sizeof(buf));
17085 		break;
17086 	default:
17087 		return;
17088 	}
17089 
17090 	printf("%s\n", buf);
17091 }
17092 
17093 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17094 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17095 			cmd_show, "show");
17096 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17097 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17098 			cmd_port, "port");
17099 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17100 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17101 			cmd_pid, RTE_UINT16);
17102 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17103 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17104 			cmd_keyword, "fec_mode");
17105 
17106 cmdline_parse_inst_t cmd_show_fec_mode = {
17107 	.f = cmd_show_fec_mode_parsed,
17108 	.data = NULL,
17109 	.help_str = "show port <port_id> fec_mode",
17110 	.tokens = {
17111 		(void *)&cmd_show_fec_mode_show,
17112 		(void *)&cmd_show_fec_mode_port,
17113 		(void *)&cmd_show_fec_mode_pid,
17114 		(void *)&cmd_show_fec_mode_keyword,
17115 		NULL,
17116 	},
17117 };
17118 
17119 /* *** set fec mode per port configuration *** */
17120 struct cmd_set_port_fec_mode {
17121 	cmdline_fixed_string_t set;
17122 	cmdline_fixed_string_t port;
17123 	portid_t port_id;
17124 	cmdline_fixed_string_t fec_mode;
17125 	cmdline_fixed_string_t fec_value;
17126 };
17127 
17128 /* Common CLI fields for set fec mode */
17129 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17130 	TOKEN_STRING_INITIALIZER
17131 		(struct cmd_set_port_fec_mode,
17132 		 set, "set");
17133 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17134 	TOKEN_STRING_INITIALIZER
17135 		(struct cmd_set_port_fec_mode,
17136 		 port, "port");
17137 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17138 	TOKEN_NUM_INITIALIZER
17139 		(struct cmd_set_port_fec_mode,
17140 		 port_id, RTE_UINT16);
17141 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17142 	TOKEN_STRING_INITIALIZER
17143 		(struct cmd_set_port_fec_mode,
17144 		 fec_mode, "fec_mode");
17145 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17146 	TOKEN_STRING_INITIALIZER
17147 		(struct cmd_set_port_fec_mode,
17148 		 fec_value, NULL);
17149 
17150 static void
17151 cmd_set_port_fec_mode_parsed(
17152 	void *parsed_result,
17153 	__rte_unused struct cmdline *cl,
17154 	__rte_unused void *data)
17155 {
17156 	struct cmd_set_port_fec_mode *res = parsed_result;
17157 	uint16_t port_id = res->port_id;
17158 	uint32_t fec_capa;
17159 	int ret;
17160 
17161 	ret = parse_fec_mode(res->fec_value, &fec_capa);
17162 	if (ret < 0) {
17163 		fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17164 				res->fec_value,	port_id);
17165 		return;
17166 	}
17167 
17168 	ret = rte_eth_fec_set(port_id, fec_capa);
17169 	if (ret == -ENOTSUP) {
17170 		fprintf(stderr, "Function not implemented\n");
17171 		return;
17172 	} else if (ret < 0) {
17173 		fprintf(stderr, "Set FEC mode failed\n");
17174 		return;
17175 	}
17176 }
17177 
17178 cmdline_parse_inst_t cmd_set_fec_mode = {
17179 	.f = cmd_set_port_fec_mode_parsed,
17180 	.data = NULL,
17181 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17182 	.tokens = {
17183 		(void *)&cmd_set_port_fec_mode_set,
17184 		(void *)&cmd_set_port_fec_mode_port,
17185 		(void *)&cmd_set_port_fec_mode_port_id,
17186 		(void *)&cmd_set_port_fec_mode_str,
17187 		(void *)&cmd_set_port_fec_mode_value,
17188 		NULL,
17189 	},
17190 };
17191 
17192 /* show port supported ptypes */
17193 
17194 /* Common result structure for show port ptypes */
17195 struct cmd_show_port_supported_ptypes_result {
17196 	cmdline_fixed_string_t show;
17197 	cmdline_fixed_string_t port;
17198 	portid_t port_id;
17199 	cmdline_fixed_string_t ptypes;
17200 };
17201 
17202 /* Common CLI fields for show port ptypes */
17203 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17204 	TOKEN_STRING_INITIALIZER
17205 		(struct cmd_show_port_supported_ptypes_result,
17206 		 show, "show");
17207 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17208 	TOKEN_STRING_INITIALIZER
17209 		(struct cmd_show_port_supported_ptypes_result,
17210 		 port, "port");
17211 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17212 	TOKEN_NUM_INITIALIZER
17213 		(struct cmd_show_port_supported_ptypes_result,
17214 		 port_id, RTE_UINT16);
17215 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17216 	TOKEN_STRING_INITIALIZER
17217 		(struct cmd_show_port_supported_ptypes_result,
17218 		 ptypes, "ptypes");
17219 
17220 static void
17221 cmd_show_port_supported_ptypes_parsed(
17222 	void *parsed_result,
17223 	__rte_unused struct cmdline *cl,
17224 	__rte_unused void *data)
17225 {
17226 #define RSVD_PTYPE_MASK       0xf0000000
17227 #define MAX_PTYPES_PER_LAYER  16
17228 #define LTYPE_NAMESIZE        32
17229 #define PTYPE_NAMESIZE        256
17230 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17231 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17232 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17233 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17234 	uint16_t port_id = res->port_id;
17235 	int ret, i;
17236 
17237 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17238 	if (ret < 0)
17239 		return;
17240 
17241 	while (ptype_mask != RSVD_PTYPE_MASK) {
17242 
17243 		switch (ptype_mask) {
17244 		case RTE_PTYPE_L2_MASK:
17245 			strlcpy(ltype, "L2", sizeof(ltype));
17246 			break;
17247 		case RTE_PTYPE_L3_MASK:
17248 			strlcpy(ltype, "L3", sizeof(ltype));
17249 			break;
17250 		case RTE_PTYPE_L4_MASK:
17251 			strlcpy(ltype, "L4", sizeof(ltype));
17252 			break;
17253 		case RTE_PTYPE_TUNNEL_MASK:
17254 			strlcpy(ltype, "Tunnel", sizeof(ltype));
17255 			break;
17256 		case RTE_PTYPE_INNER_L2_MASK:
17257 			strlcpy(ltype, "Inner L2", sizeof(ltype));
17258 			break;
17259 		case RTE_PTYPE_INNER_L3_MASK:
17260 			strlcpy(ltype, "Inner L3", sizeof(ltype));
17261 			break;
17262 		case RTE_PTYPE_INNER_L4_MASK:
17263 			strlcpy(ltype, "Inner L4", sizeof(ltype));
17264 			break;
17265 		default:
17266 			return;
17267 		}
17268 
17269 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17270 						       ptype_mask, ptypes,
17271 						       MAX_PTYPES_PER_LAYER);
17272 
17273 		if (ret > 0)
17274 			printf("Supported %s ptypes:\n", ltype);
17275 		else
17276 			printf("%s ptypes unsupported\n", ltype);
17277 
17278 		for (i = 0; i < ret; ++i) {
17279 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17280 			printf("%s\n", buf);
17281 		}
17282 
17283 		ptype_mask <<= 4;
17284 	}
17285 }
17286 
17287 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17288 	.f = cmd_show_port_supported_ptypes_parsed,
17289 	.data = NULL,
17290 	.help_str = "show port <port_id> ptypes",
17291 	.tokens = {
17292 		(void *)&cmd_show_port_supported_ptypes_show,
17293 		(void *)&cmd_show_port_supported_ptypes_port,
17294 		(void *)&cmd_show_port_supported_ptypes_port_id,
17295 		(void *)&cmd_show_port_supported_ptypes_ptypes,
17296 		NULL,
17297 	},
17298 };
17299 
17300 /* *** display rx/tx descriptor status *** */
17301 struct cmd_show_rx_tx_desc_status_result {
17302 	cmdline_fixed_string_t cmd_show;
17303 	cmdline_fixed_string_t cmd_port;
17304 	cmdline_fixed_string_t cmd_keyword;
17305 	cmdline_fixed_string_t cmd_desc;
17306 	cmdline_fixed_string_t cmd_status;
17307 	portid_t cmd_pid;
17308 	portid_t cmd_qid;
17309 	portid_t cmd_did;
17310 };
17311 
17312 static void
17313 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17314 		__rte_unused struct cmdline *cl,
17315 		__rte_unused void *data)
17316 {
17317 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17318 	int rc;
17319 
17320 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17321 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17322 		return;
17323 	}
17324 
17325 	if (!strcmp(res->cmd_keyword, "rxq")) {
17326 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17327 					     res->cmd_did);
17328 		if (rc < 0) {
17329 			fprintf(stderr,
17330 				"Invalid input: queue id = %d, desc id = %d\n",
17331 				res->cmd_qid, res->cmd_did);
17332 			return;
17333 		}
17334 		if (rc == RTE_ETH_RX_DESC_AVAIL)
17335 			printf("Desc status = AVAILABLE\n");
17336 		else if (rc == RTE_ETH_RX_DESC_DONE)
17337 			printf("Desc status = DONE\n");
17338 		else
17339 			printf("Desc status = UNAVAILABLE\n");
17340 	} else if (!strcmp(res->cmd_keyword, "txq")) {
17341 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17342 					     res->cmd_did);
17343 		if (rc < 0) {
17344 			fprintf(stderr,
17345 				"Invalid input: queue id = %d, desc id = %d\n",
17346 				res->cmd_qid, res->cmd_did);
17347 			return;
17348 		}
17349 		if (rc == RTE_ETH_TX_DESC_FULL)
17350 			printf("Desc status = FULL\n");
17351 		else if (rc == RTE_ETH_TX_DESC_DONE)
17352 			printf("Desc status = DONE\n");
17353 		else
17354 			printf("Desc status = UNAVAILABLE\n");
17355 	}
17356 }
17357 
17358 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17359 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17360 			cmd_show, "show");
17361 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17362 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17363 			cmd_port, "port");
17364 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17365 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17366 			cmd_pid, RTE_UINT16);
17367 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17368 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17369 			cmd_keyword, "rxq#txq");
17370 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17371 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17372 			cmd_qid, RTE_UINT16);
17373 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17374 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17375 			cmd_desc, "desc");
17376 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17377 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17378 			cmd_did, RTE_UINT16);
17379 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17380 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17381 			cmd_status, "status");
17382 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17383 	.f = cmd_show_rx_tx_desc_status_parsed,
17384 	.data = NULL,
17385 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17386 		"status",
17387 	.tokens = {
17388 		(void *)&cmd_show_rx_tx_desc_status_show,
17389 		(void *)&cmd_show_rx_tx_desc_status_port,
17390 		(void *)&cmd_show_rx_tx_desc_status_pid,
17391 		(void *)&cmd_show_rx_tx_desc_status_keyword,
17392 		(void *)&cmd_show_rx_tx_desc_status_qid,
17393 		(void *)&cmd_show_rx_tx_desc_status_desc,
17394 		(void *)&cmd_show_rx_tx_desc_status_did,
17395 		(void *)&cmd_show_rx_tx_desc_status_status,
17396 		NULL,
17397 	},
17398 };
17399 
17400 /* *** display rx queue desc used count *** */
17401 struct cmd_show_rx_queue_desc_used_count_result {
17402 	cmdline_fixed_string_t cmd_show;
17403 	cmdline_fixed_string_t cmd_port;
17404 	cmdline_fixed_string_t cmd_rxq;
17405 	cmdline_fixed_string_t cmd_desc;
17406 	cmdline_fixed_string_t cmd_used;
17407 	cmdline_fixed_string_t cmd_count;
17408 	portid_t cmd_pid;
17409 	portid_t cmd_qid;
17410 };
17411 
17412 static void
17413 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17414 		__rte_unused struct cmdline *cl,
17415 		__rte_unused void *data)
17416 {
17417 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17418 	int rc;
17419 
17420 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17421 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17422 		return;
17423 	}
17424 
17425 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17426 	if (rc < 0) {
17427 		fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17428 		return;
17429 	}
17430 	printf("Used desc count = %d\n", rc);
17431 }
17432 
17433 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17434 	TOKEN_STRING_INITIALIZER
17435 		(struct cmd_show_rx_queue_desc_used_count_result,
17436 		 cmd_show, "show");
17437 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17438 	TOKEN_STRING_INITIALIZER
17439 		(struct cmd_show_rx_queue_desc_used_count_result,
17440 		 cmd_port, "port");
17441 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17442 	TOKEN_NUM_INITIALIZER
17443 		(struct cmd_show_rx_queue_desc_used_count_result,
17444 		 cmd_pid, RTE_UINT16);
17445 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17446 	TOKEN_STRING_INITIALIZER
17447 		(struct cmd_show_rx_queue_desc_used_count_result,
17448 		 cmd_rxq, "rxq");
17449 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17450 	TOKEN_NUM_INITIALIZER
17451 		(struct cmd_show_rx_queue_desc_used_count_result,
17452 		 cmd_qid, RTE_UINT16);
17453 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17454 	TOKEN_STRING_INITIALIZER
17455 		(struct cmd_show_rx_queue_desc_used_count_result,
17456 		 cmd_count, "desc");
17457 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17458 	TOKEN_STRING_INITIALIZER
17459 		(struct cmd_show_rx_queue_desc_used_count_result,
17460 		 cmd_count, "used");
17461 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17462 	TOKEN_STRING_INITIALIZER
17463 		(struct cmd_show_rx_queue_desc_used_count_result,
17464 		 cmd_count, "count");
17465 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17466 	.f = cmd_show_rx_queue_desc_used_count_parsed,
17467 	.data = NULL,
17468 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
17469 	.tokens = {
17470 		(void *)&cmd_show_rx_queue_desc_used_count_show,
17471 		(void *)&cmd_show_rx_queue_desc_used_count_port,
17472 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
17473 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
17474 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
17475 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
17476 		(void *)&cmd_show_rx_queue_desc_used_count_used,
17477 		(void *)&cmd_show_rx_queue_desc_used_count_count,
17478 		NULL,
17479 	},
17480 };
17481 
17482 /* Common result structure for set port ptypes */
17483 struct cmd_set_port_ptypes_result {
17484 	cmdline_fixed_string_t set;
17485 	cmdline_fixed_string_t port;
17486 	portid_t port_id;
17487 	cmdline_fixed_string_t ptype_mask;
17488 	uint32_t mask;
17489 };
17490 
17491 /* Common CLI fields for set port ptypes */
17492 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17493 	TOKEN_STRING_INITIALIZER
17494 		(struct cmd_set_port_ptypes_result,
17495 		 set, "set");
17496 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17497 	TOKEN_STRING_INITIALIZER
17498 		(struct cmd_set_port_ptypes_result,
17499 		 port, "port");
17500 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17501 	TOKEN_NUM_INITIALIZER
17502 		(struct cmd_set_port_ptypes_result,
17503 		 port_id, RTE_UINT16);
17504 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17505 	TOKEN_STRING_INITIALIZER
17506 		(struct cmd_set_port_ptypes_result,
17507 		 ptype_mask, "ptype_mask");
17508 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17509 	TOKEN_NUM_INITIALIZER
17510 		(struct cmd_set_port_ptypes_result,
17511 		 mask, RTE_UINT32);
17512 
17513 static void
17514 cmd_set_port_ptypes_parsed(
17515 	void *parsed_result,
17516 	__rte_unused struct cmdline *cl,
17517 	__rte_unused void *data)
17518 {
17519 	struct cmd_set_port_ptypes_result *res = parsed_result;
17520 #define PTYPE_NAMESIZE        256
17521 	char ptype_name[PTYPE_NAMESIZE];
17522 	uint16_t port_id = res->port_id;
17523 	uint32_t ptype_mask = res->mask;
17524 	int ret, i;
17525 
17526 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17527 					       NULL, 0);
17528 	if (ret <= 0) {
17529 		fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17530 			port_id);
17531 		return;
17532 	}
17533 
17534 	uint32_t ptypes[ret];
17535 
17536 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17537 	if (ret < 0) {
17538 		fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17539 			port_id);
17540 		return;
17541 	}
17542 
17543 	printf("Successfully set following ptypes for Port %d\n", port_id);
17544 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17545 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17546 		printf("%s\n", ptype_name);
17547 	}
17548 
17549 	clear_ptypes = false;
17550 }
17551 
17552 cmdline_parse_inst_t cmd_set_port_ptypes = {
17553 	.f = cmd_set_port_ptypes_parsed,
17554 	.data = NULL,
17555 	.help_str = "set port <port_id> ptype_mask <mask>",
17556 	.tokens = {
17557 		(void *)&cmd_set_port_ptypes_set,
17558 		(void *)&cmd_set_port_ptypes_port,
17559 		(void *)&cmd_set_port_ptypes_port_id,
17560 		(void *)&cmd_set_port_ptypes_mask_str,
17561 		(void *)&cmd_set_port_ptypes_mask_u32,
17562 		NULL,
17563 	},
17564 };
17565 
17566 /* *** display mac addresses added to a port *** */
17567 struct cmd_showport_macs_result {
17568 	cmdline_fixed_string_t cmd_show;
17569 	cmdline_fixed_string_t cmd_port;
17570 	cmdline_fixed_string_t cmd_keyword;
17571 	portid_t cmd_pid;
17572 };
17573 
17574 static void
17575 cmd_showport_macs_parsed(void *parsed_result,
17576 		__rte_unused struct cmdline *cl,
17577 		__rte_unused void *data)
17578 {
17579 	struct cmd_showport_macs_result *res = parsed_result;
17580 
17581 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17582 		return;
17583 
17584 	if (!strcmp(res->cmd_keyword, "macs"))
17585 		show_macs(res->cmd_pid);
17586 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17587 		show_mcast_macs(res->cmd_pid);
17588 }
17589 
17590 cmdline_parse_token_string_t cmd_showport_macs_show =
17591 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17592 			cmd_show, "show");
17593 cmdline_parse_token_string_t cmd_showport_macs_port =
17594 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17595 			cmd_port, "port");
17596 cmdline_parse_token_num_t cmd_showport_macs_pid =
17597 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17598 			cmd_pid, RTE_UINT16);
17599 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17600 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17601 			cmd_keyword, "macs#mcast_macs");
17602 
17603 cmdline_parse_inst_t cmd_showport_macs = {
17604 	.f = cmd_showport_macs_parsed,
17605 	.data = NULL,
17606 	.help_str = "show port <port_id> macs|mcast_macs",
17607 	.tokens = {
17608 		(void *)&cmd_showport_macs_show,
17609 		(void *)&cmd_showport_macs_port,
17610 		(void *)&cmd_showport_macs_pid,
17611 		(void *)&cmd_showport_macs_keyword,
17612 		NULL,
17613 	},
17614 };
17615 
17616 /* *** show flow transfer proxy port ID for the given port *** */
17617 struct cmd_show_port_flow_transfer_proxy_result {
17618 	cmdline_fixed_string_t show;
17619 	cmdline_fixed_string_t port;
17620 	portid_t port_id;
17621 	cmdline_fixed_string_t flow;
17622 	cmdline_fixed_string_t transfer;
17623 	cmdline_fixed_string_t proxy;
17624 };
17625 
17626 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17627 	TOKEN_STRING_INITIALIZER
17628 		(struct cmd_show_port_flow_transfer_proxy_result,
17629 		 show, "show");
17630 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17631 	TOKEN_STRING_INITIALIZER
17632 		(struct cmd_show_port_flow_transfer_proxy_result,
17633 		 port, "port");
17634 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17635 	TOKEN_NUM_INITIALIZER
17636 		(struct cmd_show_port_flow_transfer_proxy_result,
17637 		 port_id, RTE_UINT16);
17638 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17639 	TOKEN_STRING_INITIALIZER
17640 		(struct cmd_show_port_flow_transfer_proxy_result,
17641 		 flow, "flow");
17642 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17643 	TOKEN_STRING_INITIALIZER
17644 		(struct cmd_show_port_flow_transfer_proxy_result,
17645 		 transfer, "transfer");
17646 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17647 	TOKEN_STRING_INITIALIZER
17648 		(struct cmd_show_port_flow_transfer_proxy_result,
17649 		 proxy, "proxy");
17650 
17651 static void
17652 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17653 					 __rte_unused struct cmdline *cl,
17654 					 __rte_unused void *data)
17655 {
17656 	struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17657 	portid_t proxy_port_id;
17658 	int ret;
17659 
17660 	printf("\n");
17661 
17662 	ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17663 	if (ret != 0) {
17664 		fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17665 			rte_strerror(-ret));
17666 		return;
17667 	}
17668 
17669 	printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17670 }
17671 
17672 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17673 	.f = cmd_show_port_flow_transfer_proxy_parsed,
17674 	.data = NULL,
17675 	.help_str = "show port <port_id> flow transfer proxy",
17676 	.tokens = {
17677 		(void *)&cmd_show_port_flow_transfer_proxy_show,
17678 		(void *)&cmd_show_port_flow_transfer_proxy_port,
17679 		(void *)&cmd_show_port_flow_transfer_proxy_port_id,
17680 		(void *)&cmd_show_port_flow_transfer_proxy_flow,
17681 		(void *)&cmd_show_port_flow_transfer_proxy_transfer,
17682 		(void *)&cmd_show_port_flow_transfer_proxy_proxy,
17683 		NULL,
17684 	}
17685 };
17686 
17687 /* ******************************************************************************** */
17688 
17689 /* list of instructions */
17690 cmdline_parse_ctx_t main_ctx[] = {
17691 	(cmdline_parse_inst_t *)&cmd_help_brief,
17692 	(cmdline_parse_inst_t *)&cmd_help_long,
17693 	(cmdline_parse_inst_t *)&cmd_quit,
17694 	(cmdline_parse_inst_t *)&cmd_load_from_file,
17695 	(cmdline_parse_inst_t *)&cmd_showport,
17696 	(cmdline_parse_inst_t *)&cmd_showqueue,
17697 	(cmdline_parse_inst_t *)&cmd_showeeprom,
17698 	(cmdline_parse_inst_t *)&cmd_showportall,
17699 	(cmdline_parse_inst_t *)&cmd_representor_info,
17700 	(cmdline_parse_inst_t *)&cmd_showdevice,
17701 	(cmdline_parse_inst_t *)&cmd_showcfg,
17702 	(cmdline_parse_inst_t *)&cmd_showfwdall,
17703 	(cmdline_parse_inst_t *)&cmd_start,
17704 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
17705 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17706 	(cmdline_parse_inst_t *)&cmd_set_link_up,
17707 	(cmdline_parse_inst_t *)&cmd_set_link_down,
17708 	(cmdline_parse_inst_t *)&cmd_reset,
17709 	(cmdline_parse_inst_t *)&cmd_set_numbers,
17710 	(cmdline_parse_inst_t *)&cmd_set_log,
17711 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
17712 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
17713 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
17714 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
17715 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
17716 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
17717 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17718 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17719 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17720 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17721 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17722 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17723 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17724 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17725 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
17726 	(cmdline_parse_inst_t *)&cmd_set_link_check,
17727 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17728 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
17729 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17730 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
17731 #ifdef RTE_NET_BOND
17732 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17733 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
17734 	(cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17735 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17736 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17737 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17738 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
17739 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17740 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17741 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17742 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17743 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17744 #endif
17745 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
17746 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
17747 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17748 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17749 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17750 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17751 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17752 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17753 	(cmdline_parse_inst_t *)&cmd_csum_set,
17754 	(cmdline_parse_inst_t *)&cmd_csum_show,
17755 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
17756 	(cmdline_parse_inst_t *)&cmd_tso_set,
17757 	(cmdline_parse_inst_t *)&cmd_tso_show,
17758 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17759 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17760 #ifdef RTE_LIB_GRO
17761 	(cmdline_parse_inst_t *)&cmd_gro_enable,
17762 	(cmdline_parse_inst_t *)&cmd_gro_flush,
17763 	(cmdline_parse_inst_t *)&cmd_gro_show,
17764 #endif
17765 #ifdef RTE_LIB_GSO
17766 	(cmdline_parse_inst_t *)&cmd_gso_enable,
17767 	(cmdline_parse_inst_t *)&cmd_gso_size,
17768 	(cmdline_parse_inst_t *)&cmd_gso_show,
17769 #endif
17770 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17771 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17772 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17773 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17774 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17775 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17776 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17777 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17778 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17779 	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17780 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17781 	(cmdline_parse_inst_t *)&cmd_config_dcb,
17782 	(cmdline_parse_inst_t *)&cmd_read_reg,
17783 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17784 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
17785 	(cmdline_parse_inst_t *)&cmd_write_reg,
17786 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17787 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
17788 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17789 	(cmdline_parse_inst_t *)&cmd_stop,
17790 	(cmdline_parse_inst_t *)&cmd_mac_addr,
17791 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17792 	(cmdline_parse_inst_t *)&cmd_set_qmap,
17793 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17794 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17795 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17796 	(cmdline_parse_inst_t *)&cmd_operate_port,
17797 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
17798 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
17799 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
17800 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
17801 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17802 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
17803 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
17804 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
17805 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17806 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
17807 	(cmdline_parse_inst_t *)&cmd_config_mtu,
17808 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17809 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17810 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17811 	(cmdline_parse_inst_t *)&cmd_config_rss,
17812 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17813 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17814 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17815 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17816 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
17817 	(cmdline_parse_inst_t *)&cmd_showport_reta,
17818 	(cmdline_parse_inst_t *)&cmd_showport_macs,
17819 	(cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17820 	(cmdline_parse_inst_t *)&cmd_config_burst,
17821 	(cmdline_parse_inst_t *)&cmd_config_thresh,
17822 	(cmdline_parse_inst_t *)&cmd_config_threshold,
17823 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17824 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17825 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17826 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17827 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17828 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17829 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17830 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17831 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17832 	(cmdline_parse_inst_t *)&cmd_dump,
17833 	(cmdline_parse_inst_t *)&cmd_dump_one,
17834 #ifdef RTE_NET_I40E
17835 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17836 #endif
17837 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17838 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17839 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17840 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17841 	(cmdline_parse_inst_t *)&cmd_flow,
17842 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17843 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17844 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17845 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17846 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
17847 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
17848 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
17849 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
17850 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17851 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17852 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17853 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17854 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17855 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
17856 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17857 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17858 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17859 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17860 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17861 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17862 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17863 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17864 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17865 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17866 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17867 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17868 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17869 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17870 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17871 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17872 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17873 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17874 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17875 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17876 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
17877 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17878 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17879 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
17880 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
17881 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
17882 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17883 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17884 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
17885 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17886 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
17887 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17888 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
17889 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17890 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17891 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17892 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17893 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17894 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17895 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17896 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17897 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17898 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17899 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17900 	(cmdline_parse_inst_t *)&cmd_ddp_add,
17901 	(cmdline_parse_inst_t *)&cmd_ddp_del,
17902 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
17903 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
17904 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
17905 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
17906 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
17907 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17908 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17909 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17910 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17911 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17912 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17913 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17914 
17915 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17916 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17917 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17918 	(cmdline_parse_inst_t *)&cmd_queue_region,
17919 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
17920 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
17921 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
17922 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17923 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17924 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17925 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17926 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17927 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17928 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17929 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17930 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17931 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17932 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17933 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17934 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17935 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17936 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17937 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17938 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17939 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17940 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17941 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17942 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17943 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17944 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17945 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17946 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17947 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17948 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17949 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17950 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17951 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17952 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17953 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17954 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17955 #ifdef RTE_LIB_BPF
17956 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17957 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17958 #endif
17959 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17960 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17961 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17962 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17963 	(cmdline_parse_inst_t *)&cmd_set_raw,
17964 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
17965 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17966 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17967 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
17968 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
17969 	(cmdline_parse_inst_t *)&cmd_show_capability,
17970 	(cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
17971 	(cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
17972 	NULL,
17973 };
17974 
17975 /* read cmdline commands from file */
17976 void
17977 cmdline_read_from_file(const char *filename)
17978 {
17979 	struct cmdline *cl;
17980 
17981 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17982 	if (cl == NULL) {
17983 		fprintf(stderr,
17984 			"Failed to create file based cmdline context: %s\n",
17985 			filename);
17986 		return;
17987 	}
17988 
17989 	cmdline_interact(cl);
17990 	cmdline_quit(cl);
17991 
17992 	cmdline_free(cl);
17993 
17994 	printf("Read CLI commands from %s\n", filename);
17995 }
17996 
17997 /* prompt function, called from main on MAIN lcore */
17998 void
17999 prompt(void)
18000 {
18001 	int ret;
18002 	/* initialize non-constant commands */
18003 	cmd_set_fwd_mode_init();
18004 	cmd_set_fwd_retry_mode_init();
18005 
18006 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18007 	if (testpmd_cl == NULL)
18008 		return;
18009 
18010 	ret = atexit(prompt_exit);
18011 	if (ret != 0)
18012 		fprintf(stderr, "Cannot set exit function for cmdline\n");
18013 
18014 	cmdline_interact(testpmd_cl);
18015 	if (ret != 0)
18016 		cmdline_stdin_exit(testpmd_cl);
18017 }
18018 
18019 void
18020 prompt_exit(void)
18021 {
18022 	if (testpmd_cl != NULL) {
18023 		cmdline_quit(testpmd_cl);
18024 		cmdline_stdin_exit(testpmd_cl);
18025 	}
18026 }
18027 
18028 static void
18029 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18030 {
18031 	if (id == (portid_t)RTE_PORT_ALL) {
18032 		portid_t pid;
18033 
18034 		RTE_ETH_FOREACH_DEV(pid) {
18035 			/* check if need_reconfig has been set to 1 */
18036 			if (ports[pid].need_reconfig == 0)
18037 				ports[pid].need_reconfig = dev;
18038 			/* check if need_reconfig_queues has been set to 1 */
18039 			if (ports[pid].need_reconfig_queues == 0)
18040 				ports[pid].need_reconfig_queues = queue;
18041 		}
18042 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18043 		/* check if need_reconfig has been set to 1 */
18044 		if (ports[id].need_reconfig == 0)
18045 			ports[id].need_reconfig = dev;
18046 		/* check if need_reconfig_queues has been set to 1 */
18047 		if (ports[id].need_reconfig_queues == 0)
18048 			ports[id].need_reconfig_queues = queue;
18049 	}
18050 }
18051