xref: /dpdk/app/test-pmd/cmdline.c (revision 3f47c017eed414490b6428d58d47dfca2964209e)
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 <termios.h>
12 #include <unistd.h>
13 #include <inttypes.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 
17 #include <sys/queue.h>
18 
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
21 #include <rte_log.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
28 #include <rte_eal.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
33 #include <rte_ring.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
36 #include <rte_pci.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
41 #include <rte_flow.h>
42 #include <rte_gro.h>
43 #include <rte_mbuf_dyn.h>
44 
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
52 #include <cmdline.h>
53 #ifdef RTE_NET_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
56 #endif
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
59 #endif
60 #ifdef RTE_NET_IXGBE
61 #include <rte_pmd_ixgbe.h>
62 #endif
63 #ifdef RTE_NET_I40E
64 #include <rte_pmd_i40e.h>
65 #endif
66 #ifdef RTE_NET_BNXT
67 #include <rte_pmd_bnxt.h>
68 #endif
69 #include "testpmd.h"
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
72 #include "bpf_cmd.h"
73 
74 static struct cmdline *testpmd_cl;
75 
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
77 
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 	cmdline_fixed_string_t help;
81 };
82 
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
84                                   struct cmdline *cl,
85                                   __rte_unused void *data)
86 {
87 	cmdline_printf(
88 		cl,
89 		"\n"
90 		"Help is available for the following sections:\n\n"
91 		"    help control                    : Start and stop forwarding.\n"
92 		"    help display                    : Displaying port, stats and config "
93 		"information.\n"
94 		"    help config                     : Configuration information.\n"
95 		"    help ports                      : Configuring ports.\n"
96 		"    help registers                  : Reading and setting port registers.\n"
97 		"    help filters                    : Filters configuration help.\n"
98 		"    help traffic_management         : Traffic Management commands.\n"
99 		"    help devices                    : Device related cmds.\n"
100 		"    help all                        : All of the above sections.\n\n"
101 	);
102 
103 }
104 
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 
108 cmdline_parse_inst_t cmd_help_brief = {
109 	.f = cmd_help_brief_parsed,
110 	.data = NULL,
111 	.help_str = "help: Show help",
112 	.tokens = {
113 		(void *)&cmd_help_brief_help,
114 		NULL,
115 	},
116 };
117 
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 	cmdline_fixed_string_t help;
121 	cmdline_fixed_string_t section;
122 };
123 
124 static void cmd_help_long_parsed(void *parsed_result,
125                                  struct cmdline *cl,
126                                  __rte_unused void *data)
127 {
128 	int show_all = 0;
129 	struct cmd_help_long_result *res = parsed_result;
130 
131 	if (!strcmp(res->section, "all"))
132 		show_all = 1;
133 
134 	if (show_all || !strcmp(res->section, "control")) {
135 
136 		cmdline_printf(
137 			cl,
138 			"\n"
139 			"Control forwarding:\n"
140 			"-------------------\n\n"
141 
142 			"start\n"
143 			"    Start packet forwarding with current configuration.\n\n"
144 
145 			"start tx_first\n"
146 			"    Start packet forwarding with current config"
147 			" after sending one burst of packets.\n\n"
148 
149 			"stop\n"
150 			"    Stop packet forwarding, and display accumulated"
151 			" statistics.\n\n"
152 
153 			"quit\n"
154 			"    Quit to prompt.\n\n"
155 		);
156 	}
157 
158 	if (show_all || !strcmp(res->section, "display")) {
159 
160 		cmdline_printf(
161 			cl,
162 			"\n"
163 			"Display:\n"
164 			"--------\n\n"
165 
166 			"show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 			"    Display information for port_id, or all.\n\n"
168 
169 			"show port port_id (module_eeprom|eeprom)\n"
170 			"    Display the module EEPROM or EEPROM information for port_id.\n\n"
171 
172 			"show port X rss reta (size) (mask0,mask1,...)\n"
173 			"    Display the rss redirection table entry indicated"
174 			" by masks on port X. size is used to indicate the"
175 			" hardware supported reta size\n\n"
176 
177 			"show port (port_id) rss-hash [key]\n"
178 			"    Display the RSS hash functions and RSS hash key of port\n\n"
179 
180 			"clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 			"    Clear information for port_id, or all.\n\n"
182 
183 			"show (rxq|txq) info (port_id) (queue_id)\n"
184 			"    Display information for configured RX/TX queue.\n\n"
185 
186 			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 			"    Display the given configuration.\n\n"
188 
189 			"read rxd (port_id) (queue_id) (rxd_id)\n"
190 			"    Display an RX descriptor of a port RX queue.\n\n"
191 
192 			"read txd (port_id) (queue_id) (txd_id)\n"
193 			"    Display a TX descriptor of a port TX queue.\n\n"
194 
195 			"ddp get list (port_id)\n"
196 			"    Get ddp profile info list\n\n"
197 
198 			"ddp get info (profile_path)\n"
199 			"    Get ddp profile information.\n\n"
200 
201 			"show vf stats (port_id) (vf_id)\n"
202 			"    Display a VF's statistics.\n\n"
203 
204 			"clear vf stats (port_id) (vf_id)\n"
205 			"    Reset a VF's statistics.\n\n"
206 
207 			"show port (port_id) pctype mapping\n"
208 			"    Get flow ptype to pctype mapping on a port\n\n"
209 
210 			"show port meter stats (port_id) (meter_id) (clear)\n"
211 			"    Get meter stats on a port\n\n"
212 
213 			"show fwd stats all\n"
214 			"    Display statistics for all fwd engines.\n\n"
215 
216 			"clear fwd stats all\n"
217 			"    Clear statistics for all fwd engines.\n\n"
218 
219 			"show port (port_id) rx_offload capabilities\n"
220 			"    List all per queue and per port Rx offloading"
221 			" capabilities of a port\n\n"
222 
223 			"show port (port_id) rx_offload configuration\n"
224 			"    List port level and all queue level"
225 			" Rx offloading configuration\n\n"
226 
227 			"show port (port_id) tx_offload capabilities\n"
228 			"    List all per queue and per port"
229 			" Tx offloading capabilities of a port\n\n"
230 
231 			"show port (port_id) tx_offload configuration\n"
232 			"    List port level and all queue level"
233 			" Tx offloading configuration\n\n"
234 
235 			"show port (port_id) tx_metadata\n"
236 			"    Show Tx metadata value set"
237 			" for a specific port\n\n"
238 
239 			"show port (port_id) ptypes\n"
240 			"    Show port supported ptypes"
241 			" for a specific port\n\n"
242 
243 			"show device info (<identifier>|all)"
244 			"       Show general information about devices probed.\n\n"
245 
246 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 			"       Show status of rx|tx descriptor.\n\n"
248 
249 			"show port (port_id) rxq (queue_id) desc used count\n"
250 			"    Show current number of filled receive"
251 			" packet descriptors.\n\n"
252 
253 			"show port (port_id) macs|mcast_macs"
254 			"       Display list of mac addresses added to port.\n\n"
255 
256 			"show port (port_id) fec capabilities"
257 			"	Show fec capabilities of a port.\n\n"
258 
259 			"show port (port_id) fec_mode"
260 			"	Show fec mode of a port.\n\n"
261 
262 			"show port (port_id) flow_ctrl"
263 			"	Show flow control info of a port.\n\n"
264 		);
265 	}
266 
267 	if (show_all || !strcmp(res->section, "config")) {
268 		cmdline_printf(
269 			cl,
270 			"\n"
271 			"Configuration:\n"
272 			"--------------\n"
273 			"Configuration changes only become active when"
274 			" forwarding is started/restarted.\n\n"
275 
276 			"set default\n"
277 			"    Reset forwarding to the default configuration.\n\n"
278 
279 			"set verbose (level)\n"
280 			"    Set the debug verbosity level X.\n\n"
281 
282 			"set log global|(type) (level)\n"
283 			"    Set the log level.\n\n"
284 
285 			"set nbport (num)\n"
286 			"    Set number of ports.\n\n"
287 
288 			"set nbcore (num)\n"
289 			"    Set number of cores.\n\n"
290 
291 			"set coremask (mask)\n"
292 			"    Set the forwarding cores hexadecimal mask.\n\n"
293 
294 			"set portmask (mask)\n"
295 			"    Set the forwarding ports hexadecimal mask.\n\n"
296 
297 			"set burst (num)\n"
298 			"    Set number of packets per burst.\n\n"
299 
300 			"set burst tx delay (microseconds) retry (num)\n"
301 			"    Set the transmit delay time and number of retries,"
302 			" effective when retry is enabled.\n\n"
303 
304 			"set rxoffs (x[,y]*)\n"
305 			"    Set the offset of each packet segment on"
306 			" receiving if split feature is engaged."
307 			" Affects only the queues configured with split"
308 			" offloads.\n\n"
309 
310 			"set rxpkts (x[,y]*)\n"
311 			"    Set the length of each segment to scatter"
312 			" packets on receiving if split feature is engaged."
313 			" Affects only the queues configured with split"
314 			" offloads.\n\n"
315 
316 			"set txpkts (x[,y]*)\n"
317 			"    Set the length of each segment of TXONLY"
318 			" and optionally CSUM packets.\n\n"
319 
320 			"set txsplit (off|on|rand)\n"
321 			"    Set the split policy for the TX packets."
322 			" Right now only applicable for CSUM and TXONLY"
323 			" modes\n\n"
324 
325 			"set txtimes (x, y)\n"
326 			"    Set the scheduling on timestamps"
327 			" timings for the TXONLY mode\n\n"
328 
329 			"set corelist (x[,y]*)\n"
330 			"    Set the list of forwarding cores.\n\n"
331 
332 			"set portlist (x[,y]*)\n"
333 			"    Set the list of forwarding ports.\n\n"
334 
335 			"set port setup on (iterator|event)\n"
336 			"    Select how attached port is retrieved for setup.\n\n"
337 
338 			"set tx loopback (port_id) (on|off)\n"
339 			"    Enable or disable tx loopback.\n\n"
340 
341 			"set all queues drop (port_id) (on|off)\n"
342 			"    Set drop enable bit for all queues.\n\n"
343 
344 			"set vf split drop (port_id) (vf_id) (on|off)\n"
345 			"    Set split drop enable bit for a VF from the PF.\n\n"
346 
347 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
348 			"    Set MAC antispoof for a VF from the PF.\n\n"
349 
350 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
351 			"    Enable MACsec offload.\n\n"
352 
353 			"set macsec offload (port_id) off\n"
354 			"    Disable MACsec offload.\n\n"
355 
356 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
357 			"    Configure MACsec secure connection (SC).\n\n"
358 
359 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
360 			"    Configure MACsec secure association (SA).\n\n"
361 
362 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
363 			"    Set VF broadcast for a VF from the PF.\n\n"
364 
365 			"vlan set stripq (on|off) (port_id,queue_id)\n"
366 			"    Set the VLAN strip for a queue on a port.\n\n"
367 
368 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
369 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
370 
371 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
372 			"    Set VLAN insert for a VF from the PF.\n\n"
373 
374 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
375 			"    Set VLAN antispoof for a VF from the PF.\n\n"
376 
377 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
378 			"    Set VLAN tag for a VF from the PF.\n\n"
379 
380 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
381 			"    Set a VF's max bandwidth(Mbps).\n\n"
382 
383 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
384 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
385 
386 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
387 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
388 
389 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
390 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
391 
392 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
393 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
394 
395 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
396 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
397 
398 			"vlan set (inner|outer) tpid (value) (port_id)\n"
399 			"    Set the VLAN TPID for Packet Filtering on"
400 			" a port\n\n"
401 
402 			"rx_vlan add (vlan_id|all) (port_id)\n"
403 			"    Add a vlan_id, or all identifiers, to the set"
404 			" of VLAN identifiers filtered by port_id.\n\n"
405 
406 			"rx_vlan rm (vlan_id|all) (port_id)\n"
407 			"    Remove a vlan_id, or all identifiers, from the set"
408 			" of VLAN identifiers filtered by port_id.\n\n"
409 
410 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
411 			"    Add a vlan_id, to the set of VLAN identifiers"
412 			"filtered for VF(s) from port_id.\n\n"
413 
414 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
415 			"    Remove a vlan_id, to the set of VLAN identifiers"
416 			"filtered for VF(s) from port_id.\n\n"
417 
418 			"rx_vxlan_port add (udp_port) (port_id)\n"
419 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
420 
421 			"rx_vxlan_port rm (udp_port) (port_id)\n"
422 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
423 
424 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
425 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
426 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
427 
428 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
429 			"    Set port based TX VLAN insertion.\n\n"
430 
431 			"tx_vlan reset (port_id)\n"
432 			"    Disable hardware insertion of a VLAN header in"
433 			" packets sent on a port.\n\n"
434 
435 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
436 			"    Select hardware or software calculation of the"
437 			" checksum when transmitting a packet using the"
438 			" csum forward engine.\n"
439 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
440 			"    outer-ip concerns the outer IP layer in"
441 			"    outer-udp concerns the outer UDP layer in"
442 			" case the packet is recognized as a tunnel packet by"
443 			" the forward engine (vxlan, gre and ipip are supported)\n"
444 			"    Please check the NIC datasheet for HW limits.\n\n"
445 
446 			"csum parse-tunnel (on|off) (tx_port_id)\n"
447 			"    If disabled, treat tunnel packets as non-tunneled"
448 			" packets (treat inner headers as payload). The port\n"
449 			"    argument is the port used for TX in csum forward"
450 			" engine.\n\n"
451 
452 			"csum show (port_id)\n"
453 			"    Display tx checksum offload configuration\n\n"
454 
455 			"tso set (segsize) (portid)\n"
456 			"    Enable TCP Segmentation Offload in csum forward"
457 			" engine.\n"
458 			"    Please check the NIC datasheet for HW limits.\n\n"
459 
460 			"tso show (portid)"
461 			"    Display the status of TCP Segmentation Offload.\n\n"
462 
463 			"set port (port_id) gro on|off\n"
464 			"    Enable or disable Generic Receive Offload in"
465 			" csum forwarding engine.\n\n"
466 
467 			"show port (port_id) gro\n"
468 			"    Display GRO configuration.\n\n"
469 
470 			"set gro flush (cycles)\n"
471 			"    Set the cycle to flush GROed packets from"
472 			" reassembly tables.\n\n"
473 
474 			"set port (port_id) gso (on|off)"
475 			"    Enable or disable Generic Segmentation Offload in"
476 			" csum forwarding engine.\n\n"
477 
478 			"set gso segsz (length)\n"
479 			"    Set max packet length for output GSO segments,"
480 			" including packet header and payload.\n\n"
481 
482 			"show port (port_id) gso\n"
483 			"    Show GSO configuration.\n\n"
484 
485 			"set fwd (%s)\n"
486 			"    Set packet forwarding mode.\n\n"
487 
488 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
489 			"    Add a MAC address on port_id.\n\n"
490 
491 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 			"    Remove a MAC address from port_id.\n\n"
493 
494 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
495 			"    Set the default MAC address for port_id.\n\n"
496 
497 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
498 			"    Add a MAC address for a VF on the port.\n\n"
499 
500 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
501 			"    Set the MAC address for a VF from the PF.\n\n"
502 
503 			"set eth-peer (port_id) (peer_addr)\n"
504 			"    set the peer address for certain port.\n\n"
505 
506 			"set port (port_id) uta (mac_address|all) (on|off)\n"
507 			"    Add/Remove a or all unicast hash filter(s)"
508 			"from port X.\n\n"
509 
510 			"set promisc (port_id|all) (on|off)\n"
511 			"    Set the promiscuous mode on port_id, or all.\n\n"
512 
513 			"set allmulti (port_id|all) (on|off)\n"
514 			"    Set the allmulti mode on port_id, or all.\n\n"
515 
516 			"set vf promisc (port_id) (vf_id) (on|off)\n"
517 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
518 
519 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
520 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
521 
522 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
523 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
524 			" (on|off) autoneg (on|off) (port_id)\n"
525 			"set flow_ctrl rx (on|off) (portid)\n"
526 			"set flow_ctrl tx (on|off) (portid)\n"
527 			"set flow_ctrl high_water (high_water) (portid)\n"
528 			"set flow_ctrl low_water (low_water) (portid)\n"
529 			"set flow_ctrl pause_time (pause_time) (portid)\n"
530 			"set flow_ctrl send_xon (send_xon) (portid)\n"
531 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
532 			"set flow_ctrl autoneg (on|off) (port_id)\n"
533 			"    Set the link flow control parameter on a port.\n\n"
534 
535 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
536 			" (low_water) (pause_time) (priority) (port_id)\n"
537 			"    Set the priority flow control parameter on a"
538 			" port.\n\n"
539 
540 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
541 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
542 			" queue on port.\n"
543 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
544 			" on port 0 to mapping 5.\n\n"
545 
546 			"set xstats-hide-zero on|off\n"
547 			"    Set the option to hide the zero values"
548 			" for xstats display.\n"
549 
550 			"set record-core-cycles on|off\n"
551 			"    Set the option to enable measurement of CPU cycles.\n"
552 
553 			"set record-burst-stats on|off\n"
554 			"    Set the option to enable display of RX and TX bursts.\n"
555 
556 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
557 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
558 
559 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
560 			"|MPE) (on|off)\n"
561 			"    AUPE:accepts untagged VLAN;"
562 			"ROPE:accept unicast hash\n\n"
563 			"    BAM:accepts broadcast packets;"
564 			"MPE:accepts all multicast packets\n\n"
565 			"    Enable/Disable a VF receive mode of a port\n\n"
566 
567 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
568 			"    Set rate limit for a queue of a port\n\n"
569 
570 			"set port (port_id) vf (vf_id) rate (rate_num) "
571 			"queue_mask (queue_mask_value)\n"
572 			"    Set rate limit for queues in VF of a port\n\n"
573 
574 			"set port (port_id) mirror-rule (rule_id)"
575 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
576 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
577 			"   Set pool or vlan type mirror rule on a port.\n"
578 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
579 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
580 			" to pool 0.\n\n"
581 
582 			"set port (port_id) mirror-rule (rule_id)"
583 			" (uplink-mirror|downlink-mirror) dst-pool"
584 			" (pool_id) (on|off)\n"
585 			"   Set uplink or downlink type mirror rule on a port.\n"
586 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
587 			" 0 on' enable mirror income traffic to pool 0.\n\n"
588 
589 			"reset port (port_id) mirror-rule (rule_id)\n"
590 			"   Reset a mirror rule.\n\n"
591 
592 			"set flush_rx (on|off)\n"
593 			"   Flush (default) or don't flush RX streams before"
594 			" forwarding. Mainly used with PCAP drivers.\n\n"
595 
596 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
597 			"   Set the bypass mode for the lowest port on bypass enabled"
598 			" NIC.\n\n"
599 
600 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
601 			"mode (normal|bypass|isolate) (port_id)\n"
602 			"   Set the event required to initiate specified bypass mode for"
603 			" the lowest port on a bypass enabled NIC where:\n"
604 			"       timeout   = enable bypass after watchdog timeout.\n"
605 			"       os_on     = enable bypass when OS/board is powered on.\n"
606 			"       os_off    = enable bypass when OS/board is powered off.\n"
607 			"       power_on  = enable bypass when power supply is turned on.\n"
608 			"       power_off = enable bypass when power supply is turned off."
609 			"\n\n"
610 
611 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
612 			"   Set the bypass watchdog timeout to 'n' seconds"
613 			" where 0 = instant.\n\n"
614 
615 			"show bypass config (port_id)\n"
616 			"   Show the bypass configuration for a bypass enabled NIC"
617 			" using the lowest port on the NIC.\n\n"
618 
619 #ifdef RTE_NET_BOND
620 			"create bonded device (mode) (socket)\n"
621 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
622 
623 			"add bonding slave (slave_id) (port_id)\n"
624 			"	Add a slave device to a bonded device.\n\n"
625 
626 			"remove bonding slave (slave_id) (port_id)\n"
627 			"	Remove a slave device from a bonded device.\n\n"
628 
629 			"set bonding mode (value) (port_id)\n"
630 			"	Set the bonding mode on a bonded device.\n\n"
631 
632 			"set bonding primary (slave_id) (port_id)\n"
633 			"	Set the primary slave for a bonded device.\n\n"
634 
635 			"show bonding config (port_id)\n"
636 			"	Show the bonding config for port_id.\n\n"
637 
638 			"set bonding mac_addr (port_id) (address)\n"
639 			"	Set the MAC address of a bonded device.\n\n"
640 
641 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
642 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
643 
644 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
645 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
646 
647 			"set bonding mon_period (port_id) (value)\n"
648 			"	Set the bonding link status monitoring polling period in ms.\n\n"
649 
650 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
651 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
652 
653 #endif
654 			"set link-up port (port_id)\n"
655 			"	Set link up for a port.\n\n"
656 
657 			"set link-down port (port_id)\n"
658 			"	Set link down for a port.\n\n"
659 
660 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
661 			"    Load a profile package on a port\n\n"
662 
663 			"ddp del (port_id) (backup_profile_path)\n"
664 			"    Delete a profile package from a port\n\n"
665 
666 			"ptype mapping get (port_id) (valid_only)\n"
667 			"    Get ptype mapping on a port\n\n"
668 
669 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
670 			"    Replace target with the pkt_type in ptype mapping\n\n"
671 
672 			"ptype mapping reset (port_id)\n"
673 			"    Reset ptype mapping on a port\n\n"
674 
675 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
676 			"    Update a ptype mapping item on a port\n\n"
677 
678 			"set port (port_id) ptype_mask (ptype_mask)\n"
679 			"    set packet types classification for a specific port\n\n"
680 
681 			"set port (port_id) queue-region region_id (value) "
682 			"queue_start_index (value) queue_num (value)\n"
683 			"    Set a queue region on a port\n\n"
684 
685 			"set port (port_id) queue-region region_id (value) "
686 			"flowtype (value)\n"
687 			"    Set a flowtype region index on a port\n\n"
688 
689 			"set port (port_id) queue-region UP (value) region_id (value)\n"
690 			"    Set the mapping of User Priority to "
691 			"queue region on a port\n\n"
692 
693 			"set port (port_id) queue-region flush (on|off)\n"
694 			"    flush all queue region related configuration\n\n"
695 
696 			"show port meter cap (port_id)\n"
697 			"    Show port meter capability information\n\n"
698 
699 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
700 			"    meter profile add - srtcm rfc 2697\n\n"
701 
702 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
703 			"    meter profile add - trtcm rfc 2698\n\n"
704 
705 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
706 			"    meter profile add - trtcm rfc 4115\n\n"
707 
708 			"del port meter profile (port_id) (profile_id)\n"
709 			"    meter profile delete\n\n"
710 
711 			"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
712 			"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
713 			"(dscp_tbl_entry63)]\n"
714 			"    meter create\n\n"
715 
716 			"enable port meter (port_id) (mtr_id)\n"
717 			"    meter enable\n\n"
718 
719 			"disable port meter (port_id) (mtr_id)\n"
720 			"    meter disable\n\n"
721 
722 			"del port meter (port_id) (mtr_id)\n"
723 			"    meter delete\n\n"
724 
725 			"add port meter policy (port_id) (policy_id) g_actions (actions)\n"
726 			"y_actions (actions) r_actions (actions)\n"
727 			"    meter policy add\n\n"
728 
729 			"del port meter policy (port_id) (policy_id)\n"
730 			"    meter policy delete\n\n"
731 
732 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
733 			"    meter update meter profile\n\n"
734 
735 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
736 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
737 			"    update meter dscp table entries\n\n"
738 
739 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
740 			"(action0) [(action1) (action2)]\n"
741 			"    meter update policer action\n\n"
742 
743 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
744 			"    meter update stats\n\n"
745 
746 			"show port (port_id) queue-region\n"
747 			"    show all queue region related configuration info\n\n"
748 
749 			"set port (port_id) fec_mode auto|off|rs|baser\n"
750 			"    set fec mode for a specific port\n\n"
751 
752 			, list_pkt_forwarding_modes()
753 		);
754 	}
755 
756 	if (show_all || !strcmp(res->section, "ports")) {
757 
758 		cmdline_printf(
759 			cl,
760 			"\n"
761 			"Port Operations:\n"
762 			"----------------\n\n"
763 
764 			"port start (port_id|all)\n"
765 			"    Start all ports or port_id.\n\n"
766 
767 			"port stop (port_id|all)\n"
768 			"    Stop all ports or port_id.\n\n"
769 
770 			"port close (port_id|all)\n"
771 			"    Close all ports or port_id.\n\n"
772 
773 			"port reset (port_id|all)\n"
774 			"    Reset all ports or port_id.\n\n"
775 
776 			"port attach (ident)\n"
777 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
778 
779 			"port detach (port_id)\n"
780 			"    Detach physical or virtual dev by port_id\n\n"
781 
782 			"port config (port_id|all)"
783 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
784 			" duplex (half|full|auto)\n"
785 			"    Set speed and duplex for all ports or port_id\n\n"
786 
787 			"port config (port_id|all) loopback (mode)\n"
788 			"    Set loopback mode for all ports or port_id\n\n"
789 
790 			"port config all (rxq|txq|rxd|txd) (value)\n"
791 			"    Set number for rxq/txq/rxd/txd.\n\n"
792 
793 			"port config all max-pkt-len (value)\n"
794 			"    Set the max packet length.\n\n"
795 
796 			"port config all max-lro-pkt-size (value)\n"
797 			"    Set the max LRO aggregated packet size.\n\n"
798 
799 			"port config all drop-en (on|off)\n"
800 			"    Enable or disable packet drop on all RX queues of all ports when no "
801 			"receive buffers available.\n\n"
802 
803 			"port config all rss (all|default|ip|tcp|udp|sctp|"
804 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
805 			"level-outer|level-inner|<flowtype_id>)\n"
806 			"    Set the RSS mode.\n\n"
807 
808 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
809 			"    Set the RSS redirection table.\n\n"
810 
811 			"port config (port_id) dcb vt (on|off) (traffic_class)"
812 			" pfc (on|off)\n"
813 			"    Set the DCB mode.\n\n"
814 
815 			"port config all burst (value)\n"
816 			"    Set the number of packets per burst.\n\n"
817 
818 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
819 			" (value)\n"
820 			"    Set the ring prefetch/host/writeback threshold"
821 			" for tx/rx queue.\n\n"
822 
823 			"port config all (txfreet|txrst|rxfreet) (value)\n"
824 			"    Set free threshold for rx/tx, or set"
825 			" tx rs bit threshold.\n\n"
826 			"port config mtu X value\n"
827 			"    Set the MTU of port X to a given value\n\n"
828 
829 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
830 			"    Set a rx/tx queue's ring size configuration, the new"
831 			" value will take effect after command that (re-)start the port"
832 			" or command that setup the specific queue\n\n"
833 
834 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
835 			"    Start/stop a rx/tx queue of port X. Only take effect"
836 			" when port X is started\n\n"
837 
838 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
839 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
840 			" take effect when port X is stopped.\n\n"
841 
842 			"port (port_id) (rxq|txq) (queue_id) setup\n"
843 			"    Setup a rx/tx queue of port X.\n\n"
844 
845 			"port config (port_id) pctype mapping reset\n"
846 			"    Reset flow type to pctype mapping on a port\n\n"
847 
848 			"port config (port_id) pctype mapping update"
849 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
850 			"    Update a flow type to pctype mapping item on a port\n\n"
851 
852 			"port config (port_id) pctype (pctype_id) hash_inset|"
853 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
854 			" (field_idx)\n"
855 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
856 
857 			"port config (port_id) pctype (pctype_id) hash_inset|"
858 			"fdir_inset|fdir_flx_inset clear all"
859 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
860 
861 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
862 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
863 
864 			"port config <port_id> rx_offload vlan_strip|"
865 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
866 			"outer_ipv4_cksum|macsec_strip|header_split|"
867 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
868 			"buffer_split|timestamp|security|keep_crc on|off\n"
869 			"     Enable or disable a per port Rx offloading"
870 			" on all Rx queues of a port\n\n"
871 
872 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
873 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
874 			"outer_ipv4_cksum|macsec_strip|header_split|"
875 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
876 			"buffer_split|timestamp|security|keep_crc on|off\n"
877 			"    Enable or disable a per queue Rx offloading"
878 			" only on a specific Rx queue\n\n"
879 
880 			"port config (port_id) tx_offload vlan_insert|"
881 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
882 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
883 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
884 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
885 			"security on|off\n"
886 			"    Enable or disable a per port Tx offloading"
887 			" on all Tx queues of a port\n\n"
888 
889 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
890 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
891 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
892 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
893 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
894 			" on|off\n"
895 			"    Enable or disable a per queue Tx offloading"
896 			" only on a specific Tx queue\n\n"
897 
898 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
899 			"    Load an eBPF program as a callback"
900 			" for particular RX/TX queue\n\n"
901 
902 			"bpf-unload rx|tx (port) (queue)\n"
903 			"    Unload previously loaded eBPF program"
904 			" for particular RX/TX queue\n\n"
905 
906 			"port config (port_id) tx_metadata (value)\n"
907 			"    Set Tx metadata value per port. Testpmd will add this value"
908 			" to any Tx packet sent from this port\n\n"
909 
910 			"port config (port_id) dynf (name) set|clear\n"
911 			"    Register a dynf and Set/clear this flag on Tx. "
912 			"Testpmd will set this value to any Tx packet "
913 			"sent from this port\n\n"
914 
915 			"port cleanup (port_id) txq (queue_id) (free_cnt)\n"
916 			"    Cleanup txq mbufs for a specific Tx queue\n\n"
917 		);
918 	}
919 
920 	if (show_all || !strcmp(res->section, "registers")) {
921 
922 		cmdline_printf(
923 			cl,
924 			"\n"
925 			"Registers:\n"
926 			"----------\n\n"
927 
928 			"read reg (port_id) (address)\n"
929 			"    Display value of a port register.\n\n"
930 
931 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
932 			"    Display a port register bit field.\n\n"
933 
934 			"read regbit (port_id) (address) (bit_x)\n"
935 			"    Display a single port register bit.\n\n"
936 
937 			"write reg (port_id) (address) (value)\n"
938 			"    Set value of a port register.\n\n"
939 
940 			"write regfield (port_id) (address) (bit_x) (bit_y)"
941 			" (value)\n"
942 			"    Set bit field of a port register.\n\n"
943 
944 			"write regbit (port_id) (address) (bit_x) (value)\n"
945 			"    Set single bit value of a port register.\n\n"
946 		);
947 	}
948 	if (show_all || !strcmp(res->section, "filters")) {
949 
950 		cmdline_printf(
951 			cl,
952 			"\n"
953 			"filters:\n"
954 			"--------\n\n"
955 
956 #ifdef RTE_NET_I40E
957 			"flow_director_filter (port_id) mode raw (add|del|update)"
958 			" flow (flow_id) (drop|fwd) queue (queue_id)"
959 			" fd_id (fd_id_value) packet (packet file name)\n"
960 			"    Add/Del a raw type flow director filter.\n\n"
961 #endif
962 
963 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
964 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
965 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
966 			"    Set flow director IP mask.\n\n"
967 
968 			"flow_director_mask (port_id) mode MAC-VLAN"
969 			" vlan (vlan_value)\n"
970 			"    Set flow director MAC-VLAN mask.\n\n"
971 
972 			"flow_director_mask (port_id) mode Tunnel"
973 			" vlan (vlan_value) mac (mac_value)"
974 			" tunnel-type (tunnel_type_value)"
975 			" tunnel-id (tunnel_id_value)\n"
976 			"    Set flow director Tunnel mask.\n\n"
977 
978 			"flow_director_flex_payload (port_id)"
979 			" (raw|l2|l3|l4) (config)\n"
980 			"    Configure flex payload selection.\n\n"
981 
982 			"flow validate {port_id}"
983 			" [group {group_id}] [priority {level}]"
984 			" [ingress] [egress]"
985 			" pattern {item} [/ {item} [...]] / end"
986 			" actions {action} [/ {action} [...]] / end\n"
987 			"    Check whether a flow rule can be created.\n\n"
988 
989 			"flow create {port_id}"
990 			" [group {group_id}] [priority {level}]"
991 			" [ingress] [egress]"
992 			" pattern {item} [/ {item} [...]] / end"
993 			" actions {action} [/ {action} [...]] / end\n"
994 			"    Create a flow rule.\n\n"
995 
996 			"flow destroy {port_id} rule {rule_id} [...]\n"
997 			"    Destroy specific flow rules.\n\n"
998 
999 			"flow flush {port_id}\n"
1000 			"    Destroy all flow rules.\n\n"
1001 
1002 			"flow query {port_id} {rule_id} {action}\n"
1003 			"    Query an existing flow rule.\n\n"
1004 
1005 			"flow list {port_id} [group {group_id}] [...]\n"
1006 			"    List existing flow rules sorted by priority,"
1007 			" filtered by group identifiers.\n\n"
1008 
1009 			"flow isolate {port_id} {boolean}\n"
1010 			"    Restrict ingress traffic to the defined"
1011 			" flow rules\n\n"
1012 
1013 			"flow aged {port_id} [destroy]\n"
1014 			"    List and destroy aged flows"
1015 			" flow rules\n\n"
1016 
1017 			"flow indirect_action {port_id} create"
1018 			" [action_id {indirect_action_id}]"
1019 			" [ingress] [egress]"
1020 			" action {action} / end\n"
1021 			"    Create indirect action.\n\n"
1022 
1023 			"flow indirect_action {port_id} update"
1024 			" {indirect_action_id} action {action} / end\n"
1025 			"    Update indirect action.\n\n"
1026 
1027 			"flow indirect_action {port_id} destroy"
1028 			" action_id {indirect_action_id} [...]\n"
1029 			"    Destroy specific indirect actions.\n\n"
1030 
1031 			"flow indirect_action {port_id} query"
1032 			" {indirect_action_id}\n"
1033 			"    Query an existing indirect action.\n\n"
1034 
1035 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1036 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1037 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1038 			"       Configure the VXLAN encapsulation for flows.\n\n"
1039 
1040 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1041 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1042 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1043 			" eth-dst (eth-dst)\n"
1044 			"       Configure the VXLAN encapsulation for flows.\n\n"
1045 
1046 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1047 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1048 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1049 			" eth-dst (eth-dst)\n"
1050 			"       Configure the VXLAN encapsulation for flows.\n\n"
1051 
1052 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1053 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1054 			" (eth-dst)\n"
1055 			"       Configure the NVGRE encapsulation for flows.\n\n"
1056 
1057 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1058 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1059 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1060 			"       Configure the NVGRE encapsulation for flows.\n\n"
1061 
1062 			"set raw_encap {flow items}\n"
1063 			"	Configure the encapsulation with raw data.\n\n"
1064 
1065 			"set raw_decap {flow items}\n"
1066 			"	Configure the decapsulation with raw data.\n\n"
1067 
1068 		);
1069 	}
1070 
1071 	if (show_all || !strcmp(res->section, "traffic_management")) {
1072 		cmdline_printf(
1073 			cl,
1074 			"\n"
1075 			"Traffic Management:\n"
1076 			"--------------\n"
1077 			"show port tm cap (port_id)\n"
1078 			"       Display the port TM capability.\n\n"
1079 
1080 			"show port tm level cap (port_id) (level_id)\n"
1081 			"       Display the port TM hierarchical level capability.\n\n"
1082 
1083 			"show port tm node cap (port_id) (node_id)\n"
1084 			"       Display the port TM node capability.\n\n"
1085 
1086 			"show port tm node type (port_id) (node_id)\n"
1087 			"       Display the port TM node type.\n\n"
1088 
1089 			"show port tm node stats (port_id) (node_id) (clear)\n"
1090 			"       Display the port TM node stats.\n\n"
1091 
1092 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1093 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1094 			" (packet_length_adjust) (packet_mode)\n"
1095 			"       Add port tm node private shaper profile.\n\n"
1096 
1097 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1098 			"       Delete port tm node private shaper profile.\n\n"
1099 
1100 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1101 			" (shaper_profile_id)\n"
1102 			"       Add/update port tm node shared shaper.\n\n"
1103 
1104 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1105 			"       Delete port tm node shared shaper.\n\n"
1106 
1107 			"set port tm node shaper profile (port_id) (node_id)"
1108 			" (shaper_profile_id)\n"
1109 			"       Set port tm node shaper profile.\n\n"
1110 
1111 			"add port tm node wred profile (port_id) (wred_profile_id)"
1112 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1113 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1114 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1115 			"       Add port tm node wred profile.\n\n"
1116 
1117 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1118 			"       Delete port tm node wred profile.\n\n"
1119 
1120 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1121 			" (priority) (weight) (level_id) (shaper_profile_id)"
1122 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1123 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1124 			"       Add port tm nonleaf node.\n\n"
1125 
1126 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1127 			" (priority) (weight) (level_id) (shaper_profile_id)"
1128 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1129 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1130 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
1131 
1132 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1133 			" (priority) (weight) (level_id) (shaper_profile_id)"
1134 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1135 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1136 			"       Add port tm leaf node.\n\n"
1137 
1138 			"del port tm node (port_id) (node_id)\n"
1139 			"       Delete port tm node.\n\n"
1140 
1141 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1142 			" (priority) (weight)\n"
1143 			"       Set port tm node parent.\n\n"
1144 
1145 			"suspend port tm node (port_id) (node_id)"
1146 			"       Suspend tm node.\n\n"
1147 
1148 			"resume port tm node (port_id) (node_id)"
1149 			"       Resume tm node.\n\n"
1150 
1151 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1152 			"       Commit tm hierarchy.\n\n"
1153 
1154 			"set port tm mark ip_ecn (port) (green) (yellow)"
1155 			" (red)\n"
1156 			"    Enables/Disables the traffic management marking"
1157 			" for IP ECN (Explicit Congestion Notification)"
1158 			" packets on a given port\n\n"
1159 
1160 			"set port tm mark ip_dscp (port) (green) (yellow)"
1161 			" (red)\n"
1162 			"    Enables/Disables the traffic management marking"
1163 			" on the port for IP dscp packets\n\n"
1164 
1165 			"set port tm mark vlan_dei (port) (green) (yellow)"
1166 			" (red)\n"
1167 			"    Enables/Disables the traffic management marking"
1168 			" on the port for VLAN packets with DEI enabled\n\n"
1169 		);
1170 	}
1171 
1172 	if (show_all || !strcmp(res->section, "devices")) {
1173 		cmdline_printf(
1174 			cl,
1175 			"\n"
1176 			"Device Operations:\n"
1177 			"--------------\n"
1178 			"device detach (identifier)\n"
1179 			"       Detach device by identifier.\n\n"
1180 		);
1181 	}
1182 
1183 }
1184 
1185 cmdline_parse_token_string_t cmd_help_long_help =
1186 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1187 
1188 cmdline_parse_token_string_t cmd_help_long_section =
1189 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1190 			"all#control#display#config#"
1191 			"ports#registers#filters#traffic_management#devices");
1192 
1193 cmdline_parse_inst_t cmd_help_long = {
1194 	.f = cmd_help_long_parsed,
1195 	.data = NULL,
1196 	.help_str = "help all|control|display|config|ports|register|"
1197 		"filters|traffic_management|devices: "
1198 		"Show help",
1199 	.tokens = {
1200 		(void *)&cmd_help_long_help,
1201 		(void *)&cmd_help_long_section,
1202 		NULL,
1203 	},
1204 };
1205 
1206 
1207 /* *** start/stop/close all ports *** */
1208 struct cmd_operate_port_result {
1209 	cmdline_fixed_string_t keyword;
1210 	cmdline_fixed_string_t name;
1211 	cmdline_fixed_string_t value;
1212 };
1213 
1214 static void cmd_operate_port_parsed(void *parsed_result,
1215 				__rte_unused struct cmdline *cl,
1216 				__rte_unused void *data)
1217 {
1218 	struct cmd_operate_port_result *res = parsed_result;
1219 
1220 	if (!strcmp(res->name, "start"))
1221 		start_port(RTE_PORT_ALL);
1222 	else if (!strcmp(res->name, "stop"))
1223 		stop_port(RTE_PORT_ALL);
1224 	else if (!strcmp(res->name, "close"))
1225 		close_port(RTE_PORT_ALL);
1226 	else if (!strcmp(res->name, "reset"))
1227 		reset_port(RTE_PORT_ALL);
1228 	else
1229 		printf("Unknown parameter\n");
1230 }
1231 
1232 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1233 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1234 								"port");
1235 cmdline_parse_token_string_t cmd_operate_port_all_port =
1236 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1237 						"start#stop#close#reset");
1238 cmdline_parse_token_string_t cmd_operate_port_all_all =
1239 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1240 
1241 cmdline_parse_inst_t cmd_operate_port = {
1242 	.f = cmd_operate_port_parsed,
1243 	.data = NULL,
1244 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1245 	.tokens = {
1246 		(void *)&cmd_operate_port_all_cmd,
1247 		(void *)&cmd_operate_port_all_port,
1248 		(void *)&cmd_operate_port_all_all,
1249 		NULL,
1250 	},
1251 };
1252 
1253 /* *** start/stop/close specific port *** */
1254 struct cmd_operate_specific_port_result {
1255 	cmdline_fixed_string_t keyword;
1256 	cmdline_fixed_string_t name;
1257 	uint8_t value;
1258 };
1259 
1260 static void cmd_operate_specific_port_parsed(void *parsed_result,
1261 			__rte_unused struct cmdline *cl,
1262 				__rte_unused void *data)
1263 {
1264 	struct cmd_operate_specific_port_result *res = parsed_result;
1265 
1266 	if (!strcmp(res->name, "start"))
1267 		start_port(res->value);
1268 	else if (!strcmp(res->name, "stop"))
1269 		stop_port(res->value);
1270 	else if (!strcmp(res->name, "close"))
1271 		close_port(res->value);
1272 	else if (!strcmp(res->name, "reset"))
1273 		reset_port(res->value);
1274 	else
1275 		printf("Unknown parameter\n");
1276 }
1277 
1278 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1279 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1280 							keyword, "port");
1281 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1282 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1283 						name, "start#stop#close#reset");
1284 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1285 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1286 							value, RTE_UINT8);
1287 
1288 cmdline_parse_inst_t cmd_operate_specific_port = {
1289 	.f = cmd_operate_specific_port_parsed,
1290 	.data = NULL,
1291 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1292 	.tokens = {
1293 		(void *)&cmd_operate_specific_port_cmd,
1294 		(void *)&cmd_operate_specific_port_port,
1295 		(void *)&cmd_operate_specific_port_id,
1296 		NULL,
1297 	},
1298 };
1299 
1300 /* *** enable port setup (after attach) via iterator or event *** */
1301 struct cmd_set_port_setup_on_result {
1302 	cmdline_fixed_string_t set;
1303 	cmdline_fixed_string_t port;
1304 	cmdline_fixed_string_t setup;
1305 	cmdline_fixed_string_t on;
1306 	cmdline_fixed_string_t mode;
1307 };
1308 
1309 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1310 				__rte_unused struct cmdline *cl,
1311 				__rte_unused void *data)
1312 {
1313 	struct cmd_set_port_setup_on_result *res = parsed_result;
1314 
1315 	if (strcmp(res->mode, "event") == 0)
1316 		setup_on_probe_event = true;
1317 	else if (strcmp(res->mode, "iterator") == 0)
1318 		setup_on_probe_event = false;
1319 	else
1320 		printf("Unknown mode\n");
1321 }
1322 
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1324 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1325 			set, "set");
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1327 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1328 			port, "port");
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1330 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1331 			setup, "setup");
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1333 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 			on, "on");
1335 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1336 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1337 			mode, "iterator#event");
1338 
1339 cmdline_parse_inst_t cmd_set_port_setup_on = {
1340 	.f = cmd_set_port_setup_on_parsed,
1341 	.data = NULL,
1342 	.help_str = "set port setup on iterator|event",
1343 	.tokens = {
1344 		(void *)&cmd_set_port_setup_on_set,
1345 		(void *)&cmd_set_port_setup_on_port,
1346 		(void *)&cmd_set_port_setup_on_setup,
1347 		(void *)&cmd_set_port_setup_on_on,
1348 		(void *)&cmd_set_port_setup_on_mode,
1349 		NULL,
1350 	},
1351 };
1352 
1353 /* *** attach a specified port *** */
1354 struct cmd_operate_attach_port_result {
1355 	cmdline_fixed_string_t port;
1356 	cmdline_fixed_string_t keyword;
1357 	cmdline_multi_string_t identifier;
1358 };
1359 
1360 static void cmd_operate_attach_port_parsed(void *parsed_result,
1361 				__rte_unused struct cmdline *cl,
1362 				__rte_unused void *data)
1363 {
1364 	struct cmd_operate_attach_port_result *res = parsed_result;
1365 
1366 	if (!strcmp(res->keyword, "attach"))
1367 		attach_port(res->identifier);
1368 	else
1369 		printf("Unknown parameter\n");
1370 }
1371 
1372 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1373 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1374 			port, "port");
1375 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1376 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 			keyword, "attach");
1378 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1379 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1380 			identifier, TOKEN_STRING_MULTI);
1381 
1382 cmdline_parse_inst_t cmd_operate_attach_port = {
1383 	.f = cmd_operate_attach_port_parsed,
1384 	.data = NULL,
1385 	.help_str = "port attach <identifier>: "
1386 		"(identifier: pci address or virtual dev name)",
1387 	.tokens = {
1388 		(void *)&cmd_operate_attach_port_port,
1389 		(void *)&cmd_operate_attach_port_keyword,
1390 		(void *)&cmd_operate_attach_port_identifier,
1391 		NULL,
1392 	},
1393 };
1394 
1395 /* *** detach a specified port *** */
1396 struct cmd_operate_detach_port_result {
1397 	cmdline_fixed_string_t port;
1398 	cmdline_fixed_string_t keyword;
1399 	portid_t port_id;
1400 };
1401 
1402 static void cmd_operate_detach_port_parsed(void *parsed_result,
1403 				__rte_unused struct cmdline *cl,
1404 				__rte_unused void *data)
1405 {
1406 	struct cmd_operate_detach_port_result *res = parsed_result;
1407 
1408 	if (!strcmp(res->keyword, "detach")) {
1409 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1410 		detach_port_device(res->port_id);
1411 	} else {
1412 		printf("Unknown parameter\n");
1413 	}
1414 }
1415 
1416 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1417 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1418 			port, "port");
1419 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1420 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1421 			keyword, "detach");
1422 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1423 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1424 			port_id, RTE_UINT16);
1425 
1426 cmdline_parse_inst_t cmd_operate_detach_port = {
1427 	.f = cmd_operate_detach_port_parsed,
1428 	.data = NULL,
1429 	.help_str = "port detach <port_id>",
1430 	.tokens = {
1431 		(void *)&cmd_operate_detach_port_port,
1432 		(void *)&cmd_operate_detach_port_keyword,
1433 		(void *)&cmd_operate_detach_port_port_id,
1434 		NULL,
1435 	},
1436 };
1437 
1438 /* *** detach device by identifier *** */
1439 struct cmd_operate_detach_device_result {
1440 	cmdline_fixed_string_t device;
1441 	cmdline_fixed_string_t keyword;
1442 	cmdline_fixed_string_t identifier;
1443 };
1444 
1445 static void cmd_operate_detach_device_parsed(void *parsed_result,
1446 				__rte_unused struct cmdline *cl,
1447 				__rte_unused void *data)
1448 {
1449 	struct cmd_operate_detach_device_result *res = parsed_result;
1450 
1451 	if (!strcmp(res->keyword, "detach"))
1452 		detach_devargs(res->identifier);
1453 	else
1454 		printf("Unknown parameter\n");
1455 }
1456 
1457 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1458 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1459 			device, "device");
1460 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1461 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1462 			keyword, "detach");
1463 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1464 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1465 			identifier, NULL);
1466 
1467 cmdline_parse_inst_t cmd_operate_detach_device = {
1468 	.f = cmd_operate_detach_device_parsed,
1469 	.data = NULL,
1470 	.help_str = "device detach <identifier>:"
1471 		"(identifier: pci address or virtual dev name)",
1472 	.tokens = {
1473 		(void *)&cmd_operate_detach_device_device,
1474 		(void *)&cmd_operate_detach_device_keyword,
1475 		(void *)&cmd_operate_detach_device_identifier,
1476 		NULL,
1477 	},
1478 };
1479 /* *** configure speed for all ports *** */
1480 struct cmd_config_speed_all {
1481 	cmdline_fixed_string_t port;
1482 	cmdline_fixed_string_t keyword;
1483 	cmdline_fixed_string_t all;
1484 	cmdline_fixed_string_t item1;
1485 	cmdline_fixed_string_t item2;
1486 	cmdline_fixed_string_t value1;
1487 	cmdline_fixed_string_t value2;
1488 };
1489 
1490 static int
1491 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1492 {
1493 
1494 	int duplex;
1495 
1496 	if (!strcmp(duplexstr, "half")) {
1497 		duplex = ETH_LINK_HALF_DUPLEX;
1498 	} else if (!strcmp(duplexstr, "full")) {
1499 		duplex = ETH_LINK_FULL_DUPLEX;
1500 	} else if (!strcmp(duplexstr, "auto")) {
1501 		duplex = ETH_LINK_FULL_DUPLEX;
1502 	} else {
1503 		printf("Unknown duplex parameter\n");
1504 		return -1;
1505 	}
1506 
1507 	if (!strcmp(speedstr, "10")) {
1508 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1509 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1510 	} else if (!strcmp(speedstr, "100")) {
1511 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1512 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1513 	} else {
1514 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1515 			printf("Invalid speed/duplex parameters\n");
1516 			return -1;
1517 		}
1518 		if (!strcmp(speedstr, "1000")) {
1519 			*speed = ETH_LINK_SPEED_1G;
1520 		} else if (!strcmp(speedstr, "10000")) {
1521 			*speed = ETH_LINK_SPEED_10G;
1522 		} else if (!strcmp(speedstr, "25000")) {
1523 			*speed = ETH_LINK_SPEED_25G;
1524 		} else if (!strcmp(speedstr, "40000")) {
1525 			*speed = ETH_LINK_SPEED_40G;
1526 		} else if (!strcmp(speedstr, "50000")) {
1527 			*speed = ETH_LINK_SPEED_50G;
1528 		} else if (!strcmp(speedstr, "100000")) {
1529 			*speed = ETH_LINK_SPEED_100G;
1530 		} else if (!strcmp(speedstr, "200000")) {
1531 			*speed = ETH_LINK_SPEED_200G;
1532 		} else if (!strcmp(speedstr, "auto")) {
1533 			*speed = ETH_LINK_SPEED_AUTONEG;
1534 		} else {
1535 			printf("Unknown speed parameter\n");
1536 			return -1;
1537 		}
1538 	}
1539 
1540 	if (*speed != ETH_LINK_SPEED_AUTONEG)
1541 		*speed |= ETH_LINK_SPEED_FIXED;
1542 
1543 	return 0;
1544 }
1545 
1546 static void
1547 cmd_config_speed_all_parsed(void *parsed_result,
1548 			__rte_unused struct cmdline *cl,
1549 			__rte_unused void *data)
1550 {
1551 	struct cmd_config_speed_all *res = parsed_result;
1552 	uint32_t link_speed;
1553 	portid_t pid;
1554 
1555 	if (!all_ports_stopped()) {
1556 		printf("Please stop all ports first\n");
1557 		return;
1558 	}
1559 
1560 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1561 			&link_speed) < 0)
1562 		return;
1563 
1564 	RTE_ETH_FOREACH_DEV(pid) {
1565 		ports[pid].dev_conf.link_speeds = link_speed;
1566 	}
1567 
1568 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1569 }
1570 
1571 cmdline_parse_token_string_t cmd_config_speed_all_port =
1572 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1573 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1574 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1575 							"config");
1576 cmdline_parse_token_string_t cmd_config_speed_all_all =
1577 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1578 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1579 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1580 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1581 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1582 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1583 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1584 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1585 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1586 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1587 						"half#full#auto");
1588 
1589 cmdline_parse_inst_t cmd_config_speed_all = {
1590 	.f = cmd_config_speed_all_parsed,
1591 	.data = NULL,
1592 	.help_str = "port config all speed "
1593 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1594 							"half|full|auto",
1595 	.tokens = {
1596 		(void *)&cmd_config_speed_all_port,
1597 		(void *)&cmd_config_speed_all_keyword,
1598 		(void *)&cmd_config_speed_all_all,
1599 		(void *)&cmd_config_speed_all_item1,
1600 		(void *)&cmd_config_speed_all_value1,
1601 		(void *)&cmd_config_speed_all_item2,
1602 		(void *)&cmd_config_speed_all_value2,
1603 		NULL,
1604 	},
1605 };
1606 
1607 /* *** configure speed for specific port *** */
1608 struct cmd_config_speed_specific {
1609 	cmdline_fixed_string_t port;
1610 	cmdline_fixed_string_t keyword;
1611 	portid_t id;
1612 	cmdline_fixed_string_t item1;
1613 	cmdline_fixed_string_t item2;
1614 	cmdline_fixed_string_t value1;
1615 	cmdline_fixed_string_t value2;
1616 };
1617 
1618 static void
1619 cmd_config_speed_specific_parsed(void *parsed_result,
1620 				__rte_unused struct cmdline *cl,
1621 				__rte_unused void *data)
1622 {
1623 	struct cmd_config_speed_specific *res = parsed_result;
1624 	uint32_t link_speed;
1625 
1626 	if (!all_ports_stopped()) {
1627 		printf("Please stop all ports first\n");
1628 		return;
1629 	}
1630 
1631 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1632 		return;
1633 
1634 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1635 			&link_speed) < 0)
1636 		return;
1637 
1638 	ports[res->id].dev_conf.link_speeds = link_speed;
1639 
1640 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1641 }
1642 
1643 
1644 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1645 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1646 								"port");
1647 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1648 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1649 								"config");
1650 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1651 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1652 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1653 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1654 								"speed");
1655 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1656 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1657 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1658 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1659 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1660 								"duplex");
1661 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1662 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1663 							"half#full#auto");
1664 
1665 cmdline_parse_inst_t cmd_config_speed_specific = {
1666 	.f = cmd_config_speed_specific_parsed,
1667 	.data = NULL,
1668 	.help_str = "port config <port_id> speed "
1669 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1670 							"half|full|auto",
1671 	.tokens = {
1672 		(void *)&cmd_config_speed_specific_port,
1673 		(void *)&cmd_config_speed_specific_keyword,
1674 		(void *)&cmd_config_speed_specific_id,
1675 		(void *)&cmd_config_speed_specific_item1,
1676 		(void *)&cmd_config_speed_specific_value1,
1677 		(void *)&cmd_config_speed_specific_item2,
1678 		(void *)&cmd_config_speed_specific_value2,
1679 		NULL,
1680 	},
1681 };
1682 
1683 /* *** configure loopback for all ports *** */
1684 struct cmd_config_loopback_all {
1685 	cmdline_fixed_string_t port;
1686 	cmdline_fixed_string_t keyword;
1687 	cmdline_fixed_string_t all;
1688 	cmdline_fixed_string_t item;
1689 	uint32_t mode;
1690 };
1691 
1692 static void
1693 cmd_config_loopback_all_parsed(void *parsed_result,
1694 			__rte_unused struct cmdline *cl,
1695 			__rte_unused void *data)
1696 {
1697 	struct cmd_config_loopback_all *res = parsed_result;
1698 	portid_t pid;
1699 
1700 	if (!all_ports_stopped()) {
1701 		printf("Please stop all ports first\n");
1702 		return;
1703 	}
1704 
1705 	RTE_ETH_FOREACH_DEV(pid) {
1706 		ports[pid].dev_conf.lpbk_mode = res->mode;
1707 	}
1708 
1709 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1710 }
1711 
1712 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1713 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1714 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1715 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1716 							"config");
1717 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1718 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1719 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1720 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1721 							"loopback");
1722 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1723 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1724 
1725 cmdline_parse_inst_t cmd_config_loopback_all = {
1726 	.f = cmd_config_loopback_all_parsed,
1727 	.data = NULL,
1728 	.help_str = "port config all loopback <mode>",
1729 	.tokens = {
1730 		(void *)&cmd_config_loopback_all_port,
1731 		(void *)&cmd_config_loopback_all_keyword,
1732 		(void *)&cmd_config_loopback_all_all,
1733 		(void *)&cmd_config_loopback_all_item,
1734 		(void *)&cmd_config_loopback_all_mode,
1735 		NULL,
1736 	},
1737 };
1738 
1739 /* *** configure loopback for specific port *** */
1740 struct cmd_config_loopback_specific {
1741 	cmdline_fixed_string_t port;
1742 	cmdline_fixed_string_t keyword;
1743 	uint16_t port_id;
1744 	cmdline_fixed_string_t item;
1745 	uint32_t mode;
1746 };
1747 
1748 static void
1749 cmd_config_loopback_specific_parsed(void *parsed_result,
1750 				__rte_unused struct cmdline *cl,
1751 				__rte_unused void *data)
1752 {
1753 	struct cmd_config_loopback_specific *res = parsed_result;
1754 
1755 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1756 		return;
1757 
1758 	if (!port_is_stopped(res->port_id)) {
1759 		printf("Please stop port %u first\n", res->port_id);
1760 		return;
1761 	}
1762 
1763 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1764 
1765 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1766 }
1767 
1768 
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1770 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1771 								"port");
1772 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1773 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1774 								"config");
1775 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1776 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1777 								RTE_UINT16);
1778 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1779 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1780 								"loopback");
1781 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1782 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1783 			      RTE_UINT32);
1784 
1785 cmdline_parse_inst_t cmd_config_loopback_specific = {
1786 	.f = cmd_config_loopback_specific_parsed,
1787 	.data = NULL,
1788 	.help_str = "port config <port_id> loopback <mode>",
1789 	.tokens = {
1790 		(void *)&cmd_config_loopback_specific_port,
1791 		(void *)&cmd_config_loopback_specific_keyword,
1792 		(void *)&cmd_config_loopback_specific_id,
1793 		(void *)&cmd_config_loopback_specific_item,
1794 		(void *)&cmd_config_loopback_specific_mode,
1795 		NULL,
1796 	},
1797 };
1798 
1799 /* *** configure txq/rxq, txd/rxd *** */
1800 struct cmd_config_rx_tx {
1801 	cmdline_fixed_string_t port;
1802 	cmdline_fixed_string_t keyword;
1803 	cmdline_fixed_string_t all;
1804 	cmdline_fixed_string_t name;
1805 	uint16_t value;
1806 };
1807 
1808 static void
1809 cmd_config_rx_tx_parsed(void *parsed_result,
1810 			__rte_unused struct cmdline *cl,
1811 			__rte_unused void *data)
1812 {
1813 	struct cmd_config_rx_tx *res = parsed_result;
1814 
1815 	if (!all_ports_stopped()) {
1816 		printf("Please stop all ports first\n");
1817 		return;
1818 	}
1819 	if (!strcmp(res->name, "rxq")) {
1820 		if (!res->value && !nb_txq) {
1821 			printf("Warning: Either rx or tx queues should be non zero\n");
1822 			return;
1823 		}
1824 		if (check_nb_rxq(res->value) != 0)
1825 			return;
1826 		nb_rxq = res->value;
1827 	}
1828 	else if (!strcmp(res->name, "txq")) {
1829 		if (!res->value && !nb_rxq) {
1830 			printf("Warning: Either rx or tx queues should be non zero\n");
1831 			return;
1832 		}
1833 		if (check_nb_txq(res->value) != 0)
1834 			return;
1835 		nb_txq = res->value;
1836 	}
1837 	else if (!strcmp(res->name, "rxd")) {
1838 		if (check_nb_rxd(res->value) != 0)
1839 			return;
1840 		nb_rxd = res->value;
1841 	} else if (!strcmp(res->name, "txd")) {
1842 		if (check_nb_txd(res->value) != 0)
1843 			return;
1844 
1845 		nb_txd = res->value;
1846 	} else {
1847 		printf("Unknown parameter\n");
1848 		return;
1849 	}
1850 
1851 	fwd_config_setup();
1852 
1853 	init_port_config();
1854 
1855 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1856 }
1857 
1858 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1859 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1860 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1861 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1862 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1863 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1864 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1865 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1866 						"rxq#txq#rxd#txd");
1867 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1868 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1869 
1870 cmdline_parse_inst_t cmd_config_rx_tx = {
1871 	.f = cmd_config_rx_tx_parsed,
1872 	.data = NULL,
1873 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1874 	.tokens = {
1875 		(void *)&cmd_config_rx_tx_port,
1876 		(void *)&cmd_config_rx_tx_keyword,
1877 		(void *)&cmd_config_rx_tx_all,
1878 		(void *)&cmd_config_rx_tx_name,
1879 		(void *)&cmd_config_rx_tx_value,
1880 		NULL,
1881 	},
1882 };
1883 
1884 /* *** config max packet length *** */
1885 struct cmd_config_max_pkt_len_result {
1886 	cmdline_fixed_string_t port;
1887 	cmdline_fixed_string_t keyword;
1888 	cmdline_fixed_string_t all;
1889 	cmdline_fixed_string_t name;
1890 	uint32_t value;
1891 };
1892 
1893 static void
1894 cmd_config_max_pkt_len_parsed(void *parsed_result,
1895 				__rte_unused struct cmdline *cl,
1896 				__rte_unused void *data)
1897 {
1898 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1899 	uint32_t max_rx_pkt_len_backup = 0;
1900 	portid_t pid;
1901 	int ret;
1902 
1903 	if (!all_ports_stopped()) {
1904 		printf("Please stop all ports first\n");
1905 		return;
1906 	}
1907 
1908 	RTE_ETH_FOREACH_DEV(pid) {
1909 		struct rte_port *port = &ports[pid];
1910 
1911 		if (!strcmp(res->name, "max-pkt-len")) {
1912 			if (res->value < RTE_ETHER_MIN_LEN) {
1913 				printf("max-pkt-len can not be less than %d\n",
1914 						RTE_ETHER_MIN_LEN);
1915 				return;
1916 			}
1917 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1918 				return;
1919 
1920 			ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1921 			if (ret != 0) {
1922 				printf("rte_eth_dev_info_get() failed for port %u\n",
1923 					pid);
1924 				return;
1925 			}
1926 
1927 			max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1928 
1929 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1930 			if (update_jumbo_frame_offload(pid) != 0)
1931 				port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1932 		} else {
1933 			printf("Unknown parameter\n");
1934 			return;
1935 		}
1936 	}
1937 
1938 	init_port_config();
1939 
1940 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1941 }
1942 
1943 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1944 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1945 								"port");
1946 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1947 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1948 								"config");
1949 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1950 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1951 								"all");
1952 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1953 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1954 								"max-pkt-len");
1955 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1956 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1957 								RTE_UINT32);
1958 
1959 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1960 	.f = cmd_config_max_pkt_len_parsed,
1961 	.data = NULL,
1962 	.help_str = "port config all max-pkt-len <value>",
1963 	.tokens = {
1964 		(void *)&cmd_config_max_pkt_len_port,
1965 		(void *)&cmd_config_max_pkt_len_keyword,
1966 		(void *)&cmd_config_max_pkt_len_all,
1967 		(void *)&cmd_config_max_pkt_len_name,
1968 		(void *)&cmd_config_max_pkt_len_value,
1969 		NULL,
1970 	},
1971 };
1972 
1973 /* *** config max LRO aggregated packet size *** */
1974 struct cmd_config_max_lro_pkt_size_result {
1975 	cmdline_fixed_string_t port;
1976 	cmdline_fixed_string_t keyword;
1977 	cmdline_fixed_string_t all;
1978 	cmdline_fixed_string_t name;
1979 	uint32_t value;
1980 };
1981 
1982 static void
1983 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1984 				__rte_unused struct cmdline *cl,
1985 				__rte_unused void *data)
1986 {
1987 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1988 	portid_t pid;
1989 
1990 	if (!all_ports_stopped()) {
1991 		printf("Please stop all ports first\n");
1992 		return;
1993 	}
1994 
1995 	RTE_ETH_FOREACH_DEV(pid) {
1996 		struct rte_port *port = &ports[pid];
1997 
1998 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1999 			if (res->value ==
2000 					port->dev_conf.rxmode.max_lro_pkt_size)
2001 				return;
2002 
2003 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2004 		} else {
2005 			printf("Unknown parameter\n");
2006 			return;
2007 		}
2008 	}
2009 
2010 	init_port_config();
2011 
2012 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2013 }
2014 
2015 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2016 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2017 				 port, "port");
2018 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2019 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2020 				 keyword, "config");
2021 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2022 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2023 				 all, "all");
2024 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2025 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2026 				 name, "max-lro-pkt-size");
2027 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2028 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2029 			      value, RTE_UINT32);
2030 
2031 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2032 	.f = cmd_config_max_lro_pkt_size_parsed,
2033 	.data = NULL,
2034 	.help_str = "port config all max-lro-pkt-size <value>",
2035 	.tokens = {
2036 		(void *)&cmd_config_max_lro_pkt_size_port,
2037 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2038 		(void *)&cmd_config_max_lro_pkt_size_all,
2039 		(void *)&cmd_config_max_lro_pkt_size_name,
2040 		(void *)&cmd_config_max_lro_pkt_size_value,
2041 		NULL,
2042 	},
2043 };
2044 
2045 /* *** configure port MTU *** */
2046 struct cmd_config_mtu_result {
2047 	cmdline_fixed_string_t port;
2048 	cmdline_fixed_string_t keyword;
2049 	cmdline_fixed_string_t mtu;
2050 	portid_t port_id;
2051 	uint16_t value;
2052 };
2053 
2054 static void
2055 cmd_config_mtu_parsed(void *parsed_result,
2056 		      __rte_unused struct cmdline *cl,
2057 		      __rte_unused void *data)
2058 {
2059 	struct cmd_config_mtu_result *res = parsed_result;
2060 
2061 	if (res->value < RTE_ETHER_MIN_LEN) {
2062 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2063 		return;
2064 	}
2065 	port_mtu_set(res->port_id, res->value);
2066 }
2067 
2068 cmdline_parse_token_string_t cmd_config_mtu_port =
2069 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2070 				 "port");
2071 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2072 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2073 				 "config");
2074 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2075 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2076 				 "mtu");
2077 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2078 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2079 				 RTE_UINT16);
2080 cmdline_parse_token_num_t cmd_config_mtu_value =
2081 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2082 				 RTE_UINT16);
2083 
2084 cmdline_parse_inst_t cmd_config_mtu = {
2085 	.f = cmd_config_mtu_parsed,
2086 	.data = NULL,
2087 	.help_str = "port config mtu <port_id> <value>",
2088 	.tokens = {
2089 		(void *)&cmd_config_mtu_port,
2090 		(void *)&cmd_config_mtu_keyword,
2091 		(void *)&cmd_config_mtu_mtu,
2092 		(void *)&cmd_config_mtu_port_id,
2093 		(void *)&cmd_config_mtu_value,
2094 		NULL,
2095 	},
2096 };
2097 
2098 /* *** configure rx mode *** */
2099 struct cmd_config_rx_mode_flag {
2100 	cmdline_fixed_string_t port;
2101 	cmdline_fixed_string_t keyword;
2102 	cmdline_fixed_string_t all;
2103 	cmdline_fixed_string_t name;
2104 	cmdline_fixed_string_t value;
2105 };
2106 
2107 static void
2108 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2109 				__rte_unused struct cmdline *cl,
2110 				__rte_unused void *data)
2111 {
2112 	struct cmd_config_rx_mode_flag *res = parsed_result;
2113 
2114 	if (!all_ports_stopped()) {
2115 		printf("Please stop all ports first\n");
2116 		return;
2117 	}
2118 
2119 	if (!strcmp(res->name, "drop-en")) {
2120 		if (!strcmp(res->value, "on"))
2121 			rx_drop_en = 1;
2122 		else if (!strcmp(res->value, "off"))
2123 			rx_drop_en = 0;
2124 		else {
2125 			printf("Unknown parameter\n");
2126 			return;
2127 		}
2128 	} else {
2129 		printf("Unknown parameter\n");
2130 		return;
2131 	}
2132 
2133 	init_port_config();
2134 
2135 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2136 }
2137 
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2139 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2141 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2142 								"config");
2143 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2144 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2145 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2146 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2147 					"drop-en");
2148 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2149 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2150 							"on#off");
2151 
2152 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2153 	.f = cmd_config_rx_mode_flag_parsed,
2154 	.data = NULL,
2155 	.help_str = "port config all drop-en on|off",
2156 	.tokens = {
2157 		(void *)&cmd_config_rx_mode_flag_port,
2158 		(void *)&cmd_config_rx_mode_flag_keyword,
2159 		(void *)&cmd_config_rx_mode_flag_all,
2160 		(void *)&cmd_config_rx_mode_flag_name,
2161 		(void *)&cmd_config_rx_mode_flag_value,
2162 		NULL,
2163 	},
2164 };
2165 
2166 /* *** configure rss *** */
2167 struct cmd_config_rss {
2168 	cmdline_fixed_string_t port;
2169 	cmdline_fixed_string_t keyword;
2170 	cmdline_fixed_string_t all;
2171 	cmdline_fixed_string_t name;
2172 	cmdline_fixed_string_t value;
2173 };
2174 
2175 static void
2176 cmd_config_rss_parsed(void *parsed_result,
2177 			__rte_unused struct cmdline *cl,
2178 			__rte_unused void *data)
2179 {
2180 	struct cmd_config_rss *res = parsed_result;
2181 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2182 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2183 	int use_default = 0;
2184 	int all_updated = 1;
2185 	int diag;
2186 	uint16_t i;
2187 	int ret;
2188 
2189 	if (!strcmp(res->value, "all"))
2190 		rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2191 			ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2192 			ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2193 			ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2194 			ETH_RSS_ECPRI;
2195 	else if (!strcmp(res->value, "eth"))
2196 		rss_conf.rss_hf = ETH_RSS_ETH;
2197 	else if (!strcmp(res->value, "vlan"))
2198 		rss_conf.rss_hf = ETH_RSS_VLAN;
2199 	else if (!strcmp(res->value, "ip"))
2200 		rss_conf.rss_hf = ETH_RSS_IP;
2201 	else if (!strcmp(res->value, "udp"))
2202 		rss_conf.rss_hf = ETH_RSS_UDP;
2203 	else if (!strcmp(res->value, "tcp"))
2204 		rss_conf.rss_hf = ETH_RSS_TCP;
2205 	else if (!strcmp(res->value, "sctp"))
2206 		rss_conf.rss_hf = ETH_RSS_SCTP;
2207 	else if (!strcmp(res->value, "ether"))
2208 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2209 	else if (!strcmp(res->value, "port"))
2210 		rss_conf.rss_hf = ETH_RSS_PORT;
2211 	else if (!strcmp(res->value, "vxlan"))
2212 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2213 	else if (!strcmp(res->value, "geneve"))
2214 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2215 	else if (!strcmp(res->value, "nvgre"))
2216 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2217 	else if (!strcmp(res->value, "l3-pre32"))
2218 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2219 	else if (!strcmp(res->value, "l3-pre40"))
2220 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2221 	else if (!strcmp(res->value, "l3-pre48"))
2222 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2223 	else if (!strcmp(res->value, "l3-pre56"))
2224 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2225 	else if (!strcmp(res->value, "l3-pre64"))
2226 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2227 	else if (!strcmp(res->value, "l3-pre96"))
2228 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2229 	else if (!strcmp(res->value, "l3-src-only"))
2230 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2231 	else if (!strcmp(res->value, "l3-dst-only"))
2232 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2233 	else if (!strcmp(res->value, "l4-src-only"))
2234 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2235 	else if (!strcmp(res->value, "l4-dst-only"))
2236 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2237 	else if (!strcmp(res->value, "l2-src-only"))
2238 		rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2239 	else if (!strcmp(res->value, "l2-dst-only"))
2240 		rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2241 	else if (!strcmp(res->value, "l2tpv3"))
2242 		rss_conf.rss_hf = ETH_RSS_L2TPV3;
2243 	else if (!strcmp(res->value, "esp"))
2244 		rss_conf.rss_hf = ETH_RSS_ESP;
2245 	else if (!strcmp(res->value, "ah"))
2246 		rss_conf.rss_hf = ETH_RSS_AH;
2247 	else if (!strcmp(res->value, "pfcp"))
2248 		rss_conf.rss_hf = ETH_RSS_PFCP;
2249 	else if (!strcmp(res->value, "pppoe"))
2250 		rss_conf.rss_hf = ETH_RSS_PPPOE;
2251 	else if (!strcmp(res->value, "gtpu"))
2252 		rss_conf.rss_hf = ETH_RSS_GTPU;
2253 	else if (!strcmp(res->value, "ecpri"))
2254 		rss_conf.rss_hf = ETH_RSS_ECPRI;
2255 	else if (!strcmp(res->value, "mpls"))
2256 		rss_conf.rss_hf = ETH_RSS_MPLS;
2257 	else if (!strcmp(res->value, "none"))
2258 		rss_conf.rss_hf = 0;
2259 	else if (!strcmp(res->value, "level-default")) {
2260 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2261 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2262 	} else if (!strcmp(res->value, "level-outer")) {
2263 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2264 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2265 	} else if (!strcmp(res->value, "level-inner")) {
2266 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2267 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2268 	} else if (!strcmp(res->value, "default"))
2269 		use_default = 1;
2270 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2271 						atoi(res->value) < 64)
2272 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2273 	else {
2274 		printf("Unknown parameter\n");
2275 		return;
2276 	}
2277 	rss_conf.rss_key = NULL;
2278 	/* Update global configuration for RSS types. */
2279 	RTE_ETH_FOREACH_DEV(i) {
2280 		struct rte_eth_rss_conf local_rss_conf;
2281 
2282 		ret = eth_dev_info_get_print_err(i, &dev_info);
2283 		if (ret != 0)
2284 			return;
2285 
2286 		if (use_default)
2287 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2288 
2289 		local_rss_conf = rss_conf;
2290 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2291 			dev_info.flow_type_rss_offloads;
2292 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2293 			printf("Port %u modified RSS hash function based on hardware support,"
2294 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2295 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2296 		}
2297 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2298 		if (diag < 0) {
2299 			all_updated = 0;
2300 			printf("Configuration of RSS hash at ethernet port %d "
2301 				"failed with error (%d): %s.\n",
2302 				i, -diag, strerror(-diag));
2303 		}
2304 	}
2305 	if (all_updated && !use_default) {
2306 		rss_hf = rss_conf.rss_hf;
2307 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2308 	}
2309 }
2310 
2311 cmdline_parse_token_string_t cmd_config_rss_port =
2312 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2313 cmdline_parse_token_string_t cmd_config_rss_keyword =
2314 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2315 cmdline_parse_token_string_t cmd_config_rss_all =
2316 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2317 cmdline_parse_token_string_t cmd_config_rss_name =
2318 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2319 cmdline_parse_token_string_t cmd_config_rss_value =
2320 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2321 
2322 cmdline_parse_inst_t cmd_config_rss = {
2323 	.f = cmd_config_rss_parsed,
2324 	.data = NULL,
2325 	.help_str = "port config all rss "
2326 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2327 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2328 		"level-outer|level-inner|<flowtype_id>",
2329 	.tokens = {
2330 		(void *)&cmd_config_rss_port,
2331 		(void *)&cmd_config_rss_keyword,
2332 		(void *)&cmd_config_rss_all,
2333 		(void *)&cmd_config_rss_name,
2334 		(void *)&cmd_config_rss_value,
2335 		NULL,
2336 	},
2337 };
2338 
2339 /* *** configure rss hash key *** */
2340 struct cmd_config_rss_hash_key {
2341 	cmdline_fixed_string_t port;
2342 	cmdline_fixed_string_t config;
2343 	portid_t port_id;
2344 	cmdline_fixed_string_t rss_hash_key;
2345 	cmdline_fixed_string_t rss_type;
2346 	cmdline_fixed_string_t key;
2347 };
2348 
2349 static uint8_t
2350 hexa_digit_to_value(char hexa_digit)
2351 {
2352 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2353 		return (uint8_t) (hexa_digit - '0');
2354 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2355 		return (uint8_t) ((hexa_digit - 'a') + 10);
2356 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2357 		return (uint8_t) ((hexa_digit - 'A') + 10);
2358 	/* Invalid hexa digit */
2359 	return 0xFF;
2360 }
2361 
2362 static uint8_t
2363 parse_and_check_key_hexa_digit(char *key, int idx)
2364 {
2365 	uint8_t hexa_v;
2366 
2367 	hexa_v = hexa_digit_to_value(key[idx]);
2368 	if (hexa_v == 0xFF)
2369 		printf("invalid key: character %c at position %d is not a "
2370 		       "valid hexa digit\n", key[idx], idx);
2371 	return hexa_v;
2372 }
2373 
2374 static void
2375 cmd_config_rss_hash_key_parsed(void *parsed_result,
2376 			       __rte_unused struct cmdline *cl,
2377 			       __rte_unused void *data)
2378 {
2379 	struct cmd_config_rss_hash_key *res = parsed_result;
2380 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2381 	uint8_t xdgt0;
2382 	uint8_t xdgt1;
2383 	int i;
2384 	struct rte_eth_dev_info dev_info;
2385 	uint8_t hash_key_size;
2386 	uint32_t key_len;
2387 	int ret;
2388 
2389 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2390 	if (ret != 0)
2391 		return;
2392 
2393 	if (dev_info.hash_key_size > 0 &&
2394 			dev_info.hash_key_size <= sizeof(hash_key))
2395 		hash_key_size = dev_info.hash_key_size;
2396 	else {
2397 		printf("dev_info did not provide a valid hash key size\n");
2398 		return;
2399 	}
2400 	/* Check the length of the RSS hash key */
2401 	key_len = strlen(res->key);
2402 	if (key_len != (hash_key_size * 2)) {
2403 		printf("key length: %d invalid - key must be a string of %d"
2404 			   " hexa-decimal numbers\n",
2405 			   (int) key_len, hash_key_size * 2);
2406 		return;
2407 	}
2408 	/* Translate RSS hash key into binary representation */
2409 	for (i = 0; i < hash_key_size; i++) {
2410 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2411 		if (xdgt0 == 0xFF)
2412 			return;
2413 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2414 		if (xdgt1 == 0xFF)
2415 			return;
2416 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2417 	}
2418 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2419 			hash_key_size);
2420 }
2421 
2422 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2423 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2425 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2426 				 "config");
2427 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2428 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2429 				 RTE_UINT16);
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2431 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2432 				 rss_hash_key, "rss-hash-key");
2433 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2434 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2435 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2436 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2437 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2438 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2439 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2440 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2441 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2442 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2443 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2444 
2445 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2446 	.f = cmd_config_rss_hash_key_parsed,
2447 	.data = NULL,
2448 	.help_str = "port config <port_id> rss-hash-key "
2449 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2450 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2451 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2452 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2453 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2454 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2455 		"<string of hex digits (variable length, NIC dependent)>",
2456 	.tokens = {
2457 		(void *)&cmd_config_rss_hash_key_port,
2458 		(void *)&cmd_config_rss_hash_key_config,
2459 		(void *)&cmd_config_rss_hash_key_port_id,
2460 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2461 		(void *)&cmd_config_rss_hash_key_rss_type,
2462 		(void *)&cmd_config_rss_hash_key_value,
2463 		NULL,
2464 	},
2465 };
2466 
2467 /* *** cleanup txq mbufs *** */
2468 struct cmd_cleanup_txq_mbufs_result {
2469 	cmdline_fixed_string_t port;
2470 	cmdline_fixed_string_t keyword;
2471 	cmdline_fixed_string_t name;
2472 	uint16_t port_id;
2473 	uint16_t queue_id;
2474 	uint32_t free_cnt;
2475 };
2476 
2477 static void
2478 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2479 			     __rte_unused struct cmdline *cl,
2480 			     __rte_unused void *data)
2481 {
2482 	struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2483 	uint16_t port_id = res->port_id;
2484 	uint16_t queue_id = res->queue_id;
2485 	uint32_t free_cnt = res->free_cnt;
2486 	struct rte_eth_txq_info qinfo;
2487 	int ret;
2488 
2489 	if (test_done == 0) {
2490 		printf("Please stop forwarding first\n");
2491 		return;
2492 	}
2493 
2494 	if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2495 		printf("Failed to get port %u Tx queue %u info\n",
2496 		       port_id, queue_id);
2497 		return;
2498 	}
2499 
2500 	if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2501 		printf("Tx queue %u not started\n", queue_id);
2502 		return;
2503 	}
2504 
2505 	ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2506 	if (ret < 0) {
2507 		printf("Failed to cleanup mbuf for port %u Tx queue %u "
2508 		       "error desc: %s(%d)\n",
2509 		       port_id, queue_id, strerror(-ret), ret);
2510 		return;
2511 	}
2512 
2513 	printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2514 	       port_id, queue_id, ret);
2515 }
2516 
2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2518 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2519 				 "port");
2520 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2521 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2522 				 "cleanup");
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2524 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2525 			      RTE_UINT16);
2526 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2527 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2528 				 "txq");
2529 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2530 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2531 			      RTE_UINT16);
2532 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2533 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2534 			      RTE_UINT32);
2535 
2536 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2537 	.f = cmd_cleanup_txq_mbufs_parsed,
2538 	.data = NULL,
2539 	.help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2540 	.tokens = {
2541 		(void *)&cmd_cleanup_txq_mbufs_port,
2542 		(void *)&cmd_cleanup_txq_mbufs_cleanup,
2543 		(void *)&cmd_cleanup_txq_mbufs_port_id,
2544 		(void *)&cmd_cleanup_txq_mbufs_txq,
2545 		(void *)&cmd_cleanup_txq_mbufs_queue_id,
2546 		(void *)&cmd_cleanup_txq_mbufs_free_cnt,
2547 		NULL,
2548 	},
2549 };
2550 
2551 /* *** configure port rxq/txq ring size *** */
2552 struct cmd_config_rxtx_ring_size {
2553 	cmdline_fixed_string_t port;
2554 	cmdline_fixed_string_t config;
2555 	portid_t portid;
2556 	cmdline_fixed_string_t rxtxq;
2557 	uint16_t qid;
2558 	cmdline_fixed_string_t rsize;
2559 	uint16_t size;
2560 };
2561 
2562 static void
2563 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2564 				 __rte_unused struct cmdline *cl,
2565 				 __rte_unused void *data)
2566 {
2567 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2568 	struct rte_port *port;
2569 	uint8_t isrx;
2570 
2571 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2572 		return;
2573 
2574 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2575 		printf("Invalid port id\n");
2576 		return;
2577 	}
2578 
2579 	port = &ports[res->portid];
2580 
2581 	if (!strcmp(res->rxtxq, "rxq"))
2582 		isrx = 1;
2583 	else if (!strcmp(res->rxtxq, "txq"))
2584 		isrx = 0;
2585 	else {
2586 		printf("Unknown parameter\n");
2587 		return;
2588 	}
2589 
2590 	if (isrx && rx_queue_id_is_invalid(res->qid))
2591 		return;
2592 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2593 		return;
2594 
2595 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2596 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2597 		       rx_free_thresh);
2598 		return;
2599 	}
2600 
2601 	if (isrx)
2602 		port->nb_rx_desc[res->qid] = res->size;
2603 	else
2604 		port->nb_tx_desc[res->qid] = res->size;
2605 
2606 	cmd_reconfig_device_queue(res->portid, 0, 1);
2607 }
2608 
2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2610 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2611 				 port, "port");
2612 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2613 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 				 config, "config");
2615 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2616 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2617 				 portid, RTE_UINT16);
2618 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2619 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 				 rxtxq, "rxq#txq");
2621 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2622 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2623 			      qid, RTE_UINT16);
2624 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2625 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 				 rsize, "ring_size");
2627 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2628 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2629 			      size, RTE_UINT16);
2630 
2631 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2632 	.f = cmd_config_rxtx_ring_size_parsed,
2633 	.data = NULL,
2634 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2635 	.tokens = {
2636 		(void *)&cmd_config_rxtx_ring_size_port,
2637 		(void *)&cmd_config_rxtx_ring_size_config,
2638 		(void *)&cmd_config_rxtx_ring_size_portid,
2639 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2640 		(void *)&cmd_config_rxtx_ring_size_qid,
2641 		(void *)&cmd_config_rxtx_ring_size_rsize,
2642 		(void *)&cmd_config_rxtx_ring_size_size,
2643 		NULL,
2644 	},
2645 };
2646 
2647 /* *** configure port rxq/txq start/stop *** */
2648 struct cmd_config_rxtx_queue {
2649 	cmdline_fixed_string_t port;
2650 	portid_t portid;
2651 	cmdline_fixed_string_t rxtxq;
2652 	uint16_t qid;
2653 	cmdline_fixed_string_t opname;
2654 };
2655 
2656 static void
2657 cmd_config_rxtx_queue_parsed(void *parsed_result,
2658 			__rte_unused struct cmdline *cl,
2659 			__rte_unused void *data)
2660 {
2661 	struct cmd_config_rxtx_queue *res = parsed_result;
2662 	uint8_t isrx;
2663 	uint8_t isstart;
2664 	int ret = 0;
2665 
2666 	if (test_done == 0) {
2667 		printf("Please stop forwarding first\n");
2668 		return;
2669 	}
2670 
2671 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2672 		return;
2673 
2674 	if (port_is_started(res->portid) != 1) {
2675 		printf("Please start port %u first\n", res->portid);
2676 		return;
2677 	}
2678 
2679 	if (!strcmp(res->rxtxq, "rxq"))
2680 		isrx = 1;
2681 	else if (!strcmp(res->rxtxq, "txq"))
2682 		isrx = 0;
2683 	else {
2684 		printf("Unknown parameter\n");
2685 		return;
2686 	}
2687 
2688 	if (isrx && rx_queue_id_is_invalid(res->qid))
2689 		return;
2690 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2691 		return;
2692 
2693 	if (!strcmp(res->opname, "start"))
2694 		isstart = 1;
2695 	else if (!strcmp(res->opname, "stop"))
2696 		isstart = 0;
2697 	else {
2698 		printf("Unknown parameter\n");
2699 		return;
2700 	}
2701 
2702 	if (isstart && isrx)
2703 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2704 	else if (!isstart && isrx)
2705 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2706 	else if (isstart && !isrx)
2707 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2708 	else
2709 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2710 
2711 	if (ret == -ENOTSUP)
2712 		printf("Function not supported in PMD driver\n");
2713 }
2714 
2715 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2716 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2717 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2718 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2719 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2720 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2721 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2722 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2723 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2724 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2725 						"start#stop");
2726 
2727 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2728 	.f = cmd_config_rxtx_queue_parsed,
2729 	.data = NULL,
2730 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2731 	.tokens = {
2732 		(void *)&cmd_config_rxtx_queue_port,
2733 		(void *)&cmd_config_rxtx_queue_portid,
2734 		(void *)&cmd_config_rxtx_queue_rxtxq,
2735 		(void *)&cmd_config_rxtx_queue_qid,
2736 		(void *)&cmd_config_rxtx_queue_opname,
2737 		NULL,
2738 	},
2739 };
2740 
2741 /* *** configure port rxq/txq deferred start on/off *** */
2742 struct cmd_config_deferred_start_rxtx_queue {
2743 	cmdline_fixed_string_t port;
2744 	portid_t port_id;
2745 	cmdline_fixed_string_t rxtxq;
2746 	uint16_t qid;
2747 	cmdline_fixed_string_t opname;
2748 	cmdline_fixed_string_t state;
2749 };
2750 
2751 static void
2752 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2753 			__rte_unused struct cmdline *cl,
2754 			__rte_unused void *data)
2755 {
2756 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2757 	struct rte_port *port;
2758 	uint8_t isrx;
2759 	uint8_t ison;
2760 	uint8_t needreconfig = 0;
2761 
2762 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2763 		return;
2764 
2765 	if (port_is_started(res->port_id) != 0) {
2766 		printf("Please stop port %u first\n", res->port_id);
2767 		return;
2768 	}
2769 
2770 	port = &ports[res->port_id];
2771 
2772 	isrx = !strcmp(res->rxtxq, "rxq");
2773 
2774 	if (isrx && rx_queue_id_is_invalid(res->qid))
2775 		return;
2776 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2777 		return;
2778 
2779 	ison = !strcmp(res->state, "on");
2780 
2781 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2782 		port->rx_conf[res->qid].rx_deferred_start = ison;
2783 		needreconfig = 1;
2784 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2785 		port->tx_conf[res->qid].tx_deferred_start = ison;
2786 		needreconfig = 1;
2787 	}
2788 
2789 	if (needreconfig)
2790 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2791 }
2792 
2793 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2794 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2795 						port, "port");
2796 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2797 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2798 						port_id, RTE_UINT16);
2799 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2800 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 						rxtxq, "rxq#txq");
2802 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2803 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2804 						qid, RTE_UINT16);
2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2806 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2807 						opname, "deferred_start");
2808 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2809 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2810 						state, "on#off");
2811 
2812 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2813 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2814 	.data = NULL,
2815 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2816 	.tokens = {
2817 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2818 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2819 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2820 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2821 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2822 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2823 		NULL,
2824 	},
2825 };
2826 
2827 /* *** configure port rxq/txq setup *** */
2828 struct cmd_setup_rxtx_queue {
2829 	cmdline_fixed_string_t port;
2830 	portid_t portid;
2831 	cmdline_fixed_string_t rxtxq;
2832 	uint16_t qid;
2833 	cmdline_fixed_string_t setup;
2834 };
2835 
2836 /* Common CLI fields for queue setup */
2837 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2838 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2839 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2840 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2841 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2842 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2843 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2844 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2845 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2846 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2847 
2848 static void
2849 cmd_setup_rxtx_queue_parsed(
2850 	void *parsed_result,
2851 	__rte_unused struct cmdline *cl,
2852 	__rte_unused void *data)
2853 {
2854 	struct cmd_setup_rxtx_queue *res = parsed_result;
2855 	struct rte_port *port;
2856 	struct rte_mempool *mp;
2857 	unsigned int socket_id;
2858 	uint8_t isrx = 0;
2859 	int ret;
2860 
2861 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2862 		return;
2863 
2864 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2865 		printf("Invalid port id\n");
2866 		return;
2867 	}
2868 
2869 	if (!strcmp(res->rxtxq, "rxq"))
2870 		isrx = 1;
2871 	else if (!strcmp(res->rxtxq, "txq"))
2872 		isrx = 0;
2873 	else {
2874 		printf("Unknown parameter\n");
2875 		return;
2876 	}
2877 
2878 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2879 		printf("Invalid rx queue\n");
2880 		return;
2881 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2882 		printf("Invalid tx queue\n");
2883 		return;
2884 	}
2885 
2886 	port = &ports[res->portid];
2887 	if (isrx) {
2888 		socket_id = rxring_numa[res->portid];
2889 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2890 			socket_id = port->socket_id;
2891 
2892 		mp = mbuf_pool_find(socket_id, 0);
2893 		if (mp == NULL) {
2894 			printf("Failed to setup RX queue: "
2895 				"No mempool allocation"
2896 				" on the socket %d\n",
2897 				rxring_numa[res->portid]);
2898 			return;
2899 		}
2900 		ret = rx_queue_setup(res->portid,
2901 				     res->qid,
2902 				     port->nb_rx_desc[res->qid],
2903 				     socket_id,
2904 				     &port->rx_conf[res->qid],
2905 				     mp);
2906 		if (ret)
2907 			printf("Failed to setup RX queue\n");
2908 	} else {
2909 		socket_id = txring_numa[res->portid];
2910 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2911 			socket_id = port->socket_id;
2912 
2913 		if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2914 			printf("Failed to setup TX queue: not enough descriptors\n");
2915 			return;
2916 		}
2917 		ret = rte_eth_tx_queue_setup(res->portid,
2918 					     res->qid,
2919 					     port->nb_tx_desc[res->qid],
2920 					     socket_id,
2921 					     &port->tx_conf[res->qid]);
2922 		if (ret)
2923 			printf("Failed to setup TX queue\n");
2924 	}
2925 }
2926 
2927 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2928 	.f = cmd_setup_rxtx_queue_parsed,
2929 	.data = NULL,
2930 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2931 	.tokens = {
2932 		(void *)&cmd_setup_rxtx_queue_port,
2933 		(void *)&cmd_setup_rxtx_queue_portid,
2934 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2935 		(void *)&cmd_setup_rxtx_queue_qid,
2936 		(void *)&cmd_setup_rxtx_queue_setup,
2937 		NULL,
2938 	},
2939 };
2940 
2941 
2942 /* *** Configure RSS RETA *** */
2943 struct cmd_config_rss_reta {
2944 	cmdline_fixed_string_t port;
2945 	cmdline_fixed_string_t keyword;
2946 	portid_t port_id;
2947 	cmdline_fixed_string_t name;
2948 	cmdline_fixed_string_t list_name;
2949 	cmdline_fixed_string_t list_of_items;
2950 };
2951 
2952 static int
2953 parse_reta_config(const char *str,
2954 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2955 		  uint16_t nb_entries)
2956 {
2957 	int i;
2958 	unsigned size;
2959 	uint16_t hash_index, idx, shift;
2960 	uint16_t nb_queue;
2961 	char s[256];
2962 	const char *p, *p0 = str;
2963 	char *end;
2964 	enum fieldnames {
2965 		FLD_HASH_INDEX = 0,
2966 		FLD_QUEUE,
2967 		_NUM_FLD
2968 	};
2969 	unsigned long int_fld[_NUM_FLD];
2970 	char *str_fld[_NUM_FLD];
2971 
2972 	while ((p = strchr(p0,'(')) != NULL) {
2973 		++p;
2974 		if((p0 = strchr(p,')')) == NULL)
2975 			return -1;
2976 
2977 		size = p0 - p;
2978 		if(size >= sizeof(s))
2979 			return -1;
2980 
2981 		snprintf(s, sizeof(s), "%.*s", size, p);
2982 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2983 			return -1;
2984 		for (i = 0; i < _NUM_FLD; i++) {
2985 			errno = 0;
2986 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2987 			if (errno != 0 || end == str_fld[i] ||
2988 					int_fld[i] > 65535)
2989 				return -1;
2990 		}
2991 
2992 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2993 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2994 
2995 		if (hash_index >= nb_entries) {
2996 			printf("Invalid RETA hash index=%d\n", hash_index);
2997 			return -1;
2998 		}
2999 
3000 		idx = hash_index / RTE_RETA_GROUP_SIZE;
3001 		shift = hash_index % RTE_RETA_GROUP_SIZE;
3002 		reta_conf[idx].mask |= (1ULL << shift);
3003 		reta_conf[idx].reta[shift] = nb_queue;
3004 	}
3005 
3006 	return 0;
3007 }
3008 
3009 static void
3010 cmd_set_rss_reta_parsed(void *parsed_result,
3011 			__rte_unused struct cmdline *cl,
3012 			__rte_unused void *data)
3013 {
3014 	int ret;
3015 	struct rte_eth_dev_info dev_info;
3016 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3017 	struct cmd_config_rss_reta *res = parsed_result;
3018 
3019 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3020 	if (ret != 0)
3021 		return;
3022 
3023 	if (dev_info.reta_size == 0) {
3024 		printf("Redirection table size is 0 which is "
3025 					"invalid for RSS\n");
3026 		return;
3027 	} else
3028 		printf("The reta size of port %d is %u\n",
3029 			res->port_id, dev_info.reta_size);
3030 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3031 		printf("Currently do not support more than %u entries of "
3032 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
3033 		return;
3034 	}
3035 
3036 	memset(reta_conf, 0, sizeof(reta_conf));
3037 	if (!strcmp(res->list_name, "reta")) {
3038 		if (parse_reta_config(res->list_of_items, reta_conf,
3039 						dev_info.reta_size)) {
3040 			printf("Invalid RSS Redirection Table "
3041 					"config entered\n");
3042 			return;
3043 		}
3044 		ret = rte_eth_dev_rss_reta_update(res->port_id,
3045 				reta_conf, dev_info.reta_size);
3046 		if (ret != 0)
3047 			printf("Bad redirection table parameter, "
3048 					"return code = %d \n", ret);
3049 	}
3050 }
3051 
3052 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3053 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3054 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3055 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3056 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3057 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3058 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3059 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3060 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3061 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3063         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3064                                  NULL);
3065 cmdline_parse_inst_t cmd_config_rss_reta = {
3066 	.f = cmd_set_rss_reta_parsed,
3067 	.data = NULL,
3068 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3069 	.tokens = {
3070 		(void *)&cmd_config_rss_reta_port,
3071 		(void *)&cmd_config_rss_reta_keyword,
3072 		(void *)&cmd_config_rss_reta_port_id,
3073 		(void *)&cmd_config_rss_reta_name,
3074 		(void *)&cmd_config_rss_reta_list_name,
3075 		(void *)&cmd_config_rss_reta_list_of_items,
3076 		NULL,
3077 	},
3078 };
3079 
3080 /* *** SHOW PORT RETA INFO *** */
3081 struct cmd_showport_reta {
3082 	cmdline_fixed_string_t show;
3083 	cmdline_fixed_string_t port;
3084 	portid_t port_id;
3085 	cmdline_fixed_string_t rss;
3086 	cmdline_fixed_string_t reta;
3087 	uint16_t size;
3088 	cmdline_fixed_string_t list_of_items;
3089 };
3090 
3091 static int
3092 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3093 			   uint16_t nb_entries,
3094 			   char *str)
3095 {
3096 	uint32_t size;
3097 	const char *p, *p0 = str;
3098 	char s[256];
3099 	char *end;
3100 	char *str_fld[8];
3101 	uint16_t i;
3102 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3103 			RTE_RETA_GROUP_SIZE;
3104 	int ret;
3105 
3106 	p = strchr(p0, '(');
3107 	if (p == NULL)
3108 		return -1;
3109 	p++;
3110 	p0 = strchr(p, ')');
3111 	if (p0 == NULL)
3112 		return -1;
3113 	size = p0 - p;
3114 	if (size >= sizeof(s)) {
3115 		printf("The string size exceeds the internal buffer size\n");
3116 		return -1;
3117 	}
3118 	snprintf(s, sizeof(s), "%.*s", size, p);
3119 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3120 	if (ret <= 0 || ret != num) {
3121 		printf("The bits of masks do not match the number of "
3122 					"reta entries: %u\n", num);
3123 		return -1;
3124 	}
3125 	for (i = 0; i < ret; i++)
3126 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3127 
3128 	return 0;
3129 }
3130 
3131 static void
3132 cmd_showport_reta_parsed(void *parsed_result,
3133 			 __rte_unused struct cmdline *cl,
3134 			 __rte_unused void *data)
3135 {
3136 	struct cmd_showport_reta *res = parsed_result;
3137 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3138 	struct rte_eth_dev_info dev_info;
3139 	uint16_t max_reta_size;
3140 	int ret;
3141 
3142 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3143 	if (ret != 0)
3144 		return;
3145 
3146 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3147 	if (res->size == 0 || res->size > max_reta_size) {
3148 		printf("Invalid redirection table size: %u (1-%u)\n",
3149 			res->size, max_reta_size);
3150 		return;
3151 	}
3152 
3153 	memset(reta_conf, 0, sizeof(reta_conf));
3154 	if (showport_parse_reta_config(reta_conf, res->size,
3155 				res->list_of_items) < 0) {
3156 		printf("Invalid string: %s for reta masks\n",
3157 					res->list_of_items);
3158 		return;
3159 	}
3160 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3161 }
3162 
3163 cmdline_parse_token_string_t cmd_showport_reta_show =
3164 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3165 cmdline_parse_token_string_t cmd_showport_reta_port =
3166 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3167 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3168 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3169 cmdline_parse_token_string_t cmd_showport_reta_rss =
3170 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3171 cmdline_parse_token_string_t cmd_showport_reta_reta =
3172 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3173 cmdline_parse_token_num_t cmd_showport_reta_size =
3174 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3175 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3176 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3177 					list_of_items, NULL);
3178 
3179 cmdline_parse_inst_t cmd_showport_reta = {
3180 	.f = cmd_showport_reta_parsed,
3181 	.data = NULL,
3182 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3183 	.tokens = {
3184 		(void *)&cmd_showport_reta_show,
3185 		(void *)&cmd_showport_reta_port,
3186 		(void *)&cmd_showport_reta_port_id,
3187 		(void *)&cmd_showport_reta_rss,
3188 		(void *)&cmd_showport_reta_reta,
3189 		(void *)&cmd_showport_reta_size,
3190 		(void *)&cmd_showport_reta_list_of_items,
3191 		NULL,
3192 	},
3193 };
3194 
3195 /* *** Show RSS hash configuration *** */
3196 struct cmd_showport_rss_hash {
3197 	cmdline_fixed_string_t show;
3198 	cmdline_fixed_string_t port;
3199 	portid_t port_id;
3200 	cmdline_fixed_string_t rss_hash;
3201 	cmdline_fixed_string_t rss_type;
3202 	cmdline_fixed_string_t key; /* optional argument */
3203 };
3204 
3205 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3206 				__rte_unused struct cmdline *cl,
3207 				void *show_rss_key)
3208 {
3209 	struct cmd_showport_rss_hash *res = parsed_result;
3210 
3211 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3212 }
3213 
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3215 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3216 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3217 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3218 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3219 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3220 				 RTE_UINT16);
3221 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3222 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3223 				 "rss-hash");
3224 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3225 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3226 
3227 cmdline_parse_inst_t cmd_showport_rss_hash = {
3228 	.f = cmd_showport_rss_hash_parsed,
3229 	.data = NULL,
3230 	.help_str = "show port <port_id> rss-hash",
3231 	.tokens = {
3232 		(void *)&cmd_showport_rss_hash_show,
3233 		(void *)&cmd_showport_rss_hash_port,
3234 		(void *)&cmd_showport_rss_hash_port_id,
3235 		(void *)&cmd_showport_rss_hash_rss_hash,
3236 		NULL,
3237 	},
3238 };
3239 
3240 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3241 	.f = cmd_showport_rss_hash_parsed,
3242 	.data = (void *)1,
3243 	.help_str = "show port <port_id> rss-hash key",
3244 	.tokens = {
3245 		(void *)&cmd_showport_rss_hash_show,
3246 		(void *)&cmd_showport_rss_hash_port,
3247 		(void *)&cmd_showport_rss_hash_port_id,
3248 		(void *)&cmd_showport_rss_hash_rss_hash,
3249 		(void *)&cmd_showport_rss_hash_rss_key,
3250 		NULL,
3251 	},
3252 };
3253 
3254 /* *** Configure DCB *** */
3255 struct cmd_config_dcb {
3256 	cmdline_fixed_string_t port;
3257 	cmdline_fixed_string_t config;
3258 	portid_t port_id;
3259 	cmdline_fixed_string_t dcb;
3260 	cmdline_fixed_string_t vt;
3261 	cmdline_fixed_string_t vt_en;
3262 	uint8_t num_tcs;
3263 	cmdline_fixed_string_t pfc;
3264 	cmdline_fixed_string_t pfc_en;
3265 };
3266 
3267 static void
3268 cmd_config_dcb_parsed(void *parsed_result,
3269                         __rte_unused struct cmdline *cl,
3270                         __rte_unused void *data)
3271 {
3272 	struct cmd_config_dcb *res = parsed_result;
3273 	portid_t port_id = res->port_id;
3274 	struct rte_port *port;
3275 	uint8_t pfc_en;
3276 	int ret;
3277 
3278 	port = &ports[port_id];
3279 	/** Check if the port is not started **/
3280 	if (port->port_status != RTE_PORT_STOPPED) {
3281 		printf("Please stop port %d first\n", port_id);
3282 		return;
3283 	}
3284 
3285 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3286 		printf("The invalid number of traffic class,"
3287 			" only 4 or 8 allowed.\n");
3288 		return;
3289 	}
3290 
3291 	if (nb_fwd_lcores < res->num_tcs) {
3292 		printf("nb_cores shouldn't be less than number of TCs.\n");
3293 		return;
3294 	}
3295 	if (!strncmp(res->pfc_en, "on", 2))
3296 		pfc_en = 1;
3297 	else
3298 		pfc_en = 0;
3299 
3300 	/* DCB in VT mode */
3301 	if (!strncmp(res->vt_en, "on", 2))
3302 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3303 				(enum rte_eth_nb_tcs)res->num_tcs,
3304 				pfc_en);
3305 	else
3306 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3307 				(enum rte_eth_nb_tcs)res->num_tcs,
3308 				pfc_en);
3309 
3310 
3311 	if (ret != 0) {
3312 		printf("Cannot initialize network ports.\n");
3313 		return;
3314 	}
3315 
3316 	cmd_reconfig_device_queue(port_id, 1, 1);
3317 }
3318 
3319 cmdline_parse_token_string_t cmd_config_dcb_port =
3320         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3321 cmdline_parse_token_string_t cmd_config_dcb_config =
3322         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3323 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3324 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3325 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3326         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3327 cmdline_parse_token_string_t cmd_config_dcb_vt =
3328         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3329 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3330         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3331 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3332 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3333 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3334         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3335 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3336         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3337 
3338 cmdline_parse_inst_t cmd_config_dcb = {
3339 	.f = cmd_config_dcb_parsed,
3340 	.data = NULL,
3341 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3342 	.tokens = {
3343 		(void *)&cmd_config_dcb_port,
3344 		(void *)&cmd_config_dcb_config,
3345 		(void *)&cmd_config_dcb_port_id,
3346 		(void *)&cmd_config_dcb_dcb,
3347 		(void *)&cmd_config_dcb_vt,
3348 		(void *)&cmd_config_dcb_vt_en,
3349 		(void *)&cmd_config_dcb_num_tcs,
3350 		(void *)&cmd_config_dcb_pfc,
3351 		(void *)&cmd_config_dcb_pfc_en,
3352                 NULL,
3353         },
3354 };
3355 
3356 /* *** configure number of packets per burst *** */
3357 struct cmd_config_burst {
3358 	cmdline_fixed_string_t port;
3359 	cmdline_fixed_string_t keyword;
3360 	cmdline_fixed_string_t all;
3361 	cmdline_fixed_string_t name;
3362 	uint16_t value;
3363 };
3364 
3365 static void
3366 cmd_config_burst_parsed(void *parsed_result,
3367 			__rte_unused struct cmdline *cl,
3368 			__rte_unused void *data)
3369 {
3370 	struct cmd_config_burst *res = parsed_result;
3371 	struct rte_eth_dev_info dev_info;
3372 	uint16_t rec_nb_pkts;
3373 	int ret;
3374 
3375 	if (!all_ports_stopped()) {
3376 		printf("Please stop all ports first\n");
3377 		return;
3378 	}
3379 
3380 	if (!strcmp(res->name, "burst")) {
3381 		if (res->value == 0) {
3382 			/* If user gives a value of zero, query the PMD for
3383 			 * its recommended Rx burst size. Testpmd uses a single
3384 			 * size for all ports, so assume all ports are the same
3385 			 * NIC model and use the values from Port 0.
3386 			 */
3387 			ret = eth_dev_info_get_print_err(0, &dev_info);
3388 			if (ret != 0)
3389 				return;
3390 
3391 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3392 
3393 			if (rec_nb_pkts == 0) {
3394 				printf("PMD does not recommend a burst size.\n"
3395 					"User provided value must be between"
3396 					" 1 and %d\n", MAX_PKT_BURST);
3397 				return;
3398 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3399 				printf("PMD recommended burst size of %d"
3400 					" exceeds maximum value of %d\n",
3401 					rec_nb_pkts, MAX_PKT_BURST);
3402 				return;
3403 			}
3404 			printf("Using PMD-provided burst value of %d\n",
3405 				rec_nb_pkts);
3406 			nb_pkt_per_burst = rec_nb_pkts;
3407 		} else if (res->value > MAX_PKT_BURST) {
3408 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3409 			return;
3410 		} else
3411 			nb_pkt_per_burst = res->value;
3412 	} else {
3413 		printf("Unknown parameter\n");
3414 		return;
3415 	}
3416 
3417 	init_port_config();
3418 
3419 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3420 }
3421 
3422 cmdline_parse_token_string_t cmd_config_burst_port =
3423 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3424 cmdline_parse_token_string_t cmd_config_burst_keyword =
3425 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3426 cmdline_parse_token_string_t cmd_config_burst_all =
3427 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3428 cmdline_parse_token_string_t cmd_config_burst_name =
3429 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3430 cmdline_parse_token_num_t cmd_config_burst_value =
3431 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3432 
3433 cmdline_parse_inst_t cmd_config_burst = {
3434 	.f = cmd_config_burst_parsed,
3435 	.data = NULL,
3436 	.help_str = "port config all burst <value>",
3437 	.tokens = {
3438 		(void *)&cmd_config_burst_port,
3439 		(void *)&cmd_config_burst_keyword,
3440 		(void *)&cmd_config_burst_all,
3441 		(void *)&cmd_config_burst_name,
3442 		(void *)&cmd_config_burst_value,
3443 		NULL,
3444 	},
3445 };
3446 
3447 /* *** configure rx/tx queues *** */
3448 struct cmd_config_thresh {
3449 	cmdline_fixed_string_t port;
3450 	cmdline_fixed_string_t keyword;
3451 	cmdline_fixed_string_t all;
3452 	cmdline_fixed_string_t name;
3453 	uint8_t value;
3454 };
3455 
3456 static void
3457 cmd_config_thresh_parsed(void *parsed_result,
3458 			__rte_unused struct cmdline *cl,
3459 			__rte_unused void *data)
3460 {
3461 	struct cmd_config_thresh *res = parsed_result;
3462 
3463 	if (!all_ports_stopped()) {
3464 		printf("Please stop all ports first\n");
3465 		return;
3466 	}
3467 
3468 	if (!strcmp(res->name, "txpt"))
3469 		tx_pthresh = res->value;
3470 	else if(!strcmp(res->name, "txht"))
3471 		tx_hthresh = res->value;
3472 	else if(!strcmp(res->name, "txwt"))
3473 		tx_wthresh = res->value;
3474 	else if(!strcmp(res->name, "rxpt"))
3475 		rx_pthresh = res->value;
3476 	else if(!strcmp(res->name, "rxht"))
3477 		rx_hthresh = res->value;
3478 	else if(!strcmp(res->name, "rxwt"))
3479 		rx_wthresh = res->value;
3480 	else {
3481 		printf("Unknown parameter\n");
3482 		return;
3483 	}
3484 
3485 	init_port_config();
3486 
3487 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3488 }
3489 
3490 cmdline_parse_token_string_t cmd_config_thresh_port =
3491 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3492 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3493 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3494 cmdline_parse_token_string_t cmd_config_thresh_all =
3495 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3496 cmdline_parse_token_string_t cmd_config_thresh_name =
3497 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3498 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3499 cmdline_parse_token_num_t cmd_config_thresh_value =
3500 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3501 
3502 cmdline_parse_inst_t cmd_config_thresh = {
3503 	.f = cmd_config_thresh_parsed,
3504 	.data = NULL,
3505 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3506 	.tokens = {
3507 		(void *)&cmd_config_thresh_port,
3508 		(void *)&cmd_config_thresh_keyword,
3509 		(void *)&cmd_config_thresh_all,
3510 		(void *)&cmd_config_thresh_name,
3511 		(void *)&cmd_config_thresh_value,
3512 		NULL,
3513 	},
3514 };
3515 
3516 /* *** configure free/rs threshold *** */
3517 struct cmd_config_threshold {
3518 	cmdline_fixed_string_t port;
3519 	cmdline_fixed_string_t keyword;
3520 	cmdline_fixed_string_t all;
3521 	cmdline_fixed_string_t name;
3522 	uint16_t value;
3523 };
3524 
3525 static void
3526 cmd_config_threshold_parsed(void *parsed_result,
3527 			__rte_unused struct cmdline *cl,
3528 			__rte_unused void *data)
3529 {
3530 	struct cmd_config_threshold *res = parsed_result;
3531 
3532 	if (!all_ports_stopped()) {
3533 		printf("Please stop all ports first\n");
3534 		return;
3535 	}
3536 
3537 	if (!strcmp(res->name, "txfreet"))
3538 		tx_free_thresh = res->value;
3539 	else if (!strcmp(res->name, "txrst"))
3540 		tx_rs_thresh = res->value;
3541 	else if (!strcmp(res->name, "rxfreet"))
3542 		rx_free_thresh = res->value;
3543 	else {
3544 		printf("Unknown parameter\n");
3545 		return;
3546 	}
3547 
3548 	init_port_config();
3549 
3550 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3551 }
3552 
3553 cmdline_parse_token_string_t cmd_config_threshold_port =
3554 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3555 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3556 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3557 								"config");
3558 cmdline_parse_token_string_t cmd_config_threshold_all =
3559 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3560 cmdline_parse_token_string_t cmd_config_threshold_name =
3561 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3562 						"txfreet#txrst#rxfreet");
3563 cmdline_parse_token_num_t cmd_config_threshold_value =
3564 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3565 
3566 cmdline_parse_inst_t cmd_config_threshold = {
3567 	.f = cmd_config_threshold_parsed,
3568 	.data = NULL,
3569 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3570 	.tokens = {
3571 		(void *)&cmd_config_threshold_port,
3572 		(void *)&cmd_config_threshold_keyword,
3573 		(void *)&cmd_config_threshold_all,
3574 		(void *)&cmd_config_threshold_name,
3575 		(void *)&cmd_config_threshold_value,
3576 		NULL,
3577 	},
3578 };
3579 
3580 /* *** stop *** */
3581 struct cmd_stop_result {
3582 	cmdline_fixed_string_t stop;
3583 };
3584 
3585 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3586 			    __rte_unused struct cmdline *cl,
3587 			    __rte_unused void *data)
3588 {
3589 	stop_packet_forwarding();
3590 }
3591 
3592 cmdline_parse_token_string_t cmd_stop_stop =
3593 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3594 
3595 cmdline_parse_inst_t cmd_stop = {
3596 	.f = cmd_stop_parsed,
3597 	.data = NULL,
3598 	.help_str = "stop: Stop packet forwarding",
3599 	.tokens = {
3600 		(void *)&cmd_stop_stop,
3601 		NULL,
3602 	},
3603 };
3604 
3605 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3606 
3607 unsigned int
3608 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3609 		unsigned int *parsed_items, int check_unique_values)
3610 {
3611 	unsigned int nb_item;
3612 	unsigned int value;
3613 	unsigned int i;
3614 	unsigned int j;
3615 	int value_ok;
3616 	char c;
3617 
3618 	/*
3619 	 * First parse all items in the list and store their value.
3620 	 */
3621 	value = 0;
3622 	nb_item = 0;
3623 	value_ok = 0;
3624 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3625 		c = str[i];
3626 		if ((c >= '0') && (c <= '9')) {
3627 			value = (unsigned int) (value * 10 + (c - '0'));
3628 			value_ok = 1;
3629 			continue;
3630 		}
3631 		if (c != ',') {
3632 			printf("character %c is not a decimal digit\n", c);
3633 			return 0;
3634 		}
3635 		if (! value_ok) {
3636 			printf("No valid value before comma\n");
3637 			return 0;
3638 		}
3639 		if (nb_item < max_items) {
3640 			parsed_items[nb_item] = value;
3641 			value_ok = 0;
3642 			value = 0;
3643 		}
3644 		nb_item++;
3645 	}
3646 	if (nb_item >= max_items) {
3647 		printf("Number of %s = %u > %u (maximum items)\n",
3648 		       item_name, nb_item + 1, max_items);
3649 		return 0;
3650 	}
3651 	parsed_items[nb_item++] = value;
3652 	if (! check_unique_values)
3653 		return nb_item;
3654 
3655 	/*
3656 	 * Then, check that all values in the list are differents.
3657 	 * No optimization here...
3658 	 */
3659 	for (i = 0; i < nb_item; i++) {
3660 		for (j = i + 1; j < nb_item; j++) {
3661 			if (parsed_items[j] == parsed_items[i]) {
3662 				printf("duplicated %s %u at index %u and %u\n",
3663 				       item_name, parsed_items[i], i, j);
3664 				return 0;
3665 			}
3666 		}
3667 	}
3668 	return nb_item;
3669 }
3670 
3671 struct cmd_set_list_result {
3672 	cmdline_fixed_string_t cmd_keyword;
3673 	cmdline_fixed_string_t list_name;
3674 	cmdline_fixed_string_t list_of_items;
3675 };
3676 
3677 static void cmd_set_list_parsed(void *parsed_result,
3678 				__rte_unused struct cmdline *cl,
3679 				__rte_unused void *data)
3680 {
3681 	struct cmd_set_list_result *res;
3682 	union {
3683 		unsigned int lcorelist[RTE_MAX_LCORE];
3684 		unsigned int portlist[RTE_MAX_ETHPORTS];
3685 	} parsed_items;
3686 	unsigned int nb_item;
3687 
3688 	if (test_done == 0) {
3689 		printf("Please stop forwarding first\n");
3690 		return;
3691 	}
3692 
3693 	res = parsed_result;
3694 	if (!strcmp(res->list_name, "corelist")) {
3695 		nb_item = parse_item_list(res->list_of_items, "core",
3696 					  RTE_MAX_LCORE,
3697 					  parsed_items.lcorelist, 1);
3698 		if (nb_item > 0) {
3699 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3700 			fwd_config_setup();
3701 		}
3702 		return;
3703 	}
3704 	if (!strcmp(res->list_name, "portlist")) {
3705 		nb_item = parse_item_list(res->list_of_items, "port",
3706 					  RTE_MAX_ETHPORTS,
3707 					  parsed_items.portlist, 1);
3708 		if (nb_item > 0) {
3709 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3710 			fwd_config_setup();
3711 		}
3712 	}
3713 }
3714 
3715 cmdline_parse_token_string_t cmd_set_list_keyword =
3716 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3717 				 "set");
3718 cmdline_parse_token_string_t cmd_set_list_name =
3719 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3720 				 "corelist#portlist");
3721 cmdline_parse_token_string_t cmd_set_list_of_items =
3722 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3723 				 NULL);
3724 
3725 cmdline_parse_inst_t cmd_set_fwd_list = {
3726 	.f = cmd_set_list_parsed,
3727 	.data = NULL,
3728 	.help_str = "set corelist|portlist <list0[,list1]*>",
3729 	.tokens = {
3730 		(void *)&cmd_set_list_keyword,
3731 		(void *)&cmd_set_list_name,
3732 		(void *)&cmd_set_list_of_items,
3733 		NULL,
3734 	},
3735 };
3736 
3737 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3738 
3739 struct cmd_setmask_result {
3740 	cmdline_fixed_string_t set;
3741 	cmdline_fixed_string_t mask;
3742 	uint64_t hexavalue;
3743 };
3744 
3745 static void cmd_set_mask_parsed(void *parsed_result,
3746 				__rte_unused struct cmdline *cl,
3747 				__rte_unused void *data)
3748 {
3749 	struct cmd_setmask_result *res = parsed_result;
3750 
3751 	if (test_done == 0) {
3752 		printf("Please stop forwarding first\n");
3753 		return;
3754 	}
3755 	if (!strcmp(res->mask, "coremask")) {
3756 		set_fwd_lcores_mask(res->hexavalue);
3757 		fwd_config_setup();
3758 	} else if (!strcmp(res->mask, "portmask")) {
3759 		set_fwd_ports_mask(res->hexavalue);
3760 		fwd_config_setup();
3761 	}
3762 }
3763 
3764 cmdline_parse_token_string_t cmd_setmask_set =
3765 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3766 cmdline_parse_token_string_t cmd_setmask_mask =
3767 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3768 				 "coremask#portmask");
3769 cmdline_parse_token_num_t cmd_setmask_value =
3770 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3771 
3772 cmdline_parse_inst_t cmd_set_fwd_mask = {
3773 	.f = cmd_set_mask_parsed,
3774 	.data = NULL,
3775 	.help_str = "set coremask|portmask <hexadecimal value>",
3776 	.tokens = {
3777 		(void *)&cmd_setmask_set,
3778 		(void *)&cmd_setmask_mask,
3779 		(void *)&cmd_setmask_value,
3780 		NULL,
3781 	},
3782 };
3783 
3784 /*
3785  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3786  */
3787 struct cmd_set_result {
3788 	cmdline_fixed_string_t set;
3789 	cmdline_fixed_string_t what;
3790 	uint16_t value;
3791 };
3792 
3793 static void cmd_set_parsed(void *parsed_result,
3794 			   __rte_unused struct cmdline *cl,
3795 			   __rte_unused void *data)
3796 {
3797 	struct cmd_set_result *res = parsed_result;
3798 	if (!strcmp(res->what, "nbport")) {
3799 		set_fwd_ports_number(res->value);
3800 		fwd_config_setup();
3801 	} else if (!strcmp(res->what, "nbcore")) {
3802 		set_fwd_lcores_number(res->value);
3803 		fwd_config_setup();
3804 	} else if (!strcmp(res->what, "burst"))
3805 		set_nb_pkt_per_burst(res->value);
3806 	else if (!strcmp(res->what, "verbose"))
3807 		set_verbose_level(res->value);
3808 }
3809 
3810 cmdline_parse_token_string_t cmd_set_set =
3811 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3812 cmdline_parse_token_string_t cmd_set_what =
3813 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3814 				 "nbport#nbcore#burst#verbose");
3815 cmdline_parse_token_num_t cmd_set_value =
3816 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3817 
3818 cmdline_parse_inst_t cmd_set_numbers = {
3819 	.f = cmd_set_parsed,
3820 	.data = NULL,
3821 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3822 	.tokens = {
3823 		(void *)&cmd_set_set,
3824 		(void *)&cmd_set_what,
3825 		(void *)&cmd_set_value,
3826 		NULL,
3827 	},
3828 };
3829 
3830 /* *** SET LOG LEVEL CONFIGURATION *** */
3831 
3832 struct cmd_set_log_result {
3833 	cmdline_fixed_string_t set;
3834 	cmdline_fixed_string_t log;
3835 	cmdline_fixed_string_t type;
3836 	uint32_t level;
3837 };
3838 
3839 static void
3840 cmd_set_log_parsed(void *parsed_result,
3841 		   __rte_unused struct cmdline *cl,
3842 		   __rte_unused void *data)
3843 {
3844 	struct cmd_set_log_result *res;
3845 	int ret;
3846 
3847 	res = parsed_result;
3848 	if (!strcmp(res->type, "global"))
3849 		rte_log_set_global_level(res->level);
3850 	else {
3851 		ret = rte_log_set_level_regexp(res->type, res->level);
3852 		if (ret < 0)
3853 			printf("Unable to set log level\n");
3854 	}
3855 }
3856 
3857 cmdline_parse_token_string_t cmd_set_log_set =
3858 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3859 cmdline_parse_token_string_t cmd_set_log_log =
3860 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3861 cmdline_parse_token_string_t cmd_set_log_type =
3862 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3863 cmdline_parse_token_num_t cmd_set_log_level =
3864 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3865 
3866 cmdline_parse_inst_t cmd_set_log = {
3867 	.f = cmd_set_log_parsed,
3868 	.data = NULL,
3869 	.help_str = "set log global|<type> <level>",
3870 	.tokens = {
3871 		(void *)&cmd_set_log_set,
3872 		(void *)&cmd_set_log_log,
3873 		(void *)&cmd_set_log_type,
3874 		(void *)&cmd_set_log_level,
3875 		NULL,
3876 	},
3877 };
3878 
3879 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3880 
3881 struct cmd_set_rxoffs_result {
3882 	cmdline_fixed_string_t cmd_keyword;
3883 	cmdline_fixed_string_t rxoffs;
3884 	cmdline_fixed_string_t seg_offsets;
3885 };
3886 
3887 static void
3888 cmd_set_rxoffs_parsed(void *parsed_result,
3889 		      __rte_unused struct cmdline *cl,
3890 		      __rte_unused void *data)
3891 {
3892 	struct cmd_set_rxoffs_result *res;
3893 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3894 	unsigned int nb_segs;
3895 
3896 	res = parsed_result;
3897 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3898 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3899 	if (nb_segs > 0)
3900 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3901 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3902 }
3903 
3904 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3905 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3906 				 cmd_keyword, "set");
3907 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3908 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3909 				 rxoffs, "rxoffs");
3910 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3911 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3912 				 seg_offsets, NULL);
3913 
3914 cmdline_parse_inst_t cmd_set_rxoffs = {
3915 	.f = cmd_set_rxoffs_parsed,
3916 	.data = NULL,
3917 	.help_str = "set rxoffs <len0[,len1]*>",
3918 	.tokens = {
3919 		(void *)&cmd_set_rxoffs_keyword,
3920 		(void *)&cmd_set_rxoffs_name,
3921 		(void *)&cmd_set_rxoffs_offsets,
3922 		NULL,
3923 	},
3924 };
3925 
3926 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3927 
3928 struct cmd_set_rxpkts_result {
3929 	cmdline_fixed_string_t cmd_keyword;
3930 	cmdline_fixed_string_t rxpkts;
3931 	cmdline_fixed_string_t seg_lengths;
3932 };
3933 
3934 static void
3935 cmd_set_rxpkts_parsed(void *parsed_result,
3936 		      __rte_unused struct cmdline *cl,
3937 		      __rte_unused void *data)
3938 {
3939 	struct cmd_set_rxpkts_result *res;
3940 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3941 	unsigned int nb_segs;
3942 
3943 	res = parsed_result;
3944 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3945 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3946 	if (nb_segs > 0)
3947 		set_rx_pkt_segments(seg_lengths, nb_segs);
3948 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3949 }
3950 
3951 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3952 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3953 				 cmd_keyword, "set");
3954 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3955 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3956 				 rxpkts, "rxpkts");
3957 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3958 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3959 				 seg_lengths, NULL);
3960 
3961 cmdline_parse_inst_t cmd_set_rxpkts = {
3962 	.f = cmd_set_rxpkts_parsed,
3963 	.data = NULL,
3964 	.help_str = "set rxpkts <len0[,len1]*>",
3965 	.tokens = {
3966 		(void *)&cmd_set_rxpkts_keyword,
3967 		(void *)&cmd_set_rxpkts_name,
3968 		(void *)&cmd_set_rxpkts_lengths,
3969 		NULL,
3970 	},
3971 };
3972 
3973 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3974 
3975 struct cmd_set_txpkts_result {
3976 	cmdline_fixed_string_t cmd_keyword;
3977 	cmdline_fixed_string_t txpkts;
3978 	cmdline_fixed_string_t seg_lengths;
3979 };
3980 
3981 static void
3982 cmd_set_txpkts_parsed(void *parsed_result,
3983 		      __rte_unused struct cmdline *cl,
3984 		      __rte_unused void *data)
3985 {
3986 	struct cmd_set_txpkts_result *res;
3987 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3988 	unsigned int nb_segs;
3989 
3990 	res = parsed_result;
3991 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3992 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3993 	if (nb_segs > 0)
3994 		set_tx_pkt_segments(seg_lengths, nb_segs);
3995 }
3996 
3997 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3998 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3999 				 cmd_keyword, "set");
4000 cmdline_parse_token_string_t cmd_set_txpkts_name =
4001 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4002 				 txpkts, "txpkts");
4003 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4004 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4005 				 seg_lengths, NULL);
4006 
4007 cmdline_parse_inst_t cmd_set_txpkts = {
4008 	.f = cmd_set_txpkts_parsed,
4009 	.data = NULL,
4010 	.help_str = "set txpkts <len0[,len1]*>",
4011 	.tokens = {
4012 		(void *)&cmd_set_txpkts_keyword,
4013 		(void *)&cmd_set_txpkts_name,
4014 		(void *)&cmd_set_txpkts_lengths,
4015 		NULL,
4016 	},
4017 };
4018 
4019 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4020 
4021 struct cmd_set_txsplit_result {
4022 	cmdline_fixed_string_t cmd_keyword;
4023 	cmdline_fixed_string_t txsplit;
4024 	cmdline_fixed_string_t mode;
4025 };
4026 
4027 static void
4028 cmd_set_txsplit_parsed(void *parsed_result,
4029 		      __rte_unused struct cmdline *cl,
4030 		      __rte_unused void *data)
4031 {
4032 	struct cmd_set_txsplit_result *res;
4033 
4034 	res = parsed_result;
4035 	set_tx_pkt_split(res->mode);
4036 }
4037 
4038 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4039 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4040 				 cmd_keyword, "set");
4041 cmdline_parse_token_string_t cmd_set_txsplit_name =
4042 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4043 				 txsplit, "txsplit");
4044 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4045 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4046 				 mode, NULL);
4047 
4048 cmdline_parse_inst_t cmd_set_txsplit = {
4049 	.f = cmd_set_txsplit_parsed,
4050 	.data = NULL,
4051 	.help_str = "set txsplit on|off|rand",
4052 	.tokens = {
4053 		(void *)&cmd_set_txsplit_keyword,
4054 		(void *)&cmd_set_txsplit_name,
4055 		(void *)&cmd_set_txsplit_mode,
4056 		NULL,
4057 	},
4058 };
4059 
4060 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4061 
4062 struct cmd_set_txtimes_result {
4063 	cmdline_fixed_string_t cmd_keyword;
4064 	cmdline_fixed_string_t txtimes;
4065 	cmdline_fixed_string_t tx_times;
4066 };
4067 
4068 static void
4069 cmd_set_txtimes_parsed(void *parsed_result,
4070 		       __rte_unused struct cmdline *cl,
4071 		       __rte_unused void *data)
4072 {
4073 	struct cmd_set_txtimes_result *res;
4074 	unsigned int tx_times[2] = {0, 0};
4075 	unsigned int n_times;
4076 
4077 	res = parsed_result;
4078 	n_times = parse_item_list(res->tx_times, "tx times",
4079 				  2, tx_times, 0);
4080 	if (n_times == 2)
4081 		set_tx_pkt_times(tx_times);
4082 }
4083 
4084 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4085 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4086 				 cmd_keyword, "set");
4087 cmdline_parse_token_string_t cmd_set_txtimes_name =
4088 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4089 				 txtimes, "txtimes");
4090 cmdline_parse_token_string_t cmd_set_txtimes_value =
4091 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4092 				 tx_times, NULL);
4093 
4094 cmdline_parse_inst_t cmd_set_txtimes = {
4095 	.f = cmd_set_txtimes_parsed,
4096 	.data = NULL,
4097 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
4098 	.tokens = {
4099 		(void *)&cmd_set_txtimes_keyword,
4100 		(void *)&cmd_set_txtimes_name,
4101 		(void *)&cmd_set_txtimes_value,
4102 		NULL,
4103 	},
4104 };
4105 
4106 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4107 struct cmd_rx_vlan_filter_all_result {
4108 	cmdline_fixed_string_t rx_vlan;
4109 	cmdline_fixed_string_t what;
4110 	cmdline_fixed_string_t all;
4111 	portid_t port_id;
4112 };
4113 
4114 static void
4115 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4116 			      __rte_unused struct cmdline *cl,
4117 			      __rte_unused void *data)
4118 {
4119 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4120 
4121 	if (!strcmp(res->what, "add"))
4122 		rx_vlan_all_filter_set(res->port_id, 1);
4123 	else
4124 		rx_vlan_all_filter_set(res->port_id, 0);
4125 }
4126 
4127 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4128 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4129 				 rx_vlan, "rx_vlan");
4130 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4131 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4132 				 what, "add#rm");
4133 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4134 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4135 				 all, "all");
4136 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4137 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 			      port_id, RTE_UINT16);
4139 
4140 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4141 	.f = cmd_rx_vlan_filter_all_parsed,
4142 	.data = NULL,
4143 	.help_str = "rx_vlan add|rm all <port_id>: "
4144 		"Add/Remove all identifiers to/from the set of VLAN "
4145 		"identifiers filtered by a port",
4146 	.tokens = {
4147 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4148 		(void *)&cmd_rx_vlan_filter_all_what,
4149 		(void *)&cmd_rx_vlan_filter_all_all,
4150 		(void *)&cmd_rx_vlan_filter_all_portid,
4151 		NULL,
4152 	},
4153 };
4154 
4155 /* *** VLAN OFFLOAD SET ON A PORT *** */
4156 struct cmd_vlan_offload_result {
4157 	cmdline_fixed_string_t vlan;
4158 	cmdline_fixed_string_t set;
4159 	cmdline_fixed_string_t vlan_type;
4160 	cmdline_fixed_string_t what;
4161 	cmdline_fixed_string_t on;
4162 	cmdline_fixed_string_t port_id;
4163 };
4164 
4165 static void
4166 cmd_vlan_offload_parsed(void *parsed_result,
4167 			  __rte_unused struct cmdline *cl,
4168 			  __rte_unused void *data)
4169 {
4170 	int on;
4171 	struct cmd_vlan_offload_result *res = parsed_result;
4172 	char *str;
4173 	int i, len = 0;
4174 	portid_t port_id = 0;
4175 	unsigned int tmp;
4176 
4177 	str = res->port_id;
4178 	len = strnlen(str, STR_TOKEN_SIZE);
4179 	i = 0;
4180 	/* Get port_id first */
4181 	while(i < len){
4182 		if(str[i] == ',')
4183 			break;
4184 
4185 		i++;
4186 	}
4187 	str[i]='\0';
4188 	tmp = strtoul(str, NULL, 0);
4189 	/* If port_id greater that what portid_t can represent, return */
4190 	if(tmp >= RTE_MAX_ETHPORTS)
4191 		return;
4192 	port_id = (portid_t)tmp;
4193 
4194 	if (!strcmp(res->on, "on"))
4195 		on = 1;
4196 	else
4197 		on = 0;
4198 
4199 	if (!strcmp(res->what, "strip"))
4200 		rx_vlan_strip_set(port_id,  on);
4201 	else if(!strcmp(res->what, "stripq")){
4202 		uint16_t queue_id = 0;
4203 
4204 		/* No queue_id, return */
4205 		if(i + 1 >= len) {
4206 			printf("must specify (port,queue_id)\n");
4207 			return;
4208 		}
4209 		tmp = strtoul(str + i + 1, NULL, 0);
4210 		/* If queue_id greater that what 16-bits can represent, return */
4211 		if(tmp > 0xffff)
4212 			return;
4213 
4214 		queue_id = (uint16_t)tmp;
4215 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4216 	}
4217 	else if (!strcmp(res->what, "filter"))
4218 		rx_vlan_filter_set(port_id, on);
4219 	else if (!strcmp(res->what, "qinq_strip"))
4220 		rx_vlan_qinq_strip_set(port_id, on);
4221 	else
4222 		vlan_extend_set(port_id, on);
4223 
4224 	return;
4225 }
4226 
4227 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4228 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4229 				 vlan, "vlan");
4230 cmdline_parse_token_string_t cmd_vlan_offload_set =
4231 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4232 				 set, "set");
4233 cmdline_parse_token_string_t cmd_vlan_offload_what =
4234 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4235 				what, "strip#filter#qinq_strip#extend#stripq");
4236 cmdline_parse_token_string_t cmd_vlan_offload_on =
4237 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4238 			      on, "on#off");
4239 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4240 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4241 			      port_id, NULL);
4242 
4243 cmdline_parse_inst_t cmd_vlan_offload = {
4244 	.f = cmd_vlan_offload_parsed,
4245 	.data = NULL,
4246 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4247 		"<port_id[,queue_id]>: "
4248 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4249 	.tokens = {
4250 		(void *)&cmd_vlan_offload_vlan,
4251 		(void *)&cmd_vlan_offload_set,
4252 		(void *)&cmd_vlan_offload_what,
4253 		(void *)&cmd_vlan_offload_on,
4254 		(void *)&cmd_vlan_offload_portid,
4255 		NULL,
4256 	},
4257 };
4258 
4259 /* *** VLAN TPID SET ON A PORT *** */
4260 struct cmd_vlan_tpid_result {
4261 	cmdline_fixed_string_t vlan;
4262 	cmdline_fixed_string_t set;
4263 	cmdline_fixed_string_t vlan_type;
4264 	cmdline_fixed_string_t what;
4265 	uint16_t tp_id;
4266 	portid_t port_id;
4267 };
4268 
4269 static void
4270 cmd_vlan_tpid_parsed(void *parsed_result,
4271 			  __rte_unused struct cmdline *cl,
4272 			  __rte_unused void *data)
4273 {
4274 	struct cmd_vlan_tpid_result *res = parsed_result;
4275 	enum rte_vlan_type vlan_type;
4276 
4277 	if (!strcmp(res->vlan_type, "inner"))
4278 		vlan_type = ETH_VLAN_TYPE_INNER;
4279 	else if (!strcmp(res->vlan_type, "outer"))
4280 		vlan_type = ETH_VLAN_TYPE_OUTER;
4281 	else {
4282 		printf("Unknown vlan type\n");
4283 		return;
4284 	}
4285 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4286 }
4287 
4288 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4289 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4290 				 vlan, "vlan");
4291 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4292 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4293 				 set, "set");
4294 cmdline_parse_token_string_t cmd_vlan_type =
4295 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4296 				 vlan_type, "inner#outer");
4297 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4298 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4299 				 what, "tpid");
4300 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4301 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4302 			      tp_id, RTE_UINT16);
4303 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4304 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4305 			      port_id, RTE_UINT16);
4306 
4307 cmdline_parse_inst_t cmd_vlan_tpid = {
4308 	.f = cmd_vlan_tpid_parsed,
4309 	.data = NULL,
4310 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4311 		"Set the VLAN Ether type",
4312 	.tokens = {
4313 		(void *)&cmd_vlan_tpid_vlan,
4314 		(void *)&cmd_vlan_tpid_set,
4315 		(void *)&cmd_vlan_type,
4316 		(void *)&cmd_vlan_tpid_what,
4317 		(void *)&cmd_vlan_tpid_tpid,
4318 		(void *)&cmd_vlan_tpid_portid,
4319 		NULL,
4320 	},
4321 };
4322 
4323 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4324 struct cmd_rx_vlan_filter_result {
4325 	cmdline_fixed_string_t rx_vlan;
4326 	cmdline_fixed_string_t what;
4327 	uint16_t vlan_id;
4328 	portid_t port_id;
4329 };
4330 
4331 static void
4332 cmd_rx_vlan_filter_parsed(void *parsed_result,
4333 			  __rte_unused struct cmdline *cl,
4334 			  __rte_unused void *data)
4335 {
4336 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4337 
4338 	if (!strcmp(res->what, "add"))
4339 		rx_vft_set(res->port_id, res->vlan_id, 1);
4340 	else
4341 		rx_vft_set(res->port_id, res->vlan_id, 0);
4342 }
4343 
4344 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4345 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4346 				 rx_vlan, "rx_vlan");
4347 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4348 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4349 				 what, "add#rm");
4350 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4351 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4352 			      vlan_id, RTE_UINT16);
4353 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4354 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4355 			      port_id, RTE_UINT16);
4356 
4357 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4358 	.f = cmd_rx_vlan_filter_parsed,
4359 	.data = NULL,
4360 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4361 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4362 		"identifiers filtered by a port",
4363 	.tokens = {
4364 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4365 		(void *)&cmd_rx_vlan_filter_what,
4366 		(void *)&cmd_rx_vlan_filter_vlanid,
4367 		(void *)&cmd_rx_vlan_filter_portid,
4368 		NULL,
4369 	},
4370 };
4371 
4372 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4373 struct cmd_tx_vlan_set_result {
4374 	cmdline_fixed_string_t tx_vlan;
4375 	cmdline_fixed_string_t set;
4376 	portid_t port_id;
4377 	uint16_t vlan_id;
4378 };
4379 
4380 static void
4381 cmd_tx_vlan_set_parsed(void *parsed_result,
4382 		       __rte_unused struct cmdline *cl,
4383 		       __rte_unused void *data)
4384 {
4385 	struct cmd_tx_vlan_set_result *res = parsed_result;
4386 
4387 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4388 		return;
4389 
4390 	if (!port_is_stopped(res->port_id)) {
4391 		printf("Please stop port %d first\n", res->port_id);
4392 		return;
4393 	}
4394 
4395 	tx_vlan_set(res->port_id, res->vlan_id);
4396 
4397 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4398 }
4399 
4400 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4401 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4402 				 tx_vlan, "tx_vlan");
4403 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4404 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4405 				 set, "set");
4406 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4407 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4408 			      port_id, RTE_UINT16);
4409 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4410 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4411 			      vlan_id, RTE_UINT16);
4412 
4413 cmdline_parse_inst_t cmd_tx_vlan_set = {
4414 	.f = cmd_tx_vlan_set_parsed,
4415 	.data = NULL,
4416 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4417 		"Enable hardware insertion of a single VLAN header "
4418 		"with a given TAG Identifier in packets sent on a port",
4419 	.tokens = {
4420 		(void *)&cmd_tx_vlan_set_tx_vlan,
4421 		(void *)&cmd_tx_vlan_set_set,
4422 		(void *)&cmd_tx_vlan_set_portid,
4423 		(void *)&cmd_tx_vlan_set_vlanid,
4424 		NULL,
4425 	},
4426 };
4427 
4428 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4429 struct cmd_tx_vlan_set_qinq_result {
4430 	cmdline_fixed_string_t tx_vlan;
4431 	cmdline_fixed_string_t set;
4432 	portid_t port_id;
4433 	uint16_t vlan_id;
4434 	uint16_t vlan_id_outer;
4435 };
4436 
4437 static void
4438 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4439 			    __rte_unused struct cmdline *cl,
4440 			    __rte_unused void *data)
4441 {
4442 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4443 
4444 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4445 		return;
4446 
4447 	if (!port_is_stopped(res->port_id)) {
4448 		printf("Please stop port %d first\n", res->port_id);
4449 		return;
4450 	}
4451 
4452 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4453 
4454 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4455 }
4456 
4457 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4458 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4459 		tx_vlan, "tx_vlan");
4460 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4461 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4462 		set, "set");
4463 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4464 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4465 		port_id, RTE_UINT16);
4466 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4467 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 		vlan_id, RTE_UINT16);
4469 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4470 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4471 		vlan_id_outer, RTE_UINT16);
4472 
4473 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4474 	.f = cmd_tx_vlan_set_qinq_parsed,
4475 	.data = NULL,
4476 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4477 		"Enable hardware insertion of double VLAN header "
4478 		"with given TAG Identifiers in packets sent on a port",
4479 	.tokens = {
4480 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4481 		(void *)&cmd_tx_vlan_set_qinq_set,
4482 		(void *)&cmd_tx_vlan_set_qinq_portid,
4483 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4484 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4485 		NULL,
4486 	},
4487 };
4488 
4489 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4490 struct cmd_tx_vlan_set_pvid_result {
4491 	cmdline_fixed_string_t tx_vlan;
4492 	cmdline_fixed_string_t set;
4493 	cmdline_fixed_string_t pvid;
4494 	portid_t port_id;
4495 	uint16_t vlan_id;
4496 	cmdline_fixed_string_t mode;
4497 };
4498 
4499 static void
4500 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4501 			    __rte_unused struct cmdline *cl,
4502 			    __rte_unused void *data)
4503 {
4504 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4505 
4506 	if (strcmp(res->mode, "on") == 0)
4507 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4508 	else
4509 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4510 }
4511 
4512 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4513 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4514 				 tx_vlan, "tx_vlan");
4515 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4516 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4517 				 set, "set");
4518 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4519 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4520 				 pvid, "pvid");
4521 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4522 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 			     port_id, RTE_UINT16);
4524 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4525 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 			      vlan_id, RTE_UINT16);
4527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4528 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4529 				 mode, "on#off");
4530 
4531 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4532 	.f = cmd_tx_vlan_set_pvid_parsed,
4533 	.data = NULL,
4534 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4535 	.tokens = {
4536 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4537 		(void *)&cmd_tx_vlan_set_pvid_set,
4538 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4539 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4540 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4541 		(void *)&cmd_tx_vlan_set_pvid_mode,
4542 		NULL,
4543 	},
4544 };
4545 
4546 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4547 struct cmd_tx_vlan_reset_result {
4548 	cmdline_fixed_string_t tx_vlan;
4549 	cmdline_fixed_string_t reset;
4550 	portid_t port_id;
4551 };
4552 
4553 static void
4554 cmd_tx_vlan_reset_parsed(void *parsed_result,
4555 			 __rte_unused struct cmdline *cl,
4556 			 __rte_unused void *data)
4557 {
4558 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4559 
4560 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4561 		return;
4562 
4563 	if (!port_is_stopped(res->port_id)) {
4564 		printf("Please stop port %d first\n", res->port_id);
4565 		return;
4566 	}
4567 
4568 	tx_vlan_reset(res->port_id);
4569 
4570 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4571 }
4572 
4573 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4574 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4575 				 tx_vlan, "tx_vlan");
4576 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4577 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4578 				 reset, "reset");
4579 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4580 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4581 			      port_id, RTE_UINT16);
4582 
4583 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4584 	.f = cmd_tx_vlan_reset_parsed,
4585 	.data = NULL,
4586 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4587 		"VLAN header in packets sent on a port",
4588 	.tokens = {
4589 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4590 		(void *)&cmd_tx_vlan_reset_reset,
4591 		(void *)&cmd_tx_vlan_reset_portid,
4592 		NULL,
4593 	},
4594 };
4595 
4596 
4597 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4598 struct cmd_csum_result {
4599 	cmdline_fixed_string_t csum;
4600 	cmdline_fixed_string_t mode;
4601 	cmdline_fixed_string_t proto;
4602 	cmdline_fixed_string_t hwsw;
4603 	portid_t port_id;
4604 };
4605 
4606 static void
4607 csum_show(int port_id)
4608 {
4609 	struct rte_eth_dev_info dev_info;
4610 	uint64_t tx_offloads;
4611 	int ret;
4612 
4613 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4614 	printf("Parse tunnel is %s\n",
4615 		(ports[port_id].parse_tunnel) ? "on" : "off");
4616 	printf("IP checksum offload is %s\n",
4617 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4618 	printf("UDP checksum offload is %s\n",
4619 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4620 	printf("TCP checksum offload is %s\n",
4621 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4622 	printf("SCTP checksum offload is %s\n",
4623 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4624 	printf("Outer-Ip checksum offload is %s\n",
4625 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4626 	printf("Outer-Udp checksum offload is %s\n",
4627 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4628 
4629 	/* display warnings if configuration is not supported by the NIC */
4630 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4631 	if (ret != 0)
4632 		return;
4633 
4634 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4635 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4636 		printf("Warning: hardware IP checksum enabled but not "
4637 			"supported by port %d\n", port_id);
4638 	}
4639 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4640 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4641 		printf("Warning: hardware UDP checksum enabled but not "
4642 			"supported by port %d\n", port_id);
4643 	}
4644 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4645 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4646 		printf("Warning: hardware TCP checksum enabled but not "
4647 			"supported by port %d\n", port_id);
4648 	}
4649 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4650 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4651 		printf("Warning: hardware SCTP checksum enabled but not "
4652 			"supported by port %d\n", port_id);
4653 	}
4654 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4655 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4656 		printf("Warning: hardware outer IP checksum enabled but not "
4657 			"supported by port %d\n", port_id);
4658 	}
4659 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4660 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4661 			== 0) {
4662 		printf("Warning: hardware outer UDP checksum enabled but not "
4663 			"supported by port %d\n", port_id);
4664 	}
4665 }
4666 
4667 static void
4668 cmd_config_queue_tx_offloads(struct rte_port *port)
4669 {
4670 	int k;
4671 
4672 	/* Apply queue tx offloads configuration */
4673 	for (k = 0; k < port->dev_info.max_tx_queues; k++)
4674 		port->tx_conf[k].offloads =
4675 			port->dev_conf.txmode.offloads;
4676 }
4677 
4678 static void
4679 cmd_csum_parsed(void *parsed_result,
4680 		       __rte_unused struct cmdline *cl,
4681 		       __rte_unused void *data)
4682 {
4683 	struct cmd_csum_result *res = parsed_result;
4684 	int hw = 0;
4685 	uint64_t csum_offloads = 0;
4686 	struct rte_eth_dev_info dev_info;
4687 	int ret;
4688 
4689 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4690 		printf("invalid port %d\n", res->port_id);
4691 		return;
4692 	}
4693 	if (!port_is_stopped(res->port_id)) {
4694 		printf("Please stop port %d first\n", res->port_id);
4695 		return;
4696 	}
4697 
4698 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4699 	if (ret != 0)
4700 		return;
4701 
4702 	if (!strcmp(res->mode, "set")) {
4703 
4704 		if (!strcmp(res->hwsw, "hw"))
4705 			hw = 1;
4706 
4707 		if (!strcmp(res->proto, "ip")) {
4708 			if (hw == 0 || (dev_info.tx_offload_capa &
4709 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4710 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4711 			} else {
4712 				printf("IP checksum offload is not supported "
4713 				       "by port %u\n", res->port_id);
4714 			}
4715 		} else if (!strcmp(res->proto, "udp")) {
4716 			if (hw == 0 || (dev_info.tx_offload_capa &
4717 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4718 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4719 			} else {
4720 				printf("UDP checksum offload is not supported "
4721 				       "by port %u\n", res->port_id);
4722 			}
4723 		} else if (!strcmp(res->proto, "tcp")) {
4724 			if (hw == 0 || (dev_info.tx_offload_capa &
4725 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4726 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4727 			} else {
4728 				printf("TCP checksum offload is not supported "
4729 				       "by port %u\n", res->port_id);
4730 			}
4731 		} else if (!strcmp(res->proto, "sctp")) {
4732 			if (hw == 0 || (dev_info.tx_offload_capa &
4733 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4734 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4735 			} else {
4736 				printf("SCTP checksum offload is not supported "
4737 				       "by port %u\n", res->port_id);
4738 			}
4739 		} else if (!strcmp(res->proto, "outer-ip")) {
4740 			if (hw == 0 || (dev_info.tx_offload_capa &
4741 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4742 				csum_offloads |=
4743 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4744 			} else {
4745 				printf("Outer IP checksum offload is not "
4746 				       "supported by port %u\n", res->port_id);
4747 			}
4748 		} else if (!strcmp(res->proto, "outer-udp")) {
4749 			if (hw == 0 || (dev_info.tx_offload_capa &
4750 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4751 				csum_offloads |=
4752 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4753 			} else {
4754 				printf("Outer UDP checksum offload is not "
4755 				       "supported by port %u\n", res->port_id);
4756 			}
4757 		}
4758 
4759 		if (hw) {
4760 			ports[res->port_id].dev_conf.txmode.offloads |=
4761 							csum_offloads;
4762 		} else {
4763 			ports[res->port_id].dev_conf.txmode.offloads &=
4764 							(~csum_offloads);
4765 		}
4766 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4767 	}
4768 	csum_show(res->port_id);
4769 
4770 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4771 }
4772 
4773 cmdline_parse_token_string_t cmd_csum_csum =
4774 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4775 				csum, "csum");
4776 cmdline_parse_token_string_t cmd_csum_mode =
4777 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4778 				mode, "set");
4779 cmdline_parse_token_string_t cmd_csum_proto =
4780 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4781 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4782 cmdline_parse_token_string_t cmd_csum_hwsw =
4783 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4784 				hwsw, "hw#sw");
4785 cmdline_parse_token_num_t cmd_csum_portid =
4786 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4787 				port_id, RTE_UINT16);
4788 
4789 cmdline_parse_inst_t cmd_csum_set = {
4790 	.f = cmd_csum_parsed,
4791 	.data = NULL,
4792 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4793 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4794 		"using csum forward engine",
4795 	.tokens = {
4796 		(void *)&cmd_csum_csum,
4797 		(void *)&cmd_csum_mode,
4798 		(void *)&cmd_csum_proto,
4799 		(void *)&cmd_csum_hwsw,
4800 		(void *)&cmd_csum_portid,
4801 		NULL,
4802 	},
4803 };
4804 
4805 cmdline_parse_token_string_t cmd_csum_mode_show =
4806 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4807 				mode, "show");
4808 
4809 cmdline_parse_inst_t cmd_csum_show = {
4810 	.f = cmd_csum_parsed,
4811 	.data = NULL,
4812 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4813 	.tokens = {
4814 		(void *)&cmd_csum_csum,
4815 		(void *)&cmd_csum_mode_show,
4816 		(void *)&cmd_csum_portid,
4817 		NULL,
4818 	},
4819 };
4820 
4821 /* Enable/disable tunnel parsing */
4822 struct cmd_csum_tunnel_result {
4823 	cmdline_fixed_string_t csum;
4824 	cmdline_fixed_string_t parse;
4825 	cmdline_fixed_string_t onoff;
4826 	portid_t port_id;
4827 };
4828 
4829 static void
4830 cmd_csum_tunnel_parsed(void *parsed_result,
4831 		       __rte_unused struct cmdline *cl,
4832 		       __rte_unused void *data)
4833 {
4834 	struct cmd_csum_tunnel_result *res = parsed_result;
4835 
4836 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4837 		return;
4838 
4839 	if (!strcmp(res->onoff, "on"))
4840 		ports[res->port_id].parse_tunnel = 1;
4841 	else
4842 		ports[res->port_id].parse_tunnel = 0;
4843 
4844 	csum_show(res->port_id);
4845 }
4846 
4847 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4848 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4849 				csum, "csum");
4850 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4851 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4852 				parse, "parse-tunnel");
4853 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4854 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4855 				onoff, "on#off");
4856 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4857 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4858 				port_id, RTE_UINT16);
4859 
4860 cmdline_parse_inst_t cmd_csum_tunnel = {
4861 	.f = cmd_csum_tunnel_parsed,
4862 	.data = NULL,
4863 	.help_str = "csum parse-tunnel on|off <port_id>: "
4864 		"Enable/Disable parsing of tunnels for csum engine",
4865 	.tokens = {
4866 		(void *)&cmd_csum_tunnel_csum,
4867 		(void *)&cmd_csum_tunnel_parse,
4868 		(void *)&cmd_csum_tunnel_onoff,
4869 		(void *)&cmd_csum_tunnel_portid,
4870 		NULL,
4871 	},
4872 };
4873 
4874 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4875 struct cmd_tso_set_result {
4876 	cmdline_fixed_string_t tso;
4877 	cmdline_fixed_string_t mode;
4878 	uint16_t tso_segsz;
4879 	portid_t port_id;
4880 };
4881 
4882 static void
4883 cmd_tso_set_parsed(void *parsed_result,
4884 		       __rte_unused struct cmdline *cl,
4885 		       __rte_unused void *data)
4886 {
4887 	struct cmd_tso_set_result *res = parsed_result;
4888 	struct rte_eth_dev_info dev_info;
4889 	int ret;
4890 
4891 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4892 		return;
4893 	if (!port_is_stopped(res->port_id)) {
4894 		printf("Please stop port %d first\n", res->port_id);
4895 		return;
4896 	}
4897 
4898 	if (!strcmp(res->mode, "set"))
4899 		ports[res->port_id].tso_segsz = res->tso_segsz;
4900 
4901 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4902 	if (ret != 0)
4903 		return;
4904 
4905 	if ((ports[res->port_id].tso_segsz != 0) &&
4906 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4907 		printf("Error: TSO is not supported by port %d\n",
4908 		       res->port_id);
4909 		return;
4910 	}
4911 
4912 	if (ports[res->port_id].tso_segsz == 0) {
4913 		ports[res->port_id].dev_conf.txmode.offloads &=
4914 						~DEV_TX_OFFLOAD_TCP_TSO;
4915 		printf("TSO for non-tunneled packets is disabled\n");
4916 	} else {
4917 		ports[res->port_id].dev_conf.txmode.offloads |=
4918 						DEV_TX_OFFLOAD_TCP_TSO;
4919 		printf("TSO segment size for non-tunneled packets is %d\n",
4920 			ports[res->port_id].tso_segsz);
4921 	}
4922 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4923 
4924 	/* display warnings if configuration is not supported by the NIC */
4925 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4926 	if (ret != 0)
4927 		return;
4928 
4929 	if ((ports[res->port_id].tso_segsz != 0) &&
4930 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4931 		printf("Warning: TSO enabled but not "
4932 			"supported by port %d\n", res->port_id);
4933 	}
4934 
4935 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4936 }
4937 
4938 cmdline_parse_token_string_t cmd_tso_set_tso =
4939 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4940 				tso, "tso");
4941 cmdline_parse_token_string_t cmd_tso_set_mode =
4942 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4943 				mode, "set");
4944 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4945 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4946 				tso_segsz, RTE_UINT16);
4947 cmdline_parse_token_num_t cmd_tso_set_portid =
4948 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4949 				port_id, RTE_UINT16);
4950 
4951 cmdline_parse_inst_t cmd_tso_set = {
4952 	.f = cmd_tso_set_parsed,
4953 	.data = NULL,
4954 	.help_str = "tso set <tso_segsz> <port_id>: "
4955 		"Set TSO segment size of non-tunneled packets for csum engine "
4956 		"(0 to disable)",
4957 	.tokens = {
4958 		(void *)&cmd_tso_set_tso,
4959 		(void *)&cmd_tso_set_mode,
4960 		(void *)&cmd_tso_set_tso_segsz,
4961 		(void *)&cmd_tso_set_portid,
4962 		NULL,
4963 	},
4964 };
4965 
4966 cmdline_parse_token_string_t cmd_tso_show_mode =
4967 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4968 				mode, "show");
4969 
4970 
4971 cmdline_parse_inst_t cmd_tso_show = {
4972 	.f = cmd_tso_set_parsed,
4973 	.data = NULL,
4974 	.help_str = "tso show <port_id>: "
4975 		"Show TSO segment size of non-tunneled packets for csum engine",
4976 	.tokens = {
4977 		(void *)&cmd_tso_set_tso,
4978 		(void *)&cmd_tso_show_mode,
4979 		(void *)&cmd_tso_set_portid,
4980 		NULL,
4981 	},
4982 };
4983 
4984 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4985 struct cmd_tunnel_tso_set_result {
4986 	cmdline_fixed_string_t tso;
4987 	cmdline_fixed_string_t mode;
4988 	uint16_t tso_segsz;
4989 	portid_t port_id;
4990 };
4991 
4992 static struct rte_eth_dev_info
4993 check_tunnel_tso_nic_support(portid_t port_id)
4994 {
4995 	struct rte_eth_dev_info dev_info;
4996 
4997 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4998 		return dev_info;
4999 
5000 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5001 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5002 		       "not enabled for port %d\n", port_id);
5003 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5004 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
5005 		       "not enabled for port %d\n", port_id);
5006 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5007 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
5008 		       "not enabled for port %d\n", port_id);
5009 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5010 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5011 		       "not enabled for port %d\n", port_id);
5012 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5013 		printf("Warning: IP TUNNEL TSO not supported therefore "
5014 		       "not enabled for port %d\n", port_id);
5015 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5016 		printf("Warning: UDP TUNNEL TSO not supported therefore "
5017 		       "not enabled for port %d\n", port_id);
5018 	return dev_info;
5019 }
5020 
5021 static void
5022 cmd_tunnel_tso_set_parsed(void *parsed_result,
5023 			  __rte_unused struct cmdline *cl,
5024 			  __rte_unused void *data)
5025 {
5026 	struct cmd_tunnel_tso_set_result *res = parsed_result;
5027 	struct rte_eth_dev_info dev_info;
5028 
5029 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5030 		return;
5031 	if (!port_is_stopped(res->port_id)) {
5032 		printf("Please stop port %d first\n", res->port_id);
5033 		return;
5034 	}
5035 
5036 	if (!strcmp(res->mode, "set"))
5037 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5038 
5039 	dev_info = check_tunnel_tso_nic_support(res->port_id);
5040 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
5041 		ports[res->port_id].dev_conf.txmode.offloads &=
5042 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5043 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
5044 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5045 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5046 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
5047 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
5048 		printf("TSO for tunneled packets is disabled\n");
5049 	} else {
5050 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5051 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5052 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5053 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5054 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
5055 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5056 
5057 		ports[res->port_id].dev_conf.txmode.offloads |=
5058 			(tso_offloads & dev_info.tx_offload_capa);
5059 		printf("TSO segment size for tunneled packets is %d\n",
5060 			ports[res->port_id].tunnel_tso_segsz);
5061 
5062 		/* Below conditions are needed to make it work:
5063 		 * (1) tunnel TSO is supported by the NIC;
5064 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5065 		 * are recognized;
5066 		 * (3) for tunneled pkts with outer L3 of IPv4,
5067 		 * "csum set outer-ip" must be set to hw, because after tso,
5068 		 * total_len of outer IP header is changed, and the checksum
5069 		 * of outer IP header calculated by sw should be wrong; that
5070 		 * is not necessary for IPv6 tunneled pkts because there's no
5071 		 * checksum in IP header anymore.
5072 		 */
5073 
5074 		if (!ports[res->port_id].parse_tunnel)
5075 			printf("Warning: csum parse_tunnel must be set "
5076 				"so that tunneled packets are recognized\n");
5077 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
5078 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5079 			printf("Warning: csum set outer-ip must be set to hw "
5080 				"if outer L3 is IPv4; not necessary for IPv6\n");
5081 	}
5082 
5083 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
5084 	cmd_reconfig_device_queue(res->port_id, 1, 1);
5085 }
5086 
5087 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5088 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5089 				tso, "tunnel_tso");
5090 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5091 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5092 				mode, "set");
5093 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5094 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5095 				tso_segsz, RTE_UINT16);
5096 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5097 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5098 				port_id, RTE_UINT16);
5099 
5100 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5101 	.f = cmd_tunnel_tso_set_parsed,
5102 	.data = NULL,
5103 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5104 		"Set TSO segment size of tunneled packets for csum engine "
5105 		"(0 to disable)",
5106 	.tokens = {
5107 		(void *)&cmd_tunnel_tso_set_tso,
5108 		(void *)&cmd_tunnel_tso_set_mode,
5109 		(void *)&cmd_tunnel_tso_set_tso_segsz,
5110 		(void *)&cmd_tunnel_tso_set_portid,
5111 		NULL,
5112 	},
5113 };
5114 
5115 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5116 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5117 				mode, "show");
5118 
5119 
5120 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5121 	.f = cmd_tunnel_tso_set_parsed,
5122 	.data = NULL,
5123 	.help_str = "tunnel_tso show <port_id> "
5124 		"Show TSO segment size of tunneled packets for csum engine",
5125 	.tokens = {
5126 		(void *)&cmd_tunnel_tso_set_tso,
5127 		(void *)&cmd_tunnel_tso_show_mode,
5128 		(void *)&cmd_tunnel_tso_set_portid,
5129 		NULL,
5130 	},
5131 };
5132 
5133 /* *** SET GRO FOR A PORT *** */
5134 struct cmd_gro_enable_result {
5135 	cmdline_fixed_string_t cmd_set;
5136 	cmdline_fixed_string_t cmd_port;
5137 	cmdline_fixed_string_t cmd_keyword;
5138 	cmdline_fixed_string_t cmd_onoff;
5139 	portid_t cmd_pid;
5140 };
5141 
5142 static void
5143 cmd_gro_enable_parsed(void *parsed_result,
5144 		__rte_unused struct cmdline *cl,
5145 		__rte_unused void *data)
5146 {
5147 	struct cmd_gro_enable_result *res;
5148 
5149 	res = parsed_result;
5150 	if (!strcmp(res->cmd_keyword, "gro"))
5151 		setup_gro(res->cmd_onoff, res->cmd_pid);
5152 }
5153 
5154 cmdline_parse_token_string_t cmd_gro_enable_set =
5155 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5156 			cmd_set, "set");
5157 cmdline_parse_token_string_t cmd_gro_enable_port =
5158 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5159 			cmd_keyword, "port");
5160 cmdline_parse_token_num_t cmd_gro_enable_pid =
5161 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5162 			cmd_pid, RTE_UINT16);
5163 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5164 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5165 			cmd_keyword, "gro");
5166 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5167 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5168 			cmd_onoff, "on#off");
5169 
5170 cmdline_parse_inst_t cmd_gro_enable = {
5171 	.f = cmd_gro_enable_parsed,
5172 	.data = NULL,
5173 	.help_str = "set port <port_id> gro on|off",
5174 	.tokens = {
5175 		(void *)&cmd_gro_enable_set,
5176 		(void *)&cmd_gro_enable_port,
5177 		(void *)&cmd_gro_enable_pid,
5178 		(void *)&cmd_gro_enable_keyword,
5179 		(void *)&cmd_gro_enable_onoff,
5180 		NULL,
5181 	},
5182 };
5183 
5184 /* *** DISPLAY GRO CONFIGURATION *** */
5185 struct cmd_gro_show_result {
5186 	cmdline_fixed_string_t cmd_show;
5187 	cmdline_fixed_string_t cmd_port;
5188 	cmdline_fixed_string_t cmd_keyword;
5189 	portid_t cmd_pid;
5190 };
5191 
5192 static void
5193 cmd_gro_show_parsed(void *parsed_result,
5194 		__rte_unused struct cmdline *cl,
5195 		__rte_unused void *data)
5196 {
5197 	struct cmd_gro_show_result *res;
5198 
5199 	res = parsed_result;
5200 	if (!strcmp(res->cmd_keyword, "gro"))
5201 		show_gro(res->cmd_pid);
5202 }
5203 
5204 cmdline_parse_token_string_t cmd_gro_show_show =
5205 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5206 			cmd_show, "show");
5207 cmdline_parse_token_string_t cmd_gro_show_port =
5208 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5209 			cmd_port, "port");
5210 cmdline_parse_token_num_t cmd_gro_show_pid =
5211 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5212 			cmd_pid, RTE_UINT16);
5213 cmdline_parse_token_string_t cmd_gro_show_keyword =
5214 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5215 			cmd_keyword, "gro");
5216 
5217 cmdline_parse_inst_t cmd_gro_show = {
5218 	.f = cmd_gro_show_parsed,
5219 	.data = NULL,
5220 	.help_str = "show port <port_id> gro",
5221 	.tokens = {
5222 		(void *)&cmd_gro_show_show,
5223 		(void *)&cmd_gro_show_port,
5224 		(void *)&cmd_gro_show_pid,
5225 		(void *)&cmd_gro_show_keyword,
5226 		NULL,
5227 	},
5228 };
5229 
5230 /* *** SET FLUSH CYCLES FOR GRO *** */
5231 struct cmd_gro_flush_result {
5232 	cmdline_fixed_string_t cmd_set;
5233 	cmdline_fixed_string_t cmd_keyword;
5234 	cmdline_fixed_string_t cmd_flush;
5235 	uint8_t cmd_cycles;
5236 };
5237 
5238 static void
5239 cmd_gro_flush_parsed(void *parsed_result,
5240 		__rte_unused struct cmdline *cl,
5241 		__rte_unused void *data)
5242 {
5243 	struct cmd_gro_flush_result *res;
5244 
5245 	res = parsed_result;
5246 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5247 			(!strcmp(res->cmd_flush, "flush")))
5248 		setup_gro_flush_cycles(res->cmd_cycles);
5249 }
5250 
5251 cmdline_parse_token_string_t cmd_gro_flush_set =
5252 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5253 			cmd_set, "set");
5254 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5255 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5256 			cmd_keyword, "gro");
5257 cmdline_parse_token_string_t cmd_gro_flush_flush =
5258 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5259 			cmd_flush, "flush");
5260 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5261 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5262 			cmd_cycles, RTE_UINT8);
5263 
5264 cmdline_parse_inst_t cmd_gro_flush = {
5265 	.f = cmd_gro_flush_parsed,
5266 	.data = NULL,
5267 	.help_str = "set gro flush <cycles>",
5268 	.tokens = {
5269 		(void *)&cmd_gro_flush_set,
5270 		(void *)&cmd_gro_flush_keyword,
5271 		(void *)&cmd_gro_flush_flush,
5272 		(void *)&cmd_gro_flush_cycles,
5273 		NULL,
5274 	},
5275 };
5276 
5277 /* *** ENABLE/DISABLE GSO *** */
5278 struct cmd_gso_enable_result {
5279 	cmdline_fixed_string_t cmd_set;
5280 	cmdline_fixed_string_t cmd_port;
5281 	cmdline_fixed_string_t cmd_keyword;
5282 	cmdline_fixed_string_t cmd_mode;
5283 	portid_t cmd_pid;
5284 };
5285 
5286 static void
5287 cmd_gso_enable_parsed(void *parsed_result,
5288 		__rte_unused struct cmdline *cl,
5289 		__rte_unused void *data)
5290 {
5291 	struct cmd_gso_enable_result *res;
5292 
5293 	res = parsed_result;
5294 	if (!strcmp(res->cmd_keyword, "gso"))
5295 		setup_gso(res->cmd_mode, res->cmd_pid);
5296 }
5297 
5298 cmdline_parse_token_string_t cmd_gso_enable_set =
5299 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5300 			cmd_set, "set");
5301 cmdline_parse_token_string_t cmd_gso_enable_port =
5302 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5303 			cmd_port, "port");
5304 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5305 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5306 			cmd_keyword, "gso");
5307 cmdline_parse_token_string_t cmd_gso_enable_mode =
5308 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5309 			cmd_mode, "on#off");
5310 cmdline_parse_token_num_t cmd_gso_enable_pid =
5311 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5312 			cmd_pid, RTE_UINT16);
5313 
5314 cmdline_parse_inst_t cmd_gso_enable = {
5315 	.f = cmd_gso_enable_parsed,
5316 	.data = NULL,
5317 	.help_str = "set port <port_id> gso on|off",
5318 	.tokens = {
5319 		(void *)&cmd_gso_enable_set,
5320 		(void *)&cmd_gso_enable_port,
5321 		(void *)&cmd_gso_enable_pid,
5322 		(void *)&cmd_gso_enable_keyword,
5323 		(void *)&cmd_gso_enable_mode,
5324 		NULL,
5325 	},
5326 };
5327 
5328 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5329 struct cmd_gso_size_result {
5330 	cmdline_fixed_string_t cmd_set;
5331 	cmdline_fixed_string_t cmd_keyword;
5332 	cmdline_fixed_string_t cmd_segsz;
5333 	uint16_t cmd_size;
5334 };
5335 
5336 static void
5337 cmd_gso_size_parsed(void *parsed_result,
5338 		       __rte_unused struct cmdline *cl,
5339 		       __rte_unused void *data)
5340 {
5341 	struct cmd_gso_size_result *res = parsed_result;
5342 
5343 	if (test_done == 0) {
5344 		printf("Before setting GSO segsz, please first"
5345 				" stop forwarding\n");
5346 		return;
5347 	}
5348 
5349 	if (!strcmp(res->cmd_keyword, "gso") &&
5350 			!strcmp(res->cmd_segsz, "segsz")) {
5351 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5352 			printf("gso_size should be larger than %zu."
5353 					" Please input a legal value\n",
5354 					RTE_GSO_SEG_SIZE_MIN);
5355 		else
5356 			gso_max_segment_size = res->cmd_size;
5357 	}
5358 }
5359 
5360 cmdline_parse_token_string_t cmd_gso_size_set =
5361 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5362 				cmd_set, "set");
5363 cmdline_parse_token_string_t cmd_gso_size_keyword =
5364 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5365 				cmd_keyword, "gso");
5366 cmdline_parse_token_string_t cmd_gso_size_segsz =
5367 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5368 				cmd_segsz, "segsz");
5369 cmdline_parse_token_num_t cmd_gso_size_size =
5370 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5371 				cmd_size, RTE_UINT16);
5372 
5373 cmdline_parse_inst_t cmd_gso_size = {
5374 	.f = cmd_gso_size_parsed,
5375 	.data = NULL,
5376 	.help_str = "set gso segsz <length>",
5377 	.tokens = {
5378 		(void *)&cmd_gso_size_set,
5379 		(void *)&cmd_gso_size_keyword,
5380 		(void *)&cmd_gso_size_segsz,
5381 		(void *)&cmd_gso_size_size,
5382 		NULL,
5383 	},
5384 };
5385 
5386 /* *** SHOW GSO CONFIGURATION *** */
5387 struct cmd_gso_show_result {
5388 	cmdline_fixed_string_t cmd_show;
5389 	cmdline_fixed_string_t cmd_port;
5390 	cmdline_fixed_string_t cmd_keyword;
5391 	portid_t cmd_pid;
5392 };
5393 
5394 static void
5395 cmd_gso_show_parsed(void *parsed_result,
5396 		       __rte_unused struct cmdline *cl,
5397 		       __rte_unused void *data)
5398 {
5399 	struct cmd_gso_show_result *res = parsed_result;
5400 
5401 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5402 		printf("invalid port id %u\n", res->cmd_pid);
5403 		return;
5404 	}
5405 	if (!strcmp(res->cmd_keyword, "gso")) {
5406 		if (gso_ports[res->cmd_pid].enable) {
5407 			printf("Max GSO'd packet size: %uB\n"
5408 					"Supported GSO types: TCP/IPv4, "
5409 					"UDP/IPv4, VxLAN with inner "
5410 					"TCP/IPv4 packet, GRE with inner "
5411 					"TCP/IPv4 packet\n",
5412 					gso_max_segment_size);
5413 		} else
5414 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5415 	}
5416 }
5417 
5418 cmdline_parse_token_string_t cmd_gso_show_show =
5419 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5420 		cmd_show, "show");
5421 cmdline_parse_token_string_t cmd_gso_show_port =
5422 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5423 		cmd_port, "port");
5424 cmdline_parse_token_string_t cmd_gso_show_keyword =
5425 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5426 				cmd_keyword, "gso");
5427 cmdline_parse_token_num_t cmd_gso_show_pid =
5428 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5429 				cmd_pid, RTE_UINT16);
5430 
5431 cmdline_parse_inst_t cmd_gso_show = {
5432 	.f = cmd_gso_show_parsed,
5433 	.data = NULL,
5434 	.help_str = "show port <port_id> gso",
5435 	.tokens = {
5436 		(void *)&cmd_gso_show_show,
5437 		(void *)&cmd_gso_show_port,
5438 		(void *)&cmd_gso_show_pid,
5439 		(void *)&cmd_gso_show_keyword,
5440 		NULL,
5441 	},
5442 };
5443 
5444 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5445 struct cmd_set_flush_rx {
5446 	cmdline_fixed_string_t set;
5447 	cmdline_fixed_string_t flush_rx;
5448 	cmdline_fixed_string_t mode;
5449 };
5450 
5451 static void
5452 cmd_set_flush_rx_parsed(void *parsed_result,
5453 		__rte_unused struct cmdline *cl,
5454 		__rte_unused void *data)
5455 {
5456 	struct cmd_set_flush_rx *res = parsed_result;
5457 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5458 }
5459 
5460 cmdline_parse_token_string_t cmd_setflushrx_set =
5461 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5462 			set, "set");
5463 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5464 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5465 			flush_rx, "flush_rx");
5466 cmdline_parse_token_string_t cmd_setflushrx_mode =
5467 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5468 			mode, "on#off");
5469 
5470 
5471 cmdline_parse_inst_t cmd_set_flush_rx = {
5472 	.f = cmd_set_flush_rx_parsed,
5473 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5474 	.data = NULL,
5475 	.tokens = {
5476 		(void *)&cmd_setflushrx_set,
5477 		(void *)&cmd_setflushrx_flush_rx,
5478 		(void *)&cmd_setflushrx_mode,
5479 		NULL,
5480 	},
5481 };
5482 
5483 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5484 struct cmd_set_link_check {
5485 	cmdline_fixed_string_t set;
5486 	cmdline_fixed_string_t link_check;
5487 	cmdline_fixed_string_t mode;
5488 };
5489 
5490 static void
5491 cmd_set_link_check_parsed(void *parsed_result,
5492 		__rte_unused struct cmdline *cl,
5493 		__rte_unused void *data)
5494 {
5495 	struct cmd_set_link_check *res = parsed_result;
5496 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5497 }
5498 
5499 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5500 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5501 			set, "set");
5502 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5503 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5504 			link_check, "link_check");
5505 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5506 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5507 			mode, "on#off");
5508 
5509 
5510 cmdline_parse_inst_t cmd_set_link_check = {
5511 	.f = cmd_set_link_check_parsed,
5512 	.help_str = "set link_check on|off: Enable/Disable link status check "
5513 	            "when starting/stopping a port",
5514 	.data = NULL,
5515 	.tokens = {
5516 		(void *)&cmd_setlinkcheck_set,
5517 		(void *)&cmd_setlinkcheck_link_check,
5518 		(void *)&cmd_setlinkcheck_mode,
5519 		NULL,
5520 	},
5521 };
5522 
5523 /* *** SET NIC BYPASS MODE *** */
5524 struct cmd_set_bypass_mode_result {
5525 	cmdline_fixed_string_t set;
5526 	cmdline_fixed_string_t bypass;
5527 	cmdline_fixed_string_t mode;
5528 	cmdline_fixed_string_t value;
5529 	portid_t port_id;
5530 };
5531 
5532 static void
5533 cmd_set_bypass_mode_parsed(void *parsed_result,
5534 		__rte_unused struct cmdline *cl,
5535 		__rte_unused void *data)
5536 {
5537 	struct cmd_set_bypass_mode_result *res = parsed_result;
5538 	portid_t port_id = res->port_id;
5539 	int32_t rc = -EINVAL;
5540 
5541 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5542 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5543 
5544 	if (!strcmp(res->value, "bypass"))
5545 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5546 	else if (!strcmp(res->value, "isolate"))
5547 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5548 	else
5549 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5550 
5551 	/* Set the bypass mode for the relevant port. */
5552 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5553 #endif
5554 	if (rc != 0)
5555 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5556 }
5557 
5558 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5559 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5560 			set, "set");
5561 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5562 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5563 			bypass, "bypass");
5564 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5565 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5566 			mode, "mode");
5567 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5568 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5569 			value, "normal#bypass#isolate");
5570 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5571 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5572 				port_id, RTE_UINT16);
5573 
5574 cmdline_parse_inst_t cmd_set_bypass_mode = {
5575 	.f = cmd_set_bypass_mode_parsed,
5576 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5577 	            "Set the NIC bypass mode for port_id",
5578 	.data = NULL,
5579 	.tokens = {
5580 		(void *)&cmd_setbypass_mode_set,
5581 		(void *)&cmd_setbypass_mode_bypass,
5582 		(void *)&cmd_setbypass_mode_mode,
5583 		(void *)&cmd_setbypass_mode_value,
5584 		(void *)&cmd_setbypass_mode_port,
5585 		NULL,
5586 	},
5587 };
5588 
5589 /* *** SET NIC BYPASS EVENT *** */
5590 struct cmd_set_bypass_event_result {
5591 	cmdline_fixed_string_t set;
5592 	cmdline_fixed_string_t bypass;
5593 	cmdline_fixed_string_t event;
5594 	cmdline_fixed_string_t event_value;
5595 	cmdline_fixed_string_t mode;
5596 	cmdline_fixed_string_t mode_value;
5597 	portid_t port_id;
5598 };
5599 
5600 static void
5601 cmd_set_bypass_event_parsed(void *parsed_result,
5602 		__rte_unused struct cmdline *cl,
5603 		__rte_unused void *data)
5604 {
5605 	int32_t rc = -EINVAL;
5606 	struct cmd_set_bypass_event_result *res = parsed_result;
5607 	portid_t port_id = res->port_id;
5608 
5609 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5610 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5611 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5612 
5613 	if (!strcmp(res->event_value, "timeout"))
5614 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5615 	else if (!strcmp(res->event_value, "os_on"))
5616 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5617 	else if (!strcmp(res->event_value, "os_off"))
5618 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5619 	else if (!strcmp(res->event_value, "power_on"))
5620 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5621 	else if (!strcmp(res->event_value, "power_off"))
5622 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5623 	else
5624 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5625 
5626 	if (!strcmp(res->mode_value, "bypass"))
5627 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5628 	else if (!strcmp(res->mode_value, "isolate"))
5629 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5630 	else
5631 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5632 
5633 	/* Set the watchdog timeout. */
5634 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5635 
5636 		rc = -EINVAL;
5637 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5638 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5639 							   bypass_timeout);
5640 		}
5641 		if (rc != 0) {
5642 			printf("Failed to set timeout value %u "
5643 			"for port %d, errto code: %d.\n",
5644 			bypass_timeout, port_id, rc);
5645 		}
5646 	}
5647 
5648 	/* Set the bypass event to transition to bypass mode. */
5649 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5650 					      bypass_mode);
5651 #endif
5652 
5653 	if (rc != 0)
5654 		printf("\t Failed to set bypass event for port = %d.\n",
5655 		       port_id);
5656 }
5657 
5658 cmdline_parse_token_string_t cmd_setbypass_event_set =
5659 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5660 			set, "set");
5661 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5662 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5663 			bypass, "bypass");
5664 cmdline_parse_token_string_t cmd_setbypass_event_event =
5665 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5666 			event, "event");
5667 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5668 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5669 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5670 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5671 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5672 			mode, "mode");
5673 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5674 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5675 			mode_value, "normal#bypass#isolate");
5676 cmdline_parse_token_num_t cmd_setbypass_event_port =
5677 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5678 				port_id, RTE_UINT16);
5679 
5680 cmdline_parse_inst_t cmd_set_bypass_event = {
5681 	.f = cmd_set_bypass_event_parsed,
5682 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5683 		"power_off mode normal|bypass|isolate <port_id>: "
5684 		"Set the NIC bypass event mode for port_id",
5685 	.data = NULL,
5686 	.tokens = {
5687 		(void *)&cmd_setbypass_event_set,
5688 		(void *)&cmd_setbypass_event_bypass,
5689 		(void *)&cmd_setbypass_event_event,
5690 		(void *)&cmd_setbypass_event_event_value,
5691 		(void *)&cmd_setbypass_event_mode,
5692 		(void *)&cmd_setbypass_event_mode_value,
5693 		(void *)&cmd_setbypass_event_port,
5694 		NULL,
5695 	},
5696 };
5697 
5698 
5699 /* *** SET NIC BYPASS TIMEOUT *** */
5700 struct cmd_set_bypass_timeout_result {
5701 	cmdline_fixed_string_t set;
5702 	cmdline_fixed_string_t bypass;
5703 	cmdline_fixed_string_t timeout;
5704 	cmdline_fixed_string_t value;
5705 };
5706 
5707 static void
5708 cmd_set_bypass_timeout_parsed(void *parsed_result,
5709 		__rte_unused struct cmdline *cl,
5710 		__rte_unused void *data)
5711 {
5712 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5713 
5714 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5715 	if (!strcmp(res->value, "1.5"))
5716 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5717 	else if (!strcmp(res->value, "2"))
5718 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5719 	else if (!strcmp(res->value, "3"))
5720 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5721 	else if (!strcmp(res->value, "4"))
5722 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5723 	else if (!strcmp(res->value, "8"))
5724 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5725 	else if (!strcmp(res->value, "16"))
5726 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5727 	else if (!strcmp(res->value, "32"))
5728 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5729 	else
5730 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5731 #endif
5732 }
5733 
5734 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5735 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5736 			set, "set");
5737 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5738 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5739 			bypass, "bypass");
5740 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5741 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5742 			timeout, "timeout");
5743 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5744 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5745 			value, "0#1.5#2#3#4#8#16#32");
5746 
5747 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5748 	.f = cmd_set_bypass_timeout_parsed,
5749 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5750 		"Set the NIC bypass watchdog timeout in seconds",
5751 	.data = NULL,
5752 	.tokens = {
5753 		(void *)&cmd_setbypass_timeout_set,
5754 		(void *)&cmd_setbypass_timeout_bypass,
5755 		(void *)&cmd_setbypass_timeout_timeout,
5756 		(void *)&cmd_setbypass_timeout_value,
5757 		NULL,
5758 	},
5759 };
5760 
5761 /* *** SHOW NIC BYPASS MODE *** */
5762 struct cmd_show_bypass_config_result {
5763 	cmdline_fixed_string_t show;
5764 	cmdline_fixed_string_t bypass;
5765 	cmdline_fixed_string_t config;
5766 	portid_t port_id;
5767 };
5768 
5769 static void
5770 cmd_show_bypass_config_parsed(void *parsed_result,
5771 		__rte_unused struct cmdline *cl,
5772 		__rte_unused void *data)
5773 {
5774 	struct cmd_show_bypass_config_result *res = parsed_result;
5775 	portid_t port_id = res->port_id;
5776 	int rc = -EINVAL;
5777 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5778 	uint32_t event_mode;
5779 	uint32_t bypass_mode;
5780 	uint32_t timeout = bypass_timeout;
5781 	unsigned int i;
5782 
5783 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5784 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5785 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5786 		{"UNKNOWN", "normal", "bypass", "isolate"};
5787 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5788 		"NONE",
5789 		"OS/board on",
5790 		"power supply on",
5791 		"OS/board off",
5792 		"power supply off",
5793 		"timeout"};
5794 
5795 	/* Display the bypass mode.*/
5796 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5797 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5798 		return;
5799 	}
5800 	else {
5801 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5802 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5803 
5804 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5805 	}
5806 
5807 	/* Display the bypass timeout.*/
5808 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5809 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5810 
5811 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5812 
5813 	/* Display the bypass events and associated modes. */
5814 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5815 
5816 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5817 			printf("\tFailed to get bypass mode for event = %s\n",
5818 				events[i]);
5819 		} else {
5820 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5821 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5822 
5823 			printf("\tbypass event: %-16s = %s\n", events[i],
5824 				modes[event_mode]);
5825 		}
5826 	}
5827 #endif
5828 	if (rc != 0)
5829 		printf("\tFailed to get bypass configuration for port = %d\n",
5830 		       port_id);
5831 }
5832 
5833 cmdline_parse_token_string_t cmd_showbypass_config_show =
5834 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5835 			show, "show");
5836 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5837 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5838 			bypass, "bypass");
5839 cmdline_parse_token_string_t cmd_showbypass_config_config =
5840 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5841 			config, "config");
5842 cmdline_parse_token_num_t cmd_showbypass_config_port =
5843 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5844 				port_id, RTE_UINT16);
5845 
5846 cmdline_parse_inst_t cmd_show_bypass_config = {
5847 	.f = cmd_show_bypass_config_parsed,
5848 	.help_str = "show bypass config <port_id>: "
5849 	            "Show the NIC bypass config for port_id",
5850 	.data = NULL,
5851 	.tokens = {
5852 		(void *)&cmd_showbypass_config_show,
5853 		(void *)&cmd_showbypass_config_bypass,
5854 		(void *)&cmd_showbypass_config_config,
5855 		(void *)&cmd_showbypass_config_port,
5856 		NULL,
5857 	},
5858 };
5859 
5860 #ifdef RTE_NET_BOND
5861 /* *** SET BONDING MODE *** */
5862 struct cmd_set_bonding_mode_result {
5863 	cmdline_fixed_string_t set;
5864 	cmdline_fixed_string_t bonding;
5865 	cmdline_fixed_string_t mode;
5866 	uint8_t value;
5867 	portid_t port_id;
5868 };
5869 
5870 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5871 		__rte_unused  struct cmdline *cl,
5872 		__rte_unused void *data)
5873 {
5874 	struct cmd_set_bonding_mode_result *res = parsed_result;
5875 	portid_t port_id = res->port_id;
5876 
5877 	/* Set the bonding mode for the relevant port. */
5878 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5879 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5880 }
5881 
5882 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5883 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5884 		set, "set");
5885 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5886 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5887 		bonding, "bonding");
5888 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5889 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5890 		mode, "mode");
5891 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5892 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5893 		value, RTE_UINT8);
5894 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5895 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5896 		port_id, RTE_UINT16);
5897 
5898 cmdline_parse_inst_t cmd_set_bonding_mode = {
5899 		.f = cmd_set_bonding_mode_parsed,
5900 		.help_str = "set bonding mode <mode_value> <port_id>: "
5901 			"Set the bonding mode for port_id",
5902 		.data = NULL,
5903 		.tokens = {
5904 				(void *) &cmd_setbonding_mode_set,
5905 				(void *) &cmd_setbonding_mode_bonding,
5906 				(void *) &cmd_setbonding_mode_mode,
5907 				(void *) &cmd_setbonding_mode_value,
5908 				(void *) &cmd_setbonding_mode_port,
5909 				NULL
5910 		}
5911 };
5912 
5913 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5914 struct cmd_set_bonding_lacp_dedicated_queues_result {
5915 	cmdline_fixed_string_t set;
5916 	cmdline_fixed_string_t bonding;
5917 	cmdline_fixed_string_t lacp;
5918 	cmdline_fixed_string_t dedicated_queues;
5919 	portid_t port_id;
5920 	cmdline_fixed_string_t mode;
5921 };
5922 
5923 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5924 		__rte_unused  struct cmdline *cl,
5925 		__rte_unused void *data)
5926 {
5927 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5928 	portid_t port_id = res->port_id;
5929 	struct rte_port *port;
5930 
5931 	port = &ports[port_id];
5932 
5933 	/** Check if the port is not started **/
5934 	if (port->port_status != RTE_PORT_STOPPED) {
5935 		printf("Please stop port %d first\n", port_id);
5936 		return;
5937 	}
5938 
5939 	if (!strcmp(res->mode, "enable")) {
5940 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5941 			printf("Dedicate queues for LACP control packets"
5942 					" enabled\n");
5943 		else
5944 			printf("Enabling dedicate queues for LACP control "
5945 					"packets on port %d failed\n", port_id);
5946 	} else if (!strcmp(res->mode, "disable")) {
5947 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5948 			printf("Dedicated queues for LACP control packets "
5949 					"disabled\n");
5950 		else
5951 			printf("Disabling dedicated queues for LACP control "
5952 					"traffic on port %d failed\n", port_id);
5953 	}
5954 }
5955 
5956 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5957 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5958 		set, "set");
5959 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5960 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5961 		bonding, "bonding");
5962 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5963 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5964 		lacp, "lacp");
5965 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5966 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5967 		dedicated_queues, "dedicated_queues");
5968 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5969 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5970 		port_id, RTE_UINT16);
5971 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5972 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5973 		mode, "enable#disable");
5974 
5975 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5976 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5977 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5978 			"enable|disable: "
5979 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5980 		.data = NULL,
5981 		.tokens = {
5982 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5983 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5984 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5985 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5986 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5987 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5988 			NULL
5989 		}
5990 };
5991 
5992 /* *** SET BALANCE XMIT POLICY *** */
5993 struct cmd_set_bonding_balance_xmit_policy_result {
5994 	cmdline_fixed_string_t set;
5995 	cmdline_fixed_string_t bonding;
5996 	cmdline_fixed_string_t balance_xmit_policy;
5997 	portid_t port_id;
5998 	cmdline_fixed_string_t policy;
5999 };
6000 
6001 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6002 		__rte_unused  struct cmdline *cl,
6003 		__rte_unused void *data)
6004 {
6005 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6006 	portid_t port_id = res->port_id;
6007 	uint8_t policy;
6008 
6009 	if (!strcmp(res->policy, "l2")) {
6010 		policy = BALANCE_XMIT_POLICY_LAYER2;
6011 	} else if (!strcmp(res->policy, "l23")) {
6012 		policy = BALANCE_XMIT_POLICY_LAYER23;
6013 	} else if (!strcmp(res->policy, "l34")) {
6014 		policy = BALANCE_XMIT_POLICY_LAYER34;
6015 	} else {
6016 		printf("\t Invalid xmit policy selection");
6017 		return;
6018 	}
6019 
6020 	/* Set the bonding mode for the relevant port. */
6021 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6022 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6023 				port_id);
6024 	}
6025 }
6026 
6027 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6028 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6029 		set, "set");
6030 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6032 		bonding, "bonding");
6033 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6034 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6035 		balance_xmit_policy, "balance_xmit_policy");
6036 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6037 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6038 		port_id, RTE_UINT16);
6039 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6041 		policy, "l2#l23#l34");
6042 
6043 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6044 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
6045 		.help_str = "set bonding balance_xmit_policy <port_id> "
6046 			"l2|l23|l34: "
6047 			"Set the bonding balance_xmit_policy for port_id",
6048 		.data = NULL,
6049 		.tokens = {
6050 				(void *)&cmd_setbonding_balance_xmit_policy_set,
6051 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
6052 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6053 				(void *)&cmd_setbonding_balance_xmit_policy_port,
6054 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
6055 				NULL
6056 		}
6057 };
6058 
6059 /* *** SHOW NIC BONDING CONFIGURATION *** */
6060 struct cmd_show_bonding_config_result {
6061 	cmdline_fixed_string_t show;
6062 	cmdline_fixed_string_t bonding;
6063 	cmdline_fixed_string_t config;
6064 	portid_t port_id;
6065 };
6066 
6067 static void cmd_show_bonding_config_parsed(void *parsed_result,
6068 		__rte_unused  struct cmdline *cl,
6069 		__rte_unused void *data)
6070 {
6071 	struct cmd_show_bonding_config_result *res = parsed_result;
6072 	int bonding_mode, agg_mode;
6073 	portid_t slaves[RTE_MAX_ETHPORTS];
6074 	int num_slaves, num_active_slaves;
6075 	int primary_id;
6076 	int i;
6077 	portid_t port_id = res->port_id;
6078 
6079 	/* Display the bonding mode.*/
6080 	bonding_mode = rte_eth_bond_mode_get(port_id);
6081 	if (bonding_mode < 0) {
6082 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
6083 		return;
6084 	} else
6085 		printf("\tBonding mode: %d\n", bonding_mode);
6086 
6087 	if (bonding_mode == BONDING_MODE_BALANCE) {
6088 		int balance_xmit_policy;
6089 
6090 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6091 		if (balance_xmit_policy < 0) {
6092 			printf("\tFailed to get balance xmit policy for port = %d\n",
6093 					port_id);
6094 			return;
6095 		} else {
6096 			printf("\tBalance Xmit Policy: ");
6097 
6098 			switch (balance_xmit_policy) {
6099 			case BALANCE_XMIT_POLICY_LAYER2:
6100 				printf("BALANCE_XMIT_POLICY_LAYER2");
6101 				break;
6102 			case BALANCE_XMIT_POLICY_LAYER23:
6103 				printf("BALANCE_XMIT_POLICY_LAYER23");
6104 				break;
6105 			case BALANCE_XMIT_POLICY_LAYER34:
6106 				printf("BALANCE_XMIT_POLICY_LAYER34");
6107 				break;
6108 			}
6109 			printf("\n");
6110 		}
6111 	}
6112 
6113 	if (bonding_mode == BONDING_MODE_8023AD) {
6114 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6115 		printf("\tIEEE802.3AD Aggregator Mode: ");
6116 		switch (agg_mode) {
6117 		case AGG_BANDWIDTH:
6118 			printf("bandwidth");
6119 			break;
6120 		case AGG_STABLE:
6121 			printf("stable");
6122 			break;
6123 		case AGG_COUNT:
6124 			printf("count");
6125 			break;
6126 		}
6127 		printf("\n");
6128 	}
6129 
6130 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6131 
6132 	if (num_slaves < 0) {
6133 		printf("\tFailed to get slave list for port = %d\n", port_id);
6134 		return;
6135 	}
6136 	if (num_slaves > 0) {
6137 		printf("\tSlaves (%d): [", num_slaves);
6138 		for (i = 0; i < num_slaves - 1; i++)
6139 			printf("%d ", slaves[i]);
6140 
6141 		printf("%d]\n", slaves[num_slaves - 1]);
6142 	} else {
6143 		printf("\tSlaves: []\n");
6144 
6145 	}
6146 
6147 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6148 			RTE_MAX_ETHPORTS);
6149 
6150 	if (num_active_slaves < 0) {
6151 		printf("\tFailed to get active slave list for port = %d\n", port_id);
6152 		return;
6153 	}
6154 	if (num_active_slaves > 0) {
6155 		printf("\tActive Slaves (%d): [", num_active_slaves);
6156 		for (i = 0; i < num_active_slaves - 1; i++)
6157 			printf("%d ", slaves[i]);
6158 
6159 		printf("%d]\n", slaves[num_active_slaves - 1]);
6160 
6161 	} else {
6162 		printf("\tActive Slaves: []\n");
6163 
6164 	}
6165 
6166 	primary_id = rte_eth_bond_primary_get(port_id);
6167 	if (primary_id < 0) {
6168 		printf("\tFailed to get primary slave for port = %d\n", port_id);
6169 		return;
6170 	} else
6171 		printf("\tPrimary: [%d]\n", primary_id);
6172 
6173 }
6174 
6175 cmdline_parse_token_string_t cmd_showbonding_config_show =
6176 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6177 		show, "show");
6178 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6179 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6180 		bonding, "bonding");
6181 cmdline_parse_token_string_t cmd_showbonding_config_config =
6182 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6183 		config, "config");
6184 cmdline_parse_token_num_t cmd_showbonding_config_port =
6185 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6186 		port_id, RTE_UINT16);
6187 
6188 cmdline_parse_inst_t cmd_show_bonding_config = {
6189 		.f = cmd_show_bonding_config_parsed,
6190 		.help_str = "show bonding config <port_id>: "
6191 			"Show the bonding config for port_id",
6192 		.data = NULL,
6193 		.tokens = {
6194 				(void *)&cmd_showbonding_config_show,
6195 				(void *)&cmd_showbonding_config_bonding,
6196 				(void *)&cmd_showbonding_config_config,
6197 				(void *)&cmd_showbonding_config_port,
6198 				NULL
6199 		}
6200 };
6201 
6202 /* *** SET BONDING PRIMARY *** */
6203 struct cmd_set_bonding_primary_result {
6204 	cmdline_fixed_string_t set;
6205 	cmdline_fixed_string_t bonding;
6206 	cmdline_fixed_string_t primary;
6207 	portid_t slave_id;
6208 	portid_t port_id;
6209 };
6210 
6211 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6212 		__rte_unused  struct cmdline *cl,
6213 		__rte_unused void *data)
6214 {
6215 	struct cmd_set_bonding_primary_result *res = parsed_result;
6216 	portid_t master_port_id = res->port_id;
6217 	portid_t slave_port_id = res->slave_id;
6218 
6219 	/* Set the primary slave for a bonded device. */
6220 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6221 		printf("\t Failed to set primary slave for port = %d.\n",
6222 				master_port_id);
6223 		return;
6224 	}
6225 	init_port_config();
6226 }
6227 
6228 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6230 		set, "set");
6231 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6233 		bonding, "bonding");
6234 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6235 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6236 		primary, "primary");
6237 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6238 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6239 		slave_id, RTE_UINT16);
6240 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6241 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6242 		port_id, RTE_UINT16);
6243 
6244 cmdline_parse_inst_t cmd_set_bonding_primary = {
6245 		.f = cmd_set_bonding_primary_parsed,
6246 		.help_str = "set bonding primary <slave_id> <port_id>: "
6247 			"Set the primary slave for port_id",
6248 		.data = NULL,
6249 		.tokens = {
6250 				(void *)&cmd_setbonding_primary_set,
6251 				(void *)&cmd_setbonding_primary_bonding,
6252 				(void *)&cmd_setbonding_primary_primary,
6253 				(void *)&cmd_setbonding_primary_slave,
6254 				(void *)&cmd_setbonding_primary_port,
6255 				NULL
6256 		}
6257 };
6258 
6259 /* *** ADD SLAVE *** */
6260 struct cmd_add_bonding_slave_result {
6261 	cmdline_fixed_string_t add;
6262 	cmdline_fixed_string_t bonding;
6263 	cmdline_fixed_string_t slave;
6264 	portid_t slave_id;
6265 	portid_t port_id;
6266 };
6267 
6268 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6269 		__rte_unused  struct cmdline *cl,
6270 		__rte_unused void *data)
6271 {
6272 	struct cmd_add_bonding_slave_result *res = parsed_result;
6273 	portid_t master_port_id = res->port_id;
6274 	portid_t slave_port_id = res->slave_id;
6275 
6276 	/* add the slave for a bonded device. */
6277 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6278 		printf("\t Failed to add slave %d to master port = %d.\n",
6279 				slave_port_id, master_port_id);
6280 		return;
6281 	}
6282 	init_port_config();
6283 	set_port_slave_flag(slave_port_id);
6284 }
6285 
6286 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6287 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6288 		add, "add");
6289 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6290 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6291 		bonding, "bonding");
6292 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6293 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6294 		slave, "slave");
6295 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6296 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6297 		slave_id, RTE_UINT16);
6298 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6299 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6300 		port_id, RTE_UINT16);
6301 
6302 cmdline_parse_inst_t cmd_add_bonding_slave = {
6303 		.f = cmd_add_bonding_slave_parsed,
6304 		.help_str = "add bonding slave <slave_id> <port_id>: "
6305 			"Add a slave device to a bonded device",
6306 		.data = NULL,
6307 		.tokens = {
6308 				(void *)&cmd_addbonding_slave_add,
6309 				(void *)&cmd_addbonding_slave_bonding,
6310 				(void *)&cmd_addbonding_slave_slave,
6311 				(void *)&cmd_addbonding_slave_slaveid,
6312 				(void *)&cmd_addbonding_slave_port,
6313 				NULL
6314 		}
6315 };
6316 
6317 /* *** REMOVE SLAVE *** */
6318 struct cmd_remove_bonding_slave_result {
6319 	cmdline_fixed_string_t remove;
6320 	cmdline_fixed_string_t bonding;
6321 	cmdline_fixed_string_t slave;
6322 	portid_t slave_id;
6323 	portid_t port_id;
6324 };
6325 
6326 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6327 		__rte_unused  struct cmdline *cl,
6328 		__rte_unused void *data)
6329 {
6330 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6331 	portid_t master_port_id = res->port_id;
6332 	portid_t slave_port_id = res->slave_id;
6333 
6334 	/* remove the slave from a bonded device. */
6335 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6336 		printf("\t Failed to remove slave %d from master port = %d.\n",
6337 				slave_port_id, master_port_id);
6338 		return;
6339 	}
6340 	init_port_config();
6341 	clear_port_slave_flag(slave_port_id);
6342 }
6343 
6344 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6345 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6346 				remove, "remove");
6347 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6348 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6349 				bonding, "bonding");
6350 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6351 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6352 				slave, "slave");
6353 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6354 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6355 				slave_id, RTE_UINT16);
6356 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6357 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6358 				port_id, RTE_UINT16);
6359 
6360 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6361 		.f = cmd_remove_bonding_slave_parsed,
6362 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6363 			"Remove a slave device from a bonded device",
6364 		.data = NULL,
6365 		.tokens = {
6366 				(void *)&cmd_removebonding_slave_remove,
6367 				(void *)&cmd_removebonding_slave_bonding,
6368 				(void *)&cmd_removebonding_slave_slave,
6369 				(void *)&cmd_removebonding_slave_slaveid,
6370 				(void *)&cmd_removebonding_slave_port,
6371 				NULL
6372 		}
6373 };
6374 
6375 /* *** CREATE BONDED DEVICE *** */
6376 struct cmd_create_bonded_device_result {
6377 	cmdline_fixed_string_t create;
6378 	cmdline_fixed_string_t bonded;
6379 	cmdline_fixed_string_t device;
6380 	uint8_t mode;
6381 	uint8_t socket;
6382 };
6383 
6384 static int bond_dev_num = 0;
6385 
6386 static void cmd_create_bonded_device_parsed(void *parsed_result,
6387 		__rte_unused  struct cmdline *cl,
6388 		__rte_unused void *data)
6389 {
6390 	struct cmd_create_bonded_device_result *res = parsed_result;
6391 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6392 	int port_id;
6393 	int ret;
6394 
6395 	if (test_done == 0) {
6396 		printf("Please stop forwarding first\n");
6397 		return;
6398 	}
6399 
6400 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6401 			bond_dev_num++);
6402 
6403 	/* Create a new bonded device. */
6404 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6405 	if (port_id < 0) {
6406 		printf("\t Failed to create bonded device.\n");
6407 		return;
6408 	} else {
6409 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6410 				port_id);
6411 
6412 		/* Update number of ports */
6413 		nb_ports = rte_eth_dev_count_avail();
6414 		reconfig(port_id, res->socket);
6415 		ret = rte_eth_promiscuous_enable(port_id);
6416 		if (ret != 0)
6417 			printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6418 				port_id, rte_strerror(-ret));
6419 
6420 		ports[port_id].need_setup = 0;
6421 		ports[port_id].port_status = RTE_PORT_STOPPED;
6422 	}
6423 
6424 }
6425 
6426 cmdline_parse_token_string_t cmd_createbonded_device_create =
6427 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6428 				create, "create");
6429 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6430 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6431 				bonded, "bonded");
6432 cmdline_parse_token_string_t cmd_createbonded_device_device =
6433 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6434 				device, "device");
6435 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6436 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6437 				mode, RTE_UINT8);
6438 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6439 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6440 				socket, RTE_UINT8);
6441 
6442 cmdline_parse_inst_t cmd_create_bonded_device = {
6443 		.f = cmd_create_bonded_device_parsed,
6444 		.help_str = "create bonded device <mode> <socket>: "
6445 			"Create a new bonded device with specific bonding mode and socket",
6446 		.data = NULL,
6447 		.tokens = {
6448 				(void *)&cmd_createbonded_device_create,
6449 				(void *)&cmd_createbonded_device_bonded,
6450 				(void *)&cmd_createbonded_device_device,
6451 				(void *)&cmd_createbonded_device_mode,
6452 				(void *)&cmd_createbonded_device_socket,
6453 				NULL
6454 		}
6455 };
6456 
6457 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6458 struct cmd_set_bond_mac_addr_result {
6459 	cmdline_fixed_string_t set;
6460 	cmdline_fixed_string_t bonding;
6461 	cmdline_fixed_string_t mac_addr;
6462 	uint16_t port_num;
6463 	struct rte_ether_addr address;
6464 };
6465 
6466 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6467 		__rte_unused  struct cmdline *cl,
6468 		__rte_unused void *data)
6469 {
6470 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6471 	int ret;
6472 
6473 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6474 		return;
6475 
6476 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6477 
6478 	/* check the return value and print it if is < 0 */
6479 	if (ret < 0)
6480 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6481 }
6482 
6483 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6484 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6485 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6486 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6487 				"bonding");
6488 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6489 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6490 				"mac_addr");
6491 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6492 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6493 				port_num, RTE_UINT16);
6494 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6495 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6496 
6497 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6498 		.f = cmd_set_bond_mac_addr_parsed,
6499 		.data = (void *) 0,
6500 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6501 		.tokens = {
6502 				(void *)&cmd_set_bond_mac_addr_set,
6503 				(void *)&cmd_set_bond_mac_addr_bonding,
6504 				(void *)&cmd_set_bond_mac_addr_mac,
6505 				(void *)&cmd_set_bond_mac_addr_portnum,
6506 				(void *)&cmd_set_bond_mac_addr_addr,
6507 				NULL
6508 		}
6509 };
6510 
6511 
6512 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6513 struct cmd_set_bond_mon_period_result {
6514 	cmdline_fixed_string_t set;
6515 	cmdline_fixed_string_t bonding;
6516 	cmdline_fixed_string_t mon_period;
6517 	uint16_t port_num;
6518 	uint32_t period_ms;
6519 };
6520 
6521 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6522 		__rte_unused  struct cmdline *cl,
6523 		__rte_unused void *data)
6524 {
6525 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6526 	int ret;
6527 
6528 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6529 
6530 	/* check the return value and print it if is < 0 */
6531 	if (ret < 0)
6532 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6533 }
6534 
6535 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6536 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6537 				set, "set");
6538 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6539 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6540 				bonding, "bonding");
6541 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6542 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6543 				mon_period,	"mon_period");
6544 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6545 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6546 				port_num, RTE_UINT16);
6547 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6548 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6549 				period_ms, RTE_UINT32);
6550 
6551 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6552 		.f = cmd_set_bond_mon_period_parsed,
6553 		.data = (void *) 0,
6554 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6555 		.tokens = {
6556 				(void *)&cmd_set_bond_mon_period_set,
6557 				(void *)&cmd_set_bond_mon_period_bonding,
6558 				(void *)&cmd_set_bond_mon_period_mon_period,
6559 				(void *)&cmd_set_bond_mon_period_portnum,
6560 				(void *)&cmd_set_bond_mon_period_period_ms,
6561 				NULL
6562 		}
6563 };
6564 
6565 
6566 
6567 struct cmd_set_bonding_agg_mode_policy_result {
6568 	cmdline_fixed_string_t set;
6569 	cmdline_fixed_string_t bonding;
6570 	cmdline_fixed_string_t agg_mode;
6571 	uint16_t port_num;
6572 	cmdline_fixed_string_t policy;
6573 };
6574 
6575 
6576 static void
6577 cmd_set_bonding_agg_mode(void *parsed_result,
6578 		__rte_unused struct cmdline *cl,
6579 		__rte_unused void *data)
6580 {
6581 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6582 	uint8_t policy = AGG_BANDWIDTH;
6583 
6584 	if (!strcmp(res->policy, "bandwidth"))
6585 		policy = AGG_BANDWIDTH;
6586 	else if (!strcmp(res->policy, "stable"))
6587 		policy = AGG_STABLE;
6588 	else if (!strcmp(res->policy, "count"))
6589 		policy = AGG_COUNT;
6590 
6591 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6592 }
6593 
6594 
6595 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6596 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6597 				set, "set");
6598 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6599 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6600 				bonding, "bonding");
6601 
6602 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6603 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6604 				agg_mode, "agg_mode");
6605 
6606 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6607 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6608 				port_num, RTE_UINT16);
6609 
6610 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6611 	TOKEN_STRING_INITIALIZER(
6612 			struct cmd_set_bonding_balance_xmit_policy_result,
6613 		policy, "stable#bandwidth#count");
6614 
6615 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6616 	.f = cmd_set_bonding_agg_mode,
6617 	.data = (void *) 0,
6618 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6619 	.tokens = {
6620 			(void *)&cmd_set_bonding_agg_mode_set,
6621 			(void *)&cmd_set_bonding_agg_mode_bonding,
6622 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6623 			(void *)&cmd_set_bonding_agg_mode_portnum,
6624 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6625 			NULL
6626 		}
6627 };
6628 
6629 
6630 #endif /* RTE_NET_BOND */
6631 
6632 /* *** SET FORWARDING MODE *** */
6633 struct cmd_set_fwd_mode_result {
6634 	cmdline_fixed_string_t set;
6635 	cmdline_fixed_string_t fwd;
6636 	cmdline_fixed_string_t mode;
6637 };
6638 
6639 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6640 				    __rte_unused struct cmdline *cl,
6641 				    __rte_unused void *data)
6642 {
6643 	struct cmd_set_fwd_mode_result *res = parsed_result;
6644 
6645 	retry_enabled = 0;
6646 	set_pkt_forwarding_mode(res->mode);
6647 }
6648 
6649 cmdline_parse_token_string_t cmd_setfwd_set =
6650 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6651 cmdline_parse_token_string_t cmd_setfwd_fwd =
6652 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6653 cmdline_parse_token_string_t cmd_setfwd_mode =
6654 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6655 		"" /* defined at init */);
6656 
6657 cmdline_parse_inst_t cmd_set_fwd_mode = {
6658 	.f = cmd_set_fwd_mode_parsed,
6659 	.data = NULL,
6660 	.help_str = NULL, /* defined at init */
6661 	.tokens = {
6662 		(void *)&cmd_setfwd_set,
6663 		(void *)&cmd_setfwd_fwd,
6664 		(void *)&cmd_setfwd_mode,
6665 		NULL,
6666 	},
6667 };
6668 
6669 static void cmd_set_fwd_mode_init(void)
6670 {
6671 	char *modes, *c;
6672 	static char token[128];
6673 	static char help[256];
6674 	cmdline_parse_token_string_t *token_struct;
6675 
6676 	modes = list_pkt_forwarding_modes();
6677 	snprintf(help, sizeof(help), "set fwd %s: "
6678 		"Set packet forwarding mode", modes);
6679 	cmd_set_fwd_mode.help_str = help;
6680 
6681 	/* string token separator is # */
6682 	for (c = token; *modes != '\0'; modes++)
6683 		if (*modes == '|')
6684 			*c++ = '#';
6685 		else
6686 			*c++ = *modes;
6687 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6688 	token_struct->string_data.str = token;
6689 }
6690 
6691 /* *** SET RETRY FORWARDING MODE *** */
6692 struct cmd_set_fwd_retry_mode_result {
6693 	cmdline_fixed_string_t set;
6694 	cmdline_fixed_string_t fwd;
6695 	cmdline_fixed_string_t mode;
6696 	cmdline_fixed_string_t retry;
6697 };
6698 
6699 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6700 			    __rte_unused struct cmdline *cl,
6701 			    __rte_unused void *data)
6702 {
6703 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6704 
6705 	retry_enabled = 1;
6706 	set_pkt_forwarding_mode(res->mode);
6707 }
6708 
6709 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6710 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6711 			set, "set");
6712 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6713 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6714 			fwd, "fwd");
6715 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6716 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6717 			mode,
6718 		"" /* defined at init */);
6719 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6720 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6721 			retry, "retry");
6722 
6723 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6724 	.f = cmd_set_fwd_retry_mode_parsed,
6725 	.data = NULL,
6726 	.help_str = NULL, /* defined at init */
6727 	.tokens = {
6728 		(void *)&cmd_setfwd_retry_set,
6729 		(void *)&cmd_setfwd_retry_fwd,
6730 		(void *)&cmd_setfwd_retry_mode,
6731 		(void *)&cmd_setfwd_retry_retry,
6732 		NULL,
6733 	},
6734 };
6735 
6736 static void cmd_set_fwd_retry_mode_init(void)
6737 {
6738 	char *modes, *c;
6739 	static char token[128];
6740 	static char help[256];
6741 	cmdline_parse_token_string_t *token_struct;
6742 
6743 	modes = list_pkt_forwarding_retry_modes();
6744 	snprintf(help, sizeof(help), "set fwd %s retry: "
6745 		"Set packet forwarding mode with retry", modes);
6746 	cmd_set_fwd_retry_mode.help_str = help;
6747 
6748 	/* string token separator is # */
6749 	for (c = token; *modes != '\0'; modes++)
6750 		if (*modes == '|')
6751 			*c++ = '#';
6752 		else
6753 			*c++ = *modes;
6754 	token_struct = (cmdline_parse_token_string_t *)
6755 		cmd_set_fwd_retry_mode.tokens[2];
6756 	token_struct->string_data.str = token;
6757 }
6758 
6759 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6760 struct cmd_set_burst_tx_retry_result {
6761 	cmdline_fixed_string_t set;
6762 	cmdline_fixed_string_t burst;
6763 	cmdline_fixed_string_t tx;
6764 	cmdline_fixed_string_t delay;
6765 	uint32_t time;
6766 	cmdline_fixed_string_t retry;
6767 	uint32_t retry_num;
6768 };
6769 
6770 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6771 					__rte_unused struct cmdline *cl,
6772 					__rte_unused void *data)
6773 {
6774 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6775 
6776 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6777 		&& !strcmp(res->tx, "tx")) {
6778 		if (!strcmp(res->delay, "delay"))
6779 			burst_tx_delay_time = res->time;
6780 		if (!strcmp(res->retry, "retry"))
6781 			burst_tx_retry_num = res->retry_num;
6782 	}
6783 
6784 }
6785 
6786 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6787 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6788 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6789 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6790 				 "burst");
6791 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6792 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6793 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6794 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6795 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6796 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6797 				 RTE_UINT32);
6798 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6799 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6800 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6801 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6802 				 RTE_UINT32);
6803 
6804 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6805 	.f = cmd_set_burst_tx_retry_parsed,
6806 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6807 	.tokens = {
6808 		(void *)&cmd_set_burst_tx_retry_set,
6809 		(void *)&cmd_set_burst_tx_retry_burst,
6810 		(void *)&cmd_set_burst_tx_retry_tx,
6811 		(void *)&cmd_set_burst_tx_retry_delay,
6812 		(void *)&cmd_set_burst_tx_retry_time,
6813 		(void *)&cmd_set_burst_tx_retry_retry,
6814 		(void *)&cmd_set_burst_tx_retry_retry_num,
6815 		NULL,
6816 	},
6817 };
6818 
6819 /* *** SET PROMISC MODE *** */
6820 struct cmd_set_promisc_mode_result {
6821 	cmdline_fixed_string_t set;
6822 	cmdline_fixed_string_t promisc;
6823 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6824 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6825 	cmdline_fixed_string_t mode;
6826 };
6827 
6828 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6829 					__rte_unused struct cmdline *cl,
6830 					void *allports)
6831 {
6832 	struct cmd_set_promisc_mode_result *res = parsed_result;
6833 	int enable;
6834 	portid_t i;
6835 
6836 	if (!strcmp(res->mode, "on"))
6837 		enable = 1;
6838 	else
6839 		enable = 0;
6840 
6841 	/* all ports */
6842 	if (allports) {
6843 		RTE_ETH_FOREACH_DEV(i)
6844 			eth_set_promisc_mode(i, enable);
6845 	} else {
6846 		eth_set_promisc_mode(res->port_num, enable);
6847 	}
6848 }
6849 
6850 cmdline_parse_token_string_t cmd_setpromisc_set =
6851 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6852 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6853 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6854 				 "promisc");
6855 cmdline_parse_token_string_t cmd_setpromisc_portall =
6856 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6857 				 "all");
6858 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6859 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6860 			      RTE_UINT16);
6861 cmdline_parse_token_string_t cmd_setpromisc_mode =
6862 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6863 				 "on#off");
6864 
6865 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6866 	.f = cmd_set_promisc_mode_parsed,
6867 	.data = (void *)1,
6868 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6869 	.tokens = {
6870 		(void *)&cmd_setpromisc_set,
6871 		(void *)&cmd_setpromisc_promisc,
6872 		(void *)&cmd_setpromisc_portall,
6873 		(void *)&cmd_setpromisc_mode,
6874 		NULL,
6875 	},
6876 };
6877 
6878 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6879 	.f = cmd_set_promisc_mode_parsed,
6880 	.data = (void *)0,
6881 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6882 	.tokens = {
6883 		(void *)&cmd_setpromisc_set,
6884 		(void *)&cmd_setpromisc_promisc,
6885 		(void *)&cmd_setpromisc_portnum,
6886 		(void *)&cmd_setpromisc_mode,
6887 		NULL,
6888 	},
6889 };
6890 
6891 /* *** SET ALLMULTI MODE *** */
6892 struct cmd_set_allmulti_mode_result {
6893 	cmdline_fixed_string_t set;
6894 	cmdline_fixed_string_t allmulti;
6895 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6896 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6897 	cmdline_fixed_string_t mode;
6898 };
6899 
6900 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6901 					__rte_unused struct cmdline *cl,
6902 					void *allports)
6903 {
6904 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6905 	int enable;
6906 	portid_t i;
6907 
6908 	if (!strcmp(res->mode, "on"))
6909 		enable = 1;
6910 	else
6911 		enable = 0;
6912 
6913 	/* all ports */
6914 	if (allports) {
6915 		RTE_ETH_FOREACH_DEV(i) {
6916 			eth_set_allmulticast_mode(i, enable);
6917 		}
6918 	}
6919 	else {
6920 		eth_set_allmulticast_mode(res->port_num, enable);
6921 	}
6922 }
6923 
6924 cmdline_parse_token_string_t cmd_setallmulti_set =
6925 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6926 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6927 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6928 				 "allmulti");
6929 cmdline_parse_token_string_t cmd_setallmulti_portall =
6930 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6931 				 "all");
6932 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6933 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6934 			      RTE_UINT16);
6935 cmdline_parse_token_string_t cmd_setallmulti_mode =
6936 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6937 				 "on#off");
6938 
6939 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6940 	.f = cmd_set_allmulti_mode_parsed,
6941 	.data = (void *)1,
6942 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6943 	.tokens = {
6944 		(void *)&cmd_setallmulti_set,
6945 		(void *)&cmd_setallmulti_allmulti,
6946 		(void *)&cmd_setallmulti_portall,
6947 		(void *)&cmd_setallmulti_mode,
6948 		NULL,
6949 	},
6950 };
6951 
6952 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6953 	.f = cmd_set_allmulti_mode_parsed,
6954 	.data = (void *)0,
6955 	.help_str = "set allmulti <port_id> on|off: "
6956 		"Set allmulti mode on port_id",
6957 	.tokens = {
6958 		(void *)&cmd_setallmulti_set,
6959 		(void *)&cmd_setallmulti_allmulti,
6960 		(void *)&cmd_setallmulti_portnum,
6961 		(void *)&cmd_setallmulti_mode,
6962 		NULL,
6963 	},
6964 };
6965 
6966 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6967 struct cmd_link_flow_ctrl_show {
6968 	cmdline_fixed_string_t show;
6969 	cmdline_fixed_string_t port;
6970 	portid_t port_id;
6971 	cmdline_fixed_string_t flow_ctrl;
6972 };
6973 
6974 cmdline_parse_token_string_t cmd_lfc_show_show =
6975 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6976 				show, "show");
6977 cmdline_parse_token_string_t cmd_lfc_show_port =
6978 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6979 				port, "port");
6980 cmdline_parse_token_num_t cmd_lfc_show_portid =
6981 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6982 				port_id, RTE_UINT16);
6983 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6984 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6985 				flow_ctrl, "flow_ctrl");
6986 
6987 static void
6988 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6989 			      __rte_unused struct cmdline *cl,
6990 			      __rte_unused void *data)
6991 {
6992 	struct cmd_link_flow_ctrl_show *res = parsed_result;
6993 	static const char *info_border = "*********************";
6994 	struct rte_eth_fc_conf fc_conf;
6995 	bool rx_fc_en = false;
6996 	bool tx_fc_en = false;
6997 	int ret;
6998 
6999 	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7000 	if (ret != 0) {
7001 		printf("Failed to get current flow ctrl information: err = %d\n",
7002 		       ret);
7003 		return;
7004 	}
7005 
7006 	if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7007 		rx_fc_en = true;
7008 	if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7009 		tx_fc_en = true;
7010 
7011 	printf("\n%s Flow control infos for port %-2d %s\n",
7012 		info_border, res->port_id, info_border);
7013 	printf("FC mode:\n");
7014 	printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
7015 	printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
7016 	printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7017 	printf("Pause time: 0x%x\n", fc_conf.pause_time);
7018 	printf("High waterline: 0x%x\n", fc_conf.high_water);
7019 	printf("Low waterline: 0x%x\n", fc_conf.low_water);
7020 	printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7021 	printf("Forward MAC control frames: %s\n",
7022 		fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7023 	printf("\n%s**************   End  ***********%s\n",
7024 		info_border, info_border);
7025 }
7026 
7027 cmdline_parse_inst_t cmd_link_flow_control_show = {
7028 	.f = cmd_link_flow_ctrl_show_parsed,
7029 	.data = NULL,
7030 	.help_str = "show port <port_id> flow_ctrl",
7031 	.tokens = {
7032 		(void *)&cmd_lfc_show_show,
7033 		(void *)&cmd_lfc_show_port,
7034 		(void *)&cmd_lfc_show_portid,
7035 		(void *)&cmd_lfc_show_flow_ctrl,
7036 		NULL,
7037 	},
7038 };
7039 
7040 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7041 struct cmd_link_flow_ctrl_set_result {
7042 	cmdline_fixed_string_t set;
7043 	cmdline_fixed_string_t flow_ctrl;
7044 	cmdline_fixed_string_t rx;
7045 	cmdline_fixed_string_t rx_lfc_mode;
7046 	cmdline_fixed_string_t tx;
7047 	cmdline_fixed_string_t tx_lfc_mode;
7048 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
7049 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7050 	cmdline_fixed_string_t autoneg_str;
7051 	cmdline_fixed_string_t autoneg;
7052 	cmdline_fixed_string_t hw_str;
7053 	uint32_t high_water;
7054 	cmdline_fixed_string_t lw_str;
7055 	uint32_t low_water;
7056 	cmdline_fixed_string_t pt_str;
7057 	uint16_t pause_time;
7058 	cmdline_fixed_string_t xon_str;
7059 	uint16_t send_xon;
7060 	portid_t port_id;
7061 };
7062 
7063 cmdline_parse_token_string_t cmd_lfc_set_set =
7064 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7065 				set, "set");
7066 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7067 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7068 				flow_ctrl, "flow_ctrl");
7069 cmdline_parse_token_string_t cmd_lfc_set_rx =
7070 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7071 				rx, "rx");
7072 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7073 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7074 				rx_lfc_mode, "on#off");
7075 cmdline_parse_token_string_t cmd_lfc_set_tx =
7076 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7077 				tx, "tx");
7078 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7079 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7080 				tx_lfc_mode, "on#off");
7081 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7082 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7083 				hw_str, "high_water");
7084 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7085 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7086 				high_water, RTE_UINT32);
7087 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7088 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7089 				lw_str, "low_water");
7090 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7091 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7092 				low_water, RTE_UINT32);
7093 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7094 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7095 				pt_str, "pause_time");
7096 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7097 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7098 				pause_time, RTE_UINT16);
7099 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7100 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7101 				xon_str, "send_xon");
7102 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7103 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7104 				send_xon, RTE_UINT16);
7105 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7106 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7107 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7108 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7109 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7110 				mac_ctrl_frame_fwd_mode, "on#off");
7111 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7112 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7113 				autoneg_str, "autoneg");
7114 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7115 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7116 				autoneg, "on#off");
7117 cmdline_parse_token_num_t cmd_lfc_set_portid =
7118 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7119 				port_id, RTE_UINT16);
7120 
7121 /* forward declaration */
7122 static void
7123 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7124 			      void *data);
7125 
7126 cmdline_parse_inst_t cmd_link_flow_control_set = {
7127 	.f = cmd_link_flow_ctrl_set_parsed,
7128 	.data = NULL,
7129 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7130 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7131 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
7132 	.tokens = {
7133 		(void *)&cmd_lfc_set_set,
7134 		(void *)&cmd_lfc_set_flow_ctrl,
7135 		(void *)&cmd_lfc_set_rx,
7136 		(void *)&cmd_lfc_set_rx_mode,
7137 		(void *)&cmd_lfc_set_tx,
7138 		(void *)&cmd_lfc_set_tx_mode,
7139 		(void *)&cmd_lfc_set_high_water,
7140 		(void *)&cmd_lfc_set_low_water,
7141 		(void *)&cmd_lfc_set_pause_time,
7142 		(void *)&cmd_lfc_set_send_xon,
7143 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7144 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7145 		(void *)&cmd_lfc_set_autoneg_str,
7146 		(void *)&cmd_lfc_set_autoneg,
7147 		(void *)&cmd_lfc_set_portid,
7148 		NULL,
7149 	},
7150 };
7151 
7152 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7153 	.f = cmd_link_flow_ctrl_set_parsed,
7154 	.data = (void *)&cmd_link_flow_control_set_rx,
7155 	.help_str = "set flow_ctrl rx on|off <port_id>: "
7156 		"Change rx flow control parameter",
7157 	.tokens = {
7158 		(void *)&cmd_lfc_set_set,
7159 		(void *)&cmd_lfc_set_flow_ctrl,
7160 		(void *)&cmd_lfc_set_rx,
7161 		(void *)&cmd_lfc_set_rx_mode,
7162 		(void *)&cmd_lfc_set_portid,
7163 		NULL,
7164 	},
7165 };
7166 
7167 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7168 	.f = cmd_link_flow_ctrl_set_parsed,
7169 	.data = (void *)&cmd_link_flow_control_set_tx,
7170 	.help_str = "set flow_ctrl tx on|off <port_id>: "
7171 		"Change tx flow control parameter",
7172 	.tokens = {
7173 		(void *)&cmd_lfc_set_set,
7174 		(void *)&cmd_lfc_set_flow_ctrl,
7175 		(void *)&cmd_lfc_set_tx,
7176 		(void *)&cmd_lfc_set_tx_mode,
7177 		(void *)&cmd_lfc_set_portid,
7178 		NULL,
7179 	},
7180 };
7181 
7182 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7183 	.f = cmd_link_flow_ctrl_set_parsed,
7184 	.data = (void *)&cmd_link_flow_control_set_hw,
7185 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
7186 		"Change high water flow control parameter",
7187 	.tokens = {
7188 		(void *)&cmd_lfc_set_set,
7189 		(void *)&cmd_lfc_set_flow_ctrl,
7190 		(void *)&cmd_lfc_set_high_water_str,
7191 		(void *)&cmd_lfc_set_high_water,
7192 		(void *)&cmd_lfc_set_portid,
7193 		NULL,
7194 	},
7195 };
7196 
7197 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7198 	.f = cmd_link_flow_ctrl_set_parsed,
7199 	.data = (void *)&cmd_link_flow_control_set_lw,
7200 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7201 		"Change low water flow control parameter",
7202 	.tokens = {
7203 		(void *)&cmd_lfc_set_set,
7204 		(void *)&cmd_lfc_set_flow_ctrl,
7205 		(void *)&cmd_lfc_set_low_water_str,
7206 		(void *)&cmd_lfc_set_low_water,
7207 		(void *)&cmd_lfc_set_portid,
7208 		NULL,
7209 	},
7210 };
7211 
7212 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7213 	.f = cmd_link_flow_ctrl_set_parsed,
7214 	.data = (void *)&cmd_link_flow_control_set_pt,
7215 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7216 		"Change pause time flow control parameter",
7217 	.tokens = {
7218 		(void *)&cmd_lfc_set_set,
7219 		(void *)&cmd_lfc_set_flow_ctrl,
7220 		(void *)&cmd_lfc_set_pause_time_str,
7221 		(void *)&cmd_lfc_set_pause_time,
7222 		(void *)&cmd_lfc_set_portid,
7223 		NULL,
7224 	},
7225 };
7226 
7227 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7228 	.f = cmd_link_flow_ctrl_set_parsed,
7229 	.data = (void *)&cmd_link_flow_control_set_xon,
7230 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7231 		"Change send_xon flow control parameter",
7232 	.tokens = {
7233 		(void *)&cmd_lfc_set_set,
7234 		(void *)&cmd_lfc_set_flow_ctrl,
7235 		(void *)&cmd_lfc_set_send_xon_str,
7236 		(void *)&cmd_lfc_set_send_xon,
7237 		(void *)&cmd_lfc_set_portid,
7238 		NULL,
7239 	},
7240 };
7241 
7242 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7243 	.f = cmd_link_flow_ctrl_set_parsed,
7244 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7245 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7246 		"Change mac ctrl fwd flow control parameter",
7247 	.tokens = {
7248 		(void *)&cmd_lfc_set_set,
7249 		(void *)&cmd_lfc_set_flow_ctrl,
7250 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7251 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7252 		(void *)&cmd_lfc_set_portid,
7253 		NULL,
7254 	},
7255 };
7256 
7257 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7258 	.f = cmd_link_flow_ctrl_set_parsed,
7259 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7260 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7261 		"Change autoneg flow control parameter",
7262 	.tokens = {
7263 		(void *)&cmd_lfc_set_set,
7264 		(void *)&cmd_lfc_set_flow_ctrl,
7265 		(void *)&cmd_lfc_set_autoneg_str,
7266 		(void *)&cmd_lfc_set_autoneg,
7267 		(void *)&cmd_lfc_set_portid,
7268 		NULL,
7269 	},
7270 };
7271 
7272 static void
7273 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7274 			      __rte_unused struct cmdline *cl,
7275 			      void *data)
7276 {
7277 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7278 	cmdline_parse_inst_t *cmd = data;
7279 	struct rte_eth_fc_conf fc_conf;
7280 	int rx_fc_en = 0;
7281 	int tx_fc_en = 0;
7282 	int ret;
7283 
7284 	/*
7285 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7286 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7287 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7288 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7289 	 */
7290 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7291 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7292 	};
7293 
7294 	/* Partial command line, retrieve current configuration */
7295 	if (cmd) {
7296 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7297 		if (ret != 0) {
7298 			printf("cannot get current flow ctrl parameters, return"
7299 			       "code = %d\n", ret);
7300 			return;
7301 		}
7302 
7303 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7304 		    (fc_conf.mode == RTE_FC_FULL))
7305 			rx_fc_en = 1;
7306 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7307 		    (fc_conf.mode == RTE_FC_FULL))
7308 			tx_fc_en = 1;
7309 	}
7310 
7311 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7312 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7313 
7314 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7315 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7316 
7317 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7318 
7319 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7320 		fc_conf.high_water = res->high_water;
7321 
7322 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7323 		fc_conf.low_water = res->low_water;
7324 
7325 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7326 		fc_conf.pause_time = res->pause_time;
7327 
7328 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7329 		fc_conf.send_xon = res->send_xon;
7330 
7331 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7332 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7333 			fc_conf.mac_ctrl_frame_fwd = 1;
7334 		else
7335 			fc_conf.mac_ctrl_frame_fwd = 0;
7336 	}
7337 
7338 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7339 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7340 
7341 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7342 	if (ret != 0)
7343 		printf("bad flow contrl parameter, return code = %d \n", ret);
7344 }
7345 
7346 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7347 struct cmd_priority_flow_ctrl_set_result {
7348 	cmdline_fixed_string_t set;
7349 	cmdline_fixed_string_t pfc_ctrl;
7350 	cmdline_fixed_string_t rx;
7351 	cmdline_fixed_string_t rx_pfc_mode;
7352 	cmdline_fixed_string_t tx;
7353 	cmdline_fixed_string_t tx_pfc_mode;
7354 	uint32_t high_water;
7355 	uint32_t low_water;
7356 	uint16_t pause_time;
7357 	uint8_t  priority;
7358 	portid_t port_id;
7359 };
7360 
7361 static void
7362 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7363 		       __rte_unused struct cmdline *cl,
7364 		       __rte_unused void *data)
7365 {
7366 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7367 	struct rte_eth_pfc_conf pfc_conf;
7368 	int rx_fc_enable, tx_fc_enable;
7369 	int ret;
7370 
7371 	/*
7372 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7373 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7374 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7375 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7376 	 */
7377 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7378 		{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7379 	};
7380 
7381 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7382 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7383 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7384 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7385 	pfc_conf.fc.high_water = res->high_water;
7386 	pfc_conf.fc.low_water  = res->low_water;
7387 	pfc_conf.fc.pause_time = res->pause_time;
7388 	pfc_conf.priority      = res->priority;
7389 
7390 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7391 	if (ret != 0)
7392 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7393 }
7394 
7395 cmdline_parse_token_string_t cmd_pfc_set_set =
7396 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7397 				set, "set");
7398 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7399 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7400 				pfc_ctrl, "pfc_ctrl");
7401 cmdline_parse_token_string_t cmd_pfc_set_rx =
7402 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7403 				rx, "rx");
7404 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7405 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7406 				rx_pfc_mode, "on#off");
7407 cmdline_parse_token_string_t cmd_pfc_set_tx =
7408 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7409 				tx, "tx");
7410 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7411 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7412 				tx_pfc_mode, "on#off");
7413 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7414 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7415 				high_water, RTE_UINT32);
7416 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7417 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7418 				low_water, RTE_UINT32);
7419 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7420 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7421 				pause_time, RTE_UINT16);
7422 cmdline_parse_token_num_t cmd_pfc_set_priority =
7423 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7424 				priority, RTE_UINT8);
7425 cmdline_parse_token_num_t cmd_pfc_set_portid =
7426 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7427 				port_id, RTE_UINT16);
7428 
7429 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7430 	.f = cmd_priority_flow_ctrl_set_parsed,
7431 	.data = NULL,
7432 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7433 		"<pause_time> <priority> <port_id>: "
7434 		"Configure the Ethernet priority flow control",
7435 	.tokens = {
7436 		(void *)&cmd_pfc_set_set,
7437 		(void *)&cmd_pfc_set_flow_ctrl,
7438 		(void *)&cmd_pfc_set_rx,
7439 		(void *)&cmd_pfc_set_rx_mode,
7440 		(void *)&cmd_pfc_set_tx,
7441 		(void *)&cmd_pfc_set_tx_mode,
7442 		(void *)&cmd_pfc_set_high_water,
7443 		(void *)&cmd_pfc_set_low_water,
7444 		(void *)&cmd_pfc_set_pause_time,
7445 		(void *)&cmd_pfc_set_priority,
7446 		(void *)&cmd_pfc_set_portid,
7447 		NULL,
7448 	},
7449 };
7450 
7451 /* *** RESET CONFIGURATION *** */
7452 struct cmd_reset_result {
7453 	cmdline_fixed_string_t reset;
7454 	cmdline_fixed_string_t def;
7455 };
7456 
7457 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7458 			     struct cmdline *cl,
7459 			     __rte_unused void *data)
7460 {
7461 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7462 	set_def_fwd_config();
7463 }
7464 
7465 cmdline_parse_token_string_t cmd_reset_set =
7466 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7467 cmdline_parse_token_string_t cmd_reset_def =
7468 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7469 				 "default");
7470 
7471 cmdline_parse_inst_t cmd_reset = {
7472 	.f = cmd_reset_parsed,
7473 	.data = NULL,
7474 	.help_str = "set default: Reset default forwarding configuration",
7475 	.tokens = {
7476 		(void *)&cmd_reset_set,
7477 		(void *)&cmd_reset_def,
7478 		NULL,
7479 	},
7480 };
7481 
7482 /* *** START FORWARDING *** */
7483 struct cmd_start_result {
7484 	cmdline_fixed_string_t start;
7485 };
7486 
7487 cmdline_parse_token_string_t cmd_start_start =
7488 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7489 
7490 static void cmd_start_parsed(__rte_unused void *parsed_result,
7491 			     __rte_unused struct cmdline *cl,
7492 			     __rte_unused void *data)
7493 {
7494 	start_packet_forwarding(0);
7495 }
7496 
7497 cmdline_parse_inst_t cmd_start = {
7498 	.f = cmd_start_parsed,
7499 	.data = NULL,
7500 	.help_str = "start: Start packet forwarding",
7501 	.tokens = {
7502 		(void *)&cmd_start_start,
7503 		NULL,
7504 	},
7505 };
7506 
7507 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7508 struct cmd_start_tx_first_result {
7509 	cmdline_fixed_string_t start;
7510 	cmdline_fixed_string_t tx_first;
7511 };
7512 
7513 static void
7514 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7515 			  __rte_unused struct cmdline *cl,
7516 			  __rte_unused void *data)
7517 {
7518 	start_packet_forwarding(1);
7519 }
7520 
7521 cmdline_parse_token_string_t cmd_start_tx_first_start =
7522 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7523 				 "start");
7524 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7525 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7526 				 tx_first, "tx_first");
7527 
7528 cmdline_parse_inst_t cmd_start_tx_first = {
7529 	.f = cmd_start_tx_first_parsed,
7530 	.data = NULL,
7531 	.help_str = "start tx_first: Start packet forwarding, "
7532 		"after sending 1 burst of packets",
7533 	.tokens = {
7534 		(void *)&cmd_start_tx_first_start,
7535 		(void *)&cmd_start_tx_first_tx_first,
7536 		NULL,
7537 	},
7538 };
7539 
7540 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7541 struct cmd_start_tx_first_n_result {
7542 	cmdline_fixed_string_t start;
7543 	cmdline_fixed_string_t tx_first;
7544 	uint32_t tx_num;
7545 };
7546 
7547 static void
7548 cmd_start_tx_first_n_parsed(void *parsed_result,
7549 			  __rte_unused struct cmdline *cl,
7550 			  __rte_unused void *data)
7551 {
7552 	struct cmd_start_tx_first_n_result *res = parsed_result;
7553 
7554 	start_packet_forwarding(res->tx_num);
7555 }
7556 
7557 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7558 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7559 			start, "start");
7560 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7561 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7562 			tx_first, "tx_first");
7563 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7564 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7565 			tx_num, RTE_UINT32);
7566 
7567 cmdline_parse_inst_t cmd_start_tx_first_n = {
7568 	.f = cmd_start_tx_first_n_parsed,
7569 	.data = NULL,
7570 	.help_str = "start tx_first <num>: "
7571 		"packet forwarding, after sending <num> bursts of packets",
7572 	.tokens = {
7573 		(void *)&cmd_start_tx_first_n_start,
7574 		(void *)&cmd_start_tx_first_n_tx_first,
7575 		(void *)&cmd_start_tx_first_n_tx_num,
7576 		NULL,
7577 	},
7578 };
7579 
7580 /* *** SET LINK UP *** */
7581 struct cmd_set_link_up_result {
7582 	cmdline_fixed_string_t set;
7583 	cmdline_fixed_string_t link_up;
7584 	cmdline_fixed_string_t port;
7585 	portid_t port_id;
7586 };
7587 
7588 cmdline_parse_token_string_t cmd_set_link_up_set =
7589 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7590 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7591 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7592 				"link-up");
7593 cmdline_parse_token_string_t cmd_set_link_up_port =
7594 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7595 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7596 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7597 				RTE_UINT16);
7598 
7599 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7600 			     __rte_unused struct cmdline *cl,
7601 			     __rte_unused void *data)
7602 {
7603 	struct cmd_set_link_up_result *res = parsed_result;
7604 	dev_set_link_up(res->port_id);
7605 }
7606 
7607 cmdline_parse_inst_t cmd_set_link_up = {
7608 	.f = cmd_set_link_up_parsed,
7609 	.data = NULL,
7610 	.help_str = "set link-up port <port id>",
7611 	.tokens = {
7612 		(void *)&cmd_set_link_up_set,
7613 		(void *)&cmd_set_link_up_link_up,
7614 		(void *)&cmd_set_link_up_port,
7615 		(void *)&cmd_set_link_up_port_id,
7616 		NULL,
7617 	},
7618 };
7619 
7620 /* *** SET LINK DOWN *** */
7621 struct cmd_set_link_down_result {
7622 	cmdline_fixed_string_t set;
7623 	cmdline_fixed_string_t link_down;
7624 	cmdline_fixed_string_t port;
7625 	portid_t port_id;
7626 };
7627 
7628 cmdline_parse_token_string_t cmd_set_link_down_set =
7629 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7630 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7631 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7632 				"link-down");
7633 cmdline_parse_token_string_t cmd_set_link_down_port =
7634 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7635 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7636 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7637 				RTE_UINT16);
7638 
7639 static void cmd_set_link_down_parsed(
7640 				__rte_unused void *parsed_result,
7641 				__rte_unused struct cmdline *cl,
7642 				__rte_unused void *data)
7643 {
7644 	struct cmd_set_link_down_result *res = parsed_result;
7645 	dev_set_link_down(res->port_id);
7646 }
7647 
7648 cmdline_parse_inst_t cmd_set_link_down = {
7649 	.f = cmd_set_link_down_parsed,
7650 	.data = NULL,
7651 	.help_str = "set link-down port <port id>",
7652 	.tokens = {
7653 		(void *)&cmd_set_link_down_set,
7654 		(void *)&cmd_set_link_down_link_down,
7655 		(void *)&cmd_set_link_down_port,
7656 		(void *)&cmd_set_link_down_port_id,
7657 		NULL,
7658 	},
7659 };
7660 
7661 /* *** SHOW CFG *** */
7662 struct cmd_showcfg_result {
7663 	cmdline_fixed_string_t show;
7664 	cmdline_fixed_string_t cfg;
7665 	cmdline_fixed_string_t what;
7666 };
7667 
7668 static void cmd_showcfg_parsed(void *parsed_result,
7669 			       __rte_unused struct cmdline *cl,
7670 			       __rte_unused void *data)
7671 {
7672 	struct cmd_showcfg_result *res = parsed_result;
7673 	if (!strcmp(res->what, "rxtx"))
7674 		rxtx_config_display();
7675 	else if (!strcmp(res->what, "cores"))
7676 		fwd_lcores_config_display();
7677 	else if (!strcmp(res->what, "fwd"))
7678 		pkt_fwd_config_display(&cur_fwd_config);
7679 	else if (!strcmp(res->what, "rxoffs"))
7680 		show_rx_pkt_offsets();
7681 	else if (!strcmp(res->what, "rxpkts"))
7682 		show_rx_pkt_segments();
7683 	else if (!strcmp(res->what, "txpkts"))
7684 		show_tx_pkt_segments();
7685 	else if (!strcmp(res->what, "txtimes"))
7686 		show_tx_pkt_times();
7687 }
7688 
7689 cmdline_parse_token_string_t cmd_showcfg_show =
7690 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7691 cmdline_parse_token_string_t cmd_showcfg_port =
7692 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7693 cmdline_parse_token_string_t cmd_showcfg_what =
7694 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7695 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7696 
7697 cmdline_parse_inst_t cmd_showcfg = {
7698 	.f = cmd_showcfg_parsed,
7699 	.data = NULL,
7700 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7701 	.tokens = {
7702 		(void *)&cmd_showcfg_show,
7703 		(void *)&cmd_showcfg_port,
7704 		(void *)&cmd_showcfg_what,
7705 		NULL,
7706 	},
7707 };
7708 
7709 /* *** SHOW ALL PORT INFO *** */
7710 struct cmd_showportall_result {
7711 	cmdline_fixed_string_t show;
7712 	cmdline_fixed_string_t port;
7713 	cmdline_fixed_string_t what;
7714 	cmdline_fixed_string_t all;
7715 };
7716 
7717 static void cmd_showportall_parsed(void *parsed_result,
7718 				__rte_unused struct cmdline *cl,
7719 				__rte_unused void *data)
7720 {
7721 	portid_t i;
7722 
7723 	struct cmd_showportall_result *res = parsed_result;
7724 	if (!strcmp(res->show, "clear")) {
7725 		if (!strcmp(res->what, "stats"))
7726 			RTE_ETH_FOREACH_DEV(i)
7727 				nic_stats_clear(i);
7728 		else if (!strcmp(res->what, "xstats"))
7729 			RTE_ETH_FOREACH_DEV(i)
7730 				nic_xstats_clear(i);
7731 	} else if (!strcmp(res->what, "info"))
7732 		RTE_ETH_FOREACH_DEV(i)
7733 			port_infos_display(i);
7734 	else if (!strcmp(res->what, "summary")) {
7735 		port_summary_header_display();
7736 		RTE_ETH_FOREACH_DEV(i)
7737 			port_summary_display(i);
7738 	}
7739 	else if (!strcmp(res->what, "stats"))
7740 		RTE_ETH_FOREACH_DEV(i)
7741 			nic_stats_display(i);
7742 	else if (!strcmp(res->what, "xstats"))
7743 		RTE_ETH_FOREACH_DEV(i)
7744 			nic_xstats_display(i);
7745 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7746 	else if (!strcmp(res->what, "fdir"))
7747 		RTE_ETH_FOREACH_DEV(i)
7748 			fdir_get_infos(i);
7749 #endif
7750 	else if (!strcmp(res->what, "dcb_tc"))
7751 		RTE_ETH_FOREACH_DEV(i)
7752 			port_dcb_info_display(i);
7753 }
7754 
7755 cmdline_parse_token_string_t cmd_showportall_show =
7756 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7757 				 "show#clear");
7758 cmdline_parse_token_string_t cmd_showportall_port =
7759 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7760 cmdline_parse_token_string_t cmd_showportall_what =
7761 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7762 				 "info#summary#stats#xstats#fdir#dcb_tc");
7763 cmdline_parse_token_string_t cmd_showportall_all =
7764 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7765 cmdline_parse_inst_t cmd_showportall = {
7766 	.f = cmd_showportall_parsed,
7767 	.data = NULL,
7768 	.help_str = "show|clear port "
7769 		"info|summary|stats|xstats|fdir|dcb_tc all",
7770 	.tokens = {
7771 		(void *)&cmd_showportall_show,
7772 		(void *)&cmd_showportall_port,
7773 		(void *)&cmd_showportall_what,
7774 		(void *)&cmd_showportall_all,
7775 		NULL,
7776 	},
7777 };
7778 
7779 /* *** SHOW PORT INFO *** */
7780 struct cmd_showport_result {
7781 	cmdline_fixed_string_t show;
7782 	cmdline_fixed_string_t port;
7783 	cmdline_fixed_string_t what;
7784 	uint16_t portnum;
7785 };
7786 
7787 static void cmd_showport_parsed(void *parsed_result,
7788 				__rte_unused struct cmdline *cl,
7789 				__rte_unused void *data)
7790 {
7791 	struct cmd_showport_result *res = parsed_result;
7792 	if (!strcmp(res->show, "clear")) {
7793 		if (!strcmp(res->what, "stats"))
7794 			nic_stats_clear(res->portnum);
7795 		else if (!strcmp(res->what, "xstats"))
7796 			nic_xstats_clear(res->portnum);
7797 	} else if (!strcmp(res->what, "info"))
7798 		port_infos_display(res->portnum);
7799 	else if (!strcmp(res->what, "summary")) {
7800 		port_summary_header_display();
7801 		port_summary_display(res->portnum);
7802 	}
7803 	else if (!strcmp(res->what, "stats"))
7804 		nic_stats_display(res->portnum);
7805 	else if (!strcmp(res->what, "xstats"))
7806 		nic_xstats_display(res->portnum);
7807 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7808 	else if (!strcmp(res->what, "fdir"))
7809 		 fdir_get_infos(res->portnum);
7810 #endif
7811 	else if (!strcmp(res->what, "dcb_tc"))
7812 		port_dcb_info_display(res->portnum);
7813 }
7814 
7815 cmdline_parse_token_string_t cmd_showport_show =
7816 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7817 				 "show#clear");
7818 cmdline_parse_token_string_t cmd_showport_port =
7819 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7820 cmdline_parse_token_string_t cmd_showport_what =
7821 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7822 				 "info#summary#stats#xstats#fdir#dcb_tc");
7823 cmdline_parse_token_num_t cmd_showport_portnum =
7824 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7825 
7826 cmdline_parse_inst_t cmd_showport = {
7827 	.f = cmd_showport_parsed,
7828 	.data = NULL,
7829 	.help_str = "show|clear port "
7830 		"info|summary|stats|xstats|fdir|dcb_tc "
7831 		"<port_id>",
7832 	.tokens = {
7833 		(void *)&cmd_showport_show,
7834 		(void *)&cmd_showport_port,
7835 		(void *)&cmd_showport_what,
7836 		(void *)&cmd_showport_portnum,
7837 		NULL,
7838 	},
7839 };
7840 
7841 /* *** SHOW DEVICE INFO *** */
7842 struct cmd_showdevice_result {
7843 	cmdline_fixed_string_t show;
7844 	cmdline_fixed_string_t device;
7845 	cmdline_fixed_string_t what;
7846 	cmdline_fixed_string_t identifier;
7847 };
7848 
7849 static void cmd_showdevice_parsed(void *parsed_result,
7850 				__rte_unused struct cmdline *cl,
7851 				__rte_unused void *data)
7852 {
7853 	struct cmd_showdevice_result *res = parsed_result;
7854 	if (!strcmp(res->what, "info")) {
7855 		if (!strcmp(res->identifier, "all"))
7856 			device_infos_display(NULL);
7857 		else
7858 			device_infos_display(res->identifier);
7859 	}
7860 }
7861 
7862 cmdline_parse_token_string_t cmd_showdevice_show =
7863 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7864 				 "show");
7865 cmdline_parse_token_string_t cmd_showdevice_device =
7866 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7867 cmdline_parse_token_string_t cmd_showdevice_what =
7868 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7869 				 "info");
7870 cmdline_parse_token_string_t cmd_showdevice_identifier =
7871 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7872 			identifier, NULL);
7873 
7874 cmdline_parse_inst_t cmd_showdevice = {
7875 	.f = cmd_showdevice_parsed,
7876 	.data = NULL,
7877 	.help_str = "show device info <identifier>|all",
7878 	.tokens = {
7879 		(void *)&cmd_showdevice_show,
7880 		(void *)&cmd_showdevice_device,
7881 		(void *)&cmd_showdevice_what,
7882 		(void *)&cmd_showdevice_identifier,
7883 		NULL,
7884 	},
7885 };
7886 
7887 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7888 struct cmd_showeeprom_result {
7889 	cmdline_fixed_string_t show;
7890 	cmdline_fixed_string_t port;
7891 	uint16_t portnum;
7892 	cmdline_fixed_string_t type;
7893 };
7894 
7895 static void cmd_showeeprom_parsed(void *parsed_result,
7896 		__rte_unused struct cmdline *cl,
7897 		__rte_unused void *data)
7898 {
7899 	struct cmd_showeeprom_result *res = parsed_result;
7900 
7901 	if (!strcmp(res->type, "eeprom"))
7902 		port_eeprom_display(res->portnum);
7903 	else if (!strcmp(res->type, "module_eeprom"))
7904 		port_module_eeprom_display(res->portnum);
7905 	else
7906 		printf("Unknown argument\n");
7907 }
7908 
7909 cmdline_parse_token_string_t cmd_showeeprom_show =
7910 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7911 cmdline_parse_token_string_t cmd_showeeprom_port =
7912 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7913 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7914 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7915 			RTE_UINT16);
7916 cmdline_parse_token_string_t cmd_showeeprom_type =
7917 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7918 
7919 cmdline_parse_inst_t cmd_showeeprom = {
7920 	.f = cmd_showeeprom_parsed,
7921 	.data = NULL,
7922 	.help_str = "show port <port_id> module_eeprom|eeprom",
7923 	.tokens = {
7924 		(void *)&cmd_showeeprom_show,
7925 		(void *)&cmd_showeeprom_port,
7926 		(void *)&cmd_showeeprom_portnum,
7927 		(void *)&cmd_showeeprom_type,
7928 		NULL,
7929 	},
7930 };
7931 
7932 /* *** SHOW QUEUE INFO *** */
7933 struct cmd_showqueue_result {
7934 	cmdline_fixed_string_t show;
7935 	cmdline_fixed_string_t type;
7936 	cmdline_fixed_string_t what;
7937 	uint16_t portnum;
7938 	uint16_t queuenum;
7939 };
7940 
7941 static void
7942 cmd_showqueue_parsed(void *parsed_result,
7943 	__rte_unused struct cmdline *cl,
7944 	__rte_unused void *data)
7945 {
7946 	struct cmd_showqueue_result *res = parsed_result;
7947 
7948 	if (!strcmp(res->type, "rxq"))
7949 		rx_queue_infos_display(res->portnum, res->queuenum);
7950 	else if (!strcmp(res->type, "txq"))
7951 		tx_queue_infos_display(res->portnum, res->queuenum);
7952 }
7953 
7954 cmdline_parse_token_string_t cmd_showqueue_show =
7955 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7956 cmdline_parse_token_string_t cmd_showqueue_type =
7957 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7958 cmdline_parse_token_string_t cmd_showqueue_what =
7959 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7960 cmdline_parse_token_num_t cmd_showqueue_portnum =
7961 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7962 		RTE_UINT16);
7963 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7964 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7965 		RTE_UINT16);
7966 
7967 cmdline_parse_inst_t cmd_showqueue = {
7968 	.f = cmd_showqueue_parsed,
7969 	.data = NULL,
7970 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7971 	.tokens = {
7972 		(void *)&cmd_showqueue_show,
7973 		(void *)&cmd_showqueue_type,
7974 		(void *)&cmd_showqueue_what,
7975 		(void *)&cmd_showqueue_portnum,
7976 		(void *)&cmd_showqueue_queuenum,
7977 		NULL,
7978 	},
7979 };
7980 
7981 /* show/clear fwd engine statistics */
7982 struct fwd_result {
7983 	cmdline_fixed_string_t action;
7984 	cmdline_fixed_string_t fwd;
7985 	cmdline_fixed_string_t stats;
7986 	cmdline_fixed_string_t all;
7987 };
7988 
7989 cmdline_parse_token_string_t cmd_fwd_action =
7990 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7991 cmdline_parse_token_string_t cmd_fwd_fwd =
7992 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7993 cmdline_parse_token_string_t cmd_fwd_stats =
7994 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7995 cmdline_parse_token_string_t cmd_fwd_all =
7996 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7997 
7998 static void
7999 cmd_showfwdall_parsed(void *parsed_result,
8000 		      __rte_unused struct cmdline *cl,
8001 		      __rte_unused void *data)
8002 {
8003 	struct fwd_result *res = parsed_result;
8004 
8005 	if (!strcmp(res->action, "show"))
8006 		fwd_stats_display();
8007 	else
8008 		fwd_stats_reset();
8009 }
8010 
8011 static cmdline_parse_inst_t cmd_showfwdall = {
8012 	.f = cmd_showfwdall_parsed,
8013 	.data = NULL,
8014 	.help_str = "show|clear fwd stats all",
8015 	.tokens = {
8016 		(void *)&cmd_fwd_action,
8017 		(void *)&cmd_fwd_fwd,
8018 		(void *)&cmd_fwd_stats,
8019 		(void *)&cmd_fwd_all,
8020 		NULL,
8021 	},
8022 };
8023 
8024 /* *** READ PORT REGISTER *** */
8025 struct cmd_read_reg_result {
8026 	cmdline_fixed_string_t read;
8027 	cmdline_fixed_string_t reg;
8028 	portid_t port_id;
8029 	uint32_t reg_off;
8030 };
8031 
8032 static void
8033 cmd_read_reg_parsed(void *parsed_result,
8034 		    __rte_unused struct cmdline *cl,
8035 		    __rte_unused void *data)
8036 {
8037 	struct cmd_read_reg_result *res = parsed_result;
8038 	port_reg_display(res->port_id, res->reg_off);
8039 }
8040 
8041 cmdline_parse_token_string_t cmd_read_reg_read =
8042 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8043 cmdline_parse_token_string_t cmd_read_reg_reg =
8044 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8045 cmdline_parse_token_num_t cmd_read_reg_port_id =
8046 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8047 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8048 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8049 
8050 cmdline_parse_inst_t cmd_read_reg = {
8051 	.f = cmd_read_reg_parsed,
8052 	.data = NULL,
8053 	.help_str = "read reg <port_id> <reg_off>",
8054 	.tokens = {
8055 		(void *)&cmd_read_reg_read,
8056 		(void *)&cmd_read_reg_reg,
8057 		(void *)&cmd_read_reg_port_id,
8058 		(void *)&cmd_read_reg_reg_off,
8059 		NULL,
8060 	},
8061 };
8062 
8063 /* *** READ PORT REGISTER BIT FIELD *** */
8064 struct cmd_read_reg_bit_field_result {
8065 	cmdline_fixed_string_t read;
8066 	cmdline_fixed_string_t regfield;
8067 	portid_t port_id;
8068 	uint32_t reg_off;
8069 	uint8_t bit1_pos;
8070 	uint8_t bit2_pos;
8071 };
8072 
8073 static void
8074 cmd_read_reg_bit_field_parsed(void *parsed_result,
8075 			      __rte_unused struct cmdline *cl,
8076 			      __rte_unused void *data)
8077 {
8078 	struct cmd_read_reg_bit_field_result *res = parsed_result;
8079 	port_reg_bit_field_display(res->port_id, res->reg_off,
8080 				   res->bit1_pos, res->bit2_pos);
8081 }
8082 
8083 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8084 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8085 				 "read");
8086 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8087 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8088 				 regfield, "regfield");
8089 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8090 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8091 			      RTE_UINT16);
8092 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8093 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8094 			      RTE_UINT32);
8095 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8096 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8097 			      RTE_UINT8);
8098 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8099 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8100 			      RTE_UINT8);
8101 
8102 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8103 	.f = cmd_read_reg_bit_field_parsed,
8104 	.data = NULL,
8105 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8106 	"Read register bit field between bit_x and bit_y included",
8107 	.tokens = {
8108 		(void *)&cmd_read_reg_bit_field_read,
8109 		(void *)&cmd_read_reg_bit_field_regfield,
8110 		(void *)&cmd_read_reg_bit_field_port_id,
8111 		(void *)&cmd_read_reg_bit_field_reg_off,
8112 		(void *)&cmd_read_reg_bit_field_bit1_pos,
8113 		(void *)&cmd_read_reg_bit_field_bit2_pos,
8114 		NULL,
8115 	},
8116 };
8117 
8118 /* *** READ PORT REGISTER BIT *** */
8119 struct cmd_read_reg_bit_result {
8120 	cmdline_fixed_string_t read;
8121 	cmdline_fixed_string_t regbit;
8122 	portid_t port_id;
8123 	uint32_t reg_off;
8124 	uint8_t bit_pos;
8125 };
8126 
8127 static void
8128 cmd_read_reg_bit_parsed(void *parsed_result,
8129 			__rte_unused struct cmdline *cl,
8130 			__rte_unused void *data)
8131 {
8132 	struct cmd_read_reg_bit_result *res = parsed_result;
8133 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8134 }
8135 
8136 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8137 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8138 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8139 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8140 				 regbit, "regbit");
8141 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8142 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8143 				 RTE_UINT16);
8144 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8145 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8146 				 RTE_UINT32);
8147 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8148 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8149 				 RTE_UINT8);
8150 
8151 cmdline_parse_inst_t cmd_read_reg_bit = {
8152 	.f = cmd_read_reg_bit_parsed,
8153 	.data = NULL,
8154 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8155 	.tokens = {
8156 		(void *)&cmd_read_reg_bit_read,
8157 		(void *)&cmd_read_reg_bit_regbit,
8158 		(void *)&cmd_read_reg_bit_port_id,
8159 		(void *)&cmd_read_reg_bit_reg_off,
8160 		(void *)&cmd_read_reg_bit_bit_pos,
8161 		NULL,
8162 	},
8163 };
8164 
8165 /* *** WRITE PORT REGISTER *** */
8166 struct cmd_write_reg_result {
8167 	cmdline_fixed_string_t write;
8168 	cmdline_fixed_string_t reg;
8169 	portid_t port_id;
8170 	uint32_t reg_off;
8171 	uint32_t value;
8172 };
8173 
8174 static void
8175 cmd_write_reg_parsed(void *parsed_result,
8176 		     __rte_unused struct cmdline *cl,
8177 		     __rte_unused void *data)
8178 {
8179 	struct cmd_write_reg_result *res = parsed_result;
8180 	port_reg_set(res->port_id, res->reg_off, res->value);
8181 }
8182 
8183 cmdline_parse_token_string_t cmd_write_reg_write =
8184 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8185 cmdline_parse_token_string_t cmd_write_reg_reg =
8186 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8187 cmdline_parse_token_num_t cmd_write_reg_port_id =
8188 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8189 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8190 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8191 cmdline_parse_token_num_t cmd_write_reg_value =
8192 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8193 
8194 cmdline_parse_inst_t cmd_write_reg = {
8195 	.f = cmd_write_reg_parsed,
8196 	.data = NULL,
8197 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8198 	.tokens = {
8199 		(void *)&cmd_write_reg_write,
8200 		(void *)&cmd_write_reg_reg,
8201 		(void *)&cmd_write_reg_port_id,
8202 		(void *)&cmd_write_reg_reg_off,
8203 		(void *)&cmd_write_reg_value,
8204 		NULL,
8205 	},
8206 };
8207 
8208 /* *** WRITE PORT REGISTER BIT FIELD *** */
8209 struct cmd_write_reg_bit_field_result {
8210 	cmdline_fixed_string_t write;
8211 	cmdline_fixed_string_t regfield;
8212 	portid_t port_id;
8213 	uint32_t reg_off;
8214 	uint8_t bit1_pos;
8215 	uint8_t bit2_pos;
8216 	uint32_t value;
8217 };
8218 
8219 static void
8220 cmd_write_reg_bit_field_parsed(void *parsed_result,
8221 			       __rte_unused struct cmdline *cl,
8222 			       __rte_unused void *data)
8223 {
8224 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8225 	port_reg_bit_field_set(res->port_id, res->reg_off,
8226 			  res->bit1_pos, res->bit2_pos, res->value);
8227 }
8228 
8229 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8230 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8231 				 "write");
8232 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8233 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8234 				 regfield, "regfield");
8235 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8236 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8237 			      RTE_UINT16);
8238 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8239 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8240 			      RTE_UINT32);
8241 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8242 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8243 			      RTE_UINT8);
8244 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8245 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8246 			      RTE_UINT8);
8247 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8248 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8249 			      RTE_UINT32);
8250 
8251 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8252 	.f = cmd_write_reg_bit_field_parsed,
8253 	.data = NULL,
8254 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8255 		"<reg_value>: "
8256 		"Set register bit field between bit_x and bit_y included",
8257 	.tokens = {
8258 		(void *)&cmd_write_reg_bit_field_write,
8259 		(void *)&cmd_write_reg_bit_field_regfield,
8260 		(void *)&cmd_write_reg_bit_field_port_id,
8261 		(void *)&cmd_write_reg_bit_field_reg_off,
8262 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8263 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8264 		(void *)&cmd_write_reg_bit_field_value,
8265 		NULL,
8266 	},
8267 };
8268 
8269 /* *** WRITE PORT REGISTER BIT *** */
8270 struct cmd_write_reg_bit_result {
8271 	cmdline_fixed_string_t write;
8272 	cmdline_fixed_string_t regbit;
8273 	portid_t port_id;
8274 	uint32_t reg_off;
8275 	uint8_t bit_pos;
8276 	uint8_t value;
8277 };
8278 
8279 static void
8280 cmd_write_reg_bit_parsed(void *parsed_result,
8281 			 __rte_unused struct cmdline *cl,
8282 			 __rte_unused void *data)
8283 {
8284 	struct cmd_write_reg_bit_result *res = parsed_result;
8285 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8286 }
8287 
8288 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8289 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8290 				 "write");
8291 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8292 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8293 				 regbit, "regbit");
8294 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8295 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8296 				 RTE_UINT16);
8297 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8298 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8299 				 RTE_UINT32);
8300 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8301 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8302 				 RTE_UINT8);
8303 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8304 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8305 				 RTE_UINT8);
8306 
8307 cmdline_parse_inst_t cmd_write_reg_bit = {
8308 	.f = cmd_write_reg_bit_parsed,
8309 	.data = NULL,
8310 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8311 		"0 <= bit_x <= 31",
8312 	.tokens = {
8313 		(void *)&cmd_write_reg_bit_write,
8314 		(void *)&cmd_write_reg_bit_regbit,
8315 		(void *)&cmd_write_reg_bit_port_id,
8316 		(void *)&cmd_write_reg_bit_reg_off,
8317 		(void *)&cmd_write_reg_bit_bit_pos,
8318 		(void *)&cmd_write_reg_bit_value,
8319 		NULL,
8320 	},
8321 };
8322 
8323 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8324 struct cmd_read_rxd_txd_result {
8325 	cmdline_fixed_string_t read;
8326 	cmdline_fixed_string_t rxd_txd;
8327 	portid_t port_id;
8328 	uint16_t queue_id;
8329 	uint16_t desc_id;
8330 };
8331 
8332 static void
8333 cmd_read_rxd_txd_parsed(void *parsed_result,
8334 			__rte_unused struct cmdline *cl,
8335 			__rte_unused void *data)
8336 {
8337 	struct cmd_read_rxd_txd_result *res = parsed_result;
8338 
8339 	if (!strcmp(res->rxd_txd, "rxd"))
8340 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8341 	else if (!strcmp(res->rxd_txd, "txd"))
8342 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8343 }
8344 
8345 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8346 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8347 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8348 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8349 				 "rxd#txd");
8350 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8351 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8352 				 RTE_UINT16);
8353 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8354 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8355 				 RTE_UINT16);
8356 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8357 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8358 				 RTE_UINT16);
8359 
8360 cmdline_parse_inst_t cmd_read_rxd_txd = {
8361 	.f = cmd_read_rxd_txd_parsed,
8362 	.data = NULL,
8363 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8364 	.tokens = {
8365 		(void *)&cmd_read_rxd_txd_read,
8366 		(void *)&cmd_read_rxd_txd_rxd_txd,
8367 		(void *)&cmd_read_rxd_txd_port_id,
8368 		(void *)&cmd_read_rxd_txd_queue_id,
8369 		(void *)&cmd_read_rxd_txd_desc_id,
8370 		NULL,
8371 	},
8372 };
8373 
8374 /* *** QUIT *** */
8375 struct cmd_quit_result {
8376 	cmdline_fixed_string_t quit;
8377 };
8378 
8379 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8380 			    struct cmdline *cl,
8381 			    __rte_unused void *data)
8382 {
8383 	cmdline_quit(cl);
8384 }
8385 
8386 cmdline_parse_token_string_t cmd_quit_quit =
8387 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8388 
8389 cmdline_parse_inst_t cmd_quit = {
8390 	.f = cmd_quit_parsed,
8391 	.data = NULL,
8392 	.help_str = "quit: Exit application",
8393 	.tokens = {
8394 		(void *)&cmd_quit_quit,
8395 		NULL,
8396 	},
8397 };
8398 
8399 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8400 struct cmd_mac_addr_result {
8401 	cmdline_fixed_string_t mac_addr_cmd;
8402 	cmdline_fixed_string_t what;
8403 	uint16_t port_num;
8404 	struct rte_ether_addr address;
8405 };
8406 
8407 static void cmd_mac_addr_parsed(void *parsed_result,
8408 		__rte_unused struct cmdline *cl,
8409 		__rte_unused void *data)
8410 {
8411 	struct cmd_mac_addr_result *res = parsed_result;
8412 	int ret;
8413 
8414 	if (strcmp(res->what, "add") == 0)
8415 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8416 	else if (strcmp(res->what, "set") == 0)
8417 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8418 						       &res->address);
8419 	else
8420 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8421 
8422 	/* check the return value and print it if is < 0 */
8423 	if(ret < 0)
8424 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8425 
8426 }
8427 
8428 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8429 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8430 				"mac_addr");
8431 cmdline_parse_token_string_t cmd_mac_addr_what =
8432 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8433 				"add#remove#set");
8434 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8435 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8436 					RTE_UINT16);
8437 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8438 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8439 
8440 cmdline_parse_inst_t cmd_mac_addr = {
8441 	.f = cmd_mac_addr_parsed,
8442 	.data = (void *)0,
8443 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8444 			"Add/Remove/Set MAC address on port_id",
8445 	.tokens = {
8446 		(void *)&cmd_mac_addr_cmd,
8447 		(void *)&cmd_mac_addr_what,
8448 		(void *)&cmd_mac_addr_portnum,
8449 		(void *)&cmd_mac_addr_addr,
8450 		NULL,
8451 	},
8452 };
8453 
8454 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8455 struct cmd_eth_peer_result {
8456 	cmdline_fixed_string_t set;
8457 	cmdline_fixed_string_t eth_peer;
8458 	portid_t port_id;
8459 	cmdline_fixed_string_t peer_addr;
8460 };
8461 
8462 static void cmd_set_eth_peer_parsed(void *parsed_result,
8463 			__rte_unused struct cmdline *cl,
8464 			__rte_unused void *data)
8465 {
8466 		struct cmd_eth_peer_result *res = parsed_result;
8467 
8468 		if (test_done == 0) {
8469 			printf("Please stop forwarding first\n");
8470 			return;
8471 		}
8472 		if (!strcmp(res->eth_peer, "eth-peer")) {
8473 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8474 			fwd_config_setup();
8475 		}
8476 }
8477 cmdline_parse_token_string_t cmd_eth_peer_set =
8478 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8479 cmdline_parse_token_string_t cmd_eth_peer =
8480 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8481 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8482 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8483 		RTE_UINT16);
8484 cmdline_parse_token_string_t cmd_eth_peer_addr =
8485 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8486 
8487 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8488 	.f = cmd_set_eth_peer_parsed,
8489 	.data = NULL,
8490 	.help_str = "set eth-peer <port_id> <peer_mac>",
8491 	.tokens = {
8492 		(void *)&cmd_eth_peer_set,
8493 		(void *)&cmd_eth_peer,
8494 		(void *)&cmd_eth_peer_port_id,
8495 		(void *)&cmd_eth_peer_addr,
8496 		NULL,
8497 	},
8498 };
8499 
8500 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8501 struct cmd_set_qmap_result {
8502 	cmdline_fixed_string_t set;
8503 	cmdline_fixed_string_t qmap;
8504 	cmdline_fixed_string_t what;
8505 	portid_t port_id;
8506 	uint16_t queue_id;
8507 	uint8_t map_value;
8508 };
8509 
8510 static void
8511 cmd_set_qmap_parsed(void *parsed_result,
8512 		       __rte_unused struct cmdline *cl,
8513 		       __rte_unused void *data)
8514 {
8515 	struct cmd_set_qmap_result *res = parsed_result;
8516 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8517 
8518 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8519 }
8520 
8521 cmdline_parse_token_string_t cmd_setqmap_set =
8522 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8523 				 set, "set");
8524 cmdline_parse_token_string_t cmd_setqmap_qmap =
8525 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8526 				 qmap, "stat_qmap");
8527 cmdline_parse_token_string_t cmd_setqmap_what =
8528 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8529 				 what, "tx#rx");
8530 cmdline_parse_token_num_t cmd_setqmap_portid =
8531 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8532 			      port_id, RTE_UINT16);
8533 cmdline_parse_token_num_t cmd_setqmap_queueid =
8534 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8535 			      queue_id, RTE_UINT16);
8536 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8537 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8538 			      map_value, RTE_UINT8);
8539 
8540 cmdline_parse_inst_t cmd_set_qmap = {
8541 	.f = cmd_set_qmap_parsed,
8542 	.data = NULL,
8543 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8544 		"Set statistics mapping value on tx|rx queue_id of port_id",
8545 	.tokens = {
8546 		(void *)&cmd_setqmap_set,
8547 		(void *)&cmd_setqmap_qmap,
8548 		(void *)&cmd_setqmap_what,
8549 		(void *)&cmd_setqmap_portid,
8550 		(void *)&cmd_setqmap_queueid,
8551 		(void *)&cmd_setqmap_mapvalue,
8552 		NULL,
8553 	},
8554 };
8555 
8556 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8557 struct cmd_set_xstats_hide_zero_result {
8558 	cmdline_fixed_string_t keyword;
8559 	cmdline_fixed_string_t name;
8560 	cmdline_fixed_string_t on_off;
8561 };
8562 
8563 static void
8564 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8565 			__rte_unused struct cmdline *cl,
8566 			__rte_unused void *data)
8567 {
8568 	struct cmd_set_xstats_hide_zero_result *res;
8569 	uint16_t on_off = 0;
8570 
8571 	res = parsed_result;
8572 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8573 	set_xstats_hide_zero(on_off);
8574 }
8575 
8576 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8577 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8578 				 keyword, "set");
8579 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8580 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8581 				 name, "xstats-hide-zero");
8582 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8583 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8584 				 on_off, "on#off");
8585 
8586 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8587 	.f = cmd_set_xstats_hide_zero_parsed,
8588 	.data = NULL,
8589 	.help_str = "set xstats-hide-zero on|off",
8590 	.tokens = {
8591 		(void *)&cmd_set_xstats_hide_zero_keyword,
8592 		(void *)&cmd_set_xstats_hide_zero_name,
8593 		(void *)&cmd_set_xstats_hide_zero_on_off,
8594 		NULL,
8595 	},
8596 };
8597 
8598 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8599 struct cmd_set_record_core_cycles_result {
8600 	cmdline_fixed_string_t keyword;
8601 	cmdline_fixed_string_t name;
8602 	cmdline_fixed_string_t on_off;
8603 };
8604 
8605 static void
8606 cmd_set_record_core_cycles_parsed(void *parsed_result,
8607 			__rte_unused struct cmdline *cl,
8608 			__rte_unused void *data)
8609 {
8610 	struct cmd_set_record_core_cycles_result *res;
8611 	uint16_t on_off = 0;
8612 
8613 	res = parsed_result;
8614 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8615 	set_record_core_cycles(on_off);
8616 }
8617 
8618 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8619 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8620 				 keyword, "set");
8621 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8622 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8623 				 name, "record-core-cycles");
8624 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8625 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8626 				 on_off, "on#off");
8627 
8628 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8629 	.f = cmd_set_record_core_cycles_parsed,
8630 	.data = NULL,
8631 	.help_str = "set record-core-cycles on|off",
8632 	.tokens = {
8633 		(void *)&cmd_set_record_core_cycles_keyword,
8634 		(void *)&cmd_set_record_core_cycles_name,
8635 		(void *)&cmd_set_record_core_cycles_on_off,
8636 		NULL,
8637 	},
8638 };
8639 
8640 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8641 struct cmd_set_record_burst_stats_result {
8642 	cmdline_fixed_string_t keyword;
8643 	cmdline_fixed_string_t name;
8644 	cmdline_fixed_string_t on_off;
8645 };
8646 
8647 static void
8648 cmd_set_record_burst_stats_parsed(void *parsed_result,
8649 			__rte_unused struct cmdline *cl,
8650 			__rte_unused void *data)
8651 {
8652 	struct cmd_set_record_burst_stats_result *res;
8653 	uint16_t on_off = 0;
8654 
8655 	res = parsed_result;
8656 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8657 	set_record_burst_stats(on_off);
8658 }
8659 
8660 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8661 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8662 				 keyword, "set");
8663 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8664 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8665 				 name, "record-burst-stats");
8666 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8667 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8668 				 on_off, "on#off");
8669 
8670 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8671 	.f = cmd_set_record_burst_stats_parsed,
8672 	.data = NULL,
8673 	.help_str = "set record-burst-stats on|off",
8674 	.tokens = {
8675 		(void *)&cmd_set_record_burst_stats_keyword,
8676 		(void *)&cmd_set_record_burst_stats_name,
8677 		(void *)&cmd_set_record_burst_stats_on_off,
8678 		NULL,
8679 	},
8680 };
8681 
8682 /* *** CONFIGURE UNICAST HASH TABLE *** */
8683 struct cmd_set_uc_hash_table {
8684 	cmdline_fixed_string_t set;
8685 	cmdline_fixed_string_t port;
8686 	portid_t port_id;
8687 	cmdline_fixed_string_t what;
8688 	struct rte_ether_addr address;
8689 	cmdline_fixed_string_t mode;
8690 };
8691 
8692 static void
8693 cmd_set_uc_hash_parsed(void *parsed_result,
8694 		       __rte_unused struct cmdline *cl,
8695 		       __rte_unused void *data)
8696 {
8697 	int ret=0;
8698 	struct cmd_set_uc_hash_table *res = parsed_result;
8699 
8700 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8701 
8702 	if (strcmp(res->what, "uta") == 0)
8703 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8704 						&res->address,(uint8_t)is_on);
8705 	if (ret < 0)
8706 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8707 
8708 }
8709 
8710 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8711 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8712 				 set, "set");
8713 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8714 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8715 				 port, "port");
8716 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8717 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8718 			      port_id, RTE_UINT16);
8719 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8720 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8721 				 what, "uta");
8722 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8723 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8724 				address);
8725 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8726 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8727 				 mode, "on#off");
8728 
8729 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8730 	.f = cmd_set_uc_hash_parsed,
8731 	.data = NULL,
8732 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8733 	.tokens = {
8734 		(void *)&cmd_set_uc_hash_set,
8735 		(void *)&cmd_set_uc_hash_port,
8736 		(void *)&cmd_set_uc_hash_portid,
8737 		(void *)&cmd_set_uc_hash_what,
8738 		(void *)&cmd_set_uc_hash_mac,
8739 		(void *)&cmd_set_uc_hash_mode,
8740 		NULL,
8741 	},
8742 };
8743 
8744 struct cmd_set_uc_all_hash_table {
8745 	cmdline_fixed_string_t set;
8746 	cmdline_fixed_string_t port;
8747 	portid_t port_id;
8748 	cmdline_fixed_string_t what;
8749 	cmdline_fixed_string_t value;
8750 	cmdline_fixed_string_t mode;
8751 };
8752 
8753 static void
8754 cmd_set_uc_all_hash_parsed(void *parsed_result,
8755 		       __rte_unused struct cmdline *cl,
8756 		       __rte_unused void *data)
8757 {
8758 	int ret=0;
8759 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8760 
8761 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8762 
8763 	if ((strcmp(res->what, "uta") == 0) &&
8764 		(strcmp(res->value, "all") == 0))
8765 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8766 	if (ret < 0)
8767 		printf("bad unicast hash table parameter,"
8768 			"return code = %d \n", ret);
8769 }
8770 
8771 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8772 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8773 				 set, "set");
8774 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8775 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8776 				 port, "port");
8777 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8778 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8779 			      port_id, RTE_UINT16);
8780 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8781 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8782 				 what, "uta");
8783 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8784 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8785 				value,"all");
8786 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8787 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8788 				 mode, "on#off");
8789 
8790 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8791 	.f = cmd_set_uc_all_hash_parsed,
8792 	.data = NULL,
8793 	.help_str = "set port <port_id> uta all on|off",
8794 	.tokens = {
8795 		(void *)&cmd_set_uc_all_hash_set,
8796 		(void *)&cmd_set_uc_all_hash_port,
8797 		(void *)&cmd_set_uc_all_hash_portid,
8798 		(void *)&cmd_set_uc_all_hash_what,
8799 		(void *)&cmd_set_uc_all_hash_value,
8800 		(void *)&cmd_set_uc_all_hash_mode,
8801 		NULL,
8802 	},
8803 };
8804 
8805 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8806 struct cmd_set_vf_traffic {
8807 	cmdline_fixed_string_t set;
8808 	cmdline_fixed_string_t port;
8809 	portid_t port_id;
8810 	cmdline_fixed_string_t vf;
8811 	uint8_t vf_id;
8812 	cmdline_fixed_string_t what;
8813 	cmdline_fixed_string_t mode;
8814 };
8815 
8816 static void
8817 cmd_set_vf_traffic_parsed(void *parsed_result,
8818 		       __rte_unused struct cmdline *cl,
8819 		       __rte_unused void *data)
8820 {
8821 	struct cmd_set_vf_traffic *res = parsed_result;
8822 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8823 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8824 
8825 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8826 }
8827 
8828 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8829 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8830 				 set, "set");
8831 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8832 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8833 				 port, "port");
8834 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8835 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8836 			      port_id, RTE_UINT16);
8837 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8838 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8839 				 vf, "vf");
8840 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8841 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8842 			      vf_id, RTE_UINT8);
8843 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8844 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8845 				 what, "tx#rx");
8846 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8847 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8848 				 mode, "on#off");
8849 
8850 cmdline_parse_inst_t cmd_set_vf_traffic = {
8851 	.f = cmd_set_vf_traffic_parsed,
8852 	.data = NULL,
8853 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8854 	.tokens = {
8855 		(void *)&cmd_setvf_traffic_set,
8856 		(void *)&cmd_setvf_traffic_port,
8857 		(void *)&cmd_setvf_traffic_portid,
8858 		(void *)&cmd_setvf_traffic_vf,
8859 		(void *)&cmd_setvf_traffic_vfid,
8860 		(void *)&cmd_setvf_traffic_what,
8861 		(void *)&cmd_setvf_traffic_mode,
8862 		NULL,
8863 	},
8864 };
8865 
8866 /* *** CONFIGURE VF RECEIVE MODE *** */
8867 struct cmd_set_vf_rxmode {
8868 	cmdline_fixed_string_t set;
8869 	cmdline_fixed_string_t port;
8870 	portid_t port_id;
8871 	cmdline_fixed_string_t vf;
8872 	uint8_t vf_id;
8873 	cmdline_fixed_string_t what;
8874 	cmdline_fixed_string_t mode;
8875 	cmdline_fixed_string_t on;
8876 };
8877 
8878 static void
8879 cmd_set_vf_rxmode_parsed(void *parsed_result,
8880 		       __rte_unused struct cmdline *cl,
8881 		       __rte_unused void *data)
8882 {
8883 	int ret = -ENOTSUP;
8884 	uint16_t vf_rxmode = 0;
8885 	struct cmd_set_vf_rxmode *res = parsed_result;
8886 
8887 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8888 	if (!strcmp(res->what,"rxmode")) {
8889 		if (!strcmp(res->mode, "AUPE"))
8890 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8891 		else if (!strcmp(res->mode, "ROPE"))
8892 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8893 		else if (!strcmp(res->mode, "BAM"))
8894 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8895 		else if (!strncmp(res->mode, "MPE",3))
8896 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8897 	}
8898 
8899 	RTE_SET_USED(is_on);
8900 
8901 #ifdef RTE_NET_IXGBE
8902 	if (ret == -ENOTSUP)
8903 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8904 						  vf_rxmode, (uint8_t)is_on);
8905 #endif
8906 #ifdef RTE_NET_BNXT
8907 	if (ret == -ENOTSUP)
8908 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8909 						 vf_rxmode, (uint8_t)is_on);
8910 #endif
8911 	if (ret < 0)
8912 		printf("bad VF receive mode parameter, return code = %d \n",
8913 		ret);
8914 }
8915 
8916 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8917 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8918 				 set, "set");
8919 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8920 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8921 				 port, "port");
8922 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8923 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8924 			      port_id, RTE_UINT16);
8925 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8926 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8927 				 vf, "vf");
8928 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8929 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8930 			      vf_id, RTE_UINT8);
8931 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8932 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8933 				 what, "rxmode");
8934 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8935 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8936 				 mode, "AUPE#ROPE#BAM#MPE");
8937 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8938 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8939 				 on, "on#off");
8940 
8941 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8942 	.f = cmd_set_vf_rxmode_parsed,
8943 	.data = NULL,
8944 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8945 		"AUPE|ROPE|BAM|MPE on|off",
8946 	.tokens = {
8947 		(void *)&cmd_set_vf_rxmode_set,
8948 		(void *)&cmd_set_vf_rxmode_port,
8949 		(void *)&cmd_set_vf_rxmode_portid,
8950 		(void *)&cmd_set_vf_rxmode_vf,
8951 		(void *)&cmd_set_vf_rxmode_vfid,
8952 		(void *)&cmd_set_vf_rxmode_what,
8953 		(void *)&cmd_set_vf_rxmode_mode,
8954 		(void *)&cmd_set_vf_rxmode_on,
8955 		NULL,
8956 	},
8957 };
8958 
8959 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8960 struct cmd_vf_mac_addr_result {
8961 	cmdline_fixed_string_t mac_addr_cmd;
8962 	cmdline_fixed_string_t what;
8963 	cmdline_fixed_string_t port;
8964 	uint16_t port_num;
8965 	cmdline_fixed_string_t vf;
8966 	uint8_t vf_num;
8967 	struct rte_ether_addr address;
8968 };
8969 
8970 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8971 		__rte_unused struct cmdline *cl,
8972 		__rte_unused void *data)
8973 {
8974 	struct cmd_vf_mac_addr_result *res = parsed_result;
8975 	int ret = -ENOTSUP;
8976 
8977 	if (strcmp(res->what, "add") != 0)
8978 		return;
8979 
8980 #ifdef RTE_NET_I40E
8981 	if (ret == -ENOTSUP)
8982 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8983 						   &res->address);
8984 #endif
8985 #ifdef RTE_NET_BNXT
8986 	if (ret == -ENOTSUP)
8987 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8988 						res->vf_num);
8989 #endif
8990 
8991 	if(ret < 0)
8992 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8993 
8994 }
8995 
8996 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8997 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8998 				mac_addr_cmd,"mac_addr");
8999 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9000 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9001 				what,"add");
9002 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9003 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9004 				port,"port");
9005 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9006 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9007 				port_num, RTE_UINT16);
9008 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9009 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9010 				vf,"vf");
9011 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9012 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9013 				vf_num, RTE_UINT8);
9014 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9015 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9016 				address);
9017 
9018 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9019 	.f = cmd_vf_mac_addr_parsed,
9020 	.data = (void *)0,
9021 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9022 		"Add MAC address filtering for a VF on port_id",
9023 	.tokens = {
9024 		(void *)&cmd_vf_mac_addr_cmd,
9025 		(void *)&cmd_vf_mac_addr_what,
9026 		(void *)&cmd_vf_mac_addr_port,
9027 		(void *)&cmd_vf_mac_addr_portnum,
9028 		(void *)&cmd_vf_mac_addr_vf,
9029 		(void *)&cmd_vf_mac_addr_vfnum,
9030 		(void *)&cmd_vf_mac_addr_addr,
9031 		NULL,
9032 	},
9033 };
9034 
9035 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9036 struct cmd_vf_rx_vlan_filter {
9037 	cmdline_fixed_string_t rx_vlan;
9038 	cmdline_fixed_string_t what;
9039 	uint16_t vlan_id;
9040 	cmdline_fixed_string_t port;
9041 	portid_t port_id;
9042 	cmdline_fixed_string_t vf;
9043 	uint64_t vf_mask;
9044 };
9045 
9046 static void
9047 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9048 			  __rte_unused struct cmdline *cl,
9049 			  __rte_unused void *data)
9050 {
9051 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
9052 	int ret = -ENOTSUP;
9053 
9054 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9055 
9056 #ifdef RTE_NET_IXGBE
9057 	if (ret == -ENOTSUP)
9058 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9059 				res->vlan_id, res->vf_mask, is_add);
9060 #endif
9061 #ifdef RTE_NET_I40E
9062 	if (ret == -ENOTSUP)
9063 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9064 				res->vlan_id, res->vf_mask, is_add);
9065 #endif
9066 #ifdef RTE_NET_BNXT
9067 	if (ret == -ENOTSUP)
9068 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9069 				res->vlan_id, res->vf_mask, is_add);
9070 #endif
9071 
9072 	switch (ret) {
9073 	case 0:
9074 		break;
9075 	case -EINVAL:
9076 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9077 				res->vlan_id, res->vf_mask);
9078 		break;
9079 	case -ENODEV:
9080 		printf("invalid port_id %d\n", res->port_id);
9081 		break;
9082 	case -ENOTSUP:
9083 		printf("function not implemented or supported\n");
9084 		break;
9085 	default:
9086 		printf("programming error: (%s)\n", strerror(-ret));
9087 	}
9088 }
9089 
9090 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9091 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9092 				 rx_vlan, "rx_vlan");
9093 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9094 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9095 				 what, "add#rm");
9096 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9097 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9098 			      vlan_id, RTE_UINT16);
9099 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9100 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9101 				 port, "port");
9102 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9103 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9104 			      port_id, RTE_UINT16);
9105 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9106 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9107 				 vf, "vf");
9108 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9109 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9110 			      vf_mask, RTE_UINT64);
9111 
9112 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9113 	.f = cmd_vf_rx_vlan_filter_parsed,
9114 	.data = NULL,
9115 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9116 		"(vf_mask = hexadecimal VF mask)",
9117 	.tokens = {
9118 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9119 		(void *)&cmd_vf_rx_vlan_filter_what,
9120 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
9121 		(void *)&cmd_vf_rx_vlan_filter_port,
9122 		(void *)&cmd_vf_rx_vlan_filter_portid,
9123 		(void *)&cmd_vf_rx_vlan_filter_vf,
9124 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
9125 		NULL,
9126 	},
9127 };
9128 
9129 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9130 struct cmd_queue_rate_limit_result {
9131 	cmdline_fixed_string_t set;
9132 	cmdline_fixed_string_t port;
9133 	uint16_t port_num;
9134 	cmdline_fixed_string_t queue;
9135 	uint8_t queue_num;
9136 	cmdline_fixed_string_t rate;
9137 	uint16_t rate_num;
9138 };
9139 
9140 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9141 		__rte_unused struct cmdline *cl,
9142 		__rte_unused void *data)
9143 {
9144 	struct cmd_queue_rate_limit_result *res = parsed_result;
9145 	int ret = 0;
9146 
9147 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9148 		&& (strcmp(res->queue, "queue") == 0)
9149 		&& (strcmp(res->rate, "rate") == 0))
9150 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
9151 					res->rate_num);
9152 	if (ret < 0)
9153 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9154 
9155 }
9156 
9157 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9158 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9159 				set, "set");
9160 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9161 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9162 				port, "port");
9163 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9164 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9165 				port_num, RTE_UINT16);
9166 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9167 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9168 				queue, "queue");
9169 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9170 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9171 				queue_num, RTE_UINT8);
9172 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9173 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9174 				rate, "rate");
9175 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9176 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9177 				rate_num, RTE_UINT16);
9178 
9179 cmdline_parse_inst_t cmd_queue_rate_limit = {
9180 	.f = cmd_queue_rate_limit_parsed,
9181 	.data = (void *)0,
9182 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9183 		"Set rate limit for a queue on port_id",
9184 	.tokens = {
9185 		(void *)&cmd_queue_rate_limit_set,
9186 		(void *)&cmd_queue_rate_limit_port,
9187 		(void *)&cmd_queue_rate_limit_portnum,
9188 		(void *)&cmd_queue_rate_limit_queue,
9189 		(void *)&cmd_queue_rate_limit_queuenum,
9190 		(void *)&cmd_queue_rate_limit_rate,
9191 		(void *)&cmd_queue_rate_limit_ratenum,
9192 		NULL,
9193 	},
9194 };
9195 
9196 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9197 struct cmd_vf_rate_limit_result {
9198 	cmdline_fixed_string_t set;
9199 	cmdline_fixed_string_t port;
9200 	uint16_t port_num;
9201 	cmdline_fixed_string_t vf;
9202 	uint8_t vf_num;
9203 	cmdline_fixed_string_t rate;
9204 	uint16_t rate_num;
9205 	cmdline_fixed_string_t q_msk;
9206 	uint64_t q_msk_val;
9207 };
9208 
9209 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9210 		__rte_unused struct cmdline *cl,
9211 		__rte_unused void *data)
9212 {
9213 	struct cmd_vf_rate_limit_result *res = parsed_result;
9214 	int ret = 0;
9215 
9216 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9217 		&& (strcmp(res->vf, "vf") == 0)
9218 		&& (strcmp(res->rate, "rate") == 0)
9219 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9220 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9221 					res->rate_num, res->q_msk_val);
9222 	if (ret < 0)
9223 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9224 
9225 }
9226 
9227 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9228 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9229 				set, "set");
9230 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9231 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9232 				port, "port");
9233 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9234 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9235 				port_num, RTE_UINT16);
9236 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9237 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9238 				vf, "vf");
9239 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9240 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9241 				vf_num, RTE_UINT8);
9242 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9243 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9244 				rate, "rate");
9245 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9246 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9247 				rate_num, RTE_UINT16);
9248 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9249 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9250 				q_msk, "queue_mask");
9251 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9252 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9253 				q_msk_val, RTE_UINT64);
9254 
9255 cmdline_parse_inst_t cmd_vf_rate_limit = {
9256 	.f = cmd_vf_rate_limit_parsed,
9257 	.data = (void *)0,
9258 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9259 		"queue_mask <queue_mask_value>: "
9260 		"Set rate limit for queues of VF on port_id",
9261 	.tokens = {
9262 		(void *)&cmd_vf_rate_limit_set,
9263 		(void *)&cmd_vf_rate_limit_port,
9264 		(void *)&cmd_vf_rate_limit_portnum,
9265 		(void *)&cmd_vf_rate_limit_vf,
9266 		(void *)&cmd_vf_rate_limit_vfnum,
9267 		(void *)&cmd_vf_rate_limit_rate,
9268 		(void *)&cmd_vf_rate_limit_ratenum,
9269 		(void *)&cmd_vf_rate_limit_q_msk,
9270 		(void *)&cmd_vf_rate_limit_q_msk_val,
9271 		NULL,
9272 	},
9273 };
9274 
9275 /* *** CONFIGURE TUNNEL UDP PORT *** */
9276 struct cmd_tunnel_udp_config {
9277 	cmdline_fixed_string_t rx_vxlan_port;
9278 	cmdline_fixed_string_t what;
9279 	uint16_t udp_port;
9280 	portid_t port_id;
9281 };
9282 
9283 static void
9284 cmd_tunnel_udp_config_parsed(void *parsed_result,
9285 			  __rte_unused struct cmdline *cl,
9286 			  __rte_unused void *data)
9287 {
9288 	struct cmd_tunnel_udp_config *res = parsed_result;
9289 	struct rte_eth_udp_tunnel tunnel_udp;
9290 	int ret;
9291 
9292 	tunnel_udp.udp_port = res->udp_port;
9293 	tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9294 
9295 	if (!strcmp(res->what, "add"))
9296 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9297 						      &tunnel_udp);
9298 	else
9299 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9300 							 &tunnel_udp);
9301 
9302 	if (ret < 0)
9303 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9304 }
9305 
9306 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9307 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9308 				rx_vxlan_port, "rx_vxlan_port");
9309 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9310 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9311 				what, "add#rm");
9312 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9313 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9314 				udp_port, RTE_UINT16);
9315 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9316 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9317 				port_id, RTE_UINT16);
9318 
9319 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9320 	.f = cmd_tunnel_udp_config_parsed,
9321 	.data = (void *)0,
9322 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9323 		"Add/Remove a tunneling UDP port filter",
9324 	.tokens = {
9325 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9326 		(void *)&cmd_tunnel_udp_config_what,
9327 		(void *)&cmd_tunnel_udp_config_udp_port,
9328 		(void *)&cmd_tunnel_udp_config_port_id,
9329 		NULL,
9330 	},
9331 };
9332 
9333 struct cmd_config_tunnel_udp_port {
9334 	cmdline_fixed_string_t port;
9335 	cmdline_fixed_string_t config;
9336 	portid_t port_id;
9337 	cmdline_fixed_string_t udp_tunnel_port;
9338 	cmdline_fixed_string_t action;
9339 	cmdline_fixed_string_t tunnel_type;
9340 	uint16_t udp_port;
9341 };
9342 
9343 static void
9344 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9345 			       __rte_unused struct cmdline *cl,
9346 			       __rte_unused void *data)
9347 {
9348 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9349 	struct rte_eth_udp_tunnel tunnel_udp;
9350 	int ret = 0;
9351 
9352 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9353 		return;
9354 
9355 	tunnel_udp.udp_port = res->udp_port;
9356 
9357 	if (!strcmp(res->tunnel_type, "vxlan")) {
9358 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9359 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9360 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9361 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9362 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9363 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9364 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9365 	} else {
9366 		printf("Invalid tunnel type\n");
9367 		return;
9368 	}
9369 
9370 	if (!strcmp(res->action, "add"))
9371 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9372 						      &tunnel_udp);
9373 	else
9374 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9375 							 &tunnel_udp);
9376 
9377 	if (ret < 0)
9378 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9379 }
9380 
9381 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9382 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9383 				 "port");
9384 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9385 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9386 				 "config");
9387 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9388 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9389 			      RTE_UINT16);
9390 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9391 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9392 				 udp_tunnel_port,
9393 				 "udp_tunnel_port");
9394 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9395 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9396 				 "add#rm");
9397 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9398 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9399 				 "vxlan#geneve#vxlan-gpe#ecpri");
9400 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9401 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9402 			      RTE_UINT16);
9403 
9404 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9405 	.f = cmd_cfg_tunnel_udp_port_parsed,
9406 	.data = NULL,
9407 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9408 		"geneve|vxlan-gpe|ecpri <udp_port>",
9409 	.tokens = {
9410 		(void *)&cmd_config_tunnel_udp_port_port,
9411 		(void *)&cmd_config_tunnel_udp_port_config,
9412 		(void *)&cmd_config_tunnel_udp_port_port_id,
9413 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9414 		(void *)&cmd_config_tunnel_udp_port_action,
9415 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9416 		(void *)&cmd_config_tunnel_udp_port_value,
9417 		NULL,
9418 	},
9419 };
9420 
9421 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9422 struct cmd_set_mirror_mask_result {
9423 	cmdline_fixed_string_t set;
9424 	cmdline_fixed_string_t port;
9425 	portid_t port_id;
9426 	cmdline_fixed_string_t mirror;
9427 	uint8_t rule_id;
9428 	cmdline_fixed_string_t what;
9429 	cmdline_fixed_string_t value;
9430 	cmdline_fixed_string_t dstpool;
9431 	uint8_t dstpool_id;
9432 	cmdline_fixed_string_t on;
9433 };
9434 
9435 cmdline_parse_token_string_t cmd_mirror_mask_set =
9436 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9437 				set, "set");
9438 cmdline_parse_token_string_t cmd_mirror_mask_port =
9439 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9440 				port, "port");
9441 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9442 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9443 				port_id, RTE_UINT16);
9444 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9445 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9446 				mirror, "mirror-rule");
9447 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9448 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9449 				rule_id, RTE_UINT8);
9450 cmdline_parse_token_string_t cmd_mirror_mask_what =
9451 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9452 				what, "pool-mirror-up#pool-mirror-down"
9453 				      "#vlan-mirror");
9454 cmdline_parse_token_string_t cmd_mirror_mask_value =
9455 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9456 				value, NULL);
9457 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9458 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9459 				dstpool, "dst-pool");
9460 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9461 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9462 				dstpool_id, RTE_UINT8);
9463 cmdline_parse_token_string_t cmd_mirror_mask_on =
9464 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9465 				on, "on#off");
9466 
9467 static void
9468 cmd_set_mirror_mask_parsed(void *parsed_result,
9469 		       __rte_unused struct cmdline *cl,
9470 		       __rte_unused void *data)
9471 {
9472 	int ret,nb_item,i;
9473 	struct cmd_set_mirror_mask_result *res = parsed_result;
9474 	struct rte_eth_mirror_conf mr_conf;
9475 
9476 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9477 
9478 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9479 
9480 	mr_conf.dst_pool = res->dstpool_id;
9481 
9482 	if (!strcmp(res->what, "pool-mirror-up")) {
9483 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9484 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9485 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9486 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9487 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9488 	} else if (!strcmp(res->what, "vlan-mirror")) {
9489 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9490 		nb_item = parse_item_list(res->value, "vlan",
9491 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9492 		if (nb_item <= 0)
9493 			return;
9494 
9495 		for (i = 0; i < nb_item; i++) {
9496 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9497 				printf("Invalid vlan_id: must be < 4096\n");
9498 				return;
9499 			}
9500 
9501 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9502 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9503 		}
9504 	}
9505 
9506 	if (!strcmp(res->on, "on"))
9507 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9508 						res->rule_id, 1);
9509 	else
9510 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9511 						res->rule_id, 0);
9512 	if (ret < 0)
9513 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9514 }
9515 
9516 cmdline_parse_inst_t cmd_set_mirror_mask = {
9517 		.f = cmd_set_mirror_mask_parsed,
9518 		.data = NULL,
9519 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9520 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9521 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9522 		.tokens = {
9523 			(void *)&cmd_mirror_mask_set,
9524 			(void *)&cmd_mirror_mask_port,
9525 			(void *)&cmd_mirror_mask_portid,
9526 			(void *)&cmd_mirror_mask_mirror,
9527 			(void *)&cmd_mirror_mask_ruleid,
9528 			(void *)&cmd_mirror_mask_what,
9529 			(void *)&cmd_mirror_mask_value,
9530 			(void *)&cmd_mirror_mask_dstpool,
9531 			(void *)&cmd_mirror_mask_poolid,
9532 			(void *)&cmd_mirror_mask_on,
9533 			NULL,
9534 		},
9535 };
9536 
9537 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9538 struct cmd_set_mirror_link_result {
9539 	cmdline_fixed_string_t set;
9540 	cmdline_fixed_string_t port;
9541 	portid_t port_id;
9542 	cmdline_fixed_string_t mirror;
9543 	uint8_t rule_id;
9544 	cmdline_fixed_string_t what;
9545 	cmdline_fixed_string_t dstpool;
9546 	uint8_t dstpool_id;
9547 	cmdline_fixed_string_t on;
9548 };
9549 
9550 cmdline_parse_token_string_t cmd_mirror_link_set =
9551 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9552 				 set, "set");
9553 cmdline_parse_token_string_t cmd_mirror_link_port =
9554 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9555 				port, "port");
9556 cmdline_parse_token_num_t cmd_mirror_link_portid =
9557 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9558 				port_id, RTE_UINT16);
9559 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9560 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9561 				mirror, "mirror-rule");
9562 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9563 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9564 			    rule_id, RTE_UINT8);
9565 cmdline_parse_token_string_t cmd_mirror_link_what =
9566 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9567 				what, "uplink-mirror#downlink-mirror");
9568 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9569 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9570 				dstpool, "dst-pool");
9571 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9572 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9573 				dstpool_id, RTE_UINT8);
9574 cmdline_parse_token_string_t cmd_mirror_link_on =
9575 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9576 				on, "on#off");
9577 
9578 static void
9579 cmd_set_mirror_link_parsed(void *parsed_result,
9580 		       __rte_unused struct cmdline *cl,
9581 		       __rte_unused void *data)
9582 {
9583 	int ret;
9584 	struct cmd_set_mirror_link_result *res = parsed_result;
9585 	struct rte_eth_mirror_conf mr_conf;
9586 
9587 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9588 	if (!strcmp(res->what, "uplink-mirror"))
9589 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9590 	else
9591 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9592 
9593 	mr_conf.dst_pool = res->dstpool_id;
9594 
9595 	if (!strcmp(res->on, "on"))
9596 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9597 						res->rule_id, 1);
9598 	else
9599 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9600 						res->rule_id, 0);
9601 
9602 	/* check the return value and print it if is < 0 */
9603 	if (ret < 0)
9604 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9605 
9606 }
9607 
9608 cmdline_parse_inst_t cmd_set_mirror_link = {
9609 		.f = cmd_set_mirror_link_parsed,
9610 		.data = NULL,
9611 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9612 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9613 		.tokens = {
9614 			(void *)&cmd_mirror_link_set,
9615 			(void *)&cmd_mirror_link_port,
9616 			(void *)&cmd_mirror_link_portid,
9617 			(void *)&cmd_mirror_link_mirror,
9618 			(void *)&cmd_mirror_link_ruleid,
9619 			(void *)&cmd_mirror_link_what,
9620 			(void *)&cmd_mirror_link_dstpool,
9621 			(void *)&cmd_mirror_link_poolid,
9622 			(void *)&cmd_mirror_link_on,
9623 			NULL,
9624 		},
9625 };
9626 
9627 /* *** RESET VM MIRROR RULE *** */
9628 struct cmd_rm_mirror_rule_result {
9629 	cmdline_fixed_string_t reset;
9630 	cmdline_fixed_string_t port;
9631 	portid_t port_id;
9632 	cmdline_fixed_string_t mirror;
9633 	uint8_t rule_id;
9634 };
9635 
9636 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9637 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9638 				 reset, "reset");
9639 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9640 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9641 				port, "port");
9642 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9643 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9644 				port_id, RTE_UINT16);
9645 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9646 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9647 				mirror, "mirror-rule");
9648 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9649 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9650 				rule_id, RTE_UINT8);
9651 
9652 static void
9653 cmd_reset_mirror_rule_parsed(void *parsed_result,
9654 		       __rte_unused struct cmdline *cl,
9655 		       __rte_unused void *data)
9656 {
9657 	int ret;
9658 	struct cmd_set_mirror_link_result *res = parsed_result;
9659         /* check rule_id */
9660 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9661 	if(ret < 0)
9662 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9663 }
9664 
9665 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9666 		.f = cmd_reset_mirror_rule_parsed,
9667 		.data = NULL,
9668 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9669 		.tokens = {
9670 			(void *)&cmd_rm_mirror_rule_reset,
9671 			(void *)&cmd_rm_mirror_rule_port,
9672 			(void *)&cmd_rm_mirror_rule_portid,
9673 			(void *)&cmd_rm_mirror_rule_mirror,
9674 			(void *)&cmd_rm_mirror_rule_ruleid,
9675 			NULL,
9676 		},
9677 };
9678 
9679 /* ******************************************************************************** */
9680 
9681 struct cmd_dump_result {
9682 	cmdline_fixed_string_t dump;
9683 };
9684 
9685 static void
9686 dump_struct_sizes(void)
9687 {
9688 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9689 	DUMP_SIZE(struct rte_mbuf);
9690 	DUMP_SIZE(struct rte_mempool);
9691 	DUMP_SIZE(struct rte_ring);
9692 #undef DUMP_SIZE
9693 }
9694 
9695 
9696 /* Dump the socket memory statistics on console */
9697 static void
9698 dump_socket_mem(FILE *f)
9699 {
9700 	struct rte_malloc_socket_stats socket_stats;
9701 	unsigned int i;
9702 	size_t total = 0;
9703 	size_t alloc = 0;
9704 	size_t free = 0;
9705 	unsigned int n_alloc = 0;
9706 	unsigned int n_free = 0;
9707 	static size_t last_allocs;
9708 	static size_t last_total;
9709 
9710 
9711 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9712 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9713 		    !socket_stats.heap_totalsz_bytes)
9714 			continue;
9715 		total += socket_stats.heap_totalsz_bytes;
9716 		alloc += socket_stats.heap_allocsz_bytes;
9717 		free += socket_stats.heap_freesz_bytes;
9718 		n_alloc += socket_stats.alloc_count;
9719 		n_free += socket_stats.free_count;
9720 		fprintf(f,
9721 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9722 			i,
9723 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9724 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9725 			(double)socket_stats.heap_allocsz_bytes * 100 /
9726 			(double)socket_stats.heap_totalsz_bytes,
9727 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9728 			socket_stats.alloc_count,
9729 			socket_stats.free_count);
9730 	}
9731 	fprintf(f,
9732 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9733 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9734 		(double)alloc * 100 / (double)total,
9735 		(double)free / (1024 * 1024),
9736 		n_alloc, n_free);
9737 	if (last_allocs)
9738 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9739 			((double)total - (double)last_total) / (1024 * 1024),
9740 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9741 	last_allocs = alloc;
9742 	last_total = total;
9743 }
9744 
9745 static void cmd_dump_parsed(void *parsed_result,
9746 			    __rte_unused struct cmdline *cl,
9747 			    __rte_unused void *data)
9748 {
9749 	struct cmd_dump_result *res = parsed_result;
9750 
9751 	if (!strcmp(res->dump, "dump_physmem"))
9752 		rte_dump_physmem_layout(stdout);
9753 	else if (!strcmp(res->dump, "dump_socket_mem"))
9754 		dump_socket_mem(stdout);
9755 	else if (!strcmp(res->dump, "dump_memzone"))
9756 		rte_memzone_dump(stdout);
9757 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9758 		dump_struct_sizes();
9759 	else if (!strcmp(res->dump, "dump_ring"))
9760 		rte_ring_list_dump(stdout);
9761 	else if (!strcmp(res->dump, "dump_mempool"))
9762 		rte_mempool_list_dump(stdout);
9763 	else if (!strcmp(res->dump, "dump_devargs"))
9764 		rte_devargs_dump(stdout);
9765 	else if (!strcmp(res->dump, "dump_log_types"))
9766 		rte_log_dump(stdout);
9767 }
9768 
9769 cmdline_parse_token_string_t cmd_dump_dump =
9770 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9771 		"dump_physmem#"
9772 		"dump_memzone#"
9773 		"dump_socket_mem#"
9774 		"dump_struct_sizes#"
9775 		"dump_ring#"
9776 		"dump_mempool#"
9777 		"dump_devargs#"
9778 		"dump_log_types");
9779 
9780 cmdline_parse_inst_t cmd_dump = {
9781 	.f = cmd_dump_parsed,  /* function to call */
9782 	.data = NULL,      /* 2nd arg of func */
9783 	.help_str = "Dump status",
9784 	.tokens = {        /* token list, NULL terminated */
9785 		(void *)&cmd_dump_dump,
9786 		NULL,
9787 	},
9788 };
9789 
9790 /* ******************************************************************************** */
9791 
9792 struct cmd_dump_one_result {
9793 	cmdline_fixed_string_t dump;
9794 	cmdline_fixed_string_t name;
9795 };
9796 
9797 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9798 				__rte_unused void *data)
9799 {
9800 	struct cmd_dump_one_result *res = parsed_result;
9801 
9802 	if (!strcmp(res->dump, "dump_ring")) {
9803 		struct rte_ring *r;
9804 		r = rte_ring_lookup(res->name);
9805 		if (r == NULL) {
9806 			cmdline_printf(cl, "Cannot find ring\n");
9807 			return;
9808 		}
9809 		rte_ring_dump(stdout, r);
9810 	} else if (!strcmp(res->dump, "dump_mempool")) {
9811 		struct rte_mempool *mp;
9812 		mp = rte_mempool_lookup(res->name);
9813 		if (mp == NULL) {
9814 			cmdline_printf(cl, "Cannot find mempool\n");
9815 			return;
9816 		}
9817 		rte_mempool_dump(stdout, mp);
9818 	}
9819 }
9820 
9821 cmdline_parse_token_string_t cmd_dump_one_dump =
9822 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9823 				 "dump_ring#dump_mempool");
9824 
9825 cmdline_parse_token_string_t cmd_dump_one_name =
9826 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9827 
9828 cmdline_parse_inst_t cmd_dump_one = {
9829 	.f = cmd_dump_one_parsed,  /* function to call */
9830 	.data = NULL,      /* 2nd arg of func */
9831 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9832 	.tokens = {        /* token list, NULL terminated */
9833 		(void *)&cmd_dump_one_dump,
9834 		(void *)&cmd_dump_one_name,
9835 		NULL,
9836 	},
9837 };
9838 
9839 /* *** queue region set *** */
9840 struct cmd_queue_region_result {
9841 	cmdline_fixed_string_t set;
9842 	cmdline_fixed_string_t port;
9843 	portid_t port_id;
9844 	cmdline_fixed_string_t cmd;
9845 	cmdline_fixed_string_t region;
9846 	uint8_t  region_id;
9847 	cmdline_fixed_string_t queue_start_index;
9848 	uint8_t  queue_id;
9849 	cmdline_fixed_string_t queue_num;
9850 	uint8_t  queue_num_value;
9851 };
9852 
9853 static void
9854 cmd_queue_region_parsed(void *parsed_result,
9855 			__rte_unused struct cmdline *cl,
9856 			__rte_unused void *data)
9857 {
9858 	struct cmd_queue_region_result *res = parsed_result;
9859 	int ret = -ENOTSUP;
9860 #ifdef RTE_NET_I40E
9861 	struct rte_pmd_i40e_queue_region_conf region_conf;
9862 	enum rte_pmd_i40e_queue_region_op op_type;
9863 #endif
9864 
9865 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9866 		return;
9867 
9868 #ifdef RTE_NET_I40E
9869 	memset(&region_conf, 0, sizeof(region_conf));
9870 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9871 	region_conf.region_id = res->region_id;
9872 	region_conf.queue_num = res->queue_num_value;
9873 	region_conf.queue_start_index = res->queue_id;
9874 
9875 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9876 				op_type, &region_conf);
9877 #endif
9878 
9879 	switch (ret) {
9880 	case 0:
9881 		break;
9882 	case -ENOTSUP:
9883 		printf("function not implemented or supported\n");
9884 		break;
9885 	default:
9886 		printf("queue region config error: (%s)\n", strerror(-ret));
9887 	}
9888 }
9889 
9890 cmdline_parse_token_string_t cmd_queue_region_set =
9891 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9892 		set, "set");
9893 cmdline_parse_token_string_t cmd_queue_region_port =
9894 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9895 cmdline_parse_token_num_t cmd_queue_region_port_id =
9896 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9897 				port_id, RTE_UINT16);
9898 cmdline_parse_token_string_t cmd_queue_region_cmd =
9899 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9900 				 cmd, "queue-region");
9901 cmdline_parse_token_string_t cmd_queue_region_id =
9902 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9903 				region, "region_id");
9904 cmdline_parse_token_num_t cmd_queue_region_index =
9905 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9906 				region_id, RTE_UINT8);
9907 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9908 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9909 				queue_start_index, "queue_start_index");
9910 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9911 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9912 				queue_id, RTE_UINT8);
9913 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9914 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9915 				queue_num, "queue_num");
9916 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9917 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9918 				queue_num_value, RTE_UINT8);
9919 
9920 cmdline_parse_inst_t cmd_queue_region = {
9921 	.f = cmd_queue_region_parsed,
9922 	.data = NULL,
9923 	.help_str = "set port <port_id> queue-region region_id <value> "
9924 		"queue_start_index <value> queue_num <value>: Set a queue region",
9925 	.tokens = {
9926 		(void *)&cmd_queue_region_set,
9927 		(void *)&cmd_queue_region_port,
9928 		(void *)&cmd_queue_region_port_id,
9929 		(void *)&cmd_queue_region_cmd,
9930 		(void *)&cmd_queue_region_id,
9931 		(void *)&cmd_queue_region_index,
9932 		(void *)&cmd_queue_region_queue_start_index,
9933 		(void *)&cmd_queue_region_queue_id,
9934 		(void *)&cmd_queue_region_queue_num,
9935 		(void *)&cmd_queue_region_queue_num_value,
9936 		NULL,
9937 	},
9938 };
9939 
9940 /* *** queue region and flowtype set *** */
9941 struct cmd_region_flowtype_result {
9942 	cmdline_fixed_string_t set;
9943 	cmdline_fixed_string_t port;
9944 	portid_t port_id;
9945 	cmdline_fixed_string_t cmd;
9946 	cmdline_fixed_string_t region;
9947 	uint8_t  region_id;
9948 	cmdline_fixed_string_t flowtype;
9949 	uint8_t  flowtype_id;
9950 };
9951 
9952 static void
9953 cmd_region_flowtype_parsed(void *parsed_result,
9954 			__rte_unused struct cmdline *cl,
9955 			__rte_unused void *data)
9956 {
9957 	struct cmd_region_flowtype_result *res = parsed_result;
9958 	int ret = -ENOTSUP;
9959 #ifdef RTE_NET_I40E
9960 	struct rte_pmd_i40e_queue_region_conf region_conf;
9961 	enum rte_pmd_i40e_queue_region_op op_type;
9962 #endif
9963 
9964 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9965 		return;
9966 
9967 #ifdef RTE_NET_I40E
9968 	memset(&region_conf, 0, sizeof(region_conf));
9969 
9970 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9971 	region_conf.region_id = res->region_id;
9972 	region_conf.hw_flowtype = res->flowtype_id;
9973 
9974 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9975 			op_type, &region_conf);
9976 #endif
9977 
9978 	switch (ret) {
9979 	case 0:
9980 		break;
9981 	case -ENOTSUP:
9982 		printf("function not implemented or supported\n");
9983 		break;
9984 	default:
9985 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9986 	}
9987 }
9988 
9989 cmdline_parse_token_string_t cmd_region_flowtype_set =
9990 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9991 				set, "set");
9992 cmdline_parse_token_string_t cmd_region_flowtype_port =
9993 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9994 				port, "port");
9995 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9996 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9997 				port_id, RTE_UINT16);
9998 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9999 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10000 				cmd, "queue-region");
10001 cmdline_parse_token_string_t cmd_region_flowtype_index =
10002 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10003 				region, "region_id");
10004 cmdline_parse_token_num_t cmd_region_flowtype_id =
10005 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10006 				region_id, RTE_UINT8);
10007 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10008 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10009 				flowtype, "flowtype");
10010 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10011 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10012 				flowtype_id, RTE_UINT8);
10013 cmdline_parse_inst_t cmd_region_flowtype = {
10014 	.f = cmd_region_flowtype_parsed,
10015 	.data = NULL,
10016 	.help_str = "set port <port_id> queue-region region_id <value> "
10017 		"flowtype <value>: Set a flowtype region index",
10018 	.tokens = {
10019 		(void *)&cmd_region_flowtype_set,
10020 		(void *)&cmd_region_flowtype_port,
10021 		(void *)&cmd_region_flowtype_port_index,
10022 		(void *)&cmd_region_flowtype_cmd,
10023 		(void *)&cmd_region_flowtype_index,
10024 		(void *)&cmd_region_flowtype_id,
10025 		(void *)&cmd_region_flowtype_flow_index,
10026 		(void *)&cmd_region_flowtype_flow_id,
10027 		NULL,
10028 	},
10029 };
10030 
10031 /* *** User Priority (UP) to queue region (region_id) set *** */
10032 struct cmd_user_priority_region_result {
10033 	cmdline_fixed_string_t set;
10034 	cmdline_fixed_string_t port;
10035 	portid_t port_id;
10036 	cmdline_fixed_string_t cmd;
10037 	cmdline_fixed_string_t user_priority;
10038 	uint8_t  user_priority_id;
10039 	cmdline_fixed_string_t region;
10040 	uint8_t  region_id;
10041 };
10042 
10043 static void
10044 cmd_user_priority_region_parsed(void *parsed_result,
10045 			__rte_unused struct cmdline *cl,
10046 			__rte_unused void *data)
10047 {
10048 	struct cmd_user_priority_region_result *res = parsed_result;
10049 	int ret = -ENOTSUP;
10050 #ifdef RTE_NET_I40E
10051 	struct rte_pmd_i40e_queue_region_conf region_conf;
10052 	enum rte_pmd_i40e_queue_region_op op_type;
10053 #endif
10054 
10055 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10056 		return;
10057 
10058 #ifdef RTE_NET_I40E
10059 	memset(&region_conf, 0, sizeof(region_conf));
10060 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10061 	region_conf.user_priority = res->user_priority_id;
10062 	region_conf.region_id = res->region_id;
10063 
10064 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10065 				op_type, &region_conf);
10066 #endif
10067 
10068 	switch (ret) {
10069 	case 0:
10070 		break;
10071 	case -ENOTSUP:
10072 		printf("function not implemented or supported\n");
10073 		break;
10074 	default:
10075 		printf("user_priority region config error: (%s)\n",
10076 				strerror(-ret));
10077 	}
10078 }
10079 
10080 cmdline_parse_token_string_t cmd_user_priority_region_set =
10081 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10082 				set, "set");
10083 cmdline_parse_token_string_t cmd_user_priority_region_port =
10084 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10085 				port, "port");
10086 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10087 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10088 				port_id, RTE_UINT16);
10089 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10090 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10091 				cmd, "queue-region");
10092 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10093 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10094 				user_priority, "UP");
10095 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10096 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10097 				user_priority_id, RTE_UINT8);
10098 cmdline_parse_token_string_t cmd_user_priority_region_region =
10099 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10100 				region, "region_id");
10101 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10102 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10103 				region_id, RTE_UINT8);
10104 
10105 cmdline_parse_inst_t cmd_user_priority_region = {
10106 	.f = cmd_user_priority_region_parsed,
10107 	.data = NULL,
10108 	.help_str = "set port <port_id> queue-region UP <value> "
10109 		"region_id <value>: Set the mapping of User Priority (UP) "
10110 		"to queue region (region_id) ",
10111 	.tokens = {
10112 		(void *)&cmd_user_priority_region_set,
10113 		(void *)&cmd_user_priority_region_port,
10114 		(void *)&cmd_user_priority_region_port_index,
10115 		(void *)&cmd_user_priority_region_cmd,
10116 		(void *)&cmd_user_priority_region_UP,
10117 		(void *)&cmd_user_priority_region_UP_id,
10118 		(void *)&cmd_user_priority_region_region,
10119 		(void *)&cmd_user_priority_region_region_id,
10120 		NULL,
10121 	},
10122 };
10123 
10124 /* *** flush all queue region related configuration *** */
10125 struct cmd_flush_queue_region_result {
10126 	cmdline_fixed_string_t set;
10127 	cmdline_fixed_string_t port;
10128 	portid_t port_id;
10129 	cmdline_fixed_string_t cmd;
10130 	cmdline_fixed_string_t flush;
10131 	cmdline_fixed_string_t what;
10132 };
10133 
10134 static void
10135 cmd_flush_queue_region_parsed(void *parsed_result,
10136 			__rte_unused struct cmdline *cl,
10137 			__rte_unused void *data)
10138 {
10139 	struct cmd_flush_queue_region_result *res = parsed_result;
10140 	int ret = -ENOTSUP;
10141 #ifdef RTE_NET_I40E
10142 	struct rte_pmd_i40e_queue_region_conf region_conf;
10143 	enum rte_pmd_i40e_queue_region_op op_type;
10144 #endif
10145 
10146 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10147 		return;
10148 
10149 #ifdef RTE_NET_I40E
10150 	memset(&region_conf, 0, sizeof(region_conf));
10151 
10152 	if (strcmp(res->what, "on") == 0)
10153 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10154 	else
10155 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10156 
10157 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10158 				op_type, &region_conf);
10159 #endif
10160 
10161 	switch (ret) {
10162 	case 0:
10163 		break;
10164 	case -ENOTSUP:
10165 		printf("function not implemented or supported\n");
10166 		break;
10167 	default:
10168 		printf("queue region config flush error: (%s)\n",
10169 				strerror(-ret));
10170 	}
10171 }
10172 
10173 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10174 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10175 				set, "set");
10176 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10177 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10178 				port, "port");
10179 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10180 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10181 				port_id, RTE_UINT16);
10182 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10183 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10184 				cmd, "queue-region");
10185 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10186 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10187 				flush, "flush");
10188 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10189 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10190 				what, "on#off");
10191 
10192 cmdline_parse_inst_t cmd_flush_queue_region = {
10193 	.f = cmd_flush_queue_region_parsed,
10194 	.data = NULL,
10195 	.help_str = "set port <port_id> queue-region flush on|off"
10196 		": flush all queue region related configuration",
10197 	.tokens = {
10198 		(void *)&cmd_flush_queue_region_set,
10199 		(void *)&cmd_flush_queue_region_port,
10200 		(void *)&cmd_flush_queue_region_port_index,
10201 		(void *)&cmd_flush_queue_region_cmd,
10202 		(void *)&cmd_flush_queue_region_flush,
10203 		(void *)&cmd_flush_queue_region_what,
10204 		NULL,
10205 	},
10206 };
10207 
10208 /* *** get all queue region related configuration info *** */
10209 struct cmd_show_queue_region_info {
10210 	cmdline_fixed_string_t show;
10211 	cmdline_fixed_string_t port;
10212 	portid_t port_id;
10213 	cmdline_fixed_string_t cmd;
10214 };
10215 
10216 static void
10217 cmd_show_queue_region_info_parsed(void *parsed_result,
10218 			__rte_unused struct cmdline *cl,
10219 			__rte_unused void *data)
10220 {
10221 	struct cmd_show_queue_region_info *res = parsed_result;
10222 	int ret = -ENOTSUP;
10223 #ifdef RTE_NET_I40E
10224 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10225 	enum rte_pmd_i40e_queue_region_op op_type;
10226 #endif
10227 
10228 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10229 		return;
10230 
10231 #ifdef RTE_NET_I40E
10232 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10233 
10234 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10235 
10236 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10237 					op_type, &rte_pmd_regions);
10238 
10239 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10240 #endif
10241 
10242 	switch (ret) {
10243 	case 0:
10244 		break;
10245 	case -ENOTSUP:
10246 		printf("function not implemented or supported\n");
10247 		break;
10248 	default:
10249 		printf("queue region config info show error: (%s)\n",
10250 				strerror(-ret));
10251 	}
10252 }
10253 
10254 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10255 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10256 				show, "show");
10257 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10258 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10259 				port, "port");
10260 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10261 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10262 				port_id, RTE_UINT16);
10263 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10264 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10265 				cmd, "queue-region");
10266 
10267 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10268 	.f = cmd_show_queue_region_info_parsed,
10269 	.data = NULL,
10270 	.help_str = "show port <port_id> queue-region"
10271 		": show all queue region related configuration info",
10272 	.tokens = {
10273 		(void *)&cmd_show_queue_region_info_get,
10274 		(void *)&cmd_show_queue_region_info_port,
10275 		(void *)&cmd_show_queue_region_info_port_index,
10276 		(void *)&cmd_show_queue_region_info_cmd,
10277 		NULL,
10278 	},
10279 };
10280 
10281 /* *** Filters Control *** */
10282 
10283 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10284 do { \
10285 	if ((ip_addr).family == AF_INET) \
10286 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10287 	else { \
10288 		printf("invalid parameter.\n"); \
10289 		return; \
10290 	} \
10291 } while (0)
10292 
10293 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10294 do { \
10295 	if ((ip_addr).family == AF_INET6) \
10296 		rte_memcpy(&(ip), \
10297 				 &((ip_addr).addr.ipv6), \
10298 				 sizeof(struct in6_addr)); \
10299 	else { \
10300 		printf("invalid parameter.\n"); \
10301 		return; \
10302 	} \
10303 } while (0)
10304 
10305 #ifdef RTE_NET_I40E
10306 
10307 static uint16_t
10308 str2flowtype(char *string)
10309 {
10310 	uint8_t i = 0;
10311 	static const struct {
10312 		char str[32];
10313 		uint16_t type;
10314 	} flowtype_str[] = {
10315 		{"raw", RTE_ETH_FLOW_RAW},
10316 		{"ipv4", RTE_ETH_FLOW_IPV4},
10317 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10318 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10319 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10320 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10321 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10322 		{"ipv6", RTE_ETH_FLOW_IPV6},
10323 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10324 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10325 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10326 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10327 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10328 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10329 	};
10330 
10331 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10332 		if (!strcmp(flowtype_str[i].str, string))
10333 			return flowtype_str[i].type;
10334 	}
10335 
10336 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10337 		return (uint16_t)atoi(string);
10338 
10339 	return RTE_ETH_FLOW_UNKNOWN;
10340 }
10341 
10342 /* *** deal with flow director filter *** */
10343 struct cmd_flow_director_result {
10344 	cmdline_fixed_string_t flow_director_filter;
10345 	portid_t port_id;
10346 	cmdline_fixed_string_t mode;
10347 	cmdline_fixed_string_t mode_value;
10348 	cmdline_fixed_string_t ops;
10349 	cmdline_fixed_string_t flow;
10350 	cmdline_fixed_string_t flow_type;
10351 	cmdline_fixed_string_t drop;
10352 	cmdline_fixed_string_t queue;
10353 	uint16_t  queue_id;
10354 	cmdline_fixed_string_t fd_id;
10355 	uint32_t  fd_id_value;
10356 	cmdline_fixed_string_t packet;
10357 	char filepath[];
10358 };
10359 
10360 static void
10361 cmd_flow_director_filter_parsed(void *parsed_result,
10362 			  __rte_unused struct cmdline *cl,
10363 			  __rte_unused void *data)
10364 {
10365 	struct cmd_flow_director_result *res = parsed_result;
10366 	int ret = 0;
10367 	struct rte_pmd_i40e_flow_type_mapping
10368 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10369 	struct rte_pmd_i40e_pkt_template_conf conf;
10370 	uint16_t flow_type = str2flowtype(res->flow_type);
10371 	uint16_t i, port = res->port_id;
10372 	uint8_t add;
10373 
10374 	memset(&conf, 0, sizeof(conf));
10375 
10376 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10377 		printf("Invalid flow type specified.\n");
10378 		return;
10379 	}
10380 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10381 						 mapping);
10382 	if (ret)
10383 		return;
10384 	if (mapping[flow_type].pctype == 0ULL) {
10385 		printf("Invalid flow type specified.\n");
10386 		return;
10387 	}
10388 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10389 		if (mapping[flow_type].pctype & (1ULL << i)) {
10390 			conf.input.pctype = i;
10391 			break;
10392 		}
10393 	}
10394 
10395 	conf.input.packet = open_file(res->filepath,
10396 				&conf.input.length);
10397 	if (!conf.input.packet)
10398 		return;
10399 	if (!strcmp(res->drop, "drop"))
10400 		conf.action.behavior =
10401 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10402 	else
10403 		conf.action.behavior =
10404 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10405 	conf.action.report_status =
10406 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10407 	conf.action.rx_queue = res->queue_id;
10408 	conf.soft_id = res->fd_id_value;
10409 	add  = strcmp(res->ops, "del") ? 1 : 0;
10410 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10411 							&conf,
10412 							add);
10413 	if (ret < 0)
10414 		printf("flow director config error: (%s)\n",
10415 		       strerror(-ret));
10416 	close_file(conf.input.packet);
10417 }
10418 
10419 cmdline_parse_token_string_t cmd_flow_director_filter =
10420 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10421 				 flow_director_filter, "flow_director_filter");
10422 cmdline_parse_token_num_t cmd_flow_director_port_id =
10423 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10424 			      port_id, RTE_UINT16);
10425 cmdline_parse_token_string_t cmd_flow_director_ops =
10426 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10427 				 ops, "add#del#update");
10428 cmdline_parse_token_string_t cmd_flow_director_flow =
10429 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10430 				 flow, "flow");
10431 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10432 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10433 		flow_type, NULL);
10434 cmdline_parse_token_string_t cmd_flow_director_drop =
10435 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10436 				 drop, "drop#fwd");
10437 cmdline_parse_token_string_t cmd_flow_director_queue =
10438 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10439 				 queue, "queue");
10440 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10441 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10442 			      queue_id, RTE_UINT16);
10443 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10444 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10445 				 fd_id, "fd_id");
10446 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10447 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10448 			      fd_id_value, RTE_UINT32);
10449 
10450 cmdline_parse_token_string_t cmd_flow_director_mode =
10451 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10452 				 mode, "mode");
10453 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10454 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10455 				 mode_value, "raw");
10456 cmdline_parse_token_string_t cmd_flow_director_packet =
10457 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10458 				 packet, "packet");
10459 cmdline_parse_token_string_t cmd_flow_director_filepath =
10460 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10461 				 filepath, NULL);
10462 
10463 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10464 	.f = cmd_flow_director_filter_parsed,
10465 	.data = NULL,
10466 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10467 		"director entry on NIC",
10468 	.tokens = {
10469 		(void *)&cmd_flow_director_filter,
10470 		(void *)&cmd_flow_director_port_id,
10471 		(void *)&cmd_flow_director_mode,
10472 		(void *)&cmd_flow_director_mode_raw,
10473 		(void *)&cmd_flow_director_ops,
10474 		(void *)&cmd_flow_director_flow,
10475 		(void *)&cmd_flow_director_flow_type,
10476 		(void *)&cmd_flow_director_drop,
10477 		(void *)&cmd_flow_director_queue,
10478 		(void *)&cmd_flow_director_queue_id,
10479 		(void *)&cmd_flow_director_fd_id,
10480 		(void *)&cmd_flow_director_fd_id_value,
10481 		(void *)&cmd_flow_director_packet,
10482 		(void *)&cmd_flow_director_filepath,
10483 		NULL,
10484 	},
10485 };
10486 
10487 #endif /* RTE_NET_I40E */
10488 
10489 /* *** deal with flow director mask *** */
10490 struct cmd_flow_director_mask_result {
10491 	cmdline_fixed_string_t flow_director_mask;
10492 	portid_t port_id;
10493 	cmdline_fixed_string_t mode;
10494 	cmdline_fixed_string_t mode_value;
10495 	cmdline_fixed_string_t vlan;
10496 	uint16_t vlan_mask;
10497 	cmdline_fixed_string_t src_mask;
10498 	cmdline_ipaddr_t ipv4_src;
10499 	cmdline_ipaddr_t ipv6_src;
10500 	uint16_t port_src;
10501 	cmdline_fixed_string_t dst_mask;
10502 	cmdline_ipaddr_t ipv4_dst;
10503 	cmdline_ipaddr_t ipv6_dst;
10504 	uint16_t port_dst;
10505 	cmdline_fixed_string_t mac;
10506 	uint8_t mac_addr_byte_mask;
10507 	cmdline_fixed_string_t tunnel_id;
10508 	uint32_t tunnel_id_mask;
10509 	cmdline_fixed_string_t tunnel_type;
10510 	uint8_t tunnel_type_mask;
10511 };
10512 
10513 static void
10514 cmd_flow_director_mask_parsed(void *parsed_result,
10515 			  __rte_unused struct cmdline *cl,
10516 			  __rte_unused void *data)
10517 {
10518 	struct cmd_flow_director_mask_result *res = parsed_result;
10519 	struct rte_eth_fdir_masks *mask;
10520 	struct rte_port *port;
10521 
10522 	port = &ports[res->port_id];
10523 	/** Check if the port is not started **/
10524 	if (port->port_status != RTE_PORT_STOPPED) {
10525 		printf("Please stop port %d first\n", res->port_id);
10526 		return;
10527 	}
10528 
10529 	mask = &port->dev_conf.fdir_conf.mask;
10530 
10531 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10532 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10533 			printf("Please set mode to MAC-VLAN.\n");
10534 			return;
10535 		}
10536 
10537 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10538 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10539 		if (strcmp(res->mode_value, "Tunnel")) {
10540 			printf("Please set mode to Tunnel.\n");
10541 			return;
10542 		}
10543 
10544 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10545 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10546 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10547 		mask->tunnel_type_mask = res->tunnel_type_mask;
10548 	} else {
10549 		if (strcmp(res->mode_value, "IP")) {
10550 			printf("Please set mode to IP.\n");
10551 			return;
10552 		}
10553 
10554 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10555 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10556 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10557 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10558 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10559 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10560 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10561 	}
10562 
10563 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10564 }
10565 
10566 cmdline_parse_token_string_t cmd_flow_director_mask =
10567 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10568 				 flow_director_mask, "flow_director_mask");
10569 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10570 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10571 			      port_id, RTE_UINT16);
10572 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10573 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10574 				 vlan, "vlan");
10575 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10576 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10577 			      vlan_mask, RTE_UINT16);
10578 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10579 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10580 				 src_mask, "src_mask");
10581 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10582 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10583 				 ipv4_src);
10584 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10585 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10586 				 ipv6_src);
10587 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10588 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10589 			      port_src, RTE_UINT16);
10590 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10591 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10592 				 dst_mask, "dst_mask");
10593 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10594 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10595 				 ipv4_dst);
10596 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10597 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10598 				 ipv6_dst);
10599 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10600 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10601 			      port_dst, RTE_UINT16);
10602 
10603 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10604 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10605 				 mode, "mode");
10606 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10607 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10608 				 mode_value, "IP");
10609 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10610 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10611 				 mode_value, "MAC-VLAN");
10612 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10613 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10614 				 mode_value, "Tunnel");
10615 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10616 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10617 				 mac, "mac");
10618 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10619 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10620 			      mac_addr_byte_mask, RTE_UINT8);
10621 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10622 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10623 				 tunnel_type, "tunnel-type");
10624 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10625 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10626 			      tunnel_type_mask, RTE_UINT8);
10627 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10628 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10629 				 tunnel_id, "tunnel-id");
10630 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10631 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10632 			      tunnel_id_mask, RTE_UINT32);
10633 
10634 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10635 	.f = cmd_flow_director_mask_parsed,
10636 	.data = NULL,
10637 	.help_str = "flow_director_mask ... : "
10638 		"Set IP mode flow director's mask on NIC",
10639 	.tokens = {
10640 		(void *)&cmd_flow_director_mask,
10641 		(void *)&cmd_flow_director_mask_port_id,
10642 		(void *)&cmd_flow_director_mask_mode,
10643 		(void *)&cmd_flow_director_mask_mode_ip,
10644 		(void *)&cmd_flow_director_mask_vlan,
10645 		(void *)&cmd_flow_director_mask_vlan_value,
10646 		(void *)&cmd_flow_director_mask_src,
10647 		(void *)&cmd_flow_director_mask_ipv4_src,
10648 		(void *)&cmd_flow_director_mask_ipv6_src,
10649 		(void *)&cmd_flow_director_mask_port_src,
10650 		(void *)&cmd_flow_director_mask_dst,
10651 		(void *)&cmd_flow_director_mask_ipv4_dst,
10652 		(void *)&cmd_flow_director_mask_ipv6_dst,
10653 		(void *)&cmd_flow_director_mask_port_dst,
10654 		NULL,
10655 	},
10656 };
10657 
10658 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10659 	.f = cmd_flow_director_mask_parsed,
10660 	.data = NULL,
10661 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10662 		"flow director's mask on NIC",
10663 	.tokens = {
10664 		(void *)&cmd_flow_director_mask,
10665 		(void *)&cmd_flow_director_mask_port_id,
10666 		(void *)&cmd_flow_director_mask_mode,
10667 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10668 		(void *)&cmd_flow_director_mask_vlan,
10669 		(void *)&cmd_flow_director_mask_vlan_value,
10670 		NULL,
10671 	},
10672 };
10673 
10674 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10675 	.f = cmd_flow_director_mask_parsed,
10676 	.data = NULL,
10677 	.help_str = "flow_director_mask ... : Set tunnel mode "
10678 		"flow director's mask on NIC",
10679 	.tokens = {
10680 		(void *)&cmd_flow_director_mask,
10681 		(void *)&cmd_flow_director_mask_port_id,
10682 		(void *)&cmd_flow_director_mask_mode,
10683 		(void *)&cmd_flow_director_mask_mode_tunnel,
10684 		(void *)&cmd_flow_director_mask_vlan,
10685 		(void *)&cmd_flow_director_mask_vlan_value,
10686 		(void *)&cmd_flow_director_mask_mac,
10687 		(void *)&cmd_flow_director_mask_mac_value,
10688 		(void *)&cmd_flow_director_mask_tunnel_type,
10689 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10690 		(void *)&cmd_flow_director_mask_tunnel_id,
10691 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10692 		NULL,
10693 	},
10694 };
10695 
10696 /* *** deal with flow director flexible payload configuration *** */
10697 struct cmd_flow_director_flexpayload_result {
10698 	cmdline_fixed_string_t flow_director_flexpayload;
10699 	portid_t port_id;
10700 	cmdline_fixed_string_t payload_layer;
10701 	cmdline_fixed_string_t payload_cfg;
10702 };
10703 
10704 static inline int
10705 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10706 {
10707 	char s[256];
10708 	const char *p, *p0 = q_arg;
10709 	char *end;
10710 	unsigned long int_fld;
10711 	char *str_fld[max_num];
10712 	int i;
10713 	unsigned size;
10714 	int ret = -1;
10715 
10716 	p = strchr(p0, '(');
10717 	if (p == NULL)
10718 		return -1;
10719 	++p;
10720 	p0 = strchr(p, ')');
10721 	if (p0 == NULL)
10722 		return -1;
10723 
10724 	size = p0 - p;
10725 	if (size >= sizeof(s))
10726 		return -1;
10727 
10728 	snprintf(s, sizeof(s), "%.*s", size, p);
10729 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10730 	if (ret < 0 || ret > max_num)
10731 		return -1;
10732 	for (i = 0; i < ret; i++) {
10733 		errno = 0;
10734 		int_fld = strtoul(str_fld[i], &end, 0);
10735 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10736 			return -1;
10737 		offsets[i] = (uint16_t)int_fld;
10738 	}
10739 	return ret;
10740 }
10741 
10742 static void
10743 cmd_flow_director_flxpld_parsed(void *parsed_result,
10744 			  __rte_unused struct cmdline *cl,
10745 			  __rte_unused void *data)
10746 {
10747 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
10748 	struct rte_eth_flex_payload_cfg flex_cfg;
10749 	struct rte_port *port;
10750 	int ret = 0;
10751 
10752 	port = &ports[res->port_id];
10753 	/** Check if the port is not started **/
10754 	if (port->port_status != RTE_PORT_STOPPED) {
10755 		printf("Please stop port %d first\n", res->port_id);
10756 		return;
10757 	}
10758 
10759 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10760 
10761 	if (!strcmp(res->payload_layer, "raw"))
10762 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10763 	else if (!strcmp(res->payload_layer, "l2"))
10764 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10765 	else if (!strcmp(res->payload_layer, "l3"))
10766 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10767 	else if (!strcmp(res->payload_layer, "l4"))
10768 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10769 
10770 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10771 			    RTE_ETH_FDIR_MAX_FLEXLEN);
10772 	if (ret < 0) {
10773 		printf("error: Cannot parse flex payload input.\n");
10774 		return;
10775 	}
10776 
10777 	fdir_set_flex_payload(res->port_id, &flex_cfg);
10778 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10779 }
10780 
10781 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10782 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10783 				 flow_director_flexpayload,
10784 				 "flow_director_flex_payload");
10785 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10786 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10787 			      port_id, RTE_UINT16);
10788 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10789 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10790 				 payload_layer, "raw#l2#l3#l4");
10791 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10792 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10793 				 payload_cfg, NULL);
10794 
10795 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10796 	.f = cmd_flow_director_flxpld_parsed,
10797 	.data = NULL,
10798 	.help_str = "flow_director_flexpayload ... : "
10799 		"Set flow director's flex payload on NIC",
10800 	.tokens = {
10801 		(void *)&cmd_flow_director_flexpayload,
10802 		(void *)&cmd_flow_director_flexpayload_port_id,
10803 		(void *)&cmd_flow_director_flexpayload_payload_layer,
10804 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
10805 		NULL,
10806 	},
10807 };
10808 
10809 /* Generic flow interface command. */
10810 extern cmdline_parse_inst_t cmd_flow;
10811 
10812 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10813 struct cmd_mcast_addr_result {
10814 	cmdline_fixed_string_t mcast_addr_cmd;
10815 	cmdline_fixed_string_t what;
10816 	uint16_t port_num;
10817 	struct rte_ether_addr mc_addr;
10818 };
10819 
10820 static void cmd_mcast_addr_parsed(void *parsed_result,
10821 		__rte_unused struct cmdline *cl,
10822 		__rte_unused void *data)
10823 {
10824 	struct cmd_mcast_addr_result *res = parsed_result;
10825 
10826 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10827 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10828 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10829 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10830 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10831 		return;
10832 	}
10833 	if (strcmp(res->what, "add") == 0)
10834 		mcast_addr_add(res->port_num, &res->mc_addr);
10835 	else
10836 		mcast_addr_remove(res->port_num, &res->mc_addr);
10837 }
10838 
10839 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10840 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10841 				 mcast_addr_cmd, "mcast_addr");
10842 cmdline_parse_token_string_t cmd_mcast_addr_what =
10843 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10844 				 "add#remove");
10845 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10846 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10847 				 RTE_UINT16);
10848 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10849 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10850 
10851 cmdline_parse_inst_t cmd_mcast_addr = {
10852 	.f = cmd_mcast_addr_parsed,
10853 	.data = (void *)0,
10854 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10855 		"Add/Remove multicast MAC address on port_id",
10856 	.tokens = {
10857 		(void *)&cmd_mcast_addr_cmd,
10858 		(void *)&cmd_mcast_addr_what,
10859 		(void *)&cmd_mcast_addr_portnum,
10860 		(void *)&cmd_mcast_addr_addr,
10861 		NULL,
10862 	},
10863 };
10864 
10865 /* vf vlan anti spoof configuration */
10866 
10867 /* Common result structure for vf vlan anti spoof */
10868 struct cmd_vf_vlan_anti_spoof_result {
10869 	cmdline_fixed_string_t set;
10870 	cmdline_fixed_string_t vf;
10871 	cmdline_fixed_string_t vlan;
10872 	cmdline_fixed_string_t antispoof;
10873 	portid_t port_id;
10874 	uint32_t vf_id;
10875 	cmdline_fixed_string_t on_off;
10876 };
10877 
10878 /* Common CLI fields for vf vlan anti spoof enable disable */
10879 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10880 	TOKEN_STRING_INITIALIZER
10881 		(struct cmd_vf_vlan_anti_spoof_result,
10882 		 set, "set");
10883 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10884 	TOKEN_STRING_INITIALIZER
10885 		(struct cmd_vf_vlan_anti_spoof_result,
10886 		 vf, "vf");
10887 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10888 	TOKEN_STRING_INITIALIZER
10889 		(struct cmd_vf_vlan_anti_spoof_result,
10890 		 vlan, "vlan");
10891 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10892 	TOKEN_STRING_INITIALIZER
10893 		(struct cmd_vf_vlan_anti_spoof_result,
10894 		 antispoof, "antispoof");
10895 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10896 	TOKEN_NUM_INITIALIZER
10897 		(struct cmd_vf_vlan_anti_spoof_result,
10898 		 port_id, RTE_UINT16);
10899 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10900 	TOKEN_NUM_INITIALIZER
10901 		(struct cmd_vf_vlan_anti_spoof_result,
10902 		 vf_id, RTE_UINT32);
10903 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10904 	TOKEN_STRING_INITIALIZER
10905 		(struct cmd_vf_vlan_anti_spoof_result,
10906 		 on_off, "on#off");
10907 
10908 static void
10909 cmd_set_vf_vlan_anti_spoof_parsed(
10910 	void *parsed_result,
10911 	__rte_unused struct cmdline *cl,
10912 	__rte_unused void *data)
10913 {
10914 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10915 	int ret = -ENOTSUP;
10916 
10917 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10918 
10919 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10920 		return;
10921 
10922 #ifdef RTE_NET_IXGBE
10923 	if (ret == -ENOTSUP)
10924 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10925 				res->vf_id, is_on);
10926 #endif
10927 #ifdef RTE_NET_I40E
10928 	if (ret == -ENOTSUP)
10929 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10930 				res->vf_id, is_on);
10931 #endif
10932 #ifdef RTE_NET_BNXT
10933 	if (ret == -ENOTSUP)
10934 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10935 				res->vf_id, is_on);
10936 #endif
10937 
10938 	switch (ret) {
10939 	case 0:
10940 		break;
10941 	case -EINVAL:
10942 		printf("invalid vf_id %d\n", res->vf_id);
10943 		break;
10944 	case -ENODEV:
10945 		printf("invalid port_id %d\n", res->port_id);
10946 		break;
10947 	case -ENOTSUP:
10948 		printf("function not implemented\n");
10949 		break;
10950 	default:
10951 		printf("programming error: (%s)\n", strerror(-ret));
10952 	}
10953 }
10954 
10955 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10956 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
10957 	.data = NULL,
10958 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10959 	.tokens = {
10960 		(void *)&cmd_vf_vlan_anti_spoof_set,
10961 		(void *)&cmd_vf_vlan_anti_spoof_vf,
10962 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
10963 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
10964 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
10965 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
10966 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
10967 		NULL,
10968 	},
10969 };
10970 
10971 /* vf mac anti spoof configuration */
10972 
10973 /* Common result structure for vf mac anti spoof */
10974 struct cmd_vf_mac_anti_spoof_result {
10975 	cmdline_fixed_string_t set;
10976 	cmdline_fixed_string_t vf;
10977 	cmdline_fixed_string_t mac;
10978 	cmdline_fixed_string_t antispoof;
10979 	portid_t port_id;
10980 	uint32_t vf_id;
10981 	cmdline_fixed_string_t on_off;
10982 };
10983 
10984 /* Common CLI fields for vf mac anti spoof enable disable */
10985 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10986 	TOKEN_STRING_INITIALIZER
10987 		(struct cmd_vf_mac_anti_spoof_result,
10988 		 set, "set");
10989 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10990 	TOKEN_STRING_INITIALIZER
10991 		(struct cmd_vf_mac_anti_spoof_result,
10992 		 vf, "vf");
10993 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10994 	TOKEN_STRING_INITIALIZER
10995 		(struct cmd_vf_mac_anti_spoof_result,
10996 		 mac, "mac");
10997 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10998 	TOKEN_STRING_INITIALIZER
10999 		(struct cmd_vf_mac_anti_spoof_result,
11000 		 antispoof, "antispoof");
11001 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11002 	TOKEN_NUM_INITIALIZER
11003 		(struct cmd_vf_mac_anti_spoof_result,
11004 		 port_id, RTE_UINT16);
11005 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11006 	TOKEN_NUM_INITIALIZER
11007 		(struct cmd_vf_mac_anti_spoof_result,
11008 		 vf_id, RTE_UINT32);
11009 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11010 	TOKEN_STRING_INITIALIZER
11011 		(struct cmd_vf_mac_anti_spoof_result,
11012 		 on_off, "on#off");
11013 
11014 static void
11015 cmd_set_vf_mac_anti_spoof_parsed(
11016 	void *parsed_result,
11017 	__rte_unused struct cmdline *cl,
11018 	__rte_unused void *data)
11019 {
11020 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11021 	int ret = -ENOTSUP;
11022 
11023 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11024 
11025 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11026 		return;
11027 
11028 #ifdef RTE_NET_IXGBE
11029 	if (ret == -ENOTSUP)
11030 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11031 			res->vf_id, is_on);
11032 #endif
11033 #ifdef RTE_NET_I40E
11034 	if (ret == -ENOTSUP)
11035 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11036 			res->vf_id, is_on);
11037 #endif
11038 #ifdef RTE_NET_BNXT
11039 	if (ret == -ENOTSUP)
11040 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11041 			res->vf_id, is_on);
11042 #endif
11043 
11044 	switch (ret) {
11045 	case 0:
11046 		break;
11047 	case -EINVAL:
11048 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11049 		break;
11050 	case -ENODEV:
11051 		printf("invalid port_id %d\n", res->port_id);
11052 		break;
11053 	case -ENOTSUP:
11054 		printf("function not implemented\n");
11055 		break;
11056 	default:
11057 		printf("programming error: (%s)\n", strerror(-ret));
11058 	}
11059 }
11060 
11061 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11062 	.f = cmd_set_vf_mac_anti_spoof_parsed,
11063 	.data = NULL,
11064 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11065 	.tokens = {
11066 		(void *)&cmd_vf_mac_anti_spoof_set,
11067 		(void *)&cmd_vf_mac_anti_spoof_vf,
11068 		(void *)&cmd_vf_mac_anti_spoof_mac,
11069 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
11070 		(void *)&cmd_vf_mac_anti_spoof_port_id,
11071 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
11072 		(void *)&cmd_vf_mac_anti_spoof_on_off,
11073 		NULL,
11074 	},
11075 };
11076 
11077 /* vf vlan strip queue configuration */
11078 
11079 /* Common result structure for vf mac anti spoof */
11080 struct cmd_vf_vlan_stripq_result {
11081 	cmdline_fixed_string_t set;
11082 	cmdline_fixed_string_t vf;
11083 	cmdline_fixed_string_t vlan;
11084 	cmdline_fixed_string_t stripq;
11085 	portid_t port_id;
11086 	uint16_t vf_id;
11087 	cmdline_fixed_string_t on_off;
11088 };
11089 
11090 /* Common CLI fields for vf vlan strip enable disable */
11091 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11092 	TOKEN_STRING_INITIALIZER
11093 		(struct cmd_vf_vlan_stripq_result,
11094 		 set, "set");
11095 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11096 	TOKEN_STRING_INITIALIZER
11097 		(struct cmd_vf_vlan_stripq_result,
11098 		 vf, "vf");
11099 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11100 	TOKEN_STRING_INITIALIZER
11101 		(struct cmd_vf_vlan_stripq_result,
11102 		 vlan, "vlan");
11103 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11104 	TOKEN_STRING_INITIALIZER
11105 		(struct cmd_vf_vlan_stripq_result,
11106 		 stripq, "stripq");
11107 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11108 	TOKEN_NUM_INITIALIZER
11109 		(struct cmd_vf_vlan_stripq_result,
11110 		 port_id, RTE_UINT16);
11111 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11112 	TOKEN_NUM_INITIALIZER
11113 		(struct cmd_vf_vlan_stripq_result,
11114 		 vf_id, RTE_UINT16);
11115 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11116 	TOKEN_STRING_INITIALIZER
11117 		(struct cmd_vf_vlan_stripq_result,
11118 		 on_off, "on#off");
11119 
11120 static void
11121 cmd_set_vf_vlan_stripq_parsed(
11122 	void *parsed_result,
11123 	__rte_unused struct cmdline *cl,
11124 	__rte_unused void *data)
11125 {
11126 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
11127 	int ret = -ENOTSUP;
11128 
11129 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11130 
11131 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11132 		return;
11133 
11134 #ifdef RTE_NET_IXGBE
11135 	if (ret == -ENOTSUP)
11136 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11137 			res->vf_id, is_on);
11138 #endif
11139 #ifdef RTE_NET_I40E
11140 	if (ret == -ENOTSUP)
11141 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11142 			res->vf_id, is_on);
11143 #endif
11144 #ifdef RTE_NET_BNXT
11145 	if (ret == -ENOTSUP)
11146 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11147 			res->vf_id, is_on);
11148 #endif
11149 
11150 	switch (ret) {
11151 	case 0:
11152 		break;
11153 	case -EINVAL:
11154 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11155 		break;
11156 	case -ENODEV:
11157 		printf("invalid port_id %d\n", res->port_id);
11158 		break;
11159 	case -ENOTSUP:
11160 		printf("function not implemented\n");
11161 		break;
11162 	default:
11163 		printf("programming error: (%s)\n", strerror(-ret));
11164 	}
11165 }
11166 
11167 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11168 	.f = cmd_set_vf_vlan_stripq_parsed,
11169 	.data = NULL,
11170 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11171 	.tokens = {
11172 		(void *)&cmd_vf_vlan_stripq_set,
11173 		(void *)&cmd_vf_vlan_stripq_vf,
11174 		(void *)&cmd_vf_vlan_stripq_vlan,
11175 		(void *)&cmd_vf_vlan_stripq_stripq,
11176 		(void *)&cmd_vf_vlan_stripq_port_id,
11177 		(void *)&cmd_vf_vlan_stripq_vf_id,
11178 		(void *)&cmd_vf_vlan_stripq_on_off,
11179 		NULL,
11180 	},
11181 };
11182 
11183 /* vf vlan insert configuration */
11184 
11185 /* Common result structure for vf vlan insert */
11186 struct cmd_vf_vlan_insert_result {
11187 	cmdline_fixed_string_t set;
11188 	cmdline_fixed_string_t vf;
11189 	cmdline_fixed_string_t vlan;
11190 	cmdline_fixed_string_t insert;
11191 	portid_t port_id;
11192 	uint16_t vf_id;
11193 	uint16_t vlan_id;
11194 };
11195 
11196 /* Common CLI fields for vf vlan insert enable disable */
11197 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11198 	TOKEN_STRING_INITIALIZER
11199 		(struct cmd_vf_vlan_insert_result,
11200 		 set, "set");
11201 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11202 	TOKEN_STRING_INITIALIZER
11203 		(struct cmd_vf_vlan_insert_result,
11204 		 vf, "vf");
11205 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11206 	TOKEN_STRING_INITIALIZER
11207 		(struct cmd_vf_vlan_insert_result,
11208 		 vlan, "vlan");
11209 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11210 	TOKEN_STRING_INITIALIZER
11211 		(struct cmd_vf_vlan_insert_result,
11212 		 insert, "insert");
11213 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11214 	TOKEN_NUM_INITIALIZER
11215 		(struct cmd_vf_vlan_insert_result,
11216 		 port_id, RTE_UINT16);
11217 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11218 	TOKEN_NUM_INITIALIZER
11219 		(struct cmd_vf_vlan_insert_result,
11220 		 vf_id, RTE_UINT16);
11221 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11222 	TOKEN_NUM_INITIALIZER
11223 		(struct cmd_vf_vlan_insert_result,
11224 		 vlan_id, RTE_UINT16);
11225 
11226 static void
11227 cmd_set_vf_vlan_insert_parsed(
11228 	void *parsed_result,
11229 	__rte_unused struct cmdline *cl,
11230 	__rte_unused void *data)
11231 {
11232 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11233 	int ret = -ENOTSUP;
11234 
11235 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11236 		return;
11237 
11238 #ifdef RTE_NET_IXGBE
11239 	if (ret == -ENOTSUP)
11240 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11241 			res->vlan_id);
11242 #endif
11243 #ifdef RTE_NET_I40E
11244 	if (ret == -ENOTSUP)
11245 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11246 			res->vlan_id);
11247 #endif
11248 #ifdef RTE_NET_BNXT
11249 	if (ret == -ENOTSUP)
11250 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11251 			res->vlan_id);
11252 #endif
11253 
11254 	switch (ret) {
11255 	case 0:
11256 		break;
11257 	case -EINVAL:
11258 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11259 		break;
11260 	case -ENODEV:
11261 		printf("invalid port_id %d\n", res->port_id);
11262 		break;
11263 	case -ENOTSUP:
11264 		printf("function not implemented\n");
11265 		break;
11266 	default:
11267 		printf("programming error: (%s)\n", strerror(-ret));
11268 	}
11269 }
11270 
11271 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11272 	.f = cmd_set_vf_vlan_insert_parsed,
11273 	.data = NULL,
11274 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11275 	.tokens = {
11276 		(void *)&cmd_vf_vlan_insert_set,
11277 		(void *)&cmd_vf_vlan_insert_vf,
11278 		(void *)&cmd_vf_vlan_insert_vlan,
11279 		(void *)&cmd_vf_vlan_insert_insert,
11280 		(void *)&cmd_vf_vlan_insert_port_id,
11281 		(void *)&cmd_vf_vlan_insert_vf_id,
11282 		(void *)&cmd_vf_vlan_insert_vlan_id,
11283 		NULL,
11284 	},
11285 };
11286 
11287 /* tx loopback configuration */
11288 
11289 /* Common result structure for tx loopback */
11290 struct cmd_tx_loopback_result {
11291 	cmdline_fixed_string_t set;
11292 	cmdline_fixed_string_t tx;
11293 	cmdline_fixed_string_t loopback;
11294 	portid_t port_id;
11295 	cmdline_fixed_string_t on_off;
11296 };
11297 
11298 /* Common CLI fields for tx loopback enable disable */
11299 cmdline_parse_token_string_t cmd_tx_loopback_set =
11300 	TOKEN_STRING_INITIALIZER
11301 		(struct cmd_tx_loopback_result,
11302 		 set, "set");
11303 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11304 	TOKEN_STRING_INITIALIZER
11305 		(struct cmd_tx_loopback_result,
11306 		 tx, "tx");
11307 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11308 	TOKEN_STRING_INITIALIZER
11309 		(struct cmd_tx_loopback_result,
11310 		 loopback, "loopback");
11311 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11312 	TOKEN_NUM_INITIALIZER
11313 		(struct cmd_tx_loopback_result,
11314 		 port_id, RTE_UINT16);
11315 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11316 	TOKEN_STRING_INITIALIZER
11317 		(struct cmd_tx_loopback_result,
11318 		 on_off, "on#off");
11319 
11320 static void
11321 cmd_set_tx_loopback_parsed(
11322 	void *parsed_result,
11323 	__rte_unused struct cmdline *cl,
11324 	__rte_unused void *data)
11325 {
11326 	struct cmd_tx_loopback_result *res = parsed_result;
11327 	int ret = -ENOTSUP;
11328 
11329 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11330 
11331 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11332 		return;
11333 
11334 #ifdef RTE_NET_IXGBE
11335 	if (ret == -ENOTSUP)
11336 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11337 #endif
11338 #ifdef RTE_NET_I40E
11339 	if (ret == -ENOTSUP)
11340 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11341 #endif
11342 #ifdef RTE_NET_BNXT
11343 	if (ret == -ENOTSUP)
11344 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11345 #endif
11346 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11347 	if (ret == -ENOTSUP)
11348 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11349 #endif
11350 
11351 	switch (ret) {
11352 	case 0:
11353 		break;
11354 	case -EINVAL:
11355 		printf("invalid is_on %d\n", is_on);
11356 		break;
11357 	case -ENODEV:
11358 		printf("invalid port_id %d\n", res->port_id);
11359 		break;
11360 	case -ENOTSUP:
11361 		printf("function not implemented\n");
11362 		break;
11363 	default:
11364 		printf("programming error: (%s)\n", strerror(-ret));
11365 	}
11366 }
11367 
11368 cmdline_parse_inst_t cmd_set_tx_loopback = {
11369 	.f = cmd_set_tx_loopback_parsed,
11370 	.data = NULL,
11371 	.help_str = "set tx loopback <port_id> on|off",
11372 	.tokens = {
11373 		(void *)&cmd_tx_loopback_set,
11374 		(void *)&cmd_tx_loopback_tx,
11375 		(void *)&cmd_tx_loopback_loopback,
11376 		(void *)&cmd_tx_loopback_port_id,
11377 		(void *)&cmd_tx_loopback_on_off,
11378 		NULL,
11379 	},
11380 };
11381 
11382 /* all queues drop enable configuration */
11383 
11384 /* Common result structure for all queues drop enable */
11385 struct cmd_all_queues_drop_en_result {
11386 	cmdline_fixed_string_t set;
11387 	cmdline_fixed_string_t all;
11388 	cmdline_fixed_string_t queues;
11389 	cmdline_fixed_string_t drop;
11390 	portid_t port_id;
11391 	cmdline_fixed_string_t on_off;
11392 };
11393 
11394 /* Common CLI fields for tx loopback enable disable */
11395 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11396 	TOKEN_STRING_INITIALIZER
11397 		(struct cmd_all_queues_drop_en_result,
11398 		 set, "set");
11399 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11400 	TOKEN_STRING_INITIALIZER
11401 		(struct cmd_all_queues_drop_en_result,
11402 		 all, "all");
11403 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11404 	TOKEN_STRING_INITIALIZER
11405 		(struct cmd_all_queues_drop_en_result,
11406 		 queues, "queues");
11407 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11408 	TOKEN_STRING_INITIALIZER
11409 		(struct cmd_all_queues_drop_en_result,
11410 		 drop, "drop");
11411 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11412 	TOKEN_NUM_INITIALIZER
11413 		(struct cmd_all_queues_drop_en_result,
11414 		 port_id, RTE_UINT16);
11415 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11416 	TOKEN_STRING_INITIALIZER
11417 		(struct cmd_all_queues_drop_en_result,
11418 		 on_off, "on#off");
11419 
11420 static void
11421 cmd_set_all_queues_drop_en_parsed(
11422 	void *parsed_result,
11423 	__rte_unused struct cmdline *cl,
11424 	__rte_unused void *data)
11425 {
11426 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11427 	int ret = -ENOTSUP;
11428 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11429 
11430 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11431 		return;
11432 
11433 #ifdef RTE_NET_IXGBE
11434 	if (ret == -ENOTSUP)
11435 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11436 #endif
11437 #ifdef RTE_NET_BNXT
11438 	if (ret == -ENOTSUP)
11439 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11440 #endif
11441 	switch (ret) {
11442 	case 0:
11443 		break;
11444 	case -EINVAL:
11445 		printf("invalid is_on %d\n", is_on);
11446 		break;
11447 	case -ENODEV:
11448 		printf("invalid port_id %d\n", res->port_id);
11449 		break;
11450 	case -ENOTSUP:
11451 		printf("function not implemented\n");
11452 		break;
11453 	default:
11454 		printf("programming error: (%s)\n", strerror(-ret));
11455 	}
11456 }
11457 
11458 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11459 	.f = cmd_set_all_queues_drop_en_parsed,
11460 	.data = NULL,
11461 	.help_str = "set all queues drop <port_id> on|off",
11462 	.tokens = {
11463 		(void *)&cmd_all_queues_drop_en_set,
11464 		(void *)&cmd_all_queues_drop_en_all,
11465 		(void *)&cmd_all_queues_drop_en_queues,
11466 		(void *)&cmd_all_queues_drop_en_drop,
11467 		(void *)&cmd_all_queues_drop_en_port_id,
11468 		(void *)&cmd_all_queues_drop_en_on_off,
11469 		NULL,
11470 	},
11471 };
11472 
11473 /* vf split drop enable configuration */
11474 
11475 /* Common result structure for vf split drop enable */
11476 struct cmd_vf_split_drop_en_result {
11477 	cmdline_fixed_string_t set;
11478 	cmdline_fixed_string_t vf;
11479 	cmdline_fixed_string_t split;
11480 	cmdline_fixed_string_t drop;
11481 	portid_t port_id;
11482 	uint16_t vf_id;
11483 	cmdline_fixed_string_t on_off;
11484 };
11485 
11486 /* Common CLI fields for vf split drop enable disable */
11487 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11488 	TOKEN_STRING_INITIALIZER
11489 		(struct cmd_vf_split_drop_en_result,
11490 		 set, "set");
11491 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11492 	TOKEN_STRING_INITIALIZER
11493 		(struct cmd_vf_split_drop_en_result,
11494 		 vf, "vf");
11495 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11496 	TOKEN_STRING_INITIALIZER
11497 		(struct cmd_vf_split_drop_en_result,
11498 		 split, "split");
11499 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11500 	TOKEN_STRING_INITIALIZER
11501 		(struct cmd_vf_split_drop_en_result,
11502 		 drop, "drop");
11503 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11504 	TOKEN_NUM_INITIALIZER
11505 		(struct cmd_vf_split_drop_en_result,
11506 		 port_id, RTE_UINT16);
11507 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11508 	TOKEN_NUM_INITIALIZER
11509 		(struct cmd_vf_split_drop_en_result,
11510 		 vf_id, RTE_UINT16);
11511 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11512 	TOKEN_STRING_INITIALIZER
11513 		(struct cmd_vf_split_drop_en_result,
11514 		 on_off, "on#off");
11515 
11516 static void
11517 cmd_set_vf_split_drop_en_parsed(
11518 	void *parsed_result,
11519 	__rte_unused struct cmdline *cl,
11520 	__rte_unused void *data)
11521 {
11522 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11523 	int ret = -ENOTSUP;
11524 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11525 
11526 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11527 		return;
11528 
11529 #ifdef RTE_NET_IXGBE
11530 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11531 			is_on);
11532 #endif
11533 	switch (ret) {
11534 	case 0:
11535 		break;
11536 	case -EINVAL:
11537 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11538 		break;
11539 	case -ENODEV:
11540 		printf("invalid port_id %d\n", res->port_id);
11541 		break;
11542 	case -ENOTSUP:
11543 		printf("not supported on port %d\n", res->port_id);
11544 		break;
11545 	default:
11546 		printf("programming error: (%s)\n", strerror(-ret));
11547 	}
11548 }
11549 
11550 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11551 	.f = cmd_set_vf_split_drop_en_parsed,
11552 	.data = NULL,
11553 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11554 	.tokens = {
11555 		(void *)&cmd_vf_split_drop_en_set,
11556 		(void *)&cmd_vf_split_drop_en_vf,
11557 		(void *)&cmd_vf_split_drop_en_split,
11558 		(void *)&cmd_vf_split_drop_en_drop,
11559 		(void *)&cmd_vf_split_drop_en_port_id,
11560 		(void *)&cmd_vf_split_drop_en_vf_id,
11561 		(void *)&cmd_vf_split_drop_en_on_off,
11562 		NULL,
11563 	},
11564 };
11565 
11566 /* vf mac address configuration */
11567 
11568 /* Common result structure for vf mac address */
11569 struct cmd_set_vf_mac_addr_result {
11570 	cmdline_fixed_string_t set;
11571 	cmdline_fixed_string_t vf;
11572 	cmdline_fixed_string_t mac;
11573 	cmdline_fixed_string_t addr;
11574 	portid_t port_id;
11575 	uint16_t vf_id;
11576 	struct rte_ether_addr mac_addr;
11577 
11578 };
11579 
11580 /* Common CLI fields for vf split drop enable disable */
11581 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11582 	TOKEN_STRING_INITIALIZER
11583 		(struct cmd_set_vf_mac_addr_result,
11584 		 set, "set");
11585 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11586 	TOKEN_STRING_INITIALIZER
11587 		(struct cmd_set_vf_mac_addr_result,
11588 		 vf, "vf");
11589 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11590 	TOKEN_STRING_INITIALIZER
11591 		(struct cmd_set_vf_mac_addr_result,
11592 		 mac, "mac");
11593 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11594 	TOKEN_STRING_INITIALIZER
11595 		(struct cmd_set_vf_mac_addr_result,
11596 		 addr, "addr");
11597 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11598 	TOKEN_NUM_INITIALIZER
11599 		(struct cmd_set_vf_mac_addr_result,
11600 		 port_id, RTE_UINT16);
11601 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11602 	TOKEN_NUM_INITIALIZER
11603 		(struct cmd_set_vf_mac_addr_result,
11604 		 vf_id, RTE_UINT16);
11605 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11606 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11607 		 mac_addr);
11608 
11609 static void
11610 cmd_set_vf_mac_addr_parsed(
11611 	void *parsed_result,
11612 	__rte_unused struct cmdline *cl,
11613 	__rte_unused void *data)
11614 {
11615 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11616 	int ret = -ENOTSUP;
11617 
11618 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11619 		return;
11620 
11621 #ifdef RTE_NET_IXGBE
11622 	if (ret == -ENOTSUP)
11623 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11624 				&res->mac_addr);
11625 #endif
11626 #ifdef RTE_NET_I40E
11627 	if (ret == -ENOTSUP)
11628 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11629 				&res->mac_addr);
11630 #endif
11631 #ifdef RTE_NET_BNXT
11632 	if (ret == -ENOTSUP)
11633 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11634 				&res->mac_addr);
11635 #endif
11636 
11637 	switch (ret) {
11638 	case 0:
11639 		break;
11640 	case -EINVAL:
11641 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11642 		break;
11643 	case -ENODEV:
11644 		printf("invalid port_id %d\n", res->port_id);
11645 		break;
11646 	case -ENOTSUP:
11647 		printf("function not implemented\n");
11648 		break;
11649 	default:
11650 		printf("programming error: (%s)\n", strerror(-ret));
11651 	}
11652 }
11653 
11654 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11655 	.f = cmd_set_vf_mac_addr_parsed,
11656 	.data = NULL,
11657 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11658 	.tokens = {
11659 		(void *)&cmd_set_vf_mac_addr_set,
11660 		(void *)&cmd_set_vf_mac_addr_vf,
11661 		(void *)&cmd_set_vf_mac_addr_mac,
11662 		(void *)&cmd_set_vf_mac_addr_addr,
11663 		(void *)&cmd_set_vf_mac_addr_port_id,
11664 		(void *)&cmd_set_vf_mac_addr_vf_id,
11665 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11666 		NULL,
11667 	},
11668 };
11669 
11670 /* MACsec configuration */
11671 
11672 /* Common result structure for MACsec offload enable */
11673 struct cmd_macsec_offload_on_result {
11674 	cmdline_fixed_string_t set;
11675 	cmdline_fixed_string_t macsec;
11676 	cmdline_fixed_string_t offload;
11677 	portid_t port_id;
11678 	cmdline_fixed_string_t on;
11679 	cmdline_fixed_string_t encrypt;
11680 	cmdline_fixed_string_t en_on_off;
11681 	cmdline_fixed_string_t replay_protect;
11682 	cmdline_fixed_string_t rp_on_off;
11683 };
11684 
11685 /* Common CLI fields for MACsec offload disable */
11686 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11687 	TOKEN_STRING_INITIALIZER
11688 		(struct cmd_macsec_offload_on_result,
11689 		 set, "set");
11690 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11691 	TOKEN_STRING_INITIALIZER
11692 		(struct cmd_macsec_offload_on_result,
11693 		 macsec, "macsec");
11694 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11695 	TOKEN_STRING_INITIALIZER
11696 		(struct cmd_macsec_offload_on_result,
11697 		 offload, "offload");
11698 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11699 	TOKEN_NUM_INITIALIZER
11700 		(struct cmd_macsec_offload_on_result,
11701 		 port_id, RTE_UINT16);
11702 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11703 	TOKEN_STRING_INITIALIZER
11704 		(struct cmd_macsec_offload_on_result,
11705 		 on, "on");
11706 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11707 	TOKEN_STRING_INITIALIZER
11708 		(struct cmd_macsec_offload_on_result,
11709 		 encrypt, "encrypt");
11710 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11711 	TOKEN_STRING_INITIALIZER
11712 		(struct cmd_macsec_offload_on_result,
11713 		 en_on_off, "on#off");
11714 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11715 	TOKEN_STRING_INITIALIZER
11716 		(struct cmd_macsec_offload_on_result,
11717 		 replay_protect, "replay-protect");
11718 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11719 	TOKEN_STRING_INITIALIZER
11720 		(struct cmd_macsec_offload_on_result,
11721 		 rp_on_off, "on#off");
11722 
11723 static void
11724 cmd_set_macsec_offload_on_parsed(
11725 	void *parsed_result,
11726 	__rte_unused struct cmdline *cl,
11727 	__rte_unused void *data)
11728 {
11729 	struct cmd_macsec_offload_on_result *res = parsed_result;
11730 	int ret = -ENOTSUP;
11731 	portid_t port_id = res->port_id;
11732 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11733 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11734 	struct rte_eth_dev_info dev_info;
11735 
11736 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11737 		return;
11738 	if (!port_is_stopped(port_id)) {
11739 		printf("Please stop port %d first\n", port_id);
11740 		return;
11741 	}
11742 
11743 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11744 	if (ret != 0)
11745 		return;
11746 
11747 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11748 #ifdef RTE_NET_IXGBE
11749 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11750 #endif
11751 	}
11752 	RTE_SET_USED(en);
11753 	RTE_SET_USED(rp);
11754 
11755 	switch (ret) {
11756 	case 0:
11757 		ports[port_id].dev_conf.txmode.offloads |=
11758 						DEV_TX_OFFLOAD_MACSEC_INSERT;
11759 		cmd_reconfig_device_queue(port_id, 1, 1);
11760 		break;
11761 	case -ENODEV:
11762 		printf("invalid port_id %d\n", port_id);
11763 		break;
11764 	case -ENOTSUP:
11765 		printf("not supported on port %d\n", port_id);
11766 		break;
11767 	default:
11768 		printf("programming error: (%s)\n", strerror(-ret));
11769 	}
11770 }
11771 
11772 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11773 	.f = cmd_set_macsec_offload_on_parsed,
11774 	.data = NULL,
11775 	.help_str = "set macsec offload <port_id> on "
11776 		"encrypt on|off replay-protect on|off",
11777 	.tokens = {
11778 		(void *)&cmd_macsec_offload_on_set,
11779 		(void *)&cmd_macsec_offload_on_macsec,
11780 		(void *)&cmd_macsec_offload_on_offload,
11781 		(void *)&cmd_macsec_offload_on_port_id,
11782 		(void *)&cmd_macsec_offload_on_on,
11783 		(void *)&cmd_macsec_offload_on_encrypt,
11784 		(void *)&cmd_macsec_offload_on_en_on_off,
11785 		(void *)&cmd_macsec_offload_on_replay_protect,
11786 		(void *)&cmd_macsec_offload_on_rp_on_off,
11787 		NULL,
11788 	},
11789 };
11790 
11791 /* Common result structure for MACsec offload disable */
11792 struct cmd_macsec_offload_off_result {
11793 	cmdline_fixed_string_t set;
11794 	cmdline_fixed_string_t macsec;
11795 	cmdline_fixed_string_t offload;
11796 	portid_t port_id;
11797 	cmdline_fixed_string_t off;
11798 };
11799 
11800 /* Common CLI fields for MACsec offload disable */
11801 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11802 	TOKEN_STRING_INITIALIZER
11803 		(struct cmd_macsec_offload_off_result,
11804 		 set, "set");
11805 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11806 	TOKEN_STRING_INITIALIZER
11807 		(struct cmd_macsec_offload_off_result,
11808 		 macsec, "macsec");
11809 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11810 	TOKEN_STRING_INITIALIZER
11811 		(struct cmd_macsec_offload_off_result,
11812 		 offload, "offload");
11813 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11814 	TOKEN_NUM_INITIALIZER
11815 		(struct cmd_macsec_offload_off_result,
11816 		 port_id, RTE_UINT16);
11817 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11818 	TOKEN_STRING_INITIALIZER
11819 		(struct cmd_macsec_offload_off_result,
11820 		 off, "off");
11821 
11822 static void
11823 cmd_set_macsec_offload_off_parsed(
11824 	void *parsed_result,
11825 	__rte_unused struct cmdline *cl,
11826 	__rte_unused void *data)
11827 {
11828 	struct cmd_macsec_offload_off_result *res = parsed_result;
11829 	int ret = -ENOTSUP;
11830 	struct rte_eth_dev_info dev_info;
11831 	portid_t port_id = res->port_id;
11832 
11833 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11834 		return;
11835 	if (!port_is_stopped(port_id)) {
11836 		printf("Please stop port %d first\n", port_id);
11837 		return;
11838 	}
11839 
11840 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11841 	if (ret != 0)
11842 		return;
11843 
11844 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11845 #ifdef RTE_NET_IXGBE
11846 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
11847 #endif
11848 	}
11849 	switch (ret) {
11850 	case 0:
11851 		ports[port_id].dev_conf.txmode.offloads &=
11852 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
11853 		cmd_reconfig_device_queue(port_id, 1, 1);
11854 		break;
11855 	case -ENODEV:
11856 		printf("invalid port_id %d\n", port_id);
11857 		break;
11858 	case -ENOTSUP:
11859 		printf("not supported on port %d\n", port_id);
11860 		break;
11861 	default:
11862 		printf("programming error: (%s)\n", strerror(-ret));
11863 	}
11864 }
11865 
11866 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11867 	.f = cmd_set_macsec_offload_off_parsed,
11868 	.data = NULL,
11869 	.help_str = "set macsec offload <port_id> off",
11870 	.tokens = {
11871 		(void *)&cmd_macsec_offload_off_set,
11872 		(void *)&cmd_macsec_offload_off_macsec,
11873 		(void *)&cmd_macsec_offload_off_offload,
11874 		(void *)&cmd_macsec_offload_off_port_id,
11875 		(void *)&cmd_macsec_offload_off_off,
11876 		NULL,
11877 	},
11878 };
11879 
11880 /* Common result structure for MACsec secure connection configure */
11881 struct cmd_macsec_sc_result {
11882 	cmdline_fixed_string_t set;
11883 	cmdline_fixed_string_t macsec;
11884 	cmdline_fixed_string_t sc;
11885 	cmdline_fixed_string_t tx_rx;
11886 	portid_t port_id;
11887 	struct rte_ether_addr mac;
11888 	uint16_t pi;
11889 };
11890 
11891 /* Common CLI fields for MACsec secure connection configure */
11892 cmdline_parse_token_string_t cmd_macsec_sc_set =
11893 	TOKEN_STRING_INITIALIZER
11894 		(struct cmd_macsec_sc_result,
11895 		 set, "set");
11896 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11897 	TOKEN_STRING_INITIALIZER
11898 		(struct cmd_macsec_sc_result,
11899 		 macsec, "macsec");
11900 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11901 	TOKEN_STRING_INITIALIZER
11902 		(struct cmd_macsec_sc_result,
11903 		 sc, "sc");
11904 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11905 	TOKEN_STRING_INITIALIZER
11906 		(struct cmd_macsec_sc_result,
11907 		 tx_rx, "tx#rx");
11908 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11909 	TOKEN_NUM_INITIALIZER
11910 		(struct cmd_macsec_sc_result,
11911 		 port_id, RTE_UINT16);
11912 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11913 	TOKEN_ETHERADDR_INITIALIZER
11914 		(struct cmd_macsec_sc_result,
11915 		 mac);
11916 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11917 	TOKEN_NUM_INITIALIZER
11918 		(struct cmd_macsec_sc_result,
11919 		 pi, RTE_UINT16);
11920 
11921 static void
11922 cmd_set_macsec_sc_parsed(
11923 	void *parsed_result,
11924 	__rte_unused struct cmdline *cl,
11925 	__rte_unused void *data)
11926 {
11927 	struct cmd_macsec_sc_result *res = parsed_result;
11928 	int ret = -ENOTSUP;
11929 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11930 
11931 #ifdef RTE_NET_IXGBE
11932 	ret = is_tx ?
11933 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11934 				res->mac.addr_bytes) :
11935 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11936 				res->mac.addr_bytes, res->pi);
11937 #endif
11938 	RTE_SET_USED(is_tx);
11939 
11940 	switch (ret) {
11941 	case 0:
11942 		break;
11943 	case -ENODEV:
11944 		printf("invalid port_id %d\n", res->port_id);
11945 		break;
11946 	case -ENOTSUP:
11947 		printf("not supported on port %d\n", res->port_id);
11948 		break;
11949 	default:
11950 		printf("programming error: (%s)\n", strerror(-ret));
11951 	}
11952 }
11953 
11954 cmdline_parse_inst_t cmd_set_macsec_sc = {
11955 	.f = cmd_set_macsec_sc_parsed,
11956 	.data = NULL,
11957 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11958 	.tokens = {
11959 		(void *)&cmd_macsec_sc_set,
11960 		(void *)&cmd_macsec_sc_macsec,
11961 		(void *)&cmd_macsec_sc_sc,
11962 		(void *)&cmd_macsec_sc_tx_rx,
11963 		(void *)&cmd_macsec_sc_port_id,
11964 		(void *)&cmd_macsec_sc_mac,
11965 		(void *)&cmd_macsec_sc_pi,
11966 		NULL,
11967 	},
11968 };
11969 
11970 /* Common result structure for MACsec secure connection configure */
11971 struct cmd_macsec_sa_result {
11972 	cmdline_fixed_string_t set;
11973 	cmdline_fixed_string_t macsec;
11974 	cmdline_fixed_string_t sa;
11975 	cmdline_fixed_string_t tx_rx;
11976 	portid_t port_id;
11977 	uint8_t idx;
11978 	uint8_t an;
11979 	uint32_t pn;
11980 	cmdline_fixed_string_t key;
11981 };
11982 
11983 /* Common CLI fields for MACsec secure connection configure */
11984 cmdline_parse_token_string_t cmd_macsec_sa_set =
11985 	TOKEN_STRING_INITIALIZER
11986 		(struct cmd_macsec_sa_result,
11987 		 set, "set");
11988 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11989 	TOKEN_STRING_INITIALIZER
11990 		(struct cmd_macsec_sa_result,
11991 		 macsec, "macsec");
11992 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11993 	TOKEN_STRING_INITIALIZER
11994 		(struct cmd_macsec_sa_result,
11995 		 sa, "sa");
11996 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11997 	TOKEN_STRING_INITIALIZER
11998 		(struct cmd_macsec_sa_result,
11999 		 tx_rx, "tx#rx");
12000 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12001 	TOKEN_NUM_INITIALIZER
12002 		(struct cmd_macsec_sa_result,
12003 		 port_id, RTE_UINT16);
12004 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12005 	TOKEN_NUM_INITIALIZER
12006 		(struct cmd_macsec_sa_result,
12007 		 idx, RTE_UINT8);
12008 cmdline_parse_token_num_t cmd_macsec_sa_an =
12009 	TOKEN_NUM_INITIALIZER
12010 		(struct cmd_macsec_sa_result,
12011 		 an, RTE_UINT8);
12012 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12013 	TOKEN_NUM_INITIALIZER
12014 		(struct cmd_macsec_sa_result,
12015 		 pn, RTE_UINT32);
12016 cmdline_parse_token_string_t cmd_macsec_sa_key =
12017 	TOKEN_STRING_INITIALIZER
12018 		(struct cmd_macsec_sa_result,
12019 		 key, NULL);
12020 
12021 static void
12022 cmd_set_macsec_sa_parsed(
12023 	void *parsed_result,
12024 	__rte_unused struct cmdline *cl,
12025 	__rte_unused void *data)
12026 {
12027 	struct cmd_macsec_sa_result *res = parsed_result;
12028 	int ret = -ENOTSUP;
12029 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12030 	uint8_t key[16] = { 0 };
12031 	uint8_t xdgt0;
12032 	uint8_t xdgt1;
12033 	int key_len;
12034 	int i;
12035 
12036 	key_len = strlen(res->key) / 2;
12037 	if (key_len > 16)
12038 		key_len = 16;
12039 
12040 	for (i = 0; i < key_len; i++) {
12041 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12042 		if (xdgt0 == 0xFF)
12043 			return;
12044 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12045 		if (xdgt1 == 0xFF)
12046 			return;
12047 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12048 	}
12049 
12050 #ifdef RTE_NET_IXGBE
12051 	ret = is_tx ?
12052 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12053 			res->idx, res->an, res->pn, key) :
12054 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12055 			res->idx, res->an, res->pn, key);
12056 #endif
12057 	RTE_SET_USED(is_tx);
12058 	RTE_SET_USED(key);
12059 
12060 	switch (ret) {
12061 	case 0:
12062 		break;
12063 	case -EINVAL:
12064 		printf("invalid idx %d or an %d\n", res->idx, res->an);
12065 		break;
12066 	case -ENODEV:
12067 		printf("invalid port_id %d\n", res->port_id);
12068 		break;
12069 	case -ENOTSUP:
12070 		printf("not supported on port %d\n", res->port_id);
12071 		break;
12072 	default:
12073 		printf("programming error: (%s)\n", strerror(-ret));
12074 	}
12075 }
12076 
12077 cmdline_parse_inst_t cmd_set_macsec_sa = {
12078 	.f = cmd_set_macsec_sa_parsed,
12079 	.data = NULL,
12080 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12081 	.tokens = {
12082 		(void *)&cmd_macsec_sa_set,
12083 		(void *)&cmd_macsec_sa_macsec,
12084 		(void *)&cmd_macsec_sa_sa,
12085 		(void *)&cmd_macsec_sa_tx_rx,
12086 		(void *)&cmd_macsec_sa_port_id,
12087 		(void *)&cmd_macsec_sa_idx,
12088 		(void *)&cmd_macsec_sa_an,
12089 		(void *)&cmd_macsec_sa_pn,
12090 		(void *)&cmd_macsec_sa_key,
12091 		NULL,
12092 	},
12093 };
12094 
12095 /* VF unicast promiscuous mode configuration */
12096 
12097 /* Common result structure for VF unicast promiscuous mode */
12098 struct cmd_vf_promisc_result {
12099 	cmdline_fixed_string_t set;
12100 	cmdline_fixed_string_t vf;
12101 	cmdline_fixed_string_t promisc;
12102 	portid_t port_id;
12103 	uint32_t vf_id;
12104 	cmdline_fixed_string_t on_off;
12105 };
12106 
12107 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12108 cmdline_parse_token_string_t cmd_vf_promisc_set =
12109 	TOKEN_STRING_INITIALIZER
12110 		(struct cmd_vf_promisc_result,
12111 		 set, "set");
12112 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12113 	TOKEN_STRING_INITIALIZER
12114 		(struct cmd_vf_promisc_result,
12115 		 vf, "vf");
12116 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12117 	TOKEN_STRING_INITIALIZER
12118 		(struct cmd_vf_promisc_result,
12119 		 promisc, "promisc");
12120 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12121 	TOKEN_NUM_INITIALIZER
12122 		(struct cmd_vf_promisc_result,
12123 		 port_id, RTE_UINT16);
12124 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12125 	TOKEN_NUM_INITIALIZER
12126 		(struct cmd_vf_promisc_result,
12127 		 vf_id, RTE_UINT32);
12128 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12129 	TOKEN_STRING_INITIALIZER
12130 		(struct cmd_vf_promisc_result,
12131 		 on_off, "on#off");
12132 
12133 static void
12134 cmd_set_vf_promisc_parsed(
12135 	void *parsed_result,
12136 	__rte_unused struct cmdline *cl,
12137 	__rte_unused void *data)
12138 {
12139 	struct cmd_vf_promisc_result *res = parsed_result;
12140 	int ret = -ENOTSUP;
12141 
12142 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12143 
12144 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12145 		return;
12146 
12147 #ifdef RTE_NET_I40E
12148 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12149 						  res->vf_id, is_on);
12150 #endif
12151 
12152 	switch (ret) {
12153 	case 0:
12154 		break;
12155 	case -EINVAL:
12156 		printf("invalid vf_id %d\n", res->vf_id);
12157 		break;
12158 	case -ENODEV:
12159 		printf("invalid port_id %d\n", res->port_id);
12160 		break;
12161 	case -ENOTSUP:
12162 		printf("function not implemented\n");
12163 		break;
12164 	default:
12165 		printf("programming error: (%s)\n", strerror(-ret));
12166 	}
12167 }
12168 
12169 cmdline_parse_inst_t cmd_set_vf_promisc = {
12170 	.f = cmd_set_vf_promisc_parsed,
12171 	.data = NULL,
12172 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
12173 		"Set unicast promiscuous mode for a VF from the PF",
12174 	.tokens = {
12175 		(void *)&cmd_vf_promisc_set,
12176 		(void *)&cmd_vf_promisc_vf,
12177 		(void *)&cmd_vf_promisc_promisc,
12178 		(void *)&cmd_vf_promisc_port_id,
12179 		(void *)&cmd_vf_promisc_vf_id,
12180 		(void *)&cmd_vf_promisc_on_off,
12181 		NULL,
12182 	},
12183 };
12184 
12185 /* VF multicast promiscuous mode configuration */
12186 
12187 /* Common result structure for VF multicast promiscuous mode */
12188 struct cmd_vf_allmulti_result {
12189 	cmdline_fixed_string_t set;
12190 	cmdline_fixed_string_t vf;
12191 	cmdline_fixed_string_t allmulti;
12192 	portid_t port_id;
12193 	uint32_t vf_id;
12194 	cmdline_fixed_string_t on_off;
12195 };
12196 
12197 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12198 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12199 	TOKEN_STRING_INITIALIZER
12200 		(struct cmd_vf_allmulti_result,
12201 		 set, "set");
12202 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12203 	TOKEN_STRING_INITIALIZER
12204 		(struct cmd_vf_allmulti_result,
12205 		 vf, "vf");
12206 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12207 	TOKEN_STRING_INITIALIZER
12208 		(struct cmd_vf_allmulti_result,
12209 		 allmulti, "allmulti");
12210 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12211 	TOKEN_NUM_INITIALIZER
12212 		(struct cmd_vf_allmulti_result,
12213 		 port_id, RTE_UINT16);
12214 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12215 	TOKEN_NUM_INITIALIZER
12216 		(struct cmd_vf_allmulti_result,
12217 		 vf_id, RTE_UINT32);
12218 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12219 	TOKEN_STRING_INITIALIZER
12220 		(struct cmd_vf_allmulti_result,
12221 		 on_off, "on#off");
12222 
12223 static void
12224 cmd_set_vf_allmulti_parsed(
12225 	void *parsed_result,
12226 	__rte_unused struct cmdline *cl,
12227 	__rte_unused void *data)
12228 {
12229 	struct cmd_vf_allmulti_result *res = parsed_result;
12230 	int ret = -ENOTSUP;
12231 
12232 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12233 
12234 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12235 		return;
12236 
12237 #ifdef RTE_NET_I40E
12238 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12239 						    res->vf_id, is_on);
12240 #endif
12241 
12242 	switch (ret) {
12243 	case 0:
12244 		break;
12245 	case -EINVAL:
12246 		printf("invalid vf_id %d\n", res->vf_id);
12247 		break;
12248 	case -ENODEV:
12249 		printf("invalid port_id %d\n", res->port_id);
12250 		break;
12251 	case -ENOTSUP:
12252 		printf("function not implemented\n");
12253 		break;
12254 	default:
12255 		printf("programming error: (%s)\n", strerror(-ret));
12256 	}
12257 }
12258 
12259 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12260 	.f = cmd_set_vf_allmulti_parsed,
12261 	.data = NULL,
12262 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12263 		"Set multicast promiscuous mode for a VF from the PF",
12264 	.tokens = {
12265 		(void *)&cmd_vf_allmulti_set,
12266 		(void *)&cmd_vf_allmulti_vf,
12267 		(void *)&cmd_vf_allmulti_allmulti,
12268 		(void *)&cmd_vf_allmulti_port_id,
12269 		(void *)&cmd_vf_allmulti_vf_id,
12270 		(void *)&cmd_vf_allmulti_on_off,
12271 		NULL,
12272 	},
12273 };
12274 
12275 /* vf broadcast mode configuration */
12276 
12277 /* Common result structure for vf broadcast */
12278 struct cmd_set_vf_broadcast_result {
12279 	cmdline_fixed_string_t set;
12280 	cmdline_fixed_string_t vf;
12281 	cmdline_fixed_string_t broadcast;
12282 	portid_t port_id;
12283 	uint16_t vf_id;
12284 	cmdline_fixed_string_t on_off;
12285 };
12286 
12287 /* Common CLI fields for vf broadcast enable disable */
12288 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12289 	TOKEN_STRING_INITIALIZER
12290 		(struct cmd_set_vf_broadcast_result,
12291 		 set, "set");
12292 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12293 	TOKEN_STRING_INITIALIZER
12294 		(struct cmd_set_vf_broadcast_result,
12295 		 vf, "vf");
12296 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12297 	TOKEN_STRING_INITIALIZER
12298 		(struct cmd_set_vf_broadcast_result,
12299 		 broadcast, "broadcast");
12300 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12301 	TOKEN_NUM_INITIALIZER
12302 		(struct cmd_set_vf_broadcast_result,
12303 		 port_id, RTE_UINT16);
12304 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12305 	TOKEN_NUM_INITIALIZER
12306 		(struct cmd_set_vf_broadcast_result,
12307 		 vf_id, RTE_UINT16);
12308 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12309 	TOKEN_STRING_INITIALIZER
12310 		(struct cmd_set_vf_broadcast_result,
12311 		 on_off, "on#off");
12312 
12313 static void
12314 cmd_set_vf_broadcast_parsed(
12315 	void *parsed_result,
12316 	__rte_unused struct cmdline *cl,
12317 	__rte_unused void *data)
12318 {
12319 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12320 	int ret = -ENOTSUP;
12321 
12322 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12323 
12324 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12325 		return;
12326 
12327 #ifdef RTE_NET_I40E
12328 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12329 					    res->vf_id, is_on);
12330 #endif
12331 
12332 	switch (ret) {
12333 	case 0:
12334 		break;
12335 	case -EINVAL:
12336 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12337 		break;
12338 	case -ENODEV:
12339 		printf("invalid port_id %d\n", res->port_id);
12340 		break;
12341 	case -ENOTSUP:
12342 		printf("function not implemented\n");
12343 		break;
12344 	default:
12345 		printf("programming error: (%s)\n", strerror(-ret));
12346 	}
12347 }
12348 
12349 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12350 	.f = cmd_set_vf_broadcast_parsed,
12351 	.data = NULL,
12352 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12353 	.tokens = {
12354 		(void *)&cmd_set_vf_broadcast_set,
12355 		(void *)&cmd_set_vf_broadcast_vf,
12356 		(void *)&cmd_set_vf_broadcast_broadcast,
12357 		(void *)&cmd_set_vf_broadcast_port_id,
12358 		(void *)&cmd_set_vf_broadcast_vf_id,
12359 		(void *)&cmd_set_vf_broadcast_on_off,
12360 		NULL,
12361 	},
12362 };
12363 
12364 /* vf vlan tag configuration */
12365 
12366 /* Common result structure for vf vlan tag */
12367 struct cmd_set_vf_vlan_tag_result {
12368 	cmdline_fixed_string_t set;
12369 	cmdline_fixed_string_t vf;
12370 	cmdline_fixed_string_t vlan;
12371 	cmdline_fixed_string_t tag;
12372 	portid_t port_id;
12373 	uint16_t vf_id;
12374 	cmdline_fixed_string_t on_off;
12375 };
12376 
12377 /* Common CLI fields for vf vlan tag enable disable */
12378 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12379 	TOKEN_STRING_INITIALIZER
12380 		(struct cmd_set_vf_vlan_tag_result,
12381 		 set, "set");
12382 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12383 	TOKEN_STRING_INITIALIZER
12384 		(struct cmd_set_vf_vlan_tag_result,
12385 		 vf, "vf");
12386 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12387 	TOKEN_STRING_INITIALIZER
12388 		(struct cmd_set_vf_vlan_tag_result,
12389 		 vlan, "vlan");
12390 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12391 	TOKEN_STRING_INITIALIZER
12392 		(struct cmd_set_vf_vlan_tag_result,
12393 		 tag, "tag");
12394 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12395 	TOKEN_NUM_INITIALIZER
12396 		(struct cmd_set_vf_vlan_tag_result,
12397 		 port_id, RTE_UINT16);
12398 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12399 	TOKEN_NUM_INITIALIZER
12400 		(struct cmd_set_vf_vlan_tag_result,
12401 		 vf_id, RTE_UINT16);
12402 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12403 	TOKEN_STRING_INITIALIZER
12404 		(struct cmd_set_vf_vlan_tag_result,
12405 		 on_off, "on#off");
12406 
12407 static void
12408 cmd_set_vf_vlan_tag_parsed(
12409 	void *parsed_result,
12410 	__rte_unused struct cmdline *cl,
12411 	__rte_unused void *data)
12412 {
12413 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12414 	int ret = -ENOTSUP;
12415 
12416 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12417 
12418 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12419 		return;
12420 
12421 #ifdef RTE_NET_I40E
12422 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12423 					   res->vf_id, is_on);
12424 #endif
12425 
12426 	switch (ret) {
12427 	case 0:
12428 		break;
12429 	case -EINVAL:
12430 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12431 		break;
12432 	case -ENODEV:
12433 		printf("invalid port_id %d\n", res->port_id);
12434 		break;
12435 	case -ENOTSUP:
12436 		printf("function not implemented\n");
12437 		break;
12438 	default:
12439 		printf("programming error: (%s)\n", strerror(-ret));
12440 	}
12441 }
12442 
12443 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12444 	.f = cmd_set_vf_vlan_tag_parsed,
12445 	.data = NULL,
12446 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12447 	.tokens = {
12448 		(void *)&cmd_set_vf_vlan_tag_set,
12449 		(void *)&cmd_set_vf_vlan_tag_vf,
12450 		(void *)&cmd_set_vf_vlan_tag_vlan,
12451 		(void *)&cmd_set_vf_vlan_tag_tag,
12452 		(void *)&cmd_set_vf_vlan_tag_port_id,
12453 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12454 		(void *)&cmd_set_vf_vlan_tag_on_off,
12455 		NULL,
12456 	},
12457 };
12458 
12459 /* Common definition of VF and TC TX bandwidth configuration */
12460 struct cmd_vf_tc_bw_result {
12461 	cmdline_fixed_string_t set;
12462 	cmdline_fixed_string_t vf;
12463 	cmdline_fixed_string_t tc;
12464 	cmdline_fixed_string_t tx;
12465 	cmdline_fixed_string_t min_bw;
12466 	cmdline_fixed_string_t max_bw;
12467 	cmdline_fixed_string_t strict_link_prio;
12468 	portid_t port_id;
12469 	uint16_t vf_id;
12470 	uint8_t tc_no;
12471 	uint32_t bw;
12472 	cmdline_fixed_string_t bw_list;
12473 	uint8_t tc_map;
12474 };
12475 
12476 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12477 	TOKEN_STRING_INITIALIZER
12478 		(struct cmd_vf_tc_bw_result,
12479 		 set, "set");
12480 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12481 	TOKEN_STRING_INITIALIZER
12482 		(struct cmd_vf_tc_bw_result,
12483 		 vf, "vf");
12484 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12485 	TOKEN_STRING_INITIALIZER
12486 		(struct cmd_vf_tc_bw_result,
12487 		 tc, "tc");
12488 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12489 	TOKEN_STRING_INITIALIZER
12490 		(struct cmd_vf_tc_bw_result,
12491 		 tx, "tx");
12492 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12493 	TOKEN_STRING_INITIALIZER
12494 		(struct cmd_vf_tc_bw_result,
12495 		 strict_link_prio, "strict-link-priority");
12496 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12497 	TOKEN_STRING_INITIALIZER
12498 		(struct cmd_vf_tc_bw_result,
12499 		 min_bw, "min-bandwidth");
12500 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12501 	TOKEN_STRING_INITIALIZER
12502 		(struct cmd_vf_tc_bw_result,
12503 		 max_bw, "max-bandwidth");
12504 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12505 	TOKEN_NUM_INITIALIZER
12506 		(struct cmd_vf_tc_bw_result,
12507 		 port_id, RTE_UINT16);
12508 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12509 	TOKEN_NUM_INITIALIZER
12510 		(struct cmd_vf_tc_bw_result,
12511 		 vf_id, RTE_UINT16);
12512 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12513 	TOKEN_NUM_INITIALIZER
12514 		(struct cmd_vf_tc_bw_result,
12515 		 tc_no, RTE_UINT8);
12516 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12517 	TOKEN_NUM_INITIALIZER
12518 		(struct cmd_vf_tc_bw_result,
12519 		 bw, RTE_UINT32);
12520 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12521 	TOKEN_STRING_INITIALIZER
12522 		(struct cmd_vf_tc_bw_result,
12523 		 bw_list, NULL);
12524 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12525 	TOKEN_NUM_INITIALIZER
12526 		(struct cmd_vf_tc_bw_result,
12527 		 tc_map, RTE_UINT8);
12528 
12529 /* VF max bandwidth setting */
12530 static void
12531 cmd_vf_max_bw_parsed(
12532 	void *parsed_result,
12533 	__rte_unused struct cmdline *cl,
12534 	__rte_unused void *data)
12535 {
12536 	struct cmd_vf_tc_bw_result *res = parsed_result;
12537 	int ret = -ENOTSUP;
12538 
12539 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12540 		return;
12541 
12542 #ifdef RTE_NET_I40E
12543 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12544 					 res->vf_id, res->bw);
12545 #endif
12546 
12547 	switch (ret) {
12548 	case 0:
12549 		break;
12550 	case -EINVAL:
12551 		printf("invalid vf_id %d or bandwidth %d\n",
12552 		       res->vf_id, res->bw);
12553 		break;
12554 	case -ENODEV:
12555 		printf("invalid port_id %d\n", res->port_id);
12556 		break;
12557 	case -ENOTSUP:
12558 		printf("function not implemented\n");
12559 		break;
12560 	default:
12561 		printf("programming error: (%s)\n", strerror(-ret));
12562 	}
12563 }
12564 
12565 cmdline_parse_inst_t cmd_vf_max_bw = {
12566 	.f = cmd_vf_max_bw_parsed,
12567 	.data = NULL,
12568 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12569 	.tokens = {
12570 		(void *)&cmd_vf_tc_bw_set,
12571 		(void *)&cmd_vf_tc_bw_vf,
12572 		(void *)&cmd_vf_tc_bw_tx,
12573 		(void *)&cmd_vf_tc_bw_max_bw,
12574 		(void *)&cmd_vf_tc_bw_port_id,
12575 		(void *)&cmd_vf_tc_bw_vf_id,
12576 		(void *)&cmd_vf_tc_bw_bw,
12577 		NULL,
12578 	},
12579 };
12580 
12581 static int
12582 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12583 			   uint8_t *tc_num,
12584 			   char *str)
12585 {
12586 	uint32_t size;
12587 	const char *p, *p0 = str;
12588 	char s[256];
12589 	char *end;
12590 	char *str_fld[16];
12591 	uint16_t i;
12592 	int ret;
12593 
12594 	p = strchr(p0, '(');
12595 	if (p == NULL) {
12596 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12597 		return -1;
12598 	}
12599 	p++;
12600 	p0 = strchr(p, ')');
12601 	if (p0 == NULL) {
12602 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12603 		return -1;
12604 	}
12605 	size = p0 - p;
12606 	if (size >= sizeof(s)) {
12607 		printf("The string size exceeds the internal buffer size\n");
12608 		return -1;
12609 	}
12610 	snprintf(s, sizeof(s), "%.*s", size, p);
12611 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12612 	if (ret <= 0) {
12613 		printf("Failed to get the bandwidth list. ");
12614 		return -1;
12615 	}
12616 	*tc_num = ret;
12617 	for (i = 0; i < ret; i++)
12618 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12619 
12620 	return 0;
12621 }
12622 
12623 /* TC min bandwidth setting */
12624 static void
12625 cmd_vf_tc_min_bw_parsed(
12626 	void *parsed_result,
12627 	__rte_unused struct cmdline *cl,
12628 	__rte_unused void *data)
12629 {
12630 	struct cmd_vf_tc_bw_result *res = parsed_result;
12631 	uint8_t tc_num;
12632 	uint8_t bw[16];
12633 	int ret = -ENOTSUP;
12634 
12635 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12636 		return;
12637 
12638 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12639 	if (ret)
12640 		return;
12641 
12642 #ifdef RTE_NET_I40E
12643 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12644 					      tc_num, bw);
12645 #endif
12646 
12647 	switch (ret) {
12648 	case 0:
12649 		break;
12650 	case -EINVAL:
12651 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12652 		break;
12653 	case -ENODEV:
12654 		printf("invalid port_id %d\n", res->port_id);
12655 		break;
12656 	case -ENOTSUP:
12657 		printf("function not implemented\n");
12658 		break;
12659 	default:
12660 		printf("programming error: (%s)\n", strerror(-ret));
12661 	}
12662 }
12663 
12664 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12665 	.f = cmd_vf_tc_min_bw_parsed,
12666 	.data = NULL,
12667 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12668 		    " <bw1, bw2, ...>",
12669 	.tokens = {
12670 		(void *)&cmd_vf_tc_bw_set,
12671 		(void *)&cmd_vf_tc_bw_vf,
12672 		(void *)&cmd_vf_tc_bw_tc,
12673 		(void *)&cmd_vf_tc_bw_tx,
12674 		(void *)&cmd_vf_tc_bw_min_bw,
12675 		(void *)&cmd_vf_tc_bw_port_id,
12676 		(void *)&cmd_vf_tc_bw_vf_id,
12677 		(void *)&cmd_vf_tc_bw_bw_list,
12678 		NULL,
12679 	},
12680 };
12681 
12682 static void
12683 cmd_tc_min_bw_parsed(
12684 	void *parsed_result,
12685 	__rte_unused struct cmdline *cl,
12686 	__rte_unused void *data)
12687 {
12688 	struct cmd_vf_tc_bw_result *res = parsed_result;
12689 	struct rte_port *port;
12690 	uint8_t tc_num;
12691 	uint8_t bw[16];
12692 	int ret = -ENOTSUP;
12693 
12694 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12695 		return;
12696 
12697 	port = &ports[res->port_id];
12698 	/** Check if the port is not started **/
12699 	if (port->port_status != RTE_PORT_STOPPED) {
12700 		printf("Please stop port %d first\n", res->port_id);
12701 		return;
12702 	}
12703 
12704 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12705 	if (ret)
12706 		return;
12707 
12708 #ifdef RTE_NET_IXGBE
12709 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12710 #endif
12711 
12712 	switch (ret) {
12713 	case 0:
12714 		break;
12715 	case -EINVAL:
12716 		printf("invalid bandwidth\n");
12717 		break;
12718 	case -ENODEV:
12719 		printf("invalid port_id %d\n", res->port_id);
12720 		break;
12721 	case -ENOTSUP:
12722 		printf("function not implemented\n");
12723 		break;
12724 	default:
12725 		printf("programming error: (%s)\n", strerror(-ret));
12726 	}
12727 }
12728 
12729 cmdline_parse_inst_t cmd_tc_min_bw = {
12730 	.f = cmd_tc_min_bw_parsed,
12731 	.data = NULL,
12732 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12733 	.tokens = {
12734 		(void *)&cmd_vf_tc_bw_set,
12735 		(void *)&cmd_vf_tc_bw_tc,
12736 		(void *)&cmd_vf_tc_bw_tx,
12737 		(void *)&cmd_vf_tc_bw_min_bw,
12738 		(void *)&cmd_vf_tc_bw_port_id,
12739 		(void *)&cmd_vf_tc_bw_bw_list,
12740 		NULL,
12741 	},
12742 };
12743 
12744 /* TC max bandwidth setting */
12745 static void
12746 cmd_vf_tc_max_bw_parsed(
12747 	void *parsed_result,
12748 	__rte_unused struct cmdline *cl,
12749 	__rte_unused void *data)
12750 {
12751 	struct cmd_vf_tc_bw_result *res = parsed_result;
12752 	int ret = -ENOTSUP;
12753 
12754 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12755 		return;
12756 
12757 #ifdef RTE_NET_I40E
12758 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12759 					    res->tc_no, res->bw);
12760 #endif
12761 
12762 	switch (ret) {
12763 	case 0:
12764 		break;
12765 	case -EINVAL:
12766 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12767 		       res->vf_id, res->tc_no, res->bw);
12768 		break;
12769 	case -ENODEV:
12770 		printf("invalid port_id %d\n", res->port_id);
12771 		break;
12772 	case -ENOTSUP:
12773 		printf("function not implemented\n");
12774 		break;
12775 	default:
12776 		printf("programming error: (%s)\n", strerror(-ret));
12777 	}
12778 }
12779 
12780 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12781 	.f = cmd_vf_tc_max_bw_parsed,
12782 	.data = NULL,
12783 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12784 		    " <bandwidth>",
12785 	.tokens = {
12786 		(void *)&cmd_vf_tc_bw_set,
12787 		(void *)&cmd_vf_tc_bw_vf,
12788 		(void *)&cmd_vf_tc_bw_tc,
12789 		(void *)&cmd_vf_tc_bw_tx,
12790 		(void *)&cmd_vf_tc_bw_max_bw,
12791 		(void *)&cmd_vf_tc_bw_port_id,
12792 		(void *)&cmd_vf_tc_bw_vf_id,
12793 		(void *)&cmd_vf_tc_bw_tc_no,
12794 		(void *)&cmd_vf_tc_bw_bw,
12795 		NULL,
12796 	},
12797 };
12798 
12799 /** Set VXLAN encapsulation details */
12800 struct cmd_set_vxlan_result {
12801 	cmdline_fixed_string_t set;
12802 	cmdline_fixed_string_t vxlan;
12803 	cmdline_fixed_string_t pos_token;
12804 	cmdline_fixed_string_t ip_version;
12805 	uint32_t vlan_present:1;
12806 	uint32_t vni;
12807 	uint16_t udp_src;
12808 	uint16_t udp_dst;
12809 	cmdline_ipaddr_t ip_src;
12810 	cmdline_ipaddr_t ip_dst;
12811 	uint16_t tci;
12812 	uint8_t tos;
12813 	uint8_t ttl;
12814 	struct rte_ether_addr eth_src;
12815 	struct rte_ether_addr eth_dst;
12816 };
12817 
12818 cmdline_parse_token_string_t cmd_set_vxlan_set =
12819 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12820 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12821 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12822 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12823 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12824 				 "vxlan-tos-ttl");
12825 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12826 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12827 				 "vxlan-with-vlan");
12828 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12829 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12830 				 "ip-version");
12831 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12832 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12833 				 "ipv4#ipv6");
12834 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12835 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12836 				 "vni");
12837 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12838 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12839 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12840 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12841 				 "udp-src");
12842 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12843 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12844 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12845 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12846 				 "udp-dst");
12847 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12848 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12849 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12850 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12851 				 "ip-tos");
12852 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12853 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12854 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12855 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12856 				 "ip-ttl");
12857 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12858 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12859 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12860 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12861 				 "ip-src");
12862 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12863 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12864 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12865 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12866 				 "ip-dst");
12867 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12868 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12869 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12870 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12871 				 "vlan-tci");
12872 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12873 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12874 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12875 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12876 				 "eth-src");
12877 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12878 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12879 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12880 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12881 				 "eth-dst");
12882 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12883 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12884 
12885 static void cmd_set_vxlan_parsed(void *parsed_result,
12886 	__rte_unused struct cmdline *cl,
12887 	__rte_unused void *data)
12888 {
12889 	struct cmd_set_vxlan_result *res = parsed_result;
12890 	union {
12891 		uint32_t vxlan_id;
12892 		uint8_t vni[4];
12893 	} id = {
12894 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12895 	};
12896 
12897 	vxlan_encap_conf.select_tos_ttl = 0;
12898 	if (strcmp(res->vxlan, "vxlan") == 0)
12899 		vxlan_encap_conf.select_vlan = 0;
12900 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12901 		vxlan_encap_conf.select_vlan = 1;
12902 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12903 		vxlan_encap_conf.select_vlan = 0;
12904 		vxlan_encap_conf.select_tos_ttl = 1;
12905 	}
12906 	if (strcmp(res->ip_version, "ipv4") == 0)
12907 		vxlan_encap_conf.select_ipv4 = 1;
12908 	else if (strcmp(res->ip_version, "ipv6") == 0)
12909 		vxlan_encap_conf.select_ipv4 = 0;
12910 	else
12911 		return;
12912 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12913 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12914 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12915 	vxlan_encap_conf.ip_tos = res->tos;
12916 	vxlan_encap_conf.ip_ttl = res->ttl;
12917 	if (vxlan_encap_conf.select_ipv4) {
12918 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12919 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12920 	} else {
12921 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12922 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12923 	}
12924 	if (vxlan_encap_conf.select_vlan)
12925 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12926 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12927 		   RTE_ETHER_ADDR_LEN);
12928 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12929 		   RTE_ETHER_ADDR_LEN);
12930 }
12931 
12932 cmdline_parse_inst_t cmd_set_vxlan = {
12933 	.f = cmd_set_vxlan_parsed,
12934 	.data = NULL,
12935 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12936 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12937 		" eth-src <eth-src> eth-dst <eth-dst>",
12938 	.tokens = {
12939 		(void *)&cmd_set_vxlan_set,
12940 		(void *)&cmd_set_vxlan_vxlan,
12941 		(void *)&cmd_set_vxlan_ip_version,
12942 		(void *)&cmd_set_vxlan_ip_version_value,
12943 		(void *)&cmd_set_vxlan_vni,
12944 		(void *)&cmd_set_vxlan_vni_value,
12945 		(void *)&cmd_set_vxlan_udp_src,
12946 		(void *)&cmd_set_vxlan_udp_src_value,
12947 		(void *)&cmd_set_vxlan_udp_dst,
12948 		(void *)&cmd_set_vxlan_udp_dst_value,
12949 		(void *)&cmd_set_vxlan_ip_src,
12950 		(void *)&cmd_set_vxlan_ip_src_value,
12951 		(void *)&cmd_set_vxlan_ip_dst,
12952 		(void *)&cmd_set_vxlan_ip_dst_value,
12953 		(void *)&cmd_set_vxlan_eth_src,
12954 		(void *)&cmd_set_vxlan_eth_src_value,
12955 		(void *)&cmd_set_vxlan_eth_dst,
12956 		(void *)&cmd_set_vxlan_eth_dst_value,
12957 		NULL,
12958 	},
12959 };
12960 
12961 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12962 	.f = cmd_set_vxlan_parsed,
12963 	.data = NULL,
12964 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12965 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12966 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12967 		" eth-dst <eth-dst>",
12968 	.tokens = {
12969 		(void *)&cmd_set_vxlan_set,
12970 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
12971 		(void *)&cmd_set_vxlan_ip_version,
12972 		(void *)&cmd_set_vxlan_ip_version_value,
12973 		(void *)&cmd_set_vxlan_vni,
12974 		(void *)&cmd_set_vxlan_vni_value,
12975 		(void *)&cmd_set_vxlan_udp_src,
12976 		(void *)&cmd_set_vxlan_udp_src_value,
12977 		(void *)&cmd_set_vxlan_udp_dst,
12978 		(void *)&cmd_set_vxlan_udp_dst_value,
12979 		(void *)&cmd_set_vxlan_ip_tos,
12980 		(void *)&cmd_set_vxlan_ip_tos_value,
12981 		(void *)&cmd_set_vxlan_ip_ttl,
12982 		(void *)&cmd_set_vxlan_ip_ttl_value,
12983 		(void *)&cmd_set_vxlan_ip_src,
12984 		(void *)&cmd_set_vxlan_ip_src_value,
12985 		(void *)&cmd_set_vxlan_ip_dst,
12986 		(void *)&cmd_set_vxlan_ip_dst_value,
12987 		(void *)&cmd_set_vxlan_eth_src,
12988 		(void *)&cmd_set_vxlan_eth_src_value,
12989 		(void *)&cmd_set_vxlan_eth_dst,
12990 		(void *)&cmd_set_vxlan_eth_dst_value,
12991 		NULL,
12992 	},
12993 };
12994 
12995 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12996 	.f = cmd_set_vxlan_parsed,
12997 	.data = NULL,
12998 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12999 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13000 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13001 		" <eth-dst>",
13002 	.tokens = {
13003 		(void *)&cmd_set_vxlan_set,
13004 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
13005 		(void *)&cmd_set_vxlan_ip_version,
13006 		(void *)&cmd_set_vxlan_ip_version_value,
13007 		(void *)&cmd_set_vxlan_vni,
13008 		(void *)&cmd_set_vxlan_vni_value,
13009 		(void *)&cmd_set_vxlan_udp_src,
13010 		(void *)&cmd_set_vxlan_udp_src_value,
13011 		(void *)&cmd_set_vxlan_udp_dst,
13012 		(void *)&cmd_set_vxlan_udp_dst_value,
13013 		(void *)&cmd_set_vxlan_ip_src,
13014 		(void *)&cmd_set_vxlan_ip_src_value,
13015 		(void *)&cmd_set_vxlan_ip_dst,
13016 		(void *)&cmd_set_vxlan_ip_dst_value,
13017 		(void *)&cmd_set_vxlan_vlan,
13018 		(void *)&cmd_set_vxlan_vlan_value,
13019 		(void *)&cmd_set_vxlan_eth_src,
13020 		(void *)&cmd_set_vxlan_eth_src_value,
13021 		(void *)&cmd_set_vxlan_eth_dst,
13022 		(void *)&cmd_set_vxlan_eth_dst_value,
13023 		NULL,
13024 	},
13025 };
13026 
13027 /** Set NVGRE encapsulation details */
13028 struct cmd_set_nvgre_result {
13029 	cmdline_fixed_string_t set;
13030 	cmdline_fixed_string_t nvgre;
13031 	cmdline_fixed_string_t pos_token;
13032 	cmdline_fixed_string_t ip_version;
13033 	uint32_t tni;
13034 	cmdline_ipaddr_t ip_src;
13035 	cmdline_ipaddr_t ip_dst;
13036 	uint16_t tci;
13037 	struct rte_ether_addr eth_src;
13038 	struct rte_ether_addr eth_dst;
13039 };
13040 
13041 cmdline_parse_token_string_t cmd_set_nvgre_set =
13042 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13043 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13044 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13045 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13046 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13047 				 "nvgre-with-vlan");
13048 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13049 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13050 				 "ip-version");
13051 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13052 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13053 				 "ipv4#ipv6");
13054 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13055 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13056 				 "tni");
13057 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13058 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13059 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13060 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13061 				 "ip-src");
13062 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13063 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13064 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13065 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13066 				 "ip-dst");
13067 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13068 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13069 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13070 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13071 				 "vlan-tci");
13072 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13073 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13074 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13075 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13076 				 "eth-src");
13077 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13078 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13079 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13080 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13081 				 "eth-dst");
13082 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13083 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13084 
13085 static void cmd_set_nvgre_parsed(void *parsed_result,
13086 	__rte_unused struct cmdline *cl,
13087 	__rte_unused void *data)
13088 {
13089 	struct cmd_set_nvgre_result *res = parsed_result;
13090 	union {
13091 		uint32_t nvgre_tni;
13092 		uint8_t tni[4];
13093 	} id = {
13094 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13095 	};
13096 
13097 	if (strcmp(res->nvgre, "nvgre") == 0)
13098 		nvgre_encap_conf.select_vlan = 0;
13099 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13100 		nvgre_encap_conf.select_vlan = 1;
13101 	if (strcmp(res->ip_version, "ipv4") == 0)
13102 		nvgre_encap_conf.select_ipv4 = 1;
13103 	else if (strcmp(res->ip_version, "ipv6") == 0)
13104 		nvgre_encap_conf.select_ipv4 = 0;
13105 	else
13106 		return;
13107 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13108 	if (nvgre_encap_conf.select_ipv4) {
13109 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13110 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13111 	} else {
13112 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13113 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13114 	}
13115 	if (nvgre_encap_conf.select_vlan)
13116 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13117 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13118 		   RTE_ETHER_ADDR_LEN);
13119 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13120 		   RTE_ETHER_ADDR_LEN);
13121 }
13122 
13123 cmdline_parse_inst_t cmd_set_nvgre = {
13124 	.f = cmd_set_nvgre_parsed,
13125 	.data = NULL,
13126 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13127 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13128 		" eth-dst <eth-dst>",
13129 	.tokens = {
13130 		(void *)&cmd_set_nvgre_set,
13131 		(void *)&cmd_set_nvgre_nvgre,
13132 		(void *)&cmd_set_nvgre_ip_version,
13133 		(void *)&cmd_set_nvgre_ip_version_value,
13134 		(void *)&cmd_set_nvgre_tni,
13135 		(void *)&cmd_set_nvgre_tni_value,
13136 		(void *)&cmd_set_nvgre_ip_src,
13137 		(void *)&cmd_set_nvgre_ip_src_value,
13138 		(void *)&cmd_set_nvgre_ip_dst,
13139 		(void *)&cmd_set_nvgre_ip_dst_value,
13140 		(void *)&cmd_set_nvgre_eth_src,
13141 		(void *)&cmd_set_nvgre_eth_src_value,
13142 		(void *)&cmd_set_nvgre_eth_dst,
13143 		(void *)&cmd_set_nvgre_eth_dst_value,
13144 		NULL,
13145 	},
13146 };
13147 
13148 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13149 	.f = cmd_set_nvgre_parsed,
13150 	.data = NULL,
13151 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13152 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13153 		" eth-src <eth-src> eth-dst <eth-dst>",
13154 	.tokens = {
13155 		(void *)&cmd_set_nvgre_set,
13156 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
13157 		(void *)&cmd_set_nvgre_ip_version,
13158 		(void *)&cmd_set_nvgre_ip_version_value,
13159 		(void *)&cmd_set_nvgre_tni,
13160 		(void *)&cmd_set_nvgre_tni_value,
13161 		(void *)&cmd_set_nvgre_ip_src,
13162 		(void *)&cmd_set_nvgre_ip_src_value,
13163 		(void *)&cmd_set_nvgre_ip_dst,
13164 		(void *)&cmd_set_nvgre_ip_dst_value,
13165 		(void *)&cmd_set_nvgre_vlan,
13166 		(void *)&cmd_set_nvgre_vlan_value,
13167 		(void *)&cmd_set_nvgre_eth_src,
13168 		(void *)&cmd_set_nvgre_eth_src_value,
13169 		(void *)&cmd_set_nvgre_eth_dst,
13170 		(void *)&cmd_set_nvgre_eth_dst_value,
13171 		NULL,
13172 	},
13173 };
13174 
13175 /** Set L2 encapsulation details */
13176 struct cmd_set_l2_encap_result {
13177 	cmdline_fixed_string_t set;
13178 	cmdline_fixed_string_t l2_encap;
13179 	cmdline_fixed_string_t pos_token;
13180 	cmdline_fixed_string_t ip_version;
13181 	uint32_t vlan_present:1;
13182 	uint16_t tci;
13183 	struct rte_ether_addr eth_src;
13184 	struct rte_ether_addr eth_dst;
13185 };
13186 
13187 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13188 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13189 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13190 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13191 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13192 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13193 				 "l2_encap-with-vlan");
13194 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13195 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13196 				 "ip-version");
13197 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13198 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13199 				 "ipv4#ipv6");
13200 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13201 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13202 				 "vlan-tci");
13203 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13204 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13205 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13206 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13207 				 "eth-src");
13208 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13209 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13210 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13211 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13212 				 "eth-dst");
13213 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13214 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13215 
13216 static void cmd_set_l2_encap_parsed(void *parsed_result,
13217 	__rte_unused struct cmdline *cl,
13218 	__rte_unused void *data)
13219 {
13220 	struct cmd_set_l2_encap_result *res = parsed_result;
13221 
13222 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13223 		l2_encap_conf.select_vlan = 0;
13224 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13225 		l2_encap_conf.select_vlan = 1;
13226 	if (strcmp(res->ip_version, "ipv4") == 0)
13227 		l2_encap_conf.select_ipv4 = 1;
13228 	else if (strcmp(res->ip_version, "ipv6") == 0)
13229 		l2_encap_conf.select_ipv4 = 0;
13230 	else
13231 		return;
13232 	if (l2_encap_conf.select_vlan)
13233 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13234 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13235 		   RTE_ETHER_ADDR_LEN);
13236 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13237 		   RTE_ETHER_ADDR_LEN);
13238 }
13239 
13240 cmdline_parse_inst_t cmd_set_l2_encap = {
13241 	.f = cmd_set_l2_encap_parsed,
13242 	.data = NULL,
13243 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13244 		" eth-src <eth-src> eth-dst <eth-dst>",
13245 	.tokens = {
13246 		(void *)&cmd_set_l2_encap_set,
13247 		(void *)&cmd_set_l2_encap_l2_encap,
13248 		(void *)&cmd_set_l2_encap_ip_version,
13249 		(void *)&cmd_set_l2_encap_ip_version_value,
13250 		(void *)&cmd_set_l2_encap_eth_src,
13251 		(void *)&cmd_set_l2_encap_eth_src_value,
13252 		(void *)&cmd_set_l2_encap_eth_dst,
13253 		(void *)&cmd_set_l2_encap_eth_dst_value,
13254 		NULL,
13255 	},
13256 };
13257 
13258 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13259 	.f = cmd_set_l2_encap_parsed,
13260 	.data = NULL,
13261 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13262 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13263 	.tokens = {
13264 		(void *)&cmd_set_l2_encap_set,
13265 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13266 		(void *)&cmd_set_l2_encap_ip_version,
13267 		(void *)&cmd_set_l2_encap_ip_version_value,
13268 		(void *)&cmd_set_l2_encap_vlan,
13269 		(void *)&cmd_set_l2_encap_vlan_value,
13270 		(void *)&cmd_set_l2_encap_eth_src,
13271 		(void *)&cmd_set_l2_encap_eth_src_value,
13272 		(void *)&cmd_set_l2_encap_eth_dst,
13273 		(void *)&cmd_set_l2_encap_eth_dst_value,
13274 		NULL,
13275 	},
13276 };
13277 
13278 /** Set L2 decapsulation details */
13279 struct cmd_set_l2_decap_result {
13280 	cmdline_fixed_string_t set;
13281 	cmdline_fixed_string_t l2_decap;
13282 	cmdline_fixed_string_t pos_token;
13283 	uint32_t vlan_present:1;
13284 };
13285 
13286 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13287 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13288 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13289 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13290 				 "l2_decap");
13291 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13292 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13293 				 "l2_decap-with-vlan");
13294 
13295 static void cmd_set_l2_decap_parsed(void *parsed_result,
13296 	__rte_unused struct cmdline *cl,
13297 	__rte_unused void *data)
13298 {
13299 	struct cmd_set_l2_decap_result *res = parsed_result;
13300 
13301 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13302 		l2_decap_conf.select_vlan = 0;
13303 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13304 		l2_decap_conf.select_vlan = 1;
13305 }
13306 
13307 cmdline_parse_inst_t cmd_set_l2_decap = {
13308 	.f = cmd_set_l2_decap_parsed,
13309 	.data = NULL,
13310 	.help_str = "set l2_decap",
13311 	.tokens = {
13312 		(void *)&cmd_set_l2_decap_set,
13313 		(void *)&cmd_set_l2_decap_l2_decap,
13314 		NULL,
13315 	},
13316 };
13317 
13318 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13319 	.f = cmd_set_l2_decap_parsed,
13320 	.data = NULL,
13321 	.help_str = "set l2_decap-with-vlan",
13322 	.tokens = {
13323 		(void *)&cmd_set_l2_decap_set,
13324 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13325 		NULL,
13326 	},
13327 };
13328 
13329 /** Set MPLSoGRE encapsulation details */
13330 struct cmd_set_mplsogre_encap_result {
13331 	cmdline_fixed_string_t set;
13332 	cmdline_fixed_string_t mplsogre;
13333 	cmdline_fixed_string_t pos_token;
13334 	cmdline_fixed_string_t ip_version;
13335 	uint32_t vlan_present:1;
13336 	uint32_t label;
13337 	cmdline_ipaddr_t ip_src;
13338 	cmdline_ipaddr_t ip_dst;
13339 	uint16_t tci;
13340 	struct rte_ether_addr eth_src;
13341 	struct rte_ether_addr eth_dst;
13342 };
13343 
13344 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13345 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13346 				 "set");
13347 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13348 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13349 				 "mplsogre_encap");
13350 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13351 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13352 				 mplsogre, "mplsogre_encap-with-vlan");
13353 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13354 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13355 				 pos_token, "ip-version");
13356 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13357 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13358 				 ip_version, "ipv4#ipv6");
13359 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13360 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13361 				 pos_token, "label");
13362 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13363 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13364 			      RTE_UINT32);
13365 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13366 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13367 				 pos_token, "ip-src");
13368 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13369 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13370 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13371 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13372 				 pos_token, "ip-dst");
13373 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13374 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13375 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13376 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13377 				 pos_token, "vlan-tci");
13378 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13379 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13380 			      RTE_UINT16);
13381 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13382 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13383 				 pos_token, "eth-src");
13384 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13385 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13386 				    eth_src);
13387 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13388 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13389 				 pos_token, "eth-dst");
13390 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13391 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13392 				    eth_dst);
13393 
13394 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13395 	__rte_unused struct cmdline *cl,
13396 	__rte_unused void *data)
13397 {
13398 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13399 	union {
13400 		uint32_t mplsogre_label;
13401 		uint8_t label[4];
13402 	} id = {
13403 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13404 	};
13405 
13406 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13407 		mplsogre_encap_conf.select_vlan = 0;
13408 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13409 		mplsogre_encap_conf.select_vlan = 1;
13410 	if (strcmp(res->ip_version, "ipv4") == 0)
13411 		mplsogre_encap_conf.select_ipv4 = 1;
13412 	else if (strcmp(res->ip_version, "ipv6") == 0)
13413 		mplsogre_encap_conf.select_ipv4 = 0;
13414 	else
13415 		return;
13416 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13417 	if (mplsogre_encap_conf.select_ipv4) {
13418 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13419 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13420 	} else {
13421 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13422 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13423 	}
13424 	if (mplsogre_encap_conf.select_vlan)
13425 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13426 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13427 		   RTE_ETHER_ADDR_LEN);
13428 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13429 		   RTE_ETHER_ADDR_LEN);
13430 }
13431 
13432 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13433 	.f = cmd_set_mplsogre_encap_parsed,
13434 	.data = NULL,
13435 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13436 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13437 		" eth-dst <eth-dst>",
13438 	.tokens = {
13439 		(void *)&cmd_set_mplsogre_encap_set,
13440 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13441 		(void *)&cmd_set_mplsogre_encap_ip_version,
13442 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13443 		(void *)&cmd_set_mplsogre_encap_label,
13444 		(void *)&cmd_set_mplsogre_encap_label_value,
13445 		(void *)&cmd_set_mplsogre_encap_ip_src,
13446 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13447 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13448 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13449 		(void *)&cmd_set_mplsogre_encap_eth_src,
13450 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13451 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13452 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13453 		NULL,
13454 	},
13455 };
13456 
13457 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13458 	.f = cmd_set_mplsogre_encap_parsed,
13459 	.data = NULL,
13460 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13461 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13462 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13463 	.tokens = {
13464 		(void *)&cmd_set_mplsogre_encap_set,
13465 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13466 		(void *)&cmd_set_mplsogre_encap_ip_version,
13467 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13468 		(void *)&cmd_set_mplsogre_encap_label,
13469 		(void *)&cmd_set_mplsogre_encap_label_value,
13470 		(void *)&cmd_set_mplsogre_encap_ip_src,
13471 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13472 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13473 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13474 		(void *)&cmd_set_mplsogre_encap_vlan,
13475 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13476 		(void *)&cmd_set_mplsogre_encap_eth_src,
13477 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13478 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13479 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13480 		NULL,
13481 	},
13482 };
13483 
13484 /** Set MPLSoGRE decapsulation details */
13485 struct cmd_set_mplsogre_decap_result {
13486 	cmdline_fixed_string_t set;
13487 	cmdline_fixed_string_t mplsogre;
13488 	cmdline_fixed_string_t pos_token;
13489 	cmdline_fixed_string_t ip_version;
13490 	uint32_t vlan_present:1;
13491 };
13492 
13493 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13494 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13495 				 "set");
13496 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13497 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13498 				 "mplsogre_decap");
13499 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13500 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13501 				 mplsogre, "mplsogre_decap-with-vlan");
13502 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13503 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13504 				 pos_token, "ip-version");
13505 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13506 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13507 				 ip_version, "ipv4#ipv6");
13508 
13509 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13510 	__rte_unused struct cmdline *cl,
13511 	__rte_unused void *data)
13512 {
13513 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13514 
13515 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13516 		mplsogre_decap_conf.select_vlan = 0;
13517 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13518 		mplsogre_decap_conf.select_vlan = 1;
13519 	if (strcmp(res->ip_version, "ipv4") == 0)
13520 		mplsogre_decap_conf.select_ipv4 = 1;
13521 	else if (strcmp(res->ip_version, "ipv6") == 0)
13522 		mplsogre_decap_conf.select_ipv4 = 0;
13523 }
13524 
13525 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13526 	.f = cmd_set_mplsogre_decap_parsed,
13527 	.data = NULL,
13528 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13529 	.tokens = {
13530 		(void *)&cmd_set_mplsogre_decap_set,
13531 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13532 		(void *)&cmd_set_mplsogre_decap_ip_version,
13533 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13534 		NULL,
13535 	},
13536 };
13537 
13538 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13539 	.f = cmd_set_mplsogre_decap_parsed,
13540 	.data = NULL,
13541 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13542 	.tokens = {
13543 		(void *)&cmd_set_mplsogre_decap_set,
13544 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13545 		(void *)&cmd_set_mplsogre_decap_ip_version,
13546 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13547 		NULL,
13548 	},
13549 };
13550 
13551 /** Set MPLSoUDP encapsulation details */
13552 struct cmd_set_mplsoudp_encap_result {
13553 	cmdline_fixed_string_t set;
13554 	cmdline_fixed_string_t mplsoudp;
13555 	cmdline_fixed_string_t pos_token;
13556 	cmdline_fixed_string_t ip_version;
13557 	uint32_t vlan_present:1;
13558 	uint32_t label;
13559 	uint16_t udp_src;
13560 	uint16_t udp_dst;
13561 	cmdline_ipaddr_t ip_src;
13562 	cmdline_ipaddr_t ip_dst;
13563 	uint16_t tci;
13564 	struct rte_ether_addr eth_src;
13565 	struct rte_ether_addr eth_dst;
13566 };
13567 
13568 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13569 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13570 				 "set");
13571 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13572 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13573 				 "mplsoudp_encap");
13574 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13575 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13576 				 mplsoudp, "mplsoudp_encap-with-vlan");
13577 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13578 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13579 				 pos_token, "ip-version");
13580 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13581 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13582 				 ip_version, "ipv4#ipv6");
13583 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13584 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13585 				 pos_token, "label");
13586 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13587 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13588 			      RTE_UINT32);
13589 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13590 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13591 				 pos_token, "udp-src");
13592 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13593 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13594 			      RTE_UINT16);
13595 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13596 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13597 				 pos_token, "udp-dst");
13598 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13599 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13600 			      RTE_UINT16);
13601 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13602 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13603 				 pos_token, "ip-src");
13604 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13605 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13606 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13607 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13608 				 pos_token, "ip-dst");
13609 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13610 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13611 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13612 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13613 				 pos_token, "vlan-tci");
13614 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13615 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13616 			      RTE_UINT16);
13617 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13618 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13619 				 pos_token, "eth-src");
13620 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13621 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13622 				    eth_src);
13623 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13624 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13625 				 pos_token, "eth-dst");
13626 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13627 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13628 				    eth_dst);
13629 
13630 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13631 	__rte_unused struct cmdline *cl,
13632 	__rte_unused void *data)
13633 {
13634 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13635 	union {
13636 		uint32_t mplsoudp_label;
13637 		uint8_t label[4];
13638 	} id = {
13639 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13640 	};
13641 
13642 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13643 		mplsoudp_encap_conf.select_vlan = 0;
13644 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13645 		mplsoudp_encap_conf.select_vlan = 1;
13646 	if (strcmp(res->ip_version, "ipv4") == 0)
13647 		mplsoudp_encap_conf.select_ipv4 = 1;
13648 	else if (strcmp(res->ip_version, "ipv6") == 0)
13649 		mplsoudp_encap_conf.select_ipv4 = 0;
13650 	else
13651 		return;
13652 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13653 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13654 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13655 	if (mplsoudp_encap_conf.select_ipv4) {
13656 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13657 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13658 	} else {
13659 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13660 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13661 	}
13662 	if (mplsoudp_encap_conf.select_vlan)
13663 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13664 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13665 		   RTE_ETHER_ADDR_LEN);
13666 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13667 		   RTE_ETHER_ADDR_LEN);
13668 }
13669 
13670 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13671 	.f = cmd_set_mplsoudp_encap_parsed,
13672 	.data = NULL,
13673 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13674 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13675 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13676 	.tokens = {
13677 		(void *)&cmd_set_mplsoudp_encap_set,
13678 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13679 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13680 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13681 		(void *)&cmd_set_mplsoudp_encap_label,
13682 		(void *)&cmd_set_mplsoudp_encap_label_value,
13683 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13684 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13685 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13686 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13687 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13688 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13689 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13690 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13691 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13692 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13693 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13694 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13695 		NULL,
13696 	},
13697 };
13698 
13699 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13700 	.f = cmd_set_mplsoudp_encap_parsed,
13701 	.data = NULL,
13702 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13703 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13704 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13705 		" eth-src <eth-src> eth-dst <eth-dst>",
13706 	.tokens = {
13707 		(void *)&cmd_set_mplsoudp_encap_set,
13708 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13709 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13710 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13711 		(void *)&cmd_set_mplsoudp_encap_label,
13712 		(void *)&cmd_set_mplsoudp_encap_label_value,
13713 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13714 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13715 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13716 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13717 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13718 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13719 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13720 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13721 		(void *)&cmd_set_mplsoudp_encap_vlan,
13722 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13723 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13724 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13725 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13726 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13727 		NULL,
13728 	},
13729 };
13730 
13731 /** Set MPLSoUDP decapsulation details */
13732 struct cmd_set_mplsoudp_decap_result {
13733 	cmdline_fixed_string_t set;
13734 	cmdline_fixed_string_t mplsoudp;
13735 	cmdline_fixed_string_t pos_token;
13736 	cmdline_fixed_string_t ip_version;
13737 	uint32_t vlan_present:1;
13738 };
13739 
13740 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13741 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13742 				 "set");
13743 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13744 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13745 				 "mplsoudp_decap");
13746 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13747 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13748 				 mplsoudp, "mplsoudp_decap-with-vlan");
13749 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13750 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13751 				 pos_token, "ip-version");
13752 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13753 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13754 				 ip_version, "ipv4#ipv6");
13755 
13756 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13757 	__rte_unused struct cmdline *cl,
13758 	__rte_unused void *data)
13759 {
13760 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13761 
13762 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13763 		mplsoudp_decap_conf.select_vlan = 0;
13764 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13765 		mplsoudp_decap_conf.select_vlan = 1;
13766 	if (strcmp(res->ip_version, "ipv4") == 0)
13767 		mplsoudp_decap_conf.select_ipv4 = 1;
13768 	else if (strcmp(res->ip_version, "ipv6") == 0)
13769 		mplsoudp_decap_conf.select_ipv4 = 0;
13770 }
13771 
13772 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13773 	.f = cmd_set_mplsoudp_decap_parsed,
13774 	.data = NULL,
13775 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13776 	.tokens = {
13777 		(void *)&cmd_set_mplsoudp_decap_set,
13778 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13779 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13780 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13781 		NULL,
13782 	},
13783 };
13784 
13785 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13786 	.f = cmd_set_mplsoudp_decap_parsed,
13787 	.data = NULL,
13788 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13789 	.tokens = {
13790 		(void *)&cmd_set_mplsoudp_decap_set,
13791 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13792 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13793 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13794 		NULL,
13795 	},
13796 };
13797 
13798 /** Set connection tracking object common details */
13799 struct cmd_set_conntrack_common_result {
13800 	cmdline_fixed_string_t set;
13801 	cmdline_fixed_string_t conntrack;
13802 	cmdline_fixed_string_t common;
13803 	cmdline_fixed_string_t peer;
13804 	cmdline_fixed_string_t is_orig;
13805 	cmdline_fixed_string_t enable;
13806 	cmdline_fixed_string_t live;
13807 	cmdline_fixed_string_t sack;
13808 	cmdline_fixed_string_t cack;
13809 	cmdline_fixed_string_t last_dir;
13810 	cmdline_fixed_string_t liberal;
13811 	cmdline_fixed_string_t state;
13812 	cmdline_fixed_string_t max_ack_win;
13813 	cmdline_fixed_string_t retrans;
13814 	cmdline_fixed_string_t last_win;
13815 	cmdline_fixed_string_t last_seq;
13816 	cmdline_fixed_string_t last_ack;
13817 	cmdline_fixed_string_t last_end;
13818 	cmdline_fixed_string_t last_index;
13819 	uint8_t stat;
13820 	uint8_t factor;
13821 	uint16_t peer_port;
13822 	uint32_t is_original;
13823 	uint32_t en;
13824 	uint32_t is_live;
13825 	uint32_t s_ack;
13826 	uint32_t c_ack;
13827 	uint32_t ld;
13828 	uint32_t lb;
13829 	uint8_t re_num;
13830 	uint8_t li;
13831 	uint16_t lw;
13832 	uint32_t ls;
13833 	uint32_t la;
13834 	uint32_t le;
13835 };
13836 
13837 cmdline_parse_token_string_t cmd_set_conntrack_set =
13838 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13839 				 set, "set");
13840 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13841 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13842 				 conntrack, "conntrack");
13843 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13844 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13845 				 common, "com");
13846 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13847 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13848 				 peer, "peer");
13849 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13850 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13851 			      peer_port, RTE_UINT16);
13852 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13853 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13854 				 is_orig, "is_orig");
13855 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13856 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13857 			      is_original, RTE_UINT32);
13858 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13859 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13860 				 enable, "enable");
13861 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13862 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13863 			      en, RTE_UINT32);
13864 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13865 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13866 				 live, "live");
13867 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13868 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13869 			      is_live, RTE_UINT32);
13870 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13871 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13872 				 sack, "sack");
13873 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13874 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13875 			      s_ack, RTE_UINT32);
13876 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13877 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13878 				 cack, "cack");
13879 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13880 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13881 			      c_ack, RTE_UINT32);
13882 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13883 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13884 				 last_dir, "last_dir");
13885 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13886 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13887 			      ld, RTE_UINT32);
13888 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13889 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13890 				 liberal, "liberal");
13891 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13892 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13893 			      lb, RTE_UINT32);
13894 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13895 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13896 				 state, "state");
13897 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13898 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13899 			      stat, RTE_UINT8);
13900 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13901 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13902 				 max_ack_win, "max_ack_win");
13903 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13904 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13905 			      factor, RTE_UINT8);
13906 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13907 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13908 				 retrans, "r_lim");
13909 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13910 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13911 			      re_num, RTE_UINT8);
13912 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13913 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13914 				 last_win, "last_win");
13915 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13916 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13917 			      lw, RTE_UINT16);
13918 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13919 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13920 				 last_seq, "last_seq");
13921 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13922 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13923 			      ls, RTE_UINT32);
13924 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13925 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13926 				 last_ack, "last_ack");
13927 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13928 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13929 			      la, RTE_UINT32);
13930 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13931 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13932 				 last_end, "last_end");
13933 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13934 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13935 			      le, RTE_UINT32);
13936 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13937 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13938 				 last_index, "last_index");
13939 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13940 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13941 			      li, RTE_UINT8);
13942 
13943 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13944 	__rte_unused struct cmdline *cl,
13945 	__rte_unused void *data)
13946 {
13947 	struct cmd_set_conntrack_common_result *res = parsed_result;
13948 
13949 	/* No need to swap to big endian. */
13950 	conntrack_context.peer_port = res->peer_port;
13951 	conntrack_context.is_original_dir = res->is_original;
13952 	conntrack_context.enable = res->en;
13953 	conntrack_context.live_connection = res->is_live;
13954 	conntrack_context.selective_ack = res->s_ack;
13955 	conntrack_context.challenge_ack_passed = res->c_ack;
13956 	conntrack_context.last_direction = res->ld;
13957 	conntrack_context.liberal_mode = res->lb;
13958 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13959 	conntrack_context.max_ack_window = res->factor;
13960 	conntrack_context.retransmission_limit = res->re_num;
13961 	conntrack_context.last_window = res->lw;
13962 	conntrack_context.last_index =
13963 		(enum rte_flow_conntrack_tcp_last_index)res->li;
13964 	conntrack_context.last_seq = res->ls;
13965 	conntrack_context.last_ack = res->la;
13966 	conntrack_context.last_end = res->le;
13967 }
13968 
13969 cmdline_parse_inst_t cmd_set_conntrack_common = {
13970 	.f = cmd_set_conntrack_common_parsed,
13971 	.data = NULL,
13972 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13973 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13974 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13975 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13976 		" last_index <flag>",
13977 	.tokens = {
13978 		(void *)&cmd_set_conntrack_set,
13979 		(void *)&cmd_set_conntrack_conntrack,
13980 		(void *)&cmd_set_conntrack_common_com,
13981 		(void *)&cmd_set_conntrack_common_peer,
13982 		(void *)&cmd_set_conntrack_common_peer_value,
13983 		(void *)&cmd_set_conntrack_common_is_orig,
13984 		(void *)&cmd_set_conntrack_common_is_orig_value,
13985 		(void *)&cmd_set_conntrack_common_enable,
13986 		(void *)&cmd_set_conntrack_common_enable_value,
13987 		(void *)&cmd_set_conntrack_common_live,
13988 		(void *)&cmd_set_conntrack_common_live_value,
13989 		(void *)&cmd_set_conntrack_common_sack,
13990 		(void *)&cmd_set_conntrack_common_sack_value,
13991 		(void *)&cmd_set_conntrack_common_cack,
13992 		(void *)&cmd_set_conntrack_common_cack_value,
13993 		(void *)&cmd_set_conntrack_common_last_dir,
13994 		(void *)&cmd_set_conntrack_common_last_dir_value,
13995 		(void *)&cmd_set_conntrack_common_liberal,
13996 		(void *)&cmd_set_conntrack_common_liberal_value,
13997 		(void *)&cmd_set_conntrack_common_state,
13998 		(void *)&cmd_set_conntrack_common_state_value,
13999 		(void *)&cmd_set_conntrack_common_max_ackwin,
14000 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
14001 		(void *)&cmd_set_conntrack_common_retrans,
14002 		(void *)&cmd_set_conntrack_common_retrans_value,
14003 		(void *)&cmd_set_conntrack_common_last_win,
14004 		(void *)&cmd_set_conntrack_common_last_win_value,
14005 		(void *)&cmd_set_conntrack_common_last_seq,
14006 		(void *)&cmd_set_conntrack_common_last_seq_value,
14007 		(void *)&cmd_set_conntrack_common_last_ack,
14008 		(void *)&cmd_set_conntrack_common_last_ack_value,
14009 		(void *)&cmd_set_conntrack_common_last_end,
14010 		(void *)&cmd_set_conntrack_common_last_end_value,
14011 		(void *)&cmd_set_conntrack_common_last_index,
14012 		(void *)&cmd_set_conntrack_common_last_index_value,
14013 		NULL,
14014 	},
14015 };
14016 
14017 /** Set connection tracking object both directions' details */
14018 struct cmd_set_conntrack_dir_result {
14019 	cmdline_fixed_string_t set;
14020 	cmdline_fixed_string_t conntrack;
14021 	cmdline_fixed_string_t dir;
14022 	cmdline_fixed_string_t scale;
14023 	cmdline_fixed_string_t fin;
14024 	cmdline_fixed_string_t ack_seen;
14025 	cmdline_fixed_string_t unack;
14026 	cmdline_fixed_string_t sent_end;
14027 	cmdline_fixed_string_t reply_end;
14028 	cmdline_fixed_string_t max_win;
14029 	cmdline_fixed_string_t max_ack;
14030 	uint32_t factor;
14031 	uint32_t f;
14032 	uint32_t as;
14033 	uint32_t un;
14034 	uint32_t se;
14035 	uint32_t re;
14036 	uint32_t mw;
14037 	uint32_t ma;
14038 };
14039 
14040 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14041 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14042 				 set, "set");
14043 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14044 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14045 				 conntrack, "conntrack");
14046 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14047 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14048 				 dir, "orig#rply");
14049 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14050 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14051 				 scale, "scale");
14052 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14053 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14054 			      factor, RTE_UINT32);
14055 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14056 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14057 				 fin, "fin");
14058 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14059 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14060 			      f, RTE_UINT32);
14061 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14062 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14063 				 ack_seen, "acked");
14064 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14065 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14066 			      as, RTE_UINT32);
14067 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14068 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14069 				 unack, "unack_data");
14070 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14071 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14072 			      un, RTE_UINT32);
14073 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14074 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14075 				 sent_end, "sent_end");
14076 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14077 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14078 			      se, RTE_UINT32);
14079 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14080 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14081 				 reply_end, "reply_end");
14082 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14083 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14084 			      re, RTE_UINT32);
14085 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14086 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14087 				 max_win, "max_win");
14088 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14089 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14090 			      mw, RTE_UINT32);
14091 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14092 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14093 				 max_ack, "max_ack");
14094 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14095 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14096 			      ma, RTE_UINT32);
14097 
14098 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14099 	__rte_unused struct cmdline *cl,
14100 	__rte_unused void *data)
14101 {
14102 	struct cmd_set_conntrack_dir_result *res = parsed_result;
14103 	struct rte_flow_tcp_dir_param *dir = NULL;
14104 
14105 	if (strcmp(res->dir, "orig") == 0)
14106 		dir = &conntrack_context.original_dir;
14107 	else if (strcmp(res->dir, "rply") == 0)
14108 		dir = &conntrack_context.reply_dir;
14109 	else
14110 		return;
14111 	dir->scale = res->factor;
14112 	dir->close_initiated = res->f;
14113 	dir->last_ack_seen = res->as;
14114 	dir->data_unacked = res->un;
14115 	dir->sent_end = res->se;
14116 	dir->reply_end = res->re;
14117 	dir->max_ack = res->ma;
14118 	dir->max_win = res->mw;
14119 }
14120 
14121 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14122 	.f = cmd_set_conntrack_dir_parsed,
14123 	.data = NULL,
14124 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14125 		    " acked <seen> unack_data <unack> sent_end <sent>"
14126 		    " reply_end <reply> max_win <win> max_ack <ack>",
14127 	.tokens = {
14128 		(void *)&cmd_set_conntrack_set,
14129 		(void *)&cmd_set_conntrack_conntrack,
14130 		(void *)&cmd_set_conntrack_dir_dir,
14131 		(void *)&cmd_set_conntrack_dir_scale,
14132 		(void *)&cmd_set_conntrack_dir_scale_value,
14133 		(void *)&cmd_set_conntrack_dir_fin,
14134 		(void *)&cmd_set_conntrack_dir_fin_value,
14135 		(void *)&cmd_set_conntrack_dir_ack,
14136 		(void *)&cmd_set_conntrack_dir_ack_value,
14137 		(void *)&cmd_set_conntrack_dir_unack_data,
14138 		(void *)&cmd_set_conntrack_dir_unack_data_value,
14139 		(void *)&cmd_set_conntrack_dir_sent_end,
14140 		(void *)&cmd_set_conntrack_dir_sent_end_value,
14141 		(void *)&cmd_set_conntrack_dir_reply_end,
14142 		(void *)&cmd_set_conntrack_dir_reply_end_value,
14143 		(void *)&cmd_set_conntrack_dir_max_win,
14144 		(void *)&cmd_set_conntrack_dir_max_win_value,
14145 		(void *)&cmd_set_conntrack_dir_max_ack,
14146 		(void *)&cmd_set_conntrack_dir_max_ack_value,
14147 		NULL,
14148 	},
14149 };
14150 
14151 /* Strict link priority scheduling mode setting */
14152 static void
14153 cmd_strict_link_prio_parsed(
14154 	void *parsed_result,
14155 	__rte_unused struct cmdline *cl,
14156 	__rte_unused void *data)
14157 {
14158 	struct cmd_vf_tc_bw_result *res = parsed_result;
14159 	int ret = -ENOTSUP;
14160 
14161 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14162 		return;
14163 
14164 #ifdef RTE_NET_I40E
14165 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14166 #endif
14167 
14168 	switch (ret) {
14169 	case 0:
14170 		break;
14171 	case -EINVAL:
14172 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14173 		break;
14174 	case -ENODEV:
14175 		printf("invalid port_id %d\n", res->port_id);
14176 		break;
14177 	case -ENOTSUP:
14178 		printf("function not implemented\n");
14179 		break;
14180 	default:
14181 		printf("programming error: (%s)\n", strerror(-ret));
14182 	}
14183 }
14184 
14185 cmdline_parse_inst_t cmd_strict_link_prio = {
14186 	.f = cmd_strict_link_prio_parsed,
14187 	.data = NULL,
14188 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14189 	.tokens = {
14190 		(void *)&cmd_vf_tc_bw_set,
14191 		(void *)&cmd_vf_tc_bw_tx,
14192 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14193 		(void *)&cmd_vf_tc_bw_port_id,
14194 		(void *)&cmd_vf_tc_bw_tc_map,
14195 		NULL,
14196 	},
14197 };
14198 
14199 /* Load dynamic device personalization*/
14200 struct cmd_ddp_add_result {
14201 	cmdline_fixed_string_t ddp;
14202 	cmdline_fixed_string_t add;
14203 	portid_t port_id;
14204 	char filepath[];
14205 };
14206 
14207 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14208 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14209 cmdline_parse_token_string_t cmd_ddp_add_add =
14210 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14211 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14212 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14213 		RTE_UINT16);
14214 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14215 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14216 
14217 static void
14218 cmd_ddp_add_parsed(
14219 	void *parsed_result,
14220 	__rte_unused struct cmdline *cl,
14221 	__rte_unused void *data)
14222 {
14223 	struct cmd_ddp_add_result *res = parsed_result;
14224 	uint8_t *buff;
14225 	uint32_t size;
14226 	char *filepath;
14227 	char *file_fld[2];
14228 	int file_num;
14229 	int ret = -ENOTSUP;
14230 
14231 	if (!all_ports_stopped()) {
14232 		printf("Please stop all ports first\n");
14233 		return;
14234 	}
14235 
14236 	filepath = strdup(res->filepath);
14237 	if (filepath == NULL) {
14238 		printf("Failed to allocate memory\n");
14239 		return;
14240 	}
14241 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14242 
14243 	buff = open_file(file_fld[0], &size);
14244 	if (!buff) {
14245 		free((void *)filepath);
14246 		return;
14247 	}
14248 
14249 #ifdef RTE_NET_I40E
14250 	if (ret == -ENOTSUP)
14251 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14252 					       buff, size,
14253 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14254 #endif
14255 
14256 	if (ret == -EEXIST)
14257 		printf("Profile has already existed.\n");
14258 	else if (ret < 0)
14259 		printf("Failed to load profile.\n");
14260 	else if (file_num == 2)
14261 		save_file(file_fld[1], buff, size);
14262 
14263 	close_file(buff);
14264 	free((void *)filepath);
14265 }
14266 
14267 cmdline_parse_inst_t cmd_ddp_add = {
14268 	.f = cmd_ddp_add_parsed,
14269 	.data = NULL,
14270 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14271 	.tokens = {
14272 		(void *)&cmd_ddp_add_ddp,
14273 		(void *)&cmd_ddp_add_add,
14274 		(void *)&cmd_ddp_add_port_id,
14275 		(void *)&cmd_ddp_add_filepath,
14276 		NULL,
14277 	},
14278 };
14279 
14280 /* Delete dynamic device personalization*/
14281 struct cmd_ddp_del_result {
14282 	cmdline_fixed_string_t ddp;
14283 	cmdline_fixed_string_t del;
14284 	portid_t port_id;
14285 	char filepath[];
14286 };
14287 
14288 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14289 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14290 cmdline_parse_token_string_t cmd_ddp_del_del =
14291 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14292 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14293 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14294 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14295 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14296 
14297 static void
14298 cmd_ddp_del_parsed(
14299 	void *parsed_result,
14300 	__rte_unused struct cmdline *cl,
14301 	__rte_unused void *data)
14302 {
14303 	struct cmd_ddp_del_result *res = parsed_result;
14304 	uint8_t *buff;
14305 	uint32_t size;
14306 	int ret = -ENOTSUP;
14307 
14308 	if (!all_ports_stopped()) {
14309 		printf("Please stop all ports first\n");
14310 		return;
14311 	}
14312 
14313 	buff = open_file(res->filepath, &size);
14314 	if (!buff)
14315 		return;
14316 
14317 #ifdef RTE_NET_I40E
14318 	if (ret == -ENOTSUP)
14319 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14320 					       buff, size,
14321 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14322 #endif
14323 
14324 	if (ret == -EACCES)
14325 		printf("Profile does not exist.\n");
14326 	else if (ret < 0)
14327 		printf("Failed to delete profile.\n");
14328 
14329 	close_file(buff);
14330 }
14331 
14332 cmdline_parse_inst_t cmd_ddp_del = {
14333 	.f = cmd_ddp_del_parsed,
14334 	.data = NULL,
14335 	.help_str = "ddp del <port_id> <backup_profile_path>",
14336 	.tokens = {
14337 		(void *)&cmd_ddp_del_ddp,
14338 		(void *)&cmd_ddp_del_del,
14339 		(void *)&cmd_ddp_del_port_id,
14340 		(void *)&cmd_ddp_del_filepath,
14341 		NULL,
14342 	},
14343 };
14344 
14345 /* Get dynamic device personalization profile info */
14346 struct cmd_ddp_info_result {
14347 	cmdline_fixed_string_t ddp;
14348 	cmdline_fixed_string_t get;
14349 	cmdline_fixed_string_t info;
14350 	char filepath[];
14351 };
14352 
14353 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14354 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14355 cmdline_parse_token_string_t cmd_ddp_info_get =
14356 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14357 cmdline_parse_token_string_t cmd_ddp_info_info =
14358 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14359 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14360 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14361 
14362 static void
14363 cmd_ddp_info_parsed(
14364 	void *parsed_result,
14365 	__rte_unused struct cmdline *cl,
14366 	__rte_unused void *data)
14367 {
14368 	struct cmd_ddp_info_result *res = parsed_result;
14369 	uint8_t *pkg;
14370 	uint32_t pkg_size;
14371 	int ret = -ENOTSUP;
14372 #ifdef RTE_NET_I40E
14373 	uint32_t i, j, n;
14374 	uint8_t *buff;
14375 	uint32_t buff_size = 0;
14376 	struct rte_pmd_i40e_profile_info info;
14377 	uint32_t dev_num = 0;
14378 	struct rte_pmd_i40e_ddp_device_id *devs;
14379 	uint32_t proto_num = 0;
14380 	struct rte_pmd_i40e_proto_info *proto = NULL;
14381 	uint32_t pctype_num = 0;
14382 	struct rte_pmd_i40e_ptype_info *pctype;
14383 	uint32_t ptype_num = 0;
14384 	struct rte_pmd_i40e_ptype_info *ptype;
14385 	uint8_t proto_id;
14386 
14387 #endif
14388 
14389 	pkg = open_file(res->filepath, &pkg_size);
14390 	if (!pkg)
14391 		return;
14392 
14393 #ifdef RTE_NET_I40E
14394 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14395 				(uint8_t *)&info, sizeof(info),
14396 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14397 	if (!ret) {
14398 		printf("Global Track id:       0x%x\n", info.track_id);
14399 		printf("Global Version:        %d.%d.%d.%d\n",
14400 			info.version.major,
14401 			info.version.minor,
14402 			info.version.update,
14403 			info.version.draft);
14404 		printf("Global Package name:   %s\n\n", info.name);
14405 	}
14406 
14407 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14408 				(uint8_t *)&info, sizeof(info),
14409 				RTE_PMD_I40E_PKG_INFO_HEADER);
14410 	if (!ret) {
14411 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14412 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14413 			info.version.major,
14414 			info.version.minor,
14415 			info.version.update,
14416 			info.version.draft);
14417 		printf("i40e Profile name:     %s\n\n", info.name);
14418 	}
14419 
14420 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14421 				(uint8_t *)&buff_size, sizeof(buff_size),
14422 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14423 	if (!ret && buff_size) {
14424 		buff = (uint8_t *)malloc(buff_size);
14425 		if (buff) {
14426 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14427 						buff, buff_size,
14428 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14429 			if (!ret)
14430 				printf("Package Notes:\n%s\n\n", buff);
14431 			free(buff);
14432 		}
14433 	}
14434 
14435 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14436 				(uint8_t *)&dev_num, sizeof(dev_num),
14437 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14438 	if (!ret && dev_num) {
14439 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14440 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14441 		if (devs) {
14442 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14443 						(uint8_t *)devs, buff_size,
14444 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14445 			if (!ret) {
14446 				printf("List of supported devices:\n");
14447 				for (i = 0; i < dev_num; i++) {
14448 					printf("  %04X:%04X %04X:%04X\n",
14449 						devs[i].vendor_dev_id >> 16,
14450 						devs[i].vendor_dev_id & 0xFFFF,
14451 						devs[i].sub_vendor_dev_id >> 16,
14452 						devs[i].sub_vendor_dev_id & 0xFFFF);
14453 				}
14454 				printf("\n");
14455 			}
14456 			free(devs);
14457 		}
14458 	}
14459 
14460 	/* get information about protocols and packet types */
14461 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14462 		(uint8_t *)&proto_num, sizeof(proto_num),
14463 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14464 	if (ret || !proto_num)
14465 		goto no_print_return;
14466 
14467 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14468 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14469 	if (!proto)
14470 		goto no_print_return;
14471 
14472 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14473 					buff_size,
14474 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14475 	if (!ret) {
14476 		printf("List of used protocols:\n");
14477 		for (i = 0; i < proto_num; i++)
14478 			printf("  %2u: %s\n", proto[i].proto_id,
14479 			       proto[i].name);
14480 		printf("\n");
14481 	}
14482 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14483 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14484 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14485 	if (ret || !pctype_num)
14486 		goto no_print_pctypes;
14487 
14488 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14489 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14490 	if (!pctype)
14491 		goto no_print_pctypes;
14492 
14493 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14494 					buff_size,
14495 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14496 	if (ret) {
14497 		free(pctype);
14498 		goto no_print_pctypes;
14499 	}
14500 
14501 	printf("List of defined packet classification types:\n");
14502 	for (i = 0; i < pctype_num; i++) {
14503 		printf("  %2u:", pctype[i].ptype_id);
14504 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14505 			proto_id = pctype[i].protocols[j];
14506 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14507 				for (n = 0; n < proto_num; n++) {
14508 					if (proto[n].proto_id == proto_id) {
14509 						printf(" %s", proto[n].name);
14510 						break;
14511 					}
14512 				}
14513 			}
14514 		}
14515 		printf("\n");
14516 	}
14517 	printf("\n");
14518 	free(pctype);
14519 
14520 no_print_pctypes:
14521 
14522 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14523 					sizeof(ptype_num),
14524 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14525 	if (ret || !ptype_num)
14526 		goto no_print_return;
14527 
14528 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14529 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14530 	if (!ptype)
14531 		goto no_print_return;
14532 
14533 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14534 					buff_size,
14535 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14536 	if (ret) {
14537 		free(ptype);
14538 		goto no_print_return;
14539 	}
14540 	printf("List of defined packet types:\n");
14541 	for (i = 0; i < ptype_num; i++) {
14542 		printf("  %2u:", ptype[i].ptype_id);
14543 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14544 			proto_id = ptype[i].protocols[j];
14545 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14546 				for (n = 0; n < proto_num; n++) {
14547 					if (proto[n].proto_id == proto_id) {
14548 						printf(" %s", proto[n].name);
14549 						break;
14550 					}
14551 				}
14552 			}
14553 		}
14554 		printf("\n");
14555 	}
14556 	free(ptype);
14557 	printf("\n");
14558 
14559 	ret = 0;
14560 no_print_return:
14561 	if (proto)
14562 		free(proto);
14563 #endif
14564 	if (ret == -ENOTSUP)
14565 		printf("Function not supported in PMD driver\n");
14566 	close_file(pkg);
14567 }
14568 
14569 cmdline_parse_inst_t cmd_ddp_get_info = {
14570 	.f = cmd_ddp_info_parsed,
14571 	.data = NULL,
14572 	.help_str = "ddp get info <profile_path>",
14573 	.tokens = {
14574 		(void *)&cmd_ddp_info_ddp,
14575 		(void *)&cmd_ddp_info_get,
14576 		(void *)&cmd_ddp_info_info,
14577 		(void *)&cmd_ddp_info_filepath,
14578 		NULL,
14579 	},
14580 };
14581 
14582 /* Get dynamic device personalization profile info list*/
14583 #define PROFILE_INFO_SIZE 48
14584 #define MAX_PROFILE_NUM 16
14585 
14586 struct cmd_ddp_get_list_result {
14587 	cmdline_fixed_string_t ddp;
14588 	cmdline_fixed_string_t get;
14589 	cmdline_fixed_string_t list;
14590 	portid_t port_id;
14591 };
14592 
14593 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14594 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14595 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14596 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14597 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14598 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14599 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14600 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14601 		RTE_UINT16);
14602 
14603 static void
14604 cmd_ddp_get_list_parsed(
14605 	__rte_unused void *parsed_result,
14606 	__rte_unused struct cmdline *cl,
14607 	__rte_unused void *data)
14608 {
14609 #ifdef RTE_NET_I40E
14610 	struct cmd_ddp_get_list_result *res = parsed_result;
14611 	struct rte_pmd_i40e_profile_list *p_list;
14612 	struct rte_pmd_i40e_profile_info *p_info;
14613 	uint32_t p_num;
14614 	uint32_t size;
14615 	uint32_t i;
14616 #endif
14617 	int ret = -ENOTSUP;
14618 
14619 #ifdef RTE_NET_I40E
14620 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14621 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14622 	if (!p_list) {
14623 		printf("%s: Failed to malloc buffer\n", __func__);
14624 		return;
14625 	}
14626 
14627 	if (ret == -ENOTSUP)
14628 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14629 						(uint8_t *)p_list, size);
14630 
14631 	if (!ret) {
14632 		p_num = p_list->p_count;
14633 		printf("Profile number is: %d\n\n", p_num);
14634 
14635 		for (i = 0; i < p_num; i++) {
14636 			p_info = &p_list->p_info[i];
14637 			printf("Profile %d:\n", i);
14638 			printf("Track id:     0x%x\n", p_info->track_id);
14639 			printf("Version:      %d.%d.%d.%d\n",
14640 			       p_info->version.major,
14641 			       p_info->version.minor,
14642 			       p_info->version.update,
14643 			       p_info->version.draft);
14644 			printf("Profile name: %s\n\n", p_info->name);
14645 		}
14646 	}
14647 
14648 	free(p_list);
14649 #endif
14650 
14651 	if (ret < 0)
14652 		printf("Failed to get ddp list\n");
14653 }
14654 
14655 cmdline_parse_inst_t cmd_ddp_get_list = {
14656 	.f = cmd_ddp_get_list_parsed,
14657 	.data = NULL,
14658 	.help_str = "ddp get list <port_id>",
14659 	.tokens = {
14660 		(void *)&cmd_ddp_get_list_ddp,
14661 		(void *)&cmd_ddp_get_list_get,
14662 		(void *)&cmd_ddp_get_list_list,
14663 		(void *)&cmd_ddp_get_list_port_id,
14664 		NULL,
14665 	},
14666 };
14667 
14668 /* Configure input set */
14669 struct cmd_cfg_input_set_result {
14670 	cmdline_fixed_string_t port;
14671 	cmdline_fixed_string_t cfg;
14672 	portid_t port_id;
14673 	cmdline_fixed_string_t pctype;
14674 	uint8_t pctype_id;
14675 	cmdline_fixed_string_t inset_type;
14676 	cmdline_fixed_string_t opt;
14677 	cmdline_fixed_string_t field;
14678 	uint8_t field_idx;
14679 };
14680 
14681 static void
14682 cmd_cfg_input_set_parsed(
14683 	__rte_unused void *parsed_result,
14684 	__rte_unused struct cmdline *cl,
14685 	__rte_unused void *data)
14686 {
14687 #ifdef RTE_NET_I40E
14688 	struct cmd_cfg_input_set_result *res = parsed_result;
14689 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14690 	struct rte_pmd_i40e_inset inset;
14691 #endif
14692 	int ret = -ENOTSUP;
14693 
14694 	if (!all_ports_stopped()) {
14695 		printf("Please stop all ports first\n");
14696 		return;
14697 	}
14698 
14699 #ifdef RTE_NET_I40E
14700 	if (!strcmp(res->inset_type, "hash_inset"))
14701 		inset_type = INSET_HASH;
14702 	else if (!strcmp(res->inset_type, "fdir_inset"))
14703 		inset_type = INSET_FDIR;
14704 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14705 		inset_type = INSET_FDIR_FLX;
14706 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14707 				     &inset, inset_type);
14708 	if (ret) {
14709 		printf("Failed to get input set.\n");
14710 		return;
14711 	}
14712 
14713 	if (!strcmp(res->opt, "get")) {
14714 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14715 						   res->field_idx);
14716 		if (ret)
14717 			printf("Field index %d is enabled.\n", res->field_idx);
14718 		else
14719 			printf("Field index %d is disabled.\n", res->field_idx);
14720 		return;
14721 	} else if (!strcmp(res->opt, "set"))
14722 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14723 						   res->field_idx);
14724 	else if (!strcmp(res->opt, "clear"))
14725 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14726 						     res->field_idx);
14727 	if (ret) {
14728 		printf("Failed to configure input set field.\n");
14729 		return;
14730 	}
14731 
14732 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14733 				     &inset, inset_type);
14734 	if (ret) {
14735 		printf("Failed to set input set.\n");
14736 		return;
14737 	}
14738 #endif
14739 
14740 	if (ret == -ENOTSUP)
14741 		printf("Function not supported\n");
14742 }
14743 
14744 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14745 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14746 				 port, "port");
14747 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14748 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14749 				 cfg, "config");
14750 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14751 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14752 			      port_id, RTE_UINT16);
14753 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14754 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14755 				 pctype, "pctype");
14756 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14757 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14758 			      pctype_id, RTE_UINT8);
14759 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14760 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14761 				 inset_type,
14762 				 "hash_inset#fdir_inset#fdir_flx_inset");
14763 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14764 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14765 				 opt, "get#set#clear");
14766 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14767 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14768 				 field, "field");
14769 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14770 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14771 			      field_idx, RTE_UINT8);
14772 
14773 cmdline_parse_inst_t cmd_cfg_input_set = {
14774 	.f = cmd_cfg_input_set_parsed,
14775 	.data = NULL,
14776 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14777 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14778 	.tokens = {
14779 		(void *)&cmd_cfg_input_set_port,
14780 		(void *)&cmd_cfg_input_set_cfg,
14781 		(void *)&cmd_cfg_input_set_port_id,
14782 		(void *)&cmd_cfg_input_set_pctype,
14783 		(void *)&cmd_cfg_input_set_pctype_id,
14784 		(void *)&cmd_cfg_input_set_inset_type,
14785 		(void *)&cmd_cfg_input_set_opt,
14786 		(void *)&cmd_cfg_input_set_field,
14787 		(void *)&cmd_cfg_input_set_field_idx,
14788 		NULL,
14789 	},
14790 };
14791 
14792 /* Clear input set */
14793 struct cmd_clear_input_set_result {
14794 	cmdline_fixed_string_t port;
14795 	cmdline_fixed_string_t cfg;
14796 	portid_t port_id;
14797 	cmdline_fixed_string_t pctype;
14798 	uint8_t pctype_id;
14799 	cmdline_fixed_string_t inset_type;
14800 	cmdline_fixed_string_t clear;
14801 	cmdline_fixed_string_t all;
14802 };
14803 
14804 static void
14805 cmd_clear_input_set_parsed(
14806 	__rte_unused void *parsed_result,
14807 	__rte_unused struct cmdline *cl,
14808 	__rte_unused void *data)
14809 {
14810 #ifdef RTE_NET_I40E
14811 	struct cmd_clear_input_set_result *res = parsed_result;
14812 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14813 	struct rte_pmd_i40e_inset inset;
14814 #endif
14815 	int ret = -ENOTSUP;
14816 
14817 	if (!all_ports_stopped()) {
14818 		printf("Please stop all ports first\n");
14819 		return;
14820 	}
14821 
14822 #ifdef RTE_NET_I40E
14823 	if (!strcmp(res->inset_type, "hash_inset"))
14824 		inset_type = INSET_HASH;
14825 	else if (!strcmp(res->inset_type, "fdir_inset"))
14826 		inset_type = INSET_FDIR;
14827 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14828 		inset_type = INSET_FDIR_FLX;
14829 
14830 	memset(&inset, 0, sizeof(inset));
14831 
14832 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14833 				     &inset, inset_type);
14834 	if (ret) {
14835 		printf("Failed to clear input set.\n");
14836 		return;
14837 	}
14838 
14839 #endif
14840 
14841 	if (ret == -ENOTSUP)
14842 		printf("Function not supported\n");
14843 }
14844 
14845 cmdline_parse_token_string_t cmd_clear_input_set_port =
14846 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14847 				 port, "port");
14848 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14849 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14850 				 cfg, "config");
14851 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14852 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14853 			      port_id, RTE_UINT16);
14854 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14855 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14856 				 pctype, "pctype");
14857 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14858 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14859 			      pctype_id, RTE_UINT8);
14860 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14861 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14862 				 inset_type,
14863 				 "hash_inset#fdir_inset#fdir_flx_inset");
14864 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14865 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14866 				 clear, "clear");
14867 cmdline_parse_token_string_t cmd_clear_input_set_all =
14868 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14869 				 all, "all");
14870 
14871 cmdline_parse_inst_t cmd_clear_input_set = {
14872 	.f = cmd_clear_input_set_parsed,
14873 	.data = NULL,
14874 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14875 		    "fdir_inset|fdir_flx_inset clear all",
14876 	.tokens = {
14877 		(void *)&cmd_clear_input_set_port,
14878 		(void *)&cmd_clear_input_set_cfg,
14879 		(void *)&cmd_clear_input_set_port_id,
14880 		(void *)&cmd_clear_input_set_pctype,
14881 		(void *)&cmd_clear_input_set_pctype_id,
14882 		(void *)&cmd_clear_input_set_inset_type,
14883 		(void *)&cmd_clear_input_set_clear,
14884 		(void *)&cmd_clear_input_set_all,
14885 		NULL,
14886 	},
14887 };
14888 
14889 /* show vf stats */
14890 
14891 /* Common result structure for show vf stats */
14892 struct cmd_show_vf_stats_result {
14893 	cmdline_fixed_string_t show;
14894 	cmdline_fixed_string_t vf;
14895 	cmdline_fixed_string_t stats;
14896 	portid_t port_id;
14897 	uint16_t vf_id;
14898 };
14899 
14900 /* Common CLI fields show vf stats*/
14901 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14902 	TOKEN_STRING_INITIALIZER
14903 		(struct cmd_show_vf_stats_result,
14904 		 show, "show");
14905 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14906 	TOKEN_STRING_INITIALIZER
14907 		(struct cmd_show_vf_stats_result,
14908 		 vf, "vf");
14909 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14910 	TOKEN_STRING_INITIALIZER
14911 		(struct cmd_show_vf_stats_result,
14912 		 stats, "stats");
14913 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14914 	TOKEN_NUM_INITIALIZER
14915 		(struct cmd_show_vf_stats_result,
14916 		 port_id, RTE_UINT16);
14917 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14918 	TOKEN_NUM_INITIALIZER
14919 		(struct cmd_show_vf_stats_result,
14920 		 vf_id, RTE_UINT16);
14921 
14922 static void
14923 cmd_show_vf_stats_parsed(
14924 	void *parsed_result,
14925 	__rte_unused struct cmdline *cl,
14926 	__rte_unused void *data)
14927 {
14928 	struct cmd_show_vf_stats_result *res = parsed_result;
14929 	struct rte_eth_stats stats;
14930 	int ret = -ENOTSUP;
14931 	static const char *nic_stats_border = "########################";
14932 
14933 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14934 		return;
14935 
14936 	memset(&stats, 0, sizeof(stats));
14937 
14938 #ifdef RTE_NET_I40E
14939 	if (ret == -ENOTSUP)
14940 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14941 						res->vf_id,
14942 						&stats);
14943 #endif
14944 #ifdef RTE_NET_BNXT
14945 	if (ret == -ENOTSUP)
14946 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14947 						res->vf_id,
14948 						&stats);
14949 #endif
14950 
14951 	switch (ret) {
14952 	case 0:
14953 		break;
14954 	case -EINVAL:
14955 		printf("invalid vf_id %d\n", res->vf_id);
14956 		break;
14957 	case -ENODEV:
14958 		printf("invalid port_id %d\n", res->port_id);
14959 		break;
14960 	case -ENOTSUP:
14961 		printf("function not implemented\n");
14962 		break;
14963 	default:
14964 		printf("programming error: (%s)\n", strerror(-ret));
14965 	}
14966 
14967 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
14968 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14969 
14970 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
14971 	       "%-"PRIu64"\n",
14972 	       stats.ipackets, stats.imissed, stats.ibytes);
14973 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
14974 	printf("  RX-nombuf:  %-10"PRIu64"\n",
14975 	       stats.rx_nombuf);
14976 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
14977 	       "%-"PRIu64"\n",
14978 	       stats.opackets, stats.oerrors, stats.obytes);
14979 
14980 	printf("  %s############################%s\n",
14981 			       nic_stats_border, nic_stats_border);
14982 }
14983 
14984 cmdline_parse_inst_t cmd_show_vf_stats = {
14985 	.f = cmd_show_vf_stats_parsed,
14986 	.data = NULL,
14987 	.help_str = "show vf stats <port_id> <vf_id>",
14988 	.tokens = {
14989 		(void *)&cmd_show_vf_stats_show,
14990 		(void *)&cmd_show_vf_stats_vf,
14991 		(void *)&cmd_show_vf_stats_stats,
14992 		(void *)&cmd_show_vf_stats_port_id,
14993 		(void *)&cmd_show_vf_stats_vf_id,
14994 		NULL,
14995 	},
14996 };
14997 
14998 /* clear vf stats */
14999 
15000 /* Common result structure for clear vf stats */
15001 struct cmd_clear_vf_stats_result {
15002 	cmdline_fixed_string_t clear;
15003 	cmdline_fixed_string_t vf;
15004 	cmdline_fixed_string_t stats;
15005 	portid_t port_id;
15006 	uint16_t vf_id;
15007 };
15008 
15009 /* Common CLI fields clear vf stats*/
15010 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15011 	TOKEN_STRING_INITIALIZER
15012 		(struct cmd_clear_vf_stats_result,
15013 		 clear, "clear");
15014 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15015 	TOKEN_STRING_INITIALIZER
15016 		(struct cmd_clear_vf_stats_result,
15017 		 vf, "vf");
15018 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15019 	TOKEN_STRING_INITIALIZER
15020 		(struct cmd_clear_vf_stats_result,
15021 		 stats, "stats");
15022 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15023 	TOKEN_NUM_INITIALIZER
15024 		(struct cmd_clear_vf_stats_result,
15025 		 port_id, RTE_UINT16);
15026 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15027 	TOKEN_NUM_INITIALIZER
15028 		(struct cmd_clear_vf_stats_result,
15029 		 vf_id, RTE_UINT16);
15030 
15031 static void
15032 cmd_clear_vf_stats_parsed(
15033 	void *parsed_result,
15034 	__rte_unused struct cmdline *cl,
15035 	__rte_unused void *data)
15036 {
15037 	struct cmd_clear_vf_stats_result *res = parsed_result;
15038 	int ret = -ENOTSUP;
15039 
15040 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15041 		return;
15042 
15043 #ifdef RTE_NET_I40E
15044 	if (ret == -ENOTSUP)
15045 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15046 						  res->vf_id);
15047 #endif
15048 #ifdef RTE_NET_BNXT
15049 	if (ret == -ENOTSUP)
15050 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15051 						  res->vf_id);
15052 #endif
15053 
15054 	switch (ret) {
15055 	case 0:
15056 		break;
15057 	case -EINVAL:
15058 		printf("invalid vf_id %d\n", res->vf_id);
15059 		break;
15060 	case -ENODEV:
15061 		printf("invalid port_id %d\n", res->port_id);
15062 		break;
15063 	case -ENOTSUP:
15064 		printf("function not implemented\n");
15065 		break;
15066 	default:
15067 		printf("programming error: (%s)\n", strerror(-ret));
15068 	}
15069 }
15070 
15071 cmdline_parse_inst_t cmd_clear_vf_stats = {
15072 	.f = cmd_clear_vf_stats_parsed,
15073 	.data = NULL,
15074 	.help_str = "clear vf stats <port_id> <vf_id>",
15075 	.tokens = {
15076 		(void *)&cmd_clear_vf_stats_clear,
15077 		(void *)&cmd_clear_vf_stats_vf,
15078 		(void *)&cmd_clear_vf_stats_stats,
15079 		(void *)&cmd_clear_vf_stats_port_id,
15080 		(void *)&cmd_clear_vf_stats_vf_id,
15081 		NULL,
15082 	},
15083 };
15084 
15085 /* port config pctype mapping reset */
15086 
15087 /* Common result structure for port config pctype mapping reset */
15088 struct cmd_pctype_mapping_reset_result {
15089 	cmdline_fixed_string_t port;
15090 	cmdline_fixed_string_t config;
15091 	portid_t port_id;
15092 	cmdline_fixed_string_t pctype;
15093 	cmdline_fixed_string_t mapping;
15094 	cmdline_fixed_string_t reset;
15095 };
15096 
15097 /* Common CLI fields for port config pctype mapping reset*/
15098 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15099 	TOKEN_STRING_INITIALIZER
15100 		(struct cmd_pctype_mapping_reset_result,
15101 		 port, "port");
15102 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15103 	TOKEN_STRING_INITIALIZER
15104 		(struct cmd_pctype_mapping_reset_result,
15105 		 config, "config");
15106 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15107 	TOKEN_NUM_INITIALIZER
15108 		(struct cmd_pctype_mapping_reset_result,
15109 		 port_id, RTE_UINT16);
15110 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15111 	TOKEN_STRING_INITIALIZER
15112 		(struct cmd_pctype_mapping_reset_result,
15113 		 pctype, "pctype");
15114 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15115 	TOKEN_STRING_INITIALIZER
15116 		(struct cmd_pctype_mapping_reset_result,
15117 		 mapping, "mapping");
15118 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15119 	TOKEN_STRING_INITIALIZER
15120 		(struct cmd_pctype_mapping_reset_result,
15121 		 reset, "reset");
15122 
15123 static void
15124 cmd_pctype_mapping_reset_parsed(
15125 	void *parsed_result,
15126 	__rte_unused struct cmdline *cl,
15127 	__rte_unused void *data)
15128 {
15129 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15130 	int ret = -ENOTSUP;
15131 
15132 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15133 		return;
15134 
15135 #ifdef RTE_NET_I40E
15136 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15137 #endif
15138 
15139 	switch (ret) {
15140 	case 0:
15141 		break;
15142 	case -ENODEV:
15143 		printf("invalid port_id %d\n", res->port_id);
15144 		break;
15145 	case -ENOTSUP:
15146 		printf("function not implemented\n");
15147 		break;
15148 	default:
15149 		printf("programming error: (%s)\n", strerror(-ret));
15150 	}
15151 }
15152 
15153 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15154 	.f = cmd_pctype_mapping_reset_parsed,
15155 	.data = NULL,
15156 	.help_str = "port config <port_id> pctype mapping reset",
15157 	.tokens = {
15158 		(void *)&cmd_pctype_mapping_reset_port,
15159 		(void *)&cmd_pctype_mapping_reset_config,
15160 		(void *)&cmd_pctype_mapping_reset_port_id,
15161 		(void *)&cmd_pctype_mapping_reset_pctype,
15162 		(void *)&cmd_pctype_mapping_reset_mapping,
15163 		(void *)&cmd_pctype_mapping_reset_reset,
15164 		NULL,
15165 	},
15166 };
15167 
15168 /* show port pctype mapping */
15169 
15170 /* Common result structure for show port pctype mapping */
15171 struct cmd_pctype_mapping_get_result {
15172 	cmdline_fixed_string_t show;
15173 	cmdline_fixed_string_t port;
15174 	portid_t port_id;
15175 	cmdline_fixed_string_t pctype;
15176 	cmdline_fixed_string_t mapping;
15177 };
15178 
15179 /* Common CLI fields for pctype mapping get */
15180 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15181 	TOKEN_STRING_INITIALIZER
15182 		(struct cmd_pctype_mapping_get_result,
15183 		 show, "show");
15184 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15185 	TOKEN_STRING_INITIALIZER
15186 		(struct cmd_pctype_mapping_get_result,
15187 		 port, "port");
15188 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15189 	TOKEN_NUM_INITIALIZER
15190 		(struct cmd_pctype_mapping_get_result,
15191 		 port_id, RTE_UINT16);
15192 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15193 	TOKEN_STRING_INITIALIZER
15194 		(struct cmd_pctype_mapping_get_result,
15195 		 pctype, "pctype");
15196 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15197 	TOKEN_STRING_INITIALIZER
15198 		(struct cmd_pctype_mapping_get_result,
15199 		 mapping, "mapping");
15200 
15201 static void
15202 cmd_pctype_mapping_get_parsed(
15203 	void *parsed_result,
15204 	__rte_unused struct cmdline *cl,
15205 	__rte_unused void *data)
15206 {
15207 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15208 	int ret = -ENOTSUP;
15209 #ifdef RTE_NET_I40E
15210 	struct rte_pmd_i40e_flow_type_mapping
15211 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15212 	int i, j, first_pctype;
15213 #endif
15214 
15215 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15216 		return;
15217 
15218 #ifdef RTE_NET_I40E
15219 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15220 #endif
15221 
15222 	switch (ret) {
15223 	case 0:
15224 		break;
15225 	case -ENODEV:
15226 		printf("invalid port_id %d\n", res->port_id);
15227 		return;
15228 	case -ENOTSUP:
15229 		printf("function not implemented\n");
15230 		return;
15231 	default:
15232 		printf("programming error: (%s)\n", strerror(-ret));
15233 		return;
15234 	}
15235 
15236 #ifdef RTE_NET_I40E
15237 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15238 		if (mapping[i].pctype != 0ULL) {
15239 			first_pctype = 1;
15240 
15241 			printf("pctype: ");
15242 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15243 				if (mapping[i].pctype & (1ULL << j)) {
15244 					printf(first_pctype ?
15245 					       "%02d" : ",%02d", j);
15246 					first_pctype = 0;
15247 				}
15248 			}
15249 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15250 		}
15251 	}
15252 #endif
15253 }
15254 
15255 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15256 	.f = cmd_pctype_mapping_get_parsed,
15257 	.data = NULL,
15258 	.help_str = "show port <port_id> pctype mapping",
15259 	.tokens = {
15260 		(void *)&cmd_pctype_mapping_get_show,
15261 		(void *)&cmd_pctype_mapping_get_port,
15262 		(void *)&cmd_pctype_mapping_get_port_id,
15263 		(void *)&cmd_pctype_mapping_get_pctype,
15264 		(void *)&cmd_pctype_mapping_get_mapping,
15265 		NULL,
15266 	},
15267 };
15268 
15269 /* port config pctype mapping update */
15270 
15271 /* Common result structure for port config pctype mapping update */
15272 struct cmd_pctype_mapping_update_result {
15273 	cmdline_fixed_string_t port;
15274 	cmdline_fixed_string_t config;
15275 	portid_t port_id;
15276 	cmdline_fixed_string_t pctype;
15277 	cmdline_fixed_string_t mapping;
15278 	cmdline_fixed_string_t update;
15279 	cmdline_fixed_string_t pctype_list;
15280 	uint16_t flow_type;
15281 };
15282 
15283 /* Common CLI fields for pctype mapping update*/
15284 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15285 	TOKEN_STRING_INITIALIZER
15286 		(struct cmd_pctype_mapping_update_result,
15287 		 port, "port");
15288 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15289 	TOKEN_STRING_INITIALIZER
15290 		(struct cmd_pctype_mapping_update_result,
15291 		 config, "config");
15292 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15293 	TOKEN_NUM_INITIALIZER
15294 		(struct cmd_pctype_mapping_update_result,
15295 		 port_id, RTE_UINT16);
15296 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15297 	TOKEN_STRING_INITIALIZER
15298 		(struct cmd_pctype_mapping_update_result,
15299 		 pctype, "pctype");
15300 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15301 	TOKEN_STRING_INITIALIZER
15302 		(struct cmd_pctype_mapping_update_result,
15303 		 mapping, "mapping");
15304 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15305 	TOKEN_STRING_INITIALIZER
15306 		(struct cmd_pctype_mapping_update_result,
15307 		 update, "update");
15308 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15309 	TOKEN_STRING_INITIALIZER
15310 		(struct cmd_pctype_mapping_update_result,
15311 		 pctype_list, NULL);
15312 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15313 	TOKEN_NUM_INITIALIZER
15314 		(struct cmd_pctype_mapping_update_result,
15315 		 flow_type, RTE_UINT16);
15316 
15317 static void
15318 cmd_pctype_mapping_update_parsed(
15319 	void *parsed_result,
15320 	__rte_unused struct cmdline *cl,
15321 	__rte_unused void *data)
15322 {
15323 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15324 	int ret = -ENOTSUP;
15325 #ifdef RTE_NET_I40E
15326 	struct rte_pmd_i40e_flow_type_mapping mapping;
15327 	unsigned int i;
15328 	unsigned int nb_item;
15329 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15330 #endif
15331 
15332 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15333 		return;
15334 
15335 #ifdef RTE_NET_I40E
15336 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15337 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15338 	mapping.flow_type = res->flow_type;
15339 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15340 		mapping.pctype |= (1ULL << pctype_list[i]);
15341 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15342 						&mapping,
15343 						1,
15344 						0);
15345 #endif
15346 
15347 	switch (ret) {
15348 	case 0:
15349 		break;
15350 	case -EINVAL:
15351 		printf("invalid pctype or flow type\n");
15352 		break;
15353 	case -ENODEV:
15354 		printf("invalid port_id %d\n", res->port_id);
15355 		break;
15356 	case -ENOTSUP:
15357 		printf("function not implemented\n");
15358 		break;
15359 	default:
15360 		printf("programming error: (%s)\n", strerror(-ret));
15361 	}
15362 }
15363 
15364 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15365 	.f = cmd_pctype_mapping_update_parsed,
15366 	.data = NULL,
15367 	.help_str = "port config <port_id> pctype mapping update"
15368 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15369 	.tokens = {
15370 		(void *)&cmd_pctype_mapping_update_port,
15371 		(void *)&cmd_pctype_mapping_update_config,
15372 		(void *)&cmd_pctype_mapping_update_port_id,
15373 		(void *)&cmd_pctype_mapping_update_pctype,
15374 		(void *)&cmd_pctype_mapping_update_mapping,
15375 		(void *)&cmd_pctype_mapping_update_update,
15376 		(void *)&cmd_pctype_mapping_update_pc_type,
15377 		(void *)&cmd_pctype_mapping_update_flow_type,
15378 		NULL,
15379 	},
15380 };
15381 
15382 /* ptype mapping get */
15383 
15384 /* Common result structure for ptype mapping get */
15385 struct cmd_ptype_mapping_get_result {
15386 	cmdline_fixed_string_t ptype;
15387 	cmdline_fixed_string_t mapping;
15388 	cmdline_fixed_string_t get;
15389 	portid_t port_id;
15390 	uint8_t valid_only;
15391 };
15392 
15393 /* Common CLI fields for ptype mapping get */
15394 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15395 	TOKEN_STRING_INITIALIZER
15396 		(struct cmd_ptype_mapping_get_result,
15397 		 ptype, "ptype");
15398 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15399 	TOKEN_STRING_INITIALIZER
15400 		(struct cmd_ptype_mapping_get_result,
15401 		 mapping, "mapping");
15402 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15403 	TOKEN_STRING_INITIALIZER
15404 		(struct cmd_ptype_mapping_get_result,
15405 		 get, "get");
15406 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15407 	TOKEN_NUM_INITIALIZER
15408 		(struct cmd_ptype_mapping_get_result,
15409 		 port_id, RTE_UINT16);
15410 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15411 	TOKEN_NUM_INITIALIZER
15412 		(struct cmd_ptype_mapping_get_result,
15413 		 valid_only, RTE_UINT8);
15414 
15415 static void
15416 cmd_ptype_mapping_get_parsed(
15417 	void *parsed_result,
15418 	__rte_unused struct cmdline *cl,
15419 	__rte_unused void *data)
15420 {
15421 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15422 	int ret = -ENOTSUP;
15423 #ifdef RTE_NET_I40E
15424 	int max_ptype_num = 256;
15425 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15426 	uint16_t count;
15427 	int i;
15428 #endif
15429 
15430 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15431 		return;
15432 
15433 #ifdef RTE_NET_I40E
15434 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15435 					mapping,
15436 					max_ptype_num,
15437 					&count,
15438 					res->valid_only);
15439 #endif
15440 
15441 	switch (ret) {
15442 	case 0:
15443 		break;
15444 	case -ENODEV:
15445 		printf("invalid port_id %d\n", res->port_id);
15446 		break;
15447 	case -ENOTSUP:
15448 		printf("function not implemented\n");
15449 		break;
15450 	default:
15451 		printf("programming error: (%s)\n", strerror(-ret));
15452 	}
15453 
15454 #ifdef RTE_NET_I40E
15455 	if (!ret) {
15456 		for (i = 0; i < count; i++)
15457 			printf("%3d\t0x%08x\n",
15458 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15459 	}
15460 #endif
15461 }
15462 
15463 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15464 	.f = cmd_ptype_mapping_get_parsed,
15465 	.data = NULL,
15466 	.help_str = "ptype mapping get <port_id> <valid_only>",
15467 	.tokens = {
15468 		(void *)&cmd_ptype_mapping_get_ptype,
15469 		(void *)&cmd_ptype_mapping_get_mapping,
15470 		(void *)&cmd_ptype_mapping_get_get,
15471 		(void *)&cmd_ptype_mapping_get_port_id,
15472 		(void *)&cmd_ptype_mapping_get_valid_only,
15473 		NULL,
15474 	},
15475 };
15476 
15477 /* ptype mapping replace */
15478 
15479 /* Common result structure for ptype mapping replace */
15480 struct cmd_ptype_mapping_replace_result {
15481 	cmdline_fixed_string_t ptype;
15482 	cmdline_fixed_string_t mapping;
15483 	cmdline_fixed_string_t replace;
15484 	portid_t port_id;
15485 	uint32_t target;
15486 	uint8_t mask;
15487 	uint32_t pkt_type;
15488 };
15489 
15490 /* Common CLI fields for ptype mapping replace */
15491 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15492 	TOKEN_STRING_INITIALIZER
15493 		(struct cmd_ptype_mapping_replace_result,
15494 		 ptype, "ptype");
15495 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15496 	TOKEN_STRING_INITIALIZER
15497 		(struct cmd_ptype_mapping_replace_result,
15498 		 mapping, "mapping");
15499 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15500 	TOKEN_STRING_INITIALIZER
15501 		(struct cmd_ptype_mapping_replace_result,
15502 		 replace, "replace");
15503 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15504 	TOKEN_NUM_INITIALIZER
15505 		(struct cmd_ptype_mapping_replace_result,
15506 		 port_id, RTE_UINT16);
15507 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15508 	TOKEN_NUM_INITIALIZER
15509 		(struct cmd_ptype_mapping_replace_result,
15510 		 target, RTE_UINT32);
15511 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15512 	TOKEN_NUM_INITIALIZER
15513 		(struct cmd_ptype_mapping_replace_result,
15514 		 mask, RTE_UINT8);
15515 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15516 	TOKEN_NUM_INITIALIZER
15517 		(struct cmd_ptype_mapping_replace_result,
15518 		 pkt_type, RTE_UINT32);
15519 
15520 static void
15521 cmd_ptype_mapping_replace_parsed(
15522 	void *parsed_result,
15523 	__rte_unused struct cmdline *cl,
15524 	__rte_unused void *data)
15525 {
15526 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15527 	int ret = -ENOTSUP;
15528 
15529 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15530 		return;
15531 
15532 #ifdef RTE_NET_I40E
15533 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15534 					res->target,
15535 					res->mask,
15536 					res->pkt_type);
15537 #endif
15538 
15539 	switch (ret) {
15540 	case 0:
15541 		break;
15542 	case -EINVAL:
15543 		printf("invalid ptype 0x%8x or 0x%8x\n",
15544 				res->target, res->pkt_type);
15545 		break;
15546 	case -ENODEV:
15547 		printf("invalid port_id %d\n", res->port_id);
15548 		break;
15549 	case -ENOTSUP:
15550 		printf("function not implemented\n");
15551 		break;
15552 	default:
15553 		printf("programming error: (%s)\n", strerror(-ret));
15554 	}
15555 }
15556 
15557 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15558 	.f = cmd_ptype_mapping_replace_parsed,
15559 	.data = NULL,
15560 	.help_str =
15561 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15562 	.tokens = {
15563 		(void *)&cmd_ptype_mapping_replace_ptype,
15564 		(void *)&cmd_ptype_mapping_replace_mapping,
15565 		(void *)&cmd_ptype_mapping_replace_replace,
15566 		(void *)&cmd_ptype_mapping_replace_port_id,
15567 		(void *)&cmd_ptype_mapping_replace_target,
15568 		(void *)&cmd_ptype_mapping_replace_mask,
15569 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15570 		NULL,
15571 	},
15572 };
15573 
15574 /* ptype mapping reset */
15575 
15576 /* Common result structure for ptype mapping reset */
15577 struct cmd_ptype_mapping_reset_result {
15578 	cmdline_fixed_string_t ptype;
15579 	cmdline_fixed_string_t mapping;
15580 	cmdline_fixed_string_t reset;
15581 	portid_t port_id;
15582 };
15583 
15584 /* Common CLI fields for ptype mapping reset*/
15585 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15586 	TOKEN_STRING_INITIALIZER
15587 		(struct cmd_ptype_mapping_reset_result,
15588 		 ptype, "ptype");
15589 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15590 	TOKEN_STRING_INITIALIZER
15591 		(struct cmd_ptype_mapping_reset_result,
15592 		 mapping, "mapping");
15593 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15594 	TOKEN_STRING_INITIALIZER
15595 		(struct cmd_ptype_mapping_reset_result,
15596 		 reset, "reset");
15597 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15598 	TOKEN_NUM_INITIALIZER
15599 		(struct cmd_ptype_mapping_reset_result,
15600 		 port_id, RTE_UINT16);
15601 
15602 static void
15603 cmd_ptype_mapping_reset_parsed(
15604 	void *parsed_result,
15605 	__rte_unused struct cmdline *cl,
15606 	__rte_unused void *data)
15607 {
15608 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15609 	int ret = -ENOTSUP;
15610 
15611 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15612 		return;
15613 
15614 #ifdef RTE_NET_I40E
15615 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15616 #endif
15617 
15618 	switch (ret) {
15619 	case 0:
15620 		break;
15621 	case -ENODEV:
15622 		printf("invalid port_id %d\n", res->port_id);
15623 		break;
15624 	case -ENOTSUP:
15625 		printf("function not implemented\n");
15626 		break;
15627 	default:
15628 		printf("programming error: (%s)\n", strerror(-ret));
15629 	}
15630 }
15631 
15632 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15633 	.f = cmd_ptype_mapping_reset_parsed,
15634 	.data = NULL,
15635 	.help_str = "ptype mapping reset <port_id>",
15636 	.tokens = {
15637 		(void *)&cmd_ptype_mapping_reset_ptype,
15638 		(void *)&cmd_ptype_mapping_reset_mapping,
15639 		(void *)&cmd_ptype_mapping_reset_reset,
15640 		(void *)&cmd_ptype_mapping_reset_port_id,
15641 		NULL,
15642 	},
15643 };
15644 
15645 /* ptype mapping update */
15646 
15647 /* Common result structure for ptype mapping update */
15648 struct cmd_ptype_mapping_update_result {
15649 	cmdline_fixed_string_t ptype;
15650 	cmdline_fixed_string_t mapping;
15651 	cmdline_fixed_string_t reset;
15652 	portid_t port_id;
15653 	uint8_t hw_ptype;
15654 	uint32_t sw_ptype;
15655 };
15656 
15657 /* Common CLI fields for ptype mapping update*/
15658 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15659 	TOKEN_STRING_INITIALIZER
15660 		(struct cmd_ptype_mapping_update_result,
15661 		 ptype, "ptype");
15662 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15663 	TOKEN_STRING_INITIALIZER
15664 		(struct cmd_ptype_mapping_update_result,
15665 		 mapping, "mapping");
15666 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15667 	TOKEN_STRING_INITIALIZER
15668 		(struct cmd_ptype_mapping_update_result,
15669 		 reset, "update");
15670 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15671 	TOKEN_NUM_INITIALIZER
15672 		(struct cmd_ptype_mapping_update_result,
15673 		 port_id, RTE_UINT16);
15674 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15675 	TOKEN_NUM_INITIALIZER
15676 		(struct cmd_ptype_mapping_update_result,
15677 		 hw_ptype, RTE_UINT8);
15678 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15679 	TOKEN_NUM_INITIALIZER
15680 		(struct cmd_ptype_mapping_update_result,
15681 		 sw_ptype, RTE_UINT32);
15682 
15683 static void
15684 cmd_ptype_mapping_update_parsed(
15685 	void *parsed_result,
15686 	__rte_unused struct cmdline *cl,
15687 	__rte_unused void *data)
15688 {
15689 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15690 	int ret = -ENOTSUP;
15691 #ifdef RTE_NET_I40E
15692 	struct rte_pmd_i40e_ptype_mapping mapping;
15693 #endif
15694 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15695 		return;
15696 
15697 #ifdef RTE_NET_I40E
15698 	mapping.hw_ptype = res->hw_ptype;
15699 	mapping.sw_ptype = res->sw_ptype;
15700 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15701 						&mapping,
15702 						1,
15703 						0);
15704 #endif
15705 
15706 	switch (ret) {
15707 	case 0:
15708 		break;
15709 	case -EINVAL:
15710 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
15711 		break;
15712 	case -ENODEV:
15713 		printf("invalid port_id %d\n", res->port_id);
15714 		break;
15715 	case -ENOTSUP:
15716 		printf("function not implemented\n");
15717 		break;
15718 	default:
15719 		printf("programming error: (%s)\n", strerror(-ret));
15720 	}
15721 }
15722 
15723 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15724 	.f = cmd_ptype_mapping_update_parsed,
15725 	.data = NULL,
15726 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15727 	.tokens = {
15728 		(void *)&cmd_ptype_mapping_update_ptype,
15729 		(void *)&cmd_ptype_mapping_update_mapping,
15730 		(void *)&cmd_ptype_mapping_update_update,
15731 		(void *)&cmd_ptype_mapping_update_port_id,
15732 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15733 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15734 		NULL,
15735 	},
15736 };
15737 
15738 /* Common result structure for file commands */
15739 struct cmd_cmdfile_result {
15740 	cmdline_fixed_string_t load;
15741 	cmdline_fixed_string_t filename;
15742 };
15743 
15744 /* Common CLI fields for file commands */
15745 cmdline_parse_token_string_t cmd_load_cmdfile =
15746 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15747 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15748 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15749 
15750 static void
15751 cmd_load_from_file_parsed(
15752 	void *parsed_result,
15753 	__rte_unused struct cmdline *cl,
15754 	__rte_unused void *data)
15755 {
15756 	struct cmd_cmdfile_result *res = parsed_result;
15757 
15758 	cmdline_read_from_file(res->filename);
15759 }
15760 
15761 cmdline_parse_inst_t cmd_load_from_file = {
15762 	.f = cmd_load_from_file_parsed,
15763 	.data = NULL,
15764 	.help_str = "load <filename>",
15765 	.tokens = {
15766 		(void *)&cmd_load_cmdfile,
15767 		(void *)&cmd_load_cmdfile_filename,
15768 		NULL,
15769 	},
15770 };
15771 
15772 /* Get Rx offloads capabilities */
15773 struct cmd_rx_offload_get_capa_result {
15774 	cmdline_fixed_string_t show;
15775 	cmdline_fixed_string_t port;
15776 	portid_t port_id;
15777 	cmdline_fixed_string_t rx_offload;
15778 	cmdline_fixed_string_t capabilities;
15779 };
15780 
15781 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15782 	TOKEN_STRING_INITIALIZER
15783 		(struct cmd_rx_offload_get_capa_result,
15784 		 show, "show");
15785 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15786 	TOKEN_STRING_INITIALIZER
15787 		(struct cmd_rx_offload_get_capa_result,
15788 		 port, "port");
15789 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15790 	TOKEN_NUM_INITIALIZER
15791 		(struct cmd_rx_offload_get_capa_result,
15792 		 port_id, RTE_UINT16);
15793 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15794 	TOKEN_STRING_INITIALIZER
15795 		(struct cmd_rx_offload_get_capa_result,
15796 		 rx_offload, "rx_offload");
15797 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15798 	TOKEN_STRING_INITIALIZER
15799 		(struct cmd_rx_offload_get_capa_result,
15800 		 capabilities, "capabilities");
15801 
15802 static void
15803 print_rx_offloads(uint64_t offloads)
15804 {
15805 	uint64_t single_offload;
15806 	int begin;
15807 	int end;
15808 	int bit;
15809 
15810 	if (offloads == 0)
15811 		return;
15812 
15813 	begin = __builtin_ctzll(offloads);
15814 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15815 
15816 	single_offload = 1ULL << begin;
15817 	for (bit = begin; bit < end; bit++) {
15818 		if (offloads & single_offload)
15819 			printf(" %s",
15820 			       rte_eth_dev_rx_offload_name(single_offload));
15821 		single_offload <<= 1;
15822 	}
15823 }
15824 
15825 static void
15826 cmd_rx_offload_get_capa_parsed(
15827 	void *parsed_result,
15828 	__rte_unused struct cmdline *cl,
15829 	__rte_unused void *data)
15830 {
15831 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
15832 	struct rte_eth_dev_info dev_info;
15833 	portid_t port_id = res->port_id;
15834 	uint64_t queue_offloads;
15835 	uint64_t port_offloads;
15836 	int ret;
15837 
15838 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15839 	if (ret != 0)
15840 		return;
15841 
15842 	queue_offloads = dev_info.rx_queue_offload_capa;
15843 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15844 
15845 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
15846 	printf("  Per Queue :");
15847 	print_rx_offloads(queue_offloads);
15848 
15849 	printf("\n");
15850 	printf("  Per Port  :");
15851 	print_rx_offloads(port_offloads);
15852 	printf("\n\n");
15853 }
15854 
15855 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15856 	.f = cmd_rx_offload_get_capa_parsed,
15857 	.data = NULL,
15858 	.help_str = "show port <port_id> rx_offload capabilities",
15859 	.tokens = {
15860 		(void *)&cmd_rx_offload_get_capa_show,
15861 		(void *)&cmd_rx_offload_get_capa_port,
15862 		(void *)&cmd_rx_offload_get_capa_port_id,
15863 		(void *)&cmd_rx_offload_get_capa_rx_offload,
15864 		(void *)&cmd_rx_offload_get_capa_capabilities,
15865 		NULL,
15866 	}
15867 };
15868 
15869 /* Get Rx offloads configuration */
15870 struct cmd_rx_offload_get_configuration_result {
15871 	cmdline_fixed_string_t show;
15872 	cmdline_fixed_string_t port;
15873 	portid_t port_id;
15874 	cmdline_fixed_string_t rx_offload;
15875 	cmdline_fixed_string_t configuration;
15876 };
15877 
15878 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15879 	TOKEN_STRING_INITIALIZER
15880 		(struct cmd_rx_offload_get_configuration_result,
15881 		 show, "show");
15882 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15883 	TOKEN_STRING_INITIALIZER
15884 		(struct cmd_rx_offload_get_configuration_result,
15885 		 port, "port");
15886 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15887 	TOKEN_NUM_INITIALIZER
15888 		(struct cmd_rx_offload_get_configuration_result,
15889 		 port_id, RTE_UINT16);
15890 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15891 	TOKEN_STRING_INITIALIZER
15892 		(struct cmd_rx_offload_get_configuration_result,
15893 		 rx_offload, "rx_offload");
15894 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15895 	TOKEN_STRING_INITIALIZER
15896 		(struct cmd_rx_offload_get_configuration_result,
15897 		 configuration, "configuration");
15898 
15899 static void
15900 cmd_rx_offload_get_configuration_parsed(
15901 	void *parsed_result,
15902 	__rte_unused struct cmdline *cl,
15903 	__rte_unused void *data)
15904 {
15905 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15906 	struct rte_eth_dev_info dev_info;
15907 	portid_t port_id = res->port_id;
15908 	struct rte_port *port = &ports[port_id];
15909 	uint64_t port_offloads;
15910 	uint64_t queue_offloads;
15911 	uint16_t nb_rx_queues;
15912 	int q;
15913 	int ret;
15914 
15915 	printf("Rx Offloading Configuration of port %d :\n", port_id);
15916 
15917 	port_offloads = port->dev_conf.rxmode.offloads;
15918 	printf("  Port :");
15919 	print_rx_offloads(port_offloads);
15920 	printf("\n");
15921 
15922 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15923 	if (ret != 0)
15924 		return;
15925 
15926 	nb_rx_queues = dev_info.nb_rx_queues;
15927 	for (q = 0; q < nb_rx_queues; q++) {
15928 		queue_offloads = port->rx_conf[q].offloads;
15929 		printf("  Queue[%2d] :", q);
15930 		print_rx_offloads(queue_offloads);
15931 		printf("\n");
15932 	}
15933 	printf("\n");
15934 }
15935 
15936 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15937 	.f = cmd_rx_offload_get_configuration_parsed,
15938 	.data = NULL,
15939 	.help_str = "show port <port_id> rx_offload configuration",
15940 	.tokens = {
15941 		(void *)&cmd_rx_offload_get_configuration_show,
15942 		(void *)&cmd_rx_offload_get_configuration_port,
15943 		(void *)&cmd_rx_offload_get_configuration_port_id,
15944 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
15945 		(void *)&cmd_rx_offload_get_configuration_configuration,
15946 		NULL,
15947 	}
15948 };
15949 
15950 /* Enable/Disable a per port offloading */
15951 struct cmd_config_per_port_rx_offload_result {
15952 	cmdline_fixed_string_t port;
15953 	cmdline_fixed_string_t config;
15954 	portid_t port_id;
15955 	cmdline_fixed_string_t rx_offload;
15956 	cmdline_fixed_string_t offload;
15957 	cmdline_fixed_string_t on_off;
15958 };
15959 
15960 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15961 	TOKEN_STRING_INITIALIZER
15962 		(struct cmd_config_per_port_rx_offload_result,
15963 		 port, "port");
15964 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15965 	TOKEN_STRING_INITIALIZER
15966 		(struct cmd_config_per_port_rx_offload_result,
15967 		 config, "config");
15968 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15969 	TOKEN_NUM_INITIALIZER
15970 		(struct cmd_config_per_port_rx_offload_result,
15971 		 port_id, RTE_UINT16);
15972 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15973 	TOKEN_STRING_INITIALIZER
15974 		(struct cmd_config_per_port_rx_offload_result,
15975 		 rx_offload, "rx_offload");
15976 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15977 	TOKEN_STRING_INITIALIZER
15978 		(struct cmd_config_per_port_rx_offload_result,
15979 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15980 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15981 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15982 			   "scatter#buffer_split#timestamp#security#"
15983 			   "keep_crc#rss_hash");
15984 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15985 	TOKEN_STRING_INITIALIZER
15986 		(struct cmd_config_per_port_rx_offload_result,
15987 		 on_off, "on#off");
15988 
15989 static uint64_t
15990 search_rx_offload(const char *name)
15991 {
15992 	uint64_t single_offload;
15993 	const char *single_name;
15994 	int found = 0;
15995 	unsigned int bit;
15996 
15997 	single_offload = 1;
15998 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15999 		single_name = rte_eth_dev_rx_offload_name(single_offload);
16000 		if (!strcasecmp(single_name, name)) {
16001 			found = 1;
16002 			break;
16003 		}
16004 		single_offload <<= 1;
16005 	}
16006 
16007 	if (found)
16008 		return single_offload;
16009 
16010 	return 0;
16011 }
16012 
16013 static void
16014 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16015 				__rte_unused struct cmdline *cl,
16016 				__rte_unused void *data)
16017 {
16018 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16019 	portid_t port_id = res->port_id;
16020 	struct rte_eth_dev_info dev_info;
16021 	struct rte_port *port = &ports[port_id];
16022 	uint64_t single_offload;
16023 	uint16_t nb_rx_queues;
16024 	int q;
16025 	int ret;
16026 
16027 	if (port->port_status != RTE_PORT_STOPPED) {
16028 		printf("Error: Can't config offload when Port %d "
16029 		       "is not stopped\n", port_id);
16030 		return;
16031 	}
16032 
16033 	single_offload = search_rx_offload(res->offload);
16034 	if (single_offload == 0) {
16035 		printf("Unknown offload name: %s\n", res->offload);
16036 		return;
16037 	}
16038 
16039 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16040 	if (ret != 0)
16041 		return;
16042 
16043 	nb_rx_queues = dev_info.nb_rx_queues;
16044 	if (!strcmp(res->on_off, "on")) {
16045 		port->dev_conf.rxmode.offloads |= single_offload;
16046 		for (q = 0; q < nb_rx_queues; q++)
16047 			port->rx_conf[q].offloads |= single_offload;
16048 	} else {
16049 		port->dev_conf.rxmode.offloads &= ~single_offload;
16050 		for (q = 0; q < nb_rx_queues; q++)
16051 			port->rx_conf[q].offloads &= ~single_offload;
16052 	}
16053 
16054 	cmd_reconfig_device_queue(port_id, 1, 1);
16055 }
16056 
16057 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16058 	.f = cmd_config_per_port_rx_offload_parsed,
16059 	.data = NULL,
16060 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16061 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16062 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16063 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16064 		    "keep_crc|rss_hash on|off",
16065 	.tokens = {
16066 		(void *)&cmd_config_per_port_rx_offload_result_port,
16067 		(void *)&cmd_config_per_port_rx_offload_result_config,
16068 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
16069 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16070 		(void *)&cmd_config_per_port_rx_offload_result_offload,
16071 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
16072 		NULL,
16073 	}
16074 };
16075 
16076 /* Enable/Disable a per queue offloading */
16077 struct cmd_config_per_queue_rx_offload_result {
16078 	cmdline_fixed_string_t port;
16079 	portid_t port_id;
16080 	cmdline_fixed_string_t rxq;
16081 	uint16_t queue_id;
16082 	cmdline_fixed_string_t rx_offload;
16083 	cmdline_fixed_string_t offload;
16084 	cmdline_fixed_string_t on_off;
16085 };
16086 
16087 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16088 	TOKEN_STRING_INITIALIZER
16089 		(struct cmd_config_per_queue_rx_offload_result,
16090 		 port, "port");
16091 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16092 	TOKEN_NUM_INITIALIZER
16093 		(struct cmd_config_per_queue_rx_offload_result,
16094 		 port_id, RTE_UINT16);
16095 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16096 	TOKEN_STRING_INITIALIZER
16097 		(struct cmd_config_per_queue_rx_offload_result,
16098 		 rxq, "rxq");
16099 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16100 	TOKEN_NUM_INITIALIZER
16101 		(struct cmd_config_per_queue_rx_offload_result,
16102 		 queue_id, RTE_UINT16);
16103 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16104 	TOKEN_STRING_INITIALIZER
16105 		(struct cmd_config_per_queue_rx_offload_result,
16106 		 rx_offload, "rx_offload");
16107 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16108 	TOKEN_STRING_INITIALIZER
16109 		(struct cmd_config_per_queue_rx_offload_result,
16110 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16111 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16112 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16113 			   "scatter#buffer_split#timestamp#security#keep_crc");
16114 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16115 	TOKEN_STRING_INITIALIZER
16116 		(struct cmd_config_per_queue_rx_offload_result,
16117 		 on_off, "on#off");
16118 
16119 static void
16120 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16121 				__rte_unused struct cmdline *cl,
16122 				__rte_unused void *data)
16123 {
16124 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16125 	struct rte_eth_dev_info dev_info;
16126 	portid_t port_id = res->port_id;
16127 	uint16_t queue_id = res->queue_id;
16128 	struct rte_port *port = &ports[port_id];
16129 	uint64_t single_offload;
16130 	int ret;
16131 
16132 	if (port->port_status != RTE_PORT_STOPPED) {
16133 		printf("Error: Can't config offload when Port %d "
16134 		       "is not stopped\n", port_id);
16135 		return;
16136 	}
16137 
16138 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16139 	if (ret != 0)
16140 		return;
16141 
16142 	if (queue_id >= dev_info.nb_rx_queues) {
16143 		printf("Error: input queue_id should be 0 ... "
16144 		       "%d\n", dev_info.nb_rx_queues - 1);
16145 		return;
16146 	}
16147 
16148 	single_offload = search_rx_offload(res->offload);
16149 	if (single_offload == 0) {
16150 		printf("Unknown offload name: %s\n", res->offload);
16151 		return;
16152 	}
16153 
16154 	if (!strcmp(res->on_off, "on"))
16155 		port->rx_conf[queue_id].offloads |= single_offload;
16156 	else
16157 		port->rx_conf[queue_id].offloads &= ~single_offload;
16158 
16159 	cmd_reconfig_device_queue(port_id, 1, 1);
16160 }
16161 
16162 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16163 	.f = cmd_config_per_queue_rx_offload_parsed,
16164 	.data = NULL,
16165 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
16166 		    "vlan_strip|ipv4_cksum|"
16167 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16168 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16169 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16170 		    "keep_crc on|off",
16171 	.tokens = {
16172 		(void *)&cmd_config_per_queue_rx_offload_result_port,
16173 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
16174 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
16175 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16176 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16177 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
16178 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
16179 		NULL,
16180 	}
16181 };
16182 
16183 /* Get Tx offloads capabilities */
16184 struct cmd_tx_offload_get_capa_result {
16185 	cmdline_fixed_string_t show;
16186 	cmdline_fixed_string_t port;
16187 	portid_t port_id;
16188 	cmdline_fixed_string_t tx_offload;
16189 	cmdline_fixed_string_t capabilities;
16190 };
16191 
16192 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16193 	TOKEN_STRING_INITIALIZER
16194 		(struct cmd_tx_offload_get_capa_result,
16195 		 show, "show");
16196 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16197 	TOKEN_STRING_INITIALIZER
16198 		(struct cmd_tx_offload_get_capa_result,
16199 		 port, "port");
16200 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16201 	TOKEN_NUM_INITIALIZER
16202 		(struct cmd_tx_offload_get_capa_result,
16203 		 port_id, RTE_UINT16);
16204 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16205 	TOKEN_STRING_INITIALIZER
16206 		(struct cmd_tx_offload_get_capa_result,
16207 		 tx_offload, "tx_offload");
16208 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16209 	TOKEN_STRING_INITIALIZER
16210 		(struct cmd_tx_offload_get_capa_result,
16211 		 capabilities, "capabilities");
16212 
16213 static void
16214 print_tx_offloads(uint64_t offloads)
16215 {
16216 	uint64_t single_offload;
16217 	int begin;
16218 	int end;
16219 	int bit;
16220 
16221 	if (offloads == 0)
16222 		return;
16223 
16224 	begin = __builtin_ctzll(offloads);
16225 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16226 
16227 	single_offload = 1ULL << begin;
16228 	for (bit = begin; bit < end; bit++) {
16229 		if (offloads & single_offload)
16230 			printf(" %s",
16231 			       rte_eth_dev_tx_offload_name(single_offload));
16232 		single_offload <<= 1;
16233 	}
16234 }
16235 
16236 static void
16237 cmd_tx_offload_get_capa_parsed(
16238 	void *parsed_result,
16239 	__rte_unused struct cmdline *cl,
16240 	__rte_unused void *data)
16241 {
16242 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
16243 	struct rte_eth_dev_info dev_info;
16244 	portid_t port_id = res->port_id;
16245 	uint64_t queue_offloads;
16246 	uint64_t port_offloads;
16247 	int ret;
16248 
16249 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16250 	if (ret != 0)
16251 		return;
16252 
16253 	queue_offloads = dev_info.tx_queue_offload_capa;
16254 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16255 
16256 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
16257 	printf("  Per Queue :");
16258 	print_tx_offloads(queue_offloads);
16259 
16260 	printf("\n");
16261 	printf("  Per Port  :");
16262 	print_tx_offloads(port_offloads);
16263 	printf("\n\n");
16264 }
16265 
16266 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16267 	.f = cmd_tx_offload_get_capa_parsed,
16268 	.data = NULL,
16269 	.help_str = "show port <port_id> tx_offload capabilities",
16270 	.tokens = {
16271 		(void *)&cmd_tx_offload_get_capa_show,
16272 		(void *)&cmd_tx_offload_get_capa_port,
16273 		(void *)&cmd_tx_offload_get_capa_port_id,
16274 		(void *)&cmd_tx_offload_get_capa_tx_offload,
16275 		(void *)&cmd_tx_offload_get_capa_capabilities,
16276 		NULL,
16277 	}
16278 };
16279 
16280 /* Get Tx offloads configuration */
16281 struct cmd_tx_offload_get_configuration_result {
16282 	cmdline_fixed_string_t show;
16283 	cmdline_fixed_string_t port;
16284 	portid_t port_id;
16285 	cmdline_fixed_string_t tx_offload;
16286 	cmdline_fixed_string_t configuration;
16287 };
16288 
16289 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16290 	TOKEN_STRING_INITIALIZER
16291 		(struct cmd_tx_offload_get_configuration_result,
16292 		 show, "show");
16293 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16294 	TOKEN_STRING_INITIALIZER
16295 		(struct cmd_tx_offload_get_configuration_result,
16296 		 port, "port");
16297 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16298 	TOKEN_NUM_INITIALIZER
16299 		(struct cmd_tx_offload_get_configuration_result,
16300 		 port_id, RTE_UINT16);
16301 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16302 	TOKEN_STRING_INITIALIZER
16303 		(struct cmd_tx_offload_get_configuration_result,
16304 		 tx_offload, "tx_offload");
16305 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16306 	TOKEN_STRING_INITIALIZER
16307 		(struct cmd_tx_offload_get_configuration_result,
16308 		 configuration, "configuration");
16309 
16310 static void
16311 cmd_tx_offload_get_configuration_parsed(
16312 	void *parsed_result,
16313 	__rte_unused struct cmdline *cl,
16314 	__rte_unused void *data)
16315 {
16316 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16317 	struct rte_eth_dev_info dev_info;
16318 	portid_t port_id = res->port_id;
16319 	struct rte_port *port = &ports[port_id];
16320 	uint64_t port_offloads;
16321 	uint64_t queue_offloads;
16322 	uint16_t nb_tx_queues;
16323 	int q;
16324 	int ret;
16325 
16326 	printf("Tx Offloading Configuration of port %d :\n", port_id);
16327 
16328 	port_offloads = port->dev_conf.txmode.offloads;
16329 	printf("  Port :");
16330 	print_tx_offloads(port_offloads);
16331 	printf("\n");
16332 
16333 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16334 	if (ret != 0)
16335 		return;
16336 
16337 	nb_tx_queues = dev_info.nb_tx_queues;
16338 	for (q = 0; q < nb_tx_queues; q++) {
16339 		queue_offloads = port->tx_conf[q].offloads;
16340 		printf("  Queue[%2d] :", q);
16341 		print_tx_offloads(queue_offloads);
16342 		printf("\n");
16343 	}
16344 	printf("\n");
16345 }
16346 
16347 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16348 	.f = cmd_tx_offload_get_configuration_parsed,
16349 	.data = NULL,
16350 	.help_str = "show port <port_id> tx_offload configuration",
16351 	.tokens = {
16352 		(void *)&cmd_tx_offload_get_configuration_show,
16353 		(void *)&cmd_tx_offload_get_configuration_port,
16354 		(void *)&cmd_tx_offload_get_configuration_port_id,
16355 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
16356 		(void *)&cmd_tx_offload_get_configuration_configuration,
16357 		NULL,
16358 	}
16359 };
16360 
16361 /* Enable/Disable a per port offloading */
16362 struct cmd_config_per_port_tx_offload_result {
16363 	cmdline_fixed_string_t port;
16364 	cmdline_fixed_string_t config;
16365 	portid_t port_id;
16366 	cmdline_fixed_string_t tx_offload;
16367 	cmdline_fixed_string_t offload;
16368 	cmdline_fixed_string_t on_off;
16369 };
16370 
16371 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16372 	TOKEN_STRING_INITIALIZER
16373 		(struct cmd_config_per_port_tx_offload_result,
16374 		 port, "port");
16375 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16376 	TOKEN_STRING_INITIALIZER
16377 		(struct cmd_config_per_port_tx_offload_result,
16378 		 config, "config");
16379 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16380 	TOKEN_NUM_INITIALIZER
16381 		(struct cmd_config_per_port_tx_offload_result,
16382 		 port_id, RTE_UINT16);
16383 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16384 	TOKEN_STRING_INITIALIZER
16385 		(struct cmd_config_per_port_tx_offload_result,
16386 		 tx_offload, "tx_offload");
16387 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16388 	TOKEN_STRING_INITIALIZER
16389 		(struct cmd_config_per_port_tx_offload_result,
16390 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16391 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16392 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16393 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16394 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16395 			  "send_on_timestamp");
16396 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16397 	TOKEN_STRING_INITIALIZER
16398 		(struct cmd_config_per_port_tx_offload_result,
16399 		 on_off, "on#off");
16400 
16401 static uint64_t
16402 search_tx_offload(const char *name)
16403 {
16404 	uint64_t single_offload;
16405 	const char *single_name;
16406 	int found = 0;
16407 	unsigned int bit;
16408 
16409 	single_offload = 1;
16410 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16411 		single_name = rte_eth_dev_tx_offload_name(single_offload);
16412 		if (single_name == NULL)
16413 			break;
16414 		if (!strcasecmp(single_name, name)) {
16415 			found = 1;
16416 			break;
16417 		} else if (!strcasecmp(single_name, "UNKNOWN"))
16418 			break;
16419 		single_offload <<= 1;
16420 	}
16421 
16422 	if (found)
16423 		return single_offload;
16424 
16425 	return 0;
16426 }
16427 
16428 static void
16429 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16430 				__rte_unused struct cmdline *cl,
16431 				__rte_unused void *data)
16432 {
16433 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16434 	portid_t port_id = res->port_id;
16435 	struct rte_eth_dev_info dev_info;
16436 	struct rte_port *port = &ports[port_id];
16437 	uint64_t single_offload;
16438 	uint16_t nb_tx_queues;
16439 	int q;
16440 	int ret;
16441 
16442 	if (port->port_status != RTE_PORT_STOPPED) {
16443 		printf("Error: Can't config offload when Port %d "
16444 		       "is not stopped\n", port_id);
16445 		return;
16446 	}
16447 
16448 	single_offload = search_tx_offload(res->offload);
16449 	if (single_offload == 0) {
16450 		printf("Unknown offload name: %s\n", res->offload);
16451 		return;
16452 	}
16453 
16454 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16455 	if (ret != 0)
16456 		return;
16457 
16458 	nb_tx_queues = dev_info.nb_tx_queues;
16459 	if (!strcmp(res->on_off, "on")) {
16460 		port->dev_conf.txmode.offloads |= single_offload;
16461 		for (q = 0; q < nb_tx_queues; q++)
16462 			port->tx_conf[q].offloads |= single_offload;
16463 	} else {
16464 		port->dev_conf.txmode.offloads &= ~single_offload;
16465 		for (q = 0; q < nb_tx_queues; q++)
16466 			port->tx_conf[q].offloads &= ~single_offload;
16467 	}
16468 
16469 	cmd_reconfig_device_queue(port_id, 1, 1);
16470 }
16471 
16472 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16473 	.f = cmd_config_per_port_tx_offload_parsed,
16474 	.data = NULL,
16475 	.help_str = "port config <port_id> tx_offload "
16476 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16477 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16478 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16479 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16480 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16481 		    "send_on_timestamp on|off",
16482 	.tokens = {
16483 		(void *)&cmd_config_per_port_tx_offload_result_port,
16484 		(void *)&cmd_config_per_port_tx_offload_result_config,
16485 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
16486 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16487 		(void *)&cmd_config_per_port_tx_offload_result_offload,
16488 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
16489 		NULL,
16490 	}
16491 };
16492 
16493 /* Enable/Disable a per queue offloading */
16494 struct cmd_config_per_queue_tx_offload_result {
16495 	cmdline_fixed_string_t port;
16496 	portid_t port_id;
16497 	cmdline_fixed_string_t txq;
16498 	uint16_t queue_id;
16499 	cmdline_fixed_string_t tx_offload;
16500 	cmdline_fixed_string_t offload;
16501 	cmdline_fixed_string_t on_off;
16502 };
16503 
16504 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16505 	TOKEN_STRING_INITIALIZER
16506 		(struct cmd_config_per_queue_tx_offload_result,
16507 		 port, "port");
16508 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16509 	TOKEN_NUM_INITIALIZER
16510 		(struct cmd_config_per_queue_tx_offload_result,
16511 		 port_id, RTE_UINT16);
16512 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16513 	TOKEN_STRING_INITIALIZER
16514 		(struct cmd_config_per_queue_tx_offload_result,
16515 		 txq, "txq");
16516 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16517 	TOKEN_NUM_INITIALIZER
16518 		(struct cmd_config_per_queue_tx_offload_result,
16519 		 queue_id, RTE_UINT16);
16520 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16521 	TOKEN_STRING_INITIALIZER
16522 		(struct cmd_config_per_queue_tx_offload_result,
16523 		 tx_offload, "tx_offload");
16524 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16525 	TOKEN_STRING_INITIALIZER
16526 		(struct cmd_config_per_queue_tx_offload_result,
16527 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16528 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16529 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16530 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16531 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
16532 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16533 	TOKEN_STRING_INITIALIZER
16534 		(struct cmd_config_per_queue_tx_offload_result,
16535 		 on_off, "on#off");
16536 
16537 static void
16538 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16539 				__rte_unused struct cmdline *cl,
16540 				__rte_unused void *data)
16541 {
16542 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16543 	struct rte_eth_dev_info dev_info;
16544 	portid_t port_id = res->port_id;
16545 	uint16_t queue_id = res->queue_id;
16546 	struct rte_port *port = &ports[port_id];
16547 	uint64_t single_offload;
16548 	int ret;
16549 
16550 	if (port->port_status != RTE_PORT_STOPPED) {
16551 		printf("Error: Can't config offload when Port %d "
16552 		       "is not stopped\n", port_id);
16553 		return;
16554 	}
16555 
16556 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16557 	if (ret != 0)
16558 		return;
16559 
16560 	if (queue_id >= dev_info.nb_tx_queues) {
16561 		printf("Error: input queue_id should be 0 ... "
16562 		       "%d\n", dev_info.nb_tx_queues - 1);
16563 		return;
16564 	}
16565 
16566 	single_offload = search_tx_offload(res->offload);
16567 	if (single_offload == 0) {
16568 		printf("Unknown offload name: %s\n", res->offload);
16569 		return;
16570 	}
16571 
16572 	if (!strcmp(res->on_off, "on"))
16573 		port->tx_conf[queue_id].offloads |= single_offload;
16574 	else
16575 		port->tx_conf[queue_id].offloads &= ~single_offload;
16576 
16577 	cmd_reconfig_device_queue(port_id, 1, 1);
16578 }
16579 
16580 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16581 	.f = cmd_config_per_queue_tx_offload_parsed,
16582 	.data = NULL,
16583 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16584 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16585 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16586 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16587 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16588 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16589 		    "on|off",
16590 	.tokens = {
16591 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16592 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16593 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16594 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16595 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16596 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16597 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16598 		NULL,
16599 	}
16600 };
16601 
16602 /* *** configure tx_metadata for specific port *** */
16603 struct cmd_config_tx_metadata_specific_result {
16604 	cmdline_fixed_string_t port;
16605 	cmdline_fixed_string_t keyword;
16606 	uint16_t port_id;
16607 	cmdline_fixed_string_t item;
16608 	uint32_t value;
16609 };
16610 
16611 static void
16612 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16613 				__rte_unused struct cmdline *cl,
16614 				__rte_unused void *data)
16615 {
16616 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16617 
16618 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16619 		return;
16620 	ports[res->port_id].tx_metadata = res->value;
16621 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16622 	if (ports[res->port_id].tx_metadata)
16623 		add_tx_md_callback(res->port_id);
16624 	else
16625 		remove_tx_md_callback(res->port_id);
16626 	rte_flow_dynf_metadata_register();
16627 }
16628 
16629 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16630 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16631 			port, "port");
16632 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16633 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16634 			keyword, "config");
16635 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16636 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16637 			port_id, RTE_UINT16);
16638 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16639 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16640 			item, "tx_metadata");
16641 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16642 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16643 			value, RTE_UINT32);
16644 
16645 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16646 	.f = cmd_config_tx_metadata_specific_parsed,
16647 	.data = NULL,
16648 	.help_str = "port config <port_id> tx_metadata <value>",
16649 	.tokens = {
16650 		(void *)&cmd_config_tx_metadata_specific_port,
16651 		(void *)&cmd_config_tx_metadata_specific_keyword,
16652 		(void *)&cmd_config_tx_metadata_specific_id,
16653 		(void *)&cmd_config_tx_metadata_specific_item,
16654 		(void *)&cmd_config_tx_metadata_specific_value,
16655 		NULL,
16656 	},
16657 };
16658 
16659 /* *** set dynf *** */
16660 struct cmd_config_tx_dynf_specific_result {
16661 	cmdline_fixed_string_t port;
16662 	cmdline_fixed_string_t keyword;
16663 	uint16_t port_id;
16664 	cmdline_fixed_string_t item;
16665 	cmdline_fixed_string_t name;
16666 	cmdline_fixed_string_t value;
16667 };
16668 
16669 static void
16670 cmd_config_dynf_specific_parsed(void *parsed_result,
16671 				__rte_unused struct cmdline *cl,
16672 				__rte_unused void *data)
16673 {
16674 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16675 	struct rte_mbuf_dynflag desc_flag;
16676 	int flag;
16677 	uint64_t old_port_flags;
16678 
16679 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16680 		return;
16681 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16682 	if (flag <= 0) {
16683 		if (strlcpy(desc_flag.name, res->name,
16684 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16685 			printf("Flag name too long\n");
16686 			return;
16687 		}
16688 		desc_flag.flags = 0;
16689 		flag = rte_mbuf_dynflag_register(&desc_flag);
16690 		if (flag < 0) {
16691 			printf("Can't register flag\n");
16692 			return;
16693 		}
16694 		strcpy(dynf_names[flag], desc_flag.name);
16695 	}
16696 	old_port_flags = ports[res->port_id].mbuf_dynf;
16697 	if (!strcmp(res->value, "set")) {
16698 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16699 		if (old_port_flags == 0)
16700 			add_tx_dynf_callback(res->port_id);
16701 	} else {
16702 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16703 		if (ports[res->port_id].mbuf_dynf == 0)
16704 			remove_tx_dynf_callback(res->port_id);
16705 	}
16706 }
16707 
16708 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16709 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16710 			keyword, "port");
16711 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16712 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16713 			keyword, "config");
16714 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16715 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16716 			port_id, RTE_UINT16);
16717 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16718 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16719 			item, "dynf");
16720 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16721 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16722 			name, NULL);
16723 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16724 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16725 			value, "set#clear");
16726 
16727 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16728 	.f = cmd_config_dynf_specific_parsed,
16729 	.data = NULL,
16730 	.help_str = "port config <port id> dynf <name> set|clear",
16731 	.tokens = {
16732 		(void *)&cmd_config_tx_dynf_specific_port,
16733 		(void *)&cmd_config_tx_dynf_specific_keyword,
16734 		(void *)&cmd_config_tx_dynf_specific_port_id,
16735 		(void *)&cmd_config_tx_dynf_specific_item,
16736 		(void *)&cmd_config_tx_dynf_specific_name,
16737 		(void *)&cmd_config_tx_dynf_specific_value,
16738 		NULL,
16739 	},
16740 };
16741 
16742 /* *** display tx_metadata per port configuration *** */
16743 struct cmd_show_tx_metadata_result {
16744 	cmdline_fixed_string_t cmd_show;
16745 	cmdline_fixed_string_t cmd_port;
16746 	cmdline_fixed_string_t cmd_keyword;
16747 	portid_t cmd_pid;
16748 };
16749 
16750 static void
16751 cmd_show_tx_metadata_parsed(void *parsed_result,
16752 		__rte_unused struct cmdline *cl,
16753 		__rte_unused void *data)
16754 {
16755 	struct cmd_show_tx_metadata_result *res = parsed_result;
16756 
16757 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16758 		printf("invalid port id %u\n", res->cmd_pid);
16759 		return;
16760 	}
16761 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16762 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16763 		       ports[res->cmd_pid].tx_metadata);
16764 	}
16765 }
16766 
16767 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16768 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16769 			cmd_show, "show");
16770 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16771 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16772 			cmd_port, "port");
16773 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16774 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16775 			cmd_pid, RTE_UINT16);
16776 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16777 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16778 			cmd_keyword, "tx_metadata");
16779 
16780 cmdline_parse_inst_t cmd_show_tx_metadata = {
16781 	.f = cmd_show_tx_metadata_parsed,
16782 	.data = NULL,
16783 	.help_str = "show port <port_id> tx_metadata",
16784 	.tokens = {
16785 		(void *)&cmd_show_tx_metadata_show,
16786 		(void *)&cmd_show_tx_metadata_port,
16787 		(void *)&cmd_show_tx_metadata_pid,
16788 		(void *)&cmd_show_tx_metadata_keyword,
16789 		NULL,
16790 	},
16791 };
16792 
16793 /* *** show fec capability per port configuration *** */
16794 struct cmd_show_fec_capability_result {
16795 	cmdline_fixed_string_t cmd_show;
16796 	cmdline_fixed_string_t cmd_port;
16797 	cmdline_fixed_string_t cmd_fec;
16798 	cmdline_fixed_string_t cmd_keyword;
16799 	portid_t cmd_pid;
16800 };
16801 
16802 static void
16803 cmd_show_fec_capability_parsed(void *parsed_result,
16804 		__rte_unused struct cmdline *cl,
16805 		__rte_unused void *data)
16806 {
16807 	struct cmd_show_fec_capability_result *res = parsed_result;
16808 	struct rte_eth_fec_capa *speed_fec_capa;
16809 	unsigned int num;
16810 	int ret;
16811 
16812 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16813 		printf("Invalid port id %u\n", res->cmd_pid);
16814 		return;
16815 	}
16816 
16817 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16818 	if (ret == -ENOTSUP) {
16819 		printf("Function not implemented\n");
16820 		return;
16821 	} else if (ret < 0) {
16822 		printf("Get FEC capability failed: %d\n", ret);
16823 		return;
16824 	}
16825 
16826 	num = (unsigned int)ret;
16827 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16828 	if (speed_fec_capa == NULL) {
16829 		printf("Failed to alloc FEC capability buffer\n");
16830 		return;
16831 	}
16832 
16833 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16834 	if (ret < 0) {
16835 		printf("Error getting FEC capability: %d\n", ret);
16836 		goto out;
16837 	}
16838 
16839 	show_fec_capability(num, speed_fec_capa);
16840 out:
16841 	free(speed_fec_capa);
16842 }
16843 
16844 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16845 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16846 			cmd_show, "show");
16847 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16848 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16849 			cmd_port, "port");
16850 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16851 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16852 			cmd_pid, RTE_UINT16);
16853 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16854 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16855 			cmd_fec, "fec");
16856 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16857 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16858 			cmd_keyword, "capabilities");
16859 
16860 cmdline_parse_inst_t cmd_show_capability = {
16861 	.f = cmd_show_fec_capability_parsed,
16862 	.data = NULL,
16863 	.help_str = "show port <port_id> fec capabilities",
16864 	.tokens = {
16865 		(void *)&cmd_show_fec_capability_show,
16866 		(void *)&cmd_show_fec_capability_port,
16867 		(void *)&cmd_show_fec_capability_pid,
16868 		(void *)&cmd_show_fec_capability_fec,
16869 		(void *)&cmd_show_fec_capability_keyword,
16870 		NULL,
16871 	},
16872 };
16873 
16874 /* *** show fec mode per port configuration *** */
16875 struct cmd_show_fec_metadata_result {
16876 	cmdline_fixed_string_t cmd_show;
16877 	cmdline_fixed_string_t cmd_port;
16878 	cmdline_fixed_string_t cmd_keyword;
16879 	portid_t cmd_pid;
16880 };
16881 
16882 static void
16883 cmd_show_fec_mode_parsed(void *parsed_result,
16884 		__rte_unused struct cmdline *cl,
16885 		__rte_unused void *data)
16886 {
16887 #define FEC_NAME_SIZE 16
16888 	struct cmd_show_fec_metadata_result *res = parsed_result;
16889 	uint32_t mode;
16890 	char buf[FEC_NAME_SIZE];
16891 	int ret;
16892 
16893 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16894 		printf("Invalid port id %u\n", res->cmd_pid);
16895 		return;
16896 	}
16897 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
16898 	if (ret == -ENOTSUP) {
16899 		printf("Function not implemented\n");
16900 		return;
16901 	} else if (ret < 0) {
16902 		printf("Get FEC mode failed\n");
16903 		return;
16904 	}
16905 
16906 	switch (mode) {
16907 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16908 		strlcpy(buf, "off", sizeof(buf));
16909 		break;
16910 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16911 		strlcpy(buf, "auto", sizeof(buf));
16912 		break;
16913 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16914 		strlcpy(buf, "baser", sizeof(buf));
16915 		break;
16916 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16917 		strlcpy(buf, "rs", sizeof(buf));
16918 		break;
16919 	default:
16920 		return;
16921 	}
16922 
16923 	printf("%s\n", buf);
16924 }
16925 
16926 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16927 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16928 			cmd_show, "show");
16929 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16930 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16931 			cmd_port, "port");
16932 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16933 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16934 			cmd_pid, RTE_UINT16);
16935 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16936 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16937 			cmd_keyword, "fec_mode");
16938 
16939 cmdline_parse_inst_t cmd_show_fec_mode = {
16940 	.f = cmd_show_fec_mode_parsed,
16941 	.data = NULL,
16942 	.help_str = "show port <port_id> fec_mode",
16943 	.tokens = {
16944 		(void *)&cmd_show_fec_mode_show,
16945 		(void *)&cmd_show_fec_mode_port,
16946 		(void *)&cmd_show_fec_mode_pid,
16947 		(void *)&cmd_show_fec_mode_keyword,
16948 		NULL,
16949 	},
16950 };
16951 
16952 /* *** set fec mode per port configuration *** */
16953 struct cmd_set_port_fec_mode {
16954 	cmdline_fixed_string_t set;
16955 	cmdline_fixed_string_t port;
16956 	portid_t port_id;
16957 	cmdline_fixed_string_t fec_mode;
16958 	cmdline_fixed_string_t fec_value;
16959 };
16960 
16961 /* Common CLI fields for set fec mode */
16962 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16963 	TOKEN_STRING_INITIALIZER
16964 		(struct cmd_set_port_fec_mode,
16965 		 set, "set");
16966 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16967 	TOKEN_STRING_INITIALIZER
16968 		(struct cmd_set_port_fec_mode,
16969 		 port, "port");
16970 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16971 	TOKEN_NUM_INITIALIZER
16972 		(struct cmd_set_port_fec_mode,
16973 		 port_id, RTE_UINT16);
16974 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16975 	TOKEN_STRING_INITIALIZER
16976 		(struct cmd_set_port_fec_mode,
16977 		 fec_mode, "fec_mode");
16978 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16979 	TOKEN_STRING_INITIALIZER
16980 		(struct cmd_set_port_fec_mode,
16981 		 fec_value, NULL);
16982 
16983 static void
16984 cmd_set_port_fec_mode_parsed(
16985 	void *parsed_result,
16986 	__rte_unused struct cmdline *cl,
16987 	__rte_unused void *data)
16988 {
16989 	struct cmd_set_port_fec_mode *res = parsed_result;
16990 	uint16_t port_id = res->port_id;
16991 	uint32_t mode;
16992 	int ret;
16993 
16994 	ret = parse_fec_mode(res->fec_value, &mode);
16995 	if (ret < 0) {
16996 		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16997 			port_id);
16998 		return;
16999 	}
17000 
17001 	ret = rte_eth_fec_set(port_id, mode);
17002 	if (ret == -ENOTSUP) {
17003 		printf("Function not implemented\n");
17004 		return;
17005 	} else if (ret < 0) {
17006 		printf("Set FEC mode failed\n");
17007 		return;
17008 	}
17009 }
17010 
17011 cmdline_parse_inst_t cmd_set_fec_mode = {
17012 	.f = cmd_set_port_fec_mode_parsed,
17013 	.data = NULL,
17014 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17015 	.tokens = {
17016 		(void *)&cmd_set_port_fec_mode_set,
17017 		(void *)&cmd_set_port_fec_mode_port,
17018 		(void *)&cmd_set_port_fec_mode_port_id,
17019 		(void *)&cmd_set_port_fec_mode_str,
17020 		(void *)&cmd_set_port_fec_mode_value,
17021 		NULL,
17022 	},
17023 };
17024 
17025 /* show port supported ptypes */
17026 
17027 /* Common result structure for show port ptypes */
17028 struct cmd_show_port_supported_ptypes_result {
17029 	cmdline_fixed_string_t show;
17030 	cmdline_fixed_string_t port;
17031 	portid_t port_id;
17032 	cmdline_fixed_string_t ptypes;
17033 };
17034 
17035 /* Common CLI fields for show port ptypes */
17036 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17037 	TOKEN_STRING_INITIALIZER
17038 		(struct cmd_show_port_supported_ptypes_result,
17039 		 show, "show");
17040 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17041 	TOKEN_STRING_INITIALIZER
17042 		(struct cmd_show_port_supported_ptypes_result,
17043 		 port, "port");
17044 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17045 	TOKEN_NUM_INITIALIZER
17046 		(struct cmd_show_port_supported_ptypes_result,
17047 		 port_id, RTE_UINT16);
17048 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17049 	TOKEN_STRING_INITIALIZER
17050 		(struct cmd_show_port_supported_ptypes_result,
17051 		 ptypes, "ptypes");
17052 
17053 static void
17054 cmd_show_port_supported_ptypes_parsed(
17055 	void *parsed_result,
17056 	__rte_unused struct cmdline *cl,
17057 	__rte_unused void *data)
17058 {
17059 #define RSVD_PTYPE_MASK       0xf0000000
17060 #define MAX_PTYPES_PER_LAYER  16
17061 #define LTYPE_NAMESIZE        32
17062 #define PTYPE_NAMESIZE        256
17063 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17064 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17065 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17066 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17067 	uint16_t port_id = res->port_id;
17068 	int ret, i;
17069 
17070 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17071 	if (ret < 0)
17072 		return;
17073 
17074 	while (ptype_mask != RSVD_PTYPE_MASK) {
17075 
17076 		switch (ptype_mask) {
17077 		case RTE_PTYPE_L2_MASK:
17078 			strlcpy(ltype, "L2", sizeof(ltype));
17079 			break;
17080 		case RTE_PTYPE_L3_MASK:
17081 			strlcpy(ltype, "L3", sizeof(ltype));
17082 			break;
17083 		case RTE_PTYPE_L4_MASK:
17084 			strlcpy(ltype, "L4", sizeof(ltype));
17085 			break;
17086 		case RTE_PTYPE_TUNNEL_MASK:
17087 			strlcpy(ltype, "Tunnel", sizeof(ltype));
17088 			break;
17089 		case RTE_PTYPE_INNER_L2_MASK:
17090 			strlcpy(ltype, "Inner L2", sizeof(ltype));
17091 			break;
17092 		case RTE_PTYPE_INNER_L3_MASK:
17093 			strlcpy(ltype, "Inner L3", sizeof(ltype));
17094 			break;
17095 		case RTE_PTYPE_INNER_L4_MASK:
17096 			strlcpy(ltype, "Inner L4", sizeof(ltype));
17097 			break;
17098 		default:
17099 			return;
17100 		}
17101 
17102 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17103 						       ptype_mask, ptypes,
17104 						       MAX_PTYPES_PER_LAYER);
17105 
17106 		if (ret > 0)
17107 			printf("Supported %s ptypes:\n", ltype);
17108 		else
17109 			printf("%s ptypes unsupported\n", ltype);
17110 
17111 		for (i = 0; i < ret; ++i) {
17112 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17113 			printf("%s\n", buf);
17114 		}
17115 
17116 		ptype_mask <<= 4;
17117 	}
17118 }
17119 
17120 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17121 	.f = cmd_show_port_supported_ptypes_parsed,
17122 	.data = NULL,
17123 	.help_str = "show port <port_id> ptypes",
17124 	.tokens = {
17125 		(void *)&cmd_show_port_supported_ptypes_show,
17126 		(void *)&cmd_show_port_supported_ptypes_port,
17127 		(void *)&cmd_show_port_supported_ptypes_port_id,
17128 		(void *)&cmd_show_port_supported_ptypes_ptypes,
17129 		NULL,
17130 	},
17131 };
17132 
17133 /* *** display rx/tx descriptor status *** */
17134 struct cmd_show_rx_tx_desc_status_result {
17135 	cmdline_fixed_string_t cmd_show;
17136 	cmdline_fixed_string_t cmd_port;
17137 	cmdline_fixed_string_t cmd_keyword;
17138 	cmdline_fixed_string_t cmd_desc;
17139 	cmdline_fixed_string_t cmd_status;
17140 	portid_t cmd_pid;
17141 	portid_t cmd_qid;
17142 	portid_t cmd_did;
17143 };
17144 
17145 static void
17146 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17147 		__rte_unused struct cmdline *cl,
17148 		__rte_unused void *data)
17149 {
17150 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17151 	int rc;
17152 
17153 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17154 		printf("invalid port id %u\n", res->cmd_pid);
17155 		return;
17156 	}
17157 
17158 	if (!strcmp(res->cmd_keyword, "rxq")) {
17159 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17160 					     res->cmd_did);
17161 		if (rc < 0) {
17162 			printf("Invalid input: queue id = %d, desc id = %d\n",
17163 			       res->cmd_qid, res->cmd_did);
17164 			return;
17165 		}
17166 		if (rc == RTE_ETH_RX_DESC_AVAIL)
17167 			printf("Desc status = AVAILABLE\n");
17168 		else if (rc == RTE_ETH_RX_DESC_DONE)
17169 			printf("Desc status = DONE\n");
17170 		else
17171 			printf("Desc status = UNAVAILABLE\n");
17172 	} else if (!strcmp(res->cmd_keyword, "txq")) {
17173 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17174 					     res->cmd_did);
17175 		if (rc < 0) {
17176 			printf("Invalid input: queue id = %d, desc id = %d\n",
17177 			       res->cmd_qid, res->cmd_did);
17178 			return;
17179 		}
17180 		if (rc == RTE_ETH_TX_DESC_FULL)
17181 			printf("Desc status = FULL\n");
17182 		else if (rc == RTE_ETH_TX_DESC_DONE)
17183 			printf("Desc status = DONE\n");
17184 		else
17185 			printf("Desc status = UNAVAILABLE\n");
17186 	}
17187 }
17188 
17189 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17190 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17191 			cmd_show, "show");
17192 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17193 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17194 			cmd_port, "port");
17195 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17196 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17197 			cmd_pid, RTE_UINT16);
17198 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17199 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17200 			cmd_keyword, "rxq#txq");
17201 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17202 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17203 			cmd_qid, RTE_UINT16);
17204 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17205 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17206 			cmd_desc, "desc");
17207 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17208 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17209 			cmd_did, RTE_UINT16);
17210 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17211 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17212 			cmd_status, "status");
17213 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17214 	.f = cmd_show_rx_tx_desc_status_parsed,
17215 	.data = NULL,
17216 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17217 		"status",
17218 	.tokens = {
17219 		(void *)&cmd_show_rx_tx_desc_status_show,
17220 		(void *)&cmd_show_rx_tx_desc_status_port,
17221 		(void *)&cmd_show_rx_tx_desc_status_pid,
17222 		(void *)&cmd_show_rx_tx_desc_status_keyword,
17223 		(void *)&cmd_show_rx_tx_desc_status_qid,
17224 		(void *)&cmd_show_rx_tx_desc_status_desc,
17225 		(void *)&cmd_show_rx_tx_desc_status_did,
17226 		(void *)&cmd_show_rx_tx_desc_status_status,
17227 		NULL,
17228 	},
17229 };
17230 
17231 /* *** display rx queue desc used count *** */
17232 struct cmd_show_rx_queue_desc_used_count_result {
17233 	cmdline_fixed_string_t cmd_show;
17234 	cmdline_fixed_string_t cmd_port;
17235 	cmdline_fixed_string_t cmd_rxq;
17236 	cmdline_fixed_string_t cmd_desc;
17237 	cmdline_fixed_string_t cmd_used;
17238 	cmdline_fixed_string_t cmd_count;
17239 	portid_t cmd_pid;
17240 	portid_t cmd_qid;
17241 };
17242 
17243 static void
17244 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17245 		__rte_unused struct cmdline *cl,
17246 		__rte_unused void *data)
17247 {
17248 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17249 	int rc;
17250 
17251 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17252 		printf("invalid port id %u\n", res->cmd_pid);
17253 		return;
17254 	}
17255 
17256 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17257 	if (rc < 0) {
17258 		printf("Invalid queueid = %d\n", res->cmd_qid);
17259 		return;
17260 	}
17261 	printf("Used desc count = %d\n", rc);
17262 }
17263 
17264 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17265 	TOKEN_STRING_INITIALIZER
17266 		(struct cmd_show_rx_queue_desc_used_count_result,
17267 		 cmd_show, "show");
17268 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17269 	TOKEN_STRING_INITIALIZER
17270 		(struct cmd_show_rx_queue_desc_used_count_result,
17271 		 cmd_port, "port");
17272 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17273 	TOKEN_NUM_INITIALIZER
17274 		(struct cmd_show_rx_queue_desc_used_count_result,
17275 		 cmd_pid, RTE_UINT16);
17276 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17277 	TOKEN_STRING_INITIALIZER
17278 		(struct cmd_show_rx_queue_desc_used_count_result,
17279 		 cmd_rxq, "rxq");
17280 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17281 	TOKEN_NUM_INITIALIZER
17282 		(struct cmd_show_rx_queue_desc_used_count_result,
17283 		 cmd_qid, RTE_UINT16);
17284 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17285 	TOKEN_STRING_INITIALIZER
17286 		(struct cmd_show_rx_queue_desc_used_count_result,
17287 		 cmd_count, "desc");
17288 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17289 	TOKEN_STRING_INITIALIZER
17290 		(struct cmd_show_rx_queue_desc_used_count_result,
17291 		 cmd_count, "used");
17292 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17293 	TOKEN_STRING_INITIALIZER
17294 		(struct cmd_show_rx_queue_desc_used_count_result,
17295 		 cmd_count, "count");
17296 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17297 	.f = cmd_show_rx_queue_desc_used_count_parsed,
17298 	.data = NULL,
17299 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
17300 	.tokens = {
17301 		(void *)&cmd_show_rx_queue_desc_used_count_show,
17302 		(void *)&cmd_show_rx_queue_desc_used_count_port,
17303 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
17304 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
17305 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
17306 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
17307 		(void *)&cmd_show_rx_queue_desc_used_count_used,
17308 		(void *)&cmd_show_rx_queue_desc_used_count_count,
17309 		NULL,
17310 	},
17311 };
17312 
17313 /* Common result structure for set port ptypes */
17314 struct cmd_set_port_ptypes_result {
17315 	cmdline_fixed_string_t set;
17316 	cmdline_fixed_string_t port;
17317 	portid_t port_id;
17318 	cmdline_fixed_string_t ptype_mask;
17319 	uint32_t mask;
17320 };
17321 
17322 /* Common CLI fields for set port ptypes */
17323 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17324 	TOKEN_STRING_INITIALIZER
17325 		(struct cmd_set_port_ptypes_result,
17326 		 set, "set");
17327 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17328 	TOKEN_STRING_INITIALIZER
17329 		(struct cmd_set_port_ptypes_result,
17330 		 port, "port");
17331 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17332 	TOKEN_NUM_INITIALIZER
17333 		(struct cmd_set_port_ptypes_result,
17334 		 port_id, RTE_UINT16);
17335 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17336 	TOKEN_STRING_INITIALIZER
17337 		(struct cmd_set_port_ptypes_result,
17338 		 ptype_mask, "ptype_mask");
17339 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17340 	TOKEN_NUM_INITIALIZER
17341 		(struct cmd_set_port_ptypes_result,
17342 		 mask, RTE_UINT32);
17343 
17344 static void
17345 cmd_set_port_ptypes_parsed(
17346 	void *parsed_result,
17347 	__rte_unused struct cmdline *cl,
17348 	__rte_unused void *data)
17349 {
17350 	struct cmd_set_port_ptypes_result *res = parsed_result;
17351 #define PTYPE_NAMESIZE        256
17352 	char ptype_name[PTYPE_NAMESIZE];
17353 	uint16_t port_id = res->port_id;
17354 	uint32_t ptype_mask = res->mask;
17355 	int ret, i;
17356 
17357 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17358 					       NULL, 0);
17359 	if (ret <= 0) {
17360 		printf("Port %d doesn't support any ptypes.\n", port_id);
17361 		return;
17362 	}
17363 
17364 	uint32_t ptypes[ret];
17365 
17366 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17367 	if (ret < 0) {
17368 		printf("Unable to set requested ptypes for Port %d\n", port_id);
17369 		return;
17370 	}
17371 
17372 	printf("Successfully set following ptypes for Port %d\n", port_id);
17373 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17374 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17375 		printf("%s\n", ptype_name);
17376 	}
17377 
17378 	clear_ptypes = false;
17379 }
17380 
17381 cmdline_parse_inst_t cmd_set_port_ptypes = {
17382 	.f = cmd_set_port_ptypes_parsed,
17383 	.data = NULL,
17384 	.help_str = "set port <port_id> ptype_mask <mask>",
17385 	.tokens = {
17386 		(void *)&cmd_set_port_ptypes_set,
17387 		(void *)&cmd_set_port_ptypes_port,
17388 		(void *)&cmd_set_port_ptypes_port_id,
17389 		(void *)&cmd_set_port_ptypes_mask_str,
17390 		(void *)&cmd_set_port_ptypes_mask_u32,
17391 		NULL,
17392 	},
17393 };
17394 
17395 /* *** display mac addresses added to a port *** */
17396 struct cmd_showport_macs_result {
17397 	cmdline_fixed_string_t cmd_show;
17398 	cmdline_fixed_string_t cmd_port;
17399 	cmdline_fixed_string_t cmd_keyword;
17400 	portid_t cmd_pid;
17401 };
17402 
17403 static void
17404 cmd_showport_macs_parsed(void *parsed_result,
17405 		__rte_unused struct cmdline *cl,
17406 		__rte_unused void *data)
17407 {
17408 	struct cmd_showport_macs_result *res = parsed_result;
17409 
17410 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17411 		return;
17412 
17413 	if (!strcmp(res->cmd_keyword, "macs"))
17414 		show_macs(res->cmd_pid);
17415 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17416 		show_mcast_macs(res->cmd_pid);
17417 }
17418 
17419 cmdline_parse_token_string_t cmd_showport_macs_show =
17420 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17421 			cmd_show, "show");
17422 cmdline_parse_token_string_t cmd_showport_macs_port =
17423 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17424 			cmd_port, "port");
17425 cmdline_parse_token_num_t cmd_showport_macs_pid =
17426 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17427 			cmd_pid, RTE_UINT16);
17428 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17429 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17430 			cmd_keyword, "macs#mcast_macs");
17431 
17432 cmdline_parse_inst_t cmd_showport_macs = {
17433 	.f = cmd_showport_macs_parsed,
17434 	.data = NULL,
17435 	.help_str = "show port <port_id> macs|mcast_macs",
17436 	.tokens = {
17437 		(void *)&cmd_showport_macs_show,
17438 		(void *)&cmd_showport_macs_port,
17439 		(void *)&cmd_showport_macs_pid,
17440 		(void *)&cmd_showport_macs_keyword,
17441 		NULL,
17442 	},
17443 };
17444 
17445 /* ******************************************************************************** */
17446 
17447 /* list of instructions */
17448 cmdline_parse_ctx_t main_ctx[] = {
17449 	(cmdline_parse_inst_t *)&cmd_help_brief,
17450 	(cmdline_parse_inst_t *)&cmd_help_long,
17451 	(cmdline_parse_inst_t *)&cmd_quit,
17452 	(cmdline_parse_inst_t *)&cmd_load_from_file,
17453 	(cmdline_parse_inst_t *)&cmd_showport,
17454 	(cmdline_parse_inst_t *)&cmd_showqueue,
17455 	(cmdline_parse_inst_t *)&cmd_showeeprom,
17456 	(cmdline_parse_inst_t *)&cmd_showportall,
17457 	(cmdline_parse_inst_t *)&cmd_showdevice,
17458 	(cmdline_parse_inst_t *)&cmd_showcfg,
17459 	(cmdline_parse_inst_t *)&cmd_showfwdall,
17460 	(cmdline_parse_inst_t *)&cmd_start,
17461 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
17462 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17463 	(cmdline_parse_inst_t *)&cmd_set_link_up,
17464 	(cmdline_parse_inst_t *)&cmd_set_link_down,
17465 	(cmdline_parse_inst_t *)&cmd_reset,
17466 	(cmdline_parse_inst_t *)&cmd_set_numbers,
17467 	(cmdline_parse_inst_t *)&cmd_set_log,
17468 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
17469 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
17470 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
17471 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
17472 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
17473 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
17474 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17475 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17476 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17477 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17478 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17479 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17480 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17481 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17482 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
17483 	(cmdline_parse_inst_t *)&cmd_set_link_check,
17484 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17485 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
17486 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17487 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
17488 #ifdef RTE_NET_BOND
17489 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17490 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
17491 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17492 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17493 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17494 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
17495 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17496 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17497 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17498 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17499 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17500 #endif
17501 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
17502 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
17503 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17504 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17505 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17506 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17507 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17508 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17509 	(cmdline_parse_inst_t *)&cmd_csum_set,
17510 	(cmdline_parse_inst_t *)&cmd_csum_show,
17511 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
17512 	(cmdline_parse_inst_t *)&cmd_tso_set,
17513 	(cmdline_parse_inst_t *)&cmd_tso_show,
17514 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17515 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17516 	(cmdline_parse_inst_t *)&cmd_gro_enable,
17517 	(cmdline_parse_inst_t *)&cmd_gro_flush,
17518 	(cmdline_parse_inst_t *)&cmd_gro_show,
17519 	(cmdline_parse_inst_t *)&cmd_gso_enable,
17520 	(cmdline_parse_inst_t *)&cmd_gso_size,
17521 	(cmdline_parse_inst_t *)&cmd_gso_show,
17522 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17523 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17524 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17525 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17526 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17527 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17528 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17529 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17530 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17531 	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17532 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17533 	(cmdline_parse_inst_t *)&cmd_config_dcb,
17534 	(cmdline_parse_inst_t *)&cmd_read_reg,
17535 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17536 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
17537 	(cmdline_parse_inst_t *)&cmd_write_reg,
17538 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17539 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
17540 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17541 	(cmdline_parse_inst_t *)&cmd_stop,
17542 	(cmdline_parse_inst_t *)&cmd_mac_addr,
17543 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17544 	(cmdline_parse_inst_t *)&cmd_set_qmap,
17545 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17546 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17547 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17548 	(cmdline_parse_inst_t *)&cmd_operate_port,
17549 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
17550 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
17551 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
17552 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
17553 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17554 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
17555 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
17556 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
17557 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17558 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
17559 	(cmdline_parse_inst_t *)&cmd_config_mtu,
17560 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17561 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17562 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17563 	(cmdline_parse_inst_t *)&cmd_config_rss,
17564 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17565 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17566 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17567 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17568 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
17569 	(cmdline_parse_inst_t *)&cmd_showport_reta,
17570 	(cmdline_parse_inst_t *)&cmd_showport_macs,
17571 	(cmdline_parse_inst_t *)&cmd_config_burst,
17572 	(cmdline_parse_inst_t *)&cmd_config_thresh,
17573 	(cmdline_parse_inst_t *)&cmd_config_threshold,
17574 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17575 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17576 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17577 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17578 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17579 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17580 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
17581 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17582 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17583 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17584 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17585 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17586 	(cmdline_parse_inst_t *)&cmd_dump,
17587 	(cmdline_parse_inst_t *)&cmd_dump_one,
17588 #ifdef RTE_NET_I40E
17589 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17590 #endif
17591 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17592 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17593 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17594 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17595 	(cmdline_parse_inst_t *)&cmd_flow,
17596 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17597 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17598 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17599 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17600 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
17601 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
17602 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
17603 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
17604 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17605 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17606 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17607 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17608 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17609 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
17610 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17611 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17612 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17613 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17614 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17615 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17616 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17617 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17618 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17619 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17620 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17621 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17622 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17623 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17624 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17625 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17626 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17627 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17628 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17629 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17630 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
17631 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17632 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17633 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
17634 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
17635 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
17636 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17637 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17638 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
17639 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17640 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
17641 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17642 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
17643 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17644 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17645 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17646 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17647 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17648 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17649 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17650 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17651 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17652 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17653 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17654 	(cmdline_parse_inst_t *)&cmd_ddp_add,
17655 	(cmdline_parse_inst_t *)&cmd_ddp_del,
17656 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
17657 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
17658 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
17659 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
17660 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
17661 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17662 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17663 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17664 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17665 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17666 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17667 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17668 
17669 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17670 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17671 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17672 	(cmdline_parse_inst_t *)&cmd_queue_region,
17673 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
17674 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
17675 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
17676 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17677 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17678 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17679 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17680 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17681 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17682 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17683 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17684 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17685 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17686 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17687 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17688 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17689 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17690 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17691 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17692 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17693 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17694 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17695 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17696 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17697 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17698 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17699 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17700 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17701 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17702 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17703 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17704 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17705 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17706 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17707 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17708 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17709 #ifdef RTE_LIB_BPF
17710 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17711 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17712 #endif
17713 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17714 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17715 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17716 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17717 	(cmdline_parse_inst_t *)&cmd_set_raw,
17718 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
17719 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17720 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17721 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
17722 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
17723 	(cmdline_parse_inst_t *)&cmd_show_capability,
17724 	NULL,
17725 };
17726 
17727 /* read cmdline commands from file */
17728 void
17729 cmdline_read_from_file(const char *filename)
17730 {
17731 	struct cmdline *cl;
17732 
17733 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17734 	if (cl == NULL) {
17735 		printf("Failed to create file based cmdline context: %s\n",
17736 		       filename);
17737 		return;
17738 	}
17739 
17740 	cmdline_interact(cl);
17741 	cmdline_quit(cl);
17742 
17743 	cmdline_free(cl);
17744 
17745 	printf("Read CLI commands from %s\n", filename);
17746 }
17747 
17748 /* prompt function, called from main on MAIN lcore */
17749 void
17750 prompt(void)
17751 {
17752 	int ret;
17753 	/* initialize non-constant commands */
17754 	cmd_set_fwd_mode_init();
17755 	cmd_set_fwd_retry_mode_init();
17756 
17757 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17758 	if (testpmd_cl == NULL)
17759 		return;
17760 
17761 	ret = atexit(prompt_exit);
17762 	if (ret != 0)
17763 		printf("Cannot set exit function for cmdline\n");
17764 
17765 	cmdline_interact(testpmd_cl);
17766 	if (ret != 0)
17767 		cmdline_stdin_exit(testpmd_cl);
17768 }
17769 
17770 void
17771 prompt_exit(void)
17772 {
17773 	if (testpmd_cl != NULL) {
17774 		cmdline_quit(testpmd_cl);
17775 		cmdline_stdin_exit(testpmd_cl);
17776 	}
17777 }
17778 
17779 static void
17780 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17781 {
17782 	if (id == (portid_t)RTE_PORT_ALL) {
17783 		portid_t pid;
17784 
17785 		RTE_ETH_FOREACH_DEV(pid) {
17786 			/* check if need_reconfig has been set to 1 */
17787 			if (ports[pid].need_reconfig == 0)
17788 				ports[pid].need_reconfig = dev;
17789 			/* check if need_reconfig_queues has been set to 1 */
17790 			if (ports[pid].need_reconfig_queues == 0)
17791 				ports[pid].need_reconfig_queues = queue;
17792 		}
17793 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17794 		/* check if need_reconfig has been set to 1 */
17795 		if (ports[id].need_reconfig == 0)
17796 			ports[id].need_reconfig = dev;
17797 		/* check if need_reconfig_queues has been set to 1 */
17798 		if (ports[id].need_reconfig_queues == 0)
17799 			ports[id].need_reconfig_queues = queue;
17800 	}
17801 }
17802