xref: /dpdk/app/test-pmd/cmdline.c (revision cf8a8a8f4896c0885d3996716f73513c4317e545)
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_atomic.h>
28 #include <rte_branch_prediction.h>
29 #include <rte_ring.h>
30 #include <rte_mempool.h>
31 #include <rte_interrupts.h>
32 #include <rte_pci.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_string_fns.h>
36 #include <rte_devargs.h>
37 #include <rte_flow.h>
38 #include <rte_gro.h>
39 #include <rte_mbuf_dyn.h>
40 
41 #include <cmdline_rdline.h>
42 #include <cmdline_parse.h>
43 #include <cmdline_parse_num.h>
44 #include <cmdline_parse_string.h>
45 #include <cmdline_parse_ipaddr.h>
46 #include <cmdline_parse_etheraddr.h>
47 #include <cmdline_socket.h>
48 #include <cmdline.h>
49 #ifdef RTE_NET_BOND
50 #include <rte_eth_bond.h>
51 #include <rte_eth_bond_8023ad.h>
52 #endif
53 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
54 #include <rte_pmd_dpaa.h>
55 #endif
56 #ifdef RTE_NET_IXGBE
57 #include <rte_pmd_ixgbe.h>
58 #endif
59 #ifdef RTE_NET_I40E
60 #include <rte_pmd_i40e.h>
61 #endif
62 #ifdef RTE_NET_BNXT
63 #include <rte_pmd_bnxt.h>
64 #endif
65 #include "testpmd.h"
66 #include "cmdline_mtr.h"
67 #include "cmdline_tm.h"
68 #include "bpf_cmd.h"
69 
70 static struct cmdline *testpmd_cl;
71 
72 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
73 
74 /* *** Help command with introduction. *** */
75 struct cmd_help_brief_result {
76 	cmdline_fixed_string_t help;
77 };
78 
79 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
80                                   struct cmdline *cl,
81                                   __rte_unused void *data)
82 {
83 	cmdline_printf(
84 		cl,
85 		"\n"
86 		"Help is available for the following sections:\n\n"
87 		"    help control                    : Start and stop forwarding.\n"
88 		"    help display                    : Displaying port, stats and config "
89 		"information.\n"
90 		"    help config                     : Configuration information.\n"
91 		"    help ports                      : Configuring ports.\n"
92 		"    help registers                  : Reading and setting port registers.\n"
93 		"    help filters                    : Filters configuration help.\n"
94 		"    help traffic_management         : Traffic Management commands.\n"
95 		"    help devices                    : Device related cmds.\n"
96 		"    help all                        : All of the above sections.\n\n"
97 	);
98 
99 }
100 
101 cmdline_parse_token_string_t cmd_help_brief_help =
102 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
103 
104 cmdline_parse_inst_t cmd_help_brief = {
105 	.f = cmd_help_brief_parsed,
106 	.data = NULL,
107 	.help_str = "help: Show help",
108 	.tokens = {
109 		(void *)&cmd_help_brief_help,
110 		NULL,
111 	},
112 };
113 
114 /* *** Help command with help sections. *** */
115 struct cmd_help_long_result {
116 	cmdline_fixed_string_t help;
117 	cmdline_fixed_string_t section;
118 };
119 
120 static void cmd_help_long_parsed(void *parsed_result,
121                                  struct cmdline *cl,
122                                  __rte_unused void *data)
123 {
124 	int show_all = 0;
125 	struct cmd_help_long_result *res = parsed_result;
126 
127 	if (!strcmp(res->section, "all"))
128 		show_all = 1;
129 
130 	if (show_all || !strcmp(res->section, "control")) {
131 
132 		cmdline_printf(
133 			cl,
134 			"\n"
135 			"Control forwarding:\n"
136 			"-------------------\n\n"
137 
138 			"start\n"
139 			"    Start packet forwarding with current configuration.\n\n"
140 
141 			"start tx_first\n"
142 			"    Start packet forwarding with current config"
143 			" after sending one burst of packets.\n\n"
144 
145 			"stop\n"
146 			"    Stop packet forwarding, and display accumulated"
147 			" statistics.\n\n"
148 
149 			"quit\n"
150 			"    Quit to prompt.\n\n"
151 		);
152 	}
153 
154 	if (show_all || !strcmp(res->section, "display")) {
155 
156 		cmdline_printf(
157 			cl,
158 			"\n"
159 			"Display:\n"
160 			"--------\n\n"
161 
162 			"show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
163 			"    Display information for port_id, or all.\n\n"
164 
165 			"show port port_id (module_eeprom|eeprom)\n"
166 			"    Display the module EEPROM or EEPROM information for port_id.\n\n"
167 
168 			"show port X rss reta (size) (mask0,mask1,...)\n"
169 			"    Display the rss redirection table entry indicated"
170 			" by masks on port X. size is used to indicate the"
171 			" hardware supported reta size\n\n"
172 
173 			"show port (port_id) rss-hash [key]\n"
174 			"    Display the RSS hash functions and RSS hash key of port\n\n"
175 
176 			"clear port (info|stats|xstats|fdir) (port_id|all)\n"
177 			"    Clear information for port_id, or all.\n\n"
178 
179 			"show (rxq|txq) info (port_id) (queue_id)\n"
180 			"    Display information for configured RX/TX queue.\n\n"
181 
182 			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
183 			"    Display the given configuration.\n\n"
184 
185 			"read rxd (port_id) (queue_id) (rxd_id)\n"
186 			"    Display an RX descriptor of a port RX queue.\n\n"
187 
188 			"read txd (port_id) (queue_id) (txd_id)\n"
189 			"    Display a TX descriptor of a port TX queue.\n\n"
190 
191 			"ddp get list (port_id)\n"
192 			"    Get ddp profile info list\n\n"
193 
194 			"ddp get info (profile_path)\n"
195 			"    Get ddp profile information.\n\n"
196 
197 			"show vf stats (port_id) (vf_id)\n"
198 			"    Display a VF's statistics.\n\n"
199 
200 			"clear vf stats (port_id) (vf_id)\n"
201 			"    Reset a VF's statistics.\n\n"
202 
203 			"show port (port_id) pctype mapping\n"
204 			"    Get flow ptype to pctype mapping on a port\n\n"
205 
206 			"show port meter stats (port_id) (meter_id) (clear)\n"
207 			"    Get meter stats on a port\n\n"
208 
209 			"show fwd stats all\n"
210 			"    Display statistics for all fwd engines.\n\n"
211 
212 			"clear fwd stats all\n"
213 			"    Clear statistics for all fwd engines.\n\n"
214 
215 			"show port (port_id) rx_offload capabilities\n"
216 			"    List all per queue and per port Rx offloading"
217 			" capabilities of a port\n\n"
218 
219 			"show port (port_id) rx_offload configuration\n"
220 			"    List port level and all queue level"
221 			" Rx offloading configuration\n\n"
222 
223 			"show port (port_id) tx_offload capabilities\n"
224 			"    List all per queue and per port"
225 			" Tx offloading capabilities of a port\n\n"
226 
227 			"show port (port_id) tx_offload configuration\n"
228 			"    List port level and all queue level"
229 			" Tx offloading configuration\n\n"
230 
231 			"show port (port_id) tx_metadata\n"
232 			"    Show Tx metadata value set"
233 			" for a specific port\n\n"
234 
235 			"show port (port_id) ptypes\n"
236 			"    Show port supported ptypes"
237 			" for a specific port\n\n"
238 
239 			"show device info (<identifier>|all)"
240 			"       Show general information about devices probed.\n\n"
241 
242 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 			"       Show status of rx|tx descriptor.\n\n"
244 
245 			"show port (port_id) rxq (queue_id) desc used count\n"
246 			"    Show current number of filled receive"
247 			" packet descriptors.\n\n"
248 
249 			"show port (port_id) macs|mcast_macs"
250 			"       Display list of mac addresses added to port.\n\n"
251 
252 			"show port (port_id) fec capabilities"
253 			"	Show fec capabilities of a port.\n\n"
254 
255 			"show port (port_id) fec_mode"
256 			"	Show fec mode of a port.\n\n"
257 
258 			"show port (port_id) flow_ctrl"
259 			"	Show flow control info of a port.\n\n"
260 		);
261 	}
262 
263 	if (show_all || !strcmp(res->section, "config")) {
264 		cmdline_printf(
265 			cl,
266 			"\n"
267 			"Configuration:\n"
268 			"--------------\n"
269 			"Configuration changes only become active when"
270 			" forwarding is started/restarted.\n\n"
271 
272 			"set default\n"
273 			"    Reset forwarding to the default configuration.\n\n"
274 
275 			"set verbose (level)\n"
276 			"    Set the debug verbosity level X.\n\n"
277 
278 			"set log global|(type) (level)\n"
279 			"    Set the log level.\n\n"
280 
281 			"set nbport (num)\n"
282 			"    Set number of ports.\n\n"
283 
284 			"set nbcore (num)\n"
285 			"    Set number of cores.\n\n"
286 
287 			"set coremask (mask)\n"
288 			"    Set the forwarding cores hexadecimal mask.\n\n"
289 
290 			"set portmask (mask)\n"
291 			"    Set the forwarding ports hexadecimal mask.\n\n"
292 
293 			"set burst (num)\n"
294 			"    Set number of packets per burst.\n\n"
295 
296 			"set burst tx delay (microseconds) retry (num)\n"
297 			"    Set the transmit delay time and number of retries,"
298 			" effective when retry is enabled.\n\n"
299 
300 			"set rxoffs (x[,y]*)\n"
301 			"    Set the offset of each packet segment on"
302 			" receiving if split feature is engaged."
303 			" Affects only the queues configured with split"
304 			" offloads.\n\n"
305 
306 			"set rxpkts (x[,y]*)\n"
307 			"    Set the length of each segment to scatter"
308 			" packets on receiving if split feature is engaged."
309 			" Affects only the queues configured with split"
310 			" offloads.\n\n"
311 
312 			"set txpkts (x[,y]*)\n"
313 			"    Set the length of each segment of TXONLY"
314 			" and optionally CSUM packets.\n\n"
315 
316 			"set txsplit (off|on|rand)\n"
317 			"    Set the split policy for the TX packets."
318 			" Right now only applicable for CSUM and TXONLY"
319 			" modes\n\n"
320 
321 			"set txtimes (x, y)\n"
322 			"    Set the scheduling on timestamps"
323 			" timings for the TXONLY mode\n\n"
324 
325 			"set corelist (x[,y]*)\n"
326 			"    Set the list of forwarding cores.\n\n"
327 
328 			"set portlist (x[,y]*)\n"
329 			"    Set the list of forwarding ports.\n\n"
330 
331 			"set port setup on (iterator|event)\n"
332 			"    Select how attached port is retrieved for setup.\n\n"
333 
334 			"set tx loopback (port_id) (on|off)\n"
335 			"    Enable or disable tx loopback.\n\n"
336 
337 			"set all queues drop (port_id) (on|off)\n"
338 			"    Set drop enable bit for all queues.\n\n"
339 
340 			"set vf split drop (port_id) (vf_id) (on|off)\n"
341 			"    Set split drop enable bit for a VF from the PF.\n\n"
342 
343 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
344 			"    Set MAC antispoof for a VF from the PF.\n\n"
345 
346 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
347 			"    Enable MACsec offload.\n\n"
348 
349 			"set macsec offload (port_id) off\n"
350 			"    Disable MACsec offload.\n\n"
351 
352 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
353 			"    Configure MACsec secure connection (SC).\n\n"
354 
355 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
356 			"    Configure MACsec secure association (SA).\n\n"
357 
358 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
359 			"    Set VF broadcast for a VF from the PF.\n\n"
360 
361 			"vlan set stripq (on|off) (port_id,queue_id)\n"
362 			"    Set the VLAN strip for a queue on a port.\n\n"
363 
364 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
365 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
366 
367 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
368 			"    Set VLAN insert for a VF from the PF.\n\n"
369 
370 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
371 			"    Set VLAN antispoof for a VF from the PF.\n\n"
372 
373 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
374 			"    Set VLAN tag for a VF from the PF.\n\n"
375 
376 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
377 			"    Set a VF's max bandwidth(Mbps).\n\n"
378 
379 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
380 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
381 
382 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
383 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
384 
385 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
386 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
387 
388 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
389 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
390 
391 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
392 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
393 
394 			"vlan set (inner|outer) tpid (value) (port_id)\n"
395 			"    Set the VLAN TPID for Packet Filtering on"
396 			" a port\n\n"
397 
398 			"rx_vlan add (vlan_id|all) (port_id)\n"
399 			"    Add a vlan_id, or all identifiers, to the set"
400 			" of VLAN identifiers filtered by port_id.\n\n"
401 
402 			"rx_vlan rm (vlan_id|all) (port_id)\n"
403 			"    Remove a vlan_id, or all identifiers, from the set"
404 			" of VLAN identifiers filtered by port_id.\n\n"
405 
406 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
407 			"    Add a vlan_id, to the set of VLAN identifiers"
408 			"filtered for VF(s) from port_id.\n\n"
409 
410 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
411 			"    Remove a vlan_id, to the set of VLAN identifiers"
412 			"filtered for VF(s) from port_id.\n\n"
413 
414 			"rx_vxlan_port add (udp_port) (port_id)\n"
415 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
416 
417 			"rx_vxlan_port rm (udp_port) (port_id)\n"
418 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
419 
420 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
421 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
422 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
423 
424 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
425 			"    Set port based TX VLAN insertion.\n\n"
426 
427 			"tx_vlan reset (port_id)\n"
428 			"    Disable hardware insertion of a VLAN header in"
429 			" packets sent on a port.\n\n"
430 
431 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
432 			"    Select hardware or software calculation of the"
433 			" checksum when transmitting a packet using the"
434 			" csum forward engine.\n"
435 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
436 			"    outer-ip concerns the outer IP layer in"
437 			"    outer-udp concerns the outer UDP layer in"
438 			" case the packet is recognized as a tunnel packet by"
439 			" the forward engine (vxlan, gre and ipip are supported)\n"
440 			"    Please check the NIC datasheet for HW limits.\n\n"
441 
442 			"csum parse-tunnel (on|off) (tx_port_id)\n"
443 			"    If disabled, treat tunnel packets as non-tunneled"
444 			" packets (treat inner headers as payload). The port\n"
445 			"    argument is the port used for TX in csum forward"
446 			" engine.\n\n"
447 
448 			"csum show (port_id)\n"
449 			"    Display tx checksum offload configuration\n\n"
450 
451 			"tso set (segsize) (portid)\n"
452 			"    Enable TCP Segmentation Offload in csum forward"
453 			" engine.\n"
454 			"    Please check the NIC datasheet for HW limits.\n\n"
455 
456 			"tso show (portid)"
457 			"    Display the status of TCP Segmentation Offload.\n\n"
458 
459 			"set port (port_id) gro on|off\n"
460 			"    Enable or disable Generic Receive Offload in"
461 			" csum forwarding engine.\n\n"
462 
463 			"show port (port_id) gro\n"
464 			"    Display GRO configuration.\n\n"
465 
466 			"set gro flush (cycles)\n"
467 			"    Set the cycle to flush GROed packets from"
468 			" reassembly tables.\n\n"
469 
470 			"set port (port_id) gso (on|off)"
471 			"    Enable or disable Generic Segmentation Offload in"
472 			" csum forwarding engine.\n\n"
473 
474 			"set gso segsz (length)\n"
475 			"    Set max packet length for output GSO segments,"
476 			" including packet header and payload.\n\n"
477 
478 			"show port (port_id) gso\n"
479 			"    Show GSO configuration.\n\n"
480 
481 			"set fwd (%s)\n"
482 			"    Set packet forwarding mode.\n\n"
483 
484 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 			"    Add a MAC address on port_id.\n\n"
486 
487 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 			"    Remove a MAC address from port_id.\n\n"
489 
490 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 			"    Set the default MAC address for port_id.\n\n"
492 
493 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
494 			"    Add a MAC address for a VF on the port.\n\n"
495 
496 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
497 			"    Set the MAC address for a VF from the PF.\n\n"
498 
499 			"set eth-peer (port_id) (peer_addr)\n"
500 			"    set the peer address for certain port.\n\n"
501 
502 			"set port (port_id) uta (mac_address|all) (on|off)\n"
503 			"    Add/Remove a or all unicast hash filter(s)"
504 			"from port X.\n\n"
505 
506 			"set promisc (port_id|all) (on|off)\n"
507 			"    Set the promiscuous mode on port_id, or all.\n\n"
508 
509 			"set allmulti (port_id|all) (on|off)\n"
510 			"    Set the allmulti mode on port_id, or all.\n\n"
511 
512 			"set vf promisc (port_id) (vf_id) (on|off)\n"
513 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
514 
515 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
516 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
517 
518 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
519 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
520 			" (on|off) autoneg (on|off) (port_id)\n"
521 			"set flow_ctrl rx (on|off) (portid)\n"
522 			"set flow_ctrl tx (on|off) (portid)\n"
523 			"set flow_ctrl high_water (high_water) (portid)\n"
524 			"set flow_ctrl low_water (low_water) (portid)\n"
525 			"set flow_ctrl pause_time (pause_time) (portid)\n"
526 			"set flow_ctrl send_xon (send_xon) (portid)\n"
527 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
528 			"set flow_ctrl autoneg (on|off) (port_id)\n"
529 			"    Set the link flow control parameter on a port.\n\n"
530 
531 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
532 			" (low_water) (pause_time) (priority) (port_id)\n"
533 			"    Set the priority flow control parameter on a"
534 			" port.\n\n"
535 
536 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
537 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
538 			" queue on port.\n"
539 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
540 			" on port 0 to mapping 5.\n\n"
541 
542 			"set xstats-hide-zero on|off\n"
543 			"    Set the option to hide the zero values"
544 			" for xstats display.\n"
545 
546 			"set record-core-cycles on|off\n"
547 			"    Set the option to enable measurement of CPU cycles.\n"
548 
549 			"set record-burst-stats on|off\n"
550 			"    Set the option to enable display of RX and TX bursts.\n"
551 
552 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
553 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
554 
555 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
556 			"|MPE) (on|off)\n"
557 			"    AUPE:accepts untagged VLAN;"
558 			"ROPE:accept unicast hash\n\n"
559 			"    BAM:accepts broadcast packets;"
560 			"MPE:accepts all multicast packets\n\n"
561 			"    Enable/Disable a VF receive mode of a port\n\n"
562 
563 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
564 			"    Set rate limit for a queue of a port\n\n"
565 
566 			"set port (port_id) vf (vf_id) rate (rate_num) "
567 			"queue_mask (queue_mask_value)\n"
568 			"    Set rate limit for queues in VF of a port\n\n"
569 
570 			"set port (port_id) mirror-rule (rule_id)"
571 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
572 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
573 			"   Set pool or vlan type mirror rule on a port.\n"
574 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
575 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
576 			" to pool 0.\n\n"
577 
578 			"set port (port_id) mirror-rule (rule_id)"
579 			" (uplink-mirror|downlink-mirror) dst-pool"
580 			" (pool_id) (on|off)\n"
581 			"   Set uplink or downlink type mirror rule on a port.\n"
582 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
583 			" 0 on' enable mirror income traffic to pool 0.\n\n"
584 
585 			"reset port (port_id) mirror-rule (rule_id)\n"
586 			"   Reset a mirror rule.\n\n"
587 
588 			"set flush_rx (on|off)\n"
589 			"   Flush (default) or don't flush RX streams before"
590 			" forwarding. Mainly used with PCAP drivers.\n\n"
591 
592 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
593 			"   Set the bypass mode for the lowest port on bypass enabled"
594 			" NIC.\n\n"
595 
596 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
597 			"mode (normal|bypass|isolate) (port_id)\n"
598 			"   Set the event required to initiate specified bypass mode for"
599 			" the lowest port on a bypass enabled NIC where:\n"
600 			"       timeout   = enable bypass after watchdog timeout.\n"
601 			"       os_on     = enable bypass when OS/board is powered on.\n"
602 			"       os_off    = enable bypass when OS/board is powered off.\n"
603 			"       power_on  = enable bypass when power supply is turned on.\n"
604 			"       power_off = enable bypass when power supply is turned off."
605 			"\n\n"
606 
607 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
608 			"   Set the bypass watchdog timeout to 'n' seconds"
609 			" where 0 = instant.\n\n"
610 
611 			"show bypass config (port_id)\n"
612 			"   Show the bypass configuration for a bypass enabled NIC"
613 			" using the lowest port on the NIC.\n\n"
614 
615 #ifdef RTE_NET_BOND
616 			"create bonded device (mode) (socket)\n"
617 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
618 
619 			"add bonding slave (slave_id) (port_id)\n"
620 			"	Add a slave device to a bonded device.\n\n"
621 
622 			"remove bonding slave (slave_id) (port_id)\n"
623 			"	Remove a slave device from a bonded device.\n\n"
624 
625 			"set bonding mode (value) (port_id)\n"
626 			"	Set the bonding mode on a bonded device.\n\n"
627 
628 			"set bonding primary (slave_id) (port_id)\n"
629 			"	Set the primary slave for a bonded device.\n\n"
630 
631 			"show bonding config (port_id)\n"
632 			"	Show the bonding config for port_id.\n\n"
633 
634 			"set bonding mac_addr (port_id) (address)\n"
635 			"	Set the MAC address of a bonded device.\n\n"
636 
637 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
638 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
639 
640 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
641 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
642 
643 			"set bonding mon_period (port_id) (value)\n"
644 			"	Set the bonding link status monitoring polling period in ms.\n\n"
645 
646 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
647 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
648 
649 #endif
650 			"set link-up port (port_id)\n"
651 			"	Set link up for a port.\n\n"
652 
653 			"set link-down port (port_id)\n"
654 			"	Set link down for a port.\n\n"
655 
656 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
657 			"    Load a profile package on a port\n\n"
658 
659 			"ddp del (port_id) (backup_profile_path)\n"
660 			"    Delete a profile package from a port\n\n"
661 
662 			"ptype mapping get (port_id) (valid_only)\n"
663 			"    Get ptype mapping on a port\n\n"
664 
665 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
666 			"    Replace target with the pkt_type in ptype mapping\n\n"
667 
668 			"ptype mapping reset (port_id)\n"
669 			"    Reset ptype mapping on a port\n\n"
670 
671 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
672 			"    Update a ptype mapping item on a port\n\n"
673 
674 			"set port (port_id) ptype_mask (ptype_mask)\n"
675 			"    set packet types classification for a specific port\n\n"
676 
677 			"set port (port_id) queue-region region_id (value) "
678 			"queue_start_index (value) queue_num (value)\n"
679 			"    Set a queue region on a port\n\n"
680 
681 			"set port (port_id) queue-region region_id (value) "
682 			"flowtype (value)\n"
683 			"    Set a flowtype region index on a port\n\n"
684 
685 			"set port (port_id) queue-region UP (value) region_id (value)\n"
686 			"    Set the mapping of User Priority to "
687 			"queue region on a port\n\n"
688 
689 			"set port (port_id) queue-region flush (on|off)\n"
690 			"    flush all queue region related configuration\n\n"
691 
692 			"show port meter cap (port_id)\n"
693 			"    Show port meter capability information\n\n"
694 
695 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
696 			"    meter profile add - srtcm rfc 2697\n\n"
697 
698 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
699 			"    meter profile add - trtcm rfc 2698\n\n"
700 
701 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
702 			"    meter profile add - trtcm rfc 4115\n\n"
703 
704 			"del port meter profile (port_id) (profile_id)\n"
705 			"    meter profile delete\n\n"
706 
707 			"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
708 			"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
709 			"(dscp_tbl_entry63)]\n"
710 			"    meter create\n\n"
711 
712 			"enable port meter (port_id) (mtr_id)\n"
713 			"    meter enable\n\n"
714 
715 			"disable port meter (port_id) (mtr_id)\n"
716 			"    meter disable\n\n"
717 
718 			"del port meter (port_id) (mtr_id)\n"
719 			"    meter delete\n\n"
720 
721 			"add port meter policy (port_id) (policy_id) g_actions (actions)\n"
722 			"y_actions (actions) r_actions (actions)\n"
723 			"    meter policy add\n\n"
724 
725 			"del port meter policy (port_id) (policy_id)\n"
726 			"    meter policy delete\n\n"
727 
728 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
729 			"    meter update meter profile\n\n"
730 
731 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
732 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
733 			"    update meter dscp table entries\n\n"
734 
735 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
736 			"(action0) [(action1) (action2)]\n"
737 			"    meter update policer action\n\n"
738 
739 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
740 			"    meter update stats\n\n"
741 
742 			"show port (port_id) queue-region\n"
743 			"    show all queue region related configuration info\n\n"
744 
745 			"set port (port_id) fec_mode auto|off|rs|baser\n"
746 			"    set fec mode for a specific port\n\n"
747 
748 			, list_pkt_forwarding_modes()
749 		);
750 	}
751 
752 	if (show_all || !strcmp(res->section, "ports")) {
753 
754 		cmdline_printf(
755 			cl,
756 			"\n"
757 			"Port Operations:\n"
758 			"----------------\n\n"
759 
760 			"port start (port_id|all)\n"
761 			"    Start all ports or port_id.\n\n"
762 
763 			"port stop (port_id|all)\n"
764 			"    Stop all ports or port_id.\n\n"
765 
766 			"port close (port_id|all)\n"
767 			"    Close all ports or port_id.\n\n"
768 
769 			"port reset (port_id|all)\n"
770 			"    Reset all ports or port_id.\n\n"
771 
772 			"port attach (ident)\n"
773 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
774 
775 			"port detach (port_id)\n"
776 			"    Detach physical or virtual dev by port_id\n\n"
777 
778 			"port config (port_id|all)"
779 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
780 			" duplex (half|full|auto)\n"
781 			"    Set speed and duplex for all ports or port_id\n\n"
782 
783 			"port config (port_id|all) loopback (mode)\n"
784 			"    Set loopback mode for all ports or port_id\n\n"
785 
786 			"port config all (rxq|txq|rxd|txd) (value)\n"
787 			"    Set number for rxq/txq/rxd/txd.\n\n"
788 
789 			"port config all max-pkt-len (value)\n"
790 			"    Set the max packet length.\n\n"
791 
792 			"port config all max-lro-pkt-size (value)\n"
793 			"    Set the max LRO aggregated packet size.\n\n"
794 
795 			"port config all drop-en (on|off)\n"
796 			"    Enable or disable packet drop on all RX queues of all ports when no "
797 			"receive buffers available.\n\n"
798 
799 			"port config all rss (all|default|ip|tcp|udp|sctp|"
800 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
801 			"level-outer|level-inner|<flowtype_id>)\n"
802 			"    Set the RSS mode.\n\n"
803 
804 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
805 			"    Set the RSS redirection table.\n\n"
806 
807 			"port config (port_id) dcb vt (on|off) (traffic_class)"
808 			" pfc (on|off)\n"
809 			"    Set the DCB mode.\n\n"
810 
811 			"port config all burst (value)\n"
812 			"    Set the number of packets per burst.\n\n"
813 
814 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
815 			" (value)\n"
816 			"    Set the ring prefetch/host/writeback threshold"
817 			" for tx/rx queue.\n\n"
818 
819 			"port config all (txfreet|txrst|rxfreet) (value)\n"
820 			"    Set free threshold for rx/tx, or set"
821 			" tx rs bit threshold.\n\n"
822 			"port config mtu X value\n"
823 			"    Set the MTU of port X to a given value\n\n"
824 
825 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
826 			"    Set a rx/tx queue's ring size configuration, the new"
827 			" value will take effect after command that (re-)start the port"
828 			" or command that setup the specific queue\n\n"
829 
830 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
831 			"    Start/stop a rx/tx queue of port X. Only take effect"
832 			" when port X is started\n\n"
833 
834 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
835 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
836 			" take effect when port X is stopped.\n\n"
837 
838 			"port (port_id) (rxq|txq) (queue_id) setup\n"
839 			"    Setup a rx/tx queue of port X.\n\n"
840 
841 			"port config (port_id) pctype mapping reset\n"
842 			"    Reset flow type to pctype mapping on a port\n\n"
843 
844 			"port config (port_id) pctype mapping update"
845 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 			"    Update a flow type to pctype mapping item on a port\n\n"
847 
848 			"port config (port_id) pctype (pctype_id) hash_inset|"
849 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
850 			" (field_idx)\n"
851 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
852 
853 			"port config (port_id) pctype (pctype_id) hash_inset|"
854 			"fdir_inset|fdir_flx_inset clear all"
855 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
856 
857 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
858 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
859 
860 			"port config <port_id> rx_offload vlan_strip|"
861 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 			"outer_ipv4_cksum|macsec_strip|header_split|"
863 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
864 			"buffer_split|timestamp|security|keep_crc on|off\n"
865 			"     Enable or disable a per port Rx offloading"
866 			" on all Rx queues of a port\n\n"
867 
868 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 			"outer_ipv4_cksum|macsec_strip|header_split|"
871 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
872 			"buffer_split|timestamp|security|keep_crc on|off\n"
873 			"    Enable or disable a per queue Rx offloading"
874 			" only on a specific Rx queue\n\n"
875 
876 			"port config (port_id) tx_offload vlan_insert|"
877 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
881 			"security on|off\n"
882 			"    Enable or disable a per port Tx offloading"
883 			" on all Tx queues of a port\n\n"
884 
885 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
890 			" on|off\n"
891 			"    Enable or disable a per queue Tx offloading"
892 			" only on a specific Tx queue\n\n"
893 
894 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 			"    Load an eBPF program as a callback"
896 			" for particular RX/TX queue\n\n"
897 
898 			"bpf-unload rx|tx (port) (queue)\n"
899 			"    Unload previously loaded eBPF program"
900 			" for particular RX/TX queue\n\n"
901 
902 			"port config (port_id) tx_metadata (value)\n"
903 			"    Set Tx metadata value per port. Testpmd will add this value"
904 			" to any Tx packet sent from this port\n\n"
905 
906 			"port config (port_id) dynf (name) set|clear\n"
907 			"    Register a dynf and Set/clear this flag on Tx. "
908 			"Testpmd will set this value to any Tx packet "
909 			"sent from this port\n\n"
910 
911 			"port cleanup (port_id) txq (queue_id) (free_cnt)\n"
912 			"    Cleanup txq mbufs for a specific Tx queue\n\n"
913 		);
914 	}
915 
916 	if (show_all || !strcmp(res->section, "registers")) {
917 
918 		cmdline_printf(
919 			cl,
920 			"\n"
921 			"Registers:\n"
922 			"----------\n\n"
923 
924 			"read reg (port_id) (address)\n"
925 			"    Display value of a port register.\n\n"
926 
927 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
928 			"    Display a port register bit field.\n\n"
929 
930 			"read regbit (port_id) (address) (bit_x)\n"
931 			"    Display a single port register bit.\n\n"
932 
933 			"write reg (port_id) (address) (value)\n"
934 			"    Set value of a port register.\n\n"
935 
936 			"write regfield (port_id) (address) (bit_x) (bit_y)"
937 			" (value)\n"
938 			"    Set bit field of a port register.\n\n"
939 
940 			"write regbit (port_id) (address) (bit_x) (value)\n"
941 			"    Set single bit value of a port register.\n\n"
942 		);
943 	}
944 	if (show_all || !strcmp(res->section, "filters")) {
945 
946 		cmdline_printf(
947 			cl,
948 			"\n"
949 			"filters:\n"
950 			"--------\n\n"
951 
952 #ifdef RTE_NET_I40E
953 			"flow_director_filter (port_id) mode raw (add|del|update)"
954 			" flow (flow_id) (drop|fwd) queue (queue_id)"
955 			" fd_id (fd_id_value) packet (packet file name)\n"
956 			"    Add/Del a raw type flow director filter.\n\n"
957 #endif
958 
959 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
960 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
961 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
962 			"    Set flow director IP mask.\n\n"
963 
964 			"flow_director_mask (port_id) mode MAC-VLAN"
965 			" vlan (vlan_value)\n"
966 			"    Set flow director MAC-VLAN mask.\n\n"
967 
968 			"flow_director_mask (port_id) mode Tunnel"
969 			" vlan (vlan_value) mac (mac_value)"
970 			" tunnel-type (tunnel_type_value)"
971 			" tunnel-id (tunnel_id_value)\n"
972 			"    Set flow director Tunnel mask.\n\n"
973 
974 			"flow_director_flex_payload (port_id)"
975 			" (raw|l2|l3|l4) (config)\n"
976 			"    Configure flex payload selection.\n\n"
977 
978 			"flow validate {port_id}"
979 			" [group {group_id}] [priority {level}]"
980 			" [ingress] [egress]"
981 			" pattern {item} [/ {item} [...]] / end"
982 			" actions {action} [/ {action} [...]] / end\n"
983 			"    Check whether a flow rule can be created.\n\n"
984 
985 			"flow create {port_id}"
986 			" [group {group_id}] [priority {level}]"
987 			" [ingress] [egress]"
988 			" pattern {item} [/ {item} [...]] / end"
989 			" actions {action} [/ {action} [...]] / end\n"
990 			"    Create a flow rule.\n\n"
991 
992 			"flow destroy {port_id} rule {rule_id} [...]\n"
993 			"    Destroy specific flow rules.\n\n"
994 
995 			"flow flush {port_id}\n"
996 			"    Destroy all flow rules.\n\n"
997 
998 			"flow query {port_id} {rule_id} {action}\n"
999 			"    Query an existing flow rule.\n\n"
1000 
1001 			"flow list {port_id} [group {group_id}] [...]\n"
1002 			"    List existing flow rules sorted by priority,"
1003 			" filtered by group identifiers.\n\n"
1004 
1005 			"flow isolate {port_id} {boolean}\n"
1006 			"    Restrict ingress traffic to the defined"
1007 			" flow rules\n\n"
1008 
1009 			"flow aged {port_id} [destroy]\n"
1010 			"    List and destroy aged flows"
1011 			" flow rules\n\n"
1012 
1013 			"flow indirect_action {port_id} create"
1014 			" [action_id {indirect_action_id}]"
1015 			" [ingress] [egress]"
1016 			" action {action} / end\n"
1017 			"    Create indirect action.\n\n"
1018 
1019 			"flow indirect_action {port_id} update"
1020 			" {indirect_action_id} action {action} / end\n"
1021 			"    Update indirect action.\n\n"
1022 
1023 			"flow indirect_action {port_id} destroy"
1024 			" action_id {indirect_action_id} [...]\n"
1025 			"    Destroy specific indirect actions.\n\n"
1026 
1027 			"flow indirect_action {port_id} query"
1028 			" {indirect_action_id}\n"
1029 			"    Query an existing indirect action.\n\n"
1030 
1031 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1032 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1033 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1034 			"       Configure the VXLAN encapsulation for flows.\n\n"
1035 
1036 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1037 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1038 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1039 			" eth-dst (eth-dst)\n"
1040 			"       Configure the VXLAN encapsulation for flows.\n\n"
1041 
1042 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1043 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1044 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1045 			" eth-dst (eth-dst)\n"
1046 			"       Configure the VXLAN encapsulation for flows.\n\n"
1047 
1048 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1049 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1050 			" (eth-dst)\n"
1051 			"       Configure the NVGRE encapsulation for flows.\n\n"
1052 
1053 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1054 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1055 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1056 			"       Configure the NVGRE encapsulation for flows.\n\n"
1057 
1058 			"set raw_encap {flow items}\n"
1059 			"	Configure the encapsulation with raw data.\n\n"
1060 
1061 			"set raw_decap {flow items}\n"
1062 			"	Configure the decapsulation with raw data.\n\n"
1063 
1064 		);
1065 	}
1066 
1067 	if (show_all || !strcmp(res->section, "traffic_management")) {
1068 		cmdline_printf(
1069 			cl,
1070 			"\n"
1071 			"Traffic Management:\n"
1072 			"--------------\n"
1073 			"show port tm cap (port_id)\n"
1074 			"       Display the port TM capability.\n\n"
1075 
1076 			"show port tm level cap (port_id) (level_id)\n"
1077 			"       Display the port TM hierarchical level capability.\n\n"
1078 
1079 			"show port tm node cap (port_id) (node_id)\n"
1080 			"       Display the port TM node capability.\n\n"
1081 
1082 			"show port tm node type (port_id) (node_id)\n"
1083 			"       Display the port TM node type.\n\n"
1084 
1085 			"show port tm node stats (port_id) (node_id) (clear)\n"
1086 			"       Display the port TM node stats.\n\n"
1087 
1088 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1089 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1090 			" (packet_length_adjust) (packet_mode)\n"
1091 			"       Add port tm node private shaper profile.\n\n"
1092 
1093 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1094 			"       Delete port tm node private shaper profile.\n\n"
1095 
1096 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1097 			" (shaper_profile_id)\n"
1098 			"       Add/update port tm node shared shaper.\n\n"
1099 
1100 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1101 			"       Delete port tm node shared shaper.\n\n"
1102 
1103 			"set port tm node shaper profile (port_id) (node_id)"
1104 			" (shaper_profile_id)\n"
1105 			"       Set port tm node shaper profile.\n\n"
1106 
1107 			"add port tm node wred profile (port_id) (wred_profile_id)"
1108 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1109 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1110 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1111 			"       Add port tm node wred profile.\n\n"
1112 
1113 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1114 			"       Delete port tm node wred profile.\n\n"
1115 
1116 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1117 			" (priority) (weight) (level_id) (shaper_profile_id)"
1118 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1119 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 			"       Add port tm nonleaf node.\n\n"
1121 
1122 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1123 			" (priority) (weight) (level_id) (shaper_profile_id)"
1124 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1125 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1126 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
1127 
1128 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1129 			" (priority) (weight) (level_id) (shaper_profile_id)"
1130 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1131 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1132 			"       Add port tm leaf node.\n\n"
1133 
1134 			"del port tm node (port_id) (node_id)\n"
1135 			"       Delete port tm node.\n\n"
1136 
1137 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1138 			" (priority) (weight)\n"
1139 			"       Set port tm node parent.\n\n"
1140 
1141 			"suspend port tm node (port_id) (node_id)"
1142 			"       Suspend tm node.\n\n"
1143 
1144 			"resume port tm node (port_id) (node_id)"
1145 			"       Resume tm node.\n\n"
1146 
1147 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1148 			"       Commit tm hierarchy.\n\n"
1149 
1150 			"set port tm mark ip_ecn (port) (green) (yellow)"
1151 			" (red)\n"
1152 			"    Enables/Disables the traffic management marking"
1153 			" for IP ECN (Explicit Congestion Notification)"
1154 			" packets on a given port\n\n"
1155 
1156 			"set port tm mark ip_dscp (port) (green) (yellow)"
1157 			" (red)\n"
1158 			"    Enables/Disables the traffic management marking"
1159 			" on the port for IP dscp packets\n\n"
1160 
1161 			"set port tm mark vlan_dei (port) (green) (yellow)"
1162 			" (red)\n"
1163 			"    Enables/Disables the traffic management marking"
1164 			" on the port for VLAN packets with DEI enabled\n\n"
1165 		);
1166 	}
1167 
1168 	if (show_all || !strcmp(res->section, "devices")) {
1169 		cmdline_printf(
1170 			cl,
1171 			"\n"
1172 			"Device Operations:\n"
1173 			"--------------\n"
1174 			"device detach (identifier)\n"
1175 			"       Detach device by identifier.\n\n"
1176 		);
1177 	}
1178 
1179 }
1180 
1181 cmdline_parse_token_string_t cmd_help_long_help =
1182 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1183 
1184 cmdline_parse_token_string_t cmd_help_long_section =
1185 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1186 			"all#control#display#config#"
1187 			"ports#registers#filters#traffic_management#devices");
1188 
1189 cmdline_parse_inst_t cmd_help_long = {
1190 	.f = cmd_help_long_parsed,
1191 	.data = NULL,
1192 	.help_str = "help all|control|display|config|ports|register|"
1193 		"filters|traffic_management|devices: "
1194 		"Show help",
1195 	.tokens = {
1196 		(void *)&cmd_help_long_help,
1197 		(void *)&cmd_help_long_section,
1198 		NULL,
1199 	},
1200 };
1201 
1202 
1203 /* *** start/stop/close all ports *** */
1204 struct cmd_operate_port_result {
1205 	cmdline_fixed_string_t keyword;
1206 	cmdline_fixed_string_t name;
1207 	cmdline_fixed_string_t value;
1208 };
1209 
1210 static void cmd_operate_port_parsed(void *parsed_result,
1211 				__rte_unused struct cmdline *cl,
1212 				__rte_unused void *data)
1213 {
1214 	struct cmd_operate_port_result *res = parsed_result;
1215 
1216 	if (!strcmp(res->name, "start"))
1217 		start_port(RTE_PORT_ALL);
1218 	else if (!strcmp(res->name, "stop"))
1219 		stop_port(RTE_PORT_ALL);
1220 	else if (!strcmp(res->name, "close"))
1221 		close_port(RTE_PORT_ALL);
1222 	else if (!strcmp(res->name, "reset"))
1223 		reset_port(RTE_PORT_ALL);
1224 	else
1225 		printf("Unknown parameter\n");
1226 }
1227 
1228 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1229 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1230 								"port");
1231 cmdline_parse_token_string_t cmd_operate_port_all_port =
1232 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1233 						"start#stop#close#reset");
1234 cmdline_parse_token_string_t cmd_operate_port_all_all =
1235 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1236 
1237 cmdline_parse_inst_t cmd_operate_port = {
1238 	.f = cmd_operate_port_parsed,
1239 	.data = NULL,
1240 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1241 	.tokens = {
1242 		(void *)&cmd_operate_port_all_cmd,
1243 		(void *)&cmd_operate_port_all_port,
1244 		(void *)&cmd_operate_port_all_all,
1245 		NULL,
1246 	},
1247 };
1248 
1249 /* *** start/stop/close specific port *** */
1250 struct cmd_operate_specific_port_result {
1251 	cmdline_fixed_string_t keyword;
1252 	cmdline_fixed_string_t name;
1253 	uint8_t value;
1254 };
1255 
1256 static void cmd_operate_specific_port_parsed(void *parsed_result,
1257 			__rte_unused struct cmdline *cl,
1258 				__rte_unused void *data)
1259 {
1260 	struct cmd_operate_specific_port_result *res = parsed_result;
1261 
1262 	if (!strcmp(res->name, "start"))
1263 		start_port(res->value);
1264 	else if (!strcmp(res->name, "stop"))
1265 		stop_port(res->value);
1266 	else if (!strcmp(res->name, "close"))
1267 		close_port(res->value);
1268 	else if (!strcmp(res->name, "reset"))
1269 		reset_port(res->value);
1270 	else
1271 		printf("Unknown parameter\n");
1272 }
1273 
1274 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1275 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1276 							keyword, "port");
1277 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1278 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1279 						name, "start#stop#close#reset");
1280 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1281 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1282 							value, RTE_UINT8);
1283 
1284 cmdline_parse_inst_t cmd_operate_specific_port = {
1285 	.f = cmd_operate_specific_port_parsed,
1286 	.data = NULL,
1287 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1288 	.tokens = {
1289 		(void *)&cmd_operate_specific_port_cmd,
1290 		(void *)&cmd_operate_specific_port_port,
1291 		(void *)&cmd_operate_specific_port_id,
1292 		NULL,
1293 	},
1294 };
1295 
1296 /* *** enable port setup (after attach) via iterator or event *** */
1297 struct cmd_set_port_setup_on_result {
1298 	cmdline_fixed_string_t set;
1299 	cmdline_fixed_string_t port;
1300 	cmdline_fixed_string_t setup;
1301 	cmdline_fixed_string_t on;
1302 	cmdline_fixed_string_t mode;
1303 };
1304 
1305 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1306 				__rte_unused struct cmdline *cl,
1307 				__rte_unused void *data)
1308 {
1309 	struct cmd_set_port_setup_on_result *res = parsed_result;
1310 
1311 	if (strcmp(res->mode, "event") == 0)
1312 		setup_on_probe_event = true;
1313 	else if (strcmp(res->mode, "iterator") == 0)
1314 		setup_on_probe_event = false;
1315 	else
1316 		printf("Unknown mode\n");
1317 }
1318 
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1320 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 			set, "set");
1322 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1323 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1324 			port, "port");
1325 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1326 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1327 			setup, "setup");
1328 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1329 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1330 			on, "on");
1331 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1332 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1333 			mode, "iterator#event");
1334 
1335 cmdline_parse_inst_t cmd_set_port_setup_on = {
1336 	.f = cmd_set_port_setup_on_parsed,
1337 	.data = NULL,
1338 	.help_str = "set port setup on iterator|event",
1339 	.tokens = {
1340 		(void *)&cmd_set_port_setup_on_set,
1341 		(void *)&cmd_set_port_setup_on_port,
1342 		(void *)&cmd_set_port_setup_on_setup,
1343 		(void *)&cmd_set_port_setup_on_on,
1344 		(void *)&cmd_set_port_setup_on_mode,
1345 		NULL,
1346 	},
1347 };
1348 
1349 /* *** attach a specified port *** */
1350 struct cmd_operate_attach_port_result {
1351 	cmdline_fixed_string_t port;
1352 	cmdline_fixed_string_t keyword;
1353 	cmdline_multi_string_t identifier;
1354 };
1355 
1356 static void cmd_operate_attach_port_parsed(void *parsed_result,
1357 				__rte_unused struct cmdline *cl,
1358 				__rte_unused void *data)
1359 {
1360 	struct cmd_operate_attach_port_result *res = parsed_result;
1361 
1362 	if (!strcmp(res->keyword, "attach"))
1363 		attach_port(res->identifier);
1364 	else
1365 		printf("Unknown parameter\n");
1366 }
1367 
1368 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1369 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1370 			port, "port");
1371 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1372 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1373 			keyword, "attach");
1374 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1375 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1376 			identifier, TOKEN_STRING_MULTI);
1377 
1378 cmdline_parse_inst_t cmd_operate_attach_port = {
1379 	.f = cmd_operate_attach_port_parsed,
1380 	.data = NULL,
1381 	.help_str = "port attach <identifier>: "
1382 		"(identifier: pci address or virtual dev name)",
1383 	.tokens = {
1384 		(void *)&cmd_operate_attach_port_port,
1385 		(void *)&cmd_operate_attach_port_keyword,
1386 		(void *)&cmd_operate_attach_port_identifier,
1387 		NULL,
1388 	},
1389 };
1390 
1391 /* *** detach a specified port *** */
1392 struct cmd_operate_detach_port_result {
1393 	cmdline_fixed_string_t port;
1394 	cmdline_fixed_string_t keyword;
1395 	portid_t port_id;
1396 };
1397 
1398 static void cmd_operate_detach_port_parsed(void *parsed_result,
1399 				__rte_unused struct cmdline *cl,
1400 				__rte_unused void *data)
1401 {
1402 	struct cmd_operate_detach_port_result *res = parsed_result;
1403 
1404 	if (!strcmp(res->keyword, "detach")) {
1405 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1406 		detach_port_device(res->port_id);
1407 	} else {
1408 		printf("Unknown parameter\n");
1409 	}
1410 }
1411 
1412 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1413 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1414 			port, "port");
1415 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1416 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1417 			keyword, "detach");
1418 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1419 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1420 			port_id, RTE_UINT16);
1421 
1422 cmdline_parse_inst_t cmd_operate_detach_port = {
1423 	.f = cmd_operate_detach_port_parsed,
1424 	.data = NULL,
1425 	.help_str = "port detach <port_id>",
1426 	.tokens = {
1427 		(void *)&cmd_operate_detach_port_port,
1428 		(void *)&cmd_operate_detach_port_keyword,
1429 		(void *)&cmd_operate_detach_port_port_id,
1430 		NULL,
1431 	},
1432 };
1433 
1434 /* *** detach device by identifier *** */
1435 struct cmd_operate_detach_device_result {
1436 	cmdline_fixed_string_t device;
1437 	cmdline_fixed_string_t keyword;
1438 	cmdline_fixed_string_t identifier;
1439 };
1440 
1441 static void cmd_operate_detach_device_parsed(void *parsed_result,
1442 				__rte_unused struct cmdline *cl,
1443 				__rte_unused void *data)
1444 {
1445 	struct cmd_operate_detach_device_result *res = parsed_result;
1446 
1447 	if (!strcmp(res->keyword, "detach"))
1448 		detach_devargs(res->identifier);
1449 	else
1450 		printf("Unknown parameter\n");
1451 }
1452 
1453 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1454 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1455 			device, "device");
1456 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1457 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1458 			keyword, "detach");
1459 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1460 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1461 			identifier, NULL);
1462 
1463 cmdline_parse_inst_t cmd_operate_detach_device = {
1464 	.f = cmd_operate_detach_device_parsed,
1465 	.data = NULL,
1466 	.help_str = "device detach <identifier>:"
1467 		"(identifier: pci address or virtual dev name)",
1468 	.tokens = {
1469 		(void *)&cmd_operate_detach_device_device,
1470 		(void *)&cmd_operate_detach_device_keyword,
1471 		(void *)&cmd_operate_detach_device_identifier,
1472 		NULL,
1473 	},
1474 };
1475 /* *** configure speed for all ports *** */
1476 struct cmd_config_speed_all {
1477 	cmdline_fixed_string_t port;
1478 	cmdline_fixed_string_t keyword;
1479 	cmdline_fixed_string_t all;
1480 	cmdline_fixed_string_t item1;
1481 	cmdline_fixed_string_t item2;
1482 	cmdline_fixed_string_t value1;
1483 	cmdline_fixed_string_t value2;
1484 };
1485 
1486 static int
1487 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1488 {
1489 
1490 	int duplex;
1491 
1492 	if (!strcmp(duplexstr, "half")) {
1493 		duplex = ETH_LINK_HALF_DUPLEX;
1494 	} else if (!strcmp(duplexstr, "full")) {
1495 		duplex = ETH_LINK_FULL_DUPLEX;
1496 	} else if (!strcmp(duplexstr, "auto")) {
1497 		duplex = ETH_LINK_FULL_DUPLEX;
1498 	} else {
1499 		printf("Unknown duplex parameter\n");
1500 		return -1;
1501 	}
1502 
1503 	if (!strcmp(speedstr, "10")) {
1504 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1505 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1506 	} else if (!strcmp(speedstr, "100")) {
1507 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1508 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1509 	} else {
1510 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1511 			printf("Invalid speed/duplex parameters\n");
1512 			return -1;
1513 		}
1514 		if (!strcmp(speedstr, "1000")) {
1515 			*speed = ETH_LINK_SPEED_1G;
1516 		} else if (!strcmp(speedstr, "10000")) {
1517 			*speed = ETH_LINK_SPEED_10G;
1518 		} else if (!strcmp(speedstr, "25000")) {
1519 			*speed = ETH_LINK_SPEED_25G;
1520 		} else if (!strcmp(speedstr, "40000")) {
1521 			*speed = ETH_LINK_SPEED_40G;
1522 		} else if (!strcmp(speedstr, "50000")) {
1523 			*speed = ETH_LINK_SPEED_50G;
1524 		} else if (!strcmp(speedstr, "100000")) {
1525 			*speed = ETH_LINK_SPEED_100G;
1526 		} else if (!strcmp(speedstr, "200000")) {
1527 			*speed = ETH_LINK_SPEED_200G;
1528 		} else if (!strcmp(speedstr, "auto")) {
1529 			*speed = ETH_LINK_SPEED_AUTONEG;
1530 		} else {
1531 			printf("Unknown speed parameter\n");
1532 			return -1;
1533 		}
1534 	}
1535 
1536 	if (*speed != ETH_LINK_SPEED_AUTONEG)
1537 		*speed |= ETH_LINK_SPEED_FIXED;
1538 
1539 	return 0;
1540 }
1541 
1542 static void
1543 cmd_config_speed_all_parsed(void *parsed_result,
1544 			__rte_unused struct cmdline *cl,
1545 			__rte_unused void *data)
1546 {
1547 	struct cmd_config_speed_all *res = parsed_result;
1548 	uint32_t link_speed;
1549 	portid_t pid;
1550 
1551 	if (!all_ports_stopped()) {
1552 		printf("Please stop all ports first\n");
1553 		return;
1554 	}
1555 
1556 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1557 			&link_speed) < 0)
1558 		return;
1559 
1560 	RTE_ETH_FOREACH_DEV(pid) {
1561 		ports[pid].dev_conf.link_speeds = link_speed;
1562 	}
1563 
1564 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1565 }
1566 
1567 cmdline_parse_token_string_t cmd_config_speed_all_port =
1568 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1569 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1570 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1571 							"config");
1572 cmdline_parse_token_string_t cmd_config_speed_all_all =
1573 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1574 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1575 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1576 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1577 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1578 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1579 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1580 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1581 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1582 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1583 						"half#full#auto");
1584 
1585 cmdline_parse_inst_t cmd_config_speed_all = {
1586 	.f = cmd_config_speed_all_parsed,
1587 	.data = NULL,
1588 	.help_str = "port config all speed "
1589 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1590 							"half|full|auto",
1591 	.tokens = {
1592 		(void *)&cmd_config_speed_all_port,
1593 		(void *)&cmd_config_speed_all_keyword,
1594 		(void *)&cmd_config_speed_all_all,
1595 		(void *)&cmd_config_speed_all_item1,
1596 		(void *)&cmd_config_speed_all_value1,
1597 		(void *)&cmd_config_speed_all_item2,
1598 		(void *)&cmd_config_speed_all_value2,
1599 		NULL,
1600 	},
1601 };
1602 
1603 /* *** configure speed for specific port *** */
1604 struct cmd_config_speed_specific {
1605 	cmdline_fixed_string_t port;
1606 	cmdline_fixed_string_t keyword;
1607 	portid_t id;
1608 	cmdline_fixed_string_t item1;
1609 	cmdline_fixed_string_t item2;
1610 	cmdline_fixed_string_t value1;
1611 	cmdline_fixed_string_t value2;
1612 };
1613 
1614 static void
1615 cmd_config_speed_specific_parsed(void *parsed_result,
1616 				__rte_unused struct cmdline *cl,
1617 				__rte_unused void *data)
1618 {
1619 	struct cmd_config_speed_specific *res = parsed_result;
1620 	uint32_t link_speed;
1621 
1622 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1623 		return;
1624 
1625 	if (!port_is_stopped(res->id)) {
1626 		printf("Please stop port %d first\n", res->id);
1627 		return;
1628 	}
1629 
1630 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1631 			&link_speed) < 0)
1632 		return;
1633 
1634 	ports[res->id].dev_conf.link_speeds = link_speed;
1635 
1636 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1637 }
1638 
1639 
1640 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1641 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1642 								"port");
1643 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1644 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1645 								"config");
1646 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1647 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1648 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1649 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1650 								"speed");
1651 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1652 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1653 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1654 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1655 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1656 								"duplex");
1657 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1658 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1659 							"half#full#auto");
1660 
1661 cmdline_parse_inst_t cmd_config_speed_specific = {
1662 	.f = cmd_config_speed_specific_parsed,
1663 	.data = NULL,
1664 	.help_str = "port config <port_id> speed "
1665 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1666 							"half|full|auto",
1667 	.tokens = {
1668 		(void *)&cmd_config_speed_specific_port,
1669 		(void *)&cmd_config_speed_specific_keyword,
1670 		(void *)&cmd_config_speed_specific_id,
1671 		(void *)&cmd_config_speed_specific_item1,
1672 		(void *)&cmd_config_speed_specific_value1,
1673 		(void *)&cmd_config_speed_specific_item2,
1674 		(void *)&cmd_config_speed_specific_value2,
1675 		NULL,
1676 	},
1677 };
1678 
1679 /* *** configure loopback for all ports *** */
1680 struct cmd_config_loopback_all {
1681 	cmdline_fixed_string_t port;
1682 	cmdline_fixed_string_t keyword;
1683 	cmdline_fixed_string_t all;
1684 	cmdline_fixed_string_t item;
1685 	uint32_t mode;
1686 };
1687 
1688 static void
1689 cmd_config_loopback_all_parsed(void *parsed_result,
1690 			__rte_unused struct cmdline *cl,
1691 			__rte_unused void *data)
1692 {
1693 	struct cmd_config_loopback_all *res = parsed_result;
1694 	portid_t pid;
1695 
1696 	if (!all_ports_stopped()) {
1697 		printf("Please stop all ports first\n");
1698 		return;
1699 	}
1700 
1701 	RTE_ETH_FOREACH_DEV(pid) {
1702 		ports[pid].dev_conf.lpbk_mode = res->mode;
1703 	}
1704 
1705 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1706 }
1707 
1708 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1709 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1710 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1711 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1712 							"config");
1713 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1714 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1715 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1716 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1717 							"loopback");
1718 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1719 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1720 
1721 cmdline_parse_inst_t cmd_config_loopback_all = {
1722 	.f = cmd_config_loopback_all_parsed,
1723 	.data = NULL,
1724 	.help_str = "port config all loopback <mode>",
1725 	.tokens = {
1726 		(void *)&cmd_config_loopback_all_port,
1727 		(void *)&cmd_config_loopback_all_keyword,
1728 		(void *)&cmd_config_loopback_all_all,
1729 		(void *)&cmd_config_loopback_all_item,
1730 		(void *)&cmd_config_loopback_all_mode,
1731 		NULL,
1732 	},
1733 };
1734 
1735 /* *** configure loopback for specific port *** */
1736 struct cmd_config_loopback_specific {
1737 	cmdline_fixed_string_t port;
1738 	cmdline_fixed_string_t keyword;
1739 	uint16_t port_id;
1740 	cmdline_fixed_string_t item;
1741 	uint32_t mode;
1742 };
1743 
1744 static void
1745 cmd_config_loopback_specific_parsed(void *parsed_result,
1746 				__rte_unused struct cmdline *cl,
1747 				__rte_unused void *data)
1748 {
1749 	struct cmd_config_loopback_specific *res = parsed_result;
1750 
1751 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1752 		return;
1753 
1754 	if (!port_is_stopped(res->port_id)) {
1755 		printf("Please stop port %u first\n", res->port_id);
1756 		return;
1757 	}
1758 
1759 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1760 
1761 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1762 }
1763 
1764 
1765 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1766 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1767 								"port");
1768 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1769 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1770 								"config");
1771 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1772 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1773 								RTE_UINT16);
1774 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1775 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1776 								"loopback");
1777 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1778 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1779 			      RTE_UINT32);
1780 
1781 cmdline_parse_inst_t cmd_config_loopback_specific = {
1782 	.f = cmd_config_loopback_specific_parsed,
1783 	.data = NULL,
1784 	.help_str = "port config <port_id> loopback <mode>",
1785 	.tokens = {
1786 		(void *)&cmd_config_loopback_specific_port,
1787 		(void *)&cmd_config_loopback_specific_keyword,
1788 		(void *)&cmd_config_loopback_specific_id,
1789 		(void *)&cmd_config_loopback_specific_item,
1790 		(void *)&cmd_config_loopback_specific_mode,
1791 		NULL,
1792 	},
1793 };
1794 
1795 /* *** configure txq/rxq, txd/rxd *** */
1796 struct cmd_config_rx_tx {
1797 	cmdline_fixed_string_t port;
1798 	cmdline_fixed_string_t keyword;
1799 	cmdline_fixed_string_t all;
1800 	cmdline_fixed_string_t name;
1801 	uint16_t value;
1802 };
1803 
1804 static void
1805 cmd_config_rx_tx_parsed(void *parsed_result,
1806 			__rte_unused struct cmdline *cl,
1807 			__rte_unused void *data)
1808 {
1809 	struct cmd_config_rx_tx *res = parsed_result;
1810 
1811 	if (!all_ports_stopped()) {
1812 		printf("Please stop all ports first\n");
1813 		return;
1814 	}
1815 	if (!strcmp(res->name, "rxq")) {
1816 		if (!res->value && !nb_txq) {
1817 			printf("Warning: Either rx or tx queues should be non zero\n");
1818 			return;
1819 		}
1820 		if (check_nb_rxq(res->value) != 0)
1821 			return;
1822 		nb_rxq = res->value;
1823 	}
1824 	else if (!strcmp(res->name, "txq")) {
1825 		if (!res->value && !nb_rxq) {
1826 			printf("Warning: Either rx or tx queues should be non zero\n");
1827 			return;
1828 		}
1829 		if (check_nb_txq(res->value) != 0)
1830 			return;
1831 		nb_txq = res->value;
1832 	}
1833 	else if (!strcmp(res->name, "rxd")) {
1834 		if (check_nb_rxd(res->value) != 0)
1835 			return;
1836 		nb_rxd = res->value;
1837 	} else if (!strcmp(res->name, "txd")) {
1838 		if (check_nb_txd(res->value) != 0)
1839 			return;
1840 
1841 		nb_txd = res->value;
1842 	} else {
1843 		printf("Unknown parameter\n");
1844 		return;
1845 	}
1846 
1847 	fwd_config_setup();
1848 
1849 	init_port_config();
1850 
1851 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1852 }
1853 
1854 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1855 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1856 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1857 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1858 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1859 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1860 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1861 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1862 						"rxq#txq#rxd#txd");
1863 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1864 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1865 
1866 cmdline_parse_inst_t cmd_config_rx_tx = {
1867 	.f = cmd_config_rx_tx_parsed,
1868 	.data = NULL,
1869 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1870 	.tokens = {
1871 		(void *)&cmd_config_rx_tx_port,
1872 		(void *)&cmd_config_rx_tx_keyword,
1873 		(void *)&cmd_config_rx_tx_all,
1874 		(void *)&cmd_config_rx_tx_name,
1875 		(void *)&cmd_config_rx_tx_value,
1876 		NULL,
1877 	},
1878 };
1879 
1880 /* *** config max packet length *** */
1881 struct cmd_config_max_pkt_len_result {
1882 	cmdline_fixed_string_t port;
1883 	cmdline_fixed_string_t keyword;
1884 	cmdline_fixed_string_t all;
1885 	cmdline_fixed_string_t name;
1886 	uint32_t value;
1887 };
1888 
1889 static void
1890 cmd_config_max_pkt_len_parsed(void *parsed_result,
1891 				__rte_unused struct cmdline *cl,
1892 				__rte_unused void *data)
1893 {
1894 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1895 	uint32_t max_rx_pkt_len_backup = 0;
1896 	portid_t pid;
1897 	int ret;
1898 
1899 	if (!all_ports_stopped()) {
1900 		printf("Please stop all ports first\n");
1901 		return;
1902 	}
1903 
1904 	RTE_ETH_FOREACH_DEV(pid) {
1905 		struct rte_port *port = &ports[pid];
1906 
1907 		if (!strcmp(res->name, "max-pkt-len")) {
1908 			if (res->value < RTE_ETHER_MIN_LEN) {
1909 				printf("max-pkt-len can not be less than %d\n",
1910 						RTE_ETHER_MIN_LEN);
1911 				return;
1912 			}
1913 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1914 				return;
1915 
1916 			ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1917 			if (ret != 0) {
1918 				printf("rte_eth_dev_info_get() failed for port %u\n",
1919 					pid);
1920 				return;
1921 			}
1922 
1923 			max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1924 
1925 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1926 			if (update_jumbo_frame_offload(pid) != 0)
1927 				port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1928 		} else {
1929 			printf("Unknown parameter\n");
1930 			return;
1931 		}
1932 	}
1933 
1934 	init_port_config();
1935 
1936 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1937 }
1938 
1939 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1940 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1941 								"port");
1942 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1943 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1944 								"config");
1945 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1946 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1947 								"all");
1948 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1949 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1950 								"max-pkt-len");
1951 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1952 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1953 								RTE_UINT32);
1954 
1955 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1956 	.f = cmd_config_max_pkt_len_parsed,
1957 	.data = NULL,
1958 	.help_str = "port config all max-pkt-len <value>",
1959 	.tokens = {
1960 		(void *)&cmd_config_max_pkt_len_port,
1961 		(void *)&cmd_config_max_pkt_len_keyword,
1962 		(void *)&cmd_config_max_pkt_len_all,
1963 		(void *)&cmd_config_max_pkt_len_name,
1964 		(void *)&cmd_config_max_pkt_len_value,
1965 		NULL,
1966 	},
1967 };
1968 
1969 /* *** config max LRO aggregated packet size *** */
1970 struct cmd_config_max_lro_pkt_size_result {
1971 	cmdline_fixed_string_t port;
1972 	cmdline_fixed_string_t keyword;
1973 	cmdline_fixed_string_t all;
1974 	cmdline_fixed_string_t name;
1975 	uint32_t value;
1976 };
1977 
1978 static void
1979 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1980 				__rte_unused struct cmdline *cl,
1981 				__rte_unused void *data)
1982 {
1983 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1984 	portid_t pid;
1985 
1986 	if (!all_ports_stopped()) {
1987 		printf("Please stop all ports first\n");
1988 		return;
1989 	}
1990 
1991 	RTE_ETH_FOREACH_DEV(pid) {
1992 		struct rte_port *port = &ports[pid];
1993 
1994 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1995 			if (res->value ==
1996 					port->dev_conf.rxmode.max_lro_pkt_size)
1997 				return;
1998 
1999 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2000 		} else {
2001 			printf("Unknown parameter\n");
2002 			return;
2003 		}
2004 	}
2005 
2006 	init_port_config();
2007 
2008 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2009 }
2010 
2011 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2012 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2013 				 port, "port");
2014 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2015 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 				 keyword, "config");
2017 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2018 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2019 				 all, "all");
2020 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2021 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2022 				 name, "max-lro-pkt-size");
2023 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2024 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2025 			      value, RTE_UINT32);
2026 
2027 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2028 	.f = cmd_config_max_lro_pkt_size_parsed,
2029 	.data = NULL,
2030 	.help_str = "port config all max-lro-pkt-size <value>",
2031 	.tokens = {
2032 		(void *)&cmd_config_max_lro_pkt_size_port,
2033 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2034 		(void *)&cmd_config_max_lro_pkt_size_all,
2035 		(void *)&cmd_config_max_lro_pkt_size_name,
2036 		(void *)&cmd_config_max_lro_pkt_size_value,
2037 		NULL,
2038 	},
2039 };
2040 
2041 /* *** configure port MTU *** */
2042 struct cmd_config_mtu_result {
2043 	cmdline_fixed_string_t port;
2044 	cmdline_fixed_string_t keyword;
2045 	cmdline_fixed_string_t mtu;
2046 	portid_t port_id;
2047 	uint16_t value;
2048 };
2049 
2050 static void
2051 cmd_config_mtu_parsed(void *parsed_result,
2052 		      __rte_unused struct cmdline *cl,
2053 		      __rte_unused void *data)
2054 {
2055 	struct cmd_config_mtu_result *res = parsed_result;
2056 
2057 	if (res->value < RTE_ETHER_MIN_LEN) {
2058 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2059 		return;
2060 	}
2061 	port_mtu_set(res->port_id, res->value);
2062 }
2063 
2064 cmdline_parse_token_string_t cmd_config_mtu_port =
2065 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2066 				 "port");
2067 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2068 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2069 				 "config");
2070 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2071 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2072 				 "mtu");
2073 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2074 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2075 				 RTE_UINT16);
2076 cmdline_parse_token_num_t cmd_config_mtu_value =
2077 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2078 				 RTE_UINT16);
2079 
2080 cmdline_parse_inst_t cmd_config_mtu = {
2081 	.f = cmd_config_mtu_parsed,
2082 	.data = NULL,
2083 	.help_str = "port config mtu <port_id> <value>",
2084 	.tokens = {
2085 		(void *)&cmd_config_mtu_port,
2086 		(void *)&cmd_config_mtu_keyword,
2087 		(void *)&cmd_config_mtu_mtu,
2088 		(void *)&cmd_config_mtu_port_id,
2089 		(void *)&cmd_config_mtu_value,
2090 		NULL,
2091 	},
2092 };
2093 
2094 /* *** configure rx mode *** */
2095 struct cmd_config_rx_mode_flag {
2096 	cmdline_fixed_string_t port;
2097 	cmdline_fixed_string_t keyword;
2098 	cmdline_fixed_string_t all;
2099 	cmdline_fixed_string_t name;
2100 	cmdline_fixed_string_t value;
2101 };
2102 
2103 static void
2104 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2105 				__rte_unused struct cmdline *cl,
2106 				__rte_unused void *data)
2107 {
2108 	struct cmd_config_rx_mode_flag *res = parsed_result;
2109 
2110 	if (!all_ports_stopped()) {
2111 		printf("Please stop all ports first\n");
2112 		return;
2113 	}
2114 
2115 	if (!strcmp(res->name, "drop-en")) {
2116 		if (!strcmp(res->value, "on"))
2117 			rx_drop_en = 1;
2118 		else if (!strcmp(res->value, "off"))
2119 			rx_drop_en = 0;
2120 		else {
2121 			printf("Unknown parameter\n");
2122 			return;
2123 		}
2124 	} else {
2125 		printf("Unknown parameter\n");
2126 		return;
2127 	}
2128 
2129 	init_port_config();
2130 
2131 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2132 }
2133 
2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2135 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2137 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2138 								"config");
2139 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2140 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2142 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2143 					"drop-en");
2144 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2145 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2146 							"on#off");
2147 
2148 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2149 	.f = cmd_config_rx_mode_flag_parsed,
2150 	.data = NULL,
2151 	.help_str = "port config all drop-en on|off",
2152 	.tokens = {
2153 		(void *)&cmd_config_rx_mode_flag_port,
2154 		(void *)&cmd_config_rx_mode_flag_keyword,
2155 		(void *)&cmd_config_rx_mode_flag_all,
2156 		(void *)&cmd_config_rx_mode_flag_name,
2157 		(void *)&cmd_config_rx_mode_flag_value,
2158 		NULL,
2159 	},
2160 };
2161 
2162 /* *** configure rss *** */
2163 struct cmd_config_rss {
2164 	cmdline_fixed_string_t port;
2165 	cmdline_fixed_string_t keyword;
2166 	cmdline_fixed_string_t all;
2167 	cmdline_fixed_string_t name;
2168 	cmdline_fixed_string_t value;
2169 };
2170 
2171 static void
2172 cmd_config_rss_parsed(void *parsed_result,
2173 			__rte_unused struct cmdline *cl,
2174 			__rte_unused void *data)
2175 {
2176 	struct cmd_config_rss *res = parsed_result;
2177 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2178 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2179 	int use_default = 0;
2180 	int all_updated = 1;
2181 	int diag;
2182 	uint16_t i;
2183 	int ret;
2184 
2185 	if (!strcmp(res->value, "all"))
2186 		rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2187 			ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2188 			ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2189 			ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2190 			ETH_RSS_ECPRI;
2191 	else if (!strcmp(res->value, "eth"))
2192 		rss_conf.rss_hf = ETH_RSS_ETH;
2193 	else if (!strcmp(res->value, "vlan"))
2194 		rss_conf.rss_hf = ETH_RSS_VLAN;
2195 	else if (!strcmp(res->value, "ip"))
2196 		rss_conf.rss_hf = ETH_RSS_IP;
2197 	else if (!strcmp(res->value, "udp"))
2198 		rss_conf.rss_hf = ETH_RSS_UDP;
2199 	else if (!strcmp(res->value, "tcp"))
2200 		rss_conf.rss_hf = ETH_RSS_TCP;
2201 	else if (!strcmp(res->value, "sctp"))
2202 		rss_conf.rss_hf = ETH_RSS_SCTP;
2203 	else if (!strcmp(res->value, "ether"))
2204 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2205 	else if (!strcmp(res->value, "port"))
2206 		rss_conf.rss_hf = ETH_RSS_PORT;
2207 	else if (!strcmp(res->value, "vxlan"))
2208 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2209 	else if (!strcmp(res->value, "geneve"))
2210 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2211 	else if (!strcmp(res->value, "nvgre"))
2212 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2213 	else if (!strcmp(res->value, "l3-pre32"))
2214 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2215 	else if (!strcmp(res->value, "l3-pre40"))
2216 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2217 	else if (!strcmp(res->value, "l3-pre48"))
2218 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2219 	else if (!strcmp(res->value, "l3-pre56"))
2220 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2221 	else if (!strcmp(res->value, "l3-pre64"))
2222 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2223 	else if (!strcmp(res->value, "l3-pre96"))
2224 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2225 	else if (!strcmp(res->value, "l3-src-only"))
2226 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2227 	else if (!strcmp(res->value, "l3-dst-only"))
2228 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2229 	else if (!strcmp(res->value, "l4-src-only"))
2230 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2231 	else if (!strcmp(res->value, "l4-dst-only"))
2232 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2233 	else if (!strcmp(res->value, "l2-src-only"))
2234 		rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2235 	else if (!strcmp(res->value, "l2-dst-only"))
2236 		rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2237 	else if (!strcmp(res->value, "l2tpv3"))
2238 		rss_conf.rss_hf = ETH_RSS_L2TPV3;
2239 	else if (!strcmp(res->value, "esp"))
2240 		rss_conf.rss_hf = ETH_RSS_ESP;
2241 	else if (!strcmp(res->value, "ah"))
2242 		rss_conf.rss_hf = ETH_RSS_AH;
2243 	else if (!strcmp(res->value, "pfcp"))
2244 		rss_conf.rss_hf = ETH_RSS_PFCP;
2245 	else if (!strcmp(res->value, "pppoe"))
2246 		rss_conf.rss_hf = ETH_RSS_PPPOE;
2247 	else if (!strcmp(res->value, "gtpu"))
2248 		rss_conf.rss_hf = ETH_RSS_GTPU;
2249 	else if (!strcmp(res->value, "ecpri"))
2250 		rss_conf.rss_hf = ETH_RSS_ECPRI;
2251 	else if (!strcmp(res->value, "mpls"))
2252 		rss_conf.rss_hf = ETH_RSS_MPLS;
2253 	else if (!strcmp(res->value, "none"))
2254 		rss_conf.rss_hf = 0;
2255 	else if (!strcmp(res->value, "level-default")) {
2256 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2257 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2258 	} else if (!strcmp(res->value, "level-outer")) {
2259 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2260 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2261 	} else if (!strcmp(res->value, "level-inner")) {
2262 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2263 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2264 	} else if (!strcmp(res->value, "default"))
2265 		use_default = 1;
2266 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2267 						atoi(res->value) < 64)
2268 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2269 	else {
2270 		printf("Unknown parameter\n");
2271 		return;
2272 	}
2273 	rss_conf.rss_key = NULL;
2274 	/* Update global configuration for RSS types. */
2275 	RTE_ETH_FOREACH_DEV(i) {
2276 		struct rte_eth_rss_conf local_rss_conf;
2277 
2278 		ret = eth_dev_info_get_print_err(i, &dev_info);
2279 		if (ret != 0)
2280 			return;
2281 
2282 		if (use_default)
2283 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2284 
2285 		local_rss_conf = rss_conf;
2286 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2287 			dev_info.flow_type_rss_offloads;
2288 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2289 			printf("Port %u modified RSS hash function based on hardware support,"
2290 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2291 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2292 		}
2293 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2294 		if (diag < 0) {
2295 			all_updated = 0;
2296 			printf("Configuration of RSS hash at ethernet port %d "
2297 				"failed with error (%d): %s.\n",
2298 				i, -diag, strerror(-diag));
2299 		}
2300 	}
2301 	if (all_updated && !use_default) {
2302 		rss_hf = rss_conf.rss_hf;
2303 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2304 	}
2305 }
2306 
2307 cmdline_parse_token_string_t cmd_config_rss_port =
2308 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2309 cmdline_parse_token_string_t cmd_config_rss_keyword =
2310 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2311 cmdline_parse_token_string_t cmd_config_rss_all =
2312 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2313 cmdline_parse_token_string_t cmd_config_rss_name =
2314 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2315 cmdline_parse_token_string_t cmd_config_rss_value =
2316 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2317 
2318 cmdline_parse_inst_t cmd_config_rss = {
2319 	.f = cmd_config_rss_parsed,
2320 	.data = NULL,
2321 	.help_str = "port config all rss "
2322 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2323 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2324 		"level-outer|level-inner|<flowtype_id>",
2325 	.tokens = {
2326 		(void *)&cmd_config_rss_port,
2327 		(void *)&cmd_config_rss_keyword,
2328 		(void *)&cmd_config_rss_all,
2329 		(void *)&cmd_config_rss_name,
2330 		(void *)&cmd_config_rss_value,
2331 		NULL,
2332 	},
2333 };
2334 
2335 /* *** configure rss hash key *** */
2336 struct cmd_config_rss_hash_key {
2337 	cmdline_fixed_string_t port;
2338 	cmdline_fixed_string_t config;
2339 	portid_t port_id;
2340 	cmdline_fixed_string_t rss_hash_key;
2341 	cmdline_fixed_string_t rss_type;
2342 	cmdline_fixed_string_t key;
2343 };
2344 
2345 static uint8_t
2346 hexa_digit_to_value(char hexa_digit)
2347 {
2348 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2349 		return (uint8_t) (hexa_digit - '0');
2350 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2351 		return (uint8_t) ((hexa_digit - 'a') + 10);
2352 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2353 		return (uint8_t) ((hexa_digit - 'A') + 10);
2354 	/* Invalid hexa digit */
2355 	return 0xFF;
2356 }
2357 
2358 static uint8_t
2359 parse_and_check_key_hexa_digit(char *key, int idx)
2360 {
2361 	uint8_t hexa_v;
2362 
2363 	hexa_v = hexa_digit_to_value(key[idx]);
2364 	if (hexa_v == 0xFF)
2365 		printf("invalid key: character %c at position %d is not a "
2366 		       "valid hexa digit\n", key[idx], idx);
2367 	return hexa_v;
2368 }
2369 
2370 static void
2371 cmd_config_rss_hash_key_parsed(void *parsed_result,
2372 			       __rte_unused struct cmdline *cl,
2373 			       __rte_unused void *data)
2374 {
2375 	struct cmd_config_rss_hash_key *res = parsed_result;
2376 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2377 	uint8_t xdgt0;
2378 	uint8_t xdgt1;
2379 	int i;
2380 	struct rte_eth_dev_info dev_info;
2381 	uint8_t hash_key_size;
2382 	uint32_t key_len;
2383 	int ret;
2384 
2385 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2386 	if (ret != 0)
2387 		return;
2388 
2389 	if (dev_info.hash_key_size > 0 &&
2390 			dev_info.hash_key_size <= sizeof(hash_key))
2391 		hash_key_size = dev_info.hash_key_size;
2392 	else {
2393 		printf("dev_info did not provide a valid hash key size\n");
2394 		return;
2395 	}
2396 	/* Check the length of the RSS hash key */
2397 	key_len = strlen(res->key);
2398 	if (key_len != (hash_key_size * 2)) {
2399 		printf("key length: %d invalid - key must be a string of %d"
2400 			   " hexa-decimal numbers\n",
2401 			   (int) key_len, hash_key_size * 2);
2402 		return;
2403 	}
2404 	/* Translate RSS hash key into binary representation */
2405 	for (i = 0; i < hash_key_size; i++) {
2406 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2407 		if (xdgt0 == 0xFF)
2408 			return;
2409 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2410 		if (xdgt1 == 0xFF)
2411 			return;
2412 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2413 	}
2414 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2415 			hash_key_size);
2416 }
2417 
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2419 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2420 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2421 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2422 				 "config");
2423 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2424 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2425 				 RTE_UINT16);
2426 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2427 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2428 				 rss_hash_key, "rss-hash-key");
2429 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2430 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2431 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2432 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2433 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2434 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2435 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2436 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2437 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2438 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2439 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2440 
2441 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2442 	.f = cmd_config_rss_hash_key_parsed,
2443 	.data = NULL,
2444 	.help_str = "port config <port_id> rss-hash-key "
2445 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2446 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2447 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2448 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2449 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2450 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2451 		"<string of hex digits (variable length, NIC dependent)>",
2452 	.tokens = {
2453 		(void *)&cmd_config_rss_hash_key_port,
2454 		(void *)&cmd_config_rss_hash_key_config,
2455 		(void *)&cmd_config_rss_hash_key_port_id,
2456 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2457 		(void *)&cmd_config_rss_hash_key_rss_type,
2458 		(void *)&cmd_config_rss_hash_key_value,
2459 		NULL,
2460 	},
2461 };
2462 
2463 /* *** cleanup txq mbufs *** */
2464 struct cmd_cleanup_txq_mbufs_result {
2465 	cmdline_fixed_string_t port;
2466 	cmdline_fixed_string_t keyword;
2467 	cmdline_fixed_string_t name;
2468 	uint16_t port_id;
2469 	uint16_t queue_id;
2470 	uint32_t free_cnt;
2471 };
2472 
2473 static void
2474 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2475 			     __rte_unused struct cmdline *cl,
2476 			     __rte_unused void *data)
2477 {
2478 	struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2479 	uint16_t port_id = res->port_id;
2480 	uint16_t queue_id = res->queue_id;
2481 	uint32_t free_cnt = res->free_cnt;
2482 	struct rte_eth_txq_info qinfo;
2483 	int ret;
2484 
2485 	if (test_done == 0) {
2486 		printf("Please stop forwarding first\n");
2487 		return;
2488 	}
2489 
2490 	if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2491 		printf("Failed to get port %u Tx queue %u info\n",
2492 		       port_id, queue_id);
2493 		return;
2494 	}
2495 
2496 	if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2497 		printf("Tx queue %u not started\n", queue_id);
2498 		return;
2499 	}
2500 
2501 	ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2502 	if (ret < 0) {
2503 		printf("Failed to cleanup mbuf for port %u Tx queue %u "
2504 		       "error desc: %s(%d)\n",
2505 		       port_id, queue_id, strerror(-ret), ret);
2506 		return;
2507 	}
2508 
2509 	printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2510 	       port_id, queue_id, ret);
2511 }
2512 
2513 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2514 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2515 				 "port");
2516 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2517 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2518 				 "cleanup");
2519 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2520 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2521 			      RTE_UINT16);
2522 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2523 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2524 				 "txq");
2525 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2526 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2527 			      RTE_UINT16);
2528 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2529 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2530 			      RTE_UINT32);
2531 
2532 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2533 	.f = cmd_cleanup_txq_mbufs_parsed,
2534 	.data = NULL,
2535 	.help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2536 	.tokens = {
2537 		(void *)&cmd_cleanup_txq_mbufs_port,
2538 		(void *)&cmd_cleanup_txq_mbufs_cleanup,
2539 		(void *)&cmd_cleanup_txq_mbufs_port_id,
2540 		(void *)&cmd_cleanup_txq_mbufs_txq,
2541 		(void *)&cmd_cleanup_txq_mbufs_queue_id,
2542 		(void *)&cmd_cleanup_txq_mbufs_free_cnt,
2543 		NULL,
2544 	},
2545 };
2546 
2547 /* *** configure port rxq/txq ring size *** */
2548 struct cmd_config_rxtx_ring_size {
2549 	cmdline_fixed_string_t port;
2550 	cmdline_fixed_string_t config;
2551 	portid_t portid;
2552 	cmdline_fixed_string_t rxtxq;
2553 	uint16_t qid;
2554 	cmdline_fixed_string_t rsize;
2555 	uint16_t size;
2556 };
2557 
2558 static void
2559 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2560 				 __rte_unused struct cmdline *cl,
2561 				 __rte_unused void *data)
2562 {
2563 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2564 	struct rte_port *port;
2565 	uint8_t isrx;
2566 
2567 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2568 		return;
2569 
2570 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2571 		printf("Invalid port id\n");
2572 		return;
2573 	}
2574 
2575 	port = &ports[res->portid];
2576 
2577 	if (!strcmp(res->rxtxq, "rxq"))
2578 		isrx = 1;
2579 	else if (!strcmp(res->rxtxq, "txq"))
2580 		isrx = 0;
2581 	else {
2582 		printf("Unknown parameter\n");
2583 		return;
2584 	}
2585 
2586 	if (isrx && rx_queue_id_is_invalid(res->qid))
2587 		return;
2588 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2589 		return;
2590 
2591 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2592 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2593 		       rx_free_thresh);
2594 		return;
2595 	}
2596 
2597 	if (isrx)
2598 		port->nb_rx_desc[res->qid] = res->size;
2599 	else
2600 		port->nb_tx_desc[res->qid] = res->size;
2601 
2602 	cmd_reconfig_device_queue(res->portid, 0, 1);
2603 }
2604 
2605 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2606 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 				 port, "port");
2608 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2609 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 				 config, "config");
2611 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2612 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2613 				 portid, RTE_UINT16);
2614 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2615 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 				 rxtxq, "rxq#txq");
2617 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2618 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2619 			      qid, RTE_UINT16);
2620 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2621 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2622 				 rsize, "ring_size");
2623 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2624 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2625 			      size, RTE_UINT16);
2626 
2627 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2628 	.f = cmd_config_rxtx_ring_size_parsed,
2629 	.data = NULL,
2630 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2631 	.tokens = {
2632 		(void *)&cmd_config_rxtx_ring_size_port,
2633 		(void *)&cmd_config_rxtx_ring_size_config,
2634 		(void *)&cmd_config_rxtx_ring_size_portid,
2635 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2636 		(void *)&cmd_config_rxtx_ring_size_qid,
2637 		(void *)&cmd_config_rxtx_ring_size_rsize,
2638 		(void *)&cmd_config_rxtx_ring_size_size,
2639 		NULL,
2640 	},
2641 };
2642 
2643 /* *** configure port rxq/txq start/stop *** */
2644 struct cmd_config_rxtx_queue {
2645 	cmdline_fixed_string_t port;
2646 	portid_t portid;
2647 	cmdline_fixed_string_t rxtxq;
2648 	uint16_t qid;
2649 	cmdline_fixed_string_t opname;
2650 };
2651 
2652 static void
2653 cmd_config_rxtx_queue_parsed(void *parsed_result,
2654 			__rte_unused struct cmdline *cl,
2655 			__rte_unused void *data)
2656 {
2657 	struct cmd_config_rxtx_queue *res = parsed_result;
2658 	uint8_t isrx;
2659 	uint8_t isstart;
2660 	int ret = 0;
2661 
2662 	if (test_done == 0) {
2663 		printf("Please stop forwarding first\n");
2664 		return;
2665 	}
2666 
2667 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2668 		return;
2669 
2670 	if (port_is_started(res->portid) != 1) {
2671 		printf("Please start port %u first\n", res->portid);
2672 		return;
2673 	}
2674 
2675 	if (!strcmp(res->rxtxq, "rxq"))
2676 		isrx = 1;
2677 	else if (!strcmp(res->rxtxq, "txq"))
2678 		isrx = 0;
2679 	else {
2680 		printf("Unknown parameter\n");
2681 		return;
2682 	}
2683 
2684 	if (isrx && rx_queue_id_is_invalid(res->qid))
2685 		return;
2686 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2687 		return;
2688 
2689 	if (!strcmp(res->opname, "start"))
2690 		isstart = 1;
2691 	else if (!strcmp(res->opname, "stop"))
2692 		isstart = 0;
2693 	else {
2694 		printf("Unknown parameter\n");
2695 		return;
2696 	}
2697 
2698 	if (isstart && isrx)
2699 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2700 	else if (!isstart && isrx)
2701 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2702 	else if (isstart && !isrx)
2703 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2704 	else
2705 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2706 
2707 	if (ret == -ENOTSUP)
2708 		printf("Function not supported in PMD driver\n");
2709 }
2710 
2711 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2712 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2713 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2714 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2715 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2716 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2717 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2718 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2719 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2720 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2721 						"start#stop");
2722 
2723 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2724 	.f = cmd_config_rxtx_queue_parsed,
2725 	.data = NULL,
2726 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2727 	.tokens = {
2728 		(void *)&cmd_config_rxtx_queue_port,
2729 		(void *)&cmd_config_rxtx_queue_portid,
2730 		(void *)&cmd_config_rxtx_queue_rxtxq,
2731 		(void *)&cmd_config_rxtx_queue_qid,
2732 		(void *)&cmd_config_rxtx_queue_opname,
2733 		NULL,
2734 	},
2735 };
2736 
2737 /* *** configure port rxq/txq deferred start on/off *** */
2738 struct cmd_config_deferred_start_rxtx_queue {
2739 	cmdline_fixed_string_t port;
2740 	portid_t port_id;
2741 	cmdline_fixed_string_t rxtxq;
2742 	uint16_t qid;
2743 	cmdline_fixed_string_t opname;
2744 	cmdline_fixed_string_t state;
2745 };
2746 
2747 static void
2748 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2749 			__rte_unused struct cmdline *cl,
2750 			__rte_unused void *data)
2751 {
2752 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2753 	struct rte_port *port;
2754 	uint8_t isrx;
2755 	uint8_t ison;
2756 	uint8_t needreconfig = 0;
2757 
2758 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2759 		return;
2760 
2761 	if (port_is_started(res->port_id) != 0) {
2762 		printf("Please stop port %u first\n", res->port_id);
2763 		return;
2764 	}
2765 
2766 	port = &ports[res->port_id];
2767 
2768 	isrx = !strcmp(res->rxtxq, "rxq");
2769 
2770 	if (isrx && rx_queue_id_is_invalid(res->qid))
2771 		return;
2772 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2773 		return;
2774 
2775 	ison = !strcmp(res->state, "on");
2776 
2777 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2778 		port->rx_conf[res->qid].rx_deferred_start = ison;
2779 		needreconfig = 1;
2780 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2781 		port->tx_conf[res->qid].tx_deferred_start = ison;
2782 		needreconfig = 1;
2783 	}
2784 
2785 	if (needreconfig)
2786 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2787 }
2788 
2789 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2790 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 						port, "port");
2792 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2793 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2794 						port_id, RTE_UINT16);
2795 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2796 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 						rxtxq, "rxq#txq");
2798 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2799 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2800 						qid, RTE_UINT16);
2801 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2802 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2803 						opname, "deferred_start");
2804 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2805 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2806 						state, "on#off");
2807 
2808 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2809 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2810 	.data = NULL,
2811 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2812 	.tokens = {
2813 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2814 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2815 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2816 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2817 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2818 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2819 		NULL,
2820 	},
2821 };
2822 
2823 /* *** configure port rxq/txq setup *** */
2824 struct cmd_setup_rxtx_queue {
2825 	cmdline_fixed_string_t port;
2826 	portid_t portid;
2827 	cmdline_fixed_string_t rxtxq;
2828 	uint16_t qid;
2829 	cmdline_fixed_string_t setup;
2830 };
2831 
2832 /* Common CLI fields for queue setup */
2833 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2834 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2835 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2836 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2837 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2838 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2839 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2840 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2841 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2842 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2843 
2844 static void
2845 cmd_setup_rxtx_queue_parsed(
2846 	void *parsed_result,
2847 	__rte_unused struct cmdline *cl,
2848 	__rte_unused void *data)
2849 {
2850 	struct cmd_setup_rxtx_queue *res = parsed_result;
2851 	struct rte_port *port;
2852 	struct rte_mempool *mp;
2853 	unsigned int socket_id;
2854 	uint8_t isrx = 0;
2855 	int ret;
2856 
2857 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2858 		return;
2859 
2860 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2861 		printf("Invalid port id\n");
2862 		return;
2863 	}
2864 
2865 	if (!strcmp(res->rxtxq, "rxq"))
2866 		isrx = 1;
2867 	else if (!strcmp(res->rxtxq, "txq"))
2868 		isrx = 0;
2869 	else {
2870 		printf("Unknown parameter\n");
2871 		return;
2872 	}
2873 
2874 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2875 		printf("Invalid rx queue\n");
2876 		return;
2877 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2878 		printf("Invalid tx queue\n");
2879 		return;
2880 	}
2881 
2882 	port = &ports[res->portid];
2883 	if (isrx) {
2884 		socket_id = rxring_numa[res->portid];
2885 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2886 			socket_id = port->socket_id;
2887 
2888 		mp = mbuf_pool_find(socket_id, 0);
2889 		if (mp == NULL) {
2890 			printf("Failed to setup RX queue: "
2891 				"No mempool allocation"
2892 				" on the socket %d\n",
2893 				rxring_numa[res->portid]);
2894 			return;
2895 		}
2896 		ret = rx_queue_setup(res->portid,
2897 				     res->qid,
2898 				     port->nb_rx_desc[res->qid],
2899 				     socket_id,
2900 				     &port->rx_conf[res->qid],
2901 				     mp);
2902 		if (ret)
2903 			printf("Failed to setup RX queue\n");
2904 	} else {
2905 		socket_id = txring_numa[res->portid];
2906 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2907 			socket_id = port->socket_id;
2908 
2909 		if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2910 			printf("Failed to setup TX queue: not enough descriptors\n");
2911 			return;
2912 		}
2913 		ret = rte_eth_tx_queue_setup(res->portid,
2914 					     res->qid,
2915 					     port->nb_tx_desc[res->qid],
2916 					     socket_id,
2917 					     &port->tx_conf[res->qid]);
2918 		if (ret)
2919 			printf("Failed to setup TX queue\n");
2920 	}
2921 }
2922 
2923 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2924 	.f = cmd_setup_rxtx_queue_parsed,
2925 	.data = NULL,
2926 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2927 	.tokens = {
2928 		(void *)&cmd_setup_rxtx_queue_port,
2929 		(void *)&cmd_setup_rxtx_queue_portid,
2930 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2931 		(void *)&cmd_setup_rxtx_queue_qid,
2932 		(void *)&cmd_setup_rxtx_queue_setup,
2933 		NULL,
2934 	},
2935 };
2936 
2937 
2938 /* *** Configure RSS RETA *** */
2939 struct cmd_config_rss_reta {
2940 	cmdline_fixed_string_t port;
2941 	cmdline_fixed_string_t keyword;
2942 	portid_t port_id;
2943 	cmdline_fixed_string_t name;
2944 	cmdline_fixed_string_t list_name;
2945 	cmdline_fixed_string_t list_of_items;
2946 };
2947 
2948 static int
2949 parse_reta_config(const char *str,
2950 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2951 		  uint16_t nb_entries)
2952 {
2953 	int i;
2954 	unsigned size;
2955 	uint16_t hash_index, idx, shift;
2956 	uint16_t nb_queue;
2957 	char s[256];
2958 	const char *p, *p0 = str;
2959 	char *end;
2960 	enum fieldnames {
2961 		FLD_HASH_INDEX = 0,
2962 		FLD_QUEUE,
2963 		_NUM_FLD
2964 	};
2965 	unsigned long int_fld[_NUM_FLD];
2966 	char *str_fld[_NUM_FLD];
2967 
2968 	while ((p = strchr(p0,'(')) != NULL) {
2969 		++p;
2970 		if((p0 = strchr(p,')')) == NULL)
2971 			return -1;
2972 
2973 		size = p0 - p;
2974 		if(size >= sizeof(s))
2975 			return -1;
2976 
2977 		snprintf(s, sizeof(s), "%.*s", size, p);
2978 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2979 			return -1;
2980 		for (i = 0; i < _NUM_FLD; i++) {
2981 			errno = 0;
2982 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2983 			if (errno != 0 || end == str_fld[i] ||
2984 					int_fld[i] > 65535)
2985 				return -1;
2986 		}
2987 
2988 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2989 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2990 
2991 		if (hash_index >= nb_entries) {
2992 			printf("Invalid RETA hash index=%d\n", hash_index);
2993 			return -1;
2994 		}
2995 
2996 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2997 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2998 		reta_conf[idx].mask |= (1ULL << shift);
2999 		reta_conf[idx].reta[shift] = nb_queue;
3000 	}
3001 
3002 	return 0;
3003 }
3004 
3005 static void
3006 cmd_set_rss_reta_parsed(void *parsed_result,
3007 			__rte_unused struct cmdline *cl,
3008 			__rte_unused void *data)
3009 {
3010 	int ret;
3011 	struct rte_eth_dev_info dev_info;
3012 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3013 	struct cmd_config_rss_reta *res = parsed_result;
3014 
3015 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3016 	if (ret != 0)
3017 		return;
3018 
3019 	if (dev_info.reta_size == 0) {
3020 		printf("Redirection table size is 0 which is "
3021 					"invalid for RSS\n");
3022 		return;
3023 	} else
3024 		printf("The reta size of port %d is %u\n",
3025 			res->port_id, dev_info.reta_size);
3026 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3027 		printf("Currently do not support more than %u entries of "
3028 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
3029 		return;
3030 	}
3031 
3032 	memset(reta_conf, 0, sizeof(reta_conf));
3033 	if (!strcmp(res->list_name, "reta")) {
3034 		if (parse_reta_config(res->list_of_items, reta_conf,
3035 						dev_info.reta_size)) {
3036 			printf("Invalid RSS Redirection Table "
3037 					"config entered\n");
3038 			return;
3039 		}
3040 		ret = rte_eth_dev_rss_reta_update(res->port_id,
3041 				reta_conf, dev_info.reta_size);
3042 		if (ret != 0)
3043 			printf("Bad redirection table parameter, "
3044 					"return code = %d \n", ret);
3045 	}
3046 }
3047 
3048 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3049 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3050 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3051 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3052 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3053 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3054 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3055 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3056 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3057 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3058 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3059         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3060                                  NULL);
3061 cmdline_parse_inst_t cmd_config_rss_reta = {
3062 	.f = cmd_set_rss_reta_parsed,
3063 	.data = NULL,
3064 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3065 	.tokens = {
3066 		(void *)&cmd_config_rss_reta_port,
3067 		(void *)&cmd_config_rss_reta_keyword,
3068 		(void *)&cmd_config_rss_reta_port_id,
3069 		(void *)&cmd_config_rss_reta_name,
3070 		(void *)&cmd_config_rss_reta_list_name,
3071 		(void *)&cmd_config_rss_reta_list_of_items,
3072 		NULL,
3073 	},
3074 };
3075 
3076 /* *** SHOW PORT RETA INFO *** */
3077 struct cmd_showport_reta {
3078 	cmdline_fixed_string_t show;
3079 	cmdline_fixed_string_t port;
3080 	portid_t port_id;
3081 	cmdline_fixed_string_t rss;
3082 	cmdline_fixed_string_t reta;
3083 	uint16_t size;
3084 	cmdline_fixed_string_t list_of_items;
3085 };
3086 
3087 static int
3088 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3089 			   uint16_t nb_entries,
3090 			   char *str)
3091 {
3092 	uint32_t size;
3093 	const char *p, *p0 = str;
3094 	char s[256];
3095 	char *end;
3096 	char *str_fld[8];
3097 	uint16_t i;
3098 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3099 			RTE_RETA_GROUP_SIZE;
3100 	int ret;
3101 
3102 	p = strchr(p0, '(');
3103 	if (p == NULL)
3104 		return -1;
3105 	p++;
3106 	p0 = strchr(p, ')');
3107 	if (p0 == NULL)
3108 		return -1;
3109 	size = p0 - p;
3110 	if (size >= sizeof(s)) {
3111 		printf("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 		printf("The bits of masks do not match the number of "
3118 					"reta entries: %u\n", num);
3119 		return -1;
3120 	}
3121 	for (i = 0; i < ret; i++)
3122 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3123 
3124 	return 0;
3125 }
3126 
3127 static void
3128 cmd_showport_reta_parsed(void *parsed_result,
3129 			 __rte_unused struct cmdline *cl,
3130 			 __rte_unused void *data)
3131 {
3132 	struct cmd_showport_reta *res = parsed_result;
3133 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3134 	struct rte_eth_dev_info dev_info;
3135 	uint16_t max_reta_size;
3136 	int ret;
3137 
3138 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3139 	if (ret != 0)
3140 		return;
3141 
3142 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3143 	if (res->size == 0 || res->size > max_reta_size) {
3144 		printf("Invalid redirection table size: %u (1-%u)\n",
3145 			res->size, max_reta_size);
3146 		return;
3147 	}
3148 
3149 	memset(reta_conf, 0, sizeof(reta_conf));
3150 	if (showport_parse_reta_config(reta_conf, res->size,
3151 				res->list_of_items) < 0) {
3152 		printf("Invalid string: %s for reta masks\n",
3153 					res->list_of_items);
3154 		return;
3155 	}
3156 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3157 }
3158 
3159 cmdline_parse_token_string_t cmd_showport_reta_show =
3160 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3161 cmdline_parse_token_string_t cmd_showport_reta_port =
3162 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3163 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3164 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3165 cmdline_parse_token_string_t cmd_showport_reta_rss =
3166 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3167 cmdline_parse_token_string_t cmd_showport_reta_reta =
3168 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3169 cmdline_parse_token_num_t cmd_showport_reta_size =
3170 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3171 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3172 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3173 					list_of_items, NULL);
3174 
3175 cmdline_parse_inst_t cmd_showport_reta = {
3176 	.f = cmd_showport_reta_parsed,
3177 	.data = NULL,
3178 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3179 	.tokens = {
3180 		(void *)&cmd_showport_reta_show,
3181 		(void *)&cmd_showport_reta_port,
3182 		(void *)&cmd_showport_reta_port_id,
3183 		(void *)&cmd_showport_reta_rss,
3184 		(void *)&cmd_showport_reta_reta,
3185 		(void *)&cmd_showport_reta_size,
3186 		(void *)&cmd_showport_reta_list_of_items,
3187 		NULL,
3188 	},
3189 };
3190 
3191 /* *** Show RSS hash configuration *** */
3192 struct cmd_showport_rss_hash {
3193 	cmdline_fixed_string_t show;
3194 	cmdline_fixed_string_t port;
3195 	portid_t port_id;
3196 	cmdline_fixed_string_t rss_hash;
3197 	cmdline_fixed_string_t rss_type;
3198 	cmdline_fixed_string_t key; /* optional argument */
3199 };
3200 
3201 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3202 				__rte_unused struct cmdline *cl,
3203 				void *show_rss_key)
3204 {
3205 	struct cmd_showport_rss_hash *res = parsed_result;
3206 
3207 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3208 }
3209 
3210 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3211 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3212 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3213 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3214 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3215 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3216 				 RTE_UINT16);
3217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3218 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3219 				 "rss-hash");
3220 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3221 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3222 
3223 cmdline_parse_inst_t cmd_showport_rss_hash = {
3224 	.f = cmd_showport_rss_hash_parsed,
3225 	.data = NULL,
3226 	.help_str = "show port <port_id> rss-hash",
3227 	.tokens = {
3228 		(void *)&cmd_showport_rss_hash_show,
3229 		(void *)&cmd_showport_rss_hash_port,
3230 		(void *)&cmd_showport_rss_hash_port_id,
3231 		(void *)&cmd_showport_rss_hash_rss_hash,
3232 		NULL,
3233 	},
3234 };
3235 
3236 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3237 	.f = cmd_showport_rss_hash_parsed,
3238 	.data = (void *)1,
3239 	.help_str = "show port <port_id> rss-hash key",
3240 	.tokens = {
3241 		(void *)&cmd_showport_rss_hash_show,
3242 		(void *)&cmd_showport_rss_hash_port,
3243 		(void *)&cmd_showport_rss_hash_port_id,
3244 		(void *)&cmd_showport_rss_hash_rss_hash,
3245 		(void *)&cmd_showport_rss_hash_rss_key,
3246 		NULL,
3247 	},
3248 };
3249 
3250 /* *** Configure DCB *** */
3251 struct cmd_config_dcb {
3252 	cmdline_fixed_string_t port;
3253 	cmdline_fixed_string_t config;
3254 	portid_t port_id;
3255 	cmdline_fixed_string_t dcb;
3256 	cmdline_fixed_string_t vt;
3257 	cmdline_fixed_string_t vt_en;
3258 	uint8_t num_tcs;
3259 	cmdline_fixed_string_t pfc;
3260 	cmdline_fixed_string_t pfc_en;
3261 };
3262 
3263 static void
3264 cmd_config_dcb_parsed(void *parsed_result,
3265                         __rte_unused struct cmdline *cl,
3266                         __rte_unused void *data)
3267 {
3268 	struct cmd_config_dcb *res = parsed_result;
3269 	struct rte_eth_dcb_info dcb_info;
3270 	portid_t port_id = res->port_id;
3271 	struct rte_port *port;
3272 	uint8_t pfc_en;
3273 	int ret;
3274 
3275 	port = &ports[port_id];
3276 	/** Check if the port is not started **/
3277 	if (port->port_status != RTE_PORT_STOPPED) {
3278 		printf("Please stop port %d first\n", port_id);
3279 		return;
3280 	}
3281 
3282 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3283 		printf("The invalid number of traffic class,"
3284 			" only 4 or 8 allowed.\n");
3285 		return;
3286 	}
3287 
3288 	if (nb_fwd_lcores < res->num_tcs) {
3289 		printf("nb_cores shouldn't be less than number of TCs.\n");
3290 		return;
3291 	}
3292 
3293 	/* Check whether the port supports the report of DCB info. */
3294 	ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3295 	if (ret == -ENOTSUP) {
3296 		printf("rte_eth_dev_get_dcb_info not supported.\n");
3297 		return;
3298 	}
3299 
3300 	if (!strncmp(res->pfc_en, "on", 2))
3301 		pfc_en = 1;
3302 	else
3303 		pfc_en = 0;
3304 
3305 	/* DCB in VT mode */
3306 	if (!strncmp(res->vt_en, "on", 2))
3307 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3308 				(enum rte_eth_nb_tcs)res->num_tcs,
3309 				pfc_en);
3310 	else
3311 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3312 				(enum rte_eth_nb_tcs)res->num_tcs,
3313 				pfc_en);
3314 	if (ret != 0) {
3315 		printf("Cannot initialize network ports.\n");
3316 		return;
3317 	}
3318 
3319 	fwd_config_setup();
3320 
3321 	cmd_reconfig_device_queue(port_id, 1, 1);
3322 }
3323 
3324 cmdline_parse_token_string_t cmd_config_dcb_port =
3325         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3326 cmdline_parse_token_string_t cmd_config_dcb_config =
3327         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3328 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3329 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3330 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3331         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3332 cmdline_parse_token_string_t cmd_config_dcb_vt =
3333         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3334 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3335         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3336 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3337 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3338 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3339         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3340 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3341         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3342 
3343 cmdline_parse_inst_t cmd_config_dcb = {
3344 	.f = cmd_config_dcb_parsed,
3345 	.data = NULL,
3346 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3347 	.tokens = {
3348 		(void *)&cmd_config_dcb_port,
3349 		(void *)&cmd_config_dcb_config,
3350 		(void *)&cmd_config_dcb_port_id,
3351 		(void *)&cmd_config_dcb_dcb,
3352 		(void *)&cmd_config_dcb_vt,
3353 		(void *)&cmd_config_dcb_vt_en,
3354 		(void *)&cmd_config_dcb_num_tcs,
3355 		(void *)&cmd_config_dcb_pfc,
3356 		(void *)&cmd_config_dcb_pfc_en,
3357                 NULL,
3358         },
3359 };
3360 
3361 /* *** configure number of packets per burst *** */
3362 struct cmd_config_burst {
3363 	cmdline_fixed_string_t port;
3364 	cmdline_fixed_string_t keyword;
3365 	cmdline_fixed_string_t all;
3366 	cmdline_fixed_string_t name;
3367 	uint16_t value;
3368 };
3369 
3370 static void
3371 cmd_config_burst_parsed(void *parsed_result,
3372 			__rte_unused struct cmdline *cl,
3373 			__rte_unused void *data)
3374 {
3375 	struct cmd_config_burst *res = parsed_result;
3376 	struct rte_eth_dev_info dev_info;
3377 	uint16_t rec_nb_pkts;
3378 	int ret;
3379 
3380 	if (!all_ports_stopped()) {
3381 		printf("Please stop all ports first\n");
3382 		return;
3383 	}
3384 
3385 	if (!strcmp(res->name, "burst")) {
3386 		if (res->value == 0) {
3387 			/* If user gives a value of zero, query the PMD for
3388 			 * its recommended Rx burst size. Testpmd uses a single
3389 			 * size for all ports, so assume all ports are the same
3390 			 * NIC model and use the values from Port 0.
3391 			 */
3392 			ret = eth_dev_info_get_print_err(0, &dev_info);
3393 			if (ret != 0)
3394 				return;
3395 
3396 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3397 
3398 			if (rec_nb_pkts == 0) {
3399 				printf("PMD does not recommend a burst size.\n"
3400 					"User provided value must be between"
3401 					" 1 and %d\n", MAX_PKT_BURST);
3402 				return;
3403 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3404 				printf("PMD recommended burst size of %d"
3405 					" exceeds maximum value of %d\n",
3406 					rec_nb_pkts, MAX_PKT_BURST);
3407 				return;
3408 			}
3409 			printf("Using PMD-provided burst value of %d\n",
3410 				rec_nb_pkts);
3411 			nb_pkt_per_burst = rec_nb_pkts;
3412 		} else if (res->value > MAX_PKT_BURST) {
3413 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3414 			return;
3415 		} else
3416 			nb_pkt_per_burst = res->value;
3417 	} else {
3418 		printf("Unknown parameter\n");
3419 		return;
3420 	}
3421 
3422 	init_port_config();
3423 
3424 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3425 }
3426 
3427 cmdline_parse_token_string_t cmd_config_burst_port =
3428 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3429 cmdline_parse_token_string_t cmd_config_burst_keyword =
3430 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3431 cmdline_parse_token_string_t cmd_config_burst_all =
3432 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3433 cmdline_parse_token_string_t cmd_config_burst_name =
3434 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3435 cmdline_parse_token_num_t cmd_config_burst_value =
3436 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3437 
3438 cmdline_parse_inst_t cmd_config_burst = {
3439 	.f = cmd_config_burst_parsed,
3440 	.data = NULL,
3441 	.help_str = "port config all burst <value>",
3442 	.tokens = {
3443 		(void *)&cmd_config_burst_port,
3444 		(void *)&cmd_config_burst_keyword,
3445 		(void *)&cmd_config_burst_all,
3446 		(void *)&cmd_config_burst_name,
3447 		(void *)&cmd_config_burst_value,
3448 		NULL,
3449 	},
3450 };
3451 
3452 /* *** configure rx/tx queues *** */
3453 struct cmd_config_thresh {
3454 	cmdline_fixed_string_t port;
3455 	cmdline_fixed_string_t keyword;
3456 	cmdline_fixed_string_t all;
3457 	cmdline_fixed_string_t name;
3458 	uint8_t value;
3459 };
3460 
3461 static void
3462 cmd_config_thresh_parsed(void *parsed_result,
3463 			__rte_unused struct cmdline *cl,
3464 			__rte_unused void *data)
3465 {
3466 	struct cmd_config_thresh *res = parsed_result;
3467 
3468 	if (!all_ports_stopped()) {
3469 		printf("Please stop all ports first\n");
3470 		return;
3471 	}
3472 
3473 	if (!strcmp(res->name, "txpt"))
3474 		tx_pthresh = res->value;
3475 	else if(!strcmp(res->name, "txht"))
3476 		tx_hthresh = res->value;
3477 	else if(!strcmp(res->name, "txwt"))
3478 		tx_wthresh = res->value;
3479 	else if(!strcmp(res->name, "rxpt"))
3480 		rx_pthresh = res->value;
3481 	else if(!strcmp(res->name, "rxht"))
3482 		rx_hthresh = res->value;
3483 	else if(!strcmp(res->name, "rxwt"))
3484 		rx_wthresh = res->value;
3485 	else {
3486 		printf("Unknown parameter\n");
3487 		return;
3488 	}
3489 
3490 	init_port_config();
3491 
3492 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3493 }
3494 
3495 cmdline_parse_token_string_t cmd_config_thresh_port =
3496 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3497 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3498 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3499 cmdline_parse_token_string_t cmd_config_thresh_all =
3500 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3501 cmdline_parse_token_string_t cmd_config_thresh_name =
3502 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3503 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3504 cmdline_parse_token_num_t cmd_config_thresh_value =
3505 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3506 
3507 cmdline_parse_inst_t cmd_config_thresh = {
3508 	.f = cmd_config_thresh_parsed,
3509 	.data = NULL,
3510 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3511 	.tokens = {
3512 		(void *)&cmd_config_thresh_port,
3513 		(void *)&cmd_config_thresh_keyword,
3514 		(void *)&cmd_config_thresh_all,
3515 		(void *)&cmd_config_thresh_name,
3516 		(void *)&cmd_config_thresh_value,
3517 		NULL,
3518 	},
3519 };
3520 
3521 /* *** configure free/rs threshold *** */
3522 struct cmd_config_threshold {
3523 	cmdline_fixed_string_t port;
3524 	cmdline_fixed_string_t keyword;
3525 	cmdline_fixed_string_t all;
3526 	cmdline_fixed_string_t name;
3527 	uint16_t value;
3528 };
3529 
3530 static void
3531 cmd_config_threshold_parsed(void *parsed_result,
3532 			__rte_unused struct cmdline *cl,
3533 			__rte_unused void *data)
3534 {
3535 	struct cmd_config_threshold *res = parsed_result;
3536 
3537 	if (!all_ports_stopped()) {
3538 		printf("Please stop all ports first\n");
3539 		return;
3540 	}
3541 
3542 	if (!strcmp(res->name, "txfreet"))
3543 		tx_free_thresh = res->value;
3544 	else if (!strcmp(res->name, "txrst"))
3545 		tx_rs_thresh = res->value;
3546 	else if (!strcmp(res->name, "rxfreet"))
3547 		rx_free_thresh = res->value;
3548 	else {
3549 		printf("Unknown parameter\n");
3550 		return;
3551 	}
3552 
3553 	init_port_config();
3554 
3555 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3556 }
3557 
3558 cmdline_parse_token_string_t cmd_config_threshold_port =
3559 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3560 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3561 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3562 								"config");
3563 cmdline_parse_token_string_t cmd_config_threshold_all =
3564 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3565 cmdline_parse_token_string_t cmd_config_threshold_name =
3566 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3567 						"txfreet#txrst#rxfreet");
3568 cmdline_parse_token_num_t cmd_config_threshold_value =
3569 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3570 
3571 cmdline_parse_inst_t cmd_config_threshold = {
3572 	.f = cmd_config_threshold_parsed,
3573 	.data = NULL,
3574 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3575 	.tokens = {
3576 		(void *)&cmd_config_threshold_port,
3577 		(void *)&cmd_config_threshold_keyword,
3578 		(void *)&cmd_config_threshold_all,
3579 		(void *)&cmd_config_threshold_name,
3580 		(void *)&cmd_config_threshold_value,
3581 		NULL,
3582 	},
3583 };
3584 
3585 /* *** stop *** */
3586 struct cmd_stop_result {
3587 	cmdline_fixed_string_t stop;
3588 };
3589 
3590 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3591 			    __rte_unused struct cmdline *cl,
3592 			    __rte_unused void *data)
3593 {
3594 	stop_packet_forwarding();
3595 }
3596 
3597 cmdline_parse_token_string_t cmd_stop_stop =
3598 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3599 
3600 cmdline_parse_inst_t cmd_stop = {
3601 	.f = cmd_stop_parsed,
3602 	.data = NULL,
3603 	.help_str = "stop: Stop packet forwarding",
3604 	.tokens = {
3605 		(void *)&cmd_stop_stop,
3606 		NULL,
3607 	},
3608 };
3609 
3610 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3611 
3612 unsigned int
3613 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3614 		unsigned int *parsed_items, int check_unique_values)
3615 {
3616 	unsigned int nb_item;
3617 	unsigned int value;
3618 	unsigned int i;
3619 	unsigned int j;
3620 	int value_ok;
3621 	char c;
3622 
3623 	/*
3624 	 * First parse all items in the list and store their value.
3625 	 */
3626 	value = 0;
3627 	nb_item = 0;
3628 	value_ok = 0;
3629 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3630 		c = str[i];
3631 		if ((c >= '0') && (c <= '9')) {
3632 			value = (unsigned int) (value * 10 + (c - '0'));
3633 			value_ok = 1;
3634 			continue;
3635 		}
3636 		if (c != ',') {
3637 			printf("character %c is not a decimal digit\n", c);
3638 			return 0;
3639 		}
3640 		if (! value_ok) {
3641 			printf("No valid value before comma\n");
3642 			return 0;
3643 		}
3644 		if (nb_item < max_items) {
3645 			parsed_items[nb_item] = value;
3646 			value_ok = 0;
3647 			value = 0;
3648 		}
3649 		nb_item++;
3650 	}
3651 	if (nb_item >= max_items) {
3652 		printf("Number of %s = %u > %u (maximum items)\n",
3653 		       item_name, nb_item + 1, max_items);
3654 		return 0;
3655 	}
3656 	parsed_items[nb_item++] = value;
3657 	if (! check_unique_values)
3658 		return nb_item;
3659 
3660 	/*
3661 	 * Then, check that all values in the list are differents.
3662 	 * No optimization here...
3663 	 */
3664 	for (i = 0; i < nb_item; i++) {
3665 		for (j = i + 1; j < nb_item; j++) {
3666 			if (parsed_items[j] == parsed_items[i]) {
3667 				printf("duplicated %s %u at index %u and %u\n",
3668 				       item_name, parsed_items[i], i, j);
3669 				return 0;
3670 			}
3671 		}
3672 	}
3673 	return nb_item;
3674 }
3675 
3676 struct cmd_set_list_result {
3677 	cmdline_fixed_string_t cmd_keyword;
3678 	cmdline_fixed_string_t list_name;
3679 	cmdline_fixed_string_t list_of_items;
3680 };
3681 
3682 static void cmd_set_list_parsed(void *parsed_result,
3683 				__rte_unused struct cmdline *cl,
3684 				__rte_unused void *data)
3685 {
3686 	struct cmd_set_list_result *res;
3687 	union {
3688 		unsigned int lcorelist[RTE_MAX_LCORE];
3689 		unsigned int portlist[RTE_MAX_ETHPORTS];
3690 	} parsed_items;
3691 	unsigned int nb_item;
3692 
3693 	if (test_done == 0) {
3694 		printf("Please stop forwarding first\n");
3695 		return;
3696 	}
3697 
3698 	res = parsed_result;
3699 	if (!strcmp(res->list_name, "corelist")) {
3700 		nb_item = parse_item_list(res->list_of_items, "core",
3701 					  RTE_MAX_LCORE,
3702 					  parsed_items.lcorelist, 1);
3703 		if (nb_item > 0) {
3704 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3705 			fwd_config_setup();
3706 		}
3707 		return;
3708 	}
3709 	if (!strcmp(res->list_name, "portlist")) {
3710 		nb_item = parse_item_list(res->list_of_items, "port",
3711 					  RTE_MAX_ETHPORTS,
3712 					  parsed_items.portlist, 1);
3713 		if (nb_item > 0) {
3714 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3715 			fwd_config_setup();
3716 		}
3717 	}
3718 }
3719 
3720 cmdline_parse_token_string_t cmd_set_list_keyword =
3721 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3722 				 "set");
3723 cmdline_parse_token_string_t cmd_set_list_name =
3724 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3725 				 "corelist#portlist");
3726 cmdline_parse_token_string_t cmd_set_list_of_items =
3727 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3728 				 NULL);
3729 
3730 cmdline_parse_inst_t cmd_set_fwd_list = {
3731 	.f = cmd_set_list_parsed,
3732 	.data = NULL,
3733 	.help_str = "set corelist|portlist <list0[,list1]*>",
3734 	.tokens = {
3735 		(void *)&cmd_set_list_keyword,
3736 		(void *)&cmd_set_list_name,
3737 		(void *)&cmd_set_list_of_items,
3738 		NULL,
3739 	},
3740 };
3741 
3742 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3743 
3744 struct cmd_setmask_result {
3745 	cmdline_fixed_string_t set;
3746 	cmdline_fixed_string_t mask;
3747 	uint64_t hexavalue;
3748 };
3749 
3750 static void cmd_set_mask_parsed(void *parsed_result,
3751 				__rte_unused struct cmdline *cl,
3752 				__rte_unused void *data)
3753 {
3754 	struct cmd_setmask_result *res = parsed_result;
3755 
3756 	if (test_done == 0) {
3757 		printf("Please stop forwarding first\n");
3758 		return;
3759 	}
3760 	if (!strcmp(res->mask, "coremask")) {
3761 		set_fwd_lcores_mask(res->hexavalue);
3762 		fwd_config_setup();
3763 	} else if (!strcmp(res->mask, "portmask")) {
3764 		set_fwd_ports_mask(res->hexavalue);
3765 		fwd_config_setup();
3766 	}
3767 }
3768 
3769 cmdline_parse_token_string_t cmd_setmask_set =
3770 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3771 cmdline_parse_token_string_t cmd_setmask_mask =
3772 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3773 				 "coremask#portmask");
3774 cmdline_parse_token_num_t cmd_setmask_value =
3775 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3776 
3777 cmdline_parse_inst_t cmd_set_fwd_mask = {
3778 	.f = cmd_set_mask_parsed,
3779 	.data = NULL,
3780 	.help_str = "set coremask|portmask <hexadecimal value>",
3781 	.tokens = {
3782 		(void *)&cmd_setmask_set,
3783 		(void *)&cmd_setmask_mask,
3784 		(void *)&cmd_setmask_value,
3785 		NULL,
3786 	},
3787 };
3788 
3789 /*
3790  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3791  */
3792 struct cmd_set_result {
3793 	cmdline_fixed_string_t set;
3794 	cmdline_fixed_string_t what;
3795 	uint16_t value;
3796 };
3797 
3798 static void cmd_set_parsed(void *parsed_result,
3799 			   __rte_unused struct cmdline *cl,
3800 			   __rte_unused void *data)
3801 {
3802 	struct cmd_set_result *res = parsed_result;
3803 	if (!strcmp(res->what, "nbport")) {
3804 		set_fwd_ports_number(res->value);
3805 		fwd_config_setup();
3806 	} else if (!strcmp(res->what, "nbcore")) {
3807 		set_fwd_lcores_number(res->value);
3808 		fwd_config_setup();
3809 	} else if (!strcmp(res->what, "burst"))
3810 		set_nb_pkt_per_burst(res->value);
3811 	else if (!strcmp(res->what, "verbose"))
3812 		set_verbose_level(res->value);
3813 }
3814 
3815 cmdline_parse_token_string_t cmd_set_set =
3816 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3817 cmdline_parse_token_string_t cmd_set_what =
3818 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3819 				 "nbport#nbcore#burst#verbose");
3820 cmdline_parse_token_num_t cmd_set_value =
3821 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3822 
3823 cmdline_parse_inst_t cmd_set_numbers = {
3824 	.f = cmd_set_parsed,
3825 	.data = NULL,
3826 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3827 	.tokens = {
3828 		(void *)&cmd_set_set,
3829 		(void *)&cmd_set_what,
3830 		(void *)&cmd_set_value,
3831 		NULL,
3832 	},
3833 };
3834 
3835 /* *** SET LOG LEVEL CONFIGURATION *** */
3836 
3837 struct cmd_set_log_result {
3838 	cmdline_fixed_string_t set;
3839 	cmdline_fixed_string_t log;
3840 	cmdline_fixed_string_t type;
3841 	uint32_t level;
3842 };
3843 
3844 static void
3845 cmd_set_log_parsed(void *parsed_result,
3846 		   __rte_unused struct cmdline *cl,
3847 		   __rte_unused void *data)
3848 {
3849 	struct cmd_set_log_result *res;
3850 	int ret;
3851 
3852 	res = parsed_result;
3853 	if (!strcmp(res->type, "global"))
3854 		rte_log_set_global_level(res->level);
3855 	else {
3856 		ret = rte_log_set_level_regexp(res->type, res->level);
3857 		if (ret < 0)
3858 			printf("Unable to set log level\n");
3859 	}
3860 }
3861 
3862 cmdline_parse_token_string_t cmd_set_log_set =
3863 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3864 cmdline_parse_token_string_t cmd_set_log_log =
3865 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3866 cmdline_parse_token_string_t cmd_set_log_type =
3867 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3868 cmdline_parse_token_num_t cmd_set_log_level =
3869 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3870 
3871 cmdline_parse_inst_t cmd_set_log = {
3872 	.f = cmd_set_log_parsed,
3873 	.data = NULL,
3874 	.help_str = "set log global|<type> <level>",
3875 	.tokens = {
3876 		(void *)&cmd_set_log_set,
3877 		(void *)&cmd_set_log_log,
3878 		(void *)&cmd_set_log_type,
3879 		(void *)&cmd_set_log_level,
3880 		NULL,
3881 	},
3882 };
3883 
3884 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3885 
3886 struct cmd_set_rxoffs_result {
3887 	cmdline_fixed_string_t cmd_keyword;
3888 	cmdline_fixed_string_t rxoffs;
3889 	cmdline_fixed_string_t seg_offsets;
3890 };
3891 
3892 static void
3893 cmd_set_rxoffs_parsed(void *parsed_result,
3894 		      __rte_unused struct cmdline *cl,
3895 		      __rte_unused void *data)
3896 {
3897 	struct cmd_set_rxoffs_result *res;
3898 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3899 	unsigned int nb_segs;
3900 
3901 	res = parsed_result;
3902 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3903 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3904 	if (nb_segs > 0)
3905 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3906 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3907 }
3908 
3909 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3910 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3911 				 cmd_keyword, "set");
3912 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3913 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3914 				 rxoffs, "rxoffs");
3915 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3916 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3917 				 seg_offsets, NULL);
3918 
3919 cmdline_parse_inst_t cmd_set_rxoffs = {
3920 	.f = cmd_set_rxoffs_parsed,
3921 	.data = NULL,
3922 	.help_str = "set rxoffs <len0[,len1]*>",
3923 	.tokens = {
3924 		(void *)&cmd_set_rxoffs_keyword,
3925 		(void *)&cmd_set_rxoffs_name,
3926 		(void *)&cmd_set_rxoffs_offsets,
3927 		NULL,
3928 	},
3929 };
3930 
3931 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3932 
3933 struct cmd_set_rxpkts_result {
3934 	cmdline_fixed_string_t cmd_keyword;
3935 	cmdline_fixed_string_t rxpkts;
3936 	cmdline_fixed_string_t seg_lengths;
3937 };
3938 
3939 static void
3940 cmd_set_rxpkts_parsed(void *parsed_result,
3941 		      __rte_unused struct cmdline *cl,
3942 		      __rte_unused void *data)
3943 {
3944 	struct cmd_set_rxpkts_result *res;
3945 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3946 	unsigned int nb_segs;
3947 
3948 	res = parsed_result;
3949 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3950 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3951 	if (nb_segs > 0)
3952 		set_rx_pkt_segments(seg_lengths, nb_segs);
3953 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3954 }
3955 
3956 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3957 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3958 				 cmd_keyword, "set");
3959 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3960 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3961 				 rxpkts, "rxpkts");
3962 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3963 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3964 				 seg_lengths, NULL);
3965 
3966 cmdline_parse_inst_t cmd_set_rxpkts = {
3967 	.f = cmd_set_rxpkts_parsed,
3968 	.data = NULL,
3969 	.help_str = "set rxpkts <len0[,len1]*>",
3970 	.tokens = {
3971 		(void *)&cmd_set_rxpkts_keyword,
3972 		(void *)&cmd_set_rxpkts_name,
3973 		(void *)&cmd_set_rxpkts_lengths,
3974 		NULL,
3975 	},
3976 };
3977 
3978 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3979 
3980 struct cmd_set_txpkts_result {
3981 	cmdline_fixed_string_t cmd_keyword;
3982 	cmdline_fixed_string_t txpkts;
3983 	cmdline_fixed_string_t seg_lengths;
3984 };
3985 
3986 static void
3987 cmd_set_txpkts_parsed(void *parsed_result,
3988 		      __rte_unused struct cmdline *cl,
3989 		      __rte_unused void *data)
3990 {
3991 	struct cmd_set_txpkts_result *res;
3992 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3993 	unsigned int nb_segs;
3994 
3995 	res = parsed_result;
3996 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3997 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3998 	if (nb_segs > 0)
3999 		set_tx_pkt_segments(seg_lengths, nb_segs);
4000 }
4001 
4002 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4003 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4004 				 cmd_keyword, "set");
4005 cmdline_parse_token_string_t cmd_set_txpkts_name =
4006 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4007 				 txpkts, "txpkts");
4008 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4009 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4010 				 seg_lengths, NULL);
4011 
4012 cmdline_parse_inst_t cmd_set_txpkts = {
4013 	.f = cmd_set_txpkts_parsed,
4014 	.data = NULL,
4015 	.help_str = "set txpkts <len0[,len1]*>",
4016 	.tokens = {
4017 		(void *)&cmd_set_txpkts_keyword,
4018 		(void *)&cmd_set_txpkts_name,
4019 		(void *)&cmd_set_txpkts_lengths,
4020 		NULL,
4021 	},
4022 };
4023 
4024 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4025 
4026 struct cmd_set_txsplit_result {
4027 	cmdline_fixed_string_t cmd_keyword;
4028 	cmdline_fixed_string_t txsplit;
4029 	cmdline_fixed_string_t mode;
4030 };
4031 
4032 static void
4033 cmd_set_txsplit_parsed(void *parsed_result,
4034 		      __rte_unused struct cmdline *cl,
4035 		      __rte_unused void *data)
4036 {
4037 	struct cmd_set_txsplit_result *res;
4038 
4039 	res = parsed_result;
4040 	set_tx_pkt_split(res->mode);
4041 }
4042 
4043 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4044 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4045 				 cmd_keyword, "set");
4046 cmdline_parse_token_string_t cmd_set_txsplit_name =
4047 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4048 				 txsplit, "txsplit");
4049 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4050 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4051 				 mode, NULL);
4052 
4053 cmdline_parse_inst_t cmd_set_txsplit = {
4054 	.f = cmd_set_txsplit_parsed,
4055 	.data = NULL,
4056 	.help_str = "set txsplit on|off|rand",
4057 	.tokens = {
4058 		(void *)&cmd_set_txsplit_keyword,
4059 		(void *)&cmd_set_txsplit_name,
4060 		(void *)&cmd_set_txsplit_mode,
4061 		NULL,
4062 	},
4063 };
4064 
4065 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4066 
4067 struct cmd_set_txtimes_result {
4068 	cmdline_fixed_string_t cmd_keyword;
4069 	cmdline_fixed_string_t txtimes;
4070 	cmdline_fixed_string_t tx_times;
4071 };
4072 
4073 static void
4074 cmd_set_txtimes_parsed(void *parsed_result,
4075 		       __rte_unused struct cmdline *cl,
4076 		       __rte_unused void *data)
4077 {
4078 	struct cmd_set_txtimes_result *res;
4079 	unsigned int tx_times[2] = {0, 0};
4080 	unsigned int n_times;
4081 
4082 	res = parsed_result;
4083 	n_times = parse_item_list(res->tx_times, "tx times",
4084 				  2, tx_times, 0);
4085 	if (n_times == 2)
4086 		set_tx_pkt_times(tx_times);
4087 }
4088 
4089 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4090 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4091 				 cmd_keyword, "set");
4092 cmdline_parse_token_string_t cmd_set_txtimes_name =
4093 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4094 				 txtimes, "txtimes");
4095 cmdline_parse_token_string_t cmd_set_txtimes_value =
4096 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4097 				 tx_times, NULL);
4098 
4099 cmdline_parse_inst_t cmd_set_txtimes = {
4100 	.f = cmd_set_txtimes_parsed,
4101 	.data = NULL,
4102 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
4103 	.tokens = {
4104 		(void *)&cmd_set_txtimes_keyword,
4105 		(void *)&cmd_set_txtimes_name,
4106 		(void *)&cmd_set_txtimes_value,
4107 		NULL,
4108 	},
4109 };
4110 
4111 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4112 struct cmd_rx_vlan_filter_all_result {
4113 	cmdline_fixed_string_t rx_vlan;
4114 	cmdline_fixed_string_t what;
4115 	cmdline_fixed_string_t all;
4116 	portid_t port_id;
4117 };
4118 
4119 static void
4120 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4121 			      __rte_unused struct cmdline *cl,
4122 			      __rte_unused void *data)
4123 {
4124 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4125 
4126 	if (!strcmp(res->what, "add"))
4127 		rx_vlan_all_filter_set(res->port_id, 1);
4128 	else
4129 		rx_vlan_all_filter_set(res->port_id, 0);
4130 }
4131 
4132 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4133 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4134 				 rx_vlan, "rx_vlan");
4135 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4136 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4137 				 what, "add#rm");
4138 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4139 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4140 				 all, "all");
4141 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4142 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4143 			      port_id, RTE_UINT16);
4144 
4145 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4146 	.f = cmd_rx_vlan_filter_all_parsed,
4147 	.data = NULL,
4148 	.help_str = "rx_vlan add|rm all <port_id>: "
4149 		"Add/Remove all identifiers to/from the set of VLAN "
4150 		"identifiers filtered by a port",
4151 	.tokens = {
4152 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4153 		(void *)&cmd_rx_vlan_filter_all_what,
4154 		(void *)&cmd_rx_vlan_filter_all_all,
4155 		(void *)&cmd_rx_vlan_filter_all_portid,
4156 		NULL,
4157 	},
4158 };
4159 
4160 /* *** VLAN OFFLOAD SET ON A PORT *** */
4161 struct cmd_vlan_offload_result {
4162 	cmdline_fixed_string_t vlan;
4163 	cmdline_fixed_string_t set;
4164 	cmdline_fixed_string_t vlan_type;
4165 	cmdline_fixed_string_t what;
4166 	cmdline_fixed_string_t on;
4167 	cmdline_fixed_string_t port_id;
4168 };
4169 
4170 static void
4171 cmd_vlan_offload_parsed(void *parsed_result,
4172 			  __rte_unused struct cmdline *cl,
4173 			  __rte_unused void *data)
4174 {
4175 	int on;
4176 	struct cmd_vlan_offload_result *res = parsed_result;
4177 	char *str;
4178 	int i, len = 0;
4179 	portid_t port_id = 0;
4180 	unsigned int tmp;
4181 
4182 	str = res->port_id;
4183 	len = strnlen(str, STR_TOKEN_SIZE);
4184 	i = 0;
4185 	/* Get port_id first */
4186 	while(i < len){
4187 		if(str[i] == ',')
4188 			break;
4189 
4190 		i++;
4191 	}
4192 	str[i]='\0';
4193 	tmp = strtoul(str, NULL, 0);
4194 	/* If port_id greater that what portid_t can represent, return */
4195 	if(tmp >= RTE_MAX_ETHPORTS)
4196 		return;
4197 	port_id = (portid_t)tmp;
4198 
4199 	if (!strcmp(res->on, "on"))
4200 		on = 1;
4201 	else
4202 		on = 0;
4203 
4204 	if (!strcmp(res->what, "strip"))
4205 		rx_vlan_strip_set(port_id,  on);
4206 	else if(!strcmp(res->what, "stripq")){
4207 		uint16_t queue_id = 0;
4208 
4209 		/* No queue_id, return */
4210 		if(i + 1 >= len) {
4211 			printf("must specify (port,queue_id)\n");
4212 			return;
4213 		}
4214 		tmp = strtoul(str + i + 1, NULL, 0);
4215 		/* If queue_id greater that what 16-bits can represent, return */
4216 		if(tmp > 0xffff)
4217 			return;
4218 
4219 		queue_id = (uint16_t)tmp;
4220 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4221 	}
4222 	else if (!strcmp(res->what, "filter"))
4223 		rx_vlan_filter_set(port_id, on);
4224 	else if (!strcmp(res->what, "qinq_strip"))
4225 		rx_vlan_qinq_strip_set(port_id, on);
4226 	else
4227 		vlan_extend_set(port_id, on);
4228 
4229 	return;
4230 }
4231 
4232 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4233 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4234 				 vlan, "vlan");
4235 cmdline_parse_token_string_t cmd_vlan_offload_set =
4236 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4237 				 set, "set");
4238 cmdline_parse_token_string_t cmd_vlan_offload_what =
4239 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4240 				what, "strip#filter#qinq_strip#extend#stripq");
4241 cmdline_parse_token_string_t cmd_vlan_offload_on =
4242 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4243 			      on, "on#off");
4244 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4245 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4246 			      port_id, NULL);
4247 
4248 cmdline_parse_inst_t cmd_vlan_offload = {
4249 	.f = cmd_vlan_offload_parsed,
4250 	.data = NULL,
4251 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4252 		"<port_id[,queue_id]>: "
4253 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4254 	.tokens = {
4255 		(void *)&cmd_vlan_offload_vlan,
4256 		(void *)&cmd_vlan_offload_set,
4257 		(void *)&cmd_vlan_offload_what,
4258 		(void *)&cmd_vlan_offload_on,
4259 		(void *)&cmd_vlan_offload_portid,
4260 		NULL,
4261 	},
4262 };
4263 
4264 /* *** VLAN TPID SET ON A PORT *** */
4265 struct cmd_vlan_tpid_result {
4266 	cmdline_fixed_string_t vlan;
4267 	cmdline_fixed_string_t set;
4268 	cmdline_fixed_string_t vlan_type;
4269 	cmdline_fixed_string_t what;
4270 	uint16_t tp_id;
4271 	portid_t port_id;
4272 };
4273 
4274 static void
4275 cmd_vlan_tpid_parsed(void *parsed_result,
4276 			  __rte_unused struct cmdline *cl,
4277 			  __rte_unused void *data)
4278 {
4279 	struct cmd_vlan_tpid_result *res = parsed_result;
4280 	enum rte_vlan_type vlan_type;
4281 
4282 	if (!strcmp(res->vlan_type, "inner"))
4283 		vlan_type = ETH_VLAN_TYPE_INNER;
4284 	else if (!strcmp(res->vlan_type, "outer"))
4285 		vlan_type = ETH_VLAN_TYPE_OUTER;
4286 	else {
4287 		printf("Unknown vlan type\n");
4288 		return;
4289 	}
4290 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4291 }
4292 
4293 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4294 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4295 				 vlan, "vlan");
4296 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4297 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4298 				 set, "set");
4299 cmdline_parse_token_string_t cmd_vlan_type =
4300 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4301 				 vlan_type, "inner#outer");
4302 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4303 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4304 				 what, "tpid");
4305 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4306 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4307 			      tp_id, RTE_UINT16);
4308 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4309 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4310 			      port_id, RTE_UINT16);
4311 
4312 cmdline_parse_inst_t cmd_vlan_tpid = {
4313 	.f = cmd_vlan_tpid_parsed,
4314 	.data = NULL,
4315 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4316 		"Set the VLAN Ether type",
4317 	.tokens = {
4318 		(void *)&cmd_vlan_tpid_vlan,
4319 		(void *)&cmd_vlan_tpid_set,
4320 		(void *)&cmd_vlan_type,
4321 		(void *)&cmd_vlan_tpid_what,
4322 		(void *)&cmd_vlan_tpid_tpid,
4323 		(void *)&cmd_vlan_tpid_portid,
4324 		NULL,
4325 	},
4326 };
4327 
4328 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4329 struct cmd_rx_vlan_filter_result {
4330 	cmdline_fixed_string_t rx_vlan;
4331 	cmdline_fixed_string_t what;
4332 	uint16_t vlan_id;
4333 	portid_t port_id;
4334 };
4335 
4336 static void
4337 cmd_rx_vlan_filter_parsed(void *parsed_result,
4338 			  __rte_unused struct cmdline *cl,
4339 			  __rte_unused void *data)
4340 {
4341 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4342 
4343 	if (!strcmp(res->what, "add"))
4344 		rx_vft_set(res->port_id, res->vlan_id, 1);
4345 	else
4346 		rx_vft_set(res->port_id, res->vlan_id, 0);
4347 }
4348 
4349 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4350 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4351 				 rx_vlan, "rx_vlan");
4352 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4353 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4354 				 what, "add#rm");
4355 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4356 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4357 			      vlan_id, RTE_UINT16);
4358 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4359 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4360 			      port_id, RTE_UINT16);
4361 
4362 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4363 	.f = cmd_rx_vlan_filter_parsed,
4364 	.data = NULL,
4365 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4366 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4367 		"identifiers filtered by a port",
4368 	.tokens = {
4369 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4370 		(void *)&cmd_rx_vlan_filter_what,
4371 		(void *)&cmd_rx_vlan_filter_vlanid,
4372 		(void *)&cmd_rx_vlan_filter_portid,
4373 		NULL,
4374 	},
4375 };
4376 
4377 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4378 struct cmd_tx_vlan_set_result {
4379 	cmdline_fixed_string_t tx_vlan;
4380 	cmdline_fixed_string_t set;
4381 	portid_t port_id;
4382 	uint16_t vlan_id;
4383 };
4384 
4385 static void
4386 cmd_tx_vlan_set_parsed(void *parsed_result,
4387 		       __rte_unused struct cmdline *cl,
4388 		       __rte_unused void *data)
4389 {
4390 	struct cmd_tx_vlan_set_result *res = parsed_result;
4391 
4392 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4393 		return;
4394 
4395 	if (!port_is_stopped(res->port_id)) {
4396 		printf("Please stop port %d first\n", res->port_id);
4397 		return;
4398 	}
4399 
4400 	tx_vlan_set(res->port_id, res->vlan_id);
4401 
4402 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4403 }
4404 
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4406 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4407 				 tx_vlan, "tx_vlan");
4408 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4409 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4410 				 set, "set");
4411 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4412 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4413 			      port_id, RTE_UINT16);
4414 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4415 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4416 			      vlan_id, RTE_UINT16);
4417 
4418 cmdline_parse_inst_t cmd_tx_vlan_set = {
4419 	.f = cmd_tx_vlan_set_parsed,
4420 	.data = NULL,
4421 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4422 		"Enable hardware insertion of a single VLAN header "
4423 		"with a given TAG Identifier in packets sent on a port",
4424 	.tokens = {
4425 		(void *)&cmd_tx_vlan_set_tx_vlan,
4426 		(void *)&cmd_tx_vlan_set_set,
4427 		(void *)&cmd_tx_vlan_set_portid,
4428 		(void *)&cmd_tx_vlan_set_vlanid,
4429 		NULL,
4430 	},
4431 };
4432 
4433 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4434 struct cmd_tx_vlan_set_qinq_result {
4435 	cmdline_fixed_string_t tx_vlan;
4436 	cmdline_fixed_string_t set;
4437 	portid_t port_id;
4438 	uint16_t vlan_id;
4439 	uint16_t vlan_id_outer;
4440 };
4441 
4442 static void
4443 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4444 			    __rte_unused struct cmdline *cl,
4445 			    __rte_unused void *data)
4446 {
4447 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4448 
4449 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4450 		return;
4451 
4452 	if (!port_is_stopped(res->port_id)) {
4453 		printf("Please stop port %d first\n", res->port_id);
4454 		return;
4455 	}
4456 
4457 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4458 
4459 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4460 }
4461 
4462 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4463 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4464 		tx_vlan, "tx_vlan");
4465 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4466 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4467 		set, "set");
4468 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4469 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4470 		port_id, RTE_UINT16);
4471 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4472 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4473 		vlan_id, RTE_UINT16);
4474 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4475 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4476 		vlan_id_outer, RTE_UINT16);
4477 
4478 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4479 	.f = cmd_tx_vlan_set_qinq_parsed,
4480 	.data = NULL,
4481 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4482 		"Enable hardware insertion of double VLAN header "
4483 		"with given TAG Identifiers in packets sent on a port",
4484 	.tokens = {
4485 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4486 		(void *)&cmd_tx_vlan_set_qinq_set,
4487 		(void *)&cmd_tx_vlan_set_qinq_portid,
4488 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4489 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4490 		NULL,
4491 	},
4492 };
4493 
4494 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4495 struct cmd_tx_vlan_set_pvid_result {
4496 	cmdline_fixed_string_t tx_vlan;
4497 	cmdline_fixed_string_t set;
4498 	cmdline_fixed_string_t pvid;
4499 	portid_t port_id;
4500 	uint16_t vlan_id;
4501 	cmdline_fixed_string_t mode;
4502 };
4503 
4504 static void
4505 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4506 			    __rte_unused struct cmdline *cl,
4507 			    __rte_unused void *data)
4508 {
4509 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4510 
4511 	if (strcmp(res->mode, "on") == 0)
4512 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4513 	else
4514 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4515 }
4516 
4517 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4518 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4519 				 tx_vlan, "tx_vlan");
4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4521 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4522 				 set, "set");
4523 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4524 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4525 				 pvid, "pvid");
4526 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4527 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4528 			     port_id, RTE_UINT16);
4529 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4530 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4531 			      vlan_id, RTE_UINT16);
4532 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4533 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4534 				 mode, "on#off");
4535 
4536 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4537 	.f = cmd_tx_vlan_set_pvid_parsed,
4538 	.data = NULL,
4539 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4540 	.tokens = {
4541 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4542 		(void *)&cmd_tx_vlan_set_pvid_set,
4543 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4544 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4545 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4546 		(void *)&cmd_tx_vlan_set_pvid_mode,
4547 		NULL,
4548 	},
4549 };
4550 
4551 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4552 struct cmd_tx_vlan_reset_result {
4553 	cmdline_fixed_string_t tx_vlan;
4554 	cmdline_fixed_string_t reset;
4555 	portid_t port_id;
4556 };
4557 
4558 static void
4559 cmd_tx_vlan_reset_parsed(void *parsed_result,
4560 			 __rte_unused struct cmdline *cl,
4561 			 __rte_unused void *data)
4562 {
4563 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4564 
4565 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4566 		return;
4567 
4568 	if (!port_is_stopped(res->port_id)) {
4569 		printf("Please stop port %d first\n", res->port_id);
4570 		return;
4571 	}
4572 
4573 	tx_vlan_reset(res->port_id);
4574 
4575 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4576 }
4577 
4578 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4579 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4580 				 tx_vlan, "tx_vlan");
4581 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4582 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4583 				 reset, "reset");
4584 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4585 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4586 			      port_id, RTE_UINT16);
4587 
4588 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4589 	.f = cmd_tx_vlan_reset_parsed,
4590 	.data = NULL,
4591 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4592 		"VLAN header in packets sent on a port",
4593 	.tokens = {
4594 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4595 		(void *)&cmd_tx_vlan_reset_reset,
4596 		(void *)&cmd_tx_vlan_reset_portid,
4597 		NULL,
4598 	},
4599 };
4600 
4601 
4602 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4603 struct cmd_csum_result {
4604 	cmdline_fixed_string_t csum;
4605 	cmdline_fixed_string_t mode;
4606 	cmdline_fixed_string_t proto;
4607 	cmdline_fixed_string_t hwsw;
4608 	portid_t port_id;
4609 };
4610 
4611 static void
4612 csum_show(int port_id)
4613 {
4614 	struct rte_eth_dev_info dev_info;
4615 	uint64_t tx_offloads;
4616 	int ret;
4617 
4618 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4619 	printf("Parse tunnel is %s\n",
4620 		(ports[port_id].parse_tunnel) ? "on" : "off");
4621 	printf("IP checksum offload is %s\n",
4622 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4623 	printf("UDP checksum offload is %s\n",
4624 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4625 	printf("TCP checksum offload is %s\n",
4626 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4627 	printf("SCTP checksum offload is %s\n",
4628 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4629 	printf("Outer-Ip checksum offload is %s\n",
4630 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4631 	printf("Outer-Udp checksum offload is %s\n",
4632 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4633 
4634 	/* display warnings if configuration is not supported by the NIC */
4635 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4636 	if (ret != 0)
4637 		return;
4638 
4639 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4640 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4641 		printf("Warning: hardware IP checksum enabled but not "
4642 			"supported by port %d\n", port_id);
4643 	}
4644 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4645 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4646 		printf("Warning: hardware UDP checksum enabled but not "
4647 			"supported by port %d\n", port_id);
4648 	}
4649 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4650 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4651 		printf("Warning: hardware TCP checksum enabled but not "
4652 			"supported by port %d\n", port_id);
4653 	}
4654 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4655 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4656 		printf("Warning: hardware SCTP checksum enabled but not "
4657 			"supported by port %d\n", port_id);
4658 	}
4659 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4660 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4661 		printf("Warning: hardware outer IP checksum enabled but not "
4662 			"supported by port %d\n", port_id);
4663 	}
4664 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4665 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4666 			== 0) {
4667 		printf("Warning: hardware outer UDP checksum enabled but not "
4668 			"supported by port %d\n", port_id);
4669 	}
4670 }
4671 
4672 static void
4673 cmd_config_queue_tx_offloads(struct rte_port *port)
4674 {
4675 	int k;
4676 
4677 	/* Apply queue tx offloads configuration */
4678 	for (k = 0; k < port->dev_info.max_tx_queues; k++)
4679 		port->tx_conf[k].offloads =
4680 			port->dev_conf.txmode.offloads;
4681 }
4682 
4683 static void
4684 cmd_csum_parsed(void *parsed_result,
4685 		       __rte_unused struct cmdline *cl,
4686 		       __rte_unused void *data)
4687 {
4688 	struct cmd_csum_result *res = parsed_result;
4689 	int hw = 0;
4690 	uint64_t csum_offloads = 0;
4691 	struct rte_eth_dev_info dev_info;
4692 	int ret;
4693 
4694 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4695 		printf("invalid port %d\n", res->port_id);
4696 		return;
4697 	}
4698 	if (!port_is_stopped(res->port_id)) {
4699 		printf("Please stop port %d first\n", res->port_id);
4700 		return;
4701 	}
4702 
4703 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4704 	if (ret != 0)
4705 		return;
4706 
4707 	if (!strcmp(res->mode, "set")) {
4708 
4709 		if (!strcmp(res->hwsw, "hw"))
4710 			hw = 1;
4711 
4712 		if (!strcmp(res->proto, "ip")) {
4713 			if (hw == 0 || (dev_info.tx_offload_capa &
4714 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4715 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4716 			} else {
4717 				printf("IP checksum offload is not supported "
4718 				       "by port %u\n", res->port_id);
4719 			}
4720 		} else if (!strcmp(res->proto, "udp")) {
4721 			if (hw == 0 || (dev_info.tx_offload_capa &
4722 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4723 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4724 			} else {
4725 				printf("UDP checksum offload is not supported "
4726 				       "by port %u\n", res->port_id);
4727 			}
4728 		} else if (!strcmp(res->proto, "tcp")) {
4729 			if (hw == 0 || (dev_info.tx_offload_capa &
4730 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4731 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4732 			} else {
4733 				printf("TCP checksum offload is not supported "
4734 				       "by port %u\n", res->port_id);
4735 			}
4736 		} else if (!strcmp(res->proto, "sctp")) {
4737 			if (hw == 0 || (dev_info.tx_offload_capa &
4738 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4739 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4740 			} else {
4741 				printf("SCTP checksum offload is not supported "
4742 				       "by port %u\n", res->port_id);
4743 			}
4744 		} else if (!strcmp(res->proto, "outer-ip")) {
4745 			if (hw == 0 || (dev_info.tx_offload_capa &
4746 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4747 				csum_offloads |=
4748 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4749 			} else {
4750 				printf("Outer IP checksum offload is not "
4751 				       "supported by port %u\n", res->port_id);
4752 			}
4753 		} else if (!strcmp(res->proto, "outer-udp")) {
4754 			if (hw == 0 || (dev_info.tx_offload_capa &
4755 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4756 				csum_offloads |=
4757 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4758 			} else {
4759 				printf("Outer UDP checksum offload is not "
4760 				       "supported by port %u\n", res->port_id);
4761 			}
4762 		}
4763 
4764 		if (hw) {
4765 			ports[res->port_id].dev_conf.txmode.offloads |=
4766 							csum_offloads;
4767 		} else {
4768 			ports[res->port_id].dev_conf.txmode.offloads &=
4769 							(~csum_offloads);
4770 		}
4771 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4772 	}
4773 	csum_show(res->port_id);
4774 
4775 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4776 }
4777 
4778 cmdline_parse_token_string_t cmd_csum_csum =
4779 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4780 				csum, "csum");
4781 cmdline_parse_token_string_t cmd_csum_mode =
4782 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4783 				mode, "set");
4784 cmdline_parse_token_string_t cmd_csum_proto =
4785 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4786 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4787 cmdline_parse_token_string_t cmd_csum_hwsw =
4788 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4789 				hwsw, "hw#sw");
4790 cmdline_parse_token_num_t cmd_csum_portid =
4791 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4792 				port_id, RTE_UINT16);
4793 
4794 cmdline_parse_inst_t cmd_csum_set = {
4795 	.f = cmd_csum_parsed,
4796 	.data = NULL,
4797 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4798 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4799 		"using csum forward engine",
4800 	.tokens = {
4801 		(void *)&cmd_csum_csum,
4802 		(void *)&cmd_csum_mode,
4803 		(void *)&cmd_csum_proto,
4804 		(void *)&cmd_csum_hwsw,
4805 		(void *)&cmd_csum_portid,
4806 		NULL,
4807 	},
4808 };
4809 
4810 cmdline_parse_token_string_t cmd_csum_mode_show =
4811 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4812 				mode, "show");
4813 
4814 cmdline_parse_inst_t cmd_csum_show = {
4815 	.f = cmd_csum_parsed,
4816 	.data = NULL,
4817 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4818 	.tokens = {
4819 		(void *)&cmd_csum_csum,
4820 		(void *)&cmd_csum_mode_show,
4821 		(void *)&cmd_csum_portid,
4822 		NULL,
4823 	},
4824 };
4825 
4826 /* Enable/disable tunnel parsing */
4827 struct cmd_csum_tunnel_result {
4828 	cmdline_fixed_string_t csum;
4829 	cmdline_fixed_string_t parse;
4830 	cmdline_fixed_string_t onoff;
4831 	portid_t port_id;
4832 };
4833 
4834 static void
4835 cmd_csum_tunnel_parsed(void *parsed_result,
4836 		       __rte_unused struct cmdline *cl,
4837 		       __rte_unused void *data)
4838 {
4839 	struct cmd_csum_tunnel_result *res = parsed_result;
4840 
4841 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4842 		return;
4843 
4844 	if (!strcmp(res->onoff, "on"))
4845 		ports[res->port_id].parse_tunnel = 1;
4846 	else
4847 		ports[res->port_id].parse_tunnel = 0;
4848 
4849 	csum_show(res->port_id);
4850 }
4851 
4852 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4853 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4854 				csum, "csum");
4855 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4856 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4857 				parse, "parse-tunnel");
4858 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4859 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4860 				onoff, "on#off");
4861 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4862 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4863 				port_id, RTE_UINT16);
4864 
4865 cmdline_parse_inst_t cmd_csum_tunnel = {
4866 	.f = cmd_csum_tunnel_parsed,
4867 	.data = NULL,
4868 	.help_str = "csum parse-tunnel on|off <port_id>: "
4869 		"Enable/Disable parsing of tunnels for csum engine",
4870 	.tokens = {
4871 		(void *)&cmd_csum_tunnel_csum,
4872 		(void *)&cmd_csum_tunnel_parse,
4873 		(void *)&cmd_csum_tunnel_onoff,
4874 		(void *)&cmd_csum_tunnel_portid,
4875 		NULL,
4876 	},
4877 };
4878 
4879 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4880 struct cmd_tso_set_result {
4881 	cmdline_fixed_string_t tso;
4882 	cmdline_fixed_string_t mode;
4883 	uint16_t tso_segsz;
4884 	portid_t port_id;
4885 };
4886 
4887 static void
4888 cmd_tso_set_parsed(void *parsed_result,
4889 		       __rte_unused struct cmdline *cl,
4890 		       __rte_unused void *data)
4891 {
4892 	struct cmd_tso_set_result *res = parsed_result;
4893 	struct rte_eth_dev_info dev_info;
4894 	int ret;
4895 
4896 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4897 		return;
4898 	if (!port_is_stopped(res->port_id)) {
4899 		printf("Please stop port %d first\n", res->port_id);
4900 		return;
4901 	}
4902 
4903 	if (!strcmp(res->mode, "set"))
4904 		ports[res->port_id].tso_segsz = res->tso_segsz;
4905 
4906 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4907 	if (ret != 0)
4908 		return;
4909 
4910 	if ((ports[res->port_id].tso_segsz != 0) &&
4911 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4912 		printf("Error: TSO is not supported by port %d\n",
4913 		       res->port_id);
4914 		return;
4915 	}
4916 
4917 	if (ports[res->port_id].tso_segsz == 0) {
4918 		ports[res->port_id].dev_conf.txmode.offloads &=
4919 						~DEV_TX_OFFLOAD_TCP_TSO;
4920 		printf("TSO for non-tunneled packets is disabled\n");
4921 	} else {
4922 		ports[res->port_id].dev_conf.txmode.offloads |=
4923 						DEV_TX_OFFLOAD_TCP_TSO;
4924 		printf("TSO segment size for non-tunneled packets is %d\n",
4925 			ports[res->port_id].tso_segsz);
4926 	}
4927 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4928 
4929 	/* display warnings if configuration is not supported by the NIC */
4930 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4931 	if (ret != 0)
4932 		return;
4933 
4934 	if ((ports[res->port_id].tso_segsz != 0) &&
4935 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4936 		printf("Warning: TSO enabled but not "
4937 			"supported by port %d\n", res->port_id);
4938 	}
4939 
4940 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4941 }
4942 
4943 cmdline_parse_token_string_t cmd_tso_set_tso =
4944 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4945 				tso, "tso");
4946 cmdline_parse_token_string_t cmd_tso_set_mode =
4947 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4948 				mode, "set");
4949 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4950 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4951 				tso_segsz, RTE_UINT16);
4952 cmdline_parse_token_num_t cmd_tso_set_portid =
4953 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4954 				port_id, RTE_UINT16);
4955 
4956 cmdline_parse_inst_t cmd_tso_set = {
4957 	.f = cmd_tso_set_parsed,
4958 	.data = NULL,
4959 	.help_str = "tso set <tso_segsz> <port_id>: "
4960 		"Set TSO segment size of non-tunneled packets for csum engine "
4961 		"(0 to disable)",
4962 	.tokens = {
4963 		(void *)&cmd_tso_set_tso,
4964 		(void *)&cmd_tso_set_mode,
4965 		(void *)&cmd_tso_set_tso_segsz,
4966 		(void *)&cmd_tso_set_portid,
4967 		NULL,
4968 	},
4969 };
4970 
4971 cmdline_parse_token_string_t cmd_tso_show_mode =
4972 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4973 				mode, "show");
4974 
4975 
4976 cmdline_parse_inst_t cmd_tso_show = {
4977 	.f = cmd_tso_set_parsed,
4978 	.data = NULL,
4979 	.help_str = "tso show <port_id>: "
4980 		"Show TSO segment size of non-tunneled packets for csum engine",
4981 	.tokens = {
4982 		(void *)&cmd_tso_set_tso,
4983 		(void *)&cmd_tso_show_mode,
4984 		(void *)&cmd_tso_set_portid,
4985 		NULL,
4986 	},
4987 };
4988 
4989 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4990 struct cmd_tunnel_tso_set_result {
4991 	cmdline_fixed_string_t tso;
4992 	cmdline_fixed_string_t mode;
4993 	uint16_t tso_segsz;
4994 	portid_t port_id;
4995 };
4996 
4997 static struct rte_eth_dev_info
4998 check_tunnel_tso_nic_support(portid_t port_id)
4999 {
5000 	struct rte_eth_dev_info dev_info;
5001 
5002 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5003 		return dev_info;
5004 
5005 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5006 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5007 		       "not enabled for port %d\n", port_id);
5008 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5009 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
5010 		       "not enabled for port %d\n", port_id);
5011 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5012 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
5013 		       "not enabled for port %d\n", port_id);
5014 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5015 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5016 		       "not enabled for port %d\n", port_id);
5017 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5018 		printf("Warning: IP TUNNEL TSO not supported therefore "
5019 		       "not enabled for port %d\n", port_id);
5020 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5021 		printf("Warning: UDP TUNNEL TSO not supported therefore "
5022 		       "not enabled for port %d\n", port_id);
5023 	return dev_info;
5024 }
5025 
5026 static void
5027 cmd_tunnel_tso_set_parsed(void *parsed_result,
5028 			  __rte_unused struct cmdline *cl,
5029 			  __rte_unused void *data)
5030 {
5031 	struct cmd_tunnel_tso_set_result *res = parsed_result;
5032 	struct rte_eth_dev_info dev_info;
5033 
5034 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5035 		return;
5036 	if (!port_is_stopped(res->port_id)) {
5037 		printf("Please stop port %d first\n", res->port_id);
5038 		return;
5039 	}
5040 
5041 	if (!strcmp(res->mode, "set"))
5042 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5043 
5044 	dev_info = check_tunnel_tso_nic_support(res->port_id);
5045 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
5046 		ports[res->port_id].dev_conf.txmode.offloads &=
5047 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5048 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
5049 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5050 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5051 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
5052 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
5053 		printf("TSO for tunneled packets is disabled\n");
5054 	} else {
5055 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5056 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5057 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5058 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5059 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
5060 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5061 
5062 		ports[res->port_id].dev_conf.txmode.offloads |=
5063 			(tso_offloads & dev_info.tx_offload_capa);
5064 		printf("TSO segment size for tunneled packets is %d\n",
5065 			ports[res->port_id].tunnel_tso_segsz);
5066 
5067 		/* Below conditions are needed to make it work:
5068 		 * (1) tunnel TSO is supported by the NIC;
5069 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5070 		 * are recognized;
5071 		 * (3) for tunneled pkts with outer L3 of IPv4,
5072 		 * "csum set outer-ip" must be set to hw, because after tso,
5073 		 * total_len of outer IP header is changed, and the checksum
5074 		 * of outer IP header calculated by sw should be wrong; that
5075 		 * is not necessary for IPv6 tunneled pkts because there's no
5076 		 * checksum in IP header anymore.
5077 		 */
5078 
5079 		if (!ports[res->port_id].parse_tunnel)
5080 			printf("Warning: csum parse_tunnel must be set "
5081 				"so that tunneled packets are recognized\n");
5082 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
5083 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5084 			printf("Warning: csum set outer-ip must be set to hw "
5085 				"if outer L3 is IPv4; not necessary for IPv6\n");
5086 	}
5087 
5088 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
5089 	cmd_reconfig_device_queue(res->port_id, 1, 1);
5090 }
5091 
5092 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5093 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5094 				tso, "tunnel_tso");
5095 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5096 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5097 				mode, "set");
5098 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5099 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5100 				tso_segsz, RTE_UINT16);
5101 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5102 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5103 				port_id, RTE_UINT16);
5104 
5105 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5106 	.f = cmd_tunnel_tso_set_parsed,
5107 	.data = NULL,
5108 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5109 		"Set TSO segment size of tunneled packets for csum engine "
5110 		"(0 to disable)",
5111 	.tokens = {
5112 		(void *)&cmd_tunnel_tso_set_tso,
5113 		(void *)&cmd_tunnel_tso_set_mode,
5114 		(void *)&cmd_tunnel_tso_set_tso_segsz,
5115 		(void *)&cmd_tunnel_tso_set_portid,
5116 		NULL,
5117 	},
5118 };
5119 
5120 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5121 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5122 				mode, "show");
5123 
5124 
5125 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5126 	.f = cmd_tunnel_tso_set_parsed,
5127 	.data = NULL,
5128 	.help_str = "tunnel_tso show <port_id> "
5129 		"Show TSO segment size of tunneled packets for csum engine",
5130 	.tokens = {
5131 		(void *)&cmd_tunnel_tso_set_tso,
5132 		(void *)&cmd_tunnel_tso_show_mode,
5133 		(void *)&cmd_tunnel_tso_set_portid,
5134 		NULL,
5135 	},
5136 };
5137 
5138 /* *** SET GRO FOR A PORT *** */
5139 struct cmd_gro_enable_result {
5140 	cmdline_fixed_string_t cmd_set;
5141 	cmdline_fixed_string_t cmd_port;
5142 	cmdline_fixed_string_t cmd_keyword;
5143 	cmdline_fixed_string_t cmd_onoff;
5144 	portid_t cmd_pid;
5145 };
5146 
5147 static void
5148 cmd_gro_enable_parsed(void *parsed_result,
5149 		__rte_unused struct cmdline *cl,
5150 		__rte_unused void *data)
5151 {
5152 	struct cmd_gro_enable_result *res;
5153 
5154 	res = parsed_result;
5155 	if (!strcmp(res->cmd_keyword, "gro"))
5156 		setup_gro(res->cmd_onoff, res->cmd_pid);
5157 }
5158 
5159 cmdline_parse_token_string_t cmd_gro_enable_set =
5160 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5161 			cmd_set, "set");
5162 cmdline_parse_token_string_t cmd_gro_enable_port =
5163 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5164 			cmd_keyword, "port");
5165 cmdline_parse_token_num_t cmd_gro_enable_pid =
5166 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5167 			cmd_pid, RTE_UINT16);
5168 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5169 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5170 			cmd_keyword, "gro");
5171 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5172 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5173 			cmd_onoff, "on#off");
5174 
5175 cmdline_parse_inst_t cmd_gro_enable = {
5176 	.f = cmd_gro_enable_parsed,
5177 	.data = NULL,
5178 	.help_str = "set port <port_id> gro on|off",
5179 	.tokens = {
5180 		(void *)&cmd_gro_enable_set,
5181 		(void *)&cmd_gro_enable_port,
5182 		(void *)&cmd_gro_enable_pid,
5183 		(void *)&cmd_gro_enable_keyword,
5184 		(void *)&cmd_gro_enable_onoff,
5185 		NULL,
5186 	},
5187 };
5188 
5189 /* *** DISPLAY GRO CONFIGURATION *** */
5190 struct cmd_gro_show_result {
5191 	cmdline_fixed_string_t cmd_show;
5192 	cmdline_fixed_string_t cmd_port;
5193 	cmdline_fixed_string_t cmd_keyword;
5194 	portid_t cmd_pid;
5195 };
5196 
5197 static void
5198 cmd_gro_show_parsed(void *parsed_result,
5199 		__rte_unused struct cmdline *cl,
5200 		__rte_unused void *data)
5201 {
5202 	struct cmd_gro_show_result *res;
5203 
5204 	res = parsed_result;
5205 	if (!strcmp(res->cmd_keyword, "gro"))
5206 		show_gro(res->cmd_pid);
5207 }
5208 
5209 cmdline_parse_token_string_t cmd_gro_show_show =
5210 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5211 			cmd_show, "show");
5212 cmdline_parse_token_string_t cmd_gro_show_port =
5213 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5214 			cmd_port, "port");
5215 cmdline_parse_token_num_t cmd_gro_show_pid =
5216 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5217 			cmd_pid, RTE_UINT16);
5218 cmdline_parse_token_string_t cmd_gro_show_keyword =
5219 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5220 			cmd_keyword, "gro");
5221 
5222 cmdline_parse_inst_t cmd_gro_show = {
5223 	.f = cmd_gro_show_parsed,
5224 	.data = NULL,
5225 	.help_str = "show port <port_id> gro",
5226 	.tokens = {
5227 		(void *)&cmd_gro_show_show,
5228 		(void *)&cmd_gro_show_port,
5229 		(void *)&cmd_gro_show_pid,
5230 		(void *)&cmd_gro_show_keyword,
5231 		NULL,
5232 	},
5233 };
5234 
5235 /* *** SET FLUSH CYCLES FOR GRO *** */
5236 struct cmd_gro_flush_result {
5237 	cmdline_fixed_string_t cmd_set;
5238 	cmdline_fixed_string_t cmd_keyword;
5239 	cmdline_fixed_string_t cmd_flush;
5240 	uint8_t cmd_cycles;
5241 };
5242 
5243 static void
5244 cmd_gro_flush_parsed(void *parsed_result,
5245 		__rte_unused struct cmdline *cl,
5246 		__rte_unused void *data)
5247 {
5248 	struct cmd_gro_flush_result *res;
5249 
5250 	res = parsed_result;
5251 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5252 			(!strcmp(res->cmd_flush, "flush")))
5253 		setup_gro_flush_cycles(res->cmd_cycles);
5254 }
5255 
5256 cmdline_parse_token_string_t cmd_gro_flush_set =
5257 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5258 			cmd_set, "set");
5259 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5260 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5261 			cmd_keyword, "gro");
5262 cmdline_parse_token_string_t cmd_gro_flush_flush =
5263 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5264 			cmd_flush, "flush");
5265 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5266 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5267 			cmd_cycles, RTE_UINT8);
5268 
5269 cmdline_parse_inst_t cmd_gro_flush = {
5270 	.f = cmd_gro_flush_parsed,
5271 	.data = NULL,
5272 	.help_str = "set gro flush <cycles>",
5273 	.tokens = {
5274 		(void *)&cmd_gro_flush_set,
5275 		(void *)&cmd_gro_flush_keyword,
5276 		(void *)&cmd_gro_flush_flush,
5277 		(void *)&cmd_gro_flush_cycles,
5278 		NULL,
5279 	},
5280 };
5281 
5282 /* *** ENABLE/DISABLE GSO *** */
5283 struct cmd_gso_enable_result {
5284 	cmdline_fixed_string_t cmd_set;
5285 	cmdline_fixed_string_t cmd_port;
5286 	cmdline_fixed_string_t cmd_keyword;
5287 	cmdline_fixed_string_t cmd_mode;
5288 	portid_t cmd_pid;
5289 };
5290 
5291 static void
5292 cmd_gso_enable_parsed(void *parsed_result,
5293 		__rte_unused struct cmdline *cl,
5294 		__rte_unused void *data)
5295 {
5296 	struct cmd_gso_enable_result *res;
5297 
5298 	res = parsed_result;
5299 	if (!strcmp(res->cmd_keyword, "gso"))
5300 		setup_gso(res->cmd_mode, res->cmd_pid);
5301 }
5302 
5303 cmdline_parse_token_string_t cmd_gso_enable_set =
5304 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5305 			cmd_set, "set");
5306 cmdline_parse_token_string_t cmd_gso_enable_port =
5307 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5308 			cmd_port, "port");
5309 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5310 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5311 			cmd_keyword, "gso");
5312 cmdline_parse_token_string_t cmd_gso_enable_mode =
5313 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5314 			cmd_mode, "on#off");
5315 cmdline_parse_token_num_t cmd_gso_enable_pid =
5316 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5317 			cmd_pid, RTE_UINT16);
5318 
5319 cmdline_parse_inst_t cmd_gso_enable = {
5320 	.f = cmd_gso_enable_parsed,
5321 	.data = NULL,
5322 	.help_str = "set port <port_id> gso on|off",
5323 	.tokens = {
5324 		(void *)&cmd_gso_enable_set,
5325 		(void *)&cmd_gso_enable_port,
5326 		(void *)&cmd_gso_enable_pid,
5327 		(void *)&cmd_gso_enable_keyword,
5328 		(void *)&cmd_gso_enable_mode,
5329 		NULL,
5330 	},
5331 };
5332 
5333 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5334 struct cmd_gso_size_result {
5335 	cmdline_fixed_string_t cmd_set;
5336 	cmdline_fixed_string_t cmd_keyword;
5337 	cmdline_fixed_string_t cmd_segsz;
5338 	uint16_t cmd_size;
5339 };
5340 
5341 static void
5342 cmd_gso_size_parsed(void *parsed_result,
5343 		       __rte_unused struct cmdline *cl,
5344 		       __rte_unused void *data)
5345 {
5346 	struct cmd_gso_size_result *res = parsed_result;
5347 
5348 	if (test_done == 0) {
5349 		printf("Before setting GSO segsz, please first"
5350 				" stop forwarding\n");
5351 		return;
5352 	}
5353 
5354 	if (!strcmp(res->cmd_keyword, "gso") &&
5355 			!strcmp(res->cmd_segsz, "segsz")) {
5356 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5357 			printf("gso_size should be larger than %zu."
5358 					" Please input a legal value\n",
5359 					RTE_GSO_SEG_SIZE_MIN);
5360 		else
5361 			gso_max_segment_size = res->cmd_size;
5362 	}
5363 }
5364 
5365 cmdline_parse_token_string_t cmd_gso_size_set =
5366 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5367 				cmd_set, "set");
5368 cmdline_parse_token_string_t cmd_gso_size_keyword =
5369 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5370 				cmd_keyword, "gso");
5371 cmdline_parse_token_string_t cmd_gso_size_segsz =
5372 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5373 				cmd_segsz, "segsz");
5374 cmdline_parse_token_num_t cmd_gso_size_size =
5375 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5376 				cmd_size, RTE_UINT16);
5377 
5378 cmdline_parse_inst_t cmd_gso_size = {
5379 	.f = cmd_gso_size_parsed,
5380 	.data = NULL,
5381 	.help_str = "set gso segsz <length>",
5382 	.tokens = {
5383 		(void *)&cmd_gso_size_set,
5384 		(void *)&cmd_gso_size_keyword,
5385 		(void *)&cmd_gso_size_segsz,
5386 		(void *)&cmd_gso_size_size,
5387 		NULL,
5388 	},
5389 };
5390 
5391 /* *** SHOW GSO CONFIGURATION *** */
5392 struct cmd_gso_show_result {
5393 	cmdline_fixed_string_t cmd_show;
5394 	cmdline_fixed_string_t cmd_port;
5395 	cmdline_fixed_string_t cmd_keyword;
5396 	portid_t cmd_pid;
5397 };
5398 
5399 static void
5400 cmd_gso_show_parsed(void *parsed_result,
5401 		       __rte_unused struct cmdline *cl,
5402 		       __rte_unused void *data)
5403 {
5404 	struct cmd_gso_show_result *res = parsed_result;
5405 
5406 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5407 		printf("invalid port id %u\n", res->cmd_pid);
5408 		return;
5409 	}
5410 	if (!strcmp(res->cmd_keyword, "gso")) {
5411 		if (gso_ports[res->cmd_pid].enable) {
5412 			printf("Max GSO'd packet size: %uB\n"
5413 					"Supported GSO types: TCP/IPv4, "
5414 					"UDP/IPv4, VxLAN with inner "
5415 					"TCP/IPv4 packet, GRE with inner "
5416 					"TCP/IPv4 packet\n",
5417 					gso_max_segment_size);
5418 		} else
5419 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5420 	}
5421 }
5422 
5423 cmdline_parse_token_string_t cmd_gso_show_show =
5424 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5425 		cmd_show, "show");
5426 cmdline_parse_token_string_t cmd_gso_show_port =
5427 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5428 		cmd_port, "port");
5429 cmdline_parse_token_string_t cmd_gso_show_keyword =
5430 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5431 				cmd_keyword, "gso");
5432 cmdline_parse_token_num_t cmd_gso_show_pid =
5433 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5434 				cmd_pid, RTE_UINT16);
5435 
5436 cmdline_parse_inst_t cmd_gso_show = {
5437 	.f = cmd_gso_show_parsed,
5438 	.data = NULL,
5439 	.help_str = "show port <port_id> gso",
5440 	.tokens = {
5441 		(void *)&cmd_gso_show_show,
5442 		(void *)&cmd_gso_show_port,
5443 		(void *)&cmd_gso_show_pid,
5444 		(void *)&cmd_gso_show_keyword,
5445 		NULL,
5446 	},
5447 };
5448 
5449 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5450 struct cmd_set_flush_rx {
5451 	cmdline_fixed_string_t set;
5452 	cmdline_fixed_string_t flush_rx;
5453 	cmdline_fixed_string_t mode;
5454 };
5455 
5456 static void
5457 cmd_set_flush_rx_parsed(void *parsed_result,
5458 		__rte_unused struct cmdline *cl,
5459 		__rte_unused void *data)
5460 {
5461 	struct cmd_set_flush_rx *res = parsed_result;
5462 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5463 }
5464 
5465 cmdline_parse_token_string_t cmd_setflushrx_set =
5466 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5467 			set, "set");
5468 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5469 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5470 			flush_rx, "flush_rx");
5471 cmdline_parse_token_string_t cmd_setflushrx_mode =
5472 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5473 			mode, "on#off");
5474 
5475 
5476 cmdline_parse_inst_t cmd_set_flush_rx = {
5477 	.f = cmd_set_flush_rx_parsed,
5478 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5479 	.data = NULL,
5480 	.tokens = {
5481 		(void *)&cmd_setflushrx_set,
5482 		(void *)&cmd_setflushrx_flush_rx,
5483 		(void *)&cmd_setflushrx_mode,
5484 		NULL,
5485 	},
5486 };
5487 
5488 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5489 struct cmd_set_link_check {
5490 	cmdline_fixed_string_t set;
5491 	cmdline_fixed_string_t link_check;
5492 	cmdline_fixed_string_t mode;
5493 };
5494 
5495 static void
5496 cmd_set_link_check_parsed(void *parsed_result,
5497 		__rte_unused struct cmdline *cl,
5498 		__rte_unused void *data)
5499 {
5500 	struct cmd_set_link_check *res = parsed_result;
5501 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5502 }
5503 
5504 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5505 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5506 			set, "set");
5507 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5508 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5509 			link_check, "link_check");
5510 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5511 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5512 			mode, "on#off");
5513 
5514 
5515 cmdline_parse_inst_t cmd_set_link_check = {
5516 	.f = cmd_set_link_check_parsed,
5517 	.help_str = "set link_check on|off: Enable/Disable link status check "
5518 	            "when starting/stopping a port",
5519 	.data = NULL,
5520 	.tokens = {
5521 		(void *)&cmd_setlinkcheck_set,
5522 		(void *)&cmd_setlinkcheck_link_check,
5523 		(void *)&cmd_setlinkcheck_mode,
5524 		NULL,
5525 	},
5526 };
5527 
5528 /* *** SET NIC BYPASS MODE *** */
5529 struct cmd_set_bypass_mode_result {
5530 	cmdline_fixed_string_t set;
5531 	cmdline_fixed_string_t bypass;
5532 	cmdline_fixed_string_t mode;
5533 	cmdline_fixed_string_t value;
5534 	portid_t port_id;
5535 };
5536 
5537 static void
5538 cmd_set_bypass_mode_parsed(void *parsed_result,
5539 		__rte_unused struct cmdline *cl,
5540 		__rte_unused void *data)
5541 {
5542 	struct cmd_set_bypass_mode_result *res = parsed_result;
5543 	portid_t port_id = res->port_id;
5544 	int32_t rc = -EINVAL;
5545 
5546 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5547 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5548 
5549 	if (!strcmp(res->value, "bypass"))
5550 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5551 	else if (!strcmp(res->value, "isolate"))
5552 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5553 	else
5554 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5555 
5556 	/* Set the bypass mode for the relevant port. */
5557 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5558 #endif
5559 	if (rc != 0)
5560 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5561 }
5562 
5563 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5564 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5565 			set, "set");
5566 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5567 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5568 			bypass, "bypass");
5569 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5570 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5571 			mode, "mode");
5572 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5573 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5574 			value, "normal#bypass#isolate");
5575 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5576 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5577 				port_id, RTE_UINT16);
5578 
5579 cmdline_parse_inst_t cmd_set_bypass_mode = {
5580 	.f = cmd_set_bypass_mode_parsed,
5581 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5582 	            "Set the NIC bypass mode for port_id",
5583 	.data = NULL,
5584 	.tokens = {
5585 		(void *)&cmd_setbypass_mode_set,
5586 		(void *)&cmd_setbypass_mode_bypass,
5587 		(void *)&cmd_setbypass_mode_mode,
5588 		(void *)&cmd_setbypass_mode_value,
5589 		(void *)&cmd_setbypass_mode_port,
5590 		NULL,
5591 	},
5592 };
5593 
5594 /* *** SET NIC BYPASS EVENT *** */
5595 struct cmd_set_bypass_event_result {
5596 	cmdline_fixed_string_t set;
5597 	cmdline_fixed_string_t bypass;
5598 	cmdline_fixed_string_t event;
5599 	cmdline_fixed_string_t event_value;
5600 	cmdline_fixed_string_t mode;
5601 	cmdline_fixed_string_t mode_value;
5602 	portid_t port_id;
5603 };
5604 
5605 static void
5606 cmd_set_bypass_event_parsed(void *parsed_result,
5607 		__rte_unused struct cmdline *cl,
5608 		__rte_unused void *data)
5609 {
5610 	int32_t rc = -EINVAL;
5611 	struct cmd_set_bypass_event_result *res = parsed_result;
5612 	portid_t port_id = res->port_id;
5613 
5614 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5615 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5616 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5617 
5618 	if (!strcmp(res->event_value, "timeout"))
5619 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5620 	else if (!strcmp(res->event_value, "os_on"))
5621 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5622 	else if (!strcmp(res->event_value, "os_off"))
5623 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5624 	else if (!strcmp(res->event_value, "power_on"))
5625 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5626 	else if (!strcmp(res->event_value, "power_off"))
5627 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5628 	else
5629 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5630 
5631 	if (!strcmp(res->mode_value, "bypass"))
5632 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5633 	else if (!strcmp(res->mode_value, "isolate"))
5634 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5635 	else
5636 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5637 
5638 	/* Set the watchdog timeout. */
5639 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5640 
5641 		rc = -EINVAL;
5642 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5643 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5644 							   bypass_timeout);
5645 		}
5646 		if (rc != 0) {
5647 			printf("Failed to set timeout value %u "
5648 			"for port %d, errto code: %d.\n",
5649 			bypass_timeout, port_id, rc);
5650 		}
5651 	}
5652 
5653 	/* Set the bypass event to transition to bypass mode. */
5654 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5655 					      bypass_mode);
5656 #endif
5657 
5658 	if (rc != 0)
5659 		printf("\t Failed to set bypass event for port = %d.\n",
5660 		       port_id);
5661 }
5662 
5663 cmdline_parse_token_string_t cmd_setbypass_event_set =
5664 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5665 			set, "set");
5666 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5667 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5668 			bypass, "bypass");
5669 cmdline_parse_token_string_t cmd_setbypass_event_event =
5670 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5671 			event, "event");
5672 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5673 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5674 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5675 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5676 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5677 			mode, "mode");
5678 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5679 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5680 			mode_value, "normal#bypass#isolate");
5681 cmdline_parse_token_num_t cmd_setbypass_event_port =
5682 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5683 				port_id, RTE_UINT16);
5684 
5685 cmdline_parse_inst_t cmd_set_bypass_event = {
5686 	.f = cmd_set_bypass_event_parsed,
5687 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5688 		"power_off mode normal|bypass|isolate <port_id>: "
5689 		"Set the NIC bypass event mode for port_id",
5690 	.data = NULL,
5691 	.tokens = {
5692 		(void *)&cmd_setbypass_event_set,
5693 		(void *)&cmd_setbypass_event_bypass,
5694 		(void *)&cmd_setbypass_event_event,
5695 		(void *)&cmd_setbypass_event_event_value,
5696 		(void *)&cmd_setbypass_event_mode,
5697 		(void *)&cmd_setbypass_event_mode_value,
5698 		(void *)&cmd_setbypass_event_port,
5699 		NULL,
5700 	},
5701 };
5702 
5703 
5704 /* *** SET NIC BYPASS TIMEOUT *** */
5705 struct cmd_set_bypass_timeout_result {
5706 	cmdline_fixed_string_t set;
5707 	cmdline_fixed_string_t bypass;
5708 	cmdline_fixed_string_t timeout;
5709 	cmdline_fixed_string_t value;
5710 };
5711 
5712 static void
5713 cmd_set_bypass_timeout_parsed(void *parsed_result,
5714 		__rte_unused struct cmdline *cl,
5715 		__rte_unused void *data)
5716 {
5717 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5718 
5719 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5720 	if (!strcmp(res->value, "1.5"))
5721 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5722 	else if (!strcmp(res->value, "2"))
5723 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5724 	else if (!strcmp(res->value, "3"))
5725 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5726 	else if (!strcmp(res->value, "4"))
5727 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5728 	else if (!strcmp(res->value, "8"))
5729 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5730 	else if (!strcmp(res->value, "16"))
5731 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5732 	else if (!strcmp(res->value, "32"))
5733 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5734 	else
5735 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5736 #endif
5737 }
5738 
5739 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5740 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5741 			set, "set");
5742 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5743 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5744 			bypass, "bypass");
5745 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5746 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5747 			timeout, "timeout");
5748 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5749 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5750 			value, "0#1.5#2#3#4#8#16#32");
5751 
5752 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5753 	.f = cmd_set_bypass_timeout_parsed,
5754 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5755 		"Set the NIC bypass watchdog timeout in seconds",
5756 	.data = NULL,
5757 	.tokens = {
5758 		(void *)&cmd_setbypass_timeout_set,
5759 		(void *)&cmd_setbypass_timeout_bypass,
5760 		(void *)&cmd_setbypass_timeout_timeout,
5761 		(void *)&cmd_setbypass_timeout_value,
5762 		NULL,
5763 	},
5764 };
5765 
5766 /* *** SHOW NIC BYPASS MODE *** */
5767 struct cmd_show_bypass_config_result {
5768 	cmdline_fixed_string_t show;
5769 	cmdline_fixed_string_t bypass;
5770 	cmdline_fixed_string_t config;
5771 	portid_t port_id;
5772 };
5773 
5774 static void
5775 cmd_show_bypass_config_parsed(void *parsed_result,
5776 		__rte_unused struct cmdline *cl,
5777 		__rte_unused void *data)
5778 {
5779 	struct cmd_show_bypass_config_result *res = parsed_result;
5780 	portid_t port_id = res->port_id;
5781 	int rc = -EINVAL;
5782 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5783 	uint32_t event_mode;
5784 	uint32_t bypass_mode;
5785 	uint32_t timeout = bypass_timeout;
5786 	unsigned int i;
5787 
5788 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5789 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5790 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5791 		{"UNKNOWN", "normal", "bypass", "isolate"};
5792 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5793 		"NONE",
5794 		"OS/board on",
5795 		"power supply on",
5796 		"OS/board off",
5797 		"power supply off",
5798 		"timeout"};
5799 
5800 	/* Display the bypass mode.*/
5801 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5802 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5803 		return;
5804 	}
5805 	else {
5806 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5807 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5808 
5809 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5810 	}
5811 
5812 	/* Display the bypass timeout.*/
5813 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5814 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5815 
5816 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5817 
5818 	/* Display the bypass events and associated modes. */
5819 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5820 
5821 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5822 			printf("\tFailed to get bypass mode for event = %s\n",
5823 				events[i]);
5824 		} else {
5825 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5826 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5827 
5828 			printf("\tbypass event: %-16s = %s\n", events[i],
5829 				modes[event_mode]);
5830 		}
5831 	}
5832 #endif
5833 	if (rc != 0)
5834 		printf("\tFailed to get bypass configuration for port = %d\n",
5835 		       port_id);
5836 }
5837 
5838 cmdline_parse_token_string_t cmd_showbypass_config_show =
5839 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5840 			show, "show");
5841 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5842 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5843 			bypass, "bypass");
5844 cmdline_parse_token_string_t cmd_showbypass_config_config =
5845 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5846 			config, "config");
5847 cmdline_parse_token_num_t cmd_showbypass_config_port =
5848 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5849 				port_id, RTE_UINT16);
5850 
5851 cmdline_parse_inst_t cmd_show_bypass_config = {
5852 	.f = cmd_show_bypass_config_parsed,
5853 	.help_str = "show bypass config <port_id>: "
5854 	            "Show the NIC bypass config for port_id",
5855 	.data = NULL,
5856 	.tokens = {
5857 		(void *)&cmd_showbypass_config_show,
5858 		(void *)&cmd_showbypass_config_bypass,
5859 		(void *)&cmd_showbypass_config_config,
5860 		(void *)&cmd_showbypass_config_port,
5861 		NULL,
5862 	},
5863 };
5864 
5865 #ifdef RTE_NET_BOND
5866 /* *** SET BONDING MODE *** */
5867 struct cmd_set_bonding_mode_result {
5868 	cmdline_fixed_string_t set;
5869 	cmdline_fixed_string_t bonding;
5870 	cmdline_fixed_string_t mode;
5871 	uint8_t value;
5872 	portid_t port_id;
5873 };
5874 
5875 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5876 		__rte_unused  struct cmdline *cl,
5877 		__rte_unused void *data)
5878 {
5879 	struct cmd_set_bonding_mode_result *res = parsed_result;
5880 	portid_t port_id = res->port_id;
5881 
5882 	/* Set the bonding mode for the relevant port. */
5883 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5884 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5885 }
5886 
5887 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5888 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5889 		set, "set");
5890 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5891 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5892 		bonding, "bonding");
5893 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5894 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5895 		mode, "mode");
5896 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5897 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5898 		value, RTE_UINT8);
5899 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5900 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5901 		port_id, RTE_UINT16);
5902 
5903 cmdline_parse_inst_t cmd_set_bonding_mode = {
5904 		.f = cmd_set_bonding_mode_parsed,
5905 		.help_str = "set bonding mode <mode_value> <port_id>: "
5906 			"Set the bonding mode for port_id",
5907 		.data = NULL,
5908 		.tokens = {
5909 				(void *) &cmd_setbonding_mode_set,
5910 				(void *) &cmd_setbonding_mode_bonding,
5911 				(void *) &cmd_setbonding_mode_mode,
5912 				(void *) &cmd_setbonding_mode_value,
5913 				(void *) &cmd_setbonding_mode_port,
5914 				NULL
5915 		}
5916 };
5917 
5918 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5919 struct cmd_set_bonding_lacp_dedicated_queues_result {
5920 	cmdline_fixed_string_t set;
5921 	cmdline_fixed_string_t bonding;
5922 	cmdline_fixed_string_t lacp;
5923 	cmdline_fixed_string_t dedicated_queues;
5924 	portid_t port_id;
5925 	cmdline_fixed_string_t mode;
5926 };
5927 
5928 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5929 		__rte_unused  struct cmdline *cl,
5930 		__rte_unused void *data)
5931 {
5932 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5933 	portid_t port_id = res->port_id;
5934 	struct rte_port *port;
5935 
5936 	port = &ports[port_id];
5937 
5938 	/** Check if the port is not started **/
5939 	if (port->port_status != RTE_PORT_STOPPED) {
5940 		printf("Please stop port %d first\n", port_id);
5941 		return;
5942 	}
5943 
5944 	if (!strcmp(res->mode, "enable")) {
5945 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5946 			printf("Dedicate queues for LACP control packets"
5947 					" enabled\n");
5948 		else
5949 			printf("Enabling dedicate queues for LACP control "
5950 					"packets on port %d failed\n", port_id);
5951 	} else if (!strcmp(res->mode, "disable")) {
5952 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5953 			printf("Dedicated queues for LACP control packets "
5954 					"disabled\n");
5955 		else
5956 			printf("Disabling dedicated queues for LACP control "
5957 					"traffic on port %d failed\n", port_id);
5958 	}
5959 }
5960 
5961 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5962 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5963 		set, "set");
5964 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5966 		bonding, "bonding");
5967 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5969 		lacp, "lacp");
5970 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5972 		dedicated_queues, "dedicated_queues");
5973 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5974 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5975 		port_id, RTE_UINT16);
5976 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5977 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5978 		mode, "enable#disable");
5979 
5980 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5981 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5982 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5983 			"enable|disable: "
5984 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5985 		.data = NULL,
5986 		.tokens = {
5987 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5988 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5989 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5990 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5991 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5992 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5993 			NULL
5994 		}
5995 };
5996 
5997 /* *** SET BALANCE XMIT POLICY *** */
5998 struct cmd_set_bonding_balance_xmit_policy_result {
5999 	cmdline_fixed_string_t set;
6000 	cmdline_fixed_string_t bonding;
6001 	cmdline_fixed_string_t balance_xmit_policy;
6002 	portid_t port_id;
6003 	cmdline_fixed_string_t policy;
6004 };
6005 
6006 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6007 		__rte_unused  struct cmdline *cl,
6008 		__rte_unused void *data)
6009 {
6010 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6011 	portid_t port_id = res->port_id;
6012 	uint8_t policy;
6013 
6014 	if (!strcmp(res->policy, "l2")) {
6015 		policy = BALANCE_XMIT_POLICY_LAYER2;
6016 	} else if (!strcmp(res->policy, "l23")) {
6017 		policy = BALANCE_XMIT_POLICY_LAYER23;
6018 	} else if (!strcmp(res->policy, "l34")) {
6019 		policy = BALANCE_XMIT_POLICY_LAYER34;
6020 	} else {
6021 		printf("\t Invalid xmit policy selection");
6022 		return;
6023 	}
6024 
6025 	/* Set the bonding mode for the relevant port. */
6026 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6027 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6028 				port_id);
6029 	}
6030 }
6031 
6032 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6034 		set, "set");
6035 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6036 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6037 		bonding, "bonding");
6038 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6039 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6040 		balance_xmit_policy, "balance_xmit_policy");
6041 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6042 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6043 		port_id, RTE_UINT16);
6044 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6045 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6046 		policy, "l2#l23#l34");
6047 
6048 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6049 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
6050 		.help_str = "set bonding balance_xmit_policy <port_id> "
6051 			"l2|l23|l34: "
6052 			"Set the bonding balance_xmit_policy for port_id",
6053 		.data = NULL,
6054 		.tokens = {
6055 				(void *)&cmd_setbonding_balance_xmit_policy_set,
6056 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
6057 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6058 				(void *)&cmd_setbonding_balance_xmit_policy_port,
6059 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
6060 				NULL
6061 		}
6062 };
6063 
6064 /* *** SHOW NIC BONDING CONFIGURATION *** */
6065 struct cmd_show_bonding_config_result {
6066 	cmdline_fixed_string_t show;
6067 	cmdline_fixed_string_t bonding;
6068 	cmdline_fixed_string_t config;
6069 	portid_t port_id;
6070 };
6071 
6072 static void cmd_show_bonding_config_parsed(void *parsed_result,
6073 		__rte_unused  struct cmdline *cl,
6074 		__rte_unused void *data)
6075 {
6076 	struct cmd_show_bonding_config_result *res = parsed_result;
6077 	int bonding_mode, agg_mode;
6078 	portid_t slaves[RTE_MAX_ETHPORTS];
6079 	int num_slaves, num_active_slaves;
6080 	int primary_id;
6081 	int i;
6082 	portid_t port_id = res->port_id;
6083 
6084 	/* Display the bonding mode.*/
6085 	bonding_mode = rte_eth_bond_mode_get(port_id);
6086 	if (bonding_mode < 0) {
6087 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
6088 		return;
6089 	} else
6090 		printf("\tBonding mode: %d\n", bonding_mode);
6091 
6092 	if (bonding_mode == BONDING_MODE_BALANCE) {
6093 		int balance_xmit_policy;
6094 
6095 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6096 		if (balance_xmit_policy < 0) {
6097 			printf("\tFailed to get balance xmit policy for port = %d\n",
6098 					port_id);
6099 			return;
6100 		} else {
6101 			printf("\tBalance Xmit Policy: ");
6102 
6103 			switch (balance_xmit_policy) {
6104 			case BALANCE_XMIT_POLICY_LAYER2:
6105 				printf("BALANCE_XMIT_POLICY_LAYER2");
6106 				break;
6107 			case BALANCE_XMIT_POLICY_LAYER23:
6108 				printf("BALANCE_XMIT_POLICY_LAYER23");
6109 				break;
6110 			case BALANCE_XMIT_POLICY_LAYER34:
6111 				printf("BALANCE_XMIT_POLICY_LAYER34");
6112 				break;
6113 			}
6114 			printf("\n");
6115 		}
6116 	}
6117 
6118 	if (bonding_mode == BONDING_MODE_8023AD) {
6119 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6120 		printf("\tIEEE802.3AD Aggregator Mode: ");
6121 		switch (agg_mode) {
6122 		case AGG_BANDWIDTH:
6123 			printf("bandwidth");
6124 			break;
6125 		case AGG_STABLE:
6126 			printf("stable");
6127 			break;
6128 		case AGG_COUNT:
6129 			printf("count");
6130 			break;
6131 		}
6132 		printf("\n");
6133 	}
6134 
6135 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6136 
6137 	if (num_slaves < 0) {
6138 		printf("\tFailed to get slave list for port = %d\n", port_id);
6139 		return;
6140 	}
6141 	if (num_slaves > 0) {
6142 		printf("\tSlaves (%d): [", num_slaves);
6143 		for (i = 0; i < num_slaves - 1; i++)
6144 			printf("%d ", slaves[i]);
6145 
6146 		printf("%d]\n", slaves[num_slaves - 1]);
6147 	} else {
6148 		printf("\tSlaves: []\n");
6149 
6150 	}
6151 
6152 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6153 			RTE_MAX_ETHPORTS);
6154 
6155 	if (num_active_slaves < 0) {
6156 		printf("\tFailed to get active slave list for port = %d\n", port_id);
6157 		return;
6158 	}
6159 	if (num_active_slaves > 0) {
6160 		printf("\tActive Slaves (%d): [", num_active_slaves);
6161 		for (i = 0; i < num_active_slaves - 1; i++)
6162 			printf("%d ", slaves[i]);
6163 
6164 		printf("%d]\n", slaves[num_active_slaves - 1]);
6165 
6166 	} else {
6167 		printf("\tActive Slaves: []\n");
6168 
6169 	}
6170 
6171 	primary_id = rte_eth_bond_primary_get(port_id);
6172 	if (primary_id < 0) {
6173 		printf("\tFailed to get primary slave for port = %d\n", port_id);
6174 		return;
6175 	} else
6176 		printf("\tPrimary: [%d]\n", primary_id);
6177 
6178 }
6179 
6180 cmdline_parse_token_string_t cmd_showbonding_config_show =
6181 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6182 		show, "show");
6183 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6184 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6185 		bonding, "bonding");
6186 cmdline_parse_token_string_t cmd_showbonding_config_config =
6187 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6188 		config, "config");
6189 cmdline_parse_token_num_t cmd_showbonding_config_port =
6190 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6191 		port_id, RTE_UINT16);
6192 
6193 cmdline_parse_inst_t cmd_show_bonding_config = {
6194 		.f = cmd_show_bonding_config_parsed,
6195 		.help_str = "show bonding config <port_id>: "
6196 			"Show the bonding config for port_id",
6197 		.data = NULL,
6198 		.tokens = {
6199 				(void *)&cmd_showbonding_config_show,
6200 				(void *)&cmd_showbonding_config_bonding,
6201 				(void *)&cmd_showbonding_config_config,
6202 				(void *)&cmd_showbonding_config_port,
6203 				NULL
6204 		}
6205 };
6206 
6207 /* *** SET BONDING PRIMARY *** */
6208 struct cmd_set_bonding_primary_result {
6209 	cmdline_fixed_string_t set;
6210 	cmdline_fixed_string_t bonding;
6211 	cmdline_fixed_string_t primary;
6212 	portid_t slave_id;
6213 	portid_t port_id;
6214 };
6215 
6216 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6217 		__rte_unused  struct cmdline *cl,
6218 		__rte_unused void *data)
6219 {
6220 	struct cmd_set_bonding_primary_result *res = parsed_result;
6221 	portid_t master_port_id = res->port_id;
6222 	portid_t slave_port_id = res->slave_id;
6223 
6224 	/* Set the primary slave for a bonded device. */
6225 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6226 		printf("\t Failed to set primary slave for port = %d.\n",
6227 				master_port_id);
6228 		return;
6229 	}
6230 	init_port_config();
6231 }
6232 
6233 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6235 		set, "set");
6236 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6237 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6238 		bonding, "bonding");
6239 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6240 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6241 		primary, "primary");
6242 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6243 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6244 		slave_id, RTE_UINT16);
6245 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6246 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6247 		port_id, RTE_UINT16);
6248 
6249 cmdline_parse_inst_t cmd_set_bonding_primary = {
6250 		.f = cmd_set_bonding_primary_parsed,
6251 		.help_str = "set bonding primary <slave_id> <port_id>: "
6252 			"Set the primary slave for port_id",
6253 		.data = NULL,
6254 		.tokens = {
6255 				(void *)&cmd_setbonding_primary_set,
6256 				(void *)&cmd_setbonding_primary_bonding,
6257 				(void *)&cmd_setbonding_primary_primary,
6258 				(void *)&cmd_setbonding_primary_slave,
6259 				(void *)&cmd_setbonding_primary_port,
6260 				NULL
6261 		}
6262 };
6263 
6264 /* *** ADD SLAVE *** */
6265 struct cmd_add_bonding_slave_result {
6266 	cmdline_fixed_string_t add;
6267 	cmdline_fixed_string_t bonding;
6268 	cmdline_fixed_string_t slave;
6269 	portid_t slave_id;
6270 	portid_t port_id;
6271 };
6272 
6273 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6274 		__rte_unused  struct cmdline *cl,
6275 		__rte_unused void *data)
6276 {
6277 	struct cmd_add_bonding_slave_result *res = parsed_result;
6278 	portid_t master_port_id = res->port_id;
6279 	portid_t slave_port_id = res->slave_id;
6280 
6281 	/* add the slave for a bonded device. */
6282 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6283 		printf("\t Failed to add slave %d to master port = %d.\n",
6284 				slave_port_id, master_port_id);
6285 		return;
6286 	}
6287 	init_port_config();
6288 	set_port_slave_flag(slave_port_id);
6289 }
6290 
6291 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6292 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6293 		add, "add");
6294 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6295 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6296 		bonding, "bonding");
6297 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6298 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6299 		slave, "slave");
6300 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6301 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6302 		slave_id, RTE_UINT16);
6303 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6304 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6305 		port_id, RTE_UINT16);
6306 
6307 cmdline_parse_inst_t cmd_add_bonding_slave = {
6308 		.f = cmd_add_bonding_slave_parsed,
6309 		.help_str = "add bonding slave <slave_id> <port_id>: "
6310 			"Add a slave device to a bonded device",
6311 		.data = NULL,
6312 		.tokens = {
6313 				(void *)&cmd_addbonding_slave_add,
6314 				(void *)&cmd_addbonding_slave_bonding,
6315 				(void *)&cmd_addbonding_slave_slave,
6316 				(void *)&cmd_addbonding_slave_slaveid,
6317 				(void *)&cmd_addbonding_slave_port,
6318 				NULL
6319 		}
6320 };
6321 
6322 /* *** REMOVE SLAVE *** */
6323 struct cmd_remove_bonding_slave_result {
6324 	cmdline_fixed_string_t remove;
6325 	cmdline_fixed_string_t bonding;
6326 	cmdline_fixed_string_t slave;
6327 	portid_t slave_id;
6328 	portid_t port_id;
6329 };
6330 
6331 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6332 		__rte_unused  struct cmdline *cl,
6333 		__rte_unused void *data)
6334 {
6335 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6336 	portid_t master_port_id = res->port_id;
6337 	portid_t slave_port_id = res->slave_id;
6338 
6339 	/* remove the slave from a bonded device. */
6340 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6341 		printf("\t Failed to remove slave %d from master port = %d.\n",
6342 				slave_port_id, master_port_id);
6343 		return;
6344 	}
6345 	init_port_config();
6346 	clear_port_slave_flag(slave_port_id);
6347 }
6348 
6349 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6350 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6351 				remove, "remove");
6352 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6353 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6354 				bonding, "bonding");
6355 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6356 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6357 				slave, "slave");
6358 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6359 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6360 				slave_id, RTE_UINT16);
6361 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6362 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6363 				port_id, RTE_UINT16);
6364 
6365 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6366 		.f = cmd_remove_bonding_slave_parsed,
6367 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6368 			"Remove a slave device from a bonded device",
6369 		.data = NULL,
6370 		.tokens = {
6371 				(void *)&cmd_removebonding_slave_remove,
6372 				(void *)&cmd_removebonding_slave_bonding,
6373 				(void *)&cmd_removebonding_slave_slave,
6374 				(void *)&cmd_removebonding_slave_slaveid,
6375 				(void *)&cmd_removebonding_slave_port,
6376 				NULL
6377 		}
6378 };
6379 
6380 /* *** CREATE BONDED DEVICE *** */
6381 struct cmd_create_bonded_device_result {
6382 	cmdline_fixed_string_t create;
6383 	cmdline_fixed_string_t bonded;
6384 	cmdline_fixed_string_t device;
6385 	uint8_t mode;
6386 	uint8_t socket;
6387 };
6388 
6389 static int bond_dev_num = 0;
6390 
6391 static void cmd_create_bonded_device_parsed(void *parsed_result,
6392 		__rte_unused  struct cmdline *cl,
6393 		__rte_unused void *data)
6394 {
6395 	struct cmd_create_bonded_device_result *res = parsed_result;
6396 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6397 	int port_id;
6398 	int ret;
6399 
6400 	if (test_done == 0) {
6401 		printf("Please stop forwarding first\n");
6402 		return;
6403 	}
6404 
6405 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6406 			bond_dev_num++);
6407 
6408 	/* Create a new bonded device. */
6409 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6410 	if (port_id < 0) {
6411 		printf("\t Failed to create bonded device.\n");
6412 		return;
6413 	} else {
6414 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6415 				port_id);
6416 
6417 		/* Update number of ports */
6418 		nb_ports = rte_eth_dev_count_avail();
6419 		reconfig(port_id, res->socket);
6420 		ret = rte_eth_promiscuous_enable(port_id);
6421 		if (ret != 0)
6422 			printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6423 				port_id, rte_strerror(-ret));
6424 
6425 		ports[port_id].need_setup = 0;
6426 		ports[port_id].port_status = RTE_PORT_STOPPED;
6427 	}
6428 
6429 }
6430 
6431 cmdline_parse_token_string_t cmd_createbonded_device_create =
6432 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6433 				create, "create");
6434 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6435 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6436 				bonded, "bonded");
6437 cmdline_parse_token_string_t cmd_createbonded_device_device =
6438 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6439 				device, "device");
6440 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6441 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6442 				mode, RTE_UINT8);
6443 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6444 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6445 				socket, RTE_UINT8);
6446 
6447 cmdline_parse_inst_t cmd_create_bonded_device = {
6448 		.f = cmd_create_bonded_device_parsed,
6449 		.help_str = "create bonded device <mode> <socket>: "
6450 			"Create a new bonded device with specific bonding mode and socket",
6451 		.data = NULL,
6452 		.tokens = {
6453 				(void *)&cmd_createbonded_device_create,
6454 				(void *)&cmd_createbonded_device_bonded,
6455 				(void *)&cmd_createbonded_device_device,
6456 				(void *)&cmd_createbonded_device_mode,
6457 				(void *)&cmd_createbonded_device_socket,
6458 				NULL
6459 		}
6460 };
6461 
6462 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6463 struct cmd_set_bond_mac_addr_result {
6464 	cmdline_fixed_string_t set;
6465 	cmdline_fixed_string_t bonding;
6466 	cmdline_fixed_string_t mac_addr;
6467 	uint16_t port_num;
6468 	struct rte_ether_addr address;
6469 };
6470 
6471 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6472 		__rte_unused  struct cmdline *cl,
6473 		__rte_unused void *data)
6474 {
6475 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6476 	int ret;
6477 
6478 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6479 		return;
6480 
6481 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6482 
6483 	/* check the return value and print it if is < 0 */
6484 	if (ret < 0)
6485 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6486 }
6487 
6488 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6489 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6490 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6491 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6492 				"bonding");
6493 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6494 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6495 				"mac_addr");
6496 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6497 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6498 				port_num, RTE_UINT16);
6499 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6500 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6501 
6502 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6503 		.f = cmd_set_bond_mac_addr_parsed,
6504 		.data = (void *) 0,
6505 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6506 		.tokens = {
6507 				(void *)&cmd_set_bond_mac_addr_set,
6508 				(void *)&cmd_set_bond_mac_addr_bonding,
6509 				(void *)&cmd_set_bond_mac_addr_mac,
6510 				(void *)&cmd_set_bond_mac_addr_portnum,
6511 				(void *)&cmd_set_bond_mac_addr_addr,
6512 				NULL
6513 		}
6514 };
6515 
6516 
6517 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6518 struct cmd_set_bond_mon_period_result {
6519 	cmdline_fixed_string_t set;
6520 	cmdline_fixed_string_t bonding;
6521 	cmdline_fixed_string_t mon_period;
6522 	uint16_t port_num;
6523 	uint32_t period_ms;
6524 };
6525 
6526 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6527 		__rte_unused  struct cmdline *cl,
6528 		__rte_unused void *data)
6529 {
6530 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6531 	int ret;
6532 
6533 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6534 
6535 	/* check the return value and print it if is < 0 */
6536 	if (ret < 0)
6537 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6538 }
6539 
6540 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6541 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6542 				set, "set");
6543 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6544 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6545 				bonding, "bonding");
6546 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6547 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6548 				mon_period,	"mon_period");
6549 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6550 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6551 				port_num, RTE_UINT16);
6552 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6553 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6554 				period_ms, RTE_UINT32);
6555 
6556 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6557 		.f = cmd_set_bond_mon_period_parsed,
6558 		.data = (void *) 0,
6559 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6560 		.tokens = {
6561 				(void *)&cmd_set_bond_mon_period_set,
6562 				(void *)&cmd_set_bond_mon_period_bonding,
6563 				(void *)&cmd_set_bond_mon_period_mon_period,
6564 				(void *)&cmd_set_bond_mon_period_portnum,
6565 				(void *)&cmd_set_bond_mon_period_period_ms,
6566 				NULL
6567 		}
6568 };
6569 
6570 
6571 
6572 struct cmd_set_bonding_agg_mode_policy_result {
6573 	cmdline_fixed_string_t set;
6574 	cmdline_fixed_string_t bonding;
6575 	cmdline_fixed_string_t agg_mode;
6576 	uint16_t port_num;
6577 	cmdline_fixed_string_t policy;
6578 };
6579 
6580 
6581 static void
6582 cmd_set_bonding_agg_mode(void *parsed_result,
6583 		__rte_unused struct cmdline *cl,
6584 		__rte_unused void *data)
6585 {
6586 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6587 	uint8_t policy = AGG_BANDWIDTH;
6588 
6589 	if (!strcmp(res->policy, "bandwidth"))
6590 		policy = AGG_BANDWIDTH;
6591 	else if (!strcmp(res->policy, "stable"))
6592 		policy = AGG_STABLE;
6593 	else if (!strcmp(res->policy, "count"))
6594 		policy = AGG_COUNT;
6595 
6596 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6597 }
6598 
6599 
6600 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6601 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6602 				set, "set");
6603 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6604 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6605 				bonding, "bonding");
6606 
6607 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6608 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6609 				agg_mode, "agg_mode");
6610 
6611 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6612 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6613 				port_num, RTE_UINT16);
6614 
6615 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6616 	TOKEN_STRING_INITIALIZER(
6617 			struct cmd_set_bonding_balance_xmit_policy_result,
6618 		policy, "stable#bandwidth#count");
6619 
6620 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6621 	.f = cmd_set_bonding_agg_mode,
6622 	.data = (void *) 0,
6623 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6624 	.tokens = {
6625 			(void *)&cmd_set_bonding_agg_mode_set,
6626 			(void *)&cmd_set_bonding_agg_mode_bonding,
6627 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6628 			(void *)&cmd_set_bonding_agg_mode_portnum,
6629 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6630 			NULL
6631 		}
6632 };
6633 
6634 
6635 #endif /* RTE_NET_BOND */
6636 
6637 /* *** SET FORWARDING MODE *** */
6638 struct cmd_set_fwd_mode_result {
6639 	cmdline_fixed_string_t set;
6640 	cmdline_fixed_string_t fwd;
6641 	cmdline_fixed_string_t mode;
6642 };
6643 
6644 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6645 				    __rte_unused struct cmdline *cl,
6646 				    __rte_unused void *data)
6647 {
6648 	struct cmd_set_fwd_mode_result *res = parsed_result;
6649 
6650 	retry_enabled = 0;
6651 	set_pkt_forwarding_mode(res->mode);
6652 }
6653 
6654 cmdline_parse_token_string_t cmd_setfwd_set =
6655 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6656 cmdline_parse_token_string_t cmd_setfwd_fwd =
6657 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6658 cmdline_parse_token_string_t cmd_setfwd_mode =
6659 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6660 		"" /* defined at init */);
6661 
6662 cmdline_parse_inst_t cmd_set_fwd_mode = {
6663 	.f = cmd_set_fwd_mode_parsed,
6664 	.data = NULL,
6665 	.help_str = NULL, /* defined at init */
6666 	.tokens = {
6667 		(void *)&cmd_setfwd_set,
6668 		(void *)&cmd_setfwd_fwd,
6669 		(void *)&cmd_setfwd_mode,
6670 		NULL,
6671 	},
6672 };
6673 
6674 static void cmd_set_fwd_mode_init(void)
6675 {
6676 	char *modes, *c;
6677 	static char token[128];
6678 	static char help[256];
6679 	cmdline_parse_token_string_t *token_struct;
6680 
6681 	modes = list_pkt_forwarding_modes();
6682 	snprintf(help, sizeof(help), "set fwd %s: "
6683 		"Set packet forwarding mode", modes);
6684 	cmd_set_fwd_mode.help_str = help;
6685 
6686 	/* string token separator is # */
6687 	for (c = token; *modes != '\0'; modes++)
6688 		if (*modes == '|')
6689 			*c++ = '#';
6690 		else
6691 			*c++ = *modes;
6692 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6693 	token_struct->string_data.str = token;
6694 }
6695 
6696 /* *** SET RETRY FORWARDING MODE *** */
6697 struct cmd_set_fwd_retry_mode_result {
6698 	cmdline_fixed_string_t set;
6699 	cmdline_fixed_string_t fwd;
6700 	cmdline_fixed_string_t mode;
6701 	cmdline_fixed_string_t retry;
6702 };
6703 
6704 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6705 			    __rte_unused struct cmdline *cl,
6706 			    __rte_unused void *data)
6707 {
6708 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6709 
6710 	retry_enabled = 1;
6711 	set_pkt_forwarding_mode(res->mode);
6712 }
6713 
6714 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6715 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6716 			set, "set");
6717 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6718 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6719 			fwd, "fwd");
6720 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6721 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6722 			mode,
6723 		"" /* defined at init */);
6724 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6725 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6726 			retry, "retry");
6727 
6728 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6729 	.f = cmd_set_fwd_retry_mode_parsed,
6730 	.data = NULL,
6731 	.help_str = NULL, /* defined at init */
6732 	.tokens = {
6733 		(void *)&cmd_setfwd_retry_set,
6734 		(void *)&cmd_setfwd_retry_fwd,
6735 		(void *)&cmd_setfwd_retry_mode,
6736 		(void *)&cmd_setfwd_retry_retry,
6737 		NULL,
6738 	},
6739 };
6740 
6741 static void cmd_set_fwd_retry_mode_init(void)
6742 {
6743 	char *modes, *c;
6744 	static char token[128];
6745 	static char help[256];
6746 	cmdline_parse_token_string_t *token_struct;
6747 
6748 	modes = list_pkt_forwarding_retry_modes();
6749 	snprintf(help, sizeof(help), "set fwd %s retry: "
6750 		"Set packet forwarding mode with retry", modes);
6751 	cmd_set_fwd_retry_mode.help_str = help;
6752 
6753 	/* string token separator is # */
6754 	for (c = token; *modes != '\0'; modes++)
6755 		if (*modes == '|')
6756 			*c++ = '#';
6757 		else
6758 			*c++ = *modes;
6759 	token_struct = (cmdline_parse_token_string_t *)
6760 		cmd_set_fwd_retry_mode.tokens[2];
6761 	token_struct->string_data.str = token;
6762 }
6763 
6764 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6765 struct cmd_set_burst_tx_retry_result {
6766 	cmdline_fixed_string_t set;
6767 	cmdline_fixed_string_t burst;
6768 	cmdline_fixed_string_t tx;
6769 	cmdline_fixed_string_t delay;
6770 	uint32_t time;
6771 	cmdline_fixed_string_t retry;
6772 	uint32_t retry_num;
6773 };
6774 
6775 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6776 					__rte_unused struct cmdline *cl,
6777 					__rte_unused void *data)
6778 {
6779 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6780 
6781 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6782 		&& !strcmp(res->tx, "tx")) {
6783 		if (!strcmp(res->delay, "delay"))
6784 			burst_tx_delay_time = res->time;
6785 		if (!strcmp(res->retry, "retry"))
6786 			burst_tx_retry_num = res->retry_num;
6787 	}
6788 
6789 }
6790 
6791 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6792 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6793 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6794 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6795 				 "burst");
6796 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6797 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6798 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6799 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6800 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6801 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6802 				 RTE_UINT32);
6803 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6804 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6805 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6806 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6807 				 RTE_UINT32);
6808 
6809 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6810 	.f = cmd_set_burst_tx_retry_parsed,
6811 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6812 	.tokens = {
6813 		(void *)&cmd_set_burst_tx_retry_set,
6814 		(void *)&cmd_set_burst_tx_retry_burst,
6815 		(void *)&cmd_set_burst_tx_retry_tx,
6816 		(void *)&cmd_set_burst_tx_retry_delay,
6817 		(void *)&cmd_set_burst_tx_retry_time,
6818 		(void *)&cmd_set_burst_tx_retry_retry,
6819 		(void *)&cmd_set_burst_tx_retry_retry_num,
6820 		NULL,
6821 	},
6822 };
6823 
6824 /* *** SET PROMISC MODE *** */
6825 struct cmd_set_promisc_mode_result {
6826 	cmdline_fixed_string_t set;
6827 	cmdline_fixed_string_t promisc;
6828 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6829 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6830 	cmdline_fixed_string_t mode;
6831 };
6832 
6833 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6834 					__rte_unused struct cmdline *cl,
6835 					void *allports)
6836 {
6837 	struct cmd_set_promisc_mode_result *res = parsed_result;
6838 	int enable;
6839 	portid_t i;
6840 
6841 	if (!strcmp(res->mode, "on"))
6842 		enable = 1;
6843 	else
6844 		enable = 0;
6845 
6846 	/* all ports */
6847 	if (allports) {
6848 		RTE_ETH_FOREACH_DEV(i)
6849 			eth_set_promisc_mode(i, enable);
6850 	} else {
6851 		eth_set_promisc_mode(res->port_num, enable);
6852 	}
6853 }
6854 
6855 cmdline_parse_token_string_t cmd_setpromisc_set =
6856 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6857 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6858 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6859 				 "promisc");
6860 cmdline_parse_token_string_t cmd_setpromisc_portall =
6861 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6862 				 "all");
6863 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6864 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6865 			      RTE_UINT16);
6866 cmdline_parse_token_string_t cmd_setpromisc_mode =
6867 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6868 				 "on#off");
6869 
6870 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6871 	.f = cmd_set_promisc_mode_parsed,
6872 	.data = (void *)1,
6873 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6874 	.tokens = {
6875 		(void *)&cmd_setpromisc_set,
6876 		(void *)&cmd_setpromisc_promisc,
6877 		(void *)&cmd_setpromisc_portall,
6878 		(void *)&cmd_setpromisc_mode,
6879 		NULL,
6880 	},
6881 };
6882 
6883 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6884 	.f = cmd_set_promisc_mode_parsed,
6885 	.data = (void *)0,
6886 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6887 	.tokens = {
6888 		(void *)&cmd_setpromisc_set,
6889 		(void *)&cmd_setpromisc_promisc,
6890 		(void *)&cmd_setpromisc_portnum,
6891 		(void *)&cmd_setpromisc_mode,
6892 		NULL,
6893 	},
6894 };
6895 
6896 /* *** SET ALLMULTI MODE *** */
6897 struct cmd_set_allmulti_mode_result {
6898 	cmdline_fixed_string_t set;
6899 	cmdline_fixed_string_t allmulti;
6900 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6901 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6902 	cmdline_fixed_string_t mode;
6903 };
6904 
6905 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6906 					__rte_unused struct cmdline *cl,
6907 					void *allports)
6908 {
6909 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6910 	int enable;
6911 	portid_t i;
6912 
6913 	if (!strcmp(res->mode, "on"))
6914 		enable = 1;
6915 	else
6916 		enable = 0;
6917 
6918 	/* all ports */
6919 	if (allports) {
6920 		RTE_ETH_FOREACH_DEV(i) {
6921 			eth_set_allmulticast_mode(i, enable);
6922 		}
6923 	}
6924 	else {
6925 		eth_set_allmulticast_mode(res->port_num, enable);
6926 	}
6927 }
6928 
6929 cmdline_parse_token_string_t cmd_setallmulti_set =
6930 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6931 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6932 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6933 				 "allmulti");
6934 cmdline_parse_token_string_t cmd_setallmulti_portall =
6935 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6936 				 "all");
6937 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6938 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6939 			      RTE_UINT16);
6940 cmdline_parse_token_string_t cmd_setallmulti_mode =
6941 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6942 				 "on#off");
6943 
6944 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6945 	.f = cmd_set_allmulti_mode_parsed,
6946 	.data = (void *)1,
6947 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6948 	.tokens = {
6949 		(void *)&cmd_setallmulti_set,
6950 		(void *)&cmd_setallmulti_allmulti,
6951 		(void *)&cmd_setallmulti_portall,
6952 		(void *)&cmd_setallmulti_mode,
6953 		NULL,
6954 	},
6955 };
6956 
6957 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6958 	.f = cmd_set_allmulti_mode_parsed,
6959 	.data = (void *)0,
6960 	.help_str = "set allmulti <port_id> on|off: "
6961 		"Set allmulti mode on port_id",
6962 	.tokens = {
6963 		(void *)&cmd_setallmulti_set,
6964 		(void *)&cmd_setallmulti_allmulti,
6965 		(void *)&cmd_setallmulti_portnum,
6966 		(void *)&cmd_setallmulti_mode,
6967 		NULL,
6968 	},
6969 };
6970 
6971 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6972 struct cmd_link_flow_ctrl_show {
6973 	cmdline_fixed_string_t show;
6974 	cmdline_fixed_string_t port;
6975 	portid_t port_id;
6976 	cmdline_fixed_string_t flow_ctrl;
6977 };
6978 
6979 cmdline_parse_token_string_t cmd_lfc_show_show =
6980 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6981 				show, "show");
6982 cmdline_parse_token_string_t cmd_lfc_show_port =
6983 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6984 				port, "port");
6985 cmdline_parse_token_num_t cmd_lfc_show_portid =
6986 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6987 				port_id, RTE_UINT16);
6988 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6989 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6990 				flow_ctrl, "flow_ctrl");
6991 
6992 static void
6993 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6994 			      __rte_unused struct cmdline *cl,
6995 			      __rte_unused void *data)
6996 {
6997 	struct cmd_link_flow_ctrl_show *res = parsed_result;
6998 	static const char *info_border = "*********************";
6999 	struct rte_eth_fc_conf fc_conf;
7000 	bool rx_fc_en = false;
7001 	bool tx_fc_en = false;
7002 	int ret;
7003 
7004 	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7005 	if (ret != 0) {
7006 		printf("Failed to get current flow ctrl information: err = %d\n",
7007 		       ret);
7008 		return;
7009 	}
7010 
7011 	if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7012 		rx_fc_en = true;
7013 	if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7014 		tx_fc_en = true;
7015 
7016 	printf("\n%s Flow control infos for port %-2d %s\n",
7017 		info_border, res->port_id, info_border);
7018 	printf("FC mode:\n");
7019 	printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
7020 	printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
7021 	printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7022 	printf("Pause time: 0x%x\n", fc_conf.pause_time);
7023 	printf("High waterline: 0x%x\n", fc_conf.high_water);
7024 	printf("Low waterline: 0x%x\n", fc_conf.low_water);
7025 	printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7026 	printf("Forward MAC control frames: %s\n",
7027 		fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7028 	printf("\n%s**************   End  ***********%s\n",
7029 		info_border, info_border);
7030 }
7031 
7032 cmdline_parse_inst_t cmd_link_flow_control_show = {
7033 	.f = cmd_link_flow_ctrl_show_parsed,
7034 	.data = NULL,
7035 	.help_str = "show port <port_id> flow_ctrl",
7036 	.tokens = {
7037 		(void *)&cmd_lfc_show_show,
7038 		(void *)&cmd_lfc_show_port,
7039 		(void *)&cmd_lfc_show_portid,
7040 		(void *)&cmd_lfc_show_flow_ctrl,
7041 		NULL,
7042 	},
7043 };
7044 
7045 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7046 struct cmd_link_flow_ctrl_set_result {
7047 	cmdline_fixed_string_t set;
7048 	cmdline_fixed_string_t flow_ctrl;
7049 	cmdline_fixed_string_t rx;
7050 	cmdline_fixed_string_t rx_lfc_mode;
7051 	cmdline_fixed_string_t tx;
7052 	cmdline_fixed_string_t tx_lfc_mode;
7053 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
7054 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7055 	cmdline_fixed_string_t autoneg_str;
7056 	cmdline_fixed_string_t autoneg;
7057 	cmdline_fixed_string_t hw_str;
7058 	uint32_t high_water;
7059 	cmdline_fixed_string_t lw_str;
7060 	uint32_t low_water;
7061 	cmdline_fixed_string_t pt_str;
7062 	uint16_t pause_time;
7063 	cmdline_fixed_string_t xon_str;
7064 	uint16_t send_xon;
7065 	portid_t port_id;
7066 };
7067 
7068 cmdline_parse_token_string_t cmd_lfc_set_set =
7069 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7070 				set, "set");
7071 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7072 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7073 				flow_ctrl, "flow_ctrl");
7074 cmdline_parse_token_string_t cmd_lfc_set_rx =
7075 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7076 				rx, "rx");
7077 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7078 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7079 				rx_lfc_mode, "on#off");
7080 cmdline_parse_token_string_t cmd_lfc_set_tx =
7081 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7082 				tx, "tx");
7083 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7084 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7085 				tx_lfc_mode, "on#off");
7086 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7087 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7088 				hw_str, "high_water");
7089 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7090 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7091 				high_water, RTE_UINT32);
7092 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7093 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7094 				lw_str, "low_water");
7095 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7096 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7097 				low_water, RTE_UINT32);
7098 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7099 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7100 				pt_str, "pause_time");
7101 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7102 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7103 				pause_time, RTE_UINT16);
7104 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7105 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7106 				xon_str, "send_xon");
7107 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7108 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7109 				send_xon, RTE_UINT16);
7110 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7111 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7112 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7113 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7114 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7115 				mac_ctrl_frame_fwd_mode, "on#off");
7116 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7117 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7118 				autoneg_str, "autoneg");
7119 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7120 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7121 				autoneg, "on#off");
7122 cmdline_parse_token_num_t cmd_lfc_set_portid =
7123 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7124 				port_id, RTE_UINT16);
7125 
7126 /* forward declaration */
7127 static void
7128 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7129 			      void *data);
7130 
7131 cmdline_parse_inst_t cmd_link_flow_control_set = {
7132 	.f = cmd_link_flow_ctrl_set_parsed,
7133 	.data = NULL,
7134 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7135 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7136 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
7137 	.tokens = {
7138 		(void *)&cmd_lfc_set_set,
7139 		(void *)&cmd_lfc_set_flow_ctrl,
7140 		(void *)&cmd_lfc_set_rx,
7141 		(void *)&cmd_lfc_set_rx_mode,
7142 		(void *)&cmd_lfc_set_tx,
7143 		(void *)&cmd_lfc_set_tx_mode,
7144 		(void *)&cmd_lfc_set_high_water,
7145 		(void *)&cmd_lfc_set_low_water,
7146 		(void *)&cmd_lfc_set_pause_time,
7147 		(void *)&cmd_lfc_set_send_xon,
7148 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7149 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7150 		(void *)&cmd_lfc_set_autoneg_str,
7151 		(void *)&cmd_lfc_set_autoneg,
7152 		(void *)&cmd_lfc_set_portid,
7153 		NULL,
7154 	},
7155 };
7156 
7157 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7158 	.f = cmd_link_flow_ctrl_set_parsed,
7159 	.data = (void *)&cmd_link_flow_control_set_rx,
7160 	.help_str = "set flow_ctrl rx on|off <port_id>: "
7161 		"Change rx flow control parameter",
7162 	.tokens = {
7163 		(void *)&cmd_lfc_set_set,
7164 		(void *)&cmd_lfc_set_flow_ctrl,
7165 		(void *)&cmd_lfc_set_rx,
7166 		(void *)&cmd_lfc_set_rx_mode,
7167 		(void *)&cmd_lfc_set_portid,
7168 		NULL,
7169 	},
7170 };
7171 
7172 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7173 	.f = cmd_link_flow_ctrl_set_parsed,
7174 	.data = (void *)&cmd_link_flow_control_set_tx,
7175 	.help_str = "set flow_ctrl tx on|off <port_id>: "
7176 		"Change tx flow control parameter",
7177 	.tokens = {
7178 		(void *)&cmd_lfc_set_set,
7179 		(void *)&cmd_lfc_set_flow_ctrl,
7180 		(void *)&cmd_lfc_set_tx,
7181 		(void *)&cmd_lfc_set_tx_mode,
7182 		(void *)&cmd_lfc_set_portid,
7183 		NULL,
7184 	},
7185 };
7186 
7187 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7188 	.f = cmd_link_flow_ctrl_set_parsed,
7189 	.data = (void *)&cmd_link_flow_control_set_hw,
7190 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
7191 		"Change high water flow control parameter",
7192 	.tokens = {
7193 		(void *)&cmd_lfc_set_set,
7194 		(void *)&cmd_lfc_set_flow_ctrl,
7195 		(void *)&cmd_lfc_set_high_water_str,
7196 		(void *)&cmd_lfc_set_high_water,
7197 		(void *)&cmd_lfc_set_portid,
7198 		NULL,
7199 	},
7200 };
7201 
7202 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7203 	.f = cmd_link_flow_ctrl_set_parsed,
7204 	.data = (void *)&cmd_link_flow_control_set_lw,
7205 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7206 		"Change low water flow control parameter",
7207 	.tokens = {
7208 		(void *)&cmd_lfc_set_set,
7209 		(void *)&cmd_lfc_set_flow_ctrl,
7210 		(void *)&cmd_lfc_set_low_water_str,
7211 		(void *)&cmd_lfc_set_low_water,
7212 		(void *)&cmd_lfc_set_portid,
7213 		NULL,
7214 	},
7215 };
7216 
7217 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7218 	.f = cmd_link_flow_ctrl_set_parsed,
7219 	.data = (void *)&cmd_link_flow_control_set_pt,
7220 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7221 		"Change pause time flow control parameter",
7222 	.tokens = {
7223 		(void *)&cmd_lfc_set_set,
7224 		(void *)&cmd_lfc_set_flow_ctrl,
7225 		(void *)&cmd_lfc_set_pause_time_str,
7226 		(void *)&cmd_lfc_set_pause_time,
7227 		(void *)&cmd_lfc_set_portid,
7228 		NULL,
7229 	},
7230 };
7231 
7232 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7233 	.f = cmd_link_flow_ctrl_set_parsed,
7234 	.data = (void *)&cmd_link_flow_control_set_xon,
7235 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7236 		"Change send_xon flow control parameter",
7237 	.tokens = {
7238 		(void *)&cmd_lfc_set_set,
7239 		(void *)&cmd_lfc_set_flow_ctrl,
7240 		(void *)&cmd_lfc_set_send_xon_str,
7241 		(void *)&cmd_lfc_set_send_xon,
7242 		(void *)&cmd_lfc_set_portid,
7243 		NULL,
7244 	},
7245 };
7246 
7247 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7248 	.f = cmd_link_flow_ctrl_set_parsed,
7249 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7250 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7251 		"Change mac ctrl fwd flow control parameter",
7252 	.tokens = {
7253 		(void *)&cmd_lfc_set_set,
7254 		(void *)&cmd_lfc_set_flow_ctrl,
7255 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7256 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7257 		(void *)&cmd_lfc_set_portid,
7258 		NULL,
7259 	},
7260 };
7261 
7262 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7263 	.f = cmd_link_flow_ctrl_set_parsed,
7264 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7265 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7266 		"Change autoneg flow control parameter",
7267 	.tokens = {
7268 		(void *)&cmd_lfc_set_set,
7269 		(void *)&cmd_lfc_set_flow_ctrl,
7270 		(void *)&cmd_lfc_set_autoneg_str,
7271 		(void *)&cmd_lfc_set_autoneg,
7272 		(void *)&cmd_lfc_set_portid,
7273 		NULL,
7274 	},
7275 };
7276 
7277 static void
7278 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7279 			      __rte_unused struct cmdline *cl,
7280 			      void *data)
7281 {
7282 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7283 	cmdline_parse_inst_t *cmd = data;
7284 	struct rte_eth_fc_conf fc_conf;
7285 	int rx_fc_en = 0;
7286 	int tx_fc_en = 0;
7287 	int ret;
7288 
7289 	/*
7290 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7291 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7292 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7293 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7294 	 */
7295 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7296 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7297 	};
7298 
7299 	/* Partial command line, retrieve current configuration */
7300 	if (cmd) {
7301 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7302 		if (ret != 0) {
7303 			printf("cannot get current flow ctrl parameters, return"
7304 			       "code = %d\n", ret);
7305 			return;
7306 		}
7307 
7308 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7309 		    (fc_conf.mode == RTE_FC_FULL))
7310 			rx_fc_en = 1;
7311 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7312 		    (fc_conf.mode == RTE_FC_FULL))
7313 			tx_fc_en = 1;
7314 	}
7315 
7316 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7317 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7318 
7319 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7320 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7321 
7322 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7323 
7324 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7325 		fc_conf.high_water = res->high_water;
7326 
7327 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7328 		fc_conf.low_water = res->low_water;
7329 
7330 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7331 		fc_conf.pause_time = res->pause_time;
7332 
7333 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7334 		fc_conf.send_xon = res->send_xon;
7335 
7336 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7337 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7338 			fc_conf.mac_ctrl_frame_fwd = 1;
7339 		else
7340 			fc_conf.mac_ctrl_frame_fwd = 0;
7341 	}
7342 
7343 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7344 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7345 
7346 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7347 	if (ret != 0)
7348 		printf("bad flow contrl parameter, return code = %d \n", ret);
7349 }
7350 
7351 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7352 struct cmd_priority_flow_ctrl_set_result {
7353 	cmdline_fixed_string_t set;
7354 	cmdline_fixed_string_t pfc_ctrl;
7355 	cmdline_fixed_string_t rx;
7356 	cmdline_fixed_string_t rx_pfc_mode;
7357 	cmdline_fixed_string_t tx;
7358 	cmdline_fixed_string_t tx_pfc_mode;
7359 	uint32_t high_water;
7360 	uint32_t low_water;
7361 	uint16_t pause_time;
7362 	uint8_t  priority;
7363 	portid_t port_id;
7364 };
7365 
7366 static void
7367 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7368 		       __rte_unused struct cmdline *cl,
7369 		       __rte_unused void *data)
7370 {
7371 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7372 	struct rte_eth_pfc_conf pfc_conf;
7373 	int rx_fc_enable, tx_fc_enable;
7374 	int ret;
7375 
7376 	/*
7377 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7378 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7379 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7380 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7381 	 */
7382 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7383 		{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7384 	};
7385 
7386 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7387 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7388 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7389 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7390 	pfc_conf.fc.high_water = res->high_water;
7391 	pfc_conf.fc.low_water  = res->low_water;
7392 	pfc_conf.fc.pause_time = res->pause_time;
7393 	pfc_conf.priority      = res->priority;
7394 
7395 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7396 	if (ret != 0)
7397 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7398 }
7399 
7400 cmdline_parse_token_string_t cmd_pfc_set_set =
7401 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7402 				set, "set");
7403 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7404 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7405 				pfc_ctrl, "pfc_ctrl");
7406 cmdline_parse_token_string_t cmd_pfc_set_rx =
7407 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7408 				rx, "rx");
7409 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7410 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7411 				rx_pfc_mode, "on#off");
7412 cmdline_parse_token_string_t cmd_pfc_set_tx =
7413 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7414 				tx, "tx");
7415 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7416 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7417 				tx_pfc_mode, "on#off");
7418 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7419 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7420 				high_water, RTE_UINT32);
7421 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7422 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7423 				low_water, RTE_UINT32);
7424 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7425 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7426 				pause_time, RTE_UINT16);
7427 cmdline_parse_token_num_t cmd_pfc_set_priority =
7428 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7429 				priority, RTE_UINT8);
7430 cmdline_parse_token_num_t cmd_pfc_set_portid =
7431 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7432 				port_id, RTE_UINT16);
7433 
7434 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7435 	.f = cmd_priority_flow_ctrl_set_parsed,
7436 	.data = NULL,
7437 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7438 		"<pause_time> <priority> <port_id>: "
7439 		"Configure the Ethernet priority flow control",
7440 	.tokens = {
7441 		(void *)&cmd_pfc_set_set,
7442 		(void *)&cmd_pfc_set_flow_ctrl,
7443 		(void *)&cmd_pfc_set_rx,
7444 		(void *)&cmd_pfc_set_rx_mode,
7445 		(void *)&cmd_pfc_set_tx,
7446 		(void *)&cmd_pfc_set_tx_mode,
7447 		(void *)&cmd_pfc_set_high_water,
7448 		(void *)&cmd_pfc_set_low_water,
7449 		(void *)&cmd_pfc_set_pause_time,
7450 		(void *)&cmd_pfc_set_priority,
7451 		(void *)&cmd_pfc_set_portid,
7452 		NULL,
7453 	},
7454 };
7455 
7456 /* *** RESET CONFIGURATION *** */
7457 struct cmd_reset_result {
7458 	cmdline_fixed_string_t reset;
7459 	cmdline_fixed_string_t def;
7460 };
7461 
7462 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7463 			     struct cmdline *cl,
7464 			     __rte_unused void *data)
7465 {
7466 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7467 	set_def_fwd_config();
7468 }
7469 
7470 cmdline_parse_token_string_t cmd_reset_set =
7471 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7472 cmdline_parse_token_string_t cmd_reset_def =
7473 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7474 				 "default");
7475 
7476 cmdline_parse_inst_t cmd_reset = {
7477 	.f = cmd_reset_parsed,
7478 	.data = NULL,
7479 	.help_str = "set default: Reset default forwarding configuration",
7480 	.tokens = {
7481 		(void *)&cmd_reset_set,
7482 		(void *)&cmd_reset_def,
7483 		NULL,
7484 	},
7485 };
7486 
7487 /* *** START FORWARDING *** */
7488 struct cmd_start_result {
7489 	cmdline_fixed_string_t start;
7490 };
7491 
7492 cmdline_parse_token_string_t cmd_start_start =
7493 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7494 
7495 static void cmd_start_parsed(__rte_unused void *parsed_result,
7496 			     __rte_unused struct cmdline *cl,
7497 			     __rte_unused void *data)
7498 {
7499 	start_packet_forwarding(0);
7500 }
7501 
7502 cmdline_parse_inst_t cmd_start = {
7503 	.f = cmd_start_parsed,
7504 	.data = NULL,
7505 	.help_str = "start: Start packet forwarding",
7506 	.tokens = {
7507 		(void *)&cmd_start_start,
7508 		NULL,
7509 	},
7510 };
7511 
7512 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7513 struct cmd_start_tx_first_result {
7514 	cmdline_fixed_string_t start;
7515 	cmdline_fixed_string_t tx_first;
7516 };
7517 
7518 static void
7519 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7520 			  __rte_unused struct cmdline *cl,
7521 			  __rte_unused void *data)
7522 {
7523 	start_packet_forwarding(1);
7524 }
7525 
7526 cmdline_parse_token_string_t cmd_start_tx_first_start =
7527 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7528 				 "start");
7529 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7530 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7531 				 tx_first, "tx_first");
7532 
7533 cmdline_parse_inst_t cmd_start_tx_first = {
7534 	.f = cmd_start_tx_first_parsed,
7535 	.data = NULL,
7536 	.help_str = "start tx_first: Start packet forwarding, "
7537 		"after sending 1 burst of packets",
7538 	.tokens = {
7539 		(void *)&cmd_start_tx_first_start,
7540 		(void *)&cmd_start_tx_first_tx_first,
7541 		NULL,
7542 	},
7543 };
7544 
7545 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7546 struct cmd_start_tx_first_n_result {
7547 	cmdline_fixed_string_t start;
7548 	cmdline_fixed_string_t tx_first;
7549 	uint32_t tx_num;
7550 };
7551 
7552 static void
7553 cmd_start_tx_first_n_parsed(void *parsed_result,
7554 			  __rte_unused struct cmdline *cl,
7555 			  __rte_unused void *data)
7556 {
7557 	struct cmd_start_tx_first_n_result *res = parsed_result;
7558 
7559 	start_packet_forwarding(res->tx_num);
7560 }
7561 
7562 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7563 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7564 			start, "start");
7565 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7566 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7567 			tx_first, "tx_first");
7568 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7569 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7570 			tx_num, RTE_UINT32);
7571 
7572 cmdline_parse_inst_t cmd_start_tx_first_n = {
7573 	.f = cmd_start_tx_first_n_parsed,
7574 	.data = NULL,
7575 	.help_str = "start tx_first <num>: "
7576 		"packet forwarding, after sending <num> bursts of packets",
7577 	.tokens = {
7578 		(void *)&cmd_start_tx_first_n_start,
7579 		(void *)&cmd_start_tx_first_n_tx_first,
7580 		(void *)&cmd_start_tx_first_n_tx_num,
7581 		NULL,
7582 	},
7583 };
7584 
7585 /* *** SET LINK UP *** */
7586 struct cmd_set_link_up_result {
7587 	cmdline_fixed_string_t set;
7588 	cmdline_fixed_string_t link_up;
7589 	cmdline_fixed_string_t port;
7590 	portid_t port_id;
7591 };
7592 
7593 cmdline_parse_token_string_t cmd_set_link_up_set =
7594 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7595 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7596 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7597 				"link-up");
7598 cmdline_parse_token_string_t cmd_set_link_up_port =
7599 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7600 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7601 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7602 				RTE_UINT16);
7603 
7604 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7605 			     __rte_unused struct cmdline *cl,
7606 			     __rte_unused void *data)
7607 {
7608 	struct cmd_set_link_up_result *res = parsed_result;
7609 	dev_set_link_up(res->port_id);
7610 }
7611 
7612 cmdline_parse_inst_t cmd_set_link_up = {
7613 	.f = cmd_set_link_up_parsed,
7614 	.data = NULL,
7615 	.help_str = "set link-up port <port id>",
7616 	.tokens = {
7617 		(void *)&cmd_set_link_up_set,
7618 		(void *)&cmd_set_link_up_link_up,
7619 		(void *)&cmd_set_link_up_port,
7620 		(void *)&cmd_set_link_up_port_id,
7621 		NULL,
7622 	},
7623 };
7624 
7625 /* *** SET LINK DOWN *** */
7626 struct cmd_set_link_down_result {
7627 	cmdline_fixed_string_t set;
7628 	cmdline_fixed_string_t link_down;
7629 	cmdline_fixed_string_t port;
7630 	portid_t port_id;
7631 };
7632 
7633 cmdline_parse_token_string_t cmd_set_link_down_set =
7634 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7635 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7636 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7637 				"link-down");
7638 cmdline_parse_token_string_t cmd_set_link_down_port =
7639 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7640 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7641 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7642 				RTE_UINT16);
7643 
7644 static void cmd_set_link_down_parsed(
7645 				__rte_unused void *parsed_result,
7646 				__rte_unused struct cmdline *cl,
7647 				__rte_unused void *data)
7648 {
7649 	struct cmd_set_link_down_result *res = parsed_result;
7650 	dev_set_link_down(res->port_id);
7651 }
7652 
7653 cmdline_parse_inst_t cmd_set_link_down = {
7654 	.f = cmd_set_link_down_parsed,
7655 	.data = NULL,
7656 	.help_str = "set link-down port <port id>",
7657 	.tokens = {
7658 		(void *)&cmd_set_link_down_set,
7659 		(void *)&cmd_set_link_down_link_down,
7660 		(void *)&cmd_set_link_down_port,
7661 		(void *)&cmd_set_link_down_port_id,
7662 		NULL,
7663 	},
7664 };
7665 
7666 /* *** SHOW CFG *** */
7667 struct cmd_showcfg_result {
7668 	cmdline_fixed_string_t show;
7669 	cmdline_fixed_string_t cfg;
7670 	cmdline_fixed_string_t what;
7671 };
7672 
7673 static void cmd_showcfg_parsed(void *parsed_result,
7674 			       __rte_unused struct cmdline *cl,
7675 			       __rte_unused void *data)
7676 {
7677 	struct cmd_showcfg_result *res = parsed_result;
7678 	if (!strcmp(res->what, "rxtx"))
7679 		rxtx_config_display();
7680 	else if (!strcmp(res->what, "cores"))
7681 		fwd_lcores_config_display();
7682 	else if (!strcmp(res->what, "fwd"))
7683 		pkt_fwd_config_display(&cur_fwd_config);
7684 	else if (!strcmp(res->what, "rxoffs"))
7685 		show_rx_pkt_offsets();
7686 	else if (!strcmp(res->what, "rxpkts"))
7687 		show_rx_pkt_segments();
7688 	else if (!strcmp(res->what, "txpkts"))
7689 		show_tx_pkt_segments();
7690 	else if (!strcmp(res->what, "txtimes"))
7691 		show_tx_pkt_times();
7692 }
7693 
7694 cmdline_parse_token_string_t cmd_showcfg_show =
7695 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7696 cmdline_parse_token_string_t cmd_showcfg_port =
7697 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7698 cmdline_parse_token_string_t cmd_showcfg_what =
7699 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7700 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7701 
7702 cmdline_parse_inst_t cmd_showcfg = {
7703 	.f = cmd_showcfg_parsed,
7704 	.data = NULL,
7705 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7706 	.tokens = {
7707 		(void *)&cmd_showcfg_show,
7708 		(void *)&cmd_showcfg_port,
7709 		(void *)&cmd_showcfg_what,
7710 		NULL,
7711 	},
7712 };
7713 
7714 /* *** SHOW ALL PORT INFO *** */
7715 struct cmd_showportall_result {
7716 	cmdline_fixed_string_t show;
7717 	cmdline_fixed_string_t port;
7718 	cmdline_fixed_string_t what;
7719 	cmdline_fixed_string_t all;
7720 };
7721 
7722 static void cmd_showportall_parsed(void *parsed_result,
7723 				__rte_unused struct cmdline *cl,
7724 				__rte_unused void *data)
7725 {
7726 	portid_t i;
7727 
7728 	struct cmd_showportall_result *res = parsed_result;
7729 	if (!strcmp(res->show, "clear")) {
7730 		if (!strcmp(res->what, "stats"))
7731 			RTE_ETH_FOREACH_DEV(i)
7732 				nic_stats_clear(i);
7733 		else if (!strcmp(res->what, "xstats"))
7734 			RTE_ETH_FOREACH_DEV(i)
7735 				nic_xstats_clear(i);
7736 	} else if (!strcmp(res->what, "info"))
7737 		RTE_ETH_FOREACH_DEV(i)
7738 			port_infos_display(i);
7739 	else if (!strcmp(res->what, "summary")) {
7740 		port_summary_header_display();
7741 		RTE_ETH_FOREACH_DEV(i)
7742 			port_summary_display(i);
7743 	}
7744 	else if (!strcmp(res->what, "stats"))
7745 		RTE_ETH_FOREACH_DEV(i)
7746 			nic_stats_display(i);
7747 	else if (!strcmp(res->what, "xstats"))
7748 		RTE_ETH_FOREACH_DEV(i)
7749 			nic_xstats_display(i);
7750 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7751 	else if (!strcmp(res->what, "fdir"))
7752 		RTE_ETH_FOREACH_DEV(i)
7753 			fdir_get_infos(i);
7754 #endif
7755 	else if (!strcmp(res->what, "dcb_tc"))
7756 		RTE_ETH_FOREACH_DEV(i)
7757 			port_dcb_info_display(i);
7758 }
7759 
7760 cmdline_parse_token_string_t cmd_showportall_show =
7761 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7762 				 "show#clear");
7763 cmdline_parse_token_string_t cmd_showportall_port =
7764 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7765 cmdline_parse_token_string_t cmd_showportall_what =
7766 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7767 				 "info#summary#stats#xstats#fdir#dcb_tc");
7768 cmdline_parse_token_string_t cmd_showportall_all =
7769 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7770 cmdline_parse_inst_t cmd_showportall = {
7771 	.f = cmd_showportall_parsed,
7772 	.data = NULL,
7773 	.help_str = "show|clear port "
7774 		"info|summary|stats|xstats|fdir|dcb_tc all",
7775 	.tokens = {
7776 		(void *)&cmd_showportall_show,
7777 		(void *)&cmd_showportall_port,
7778 		(void *)&cmd_showportall_what,
7779 		(void *)&cmd_showportall_all,
7780 		NULL,
7781 	},
7782 };
7783 
7784 /* *** SHOW PORT INFO *** */
7785 struct cmd_showport_result {
7786 	cmdline_fixed_string_t show;
7787 	cmdline_fixed_string_t port;
7788 	cmdline_fixed_string_t what;
7789 	uint16_t portnum;
7790 };
7791 
7792 static void cmd_showport_parsed(void *parsed_result,
7793 				__rte_unused struct cmdline *cl,
7794 				__rte_unused void *data)
7795 {
7796 	struct cmd_showport_result *res = parsed_result;
7797 	if (!strcmp(res->show, "clear")) {
7798 		if (!strcmp(res->what, "stats"))
7799 			nic_stats_clear(res->portnum);
7800 		else if (!strcmp(res->what, "xstats"))
7801 			nic_xstats_clear(res->portnum);
7802 	} else if (!strcmp(res->what, "info"))
7803 		port_infos_display(res->portnum);
7804 	else if (!strcmp(res->what, "summary")) {
7805 		port_summary_header_display();
7806 		port_summary_display(res->portnum);
7807 	}
7808 	else if (!strcmp(res->what, "stats"))
7809 		nic_stats_display(res->portnum);
7810 	else if (!strcmp(res->what, "xstats"))
7811 		nic_xstats_display(res->portnum);
7812 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7813 	else if (!strcmp(res->what, "fdir"))
7814 		 fdir_get_infos(res->portnum);
7815 #endif
7816 	else if (!strcmp(res->what, "dcb_tc"))
7817 		port_dcb_info_display(res->portnum);
7818 }
7819 
7820 cmdline_parse_token_string_t cmd_showport_show =
7821 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7822 				 "show#clear");
7823 cmdline_parse_token_string_t cmd_showport_port =
7824 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7825 cmdline_parse_token_string_t cmd_showport_what =
7826 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7827 				 "info#summary#stats#xstats#fdir#dcb_tc");
7828 cmdline_parse_token_num_t cmd_showport_portnum =
7829 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7830 
7831 cmdline_parse_inst_t cmd_showport = {
7832 	.f = cmd_showport_parsed,
7833 	.data = NULL,
7834 	.help_str = "show|clear port "
7835 		"info|summary|stats|xstats|fdir|dcb_tc "
7836 		"<port_id>",
7837 	.tokens = {
7838 		(void *)&cmd_showport_show,
7839 		(void *)&cmd_showport_port,
7840 		(void *)&cmd_showport_what,
7841 		(void *)&cmd_showport_portnum,
7842 		NULL,
7843 	},
7844 };
7845 
7846 /* *** SHOW DEVICE INFO *** */
7847 struct cmd_showdevice_result {
7848 	cmdline_fixed_string_t show;
7849 	cmdline_fixed_string_t device;
7850 	cmdline_fixed_string_t what;
7851 	cmdline_fixed_string_t identifier;
7852 };
7853 
7854 static void cmd_showdevice_parsed(void *parsed_result,
7855 				__rte_unused struct cmdline *cl,
7856 				__rte_unused void *data)
7857 {
7858 	struct cmd_showdevice_result *res = parsed_result;
7859 	if (!strcmp(res->what, "info")) {
7860 		if (!strcmp(res->identifier, "all"))
7861 			device_infos_display(NULL);
7862 		else
7863 			device_infos_display(res->identifier);
7864 	}
7865 }
7866 
7867 cmdline_parse_token_string_t cmd_showdevice_show =
7868 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7869 				 "show");
7870 cmdline_parse_token_string_t cmd_showdevice_device =
7871 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7872 cmdline_parse_token_string_t cmd_showdevice_what =
7873 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7874 				 "info");
7875 cmdline_parse_token_string_t cmd_showdevice_identifier =
7876 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7877 			identifier, NULL);
7878 
7879 cmdline_parse_inst_t cmd_showdevice = {
7880 	.f = cmd_showdevice_parsed,
7881 	.data = NULL,
7882 	.help_str = "show device info <identifier>|all",
7883 	.tokens = {
7884 		(void *)&cmd_showdevice_show,
7885 		(void *)&cmd_showdevice_device,
7886 		(void *)&cmd_showdevice_what,
7887 		(void *)&cmd_showdevice_identifier,
7888 		NULL,
7889 	},
7890 };
7891 
7892 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7893 struct cmd_showeeprom_result {
7894 	cmdline_fixed_string_t show;
7895 	cmdline_fixed_string_t port;
7896 	uint16_t portnum;
7897 	cmdline_fixed_string_t type;
7898 };
7899 
7900 static void cmd_showeeprom_parsed(void *parsed_result,
7901 		__rte_unused struct cmdline *cl,
7902 		__rte_unused void *data)
7903 {
7904 	struct cmd_showeeprom_result *res = parsed_result;
7905 
7906 	if (!strcmp(res->type, "eeprom"))
7907 		port_eeprom_display(res->portnum);
7908 	else if (!strcmp(res->type, "module_eeprom"))
7909 		port_module_eeprom_display(res->portnum);
7910 	else
7911 		printf("Unknown argument\n");
7912 }
7913 
7914 cmdline_parse_token_string_t cmd_showeeprom_show =
7915 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7916 cmdline_parse_token_string_t cmd_showeeprom_port =
7917 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7918 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7919 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7920 			RTE_UINT16);
7921 cmdline_parse_token_string_t cmd_showeeprom_type =
7922 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7923 
7924 cmdline_parse_inst_t cmd_showeeprom = {
7925 	.f = cmd_showeeprom_parsed,
7926 	.data = NULL,
7927 	.help_str = "show port <port_id> module_eeprom|eeprom",
7928 	.tokens = {
7929 		(void *)&cmd_showeeprom_show,
7930 		(void *)&cmd_showeeprom_port,
7931 		(void *)&cmd_showeeprom_portnum,
7932 		(void *)&cmd_showeeprom_type,
7933 		NULL,
7934 	},
7935 };
7936 
7937 /* *** SHOW QUEUE INFO *** */
7938 struct cmd_showqueue_result {
7939 	cmdline_fixed_string_t show;
7940 	cmdline_fixed_string_t type;
7941 	cmdline_fixed_string_t what;
7942 	uint16_t portnum;
7943 	uint16_t queuenum;
7944 };
7945 
7946 static void
7947 cmd_showqueue_parsed(void *parsed_result,
7948 	__rte_unused struct cmdline *cl,
7949 	__rte_unused void *data)
7950 {
7951 	struct cmd_showqueue_result *res = parsed_result;
7952 
7953 	if (!strcmp(res->type, "rxq"))
7954 		rx_queue_infos_display(res->portnum, res->queuenum);
7955 	else if (!strcmp(res->type, "txq"))
7956 		tx_queue_infos_display(res->portnum, res->queuenum);
7957 }
7958 
7959 cmdline_parse_token_string_t cmd_showqueue_show =
7960 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7961 cmdline_parse_token_string_t cmd_showqueue_type =
7962 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7963 cmdline_parse_token_string_t cmd_showqueue_what =
7964 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7965 cmdline_parse_token_num_t cmd_showqueue_portnum =
7966 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7967 		RTE_UINT16);
7968 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7969 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7970 		RTE_UINT16);
7971 
7972 cmdline_parse_inst_t cmd_showqueue = {
7973 	.f = cmd_showqueue_parsed,
7974 	.data = NULL,
7975 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7976 	.tokens = {
7977 		(void *)&cmd_showqueue_show,
7978 		(void *)&cmd_showqueue_type,
7979 		(void *)&cmd_showqueue_what,
7980 		(void *)&cmd_showqueue_portnum,
7981 		(void *)&cmd_showqueue_queuenum,
7982 		NULL,
7983 	},
7984 };
7985 
7986 /* show/clear fwd engine statistics */
7987 struct fwd_result {
7988 	cmdline_fixed_string_t action;
7989 	cmdline_fixed_string_t fwd;
7990 	cmdline_fixed_string_t stats;
7991 	cmdline_fixed_string_t all;
7992 };
7993 
7994 cmdline_parse_token_string_t cmd_fwd_action =
7995 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7996 cmdline_parse_token_string_t cmd_fwd_fwd =
7997 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7998 cmdline_parse_token_string_t cmd_fwd_stats =
7999 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8000 cmdline_parse_token_string_t cmd_fwd_all =
8001 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8002 
8003 static void
8004 cmd_showfwdall_parsed(void *parsed_result,
8005 		      __rte_unused struct cmdline *cl,
8006 		      __rte_unused void *data)
8007 {
8008 	struct fwd_result *res = parsed_result;
8009 
8010 	if (!strcmp(res->action, "show"))
8011 		fwd_stats_display();
8012 	else
8013 		fwd_stats_reset();
8014 }
8015 
8016 static cmdline_parse_inst_t cmd_showfwdall = {
8017 	.f = cmd_showfwdall_parsed,
8018 	.data = NULL,
8019 	.help_str = "show|clear fwd stats all",
8020 	.tokens = {
8021 		(void *)&cmd_fwd_action,
8022 		(void *)&cmd_fwd_fwd,
8023 		(void *)&cmd_fwd_stats,
8024 		(void *)&cmd_fwd_all,
8025 		NULL,
8026 	},
8027 };
8028 
8029 /* *** READ PORT REGISTER *** */
8030 struct cmd_read_reg_result {
8031 	cmdline_fixed_string_t read;
8032 	cmdline_fixed_string_t reg;
8033 	portid_t port_id;
8034 	uint32_t reg_off;
8035 };
8036 
8037 static void
8038 cmd_read_reg_parsed(void *parsed_result,
8039 		    __rte_unused struct cmdline *cl,
8040 		    __rte_unused void *data)
8041 {
8042 	struct cmd_read_reg_result *res = parsed_result;
8043 	port_reg_display(res->port_id, res->reg_off);
8044 }
8045 
8046 cmdline_parse_token_string_t cmd_read_reg_read =
8047 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8048 cmdline_parse_token_string_t cmd_read_reg_reg =
8049 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8050 cmdline_parse_token_num_t cmd_read_reg_port_id =
8051 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8052 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8053 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8054 
8055 cmdline_parse_inst_t cmd_read_reg = {
8056 	.f = cmd_read_reg_parsed,
8057 	.data = NULL,
8058 	.help_str = "read reg <port_id> <reg_off>",
8059 	.tokens = {
8060 		(void *)&cmd_read_reg_read,
8061 		(void *)&cmd_read_reg_reg,
8062 		(void *)&cmd_read_reg_port_id,
8063 		(void *)&cmd_read_reg_reg_off,
8064 		NULL,
8065 	},
8066 };
8067 
8068 /* *** READ PORT REGISTER BIT FIELD *** */
8069 struct cmd_read_reg_bit_field_result {
8070 	cmdline_fixed_string_t read;
8071 	cmdline_fixed_string_t regfield;
8072 	portid_t port_id;
8073 	uint32_t reg_off;
8074 	uint8_t bit1_pos;
8075 	uint8_t bit2_pos;
8076 };
8077 
8078 static void
8079 cmd_read_reg_bit_field_parsed(void *parsed_result,
8080 			      __rte_unused struct cmdline *cl,
8081 			      __rte_unused void *data)
8082 {
8083 	struct cmd_read_reg_bit_field_result *res = parsed_result;
8084 	port_reg_bit_field_display(res->port_id, res->reg_off,
8085 				   res->bit1_pos, res->bit2_pos);
8086 }
8087 
8088 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8089 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8090 				 "read");
8091 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8092 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8093 				 regfield, "regfield");
8094 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8095 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8096 			      RTE_UINT16);
8097 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8098 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8099 			      RTE_UINT32);
8100 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8101 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8102 			      RTE_UINT8);
8103 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8104 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8105 			      RTE_UINT8);
8106 
8107 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8108 	.f = cmd_read_reg_bit_field_parsed,
8109 	.data = NULL,
8110 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8111 	"Read register bit field between bit_x and bit_y included",
8112 	.tokens = {
8113 		(void *)&cmd_read_reg_bit_field_read,
8114 		(void *)&cmd_read_reg_bit_field_regfield,
8115 		(void *)&cmd_read_reg_bit_field_port_id,
8116 		(void *)&cmd_read_reg_bit_field_reg_off,
8117 		(void *)&cmd_read_reg_bit_field_bit1_pos,
8118 		(void *)&cmd_read_reg_bit_field_bit2_pos,
8119 		NULL,
8120 	},
8121 };
8122 
8123 /* *** READ PORT REGISTER BIT *** */
8124 struct cmd_read_reg_bit_result {
8125 	cmdline_fixed_string_t read;
8126 	cmdline_fixed_string_t regbit;
8127 	portid_t port_id;
8128 	uint32_t reg_off;
8129 	uint8_t bit_pos;
8130 };
8131 
8132 static void
8133 cmd_read_reg_bit_parsed(void *parsed_result,
8134 			__rte_unused struct cmdline *cl,
8135 			__rte_unused void *data)
8136 {
8137 	struct cmd_read_reg_bit_result *res = parsed_result;
8138 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8139 }
8140 
8141 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8142 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8143 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8144 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8145 				 regbit, "regbit");
8146 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8147 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8148 				 RTE_UINT16);
8149 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8150 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8151 				 RTE_UINT32);
8152 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8153 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8154 				 RTE_UINT8);
8155 
8156 cmdline_parse_inst_t cmd_read_reg_bit = {
8157 	.f = cmd_read_reg_bit_parsed,
8158 	.data = NULL,
8159 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8160 	.tokens = {
8161 		(void *)&cmd_read_reg_bit_read,
8162 		(void *)&cmd_read_reg_bit_regbit,
8163 		(void *)&cmd_read_reg_bit_port_id,
8164 		(void *)&cmd_read_reg_bit_reg_off,
8165 		(void *)&cmd_read_reg_bit_bit_pos,
8166 		NULL,
8167 	},
8168 };
8169 
8170 /* *** WRITE PORT REGISTER *** */
8171 struct cmd_write_reg_result {
8172 	cmdline_fixed_string_t write;
8173 	cmdline_fixed_string_t reg;
8174 	portid_t port_id;
8175 	uint32_t reg_off;
8176 	uint32_t value;
8177 };
8178 
8179 static void
8180 cmd_write_reg_parsed(void *parsed_result,
8181 		     __rte_unused struct cmdline *cl,
8182 		     __rte_unused void *data)
8183 {
8184 	struct cmd_write_reg_result *res = parsed_result;
8185 	port_reg_set(res->port_id, res->reg_off, res->value);
8186 }
8187 
8188 cmdline_parse_token_string_t cmd_write_reg_write =
8189 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8190 cmdline_parse_token_string_t cmd_write_reg_reg =
8191 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8192 cmdline_parse_token_num_t cmd_write_reg_port_id =
8193 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8194 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8195 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8196 cmdline_parse_token_num_t cmd_write_reg_value =
8197 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8198 
8199 cmdline_parse_inst_t cmd_write_reg = {
8200 	.f = cmd_write_reg_parsed,
8201 	.data = NULL,
8202 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8203 	.tokens = {
8204 		(void *)&cmd_write_reg_write,
8205 		(void *)&cmd_write_reg_reg,
8206 		(void *)&cmd_write_reg_port_id,
8207 		(void *)&cmd_write_reg_reg_off,
8208 		(void *)&cmd_write_reg_value,
8209 		NULL,
8210 	},
8211 };
8212 
8213 /* *** WRITE PORT REGISTER BIT FIELD *** */
8214 struct cmd_write_reg_bit_field_result {
8215 	cmdline_fixed_string_t write;
8216 	cmdline_fixed_string_t regfield;
8217 	portid_t port_id;
8218 	uint32_t reg_off;
8219 	uint8_t bit1_pos;
8220 	uint8_t bit2_pos;
8221 	uint32_t value;
8222 };
8223 
8224 static void
8225 cmd_write_reg_bit_field_parsed(void *parsed_result,
8226 			       __rte_unused struct cmdline *cl,
8227 			       __rte_unused void *data)
8228 {
8229 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8230 	port_reg_bit_field_set(res->port_id, res->reg_off,
8231 			  res->bit1_pos, res->bit2_pos, res->value);
8232 }
8233 
8234 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8235 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8236 				 "write");
8237 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8238 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8239 				 regfield, "regfield");
8240 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8241 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8242 			      RTE_UINT16);
8243 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8244 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8245 			      RTE_UINT32);
8246 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8247 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8248 			      RTE_UINT8);
8249 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8250 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8251 			      RTE_UINT8);
8252 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8253 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8254 			      RTE_UINT32);
8255 
8256 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8257 	.f = cmd_write_reg_bit_field_parsed,
8258 	.data = NULL,
8259 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8260 		"<reg_value>: "
8261 		"Set register bit field between bit_x and bit_y included",
8262 	.tokens = {
8263 		(void *)&cmd_write_reg_bit_field_write,
8264 		(void *)&cmd_write_reg_bit_field_regfield,
8265 		(void *)&cmd_write_reg_bit_field_port_id,
8266 		(void *)&cmd_write_reg_bit_field_reg_off,
8267 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8268 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8269 		(void *)&cmd_write_reg_bit_field_value,
8270 		NULL,
8271 	},
8272 };
8273 
8274 /* *** WRITE PORT REGISTER BIT *** */
8275 struct cmd_write_reg_bit_result {
8276 	cmdline_fixed_string_t write;
8277 	cmdline_fixed_string_t regbit;
8278 	portid_t port_id;
8279 	uint32_t reg_off;
8280 	uint8_t bit_pos;
8281 	uint8_t value;
8282 };
8283 
8284 static void
8285 cmd_write_reg_bit_parsed(void *parsed_result,
8286 			 __rte_unused struct cmdline *cl,
8287 			 __rte_unused void *data)
8288 {
8289 	struct cmd_write_reg_bit_result *res = parsed_result;
8290 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8291 }
8292 
8293 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8294 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8295 				 "write");
8296 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8297 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8298 				 regbit, "regbit");
8299 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8300 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8301 				 RTE_UINT16);
8302 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8303 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8304 				 RTE_UINT32);
8305 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8306 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8307 				 RTE_UINT8);
8308 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8309 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8310 				 RTE_UINT8);
8311 
8312 cmdline_parse_inst_t cmd_write_reg_bit = {
8313 	.f = cmd_write_reg_bit_parsed,
8314 	.data = NULL,
8315 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8316 		"0 <= bit_x <= 31",
8317 	.tokens = {
8318 		(void *)&cmd_write_reg_bit_write,
8319 		(void *)&cmd_write_reg_bit_regbit,
8320 		(void *)&cmd_write_reg_bit_port_id,
8321 		(void *)&cmd_write_reg_bit_reg_off,
8322 		(void *)&cmd_write_reg_bit_bit_pos,
8323 		(void *)&cmd_write_reg_bit_value,
8324 		NULL,
8325 	},
8326 };
8327 
8328 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8329 struct cmd_read_rxd_txd_result {
8330 	cmdline_fixed_string_t read;
8331 	cmdline_fixed_string_t rxd_txd;
8332 	portid_t port_id;
8333 	uint16_t queue_id;
8334 	uint16_t desc_id;
8335 };
8336 
8337 static void
8338 cmd_read_rxd_txd_parsed(void *parsed_result,
8339 			__rte_unused struct cmdline *cl,
8340 			__rte_unused void *data)
8341 {
8342 	struct cmd_read_rxd_txd_result *res = parsed_result;
8343 
8344 	if (!strcmp(res->rxd_txd, "rxd"))
8345 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8346 	else if (!strcmp(res->rxd_txd, "txd"))
8347 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8348 }
8349 
8350 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8351 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8352 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8353 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8354 				 "rxd#txd");
8355 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8356 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8357 				 RTE_UINT16);
8358 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8359 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8360 				 RTE_UINT16);
8361 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8362 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8363 				 RTE_UINT16);
8364 
8365 cmdline_parse_inst_t cmd_read_rxd_txd = {
8366 	.f = cmd_read_rxd_txd_parsed,
8367 	.data = NULL,
8368 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8369 	.tokens = {
8370 		(void *)&cmd_read_rxd_txd_read,
8371 		(void *)&cmd_read_rxd_txd_rxd_txd,
8372 		(void *)&cmd_read_rxd_txd_port_id,
8373 		(void *)&cmd_read_rxd_txd_queue_id,
8374 		(void *)&cmd_read_rxd_txd_desc_id,
8375 		NULL,
8376 	},
8377 };
8378 
8379 /* *** QUIT *** */
8380 struct cmd_quit_result {
8381 	cmdline_fixed_string_t quit;
8382 };
8383 
8384 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8385 			    struct cmdline *cl,
8386 			    __rte_unused void *data)
8387 {
8388 	cmdline_quit(cl);
8389 }
8390 
8391 cmdline_parse_token_string_t cmd_quit_quit =
8392 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8393 
8394 cmdline_parse_inst_t cmd_quit = {
8395 	.f = cmd_quit_parsed,
8396 	.data = NULL,
8397 	.help_str = "quit: Exit application",
8398 	.tokens = {
8399 		(void *)&cmd_quit_quit,
8400 		NULL,
8401 	},
8402 };
8403 
8404 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8405 struct cmd_mac_addr_result {
8406 	cmdline_fixed_string_t mac_addr_cmd;
8407 	cmdline_fixed_string_t what;
8408 	uint16_t port_num;
8409 	struct rte_ether_addr address;
8410 };
8411 
8412 static void cmd_mac_addr_parsed(void *parsed_result,
8413 		__rte_unused struct cmdline *cl,
8414 		__rte_unused void *data)
8415 {
8416 	struct cmd_mac_addr_result *res = parsed_result;
8417 	int ret;
8418 
8419 	if (strcmp(res->what, "add") == 0)
8420 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8421 	else if (strcmp(res->what, "set") == 0)
8422 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8423 						       &res->address);
8424 	else
8425 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8426 
8427 	/* check the return value and print it if is < 0 */
8428 	if(ret < 0)
8429 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8430 
8431 }
8432 
8433 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8434 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8435 				"mac_addr");
8436 cmdline_parse_token_string_t cmd_mac_addr_what =
8437 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8438 				"add#remove#set");
8439 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8440 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8441 					RTE_UINT16);
8442 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8443 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8444 
8445 cmdline_parse_inst_t cmd_mac_addr = {
8446 	.f = cmd_mac_addr_parsed,
8447 	.data = (void *)0,
8448 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8449 			"Add/Remove/Set MAC address on port_id",
8450 	.tokens = {
8451 		(void *)&cmd_mac_addr_cmd,
8452 		(void *)&cmd_mac_addr_what,
8453 		(void *)&cmd_mac_addr_portnum,
8454 		(void *)&cmd_mac_addr_addr,
8455 		NULL,
8456 	},
8457 };
8458 
8459 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8460 struct cmd_eth_peer_result {
8461 	cmdline_fixed_string_t set;
8462 	cmdline_fixed_string_t eth_peer;
8463 	portid_t port_id;
8464 	cmdline_fixed_string_t peer_addr;
8465 };
8466 
8467 static void cmd_set_eth_peer_parsed(void *parsed_result,
8468 			__rte_unused struct cmdline *cl,
8469 			__rte_unused void *data)
8470 {
8471 		struct cmd_eth_peer_result *res = parsed_result;
8472 
8473 		if (test_done == 0) {
8474 			printf("Please stop forwarding first\n");
8475 			return;
8476 		}
8477 		if (!strcmp(res->eth_peer, "eth-peer")) {
8478 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8479 			fwd_config_setup();
8480 		}
8481 }
8482 cmdline_parse_token_string_t cmd_eth_peer_set =
8483 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8484 cmdline_parse_token_string_t cmd_eth_peer =
8485 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8486 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8487 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8488 		RTE_UINT16);
8489 cmdline_parse_token_string_t cmd_eth_peer_addr =
8490 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8491 
8492 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8493 	.f = cmd_set_eth_peer_parsed,
8494 	.data = NULL,
8495 	.help_str = "set eth-peer <port_id> <peer_mac>",
8496 	.tokens = {
8497 		(void *)&cmd_eth_peer_set,
8498 		(void *)&cmd_eth_peer,
8499 		(void *)&cmd_eth_peer_port_id,
8500 		(void *)&cmd_eth_peer_addr,
8501 		NULL,
8502 	},
8503 };
8504 
8505 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8506 struct cmd_set_qmap_result {
8507 	cmdline_fixed_string_t set;
8508 	cmdline_fixed_string_t qmap;
8509 	cmdline_fixed_string_t what;
8510 	portid_t port_id;
8511 	uint16_t queue_id;
8512 	uint8_t map_value;
8513 };
8514 
8515 static void
8516 cmd_set_qmap_parsed(void *parsed_result,
8517 		       __rte_unused struct cmdline *cl,
8518 		       __rte_unused void *data)
8519 {
8520 	struct cmd_set_qmap_result *res = parsed_result;
8521 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8522 
8523 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8524 }
8525 
8526 cmdline_parse_token_string_t cmd_setqmap_set =
8527 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8528 				 set, "set");
8529 cmdline_parse_token_string_t cmd_setqmap_qmap =
8530 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8531 				 qmap, "stat_qmap");
8532 cmdline_parse_token_string_t cmd_setqmap_what =
8533 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8534 				 what, "tx#rx");
8535 cmdline_parse_token_num_t cmd_setqmap_portid =
8536 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8537 			      port_id, RTE_UINT16);
8538 cmdline_parse_token_num_t cmd_setqmap_queueid =
8539 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8540 			      queue_id, RTE_UINT16);
8541 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8542 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8543 			      map_value, RTE_UINT8);
8544 
8545 cmdline_parse_inst_t cmd_set_qmap = {
8546 	.f = cmd_set_qmap_parsed,
8547 	.data = NULL,
8548 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8549 		"Set statistics mapping value on tx|rx queue_id of port_id",
8550 	.tokens = {
8551 		(void *)&cmd_setqmap_set,
8552 		(void *)&cmd_setqmap_qmap,
8553 		(void *)&cmd_setqmap_what,
8554 		(void *)&cmd_setqmap_portid,
8555 		(void *)&cmd_setqmap_queueid,
8556 		(void *)&cmd_setqmap_mapvalue,
8557 		NULL,
8558 	},
8559 };
8560 
8561 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8562 struct cmd_set_xstats_hide_zero_result {
8563 	cmdline_fixed_string_t keyword;
8564 	cmdline_fixed_string_t name;
8565 	cmdline_fixed_string_t on_off;
8566 };
8567 
8568 static void
8569 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8570 			__rte_unused struct cmdline *cl,
8571 			__rte_unused void *data)
8572 {
8573 	struct cmd_set_xstats_hide_zero_result *res;
8574 	uint16_t on_off = 0;
8575 
8576 	res = parsed_result;
8577 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8578 	set_xstats_hide_zero(on_off);
8579 }
8580 
8581 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8582 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8583 				 keyword, "set");
8584 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8585 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8586 				 name, "xstats-hide-zero");
8587 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8588 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8589 				 on_off, "on#off");
8590 
8591 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8592 	.f = cmd_set_xstats_hide_zero_parsed,
8593 	.data = NULL,
8594 	.help_str = "set xstats-hide-zero on|off",
8595 	.tokens = {
8596 		(void *)&cmd_set_xstats_hide_zero_keyword,
8597 		(void *)&cmd_set_xstats_hide_zero_name,
8598 		(void *)&cmd_set_xstats_hide_zero_on_off,
8599 		NULL,
8600 	},
8601 };
8602 
8603 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8604 struct cmd_set_record_core_cycles_result {
8605 	cmdline_fixed_string_t keyword;
8606 	cmdline_fixed_string_t name;
8607 	cmdline_fixed_string_t on_off;
8608 };
8609 
8610 static void
8611 cmd_set_record_core_cycles_parsed(void *parsed_result,
8612 			__rte_unused struct cmdline *cl,
8613 			__rte_unused void *data)
8614 {
8615 	struct cmd_set_record_core_cycles_result *res;
8616 	uint16_t on_off = 0;
8617 
8618 	res = parsed_result;
8619 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8620 	set_record_core_cycles(on_off);
8621 }
8622 
8623 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8624 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8625 				 keyword, "set");
8626 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8627 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8628 				 name, "record-core-cycles");
8629 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8630 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8631 				 on_off, "on#off");
8632 
8633 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8634 	.f = cmd_set_record_core_cycles_parsed,
8635 	.data = NULL,
8636 	.help_str = "set record-core-cycles on|off",
8637 	.tokens = {
8638 		(void *)&cmd_set_record_core_cycles_keyword,
8639 		(void *)&cmd_set_record_core_cycles_name,
8640 		(void *)&cmd_set_record_core_cycles_on_off,
8641 		NULL,
8642 	},
8643 };
8644 
8645 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8646 struct cmd_set_record_burst_stats_result {
8647 	cmdline_fixed_string_t keyword;
8648 	cmdline_fixed_string_t name;
8649 	cmdline_fixed_string_t on_off;
8650 };
8651 
8652 static void
8653 cmd_set_record_burst_stats_parsed(void *parsed_result,
8654 			__rte_unused struct cmdline *cl,
8655 			__rte_unused void *data)
8656 {
8657 	struct cmd_set_record_burst_stats_result *res;
8658 	uint16_t on_off = 0;
8659 
8660 	res = parsed_result;
8661 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8662 	set_record_burst_stats(on_off);
8663 }
8664 
8665 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8666 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8667 				 keyword, "set");
8668 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8669 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8670 				 name, "record-burst-stats");
8671 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8672 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8673 				 on_off, "on#off");
8674 
8675 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8676 	.f = cmd_set_record_burst_stats_parsed,
8677 	.data = NULL,
8678 	.help_str = "set record-burst-stats on|off",
8679 	.tokens = {
8680 		(void *)&cmd_set_record_burst_stats_keyword,
8681 		(void *)&cmd_set_record_burst_stats_name,
8682 		(void *)&cmd_set_record_burst_stats_on_off,
8683 		NULL,
8684 	},
8685 };
8686 
8687 /* *** CONFIGURE UNICAST HASH TABLE *** */
8688 struct cmd_set_uc_hash_table {
8689 	cmdline_fixed_string_t set;
8690 	cmdline_fixed_string_t port;
8691 	portid_t port_id;
8692 	cmdline_fixed_string_t what;
8693 	struct rte_ether_addr address;
8694 	cmdline_fixed_string_t mode;
8695 };
8696 
8697 static void
8698 cmd_set_uc_hash_parsed(void *parsed_result,
8699 		       __rte_unused struct cmdline *cl,
8700 		       __rte_unused void *data)
8701 {
8702 	int ret=0;
8703 	struct cmd_set_uc_hash_table *res = parsed_result;
8704 
8705 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8706 
8707 	if (strcmp(res->what, "uta") == 0)
8708 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8709 						&res->address,(uint8_t)is_on);
8710 	if (ret < 0)
8711 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8712 
8713 }
8714 
8715 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8716 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8717 				 set, "set");
8718 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8719 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8720 				 port, "port");
8721 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8722 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8723 			      port_id, RTE_UINT16);
8724 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8725 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8726 				 what, "uta");
8727 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8728 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8729 				address);
8730 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8731 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8732 				 mode, "on#off");
8733 
8734 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8735 	.f = cmd_set_uc_hash_parsed,
8736 	.data = NULL,
8737 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8738 	.tokens = {
8739 		(void *)&cmd_set_uc_hash_set,
8740 		(void *)&cmd_set_uc_hash_port,
8741 		(void *)&cmd_set_uc_hash_portid,
8742 		(void *)&cmd_set_uc_hash_what,
8743 		(void *)&cmd_set_uc_hash_mac,
8744 		(void *)&cmd_set_uc_hash_mode,
8745 		NULL,
8746 	},
8747 };
8748 
8749 struct cmd_set_uc_all_hash_table {
8750 	cmdline_fixed_string_t set;
8751 	cmdline_fixed_string_t port;
8752 	portid_t port_id;
8753 	cmdline_fixed_string_t what;
8754 	cmdline_fixed_string_t value;
8755 	cmdline_fixed_string_t mode;
8756 };
8757 
8758 static void
8759 cmd_set_uc_all_hash_parsed(void *parsed_result,
8760 		       __rte_unused struct cmdline *cl,
8761 		       __rte_unused void *data)
8762 {
8763 	int ret=0;
8764 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8765 
8766 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8767 
8768 	if ((strcmp(res->what, "uta") == 0) &&
8769 		(strcmp(res->value, "all") == 0))
8770 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8771 	if (ret < 0)
8772 		printf("bad unicast hash table parameter,"
8773 			"return code = %d \n", ret);
8774 }
8775 
8776 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8777 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8778 				 set, "set");
8779 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8780 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8781 				 port, "port");
8782 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8783 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8784 			      port_id, RTE_UINT16);
8785 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8786 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8787 				 what, "uta");
8788 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8789 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8790 				value,"all");
8791 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8792 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8793 				 mode, "on#off");
8794 
8795 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8796 	.f = cmd_set_uc_all_hash_parsed,
8797 	.data = NULL,
8798 	.help_str = "set port <port_id> uta all on|off",
8799 	.tokens = {
8800 		(void *)&cmd_set_uc_all_hash_set,
8801 		(void *)&cmd_set_uc_all_hash_port,
8802 		(void *)&cmd_set_uc_all_hash_portid,
8803 		(void *)&cmd_set_uc_all_hash_what,
8804 		(void *)&cmd_set_uc_all_hash_value,
8805 		(void *)&cmd_set_uc_all_hash_mode,
8806 		NULL,
8807 	},
8808 };
8809 
8810 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8811 struct cmd_set_vf_traffic {
8812 	cmdline_fixed_string_t set;
8813 	cmdline_fixed_string_t port;
8814 	portid_t port_id;
8815 	cmdline_fixed_string_t vf;
8816 	uint8_t vf_id;
8817 	cmdline_fixed_string_t what;
8818 	cmdline_fixed_string_t mode;
8819 };
8820 
8821 static void
8822 cmd_set_vf_traffic_parsed(void *parsed_result,
8823 		       __rte_unused struct cmdline *cl,
8824 		       __rte_unused void *data)
8825 {
8826 	struct cmd_set_vf_traffic *res = parsed_result;
8827 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8828 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8829 
8830 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8831 }
8832 
8833 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8834 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8835 				 set, "set");
8836 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8837 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8838 				 port, "port");
8839 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8840 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8841 			      port_id, RTE_UINT16);
8842 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8843 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8844 				 vf, "vf");
8845 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8846 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8847 			      vf_id, RTE_UINT8);
8848 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8849 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8850 				 what, "tx#rx");
8851 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8852 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8853 				 mode, "on#off");
8854 
8855 cmdline_parse_inst_t cmd_set_vf_traffic = {
8856 	.f = cmd_set_vf_traffic_parsed,
8857 	.data = NULL,
8858 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8859 	.tokens = {
8860 		(void *)&cmd_setvf_traffic_set,
8861 		(void *)&cmd_setvf_traffic_port,
8862 		(void *)&cmd_setvf_traffic_portid,
8863 		(void *)&cmd_setvf_traffic_vf,
8864 		(void *)&cmd_setvf_traffic_vfid,
8865 		(void *)&cmd_setvf_traffic_what,
8866 		(void *)&cmd_setvf_traffic_mode,
8867 		NULL,
8868 	},
8869 };
8870 
8871 /* *** CONFIGURE VF RECEIVE MODE *** */
8872 struct cmd_set_vf_rxmode {
8873 	cmdline_fixed_string_t set;
8874 	cmdline_fixed_string_t port;
8875 	portid_t port_id;
8876 	cmdline_fixed_string_t vf;
8877 	uint8_t vf_id;
8878 	cmdline_fixed_string_t what;
8879 	cmdline_fixed_string_t mode;
8880 	cmdline_fixed_string_t on;
8881 };
8882 
8883 static void
8884 cmd_set_vf_rxmode_parsed(void *parsed_result,
8885 		       __rte_unused struct cmdline *cl,
8886 		       __rte_unused void *data)
8887 {
8888 	int ret = -ENOTSUP;
8889 	uint16_t vf_rxmode = 0;
8890 	struct cmd_set_vf_rxmode *res = parsed_result;
8891 
8892 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8893 	if (!strcmp(res->what,"rxmode")) {
8894 		if (!strcmp(res->mode, "AUPE"))
8895 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8896 		else if (!strcmp(res->mode, "ROPE"))
8897 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8898 		else if (!strcmp(res->mode, "BAM"))
8899 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8900 		else if (!strncmp(res->mode, "MPE",3))
8901 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8902 	}
8903 
8904 	RTE_SET_USED(is_on);
8905 
8906 #ifdef RTE_NET_IXGBE
8907 	if (ret == -ENOTSUP)
8908 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8909 						  vf_rxmode, (uint8_t)is_on);
8910 #endif
8911 #ifdef RTE_NET_BNXT
8912 	if (ret == -ENOTSUP)
8913 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8914 						 vf_rxmode, (uint8_t)is_on);
8915 #endif
8916 	if (ret < 0)
8917 		printf("bad VF receive mode parameter, return code = %d \n",
8918 		ret);
8919 }
8920 
8921 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8922 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8923 				 set, "set");
8924 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8925 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8926 				 port, "port");
8927 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8928 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8929 			      port_id, RTE_UINT16);
8930 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8931 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8932 				 vf, "vf");
8933 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8934 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8935 			      vf_id, RTE_UINT8);
8936 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8937 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8938 				 what, "rxmode");
8939 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8940 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8941 				 mode, "AUPE#ROPE#BAM#MPE");
8942 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8943 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8944 				 on, "on#off");
8945 
8946 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8947 	.f = cmd_set_vf_rxmode_parsed,
8948 	.data = NULL,
8949 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8950 		"AUPE|ROPE|BAM|MPE on|off",
8951 	.tokens = {
8952 		(void *)&cmd_set_vf_rxmode_set,
8953 		(void *)&cmd_set_vf_rxmode_port,
8954 		(void *)&cmd_set_vf_rxmode_portid,
8955 		(void *)&cmd_set_vf_rxmode_vf,
8956 		(void *)&cmd_set_vf_rxmode_vfid,
8957 		(void *)&cmd_set_vf_rxmode_what,
8958 		(void *)&cmd_set_vf_rxmode_mode,
8959 		(void *)&cmd_set_vf_rxmode_on,
8960 		NULL,
8961 	},
8962 };
8963 
8964 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8965 struct cmd_vf_mac_addr_result {
8966 	cmdline_fixed_string_t mac_addr_cmd;
8967 	cmdline_fixed_string_t what;
8968 	cmdline_fixed_string_t port;
8969 	uint16_t port_num;
8970 	cmdline_fixed_string_t vf;
8971 	uint8_t vf_num;
8972 	struct rte_ether_addr address;
8973 };
8974 
8975 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8976 		__rte_unused struct cmdline *cl,
8977 		__rte_unused void *data)
8978 {
8979 	struct cmd_vf_mac_addr_result *res = parsed_result;
8980 	int ret = -ENOTSUP;
8981 
8982 	if (strcmp(res->what, "add") != 0)
8983 		return;
8984 
8985 #ifdef RTE_NET_I40E
8986 	if (ret == -ENOTSUP)
8987 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8988 						   &res->address);
8989 #endif
8990 #ifdef RTE_NET_BNXT
8991 	if (ret == -ENOTSUP)
8992 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8993 						res->vf_num);
8994 #endif
8995 
8996 	if(ret < 0)
8997 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8998 
8999 }
9000 
9001 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9002 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9003 				mac_addr_cmd,"mac_addr");
9004 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9005 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9006 				what,"add");
9007 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9008 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9009 				port,"port");
9010 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9011 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9012 				port_num, RTE_UINT16);
9013 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9014 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9015 				vf,"vf");
9016 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9017 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9018 				vf_num, RTE_UINT8);
9019 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9020 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9021 				address);
9022 
9023 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9024 	.f = cmd_vf_mac_addr_parsed,
9025 	.data = (void *)0,
9026 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9027 		"Add MAC address filtering for a VF on port_id",
9028 	.tokens = {
9029 		(void *)&cmd_vf_mac_addr_cmd,
9030 		(void *)&cmd_vf_mac_addr_what,
9031 		(void *)&cmd_vf_mac_addr_port,
9032 		(void *)&cmd_vf_mac_addr_portnum,
9033 		(void *)&cmd_vf_mac_addr_vf,
9034 		(void *)&cmd_vf_mac_addr_vfnum,
9035 		(void *)&cmd_vf_mac_addr_addr,
9036 		NULL,
9037 	},
9038 };
9039 
9040 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9041 struct cmd_vf_rx_vlan_filter {
9042 	cmdline_fixed_string_t rx_vlan;
9043 	cmdline_fixed_string_t what;
9044 	uint16_t vlan_id;
9045 	cmdline_fixed_string_t port;
9046 	portid_t port_id;
9047 	cmdline_fixed_string_t vf;
9048 	uint64_t vf_mask;
9049 };
9050 
9051 static void
9052 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9053 			  __rte_unused struct cmdline *cl,
9054 			  __rte_unused void *data)
9055 {
9056 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
9057 	int ret = -ENOTSUP;
9058 
9059 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9060 
9061 #ifdef RTE_NET_IXGBE
9062 	if (ret == -ENOTSUP)
9063 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9064 				res->vlan_id, res->vf_mask, is_add);
9065 #endif
9066 #ifdef RTE_NET_I40E
9067 	if (ret == -ENOTSUP)
9068 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9069 				res->vlan_id, res->vf_mask, is_add);
9070 #endif
9071 #ifdef RTE_NET_BNXT
9072 	if (ret == -ENOTSUP)
9073 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9074 				res->vlan_id, res->vf_mask, is_add);
9075 #endif
9076 
9077 	switch (ret) {
9078 	case 0:
9079 		break;
9080 	case -EINVAL:
9081 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9082 				res->vlan_id, res->vf_mask);
9083 		break;
9084 	case -ENODEV:
9085 		printf("invalid port_id %d\n", res->port_id);
9086 		break;
9087 	case -ENOTSUP:
9088 		printf("function not implemented or supported\n");
9089 		break;
9090 	default:
9091 		printf("programming error: (%s)\n", strerror(-ret));
9092 	}
9093 }
9094 
9095 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9096 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9097 				 rx_vlan, "rx_vlan");
9098 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9099 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9100 				 what, "add#rm");
9101 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9102 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9103 			      vlan_id, RTE_UINT16);
9104 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9105 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9106 				 port, "port");
9107 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9108 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9109 			      port_id, RTE_UINT16);
9110 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9111 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9112 				 vf, "vf");
9113 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9114 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9115 			      vf_mask, RTE_UINT64);
9116 
9117 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9118 	.f = cmd_vf_rx_vlan_filter_parsed,
9119 	.data = NULL,
9120 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9121 		"(vf_mask = hexadecimal VF mask)",
9122 	.tokens = {
9123 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9124 		(void *)&cmd_vf_rx_vlan_filter_what,
9125 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
9126 		(void *)&cmd_vf_rx_vlan_filter_port,
9127 		(void *)&cmd_vf_rx_vlan_filter_portid,
9128 		(void *)&cmd_vf_rx_vlan_filter_vf,
9129 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
9130 		NULL,
9131 	},
9132 };
9133 
9134 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9135 struct cmd_queue_rate_limit_result {
9136 	cmdline_fixed_string_t set;
9137 	cmdline_fixed_string_t port;
9138 	uint16_t port_num;
9139 	cmdline_fixed_string_t queue;
9140 	uint8_t queue_num;
9141 	cmdline_fixed_string_t rate;
9142 	uint16_t rate_num;
9143 };
9144 
9145 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9146 		__rte_unused struct cmdline *cl,
9147 		__rte_unused void *data)
9148 {
9149 	struct cmd_queue_rate_limit_result *res = parsed_result;
9150 	int ret = 0;
9151 
9152 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9153 		&& (strcmp(res->queue, "queue") == 0)
9154 		&& (strcmp(res->rate, "rate") == 0))
9155 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
9156 					res->rate_num);
9157 	if (ret < 0)
9158 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9159 
9160 }
9161 
9162 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9163 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9164 				set, "set");
9165 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9166 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9167 				port, "port");
9168 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9169 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9170 				port_num, RTE_UINT16);
9171 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9172 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9173 				queue, "queue");
9174 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9175 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9176 				queue_num, RTE_UINT8);
9177 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9178 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9179 				rate, "rate");
9180 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9181 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9182 				rate_num, RTE_UINT16);
9183 
9184 cmdline_parse_inst_t cmd_queue_rate_limit = {
9185 	.f = cmd_queue_rate_limit_parsed,
9186 	.data = (void *)0,
9187 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9188 		"Set rate limit for a queue on port_id",
9189 	.tokens = {
9190 		(void *)&cmd_queue_rate_limit_set,
9191 		(void *)&cmd_queue_rate_limit_port,
9192 		(void *)&cmd_queue_rate_limit_portnum,
9193 		(void *)&cmd_queue_rate_limit_queue,
9194 		(void *)&cmd_queue_rate_limit_queuenum,
9195 		(void *)&cmd_queue_rate_limit_rate,
9196 		(void *)&cmd_queue_rate_limit_ratenum,
9197 		NULL,
9198 	},
9199 };
9200 
9201 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9202 struct cmd_vf_rate_limit_result {
9203 	cmdline_fixed_string_t set;
9204 	cmdline_fixed_string_t port;
9205 	uint16_t port_num;
9206 	cmdline_fixed_string_t vf;
9207 	uint8_t vf_num;
9208 	cmdline_fixed_string_t rate;
9209 	uint16_t rate_num;
9210 	cmdline_fixed_string_t q_msk;
9211 	uint64_t q_msk_val;
9212 };
9213 
9214 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9215 		__rte_unused struct cmdline *cl,
9216 		__rte_unused void *data)
9217 {
9218 	struct cmd_vf_rate_limit_result *res = parsed_result;
9219 	int ret = 0;
9220 
9221 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9222 		&& (strcmp(res->vf, "vf") == 0)
9223 		&& (strcmp(res->rate, "rate") == 0)
9224 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9225 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9226 					res->rate_num, res->q_msk_val);
9227 	if (ret < 0)
9228 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9229 
9230 }
9231 
9232 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9233 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9234 				set, "set");
9235 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9236 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9237 				port, "port");
9238 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9239 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9240 				port_num, RTE_UINT16);
9241 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9242 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9243 				vf, "vf");
9244 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9245 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9246 				vf_num, RTE_UINT8);
9247 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9248 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9249 				rate, "rate");
9250 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9251 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9252 				rate_num, RTE_UINT16);
9253 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9254 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9255 				q_msk, "queue_mask");
9256 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9257 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9258 				q_msk_val, RTE_UINT64);
9259 
9260 cmdline_parse_inst_t cmd_vf_rate_limit = {
9261 	.f = cmd_vf_rate_limit_parsed,
9262 	.data = (void *)0,
9263 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9264 		"queue_mask <queue_mask_value>: "
9265 		"Set rate limit for queues of VF on port_id",
9266 	.tokens = {
9267 		(void *)&cmd_vf_rate_limit_set,
9268 		(void *)&cmd_vf_rate_limit_port,
9269 		(void *)&cmd_vf_rate_limit_portnum,
9270 		(void *)&cmd_vf_rate_limit_vf,
9271 		(void *)&cmd_vf_rate_limit_vfnum,
9272 		(void *)&cmd_vf_rate_limit_rate,
9273 		(void *)&cmd_vf_rate_limit_ratenum,
9274 		(void *)&cmd_vf_rate_limit_q_msk,
9275 		(void *)&cmd_vf_rate_limit_q_msk_val,
9276 		NULL,
9277 	},
9278 };
9279 
9280 /* *** CONFIGURE TUNNEL UDP PORT *** */
9281 struct cmd_tunnel_udp_config {
9282 	cmdline_fixed_string_t rx_vxlan_port;
9283 	cmdline_fixed_string_t what;
9284 	uint16_t udp_port;
9285 	portid_t port_id;
9286 };
9287 
9288 static void
9289 cmd_tunnel_udp_config_parsed(void *parsed_result,
9290 			  __rte_unused struct cmdline *cl,
9291 			  __rte_unused void *data)
9292 {
9293 	struct cmd_tunnel_udp_config *res = parsed_result;
9294 	struct rte_eth_udp_tunnel tunnel_udp;
9295 	int ret;
9296 
9297 	tunnel_udp.udp_port = res->udp_port;
9298 	tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9299 
9300 	if (!strcmp(res->what, "add"))
9301 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9302 						      &tunnel_udp);
9303 	else
9304 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9305 							 &tunnel_udp);
9306 
9307 	if (ret < 0)
9308 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9309 }
9310 
9311 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9312 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9313 				rx_vxlan_port, "rx_vxlan_port");
9314 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9315 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9316 				what, "add#rm");
9317 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9318 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9319 				udp_port, RTE_UINT16);
9320 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9321 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9322 				port_id, RTE_UINT16);
9323 
9324 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9325 	.f = cmd_tunnel_udp_config_parsed,
9326 	.data = (void *)0,
9327 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9328 		"Add/Remove a tunneling UDP port filter",
9329 	.tokens = {
9330 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9331 		(void *)&cmd_tunnel_udp_config_what,
9332 		(void *)&cmd_tunnel_udp_config_udp_port,
9333 		(void *)&cmd_tunnel_udp_config_port_id,
9334 		NULL,
9335 	},
9336 };
9337 
9338 struct cmd_config_tunnel_udp_port {
9339 	cmdline_fixed_string_t port;
9340 	cmdline_fixed_string_t config;
9341 	portid_t port_id;
9342 	cmdline_fixed_string_t udp_tunnel_port;
9343 	cmdline_fixed_string_t action;
9344 	cmdline_fixed_string_t tunnel_type;
9345 	uint16_t udp_port;
9346 };
9347 
9348 static void
9349 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9350 			       __rte_unused struct cmdline *cl,
9351 			       __rte_unused void *data)
9352 {
9353 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9354 	struct rte_eth_udp_tunnel tunnel_udp;
9355 	int ret = 0;
9356 
9357 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9358 		return;
9359 
9360 	tunnel_udp.udp_port = res->udp_port;
9361 
9362 	if (!strcmp(res->tunnel_type, "vxlan")) {
9363 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9364 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9365 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9366 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9367 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9368 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9369 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9370 	} else {
9371 		printf("Invalid tunnel type\n");
9372 		return;
9373 	}
9374 
9375 	if (!strcmp(res->action, "add"))
9376 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9377 						      &tunnel_udp);
9378 	else
9379 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9380 							 &tunnel_udp);
9381 
9382 	if (ret < 0)
9383 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9384 }
9385 
9386 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9387 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9388 				 "port");
9389 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9390 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9391 				 "config");
9392 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9393 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9394 			      RTE_UINT16);
9395 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9396 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9397 				 udp_tunnel_port,
9398 				 "udp_tunnel_port");
9399 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9400 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9401 				 "add#rm");
9402 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9403 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9404 				 "vxlan#geneve#vxlan-gpe#ecpri");
9405 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9406 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9407 			      RTE_UINT16);
9408 
9409 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9410 	.f = cmd_cfg_tunnel_udp_port_parsed,
9411 	.data = NULL,
9412 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9413 		"geneve|vxlan-gpe|ecpri <udp_port>",
9414 	.tokens = {
9415 		(void *)&cmd_config_tunnel_udp_port_port,
9416 		(void *)&cmd_config_tunnel_udp_port_config,
9417 		(void *)&cmd_config_tunnel_udp_port_port_id,
9418 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9419 		(void *)&cmd_config_tunnel_udp_port_action,
9420 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9421 		(void *)&cmd_config_tunnel_udp_port_value,
9422 		NULL,
9423 	},
9424 };
9425 
9426 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9427 struct cmd_set_mirror_mask_result {
9428 	cmdline_fixed_string_t set;
9429 	cmdline_fixed_string_t port;
9430 	portid_t port_id;
9431 	cmdline_fixed_string_t mirror;
9432 	uint8_t rule_id;
9433 	cmdline_fixed_string_t what;
9434 	cmdline_fixed_string_t value;
9435 	cmdline_fixed_string_t dstpool;
9436 	uint8_t dstpool_id;
9437 	cmdline_fixed_string_t on;
9438 };
9439 
9440 cmdline_parse_token_string_t cmd_mirror_mask_set =
9441 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9442 				set, "set");
9443 cmdline_parse_token_string_t cmd_mirror_mask_port =
9444 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9445 				port, "port");
9446 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9447 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9448 				port_id, RTE_UINT16);
9449 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9450 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9451 				mirror, "mirror-rule");
9452 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9453 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9454 				rule_id, RTE_UINT8);
9455 cmdline_parse_token_string_t cmd_mirror_mask_what =
9456 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9457 				what, "pool-mirror-up#pool-mirror-down"
9458 				      "#vlan-mirror");
9459 cmdline_parse_token_string_t cmd_mirror_mask_value =
9460 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9461 				value, NULL);
9462 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9463 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9464 				dstpool, "dst-pool");
9465 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9466 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9467 				dstpool_id, RTE_UINT8);
9468 cmdline_parse_token_string_t cmd_mirror_mask_on =
9469 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9470 				on, "on#off");
9471 
9472 static void
9473 cmd_set_mirror_mask_parsed(void *parsed_result,
9474 		       __rte_unused struct cmdline *cl,
9475 		       __rte_unused void *data)
9476 {
9477 	int ret,nb_item,i;
9478 	struct cmd_set_mirror_mask_result *res = parsed_result;
9479 	struct rte_eth_mirror_conf mr_conf;
9480 
9481 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9482 
9483 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9484 
9485 	mr_conf.dst_pool = res->dstpool_id;
9486 
9487 	if (!strcmp(res->what, "pool-mirror-up")) {
9488 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9489 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9490 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9491 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9492 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9493 	} else if (!strcmp(res->what, "vlan-mirror")) {
9494 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9495 		nb_item = parse_item_list(res->value, "vlan",
9496 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9497 		if (nb_item <= 0)
9498 			return;
9499 
9500 		for (i = 0; i < nb_item; i++) {
9501 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9502 				printf("Invalid vlan_id: must be < 4096\n");
9503 				return;
9504 			}
9505 
9506 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9507 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9508 		}
9509 	}
9510 
9511 	if (!strcmp(res->on, "on"))
9512 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9513 						res->rule_id, 1);
9514 	else
9515 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9516 						res->rule_id, 0);
9517 	if (ret < 0)
9518 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9519 }
9520 
9521 cmdline_parse_inst_t cmd_set_mirror_mask = {
9522 		.f = cmd_set_mirror_mask_parsed,
9523 		.data = NULL,
9524 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9525 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9526 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9527 		.tokens = {
9528 			(void *)&cmd_mirror_mask_set,
9529 			(void *)&cmd_mirror_mask_port,
9530 			(void *)&cmd_mirror_mask_portid,
9531 			(void *)&cmd_mirror_mask_mirror,
9532 			(void *)&cmd_mirror_mask_ruleid,
9533 			(void *)&cmd_mirror_mask_what,
9534 			(void *)&cmd_mirror_mask_value,
9535 			(void *)&cmd_mirror_mask_dstpool,
9536 			(void *)&cmd_mirror_mask_poolid,
9537 			(void *)&cmd_mirror_mask_on,
9538 			NULL,
9539 		},
9540 };
9541 
9542 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9543 struct cmd_set_mirror_link_result {
9544 	cmdline_fixed_string_t set;
9545 	cmdline_fixed_string_t port;
9546 	portid_t port_id;
9547 	cmdline_fixed_string_t mirror;
9548 	uint8_t rule_id;
9549 	cmdline_fixed_string_t what;
9550 	cmdline_fixed_string_t dstpool;
9551 	uint8_t dstpool_id;
9552 	cmdline_fixed_string_t on;
9553 };
9554 
9555 cmdline_parse_token_string_t cmd_mirror_link_set =
9556 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9557 				 set, "set");
9558 cmdline_parse_token_string_t cmd_mirror_link_port =
9559 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9560 				port, "port");
9561 cmdline_parse_token_num_t cmd_mirror_link_portid =
9562 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9563 				port_id, RTE_UINT16);
9564 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9565 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9566 				mirror, "mirror-rule");
9567 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9568 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9569 			    rule_id, RTE_UINT8);
9570 cmdline_parse_token_string_t cmd_mirror_link_what =
9571 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9572 				what, "uplink-mirror#downlink-mirror");
9573 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9574 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9575 				dstpool, "dst-pool");
9576 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9577 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9578 				dstpool_id, RTE_UINT8);
9579 cmdline_parse_token_string_t cmd_mirror_link_on =
9580 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9581 				on, "on#off");
9582 
9583 static void
9584 cmd_set_mirror_link_parsed(void *parsed_result,
9585 		       __rte_unused struct cmdline *cl,
9586 		       __rte_unused void *data)
9587 {
9588 	int ret;
9589 	struct cmd_set_mirror_link_result *res = parsed_result;
9590 	struct rte_eth_mirror_conf mr_conf;
9591 
9592 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9593 	if (!strcmp(res->what, "uplink-mirror"))
9594 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9595 	else
9596 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9597 
9598 	mr_conf.dst_pool = res->dstpool_id;
9599 
9600 	if (!strcmp(res->on, "on"))
9601 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9602 						res->rule_id, 1);
9603 	else
9604 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9605 						res->rule_id, 0);
9606 
9607 	/* check the return value and print it if is < 0 */
9608 	if (ret < 0)
9609 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9610 
9611 }
9612 
9613 cmdline_parse_inst_t cmd_set_mirror_link = {
9614 		.f = cmd_set_mirror_link_parsed,
9615 		.data = NULL,
9616 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9617 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9618 		.tokens = {
9619 			(void *)&cmd_mirror_link_set,
9620 			(void *)&cmd_mirror_link_port,
9621 			(void *)&cmd_mirror_link_portid,
9622 			(void *)&cmd_mirror_link_mirror,
9623 			(void *)&cmd_mirror_link_ruleid,
9624 			(void *)&cmd_mirror_link_what,
9625 			(void *)&cmd_mirror_link_dstpool,
9626 			(void *)&cmd_mirror_link_poolid,
9627 			(void *)&cmd_mirror_link_on,
9628 			NULL,
9629 		},
9630 };
9631 
9632 /* *** RESET VM MIRROR RULE *** */
9633 struct cmd_rm_mirror_rule_result {
9634 	cmdline_fixed_string_t reset;
9635 	cmdline_fixed_string_t port;
9636 	portid_t port_id;
9637 	cmdline_fixed_string_t mirror;
9638 	uint8_t rule_id;
9639 };
9640 
9641 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9642 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9643 				 reset, "reset");
9644 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9645 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9646 				port, "port");
9647 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9648 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9649 				port_id, RTE_UINT16);
9650 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9651 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9652 				mirror, "mirror-rule");
9653 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9654 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9655 				rule_id, RTE_UINT8);
9656 
9657 static void
9658 cmd_reset_mirror_rule_parsed(void *parsed_result,
9659 		       __rte_unused struct cmdline *cl,
9660 		       __rte_unused void *data)
9661 {
9662 	int ret;
9663 	struct cmd_set_mirror_link_result *res = parsed_result;
9664         /* check rule_id */
9665 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9666 	if(ret < 0)
9667 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9668 }
9669 
9670 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9671 		.f = cmd_reset_mirror_rule_parsed,
9672 		.data = NULL,
9673 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9674 		.tokens = {
9675 			(void *)&cmd_rm_mirror_rule_reset,
9676 			(void *)&cmd_rm_mirror_rule_port,
9677 			(void *)&cmd_rm_mirror_rule_portid,
9678 			(void *)&cmd_rm_mirror_rule_mirror,
9679 			(void *)&cmd_rm_mirror_rule_ruleid,
9680 			NULL,
9681 		},
9682 };
9683 
9684 /* ******************************************************************************** */
9685 
9686 struct cmd_dump_result {
9687 	cmdline_fixed_string_t dump;
9688 };
9689 
9690 static void
9691 dump_struct_sizes(void)
9692 {
9693 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9694 	DUMP_SIZE(struct rte_mbuf);
9695 	DUMP_SIZE(struct rte_mempool);
9696 	DUMP_SIZE(struct rte_ring);
9697 #undef DUMP_SIZE
9698 }
9699 
9700 
9701 /* Dump the socket memory statistics on console */
9702 static void
9703 dump_socket_mem(FILE *f)
9704 {
9705 	struct rte_malloc_socket_stats socket_stats;
9706 	unsigned int i;
9707 	size_t total = 0;
9708 	size_t alloc = 0;
9709 	size_t free = 0;
9710 	unsigned int n_alloc = 0;
9711 	unsigned int n_free = 0;
9712 	static size_t last_allocs;
9713 	static size_t last_total;
9714 
9715 
9716 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9717 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9718 		    !socket_stats.heap_totalsz_bytes)
9719 			continue;
9720 		total += socket_stats.heap_totalsz_bytes;
9721 		alloc += socket_stats.heap_allocsz_bytes;
9722 		free += socket_stats.heap_freesz_bytes;
9723 		n_alloc += socket_stats.alloc_count;
9724 		n_free += socket_stats.free_count;
9725 		fprintf(f,
9726 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9727 			i,
9728 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9729 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9730 			(double)socket_stats.heap_allocsz_bytes * 100 /
9731 			(double)socket_stats.heap_totalsz_bytes,
9732 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9733 			socket_stats.alloc_count,
9734 			socket_stats.free_count);
9735 	}
9736 	fprintf(f,
9737 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9738 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9739 		total ? ((double)alloc * 100 / (double)total) : 0,
9740 		(double)free / (1024 * 1024),
9741 		n_alloc, n_free);
9742 	if (last_allocs)
9743 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9744 			((double)total - (double)last_total) / (1024 * 1024),
9745 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9746 	last_allocs = alloc;
9747 	last_total = total;
9748 }
9749 
9750 static void cmd_dump_parsed(void *parsed_result,
9751 			    __rte_unused struct cmdline *cl,
9752 			    __rte_unused void *data)
9753 {
9754 	struct cmd_dump_result *res = parsed_result;
9755 
9756 	if (!strcmp(res->dump, "dump_physmem"))
9757 		rte_dump_physmem_layout(stdout);
9758 	else if (!strcmp(res->dump, "dump_socket_mem"))
9759 		dump_socket_mem(stdout);
9760 	else if (!strcmp(res->dump, "dump_memzone"))
9761 		rte_memzone_dump(stdout);
9762 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9763 		dump_struct_sizes();
9764 	else if (!strcmp(res->dump, "dump_ring"))
9765 		rte_ring_list_dump(stdout);
9766 	else if (!strcmp(res->dump, "dump_mempool"))
9767 		rte_mempool_list_dump(stdout);
9768 	else if (!strcmp(res->dump, "dump_devargs"))
9769 		rte_devargs_dump(stdout);
9770 	else if (!strcmp(res->dump, "dump_log_types"))
9771 		rte_log_dump(stdout);
9772 }
9773 
9774 cmdline_parse_token_string_t cmd_dump_dump =
9775 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9776 		"dump_physmem#"
9777 		"dump_memzone#"
9778 		"dump_socket_mem#"
9779 		"dump_struct_sizes#"
9780 		"dump_ring#"
9781 		"dump_mempool#"
9782 		"dump_devargs#"
9783 		"dump_log_types");
9784 
9785 cmdline_parse_inst_t cmd_dump = {
9786 	.f = cmd_dump_parsed,  /* function to call */
9787 	.data = NULL,      /* 2nd arg of func */
9788 	.help_str = "Dump status",
9789 	.tokens = {        /* token list, NULL terminated */
9790 		(void *)&cmd_dump_dump,
9791 		NULL,
9792 	},
9793 };
9794 
9795 /* ******************************************************************************** */
9796 
9797 struct cmd_dump_one_result {
9798 	cmdline_fixed_string_t dump;
9799 	cmdline_fixed_string_t name;
9800 };
9801 
9802 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9803 				__rte_unused void *data)
9804 {
9805 	struct cmd_dump_one_result *res = parsed_result;
9806 
9807 	if (!strcmp(res->dump, "dump_ring")) {
9808 		struct rte_ring *r;
9809 		r = rte_ring_lookup(res->name);
9810 		if (r == NULL) {
9811 			cmdline_printf(cl, "Cannot find ring\n");
9812 			return;
9813 		}
9814 		rte_ring_dump(stdout, r);
9815 	} else if (!strcmp(res->dump, "dump_mempool")) {
9816 		struct rte_mempool *mp;
9817 		mp = rte_mempool_lookup(res->name);
9818 		if (mp == NULL) {
9819 			cmdline_printf(cl, "Cannot find mempool\n");
9820 			return;
9821 		}
9822 		rte_mempool_dump(stdout, mp);
9823 	}
9824 }
9825 
9826 cmdline_parse_token_string_t cmd_dump_one_dump =
9827 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9828 				 "dump_ring#dump_mempool");
9829 
9830 cmdline_parse_token_string_t cmd_dump_one_name =
9831 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9832 
9833 cmdline_parse_inst_t cmd_dump_one = {
9834 	.f = cmd_dump_one_parsed,  /* function to call */
9835 	.data = NULL,      /* 2nd arg of func */
9836 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9837 	.tokens = {        /* token list, NULL terminated */
9838 		(void *)&cmd_dump_one_dump,
9839 		(void *)&cmd_dump_one_name,
9840 		NULL,
9841 	},
9842 };
9843 
9844 /* *** queue region set *** */
9845 struct cmd_queue_region_result {
9846 	cmdline_fixed_string_t set;
9847 	cmdline_fixed_string_t port;
9848 	portid_t port_id;
9849 	cmdline_fixed_string_t cmd;
9850 	cmdline_fixed_string_t region;
9851 	uint8_t  region_id;
9852 	cmdline_fixed_string_t queue_start_index;
9853 	uint8_t  queue_id;
9854 	cmdline_fixed_string_t queue_num;
9855 	uint8_t  queue_num_value;
9856 };
9857 
9858 static void
9859 cmd_queue_region_parsed(void *parsed_result,
9860 			__rte_unused struct cmdline *cl,
9861 			__rte_unused void *data)
9862 {
9863 	struct cmd_queue_region_result *res = parsed_result;
9864 	int ret = -ENOTSUP;
9865 #ifdef RTE_NET_I40E
9866 	struct rte_pmd_i40e_queue_region_conf region_conf;
9867 	enum rte_pmd_i40e_queue_region_op op_type;
9868 #endif
9869 
9870 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9871 		return;
9872 
9873 #ifdef RTE_NET_I40E
9874 	memset(&region_conf, 0, sizeof(region_conf));
9875 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9876 	region_conf.region_id = res->region_id;
9877 	region_conf.queue_num = res->queue_num_value;
9878 	region_conf.queue_start_index = res->queue_id;
9879 
9880 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9881 				op_type, &region_conf);
9882 #endif
9883 
9884 	switch (ret) {
9885 	case 0:
9886 		break;
9887 	case -ENOTSUP:
9888 		printf("function not implemented or supported\n");
9889 		break;
9890 	default:
9891 		printf("queue region config error: (%s)\n", strerror(-ret));
9892 	}
9893 }
9894 
9895 cmdline_parse_token_string_t cmd_queue_region_set =
9896 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9897 		set, "set");
9898 cmdline_parse_token_string_t cmd_queue_region_port =
9899 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9900 cmdline_parse_token_num_t cmd_queue_region_port_id =
9901 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9902 				port_id, RTE_UINT16);
9903 cmdline_parse_token_string_t cmd_queue_region_cmd =
9904 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9905 				 cmd, "queue-region");
9906 cmdline_parse_token_string_t cmd_queue_region_id =
9907 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9908 				region, "region_id");
9909 cmdline_parse_token_num_t cmd_queue_region_index =
9910 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9911 				region_id, RTE_UINT8);
9912 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9913 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9914 				queue_start_index, "queue_start_index");
9915 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9916 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9917 				queue_id, RTE_UINT8);
9918 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9919 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9920 				queue_num, "queue_num");
9921 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9922 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9923 				queue_num_value, RTE_UINT8);
9924 
9925 cmdline_parse_inst_t cmd_queue_region = {
9926 	.f = cmd_queue_region_parsed,
9927 	.data = NULL,
9928 	.help_str = "set port <port_id> queue-region region_id <value> "
9929 		"queue_start_index <value> queue_num <value>: Set a queue region",
9930 	.tokens = {
9931 		(void *)&cmd_queue_region_set,
9932 		(void *)&cmd_queue_region_port,
9933 		(void *)&cmd_queue_region_port_id,
9934 		(void *)&cmd_queue_region_cmd,
9935 		(void *)&cmd_queue_region_id,
9936 		(void *)&cmd_queue_region_index,
9937 		(void *)&cmd_queue_region_queue_start_index,
9938 		(void *)&cmd_queue_region_queue_id,
9939 		(void *)&cmd_queue_region_queue_num,
9940 		(void *)&cmd_queue_region_queue_num_value,
9941 		NULL,
9942 	},
9943 };
9944 
9945 /* *** queue region and flowtype set *** */
9946 struct cmd_region_flowtype_result {
9947 	cmdline_fixed_string_t set;
9948 	cmdline_fixed_string_t port;
9949 	portid_t port_id;
9950 	cmdline_fixed_string_t cmd;
9951 	cmdline_fixed_string_t region;
9952 	uint8_t  region_id;
9953 	cmdline_fixed_string_t flowtype;
9954 	uint8_t  flowtype_id;
9955 };
9956 
9957 static void
9958 cmd_region_flowtype_parsed(void *parsed_result,
9959 			__rte_unused struct cmdline *cl,
9960 			__rte_unused void *data)
9961 {
9962 	struct cmd_region_flowtype_result *res = parsed_result;
9963 	int ret = -ENOTSUP;
9964 #ifdef RTE_NET_I40E
9965 	struct rte_pmd_i40e_queue_region_conf region_conf;
9966 	enum rte_pmd_i40e_queue_region_op op_type;
9967 #endif
9968 
9969 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9970 		return;
9971 
9972 #ifdef RTE_NET_I40E
9973 	memset(&region_conf, 0, sizeof(region_conf));
9974 
9975 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9976 	region_conf.region_id = res->region_id;
9977 	region_conf.hw_flowtype = res->flowtype_id;
9978 
9979 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9980 			op_type, &region_conf);
9981 #endif
9982 
9983 	switch (ret) {
9984 	case 0:
9985 		break;
9986 	case -ENOTSUP:
9987 		printf("function not implemented or supported\n");
9988 		break;
9989 	default:
9990 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9991 	}
9992 }
9993 
9994 cmdline_parse_token_string_t cmd_region_flowtype_set =
9995 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9996 				set, "set");
9997 cmdline_parse_token_string_t cmd_region_flowtype_port =
9998 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9999 				port, "port");
10000 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10001 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10002 				port_id, RTE_UINT16);
10003 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10004 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10005 				cmd, "queue-region");
10006 cmdline_parse_token_string_t cmd_region_flowtype_index =
10007 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10008 				region, "region_id");
10009 cmdline_parse_token_num_t cmd_region_flowtype_id =
10010 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10011 				region_id, RTE_UINT8);
10012 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10013 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10014 				flowtype, "flowtype");
10015 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10016 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10017 				flowtype_id, RTE_UINT8);
10018 cmdline_parse_inst_t cmd_region_flowtype = {
10019 	.f = cmd_region_flowtype_parsed,
10020 	.data = NULL,
10021 	.help_str = "set port <port_id> queue-region region_id <value> "
10022 		"flowtype <value>: Set a flowtype region index",
10023 	.tokens = {
10024 		(void *)&cmd_region_flowtype_set,
10025 		(void *)&cmd_region_flowtype_port,
10026 		(void *)&cmd_region_flowtype_port_index,
10027 		(void *)&cmd_region_flowtype_cmd,
10028 		(void *)&cmd_region_flowtype_index,
10029 		(void *)&cmd_region_flowtype_id,
10030 		(void *)&cmd_region_flowtype_flow_index,
10031 		(void *)&cmd_region_flowtype_flow_id,
10032 		NULL,
10033 	},
10034 };
10035 
10036 /* *** User Priority (UP) to queue region (region_id) set *** */
10037 struct cmd_user_priority_region_result {
10038 	cmdline_fixed_string_t set;
10039 	cmdline_fixed_string_t port;
10040 	portid_t port_id;
10041 	cmdline_fixed_string_t cmd;
10042 	cmdline_fixed_string_t user_priority;
10043 	uint8_t  user_priority_id;
10044 	cmdline_fixed_string_t region;
10045 	uint8_t  region_id;
10046 };
10047 
10048 static void
10049 cmd_user_priority_region_parsed(void *parsed_result,
10050 			__rte_unused struct cmdline *cl,
10051 			__rte_unused void *data)
10052 {
10053 	struct cmd_user_priority_region_result *res = parsed_result;
10054 	int ret = -ENOTSUP;
10055 #ifdef RTE_NET_I40E
10056 	struct rte_pmd_i40e_queue_region_conf region_conf;
10057 	enum rte_pmd_i40e_queue_region_op op_type;
10058 #endif
10059 
10060 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10061 		return;
10062 
10063 #ifdef RTE_NET_I40E
10064 	memset(&region_conf, 0, sizeof(region_conf));
10065 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10066 	region_conf.user_priority = res->user_priority_id;
10067 	region_conf.region_id = res->region_id;
10068 
10069 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10070 				op_type, &region_conf);
10071 #endif
10072 
10073 	switch (ret) {
10074 	case 0:
10075 		break;
10076 	case -ENOTSUP:
10077 		printf("function not implemented or supported\n");
10078 		break;
10079 	default:
10080 		printf("user_priority region config error: (%s)\n",
10081 				strerror(-ret));
10082 	}
10083 }
10084 
10085 cmdline_parse_token_string_t cmd_user_priority_region_set =
10086 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10087 				set, "set");
10088 cmdline_parse_token_string_t cmd_user_priority_region_port =
10089 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10090 				port, "port");
10091 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10092 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10093 				port_id, RTE_UINT16);
10094 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10095 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10096 				cmd, "queue-region");
10097 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10098 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10099 				user_priority, "UP");
10100 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10101 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10102 				user_priority_id, RTE_UINT8);
10103 cmdline_parse_token_string_t cmd_user_priority_region_region =
10104 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10105 				region, "region_id");
10106 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10107 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10108 				region_id, RTE_UINT8);
10109 
10110 cmdline_parse_inst_t cmd_user_priority_region = {
10111 	.f = cmd_user_priority_region_parsed,
10112 	.data = NULL,
10113 	.help_str = "set port <port_id> queue-region UP <value> "
10114 		"region_id <value>: Set the mapping of User Priority (UP) "
10115 		"to queue region (region_id) ",
10116 	.tokens = {
10117 		(void *)&cmd_user_priority_region_set,
10118 		(void *)&cmd_user_priority_region_port,
10119 		(void *)&cmd_user_priority_region_port_index,
10120 		(void *)&cmd_user_priority_region_cmd,
10121 		(void *)&cmd_user_priority_region_UP,
10122 		(void *)&cmd_user_priority_region_UP_id,
10123 		(void *)&cmd_user_priority_region_region,
10124 		(void *)&cmd_user_priority_region_region_id,
10125 		NULL,
10126 	},
10127 };
10128 
10129 /* *** flush all queue region related configuration *** */
10130 struct cmd_flush_queue_region_result {
10131 	cmdline_fixed_string_t set;
10132 	cmdline_fixed_string_t port;
10133 	portid_t port_id;
10134 	cmdline_fixed_string_t cmd;
10135 	cmdline_fixed_string_t flush;
10136 	cmdline_fixed_string_t what;
10137 };
10138 
10139 static void
10140 cmd_flush_queue_region_parsed(void *parsed_result,
10141 			__rte_unused struct cmdline *cl,
10142 			__rte_unused void *data)
10143 {
10144 	struct cmd_flush_queue_region_result *res = parsed_result;
10145 	int ret = -ENOTSUP;
10146 #ifdef RTE_NET_I40E
10147 	struct rte_pmd_i40e_queue_region_conf region_conf;
10148 	enum rte_pmd_i40e_queue_region_op op_type;
10149 #endif
10150 
10151 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10152 		return;
10153 
10154 #ifdef RTE_NET_I40E
10155 	memset(&region_conf, 0, sizeof(region_conf));
10156 
10157 	if (strcmp(res->what, "on") == 0)
10158 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10159 	else
10160 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10161 
10162 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10163 				op_type, &region_conf);
10164 #endif
10165 
10166 	switch (ret) {
10167 	case 0:
10168 		break;
10169 	case -ENOTSUP:
10170 		printf("function not implemented or supported\n");
10171 		break;
10172 	default:
10173 		printf("queue region config flush error: (%s)\n",
10174 				strerror(-ret));
10175 	}
10176 }
10177 
10178 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10179 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10180 				set, "set");
10181 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10182 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10183 				port, "port");
10184 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10185 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10186 				port_id, RTE_UINT16);
10187 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10188 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10189 				cmd, "queue-region");
10190 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10191 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10192 				flush, "flush");
10193 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10194 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10195 				what, "on#off");
10196 
10197 cmdline_parse_inst_t cmd_flush_queue_region = {
10198 	.f = cmd_flush_queue_region_parsed,
10199 	.data = NULL,
10200 	.help_str = "set port <port_id> queue-region flush on|off"
10201 		": flush all queue region related configuration",
10202 	.tokens = {
10203 		(void *)&cmd_flush_queue_region_set,
10204 		(void *)&cmd_flush_queue_region_port,
10205 		(void *)&cmd_flush_queue_region_port_index,
10206 		(void *)&cmd_flush_queue_region_cmd,
10207 		(void *)&cmd_flush_queue_region_flush,
10208 		(void *)&cmd_flush_queue_region_what,
10209 		NULL,
10210 	},
10211 };
10212 
10213 /* *** get all queue region related configuration info *** */
10214 struct cmd_show_queue_region_info {
10215 	cmdline_fixed_string_t show;
10216 	cmdline_fixed_string_t port;
10217 	portid_t port_id;
10218 	cmdline_fixed_string_t cmd;
10219 };
10220 
10221 static void
10222 cmd_show_queue_region_info_parsed(void *parsed_result,
10223 			__rte_unused struct cmdline *cl,
10224 			__rte_unused void *data)
10225 {
10226 	struct cmd_show_queue_region_info *res = parsed_result;
10227 	int ret = -ENOTSUP;
10228 #ifdef RTE_NET_I40E
10229 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10230 	enum rte_pmd_i40e_queue_region_op op_type;
10231 #endif
10232 
10233 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10234 		return;
10235 
10236 #ifdef RTE_NET_I40E
10237 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10238 
10239 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10240 
10241 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10242 					op_type, &rte_pmd_regions);
10243 
10244 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10245 #endif
10246 
10247 	switch (ret) {
10248 	case 0:
10249 		break;
10250 	case -ENOTSUP:
10251 		printf("function not implemented or supported\n");
10252 		break;
10253 	default:
10254 		printf("queue region config info show error: (%s)\n",
10255 				strerror(-ret));
10256 	}
10257 }
10258 
10259 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10260 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10261 				show, "show");
10262 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10263 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10264 				port, "port");
10265 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10266 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10267 				port_id, RTE_UINT16);
10268 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10269 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10270 				cmd, "queue-region");
10271 
10272 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10273 	.f = cmd_show_queue_region_info_parsed,
10274 	.data = NULL,
10275 	.help_str = "show port <port_id> queue-region"
10276 		": show all queue region related configuration info",
10277 	.tokens = {
10278 		(void *)&cmd_show_queue_region_info_get,
10279 		(void *)&cmd_show_queue_region_info_port,
10280 		(void *)&cmd_show_queue_region_info_port_index,
10281 		(void *)&cmd_show_queue_region_info_cmd,
10282 		NULL,
10283 	},
10284 };
10285 
10286 /* *** Filters Control *** */
10287 
10288 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10289 do { \
10290 	if ((ip_addr).family == AF_INET) \
10291 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10292 	else { \
10293 		printf("invalid parameter.\n"); \
10294 		return; \
10295 	} \
10296 } while (0)
10297 
10298 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10299 do { \
10300 	if ((ip_addr).family == AF_INET6) \
10301 		rte_memcpy(&(ip), \
10302 				 &((ip_addr).addr.ipv6), \
10303 				 sizeof(struct in6_addr)); \
10304 	else { \
10305 		printf("invalid parameter.\n"); \
10306 		return; \
10307 	} \
10308 } while (0)
10309 
10310 #ifdef RTE_NET_I40E
10311 
10312 static uint16_t
10313 str2flowtype(char *string)
10314 {
10315 	uint8_t i = 0;
10316 	static const struct {
10317 		char str[32];
10318 		uint16_t type;
10319 	} flowtype_str[] = {
10320 		{"raw", RTE_ETH_FLOW_RAW},
10321 		{"ipv4", RTE_ETH_FLOW_IPV4},
10322 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10323 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10324 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10325 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10326 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10327 		{"ipv6", RTE_ETH_FLOW_IPV6},
10328 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10329 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10330 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10331 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10332 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10333 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10334 	};
10335 
10336 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10337 		if (!strcmp(flowtype_str[i].str, string))
10338 			return flowtype_str[i].type;
10339 	}
10340 
10341 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10342 		return (uint16_t)atoi(string);
10343 
10344 	return RTE_ETH_FLOW_UNKNOWN;
10345 }
10346 
10347 /* *** deal with flow director filter *** */
10348 struct cmd_flow_director_result {
10349 	cmdline_fixed_string_t flow_director_filter;
10350 	portid_t port_id;
10351 	cmdline_fixed_string_t mode;
10352 	cmdline_fixed_string_t mode_value;
10353 	cmdline_fixed_string_t ops;
10354 	cmdline_fixed_string_t flow;
10355 	cmdline_fixed_string_t flow_type;
10356 	cmdline_fixed_string_t drop;
10357 	cmdline_fixed_string_t queue;
10358 	uint16_t  queue_id;
10359 	cmdline_fixed_string_t fd_id;
10360 	uint32_t  fd_id_value;
10361 	cmdline_fixed_string_t packet;
10362 	char filepath[];
10363 };
10364 
10365 static void
10366 cmd_flow_director_filter_parsed(void *parsed_result,
10367 			  __rte_unused struct cmdline *cl,
10368 			  __rte_unused void *data)
10369 {
10370 	struct cmd_flow_director_result *res = parsed_result;
10371 	int ret = 0;
10372 	struct rte_pmd_i40e_flow_type_mapping
10373 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10374 	struct rte_pmd_i40e_pkt_template_conf conf;
10375 	uint16_t flow_type = str2flowtype(res->flow_type);
10376 	uint16_t i, port = res->port_id;
10377 	uint8_t add;
10378 
10379 	memset(&conf, 0, sizeof(conf));
10380 
10381 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10382 		printf("Invalid flow type specified.\n");
10383 		return;
10384 	}
10385 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10386 						 mapping);
10387 	if (ret)
10388 		return;
10389 	if (mapping[flow_type].pctype == 0ULL) {
10390 		printf("Invalid flow type specified.\n");
10391 		return;
10392 	}
10393 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10394 		if (mapping[flow_type].pctype & (1ULL << i)) {
10395 			conf.input.pctype = i;
10396 			break;
10397 		}
10398 	}
10399 
10400 	conf.input.packet = open_file(res->filepath,
10401 				&conf.input.length);
10402 	if (!conf.input.packet)
10403 		return;
10404 	if (!strcmp(res->drop, "drop"))
10405 		conf.action.behavior =
10406 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10407 	else
10408 		conf.action.behavior =
10409 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10410 	conf.action.report_status =
10411 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10412 	conf.action.rx_queue = res->queue_id;
10413 	conf.soft_id = res->fd_id_value;
10414 	add  = strcmp(res->ops, "del") ? 1 : 0;
10415 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10416 							&conf,
10417 							add);
10418 	if (ret < 0)
10419 		printf("flow director config error: (%s)\n",
10420 		       strerror(-ret));
10421 	close_file(conf.input.packet);
10422 }
10423 
10424 cmdline_parse_token_string_t cmd_flow_director_filter =
10425 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10426 				 flow_director_filter, "flow_director_filter");
10427 cmdline_parse_token_num_t cmd_flow_director_port_id =
10428 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10429 			      port_id, RTE_UINT16);
10430 cmdline_parse_token_string_t cmd_flow_director_ops =
10431 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10432 				 ops, "add#del#update");
10433 cmdline_parse_token_string_t cmd_flow_director_flow =
10434 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10435 				 flow, "flow");
10436 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10437 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10438 		flow_type, NULL);
10439 cmdline_parse_token_string_t cmd_flow_director_drop =
10440 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10441 				 drop, "drop#fwd");
10442 cmdline_parse_token_string_t cmd_flow_director_queue =
10443 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10444 				 queue, "queue");
10445 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10446 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10447 			      queue_id, RTE_UINT16);
10448 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10449 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10450 				 fd_id, "fd_id");
10451 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10452 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10453 			      fd_id_value, RTE_UINT32);
10454 
10455 cmdline_parse_token_string_t cmd_flow_director_mode =
10456 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10457 				 mode, "mode");
10458 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10459 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10460 				 mode_value, "raw");
10461 cmdline_parse_token_string_t cmd_flow_director_packet =
10462 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10463 				 packet, "packet");
10464 cmdline_parse_token_string_t cmd_flow_director_filepath =
10465 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10466 				 filepath, NULL);
10467 
10468 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10469 	.f = cmd_flow_director_filter_parsed,
10470 	.data = NULL,
10471 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10472 		"director entry on NIC",
10473 	.tokens = {
10474 		(void *)&cmd_flow_director_filter,
10475 		(void *)&cmd_flow_director_port_id,
10476 		(void *)&cmd_flow_director_mode,
10477 		(void *)&cmd_flow_director_mode_raw,
10478 		(void *)&cmd_flow_director_ops,
10479 		(void *)&cmd_flow_director_flow,
10480 		(void *)&cmd_flow_director_flow_type,
10481 		(void *)&cmd_flow_director_drop,
10482 		(void *)&cmd_flow_director_queue,
10483 		(void *)&cmd_flow_director_queue_id,
10484 		(void *)&cmd_flow_director_fd_id,
10485 		(void *)&cmd_flow_director_fd_id_value,
10486 		(void *)&cmd_flow_director_packet,
10487 		(void *)&cmd_flow_director_filepath,
10488 		NULL,
10489 	},
10490 };
10491 
10492 #endif /* RTE_NET_I40E */
10493 
10494 /* *** deal with flow director mask *** */
10495 struct cmd_flow_director_mask_result {
10496 	cmdline_fixed_string_t flow_director_mask;
10497 	portid_t port_id;
10498 	cmdline_fixed_string_t mode;
10499 	cmdline_fixed_string_t mode_value;
10500 	cmdline_fixed_string_t vlan;
10501 	uint16_t vlan_mask;
10502 	cmdline_fixed_string_t src_mask;
10503 	cmdline_ipaddr_t ipv4_src;
10504 	cmdline_ipaddr_t ipv6_src;
10505 	uint16_t port_src;
10506 	cmdline_fixed_string_t dst_mask;
10507 	cmdline_ipaddr_t ipv4_dst;
10508 	cmdline_ipaddr_t ipv6_dst;
10509 	uint16_t port_dst;
10510 	cmdline_fixed_string_t mac;
10511 	uint8_t mac_addr_byte_mask;
10512 	cmdline_fixed_string_t tunnel_id;
10513 	uint32_t tunnel_id_mask;
10514 	cmdline_fixed_string_t tunnel_type;
10515 	uint8_t tunnel_type_mask;
10516 };
10517 
10518 static void
10519 cmd_flow_director_mask_parsed(void *parsed_result,
10520 			  __rte_unused struct cmdline *cl,
10521 			  __rte_unused void *data)
10522 {
10523 	struct cmd_flow_director_mask_result *res = parsed_result;
10524 	struct rte_eth_fdir_masks *mask;
10525 	struct rte_port *port;
10526 
10527 	port = &ports[res->port_id];
10528 	/** Check if the port is not started **/
10529 	if (port->port_status != RTE_PORT_STOPPED) {
10530 		printf("Please stop port %d first\n", res->port_id);
10531 		return;
10532 	}
10533 
10534 	mask = &port->dev_conf.fdir_conf.mask;
10535 
10536 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10537 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10538 			printf("Please set mode to MAC-VLAN.\n");
10539 			return;
10540 		}
10541 
10542 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10543 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10544 		if (strcmp(res->mode_value, "Tunnel")) {
10545 			printf("Please set mode to Tunnel.\n");
10546 			return;
10547 		}
10548 
10549 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10550 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10551 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10552 		mask->tunnel_type_mask = res->tunnel_type_mask;
10553 	} else {
10554 		if (strcmp(res->mode_value, "IP")) {
10555 			printf("Please set mode to IP.\n");
10556 			return;
10557 		}
10558 
10559 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10560 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10561 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10562 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10563 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10564 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10565 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10566 	}
10567 
10568 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10569 }
10570 
10571 cmdline_parse_token_string_t cmd_flow_director_mask =
10572 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10573 				 flow_director_mask, "flow_director_mask");
10574 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10575 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10576 			      port_id, RTE_UINT16);
10577 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10578 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10579 				 vlan, "vlan");
10580 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10581 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10582 			      vlan_mask, RTE_UINT16);
10583 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10584 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10585 				 src_mask, "src_mask");
10586 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10587 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10588 				 ipv4_src);
10589 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10590 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10591 				 ipv6_src);
10592 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10593 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10594 			      port_src, RTE_UINT16);
10595 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10596 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10597 				 dst_mask, "dst_mask");
10598 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10599 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10600 				 ipv4_dst);
10601 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10602 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10603 				 ipv6_dst);
10604 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10605 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10606 			      port_dst, RTE_UINT16);
10607 
10608 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10609 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10610 				 mode, "mode");
10611 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10612 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10613 				 mode_value, "IP");
10614 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10615 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10616 				 mode_value, "MAC-VLAN");
10617 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10618 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10619 				 mode_value, "Tunnel");
10620 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10621 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10622 				 mac, "mac");
10623 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10624 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10625 			      mac_addr_byte_mask, RTE_UINT8);
10626 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10627 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10628 				 tunnel_type, "tunnel-type");
10629 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10630 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10631 			      tunnel_type_mask, RTE_UINT8);
10632 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10633 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10634 				 tunnel_id, "tunnel-id");
10635 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10636 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10637 			      tunnel_id_mask, RTE_UINT32);
10638 
10639 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10640 	.f = cmd_flow_director_mask_parsed,
10641 	.data = NULL,
10642 	.help_str = "flow_director_mask ... : "
10643 		"Set IP mode flow director's mask on NIC",
10644 	.tokens = {
10645 		(void *)&cmd_flow_director_mask,
10646 		(void *)&cmd_flow_director_mask_port_id,
10647 		(void *)&cmd_flow_director_mask_mode,
10648 		(void *)&cmd_flow_director_mask_mode_ip,
10649 		(void *)&cmd_flow_director_mask_vlan,
10650 		(void *)&cmd_flow_director_mask_vlan_value,
10651 		(void *)&cmd_flow_director_mask_src,
10652 		(void *)&cmd_flow_director_mask_ipv4_src,
10653 		(void *)&cmd_flow_director_mask_ipv6_src,
10654 		(void *)&cmd_flow_director_mask_port_src,
10655 		(void *)&cmd_flow_director_mask_dst,
10656 		(void *)&cmd_flow_director_mask_ipv4_dst,
10657 		(void *)&cmd_flow_director_mask_ipv6_dst,
10658 		(void *)&cmd_flow_director_mask_port_dst,
10659 		NULL,
10660 	},
10661 };
10662 
10663 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10664 	.f = cmd_flow_director_mask_parsed,
10665 	.data = NULL,
10666 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10667 		"flow director's mask on NIC",
10668 	.tokens = {
10669 		(void *)&cmd_flow_director_mask,
10670 		(void *)&cmd_flow_director_mask_port_id,
10671 		(void *)&cmd_flow_director_mask_mode,
10672 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10673 		(void *)&cmd_flow_director_mask_vlan,
10674 		(void *)&cmd_flow_director_mask_vlan_value,
10675 		NULL,
10676 	},
10677 };
10678 
10679 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10680 	.f = cmd_flow_director_mask_parsed,
10681 	.data = NULL,
10682 	.help_str = "flow_director_mask ... : Set tunnel mode "
10683 		"flow director's mask on NIC",
10684 	.tokens = {
10685 		(void *)&cmd_flow_director_mask,
10686 		(void *)&cmd_flow_director_mask_port_id,
10687 		(void *)&cmd_flow_director_mask_mode,
10688 		(void *)&cmd_flow_director_mask_mode_tunnel,
10689 		(void *)&cmd_flow_director_mask_vlan,
10690 		(void *)&cmd_flow_director_mask_vlan_value,
10691 		(void *)&cmd_flow_director_mask_mac,
10692 		(void *)&cmd_flow_director_mask_mac_value,
10693 		(void *)&cmd_flow_director_mask_tunnel_type,
10694 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10695 		(void *)&cmd_flow_director_mask_tunnel_id,
10696 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10697 		NULL,
10698 	},
10699 };
10700 
10701 /* *** deal with flow director flexible payload configuration *** */
10702 struct cmd_flow_director_flexpayload_result {
10703 	cmdline_fixed_string_t flow_director_flexpayload;
10704 	portid_t port_id;
10705 	cmdline_fixed_string_t payload_layer;
10706 	cmdline_fixed_string_t payload_cfg;
10707 };
10708 
10709 static inline int
10710 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10711 {
10712 	char s[256];
10713 	const char *p, *p0 = q_arg;
10714 	char *end;
10715 	unsigned long int_fld;
10716 	char *str_fld[max_num];
10717 	int i;
10718 	unsigned size;
10719 	int ret = -1;
10720 
10721 	p = strchr(p0, '(');
10722 	if (p == NULL)
10723 		return -1;
10724 	++p;
10725 	p0 = strchr(p, ')');
10726 	if (p0 == NULL)
10727 		return -1;
10728 
10729 	size = p0 - p;
10730 	if (size >= sizeof(s))
10731 		return -1;
10732 
10733 	snprintf(s, sizeof(s), "%.*s", size, p);
10734 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10735 	if (ret < 0 || ret > max_num)
10736 		return -1;
10737 	for (i = 0; i < ret; i++) {
10738 		errno = 0;
10739 		int_fld = strtoul(str_fld[i], &end, 0);
10740 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10741 			return -1;
10742 		offsets[i] = (uint16_t)int_fld;
10743 	}
10744 	return ret;
10745 }
10746 
10747 static void
10748 cmd_flow_director_flxpld_parsed(void *parsed_result,
10749 			  __rte_unused struct cmdline *cl,
10750 			  __rte_unused void *data)
10751 {
10752 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
10753 	struct rte_eth_flex_payload_cfg flex_cfg;
10754 	struct rte_port *port;
10755 	int ret = 0;
10756 
10757 	port = &ports[res->port_id];
10758 	/** Check if the port is not started **/
10759 	if (port->port_status != RTE_PORT_STOPPED) {
10760 		printf("Please stop port %d first\n", res->port_id);
10761 		return;
10762 	}
10763 
10764 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10765 
10766 	if (!strcmp(res->payload_layer, "raw"))
10767 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10768 	else if (!strcmp(res->payload_layer, "l2"))
10769 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10770 	else if (!strcmp(res->payload_layer, "l3"))
10771 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10772 	else if (!strcmp(res->payload_layer, "l4"))
10773 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10774 
10775 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10776 			    RTE_ETH_FDIR_MAX_FLEXLEN);
10777 	if (ret < 0) {
10778 		printf("error: Cannot parse flex payload input.\n");
10779 		return;
10780 	}
10781 
10782 	fdir_set_flex_payload(res->port_id, &flex_cfg);
10783 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10784 }
10785 
10786 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10787 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10788 				 flow_director_flexpayload,
10789 				 "flow_director_flex_payload");
10790 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10791 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10792 			      port_id, RTE_UINT16);
10793 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10794 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10795 				 payload_layer, "raw#l2#l3#l4");
10796 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10797 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10798 				 payload_cfg, NULL);
10799 
10800 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10801 	.f = cmd_flow_director_flxpld_parsed,
10802 	.data = NULL,
10803 	.help_str = "flow_director_flexpayload ... : "
10804 		"Set flow director's flex payload on NIC",
10805 	.tokens = {
10806 		(void *)&cmd_flow_director_flexpayload,
10807 		(void *)&cmd_flow_director_flexpayload_port_id,
10808 		(void *)&cmd_flow_director_flexpayload_payload_layer,
10809 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
10810 		NULL,
10811 	},
10812 };
10813 
10814 /* Generic flow interface command. */
10815 extern cmdline_parse_inst_t cmd_flow;
10816 
10817 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10818 struct cmd_mcast_addr_result {
10819 	cmdline_fixed_string_t mcast_addr_cmd;
10820 	cmdline_fixed_string_t what;
10821 	uint16_t port_num;
10822 	struct rte_ether_addr mc_addr;
10823 };
10824 
10825 static void cmd_mcast_addr_parsed(void *parsed_result,
10826 		__rte_unused struct cmdline *cl,
10827 		__rte_unused void *data)
10828 {
10829 	struct cmd_mcast_addr_result *res = parsed_result;
10830 
10831 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10832 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10833 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10834 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10835 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10836 		return;
10837 	}
10838 	if (strcmp(res->what, "add") == 0)
10839 		mcast_addr_add(res->port_num, &res->mc_addr);
10840 	else
10841 		mcast_addr_remove(res->port_num, &res->mc_addr);
10842 }
10843 
10844 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10845 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10846 				 mcast_addr_cmd, "mcast_addr");
10847 cmdline_parse_token_string_t cmd_mcast_addr_what =
10848 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10849 				 "add#remove");
10850 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10851 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10852 				 RTE_UINT16);
10853 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10854 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10855 
10856 cmdline_parse_inst_t cmd_mcast_addr = {
10857 	.f = cmd_mcast_addr_parsed,
10858 	.data = (void *)0,
10859 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10860 		"Add/Remove multicast MAC address on port_id",
10861 	.tokens = {
10862 		(void *)&cmd_mcast_addr_cmd,
10863 		(void *)&cmd_mcast_addr_what,
10864 		(void *)&cmd_mcast_addr_portnum,
10865 		(void *)&cmd_mcast_addr_addr,
10866 		NULL,
10867 	},
10868 };
10869 
10870 /* vf vlan anti spoof configuration */
10871 
10872 /* Common result structure for vf vlan anti spoof */
10873 struct cmd_vf_vlan_anti_spoof_result {
10874 	cmdline_fixed_string_t set;
10875 	cmdline_fixed_string_t vf;
10876 	cmdline_fixed_string_t vlan;
10877 	cmdline_fixed_string_t antispoof;
10878 	portid_t port_id;
10879 	uint32_t vf_id;
10880 	cmdline_fixed_string_t on_off;
10881 };
10882 
10883 /* Common CLI fields for vf vlan anti spoof enable disable */
10884 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10885 	TOKEN_STRING_INITIALIZER
10886 		(struct cmd_vf_vlan_anti_spoof_result,
10887 		 set, "set");
10888 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10889 	TOKEN_STRING_INITIALIZER
10890 		(struct cmd_vf_vlan_anti_spoof_result,
10891 		 vf, "vf");
10892 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10893 	TOKEN_STRING_INITIALIZER
10894 		(struct cmd_vf_vlan_anti_spoof_result,
10895 		 vlan, "vlan");
10896 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10897 	TOKEN_STRING_INITIALIZER
10898 		(struct cmd_vf_vlan_anti_spoof_result,
10899 		 antispoof, "antispoof");
10900 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10901 	TOKEN_NUM_INITIALIZER
10902 		(struct cmd_vf_vlan_anti_spoof_result,
10903 		 port_id, RTE_UINT16);
10904 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10905 	TOKEN_NUM_INITIALIZER
10906 		(struct cmd_vf_vlan_anti_spoof_result,
10907 		 vf_id, RTE_UINT32);
10908 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10909 	TOKEN_STRING_INITIALIZER
10910 		(struct cmd_vf_vlan_anti_spoof_result,
10911 		 on_off, "on#off");
10912 
10913 static void
10914 cmd_set_vf_vlan_anti_spoof_parsed(
10915 	void *parsed_result,
10916 	__rte_unused struct cmdline *cl,
10917 	__rte_unused void *data)
10918 {
10919 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10920 	int ret = -ENOTSUP;
10921 
10922 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10923 
10924 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10925 		return;
10926 
10927 #ifdef RTE_NET_IXGBE
10928 	if (ret == -ENOTSUP)
10929 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10930 				res->vf_id, is_on);
10931 #endif
10932 #ifdef RTE_NET_I40E
10933 	if (ret == -ENOTSUP)
10934 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10935 				res->vf_id, is_on);
10936 #endif
10937 #ifdef RTE_NET_BNXT
10938 	if (ret == -ENOTSUP)
10939 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10940 				res->vf_id, is_on);
10941 #endif
10942 
10943 	switch (ret) {
10944 	case 0:
10945 		break;
10946 	case -EINVAL:
10947 		printf("invalid vf_id %d\n", res->vf_id);
10948 		break;
10949 	case -ENODEV:
10950 		printf("invalid port_id %d\n", res->port_id);
10951 		break;
10952 	case -ENOTSUP:
10953 		printf("function not implemented\n");
10954 		break;
10955 	default:
10956 		printf("programming error: (%s)\n", strerror(-ret));
10957 	}
10958 }
10959 
10960 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10961 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
10962 	.data = NULL,
10963 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10964 	.tokens = {
10965 		(void *)&cmd_vf_vlan_anti_spoof_set,
10966 		(void *)&cmd_vf_vlan_anti_spoof_vf,
10967 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
10968 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
10969 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
10970 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
10971 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
10972 		NULL,
10973 	},
10974 };
10975 
10976 /* vf mac anti spoof configuration */
10977 
10978 /* Common result structure for vf mac anti spoof */
10979 struct cmd_vf_mac_anti_spoof_result {
10980 	cmdline_fixed_string_t set;
10981 	cmdline_fixed_string_t vf;
10982 	cmdline_fixed_string_t mac;
10983 	cmdline_fixed_string_t antispoof;
10984 	portid_t port_id;
10985 	uint32_t vf_id;
10986 	cmdline_fixed_string_t on_off;
10987 };
10988 
10989 /* Common CLI fields for vf mac anti spoof enable disable */
10990 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10991 	TOKEN_STRING_INITIALIZER
10992 		(struct cmd_vf_mac_anti_spoof_result,
10993 		 set, "set");
10994 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10995 	TOKEN_STRING_INITIALIZER
10996 		(struct cmd_vf_mac_anti_spoof_result,
10997 		 vf, "vf");
10998 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10999 	TOKEN_STRING_INITIALIZER
11000 		(struct cmd_vf_mac_anti_spoof_result,
11001 		 mac, "mac");
11002 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11003 	TOKEN_STRING_INITIALIZER
11004 		(struct cmd_vf_mac_anti_spoof_result,
11005 		 antispoof, "antispoof");
11006 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11007 	TOKEN_NUM_INITIALIZER
11008 		(struct cmd_vf_mac_anti_spoof_result,
11009 		 port_id, RTE_UINT16);
11010 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11011 	TOKEN_NUM_INITIALIZER
11012 		(struct cmd_vf_mac_anti_spoof_result,
11013 		 vf_id, RTE_UINT32);
11014 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11015 	TOKEN_STRING_INITIALIZER
11016 		(struct cmd_vf_mac_anti_spoof_result,
11017 		 on_off, "on#off");
11018 
11019 static void
11020 cmd_set_vf_mac_anti_spoof_parsed(
11021 	void *parsed_result,
11022 	__rte_unused struct cmdline *cl,
11023 	__rte_unused void *data)
11024 {
11025 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11026 	int ret = -ENOTSUP;
11027 
11028 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11029 
11030 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11031 		return;
11032 
11033 #ifdef RTE_NET_IXGBE
11034 	if (ret == -ENOTSUP)
11035 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11036 			res->vf_id, is_on);
11037 #endif
11038 #ifdef RTE_NET_I40E
11039 	if (ret == -ENOTSUP)
11040 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11041 			res->vf_id, is_on);
11042 #endif
11043 #ifdef RTE_NET_BNXT
11044 	if (ret == -ENOTSUP)
11045 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11046 			res->vf_id, is_on);
11047 #endif
11048 
11049 	switch (ret) {
11050 	case 0:
11051 		break;
11052 	case -EINVAL:
11053 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11054 		break;
11055 	case -ENODEV:
11056 		printf("invalid port_id %d\n", res->port_id);
11057 		break;
11058 	case -ENOTSUP:
11059 		printf("function not implemented\n");
11060 		break;
11061 	default:
11062 		printf("programming error: (%s)\n", strerror(-ret));
11063 	}
11064 }
11065 
11066 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11067 	.f = cmd_set_vf_mac_anti_spoof_parsed,
11068 	.data = NULL,
11069 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11070 	.tokens = {
11071 		(void *)&cmd_vf_mac_anti_spoof_set,
11072 		(void *)&cmd_vf_mac_anti_spoof_vf,
11073 		(void *)&cmd_vf_mac_anti_spoof_mac,
11074 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
11075 		(void *)&cmd_vf_mac_anti_spoof_port_id,
11076 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
11077 		(void *)&cmd_vf_mac_anti_spoof_on_off,
11078 		NULL,
11079 	},
11080 };
11081 
11082 /* vf vlan strip queue configuration */
11083 
11084 /* Common result structure for vf mac anti spoof */
11085 struct cmd_vf_vlan_stripq_result {
11086 	cmdline_fixed_string_t set;
11087 	cmdline_fixed_string_t vf;
11088 	cmdline_fixed_string_t vlan;
11089 	cmdline_fixed_string_t stripq;
11090 	portid_t port_id;
11091 	uint16_t vf_id;
11092 	cmdline_fixed_string_t on_off;
11093 };
11094 
11095 /* Common CLI fields for vf vlan strip enable disable */
11096 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11097 	TOKEN_STRING_INITIALIZER
11098 		(struct cmd_vf_vlan_stripq_result,
11099 		 set, "set");
11100 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11101 	TOKEN_STRING_INITIALIZER
11102 		(struct cmd_vf_vlan_stripq_result,
11103 		 vf, "vf");
11104 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11105 	TOKEN_STRING_INITIALIZER
11106 		(struct cmd_vf_vlan_stripq_result,
11107 		 vlan, "vlan");
11108 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11109 	TOKEN_STRING_INITIALIZER
11110 		(struct cmd_vf_vlan_stripq_result,
11111 		 stripq, "stripq");
11112 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11113 	TOKEN_NUM_INITIALIZER
11114 		(struct cmd_vf_vlan_stripq_result,
11115 		 port_id, RTE_UINT16);
11116 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11117 	TOKEN_NUM_INITIALIZER
11118 		(struct cmd_vf_vlan_stripq_result,
11119 		 vf_id, RTE_UINT16);
11120 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11121 	TOKEN_STRING_INITIALIZER
11122 		(struct cmd_vf_vlan_stripq_result,
11123 		 on_off, "on#off");
11124 
11125 static void
11126 cmd_set_vf_vlan_stripq_parsed(
11127 	void *parsed_result,
11128 	__rte_unused struct cmdline *cl,
11129 	__rte_unused void *data)
11130 {
11131 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
11132 	int ret = -ENOTSUP;
11133 
11134 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11135 
11136 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11137 		return;
11138 
11139 #ifdef RTE_NET_IXGBE
11140 	if (ret == -ENOTSUP)
11141 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11142 			res->vf_id, is_on);
11143 #endif
11144 #ifdef RTE_NET_I40E
11145 	if (ret == -ENOTSUP)
11146 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11147 			res->vf_id, is_on);
11148 #endif
11149 #ifdef RTE_NET_BNXT
11150 	if (ret == -ENOTSUP)
11151 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11152 			res->vf_id, is_on);
11153 #endif
11154 
11155 	switch (ret) {
11156 	case 0:
11157 		break;
11158 	case -EINVAL:
11159 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11160 		break;
11161 	case -ENODEV:
11162 		printf("invalid port_id %d\n", res->port_id);
11163 		break;
11164 	case -ENOTSUP:
11165 		printf("function not implemented\n");
11166 		break;
11167 	default:
11168 		printf("programming error: (%s)\n", strerror(-ret));
11169 	}
11170 }
11171 
11172 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11173 	.f = cmd_set_vf_vlan_stripq_parsed,
11174 	.data = NULL,
11175 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11176 	.tokens = {
11177 		(void *)&cmd_vf_vlan_stripq_set,
11178 		(void *)&cmd_vf_vlan_stripq_vf,
11179 		(void *)&cmd_vf_vlan_stripq_vlan,
11180 		(void *)&cmd_vf_vlan_stripq_stripq,
11181 		(void *)&cmd_vf_vlan_stripq_port_id,
11182 		(void *)&cmd_vf_vlan_stripq_vf_id,
11183 		(void *)&cmd_vf_vlan_stripq_on_off,
11184 		NULL,
11185 	},
11186 };
11187 
11188 /* vf vlan insert configuration */
11189 
11190 /* Common result structure for vf vlan insert */
11191 struct cmd_vf_vlan_insert_result {
11192 	cmdline_fixed_string_t set;
11193 	cmdline_fixed_string_t vf;
11194 	cmdline_fixed_string_t vlan;
11195 	cmdline_fixed_string_t insert;
11196 	portid_t port_id;
11197 	uint16_t vf_id;
11198 	uint16_t vlan_id;
11199 };
11200 
11201 /* Common CLI fields for vf vlan insert enable disable */
11202 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11203 	TOKEN_STRING_INITIALIZER
11204 		(struct cmd_vf_vlan_insert_result,
11205 		 set, "set");
11206 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11207 	TOKEN_STRING_INITIALIZER
11208 		(struct cmd_vf_vlan_insert_result,
11209 		 vf, "vf");
11210 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11211 	TOKEN_STRING_INITIALIZER
11212 		(struct cmd_vf_vlan_insert_result,
11213 		 vlan, "vlan");
11214 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11215 	TOKEN_STRING_INITIALIZER
11216 		(struct cmd_vf_vlan_insert_result,
11217 		 insert, "insert");
11218 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11219 	TOKEN_NUM_INITIALIZER
11220 		(struct cmd_vf_vlan_insert_result,
11221 		 port_id, RTE_UINT16);
11222 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11223 	TOKEN_NUM_INITIALIZER
11224 		(struct cmd_vf_vlan_insert_result,
11225 		 vf_id, RTE_UINT16);
11226 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11227 	TOKEN_NUM_INITIALIZER
11228 		(struct cmd_vf_vlan_insert_result,
11229 		 vlan_id, RTE_UINT16);
11230 
11231 static void
11232 cmd_set_vf_vlan_insert_parsed(
11233 	void *parsed_result,
11234 	__rte_unused struct cmdline *cl,
11235 	__rte_unused void *data)
11236 {
11237 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11238 	int ret = -ENOTSUP;
11239 
11240 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11241 		return;
11242 
11243 #ifdef RTE_NET_IXGBE
11244 	if (ret == -ENOTSUP)
11245 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11246 			res->vlan_id);
11247 #endif
11248 #ifdef RTE_NET_I40E
11249 	if (ret == -ENOTSUP)
11250 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11251 			res->vlan_id);
11252 #endif
11253 #ifdef RTE_NET_BNXT
11254 	if (ret == -ENOTSUP)
11255 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11256 			res->vlan_id);
11257 #endif
11258 
11259 	switch (ret) {
11260 	case 0:
11261 		break;
11262 	case -EINVAL:
11263 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11264 		break;
11265 	case -ENODEV:
11266 		printf("invalid port_id %d\n", res->port_id);
11267 		break;
11268 	case -ENOTSUP:
11269 		printf("function not implemented\n");
11270 		break;
11271 	default:
11272 		printf("programming error: (%s)\n", strerror(-ret));
11273 	}
11274 }
11275 
11276 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11277 	.f = cmd_set_vf_vlan_insert_parsed,
11278 	.data = NULL,
11279 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11280 	.tokens = {
11281 		(void *)&cmd_vf_vlan_insert_set,
11282 		(void *)&cmd_vf_vlan_insert_vf,
11283 		(void *)&cmd_vf_vlan_insert_vlan,
11284 		(void *)&cmd_vf_vlan_insert_insert,
11285 		(void *)&cmd_vf_vlan_insert_port_id,
11286 		(void *)&cmd_vf_vlan_insert_vf_id,
11287 		(void *)&cmd_vf_vlan_insert_vlan_id,
11288 		NULL,
11289 	},
11290 };
11291 
11292 /* tx loopback configuration */
11293 
11294 /* Common result structure for tx loopback */
11295 struct cmd_tx_loopback_result {
11296 	cmdline_fixed_string_t set;
11297 	cmdline_fixed_string_t tx;
11298 	cmdline_fixed_string_t loopback;
11299 	portid_t port_id;
11300 	cmdline_fixed_string_t on_off;
11301 };
11302 
11303 /* Common CLI fields for tx loopback enable disable */
11304 cmdline_parse_token_string_t cmd_tx_loopback_set =
11305 	TOKEN_STRING_INITIALIZER
11306 		(struct cmd_tx_loopback_result,
11307 		 set, "set");
11308 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11309 	TOKEN_STRING_INITIALIZER
11310 		(struct cmd_tx_loopback_result,
11311 		 tx, "tx");
11312 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11313 	TOKEN_STRING_INITIALIZER
11314 		(struct cmd_tx_loopback_result,
11315 		 loopback, "loopback");
11316 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11317 	TOKEN_NUM_INITIALIZER
11318 		(struct cmd_tx_loopback_result,
11319 		 port_id, RTE_UINT16);
11320 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11321 	TOKEN_STRING_INITIALIZER
11322 		(struct cmd_tx_loopback_result,
11323 		 on_off, "on#off");
11324 
11325 static void
11326 cmd_set_tx_loopback_parsed(
11327 	void *parsed_result,
11328 	__rte_unused struct cmdline *cl,
11329 	__rte_unused void *data)
11330 {
11331 	struct cmd_tx_loopback_result *res = parsed_result;
11332 	int ret = -ENOTSUP;
11333 
11334 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11335 
11336 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11337 		return;
11338 
11339 #ifdef RTE_NET_IXGBE
11340 	if (ret == -ENOTSUP)
11341 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11342 #endif
11343 #ifdef RTE_NET_I40E
11344 	if (ret == -ENOTSUP)
11345 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11346 #endif
11347 #ifdef RTE_NET_BNXT
11348 	if (ret == -ENOTSUP)
11349 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11350 #endif
11351 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11352 	if (ret == -ENOTSUP)
11353 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11354 #endif
11355 
11356 	switch (ret) {
11357 	case 0:
11358 		break;
11359 	case -EINVAL:
11360 		printf("invalid is_on %d\n", is_on);
11361 		break;
11362 	case -ENODEV:
11363 		printf("invalid port_id %d\n", res->port_id);
11364 		break;
11365 	case -ENOTSUP:
11366 		printf("function not implemented\n");
11367 		break;
11368 	default:
11369 		printf("programming error: (%s)\n", strerror(-ret));
11370 	}
11371 }
11372 
11373 cmdline_parse_inst_t cmd_set_tx_loopback = {
11374 	.f = cmd_set_tx_loopback_parsed,
11375 	.data = NULL,
11376 	.help_str = "set tx loopback <port_id> on|off",
11377 	.tokens = {
11378 		(void *)&cmd_tx_loopback_set,
11379 		(void *)&cmd_tx_loopback_tx,
11380 		(void *)&cmd_tx_loopback_loopback,
11381 		(void *)&cmd_tx_loopback_port_id,
11382 		(void *)&cmd_tx_loopback_on_off,
11383 		NULL,
11384 	},
11385 };
11386 
11387 /* all queues drop enable configuration */
11388 
11389 /* Common result structure for all queues drop enable */
11390 struct cmd_all_queues_drop_en_result {
11391 	cmdline_fixed_string_t set;
11392 	cmdline_fixed_string_t all;
11393 	cmdline_fixed_string_t queues;
11394 	cmdline_fixed_string_t drop;
11395 	portid_t port_id;
11396 	cmdline_fixed_string_t on_off;
11397 };
11398 
11399 /* Common CLI fields for tx loopback enable disable */
11400 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11401 	TOKEN_STRING_INITIALIZER
11402 		(struct cmd_all_queues_drop_en_result,
11403 		 set, "set");
11404 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11405 	TOKEN_STRING_INITIALIZER
11406 		(struct cmd_all_queues_drop_en_result,
11407 		 all, "all");
11408 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11409 	TOKEN_STRING_INITIALIZER
11410 		(struct cmd_all_queues_drop_en_result,
11411 		 queues, "queues");
11412 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11413 	TOKEN_STRING_INITIALIZER
11414 		(struct cmd_all_queues_drop_en_result,
11415 		 drop, "drop");
11416 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11417 	TOKEN_NUM_INITIALIZER
11418 		(struct cmd_all_queues_drop_en_result,
11419 		 port_id, RTE_UINT16);
11420 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11421 	TOKEN_STRING_INITIALIZER
11422 		(struct cmd_all_queues_drop_en_result,
11423 		 on_off, "on#off");
11424 
11425 static void
11426 cmd_set_all_queues_drop_en_parsed(
11427 	void *parsed_result,
11428 	__rte_unused struct cmdline *cl,
11429 	__rte_unused void *data)
11430 {
11431 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11432 	int ret = -ENOTSUP;
11433 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11434 
11435 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11436 		return;
11437 
11438 #ifdef RTE_NET_IXGBE
11439 	if (ret == -ENOTSUP)
11440 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11441 #endif
11442 #ifdef RTE_NET_BNXT
11443 	if (ret == -ENOTSUP)
11444 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11445 #endif
11446 	switch (ret) {
11447 	case 0:
11448 		break;
11449 	case -EINVAL:
11450 		printf("invalid is_on %d\n", is_on);
11451 		break;
11452 	case -ENODEV:
11453 		printf("invalid port_id %d\n", res->port_id);
11454 		break;
11455 	case -ENOTSUP:
11456 		printf("function not implemented\n");
11457 		break;
11458 	default:
11459 		printf("programming error: (%s)\n", strerror(-ret));
11460 	}
11461 }
11462 
11463 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11464 	.f = cmd_set_all_queues_drop_en_parsed,
11465 	.data = NULL,
11466 	.help_str = "set all queues drop <port_id> on|off",
11467 	.tokens = {
11468 		(void *)&cmd_all_queues_drop_en_set,
11469 		(void *)&cmd_all_queues_drop_en_all,
11470 		(void *)&cmd_all_queues_drop_en_queues,
11471 		(void *)&cmd_all_queues_drop_en_drop,
11472 		(void *)&cmd_all_queues_drop_en_port_id,
11473 		(void *)&cmd_all_queues_drop_en_on_off,
11474 		NULL,
11475 	},
11476 };
11477 
11478 /* vf split drop enable configuration */
11479 
11480 /* Common result structure for vf split drop enable */
11481 struct cmd_vf_split_drop_en_result {
11482 	cmdline_fixed_string_t set;
11483 	cmdline_fixed_string_t vf;
11484 	cmdline_fixed_string_t split;
11485 	cmdline_fixed_string_t drop;
11486 	portid_t port_id;
11487 	uint16_t vf_id;
11488 	cmdline_fixed_string_t on_off;
11489 };
11490 
11491 /* Common CLI fields for vf split drop enable disable */
11492 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11493 	TOKEN_STRING_INITIALIZER
11494 		(struct cmd_vf_split_drop_en_result,
11495 		 set, "set");
11496 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11497 	TOKEN_STRING_INITIALIZER
11498 		(struct cmd_vf_split_drop_en_result,
11499 		 vf, "vf");
11500 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11501 	TOKEN_STRING_INITIALIZER
11502 		(struct cmd_vf_split_drop_en_result,
11503 		 split, "split");
11504 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11505 	TOKEN_STRING_INITIALIZER
11506 		(struct cmd_vf_split_drop_en_result,
11507 		 drop, "drop");
11508 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11509 	TOKEN_NUM_INITIALIZER
11510 		(struct cmd_vf_split_drop_en_result,
11511 		 port_id, RTE_UINT16);
11512 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11513 	TOKEN_NUM_INITIALIZER
11514 		(struct cmd_vf_split_drop_en_result,
11515 		 vf_id, RTE_UINT16);
11516 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11517 	TOKEN_STRING_INITIALIZER
11518 		(struct cmd_vf_split_drop_en_result,
11519 		 on_off, "on#off");
11520 
11521 static void
11522 cmd_set_vf_split_drop_en_parsed(
11523 	void *parsed_result,
11524 	__rte_unused struct cmdline *cl,
11525 	__rte_unused void *data)
11526 {
11527 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11528 	int ret = -ENOTSUP;
11529 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11530 
11531 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11532 		return;
11533 
11534 #ifdef RTE_NET_IXGBE
11535 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11536 			is_on);
11537 #endif
11538 	switch (ret) {
11539 	case 0:
11540 		break;
11541 	case -EINVAL:
11542 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11543 		break;
11544 	case -ENODEV:
11545 		printf("invalid port_id %d\n", res->port_id);
11546 		break;
11547 	case -ENOTSUP:
11548 		printf("not supported on port %d\n", res->port_id);
11549 		break;
11550 	default:
11551 		printf("programming error: (%s)\n", strerror(-ret));
11552 	}
11553 }
11554 
11555 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11556 	.f = cmd_set_vf_split_drop_en_parsed,
11557 	.data = NULL,
11558 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11559 	.tokens = {
11560 		(void *)&cmd_vf_split_drop_en_set,
11561 		(void *)&cmd_vf_split_drop_en_vf,
11562 		(void *)&cmd_vf_split_drop_en_split,
11563 		(void *)&cmd_vf_split_drop_en_drop,
11564 		(void *)&cmd_vf_split_drop_en_port_id,
11565 		(void *)&cmd_vf_split_drop_en_vf_id,
11566 		(void *)&cmd_vf_split_drop_en_on_off,
11567 		NULL,
11568 	},
11569 };
11570 
11571 /* vf mac address configuration */
11572 
11573 /* Common result structure for vf mac address */
11574 struct cmd_set_vf_mac_addr_result {
11575 	cmdline_fixed_string_t set;
11576 	cmdline_fixed_string_t vf;
11577 	cmdline_fixed_string_t mac;
11578 	cmdline_fixed_string_t addr;
11579 	portid_t port_id;
11580 	uint16_t vf_id;
11581 	struct rte_ether_addr mac_addr;
11582 
11583 };
11584 
11585 /* Common CLI fields for vf split drop enable disable */
11586 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11587 	TOKEN_STRING_INITIALIZER
11588 		(struct cmd_set_vf_mac_addr_result,
11589 		 set, "set");
11590 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11591 	TOKEN_STRING_INITIALIZER
11592 		(struct cmd_set_vf_mac_addr_result,
11593 		 vf, "vf");
11594 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11595 	TOKEN_STRING_INITIALIZER
11596 		(struct cmd_set_vf_mac_addr_result,
11597 		 mac, "mac");
11598 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11599 	TOKEN_STRING_INITIALIZER
11600 		(struct cmd_set_vf_mac_addr_result,
11601 		 addr, "addr");
11602 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11603 	TOKEN_NUM_INITIALIZER
11604 		(struct cmd_set_vf_mac_addr_result,
11605 		 port_id, RTE_UINT16);
11606 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11607 	TOKEN_NUM_INITIALIZER
11608 		(struct cmd_set_vf_mac_addr_result,
11609 		 vf_id, RTE_UINT16);
11610 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11611 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11612 		 mac_addr);
11613 
11614 static void
11615 cmd_set_vf_mac_addr_parsed(
11616 	void *parsed_result,
11617 	__rte_unused struct cmdline *cl,
11618 	__rte_unused void *data)
11619 {
11620 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11621 	int ret = -ENOTSUP;
11622 
11623 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11624 		return;
11625 
11626 #ifdef RTE_NET_IXGBE
11627 	if (ret == -ENOTSUP)
11628 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11629 				&res->mac_addr);
11630 #endif
11631 #ifdef RTE_NET_I40E
11632 	if (ret == -ENOTSUP)
11633 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11634 				&res->mac_addr);
11635 #endif
11636 #ifdef RTE_NET_BNXT
11637 	if (ret == -ENOTSUP)
11638 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11639 				&res->mac_addr);
11640 #endif
11641 
11642 	switch (ret) {
11643 	case 0:
11644 		break;
11645 	case -EINVAL:
11646 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11647 		break;
11648 	case -ENODEV:
11649 		printf("invalid port_id %d\n", res->port_id);
11650 		break;
11651 	case -ENOTSUP:
11652 		printf("function not implemented\n");
11653 		break;
11654 	default:
11655 		printf("programming error: (%s)\n", strerror(-ret));
11656 	}
11657 }
11658 
11659 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11660 	.f = cmd_set_vf_mac_addr_parsed,
11661 	.data = NULL,
11662 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11663 	.tokens = {
11664 		(void *)&cmd_set_vf_mac_addr_set,
11665 		(void *)&cmd_set_vf_mac_addr_vf,
11666 		(void *)&cmd_set_vf_mac_addr_mac,
11667 		(void *)&cmd_set_vf_mac_addr_addr,
11668 		(void *)&cmd_set_vf_mac_addr_port_id,
11669 		(void *)&cmd_set_vf_mac_addr_vf_id,
11670 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11671 		NULL,
11672 	},
11673 };
11674 
11675 /* MACsec configuration */
11676 
11677 /* Common result structure for MACsec offload enable */
11678 struct cmd_macsec_offload_on_result {
11679 	cmdline_fixed_string_t set;
11680 	cmdline_fixed_string_t macsec;
11681 	cmdline_fixed_string_t offload;
11682 	portid_t port_id;
11683 	cmdline_fixed_string_t on;
11684 	cmdline_fixed_string_t encrypt;
11685 	cmdline_fixed_string_t en_on_off;
11686 	cmdline_fixed_string_t replay_protect;
11687 	cmdline_fixed_string_t rp_on_off;
11688 };
11689 
11690 /* Common CLI fields for MACsec offload disable */
11691 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11692 	TOKEN_STRING_INITIALIZER
11693 		(struct cmd_macsec_offload_on_result,
11694 		 set, "set");
11695 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11696 	TOKEN_STRING_INITIALIZER
11697 		(struct cmd_macsec_offload_on_result,
11698 		 macsec, "macsec");
11699 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11700 	TOKEN_STRING_INITIALIZER
11701 		(struct cmd_macsec_offload_on_result,
11702 		 offload, "offload");
11703 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11704 	TOKEN_NUM_INITIALIZER
11705 		(struct cmd_macsec_offload_on_result,
11706 		 port_id, RTE_UINT16);
11707 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11708 	TOKEN_STRING_INITIALIZER
11709 		(struct cmd_macsec_offload_on_result,
11710 		 on, "on");
11711 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11712 	TOKEN_STRING_INITIALIZER
11713 		(struct cmd_macsec_offload_on_result,
11714 		 encrypt, "encrypt");
11715 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11716 	TOKEN_STRING_INITIALIZER
11717 		(struct cmd_macsec_offload_on_result,
11718 		 en_on_off, "on#off");
11719 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11720 	TOKEN_STRING_INITIALIZER
11721 		(struct cmd_macsec_offload_on_result,
11722 		 replay_protect, "replay-protect");
11723 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11724 	TOKEN_STRING_INITIALIZER
11725 		(struct cmd_macsec_offload_on_result,
11726 		 rp_on_off, "on#off");
11727 
11728 static void
11729 cmd_set_macsec_offload_on_parsed(
11730 	void *parsed_result,
11731 	__rte_unused struct cmdline *cl,
11732 	__rte_unused void *data)
11733 {
11734 	struct cmd_macsec_offload_on_result *res = parsed_result;
11735 	int ret = -ENOTSUP;
11736 	portid_t port_id = res->port_id;
11737 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11738 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11739 	struct rte_eth_dev_info dev_info;
11740 
11741 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11742 		return;
11743 	if (!port_is_stopped(port_id)) {
11744 		printf("Please stop port %d first\n", port_id);
11745 		return;
11746 	}
11747 
11748 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11749 	if (ret != 0)
11750 		return;
11751 
11752 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11753 #ifdef RTE_NET_IXGBE
11754 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11755 #endif
11756 	}
11757 	RTE_SET_USED(en);
11758 	RTE_SET_USED(rp);
11759 
11760 	switch (ret) {
11761 	case 0:
11762 		ports[port_id].dev_conf.txmode.offloads |=
11763 						DEV_TX_OFFLOAD_MACSEC_INSERT;
11764 		cmd_reconfig_device_queue(port_id, 1, 1);
11765 		break;
11766 	case -ENODEV:
11767 		printf("invalid port_id %d\n", port_id);
11768 		break;
11769 	case -ENOTSUP:
11770 		printf("not supported on port %d\n", port_id);
11771 		break;
11772 	default:
11773 		printf("programming error: (%s)\n", strerror(-ret));
11774 	}
11775 }
11776 
11777 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11778 	.f = cmd_set_macsec_offload_on_parsed,
11779 	.data = NULL,
11780 	.help_str = "set macsec offload <port_id> on "
11781 		"encrypt on|off replay-protect on|off",
11782 	.tokens = {
11783 		(void *)&cmd_macsec_offload_on_set,
11784 		(void *)&cmd_macsec_offload_on_macsec,
11785 		(void *)&cmd_macsec_offload_on_offload,
11786 		(void *)&cmd_macsec_offload_on_port_id,
11787 		(void *)&cmd_macsec_offload_on_on,
11788 		(void *)&cmd_macsec_offload_on_encrypt,
11789 		(void *)&cmd_macsec_offload_on_en_on_off,
11790 		(void *)&cmd_macsec_offload_on_replay_protect,
11791 		(void *)&cmd_macsec_offload_on_rp_on_off,
11792 		NULL,
11793 	},
11794 };
11795 
11796 /* Common result structure for MACsec offload disable */
11797 struct cmd_macsec_offload_off_result {
11798 	cmdline_fixed_string_t set;
11799 	cmdline_fixed_string_t macsec;
11800 	cmdline_fixed_string_t offload;
11801 	portid_t port_id;
11802 	cmdline_fixed_string_t off;
11803 };
11804 
11805 /* Common CLI fields for MACsec offload disable */
11806 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11807 	TOKEN_STRING_INITIALIZER
11808 		(struct cmd_macsec_offload_off_result,
11809 		 set, "set");
11810 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11811 	TOKEN_STRING_INITIALIZER
11812 		(struct cmd_macsec_offload_off_result,
11813 		 macsec, "macsec");
11814 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11815 	TOKEN_STRING_INITIALIZER
11816 		(struct cmd_macsec_offload_off_result,
11817 		 offload, "offload");
11818 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11819 	TOKEN_NUM_INITIALIZER
11820 		(struct cmd_macsec_offload_off_result,
11821 		 port_id, RTE_UINT16);
11822 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11823 	TOKEN_STRING_INITIALIZER
11824 		(struct cmd_macsec_offload_off_result,
11825 		 off, "off");
11826 
11827 static void
11828 cmd_set_macsec_offload_off_parsed(
11829 	void *parsed_result,
11830 	__rte_unused struct cmdline *cl,
11831 	__rte_unused void *data)
11832 {
11833 	struct cmd_macsec_offload_off_result *res = parsed_result;
11834 	int ret = -ENOTSUP;
11835 	struct rte_eth_dev_info dev_info;
11836 	portid_t port_id = res->port_id;
11837 
11838 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11839 		return;
11840 	if (!port_is_stopped(port_id)) {
11841 		printf("Please stop port %d first\n", port_id);
11842 		return;
11843 	}
11844 
11845 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11846 	if (ret != 0)
11847 		return;
11848 
11849 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11850 #ifdef RTE_NET_IXGBE
11851 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
11852 #endif
11853 	}
11854 	switch (ret) {
11855 	case 0:
11856 		ports[port_id].dev_conf.txmode.offloads &=
11857 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
11858 		cmd_reconfig_device_queue(port_id, 1, 1);
11859 		break;
11860 	case -ENODEV:
11861 		printf("invalid port_id %d\n", port_id);
11862 		break;
11863 	case -ENOTSUP:
11864 		printf("not supported on port %d\n", port_id);
11865 		break;
11866 	default:
11867 		printf("programming error: (%s)\n", strerror(-ret));
11868 	}
11869 }
11870 
11871 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11872 	.f = cmd_set_macsec_offload_off_parsed,
11873 	.data = NULL,
11874 	.help_str = "set macsec offload <port_id> off",
11875 	.tokens = {
11876 		(void *)&cmd_macsec_offload_off_set,
11877 		(void *)&cmd_macsec_offload_off_macsec,
11878 		(void *)&cmd_macsec_offload_off_offload,
11879 		(void *)&cmd_macsec_offload_off_port_id,
11880 		(void *)&cmd_macsec_offload_off_off,
11881 		NULL,
11882 	},
11883 };
11884 
11885 /* Common result structure for MACsec secure connection configure */
11886 struct cmd_macsec_sc_result {
11887 	cmdline_fixed_string_t set;
11888 	cmdline_fixed_string_t macsec;
11889 	cmdline_fixed_string_t sc;
11890 	cmdline_fixed_string_t tx_rx;
11891 	portid_t port_id;
11892 	struct rte_ether_addr mac;
11893 	uint16_t pi;
11894 };
11895 
11896 /* Common CLI fields for MACsec secure connection configure */
11897 cmdline_parse_token_string_t cmd_macsec_sc_set =
11898 	TOKEN_STRING_INITIALIZER
11899 		(struct cmd_macsec_sc_result,
11900 		 set, "set");
11901 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11902 	TOKEN_STRING_INITIALIZER
11903 		(struct cmd_macsec_sc_result,
11904 		 macsec, "macsec");
11905 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11906 	TOKEN_STRING_INITIALIZER
11907 		(struct cmd_macsec_sc_result,
11908 		 sc, "sc");
11909 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11910 	TOKEN_STRING_INITIALIZER
11911 		(struct cmd_macsec_sc_result,
11912 		 tx_rx, "tx#rx");
11913 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11914 	TOKEN_NUM_INITIALIZER
11915 		(struct cmd_macsec_sc_result,
11916 		 port_id, RTE_UINT16);
11917 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11918 	TOKEN_ETHERADDR_INITIALIZER
11919 		(struct cmd_macsec_sc_result,
11920 		 mac);
11921 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11922 	TOKEN_NUM_INITIALIZER
11923 		(struct cmd_macsec_sc_result,
11924 		 pi, RTE_UINT16);
11925 
11926 static void
11927 cmd_set_macsec_sc_parsed(
11928 	void *parsed_result,
11929 	__rte_unused struct cmdline *cl,
11930 	__rte_unused void *data)
11931 {
11932 	struct cmd_macsec_sc_result *res = parsed_result;
11933 	int ret = -ENOTSUP;
11934 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11935 
11936 #ifdef RTE_NET_IXGBE
11937 	ret = is_tx ?
11938 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11939 				res->mac.addr_bytes) :
11940 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11941 				res->mac.addr_bytes, res->pi);
11942 #endif
11943 	RTE_SET_USED(is_tx);
11944 
11945 	switch (ret) {
11946 	case 0:
11947 		break;
11948 	case -ENODEV:
11949 		printf("invalid port_id %d\n", res->port_id);
11950 		break;
11951 	case -ENOTSUP:
11952 		printf("not supported on port %d\n", res->port_id);
11953 		break;
11954 	default:
11955 		printf("programming error: (%s)\n", strerror(-ret));
11956 	}
11957 }
11958 
11959 cmdline_parse_inst_t cmd_set_macsec_sc = {
11960 	.f = cmd_set_macsec_sc_parsed,
11961 	.data = NULL,
11962 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11963 	.tokens = {
11964 		(void *)&cmd_macsec_sc_set,
11965 		(void *)&cmd_macsec_sc_macsec,
11966 		(void *)&cmd_macsec_sc_sc,
11967 		(void *)&cmd_macsec_sc_tx_rx,
11968 		(void *)&cmd_macsec_sc_port_id,
11969 		(void *)&cmd_macsec_sc_mac,
11970 		(void *)&cmd_macsec_sc_pi,
11971 		NULL,
11972 	},
11973 };
11974 
11975 /* Common result structure for MACsec secure connection configure */
11976 struct cmd_macsec_sa_result {
11977 	cmdline_fixed_string_t set;
11978 	cmdline_fixed_string_t macsec;
11979 	cmdline_fixed_string_t sa;
11980 	cmdline_fixed_string_t tx_rx;
11981 	portid_t port_id;
11982 	uint8_t idx;
11983 	uint8_t an;
11984 	uint32_t pn;
11985 	cmdline_fixed_string_t key;
11986 };
11987 
11988 /* Common CLI fields for MACsec secure connection configure */
11989 cmdline_parse_token_string_t cmd_macsec_sa_set =
11990 	TOKEN_STRING_INITIALIZER
11991 		(struct cmd_macsec_sa_result,
11992 		 set, "set");
11993 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11994 	TOKEN_STRING_INITIALIZER
11995 		(struct cmd_macsec_sa_result,
11996 		 macsec, "macsec");
11997 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11998 	TOKEN_STRING_INITIALIZER
11999 		(struct cmd_macsec_sa_result,
12000 		 sa, "sa");
12001 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12002 	TOKEN_STRING_INITIALIZER
12003 		(struct cmd_macsec_sa_result,
12004 		 tx_rx, "tx#rx");
12005 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12006 	TOKEN_NUM_INITIALIZER
12007 		(struct cmd_macsec_sa_result,
12008 		 port_id, RTE_UINT16);
12009 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12010 	TOKEN_NUM_INITIALIZER
12011 		(struct cmd_macsec_sa_result,
12012 		 idx, RTE_UINT8);
12013 cmdline_parse_token_num_t cmd_macsec_sa_an =
12014 	TOKEN_NUM_INITIALIZER
12015 		(struct cmd_macsec_sa_result,
12016 		 an, RTE_UINT8);
12017 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12018 	TOKEN_NUM_INITIALIZER
12019 		(struct cmd_macsec_sa_result,
12020 		 pn, RTE_UINT32);
12021 cmdline_parse_token_string_t cmd_macsec_sa_key =
12022 	TOKEN_STRING_INITIALIZER
12023 		(struct cmd_macsec_sa_result,
12024 		 key, NULL);
12025 
12026 static void
12027 cmd_set_macsec_sa_parsed(
12028 	void *parsed_result,
12029 	__rte_unused struct cmdline *cl,
12030 	__rte_unused void *data)
12031 {
12032 	struct cmd_macsec_sa_result *res = parsed_result;
12033 	int ret = -ENOTSUP;
12034 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12035 	uint8_t key[16] = { 0 };
12036 	uint8_t xdgt0;
12037 	uint8_t xdgt1;
12038 	int key_len;
12039 	int i;
12040 
12041 	key_len = strlen(res->key) / 2;
12042 	if (key_len > 16)
12043 		key_len = 16;
12044 
12045 	for (i = 0; i < key_len; i++) {
12046 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12047 		if (xdgt0 == 0xFF)
12048 			return;
12049 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12050 		if (xdgt1 == 0xFF)
12051 			return;
12052 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12053 	}
12054 
12055 #ifdef RTE_NET_IXGBE
12056 	ret = is_tx ?
12057 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12058 			res->idx, res->an, res->pn, key) :
12059 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12060 			res->idx, res->an, res->pn, key);
12061 #endif
12062 	RTE_SET_USED(is_tx);
12063 	RTE_SET_USED(key);
12064 
12065 	switch (ret) {
12066 	case 0:
12067 		break;
12068 	case -EINVAL:
12069 		printf("invalid idx %d or an %d\n", res->idx, res->an);
12070 		break;
12071 	case -ENODEV:
12072 		printf("invalid port_id %d\n", res->port_id);
12073 		break;
12074 	case -ENOTSUP:
12075 		printf("not supported on port %d\n", res->port_id);
12076 		break;
12077 	default:
12078 		printf("programming error: (%s)\n", strerror(-ret));
12079 	}
12080 }
12081 
12082 cmdline_parse_inst_t cmd_set_macsec_sa = {
12083 	.f = cmd_set_macsec_sa_parsed,
12084 	.data = NULL,
12085 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12086 	.tokens = {
12087 		(void *)&cmd_macsec_sa_set,
12088 		(void *)&cmd_macsec_sa_macsec,
12089 		(void *)&cmd_macsec_sa_sa,
12090 		(void *)&cmd_macsec_sa_tx_rx,
12091 		(void *)&cmd_macsec_sa_port_id,
12092 		(void *)&cmd_macsec_sa_idx,
12093 		(void *)&cmd_macsec_sa_an,
12094 		(void *)&cmd_macsec_sa_pn,
12095 		(void *)&cmd_macsec_sa_key,
12096 		NULL,
12097 	},
12098 };
12099 
12100 /* VF unicast promiscuous mode configuration */
12101 
12102 /* Common result structure for VF unicast promiscuous mode */
12103 struct cmd_vf_promisc_result {
12104 	cmdline_fixed_string_t set;
12105 	cmdline_fixed_string_t vf;
12106 	cmdline_fixed_string_t promisc;
12107 	portid_t port_id;
12108 	uint32_t vf_id;
12109 	cmdline_fixed_string_t on_off;
12110 };
12111 
12112 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12113 cmdline_parse_token_string_t cmd_vf_promisc_set =
12114 	TOKEN_STRING_INITIALIZER
12115 		(struct cmd_vf_promisc_result,
12116 		 set, "set");
12117 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12118 	TOKEN_STRING_INITIALIZER
12119 		(struct cmd_vf_promisc_result,
12120 		 vf, "vf");
12121 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12122 	TOKEN_STRING_INITIALIZER
12123 		(struct cmd_vf_promisc_result,
12124 		 promisc, "promisc");
12125 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12126 	TOKEN_NUM_INITIALIZER
12127 		(struct cmd_vf_promisc_result,
12128 		 port_id, RTE_UINT16);
12129 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12130 	TOKEN_NUM_INITIALIZER
12131 		(struct cmd_vf_promisc_result,
12132 		 vf_id, RTE_UINT32);
12133 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12134 	TOKEN_STRING_INITIALIZER
12135 		(struct cmd_vf_promisc_result,
12136 		 on_off, "on#off");
12137 
12138 static void
12139 cmd_set_vf_promisc_parsed(
12140 	void *parsed_result,
12141 	__rte_unused struct cmdline *cl,
12142 	__rte_unused void *data)
12143 {
12144 	struct cmd_vf_promisc_result *res = parsed_result;
12145 	int ret = -ENOTSUP;
12146 
12147 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12148 
12149 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12150 		return;
12151 
12152 #ifdef RTE_NET_I40E
12153 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12154 						  res->vf_id, is_on);
12155 #endif
12156 
12157 	switch (ret) {
12158 	case 0:
12159 		break;
12160 	case -EINVAL:
12161 		printf("invalid vf_id %d\n", res->vf_id);
12162 		break;
12163 	case -ENODEV:
12164 		printf("invalid port_id %d\n", res->port_id);
12165 		break;
12166 	case -ENOTSUP:
12167 		printf("function not implemented\n");
12168 		break;
12169 	default:
12170 		printf("programming error: (%s)\n", strerror(-ret));
12171 	}
12172 }
12173 
12174 cmdline_parse_inst_t cmd_set_vf_promisc = {
12175 	.f = cmd_set_vf_promisc_parsed,
12176 	.data = NULL,
12177 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
12178 		"Set unicast promiscuous mode for a VF from the PF",
12179 	.tokens = {
12180 		(void *)&cmd_vf_promisc_set,
12181 		(void *)&cmd_vf_promisc_vf,
12182 		(void *)&cmd_vf_promisc_promisc,
12183 		(void *)&cmd_vf_promisc_port_id,
12184 		(void *)&cmd_vf_promisc_vf_id,
12185 		(void *)&cmd_vf_promisc_on_off,
12186 		NULL,
12187 	},
12188 };
12189 
12190 /* VF multicast promiscuous mode configuration */
12191 
12192 /* Common result structure for VF multicast promiscuous mode */
12193 struct cmd_vf_allmulti_result {
12194 	cmdline_fixed_string_t set;
12195 	cmdline_fixed_string_t vf;
12196 	cmdline_fixed_string_t allmulti;
12197 	portid_t port_id;
12198 	uint32_t vf_id;
12199 	cmdline_fixed_string_t on_off;
12200 };
12201 
12202 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12203 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12204 	TOKEN_STRING_INITIALIZER
12205 		(struct cmd_vf_allmulti_result,
12206 		 set, "set");
12207 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12208 	TOKEN_STRING_INITIALIZER
12209 		(struct cmd_vf_allmulti_result,
12210 		 vf, "vf");
12211 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12212 	TOKEN_STRING_INITIALIZER
12213 		(struct cmd_vf_allmulti_result,
12214 		 allmulti, "allmulti");
12215 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12216 	TOKEN_NUM_INITIALIZER
12217 		(struct cmd_vf_allmulti_result,
12218 		 port_id, RTE_UINT16);
12219 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12220 	TOKEN_NUM_INITIALIZER
12221 		(struct cmd_vf_allmulti_result,
12222 		 vf_id, RTE_UINT32);
12223 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12224 	TOKEN_STRING_INITIALIZER
12225 		(struct cmd_vf_allmulti_result,
12226 		 on_off, "on#off");
12227 
12228 static void
12229 cmd_set_vf_allmulti_parsed(
12230 	void *parsed_result,
12231 	__rte_unused struct cmdline *cl,
12232 	__rte_unused void *data)
12233 {
12234 	struct cmd_vf_allmulti_result *res = parsed_result;
12235 	int ret = -ENOTSUP;
12236 
12237 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12238 
12239 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12240 		return;
12241 
12242 #ifdef RTE_NET_I40E
12243 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12244 						    res->vf_id, is_on);
12245 #endif
12246 
12247 	switch (ret) {
12248 	case 0:
12249 		break;
12250 	case -EINVAL:
12251 		printf("invalid vf_id %d\n", res->vf_id);
12252 		break;
12253 	case -ENODEV:
12254 		printf("invalid port_id %d\n", res->port_id);
12255 		break;
12256 	case -ENOTSUP:
12257 		printf("function not implemented\n");
12258 		break;
12259 	default:
12260 		printf("programming error: (%s)\n", strerror(-ret));
12261 	}
12262 }
12263 
12264 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12265 	.f = cmd_set_vf_allmulti_parsed,
12266 	.data = NULL,
12267 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12268 		"Set multicast promiscuous mode for a VF from the PF",
12269 	.tokens = {
12270 		(void *)&cmd_vf_allmulti_set,
12271 		(void *)&cmd_vf_allmulti_vf,
12272 		(void *)&cmd_vf_allmulti_allmulti,
12273 		(void *)&cmd_vf_allmulti_port_id,
12274 		(void *)&cmd_vf_allmulti_vf_id,
12275 		(void *)&cmd_vf_allmulti_on_off,
12276 		NULL,
12277 	},
12278 };
12279 
12280 /* vf broadcast mode configuration */
12281 
12282 /* Common result structure for vf broadcast */
12283 struct cmd_set_vf_broadcast_result {
12284 	cmdline_fixed_string_t set;
12285 	cmdline_fixed_string_t vf;
12286 	cmdline_fixed_string_t broadcast;
12287 	portid_t port_id;
12288 	uint16_t vf_id;
12289 	cmdline_fixed_string_t on_off;
12290 };
12291 
12292 /* Common CLI fields for vf broadcast enable disable */
12293 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12294 	TOKEN_STRING_INITIALIZER
12295 		(struct cmd_set_vf_broadcast_result,
12296 		 set, "set");
12297 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12298 	TOKEN_STRING_INITIALIZER
12299 		(struct cmd_set_vf_broadcast_result,
12300 		 vf, "vf");
12301 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12302 	TOKEN_STRING_INITIALIZER
12303 		(struct cmd_set_vf_broadcast_result,
12304 		 broadcast, "broadcast");
12305 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12306 	TOKEN_NUM_INITIALIZER
12307 		(struct cmd_set_vf_broadcast_result,
12308 		 port_id, RTE_UINT16);
12309 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12310 	TOKEN_NUM_INITIALIZER
12311 		(struct cmd_set_vf_broadcast_result,
12312 		 vf_id, RTE_UINT16);
12313 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12314 	TOKEN_STRING_INITIALIZER
12315 		(struct cmd_set_vf_broadcast_result,
12316 		 on_off, "on#off");
12317 
12318 static void
12319 cmd_set_vf_broadcast_parsed(
12320 	void *parsed_result,
12321 	__rte_unused struct cmdline *cl,
12322 	__rte_unused void *data)
12323 {
12324 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12325 	int ret = -ENOTSUP;
12326 
12327 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12328 
12329 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12330 		return;
12331 
12332 #ifdef RTE_NET_I40E
12333 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12334 					    res->vf_id, is_on);
12335 #endif
12336 
12337 	switch (ret) {
12338 	case 0:
12339 		break;
12340 	case -EINVAL:
12341 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12342 		break;
12343 	case -ENODEV:
12344 		printf("invalid port_id %d\n", res->port_id);
12345 		break;
12346 	case -ENOTSUP:
12347 		printf("function not implemented\n");
12348 		break;
12349 	default:
12350 		printf("programming error: (%s)\n", strerror(-ret));
12351 	}
12352 }
12353 
12354 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12355 	.f = cmd_set_vf_broadcast_parsed,
12356 	.data = NULL,
12357 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12358 	.tokens = {
12359 		(void *)&cmd_set_vf_broadcast_set,
12360 		(void *)&cmd_set_vf_broadcast_vf,
12361 		(void *)&cmd_set_vf_broadcast_broadcast,
12362 		(void *)&cmd_set_vf_broadcast_port_id,
12363 		(void *)&cmd_set_vf_broadcast_vf_id,
12364 		(void *)&cmd_set_vf_broadcast_on_off,
12365 		NULL,
12366 	},
12367 };
12368 
12369 /* vf vlan tag configuration */
12370 
12371 /* Common result structure for vf vlan tag */
12372 struct cmd_set_vf_vlan_tag_result {
12373 	cmdline_fixed_string_t set;
12374 	cmdline_fixed_string_t vf;
12375 	cmdline_fixed_string_t vlan;
12376 	cmdline_fixed_string_t tag;
12377 	portid_t port_id;
12378 	uint16_t vf_id;
12379 	cmdline_fixed_string_t on_off;
12380 };
12381 
12382 /* Common CLI fields for vf vlan tag enable disable */
12383 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12384 	TOKEN_STRING_INITIALIZER
12385 		(struct cmd_set_vf_vlan_tag_result,
12386 		 set, "set");
12387 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12388 	TOKEN_STRING_INITIALIZER
12389 		(struct cmd_set_vf_vlan_tag_result,
12390 		 vf, "vf");
12391 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12392 	TOKEN_STRING_INITIALIZER
12393 		(struct cmd_set_vf_vlan_tag_result,
12394 		 vlan, "vlan");
12395 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12396 	TOKEN_STRING_INITIALIZER
12397 		(struct cmd_set_vf_vlan_tag_result,
12398 		 tag, "tag");
12399 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12400 	TOKEN_NUM_INITIALIZER
12401 		(struct cmd_set_vf_vlan_tag_result,
12402 		 port_id, RTE_UINT16);
12403 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12404 	TOKEN_NUM_INITIALIZER
12405 		(struct cmd_set_vf_vlan_tag_result,
12406 		 vf_id, RTE_UINT16);
12407 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12408 	TOKEN_STRING_INITIALIZER
12409 		(struct cmd_set_vf_vlan_tag_result,
12410 		 on_off, "on#off");
12411 
12412 static void
12413 cmd_set_vf_vlan_tag_parsed(
12414 	void *parsed_result,
12415 	__rte_unused struct cmdline *cl,
12416 	__rte_unused void *data)
12417 {
12418 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12419 	int ret = -ENOTSUP;
12420 
12421 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12422 
12423 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12424 		return;
12425 
12426 #ifdef RTE_NET_I40E
12427 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12428 					   res->vf_id, is_on);
12429 #endif
12430 
12431 	switch (ret) {
12432 	case 0:
12433 		break;
12434 	case -EINVAL:
12435 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12436 		break;
12437 	case -ENODEV:
12438 		printf("invalid port_id %d\n", res->port_id);
12439 		break;
12440 	case -ENOTSUP:
12441 		printf("function not implemented\n");
12442 		break;
12443 	default:
12444 		printf("programming error: (%s)\n", strerror(-ret));
12445 	}
12446 }
12447 
12448 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12449 	.f = cmd_set_vf_vlan_tag_parsed,
12450 	.data = NULL,
12451 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12452 	.tokens = {
12453 		(void *)&cmd_set_vf_vlan_tag_set,
12454 		(void *)&cmd_set_vf_vlan_tag_vf,
12455 		(void *)&cmd_set_vf_vlan_tag_vlan,
12456 		(void *)&cmd_set_vf_vlan_tag_tag,
12457 		(void *)&cmd_set_vf_vlan_tag_port_id,
12458 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12459 		(void *)&cmd_set_vf_vlan_tag_on_off,
12460 		NULL,
12461 	},
12462 };
12463 
12464 /* Common definition of VF and TC TX bandwidth configuration */
12465 struct cmd_vf_tc_bw_result {
12466 	cmdline_fixed_string_t set;
12467 	cmdline_fixed_string_t vf;
12468 	cmdline_fixed_string_t tc;
12469 	cmdline_fixed_string_t tx;
12470 	cmdline_fixed_string_t min_bw;
12471 	cmdline_fixed_string_t max_bw;
12472 	cmdline_fixed_string_t strict_link_prio;
12473 	portid_t port_id;
12474 	uint16_t vf_id;
12475 	uint8_t tc_no;
12476 	uint32_t bw;
12477 	cmdline_fixed_string_t bw_list;
12478 	uint8_t tc_map;
12479 };
12480 
12481 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12482 	TOKEN_STRING_INITIALIZER
12483 		(struct cmd_vf_tc_bw_result,
12484 		 set, "set");
12485 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12486 	TOKEN_STRING_INITIALIZER
12487 		(struct cmd_vf_tc_bw_result,
12488 		 vf, "vf");
12489 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12490 	TOKEN_STRING_INITIALIZER
12491 		(struct cmd_vf_tc_bw_result,
12492 		 tc, "tc");
12493 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12494 	TOKEN_STRING_INITIALIZER
12495 		(struct cmd_vf_tc_bw_result,
12496 		 tx, "tx");
12497 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12498 	TOKEN_STRING_INITIALIZER
12499 		(struct cmd_vf_tc_bw_result,
12500 		 strict_link_prio, "strict-link-priority");
12501 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12502 	TOKEN_STRING_INITIALIZER
12503 		(struct cmd_vf_tc_bw_result,
12504 		 min_bw, "min-bandwidth");
12505 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12506 	TOKEN_STRING_INITIALIZER
12507 		(struct cmd_vf_tc_bw_result,
12508 		 max_bw, "max-bandwidth");
12509 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12510 	TOKEN_NUM_INITIALIZER
12511 		(struct cmd_vf_tc_bw_result,
12512 		 port_id, RTE_UINT16);
12513 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12514 	TOKEN_NUM_INITIALIZER
12515 		(struct cmd_vf_tc_bw_result,
12516 		 vf_id, RTE_UINT16);
12517 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12518 	TOKEN_NUM_INITIALIZER
12519 		(struct cmd_vf_tc_bw_result,
12520 		 tc_no, RTE_UINT8);
12521 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12522 	TOKEN_NUM_INITIALIZER
12523 		(struct cmd_vf_tc_bw_result,
12524 		 bw, RTE_UINT32);
12525 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12526 	TOKEN_STRING_INITIALIZER
12527 		(struct cmd_vf_tc_bw_result,
12528 		 bw_list, NULL);
12529 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12530 	TOKEN_NUM_INITIALIZER
12531 		(struct cmd_vf_tc_bw_result,
12532 		 tc_map, RTE_UINT8);
12533 
12534 /* VF max bandwidth setting */
12535 static void
12536 cmd_vf_max_bw_parsed(
12537 	void *parsed_result,
12538 	__rte_unused struct cmdline *cl,
12539 	__rte_unused void *data)
12540 {
12541 	struct cmd_vf_tc_bw_result *res = parsed_result;
12542 	int ret = -ENOTSUP;
12543 
12544 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12545 		return;
12546 
12547 #ifdef RTE_NET_I40E
12548 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12549 					 res->vf_id, res->bw);
12550 #endif
12551 
12552 	switch (ret) {
12553 	case 0:
12554 		break;
12555 	case -EINVAL:
12556 		printf("invalid vf_id %d or bandwidth %d\n",
12557 		       res->vf_id, res->bw);
12558 		break;
12559 	case -ENODEV:
12560 		printf("invalid port_id %d\n", res->port_id);
12561 		break;
12562 	case -ENOTSUP:
12563 		printf("function not implemented\n");
12564 		break;
12565 	default:
12566 		printf("programming error: (%s)\n", strerror(-ret));
12567 	}
12568 }
12569 
12570 cmdline_parse_inst_t cmd_vf_max_bw = {
12571 	.f = cmd_vf_max_bw_parsed,
12572 	.data = NULL,
12573 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12574 	.tokens = {
12575 		(void *)&cmd_vf_tc_bw_set,
12576 		(void *)&cmd_vf_tc_bw_vf,
12577 		(void *)&cmd_vf_tc_bw_tx,
12578 		(void *)&cmd_vf_tc_bw_max_bw,
12579 		(void *)&cmd_vf_tc_bw_port_id,
12580 		(void *)&cmd_vf_tc_bw_vf_id,
12581 		(void *)&cmd_vf_tc_bw_bw,
12582 		NULL,
12583 	},
12584 };
12585 
12586 static int
12587 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12588 			   uint8_t *tc_num,
12589 			   char *str)
12590 {
12591 	uint32_t size;
12592 	const char *p, *p0 = str;
12593 	char s[256];
12594 	char *end;
12595 	char *str_fld[16];
12596 	uint16_t i;
12597 	int ret;
12598 
12599 	p = strchr(p0, '(');
12600 	if (p == NULL) {
12601 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12602 		return -1;
12603 	}
12604 	p++;
12605 	p0 = strchr(p, ')');
12606 	if (p0 == NULL) {
12607 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12608 		return -1;
12609 	}
12610 	size = p0 - p;
12611 	if (size >= sizeof(s)) {
12612 		printf("The string size exceeds the internal buffer size\n");
12613 		return -1;
12614 	}
12615 	snprintf(s, sizeof(s), "%.*s", size, p);
12616 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12617 	if (ret <= 0) {
12618 		printf("Failed to get the bandwidth list. ");
12619 		return -1;
12620 	}
12621 	*tc_num = ret;
12622 	for (i = 0; i < ret; i++)
12623 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12624 
12625 	return 0;
12626 }
12627 
12628 /* TC min bandwidth setting */
12629 static void
12630 cmd_vf_tc_min_bw_parsed(
12631 	void *parsed_result,
12632 	__rte_unused struct cmdline *cl,
12633 	__rte_unused void *data)
12634 {
12635 	struct cmd_vf_tc_bw_result *res = parsed_result;
12636 	uint8_t tc_num;
12637 	uint8_t bw[16];
12638 	int ret = -ENOTSUP;
12639 
12640 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12641 		return;
12642 
12643 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12644 	if (ret)
12645 		return;
12646 
12647 #ifdef RTE_NET_I40E
12648 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12649 					      tc_num, bw);
12650 #endif
12651 
12652 	switch (ret) {
12653 	case 0:
12654 		break;
12655 	case -EINVAL:
12656 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12657 		break;
12658 	case -ENODEV:
12659 		printf("invalid port_id %d\n", res->port_id);
12660 		break;
12661 	case -ENOTSUP:
12662 		printf("function not implemented\n");
12663 		break;
12664 	default:
12665 		printf("programming error: (%s)\n", strerror(-ret));
12666 	}
12667 }
12668 
12669 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12670 	.f = cmd_vf_tc_min_bw_parsed,
12671 	.data = NULL,
12672 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12673 		    " <bw1, bw2, ...>",
12674 	.tokens = {
12675 		(void *)&cmd_vf_tc_bw_set,
12676 		(void *)&cmd_vf_tc_bw_vf,
12677 		(void *)&cmd_vf_tc_bw_tc,
12678 		(void *)&cmd_vf_tc_bw_tx,
12679 		(void *)&cmd_vf_tc_bw_min_bw,
12680 		(void *)&cmd_vf_tc_bw_port_id,
12681 		(void *)&cmd_vf_tc_bw_vf_id,
12682 		(void *)&cmd_vf_tc_bw_bw_list,
12683 		NULL,
12684 	},
12685 };
12686 
12687 static void
12688 cmd_tc_min_bw_parsed(
12689 	void *parsed_result,
12690 	__rte_unused struct cmdline *cl,
12691 	__rte_unused void *data)
12692 {
12693 	struct cmd_vf_tc_bw_result *res = parsed_result;
12694 	struct rte_port *port;
12695 	uint8_t tc_num;
12696 	uint8_t bw[16];
12697 	int ret = -ENOTSUP;
12698 
12699 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12700 		return;
12701 
12702 	port = &ports[res->port_id];
12703 	/** Check if the port is not started **/
12704 	if (port->port_status != RTE_PORT_STOPPED) {
12705 		printf("Please stop port %d first\n", res->port_id);
12706 		return;
12707 	}
12708 
12709 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12710 	if (ret)
12711 		return;
12712 
12713 #ifdef RTE_NET_IXGBE
12714 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12715 #endif
12716 
12717 	switch (ret) {
12718 	case 0:
12719 		break;
12720 	case -EINVAL:
12721 		printf("invalid bandwidth\n");
12722 		break;
12723 	case -ENODEV:
12724 		printf("invalid port_id %d\n", res->port_id);
12725 		break;
12726 	case -ENOTSUP:
12727 		printf("function not implemented\n");
12728 		break;
12729 	default:
12730 		printf("programming error: (%s)\n", strerror(-ret));
12731 	}
12732 }
12733 
12734 cmdline_parse_inst_t cmd_tc_min_bw = {
12735 	.f = cmd_tc_min_bw_parsed,
12736 	.data = NULL,
12737 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12738 	.tokens = {
12739 		(void *)&cmd_vf_tc_bw_set,
12740 		(void *)&cmd_vf_tc_bw_tc,
12741 		(void *)&cmd_vf_tc_bw_tx,
12742 		(void *)&cmd_vf_tc_bw_min_bw,
12743 		(void *)&cmd_vf_tc_bw_port_id,
12744 		(void *)&cmd_vf_tc_bw_bw_list,
12745 		NULL,
12746 	},
12747 };
12748 
12749 /* TC max bandwidth setting */
12750 static void
12751 cmd_vf_tc_max_bw_parsed(
12752 	void *parsed_result,
12753 	__rte_unused struct cmdline *cl,
12754 	__rte_unused void *data)
12755 {
12756 	struct cmd_vf_tc_bw_result *res = parsed_result;
12757 	int ret = -ENOTSUP;
12758 
12759 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12760 		return;
12761 
12762 #ifdef RTE_NET_I40E
12763 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12764 					    res->tc_no, res->bw);
12765 #endif
12766 
12767 	switch (ret) {
12768 	case 0:
12769 		break;
12770 	case -EINVAL:
12771 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12772 		       res->vf_id, res->tc_no, res->bw);
12773 		break;
12774 	case -ENODEV:
12775 		printf("invalid port_id %d\n", res->port_id);
12776 		break;
12777 	case -ENOTSUP:
12778 		printf("function not implemented\n");
12779 		break;
12780 	default:
12781 		printf("programming error: (%s)\n", strerror(-ret));
12782 	}
12783 }
12784 
12785 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12786 	.f = cmd_vf_tc_max_bw_parsed,
12787 	.data = NULL,
12788 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12789 		    " <bandwidth>",
12790 	.tokens = {
12791 		(void *)&cmd_vf_tc_bw_set,
12792 		(void *)&cmd_vf_tc_bw_vf,
12793 		(void *)&cmd_vf_tc_bw_tc,
12794 		(void *)&cmd_vf_tc_bw_tx,
12795 		(void *)&cmd_vf_tc_bw_max_bw,
12796 		(void *)&cmd_vf_tc_bw_port_id,
12797 		(void *)&cmd_vf_tc_bw_vf_id,
12798 		(void *)&cmd_vf_tc_bw_tc_no,
12799 		(void *)&cmd_vf_tc_bw_bw,
12800 		NULL,
12801 	},
12802 };
12803 
12804 /** Set VXLAN encapsulation details */
12805 struct cmd_set_vxlan_result {
12806 	cmdline_fixed_string_t set;
12807 	cmdline_fixed_string_t vxlan;
12808 	cmdline_fixed_string_t pos_token;
12809 	cmdline_fixed_string_t ip_version;
12810 	uint32_t vlan_present:1;
12811 	uint32_t vni;
12812 	uint16_t udp_src;
12813 	uint16_t udp_dst;
12814 	cmdline_ipaddr_t ip_src;
12815 	cmdline_ipaddr_t ip_dst;
12816 	uint16_t tci;
12817 	uint8_t tos;
12818 	uint8_t ttl;
12819 	struct rte_ether_addr eth_src;
12820 	struct rte_ether_addr eth_dst;
12821 };
12822 
12823 cmdline_parse_token_string_t cmd_set_vxlan_set =
12824 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12825 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12826 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12827 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12828 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12829 				 "vxlan-tos-ttl");
12830 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12831 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12832 				 "vxlan-with-vlan");
12833 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12834 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12835 				 "ip-version");
12836 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12837 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12838 				 "ipv4#ipv6");
12839 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12840 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12841 				 "vni");
12842 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12843 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12844 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12845 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12846 				 "udp-src");
12847 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12848 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12849 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12850 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12851 				 "udp-dst");
12852 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12853 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12854 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12855 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12856 				 "ip-tos");
12857 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12858 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12859 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12860 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12861 				 "ip-ttl");
12862 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12863 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12864 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12865 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12866 				 "ip-src");
12867 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12868 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12869 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12870 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12871 				 "ip-dst");
12872 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12873 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12874 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12875 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12876 				 "vlan-tci");
12877 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12878 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12879 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12880 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12881 				 "eth-src");
12882 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12883 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12884 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12885 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12886 				 "eth-dst");
12887 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12888 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12889 
12890 static void cmd_set_vxlan_parsed(void *parsed_result,
12891 	__rte_unused struct cmdline *cl,
12892 	__rte_unused void *data)
12893 {
12894 	struct cmd_set_vxlan_result *res = parsed_result;
12895 	union {
12896 		uint32_t vxlan_id;
12897 		uint8_t vni[4];
12898 	} id = {
12899 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12900 	};
12901 
12902 	vxlan_encap_conf.select_tos_ttl = 0;
12903 	if (strcmp(res->vxlan, "vxlan") == 0)
12904 		vxlan_encap_conf.select_vlan = 0;
12905 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12906 		vxlan_encap_conf.select_vlan = 1;
12907 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12908 		vxlan_encap_conf.select_vlan = 0;
12909 		vxlan_encap_conf.select_tos_ttl = 1;
12910 	}
12911 	if (strcmp(res->ip_version, "ipv4") == 0)
12912 		vxlan_encap_conf.select_ipv4 = 1;
12913 	else if (strcmp(res->ip_version, "ipv6") == 0)
12914 		vxlan_encap_conf.select_ipv4 = 0;
12915 	else
12916 		return;
12917 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12918 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12919 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12920 	vxlan_encap_conf.ip_tos = res->tos;
12921 	vxlan_encap_conf.ip_ttl = res->ttl;
12922 	if (vxlan_encap_conf.select_ipv4) {
12923 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12924 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12925 	} else {
12926 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12927 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12928 	}
12929 	if (vxlan_encap_conf.select_vlan)
12930 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12931 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12932 		   RTE_ETHER_ADDR_LEN);
12933 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12934 		   RTE_ETHER_ADDR_LEN);
12935 }
12936 
12937 cmdline_parse_inst_t cmd_set_vxlan = {
12938 	.f = cmd_set_vxlan_parsed,
12939 	.data = NULL,
12940 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12941 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12942 		" eth-src <eth-src> eth-dst <eth-dst>",
12943 	.tokens = {
12944 		(void *)&cmd_set_vxlan_set,
12945 		(void *)&cmd_set_vxlan_vxlan,
12946 		(void *)&cmd_set_vxlan_ip_version,
12947 		(void *)&cmd_set_vxlan_ip_version_value,
12948 		(void *)&cmd_set_vxlan_vni,
12949 		(void *)&cmd_set_vxlan_vni_value,
12950 		(void *)&cmd_set_vxlan_udp_src,
12951 		(void *)&cmd_set_vxlan_udp_src_value,
12952 		(void *)&cmd_set_vxlan_udp_dst,
12953 		(void *)&cmd_set_vxlan_udp_dst_value,
12954 		(void *)&cmd_set_vxlan_ip_src,
12955 		(void *)&cmd_set_vxlan_ip_src_value,
12956 		(void *)&cmd_set_vxlan_ip_dst,
12957 		(void *)&cmd_set_vxlan_ip_dst_value,
12958 		(void *)&cmd_set_vxlan_eth_src,
12959 		(void *)&cmd_set_vxlan_eth_src_value,
12960 		(void *)&cmd_set_vxlan_eth_dst,
12961 		(void *)&cmd_set_vxlan_eth_dst_value,
12962 		NULL,
12963 	},
12964 };
12965 
12966 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12967 	.f = cmd_set_vxlan_parsed,
12968 	.data = NULL,
12969 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12970 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12971 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12972 		" eth-dst <eth-dst>",
12973 	.tokens = {
12974 		(void *)&cmd_set_vxlan_set,
12975 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
12976 		(void *)&cmd_set_vxlan_ip_version,
12977 		(void *)&cmd_set_vxlan_ip_version_value,
12978 		(void *)&cmd_set_vxlan_vni,
12979 		(void *)&cmd_set_vxlan_vni_value,
12980 		(void *)&cmd_set_vxlan_udp_src,
12981 		(void *)&cmd_set_vxlan_udp_src_value,
12982 		(void *)&cmd_set_vxlan_udp_dst,
12983 		(void *)&cmd_set_vxlan_udp_dst_value,
12984 		(void *)&cmd_set_vxlan_ip_tos,
12985 		(void *)&cmd_set_vxlan_ip_tos_value,
12986 		(void *)&cmd_set_vxlan_ip_ttl,
12987 		(void *)&cmd_set_vxlan_ip_ttl_value,
12988 		(void *)&cmd_set_vxlan_ip_src,
12989 		(void *)&cmd_set_vxlan_ip_src_value,
12990 		(void *)&cmd_set_vxlan_ip_dst,
12991 		(void *)&cmd_set_vxlan_ip_dst_value,
12992 		(void *)&cmd_set_vxlan_eth_src,
12993 		(void *)&cmd_set_vxlan_eth_src_value,
12994 		(void *)&cmd_set_vxlan_eth_dst,
12995 		(void *)&cmd_set_vxlan_eth_dst_value,
12996 		NULL,
12997 	},
12998 };
12999 
13000 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13001 	.f = cmd_set_vxlan_parsed,
13002 	.data = NULL,
13003 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13004 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13005 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13006 		" <eth-dst>",
13007 	.tokens = {
13008 		(void *)&cmd_set_vxlan_set,
13009 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
13010 		(void *)&cmd_set_vxlan_ip_version,
13011 		(void *)&cmd_set_vxlan_ip_version_value,
13012 		(void *)&cmd_set_vxlan_vni,
13013 		(void *)&cmd_set_vxlan_vni_value,
13014 		(void *)&cmd_set_vxlan_udp_src,
13015 		(void *)&cmd_set_vxlan_udp_src_value,
13016 		(void *)&cmd_set_vxlan_udp_dst,
13017 		(void *)&cmd_set_vxlan_udp_dst_value,
13018 		(void *)&cmd_set_vxlan_ip_src,
13019 		(void *)&cmd_set_vxlan_ip_src_value,
13020 		(void *)&cmd_set_vxlan_ip_dst,
13021 		(void *)&cmd_set_vxlan_ip_dst_value,
13022 		(void *)&cmd_set_vxlan_vlan,
13023 		(void *)&cmd_set_vxlan_vlan_value,
13024 		(void *)&cmd_set_vxlan_eth_src,
13025 		(void *)&cmd_set_vxlan_eth_src_value,
13026 		(void *)&cmd_set_vxlan_eth_dst,
13027 		(void *)&cmd_set_vxlan_eth_dst_value,
13028 		NULL,
13029 	},
13030 };
13031 
13032 /** Set NVGRE encapsulation details */
13033 struct cmd_set_nvgre_result {
13034 	cmdline_fixed_string_t set;
13035 	cmdline_fixed_string_t nvgre;
13036 	cmdline_fixed_string_t pos_token;
13037 	cmdline_fixed_string_t ip_version;
13038 	uint32_t tni;
13039 	cmdline_ipaddr_t ip_src;
13040 	cmdline_ipaddr_t ip_dst;
13041 	uint16_t tci;
13042 	struct rte_ether_addr eth_src;
13043 	struct rte_ether_addr eth_dst;
13044 };
13045 
13046 cmdline_parse_token_string_t cmd_set_nvgre_set =
13047 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13048 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13049 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13050 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13051 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13052 				 "nvgre-with-vlan");
13053 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13054 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13055 				 "ip-version");
13056 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13057 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13058 				 "ipv4#ipv6");
13059 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13060 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13061 				 "tni");
13062 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13063 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13064 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13065 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13066 				 "ip-src");
13067 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13068 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13069 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13070 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13071 				 "ip-dst");
13072 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13073 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13074 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13075 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13076 				 "vlan-tci");
13077 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13078 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13079 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13080 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13081 				 "eth-src");
13082 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13083 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13084 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13085 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13086 				 "eth-dst");
13087 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13088 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13089 
13090 static void cmd_set_nvgre_parsed(void *parsed_result,
13091 	__rte_unused struct cmdline *cl,
13092 	__rte_unused void *data)
13093 {
13094 	struct cmd_set_nvgre_result *res = parsed_result;
13095 	union {
13096 		uint32_t nvgre_tni;
13097 		uint8_t tni[4];
13098 	} id = {
13099 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13100 	};
13101 
13102 	if (strcmp(res->nvgre, "nvgre") == 0)
13103 		nvgre_encap_conf.select_vlan = 0;
13104 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13105 		nvgre_encap_conf.select_vlan = 1;
13106 	if (strcmp(res->ip_version, "ipv4") == 0)
13107 		nvgre_encap_conf.select_ipv4 = 1;
13108 	else if (strcmp(res->ip_version, "ipv6") == 0)
13109 		nvgre_encap_conf.select_ipv4 = 0;
13110 	else
13111 		return;
13112 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13113 	if (nvgre_encap_conf.select_ipv4) {
13114 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13115 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13116 	} else {
13117 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13118 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13119 	}
13120 	if (nvgre_encap_conf.select_vlan)
13121 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13122 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13123 		   RTE_ETHER_ADDR_LEN);
13124 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13125 		   RTE_ETHER_ADDR_LEN);
13126 }
13127 
13128 cmdline_parse_inst_t cmd_set_nvgre = {
13129 	.f = cmd_set_nvgre_parsed,
13130 	.data = NULL,
13131 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13132 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13133 		" eth-dst <eth-dst>",
13134 	.tokens = {
13135 		(void *)&cmd_set_nvgre_set,
13136 		(void *)&cmd_set_nvgre_nvgre,
13137 		(void *)&cmd_set_nvgre_ip_version,
13138 		(void *)&cmd_set_nvgre_ip_version_value,
13139 		(void *)&cmd_set_nvgre_tni,
13140 		(void *)&cmd_set_nvgre_tni_value,
13141 		(void *)&cmd_set_nvgre_ip_src,
13142 		(void *)&cmd_set_nvgre_ip_src_value,
13143 		(void *)&cmd_set_nvgre_ip_dst,
13144 		(void *)&cmd_set_nvgre_ip_dst_value,
13145 		(void *)&cmd_set_nvgre_eth_src,
13146 		(void *)&cmd_set_nvgre_eth_src_value,
13147 		(void *)&cmd_set_nvgre_eth_dst,
13148 		(void *)&cmd_set_nvgre_eth_dst_value,
13149 		NULL,
13150 	},
13151 };
13152 
13153 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13154 	.f = cmd_set_nvgre_parsed,
13155 	.data = NULL,
13156 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13157 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13158 		" eth-src <eth-src> eth-dst <eth-dst>",
13159 	.tokens = {
13160 		(void *)&cmd_set_nvgre_set,
13161 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
13162 		(void *)&cmd_set_nvgre_ip_version,
13163 		(void *)&cmd_set_nvgre_ip_version_value,
13164 		(void *)&cmd_set_nvgre_tni,
13165 		(void *)&cmd_set_nvgre_tni_value,
13166 		(void *)&cmd_set_nvgre_ip_src,
13167 		(void *)&cmd_set_nvgre_ip_src_value,
13168 		(void *)&cmd_set_nvgre_ip_dst,
13169 		(void *)&cmd_set_nvgre_ip_dst_value,
13170 		(void *)&cmd_set_nvgre_vlan,
13171 		(void *)&cmd_set_nvgre_vlan_value,
13172 		(void *)&cmd_set_nvgre_eth_src,
13173 		(void *)&cmd_set_nvgre_eth_src_value,
13174 		(void *)&cmd_set_nvgre_eth_dst,
13175 		(void *)&cmd_set_nvgre_eth_dst_value,
13176 		NULL,
13177 	},
13178 };
13179 
13180 /** Set L2 encapsulation details */
13181 struct cmd_set_l2_encap_result {
13182 	cmdline_fixed_string_t set;
13183 	cmdline_fixed_string_t l2_encap;
13184 	cmdline_fixed_string_t pos_token;
13185 	cmdline_fixed_string_t ip_version;
13186 	uint32_t vlan_present:1;
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_l2_encap_set =
13193 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13194 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13195 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13196 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13197 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13198 				 "l2_encap-with-vlan");
13199 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13200 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13201 				 "ip-version");
13202 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13203 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13204 				 "ipv4#ipv6");
13205 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13206 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13207 				 "vlan-tci");
13208 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13209 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13210 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13211 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13212 				 "eth-src");
13213 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13214 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13215 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13216 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13217 				 "eth-dst");
13218 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13219 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13220 
13221 static void cmd_set_l2_encap_parsed(void *parsed_result,
13222 	__rte_unused struct cmdline *cl,
13223 	__rte_unused void *data)
13224 {
13225 	struct cmd_set_l2_encap_result *res = parsed_result;
13226 
13227 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13228 		l2_encap_conf.select_vlan = 0;
13229 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13230 		l2_encap_conf.select_vlan = 1;
13231 	if (strcmp(res->ip_version, "ipv4") == 0)
13232 		l2_encap_conf.select_ipv4 = 1;
13233 	else if (strcmp(res->ip_version, "ipv6") == 0)
13234 		l2_encap_conf.select_ipv4 = 0;
13235 	else
13236 		return;
13237 	if (l2_encap_conf.select_vlan)
13238 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13239 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13240 		   RTE_ETHER_ADDR_LEN);
13241 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13242 		   RTE_ETHER_ADDR_LEN);
13243 }
13244 
13245 cmdline_parse_inst_t cmd_set_l2_encap = {
13246 	.f = cmd_set_l2_encap_parsed,
13247 	.data = NULL,
13248 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13249 		" eth-src <eth-src> eth-dst <eth-dst>",
13250 	.tokens = {
13251 		(void *)&cmd_set_l2_encap_set,
13252 		(void *)&cmd_set_l2_encap_l2_encap,
13253 		(void *)&cmd_set_l2_encap_ip_version,
13254 		(void *)&cmd_set_l2_encap_ip_version_value,
13255 		(void *)&cmd_set_l2_encap_eth_src,
13256 		(void *)&cmd_set_l2_encap_eth_src_value,
13257 		(void *)&cmd_set_l2_encap_eth_dst,
13258 		(void *)&cmd_set_l2_encap_eth_dst_value,
13259 		NULL,
13260 	},
13261 };
13262 
13263 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13264 	.f = cmd_set_l2_encap_parsed,
13265 	.data = NULL,
13266 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13267 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13268 	.tokens = {
13269 		(void *)&cmd_set_l2_encap_set,
13270 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13271 		(void *)&cmd_set_l2_encap_ip_version,
13272 		(void *)&cmd_set_l2_encap_ip_version_value,
13273 		(void *)&cmd_set_l2_encap_vlan,
13274 		(void *)&cmd_set_l2_encap_vlan_value,
13275 		(void *)&cmd_set_l2_encap_eth_src,
13276 		(void *)&cmd_set_l2_encap_eth_src_value,
13277 		(void *)&cmd_set_l2_encap_eth_dst,
13278 		(void *)&cmd_set_l2_encap_eth_dst_value,
13279 		NULL,
13280 	},
13281 };
13282 
13283 /** Set L2 decapsulation details */
13284 struct cmd_set_l2_decap_result {
13285 	cmdline_fixed_string_t set;
13286 	cmdline_fixed_string_t l2_decap;
13287 	cmdline_fixed_string_t pos_token;
13288 	uint32_t vlan_present:1;
13289 };
13290 
13291 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13292 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13293 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13294 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13295 				 "l2_decap");
13296 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13297 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13298 				 "l2_decap-with-vlan");
13299 
13300 static void cmd_set_l2_decap_parsed(void *parsed_result,
13301 	__rte_unused struct cmdline *cl,
13302 	__rte_unused void *data)
13303 {
13304 	struct cmd_set_l2_decap_result *res = parsed_result;
13305 
13306 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13307 		l2_decap_conf.select_vlan = 0;
13308 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13309 		l2_decap_conf.select_vlan = 1;
13310 }
13311 
13312 cmdline_parse_inst_t cmd_set_l2_decap = {
13313 	.f = cmd_set_l2_decap_parsed,
13314 	.data = NULL,
13315 	.help_str = "set l2_decap",
13316 	.tokens = {
13317 		(void *)&cmd_set_l2_decap_set,
13318 		(void *)&cmd_set_l2_decap_l2_decap,
13319 		NULL,
13320 	},
13321 };
13322 
13323 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13324 	.f = cmd_set_l2_decap_parsed,
13325 	.data = NULL,
13326 	.help_str = "set l2_decap-with-vlan",
13327 	.tokens = {
13328 		(void *)&cmd_set_l2_decap_set,
13329 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13330 		NULL,
13331 	},
13332 };
13333 
13334 /** Set MPLSoGRE encapsulation details */
13335 struct cmd_set_mplsogre_encap_result {
13336 	cmdline_fixed_string_t set;
13337 	cmdline_fixed_string_t mplsogre;
13338 	cmdline_fixed_string_t pos_token;
13339 	cmdline_fixed_string_t ip_version;
13340 	uint32_t vlan_present:1;
13341 	uint32_t label;
13342 	cmdline_ipaddr_t ip_src;
13343 	cmdline_ipaddr_t ip_dst;
13344 	uint16_t tci;
13345 	struct rte_ether_addr eth_src;
13346 	struct rte_ether_addr eth_dst;
13347 };
13348 
13349 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13350 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13351 				 "set");
13352 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13353 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13354 				 "mplsogre_encap");
13355 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13356 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13357 				 mplsogre, "mplsogre_encap-with-vlan");
13358 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13359 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13360 				 pos_token, "ip-version");
13361 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13362 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13363 				 ip_version, "ipv4#ipv6");
13364 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13365 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13366 				 pos_token, "label");
13367 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13368 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13369 			      RTE_UINT32);
13370 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13371 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13372 				 pos_token, "ip-src");
13373 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13374 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13375 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13376 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13377 				 pos_token, "ip-dst");
13378 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13379 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13380 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13381 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13382 				 pos_token, "vlan-tci");
13383 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13384 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13385 			      RTE_UINT16);
13386 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13387 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13388 				 pos_token, "eth-src");
13389 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13390 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13391 				    eth_src);
13392 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13393 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13394 				 pos_token, "eth-dst");
13395 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13396 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13397 				    eth_dst);
13398 
13399 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13400 	__rte_unused struct cmdline *cl,
13401 	__rte_unused void *data)
13402 {
13403 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13404 	union {
13405 		uint32_t mplsogre_label;
13406 		uint8_t label[4];
13407 	} id = {
13408 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13409 	};
13410 
13411 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13412 		mplsogre_encap_conf.select_vlan = 0;
13413 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13414 		mplsogre_encap_conf.select_vlan = 1;
13415 	if (strcmp(res->ip_version, "ipv4") == 0)
13416 		mplsogre_encap_conf.select_ipv4 = 1;
13417 	else if (strcmp(res->ip_version, "ipv6") == 0)
13418 		mplsogre_encap_conf.select_ipv4 = 0;
13419 	else
13420 		return;
13421 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13422 	if (mplsogre_encap_conf.select_ipv4) {
13423 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13424 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13425 	} else {
13426 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13427 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13428 	}
13429 	if (mplsogre_encap_conf.select_vlan)
13430 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13431 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13432 		   RTE_ETHER_ADDR_LEN);
13433 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13434 		   RTE_ETHER_ADDR_LEN);
13435 }
13436 
13437 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13438 	.f = cmd_set_mplsogre_encap_parsed,
13439 	.data = NULL,
13440 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13441 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13442 		" eth-dst <eth-dst>",
13443 	.tokens = {
13444 		(void *)&cmd_set_mplsogre_encap_set,
13445 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13446 		(void *)&cmd_set_mplsogre_encap_ip_version,
13447 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13448 		(void *)&cmd_set_mplsogre_encap_label,
13449 		(void *)&cmd_set_mplsogre_encap_label_value,
13450 		(void *)&cmd_set_mplsogre_encap_ip_src,
13451 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13452 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13453 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13454 		(void *)&cmd_set_mplsogre_encap_eth_src,
13455 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13456 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13457 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13458 		NULL,
13459 	},
13460 };
13461 
13462 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13463 	.f = cmd_set_mplsogre_encap_parsed,
13464 	.data = NULL,
13465 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13466 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13467 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13468 	.tokens = {
13469 		(void *)&cmd_set_mplsogre_encap_set,
13470 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13471 		(void *)&cmd_set_mplsogre_encap_ip_version,
13472 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13473 		(void *)&cmd_set_mplsogre_encap_label,
13474 		(void *)&cmd_set_mplsogre_encap_label_value,
13475 		(void *)&cmd_set_mplsogre_encap_ip_src,
13476 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13477 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13478 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13479 		(void *)&cmd_set_mplsogre_encap_vlan,
13480 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13481 		(void *)&cmd_set_mplsogre_encap_eth_src,
13482 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13483 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13484 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13485 		NULL,
13486 	},
13487 };
13488 
13489 /** Set MPLSoGRE decapsulation details */
13490 struct cmd_set_mplsogre_decap_result {
13491 	cmdline_fixed_string_t set;
13492 	cmdline_fixed_string_t mplsogre;
13493 	cmdline_fixed_string_t pos_token;
13494 	cmdline_fixed_string_t ip_version;
13495 	uint32_t vlan_present:1;
13496 };
13497 
13498 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13499 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13500 				 "set");
13501 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13502 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13503 				 "mplsogre_decap");
13504 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13505 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13506 				 mplsogre, "mplsogre_decap-with-vlan");
13507 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13508 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13509 				 pos_token, "ip-version");
13510 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13511 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13512 				 ip_version, "ipv4#ipv6");
13513 
13514 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13515 	__rte_unused struct cmdline *cl,
13516 	__rte_unused void *data)
13517 {
13518 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13519 
13520 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13521 		mplsogre_decap_conf.select_vlan = 0;
13522 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13523 		mplsogre_decap_conf.select_vlan = 1;
13524 	if (strcmp(res->ip_version, "ipv4") == 0)
13525 		mplsogre_decap_conf.select_ipv4 = 1;
13526 	else if (strcmp(res->ip_version, "ipv6") == 0)
13527 		mplsogre_decap_conf.select_ipv4 = 0;
13528 }
13529 
13530 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13531 	.f = cmd_set_mplsogre_decap_parsed,
13532 	.data = NULL,
13533 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13534 	.tokens = {
13535 		(void *)&cmd_set_mplsogre_decap_set,
13536 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13537 		(void *)&cmd_set_mplsogre_decap_ip_version,
13538 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13539 		NULL,
13540 	},
13541 };
13542 
13543 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13544 	.f = cmd_set_mplsogre_decap_parsed,
13545 	.data = NULL,
13546 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13547 	.tokens = {
13548 		(void *)&cmd_set_mplsogre_decap_set,
13549 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13550 		(void *)&cmd_set_mplsogre_decap_ip_version,
13551 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13552 		NULL,
13553 	},
13554 };
13555 
13556 /** Set MPLSoUDP encapsulation details */
13557 struct cmd_set_mplsoudp_encap_result {
13558 	cmdline_fixed_string_t set;
13559 	cmdline_fixed_string_t mplsoudp;
13560 	cmdline_fixed_string_t pos_token;
13561 	cmdline_fixed_string_t ip_version;
13562 	uint32_t vlan_present:1;
13563 	uint32_t label;
13564 	uint16_t udp_src;
13565 	uint16_t udp_dst;
13566 	cmdline_ipaddr_t ip_src;
13567 	cmdline_ipaddr_t ip_dst;
13568 	uint16_t tci;
13569 	struct rte_ether_addr eth_src;
13570 	struct rte_ether_addr eth_dst;
13571 };
13572 
13573 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13574 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13575 				 "set");
13576 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13577 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13578 				 "mplsoudp_encap");
13579 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13580 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13581 				 mplsoudp, "mplsoudp_encap-with-vlan");
13582 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13583 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13584 				 pos_token, "ip-version");
13585 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13586 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13587 				 ip_version, "ipv4#ipv6");
13588 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13589 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13590 				 pos_token, "label");
13591 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13592 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13593 			      RTE_UINT32);
13594 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13595 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13596 				 pos_token, "udp-src");
13597 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13598 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13599 			      RTE_UINT16);
13600 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13601 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13602 				 pos_token, "udp-dst");
13603 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13604 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13605 			      RTE_UINT16);
13606 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13607 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13608 				 pos_token, "ip-src");
13609 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13610 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13611 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13612 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13613 				 pos_token, "ip-dst");
13614 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13615 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13616 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13617 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13618 				 pos_token, "vlan-tci");
13619 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13620 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13621 			      RTE_UINT16);
13622 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13623 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13624 				 pos_token, "eth-src");
13625 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13626 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13627 				    eth_src);
13628 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13629 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13630 				 pos_token, "eth-dst");
13631 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13632 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13633 				    eth_dst);
13634 
13635 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13636 	__rte_unused struct cmdline *cl,
13637 	__rte_unused void *data)
13638 {
13639 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13640 	union {
13641 		uint32_t mplsoudp_label;
13642 		uint8_t label[4];
13643 	} id = {
13644 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13645 	};
13646 
13647 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13648 		mplsoudp_encap_conf.select_vlan = 0;
13649 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13650 		mplsoudp_encap_conf.select_vlan = 1;
13651 	if (strcmp(res->ip_version, "ipv4") == 0)
13652 		mplsoudp_encap_conf.select_ipv4 = 1;
13653 	else if (strcmp(res->ip_version, "ipv6") == 0)
13654 		mplsoudp_encap_conf.select_ipv4 = 0;
13655 	else
13656 		return;
13657 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13658 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13659 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13660 	if (mplsoudp_encap_conf.select_ipv4) {
13661 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13662 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13663 	} else {
13664 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13665 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13666 	}
13667 	if (mplsoudp_encap_conf.select_vlan)
13668 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13669 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13670 		   RTE_ETHER_ADDR_LEN);
13671 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13672 		   RTE_ETHER_ADDR_LEN);
13673 }
13674 
13675 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13676 	.f = cmd_set_mplsoudp_encap_parsed,
13677 	.data = NULL,
13678 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13679 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13680 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13681 	.tokens = {
13682 		(void *)&cmd_set_mplsoudp_encap_set,
13683 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13684 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13685 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13686 		(void *)&cmd_set_mplsoudp_encap_label,
13687 		(void *)&cmd_set_mplsoudp_encap_label_value,
13688 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13689 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13690 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13691 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13692 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13693 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13694 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13695 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13696 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13697 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13698 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13699 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13700 		NULL,
13701 	},
13702 };
13703 
13704 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13705 	.f = cmd_set_mplsoudp_encap_parsed,
13706 	.data = NULL,
13707 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13708 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13709 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13710 		" eth-src <eth-src> eth-dst <eth-dst>",
13711 	.tokens = {
13712 		(void *)&cmd_set_mplsoudp_encap_set,
13713 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13714 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13715 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13716 		(void *)&cmd_set_mplsoudp_encap_label,
13717 		(void *)&cmd_set_mplsoudp_encap_label_value,
13718 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13719 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13720 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13721 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13722 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13723 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13724 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13725 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13726 		(void *)&cmd_set_mplsoudp_encap_vlan,
13727 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13728 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13729 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13730 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13731 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13732 		NULL,
13733 	},
13734 };
13735 
13736 /** Set MPLSoUDP decapsulation details */
13737 struct cmd_set_mplsoudp_decap_result {
13738 	cmdline_fixed_string_t set;
13739 	cmdline_fixed_string_t mplsoudp;
13740 	cmdline_fixed_string_t pos_token;
13741 	cmdline_fixed_string_t ip_version;
13742 	uint32_t vlan_present:1;
13743 };
13744 
13745 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13746 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13747 				 "set");
13748 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13749 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13750 				 "mplsoudp_decap");
13751 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13752 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13753 				 mplsoudp, "mplsoudp_decap-with-vlan");
13754 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13755 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13756 				 pos_token, "ip-version");
13757 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13758 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13759 				 ip_version, "ipv4#ipv6");
13760 
13761 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13762 	__rte_unused struct cmdline *cl,
13763 	__rte_unused void *data)
13764 {
13765 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13766 
13767 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13768 		mplsoudp_decap_conf.select_vlan = 0;
13769 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13770 		mplsoudp_decap_conf.select_vlan = 1;
13771 	if (strcmp(res->ip_version, "ipv4") == 0)
13772 		mplsoudp_decap_conf.select_ipv4 = 1;
13773 	else if (strcmp(res->ip_version, "ipv6") == 0)
13774 		mplsoudp_decap_conf.select_ipv4 = 0;
13775 }
13776 
13777 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13778 	.f = cmd_set_mplsoudp_decap_parsed,
13779 	.data = NULL,
13780 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13781 	.tokens = {
13782 		(void *)&cmd_set_mplsoudp_decap_set,
13783 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13784 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13785 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13786 		NULL,
13787 	},
13788 };
13789 
13790 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13791 	.f = cmd_set_mplsoudp_decap_parsed,
13792 	.data = NULL,
13793 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13794 	.tokens = {
13795 		(void *)&cmd_set_mplsoudp_decap_set,
13796 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13797 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13798 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13799 		NULL,
13800 	},
13801 };
13802 
13803 /** Set connection tracking object common details */
13804 struct cmd_set_conntrack_common_result {
13805 	cmdline_fixed_string_t set;
13806 	cmdline_fixed_string_t conntrack;
13807 	cmdline_fixed_string_t common;
13808 	cmdline_fixed_string_t peer;
13809 	cmdline_fixed_string_t is_orig;
13810 	cmdline_fixed_string_t enable;
13811 	cmdline_fixed_string_t live;
13812 	cmdline_fixed_string_t sack;
13813 	cmdline_fixed_string_t cack;
13814 	cmdline_fixed_string_t last_dir;
13815 	cmdline_fixed_string_t liberal;
13816 	cmdline_fixed_string_t state;
13817 	cmdline_fixed_string_t max_ack_win;
13818 	cmdline_fixed_string_t retrans;
13819 	cmdline_fixed_string_t last_win;
13820 	cmdline_fixed_string_t last_seq;
13821 	cmdline_fixed_string_t last_ack;
13822 	cmdline_fixed_string_t last_end;
13823 	cmdline_fixed_string_t last_index;
13824 	uint8_t stat;
13825 	uint8_t factor;
13826 	uint16_t peer_port;
13827 	uint32_t is_original;
13828 	uint32_t en;
13829 	uint32_t is_live;
13830 	uint32_t s_ack;
13831 	uint32_t c_ack;
13832 	uint32_t ld;
13833 	uint32_t lb;
13834 	uint8_t re_num;
13835 	uint8_t li;
13836 	uint16_t lw;
13837 	uint32_t ls;
13838 	uint32_t la;
13839 	uint32_t le;
13840 };
13841 
13842 cmdline_parse_token_string_t cmd_set_conntrack_set =
13843 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13844 				 set, "set");
13845 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13846 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13847 				 conntrack, "conntrack");
13848 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13849 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13850 				 common, "com");
13851 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13852 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13853 				 peer, "peer");
13854 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13855 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13856 			      peer_port, RTE_UINT16);
13857 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13858 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13859 				 is_orig, "is_orig");
13860 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13861 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13862 			      is_original, RTE_UINT32);
13863 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13864 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13865 				 enable, "enable");
13866 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13867 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13868 			      en, RTE_UINT32);
13869 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13870 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13871 				 live, "live");
13872 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13873 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13874 			      is_live, RTE_UINT32);
13875 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13876 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13877 				 sack, "sack");
13878 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13879 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13880 			      s_ack, RTE_UINT32);
13881 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13882 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13883 				 cack, "cack");
13884 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13885 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13886 			      c_ack, RTE_UINT32);
13887 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13888 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13889 				 last_dir, "last_dir");
13890 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13891 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13892 			      ld, RTE_UINT32);
13893 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13894 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13895 				 liberal, "liberal");
13896 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13897 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13898 			      lb, RTE_UINT32);
13899 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13900 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13901 				 state, "state");
13902 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13903 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13904 			      stat, RTE_UINT8);
13905 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13906 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13907 				 max_ack_win, "max_ack_win");
13908 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13909 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13910 			      factor, RTE_UINT8);
13911 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13912 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13913 				 retrans, "r_lim");
13914 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13915 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13916 			      re_num, RTE_UINT8);
13917 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13918 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13919 				 last_win, "last_win");
13920 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13921 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13922 			      lw, RTE_UINT16);
13923 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13924 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13925 				 last_seq, "last_seq");
13926 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13927 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13928 			      ls, RTE_UINT32);
13929 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13930 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13931 				 last_ack, "last_ack");
13932 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13933 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13934 			      la, RTE_UINT32);
13935 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13936 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13937 				 last_end, "last_end");
13938 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13939 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13940 			      le, RTE_UINT32);
13941 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13942 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13943 				 last_index, "last_index");
13944 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13945 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13946 			      li, RTE_UINT8);
13947 
13948 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13949 	__rte_unused struct cmdline *cl,
13950 	__rte_unused void *data)
13951 {
13952 	struct cmd_set_conntrack_common_result *res = parsed_result;
13953 
13954 	/* No need to swap to big endian. */
13955 	conntrack_context.peer_port = res->peer_port;
13956 	conntrack_context.is_original_dir = res->is_original;
13957 	conntrack_context.enable = res->en;
13958 	conntrack_context.live_connection = res->is_live;
13959 	conntrack_context.selective_ack = res->s_ack;
13960 	conntrack_context.challenge_ack_passed = res->c_ack;
13961 	conntrack_context.last_direction = res->ld;
13962 	conntrack_context.liberal_mode = res->lb;
13963 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13964 	conntrack_context.max_ack_window = res->factor;
13965 	conntrack_context.retransmission_limit = res->re_num;
13966 	conntrack_context.last_window = res->lw;
13967 	conntrack_context.last_index =
13968 		(enum rte_flow_conntrack_tcp_last_index)res->li;
13969 	conntrack_context.last_seq = res->ls;
13970 	conntrack_context.last_ack = res->la;
13971 	conntrack_context.last_end = res->le;
13972 }
13973 
13974 cmdline_parse_inst_t cmd_set_conntrack_common = {
13975 	.f = cmd_set_conntrack_common_parsed,
13976 	.data = NULL,
13977 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13978 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13979 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13980 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13981 		" last_index <flag>",
13982 	.tokens = {
13983 		(void *)&cmd_set_conntrack_set,
13984 		(void *)&cmd_set_conntrack_conntrack,
13985 		(void *)&cmd_set_conntrack_common_com,
13986 		(void *)&cmd_set_conntrack_common_peer,
13987 		(void *)&cmd_set_conntrack_common_peer_value,
13988 		(void *)&cmd_set_conntrack_common_is_orig,
13989 		(void *)&cmd_set_conntrack_common_is_orig_value,
13990 		(void *)&cmd_set_conntrack_common_enable,
13991 		(void *)&cmd_set_conntrack_common_enable_value,
13992 		(void *)&cmd_set_conntrack_common_live,
13993 		(void *)&cmd_set_conntrack_common_live_value,
13994 		(void *)&cmd_set_conntrack_common_sack,
13995 		(void *)&cmd_set_conntrack_common_sack_value,
13996 		(void *)&cmd_set_conntrack_common_cack,
13997 		(void *)&cmd_set_conntrack_common_cack_value,
13998 		(void *)&cmd_set_conntrack_common_last_dir,
13999 		(void *)&cmd_set_conntrack_common_last_dir_value,
14000 		(void *)&cmd_set_conntrack_common_liberal,
14001 		(void *)&cmd_set_conntrack_common_liberal_value,
14002 		(void *)&cmd_set_conntrack_common_state,
14003 		(void *)&cmd_set_conntrack_common_state_value,
14004 		(void *)&cmd_set_conntrack_common_max_ackwin,
14005 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
14006 		(void *)&cmd_set_conntrack_common_retrans,
14007 		(void *)&cmd_set_conntrack_common_retrans_value,
14008 		(void *)&cmd_set_conntrack_common_last_win,
14009 		(void *)&cmd_set_conntrack_common_last_win_value,
14010 		(void *)&cmd_set_conntrack_common_last_seq,
14011 		(void *)&cmd_set_conntrack_common_last_seq_value,
14012 		(void *)&cmd_set_conntrack_common_last_ack,
14013 		(void *)&cmd_set_conntrack_common_last_ack_value,
14014 		(void *)&cmd_set_conntrack_common_last_end,
14015 		(void *)&cmd_set_conntrack_common_last_end_value,
14016 		(void *)&cmd_set_conntrack_common_last_index,
14017 		(void *)&cmd_set_conntrack_common_last_index_value,
14018 		NULL,
14019 	},
14020 };
14021 
14022 /** Set connection tracking object both directions' details */
14023 struct cmd_set_conntrack_dir_result {
14024 	cmdline_fixed_string_t set;
14025 	cmdline_fixed_string_t conntrack;
14026 	cmdline_fixed_string_t dir;
14027 	cmdline_fixed_string_t scale;
14028 	cmdline_fixed_string_t fin;
14029 	cmdline_fixed_string_t ack_seen;
14030 	cmdline_fixed_string_t unack;
14031 	cmdline_fixed_string_t sent_end;
14032 	cmdline_fixed_string_t reply_end;
14033 	cmdline_fixed_string_t max_win;
14034 	cmdline_fixed_string_t max_ack;
14035 	uint32_t factor;
14036 	uint32_t f;
14037 	uint32_t as;
14038 	uint32_t un;
14039 	uint32_t se;
14040 	uint32_t re;
14041 	uint32_t mw;
14042 	uint32_t ma;
14043 };
14044 
14045 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14046 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14047 				 set, "set");
14048 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14049 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14050 				 conntrack, "conntrack");
14051 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14052 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14053 				 dir, "orig#rply");
14054 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14055 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14056 				 scale, "scale");
14057 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14058 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14059 			      factor, RTE_UINT32);
14060 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14061 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14062 				 fin, "fin");
14063 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14064 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14065 			      f, RTE_UINT32);
14066 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14067 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14068 				 ack_seen, "acked");
14069 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14070 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14071 			      as, RTE_UINT32);
14072 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14073 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14074 				 unack, "unack_data");
14075 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14076 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14077 			      un, RTE_UINT32);
14078 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14079 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14080 				 sent_end, "sent_end");
14081 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14082 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14083 			      se, RTE_UINT32);
14084 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14085 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14086 				 reply_end, "reply_end");
14087 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14088 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14089 			      re, RTE_UINT32);
14090 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14091 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14092 				 max_win, "max_win");
14093 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14094 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14095 			      mw, RTE_UINT32);
14096 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14097 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14098 				 max_ack, "max_ack");
14099 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14100 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14101 			      ma, RTE_UINT32);
14102 
14103 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14104 	__rte_unused struct cmdline *cl,
14105 	__rte_unused void *data)
14106 {
14107 	struct cmd_set_conntrack_dir_result *res = parsed_result;
14108 	struct rte_flow_tcp_dir_param *dir = NULL;
14109 
14110 	if (strcmp(res->dir, "orig") == 0)
14111 		dir = &conntrack_context.original_dir;
14112 	else if (strcmp(res->dir, "rply") == 0)
14113 		dir = &conntrack_context.reply_dir;
14114 	else
14115 		return;
14116 	dir->scale = res->factor;
14117 	dir->close_initiated = res->f;
14118 	dir->last_ack_seen = res->as;
14119 	dir->data_unacked = res->un;
14120 	dir->sent_end = res->se;
14121 	dir->reply_end = res->re;
14122 	dir->max_ack = res->ma;
14123 	dir->max_win = res->mw;
14124 }
14125 
14126 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14127 	.f = cmd_set_conntrack_dir_parsed,
14128 	.data = NULL,
14129 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14130 		    " acked <seen> unack_data <unack> sent_end <sent>"
14131 		    " reply_end <reply> max_win <win> max_ack <ack>",
14132 	.tokens = {
14133 		(void *)&cmd_set_conntrack_set,
14134 		(void *)&cmd_set_conntrack_conntrack,
14135 		(void *)&cmd_set_conntrack_dir_dir,
14136 		(void *)&cmd_set_conntrack_dir_scale,
14137 		(void *)&cmd_set_conntrack_dir_scale_value,
14138 		(void *)&cmd_set_conntrack_dir_fin,
14139 		(void *)&cmd_set_conntrack_dir_fin_value,
14140 		(void *)&cmd_set_conntrack_dir_ack,
14141 		(void *)&cmd_set_conntrack_dir_ack_value,
14142 		(void *)&cmd_set_conntrack_dir_unack_data,
14143 		(void *)&cmd_set_conntrack_dir_unack_data_value,
14144 		(void *)&cmd_set_conntrack_dir_sent_end,
14145 		(void *)&cmd_set_conntrack_dir_sent_end_value,
14146 		(void *)&cmd_set_conntrack_dir_reply_end,
14147 		(void *)&cmd_set_conntrack_dir_reply_end_value,
14148 		(void *)&cmd_set_conntrack_dir_max_win,
14149 		(void *)&cmd_set_conntrack_dir_max_win_value,
14150 		(void *)&cmd_set_conntrack_dir_max_ack,
14151 		(void *)&cmd_set_conntrack_dir_max_ack_value,
14152 		NULL,
14153 	},
14154 };
14155 
14156 /* Strict link priority scheduling mode setting */
14157 static void
14158 cmd_strict_link_prio_parsed(
14159 	void *parsed_result,
14160 	__rte_unused struct cmdline *cl,
14161 	__rte_unused void *data)
14162 {
14163 	struct cmd_vf_tc_bw_result *res = parsed_result;
14164 	int ret = -ENOTSUP;
14165 
14166 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14167 		return;
14168 
14169 #ifdef RTE_NET_I40E
14170 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14171 #endif
14172 
14173 	switch (ret) {
14174 	case 0:
14175 		break;
14176 	case -EINVAL:
14177 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14178 		break;
14179 	case -ENODEV:
14180 		printf("invalid port_id %d\n", res->port_id);
14181 		break;
14182 	case -ENOTSUP:
14183 		printf("function not implemented\n");
14184 		break;
14185 	default:
14186 		printf("programming error: (%s)\n", strerror(-ret));
14187 	}
14188 }
14189 
14190 cmdline_parse_inst_t cmd_strict_link_prio = {
14191 	.f = cmd_strict_link_prio_parsed,
14192 	.data = NULL,
14193 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14194 	.tokens = {
14195 		(void *)&cmd_vf_tc_bw_set,
14196 		(void *)&cmd_vf_tc_bw_tx,
14197 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14198 		(void *)&cmd_vf_tc_bw_port_id,
14199 		(void *)&cmd_vf_tc_bw_tc_map,
14200 		NULL,
14201 	},
14202 };
14203 
14204 /* Load dynamic device personalization*/
14205 struct cmd_ddp_add_result {
14206 	cmdline_fixed_string_t ddp;
14207 	cmdline_fixed_string_t add;
14208 	portid_t port_id;
14209 	char filepath[];
14210 };
14211 
14212 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14213 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14214 cmdline_parse_token_string_t cmd_ddp_add_add =
14215 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14216 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14217 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14218 		RTE_UINT16);
14219 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14220 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14221 
14222 static void
14223 cmd_ddp_add_parsed(
14224 	void *parsed_result,
14225 	__rte_unused struct cmdline *cl,
14226 	__rte_unused void *data)
14227 {
14228 	struct cmd_ddp_add_result *res = parsed_result;
14229 	uint8_t *buff;
14230 	uint32_t size;
14231 	char *filepath;
14232 	char *file_fld[2];
14233 	int file_num;
14234 	int ret = -ENOTSUP;
14235 
14236 	if (!all_ports_stopped()) {
14237 		printf("Please stop all ports first\n");
14238 		return;
14239 	}
14240 
14241 	filepath = strdup(res->filepath);
14242 	if (filepath == NULL) {
14243 		printf("Failed to allocate memory\n");
14244 		return;
14245 	}
14246 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14247 
14248 	buff = open_file(file_fld[0], &size);
14249 	if (!buff) {
14250 		free((void *)filepath);
14251 		return;
14252 	}
14253 
14254 #ifdef RTE_NET_I40E
14255 	if (ret == -ENOTSUP)
14256 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14257 					       buff, size,
14258 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14259 #endif
14260 
14261 	if (ret == -EEXIST)
14262 		printf("Profile has already existed.\n");
14263 	else if (ret < 0)
14264 		printf("Failed to load profile.\n");
14265 	else if (file_num == 2)
14266 		save_file(file_fld[1], buff, size);
14267 
14268 	close_file(buff);
14269 	free((void *)filepath);
14270 }
14271 
14272 cmdline_parse_inst_t cmd_ddp_add = {
14273 	.f = cmd_ddp_add_parsed,
14274 	.data = NULL,
14275 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14276 	.tokens = {
14277 		(void *)&cmd_ddp_add_ddp,
14278 		(void *)&cmd_ddp_add_add,
14279 		(void *)&cmd_ddp_add_port_id,
14280 		(void *)&cmd_ddp_add_filepath,
14281 		NULL,
14282 	},
14283 };
14284 
14285 /* Delete dynamic device personalization*/
14286 struct cmd_ddp_del_result {
14287 	cmdline_fixed_string_t ddp;
14288 	cmdline_fixed_string_t del;
14289 	portid_t port_id;
14290 	char filepath[];
14291 };
14292 
14293 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14294 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14295 cmdline_parse_token_string_t cmd_ddp_del_del =
14296 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14297 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14298 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14299 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14300 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14301 
14302 static void
14303 cmd_ddp_del_parsed(
14304 	void *parsed_result,
14305 	__rte_unused struct cmdline *cl,
14306 	__rte_unused void *data)
14307 {
14308 	struct cmd_ddp_del_result *res = parsed_result;
14309 	uint8_t *buff;
14310 	uint32_t size;
14311 	int ret = -ENOTSUP;
14312 
14313 	if (!all_ports_stopped()) {
14314 		printf("Please stop all ports first\n");
14315 		return;
14316 	}
14317 
14318 	buff = open_file(res->filepath, &size);
14319 	if (!buff)
14320 		return;
14321 
14322 #ifdef RTE_NET_I40E
14323 	if (ret == -ENOTSUP)
14324 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14325 					       buff, size,
14326 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14327 #endif
14328 
14329 	if (ret == -EACCES)
14330 		printf("Profile does not exist.\n");
14331 	else if (ret < 0)
14332 		printf("Failed to delete profile.\n");
14333 
14334 	close_file(buff);
14335 }
14336 
14337 cmdline_parse_inst_t cmd_ddp_del = {
14338 	.f = cmd_ddp_del_parsed,
14339 	.data = NULL,
14340 	.help_str = "ddp del <port_id> <backup_profile_path>",
14341 	.tokens = {
14342 		(void *)&cmd_ddp_del_ddp,
14343 		(void *)&cmd_ddp_del_del,
14344 		(void *)&cmd_ddp_del_port_id,
14345 		(void *)&cmd_ddp_del_filepath,
14346 		NULL,
14347 	},
14348 };
14349 
14350 /* Get dynamic device personalization profile info */
14351 struct cmd_ddp_info_result {
14352 	cmdline_fixed_string_t ddp;
14353 	cmdline_fixed_string_t get;
14354 	cmdline_fixed_string_t info;
14355 	char filepath[];
14356 };
14357 
14358 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14359 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14360 cmdline_parse_token_string_t cmd_ddp_info_get =
14361 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14362 cmdline_parse_token_string_t cmd_ddp_info_info =
14363 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14364 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14365 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14366 
14367 static void
14368 cmd_ddp_info_parsed(
14369 	void *parsed_result,
14370 	__rte_unused struct cmdline *cl,
14371 	__rte_unused void *data)
14372 {
14373 	struct cmd_ddp_info_result *res = parsed_result;
14374 	uint8_t *pkg;
14375 	uint32_t pkg_size;
14376 	int ret = -ENOTSUP;
14377 #ifdef RTE_NET_I40E
14378 	uint32_t i, j, n;
14379 	uint8_t *buff;
14380 	uint32_t buff_size = 0;
14381 	struct rte_pmd_i40e_profile_info info;
14382 	uint32_t dev_num = 0;
14383 	struct rte_pmd_i40e_ddp_device_id *devs;
14384 	uint32_t proto_num = 0;
14385 	struct rte_pmd_i40e_proto_info *proto = NULL;
14386 	uint32_t pctype_num = 0;
14387 	struct rte_pmd_i40e_ptype_info *pctype;
14388 	uint32_t ptype_num = 0;
14389 	struct rte_pmd_i40e_ptype_info *ptype;
14390 	uint8_t proto_id;
14391 
14392 #endif
14393 
14394 	pkg = open_file(res->filepath, &pkg_size);
14395 	if (!pkg)
14396 		return;
14397 
14398 #ifdef RTE_NET_I40E
14399 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14400 				(uint8_t *)&info, sizeof(info),
14401 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14402 	if (!ret) {
14403 		printf("Global Track id:       0x%x\n", info.track_id);
14404 		printf("Global Version:        %d.%d.%d.%d\n",
14405 			info.version.major,
14406 			info.version.minor,
14407 			info.version.update,
14408 			info.version.draft);
14409 		printf("Global Package name:   %s\n\n", info.name);
14410 	}
14411 
14412 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14413 				(uint8_t *)&info, sizeof(info),
14414 				RTE_PMD_I40E_PKG_INFO_HEADER);
14415 	if (!ret) {
14416 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14417 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14418 			info.version.major,
14419 			info.version.minor,
14420 			info.version.update,
14421 			info.version.draft);
14422 		printf("i40e Profile name:     %s\n\n", info.name);
14423 	}
14424 
14425 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14426 				(uint8_t *)&buff_size, sizeof(buff_size),
14427 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14428 	if (!ret && buff_size) {
14429 		buff = (uint8_t *)malloc(buff_size);
14430 		if (buff) {
14431 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14432 						buff, buff_size,
14433 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14434 			if (!ret)
14435 				printf("Package Notes:\n%s\n\n", buff);
14436 			free(buff);
14437 		}
14438 	}
14439 
14440 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14441 				(uint8_t *)&dev_num, sizeof(dev_num),
14442 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14443 	if (!ret && dev_num) {
14444 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14445 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14446 		if (devs) {
14447 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14448 						(uint8_t *)devs, buff_size,
14449 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14450 			if (!ret) {
14451 				printf("List of supported devices:\n");
14452 				for (i = 0; i < dev_num; i++) {
14453 					printf("  %04X:%04X %04X:%04X\n",
14454 						devs[i].vendor_dev_id >> 16,
14455 						devs[i].vendor_dev_id & 0xFFFF,
14456 						devs[i].sub_vendor_dev_id >> 16,
14457 						devs[i].sub_vendor_dev_id & 0xFFFF);
14458 				}
14459 				printf("\n");
14460 			}
14461 			free(devs);
14462 		}
14463 	}
14464 
14465 	/* get information about protocols and packet types */
14466 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14467 		(uint8_t *)&proto_num, sizeof(proto_num),
14468 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14469 	if (ret || !proto_num)
14470 		goto no_print_return;
14471 
14472 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14473 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14474 	if (!proto)
14475 		goto no_print_return;
14476 
14477 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14478 					buff_size,
14479 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14480 	if (!ret) {
14481 		printf("List of used protocols:\n");
14482 		for (i = 0; i < proto_num; i++)
14483 			printf("  %2u: %s\n", proto[i].proto_id,
14484 			       proto[i].name);
14485 		printf("\n");
14486 	}
14487 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14488 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14489 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14490 	if (ret || !pctype_num)
14491 		goto no_print_pctypes;
14492 
14493 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14494 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14495 	if (!pctype)
14496 		goto no_print_pctypes;
14497 
14498 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14499 					buff_size,
14500 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14501 	if (ret) {
14502 		free(pctype);
14503 		goto no_print_pctypes;
14504 	}
14505 
14506 	printf("List of defined packet classification types:\n");
14507 	for (i = 0; i < pctype_num; i++) {
14508 		printf("  %2u:", pctype[i].ptype_id);
14509 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14510 			proto_id = pctype[i].protocols[j];
14511 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14512 				for (n = 0; n < proto_num; n++) {
14513 					if (proto[n].proto_id == proto_id) {
14514 						printf(" %s", proto[n].name);
14515 						break;
14516 					}
14517 				}
14518 			}
14519 		}
14520 		printf("\n");
14521 	}
14522 	printf("\n");
14523 	free(pctype);
14524 
14525 no_print_pctypes:
14526 
14527 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14528 					sizeof(ptype_num),
14529 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14530 	if (ret || !ptype_num)
14531 		goto no_print_return;
14532 
14533 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14534 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14535 	if (!ptype)
14536 		goto no_print_return;
14537 
14538 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14539 					buff_size,
14540 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14541 	if (ret) {
14542 		free(ptype);
14543 		goto no_print_return;
14544 	}
14545 	printf("List of defined packet types:\n");
14546 	for (i = 0; i < ptype_num; i++) {
14547 		printf("  %2u:", ptype[i].ptype_id);
14548 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14549 			proto_id = ptype[i].protocols[j];
14550 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14551 				for (n = 0; n < proto_num; n++) {
14552 					if (proto[n].proto_id == proto_id) {
14553 						printf(" %s", proto[n].name);
14554 						break;
14555 					}
14556 				}
14557 			}
14558 		}
14559 		printf("\n");
14560 	}
14561 	free(ptype);
14562 	printf("\n");
14563 
14564 	ret = 0;
14565 no_print_return:
14566 	if (proto)
14567 		free(proto);
14568 #endif
14569 	if (ret == -ENOTSUP)
14570 		printf("Function not supported in PMD driver\n");
14571 	close_file(pkg);
14572 }
14573 
14574 cmdline_parse_inst_t cmd_ddp_get_info = {
14575 	.f = cmd_ddp_info_parsed,
14576 	.data = NULL,
14577 	.help_str = "ddp get info <profile_path>",
14578 	.tokens = {
14579 		(void *)&cmd_ddp_info_ddp,
14580 		(void *)&cmd_ddp_info_get,
14581 		(void *)&cmd_ddp_info_info,
14582 		(void *)&cmd_ddp_info_filepath,
14583 		NULL,
14584 	},
14585 };
14586 
14587 /* Get dynamic device personalization profile info list*/
14588 #define PROFILE_INFO_SIZE 48
14589 #define MAX_PROFILE_NUM 16
14590 
14591 struct cmd_ddp_get_list_result {
14592 	cmdline_fixed_string_t ddp;
14593 	cmdline_fixed_string_t get;
14594 	cmdline_fixed_string_t list;
14595 	portid_t port_id;
14596 };
14597 
14598 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14599 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14600 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14601 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14602 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14603 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14604 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14605 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14606 		RTE_UINT16);
14607 
14608 static void
14609 cmd_ddp_get_list_parsed(
14610 	__rte_unused void *parsed_result,
14611 	__rte_unused struct cmdline *cl,
14612 	__rte_unused void *data)
14613 {
14614 #ifdef RTE_NET_I40E
14615 	struct cmd_ddp_get_list_result *res = parsed_result;
14616 	struct rte_pmd_i40e_profile_list *p_list;
14617 	struct rte_pmd_i40e_profile_info *p_info;
14618 	uint32_t p_num;
14619 	uint32_t size;
14620 	uint32_t i;
14621 #endif
14622 	int ret = -ENOTSUP;
14623 
14624 #ifdef RTE_NET_I40E
14625 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14626 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14627 	if (!p_list) {
14628 		printf("%s: Failed to malloc buffer\n", __func__);
14629 		return;
14630 	}
14631 
14632 	if (ret == -ENOTSUP)
14633 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14634 						(uint8_t *)p_list, size);
14635 
14636 	if (!ret) {
14637 		p_num = p_list->p_count;
14638 		printf("Profile number is: %d\n\n", p_num);
14639 
14640 		for (i = 0; i < p_num; i++) {
14641 			p_info = &p_list->p_info[i];
14642 			printf("Profile %d:\n", i);
14643 			printf("Track id:     0x%x\n", p_info->track_id);
14644 			printf("Version:      %d.%d.%d.%d\n",
14645 			       p_info->version.major,
14646 			       p_info->version.minor,
14647 			       p_info->version.update,
14648 			       p_info->version.draft);
14649 			printf("Profile name: %s\n\n", p_info->name);
14650 		}
14651 	}
14652 
14653 	free(p_list);
14654 #endif
14655 
14656 	if (ret < 0)
14657 		printf("Failed to get ddp list\n");
14658 }
14659 
14660 cmdline_parse_inst_t cmd_ddp_get_list = {
14661 	.f = cmd_ddp_get_list_parsed,
14662 	.data = NULL,
14663 	.help_str = "ddp get list <port_id>",
14664 	.tokens = {
14665 		(void *)&cmd_ddp_get_list_ddp,
14666 		(void *)&cmd_ddp_get_list_get,
14667 		(void *)&cmd_ddp_get_list_list,
14668 		(void *)&cmd_ddp_get_list_port_id,
14669 		NULL,
14670 	},
14671 };
14672 
14673 /* Configure input set */
14674 struct cmd_cfg_input_set_result {
14675 	cmdline_fixed_string_t port;
14676 	cmdline_fixed_string_t cfg;
14677 	portid_t port_id;
14678 	cmdline_fixed_string_t pctype;
14679 	uint8_t pctype_id;
14680 	cmdline_fixed_string_t inset_type;
14681 	cmdline_fixed_string_t opt;
14682 	cmdline_fixed_string_t field;
14683 	uint8_t field_idx;
14684 };
14685 
14686 static void
14687 cmd_cfg_input_set_parsed(
14688 	__rte_unused void *parsed_result,
14689 	__rte_unused struct cmdline *cl,
14690 	__rte_unused void *data)
14691 {
14692 #ifdef RTE_NET_I40E
14693 	struct cmd_cfg_input_set_result *res = parsed_result;
14694 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14695 	struct rte_pmd_i40e_inset inset;
14696 #endif
14697 	int ret = -ENOTSUP;
14698 
14699 	if (!all_ports_stopped()) {
14700 		printf("Please stop all ports first\n");
14701 		return;
14702 	}
14703 
14704 #ifdef RTE_NET_I40E
14705 	if (!strcmp(res->inset_type, "hash_inset"))
14706 		inset_type = INSET_HASH;
14707 	else if (!strcmp(res->inset_type, "fdir_inset"))
14708 		inset_type = INSET_FDIR;
14709 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14710 		inset_type = INSET_FDIR_FLX;
14711 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14712 				     &inset, inset_type);
14713 	if (ret) {
14714 		printf("Failed to get input set.\n");
14715 		return;
14716 	}
14717 
14718 	if (!strcmp(res->opt, "get")) {
14719 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14720 						   res->field_idx);
14721 		if (ret)
14722 			printf("Field index %d is enabled.\n", res->field_idx);
14723 		else
14724 			printf("Field index %d is disabled.\n", res->field_idx);
14725 		return;
14726 	} else if (!strcmp(res->opt, "set"))
14727 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14728 						   res->field_idx);
14729 	else if (!strcmp(res->opt, "clear"))
14730 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14731 						     res->field_idx);
14732 	if (ret) {
14733 		printf("Failed to configure input set field.\n");
14734 		return;
14735 	}
14736 
14737 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14738 				     &inset, inset_type);
14739 	if (ret) {
14740 		printf("Failed to set input set.\n");
14741 		return;
14742 	}
14743 #endif
14744 
14745 	if (ret == -ENOTSUP)
14746 		printf("Function not supported\n");
14747 }
14748 
14749 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14750 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14751 				 port, "port");
14752 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14753 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14754 				 cfg, "config");
14755 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14756 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14757 			      port_id, RTE_UINT16);
14758 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14759 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14760 				 pctype, "pctype");
14761 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14762 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14763 			      pctype_id, RTE_UINT8);
14764 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14765 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14766 				 inset_type,
14767 				 "hash_inset#fdir_inset#fdir_flx_inset");
14768 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14769 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14770 				 opt, "get#set#clear");
14771 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14772 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14773 				 field, "field");
14774 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14775 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14776 			      field_idx, RTE_UINT8);
14777 
14778 cmdline_parse_inst_t cmd_cfg_input_set = {
14779 	.f = cmd_cfg_input_set_parsed,
14780 	.data = NULL,
14781 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14782 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14783 	.tokens = {
14784 		(void *)&cmd_cfg_input_set_port,
14785 		(void *)&cmd_cfg_input_set_cfg,
14786 		(void *)&cmd_cfg_input_set_port_id,
14787 		(void *)&cmd_cfg_input_set_pctype,
14788 		(void *)&cmd_cfg_input_set_pctype_id,
14789 		(void *)&cmd_cfg_input_set_inset_type,
14790 		(void *)&cmd_cfg_input_set_opt,
14791 		(void *)&cmd_cfg_input_set_field,
14792 		(void *)&cmd_cfg_input_set_field_idx,
14793 		NULL,
14794 	},
14795 };
14796 
14797 /* Clear input set */
14798 struct cmd_clear_input_set_result {
14799 	cmdline_fixed_string_t port;
14800 	cmdline_fixed_string_t cfg;
14801 	portid_t port_id;
14802 	cmdline_fixed_string_t pctype;
14803 	uint8_t pctype_id;
14804 	cmdline_fixed_string_t inset_type;
14805 	cmdline_fixed_string_t clear;
14806 	cmdline_fixed_string_t all;
14807 };
14808 
14809 static void
14810 cmd_clear_input_set_parsed(
14811 	__rte_unused void *parsed_result,
14812 	__rte_unused struct cmdline *cl,
14813 	__rte_unused void *data)
14814 {
14815 #ifdef RTE_NET_I40E
14816 	struct cmd_clear_input_set_result *res = parsed_result;
14817 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14818 	struct rte_pmd_i40e_inset inset;
14819 #endif
14820 	int ret = -ENOTSUP;
14821 
14822 	if (!all_ports_stopped()) {
14823 		printf("Please stop all ports first\n");
14824 		return;
14825 	}
14826 
14827 #ifdef RTE_NET_I40E
14828 	if (!strcmp(res->inset_type, "hash_inset"))
14829 		inset_type = INSET_HASH;
14830 	else if (!strcmp(res->inset_type, "fdir_inset"))
14831 		inset_type = INSET_FDIR;
14832 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14833 		inset_type = INSET_FDIR_FLX;
14834 
14835 	memset(&inset, 0, sizeof(inset));
14836 
14837 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14838 				     &inset, inset_type);
14839 	if (ret) {
14840 		printf("Failed to clear input set.\n");
14841 		return;
14842 	}
14843 
14844 #endif
14845 
14846 	if (ret == -ENOTSUP)
14847 		printf("Function not supported\n");
14848 }
14849 
14850 cmdline_parse_token_string_t cmd_clear_input_set_port =
14851 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14852 				 port, "port");
14853 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14854 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14855 				 cfg, "config");
14856 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14857 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14858 			      port_id, RTE_UINT16);
14859 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14860 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14861 				 pctype, "pctype");
14862 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14863 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14864 			      pctype_id, RTE_UINT8);
14865 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14866 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14867 				 inset_type,
14868 				 "hash_inset#fdir_inset#fdir_flx_inset");
14869 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14870 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14871 				 clear, "clear");
14872 cmdline_parse_token_string_t cmd_clear_input_set_all =
14873 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14874 				 all, "all");
14875 
14876 cmdline_parse_inst_t cmd_clear_input_set = {
14877 	.f = cmd_clear_input_set_parsed,
14878 	.data = NULL,
14879 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14880 		    "fdir_inset|fdir_flx_inset clear all",
14881 	.tokens = {
14882 		(void *)&cmd_clear_input_set_port,
14883 		(void *)&cmd_clear_input_set_cfg,
14884 		(void *)&cmd_clear_input_set_port_id,
14885 		(void *)&cmd_clear_input_set_pctype,
14886 		(void *)&cmd_clear_input_set_pctype_id,
14887 		(void *)&cmd_clear_input_set_inset_type,
14888 		(void *)&cmd_clear_input_set_clear,
14889 		(void *)&cmd_clear_input_set_all,
14890 		NULL,
14891 	},
14892 };
14893 
14894 /* show vf stats */
14895 
14896 /* Common result structure for show vf stats */
14897 struct cmd_show_vf_stats_result {
14898 	cmdline_fixed_string_t show;
14899 	cmdline_fixed_string_t vf;
14900 	cmdline_fixed_string_t stats;
14901 	portid_t port_id;
14902 	uint16_t vf_id;
14903 };
14904 
14905 /* Common CLI fields show vf stats*/
14906 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14907 	TOKEN_STRING_INITIALIZER
14908 		(struct cmd_show_vf_stats_result,
14909 		 show, "show");
14910 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14911 	TOKEN_STRING_INITIALIZER
14912 		(struct cmd_show_vf_stats_result,
14913 		 vf, "vf");
14914 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14915 	TOKEN_STRING_INITIALIZER
14916 		(struct cmd_show_vf_stats_result,
14917 		 stats, "stats");
14918 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14919 	TOKEN_NUM_INITIALIZER
14920 		(struct cmd_show_vf_stats_result,
14921 		 port_id, RTE_UINT16);
14922 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14923 	TOKEN_NUM_INITIALIZER
14924 		(struct cmd_show_vf_stats_result,
14925 		 vf_id, RTE_UINT16);
14926 
14927 static void
14928 cmd_show_vf_stats_parsed(
14929 	void *parsed_result,
14930 	__rte_unused struct cmdline *cl,
14931 	__rte_unused void *data)
14932 {
14933 	struct cmd_show_vf_stats_result *res = parsed_result;
14934 	struct rte_eth_stats stats;
14935 	int ret = -ENOTSUP;
14936 	static const char *nic_stats_border = "########################";
14937 
14938 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14939 		return;
14940 
14941 	memset(&stats, 0, sizeof(stats));
14942 
14943 #ifdef RTE_NET_I40E
14944 	if (ret == -ENOTSUP)
14945 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14946 						res->vf_id,
14947 						&stats);
14948 #endif
14949 #ifdef RTE_NET_BNXT
14950 	if (ret == -ENOTSUP)
14951 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14952 						res->vf_id,
14953 						&stats);
14954 #endif
14955 
14956 	switch (ret) {
14957 	case 0:
14958 		break;
14959 	case -EINVAL:
14960 		printf("invalid vf_id %d\n", res->vf_id);
14961 		break;
14962 	case -ENODEV:
14963 		printf("invalid port_id %d\n", res->port_id);
14964 		break;
14965 	case -ENOTSUP:
14966 		printf("function not implemented\n");
14967 		break;
14968 	default:
14969 		printf("programming error: (%s)\n", strerror(-ret));
14970 	}
14971 
14972 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
14973 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14974 
14975 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
14976 	       "%-"PRIu64"\n",
14977 	       stats.ipackets, stats.imissed, stats.ibytes);
14978 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
14979 	printf("  RX-nombuf:  %-10"PRIu64"\n",
14980 	       stats.rx_nombuf);
14981 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
14982 	       "%-"PRIu64"\n",
14983 	       stats.opackets, stats.oerrors, stats.obytes);
14984 
14985 	printf("  %s############################%s\n",
14986 			       nic_stats_border, nic_stats_border);
14987 }
14988 
14989 cmdline_parse_inst_t cmd_show_vf_stats = {
14990 	.f = cmd_show_vf_stats_parsed,
14991 	.data = NULL,
14992 	.help_str = "show vf stats <port_id> <vf_id>",
14993 	.tokens = {
14994 		(void *)&cmd_show_vf_stats_show,
14995 		(void *)&cmd_show_vf_stats_vf,
14996 		(void *)&cmd_show_vf_stats_stats,
14997 		(void *)&cmd_show_vf_stats_port_id,
14998 		(void *)&cmd_show_vf_stats_vf_id,
14999 		NULL,
15000 	},
15001 };
15002 
15003 /* clear vf stats */
15004 
15005 /* Common result structure for clear vf stats */
15006 struct cmd_clear_vf_stats_result {
15007 	cmdline_fixed_string_t clear;
15008 	cmdline_fixed_string_t vf;
15009 	cmdline_fixed_string_t stats;
15010 	portid_t port_id;
15011 	uint16_t vf_id;
15012 };
15013 
15014 /* Common CLI fields clear vf stats*/
15015 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15016 	TOKEN_STRING_INITIALIZER
15017 		(struct cmd_clear_vf_stats_result,
15018 		 clear, "clear");
15019 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15020 	TOKEN_STRING_INITIALIZER
15021 		(struct cmd_clear_vf_stats_result,
15022 		 vf, "vf");
15023 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15024 	TOKEN_STRING_INITIALIZER
15025 		(struct cmd_clear_vf_stats_result,
15026 		 stats, "stats");
15027 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15028 	TOKEN_NUM_INITIALIZER
15029 		(struct cmd_clear_vf_stats_result,
15030 		 port_id, RTE_UINT16);
15031 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15032 	TOKEN_NUM_INITIALIZER
15033 		(struct cmd_clear_vf_stats_result,
15034 		 vf_id, RTE_UINT16);
15035 
15036 static void
15037 cmd_clear_vf_stats_parsed(
15038 	void *parsed_result,
15039 	__rte_unused struct cmdline *cl,
15040 	__rte_unused void *data)
15041 {
15042 	struct cmd_clear_vf_stats_result *res = parsed_result;
15043 	int ret = -ENOTSUP;
15044 
15045 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15046 		return;
15047 
15048 #ifdef RTE_NET_I40E
15049 	if (ret == -ENOTSUP)
15050 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15051 						  res->vf_id);
15052 #endif
15053 #ifdef RTE_NET_BNXT
15054 	if (ret == -ENOTSUP)
15055 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15056 						  res->vf_id);
15057 #endif
15058 
15059 	switch (ret) {
15060 	case 0:
15061 		break;
15062 	case -EINVAL:
15063 		printf("invalid vf_id %d\n", res->vf_id);
15064 		break;
15065 	case -ENODEV:
15066 		printf("invalid port_id %d\n", res->port_id);
15067 		break;
15068 	case -ENOTSUP:
15069 		printf("function not implemented\n");
15070 		break;
15071 	default:
15072 		printf("programming error: (%s)\n", strerror(-ret));
15073 	}
15074 }
15075 
15076 cmdline_parse_inst_t cmd_clear_vf_stats = {
15077 	.f = cmd_clear_vf_stats_parsed,
15078 	.data = NULL,
15079 	.help_str = "clear vf stats <port_id> <vf_id>",
15080 	.tokens = {
15081 		(void *)&cmd_clear_vf_stats_clear,
15082 		(void *)&cmd_clear_vf_stats_vf,
15083 		(void *)&cmd_clear_vf_stats_stats,
15084 		(void *)&cmd_clear_vf_stats_port_id,
15085 		(void *)&cmd_clear_vf_stats_vf_id,
15086 		NULL,
15087 	},
15088 };
15089 
15090 /* port config pctype mapping reset */
15091 
15092 /* Common result structure for port config pctype mapping reset */
15093 struct cmd_pctype_mapping_reset_result {
15094 	cmdline_fixed_string_t port;
15095 	cmdline_fixed_string_t config;
15096 	portid_t port_id;
15097 	cmdline_fixed_string_t pctype;
15098 	cmdline_fixed_string_t mapping;
15099 	cmdline_fixed_string_t reset;
15100 };
15101 
15102 /* Common CLI fields for port config pctype mapping reset*/
15103 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15104 	TOKEN_STRING_INITIALIZER
15105 		(struct cmd_pctype_mapping_reset_result,
15106 		 port, "port");
15107 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15108 	TOKEN_STRING_INITIALIZER
15109 		(struct cmd_pctype_mapping_reset_result,
15110 		 config, "config");
15111 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15112 	TOKEN_NUM_INITIALIZER
15113 		(struct cmd_pctype_mapping_reset_result,
15114 		 port_id, RTE_UINT16);
15115 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15116 	TOKEN_STRING_INITIALIZER
15117 		(struct cmd_pctype_mapping_reset_result,
15118 		 pctype, "pctype");
15119 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15120 	TOKEN_STRING_INITIALIZER
15121 		(struct cmd_pctype_mapping_reset_result,
15122 		 mapping, "mapping");
15123 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15124 	TOKEN_STRING_INITIALIZER
15125 		(struct cmd_pctype_mapping_reset_result,
15126 		 reset, "reset");
15127 
15128 static void
15129 cmd_pctype_mapping_reset_parsed(
15130 	void *parsed_result,
15131 	__rte_unused struct cmdline *cl,
15132 	__rte_unused void *data)
15133 {
15134 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15135 	int ret = -ENOTSUP;
15136 
15137 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15138 		return;
15139 
15140 #ifdef RTE_NET_I40E
15141 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15142 #endif
15143 
15144 	switch (ret) {
15145 	case 0:
15146 		break;
15147 	case -ENODEV:
15148 		printf("invalid port_id %d\n", res->port_id);
15149 		break;
15150 	case -ENOTSUP:
15151 		printf("function not implemented\n");
15152 		break;
15153 	default:
15154 		printf("programming error: (%s)\n", strerror(-ret));
15155 	}
15156 }
15157 
15158 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15159 	.f = cmd_pctype_mapping_reset_parsed,
15160 	.data = NULL,
15161 	.help_str = "port config <port_id> pctype mapping reset",
15162 	.tokens = {
15163 		(void *)&cmd_pctype_mapping_reset_port,
15164 		(void *)&cmd_pctype_mapping_reset_config,
15165 		(void *)&cmd_pctype_mapping_reset_port_id,
15166 		(void *)&cmd_pctype_mapping_reset_pctype,
15167 		(void *)&cmd_pctype_mapping_reset_mapping,
15168 		(void *)&cmd_pctype_mapping_reset_reset,
15169 		NULL,
15170 	},
15171 };
15172 
15173 /* show port pctype mapping */
15174 
15175 /* Common result structure for show port pctype mapping */
15176 struct cmd_pctype_mapping_get_result {
15177 	cmdline_fixed_string_t show;
15178 	cmdline_fixed_string_t port;
15179 	portid_t port_id;
15180 	cmdline_fixed_string_t pctype;
15181 	cmdline_fixed_string_t mapping;
15182 };
15183 
15184 /* Common CLI fields for pctype mapping get */
15185 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15186 	TOKEN_STRING_INITIALIZER
15187 		(struct cmd_pctype_mapping_get_result,
15188 		 show, "show");
15189 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15190 	TOKEN_STRING_INITIALIZER
15191 		(struct cmd_pctype_mapping_get_result,
15192 		 port, "port");
15193 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15194 	TOKEN_NUM_INITIALIZER
15195 		(struct cmd_pctype_mapping_get_result,
15196 		 port_id, RTE_UINT16);
15197 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15198 	TOKEN_STRING_INITIALIZER
15199 		(struct cmd_pctype_mapping_get_result,
15200 		 pctype, "pctype");
15201 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15202 	TOKEN_STRING_INITIALIZER
15203 		(struct cmd_pctype_mapping_get_result,
15204 		 mapping, "mapping");
15205 
15206 static void
15207 cmd_pctype_mapping_get_parsed(
15208 	void *parsed_result,
15209 	__rte_unused struct cmdline *cl,
15210 	__rte_unused void *data)
15211 {
15212 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15213 	int ret = -ENOTSUP;
15214 #ifdef RTE_NET_I40E
15215 	struct rte_pmd_i40e_flow_type_mapping
15216 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15217 	int i, j, first_pctype;
15218 #endif
15219 
15220 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15221 		return;
15222 
15223 #ifdef RTE_NET_I40E
15224 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15225 #endif
15226 
15227 	switch (ret) {
15228 	case 0:
15229 		break;
15230 	case -ENODEV:
15231 		printf("invalid port_id %d\n", res->port_id);
15232 		return;
15233 	case -ENOTSUP:
15234 		printf("function not implemented\n");
15235 		return;
15236 	default:
15237 		printf("programming error: (%s)\n", strerror(-ret));
15238 		return;
15239 	}
15240 
15241 #ifdef RTE_NET_I40E
15242 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15243 		if (mapping[i].pctype != 0ULL) {
15244 			first_pctype = 1;
15245 
15246 			printf("pctype: ");
15247 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15248 				if (mapping[i].pctype & (1ULL << j)) {
15249 					printf(first_pctype ?
15250 					       "%02d" : ",%02d", j);
15251 					first_pctype = 0;
15252 				}
15253 			}
15254 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15255 		}
15256 	}
15257 #endif
15258 }
15259 
15260 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15261 	.f = cmd_pctype_mapping_get_parsed,
15262 	.data = NULL,
15263 	.help_str = "show port <port_id> pctype mapping",
15264 	.tokens = {
15265 		(void *)&cmd_pctype_mapping_get_show,
15266 		(void *)&cmd_pctype_mapping_get_port,
15267 		(void *)&cmd_pctype_mapping_get_port_id,
15268 		(void *)&cmd_pctype_mapping_get_pctype,
15269 		(void *)&cmd_pctype_mapping_get_mapping,
15270 		NULL,
15271 	},
15272 };
15273 
15274 /* port config pctype mapping update */
15275 
15276 /* Common result structure for port config pctype mapping update */
15277 struct cmd_pctype_mapping_update_result {
15278 	cmdline_fixed_string_t port;
15279 	cmdline_fixed_string_t config;
15280 	portid_t port_id;
15281 	cmdline_fixed_string_t pctype;
15282 	cmdline_fixed_string_t mapping;
15283 	cmdline_fixed_string_t update;
15284 	cmdline_fixed_string_t pctype_list;
15285 	uint16_t flow_type;
15286 };
15287 
15288 /* Common CLI fields for pctype mapping update*/
15289 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15290 	TOKEN_STRING_INITIALIZER
15291 		(struct cmd_pctype_mapping_update_result,
15292 		 port, "port");
15293 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15294 	TOKEN_STRING_INITIALIZER
15295 		(struct cmd_pctype_mapping_update_result,
15296 		 config, "config");
15297 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15298 	TOKEN_NUM_INITIALIZER
15299 		(struct cmd_pctype_mapping_update_result,
15300 		 port_id, RTE_UINT16);
15301 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15302 	TOKEN_STRING_INITIALIZER
15303 		(struct cmd_pctype_mapping_update_result,
15304 		 pctype, "pctype");
15305 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15306 	TOKEN_STRING_INITIALIZER
15307 		(struct cmd_pctype_mapping_update_result,
15308 		 mapping, "mapping");
15309 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15310 	TOKEN_STRING_INITIALIZER
15311 		(struct cmd_pctype_mapping_update_result,
15312 		 update, "update");
15313 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15314 	TOKEN_STRING_INITIALIZER
15315 		(struct cmd_pctype_mapping_update_result,
15316 		 pctype_list, NULL);
15317 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15318 	TOKEN_NUM_INITIALIZER
15319 		(struct cmd_pctype_mapping_update_result,
15320 		 flow_type, RTE_UINT16);
15321 
15322 static void
15323 cmd_pctype_mapping_update_parsed(
15324 	void *parsed_result,
15325 	__rte_unused struct cmdline *cl,
15326 	__rte_unused void *data)
15327 {
15328 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15329 	int ret = -ENOTSUP;
15330 #ifdef RTE_NET_I40E
15331 	struct rte_pmd_i40e_flow_type_mapping mapping;
15332 	unsigned int i;
15333 	unsigned int nb_item;
15334 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15335 #endif
15336 
15337 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15338 		return;
15339 
15340 #ifdef RTE_NET_I40E
15341 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15342 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15343 	mapping.flow_type = res->flow_type;
15344 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15345 		mapping.pctype |= (1ULL << pctype_list[i]);
15346 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15347 						&mapping,
15348 						1,
15349 						0);
15350 #endif
15351 
15352 	switch (ret) {
15353 	case 0:
15354 		break;
15355 	case -EINVAL:
15356 		printf("invalid pctype or flow type\n");
15357 		break;
15358 	case -ENODEV:
15359 		printf("invalid port_id %d\n", res->port_id);
15360 		break;
15361 	case -ENOTSUP:
15362 		printf("function not implemented\n");
15363 		break;
15364 	default:
15365 		printf("programming error: (%s)\n", strerror(-ret));
15366 	}
15367 }
15368 
15369 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15370 	.f = cmd_pctype_mapping_update_parsed,
15371 	.data = NULL,
15372 	.help_str = "port config <port_id> pctype mapping update"
15373 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15374 	.tokens = {
15375 		(void *)&cmd_pctype_mapping_update_port,
15376 		(void *)&cmd_pctype_mapping_update_config,
15377 		(void *)&cmd_pctype_mapping_update_port_id,
15378 		(void *)&cmd_pctype_mapping_update_pctype,
15379 		(void *)&cmd_pctype_mapping_update_mapping,
15380 		(void *)&cmd_pctype_mapping_update_update,
15381 		(void *)&cmd_pctype_mapping_update_pc_type,
15382 		(void *)&cmd_pctype_mapping_update_flow_type,
15383 		NULL,
15384 	},
15385 };
15386 
15387 /* ptype mapping get */
15388 
15389 /* Common result structure for ptype mapping get */
15390 struct cmd_ptype_mapping_get_result {
15391 	cmdline_fixed_string_t ptype;
15392 	cmdline_fixed_string_t mapping;
15393 	cmdline_fixed_string_t get;
15394 	portid_t port_id;
15395 	uint8_t valid_only;
15396 };
15397 
15398 /* Common CLI fields for ptype mapping get */
15399 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15400 	TOKEN_STRING_INITIALIZER
15401 		(struct cmd_ptype_mapping_get_result,
15402 		 ptype, "ptype");
15403 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15404 	TOKEN_STRING_INITIALIZER
15405 		(struct cmd_ptype_mapping_get_result,
15406 		 mapping, "mapping");
15407 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15408 	TOKEN_STRING_INITIALIZER
15409 		(struct cmd_ptype_mapping_get_result,
15410 		 get, "get");
15411 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15412 	TOKEN_NUM_INITIALIZER
15413 		(struct cmd_ptype_mapping_get_result,
15414 		 port_id, RTE_UINT16);
15415 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15416 	TOKEN_NUM_INITIALIZER
15417 		(struct cmd_ptype_mapping_get_result,
15418 		 valid_only, RTE_UINT8);
15419 
15420 static void
15421 cmd_ptype_mapping_get_parsed(
15422 	void *parsed_result,
15423 	__rte_unused struct cmdline *cl,
15424 	__rte_unused void *data)
15425 {
15426 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15427 	int ret = -ENOTSUP;
15428 #ifdef RTE_NET_I40E
15429 	int max_ptype_num = 256;
15430 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15431 	uint16_t count;
15432 	int i;
15433 #endif
15434 
15435 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15436 		return;
15437 
15438 #ifdef RTE_NET_I40E
15439 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15440 					mapping,
15441 					max_ptype_num,
15442 					&count,
15443 					res->valid_only);
15444 #endif
15445 
15446 	switch (ret) {
15447 	case 0:
15448 		break;
15449 	case -ENODEV:
15450 		printf("invalid port_id %d\n", res->port_id);
15451 		break;
15452 	case -ENOTSUP:
15453 		printf("function not implemented\n");
15454 		break;
15455 	default:
15456 		printf("programming error: (%s)\n", strerror(-ret));
15457 	}
15458 
15459 #ifdef RTE_NET_I40E
15460 	if (!ret) {
15461 		for (i = 0; i < count; i++)
15462 			printf("%3d\t0x%08x\n",
15463 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15464 	}
15465 #endif
15466 }
15467 
15468 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15469 	.f = cmd_ptype_mapping_get_parsed,
15470 	.data = NULL,
15471 	.help_str = "ptype mapping get <port_id> <valid_only>",
15472 	.tokens = {
15473 		(void *)&cmd_ptype_mapping_get_ptype,
15474 		(void *)&cmd_ptype_mapping_get_mapping,
15475 		(void *)&cmd_ptype_mapping_get_get,
15476 		(void *)&cmd_ptype_mapping_get_port_id,
15477 		(void *)&cmd_ptype_mapping_get_valid_only,
15478 		NULL,
15479 	},
15480 };
15481 
15482 /* ptype mapping replace */
15483 
15484 /* Common result structure for ptype mapping replace */
15485 struct cmd_ptype_mapping_replace_result {
15486 	cmdline_fixed_string_t ptype;
15487 	cmdline_fixed_string_t mapping;
15488 	cmdline_fixed_string_t replace;
15489 	portid_t port_id;
15490 	uint32_t target;
15491 	uint8_t mask;
15492 	uint32_t pkt_type;
15493 };
15494 
15495 /* Common CLI fields for ptype mapping replace */
15496 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15497 	TOKEN_STRING_INITIALIZER
15498 		(struct cmd_ptype_mapping_replace_result,
15499 		 ptype, "ptype");
15500 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15501 	TOKEN_STRING_INITIALIZER
15502 		(struct cmd_ptype_mapping_replace_result,
15503 		 mapping, "mapping");
15504 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15505 	TOKEN_STRING_INITIALIZER
15506 		(struct cmd_ptype_mapping_replace_result,
15507 		 replace, "replace");
15508 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15509 	TOKEN_NUM_INITIALIZER
15510 		(struct cmd_ptype_mapping_replace_result,
15511 		 port_id, RTE_UINT16);
15512 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15513 	TOKEN_NUM_INITIALIZER
15514 		(struct cmd_ptype_mapping_replace_result,
15515 		 target, RTE_UINT32);
15516 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15517 	TOKEN_NUM_INITIALIZER
15518 		(struct cmd_ptype_mapping_replace_result,
15519 		 mask, RTE_UINT8);
15520 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15521 	TOKEN_NUM_INITIALIZER
15522 		(struct cmd_ptype_mapping_replace_result,
15523 		 pkt_type, RTE_UINT32);
15524 
15525 static void
15526 cmd_ptype_mapping_replace_parsed(
15527 	void *parsed_result,
15528 	__rte_unused struct cmdline *cl,
15529 	__rte_unused void *data)
15530 {
15531 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15532 	int ret = -ENOTSUP;
15533 
15534 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15535 		return;
15536 
15537 #ifdef RTE_NET_I40E
15538 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15539 					res->target,
15540 					res->mask,
15541 					res->pkt_type);
15542 #endif
15543 
15544 	switch (ret) {
15545 	case 0:
15546 		break;
15547 	case -EINVAL:
15548 		printf("invalid ptype 0x%8x or 0x%8x\n",
15549 				res->target, res->pkt_type);
15550 		break;
15551 	case -ENODEV:
15552 		printf("invalid port_id %d\n", res->port_id);
15553 		break;
15554 	case -ENOTSUP:
15555 		printf("function not implemented\n");
15556 		break;
15557 	default:
15558 		printf("programming error: (%s)\n", strerror(-ret));
15559 	}
15560 }
15561 
15562 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15563 	.f = cmd_ptype_mapping_replace_parsed,
15564 	.data = NULL,
15565 	.help_str =
15566 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15567 	.tokens = {
15568 		(void *)&cmd_ptype_mapping_replace_ptype,
15569 		(void *)&cmd_ptype_mapping_replace_mapping,
15570 		(void *)&cmd_ptype_mapping_replace_replace,
15571 		(void *)&cmd_ptype_mapping_replace_port_id,
15572 		(void *)&cmd_ptype_mapping_replace_target,
15573 		(void *)&cmd_ptype_mapping_replace_mask,
15574 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15575 		NULL,
15576 	},
15577 };
15578 
15579 /* ptype mapping reset */
15580 
15581 /* Common result structure for ptype mapping reset */
15582 struct cmd_ptype_mapping_reset_result {
15583 	cmdline_fixed_string_t ptype;
15584 	cmdline_fixed_string_t mapping;
15585 	cmdline_fixed_string_t reset;
15586 	portid_t port_id;
15587 };
15588 
15589 /* Common CLI fields for ptype mapping reset*/
15590 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15591 	TOKEN_STRING_INITIALIZER
15592 		(struct cmd_ptype_mapping_reset_result,
15593 		 ptype, "ptype");
15594 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15595 	TOKEN_STRING_INITIALIZER
15596 		(struct cmd_ptype_mapping_reset_result,
15597 		 mapping, "mapping");
15598 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15599 	TOKEN_STRING_INITIALIZER
15600 		(struct cmd_ptype_mapping_reset_result,
15601 		 reset, "reset");
15602 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15603 	TOKEN_NUM_INITIALIZER
15604 		(struct cmd_ptype_mapping_reset_result,
15605 		 port_id, RTE_UINT16);
15606 
15607 static void
15608 cmd_ptype_mapping_reset_parsed(
15609 	void *parsed_result,
15610 	__rte_unused struct cmdline *cl,
15611 	__rte_unused void *data)
15612 {
15613 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15614 	int ret = -ENOTSUP;
15615 
15616 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15617 		return;
15618 
15619 #ifdef RTE_NET_I40E
15620 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15621 #endif
15622 
15623 	switch (ret) {
15624 	case 0:
15625 		break;
15626 	case -ENODEV:
15627 		printf("invalid port_id %d\n", res->port_id);
15628 		break;
15629 	case -ENOTSUP:
15630 		printf("function not implemented\n");
15631 		break;
15632 	default:
15633 		printf("programming error: (%s)\n", strerror(-ret));
15634 	}
15635 }
15636 
15637 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15638 	.f = cmd_ptype_mapping_reset_parsed,
15639 	.data = NULL,
15640 	.help_str = "ptype mapping reset <port_id>",
15641 	.tokens = {
15642 		(void *)&cmd_ptype_mapping_reset_ptype,
15643 		(void *)&cmd_ptype_mapping_reset_mapping,
15644 		(void *)&cmd_ptype_mapping_reset_reset,
15645 		(void *)&cmd_ptype_mapping_reset_port_id,
15646 		NULL,
15647 	},
15648 };
15649 
15650 /* ptype mapping update */
15651 
15652 /* Common result structure for ptype mapping update */
15653 struct cmd_ptype_mapping_update_result {
15654 	cmdline_fixed_string_t ptype;
15655 	cmdline_fixed_string_t mapping;
15656 	cmdline_fixed_string_t reset;
15657 	portid_t port_id;
15658 	uint8_t hw_ptype;
15659 	uint32_t sw_ptype;
15660 };
15661 
15662 /* Common CLI fields for ptype mapping update*/
15663 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15664 	TOKEN_STRING_INITIALIZER
15665 		(struct cmd_ptype_mapping_update_result,
15666 		 ptype, "ptype");
15667 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15668 	TOKEN_STRING_INITIALIZER
15669 		(struct cmd_ptype_mapping_update_result,
15670 		 mapping, "mapping");
15671 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15672 	TOKEN_STRING_INITIALIZER
15673 		(struct cmd_ptype_mapping_update_result,
15674 		 reset, "update");
15675 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15676 	TOKEN_NUM_INITIALIZER
15677 		(struct cmd_ptype_mapping_update_result,
15678 		 port_id, RTE_UINT16);
15679 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15680 	TOKEN_NUM_INITIALIZER
15681 		(struct cmd_ptype_mapping_update_result,
15682 		 hw_ptype, RTE_UINT8);
15683 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15684 	TOKEN_NUM_INITIALIZER
15685 		(struct cmd_ptype_mapping_update_result,
15686 		 sw_ptype, RTE_UINT32);
15687 
15688 static void
15689 cmd_ptype_mapping_update_parsed(
15690 	void *parsed_result,
15691 	__rte_unused struct cmdline *cl,
15692 	__rte_unused void *data)
15693 {
15694 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15695 	int ret = -ENOTSUP;
15696 #ifdef RTE_NET_I40E
15697 	struct rte_pmd_i40e_ptype_mapping mapping;
15698 #endif
15699 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15700 		return;
15701 
15702 #ifdef RTE_NET_I40E
15703 	mapping.hw_ptype = res->hw_ptype;
15704 	mapping.sw_ptype = res->sw_ptype;
15705 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15706 						&mapping,
15707 						1,
15708 						0);
15709 #endif
15710 
15711 	switch (ret) {
15712 	case 0:
15713 		break;
15714 	case -EINVAL:
15715 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
15716 		break;
15717 	case -ENODEV:
15718 		printf("invalid port_id %d\n", res->port_id);
15719 		break;
15720 	case -ENOTSUP:
15721 		printf("function not implemented\n");
15722 		break;
15723 	default:
15724 		printf("programming error: (%s)\n", strerror(-ret));
15725 	}
15726 }
15727 
15728 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15729 	.f = cmd_ptype_mapping_update_parsed,
15730 	.data = NULL,
15731 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15732 	.tokens = {
15733 		(void *)&cmd_ptype_mapping_update_ptype,
15734 		(void *)&cmd_ptype_mapping_update_mapping,
15735 		(void *)&cmd_ptype_mapping_update_update,
15736 		(void *)&cmd_ptype_mapping_update_port_id,
15737 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15738 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15739 		NULL,
15740 	},
15741 };
15742 
15743 /* Common result structure for file commands */
15744 struct cmd_cmdfile_result {
15745 	cmdline_fixed_string_t load;
15746 	cmdline_fixed_string_t filename;
15747 };
15748 
15749 /* Common CLI fields for file commands */
15750 cmdline_parse_token_string_t cmd_load_cmdfile =
15751 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15752 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15753 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15754 
15755 static void
15756 cmd_load_from_file_parsed(
15757 	void *parsed_result,
15758 	__rte_unused struct cmdline *cl,
15759 	__rte_unused void *data)
15760 {
15761 	struct cmd_cmdfile_result *res = parsed_result;
15762 
15763 	cmdline_read_from_file(res->filename);
15764 }
15765 
15766 cmdline_parse_inst_t cmd_load_from_file = {
15767 	.f = cmd_load_from_file_parsed,
15768 	.data = NULL,
15769 	.help_str = "load <filename>",
15770 	.tokens = {
15771 		(void *)&cmd_load_cmdfile,
15772 		(void *)&cmd_load_cmdfile_filename,
15773 		NULL,
15774 	},
15775 };
15776 
15777 /* Get Rx offloads capabilities */
15778 struct cmd_rx_offload_get_capa_result {
15779 	cmdline_fixed_string_t show;
15780 	cmdline_fixed_string_t port;
15781 	portid_t port_id;
15782 	cmdline_fixed_string_t rx_offload;
15783 	cmdline_fixed_string_t capabilities;
15784 };
15785 
15786 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15787 	TOKEN_STRING_INITIALIZER
15788 		(struct cmd_rx_offload_get_capa_result,
15789 		 show, "show");
15790 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15791 	TOKEN_STRING_INITIALIZER
15792 		(struct cmd_rx_offload_get_capa_result,
15793 		 port, "port");
15794 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15795 	TOKEN_NUM_INITIALIZER
15796 		(struct cmd_rx_offload_get_capa_result,
15797 		 port_id, RTE_UINT16);
15798 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15799 	TOKEN_STRING_INITIALIZER
15800 		(struct cmd_rx_offload_get_capa_result,
15801 		 rx_offload, "rx_offload");
15802 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15803 	TOKEN_STRING_INITIALIZER
15804 		(struct cmd_rx_offload_get_capa_result,
15805 		 capabilities, "capabilities");
15806 
15807 static void
15808 print_rx_offloads(uint64_t offloads)
15809 {
15810 	uint64_t single_offload;
15811 	int begin;
15812 	int end;
15813 	int bit;
15814 
15815 	if (offloads == 0)
15816 		return;
15817 
15818 	begin = __builtin_ctzll(offloads);
15819 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15820 
15821 	single_offload = 1ULL << begin;
15822 	for (bit = begin; bit < end; bit++) {
15823 		if (offloads & single_offload)
15824 			printf(" %s",
15825 			       rte_eth_dev_rx_offload_name(single_offload));
15826 		single_offload <<= 1;
15827 	}
15828 }
15829 
15830 static void
15831 cmd_rx_offload_get_capa_parsed(
15832 	void *parsed_result,
15833 	__rte_unused struct cmdline *cl,
15834 	__rte_unused void *data)
15835 {
15836 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
15837 	struct rte_eth_dev_info dev_info;
15838 	portid_t port_id = res->port_id;
15839 	uint64_t queue_offloads;
15840 	uint64_t port_offloads;
15841 	int ret;
15842 
15843 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15844 	if (ret != 0)
15845 		return;
15846 
15847 	queue_offloads = dev_info.rx_queue_offload_capa;
15848 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15849 
15850 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
15851 	printf("  Per Queue :");
15852 	print_rx_offloads(queue_offloads);
15853 
15854 	printf("\n");
15855 	printf("  Per Port  :");
15856 	print_rx_offloads(port_offloads);
15857 	printf("\n\n");
15858 }
15859 
15860 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15861 	.f = cmd_rx_offload_get_capa_parsed,
15862 	.data = NULL,
15863 	.help_str = "show port <port_id> rx_offload capabilities",
15864 	.tokens = {
15865 		(void *)&cmd_rx_offload_get_capa_show,
15866 		(void *)&cmd_rx_offload_get_capa_port,
15867 		(void *)&cmd_rx_offload_get_capa_port_id,
15868 		(void *)&cmd_rx_offload_get_capa_rx_offload,
15869 		(void *)&cmd_rx_offload_get_capa_capabilities,
15870 		NULL,
15871 	}
15872 };
15873 
15874 /* Get Rx offloads configuration */
15875 struct cmd_rx_offload_get_configuration_result {
15876 	cmdline_fixed_string_t show;
15877 	cmdline_fixed_string_t port;
15878 	portid_t port_id;
15879 	cmdline_fixed_string_t rx_offload;
15880 	cmdline_fixed_string_t configuration;
15881 };
15882 
15883 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15884 	TOKEN_STRING_INITIALIZER
15885 		(struct cmd_rx_offload_get_configuration_result,
15886 		 show, "show");
15887 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15888 	TOKEN_STRING_INITIALIZER
15889 		(struct cmd_rx_offload_get_configuration_result,
15890 		 port, "port");
15891 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15892 	TOKEN_NUM_INITIALIZER
15893 		(struct cmd_rx_offload_get_configuration_result,
15894 		 port_id, RTE_UINT16);
15895 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15896 	TOKEN_STRING_INITIALIZER
15897 		(struct cmd_rx_offload_get_configuration_result,
15898 		 rx_offload, "rx_offload");
15899 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15900 	TOKEN_STRING_INITIALIZER
15901 		(struct cmd_rx_offload_get_configuration_result,
15902 		 configuration, "configuration");
15903 
15904 static void
15905 cmd_rx_offload_get_configuration_parsed(
15906 	void *parsed_result,
15907 	__rte_unused struct cmdline *cl,
15908 	__rte_unused void *data)
15909 {
15910 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15911 	struct rte_eth_dev_info dev_info;
15912 	portid_t port_id = res->port_id;
15913 	struct rte_port *port = &ports[port_id];
15914 	uint64_t port_offloads;
15915 	uint64_t queue_offloads;
15916 	uint16_t nb_rx_queues;
15917 	int q;
15918 	int ret;
15919 
15920 	printf("Rx Offloading Configuration of port %d :\n", port_id);
15921 
15922 	port_offloads = port->dev_conf.rxmode.offloads;
15923 	printf("  Port :");
15924 	print_rx_offloads(port_offloads);
15925 	printf("\n");
15926 
15927 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15928 	if (ret != 0)
15929 		return;
15930 
15931 	nb_rx_queues = dev_info.nb_rx_queues;
15932 	for (q = 0; q < nb_rx_queues; q++) {
15933 		queue_offloads = port->rx_conf[q].offloads;
15934 		printf("  Queue[%2d] :", q);
15935 		print_rx_offloads(queue_offloads);
15936 		printf("\n");
15937 	}
15938 	printf("\n");
15939 }
15940 
15941 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15942 	.f = cmd_rx_offload_get_configuration_parsed,
15943 	.data = NULL,
15944 	.help_str = "show port <port_id> rx_offload configuration",
15945 	.tokens = {
15946 		(void *)&cmd_rx_offload_get_configuration_show,
15947 		(void *)&cmd_rx_offload_get_configuration_port,
15948 		(void *)&cmd_rx_offload_get_configuration_port_id,
15949 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
15950 		(void *)&cmd_rx_offload_get_configuration_configuration,
15951 		NULL,
15952 	}
15953 };
15954 
15955 /* Enable/Disable a per port offloading */
15956 struct cmd_config_per_port_rx_offload_result {
15957 	cmdline_fixed_string_t port;
15958 	cmdline_fixed_string_t config;
15959 	portid_t port_id;
15960 	cmdline_fixed_string_t rx_offload;
15961 	cmdline_fixed_string_t offload;
15962 	cmdline_fixed_string_t on_off;
15963 };
15964 
15965 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15966 	TOKEN_STRING_INITIALIZER
15967 		(struct cmd_config_per_port_rx_offload_result,
15968 		 port, "port");
15969 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15970 	TOKEN_STRING_INITIALIZER
15971 		(struct cmd_config_per_port_rx_offload_result,
15972 		 config, "config");
15973 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15974 	TOKEN_NUM_INITIALIZER
15975 		(struct cmd_config_per_port_rx_offload_result,
15976 		 port_id, RTE_UINT16);
15977 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15978 	TOKEN_STRING_INITIALIZER
15979 		(struct cmd_config_per_port_rx_offload_result,
15980 		 rx_offload, "rx_offload");
15981 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15982 	TOKEN_STRING_INITIALIZER
15983 		(struct cmd_config_per_port_rx_offload_result,
15984 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15985 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15986 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15987 			   "scatter#buffer_split#timestamp#security#"
15988 			   "keep_crc#rss_hash");
15989 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15990 	TOKEN_STRING_INITIALIZER
15991 		(struct cmd_config_per_port_rx_offload_result,
15992 		 on_off, "on#off");
15993 
15994 static uint64_t
15995 search_rx_offload(const char *name)
15996 {
15997 	uint64_t single_offload;
15998 	const char *single_name;
15999 	int found = 0;
16000 	unsigned int bit;
16001 
16002 	single_offload = 1;
16003 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16004 		single_name = rte_eth_dev_rx_offload_name(single_offload);
16005 		if (!strcasecmp(single_name, name)) {
16006 			found = 1;
16007 			break;
16008 		}
16009 		single_offload <<= 1;
16010 	}
16011 
16012 	if (found)
16013 		return single_offload;
16014 
16015 	return 0;
16016 }
16017 
16018 static void
16019 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16020 				__rte_unused struct cmdline *cl,
16021 				__rte_unused void *data)
16022 {
16023 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16024 	portid_t port_id = res->port_id;
16025 	struct rte_eth_dev_info dev_info;
16026 	struct rte_port *port = &ports[port_id];
16027 	uint64_t single_offload;
16028 	uint16_t nb_rx_queues;
16029 	int q;
16030 	int ret;
16031 
16032 	if (port->port_status != RTE_PORT_STOPPED) {
16033 		printf("Error: Can't config offload when Port %d "
16034 		       "is not stopped\n", port_id);
16035 		return;
16036 	}
16037 
16038 	single_offload = search_rx_offload(res->offload);
16039 	if (single_offload == 0) {
16040 		printf("Unknown offload name: %s\n", res->offload);
16041 		return;
16042 	}
16043 
16044 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16045 	if (ret != 0)
16046 		return;
16047 
16048 	nb_rx_queues = dev_info.nb_rx_queues;
16049 	if (!strcmp(res->on_off, "on")) {
16050 		port->dev_conf.rxmode.offloads |= single_offload;
16051 		for (q = 0; q < nb_rx_queues; q++)
16052 			port->rx_conf[q].offloads |= single_offload;
16053 	} else {
16054 		port->dev_conf.rxmode.offloads &= ~single_offload;
16055 		for (q = 0; q < nb_rx_queues; q++)
16056 			port->rx_conf[q].offloads &= ~single_offload;
16057 	}
16058 
16059 	cmd_reconfig_device_queue(port_id, 1, 1);
16060 }
16061 
16062 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16063 	.f = cmd_config_per_port_rx_offload_parsed,
16064 	.data = NULL,
16065 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16066 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16067 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16068 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16069 		    "keep_crc|rss_hash on|off",
16070 	.tokens = {
16071 		(void *)&cmd_config_per_port_rx_offload_result_port,
16072 		(void *)&cmd_config_per_port_rx_offload_result_config,
16073 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
16074 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16075 		(void *)&cmd_config_per_port_rx_offload_result_offload,
16076 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
16077 		NULL,
16078 	}
16079 };
16080 
16081 /* Enable/Disable a per queue offloading */
16082 struct cmd_config_per_queue_rx_offload_result {
16083 	cmdline_fixed_string_t port;
16084 	portid_t port_id;
16085 	cmdline_fixed_string_t rxq;
16086 	uint16_t queue_id;
16087 	cmdline_fixed_string_t rx_offload;
16088 	cmdline_fixed_string_t offload;
16089 	cmdline_fixed_string_t on_off;
16090 };
16091 
16092 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16093 	TOKEN_STRING_INITIALIZER
16094 		(struct cmd_config_per_queue_rx_offload_result,
16095 		 port, "port");
16096 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16097 	TOKEN_NUM_INITIALIZER
16098 		(struct cmd_config_per_queue_rx_offload_result,
16099 		 port_id, RTE_UINT16);
16100 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16101 	TOKEN_STRING_INITIALIZER
16102 		(struct cmd_config_per_queue_rx_offload_result,
16103 		 rxq, "rxq");
16104 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16105 	TOKEN_NUM_INITIALIZER
16106 		(struct cmd_config_per_queue_rx_offload_result,
16107 		 queue_id, RTE_UINT16);
16108 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16109 	TOKEN_STRING_INITIALIZER
16110 		(struct cmd_config_per_queue_rx_offload_result,
16111 		 rx_offload, "rx_offload");
16112 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16113 	TOKEN_STRING_INITIALIZER
16114 		(struct cmd_config_per_queue_rx_offload_result,
16115 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16116 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16117 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16118 			   "scatter#buffer_split#timestamp#security#keep_crc");
16119 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16120 	TOKEN_STRING_INITIALIZER
16121 		(struct cmd_config_per_queue_rx_offload_result,
16122 		 on_off, "on#off");
16123 
16124 static void
16125 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16126 				__rte_unused struct cmdline *cl,
16127 				__rte_unused void *data)
16128 {
16129 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16130 	struct rte_eth_dev_info dev_info;
16131 	portid_t port_id = res->port_id;
16132 	uint16_t queue_id = res->queue_id;
16133 	struct rte_port *port = &ports[port_id];
16134 	uint64_t single_offload;
16135 	int ret;
16136 
16137 	if (port->port_status != RTE_PORT_STOPPED) {
16138 		printf("Error: Can't config offload when Port %d "
16139 		       "is not stopped\n", port_id);
16140 		return;
16141 	}
16142 
16143 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16144 	if (ret != 0)
16145 		return;
16146 
16147 	if (queue_id >= dev_info.nb_rx_queues) {
16148 		printf("Error: input queue_id should be 0 ... "
16149 		       "%d\n", dev_info.nb_rx_queues - 1);
16150 		return;
16151 	}
16152 
16153 	single_offload = search_rx_offload(res->offload);
16154 	if (single_offload == 0) {
16155 		printf("Unknown offload name: %s\n", res->offload);
16156 		return;
16157 	}
16158 
16159 	if (!strcmp(res->on_off, "on"))
16160 		port->rx_conf[queue_id].offloads |= single_offload;
16161 	else
16162 		port->rx_conf[queue_id].offloads &= ~single_offload;
16163 
16164 	cmd_reconfig_device_queue(port_id, 1, 1);
16165 }
16166 
16167 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16168 	.f = cmd_config_per_queue_rx_offload_parsed,
16169 	.data = NULL,
16170 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
16171 		    "vlan_strip|ipv4_cksum|"
16172 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16173 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16174 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16175 		    "keep_crc on|off",
16176 	.tokens = {
16177 		(void *)&cmd_config_per_queue_rx_offload_result_port,
16178 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
16179 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
16180 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16181 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16182 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
16183 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
16184 		NULL,
16185 	}
16186 };
16187 
16188 /* Get Tx offloads capabilities */
16189 struct cmd_tx_offload_get_capa_result {
16190 	cmdline_fixed_string_t show;
16191 	cmdline_fixed_string_t port;
16192 	portid_t port_id;
16193 	cmdline_fixed_string_t tx_offload;
16194 	cmdline_fixed_string_t capabilities;
16195 };
16196 
16197 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16198 	TOKEN_STRING_INITIALIZER
16199 		(struct cmd_tx_offload_get_capa_result,
16200 		 show, "show");
16201 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16202 	TOKEN_STRING_INITIALIZER
16203 		(struct cmd_tx_offload_get_capa_result,
16204 		 port, "port");
16205 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16206 	TOKEN_NUM_INITIALIZER
16207 		(struct cmd_tx_offload_get_capa_result,
16208 		 port_id, RTE_UINT16);
16209 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16210 	TOKEN_STRING_INITIALIZER
16211 		(struct cmd_tx_offload_get_capa_result,
16212 		 tx_offload, "tx_offload");
16213 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16214 	TOKEN_STRING_INITIALIZER
16215 		(struct cmd_tx_offload_get_capa_result,
16216 		 capabilities, "capabilities");
16217 
16218 static void
16219 print_tx_offloads(uint64_t offloads)
16220 {
16221 	uint64_t single_offload;
16222 	int begin;
16223 	int end;
16224 	int bit;
16225 
16226 	if (offloads == 0)
16227 		return;
16228 
16229 	begin = __builtin_ctzll(offloads);
16230 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16231 
16232 	single_offload = 1ULL << begin;
16233 	for (bit = begin; bit < end; bit++) {
16234 		if (offloads & single_offload)
16235 			printf(" %s",
16236 			       rte_eth_dev_tx_offload_name(single_offload));
16237 		single_offload <<= 1;
16238 	}
16239 }
16240 
16241 static void
16242 cmd_tx_offload_get_capa_parsed(
16243 	void *parsed_result,
16244 	__rte_unused struct cmdline *cl,
16245 	__rte_unused void *data)
16246 {
16247 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
16248 	struct rte_eth_dev_info dev_info;
16249 	portid_t port_id = res->port_id;
16250 	uint64_t queue_offloads;
16251 	uint64_t port_offloads;
16252 	int ret;
16253 
16254 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16255 	if (ret != 0)
16256 		return;
16257 
16258 	queue_offloads = dev_info.tx_queue_offload_capa;
16259 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16260 
16261 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
16262 	printf("  Per Queue :");
16263 	print_tx_offloads(queue_offloads);
16264 
16265 	printf("\n");
16266 	printf("  Per Port  :");
16267 	print_tx_offloads(port_offloads);
16268 	printf("\n\n");
16269 }
16270 
16271 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16272 	.f = cmd_tx_offload_get_capa_parsed,
16273 	.data = NULL,
16274 	.help_str = "show port <port_id> tx_offload capabilities",
16275 	.tokens = {
16276 		(void *)&cmd_tx_offload_get_capa_show,
16277 		(void *)&cmd_tx_offload_get_capa_port,
16278 		(void *)&cmd_tx_offload_get_capa_port_id,
16279 		(void *)&cmd_tx_offload_get_capa_tx_offload,
16280 		(void *)&cmd_tx_offload_get_capa_capabilities,
16281 		NULL,
16282 	}
16283 };
16284 
16285 /* Get Tx offloads configuration */
16286 struct cmd_tx_offload_get_configuration_result {
16287 	cmdline_fixed_string_t show;
16288 	cmdline_fixed_string_t port;
16289 	portid_t port_id;
16290 	cmdline_fixed_string_t tx_offload;
16291 	cmdline_fixed_string_t configuration;
16292 };
16293 
16294 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16295 	TOKEN_STRING_INITIALIZER
16296 		(struct cmd_tx_offload_get_configuration_result,
16297 		 show, "show");
16298 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16299 	TOKEN_STRING_INITIALIZER
16300 		(struct cmd_tx_offload_get_configuration_result,
16301 		 port, "port");
16302 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16303 	TOKEN_NUM_INITIALIZER
16304 		(struct cmd_tx_offload_get_configuration_result,
16305 		 port_id, RTE_UINT16);
16306 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16307 	TOKEN_STRING_INITIALIZER
16308 		(struct cmd_tx_offload_get_configuration_result,
16309 		 tx_offload, "tx_offload");
16310 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16311 	TOKEN_STRING_INITIALIZER
16312 		(struct cmd_tx_offload_get_configuration_result,
16313 		 configuration, "configuration");
16314 
16315 static void
16316 cmd_tx_offload_get_configuration_parsed(
16317 	void *parsed_result,
16318 	__rte_unused struct cmdline *cl,
16319 	__rte_unused void *data)
16320 {
16321 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16322 	struct rte_eth_dev_info dev_info;
16323 	portid_t port_id = res->port_id;
16324 	struct rte_port *port = &ports[port_id];
16325 	uint64_t port_offloads;
16326 	uint64_t queue_offloads;
16327 	uint16_t nb_tx_queues;
16328 	int q;
16329 	int ret;
16330 
16331 	printf("Tx Offloading Configuration of port %d :\n", port_id);
16332 
16333 	port_offloads = port->dev_conf.txmode.offloads;
16334 	printf("  Port :");
16335 	print_tx_offloads(port_offloads);
16336 	printf("\n");
16337 
16338 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16339 	if (ret != 0)
16340 		return;
16341 
16342 	nb_tx_queues = dev_info.nb_tx_queues;
16343 	for (q = 0; q < nb_tx_queues; q++) {
16344 		queue_offloads = port->tx_conf[q].offloads;
16345 		printf("  Queue[%2d] :", q);
16346 		print_tx_offloads(queue_offloads);
16347 		printf("\n");
16348 	}
16349 	printf("\n");
16350 }
16351 
16352 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16353 	.f = cmd_tx_offload_get_configuration_parsed,
16354 	.data = NULL,
16355 	.help_str = "show port <port_id> tx_offload configuration",
16356 	.tokens = {
16357 		(void *)&cmd_tx_offload_get_configuration_show,
16358 		(void *)&cmd_tx_offload_get_configuration_port,
16359 		(void *)&cmd_tx_offload_get_configuration_port_id,
16360 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
16361 		(void *)&cmd_tx_offload_get_configuration_configuration,
16362 		NULL,
16363 	}
16364 };
16365 
16366 /* Enable/Disable a per port offloading */
16367 struct cmd_config_per_port_tx_offload_result {
16368 	cmdline_fixed_string_t port;
16369 	cmdline_fixed_string_t config;
16370 	portid_t port_id;
16371 	cmdline_fixed_string_t tx_offload;
16372 	cmdline_fixed_string_t offload;
16373 	cmdline_fixed_string_t on_off;
16374 };
16375 
16376 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16377 	TOKEN_STRING_INITIALIZER
16378 		(struct cmd_config_per_port_tx_offload_result,
16379 		 port, "port");
16380 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16381 	TOKEN_STRING_INITIALIZER
16382 		(struct cmd_config_per_port_tx_offload_result,
16383 		 config, "config");
16384 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16385 	TOKEN_NUM_INITIALIZER
16386 		(struct cmd_config_per_port_tx_offload_result,
16387 		 port_id, RTE_UINT16);
16388 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16389 	TOKEN_STRING_INITIALIZER
16390 		(struct cmd_config_per_port_tx_offload_result,
16391 		 tx_offload, "tx_offload");
16392 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16393 	TOKEN_STRING_INITIALIZER
16394 		(struct cmd_config_per_port_tx_offload_result,
16395 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16396 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16397 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16398 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16399 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16400 			  "send_on_timestamp");
16401 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16402 	TOKEN_STRING_INITIALIZER
16403 		(struct cmd_config_per_port_tx_offload_result,
16404 		 on_off, "on#off");
16405 
16406 static uint64_t
16407 search_tx_offload(const char *name)
16408 {
16409 	uint64_t single_offload;
16410 	const char *single_name;
16411 	int found = 0;
16412 	unsigned int bit;
16413 
16414 	single_offload = 1;
16415 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16416 		single_name = rte_eth_dev_tx_offload_name(single_offload);
16417 		if (single_name == NULL)
16418 			break;
16419 		if (!strcasecmp(single_name, name)) {
16420 			found = 1;
16421 			break;
16422 		} else if (!strcasecmp(single_name, "UNKNOWN"))
16423 			break;
16424 		single_offload <<= 1;
16425 	}
16426 
16427 	if (found)
16428 		return single_offload;
16429 
16430 	return 0;
16431 }
16432 
16433 static void
16434 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16435 				__rte_unused struct cmdline *cl,
16436 				__rte_unused void *data)
16437 {
16438 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16439 	portid_t port_id = res->port_id;
16440 	struct rte_eth_dev_info dev_info;
16441 	struct rte_port *port = &ports[port_id];
16442 	uint64_t single_offload;
16443 	uint16_t nb_tx_queues;
16444 	int q;
16445 	int ret;
16446 
16447 	if (port->port_status != RTE_PORT_STOPPED) {
16448 		printf("Error: Can't config offload when Port %d "
16449 		       "is not stopped\n", port_id);
16450 		return;
16451 	}
16452 
16453 	single_offload = search_tx_offload(res->offload);
16454 	if (single_offload == 0) {
16455 		printf("Unknown offload name: %s\n", res->offload);
16456 		return;
16457 	}
16458 
16459 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16460 	if (ret != 0)
16461 		return;
16462 
16463 	nb_tx_queues = dev_info.nb_tx_queues;
16464 	if (!strcmp(res->on_off, "on")) {
16465 		port->dev_conf.txmode.offloads |= single_offload;
16466 		for (q = 0; q < nb_tx_queues; q++)
16467 			port->tx_conf[q].offloads |= single_offload;
16468 	} else {
16469 		port->dev_conf.txmode.offloads &= ~single_offload;
16470 		for (q = 0; q < nb_tx_queues; q++)
16471 			port->tx_conf[q].offloads &= ~single_offload;
16472 	}
16473 
16474 	cmd_reconfig_device_queue(port_id, 1, 1);
16475 }
16476 
16477 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16478 	.f = cmd_config_per_port_tx_offload_parsed,
16479 	.data = NULL,
16480 	.help_str = "port config <port_id> tx_offload "
16481 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16482 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16483 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16484 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16485 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16486 		    "send_on_timestamp on|off",
16487 	.tokens = {
16488 		(void *)&cmd_config_per_port_tx_offload_result_port,
16489 		(void *)&cmd_config_per_port_tx_offload_result_config,
16490 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
16491 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16492 		(void *)&cmd_config_per_port_tx_offload_result_offload,
16493 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
16494 		NULL,
16495 	}
16496 };
16497 
16498 /* Enable/Disable a per queue offloading */
16499 struct cmd_config_per_queue_tx_offload_result {
16500 	cmdline_fixed_string_t port;
16501 	portid_t port_id;
16502 	cmdline_fixed_string_t txq;
16503 	uint16_t queue_id;
16504 	cmdline_fixed_string_t tx_offload;
16505 	cmdline_fixed_string_t offload;
16506 	cmdline_fixed_string_t on_off;
16507 };
16508 
16509 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16510 	TOKEN_STRING_INITIALIZER
16511 		(struct cmd_config_per_queue_tx_offload_result,
16512 		 port, "port");
16513 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16514 	TOKEN_NUM_INITIALIZER
16515 		(struct cmd_config_per_queue_tx_offload_result,
16516 		 port_id, RTE_UINT16);
16517 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16518 	TOKEN_STRING_INITIALIZER
16519 		(struct cmd_config_per_queue_tx_offload_result,
16520 		 txq, "txq");
16521 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16522 	TOKEN_NUM_INITIALIZER
16523 		(struct cmd_config_per_queue_tx_offload_result,
16524 		 queue_id, RTE_UINT16);
16525 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16526 	TOKEN_STRING_INITIALIZER
16527 		(struct cmd_config_per_queue_tx_offload_result,
16528 		 tx_offload, "tx_offload");
16529 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16530 	TOKEN_STRING_INITIALIZER
16531 		(struct cmd_config_per_queue_tx_offload_result,
16532 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16533 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16534 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16535 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16536 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
16537 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16538 	TOKEN_STRING_INITIALIZER
16539 		(struct cmd_config_per_queue_tx_offload_result,
16540 		 on_off, "on#off");
16541 
16542 static void
16543 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16544 				__rte_unused struct cmdline *cl,
16545 				__rte_unused void *data)
16546 {
16547 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16548 	struct rte_eth_dev_info dev_info;
16549 	portid_t port_id = res->port_id;
16550 	uint16_t queue_id = res->queue_id;
16551 	struct rte_port *port = &ports[port_id];
16552 	uint64_t single_offload;
16553 	int ret;
16554 
16555 	if (port->port_status != RTE_PORT_STOPPED) {
16556 		printf("Error: Can't config offload when Port %d "
16557 		       "is not stopped\n", port_id);
16558 		return;
16559 	}
16560 
16561 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16562 	if (ret != 0)
16563 		return;
16564 
16565 	if (queue_id >= dev_info.nb_tx_queues) {
16566 		printf("Error: input queue_id should be 0 ... "
16567 		       "%d\n", dev_info.nb_tx_queues - 1);
16568 		return;
16569 	}
16570 
16571 	single_offload = search_tx_offload(res->offload);
16572 	if (single_offload == 0) {
16573 		printf("Unknown offload name: %s\n", res->offload);
16574 		return;
16575 	}
16576 
16577 	if (!strcmp(res->on_off, "on"))
16578 		port->tx_conf[queue_id].offloads |= single_offload;
16579 	else
16580 		port->tx_conf[queue_id].offloads &= ~single_offload;
16581 
16582 	cmd_reconfig_device_queue(port_id, 1, 1);
16583 }
16584 
16585 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16586 	.f = cmd_config_per_queue_tx_offload_parsed,
16587 	.data = NULL,
16588 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16589 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16590 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16591 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16592 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16593 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16594 		    "on|off",
16595 	.tokens = {
16596 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16597 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16598 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16599 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16600 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16601 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16602 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16603 		NULL,
16604 	}
16605 };
16606 
16607 /* *** configure tx_metadata for specific port *** */
16608 struct cmd_config_tx_metadata_specific_result {
16609 	cmdline_fixed_string_t port;
16610 	cmdline_fixed_string_t keyword;
16611 	uint16_t port_id;
16612 	cmdline_fixed_string_t item;
16613 	uint32_t value;
16614 };
16615 
16616 static void
16617 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16618 				__rte_unused struct cmdline *cl,
16619 				__rte_unused void *data)
16620 {
16621 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16622 
16623 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16624 		return;
16625 	ports[res->port_id].tx_metadata = res->value;
16626 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16627 	if (ports[res->port_id].tx_metadata)
16628 		add_tx_md_callback(res->port_id);
16629 	else
16630 		remove_tx_md_callback(res->port_id);
16631 	rte_flow_dynf_metadata_register();
16632 }
16633 
16634 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16635 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16636 			port, "port");
16637 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16638 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16639 			keyword, "config");
16640 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16641 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16642 			port_id, RTE_UINT16);
16643 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16644 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16645 			item, "tx_metadata");
16646 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16647 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16648 			value, RTE_UINT32);
16649 
16650 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16651 	.f = cmd_config_tx_metadata_specific_parsed,
16652 	.data = NULL,
16653 	.help_str = "port config <port_id> tx_metadata <value>",
16654 	.tokens = {
16655 		(void *)&cmd_config_tx_metadata_specific_port,
16656 		(void *)&cmd_config_tx_metadata_specific_keyword,
16657 		(void *)&cmd_config_tx_metadata_specific_id,
16658 		(void *)&cmd_config_tx_metadata_specific_item,
16659 		(void *)&cmd_config_tx_metadata_specific_value,
16660 		NULL,
16661 	},
16662 };
16663 
16664 /* *** set dynf *** */
16665 struct cmd_config_tx_dynf_specific_result {
16666 	cmdline_fixed_string_t port;
16667 	cmdline_fixed_string_t keyword;
16668 	uint16_t port_id;
16669 	cmdline_fixed_string_t item;
16670 	cmdline_fixed_string_t name;
16671 	cmdline_fixed_string_t value;
16672 };
16673 
16674 static void
16675 cmd_config_dynf_specific_parsed(void *parsed_result,
16676 				__rte_unused struct cmdline *cl,
16677 				__rte_unused void *data)
16678 {
16679 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16680 	struct rte_mbuf_dynflag desc_flag;
16681 	int flag;
16682 	uint64_t old_port_flags;
16683 
16684 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16685 		return;
16686 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16687 	if (flag <= 0) {
16688 		if (strlcpy(desc_flag.name, res->name,
16689 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16690 			printf("Flag name too long\n");
16691 			return;
16692 		}
16693 		desc_flag.flags = 0;
16694 		flag = rte_mbuf_dynflag_register(&desc_flag);
16695 		if (flag < 0) {
16696 			printf("Can't register flag\n");
16697 			return;
16698 		}
16699 		strcpy(dynf_names[flag], desc_flag.name);
16700 	}
16701 	old_port_flags = ports[res->port_id].mbuf_dynf;
16702 	if (!strcmp(res->value, "set")) {
16703 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16704 		if (old_port_flags == 0)
16705 			add_tx_dynf_callback(res->port_id);
16706 	} else {
16707 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16708 		if (ports[res->port_id].mbuf_dynf == 0)
16709 			remove_tx_dynf_callback(res->port_id);
16710 	}
16711 }
16712 
16713 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16714 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16715 			keyword, "port");
16716 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16717 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16718 			keyword, "config");
16719 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16720 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16721 			port_id, RTE_UINT16);
16722 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16723 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16724 			item, "dynf");
16725 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16726 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16727 			name, NULL);
16728 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16729 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16730 			value, "set#clear");
16731 
16732 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16733 	.f = cmd_config_dynf_specific_parsed,
16734 	.data = NULL,
16735 	.help_str = "port config <port id> dynf <name> set|clear",
16736 	.tokens = {
16737 		(void *)&cmd_config_tx_dynf_specific_port,
16738 		(void *)&cmd_config_tx_dynf_specific_keyword,
16739 		(void *)&cmd_config_tx_dynf_specific_port_id,
16740 		(void *)&cmd_config_tx_dynf_specific_item,
16741 		(void *)&cmd_config_tx_dynf_specific_name,
16742 		(void *)&cmd_config_tx_dynf_specific_value,
16743 		NULL,
16744 	},
16745 };
16746 
16747 /* *** display tx_metadata per port configuration *** */
16748 struct cmd_show_tx_metadata_result {
16749 	cmdline_fixed_string_t cmd_show;
16750 	cmdline_fixed_string_t cmd_port;
16751 	cmdline_fixed_string_t cmd_keyword;
16752 	portid_t cmd_pid;
16753 };
16754 
16755 static void
16756 cmd_show_tx_metadata_parsed(void *parsed_result,
16757 		__rte_unused struct cmdline *cl,
16758 		__rte_unused void *data)
16759 {
16760 	struct cmd_show_tx_metadata_result *res = parsed_result;
16761 
16762 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16763 		printf("invalid port id %u\n", res->cmd_pid);
16764 		return;
16765 	}
16766 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16767 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16768 		       ports[res->cmd_pid].tx_metadata);
16769 	}
16770 }
16771 
16772 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16773 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16774 			cmd_show, "show");
16775 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16776 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16777 			cmd_port, "port");
16778 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16779 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16780 			cmd_pid, RTE_UINT16);
16781 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16782 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16783 			cmd_keyword, "tx_metadata");
16784 
16785 cmdline_parse_inst_t cmd_show_tx_metadata = {
16786 	.f = cmd_show_tx_metadata_parsed,
16787 	.data = NULL,
16788 	.help_str = "show port <port_id> tx_metadata",
16789 	.tokens = {
16790 		(void *)&cmd_show_tx_metadata_show,
16791 		(void *)&cmd_show_tx_metadata_port,
16792 		(void *)&cmd_show_tx_metadata_pid,
16793 		(void *)&cmd_show_tx_metadata_keyword,
16794 		NULL,
16795 	},
16796 };
16797 
16798 /* *** show fec capability per port configuration *** */
16799 struct cmd_show_fec_capability_result {
16800 	cmdline_fixed_string_t cmd_show;
16801 	cmdline_fixed_string_t cmd_port;
16802 	cmdline_fixed_string_t cmd_fec;
16803 	cmdline_fixed_string_t cmd_keyword;
16804 	portid_t cmd_pid;
16805 };
16806 
16807 static void
16808 cmd_show_fec_capability_parsed(void *parsed_result,
16809 		__rte_unused struct cmdline *cl,
16810 		__rte_unused void *data)
16811 {
16812 	struct cmd_show_fec_capability_result *res = parsed_result;
16813 	struct rte_eth_fec_capa *speed_fec_capa;
16814 	unsigned int num;
16815 	int ret;
16816 
16817 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16818 		printf("Invalid port id %u\n", res->cmd_pid);
16819 		return;
16820 	}
16821 
16822 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16823 	if (ret == -ENOTSUP) {
16824 		printf("Function not implemented\n");
16825 		return;
16826 	} else if (ret < 0) {
16827 		printf("Get FEC capability failed: %d\n", ret);
16828 		return;
16829 	}
16830 
16831 	num = (unsigned int)ret;
16832 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16833 	if (speed_fec_capa == NULL) {
16834 		printf("Failed to alloc FEC capability buffer\n");
16835 		return;
16836 	}
16837 
16838 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16839 	if (ret < 0) {
16840 		printf("Error getting FEC capability: %d\n", ret);
16841 		goto out;
16842 	}
16843 
16844 	show_fec_capability(num, speed_fec_capa);
16845 out:
16846 	free(speed_fec_capa);
16847 }
16848 
16849 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16850 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16851 			cmd_show, "show");
16852 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16853 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16854 			cmd_port, "port");
16855 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16856 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16857 			cmd_pid, RTE_UINT16);
16858 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16859 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16860 			cmd_fec, "fec");
16861 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16862 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16863 			cmd_keyword, "capabilities");
16864 
16865 cmdline_parse_inst_t cmd_show_capability = {
16866 	.f = cmd_show_fec_capability_parsed,
16867 	.data = NULL,
16868 	.help_str = "show port <port_id> fec capabilities",
16869 	.tokens = {
16870 		(void *)&cmd_show_fec_capability_show,
16871 		(void *)&cmd_show_fec_capability_port,
16872 		(void *)&cmd_show_fec_capability_pid,
16873 		(void *)&cmd_show_fec_capability_fec,
16874 		(void *)&cmd_show_fec_capability_keyword,
16875 		NULL,
16876 	},
16877 };
16878 
16879 /* *** show fec mode per port configuration *** */
16880 struct cmd_show_fec_metadata_result {
16881 	cmdline_fixed_string_t cmd_show;
16882 	cmdline_fixed_string_t cmd_port;
16883 	cmdline_fixed_string_t cmd_keyword;
16884 	portid_t cmd_pid;
16885 };
16886 
16887 static void
16888 cmd_show_fec_mode_parsed(void *parsed_result,
16889 		__rte_unused struct cmdline *cl,
16890 		__rte_unused void *data)
16891 {
16892 #define FEC_NAME_SIZE 16
16893 	struct cmd_show_fec_metadata_result *res = parsed_result;
16894 	uint32_t mode;
16895 	char buf[FEC_NAME_SIZE];
16896 	int ret;
16897 
16898 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16899 		printf("Invalid port id %u\n", res->cmd_pid);
16900 		return;
16901 	}
16902 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
16903 	if (ret == -ENOTSUP) {
16904 		printf("Function not implemented\n");
16905 		return;
16906 	} else if (ret < 0) {
16907 		printf("Get FEC mode failed\n");
16908 		return;
16909 	}
16910 
16911 	switch (mode) {
16912 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16913 		strlcpy(buf, "off", sizeof(buf));
16914 		break;
16915 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16916 		strlcpy(buf, "auto", sizeof(buf));
16917 		break;
16918 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16919 		strlcpy(buf, "baser", sizeof(buf));
16920 		break;
16921 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16922 		strlcpy(buf, "rs", sizeof(buf));
16923 		break;
16924 	default:
16925 		return;
16926 	}
16927 
16928 	printf("%s\n", buf);
16929 }
16930 
16931 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16932 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16933 			cmd_show, "show");
16934 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16935 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16936 			cmd_port, "port");
16937 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16938 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16939 			cmd_pid, RTE_UINT16);
16940 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16941 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16942 			cmd_keyword, "fec_mode");
16943 
16944 cmdline_parse_inst_t cmd_show_fec_mode = {
16945 	.f = cmd_show_fec_mode_parsed,
16946 	.data = NULL,
16947 	.help_str = "show port <port_id> fec_mode",
16948 	.tokens = {
16949 		(void *)&cmd_show_fec_mode_show,
16950 		(void *)&cmd_show_fec_mode_port,
16951 		(void *)&cmd_show_fec_mode_pid,
16952 		(void *)&cmd_show_fec_mode_keyword,
16953 		NULL,
16954 	},
16955 };
16956 
16957 /* *** set fec mode per port configuration *** */
16958 struct cmd_set_port_fec_mode {
16959 	cmdline_fixed_string_t set;
16960 	cmdline_fixed_string_t port;
16961 	portid_t port_id;
16962 	cmdline_fixed_string_t fec_mode;
16963 	cmdline_fixed_string_t fec_value;
16964 };
16965 
16966 /* Common CLI fields for set fec mode */
16967 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16968 	TOKEN_STRING_INITIALIZER
16969 		(struct cmd_set_port_fec_mode,
16970 		 set, "set");
16971 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16972 	TOKEN_STRING_INITIALIZER
16973 		(struct cmd_set_port_fec_mode,
16974 		 port, "port");
16975 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16976 	TOKEN_NUM_INITIALIZER
16977 		(struct cmd_set_port_fec_mode,
16978 		 port_id, RTE_UINT16);
16979 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16980 	TOKEN_STRING_INITIALIZER
16981 		(struct cmd_set_port_fec_mode,
16982 		 fec_mode, "fec_mode");
16983 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16984 	TOKEN_STRING_INITIALIZER
16985 		(struct cmd_set_port_fec_mode,
16986 		 fec_value, NULL);
16987 
16988 static void
16989 cmd_set_port_fec_mode_parsed(
16990 	void *parsed_result,
16991 	__rte_unused struct cmdline *cl,
16992 	__rte_unused void *data)
16993 {
16994 	struct cmd_set_port_fec_mode *res = parsed_result;
16995 	uint16_t port_id = res->port_id;
16996 	uint32_t fec_capa;
16997 	int ret;
16998 
16999 	ret = parse_fec_mode(res->fec_value, &fec_capa);
17000 	if (ret < 0) {
17001 		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
17002 			port_id);
17003 		return;
17004 	}
17005 
17006 	ret = rte_eth_fec_set(port_id, fec_capa);
17007 	if (ret == -ENOTSUP) {
17008 		printf("Function not implemented\n");
17009 		return;
17010 	} else if (ret < 0) {
17011 		printf("Set FEC mode failed\n");
17012 		return;
17013 	}
17014 }
17015 
17016 cmdline_parse_inst_t cmd_set_fec_mode = {
17017 	.f = cmd_set_port_fec_mode_parsed,
17018 	.data = NULL,
17019 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17020 	.tokens = {
17021 		(void *)&cmd_set_port_fec_mode_set,
17022 		(void *)&cmd_set_port_fec_mode_port,
17023 		(void *)&cmd_set_port_fec_mode_port_id,
17024 		(void *)&cmd_set_port_fec_mode_str,
17025 		(void *)&cmd_set_port_fec_mode_value,
17026 		NULL,
17027 	},
17028 };
17029 
17030 /* show port supported ptypes */
17031 
17032 /* Common result structure for show port ptypes */
17033 struct cmd_show_port_supported_ptypes_result {
17034 	cmdline_fixed_string_t show;
17035 	cmdline_fixed_string_t port;
17036 	portid_t port_id;
17037 	cmdline_fixed_string_t ptypes;
17038 };
17039 
17040 /* Common CLI fields for show port ptypes */
17041 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17042 	TOKEN_STRING_INITIALIZER
17043 		(struct cmd_show_port_supported_ptypes_result,
17044 		 show, "show");
17045 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17046 	TOKEN_STRING_INITIALIZER
17047 		(struct cmd_show_port_supported_ptypes_result,
17048 		 port, "port");
17049 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17050 	TOKEN_NUM_INITIALIZER
17051 		(struct cmd_show_port_supported_ptypes_result,
17052 		 port_id, RTE_UINT16);
17053 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17054 	TOKEN_STRING_INITIALIZER
17055 		(struct cmd_show_port_supported_ptypes_result,
17056 		 ptypes, "ptypes");
17057 
17058 static void
17059 cmd_show_port_supported_ptypes_parsed(
17060 	void *parsed_result,
17061 	__rte_unused struct cmdline *cl,
17062 	__rte_unused void *data)
17063 {
17064 #define RSVD_PTYPE_MASK       0xf0000000
17065 #define MAX_PTYPES_PER_LAYER  16
17066 #define LTYPE_NAMESIZE        32
17067 #define PTYPE_NAMESIZE        256
17068 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17069 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17070 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17071 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17072 	uint16_t port_id = res->port_id;
17073 	int ret, i;
17074 
17075 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17076 	if (ret < 0)
17077 		return;
17078 
17079 	while (ptype_mask != RSVD_PTYPE_MASK) {
17080 
17081 		switch (ptype_mask) {
17082 		case RTE_PTYPE_L2_MASK:
17083 			strlcpy(ltype, "L2", sizeof(ltype));
17084 			break;
17085 		case RTE_PTYPE_L3_MASK:
17086 			strlcpy(ltype, "L3", sizeof(ltype));
17087 			break;
17088 		case RTE_PTYPE_L4_MASK:
17089 			strlcpy(ltype, "L4", sizeof(ltype));
17090 			break;
17091 		case RTE_PTYPE_TUNNEL_MASK:
17092 			strlcpy(ltype, "Tunnel", sizeof(ltype));
17093 			break;
17094 		case RTE_PTYPE_INNER_L2_MASK:
17095 			strlcpy(ltype, "Inner L2", sizeof(ltype));
17096 			break;
17097 		case RTE_PTYPE_INNER_L3_MASK:
17098 			strlcpy(ltype, "Inner L3", sizeof(ltype));
17099 			break;
17100 		case RTE_PTYPE_INNER_L4_MASK:
17101 			strlcpy(ltype, "Inner L4", sizeof(ltype));
17102 			break;
17103 		default:
17104 			return;
17105 		}
17106 
17107 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17108 						       ptype_mask, ptypes,
17109 						       MAX_PTYPES_PER_LAYER);
17110 
17111 		if (ret > 0)
17112 			printf("Supported %s ptypes:\n", ltype);
17113 		else
17114 			printf("%s ptypes unsupported\n", ltype);
17115 
17116 		for (i = 0; i < ret; ++i) {
17117 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17118 			printf("%s\n", buf);
17119 		}
17120 
17121 		ptype_mask <<= 4;
17122 	}
17123 }
17124 
17125 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17126 	.f = cmd_show_port_supported_ptypes_parsed,
17127 	.data = NULL,
17128 	.help_str = "show port <port_id> ptypes",
17129 	.tokens = {
17130 		(void *)&cmd_show_port_supported_ptypes_show,
17131 		(void *)&cmd_show_port_supported_ptypes_port,
17132 		(void *)&cmd_show_port_supported_ptypes_port_id,
17133 		(void *)&cmd_show_port_supported_ptypes_ptypes,
17134 		NULL,
17135 	},
17136 };
17137 
17138 /* *** display rx/tx descriptor status *** */
17139 struct cmd_show_rx_tx_desc_status_result {
17140 	cmdline_fixed_string_t cmd_show;
17141 	cmdline_fixed_string_t cmd_port;
17142 	cmdline_fixed_string_t cmd_keyword;
17143 	cmdline_fixed_string_t cmd_desc;
17144 	cmdline_fixed_string_t cmd_status;
17145 	portid_t cmd_pid;
17146 	portid_t cmd_qid;
17147 	portid_t cmd_did;
17148 };
17149 
17150 static void
17151 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17152 		__rte_unused struct cmdline *cl,
17153 		__rte_unused void *data)
17154 {
17155 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17156 	int rc;
17157 
17158 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17159 		printf("invalid port id %u\n", res->cmd_pid);
17160 		return;
17161 	}
17162 
17163 	if (!strcmp(res->cmd_keyword, "rxq")) {
17164 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17165 					     res->cmd_did);
17166 		if (rc < 0) {
17167 			printf("Invalid input: queue id = %d, desc id = %d\n",
17168 			       res->cmd_qid, res->cmd_did);
17169 			return;
17170 		}
17171 		if (rc == RTE_ETH_RX_DESC_AVAIL)
17172 			printf("Desc status = AVAILABLE\n");
17173 		else if (rc == RTE_ETH_RX_DESC_DONE)
17174 			printf("Desc status = DONE\n");
17175 		else
17176 			printf("Desc status = UNAVAILABLE\n");
17177 	} else if (!strcmp(res->cmd_keyword, "txq")) {
17178 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17179 					     res->cmd_did);
17180 		if (rc < 0) {
17181 			printf("Invalid input: queue id = %d, desc id = %d\n",
17182 			       res->cmd_qid, res->cmd_did);
17183 			return;
17184 		}
17185 		if (rc == RTE_ETH_TX_DESC_FULL)
17186 			printf("Desc status = FULL\n");
17187 		else if (rc == RTE_ETH_TX_DESC_DONE)
17188 			printf("Desc status = DONE\n");
17189 		else
17190 			printf("Desc status = UNAVAILABLE\n");
17191 	}
17192 }
17193 
17194 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17195 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17196 			cmd_show, "show");
17197 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17198 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17199 			cmd_port, "port");
17200 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17201 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17202 			cmd_pid, RTE_UINT16);
17203 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17204 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17205 			cmd_keyword, "rxq#txq");
17206 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17207 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17208 			cmd_qid, RTE_UINT16);
17209 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17210 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17211 			cmd_desc, "desc");
17212 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17213 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17214 			cmd_did, RTE_UINT16);
17215 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17216 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17217 			cmd_status, "status");
17218 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17219 	.f = cmd_show_rx_tx_desc_status_parsed,
17220 	.data = NULL,
17221 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17222 		"status",
17223 	.tokens = {
17224 		(void *)&cmd_show_rx_tx_desc_status_show,
17225 		(void *)&cmd_show_rx_tx_desc_status_port,
17226 		(void *)&cmd_show_rx_tx_desc_status_pid,
17227 		(void *)&cmd_show_rx_tx_desc_status_keyword,
17228 		(void *)&cmd_show_rx_tx_desc_status_qid,
17229 		(void *)&cmd_show_rx_tx_desc_status_desc,
17230 		(void *)&cmd_show_rx_tx_desc_status_did,
17231 		(void *)&cmd_show_rx_tx_desc_status_status,
17232 		NULL,
17233 	},
17234 };
17235 
17236 /* *** display rx queue desc used count *** */
17237 struct cmd_show_rx_queue_desc_used_count_result {
17238 	cmdline_fixed_string_t cmd_show;
17239 	cmdline_fixed_string_t cmd_port;
17240 	cmdline_fixed_string_t cmd_rxq;
17241 	cmdline_fixed_string_t cmd_desc;
17242 	cmdline_fixed_string_t cmd_used;
17243 	cmdline_fixed_string_t cmd_count;
17244 	portid_t cmd_pid;
17245 	portid_t cmd_qid;
17246 };
17247 
17248 static void
17249 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17250 		__rte_unused struct cmdline *cl,
17251 		__rte_unused void *data)
17252 {
17253 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17254 	int rc;
17255 
17256 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17257 		printf("invalid port id %u\n", res->cmd_pid);
17258 		return;
17259 	}
17260 
17261 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17262 	if (rc < 0) {
17263 		printf("Invalid queueid = %d\n", res->cmd_qid);
17264 		return;
17265 	}
17266 	printf("Used desc count = %d\n", rc);
17267 }
17268 
17269 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17270 	TOKEN_STRING_INITIALIZER
17271 		(struct cmd_show_rx_queue_desc_used_count_result,
17272 		 cmd_show, "show");
17273 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17274 	TOKEN_STRING_INITIALIZER
17275 		(struct cmd_show_rx_queue_desc_used_count_result,
17276 		 cmd_port, "port");
17277 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17278 	TOKEN_NUM_INITIALIZER
17279 		(struct cmd_show_rx_queue_desc_used_count_result,
17280 		 cmd_pid, RTE_UINT16);
17281 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17282 	TOKEN_STRING_INITIALIZER
17283 		(struct cmd_show_rx_queue_desc_used_count_result,
17284 		 cmd_rxq, "rxq");
17285 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17286 	TOKEN_NUM_INITIALIZER
17287 		(struct cmd_show_rx_queue_desc_used_count_result,
17288 		 cmd_qid, RTE_UINT16);
17289 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17290 	TOKEN_STRING_INITIALIZER
17291 		(struct cmd_show_rx_queue_desc_used_count_result,
17292 		 cmd_count, "desc");
17293 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17294 	TOKEN_STRING_INITIALIZER
17295 		(struct cmd_show_rx_queue_desc_used_count_result,
17296 		 cmd_count, "used");
17297 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17298 	TOKEN_STRING_INITIALIZER
17299 		(struct cmd_show_rx_queue_desc_used_count_result,
17300 		 cmd_count, "count");
17301 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17302 	.f = cmd_show_rx_queue_desc_used_count_parsed,
17303 	.data = NULL,
17304 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
17305 	.tokens = {
17306 		(void *)&cmd_show_rx_queue_desc_used_count_show,
17307 		(void *)&cmd_show_rx_queue_desc_used_count_port,
17308 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
17309 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
17310 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
17311 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
17312 		(void *)&cmd_show_rx_queue_desc_used_count_used,
17313 		(void *)&cmd_show_rx_queue_desc_used_count_count,
17314 		NULL,
17315 	},
17316 };
17317 
17318 /* Common result structure for set port ptypes */
17319 struct cmd_set_port_ptypes_result {
17320 	cmdline_fixed_string_t set;
17321 	cmdline_fixed_string_t port;
17322 	portid_t port_id;
17323 	cmdline_fixed_string_t ptype_mask;
17324 	uint32_t mask;
17325 };
17326 
17327 /* Common CLI fields for set port ptypes */
17328 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17329 	TOKEN_STRING_INITIALIZER
17330 		(struct cmd_set_port_ptypes_result,
17331 		 set, "set");
17332 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17333 	TOKEN_STRING_INITIALIZER
17334 		(struct cmd_set_port_ptypes_result,
17335 		 port, "port");
17336 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17337 	TOKEN_NUM_INITIALIZER
17338 		(struct cmd_set_port_ptypes_result,
17339 		 port_id, RTE_UINT16);
17340 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17341 	TOKEN_STRING_INITIALIZER
17342 		(struct cmd_set_port_ptypes_result,
17343 		 ptype_mask, "ptype_mask");
17344 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17345 	TOKEN_NUM_INITIALIZER
17346 		(struct cmd_set_port_ptypes_result,
17347 		 mask, RTE_UINT32);
17348 
17349 static void
17350 cmd_set_port_ptypes_parsed(
17351 	void *parsed_result,
17352 	__rte_unused struct cmdline *cl,
17353 	__rte_unused void *data)
17354 {
17355 	struct cmd_set_port_ptypes_result *res = parsed_result;
17356 #define PTYPE_NAMESIZE        256
17357 	char ptype_name[PTYPE_NAMESIZE];
17358 	uint16_t port_id = res->port_id;
17359 	uint32_t ptype_mask = res->mask;
17360 	int ret, i;
17361 
17362 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17363 					       NULL, 0);
17364 	if (ret <= 0) {
17365 		printf("Port %d doesn't support any ptypes.\n", port_id);
17366 		return;
17367 	}
17368 
17369 	uint32_t ptypes[ret];
17370 
17371 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17372 	if (ret < 0) {
17373 		printf("Unable to set requested ptypes for Port %d\n", port_id);
17374 		return;
17375 	}
17376 
17377 	printf("Successfully set following ptypes for Port %d\n", port_id);
17378 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17379 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17380 		printf("%s\n", ptype_name);
17381 	}
17382 
17383 	clear_ptypes = false;
17384 }
17385 
17386 cmdline_parse_inst_t cmd_set_port_ptypes = {
17387 	.f = cmd_set_port_ptypes_parsed,
17388 	.data = NULL,
17389 	.help_str = "set port <port_id> ptype_mask <mask>",
17390 	.tokens = {
17391 		(void *)&cmd_set_port_ptypes_set,
17392 		(void *)&cmd_set_port_ptypes_port,
17393 		(void *)&cmd_set_port_ptypes_port_id,
17394 		(void *)&cmd_set_port_ptypes_mask_str,
17395 		(void *)&cmd_set_port_ptypes_mask_u32,
17396 		NULL,
17397 	},
17398 };
17399 
17400 /* *** display mac addresses added to a port *** */
17401 struct cmd_showport_macs_result {
17402 	cmdline_fixed_string_t cmd_show;
17403 	cmdline_fixed_string_t cmd_port;
17404 	cmdline_fixed_string_t cmd_keyword;
17405 	portid_t cmd_pid;
17406 };
17407 
17408 static void
17409 cmd_showport_macs_parsed(void *parsed_result,
17410 		__rte_unused struct cmdline *cl,
17411 		__rte_unused void *data)
17412 {
17413 	struct cmd_showport_macs_result *res = parsed_result;
17414 
17415 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17416 		return;
17417 
17418 	if (!strcmp(res->cmd_keyword, "macs"))
17419 		show_macs(res->cmd_pid);
17420 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17421 		show_mcast_macs(res->cmd_pid);
17422 }
17423 
17424 cmdline_parse_token_string_t cmd_showport_macs_show =
17425 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17426 			cmd_show, "show");
17427 cmdline_parse_token_string_t cmd_showport_macs_port =
17428 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17429 			cmd_port, "port");
17430 cmdline_parse_token_num_t cmd_showport_macs_pid =
17431 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17432 			cmd_pid, RTE_UINT16);
17433 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17434 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17435 			cmd_keyword, "macs#mcast_macs");
17436 
17437 cmdline_parse_inst_t cmd_showport_macs = {
17438 	.f = cmd_showport_macs_parsed,
17439 	.data = NULL,
17440 	.help_str = "show port <port_id> macs|mcast_macs",
17441 	.tokens = {
17442 		(void *)&cmd_showport_macs_show,
17443 		(void *)&cmd_showport_macs_port,
17444 		(void *)&cmd_showport_macs_pid,
17445 		(void *)&cmd_showport_macs_keyword,
17446 		NULL,
17447 	},
17448 };
17449 
17450 /* ******************************************************************************** */
17451 
17452 /* list of instructions */
17453 cmdline_parse_ctx_t main_ctx[] = {
17454 	(cmdline_parse_inst_t *)&cmd_help_brief,
17455 	(cmdline_parse_inst_t *)&cmd_help_long,
17456 	(cmdline_parse_inst_t *)&cmd_quit,
17457 	(cmdline_parse_inst_t *)&cmd_load_from_file,
17458 	(cmdline_parse_inst_t *)&cmd_showport,
17459 	(cmdline_parse_inst_t *)&cmd_showqueue,
17460 	(cmdline_parse_inst_t *)&cmd_showeeprom,
17461 	(cmdline_parse_inst_t *)&cmd_showportall,
17462 	(cmdline_parse_inst_t *)&cmd_showdevice,
17463 	(cmdline_parse_inst_t *)&cmd_showcfg,
17464 	(cmdline_parse_inst_t *)&cmd_showfwdall,
17465 	(cmdline_parse_inst_t *)&cmd_start,
17466 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
17467 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17468 	(cmdline_parse_inst_t *)&cmd_set_link_up,
17469 	(cmdline_parse_inst_t *)&cmd_set_link_down,
17470 	(cmdline_parse_inst_t *)&cmd_reset,
17471 	(cmdline_parse_inst_t *)&cmd_set_numbers,
17472 	(cmdline_parse_inst_t *)&cmd_set_log,
17473 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
17474 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
17475 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
17476 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
17477 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
17478 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
17479 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17480 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17481 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17482 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17483 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17484 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17485 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17486 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17487 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
17488 	(cmdline_parse_inst_t *)&cmd_set_link_check,
17489 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17490 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
17491 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17492 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
17493 #ifdef RTE_NET_BOND
17494 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17495 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
17496 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17497 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17498 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17499 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
17500 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17501 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17502 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17503 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17504 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17505 #endif
17506 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
17507 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
17508 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17509 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17510 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17511 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17512 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17513 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17514 	(cmdline_parse_inst_t *)&cmd_csum_set,
17515 	(cmdline_parse_inst_t *)&cmd_csum_show,
17516 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
17517 	(cmdline_parse_inst_t *)&cmd_tso_set,
17518 	(cmdline_parse_inst_t *)&cmd_tso_show,
17519 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17520 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17521 	(cmdline_parse_inst_t *)&cmd_gro_enable,
17522 	(cmdline_parse_inst_t *)&cmd_gro_flush,
17523 	(cmdline_parse_inst_t *)&cmd_gro_show,
17524 	(cmdline_parse_inst_t *)&cmd_gso_enable,
17525 	(cmdline_parse_inst_t *)&cmd_gso_size,
17526 	(cmdline_parse_inst_t *)&cmd_gso_show,
17527 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17528 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17529 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17530 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17531 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17532 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17533 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17534 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17535 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17536 	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17537 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17538 	(cmdline_parse_inst_t *)&cmd_config_dcb,
17539 	(cmdline_parse_inst_t *)&cmd_read_reg,
17540 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17541 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
17542 	(cmdline_parse_inst_t *)&cmd_write_reg,
17543 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17544 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
17545 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17546 	(cmdline_parse_inst_t *)&cmd_stop,
17547 	(cmdline_parse_inst_t *)&cmd_mac_addr,
17548 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17549 	(cmdline_parse_inst_t *)&cmd_set_qmap,
17550 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17551 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17552 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17553 	(cmdline_parse_inst_t *)&cmd_operate_port,
17554 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
17555 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
17556 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
17557 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
17558 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17559 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
17560 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
17561 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
17562 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17563 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
17564 	(cmdline_parse_inst_t *)&cmd_config_mtu,
17565 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17566 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17567 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17568 	(cmdline_parse_inst_t *)&cmd_config_rss,
17569 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17570 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17571 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17572 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17573 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
17574 	(cmdline_parse_inst_t *)&cmd_showport_reta,
17575 	(cmdline_parse_inst_t *)&cmd_showport_macs,
17576 	(cmdline_parse_inst_t *)&cmd_config_burst,
17577 	(cmdline_parse_inst_t *)&cmd_config_thresh,
17578 	(cmdline_parse_inst_t *)&cmd_config_threshold,
17579 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17580 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17581 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17582 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17583 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17584 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17585 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
17586 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17587 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17588 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17589 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17590 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17591 	(cmdline_parse_inst_t *)&cmd_dump,
17592 	(cmdline_parse_inst_t *)&cmd_dump_one,
17593 #ifdef RTE_NET_I40E
17594 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17595 #endif
17596 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17597 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17598 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17599 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17600 	(cmdline_parse_inst_t *)&cmd_flow,
17601 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17602 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17603 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17604 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17605 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
17606 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
17607 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
17608 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
17609 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17610 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17611 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17612 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17613 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17614 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
17615 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17616 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17617 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17618 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17619 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17620 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17621 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17622 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17623 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17624 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17625 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17626 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17627 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17628 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17629 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17630 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17631 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17632 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17633 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17634 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17635 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
17636 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17637 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17638 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
17639 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
17640 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
17641 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17642 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17643 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
17644 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17645 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
17646 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17647 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
17648 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17649 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17650 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17651 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17652 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17653 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17654 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17655 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17656 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17657 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17658 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17659 	(cmdline_parse_inst_t *)&cmd_ddp_add,
17660 	(cmdline_parse_inst_t *)&cmd_ddp_del,
17661 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
17662 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
17663 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
17664 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
17665 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
17666 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17667 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17668 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17669 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17670 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17671 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17672 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17673 
17674 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17675 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17676 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17677 	(cmdline_parse_inst_t *)&cmd_queue_region,
17678 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
17679 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
17680 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
17681 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17682 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17683 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17684 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17685 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17686 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17687 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17688 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17689 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17690 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17691 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17692 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17693 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17694 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17695 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17696 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17697 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17698 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17699 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17700 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17701 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17702 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17703 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17704 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17705 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17706 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17707 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17708 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17709 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17710 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17711 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17712 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17713 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17714 #ifdef RTE_LIB_BPF
17715 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17716 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17717 #endif
17718 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17719 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17720 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17721 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17722 	(cmdline_parse_inst_t *)&cmd_set_raw,
17723 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
17724 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17725 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17726 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
17727 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
17728 	(cmdline_parse_inst_t *)&cmd_show_capability,
17729 	NULL,
17730 };
17731 
17732 /* read cmdline commands from file */
17733 void
17734 cmdline_read_from_file(const char *filename)
17735 {
17736 	struct cmdline *cl;
17737 
17738 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17739 	if (cl == NULL) {
17740 		printf("Failed to create file based cmdline context: %s\n",
17741 		       filename);
17742 		return;
17743 	}
17744 
17745 	cmdline_interact(cl);
17746 	cmdline_quit(cl);
17747 
17748 	cmdline_free(cl);
17749 
17750 	printf("Read CLI commands from %s\n", filename);
17751 }
17752 
17753 /* prompt function, called from main on MAIN lcore */
17754 void
17755 prompt(void)
17756 {
17757 	int ret;
17758 	/* initialize non-constant commands */
17759 	cmd_set_fwd_mode_init();
17760 	cmd_set_fwd_retry_mode_init();
17761 
17762 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17763 	if (testpmd_cl == NULL)
17764 		return;
17765 
17766 	ret = atexit(prompt_exit);
17767 	if (ret != 0)
17768 		printf("Cannot set exit function for cmdline\n");
17769 
17770 	cmdline_interact(testpmd_cl);
17771 	if (ret != 0)
17772 		cmdline_stdin_exit(testpmd_cl);
17773 }
17774 
17775 void
17776 prompt_exit(void)
17777 {
17778 	if (testpmd_cl != NULL) {
17779 		cmdline_quit(testpmd_cl);
17780 		cmdline_stdin_exit(testpmd_cl);
17781 	}
17782 }
17783 
17784 static void
17785 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17786 {
17787 	if (id == (portid_t)RTE_PORT_ALL) {
17788 		portid_t pid;
17789 
17790 		RTE_ETH_FOREACH_DEV(pid) {
17791 			/* check if need_reconfig has been set to 1 */
17792 			if (ports[pid].need_reconfig == 0)
17793 				ports[pid].need_reconfig = dev;
17794 			/* check if need_reconfig_queues has been set to 1 */
17795 			if (ports[pid].need_reconfig_queues == 0)
17796 				ports[pid].need_reconfig_queues = queue;
17797 		}
17798 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17799 		/* check if need_reconfig has been set to 1 */
17800 		if (ports[id].need_reconfig == 0)
17801 			ports[id].need_reconfig = dev;
17802 		/* check if need_reconfig_queues has been set to 1 */
17803 		if (ports[id].need_reconfig_queues == 0)
17804 			ports[id].need_reconfig_queues = queue;
17805 	}
17806 }
17807