xref: /dpdk/app/test-pmd/cmdline.c (revision 8d935fff)
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|cap) (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) macs|mcast_macs"
250 			"       Display list of mac addresses added to port.\n\n"
251 
252 			"show port (port_id) fec capabilities"
253 			"	Show fec capabilities of a port.\n\n"
254 
255 			"show port (port_id) fec_mode"
256 			"	Show fec mode of a port.\n\n"
257 		);
258 	}
259 
260 	if (show_all || !strcmp(res->section, "config")) {
261 		cmdline_printf(
262 			cl,
263 			"\n"
264 			"Configuration:\n"
265 			"--------------\n"
266 			"Configuration changes only become active when"
267 			" forwarding is started/restarted.\n\n"
268 
269 			"set default\n"
270 			"    Reset forwarding to the default configuration.\n\n"
271 
272 			"set verbose (level)\n"
273 			"    Set the debug verbosity level X.\n\n"
274 
275 			"set log global|(type) (level)\n"
276 			"    Set the log level.\n\n"
277 
278 			"set nbport (num)\n"
279 			"    Set number of ports.\n\n"
280 
281 			"set nbcore (num)\n"
282 			"    Set number of cores.\n\n"
283 
284 			"set coremask (mask)\n"
285 			"    Set the forwarding cores hexadecimal mask.\n\n"
286 
287 			"set portmask (mask)\n"
288 			"    Set the forwarding ports hexadecimal mask.\n\n"
289 
290 			"set burst (num)\n"
291 			"    Set number of packets per burst.\n\n"
292 
293 			"set burst tx delay (microseconds) retry (num)\n"
294 			"    Set the transmit delay time and number of retries,"
295 			" effective when retry is enabled.\n\n"
296 
297 			"set rxoffs (x[,y]*)\n"
298 			"    Set the offset of each packet segment on"
299 			" receiving if split feature is engaged."
300 			" Affects only the queues configured with split"
301 			" offloads.\n\n"
302 
303 			"set rxpkts (x[,y]*)\n"
304 			"    Set the length of each segment to scatter"
305 			" packets on receiving if split feature is engaged."
306 			" Affects only the queues configured with split"
307 			" offloads.\n\n"
308 
309 			"set txpkts (x[,y]*)\n"
310 			"    Set the length of each segment of TXONLY"
311 			" and optionally CSUM packets.\n\n"
312 
313 			"set txsplit (off|on|rand)\n"
314 			"    Set the split policy for the TX packets."
315 			" Right now only applicable for CSUM and TXONLY"
316 			" modes\n\n"
317 
318 			"set txtimes (x, y)\n"
319 			"    Set the scheduling on timestamps"
320 			" timings for the TXONLY mode\n\n"
321 
322 			"set corelist (x[,y]*)\n"
323 			"    Set the list of forwarding cores.\n\n"
324 
325 			"set portlist (x[,y]*)\n"
326 			"    Set the list of forwarding ports.\n\n"
327 
328 			"set port setup on (iterator|event)\n"
329 			"    Select how attached port is retrieved for setup.\n\n"
330 
331 			"set tx loopback (port_id) (on|off)\n"
332 			"    Enable or disable tx loopback.\n\n"
333 
334 			"set all queues drop (port_id) (on|off)\n"
335 			"    Set drop enable bit for all queues.\n\n"
336 
337 			"set vf split drop (port_id) (vf_id) (on|off)\n"
338 			"    Set split drop enable bit for a VF from the PF.\n\n"
339 
340 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
341 			"    Set MAC antispoof for a VF from the PF.\n\n"
342 
343 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
344 			"    Enable MACsec offload.\n\n"
345 
346 			"set macsec offload (port_id) off\n"
347 			"    Disable MACsec offload.\n\n"
348 
349 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
350 			"    Configure MACsec secure connection (SC).\n\n"
351 
352 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
353 			"    Configure MACsec secure association (SA).\n\n"
354 
355 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
356 			"    Set VF broadcast for a VF from the PF.\n\n"
357 
358 			"vlan set stripq (on|off) (port_id,queue_id)\n"
359 			"    Set the VLAN strip for a queue on a port.\n\n"
360 
361 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
362 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
363 
364 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
365 			"    Set VLAN insert for a VF from the PF.\n\n"
366 
367 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
368 			"    Set VLAN antispoof for a VF from the PF.\n\n"
369 
370 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
371 			"    Set VLAN tag for a VF from the PF.\n\n"
372 
373 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
374 			"    Set a VF's max bandwidth(Mbps).\n\n"
375 
376 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
377 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
378 
379 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
380 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
381 
382 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
383 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
384 
385 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
386 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
387 
388 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
389 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
390 
391 			"vlan set (inner|outer) tpid (value) (port_id)\n"
392 			"    Set the VLAN TPID for Packet Filtering on"
393 			" a port\n\n"
394 
395 			"rx_vlan add (vlan_id|all) (port_id)\n"
396 			"    Add a vlan_id, or all identifiers, to the set"
397 			" of VLAN identifiers filtered by port_id.\n\n"
398 
399 			"rx_vlan rm (vlan_id|all) (port_id)\n"
400 			"    Remove a vlan_id, or all identifiers, from the set"
401 			" of VLAN identifiers filtered by port_id.\n\n"
402 
403 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
404 			"    Add a vlan_id, to the set of VLAN identifiers"
405 			"filtered for VF(s) from port_id.\n\n"
406 
407 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
408 			"    Remove a vlan_id, to the set of VLAN identifiers"
409 			"filtered for VF(s) from port_id.\n\n"
410 
411 			"rx_vxlan_port add (udp_port) (port_id)\n"
412 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
413 
414 			"rx_vxlan_port rm (udp_port) (port_id)\n"
415 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
416 
417 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
418 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
419 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
420 
421 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
422 			"    Set port based TX VLAN insertion.\n\n"
423 
424 			"tx_vlan reset (port_id)\n"
425 			"    Disable hardware insertion of a VLAN header in"
426 			" packets sent on a port.\n\n"
427 
428 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
429 			"    Select hardware or software calculation of the"
430 			" checksum when transmitting a packet using the"
431 			" csum forward engine.\n"
432 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
433 			"    outer-ip concerns the outer IP layer in"
434 			"    outer-udp concerns the outer UDP layer in"
435 			" case the packet is recognized as a tunnel packet by"
436 			" the forward engine (vxlan, gre and ipip are supported)\n"
437 			"    Please check the NIC datasheet for HW limits.\n\n"
438 
439 			"csum parse-tunnel (on|off) (tx_port_id)\n"
440 			"    If disabled, treat tunnel packets as non-tunneled"
441 			" packets (treat inner headers as payload). The port\n"
442 			"    argument is the port used for TX in csum forward"
443 			" engine.\n\n"
444 
445 			"csum show (port_id)\n"
446 			"    Display tx checksum offload configuration\n\n"
447 
448 			"tso set (segsize) (portid)\n"
449 			"    Enable TCP Segmentation Offload in csum forward"
450 			" engine.\n"
451 			"    Please check the NIC datasheet for HW limits.\n\n"
452 
453 			"tso show (portid)"
454 			"    Display the status of TCP Segmentation Offload.\n\n"
455 
456 			"set port (port_id) gro on|off\n"
457 			"    Enable or disable Generic Receive Offload in"
458 			" csum forwarding engine.\n\n"
459 
460 			"show port (port_id) gro\n"
461 			"    Display GRO configuration.\n\n"
462 
463 			"set gro flush (cycles)\n"
464 			"    Set the cycle to flush GROed packets from"
465 			" reassembly tables.\n\n"
466 
467 			"set port (port_id) gso (on|off)"
468 			"    Enable or disable Generic Segmentation Offload in"
469 			" csum forwarding engine.\n\n"
470 
471 			"set gso segsz (length)\n"
472 			"    Set max packet length for output GSO segments,"
473 			" including packet header and payload.\n\n"
474 
475 			"show port (port_id) gso\n"
476 			"    Show GSO configuration.\n\n"
477 
478 			"set fwd (%s)\n"
479 			"    Set packet forwarding mode.\n\n"
480 
481 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
482 			"    Add a MAC address on port_id.\n\n"
483 
484 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 			"    Remove a MAC address from port_id.\n\n"
486 
487 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 			"    Set the default MAC address for port_id.\n\n"
489 
490 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
491 			"    Add a MAC address for a VF on the port.\n\n"
492 
493 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
494 			"    Set the MAC address for a VF from the PF.\n\n"
495 
496 			"set eth-peer (port_id) (peer_addr)\n"
497 			"    set the peer address for certain port.\n\n"
498 
499 			"set port (port_id) uta (mac_address|all) (on|off)\n"
500 			"    Add/Remove a or all unicast hash filter(s)"
501 			"from port X.\n\n"
502 
503 			"set promisc (port_id|all) (on|off)\n"
504 			"    Set the promiscuous mode on port_id, or all.\n\n"
505 
506 			"set allmulti (port_id|all) (on|off)\n"
507 			"    Set the allmulti mode on port_id, or all.\n\n"
508 
509 			"set vf promisc (port_id) (vf_id) (on|off)\n"
510 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
511 
512 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
513 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
514 
515 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
516 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
517 			" (on|off) autoneg (on|off) (port_id)\n"
518 			"set flow_ctrl rx (on|off) (portid)\n"
519 			"set flow_ctrl tx (on|off) (portid)\n"
520 			"set flow_ctrl high_water (high_water) (portid)\n"
521 			"set flow_ctrl low_water (low_water) (portid)\n"
522 			"set flow_ctrl pause_time (pause_time) (portid)\n"
523 			"set flow_ctrl send_xon (send_xon) (portid)\n"
524 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
525 			"set flow_ctrl autoneg (on|off) (port_id)\n"
526 			"    Set the link flow control parameter on a port.\n\n"
527 
528 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
529 			" (low_water) (pause_time) (priority) (port_id)\n"
530 			"    Set the priority flow control parameter on a"
531 			" port.\n\n"
532 
533 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
534 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
535 			" queue on port.\n"
536 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
537 			" on port 0 to mapping 5.\n\n"
538 
539 			"set xstats-hide-zero on|off\n"
540 			"    Set the option to hide the zero values"
541 			" for xstats display.\n"
542 
543 			"set record-core-cycles on|off\n"
544 			"    Set the option to enable measurement of CPU cycles.\n"
545 
546 			"set record-burst-stats on|off\n"
547 			"    Set the option to enable display of RX and TX bursts.\n"
548 
549 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
550 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
551 
552 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
553 			"|MPE) (on|off)\n"
554 			"    AUPE:accepts untagged VLAN;"
555 			"ROPE:accept unicast hash\n\n"
556 			"    BAM:accepts broadcast packets;"
557 			"MPE:accepts all multicast packets\n\n"
558 			"    Enable/Disable a VF receive mode of a port\n\n"
559 
560 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
561 			"    Set rate limit for a queue of a port\n\n"
562 
563 			"set port (port_id) vf (vf_id) rate (rate_num) "
564 			"queue_mask (queue_mask_value)\n"
565 			"    Set rate limit for queues in VF of a port\n\n"
566 
567 			"set port (port_id) mirror-rule (rule_id)"
568 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
569 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
570 			"   Set pool or vlan type mirror rule on a port.\n"
571 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
572 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
573 			" to pool 0.\n\n"
574 
575 			"set port (port_id) mirror-rule (rule_id)"
576 			" (uplink-mirror|downlink-mirror) dst-pool"
577 			" (pool_id) (on|off)\n"
578 			"   Set uplink or downlink type mirror rule on a port.\n"
579 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
580 			" 0 on' enable mirror income traffic to pool 0.\n\n"
581 
582 			"reset port (port_id) mirror-rule (rule_id)\n"
583 			"   Reset a mirror rule.\n\n"
584 
585 			"set flush_rx (on|off)\n"
586 			"   Flush (default) or don't flush RX streams before"
587 			" forwarding. Mainly used with PCAP drivers.\n\n"
588 
589 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
590 			"   Set the bypass mode for the lowest port on bypass enabled"
591 			" NIC.\n\n"
592 
593 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
594 			"mode (normal|bypass|isolate) (port_id)\n"
595 			"   Set the event required to initiate specified bypass mode for"
596 			" the lowest port on a bypass enabled NIC where:\n"
597 			"       timeout   = enable bypass after watchdog timeout.\n"
598 			"       os_on     = enable bypass when OS/board is powered on.\n"
599 			"       os_off    = enable bypass when OS/board is powered off.\n"
600 			"       power_on  = enable bypass when power supply is turned on.\n"
601 			"       power_off = enable bypass when power supply is turned off."
602 			"\n\n"
603 
604 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
605 			"   Set the bypass watchdog timeout to 'n' seconds"
606 			" where 0 = instant.\n\n"
607 
608 			"show bypass config (port_id)\n"
609 			"   Show the bypass configuration for a bypass enabled NIC"
610 			" using the lowest port on the NIC.\n\n"
611 
612 #ifdef RTE_NET_BOND
613 			"create bonded device (mode) (socket)\n"
614 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
615 
616 			"add bonding slave (slave_id) (port_id)\n"
617 			"	Add a slave device to a bonded device.\n\n"
618 
619 			"remove bonding slave (slave_id) (port_id)\n"
620 			"	Remove a slave device from a bonded device.\n\n"
621 
622 			"set bonding mode (value) (port_id)\n"
623 			"	Set the bonding mode on a bonded device.\n\n"
624 
625 			"set bonding primary (slave_id) (port_id)\n"
626 			"	Set the primary slave for a bonded device.\n\n"
627 
628 			"show bonding config (port_id)\n"
629 			"	Show the bonding config for port_id.\n\n"
630 
631 			"set bonding mac_addr (port_id) (address)\n"
632 			"	Set the MAC address of a bonded device.\n\n"
633 
634 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
635 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
636 
637 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
638 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
639 
640 			"set bonding mon_period (port_id) (value)\n"
641 			"	Set the bonding link status monitoring polling period in ms.\n\n"
642 
643 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
644 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
645 
646 #endif
647 			"set link-up port (port_id)\n"
648 			"	Set link up for a port.\n\n"
649 
650 			"set link-down port (port_id)\n"
651 			"	Set link down for a port.\n\n"
652 
653 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
654 			"    Load a profile package on a port\n\n"
655 
656 			"ddp del (port_id) (backup_profile_path)\n"
657 			"    Delete a profile package from a port\n\n"
658 
659 			"ptype mapping get (port_id) (valid_only)\n"
660 			"    Get ptype mapping on a port\n\n"
661 
662 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
663 			"    Replace target with the pkt_type in ptype mapping\n\n"
664 
665 			"ptype mapping reset (port_id)\n"
666 			"    Reset ptype mapping on a port\n\n"
667 
668 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
669 			"    Update a ptype mapping item on a port\n\n"
670 
671 			"set port (port_id) ptype_mask (ptype_mask)\n"
672 			"    set packet types classification for a specific port\n\n"
673 
674 			"set port (port_id) queue-region region_id (value) "
675 			"queue_start_index (value) queue_num (value)\n"
676 			"    Set a queue region on a port\n\n"
677 
678 			"set port (port_id) queue-region region_id (value) "
679 			"flowtype (value)\n"
680 			"    Set a flowtype region index on a port\n\n"
681 
682 			"set port (port_id) queue-region UP (value) region_id (value)\n"
683 			"    Set the mapping of User Priority to "
684 			"queue region on a port\n\n"
685 
686 			"set port (port_id) queue-region flush (on|off)\n"
687 			"    flush all queue region related configuration\n\n"
688 
689 			"show port meter cap (port_id)\n"
690 			"    Show port meter capability information\n\n"
691 
692 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
693 			"    meter profile add - srtcm rfc 2697\n\n"
694 
695 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
696 			"    meter profile add - trtcm rfc 2698\n\n"
697 
698 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
699 			"    meter profile add - trtcm rfc 4115\n\n"
700 
701 			"del port meter profile (port_id) (profile_id)\n"
702 			"    meter profile delete\n\n"
703 
704 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
705 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
706 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
707 			"(dscp_tbl_entry63)]\n"
708 			"    meter create\n\n"
709 
710 			"enable port meter (port_id) (mtr_id)\n"
711 			"    meter enable\n\n"
712 
713 			"disable port meter (port_id) (mtr_id)\n"
714 			"    meter disable\n\n"
715 
716 			"del port meter (port_id) (mtr_id)\n"
717 			"    meter delete\n\n"
718 
719 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
720 			"    meter update meter profile\n\n"
721 
722 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
723 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
724 			"    update meter dscp table entries\n\n"
725 
726 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
727 			"(action0) [(action1) (action2)]\n"
728 			"    meter update policer action\n\n"
729 
730 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
731 			"    meter update stats\n\n"
732 
733 			"show port (port_id) queue-region\n"
734 			"    show all queue region related configuration info\n\n"
735 
736 			"set port (port_id) fec_mode auto|off|rs|baser\n"
737 			"    set fec mode for a specific port\n\n"
738 
739 			, list_pkt_forwarding_modes()
740 		);
741 	}
742 
743 	if (show_all || !strcmp(res->section, "ports")) {
744 
745 		cmdline_printf(
746 			cl,
747 			"\n"
748 			"Port Operations:\n"
749 			"----------------\n\n"
750 
751 			"port start (port_id|all)\n"
752 			"    Start all ports or port_id.\n\n"
753 
754 			"port stop (port_id|all)\n"
755 			"    Stop all ports or port_id.\n\n"
756 
757 			"port close (port_id|all)\n"
758 			"    Close all ports or port_id.\n\n"
759 
760 			"port reset (port_id|all)\n"
761 			"    Reset all ports or port_id.\n\n"
762 
763 			"port attach (ident)\n"
764 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
765 
766 			"port detach (port_id)\n"
767 			"    Detach physical or virtual dev by port_id\n\n"
768 
769 			"port config (port_id|all)"
770 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
771 			" duplex (half|full|auto)\n"
772 			"    Set speed and duplex for all ports or port_id\n\n"
773 
774 			"port config (port_id|all) loopback (mode)\n"
775 			"    Set loopback mode for all ports or port_id\n\n"
776 
777 			"port config all (rxq|txq|rxd|txd) (value)\n"
778 			"    Set number for rxq/txq/rxd/txd.\n\n"
779 
780 			"port config all max-pkt-len (value)\n"
781 			"    Set the max packet length.\n\n"
782 
783 			"port config all max-lro-pkt-size (value)\n"
784 			"    Set the max LRO aggregated packet size.\n\n"
785 
786 			"port config all drop-en (on|off)\n"
787 			"    Enable or disable packet drop on all RX queues of all ports when no "
788 			"receive buffers available.\n\n"
789 
790 			"port config all rss (all|default|ip|tcp|udp|sctp|"
791 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
792 			"level-outer|level-inner|<flowtype_id>)\n"
793 			"    Set the RSS mode.\n\n"
794 
795 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
796 			"    Set the RSS redirection table.\n\n"
797 
798 			"port config (port_id) dcb vt (on|off) (traffic_class)"
799 			" pfc (on|off)\n"
800 			"    Set the DCB mode.\n\n"
801 
802 			"port config all burst (value)\n"
803 			"    Set the number of packets per burst.\n\n"
804 
805 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
806 			" (value)\n"
807 			"    Set the ring prefetch/host/writeback threshold"
808 			" for tx/rx queue.\n\n"
809 
810 			"port config all (txfreet|txrst|rxfreet) (value)\n"
811 			"    Set free threshold for rx/tx, or set"
812 			" tx rs bit threshold.\n\n"
813 			"port config mtu X value\n"
814 			"    Set the MTU of port X to a given value\n\n"
815 
816 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
817 			"    Set a rx/tx queue's ring size configuration, the new"
818 			" value will take effect after command that (re-)start the port"
819 			" or command that setup the specific queue\n\n"
820 
821 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
822 			"    Start/stop a rx/tx queue of port X. Only take effect"
823 			" when port X is started\n\n"
824 
825 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
826 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
827 			" take effect when port X is stopped.\n\n"
828 
829 			"port (port_id) (rxq|txq) (queue_id) setup\n"
830 			"    Setup a rx/tx queue of port X.\n\n"
831 
832 			"port config (port_id) pctype mapping reset\n"
833 			"    Reset flow type to pctype mapping on a port\n\n"
834 
835 			"port config (port_id) pctype mapping update"
836 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
837 			"    Update a flow type to pctype mapping item on a port\n\n"
838 
839 			"port config (port_id) pctype (pctype_id) hash_inset|"
840 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
841 			" (field_idx)\n"
842 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
843 
844 			"port config (port_id) pctype (pctype_id) hash_inset|"
845 			"fdir_inset|fdir_flx_inset clear all"
846 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
847 
848 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
849 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
850 
851 			"port config <port_id> rx_offload vlan_strip|"
852 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
853 			"outer_ipv4_cksum|macsec_strip|header_split|"
854 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
855 			"buffer_split|timestamp|security|keep_crc on|off\n"
856 			"     Enable or disable a per port Rx offloading"
857 			" on all Rx queues of a port\n\n"
858 
859 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
860 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
861 			"outer_ipv4_cksum|macsec_strip|header_split|"
862 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
863 			"buffer_split|timestamp|security|keep_crc on|off\n"
864 			"    Enable or disable a per queue Rx offloading"
865 			" only on a specific Rx queue\n\n"
866 
867 			"port config (port_id) tx_offload vlan_insert|"
868 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
869 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
870 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
871 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
872 			"security on|off\n"
873 			"    Enable or disable a per port Tx offloading"
874 			" on all Tx queues of a port\n\n"
875 
876 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
877 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
880 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
881 			" on|off\n"
882 			"    Enable or disable a per queue Tx offloading"
883 			" only on a specific Tx queue\n\n"
884 
885 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
886 			"    Load an eBPF program as a callback"
887 			" for particular RX/TX queue\n\n"
888 
889 			"bpf-unload rx|tx (port) (queue)\n"
890 			"    Unload previously loaded eBPF program"
891 			" for particular RX/TX queue\n\n"
892 
893 			"port config (port_id) tx_metadata (value)\n"
894 			"    Set Tx metadata value per port. Testpmd will add this value"
895 			" to any Tx packet sent from this port\n\n"
896 
897 			"port config (port_id) dynf (name) set|clear\n"
898 			"    Register a dynf and Set/clear this flag on Tx. "
899 			"Testpmd will set this value to any Tx packet "
900 			"sent from this port\n\n"
901 		);
902 	}
903 
904 	if (show_all || !strcmp(res->section, "registers")) {
905 
906 		cmdline_printf(
907 			cl,
908 			"\n"
909 			"Registers:\n"
910 			"----------\n\n"
911 
912 			"read reg (port_id) (address)\n"
913 			"    Display value of a port register.\n\n"
914 
915 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
916 			"    Display a port register bit field.\n\n"
917 
918 			"read regbit (port_id) (address) (bit_x)\n"
919 			"    Display a single port register bit.\n\n"
920 
921 			"write reg (port_id) (address) (value)\n"
922 			"    Set value of a port register.\n\n"
923 
924 			"write regfield (port_id) (address) (bit_x) (bit_y)"
925 			" (value)\n"
926 			"    Set bit field of a port register.\n\n"
927 
928 			"write regbit (port_id) (address) (bit_x) (value)\n"
929 			"    Set single bit value of a port register.\n\n"
930 		);
931 	}
932 	if (show_all || !strcmp(res->section, "filters")) {
933 
934 		cmdline_printf(
935 			cl,
936 			"\n"
937 			"filters:\n"
938 			"--------\n\n"
939 
940 #ifdef RTE_NET_I40E
941 			"flow_director_filter (port_id) mode raw (add|del|update)"
942 			" flow (flow_id) (drop|fwd) queue (queue_id)"
943 			" fd_id (fd_id_value) packet (packet file name)\n"
944 			"    Add/Del a raw type flow director filter.\n\n"
945 #endif
946 
947 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
948 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
949 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
950 			"    Set flow director IP mask.\n\n"
951 
952 			"flow_director_mask (port_id) mode MAC-VLAN"
953 			" vlan (vlan_value)\n"
954 			"    Set flow director MAC-VLAN mask.\n\n"
955 
956 			"flow_director_mask (port_id) mode Tunnel"
957 			" vlan (vlan_value) mac (mac_value)"
958 			" tunnel-type (tunnel_type_value)"
959 			" tunnel-id (tunnel_id_value)\n"
960 			"    Set flow director Tunnel mask.\n\n"
961 
962 			"flow_director_flex_payload (port_id)"
963 			" (raw|l2|l3|l4) (config)\n"
964 			"    Configure flex payload selection.\n\n"
965 
966 			"flow validate {port_id}"
967 			" [group {group_id}] [priority {level}]"
968 			" [ingress] [egress]"
969 			" pattern {item} [/ {item} [...]] / end"
970 			" actions {action} [/ {action} [...]] / end\n"
971 			"    Check whether a flow rule can be created.\n\n"
972 
973 			"flow create {port_id}"
974 			" [group {group_id}] [priority {level}]"
975 			" [ingress] [egress]"
976 			" pattern {item} [/ {item} [...]] / end"
977 			" actions {action} [/ {action} [...]] / end\n"
978 			"    Create a flow rule.\n\n"
979 
980 			"flow destroy {port_id} rule {rule_id} [...]\n"
981 			"    Destroy specific flow rules.\n\n"
982 
983 			"flow flush {port_id}\n"
984 			"    Destroy all flow rules.\n\n"
985 
986 			"flow query {port_id} {rule_id} {action}\n"
987 			"    Query an existing flow rule.\n\n"
988 
989 			"flow list {port_id} [group {group_id}] [...]\n"
990 			"    List existing flow rules sorted by priority,"
991 			" filtered by group identifiers.\n\n"
992 
993 			"flow isolate {port_id} {boolean}\n"
994 			"    Restrict ingress traffic to the defined"
995 			" flow rules\n\n"
996 
997 			"flow aged {port_id} [destroy]\n"
998 			"    List and destroy aged flows"
999 			" flow rules\n\n"
1000 
1001 			"flow shared_action {port_id} create"
1002 			" [action_id {shared_action_id}]"
1003 			" [ingress] [egress]"
1004 			" action {action} / end\n"
1005 			"    Create shared action.\n\n"
1006 
1007 			"flow shared_action {port_id} update"
1008 			" {shared_action_id} action {action} / end\n"
1009 			"    Update shared action.\n\n"
1010 
1011 			"flow shared_action {port_id} destroy"
1012 			" action_id {shared_action_id} [...]\n"
1013 			"    Destroy specific shared actions.\n\n"
1014 
1015 			"flow shared_action {port_id} query"
1016 			" {shared_action_id}\n"
1017 			"    Query an existing shared action.\n\n"
1018 
1019 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1020 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1021 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1022 			"       Configure the VXLAN encapsulation for flows.\n\n"
1023 
1024 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1025 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1026 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1027 			" eth-dst (eth-dst)\n"
1028 			"       Configure the VXLAN encapsulation for flows.\n\n"
1029 
1030 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1031 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1032 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1033 			" eth-dst (eth-dst)\n"
1034 			"       Configure the VXLAN encapsulation for flows.\n\n"
1035 
1036 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1037 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1038 			" (eth-dst)\n"
1039 			"       Configure the NVGRE encapsulation for flows.\n\n"
1040 
1041 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1042 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1043 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1044 			"       Configure the NVGRE encapsulation for flows.\n\n"
1045 
1046 			"set raw_encap {flow items}\n"
1047 			"	Configure the encapsulation with raw data.\n\n"
1048 
1049 			"set raw_decap {flow items}\n"
1050 			"	Configure the decapsulation with raw data.\n\n"
1051 
1052 		);
1053 	}
1054 
1055 	if (show_all || !strcmp(res->section, "traffic_management")) {
1056 		cmdline_printf(
1057 			cl,
1058 			"\n"
1059 			"Traffic Management:\n"
1060 			"--------------\n"
1061 			"show port tm cap (port_id)\n"
1062 			"       Display the port TM capability.\n\n"
1063 
1064 			"show port tm level cap (port_id) (level_id)\n"
1065 			"       Display the port TM hierarchical level capability.\n\n"
1066 
1067 			"show port tm node cap (port_id) (node_id)\n"
1068 			"       Display the port TM node capability.\n\n"
1069 
1070 			"show port tm node type (port_id) (node_id)\n"
1071 			"       Display the port TM node type.\n\n"
1072 
1073 			"show port tm node stats (port_id) (node_id) (clear)\n"
1074 			"       Display the port TM node stats.\n\n"
1075 
1076 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1077 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1078 			" (packet_length_adjust) (packet_mode)\n"
1079 			"       Add port tm node private shaper profile.\n\n"
1080 
1081 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1082 			"       Delete port tm node private shaper profile.\n\n"
1083 
1084 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1085 			" (shaper_profile_id)\n"
1086 			"       Add/update port tm node shared shaper.\n\n"
1087 
1088 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1089 			"       Delete port tm node shared shaper.\n\n"
1090 
1091 			"set port tm node shaper profile (port_id) (node_id)"
1092 			" (shaper_profile_id)\n"
1093 			"       Set port tm node shaper profile.\n\n"
1094 
1095 			"add port tm node wred profile (port_id) (wred_profile_id)"
1096 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1097 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1098 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1099 			"       Add port tm node wred profile.\n\n"
1100 
1101 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1102 			"       Delete port tm node wred profile.\n\n"
1103 
1104 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1105 			" (priority) (weight) (level_id) (shaper_profile_id)"
1106 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1107 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1108 			"       Add port tm nonleaf node.\n\n"
1109 
1110 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1111 			" (priority) (weight) (level_id) (shaper_profile_id)"
1112 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1113 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1114 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
1115 
1116 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1117 			" (priority) (weight) (level_id) (shaper_profile_id)"
1118 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1119 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 			"       Add port tm leaf node.\n\n"
1121 
1122 			"del port tm node (port_id) (node_id)\n"
1123 			"       Delete port tm node.\n\n"
1124 
1125 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1126 			" (priority) (weight)\n"
1127 			"       Set port tm node parent.\n\n"
1128 
1129 			"suspend port tm node (port_id) (node_id)"
1130 			"       Suspend tm node.\n\n"
1131 
1132 			"resume port tm node (port_id) (node_id)"
1133 			"       Resume tm node.\n\n"
1134 
1135 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1136 			"       Commit tm hierarchy.\n\n"
1137 
1138 			"set port tm mark ip_ecn (port) (green) (yellow)"
1139 			" (red)\n"
1140 			"    Enables/Disables the traffic management marking"
1141 			" for IP ECN (Explicit Congestion Notification)"
1142 			" packets on a given port\n\n"
1143 
1144 			"set port tm mark ip_dscp (port) (green) (yellow)"
1145 			" (red)\n"
1146 			"    Enables/Disables the traffic management marking"
1147 			" on the port for IP dscp packets\n\n"
1148 
1149 			"set port tm mark vlan_dei (port) (green) (yellow)"
1150 			" (red)\n"
1151 			"    Enables/Disables the traffic management marking"
1152 			" on the port for VLAN packets with DEI enabled\n\n"
1153 		);
1154 	}
1155 
1156 	if (show_all || !strcmp(res->section, "devices")) {
1157 		cmdline_printf(
1158 			cl,
1159 			"\n"
1160 			"Device Operations:\n"
1161 			"--------------\n"
1162 			"device detach (identifier)\n"
1163 			"       Detach device by identifier.\n\n"
1164 		);
1165 	}
1166 
1167 }
1168 
1169 cmdline_parse_token_string_t cmd_help_long_help =
1170 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1171 
1172 cmdline_parse_token_string_t cmd_help_long_section =
1173 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1174 			"all#control#display#config#"
1175 			"ports#registers#filters#traffic_management#devices");
1176 
1177 cmdline_parse_inst_t cmd_help_long = {
1178 	.f = cmd_help_long_parsed,
1179 	.data = NULL,
1180 	.help_str = "help all|control|display|config|ports|register|"
1181 		"filters|traffic_management|devices: "
1182 		"Show help",
1183 	.tokens = {
1184 		(void *)&cmd_help_long_help,
1185 		(void *)&cmd_help_long_section,
1186 		NULL,
1187 	},
1188 };
1189 
1190 
1191 /* *** start/stop/close all ports *** */
1192 struct cmd_operate_port_result {
1193 	cmdline_fixed_string_t keyword;
1194 	cmdline_fixed_string_t name;
1195 	cmdline_fixed_string_t value;
1196 };
1197 
1198 static void cmd_operate_port_parsed(void *parsed_result,
1199 				__rte_unused struct cmdline *cl,
1200 				__rte_unused void *data)
1201 {
1202 	struct cmd_operate_port_result *res = parsed_result;
1203 
1204 	if (!strcmp(res->name, "start"))
1205 		start_port(RTE_PORT_ALL);
1206 	else if (!strcmp(res->name, "stop"))
1207 		stop_port(RTE_PORT_ALL);
1208 	else if (!strcmp(res->name, "close"))
1209 		close_port(RTE_PORT_ALL);
1210 	else if (!strcmp(res->name, "reset"))
1211 		reset_port(RTE_PORT_ALL);
1212 	else
1213 		printf("Unknown parameter\n");
1214 }
1215 
1216 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1217 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1218 								"port");
1219 cmdline_parse_token_string_t cmd_operate_port_all_port =
1220 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1221 						"start#stop#close#reset");
1222 cmdline_parse_token_string_t cmd_operate_port_all_all =
1223 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1224 
1225 cmdline_parse_inst_t cmd_operate_port = {
1226 	.f = cmd_operate_port_parsed,
1227 	.data = NULL,
1228 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1229 	.tokens = {
1230 		(void *)&cmd_operate_port_all_cmd,
1231 		(void *)&cmd_operate_port_all_port,
1232 		(void *)&cmd_operate_port_all_all,
1233 		NULL,
1234 	},
1235 };
1236 
1237 /* *** start/stop/close specific port *** */
1238 struct cmd_operate_specific_port_result {
1239 	cmdline_fixed_string_t keyword;
1240 	cmdline_fixed_string_t name;
1241 	uint8_t value;
1242 };
1243 
1244 static void cmd_operate_specific_port_parsed(void *parsed_result,
1245 			__rte_unused struct cmdline *cl,
1246 				__rte_unused void *data)
1247 {
1248 	struct cmd_operate_specific_port_result *res = parsed_result;
1249 
1250 	if (!strcmp(res->name, "start"))
1251 		start_port(res->value);
1252 	else if (!strcmp(res->name, "stop"))
1253 		stop_port(res->value);
1254 	else if (!strcmp(res->name, "close"))
1255 		close_port(res->value);
1256 	else if (!strcmp(res->name, "reset"))
1257 		reset_port(res->value);
1258 	else
1259 		printf("Unknown parameter\n");
1260 }
1261 
1262 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1263 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1264 							keyword, "port");
1265 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1266 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1267 						name, "start#stop#close#reset");
1268 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1269 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1270 							value, RTE_UINT8);
1271 
1272 cmdline_parse_inst_t cmd_operate_specific_port = {
1273 	.f = cmd_operate_specific_port_parsed,
1274 	.data = NULL,
1275 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1276 	.tokens = {
1277 		(void *)&cmd_operate_specific_port_cmd,
1278 		(void *)&cmd_operate_specific_port_port,
1279 		(void *)&cmd_operate_specific_port_id,
1280 		NULL,
1281 	},
1282 };
1283 
1284 /* *** enable port setup (after attach) via iterator or event *** */
1285 struct cmd_set_port_setup_on_result {
1286 	cmdline_fixed_string_t set;
1287 	cmdline_fixed_string_t port;
1288 	cmdline_fixed_string_t setup;
1289 	cmdline_fixed_string_t on;
1290 	cmdline_fixed_string_t mode;
1291 };
1292 
1293 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1294 				__rte_unused struct cmdline *cl,
1295 				__rte_unused void *data)
1296 {
1297 	struct cmd_set_port_setup_on_result *res = parsed_result;
1298 
1299 	if (strcmp(res->mode, "event") == 0)
1300 		setup_on_probe_event = true;
1301 	else if (strcmp(res->mode, "iterator") == 0)
1302 		setup_on_probe_event = false;
1303 	else
1304 		printf("Unknown mode\n");
1305 }
1306 
1307 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1308 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1309 			set, "set");
1310 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1311 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1312 			port, "port");
1313 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1314 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1315 			setup, "setup");
1316 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1317 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1318 			on, "on");
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1320 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 			mode, "iterator#event");
1322 
1323 cmdline_parse_inst_t cmd_set_port_setup_on = {
1324 	.f = cmd_set_port_setup_on_parsed,
1325 	.data = NULL,
1326 	.help_str = "set port setup on iterator|event",
1327 	.tokens = {
1328 		(void *)&cmd_set_port_setup_on_set,
1329 		(void *)&cmd_set_port_setup_on_port,
1330 		(void *)&cmd_set_port_setup_on_setup,
1331 		(void *)&cmd_set_port_setup_on_on,
1332 		(void *)&cmd_set_port_setup_on_mode,
1333 		NULL,
1334 	},
1335 };
1336 
1337 /* *** attach a specified port *** */
1338 struct cmd_operate_attach_port_result {
1339 	cmdline_fixed_string_t port;
1340 	cmdline_fixed_string_t keyword;
1341 	cmdline_multi_string_t identifier;
1342 };
1343 
1344 static void cmd_operate_attach_port_parsed(void *parsed_result,
1345 				__rte_unused struct cmdline *cl,
1346 				__rte_unused void *data)
1347 {
1348 	struct cmd_operate_attach_port_result *res = parsed_result;
1349 
1350 	if (!strcmp(res->keyword, "attach"))
1351 		attach_port(res->identifier);
1352 	else
1353 		printf("Unknown parameter\n");
1354 }
1355 
1356 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1357 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1358 			port, "port");
1359 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1360 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1361 			keyword, "attach");
1362 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1363 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1364 			identifier, TOKEN_STRING_MULTI);
1365 
1366 cmdline_parse_inst_t cmd_operate_attach_port = {
1367 	.f = cmd_operate_attach_port_parsed,
1368 	.data = NULL,
1369 	.help_str = "port attach <identifier>: "
1370 		"(identifier: pci address or virtual dev name)",
1371 	.tokens = {
1372 		(void *)&cmd_operate_attach_port_port,
1373 		(void *)&cmd_operate_attach_port_keyword,
1374 		(void *)&cmd_operate_attach_port_identifier,
1375 		NULL,
1376 	},
1377 };
1378 
1379 /* *** detach a specified port *** */
1380 struct cmd_operate_detach_port_result {
1381 	cmdline_fixed_string_t port;
1382 	cmdline_fixed_string_t keyword;
1383 	portid_t port_id;
1384 };
1385 
1386 static void cmd_operate_detach_port_parsed(void *parsed_result,
1387 				__rte_unused struct cmdline *cl,
1388 				__rte_unused void *data)
1389 {
1390 	struct cmd_operate_detach_port_result *res = parsed_result;
1391 
1392 	if (!strcmp(res->keyword, "detach")) {
1393 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1394 		detach_port_device(res->port_id);
1395 	} else {
1396 		printf("Unknown parameter\n");
1397 	}
1398 }
1399 
1400 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1401 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1402 			port, "port");
1403 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1404 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1405 			keyword, "detach");
1406 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1407 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1408 			port_id, RTE_UINT16);
1409 
1410 cmdline_parse_inst_t cmd_operate_detach_port = {
1411 	.f = cmd_operate_detach_port_parsed,
1412 	.data = NULL,
1413 	.help_str = "port detach <port_id>",
1414 	.tokens = {
1415 		(void *)&cmd_operate_detach_port_port,
1416 		(void *)&cmd_operate_detach_port_keyword,
1417 		(void *)&cmd_operate_detach_port_port_id,
1418 		NULL,
1419 	},
1420 };
1421 
1422 /* *** detach device by identifier *** */
1423 struct cmd_operate_detach_device_result {
1424 	cmdline_fixed_string_t device;
1425 	cmdline_fixed_string_t keyword;
1426 	cmdline_fixed_string_t identifier;
1427 };
1428 
1429 static void cmd_operate_detach_device_parsed(void *parsed_result,
1430 				__rte_unused struct cmdline *cl,
1431 				__rte_unused void *data)
1432 {
1433 	struct cmd_operate_detach_device_result *res = parsed_result;
1434 
1435 	if (!strcmp(res->keyword, "detach"))
1436 		detach_devargs(res->identifier);
1437 	else
1438 		printf("Unknown parameter\n");
1439 }
1440 
1441 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1442 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1443 			device, "device");
1444 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1445 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1446 			keyword, "detach");
1447 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1448 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1449 			identifier, NULL);
1450 
1451 cmdline_parse_inst_t cmd_operate_detach_device = {
1452 	.f = cmd_operate_detach_device_parsed,
1453 	.data = NULL,
1454 	.help_str = "device detach <identifier>:"
1455 		"(identifier: pci address or virtual dev name)",
1456 	.tokens = {
1457 		(void *)&cmd_operate_detach_device_device,
1458 		(void *)&cmd_operate_detach_device_keyword,
1459 		(void *)&cmd_operate_detach_device_identifier,
1460 		NULL,
1461 	},
1462 };
1463 /* *** configure speed for all ports *** */
1464 struct cmd_config_speed_all {
1465 	cmdline_fixed_string_t port;
1466 	cmdline_fixed_string_t keyword;
1467 	cmdline_fixed_string_t all;
1468 	cmdline_fixed_string_t item1;
1469 	cmdline_fixed_string_t item2;
1470 	cmdline_fixed_string_t value1;
1471 	cmdline_fixed_string_t value2;
1472 };
1473 
1474 static int
1475 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1476 {
1477 
1478 	int duplex;
1479 
1480 	if (!strcmp(duplexstr, "half")) {
1481 		duplex = ETH_LINK_HALF_DUPLEX;
1482 	} else if (!strcmp(duplexstr, "full")) {
1483 		duplex = ETH_LINK_FULL_DUPLEX;
1484 	} else if (!strcmp(duplexstr, "auto")) {
1485 		duplex = ETH_LINK_FULL_DUPLEX;
1486 	} else {
1487 		printf("Unknown duplex parameter\n");
1488 		return -1;
1489 	}
1490 
1491 	if (!strcmp(speedstr, "10")) {
1492 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1493 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1494 	} else if (!strcmp(speedstr, "100")) {
1495 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1496 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1497 	} else {
1498 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1499 			printf("Invalid speed/duplex parameters\n");
1500 			return -1;
1501 		}
1502 		if (!strcmp(speedstr, "1000")) {
1503 			*speed = ETH_LINK_SPEED_1G;
1504 		} else if (!strcmp(speedstr, "10000")) {
1505 			*speed = ETH_LINK_SPEED_10G;
1506 		} else if (!strcmp(speedstr, "25000")) {
1507 			*speed = ETH_LINK_SPEED_25G;
1508 		} else if (!strcmp(speedstr, "40000")) {
1509 			*speed = ETH_LINK_SPEED_40G;
1510 		} else if (!strcmp(speedstr, "50000")) {
1511 			*speed = ETH_LINK_SPEED_50G;
1512 		} else if (!strcmp(speedstr, "100000")) {
1513 			*speed = ETH_LINK_SPEED_100G;
1514 		} else if (!strcmp(speedstr, "200000")) {
1515 			*speed = ETH_LINK_SPEED_200G;
1516 		} else if (!strcmp(speedstr, "auto")) {
1517 			*speed = ETH_LINK_SPEED_AUTONEG;
1518 		} else {
1519 			printf("Unknown speed parameter\n");
1520 			return -1;
1521 		}
1522 	}
1523 
1524 	return 0;
1525 }
1526 
1527 static void
1528 cmd_config_speed_all_parsed(void *parsed_result,
1529 			__rte_unused struct cmdline *cl,
1530 			__rte_unused void *data)
1531 {
1532 	struct cmd_config_speed_all *res = parsed_result;
1533 	uint32_t link_speed;
1534 	portid_t pid;
1535 
1536 	if (!all_ports_stopped()) {
1537 		printf("Please stop all ports first\n");
1538 		return;
1539 	}
1540 
1541 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1542 			&link_speed) < 0)
1543 		return;
1544 
1545 	RTE_ETH_FOREACH_DEV(pid) {
1546 		ports[pid].dev_conf.link_speeds = link_speed;
1547 	}
1548 
1549 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1550 }
1551 
1552 cmdline_parse_token_string_t cmd_config_speed_all_port =
1553 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1554 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1555 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1556 							"config");
1557 cmdline_parse_token_string_t cmd_config_speed_all_all =
1558 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1559 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1560 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1561 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1562 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1563 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1564 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1565 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1566 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1567 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1568 						"half#full#auto");
1569 
1570 cmdline_parse_inst_t cmd_config_speed_all = {
1571 	.f = cmd_config_speed_all_parsed,
1572 	.data = NULL,
1573 	.help_str = "port config all speed "
1574 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1575 							"half|full|auto",
1576 	.tokens = {
1577 		(void *)&cmd_config_speed_all_port,
1578 		(void *)&cmd_config_speed_all_keyword,
1579 		(void *)&cmd_config_speed_all_all,
1580 		(void *)&cmd_config_speed_all_item1,
1581 		(void *)&cmd_config_speed_all_value1,
1582 		(void *)&cmd_config_speed_all_item2,
1583 		(void *)&cmd_config_speed_all_value2,
1584 		NULL,
1585 	},
1586 };
1587 
1588 /* *** configure speed for specific port *** */
1589 struct cmd_config_speed_specific {
1590 	cmdline_fixed_string_t port;
1591 	cmdline_fixed_string_t keyword;
1592 	portid_t id;
1593 	cmdline_fixed_string_t item1;
1594 	cmdline_fixed_string_t item2;
1595 	cmdline_fixed_string_t value1;
1596 	cmdline_fixed_string_t value2;
1597 };
1598 
1599 static void
1600 cmd_config_speed_specific_parsed(void *parsed_result,
1601 				__rte_unused struct cmdline *cl,
1602 				__rte_unused void *data)
1603 {
1604 	struct cmd_config_speed_specific *res = parsed_result;
1605 	uint32_t link_speed;
1606 
1607 	if (!all_ports_stopped()) {
1608 		printf("Please stop all ports first\n");
1609 		return;
1610 	}
1611 
1612 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1613 		return;
1614 
1615 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1616 			&link_speed) < 0)
1617 		return;
1618 
1619 	ports[res->id].dev_conf.link_speeds = link_speed;
1620 
1621 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1622 }
1623 
1624 
1625 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1626 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1627 								"port");
1628 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1629 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1630 								"config");
1631 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1632 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1633 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1634 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1635 								"speed");
1636 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1637 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1638 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1639 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1640 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1641 								"duplex");
1642 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1643 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1644 							"half#full#auto");
1645 
1646 cmdline_parse_inst_t cmd_config_speed_specific = {
1647 	.f = cmd_config_speed_specific_parsed,
1648 	.data = NULL,
1649 	.help_str = "port config <port_id> speed "
1650 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1651 							"half|full|auto",
1652 	.tokens = {
1653 		(void *)&cmd_config_speed_specific_port,
1654 		(void *)&cmd_config_speed_specific_keyword,
1655 		(void *)&cmd_config_speed_specific_id,
1656 		(void *)&cmd_config_speed_specific_item1,
1657 		(void *)&cmd_config_speed_specific_value1,
1658 		(void *)&cmd_config_speed_specific_item2,
1659 		(void *)&cmd_config_speed_specific_value2,
1660 		NULL,
1661 	},
1662 };
1663 
1664 /* *** configure loopback for all ports *** */
1665 struct cmd_config_loopback_all {
1666 	cmdline_fixed_string_t port;
1667 	cmdline_fixed_string_t keyword;
1668 	cmdline_fixed_string_t all;
1669 	cmdline_fixed_string_t item;
1670 	uint32_t mode;
1671 };
1672 
1673 static void
1674 cmd_config_loopback_all_parsed(void *parsed_result,
1675 			__rte_unused struct cmdline *cl,
1676 			__rte_unused void *data)
1677 {
1678 	struct cmd_config_loopback_all *res = parsed_result;
1679 	portid_t pid;
1680 
1681 	if (!all_ports_stopped()) {
1682 		printf("Please stop all ports first\n");
1683 		return;
1684 	}
1685 
1686 	RTE_ETH_FOREACH_DEV(pid) {
1687 		ports[pid].dev_conf.lpbk_mode = res->mode;
1688 	}
1689 
1690 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1691 }
1692 
1693 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1694 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1695 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1696 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1697 							"config");
1698 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1699 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1700 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1701 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1702 							"loopback");
1703 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1704 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1705 
1706 cmdline_parse_inst_t cmd_config_loopback_all = {
1707 	.f = cmd_config_loopback_all_parsed,
1708 	.data = NULL,
1709 	.help_str = "port config all loopback <mode>",
1710 	.tokens = {
1711 		(void *)&cmd_config_loopback_all_port,
1712 		(void *)&cmd_config_loopback_all_keyword,
1713 		(void *)&cmd_config_loopback_all_all,
1714 		(void *)&cmd_config_loopback_all_item,
1715 		(void *)&cmd_config_loopback_all_mode,
1716 		NULL,
1717 	},
1718 };
1719 
1720 /* *** configure loopback for specific port *** */
1721 struct cmd_config_loopback_specific {
1722 	cmdline_fixed_string_t port;
1723 	cmdline_fixed_string_t keyword;
1724 	uint16_t port_id;
1725 	cmdline_fixed_string_t item;
1726 	uint32_t mode;
1727 };
1728 
1729 static void
1730 cmd_config_loopback_specific_parsed(void *parsed_result,
1731 				__rte_unused struct cmdline *cl,
1732 				__rte_unused void *data)
1733 {
1734 	struct cmd_config_loopback_specific *res = parsed_result;
1735 
1736 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1737 		return;
1738 
1739 	if (!port_is_stopped(res->port_id)) {
1740 		printf("Please stop port %u first\n", res->port_id);
1741 		return;
1742 	}
1743 
1744 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1745 
1746 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1747 }
1748 
1749 
1750 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1751 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1752 								"port");
1753 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1754 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1755 								"config");
1756 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1757 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1758 								RTE_UINT16);
1759 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1760 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1761 								"loopback");
1762 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1763 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1764 			      RTE_UINT32);
1765 
1766 cmdline_parse_inst_t cmd_config_loopback_specific = {
1767 	.f = cmd_config_loopback_specific_parsed,
1768 	.data = NULL,
1769 	.help_str = "port config <port_id> loopback <mode>",
1770 	.tokens = {
1771 		(void *)&cmd_config_loopback_specific_port,
1772 		(void *)&cmd_config_loopback_specific_keyword,
1773 		(void *)&cmd_config_loopback_specific_id,
1774 		(void *)&cmd_config_loopback_specific_item,
1775 		(void *)&cmd_config_loopback_specific_mode,
1776 		NULL,
1777 	},
1778 };
1779 
1780 /* *** configure txq/rxq, txd/rxd *** */
1781 struct cmd_config_rx_tx {
1782 	cmdline_fixed_string_t port;
1783 	cmdline_fixed_string_t keyword;
1784 	cmdline_fixed_string_t all;
1785 	cmdline_fixed_string_t name;
1786 	uint16_t value;
1787 };
1788 
1789 static void
1790 cmd_config_rx_tx_parsed(void *parsed_result,
1791 			__rte_unused struct cmdline *cl,
1792 			__rte_unused void *data)
1793 {
1794 	struct cmd_config_rx_tx *res = parsed_result;
1795 
1796 	if (!all_ports_stopped()) {
1797 		printf("Please stop all ports first\n");
1798 		return;
1799 	}
1800 	if (!strcmp(res->name, "rxq")) {
1801 		if (!res->value && !nb_txq) {
1802 			printf("Warning: Either rx or tx queues should be non zero\n");
1803 			return;
1804 		}
1805 		if (check_nb_rxq(res->value) != 0)
1806 			return;
1807 		nb_rxq = res->value;
1808 	}
1809 	else if (!strcmp(res->name, "txq")) {
1810 		if (!res->value && !nb_rxq) {
1811 			printf("Warning: Either rx or tx queues should be non zero\n");
1812 			return;
1813 		}
1814 		if (check_nb_txq(res->value) != 0)
1815 			return;
1816 		nb_txq = res->value;
1817 	}
1818 	else if (!strcmp(res->name, "rxd")) {
1819 		if (check_nb_rxd(res->value) != 0)
1820 			return;
1821 		nb_rxd = res->value;
1822 	} else if (!strcmp(res->name, "txd")) {
1823 		if (check_nb_txd(res->value) != 0)
1824 			return;
1825 
1826 		nb_txd = res->value;
1827 	} else {
1828 		printf("Unknown parameter\n");
1829 		return;
1830 	}
1831 
1832 	fwd_config_setup();
1833 
1834 	init_port_config();
1835 
1836 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1837 }
1838 
1839 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1840 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1841 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1842 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1843 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1844 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1845 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1846 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1847 						"rxq#txq#rxd#txd");
1848 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1849 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1850 
1851 cmdline_parse_inst_t cmd_config_rx_tx = {
1852 	.f = cmd_config_rx_tx_parsed,
1853 	.data = NULL,
1854 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1855 	.tokens = {
1856 		(void *)&cmd_config_rx_tx_port,
1857 		(void *)&cmd_config_rx_tx_keyword,
1858 		(void *)&cmd_config_rx_tx_all,
1859 		(void *)&cmd_config_rx_tx_name,
1860 		(void *)&cmd_config_rx_tx_value,
1861 		NULL,
1862 	},
1863 };
1864 
1865 /* *** config max packet length *** */
1866 struct cmd_config_max_pkt_len_result {
1867 	cmdline_fixed_string_t port;
1868 	cmdline_fixed_string_t keyword;
1869 	cmdline_fixed_string_t all;
1870 	cmdline_fixed_string_t name;
1871 	uint32_t value;
1872 };
1873 
1874 static void
1875 cmd_config_max_pkt_len_parsed(void *parsed_result,
1876 				__rte_unused struct cmdline *cl,
1877 				__rte_unused void *data)
1878 {
1879 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1880 	portid_t pid;
1881 
1882 	if (!all_ports_stopped()) {
1883 		printf("Please stop all ports first\n");
1884 		return;
1885 	}
1886 
1887 	RTE_ETH_FOREACH_DEV(pid) {
1888 		struct rte_port *port = &ports[pid];
1889 
1890 		if (!strcmp(res->name, "max-pkt-len")) {
1891 			if (res->value < RTE_ETHER_MIN_LEN) {
1892 				printf("max-pkt-len can not be less than %d\n",
1893 						RTE_ETHER_MIN_LEN);
1894 				return;
1895 			}
1896 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1897 				return;
1898 
1899 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1900 		} else {
1901 			printf("Unknown parameter\n");
1902 			return;
1903 		}
1904 	}
1905 
1906 	init_port_config();
1907 
1908 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1909 }
1910 
1911 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1912 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1913 								"port");
1914 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1915 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1916 								"config");
1917 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1918 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1919 								"all");
1920 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1921 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1922 								"max-pkt-len");
1923 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1924 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1925 								RTE_UINT32);
1926 
1927 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1928 	.f = cmd_config_max_pkt_len_parsed,
1929 	.data = NULL,
1930 	.help_str = "port config all max-pkt-len <value>",
1931 	.tokens = {
1932 		(void *)&cmd_config_max_pkt_len_port,
1933 		(void *)&cmd_config_max_pkt_len_keyword,
1934 		(void *)&cmd_config_max_pkt_len_all,
1935 		(void *)&cmd_config_max_pkt_len_name,
1936 		(void *)&cmd_config_max_pkt_len_value,
1937 		NULL,
1938 	},
1939 };
1940 
1941 /* *** config max LRO aggregated packet size *** */
1942 struct cmd_config_max_lro_pkt_size_result {
1943 	cmdline_fixed_string_t port;
1944 	cmdline_fixed_string_t keyword;
1945 	cmdline_fixed_string_t all;
1946 	cmdline_fixed_string_t name;
1947 	uint32_t value;
1948 };
1949 
1950 static void
1951 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1952 				__rte_unused struct cmdline *cl,
1953 				__rte_unused void *data)
1954 {
1955 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1956 	portid_t pid;
1957 
1958 	if (!all_ports_stopped()) {
1959 		printf("Please stop all ports first\n");
1960 		return;
1961 	}
1962 
1963 	RTE_ETH_FOREACH_DEV(pid) {
1964 		struct rte_port *port = &ports[pid];
1965 
1966 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1967 			if (res->value ==
1968 					port->dev_conf.rxmode.max_lro_pkt_size)
1969 				return;
1970 
1971 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1972 		} else {
1973 			printf("Unknown parameter\n");
1974 			return;
1975 		}
1976 	}
1977 
1978 	init_port_config();
1979 
1980 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1981 }
1982 
1983 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1984 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1985 				 port, "port");
1986 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1987 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1988 				 keyword, "config");
1989 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
1990 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1991 				 all, "all");
1992 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
1993 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1994 				 name, "max-lro-pkt-size");
1995 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
1996 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1997 			      value, RTE_UINT32);
1998 
1999 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2000 	.f = cmd_config_max_lro_pkt_size_parsed,
2001 	.data = NULL,
2002 	.help_str = "port config all max-lro-pkt-size <value>",
2003 	.tokens = {
2004 		(void *)&cmd_config_max_lro_pkt_size_port,
2005 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2006 		(void *)&cmd_config_max_lro_pkt_size_all,
2007 		(void *)&cmd_config_max_lro_pkt_size_name,
2008 		(void *)&cmd_config_max_lro_pkt_size_value,
2009 		NULL,
2010 	},
2011 };
2012 
2013 /* *** configure port MTU *** */
2014 struct cmd_config_mtu_result {
2015 	cmdline_fixed_string_t port;
2016 	cmdline_fixed_string_t keyword;
2017 	cmdline_fixed_string_t mtu;
2018 	portid_t port_id;
2019 	uint16_t value;
2020 };
2021 
2022 static void
2023 cmd_config_mtu_parsed(void *parsed_result,
2024 		      __rte_unused struct cmdline *cl,
2025 		      __rte_unused void *data)
2026 {
2027 	struct cmd_config_mtu_result *res = parsed_result;
2028 
2029 	if (res->value < RTE_ETHER_MIN_LEN) {
2030 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2031 		return;
2032 	}
2033 	port_mtu_set(res->port_id, res->value);
2034 }
2035 
2036 cmdline_parse_token_string_t cmd_config_mtu_port =
2037 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2038 				 "port");
2039 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2040 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2041 				 "config");
2042 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2043 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2044 				 "mtu");
2045 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2046 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2047 				 RTE_UINT16);
2048 cmdline_parse_token_num_t cmd_config_mtu_value =
2049 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2050 				 RTE_UINT16);
2051 
2052 cmdline_parse_inst_t cmd_config_mtu = {
2053 	.f = cmd_config_mtu_parsed,
2054 	.data = NULL,
2055 	.help_str = "port config mtu <port_id> <value>",
2056 	.tokens = {
2057 		(void *)&cmd_config_mtu_port,
2058 		(void *)&cmd_config_mtu_keyword,
2059 		(void *)&cmd_config_mtu_mtu,
2060 		(void *)&cmd_config_mtu_port_id,
2061 		(void *)&cmd_config_mtu_value,
2062 		NULL,
2063 	},
2064 };
2065 
2066 /* *** configure rx mode *** */
2067 struct cmd_config_rx_mode_flag {
2068 	cmdline_fixed_string_t port;
2069 	cmdline_fixed_string_t keyword;
2070 	cmdline_fixed_string_t all;
2071 	cmdline_fixed_string_t name;
2072 	cmdline_fixed_string_t value;
2073 };
2074 
2075 static void
2076 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2077 				__rte_unused struct cmdline *cl,
2078 				__rte_unused void *data)
2079 {
2080 	struct cmd_config_rx_mode_flag *res = parsed_result;
2081 
2082 	if (!all_ports_stopped()) {
2083 		printf("Please stop all ports first\n");
2084 		return;
2085 	}
2086 
2087 	if (!strcmp(res->name, "drop-en")) {
2088 		if (!strcmp(res->value, "on"))
2089 			rx_drop_en = 1;
2090 		else if (!strcmp(res->value, "off"))
2091 			rx_drop_en = 0;
2092 		else {
2093 			printf("Unknown parameter\n");
2094 			return;
2095 		}
2096 	} else {
2097 		printf("Unknown parameter\n");
2098 		return;
2099 	}
2100 
2101 	init_port_config();
2102 
2103 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2104 }
2105 
2106 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2107 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2108 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2109 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2110 								"config");
2111 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2112 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2113 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2114 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2115 					"drop-en");
2116 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2117 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2118 							"on#off");
2119 
2120 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2121 	.f = cmd_config_rx_mode_flag_parsed,
2122 	.data = NULL,
2123 	.help_str = "port config all drop-en on|off",
2124 	.tokens = {
2125 		(void *)&cmd_config_rx_mode_flag_port,
2126 		(void *)&cmd_config_rx_mode_flag_keyword,
2127 		(void *)&cmd_config_rx_mode_flag_all,
2128 		(void *)&cmd_config_rx_mode_flag_name,
2129 		(void *)&cmd_config_rx_mode_flag_value,
2130 		NULL,
2131 	},
2132 };
2133 
2134 /* *** configure rss *** */
2135 struct cmd_config_rss {
2136 	cmdline_fixed_string_t port;
2137 	cmdline_fixed_string_t keyword;
2138 	cmdline_fixed_string_t all;
2139 	cmdline_fixed_string_t name;
2140 	cmdline_fixed_string_t value;
2141 };
2142 
2143 static void
2144 cmd_config_rss_parsed(void *parsed_result,
2145 			__rte_unused struct cmdline *cl,
2146 			__rte_unused void *data)
2147 {
2148 	struct cmd_config_rss *res = parsed_result;
2149 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2150 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2151 	int use_default = 0;
2152 	int all_updated = 1;
2153 	int diag;
2154 	uint16_t i;
2155 	int ret;
2156 
2157 	if (!strcmp(res->value, "all"))
2158 		rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2159 			ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2160 			ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2161 			ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2162 			ETH_RSS_ECPRI;
2163 	else if (!strcmp(res->value, "eth"))
2164 		rss_conf.rss_hf = ETH_RSS_ETH;
2165 	else if (!strcmp(res->value, "vlan"))
2166 		rss_conf.rss_hf = ETH_RSS_VLAN;
2167 	else if (!strcmp(res->value, "ip"))
2168 		rss_conf.rss_hf = ETH_RSS_IP;
2169 	else if (!strcmp(res->value, "udp"))
2170 		rss_conf.rss_hf = ETH_RSS_UDP;
2171 	else if (!strcmp(res->value, "tcp"))
2172 		rss_conf.rss_hf = ETH_RSS_TCP;
2173 	else if (!strcmp(res->value, "sctp"))
2174 		rss_conf.rss_hf = ETH_RSS_SCTP;
2175 	else if (!strcmp(res->value, "ether"))
2176 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2177 	else if (!strcmp(res->value, "port"))
2178 		rss_conf.rss_hf = ETH_RSS_PORT;
2179 	else if (!strcmp(res->value, "vxlan"))
2180 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2181 	else if (!strcmp(res->value, "geneve"))
2182 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2183 	else if (!strcmp(res->value, "nvgre"))
2184 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2185 	else if (!strcmp(res->value, "l3-pre32"))
2186 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2187 	else if (!strcmp(res->value, "l3-pre40"))
2188 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2189 	else if (!strcmp(res->value, "l3-pre48"))
2190 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2191 	else if (!strcmp(res->value, "l3-pre56"))
2192 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2193 	else if (!strcmp(res->value, "l3-pre64"))
2194 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2195 	else if (!strcmp(res->value, "l3-pre96"))
2196 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2197 	else if (!strcmp(res->value, "l3-src-only"))
2198 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2199 	else if (!strcmp(res->value, "l3-dst-only"))
2200 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2201 	else if (!strcmp(res->value, "l4-src-only"))
2202 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2203 	else if (!strcmp(res->value, "l4-dst-only"))
2204 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2205 	else if (!strcmp(res->value, "l2-src-only"))
2206 		rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2207 	else if (!strcmp(res->value, "l2-dst-only"))
2208 		rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2209 	else if (!strcmp(res->value, "l2tpv3"))
2210 		rss_conf.rss_hf = ETH_RSS_L2TPV3;
2211 	else if (!strcmp(res->value, "esp"))
2212 		rss_conf.rss_hf = ETH_RSS_ESP;
2213 	else if (!strcmp(res->value, "ah"))
2214 		rss_conf.rss_hf = ETH_RSS_AH;
2215 	else if (!strcmp(res->value, "pfcp"))
2216 		rss_conf.rss_hf = ETH_RSS_PFCP;
2217 	else if (!strcmp(res->value, "pppoe"))
2218 		rss_conf.rss_hf = ETH_RSS_PPPOE;
2219 	else if (!strcmp(res->value, "gtpu"))
2220 		rss_conf.rss_hf = ETH_RSS_GTPU;
2221 	else if (!strcmp(res->value, "ecpri"))
2222 		rss_conf.rss_hf = ETH_RSS_ECPRI;
2223 	else if (!strcmp(res->value, "mpls"))
2224 		rss_conf.rss_hf = ETH_RSS_MPLS;
2225 	else if (!strcmp(res->value, "none"))
2226 		rss_conf.rss_hf = 0;
2227 	else if (!strcmp(res->value, "level-default")) {
2228 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2229 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2230 	} else if (!strcmp(res->value, "level-outer")) {
2231 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2232 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2233 	} else if (!strcmp(res->value, "level-inner")) {
2234 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2235 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2236 	} else if (!strcmp(res->value, "default"))
2237 		use_default = 1;
2238 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2239 						atoi(res->value) < 64)
2240 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2241 	else {
2242 		printf("Unknown parameter\n");
2243 		return;
2244 	}
2245 	rss_conf.rss_key = NULL;
2246 	/* Update global configuration for RSS types. */
2247 	RTE_ETH_FOREACH_DEV(i) {
2248 		struct rte_eth_rss_conf local_rss_conf;
2249 
2250 		ret = eth_dev_info_get_print_err(i, &dev_info);
2251 		if (ret != 0)
2252 			return;
2253 
2254 		if (use_default)
2255 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2256 
2257 		local_rss_conf = rss_conf;
2258 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2259 			dev_info.flow_type_rss_offloads;
2260 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2261 			printf("Port %u modified RSS hash function based on hardware support,"
2262 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2263 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2264 		}
2265 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2266 		if (diag < 0) {
2267 			all_updated = 0;
2268 			printf("Configuration of RSS hash at ethernet port %d "
2269 				"failed with error (%d): %s.\n",
2270 				i, -diag, strerror(-diag));
2271 		}
2272 	}
2273 	if (all_updated && !use_default) {
2274 		rss_hf = rss_conf.rss_hf;
2275 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2276 	}
2277 }
2278 
2279 cmdline_parse_token_string_t cmd_config_rss_port =
2280 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2281 cmdline_parse_token_string_t cmd_config_rss_keyword =
2282 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2283 cmdline_parse_token_string_t cmd_config_rss_all =
2284 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2285 cmdline_parse_token_string_t cmd_config_rss_name =
2286 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2287 cmdline_parse_token_string_t cmd_config_rss_value =
2288 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2289 
2290 cmdline_parse_inst_t cmd_config_rss = {
2291 	.f = cmd_config_rss_parsed,
2292 	.data = NULL,
2293 	.help_str = "port config all rss "
2294 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2295 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2296 		"level-outer|level-inner|<flowtype_id>",
2297 	.tokens = {
2298 		(void *)&cmd_config_rss_port,
2299 		(void *)&cmd_config_rss_keyword,
2300 		(void *)&cmd_config_rss_all,
2301 		(void *)&cmd_config_rss_name,
2302 		(void *)&cmd_config_rss_value,
2303 		NULL,
2304 	},
2305 };
2306 
2307 /* *** configure rss hash key *** */
2308 struct cmd_config_rss_hash_key {
2309 	cmdline_fixed_string_t port;
2310 	cmdline_fixed_string_t config;
2311 	portid_t port_id;
2312 	cmdline_fixed_string_t rss_hash_key;
2313 	cmdline_fixed_string_t rss_type;
2314 	cmdline_fixed_string_t key;
2315 };
2316 
2317 static uint8_t
2318 hexa_digit_to_value(char hexa_digit)
2319 {
2320 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2321 		return (uint8_t) (hexa_digit - '0');
2322 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2323 		return (uint8_t) ((hexa_digit - 'a') + 10);
2324 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2325 		return (uint8_t) ((hexa_digit - 'A') + 10);
2326 	/* Invalid hexa digit */
2327 	return 0xFF;
2328 }
2329 
2330 static uint8_t
2331 parse_and_check_key_hexa_digit(char *key, int idx)
2332 {
2333 	uint8_t hexa_v;
2334 
2335 	hexa_v = hexa_digit_to_value(key[idx]);
2336 	if (hexa_v == 0xFF)
2337 		printf("invalid key: character %c at position %d is not a "
2338 		       "valid hexa digit\n", key[idx], idx);
2339 	return hexa_v;
2340 }
2341 
2342 static void
2343 cmd_config_rss_hash_key_parsed(void *parsed_result,
2344 			       __rte_unused struct cmdline *cl,
2345 			       __rte_unused void *data)
2346 {
2347 	struct cmd_config_rss_hash_key *res = parsed_result;
2348 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2349 	uint8_t xdgt0;
2350 	uint8_t xdgt1;
2351 	int i;
2352 	struct rte_eth_dev_info dev_info;
2353 	uint8_t hash_key_size;
2354 	uint32_t key_len;
2355 	int ret;
2356 
2357 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2358 	if (ret != 0)
2359 		return;
2360 
2361 	if (dev_info.hash_key_size > 0 &&
2362 			dev_info.hash_key_size <= sizeof(hash_key))
2363 		hash_key_size = dev_info.hash_key_size;
2364 	else {
2365 		printf("dev_info did not provide a valid hash key size\n");
2366 		return;
2367 	}
2368 	/* Check the length of the RSS hash key */
2369 	key_len = strlen(res->key);
2370 	if (key_len != (hash_key_size * 2)) {
2371 		printf("key length: %d invalid - key must be a string of %d"
2372 			   " hexa-decimal numbers\n",
2373 			   (int) key_len, hash_key_size * 2);
2374 		return;
2375 	}
2376 	/* Translate RSS hash key into binary representation */
2377 	for (i = 0; i < hash_key_size; i++) {
2378 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2379 		if (xdgt0 == 0xFF)
2380 			return;
2381 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2382 		if (xdgt1 == 0xFF)
2383 			return;
2384 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2385 	}
2386 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2387 			hash_key_size);
2388 }
2389 
2390 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2391 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2392 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2393 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2394 				 "config");
2395 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2396 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2397 				 RTE_UINT16);
2398 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2399 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2400 				 rss_hash_key, "rss-hash-key");
2401 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2402 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2403 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2404 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2405 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2406 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2407 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2408 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2409 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri");
2410 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2411 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2412 
2413 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2414 	.f = cmd_config_rss_hash_key_parsed,
2415 	.data = NULL,
2416 	.help_str = "port config <port_id> rss-hash-key "
2417 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2418 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2419 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2420 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2421 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2422 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri "
2423 		"<string of hex digits (variable length, NIC dependent)>",
2424 	.tokens = {
2425 		(void *)&cmd_config_rss_hash_key_port,
2426 		(void *)&cmd_config_rss_hash_key_config,
2427 		(void *)&cmd_config_rss_hash_key_port_id,
2428 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2429 		(void *)&cmd_config_rss_hash_key_rss_type,
2430 		(void *)&cmd_config_rss_hash_key_value,
2431 		NULL,
2432 	},
2433 };
2434 
2435 /* *** configure port rxq/txq ring size *** */
2436 struct cmd_config_rxtx_ring_size {
2437 	cmdline_fixed_string_t port;
2438 	cmdline_fixed_string_t config;
2439 	portid_t portid;
2440 	cmdline_fixed_string_t rxtxq;
2441 	uint16_t qid;
2442 	cmdline_fixed_string_t rsize;
2443 	uint16_t size;
2444 };
2445 
2446 static void
2447 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2448 				 __rte_unused struct cmdline *cl,
2449 				 __rte_unused void *data)
2450 {
2451 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2452 	struct rte_port *port;
2453 	uint8_t isrx;
2454 
2455 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2456 		return;
2457 
2458 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2459 		printf("Invalid port id\n");
2460 		return;
2461 	}
2462 
2463 	port = &ports[res->portid];
2464 
2465 	if (!strcmp(res->rxtxq, "rxq"))
2466 		isrx = 1;
2467 	else if (!strcmp(res->rxtxq, "txq"))
2468 		isrx = 0;
2469 	else {
2470 		printf("Unknown parameter\n");
2471 		return;
2472 	}
2473 
2474 	if (isrx && rx_queue_id_is_invalid(res->qid))
2475 		return;
2476 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2477 		return;
2478 
2479 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2480 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2481 		       rx_free_thresh);
2482 		return;
2483 	}
2484 
2485 	if (isrx)
2486 		port->nb_rx_desc[res->qid] = res->size;
2487 	else
2488 		port->nb_tx_desc[res->qid] = res->size;
2489 
2490 	cmd_reconfig_device_queue(res->portid, 0, 1);
2491 }
2492 
2493 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2494 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2495 				 port, "port");
2496 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2497 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2498 				 config, "config");
2499 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2500 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2501 				 portid, RTE_UINT16);
2502 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2503 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2504 				 rxtxq, "rxq#txq");
2505 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2506 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2507 			      qid, RTE_UINT16);
2508 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2509 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2510 				 rsize, "ring_size");
2511 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2512 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2513 			      size, RTE_UINT16);
2514 
2515 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2516 	.f = cmd_config_rxtx_ring_size_parsed,
2517 	.data = NULL,
2518 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2519 	.tokens = {
2520 		(void *)&cmd_config_rxtx_ring_size_port,
2521 		(void *)&cmd_config_rxtx_ring_size_config,
2522 		(void *)&cmd_config_rxtx_ring_size_portid,
2523 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2524 		(void *)&cmd_config_rxtx_ring_size_qid,
2525 		(void *)&cmd_config_rxtx_ring_size_rsize,
2526 		(void *)&cmd_config_rxtx_ring_size_size,
2527 		NULL,
2528 	},
2529 };
2530 
2531 /* *** configure port rxq/txq start/stop *** */
2532 struct cmd_config_rxtx_queue {
2533 	cmdline_fixed_string_t port;
2534 	portid_t portid;
2535 	cmdline_fixed_string_t rxtxq;
2536 	uint16_t qid;
2537 	cmdline_fixed_string_t opname;
2538 };
2539 
2540 static void
2541 cmd_config_rxtx_queue_parsed(void *parsed_result,
2542 			__rte_unused struct cmdline *cl,
2543 			__rte_unused void *data)
2544 {
2545 	struct cmd_config_rxtx_queue *res = parsed_result;
2546 	uint8_t isrx;
2547 	uint8_t isstart;
2548 	int ret = 0;
2549 
2550 	if (test_done == 0) {
2551 		printf("Please stop forwarding first\n");
2552 		return;
2553 	}
2554 
2555 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2556 		return;
2557 
2558 	if (port_is_started(res->portid) != 1) {
2559 		printf("Please start port %u first\n", res->portid);
2560 		return;
2561 	}
2562 
2563 	if (!strcmp(res->rxtxq, "rxq"))
2564 		isrx = 1;
2565 	else if (!strcmp(res->rxtxq, "txq"))
2566 		isrx = 0;
2567 	else {
2568 		printf("Unknown parameter\n");
2569 		return;
2570 	}
2571 
2572 	if (isrx && rx_queue_id_is_invalid(res->qid))
2573 		return;
2574 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2575 		return;
2576 
2577 	if (!strcmp(res->opname, "start"))
2578 		isstart = 1;
2579 	else if (!strcmp(res->opname, "stop"))
2580 		isstart = 0;
2581 	else {
2582 		printf("Unknown parameter\n");
2583 		return;
2584 	}
2585 
2586 	if (isstart && isrx)
2587 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2588 	else if (!isstart && isrx)
2589 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2590 	else if (isstart && !isrx)
2591 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2592 	else
2593 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2594 
2595 	if (ret == -ENOTSUP)
2596 		printf("Function not supported in PMD driver\n");
2597 }
2598 
2599 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2600 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2601 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2602 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2603 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2604 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2605 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2606 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2607 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2608 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2609 						"start#stop");
2610 
2611 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2612 	.f = cmd_config_rxtx_queue_parsed,
2613 	.data = NULL,
2614 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2615 	.tokens = {
2616 		(void *)&cmd_config_rxtx_queue_port,
2617 		(void *)&cmd_config_rxtx_queue_portid,
2618 		(void *)&cmd_config_rxtx_queue_rxtxq,
2619 		(void *)&cmd_config_rxtx_queue_qid,
2620 		(void *)&cmd_config_rxtx_queue_opname,
2621 		NULL,
2622 	},
2623 };
2624 
2625 /* *** configure port rxq/txq deferred start on/off *** */
2626 struct cmd_config_deferred_start_rxtx_queue {
2627 	cmdline_fixed_string_t port;
2628 	portid_t port_id;
2629 	cmdline_fixed_string_t rxtxq;
2630 	uint16_t qid;
2631 	cmdline_fixed_string_t opname;
2632 	cmdline_fixed_string_t state;
2633 };
2634 
2635 static void
2636 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2637 			__rte_unused struct cmdline *cl,
2638 			__rte_unused void *data)
2639 {
2640 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2641 	struct rte_port *port;
2642 	uint8_t isrx;
2643 	uint8_t ison;
2644 	uint8_t needreconfig = 0;
2645 
2646 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2647 		return;
2648 
2649 	if (port_is_started(res->port_id) != 0) {
2650 		printf("Please stop port %u first\n", res->port_id);
2651 		return;
2652 	}
2653 
2654 	port = &ports[res->port_id];
2655 
2656 	isrx = !strcmp(res->rxtxq, "rxq");
2657 
2658 	if (isrx && rx_queue_id_is_invalid(res->qid))
2659 		return;
2660 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2661 		return;
2662 
2663 	ison = !strcmp(res->state, "on");
2664 
2665 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2666 		port->rx_conf[res->qid].rx_deferred_start = ison;
2667 		needreconfig = 1;
2668 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2669 		port->tx_conf[res->qid].tx_deferred_start = ison;
2670 		needreconfig = 1;
2671 	}
2672 
2673 	if (needreconfig)
2674 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2675 }
2676 
2677 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2678 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2679 						port, "port");
2680 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2681 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2682 						port_id, RTE_UINT16);
2683 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2684 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2685 						rxtxq, "rxq#txq");
2686 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2687 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2688 						qid, RTE_UINT16);
2689 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2690 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2691 						opname, "deferred_start");
2692 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2693 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2694 						state, "on#off");
2695 
2696 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2697 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2698 	.data = NULL,
2699 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2700 	.tokens = {
2701 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2702 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2703 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2704 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2705 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2706 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2707 		NULL,
2708 	},
2709 };
2710 
2711 /* *** configure port rxq/txq setup *** */
2712 struct cmd_setup_rxtx_queue {
2713 	cmdline_fixed_string_t port;
2714 	portid_t portid;
2715 	cmdline_fixed_string_t rxtxq;
2716 	uint16_t qid;
2717 	cmdline_fixed_string_t setup;
2718 };
2719 
2720 /* Common CLI fields for queue setup */
2721 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2722 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2723 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2724 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2725 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2726 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2727 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2728 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2729 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2730 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2731 
2732 static void
2733 cmd_setup_rxtx_queue_parsed(
2734 	void *parsed_result,
2735 	__rte_unused struct cmdline *cl,
2736 	__rte_unused void *data)
2737 {
2738 	struct cmd_setup_rxtx_queue *res = parsed_result;
2739 	struct rte_port *port;
2740 	struct rte_mempool *mp;
2741 	unsigned int socket_id;
2742 	uint8_t isrx = 0;
2743 	int ret;
2744 
2745 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2746 		return;
2747 
2748 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2749 		printf("Invalid port id\n");
2750 		return;
2751 	}
2752 
2753 	if (!strcmp(res->rxtxq, "rxq"))
2754 		isrx = 1;
2755 	else if (!strcmp(res->rxtxq, "txq"))
2756 		isrx = 0;
2757 	else {
2758 		printf("Unknown parameter\n");
2759 		return;
2760 	}
2761 
2762 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2763 		printf("Invalid rx queue\n");
2764 		return;
2765 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2766 		printf("Invalid tx queue\n");
2767 		return;
2768 	}
2769 
2770 	port = &ports[res->portid];
2771 	if (isrx) {
2772 		socket_id = rxring_numa[res->portid];
2773 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2774 			socket_id = port->socket_id;
2775 
2776 		mp = mbuf_pool_find(socket_id, 0);
2777 		if (mp == NULL) {
2778 			printf("Failed to setup RX queue: "
2779 				"No mempool allocation"
2780 				" on the socket %d\n",
2781 				rxring_numa[res->portid]);
2782 			return;
2783 		}
2784 		ret = rx_queue_setup(res->portid,
2785 				     res->qid,
2786 				     port->nb_rx_desc[res->qid],
2787 				     socket_id,
2788 				     &port->rx_conf[res->qid],
2789 				     mp);
2790 		if (ret)
2791 			printf("Failed to setup RX queue\n");
2792 	} else {
2793 		socket_id = txring_numa[res->portid];
2794 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2795 			socket_id = port->socket_id;
2796 
2797 		ret = rte_eth_tx_queue_setup(res->portid,
2798 					     res->qid,
2799 					     port->nb_tx_desc[res->qid],
2800 					     socket_id,
2801 					     &port->tx_conf[res->qid]);
2802 		if (ret)
2803 			printf("Failed to setup TX queue\n");
2804 	}
2805 }
2806 
2807 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2808 	.f = cmd_setup_rxtx_queue_parsed,
2809 	.data = NULL,
2810 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2811 	.tokens = {
2812 		(void *)&cmd_setup_rxtx_queue_port,
2813 		(void *)&cmd_setup_rxtx_queue_portid,
2814 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2815 		(void *)&cmd_setup_rxtx_queue_qid,
2816 		(void *)&cmd_setup_rxtx_queue_setup,
2817 		NULL,
2818 	},
2819 };
2820 
2821 
2822 /* *** Configure RSS RETA *** */
2823 struct cmd_config_rss_reta {
2824 	cmdline_fixed_string_t port;
2825 	cmdline_fixed_string_t keyword;
2826 	portid_t port_id;
2827 	cmdline_fixed_string_t name;
2828 	cmdline_fixed_string_t list_name;
2829 	cmdline_fixed_string_t list_of_items;
2830 };
2831 
2832 static int
2833 parse_reta_config(const char *str,
2834 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2835 		  uint16_t nb_entries)
2836 {
2837 	int i;
2838 	unsigned size;
2839 	uint16_t hash_index, idx, shift;
2840 	uint16_t nb_queue;
2841 	char s[256];
2842 	const char *p, *p0 = str;
2843 	char *end;
2844 	enum fieldnames {
2845 		FLD_HASH_INDEX = 0,
2846 		FLD_QUEUE,
2847 		_NUM_FLD
2848 	};
2849 	unsigned long int_fld[_NUM_FLD];
2850 	char *str_fld[_NUM_FLD];
2851 
2852 	while ((p = strchr(p0,'(')) != NULL) {
2853 		++p;
2854 		if((p0 = strchr(p,')')) == NULL)
2855 			return -1;
2856 
2857 		size = p0 - p;
2858 		if(size >= sizeof(s))
2859 			return -1;
2860 
2861 		snprintf(s, sizeof(s), "%.*s", size, p);
2862 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2863 			return -1;
2864 		for (i = 0; i < _NUM_FLD; i++) {
2865 			errno = 0;
2866 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2867 			if (errno != 0 || end == str_fld[i] ||
2868 					int_fld[i] > 65535)
2869 				return -1;
2870 		}
2871 
2872 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2873 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2874 
2875 		if (hash_index >= nb_entries) {
2876 			printf("Invalid RETA hash index=%d\n", hash_index);
2877 			return -1;
2878 		}
2879 
2880 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2881 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2882 		reta_conf[idx].mask |= (1ULL << shift);
2883 		reta_conf[idx].reta[shift] = nb_queue;
2884 	}
2885 
2886 	return 0;
2887 }
2888 
2889 static void
2890 cmd_set_rss_reta_parsed(void *parsed_result,
2891 			__rte_unused struct cmdline *cl,
2892 			__rte_unused void *data)
2893 {
2894 	int ret;
2895 	struct rte_eth_dev_info dev_info;
2896 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2897 	struct cmd_config_rss_reta *res = parsed_result;
2898 
2899 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2900 	if (ret != 0)
2901 		return;
2902 
2903 	if (dev_info.reta_size == 0) {
2904 		printf("Redirection table size is 0 which is "
2905 					"invalid for RSS\n");
2906 		return;
2907 	} else
2908 		printf("The reta size of port %d is %u\n",
2909 			res->port_id, dev_info.reta_size);
2910 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2911 		printf("Currently do not support more than %u entries of "
2912 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
2913 		return;
2914 	}
2915 
2916 	memset(reta_conf, 0, sizeof(reta_conf));
2917 	if (!strcmp(res->list_name, "reta")) {
2918 		if (parse_reta_config(res->list_of_items, reta_conf,
2919 						dev_info.reta_size)) {
2920 			printf("Invalid RSS Redirection Table "
2921 					"config entered\n");
2922 			return;
2923 		}
2924 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2925 				reta_conf, dev_info.reta_size);
2926 		if (ret != 0)
2927 			printf("Bad redirection table parameter, "
2928 					"return code = %d \n", ret);
2929 	}
2930 }
2931 
2932 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2933 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2934 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2935 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2936 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2937 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2938 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2939 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2940 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2941 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2942 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2943         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2944                                  NULL);
2945 cmdline_parse_inst_t cmd_config_rss_reta = {
2946 	.f = cmd_set_rss_reta_parsed,
2947 	.data = NULL,
2948 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2949 	.tokens = {
2950 		(void *)&cmd_config_rss_reta_port,
2951 		(void *)&cmd_config_rss_reta_keyword,
2952 		(void *)&cmd_config_rss_reta_port_id,
2953 		(void *)&cmd_config_rss_reta_name,
2954 		(void *)&cmd_config_rss_reta_list_name,
2955 		(void *)&cmd_config_rss_reta_list_of_items,
2956 		NULL,
2957 	},
2958 };
2959 
2960 /* *** SHOW PORT RETA INFO *** */
2961 struct cmd_showport_reta {
2962 	cmdline_fixed_string_t show;
2963 	cmdline_fixed_string_t port;
2964 	portid_t port_id;
2965 	cmdline_fixed_string_t rss;
2966 	cmdline_fixed_string_t reta;
2967 	uint16_t size;
2968 	cmdline_fixed_string_t list_of_items;
2969 };
2970 
2971 static int
2972 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2973 			   uint16_t nb_entries,
2974 			   char *str)
2975 {
2976 	uint32_t size;
2977 	const char *p, *p0 = str;
2978 	char s[256];
2979 	char *end;
2980 	char *str_fld[8];
2981 	uint16_t i;
2982 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2983 			RTE_RETA_GROUP_SIZE;
2984 	int ret;
2985 
2986 	p = strchr(p0, '(');
2987 	if (p == NULL)
2988 		return -1;
2989 	p++;
2990 	p0 = strchr(p, ')');
2991 	if (p0 == NULL)
2992 		return -1;
2993 	size = p0 - p;
2994 	if (size >= sizeof(s)) {
2995 		printf("The string size exceeds the internal buffer size\n");
2996 		return -1;
2997 	}
2998 	snprintf(s, sizeof(s), "%.*s", size, p);
2999 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3000 	if (ret <= 0 || ret != num) {
3001 		printf("The bits of masks do not match the number of "
3002 					"reta entries: %u\n", num);
3003 		return -1;
3004 	}
3005 	for (i = 0; i < ret; i++)
3006 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3007 
3008 	return 0;
3009 }
3010 
3011 static void
3012 cmd_showport_reta_parsed(void *parsed_result,
3013 			 __rte_unused struct cmdline *cl,
3014 			 __rte_unused void *data)
3015 {
3016 	struct cmd_showport_reta *res = parsed_result;
3017 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3018 	struct rte_eth_dev_info dev_info;
3019 	uint16_t max_reta_size;
3020 	int ret;
3021 
3022 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3023 	if (ret != 0)
3024 		return;
3025 
3026 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3027 	if (res->size == 0 || res->size > max_reta_size) {
3028 		printf("Invalid redirection table size: %u (1-%u)\n",
3029 			res->size, max_reta_size);
3030 		return;
3031 	}
3032 
3033 	memset(reta_conf, 0, sizeof(reta_conf));
3034 	if (showport_parse_reta_config(reta_conf, res->size,
3035 				res->list_of_items) < 0) {
3036 		printf("Invalid string: %s for reta masks\n",
3037 					res->list_of_items);
3038 		return;
3039 	}
3040 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3041 }
3042 
3043 cmdline_parse_token_string_t cmd_showport_reta_show =
3044 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3045 cmdline_parse_token_string_t cmd_showport_reta_port =
3046 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3047 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3048 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3049 cmdline_parse_token_string_t cmd_showport_reta_rss =
3050 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3051 cmdline_parse_token_string_t cmd_showport_reta_reta =
3052 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3053 cmdline_parse_token_num_t cmd_showport_reta_size =
3054 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3055 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3056 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3057 					list_of_items, NULL);
3058 
3059 cmdline_parse_inst_t cmd_showport_reta = {
3060 	.f = cmd_showport_reta_parsed,
3061 	.data = NULL,
3062 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3063 	.tokens = {
3064 		(void *)&cmd_showport_reta_show,
3065 		(void *)&cmd_showport_reta_port,
3066 		(void *)&cmd_showport_reta_port_id,
3067 		(void *)&cmd_showport_reta_rss,
3068 		(void *)&cmd_showport_reta_reta,
3069 		(void *)&cmd_showport_reta_size,
3070 		(void *)&cmd_showport_reta_list_of_items,
3071 		NULL,
3072 	},
3073 };
3074 
3075 /* *** Show RSS hash configuration *** */
3076 struct cmd_showport_rss_hash {
3077 	cmdline_fixed_string_t show;
3078 	cmdline_fixed_string_t port;
3079 	portid_t port_id;
3080 	cmdline_fixed_string_t rss_hash;
3081 	cmdline_fixed_string_t rss_type;
3082 	cmdline_fixed_string_t key; /* optional argument */
3083 };
3084 
3085 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3086 				__rte_unused struct cmdline *cl,
3087 				void *show_rss_key)
3088 {
3089 	struct cmd_showport_rss_hash *res = parsed_result;
3090 
3091 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3092 }
3093 
3094 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3095 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3096 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3097 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3098 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3099 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3100 				 RTE_UINT16);
3101 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3102 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3103 				 "rss-hash");
3104 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3105 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3106 
3107 cmdline_parse_inst_t cmd_showport_rss_hash = {
3108 	.f = cmd_showport_rss_hash_parsed,
3109 	.data = NULL,
3110 	.help_str = "show port <port_id> rss-hash",
3111 	.tokens = {
3112 		(void *)&cmd_showport_rss_hash_show,
3113 		(void *)&cmd_showport_rss_hash_port,
3114 		(void *)&cmd_showport_rss_hash_port_id,
3115 		(void *)&cmd_showport_rss_hash_rss_hash,
3116 		NULL,
3117 	},
3118 };
3119 
3120 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3121 	.f = cmd_showport_rss_hash_parsed,
3122 	.data = (void *)1,
3123 	.help_str = "show port <port_id> rss-hash key",
3124 	.tokens = {
3125 		(void *)&cmd_showport_rss_hash_show,
3126 		(void *)&cmd_showport_rss_hash_port,
3127 		(void *)&cmd_showport_rss_hash_port_id,
3128 		(void *)&cmd_showport_rss_hash_rss_hash,
3129 		(void *)&cmd_showport_rss_hash_rss_key,
3130 		NULL,
3131 	},
3132 };
3133 
3134 /* *** Configure DCB *** */
3135 struct cmd_config_dcb {
3136 	cmdline_fixed_string_t port;
3137 	cmdline_fixed_string_t config;
3138 	portid_t port_id;
3139 	cmdline_fixed_string_t dcb;
3140 	cmdline_fixed_string_t vt;
3141 	cmdline_fixed_string_t vt_en;
3142 	uint8_t num_tcs;
3143 	cmdline_fixed_string_t pfc;
3144 	cmdline_fixed_string_t pfc_en;
3145 };
3146 
3147 static void
3148 cmd_config_dcb_parsed(void *parsed_result,
3149                         __rte_unused struct cmdline *cl,
3150                         __rte_unused void *data)
3151 {
3152 	struct cmd_config_dcb *res = parsed_result;
3153 	portid_t port_id = res->port_id;
3154 	struct rte_port *port;
3155 	uint8_t pfc_en;
3156 	int ret;
3157 
3158 	port = &ports[port_id];
3159 	/** Check if the port is not started **/
3160 	if (port->port_status != RTE_PORT_STOPPED) {
3161 		printf("Please stop port %d first\n", port_id);
3162 		return;
3163 	}
3164 
3165 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3166 		printf("The invalid number of traffic class,"
3167 			" only 4 or 8 allowed.\n");
3168 		return;
3169 	}
3170 
3171 	if (nb_fwd_lcores < res->num_tcs) {
3172 		printf("nb_cores shouldn't be less than number of TCs.\n");
3173 		return;
3174 	}
3175 	if (!strncmp(res->pfc_en, "on", 2))
3176 		pfc_en = 1;
3177 	else
3178 		pfc_en = 0;
3179 
3180 	/* DCB in VT mode */
3181 	if (!strncmp(res->vt_en, "on", 2))
3182 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3183 				(enum rte_eth_nb_tcs)res->num_tcs,
3184 				pfc_en);
3185 	else
3186 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3187 				(enum rte_eth_nb_tcs)res->num_tcs,
3188 				pfc_en);
3189 
3190 
3191 	if (ret != 0) {
3192 		printf("Cannot initialize network ports.\n");
3193 		return;
3194 	}
3195 
3196 	cmd_reconfig_device_queue(port_id, 1, 1);
3197 }
3198 
3199 cmdline_parse_token_string_t cmd_config_dcb_port =
3200         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3201 cmdline_parse_token_string_t cmd_config_dcb_config =
3202         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3203 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3204 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3205 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3206         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3207 cmdline_parse_token_string_t cmd_config_dcb_vt =
3208         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3209 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3210         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3211 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3212 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3213 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3214         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3215 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3216         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3217 
3218 cmdline_parse_inst_t cmd_config_dcb = {
3219 	.f = cmd_config_dcb_parsed,
3220 	.data = NULL,
3221 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3222 	.tokens = {
3223 		(void *)&cmd_config_dcb_port,
3224 		(void *)&cmd_config_dcb_config,
3225 		(void *)&cmd_config_dcb_port_id,
3226 		(void *)&cmd_config_dcb_dcb,
3227 		(void *)&cmd_config_dcb_vt,
3228 		(void *)&cmd_config_dcb_vt_en,
3229 		(void *)&cmd_config_dcb_num_tcs,
3230 		(void *)&cmd_config_dcb_pfc,
3231 		(void *)&cmd_config_dcb_pfc_en,
3232                 NULL,
3233         },
3234 };
3235 
3236 /* *** configure number of packets per burst *** */
3237 struct cmd_config_burst {
3238 	cmdline_fixed_string_t port;
3239 	cmdline_fixed_string_t keyword;
3240 	cmdline_fixed_string_t all;
3241 	cmdline_fixed_string_t name;
3242 	uint16_t value;
3243 };
3244 
3245 static void
3246 cmd_config_burst_parsed(void *parsed_result,
3247 			__rte_unused struct cmdline *cl,
3248 			__rte_unused void *data)
3249 {
3250 	struct cmd_config_burst *res = parsed_result;
3251 	struct rte_eth_dev_info dev_info;
3252 	uint16_t rec_nb_pkts;
3253 	int ret;
3254 
3255 	if (!all_ports_stopped()) {
3256 		printf("Please stop all ports first\n");
3257 		return;
3258 	}
3259 
3260 	if (!strcmp(res->name, "burst")) {
3261 		if (res->value == 0) {
3262 			/* If user gives a value of zero, query the PMD for
3263 			 * its recommended Rx burst size. Testpmd uses a single
3264 			 * size for all ports, so assume all ports are the same
3265 			 * NIC model and use the values from Port 0.
3266 			 */
3267 			ret = eth_dev_info_get_print_err(0, &dev_info);
3268 			if (ret != 0)
3269 				return;
3270 
3271 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3272 
3273 			if (rec_nb_pkts == 0) {
3274 				printf("PMD does not recommend a burst size.\n"
3275 					"User provided value must be between"
3276 					" 1 and %d\n", MAX_PKT_BURST);
3277 				return;
3278 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3279 				printf("PMD recommended burst size of %d"
3280 					" exceeds maximum value of %d\n",
3281 					rec_nb_pkts, MAX_PKT_BURST);
3282 				return;
3283 			}
3284 			printf("Using PMD-provided burst value of %d\n",
3285 				rec_nb_pkts);
3286 			nb_pkt_per_burst = rec_nb_pkts;
3287 		} else if (res->value > MAX_PKT_BURST) {
3288 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3289 			return;
3290 		} else
3291 			nb_pkt_per_burst = res->value;
3292 	} else {
3293 		printf("Unknown parameter\n");
3294 		return;
3295 	}
3296 
3297 	init_port_config();
3298 
3299 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3300 }
3301 
3302 cmdline_parse_token_string_t cmd_config_burst_port =
3303 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3304 cmdline_parse_token_string_t cmd_config_burst_keyword =
3305 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3306 cmdline_parse_token_string_t cmd_config_burst_all =
3307 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3308 cmdline_parse_token_string_t cmd_config_burst_name =
3309 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3310 cmdline_parse_token_num_t cmd_config_burst_value =
3311 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3312 
3313 cmdline_parse_inst_t cmd_config_burst = {
3314 	.f = cmd_config_burst_parsed,
3315 	.data = NULL,
3316 	.help_str = "port config all burst <value>",
3317 	.tokens = {
3318 		(void *)&cmd_config_burst_port,
3319 		(void *)&cmd_config_burst_keyword,
3320 		(void *)&cmd_config_burst_all,
3321 		(void *)&cmd_config_burst_name,
3322 		(void *)&cmd_config_burst_value,
3323 		NULL,
3324 	},
3325 };
3326 
3327 /* *** configure rx/tx queues *** */
3328 struct cmd_config_thresh {
3329 	cmdline_fixed_string_t port;
3330 	cmdline_fixed_string_t keyword;
3331 	cmdline_fixed_string_t all;
3332 	cmdline_fixed_string_t name;
3333 	uint8_t value;
3334 };
3335 
3336 static void
3337 cmd_config_thresh_parsed(void *parsed_result,
3338 			__rte_unused struct cmdline *cl,
3339 			__rte_unused void *data)
3340 {
3341 	struct cmd_config_thresh *res = parsed_result;
3342 
3343 	if (!all_ports_stopped()) {
3344 		printf("Please stop all ports first\n");
3345 		return;
3346 	}
3347 
3348 	if (!strcmp(res->name, "txpt"))
3349 		tx_pthresh = res->value;
3350 	else if(!strcmp(res->name, "txht"))
3351 		tx_hthresh = res->value;
3352 	else if(!strcmp(res->name, "txwt"))
3353 		tx_wthresh = res->value;
3354 	else if(!strcmp(res->name, "rxpt"))
3355 		rx_pthresh = res->value;
3356 	else if(!strcmp(res->name, "rxht"))
3357 		rx_hthresh = res->value;
3358 	else if(!strcmp(res->name, "rxwt"))
3359 		rx_wthresh = res->value;
3360 	else {
3361 		printf("Unknown parameter\n");
3362 		return;
3363 	}
3364 
3365 	init_port_config();
3366 
3367 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3368 }
3369 
3370 cmdline_parse_token_string_t cmd_config_thresh_port =
3371 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3372 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3373 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3374 cmdline_parse_token_string_t cmd_config_thresh_all =
3375 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3376 cmdline_parse_token_string_t cmd_config_thresh_name =
3377 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3378 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3379 cmdline_parse_token_num_t cmd_config_thresh_value =
3380 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3381 
3382 cmdline_parse_inst_t cmd_config_thresh = {
3383 	.f = cmd_config_thresh_parsed,
3384 	.data = NULL,
3385 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3386 	.tokens = {
3387 		(void *)&cmd_config_thresh_port,
3388 		(void *)&cmd_config_thresh_keyword,
3389 		(void *)&cmd_config_thresh_all,
3390 		(void *)&cmd_config_thresh_name,
3391 		(void *)&cmd_config_thresh_value,
3392 		NULL,
3393 	},
3394 };
3395 
3396 /* *** configure free/rs threshold *** */
3397 struct cmd_config_threshold {
3398 	cmdline_fixed_string_t port;
3399 	cmdline_fixed_string_t keyword;
3400 	cmdline_fixed_string_t all;
3401 	cmdline_fixed_string_t name;
3402 	uint16_t value;
3403 };
3404 
3405 static void
3406 cmd_config_threshold_parsed(void *parsed_result,
3407 			__rte_unused struct cmdline *cl,
3408 			__rte_unused void *data)
3409 {
3410 	struct cmd_config_threshold *res = parsed_result;
3411 
3412 	if (!all_ports_stopped()) {
3413 		printf("Please stop all ports first\n");
3414 		return;
3415 	}
3416 
3417 	if (!strcmp(res->name, "txfreet"))
3418 		tx_free_thresh = res->value;
3419 	else if (!strcmp(res->name, "txrst"))
3420 		tx_rs_thresh = res->value;
3421 	else if (!strcmp(res->name, "rxfreet"))
3422 		rx_free_thresh = res->value;
3423 	else {
3424 		printf("Unknown parameter\n");
3425 		return;
3426 	}
3427 
3428 	init_port_config();
3429 
3430 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3431 }
3432 
3433 cmdline_parse_token_string_t cmd_config_threshold_port =
3434 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3435 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3436 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3437 								"config");
3438 cmdline_parse_token_string_t cmd_config_threshold_all =
3439 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3440 cmdline_parse_token_string_t cmd_config_threshold_name =
3441 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3442 						"txfreet#txrst#rxfreet");
3443 cmdline_parse_token_num_t cmd_config_threshold_value =
3444 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3445 
3446 cmdline_parse_inst_t cmd_config_threshold = {
3447 	.f = cmd_config_threshold_parsed,
3448 	.data = NULL,
3449 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3450 	.tokens = {
3451 		(void *)&cmd_config_threshold_port,
3452 		(void *)&cmd_config_threshold_keyword,
3453 		(void *)&cmd_config_threshold_all,
3454 		(void *)&cmd_config_threshold_name,
3455 		(void *)&cmd_config_threshold_value,
3456 		NULL,
3457 	},
3458 };
3459 
3460 /* *** stop *** */
3461 struct cmd_stop_result {
3462 	cmdline_fixed_string_t stop;
3463 };
3464 
3465 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3466 			    __rte_unused struct cmdline *cl,
3467 			    __rte_unused void *data)
3468 {
3469 	stop_packet_forwarding();
3470 }
3471 
3472 cmdline_parse_token_string_t cmd_stop_stop =
3473 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3474 
3475 cmdline_parse_inst_t cmd_stop = {
3476 	.f = cmd_stop_parsed,
3477 	.data = NULL,
3478 	.help_str = "stop: Stop packet forwarding",
3479 	.tokens = {
3480 		(void *)&cmd_stop_stop,
3481 		NULL,
3482 	},
3483 };
3484 
3485 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3486 
3487 unsigned int
3488 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3489 		unsigned int *parsed_items, int check_unique_values)
3490 {
3491 	unsigned int nb_item;
3492 	unsigned int value;
3493 	unsigned int i;
3494 	unsigned int j;
3495 	int value_ok;
3496 	char c;
3497 
3498 	/*
3499 	 * First parse all items in the list and store their value.
3500 	 */
3501 	value = 0;
3502 	nb_item = 0;
3503 	value_ok = 0;
3504 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3505 		c = str[i];
3506 		if ((c >= '0') && (c <= '9')) {
3507 			value = (unsigned int) (value * 10 + (c - '0'));
3508 			value_ok = 1;
3509 			continue;
3510 		}
3511 		if (c != ',') {
3512 			printf("character %c is not a decimal digit\n", c);
3513 			return 0;
3514 		}
3515 		if (! value_ok) {
3516 			printf("No valid value before comma\n");
3517 			return 0;
3518 		}
3519 		if (nb_item < max_items) {
3520 			parsed_items[nb_item] = value;
3521 			value_ok = 0;
3522 			value = 0;
3523 		}
3524 		nb_item++;
3525 	}
3526 	if (nb_item >= max_items) {
3527 		printf("Number of %s = %u > %u (maximum items)\n",
3528 		       item_name, nb_item + 1, max_items);
3529 		return 0;
3530 	}
3531 	parsed_items[nb_item++] = value;
3532 	if (! check_unique_values)
3533 		return nb_item;
3534 
3535 	/*
3536 	 * Then, check that all values in the list are differents.
3537 	 * No optimization here...
3538 	 */
3539 	for (i = 0; i < nb_item; i++) {
3540 		for (j = i + 1; j < nb_item; j++) {
3541 			if (parsed_items[j] == parsed_items[i]) {
3542 				printf("duplicated %s %u at index %u and %u\n",
3543 				       item_name, parsed_items[i], i, j);
3544 				return 0;
3545 			}
3546 		}
3547 	}
3548 	return nb_item;
3549 }
3550 
3551 struct cmd_set_list_result {
3552 	cmdline_fixed_string_t cmd_keyword;
3553 	cmdline_fixed_string_t list_name;
3554 	cmdline_fixed_string_t list_of_items;
3555 };
3556 
3557 static void cmd_set_list_parsed(void *parsed_result,
3558 				__rte_unused struct cmdline *cl,
3559 				__rte_unused void *data)
3560 {
3561 	struct cmd_set_list_result *res;
3562 	union {
3563 		unsigned int lcorelist[RTE_MAX_LCORE];
3564 		unsigned int portlist[RTE_MAX_ETHPORTS];
3565 	} parsed_items;
3566 	unsigned int nb_item;
3567 
3568 	if (test_done == 0) {
3569 		printf("Please stop forwarding first\n");
3570 		return;
3571 	}
3572 
3573 	res = parsed_result;
3574 	if (!strcmp(res->list_name, "corelist")) {
3575 		nb_item = parse_item_list(res->list_of_items, "core",
3576 					  RTE_MAX_LCORE,
3577 					  parsed_items.lcorelist, 1);
3578 		if (nb_item > 0) {
3579 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3580 			fwd_config_setup();
3581 		}
3582 		return;
3583 	}
3584 	if (!strcmp(res->list_name, "portlist")) {
3585 		nb_item = parse_item_list(res->list_of_items, "port",
3586 					  RTE_MAX_ETHPORTS,
3587 					  parsed_items.portlist, 1);
3588 		if (nb_item > 0) {
3589 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3590 			fwd_config_setup();
3591 		}
3592 	}
3593 }
3594 
3595 cmdline_parse_token_string_t cmd_set_list_keyword =
3596 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3597 				 "set");
3598 cmdline_parse_token_string_t cmd_set_list_name =
3599 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3600 				 "corelist#portlist");
3601 cmdline_parse_token_string_t cmd_set_list_of_items =
3602 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3603 				 NULL);
3604 
3605 cmdline_parse_inst_t cmd_set_fwd_list = {
3606 	.f = cmd_set_list_parsed,
3607 	.data = NULL,
3608 	.help_str = "set corelist|portlist <list0[,list1]*>",
3609 	.tokens = {
3610 		(void *)&cmd_set_list_keyword,
3611 		(void *)&cmd_set_list_name,
3612 		(void *)&cmd_set_list_of_items,
3613 		NULL,
3614 	},
3615 };
3616 
3617 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3618 
3619 struct cmd_setmask_result {
3620 	cmdline_fixed_string_t set;
3621 	cmdline_fixed_string_t mask;
3622 	uint64_t hexavalue;
3623 };
3624 
3625 static void cmd_set_mask_parsed(void *parsed_result,
3626 				__rte_unused struct cmdline *cl,
3627 				__rte_unused void *data)
3628 {
3629 	struct cmd_setmask_result *res = parsed_result;
3630 
3631 	if (test_done == 0) {
3632 		printf("Please stop forwarding first\n");
3633 		return;
3634 	}
3635 	if (!strcmp(res->mask, "coremask")) {
3636 		set_fwd_lcores_mask(res->hexavalue);
3637 		fwd_config_setup();
3638 	} else if (!strcmp(res->mask, "portmask")) {
3639 		set_fwd_ports_mask(res->hexavalue);
3640 		fwd_config_setup();
3641 	}
3642 }
3643 
3644 cmdline_parse_token_string_t cmd_setmask_set =
3645 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3646 cmdline_parse_token_string_t cmd_setmask_mask =
3647 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3648 				 "coremask#portmask");
3649 cmdline_parse_token_num_t cmd_setmask_value =
3650 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3651 
3652 cmdline_parse_inst_t cmd_set_fwd_mask = {
3653 	.f = cmd_set_mask_parsed,
3654 	.data = NULL,
3655 	.help_str = "set coremask|portmask <hexadecimal value>",
3656 	.tokens = {
3657 		(void *)&cmd_setmask_set,
3658 		(void *)&cmd_setmask_mask,
3659 		(void *)&cmd_setmask_value,
3660 		NULL,
3661 	},
3662 };
3663 
3664 /*
3665  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3666  */
3667 struct cmd_set_result {
3668 	cmdline_fixed_string_t set;
3669 	cmdline_fixed_string_t what;
3670 	uint16_t value;
3671 };
3672 
3673 static void cmd_set_parsed(void *parsed_result,
3674 			   __rte_unused struct cmdline *cl,
3675 			   __rte_unused void *data)
3676 {
3677 	struct cmd_set_result *res = parsed_result;
3678 	if (!strcmp(res->what, "nbport")) {
3679 		set_fwd_ports_number(res->value);
3680 		fwd_config_setup();
3681 	} else if (!strcmp(res->what, "nbcore")) {
3682 		set_fwd_lcores_number(res->value);
3683 		fwd_config_setup();
3684 	} else if (!strcmp(res->what, "burst"))
3685 		set_nb_pkt_per_burst(res->value);
3686 	else if (!strcmp(res->what, "verbose"))
3687 		set_verbose_level(res->value);
3688 }
3689 
3690 cmdline_parse_token_string_t cmd_set_set =
3691 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3692 cmdline_parse_token_string_t cmd_set_what =
3693 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3694 				 "nbport#nbcore#burst#verbose");
3695 cmdline_parse_token_num_t cmd_set_value =
3696 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3697 
3698 cmdline_parse_inst_t cmd_set_numbers = {
3699 	.f = cmd_set_parsed,
3700 	.data = NULL,
3701 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3702 	.tokens = {
3703 		(void *)&cmd_set_set,
3704 		(void *)&cmd_set_what,
3705 		(void *)&cmd_set_value,
3706 		NULL,
3707 	},
3708 };
3709 
3710 /* *** SET LOG LEVEL CONFIGURATION *** */
3711 
3712 struct cmd_set_log_result {
3713 	cmdline_fixed_string_t set;
3714 	cmdline_fixed_string_t log;
3715 	cmdline_fixed_string_t type;
3716 	uint32_t level;
3717 };
3718 
3719 static void
3720 cmd_set_log_parsed(void *parsed_result,
3721 		   __rte_unused struct cmdline *cl,
3722 		   __rte_unused void *data)
3723 {
3724 	struct cmd_set_log_result *res;
3725 	int ret;
3726 
3727 	res = parsed_result;
3728 	if (!strcmp(res->type, "global"))
3729 		rte_log_set_global_level(res->level);
3730 	else {
3731 		ret = rte_log_set_level_regexp(res->type, res->level);
3732 		if (ret < 0)
3733 			printf("Unable to set log level\n");
3734 	}
3735 }
3736 
3737 cmdline_parse_token_string_t cmd_set_log_set =
3738 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3739 cmdline_parse_token_string_t cmd_set_log_log =
3740 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3741 cmdline_parse_token_string_t cmd_set_log_type =
3742 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3743 cmdline_parse_token_num_t cmd_set_log_level =
3744 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3745 
3746 cmdline_parse_inst_t cmd_set_log = {
3747 	.f = cmd_set_log_parsed,
3748 	.data = NULL,
3749 	.help_str = "set log global|<type> <level>",
3750 	.tokens = {
3751 		(void *)&cmd_set_log_set,
3752 		(void *)&cmd_set_log_log,
3753 		(void *)&cmd_set_log_type,
3754 		(void *)&cmd_set_log_level,
3755 		NULL,
3756 	},
3757 };
3758 
3759 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3760 
3761 struct cmd_set_rxoffs_result {
3762 	cmdline_fixed_string_t cmd_keyword;
3763 	cmdline_fixed_string_t rxoffs;
3764 	cmdline_fixed_string_t seg_offsets;
3765 };
3766 
3767 static void
3768 cmd_set_rxoffs_parsed(void *parsed_result,
3769 		      __rte_unused struct cmdline *cl,
3770 		      __rte_unused void *data)
3771 {
3772 	struct cmd_set_rxoffs_result *res;
3773 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3774 	unsigned int nb_segs;
3775 
3776 	res = parsed_result;
3777 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3778 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3779 	if (nb_segs > 0)
3780 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3781 }
3782 
3783 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3784 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3785 				 cmd_keyword, "set");
3786 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3787 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3788 				 rxoffs, "rxoffs");
3789 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3790 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3791 				 seg_offsets, NULL);
3792 
3793 cmdline_parse_inst_t cmd_set_rxoffs = {
3794 	.f = cmd_set_rxoffs_parsed,
3795 	.data = NULL,
3796 	.help_str = "set rxoffs <len0[,len1]*>",
3797 	.tokens = {
3798 		(void *)&cmd_set_rxoffs_keyword,
3799 		(void *)&cmd_set_rxoffs_name,
3800 		(void *)&cmd_set_rxoffs_offsets,
3801 		NULL,
3802 	},
3803 };
3804 
3805 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3806 
3807 struct cmd_set_rxpkts_result {
3808 	cmdline_fixed_string_t cmd_keyword;
3809 	cmdline_fixed_string_t rxpkts;
3810 	cmdline_fixed_string_t seg_lengths;
3811 };
3812 
3813 static void
3814 cmd_set_rxpkts_parsed(void *parsed_result,
3815 		      __rte_unused struct cmdline *cl,
3816 		      __rte_unused void *data)
3817 {
3818 	struct cmd_set_rxpkts_result *res;
3819 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3820 	unsigned int nb_segs;
3821 
3822 	res = parsed_result;
3823 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3824 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3825 	if (nb_segs > 0)
3826 		set_rx_pkt_segments(seg_lengths, nb_segs);
3827 }
3828 
3829 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3830 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3831 				 cmd_keyword, "set");
3832 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3833 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3834 				 rxpkts, "rxpkts");
3835 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3836 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3837 				 seg_lengths, NULL);
3838 
3839 cmdline_parse_inst_t cmd_set_rxpkts = {
3840 	.f = cmd_set_rxpkts_parsed,
3841 	.data = NULL,
3842 	.help_str = "set rxpkts <len0[,len1]*>",
3843 	.tokens = {
3844 		(void *)&cmd_set_rxpkts_keyword,
3845 		(void *)&cmd_set_rxpkts_name,
3846 		(void *)&cmd_set_rxpkts_lengths,
3847 		NULL,
3848 	},
3849 };
3850 
3851 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3852 
3853 struct cmd_set_txpkts_result {
3854 	cmdline_fixed_string_t cmd_keyword;
3855 	cmdline_fixed_string_t txpkts;
3856 	cmdline_fixed_string_t seg_lengths;
3857 };
3858 
3859 static void
3860 cmd_set_txpkts_parsed(void *parsed_result,
3861 		      __rte_unused struct cmdline *cl,
3862 		      __rte_unused void *data)
3863 {
3864 	struct cmd_set_txpkts_result *res;
3865 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3866 	unsigned int nb_segs;
3867 
3868 	res = parsed_result;
3869 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3870 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3871 	if (nb_segs > 0)
3872 		set_tx_pkt_segments(seg_lengths, nb_segs);
3873 }
3874 
3875 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3876 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3877 				 cmd_keyword, "set");
3878 cmdline_parse_token_string_t cmd_set_txpkts_name =
3879 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3880 				 txpkts, "txpkts");
3881 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3882 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3883 				 seg_lengths, NULL);
3884 
3885 cmdline_parse_inst_t cmd_set_txpkts = {
3886 	.f = cmd_set_txpkts_parsed,
3887 	.data = NULL,
3888 	.help_str = "set txpkts <len0[,len1]*>",
3889 	.tokens = {
3890 		(void *)&cmd_set_txpkts_keyword,
3891 		(void *)&cmd_set_txpkts_name,
3892 		(void *)&cmd_set_txpkts_lengths,
3893 		NULL,
3894 	},
3895 };
3896 
3897 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3898 
3899 struct cmd_set_txsplit_result {
3900 	cmdline_fixed_string_t cmd_keyword;
3901 	cmdline_fixed_string_t txsplit;
3902 	cmdline_fixed_string_t mode;
3903 };
3904 
3905 static void
3906 cmd_set_txsplit_parsed(void *parsed_result,
3907 		      __rte_unused struct cmdline *cl,
3908 		      __rte_unused void *data)
3909 {
3910 	struct cmd_set_txsplit_result *res;
3911 
3912 	res = parsed_result;
3913 	set_tx_pkt_split(res->mode);
3914 }
3915 
3916 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3917 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3918 				 cmd_keyword, "set");
3919 cmdline_parse_token_string_t cmd_set_txsplit_name =
3920 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3921 				 txsplit, "txsplit");
3922 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3923 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3924 				 mode, NULL);
3925 
3926 cmdline_parse_inst_t cmd_set_txsplit = {
3927 	.f = cmd_set_txsplit_parsed,
3928 	.data = NULL,
3929 	.help_str = "set txsplit on|off|rand",
3930 	.tokens = {
3931 		(void *)&cmd_set_txsplit_keyword,
3932 		(void *)&cmd_set_txsplit_name,
3933 		(void *)&cmd_set_txsplit_mode,
3934 		NULL,
3935 	},
3936 };
3937 
3938 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3939 
3940 struct cmd_set_txtimes_result {
3941 	cmdline_fixed_string_t cmd_keyword;
3942 	cmdline_fixed_string_t txtimes;
3943 	cmdline_fixed_string_t tx_times;
3944 };
3945 
3946 static void
3947 cmd_set_txtimes_parsed(void *parsed_result,
3948 		       __rte_unused struct cmdline *cl,
3949 		       __rte_unused void *data)
3950 {
3951 	struct cmd_set_txtimes_result *res;
3952 	unsigned int tx_times[2] = {0, 0};
3953 	unsigned int n_times;
3954 
3955 	res = parsed_result;
3956 	n_times = parse_item_list(res->tx_times, "tx times",
3957 				  2, tx_times, 0);
3958 	if (n_times == 2)
3959 		set_tx_pkt_times(tx_times);
3960 }
3961 
3962 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3963 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3964 				 cmd_keyword, "set");
3965 cmdline_parse_token_string_t cmd_set_txtimes_name =
3966 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3967 				 txtimes, "txtimes");
3968 cmdline_parse_token_string_t cmd_set_txtimes_value =
3969 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3970 				 tx_times, NULL);
3971 
3972 cmdline_parse_inst_t cmd_set_txtimes = {
3973 	.f = cmd_set_txtimes_parsed,
3974 	.data = NULL,
3975 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
3976 	.tokens = {
3977 		(void *)&cmd_set_txtimes_keyword,
3978 		(void *)&cmd_set_txtimes_name,
3979 		(void *)&cmd_set_txtimes_value,
3980 		NULL,
3981 	},
3982 };
3983 
3984 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3985 struct cmd_rx_vlan_filter_all_result {
3986 	cmdline_fixed_string_t rx_vlan;
3987 	cmdline_fixed_string_t what;
3988 	cmdline_fixed_string_t all;
3989 	portid_t port_id;
3990 };
3991 
3992 static void
3993 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3994 			      __rte_unused struct cmdline *cl,
3995 			      __rte_unused void *data)
3996 {
3997 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3998 
3999 	if (!strcmp(res->what, "add"))
4000 		rx_vlan_all_filter_set(res->port_id, 1);
4001 	else
4002 		rx_vlan_all_filter_set(res->port_id, 0);
4003 }
4004 
4005 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4006 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4007 				 rx_vlan, "rx_vlan");
4008 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4009 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4010 				 what, "add#rm");
4011 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4012 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4013 				 all, "all");
4014 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4015 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4016 			      port_id, RTE_UINT16);
4017 
4018 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4019 	.f = cmd_rx_vlan_filter_all_parsed,
4020 	.data = NULL,
4021 	.help_str = "rx_vlan add|rm all <port_id>: "
4022 		"Add/Remove all identifiers to/from the set of VLAN "
4023 		"identifiers filtered by a port",
4024 	.tokens = {
4025 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4026 		(void *)&cmd_rx_vlan_filter_all_what,
4027 		(void *)&cmd_rx_vlan_filter_all_all,
4028 		(void *)&cmd_rx_vlan_filter_all_portid,
4029 		NULL,
4030 	},
4031 };
4032 
4033 /* *** VLAN OFFLOAD SET ON A PORT *** */
4034 struct cmd_vlan_offload_result {
4035 	cmdline_fixed_string_t vlan;
4036 	cmdline_fixed_string_t set;
4037 	cmdline_fixed_string_t vlan_type;
4038 	cmdline_fixed_string_t what;
4039 	cmdline_fixed_string_t on;
4040 	cmdline_fixed_string_t port_id;
4041 };
4042 
4043 static void
4044 cmd_vlan_offload_parsed(void *parsed_result,
4045 			  __rte_unused struct cmdline *cl,
4046 			  __rte_unused void *data)
4047 {
4048 	int on;
4049 	struct cmd_vlan_offload_result *res = parsed_result;
4050 	char *str;
4051 	int i, len = 0;
4052 	portid_t port_id = 0;
4053 	unsigned int tmp;
4054 
4055 	str = res->port_id;
4056 	len = strnlen(str, STR_TOKEN_SIZE);
4057 	i = 0;
4058 	/* Get port_id first */
4059 	while(i < len){
4060 		if(str[i] == ',')
4061 			break;
4062 
4063 		i++;
4064 	}
4065 	str[i]='\0';
4066 	tmp = strtoul(str, NULL, 0);
4067 	/* If port_id greater that what portid_t can represent, return */
4068 	if(tmp >= RTE_MAX_ETHPORTS)
4069 		return;
4070 	port_id = (portid_t)tmp;
4071 
4072 	if (!strcmp(res->on, "on"))
4073 		on = 1;
4074 	else
4075 		on = 0;
4076 
4077 	if (!strcmp(res->what, "strip"))
4078 		rx_vlan_strip_set(port_id,  on);
4079 	else if(!strcmp(res->what, "stripq")){
4080 		uint16_t queue_id = 0;
4081 
4082 		/* No queue_id, return */
4083 		if(i + 1 >= len) {
4084 			printf("must specify (port,queue_id)\n");
4085 			return;
4086 		}
4087 		tmp = strtoul(str + i + 1, NULL, 0);
4088 		/* If queue_id greater that what 16-bits can represent, return */
4089 		if(tmp > 0xffff)
4090 			return;
4091 
4092 		queue_id = (uint16_t)tmp;
4093 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4094 	}
4095 	else if (!strcmp(res->what, "filter"))
4096 		rx_vlan_filter_set(port_id, on);
4097 	else if (!strcmp(res->what, "qinq_strip"))
4098 		rx_vlan_qinq_strip_set(port_id, on);
4099 	else
4100 		vlan_extend_set(port_id, on);
4101 
4102 	return;
4103 }
4104 
4105 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4106 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4107 				 vlan, "vlan");
4108 cmdline_parse_token_string_t cmd_vlan_offload_set =
4109 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4110 				 set, "set");
4111 cmdline_parse_token_string_t cmd_vlan_offload_what =
4112 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4113 				what, "strip#filter#qinq_strip#extend#stripq");
4114 cmdline_parse_token_string_t cmd_vlan_offload_on =
4115 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4116 			      on, "on#off");
4117 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4118 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4119 			      port_id, NULL);
4120 
4121 cmdline_parse_inst_t cmd_vlan_offload = {
4122 	.f = cmd_vlan_offload_parsed,
4123 	.data = NULL,
4124 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4125 		"<port_id[,queue_id]>: "
4126 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4127 	.tokens = {
4128 		(void *)&cmd_vlan_offload_vlan,
4129 		(void *)&cmd_vlan_offload_set,
4130 		(void *)&cmd_vlan_offload_what,
4131 		(void *)&cmd_vlan_offload_on,
4132 		(void *)&cmd_vlan_offload_portid,
4133 		NULL,
4134 	},
4135 };
4136 
4137 /* *** VLAN TPID SET ON A PORT *** */
4138 struct cmd_vlan_tpid_result {
4139 	cmdline_fixed_string_t vlan;
4140 	cmdline_fixed_string_t set;
4141 	cmdline_fixed_string_t vlan_type;
4142 	cmdline_fixed_string_t what;
4143 	uint16_t tp_id;
4144 	portid_t port_id;
4145 };
4146 
4147 static void
4148 cmd_vlan_tpid_parsed(void *parsed_result,
4149 			  __rte_unused struct cmdline *cl,
4150 			  __rte_unused void *data)
4151 {
4152 	struct cmd_vlan_tpid_result *res = parsed_result;
4153 	enum rte_vlan_type vlan_type;
4154 
4155 	if (!strcmp(res->vlan_type, "inner"))
4156 		vlan_type = ETH_VLAN_TYPE_INNER;
4157 	else if (!strcmp(res->vlan_type, "outer"))
4158 		vlan_type = ETH_VLAN_TYPE_OUTER;
4159 	else {
4160 		printf("Unknown vlan type\n");
4161 		return;
4162 	}
4163 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4164 }
4165 
4166 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4167 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4168 				 vlan, "vlan");
4169 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4170 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4171 				 set, "set");
4172 cmdline_parse_token_string_t cmd_vlan_type =
4173 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4174 				 vlan_type, "inner#outer");
4175 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4176 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4177 				 what, "tpid");
4178 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4179 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4180 			      tp_id, RTE_UINT16);
4181 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4182 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4183 			      port_id, RTE_UINT16);
4184 
4185 cmdline_parse_inst_t cmd_vlan_tpid = {
4186 	.f = cmd_vlan_tpid_parsed,
4187 	.data = NULL,
4188 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4189 		"Set the VLAN Ether type",
4190 	.tokens = {
4191 		(void *)&cmd_vlan_tpid_vlan,
4192 		(void *)&cmd_vlan_tpid_set,
4193 		(void *)&cmd_vlan_type,
4194 		(void *)&cmd_vlan_tpid_what,
4195 		(void *)&cmd_vlan_tpid_tpid,
4196 		(void *)&cmd_vlan_tpid_portid,
4197 		NULL,
4198 	},
4199 };
4200 
4201 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4202 struct cmd_rx_vlan_filter_result {
4203 	cmdline_fixed_string_t rx_vlan;
4204 	cmdline_fixed_string_t what;
4205 	uint16_t vlan_id;
4206 	portid_t port_id;
4207 };
4208 
4209 static void
4210 cmd_rx_vlan_filter_parsed(void *parsed_result,
4211 			  __rte_unused struct cmdline *cl,
4212 			  __rte_unused void *data)
4213 {
4214 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4215 
4216 	if (!strcmp(res->what, "add"))
4217 		rx_vft_set(res->port_id, res->vlan_id, 1);
4218 	else
4219 		rx_vft_set(res->port_id, res->vlan_id, 0);
4220 }
4221 
4222 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4223 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4224 				 rx_vlan, "rx_vlan");
4225 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4226 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4227 				 what, "add#rm");
4228 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4229 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4230 			      vlan_id, RTE_UINT16);
4231 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4232 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4233 			      port_id, RTE_UINT16);
4234 
4235 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4236 	.f = cmd_rx_vlan_filter_parsed,
4237 	.data = NULL,
4238 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4239 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4240 		"identifiers filtered by a port",
4241 	.tokens = {
4242 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4243 		(void *)&cmd_rx_vlan_filter_what,
4244 		(void *)&cmd_rx_vlan_filter_vlanid,
4245 		(void *)&cmd_rx_vlan_filter_portid,
4246 		NULL,
4247 	},
4248 };
4249 
4250 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4251 struct cmd_tx_vlan_set_result {
4252 	cmdline_fixed_string_t tx_vlan;
4253 	cmdline_fixed_string_t set;
4254 	portid_t port_id;
4255 	uint16_t vlan_id;
4256 };
4257 
4258 static void
4259 cmd_tx_vlan_set_parsed(void *parsed_result,
4260 		       __rte_unused struct cmdline *cl,
4261 		       __rte_unused void *data)
4262 {
4263 	struct cmd_tx_vlan_set_result *res = parsed_result;
4264 
4265 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4266 		return;
4267 
4268 	if (!port_is_stopped(res->port_id)) {
4269 		printf("Please stop port %d first\n", res->port_id);
4270 		return;
4271 	}
4272 
4273 	tx_vlan_set(res->port_id, res->vlan_id);
4274 
4275 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4276 }
4277 
4278 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4279 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4280 				 tx_vlan, "tx_vlan");
4281 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4282 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4283 				 set, "set");
4284 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4285 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4286 			      port_id, RTE_UINT16);
4287 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4288 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4289 			      vlan_id, RTE_UINT16);
4290 
4291 cmdline_parse_inst_t cmd_tx_vlan_set = {
4292 	.f = cmd_tx_vlan_set_parsed,
4293 	.data = NULL,
4294 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4295 		"Enable hardware insertion of a single VLAN header "
4296 		"with a given TAG Identifier in packets sent on a port",
4297 	.tokens = {
4298 		(void *)&cmd_tx_vlan_set_tx_vlan,
4299 		(void *)&cmd_tx_vlan_set_set,
4300 		(void *)&cmd_tx_vlan_set_portid,
4301 		(void *)&cmd_tx_vlan_set_vlanid,
4302 		NULL,
4303 	},
4304 };
4305 
4306 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4307 struct cmd_tx_vlan_set_qinq_result {
4308 	cmdline_fixed_string_t tx_vlan;
4309 	cmdline_fixed_string_t set;
4310 	portid_t port_id;
4311 	uint16_t vlan_id;
4312 	uint16_t vlan_id_outer;
4313 };
4314 
4315 static void
4316 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4317 			    __rte_unused struct cmdline *cl,
4318 			    __rte_unused void *data)
4319 {
4320 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4321 
4322 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4323 		return;
4324 
4325 	if (!port_is_stopped(res->port_id)) {
4326 		printf("Please stop port %d first\n", res->port_id);
4327 		return;
4328 	}
4329 
4330 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4331 
4332 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4333 }
4334 
4335 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4336 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4337 		tx_vlan, "tx_vlan");
4338 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4339 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4340 		set, "set");
4341 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4342 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4343 		port_id, RTE_UINT16);
4344 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4345 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4346 		vlan_id, RTE_UINT16);
4347 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4348 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4349 		vlan_id_outer, RTE_UINT16);
4350 
4351 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4352 	.f = cmd_tx_vlan_set_qinq_parsed,
4353 	.data = NULL,
4354 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4355 		"Enable hardware insertion of double VLAN header "
4356 		"with given TAG Identifiers in packets sent on a port",
4357 	.tokens = {
4358 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4359 		(void *)&cmd_tx_vlan_set_qinq_set,
4360 		(void *)&cmd_tx_vlan_set_qinq_portid,
4361 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4362 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4363 		NULL,
4364 	},
4365 };
4366 
4367 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4368 struct cmd_tx_vlan_set_pvid_result {
4369 	cmdline_fixed_string_t tx_vlan;
4370 	cmdline_fixed_string_t set;
4371 	cmdline_fixed_string_t pvid;
4372 	portid_t port_id;
4373 	uint16_t vlan_id;
4374 	cmdline_fixed_string_t mode;
4375 };
4376 
4377 static void
4378 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4379 			    __rte_unused struct cmdline *cl,
4380 			    __rte_unused void *data)
4381 {
4382 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4383 
4384 	if (strcmp(res->mode, "on") == 0)
4385 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4386 	else
4387 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4388 }
4389 
4390 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4391 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4392 				 tx_vlan, "tx_vlan");
4393 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4394 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4395 				 set, "set");
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4397 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4398 				 pvid, "pvid");
4399 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4400 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4401 			     port_id, RTE_UINT16);
4402 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4403 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4404 			      vlan_id, RTE_UINT16);
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4406 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4407 				 mode, "on#off");
4408 
4409 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4410 	.f = cmd_tx_vlan_set_pvid_parsed,
4411 	.data = NULL,
4412 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4413 	.tokens = {
4414 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4415 		(void *)&cmd_tx_vlan_set_pvid_set,
4416 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4417 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4418 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4419 		(void *)&cmd_tx_vlan_set_pvid_mode,
4420 		NULL,
4421 	},
4422 };
4423 
4424 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4425 struct cmd_tx_vlan_reset_result {
4426 	cmdline_fixed_string_t tx_vlan;
4427 	cmdline_fixed_string_t reset;
4428 	portid_t port_id;
4429 };
4430 
4431 static void
4432 cmd_tx_vlan_reset_parsed(void *parsed_result,
4433 			 __rte_unused struct cmdline *cl,
4434 			 __rte_unused void *data)
4435 {
4436 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4437 
4438 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4439 		return;
4440 
4441 	if (!port_is_stopped(res->port_id)) {
4442 		printf("Please stop port %d first\n", res->port_id);
4443 		return;
4444 	}
4445 
4446 	tx_vlan_reset(res->port_id);
4447 
4448 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4449 }
4450 
4451 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4452 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4453 				 tx_vlan, "tx_vlan");
4454 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4455 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4456 				 reset, "reset");
4457 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4458 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4459 			      port_id, RTE_UINT16);
4460 
4461 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4462 	.f = cmd_tx_vlan_reset_parsed,
4463 	.data = NULL,
4464 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4465 		"VLAN header in packets sent on a port",
4466 	.tokens = {
4467 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4468 		(void *)&cmd_tx_vlan_reset_reset,
4469 		(void *)&cmd_tx_vlan_reset_portid,
4470 		NULL,
4471 	},
4472 };
4473 
4474 
4475 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4476 struct cmd_csum_result {
4477 	cmdline_fixed_string_t csum;
4478 	cmdline_fixed_string_t mode;
4479 	cmdline_fixed_string_t proto;
4480 	cmdline_fixed_string_t hwsw;
4481 	portid_t port_id;
4482 };
4483 
4484 static void
4485 csum_show(int port_id)
4486 {
4487 	struct rte_eth_dev_info dev_info;
4488 	uint64_t tx_offloads;
4489 	int ret;
4490 
4491 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4492 	printf("Parse tunnel is %s\n",
4493 		(ports[port_id].parse_tunnel) ? "on" : "off");
4494 	printf("IP checksum offload is %s\n",
4495 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4496 	printf("UDP checksum offload is %s\n",
4497 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4498 	printf("TCP checksum offload is %s\n",
4499 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4500 	printf("SCTP checksum offload is %s\n",
4501 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4502 	printf("Outer-Ip checksum offload is %s\n",
4503 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4504 	printf("Outer-Udp checksum offload is %s\n",
4505 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4506 
4507 	/* display warnings if configuration is not supported by the NIC */
4508 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4509 	if (ret != 0)
4510 		return;
4511 
4512 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4513 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4514 		printf("Warning: hardware IP checksum enabled but not "
4515 			"supported by port %d\n", port_id);
4516 	}
4517 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4518 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4519 		printf("Warning: hardware UDP checksum enabled but not "
4520 			"supported by port %d\n", port_id);
4521 	}
4522 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4523 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4524 		printf("Warning: hardware TCP checksum enabled but not "
4525 			"supported by port %d\n", port_id);
4526 	}
4527 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4528 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4529 		printf("Warning: hardware SCTP checksum enabled but not "
4530 			"supported by port %d\n", port_id);
4531 	}
4532 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4533 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4534 		printf("Warning: hardware outer IP checksum enabled but not "
4535 			"supported by port %d\n", port_id);
4536 	}
4537 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4538 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4539 			== 0) {
4540 		printf("Warning: hardware outer UDP checksum enabled but not "
4541 			"supported by port %d\n", port_id);
4542 	}
4543 }
4544 
4545 static void
4546 cmd_config_queue_tx_offloads(struct rte_port *port)
4547 {
4548 	int k;
4549 
4550 	/* Apply queue tx offloads configuration */
4551 	for (k = 0; k < port->dev_info.max_rx_queues; k++)
4552 		port->tx_conf[k].offloads =
4553 			port->dev_conf.txmode.offloads;
4554 }
4555 
4556 static void
4557 cmd_csum_parsed(void *parsed_result,
4558 		       __rte_unused struct cmdline *cl,
4559 		       __rte_unused void *data)
4560 {
4561 	struct cmd_csum_result *res = parsed_result;
4562 	int hw = 0;
4563 	uint64_t csum_offloads = 0;
4564 	struct rte_eth_dev_info dev_info;
4565 	int ret;
4566 
4567 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4568 		printf("invalid port %d\n", res->port_id);
4569 		return;
4570 	}
4571 	if (!port_is_stopped(res->port_id)) {
4572 		printf("Please stop port %d first\n", res->port_id);
4573 		return;
4574 	}
4575 
4576 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4577 	if (ret != 0)
4578 		return;
4579 
4580 	if (!strcmp(res->mode, "set")) {
4581 
4582 		if (!strcmp(res->hwsw, "hw"))
4583 			hw = 1;
4584 
4585 		if (!strcmp(res->proto, "ip")) {
4586 			if (hw == 0 || (dev_info.tx_offload_capa &
4587 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4588 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4589 			} else {
4590 				printf("IP checksum offload is not supported "
4591 				       "by port %u\n", res->port_id);
4592 			}
4593 		} else if (!strcmp(res->proto, "udp")) {
4594 			if (hw == 0 || (dev_info.tx_offload_capa &
4595 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4596 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4597 			} else {
4598 				printf("UDP checksum offload is not supported "
4599 				       "by port %u\n", res->port_id);
4600 			}
4601 		} else if (!strcmp(res->proto, "tcp")) {
4602 			if (hw == 0 || (dev_info.tx_offload_capa &
4603 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4604 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4605 			} else {
4606 				printf("TCP checksum offload is not supported "
4607 				       "by port %u\n", res->port_id);
4608 			}
4609 		} else if (!strcmp(res->proto, "sctp")) {
4610 			if (hw == 0 || (dev_info.tx_offload_capa &
4611 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4612 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4613 			} else {
4614 				printf("SCTP checksum offload is not supported "
4615 				       "by port %u\n", res->port_id);
4616 			}
4617 		} else if (!strcmp(res->proto, "outer-ip")) {
4618 			if (hw == 0 || (dev_info.tx_offload_capa &
4619 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4620 				csum_offloads |=
4621 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4622 			} else {
4623 				printf("Outer IP checksum offload is not "
4624 				       "supported by port %u\n", res->port_id);
4625 			}
4626 		} else if (!strcmp(res->proto, "outer-udp")) {
4627 			if (hw == 0 || (dev_info.tx_offload_capa &
4628 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4629 				csum_offloads |=
4630 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4631 			} else {
4632 				printf("Outer UDP checksum offload is not "
4633 				       "supported by port %u\n", res->port_id);
4634 			}
4635 		}
4636 
4637 		if (hw) {
4638 			ports[res->port_id].dev_conf.txmode.offloads |=
4639 							csum_offloads;
4640 		} else {
4641 			ports[res->port_id].dev_conf.txmode.offloads &=
4642 							(~csum_offloads);
4643 		}
4644 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4645 	}
4646 	csum_show(res->port_id);
4647 
4648 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4649 }
4650 
4651 cmdline_parse_token_string_t cmd_csum_csum =
4652 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4653 				csum, "csum");
4654 cmdline_parse_token_string_t cmd_csum_mode =
4655 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4656 				mode, "set");
4657 cmdline_parse_token_string_t cmd_csum_proto =
4658 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4659 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4660 cmdline_parse_token_string_t cmd_csum_hwsw =
4661 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4662 				hwsw, "hw#sw");
4663 cmdline_parse_token_num_t cmd_csum_portid =
4664 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4665 				port_id, RTE_UINT16);
4666 
4667 cmdline_parse_inst_t cmd_csum_set = {
4668 	.f = cmd_csum_parsed,
4669 	.data = NULL,
4670 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4671 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4672 		"using csum forward engine",
4673 	.tokens = {
4674 		(void *)&cmd_csum_csum,
4675 		(void *)&cmd_csum_mode,
4676 		(void *)&cmd_csum_proto,
4677 		(void *)&cmd_csum_hwsw,
4678 		(void *)&cmd_csum_portid,
4679 		NULL,
4680 	},
4681 };
4682 
4683 cmdline_parse_token_string_t cmd_csum_mode_show =
4684 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4685 				mode, "show");
4686 
4687 cmdline_parse_inst_t cmd_csum_show = {
4688 	.f = cmd_csum_parsed,
4689 	.data = NULL,
4690 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4691 	.tokens = {
4692 		(void *)&cmd_csum_csum,
4693 		(void *)&cmd_csum_mode_show,
4694 		(void *)&cmd_csum_portid,
4695 		NULL,
4696 	},
4697 };
4698 
4699 /* Enable/disable tunnel parsing */
4700 struct cmd_csum_tunnel_result {
4701 	cmdline_fixed_string_t csum;
4702 	cmdline_fixed_string_t parse;
4703 	cmdline_fixed_string_t onoff;
4704 	portid_t port_id;
4705 };
4706 
4707 static void
4708 cmd_csum_tunnel_parsed(void *parsed_result,
4709 		       __rte_unused struct cmdline *cl,
4710 		       __rte_unused void *data)
4711 {
4712 	struct cmd_csum_tunnel_result *res = parsed_result;
4713 
4714 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4715 		return;
4716 
4717 	if (!strcmp(res->onoff, "on"))
4718 		ports[res->port_id].parse_tunnel = 1;
4719 	else
4720 		ports[res->port_id].parse_tunnel = 0;
4721 
4722 	csum_show(res->port_id);
4723 }
4724 
4725 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4726 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4727 				csum, "csum");
4728 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4729 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4730 				parse, "parse-tunnel");
4731 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4732 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4733 				onoff, "on#off");
4734 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4735 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4736 				port_id, RTE_UINT16);
4737 
4738 cmdline_parse_inst_t cmd_csum_tunnel = {
4739 	.f = cmd_csum_tunnel_parsed,
4740 	.data = NULL,
4741 	.help_str = "csum parse-tunnel on|off <port_id>: "
4742 		"Enable/Disable parsing of tunnels for csum engine",
4743 	.tokens = {
4744 		(void *)&cmd_csum_tunnel_csum,
4745 		(void *)&cmd_csum_tunnel_parse,
4746 		(void *)&cmd_csum_tunnel_onoff,
4747 		(void *)&cmd_csum_tunnel_portid,
4748 		NULL,
4749 	},
4750 };
4751 
4752 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4753 struct cmd_tso_set_result {
4754 	cmdline_fixed_string_t tso;
4755 	cmdline_fixed_string_t mode;
4756 	uint16_t tso_segsz;
4757 	portid_t port_id;
4758 };
4759 
4760 static void
4761 cmd_tso_set_parsed(void *parsed_result,
4762 		       __rte_unused struct cmdline *cl,
4763 		       __rte_unused void *data)
4764 {
4765 	struct cmd_tso_set_result *res = parsed_result;
4766 	struct rte_eth_dev_info dev_info;
4767 	int ret;
4768 
4769 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4770 		return;
4771 	if (!port_is_stopped(res->port_id)) {
4772 		printf("Please stop port %d first\n", res->port_id);
4773 		return;
4774 	}
4775 
4776 	if (!strcmp(res->mode, "set"))
4777 		ports[res->port_id].tso_segsz = res->tso_segsz;
4778 
4779 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4780 	if (ret != 0)
4781 		return;
4782 
4783 	if ((ports[res->port_id].tso_segsz != 0) &&
4784 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4785 		printf("Error: TSO is not supported by port %d\n",
4786 		       res->port_id);
4787 		return;
4788 	}
4789 
4790 	if (ports[res->port_id].tso_segsz == 0) {
4791 		ports[res->port_id].dev_conf.txmode.offloads &=
4792 						~DEV_TX_OFFLOAD_TCP_TSO;
4793 		printf("TSO for non-tunneled packets is disabled\n");
4794 	} else {
4795 		ports[res->port_id].dev_conf.txmode.offloads |=
4796 						DEV_TX_OFFLOAD_TCP_TSO;
4797 		printf("TSO segment size for non-tunneled packets is %d\n",
4798 			ports[res->port_id].tso_segsz);
4799 	}
4800 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4801 
4802 	/* display warnings if configuration is not supported by the NIC */
4803 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4804 	if (ret != 0)
4805 		return;
4806 
4807 	if ((ports[res->port_id].tso_segsz != 0) &&
4808 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4809 		printf("Warning: TSO enabled but not "
4810 			"supported by port %d\n", res->port_id);
4811 	}
4812 
4813 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4814 }
4815 
4816 cmdline_parse_token_string_t cmd_tso_set_tso =
4817 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4818 				tso, "tso");
4819 cmdline_parse_token_string_t cmd_tso_set_mode =
4820 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4821 				mode, "set");
4822 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4823 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4824 				tso_segsz, RTE_UINT16);
4825 cmdline_parse_token_num_t cmd_tso_set_portid =
4826 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4827 				port_id, RTE_UINT16);
4828 
4829 cmdline_parse_inst_t cmd_tso_set = {
4830 	.f = cmd_tso_set_parsed,
4831 	.data = NULL,
4832 	.help_str = "tso set <tso_segsz> <port_id>: "
4833 		"Set TSO segment size of non-tunneled packets for csum engine "
4834 		"(0 to disable)",
4835 	.tokens = {
4836 		(void *)&cmd_tso_set_tso,
4837 		(void *)&cmd_tso_set_mode,
4838 		(void *)&cmd_tso_set_tso_segsz,
4839 		(void *)&cmd_tso_set_portid,
4840 		NULL,
4841 	},
4842 };
4843 
4844 cmdline_parse_token_string_t cmd_tso_show_mode =
4845 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4846 				mode, "show");
4847 
4848 
4849 cmdline_parse_inst_t cmd_tso_show = {
4850 	.f = cmd_tso_set_parsed,
4851 	.data = NULL,
4852 	.help_str = "tso show <port_id>: "
4853 		"Show TSO segment size of non-tunneled packets for csum engine",
4854 	.tokens = {
4855 		(void *)&cmd_tso_set_tso,
4856 		(void *)&cmd_tso_show_mode,
4857 		(void *)&cmd_tso_set_portid,
4858 		NULL,
4859 	},
4860 };
4861 
4862 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4863 struct cmd_tunnel_tso_set_result {
4864 	cmdline_fixed_string_t tso;
4865 	cmdline_fixed_string_t mode;
4866 	uint16_t tso_segsz;
4867 	portid_t port_id;
4868 };
4869 
4870 static struct rte_eth_dev_info
4871 check_tunnel_tso_nic_support(portid_t port_id)
4872 {
4873 	struct rte_eth_dev_info dev_info;
4874 
4875 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4876 		return dev_info;
4877 
4878 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4879 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4880 		       "not enabled for port %d\n", port_id);
4881 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4882 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4883 		       "not enabled for port %d\n", port_id);
4884 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4885 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
4886 		       "not enabled for port %d\n", port_id);
4887 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4888 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4889 		       "not enabled for port %d\n", port_id);
4890 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4891 		printf("Warning: IP TUNNEL TSO not supported therefore "
4892 		       "not enabled for port %d\n", port_id);
4893 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4894 		printf("Warning: UDP TUNNEL TSO not supported therefore "
4895 		       "not enabled for port %d\n", port_id);
4896 	return dev_info;
4897 }
4898 
4899 static void
4900 cmd_tunnel_tso_set_parsed(void *parsed_result,
4901 			  __rte_unused struct cmdline *cl,
4902 			  __rte_unused void *data)
4903 {
4904 	struct cmd_tunnel_tso_set_result *res = parsed_result;
4905 	struct rte_eth_dev_info dev_info;
4906 
4907 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4908 		return;
4909 	if (!port_is_stopped(res->port_id)) {
4910 		printf("Please stop port %d first\n", res->port_id);
4911 		return;
4912 	}
4913 
4914 	if (!strcmp(res->mode, "set"))
4915 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4916 
4917 	dev_info = check_tunnel_tso_nic_support(res->port_id);
4918 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4919 		ports[res->port_id].dev_conf.txmode.offloads &=
4920 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4921 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4922 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4923 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4924 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
4925 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
4926 		printf("TSO for tunneled packets is disabled\n");
4927 	} else {
4928 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4929 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4930 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4931 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4932 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
4933 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4934 
4935 		ports[res->port_id].dev_conf.txmode.offloads |=
4936 			(tso_offloads & dev_info.tx_offload_capa);
4937 		printf("TSO segment size for tunneled packets is %d\n",
4938 			ports[res->port_id].tunnel_tso_segsz);
4939 
4940 		/* Below conditions are needed to make it work:
4941 		 * (1) tunnel TSO is supported by the NIC;
4942 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4943 		 * are recognized;
4944 		 * (3) for tunneled pkts with outer L3 of IPv4,
4945 		 * "csum set outer-ip" must be set to hw, because after tso,
4946 		 * total_len of outer IP header is changed, and the checksum
4947 		 * of outer IP header calculated by sw should be wrong; that
4948 		 * is not necessary for IPv6 tunneled pkts because there's no
4949 		 * checksum in IP header anymore.
4950 		 */
4951 
4952 		if (!ports[res->port_id].parse_tunnel)
4953 			printf("Warning: csum parse_tunnel must be set "
4954 				"so that tunneled packets are recognized\n");
4955 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4956 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4957 			printf("Warning: csum set outer-ip must be set to hw "
4958 				"if outer L3 is IPv4; not necessary for IPv6\n");
4959 	}
4960 
4961 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4962 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4963 }
4964 
4965 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4966 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4967 				tso, "tunnel_tso");
4968 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4969 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4970 				mode, "set");
4971 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4972 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4973 				tso_segsz, RTE_UINT16);
4974 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4975 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4976 				port_id, RTE_UINT16);
4977 
4978 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4979 	.f = cmd_tunnel_tso_set_parsed,
4980 	.data = NULL,
4981 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4982 		"Set TSO segment size of tunneled packets for csum engine "
4983 		"(0 to disable)",
4984 	.tokens = {
4985 		(void *)&cmd_tunnel_tso_set_tso,
4986 		(void *)&cmd_tunnel_tso_set_mode,
4987 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4988 		(void *)&cmd_tunnel_tso_set_portid,
4989 		NULL,
4990 	},
4991 };
4992 
4993 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4994 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4995 				mode, "show");
4996 
4997 
4998 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4999 	.f = cmd_tunnel_tso_set_parsed,
5000 	.data = NULL,
5001 	.help_str = "tunnel_tso show <port_id> "
5002 		"Show TSO segment size of tunneled packets for csum engine",
5003 	.tokens = {
5004 		(void *)&cmd_tunnel_tso_set_tso,
5005 		(void *)&cmd_tunnel_tso_show_mode,
5006 		(void *)&cmd_tunnel_tso_set_portid,
5007 		NULL,
5008 	},
5009 };
5010 
5011 /* *** SET GRO FOR A PORT *** */
5012 struct cmd_gro_enable_result {
5013 	cmdline_fixed_string_t cmd_set;
5014 	cmdline_fixed_string_t cmd_port;
5015 	cmdline_fixed_string_t cmd_keyword;
5016 	cmdline_fixed_string_t cmd_onoff;
5017 	portid_t cmd_pid;
5018 };
5019 
5020 static void
5021 cmd_gro_enable_parsed(void *parsed_result,
5022 		__rte_unused struct cmdline *cl,
5023 		__rte_unused void *data)
5024 {
5025 	struct cmd_gro_enable_result *res;
5026 
5027 	res = parsed_result;
5028 	if (!strcmp(res->cmd_keyword, "gro"))
5029 		setup_gro(res->cmd_onoff, res->cmd_pid);
5030 }
5031 
5032 cmdline_parse_token_string_t cmd_gro_enable_set =
5033 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5034 			cmd_set, "set");
5035 cmdline_parse_token_string_t cmd_gro_enable_port =
5036 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5037 			cmd_keyword, "port");
5038 cmdline_parse_token_num_t cmd_gro_enable_pid =
5039 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5040 			cmd_pid, RTE_UINT16);
5041 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5042 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5043 			cmd_keyword, "gro");
5044 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5045 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5046 			cmd_onoff, "on#off");
5047 
5048 cmdline_parse_inst_t cmd_gro_enable = {
5049 	.f = cmd_gro_enable_parsed,
5050 	.data = NULL,
5051 	.help_str = "set port <port_id> gro on|off",
5052 	.tokens = {
5053 		(void *)&cmd_gro_enable_set,
5054 		(void *)&cmd_gro_enable_port,
5055 		(void *)&cmd_gro_enable_pid,
5056 		(void *)&cmd_gro_enable_keyword,
5057 		(void *)&cmd_gro_enable_onoff,
5058 		NULL,
5059 	},
5060 };
5061 
5062 /* *** DISPLAY GRO CONFIGURATION *** */
5063 struct cmd_gro_show_result {
5064 	cmdline_fixed_string_t cmd_show;
5065 	cmdline_fixed_string_t cmd_port;
5066 	cmdline_fixed_string_t cmd_keyword;
5067 	portid_t cmd_pid;
5068 };
5069 
5070 static void
5071 cmd_gro_show_parsed(void *parsed_result,
5072 		__rte_unused struct cmdline *cl,
5073 		__rte_unused void *data)
5074 {
5075 	struct cmd_gro_show_result *res;
5076 
5077 	res = parsed_result;
5078 	if (!strcmp(res->cmd_keyword, "gro"))
5079 		show_gro(res->cmd_pid);
5080 }
5081 
5082 cmdline_parse_token_string_t cmd_gro_show_show =
5083 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5084 			cmd_show, "show");
5085 cmdline_parse_token_string_t cmd_gro_show_port =
5086 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5087 			cmd_port, "port");
5088 cmdline_parse_token_num_t cmd_gro_show_pid =
5089 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5090 			cmd_pid, RTE_UINT16);
5091 cmdline_parse_token_string_t cmd_gro_show_keyword =
5092 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5093 			cmd_keyword, "gro");
5094 
5095 cmdline_parse_inst_t cmd_gro_show = {
5096 	.f = cmd_gro_show_parsed,
5097 	.data = NULL,
5098 	.help_str = "show port <port_id> gro",
5099 	.tokens = {
5100 		(void *)&cmd_gro_show_show,
5101 		(void *)&cmd_gro_show_port,
5102 		(void *)&cmd_gro_show_pid,
5103 		(void *)&cmd_gro_show_keyword,
5104 		NULL,
5105 	},
5106 };
5107 
5108 /* *** SET FLUSH CYCLES FOR GRO *** */
5109 struct cmd_gro_flush_result {
5110 	cmdline_fixed_string_t cmd_set;
5111 	cmdline_fixed_string_t cmd_keyword;
5112 	cmdline_fixed_string_t cmd_flush;
5113 	uint8_t cmd_cycles;
5114 };
5115 
5116 static void
5117 cmd_gro_flush_parsed(void *parsed_result,
5118 		__rte_unused struct cmdline *cl,
5119 		__rte_unused void *data)
5120 {
5121 	struct cmd_gro_flush_result *res;
5122 
5123 	res = parsed_result;
5124 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5125 			(!strcmp(res->cmd_flush, "flush")))
5126 		setup_gro_flush_cycles(res->cmd_cycles);
5127 }
5128 
5129 cmdline_parse_token_string_t cmd_gro_flush_set =
5130 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5131 			cmd_set, "set");
5132 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5133 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5134 			cmd_keyword, "gro");
5135 cmdline_parse_token_string_t cmd_gro_flush_flush =
5136 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5137 			cmd_flush, "flush");
5138 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5139 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5140 			cmd_cycles, RTE_UINT8);
5141 
5142 cmdline_parse_inst_t cmd_gro_flush = {
5143 	.f = cmd_gro_flush_parsed,
5144 	.data = NULL,
5145 	.help_str = "set gro flush <cycles>",
5146 	.tokens = {
5147 		(void *)&cmd_gro_flush_set,
5148 		(void *)&cmd_gro_flush_keyword,
5149 		(void *)&cmd_gro_flush_flush,
5150 		(void *)&cmd_gro_flush_cycles,
5151 		NULL,
5152 	},
5153 };
5154 
5155 /* *** ENABLE/DISABLE GSO *** */
5156 struct cmd_gso_enable_result {
5157 	cmdline_fixed_string_t cmd_set;
5158 	cmdline_fixed_string_t cmd_port;
5159 	cmdline_fixed_string_t cmd_keyword;
5160 	cmdline_fixed_string_t cmd_mode;
5161 	portid_t cmd_pid;
5162 };
5163 
5164 static void
5165 cmd_gso_enable_parsed(void *parsed_result,
5166 		__rte_unused struct cmdline *cl,
5167 		__rte_unused void *data)
5168 {
5169 	struct cmd_gso_enable_result *res;
5170 
5171 	res = parsed_result;
5172 	if (!strcmp(res->cmd_keyword, "gso"))
5173 		setup_gso(res->cmd_mode, res->cmd_pid);
5174 }
5175 
5176 cmdline_parse_token_string_t cmd_gso_enable_set =
5177 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5178 			cmd_set, "set");
5179 cmdline_parse_token_string_t cmd_gso_enable_port =
5180 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5181 			cmd_port, "port");
5182 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5183 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5184 			cmd_keyword, "gso");
5185 cmdline_parse_token_string_t cmd_gso_enable_mode =
5186 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5187 			cmd_mode, "on#off");
5188 cmdline_parse_token_num_t cmd_gso_enable_pid =
5189 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5190 			cmd_pid, RTE_UINT16);
5191 
5192 cmdline_parse_inst_t cmd_gso_enable = {
5193 	.f = cmd_gso_enable_parsed,
5194 	.data = NULL,
5195 	.help_str = "set port <port_id> gso on|off",
5196 	.tokens = {
5197 		(void *)&cmd_gso_enable_set,
5198 		(void *)&cmd_gso_enable_port,
5199 		(void *)&cmd_gso_enable_pid,
5200 		(void *)&cmd_gso_enable_keyword,
5201 		(void *)&cmd_gso_enable_mode,
5202 		NULL,
5203 	},
5204 };
5205 
5206 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5207 struct cmd_gso_size_result {
5208 	cmdline_fixed_string_t cmd_set;
5209 	cmdline_fixed_string_t cmd_keyword;
5210 	cmdline_fixed_string_t cmd_segsz;
5211 	uint16_t cmd_size;
5212 };
5213 
5214 static void
5215 cmd_gso_size_parsed(void *parsed_result,
5216 		       __rte_unused struct cmdline *cl,
5217 		       __rte_unused void *data)
5218 {
5219 	struct cmd_gso_size_result *res = parsed_result;
5220 
5221 	if (test_done == 0) {
5222 		printf("Before setting GSO segsz, please first"
5223 				" stop forwarding\n");
5224 		return;
5225 	}
5226 
5227 	if (!strcmp(res->cmd_keyword, "gso") &&
5228 			!strcmp(res->cmd_segsz, "segsz")) {
5229 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5230 			printf("gso_size should be larger than %zu."
5231 					" Please input a legal value\n",
5232 					RTE_GSO_SEG_SIZE_MIN);
5233 		else
5234 			gso_max_segment_size = res->cmd_size;
5235 	}
5236 }
5237 
5238 cmdline_parse_token_string_t cmd_gso_size_set =
5239 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5240 				cmd_set, "set");
5241 cmdline_parse_token_string_t cmd_gso_size_keyword =
5242 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5243 				cmd_keyword, "gso");
5244 cmdline_parse_token_string_t cmd_gso_size_segsz =
5245 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5246 				cmd_segsz, "segsz");
5247 cmdline_parse_token_num_t cmd_gso_size_size =
5248 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5249 				cmd_size, RTE_UINT16);
5250 
5251 cmdline_parse_inst_t cmd_gso_size = {
5252 	.f = cmd_gso_size_parsed,
5253 	.data = NULL,
5254 	.help_str = "set gso segsz <length>",
5255 	.tokens = {
5256 		(void *)&cmd_gso_size_set,
5257 		(void *)&cmd_gso_size_keyword,
5258 		(void *)&cmd_gso_size_segsz,
5259 		(void *)&cmd_gso_size_size,
5260 		NULL,
5261 	},
5262 };
5263 
5264 /* *** SHOW GSO CONFIGURATION *** */
5265 struct cmd_gso_show_result {
5266 	cmdline_fixed_string_t cmd_show;
5267 	cmdline_fixed_string_t cmd_port;
5268 	cmdline_fixed_string_t cmd_keyword;
5269 	portid_t cmd_pid;
5270 };
5271 
5272 static void
5273 cmd_gso_show_parsed(void *parsed_result,
5274 		       __rte_unused struct cmdline *cl,
5275 		       __rte_unused void *data)
5276 {
5277 	struct cmd_gso_show_result *res = parsed_result;
5278 
5279 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5280 		printf("invalid port id %u\n", res->cmd_pid);
5281 		return;
5282 	}
5283 	if (!strcmp(res->cmd_keyword, "gso")) {
5284 		if (gso_ports[res->cmd_pid].enable) {
5285 			printf("Max GSO'd packet size: %uB\n"
5286 					"Supported GSO types: TCP/IPv4, "
5287 					"UDP/IPv4, VxLAN with inner "
5288 					"TCP/IPv4 packet, GRE with inner "
5289 					"TCP/IPv4 packet\n",
5290 					gso_max_segment_size);
5291 		} else
5292 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5293 	}
5294 }
5295 
5296 cmdline_parse_token_string_t cmd_gso_show_show =
5297 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5298 		cmd_show, "show");
5299 cmdline_parse_token_string_t cmd_gso_show_port =
5300 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5301 		cmd_port, "port");
5302 cmdline_parse_token_string_t cmd_gso_show_keyword =
5303 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5304 				cmd_keyword, "gso");
5305 cmdline_parse_token_num_t cmd_gso_show_pid =
5306 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5307 				cmd_pid, RTE_UINT16);
5308 
5309 cmdline_parse_inst_t cmd_gso_show = {
5310 	.f = cmd_gso_show_parsed,
5311 	.data = NULL,
5312 	.help_str = "show port <port_id> gso",
5313 	.tokens = {
5314 		(void *)&cmd_gso_show_show,
5315 		(void *)&cmd_gso_show_port,
5316 		(void *)&cmd_gso_show_pid,
5317 		(void *)&cmd_gso_show_keyword,
5318 		NULL,
5319 	},
5320 };
5321 
5322 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5323 struct cmd_set_flush_rx {
5324 	cmdline_fixed_string_t set;
5325 	cmdline_fixed_string_t flush_rx;
5326 	cmdline_fixed_string_t mode;
5327 };
5328 
5329 static void
5330 cmd_set_flush_rx_parsed(void *parsed_result,
5331 		__rte_unused struct cmdline *cl,
5332 		__rte_unused void *data)
5333 {
5334 	struct cmd_set_flush_rx *res = parsed_result;
5335 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5336 }
5337 
5338 cmdline_parse_token_string_t cmd_setflushrx_set =
5339 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5340 			set, "set");
5341 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5342 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5343 			flush_rx, "flush_rx");
5344 cmdline_parse_token_string_t cmd_setflushrx_mode =
5345 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5346 			mode, "on#off");
5347 
5348 
5349 cmdline_parse_inst_t cmd_set_flush_rx = {
5350 	.f = cmd_set_flush_rx_parsed,
5351 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5352 	.data = NULL,
5353 	.tokens = {
5354 		(void *)&cmd_setflushrx_set,
5355 		(void *)&cmd_setflushrx_flush_rx,
5356 		(void *)&cmd_setflushrx_mode,
5357 		NULL,
5358 	},
5359 };
5360 
5361 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5362 struct cmd_set_link_check {
5363 	cmdline_fixed_string_t set;
5364 	cmdline_fixed_string_t link_check;
5365 	cmdline_fixed_string_t mode;
5366 };
5367 
5368 static void
5369 cmd_set_link_check_parsed(void *parsed_result,
5370 		__rte_unused struct cmdline *cl,
5371 		__rte_unused void *data)
5372 {
5373 	struct cmd_set_link_check *res = parsed_result;
5374 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5375 }
5376 
5377 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5378 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5379 			set, "set");
5380 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5381 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5382 			link_check, "link_check");
5383 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5384 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5385 			mode, "on#off");
5386 
5387 
5388 cmdline_parse_inst_t cmd_set_link_check = {
5389 	.f = cmd_set_link_check_parsed,
5390 	.help_str = "set link_check on|off: Enable/Disable link status check "
5391 	            "when starting/stopping a port",
5392 	.data = NULL,
5393 	.tokens = {
5394 		(void *)&cmd_setlinkcheck_set,
5395 		(void *)&cmd_setlinkcheck_link_check,
5396 		(void *)&cmd_setlinkcheck_mode,
5397 		NULL,
5398 	},
5399 };
5400 
5401 /* *** SET NIC BYPASS MODE *** */
5402 struct cmd_set_bypass_mode_result {
5403 	cmdline_fixed_string_t set;
5404 	cmdline_fixed_string_t bypass;
5405 	cmdline_fixed_string_t mode;
5406 	cmdline_fixed_string_t value;
5407 	portid_t port_id;
5408 };
5409 
5410 static void
5411 cmd_set_bypass_mode_parsed(void *parsed_result,
5412 		__rte_unused struct cmdline *cl,
5413 		__rte_unused void *data)
5414 {
5415 	struct cmd_set_bypass_mode_result *res = parsed_result;
5416 	portid_t port_id = res->port_id;
5417 	int32_t rc = -EINVAL;
5418 
5419 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5420 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5421 
5422 	if (!strcmp(res->value, "bypass"))
5423 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5424 	else if (!strcmp(res->value, "isolate"))
5425 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5426 	else
5427 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5428 
5429 	/* Set the bypass mode for the relevant port. */
5430 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5431 #endif
5432 	if (rc != 0)
5433 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5434 }
5435 
5436 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5437 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5438 			set, "set");
5439 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5440 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5441 			bypass, "bypass");
5442 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5443 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5444 			mode, "mode");
5445 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5446 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5447 			value, "normal#bypass#isolate");
5448 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5449 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5450 				port_id, RTE_UINT16);
5451 
5452 cmdline_parse_inst_t cmd_set_bypass_mode = {
5453 	.f = cmd_set_bypass_mode_parsed,
5454 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5455 	            "Set the NIC bypass mode for port_id",
5456 	.data = NULL,
5457 	.tokens = {
5458 		(void *)&cmd_setbypass_mode_set,
5459 		(void *)&cmd_setbypass_mode_bypass,
5460 		(void *)&cmd_setbypass_mode_mode,
5461 		(void *)&cmd_setbypass_mode_value,
5462 		(void *)&cmd_setbypass_mode_port,
5463 		NULL,
5464 	},
5465 };
5466 
5467 /* *** SET NIC BYPASS EVENT *** */
5468 struct cmd_set_bypass_event_result {
5469 	cmdline_fixed_string_t set;
5470 	cmdline_fixed_string_t bypass;
5471 	cmdline_fixed_string_t event;
5472 	cmdline_fixed_string_t event_value;
5473 	cmdline_fixed_string_t mode;
5474 	cmdline_fixed_string_t mode_value;
5475 	portid_t port_id;
5476 };
5477 
5478 static void
5479 cmd_set_bypass_event_parsed(void *parsed_result,
5480 		__rte_unused struct cmdline *cl,
5481 		__rte_unused void *data)
5482 {
5483 	int32_t rc = -EINVAL;
5484 	struct cmd_set_bypass_event_result *res = parsed_result;
5485 	portid_t port_id = res->port_id;
5486 
5487 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5488 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5489 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5490 
5491 	if (!strcmp(res->event_value, "timeout"))
5492 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5493 	else if (!strcmp(res->event_value, "os_on"))
5494 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5495 	else if (!strcmp(res->event_value, "os_off"))
5496 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5497 	else if (!strcmp(res->event_value, "power_on"))
5498 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5499 	else if (!strcmp(res->event_value, "power_off"))
5500 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5501 	else
5502 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5503 
5504 	if (!strcmp(res->mode_value, "bypass"))
5505 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5506 	else if (!strcmp(res->mode_value, "isolate"))
5507 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5508 	else
5509 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5510 
5511 	/* Set the watchdog timeout. */
5512 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5513 
5514 		rc = -EINVAL;
5515 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5516 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5517 							   bypass_timeout);
5518 		}
5519 		if (rc != 0) {
5520 			printf("Failed to set timeout value %u "
5521 			"for port %d, errto code: %d.\n",
5522 			bypass_timeout, port_id, rc);
5523 		}
5524 	}
5525 
5526 	/* Set the bypass event to transition to bypass mode. */
5527 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5528 					      bypass_mode);
5529 #endif
5530 
5531 	if (rc != 0)
5532 		printf("\t Failed to set bypass event for port = %d.\n",
5533 		       port_id);
5534 }
5535 
5536 cmdline_parse_token_string_t cmd_setbypass_event_set =
5537 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5538 			set, "set");
5539 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5540 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5541 			bypass, "bypass");
5542 cmdline_parse_token_string_t cmd_setbypass_event_event =
5543 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5544 			event, "event");
5545 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5546 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5547 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5548 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5549 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5550 			mode, "mode");
5551 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5552 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5553 			mode_value, "normal#bypass#isolate");
5554 cmdline_parse_token_num_t cmd_setbypass_event_port =
5555 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5556 				port_id, RTE_UINT16);
5557 
5558 cmdline_parse_inst_t cmd_set_bypass_event = {
5559 	.f = cmd_set_bypass_event_parsed,
5560 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5561 		"power_off mode normal|bypass|isolate <port_id>: "
5562 		"Set the NIC bypass event mode for port_id",
5563 	.data = NULL,
5564 	.tokens = {
5565 		(void *)&cmd_setbypass_event_set,
5566 		(void *)&cmd_setbypass_event_bypass,
5567 		(void *)&cmd_setbypass_event_event,
5568 		(void *)&cmd_setbypass_event_event_value,
5569 		(void *)&cmd_setbypass_event_mode,
5570 		(void *)&cmd_setbypass_event_mode_value,
5571 		(void *)&cmd_setbypass_event_port,
5572 		NULL,
5573 	},
5574 };
5575 
5576 
5577 /* *** SET NIC BYPASS TIMEOUT *** */
5578 struct cmd_set_bypass_timeout_result {
5579 	cmdline_fixed_string_t set;
5580 	cmdline_fixed_string_t bypass;
5581 	cmdline_fixed_string_t timeout;
5582 	cmdline_fixed_string_t value;
5583 };
5584 
5585 static void
5586 cmd_set_bypass_timeout_parsed(void *parsed_result,
5587 		__rte_unused struct cmdline *cl,
5588 		__rte_unused void *data)
5589 {
5590 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5591 
5592 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5593 	if (!strcmp(res->value, "1.5"))
5594 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5595 	else if (!strcmp(res->value, "2"))
5596 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5597 	else if (!strcmp(res->value, "3"))
5598 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5599 	else if (!strcmp(res->value, "4"))
5600 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5601 	else if (!strcmp(res->value, "8"))
5602 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5603 	else if (!strcmp(res->value, "16"))
5604 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5605 	else if (!strcmp(res->value, "32"))
5606 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5607 	else
5608 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5609 #endif
5610 }
5611 
5612 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5613 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5614 			set, "set");
5615 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5616 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5617 			bypass, "bypass");
5618 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5619 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5620 			timeout, "timeout");
5621 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5622 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5623 			value, "0#1.5#2#3#4#8#16#32");
5624 
5625 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5626 	.f = cmd_set_bypass_timeout_parsed,
5627 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5628 		"Set the NIC bypass watchdog timeout in seconds",
5629 	.data = NULL,
5630 	.tokens = {
5631 		(void *)&cmd_setbypass_timeout_set,
5632 		(void *)&cmd_setbypass_timeout_bypass,
5633 		(void *)&cmd_setbypass_timeout_timeout,
5634 		(void *)&cmd_setbypass_timeout_value,
5635 		NULL,
5636 	},
5637 };
5638 
5639 /* *** SHOW NIC BYPASS MODE *** */
5640 struct cmd_show_bypass_config_result {
5641 	cmdline_fixed_string_t show;
5642 	cmdline_fixed_string_t bypass;
5643 	cmdline_fixed_string_t config;
5644 	portid_t port_id;
5645 };
5646 
5647 static void
5648 cmd_show_bypass_config_parsed(void *parsed_result,
5649 		__rte_unused struct cmdline *cl,
5650 		__rte_unused void *data)
5651 {
5652 	struct cmd_show_bypass_config_result *res = parsed_result;
5653 	portid_t port_id = res->port_id;
5654 	int rc = -EINVAL;
5655 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5656 	uint32_t event_mode;
5657 	uint32_t bypass_mode;
5658 	uint32_t timeout = bypass_timeout;
5659 	unsigned int i;
5660 
5661 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5662 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5663 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5664 		{"UNKNOWN", "normal", "bypass", "isolate"};
5665 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5666 		"NONE",
5667 		"OS/board on",
5668 		"power supply on",
5669 		"OS/board off",
5670 		"power supply off",
5671 		"timeout"};
5672 
5673 	/* Display the bypass mode.*/
5674 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5675 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5676 		return;
5677 	}
5678 	else {
5679 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5680 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5681 
5682 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5683 	}
5684 
5685 	/* Display the bypass timeout.*/
5686 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5687 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5688 
5689 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5690 
5691 	/* Display the bypass events and associated modes. */
5692 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5693 
5694 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5695 			printf("\tFailed to get bypass mode for event = %s\n",
5696 				events[i]);
5697 		} else {
5698 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5699 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5700 
5701 			printf("\tbypass event: %-16s = %s\n", events[i],
5702 				modes[event_mode]);
5703 		}
5704 	}
5705 #endif
5706 	if (rc != 0)
5707 		printf("\tFailed to get bypass configuration for port = %d\n",
5708 		       port_id);
5709 }
5710 
5711 cmdline_parse_token_string_t cmd_showbypass_config_show =
5712 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5713 			show, "show");
5714 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5715 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5716 			bypass, "bypass");
5717 cmdline_parse_token_string_t cmd_showbypass_config_config =
5718 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5719 			config, "config");
5720 cmdline_parse_token_num_t cmd_showbypass_config_port =
5721 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5722 				port_id, RTE_UINT16);
5723 
5724 cmdline_parse_inst_t cmd_show_bypass_config = {
5725 	.f = cmd_show_bypass_config_parsed,
5726 	.help_str = "show bypass config <port_id>: "
5727 	            "Show the NIC bypass config for port_id",
5728 	.data = NULL,
5729 	.tokens = {
5730 		(void *)&cmd_showbypass_config_show,
5731 		(void *)&cmd_showbypass_config_bypass,
5732 		(void *)&cmd_showbypass_config_config,
5733 		(void *)&cmd_showbypass_config_port,
5734 		NULL,
5735 	},
5736 };
5737 
5738 #ifdef RTE_NET_BOND
5739 /* *** SET BONDING MODE *** */
5740 struct cmd_set_bonding_mode_result {
5741 	cmdline_fixed_string_t set;
5742 	cmdline_fixed_string_t bonding;
5743 	cmdline_fixed_string_t mode;
5744 	uint8_t value;
5745 	portid_t port_id;
5746 };
5747 
5748 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5749 		__rte_unused  struct cmdline *cl,
5750 		__rte_unused void *data)
5751 {
5752 	struct cmd_set_bonding_mode_result *res = parsed_result;
5753 	portid_t port_id = res->port_id;
5754 
5755 	/* Set the bonding mode for the relevant port. */
5756 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5757 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5758 }
5759 
5760 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5762 		set, "set");
5763 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5765 		bonding, "bonding");
5766 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5768 		mode, "mode");
5769 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5771 		value, RTE_UINT8);
5772 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5773 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5774 		port_id, RTE_UINT16);
5775 
5776 cmdline_parse_inst_t cmd_set_bonding_mode = {
5777 		.f = cmd_set_bonding_mode_parsed,
5778 		.help_str = "set bonding mode <mode_value> <port_id>: "
5779 			"Set the bonding mode for port_id",
5780 		.data = NULL,
5781 		.tokens = {
5782 				(void *) &cmd_setbonding_mode_set,
5783 				(void *) &cmd_setbonding_mode_bonding,
5784 				(void *) &cmd_setbonding_mode_mode,
5785 				(void *) &cmd_setbonding_mode_value,
5786 				(void *) &cmd_setbonding_mode_port,
5787 				NULL
5788 		}
5789 };
5790 
5791 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5792 struct cmd_set_bonding_lacp_dedicated_queues_result {
5793 	cmdline_fixed_string_t set;
5794 	cmdline_fixed_string_t bonding;
5795 	cmdline_fixed_string_t lacp;
5796 	cmdline_fixed_string_t dedicated_queues;
5797 	portid_t port_id;
5798 	cmdline_fixed_string_t mode;
5799 };
5800 
5801 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5802 		__rte_unused  struct cmdline *cl,
5803 		__rte_unused void *data)
5804 {
5805 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5806 	portid_t port_id = res->port_id;
5807 	struct rte_port *port;
5808 
5809 	port = &ports[port_id];
5810 
5811 	/** Check if the port is not started **/
5812 	if (port->port_status != RTE_PORT_STOPPED) {
5813 		printf("Please stop port %d first\n", port_id);
5814 		return;
5815 	}
5816 
5817 	if (!strcmp(res->mode, "enable")) {
5818 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5819 			printf("Dedicate queues for LACP control packets"
5820 					" enabled\n");
5821 		else
5822 			printf("Enabling dedicate queues for LACP control "
5823 					"packets on port %d failed\n", port_id);
5824 	} else if (!strcmp(res->mode, "disable")) {
5825 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5826 			printf("Dedicated queues for LACP control packets "
5827 					"disabled\n");
5828 		else
5829 			printf("Disabling dedicated queues for LACP control "
5830 					"traffic on port %d failed\n", port_id);
5831 	}
5832 }
5833 
5834 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5836 		set, "set");
5837 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5839 		bonding, "bonding");
5840 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5842 		lacp, "lacp");
5843 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5845 		dedicated_queues, "dedicated_queues");
5846 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5847 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5848 		port_id, RTE_UINT16);
5849 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5851 		mode, "enable#disable");
5852 
5853 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5854 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5855 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5856 			"enable|disable: "
5857 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5858 		.data = NULL,
5859 		.tokens = {
5860 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5861 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5862 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5863 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5864 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5865 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5866 			NULL
5867 		}
5868 };
5869 
5870 /* *** SET BALANCE XMIT POLICY *** */
5871 struct cmd_set_bonding_balance_xmit_policy_result {
5872 	cmdline_fixed_string_t set;
5873 	cmdline_fixed_string_t bonding;
5874 	cmdline_fixed_string_t balance_xmit_policy;
5875 	portid_t port_id;
5876 	cmdline_fixed_string_t policy;
5877 };
5878 
5879 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5880 		__rte_unused  struct cmdline *cl,
5881 		__rte_unused void *data)
5882 {
5883 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5884 	portid_t port_id = res->port_id;
5885 	uint8_t policy;
5886 
5887 	if (!strcmp(res->policy, "l2")) {
5888 		policy = BALANCE_XMIT_POLICY_LAYER2;
5889 	} else if (!strcmp(res->policy, "l23")) {
5890 		policy = BALANCE_XMIT_POLICY_LAYER23;
5891 	} else if (!strcmp(res->policy, "l34")) {
5892 		policy = BALANCE_XMIT_POLICY_LAYER34;
5893 	} else {
5894 		printf("\t Invalid xmit policy selection");
5895 		return;
5896 	}
5897 
5898 	/* Set the bonding mode for the relevant port. */
5899 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5900 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5901 				port_id);
5902 	}
5903 }
5904 
5905 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5907 		set, "set");
5908 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5910 		bonding, "bonding");
5911 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5913 		balance_xmit_policy, "balance_xmit_policy");
5914 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5915 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5916 		port_id, RTE_UINT16);
5917 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5919 		policy, "l2#l23#l34");
5920 
5921 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5922 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
5923 		.help_str = "set bonding balance_xmit_policy <port_id> "
5924 			"l2|l23|l34: "
5925 			"Set the bonding balance_xmit_policy for port_id",
5926 		.data = NULL,
5927 		.tokens = {
5928 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5929 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5930 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5931 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5932 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5933 				NULL
5934 		}
5935 };
5936 
5937 /* *** SHOW NIC BONDING CONFIGURATION *** */
5938 struct cmd_show_bonding_config_result {
5939 	cmdline_fixed_string_t show;
5940 	cmdline_fixed_string_t bonding;
5941 	cmdline_fixed_string_t config;
5942 	portid_t port_id;
5943 };
5944 
5945 static void cmd_show_bonding_config_parsed(void *parsed_result,
5946 		__rte_unused  struct cmdline *cl,
5947 		__rte_unused void *data)
5948 {
5949 	struct cmd_show_bonding_config_result *res = parsed_result;
5950 	int bonding_mode, agg_mode;
5951 	portid_t slaves[RTE_MAX_ETHPORTS];
5952 	int num_slaves, num_active_slaves;
5953 	int primary_id;
5954 	int i;
5955 	portid_t port_id = res->port_id;
5956 
5957 	/* Display the bonding mode.*/
5958 	bonding_mode = rte_eth_bond_mode_get(port_id);
5959 	if (bonding_mode < 0) {
5960 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5961 		return;
5962 	} else
5963 		printf("\tBonding mode: %d\n", bonding_mode);
5964 
5965 	if (bonding_mode == BONDING_MODE_BALANCE) {
5966 		int balance_xmit_policy;
5967 
5968 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5969 		if (balance_xmit_policy < 0) {
5970 			printf("\tFailed to get balance xmit policy for port = %d\n",
5971 					port_id);
5972 			return;
5973 		} else {
5974 			printf("\tBalance Xmit Policy: ");
5975 
5976 			switch (balance_xmit_policy) {
5977 			case BALANCE_XMIT_POLICY_LAYER2:
5978 				printf("BALANCE_XMIT_POLICY_LAYER2");
5979 				break;
5980 			case BALANCE_XMIT_POLICY_LAYER23:
5981 				printf("BALANCE_XMIT_POLICY_LAYER23");
5982 				break;
5983 			case BALANCE_XMIT_POLICY_LAYER34:
5984 				printf("BALANCE_XMIT_POLICY_LAYER34");
5985 				break;
5986 			}
5987 			printf("\n");
5988 		}
5989 	}
5990 
5991 	if (bonding_mode == BONDING_MODE_8023AD) {
5992 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5993 		printf("\tIEEE802.3AD Aggregator Mode: ");
5994 		switch (agg_mode) {
5995 		case AGG_BANDWIDTH:
5996 			printf("bandwidth");
5997 			break;
5998 		case AGG_STABLE:
5999 			printf("stable");
6000 			break;
6001 		case AGG_COUNT:
6002 			printf("count");
6003 			break;
6004 		}
6005 		printf("\n");
6006 	}
6007 
6008 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6009 
6010 	if (num_slaves < 0) {
6011 		printf("\tFailed to get slave list for port = %d\n", port_id);
6012 		return;
6013 	}
6014 	if (num_slaves > 0) {
6015 		printf("\tSlaves (%d): [", num_slaves);
6016 		for (i = 0; i < num_slaves - 1; i++)
6017 			printf("%d ", slaves[i]);
6018 
6019 		printf("%d]\n", slaves[num_slaves - 1]);
6020 	} else {
6021 		printf("\tSlaves: []\n");
6022 
6023 	}
6024 
6025 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6026 			RTE_MAX_ETHPORTS);
6027 
6028 	if (num_active_slaves < 0) {
6029 		printf("\tFailed to get active slave list for port = %d\n", port_id);
6030 		return;
6031 	}
6032 	if (num_active_slaves > 0) {
6033 		printf("\tActive Slaves (%d): [", num_active_slaves);
6034 		for (i = 0; i < num_active_slaves - 1; i++)
6035 			printf("%d ", slaves[i]);
6036 
6037 		printf("%d]\n", slaves[num_active_slaves - 1]);
6038 
6039 	} else {
6040 		printf("\tActive Slaves: []\n");
6041 
6042 	}
6043 
6044 	primary_id = rte_eth_bond_primary_get(port_id);
6045 	if (primary_id < 0) {
6046 		printf("\tFailed to get primary slave for port = %d\n", port_id);
6047 		return;
6048 	} else
6049 		printf("\tPrimary: [%d]\n", primary_id);
6050 
6051 }
6052 
6053 cmdline_parse_token_string_t cmd_showbonding_config_show =
6054 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6055 		show, "show");
6056 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6057 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6058 		bonding, "bonding");
6059 cmdline_parse_token_string_t cmd_showbonding_config_config =
6060 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6061 		config, "config");
6062 cmdline_parse_token_num_t cmd_showbonding_config_port =
6063 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6064 		port_id, RTE_UINT16);
6065 
6066 cmdline_parse_inst_t cmd_show_bonding_config = {
6067 		.f = cmd_show_bonding_config_parsed,
6068 		.help_str = "show bonding config <port_id>: "
6069 			"Show the bonding config for port_id",
6070 		.data = NULL,
6071 		.tokens = {
6072 				(void *)&cmd_showbonding_config_show,
6073 				(void *)&cmd_showbonding_config_bonding,
6074 				(void *)&cmd_showbonding_config_config,
6075 				(void *)&cmd_showbonding_config_port,
6076 				NULL
6077 		}
6078 };
6079 
6080 /* *** SET BONDING PRIMARY *** */
6081 struct cmd_set_bonding_primary_result {
6082 	cmdline_fixed_string_t set;
6083 	cmdline_fixed_string_t bonding;
6084 	cmdline_fixed_string_t primary;
6085 	portid_t slave_id;
6086 	portid_t port_id;
6087 };
6088 
6089 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6090 		__rte_unused  struct cmdline *cl,
6091 		__rte_unused void *data)
6092 {
6093 	struct cmd_set_bonding_primary_result *res = parsed_result;
6094 	portid_t master_port_id = res->port_id;
6095 	portid_t slave_port_id = res->slave_id;
6096 
6097 	/* Set the primary slave for a bonded device. */
6098 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6099 		printf("\t Failed to set primary slave for port = %d.\n",
6100 				master_port_id);
6101 		return;
6102 	}
6103 	init_port_config();
6104 }
6105 
6106 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6108 		set, "set");
6109 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6111 		bonding, "bonding");
6112 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6114 		primary, "primary");
6115 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6117 		slave_id, RTE_UINT16);
6118 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6119 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6120 		port_id, RTE_UINT16);
6121 
6122 cmdline_parse_inst_t cmd_set_bonding_primary = {
6123 		.f = cmd_set_bonding_primary_parsed,
6124 		.help_str = "set bonding primary <slave_id> <port_id>: "
6125 			"Set the primary slave for port_id",
6126 		.data = NULL,
6127 		.tokens = {
6128 				(void *)&cmd_setbonding_primary_set,
6129 				(void *)&cmd_setbonding_primary_bonding,
6130 				(void *)&cmd_setbonding_primary_primary,
6131 				(void *)&cmd_setbonding_primary_slave,
6132 				(void *)&cmd_setbonding_primary_port,
6133 				NULL
6134 		}
6135 };
6136 
6137 /* *** ADD SLAVE *** */
6138 struct cmd_add_bonding_slave_result {
6139 	cmdline_fixed_string_t add;
6140 	cmdline_fixed_string_t bonding;
6141 	cmdline_fixed_string_t slave;
6142 	portid_t slave_id;
6143 	portid_t port_id;
6144 };
6145 
6146 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6147 		__rte_unused  struct cmdline *cl,
6148 		__rte_unused void *data)
6149 {
6150 	struct cmd_add_bonding_slave_result *res = parsed_result;
6151 	portid_t master_port_id = res->port_id;
6152 	portid_t slave_port_id = res->slave_id;
6153 
6154 	/* add the slave for a bonded device. */
6155 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6156 		printf("\t Failed to add slave %d to master port = %d.\n",
6157 				slave_port_id, master_port_id);
6158 		return;
6159 	}
6160 	init_port_config();
6161 	set_port_slave_flag(slave_port_id);
6162 }
6163 
6164 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6165 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6166 		add, "add");
6167 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6168 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6169 		bonding, "bonding");
6170 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6171 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6172 		slave, "slave");
6173 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6174 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6175 		slave_id, RTE_UINT16);
6176 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6177 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6178 		port_id, RTE_UINT16);
6179 
6180 cmdline_parse_inst_t cmd_add_bonding_slave = {
6181 		.f = cmd_add_bonding_slave_parsed,
6182 		.help_str = "add bonding slave <slave_id> <port_id>: "
6183 			"Add a slave device to a bonded device",
6184 		.data = NULL,
6185 		.tokens = {
6186 				(void *)&cmd_addbonding_slave_add,
6187 				(void *)&cmd_addbonding_slave_bonding,
6188 				(void *)&cmd_addbonding_slave_slave,
6189 				(void *)&cmd_addbonding_slave_slaveid,
6190 				(void *)&cmd_addbonding_slave_port,
6191 				NULL
6192 		}
6193 };
6194 
6195 /* *** REMOVE SLAVE *** */
6196 struct cmd_remove_bonding_slave_result {
6197 	cmdline_fixed_string_t remove;
6198 	cmdline_fixed_string_t bonding;
6199 	cmdline_fixed_string_t slave;
6200 	portid_t slave_id;
6201 	portid_t port_id;
6202 };
6203 
6204 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6205 		__rte_unused  struct cmdline *cl,
6206 		__rte_unused void *data)
6207 {
6208 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6209 	portid_t master_port_id = res->port_id;
6210 	portid_t slave_port_id = res->slave_id;
6211 
6212 	/* remove the slave from a bonded device. */
6213 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6214 		printf("\t Failed to remove slave %d from master port = %d.\n",
6215 				slave_port_id, master_port_id);
6216 		return;
6217 	}
6218 	init_port_config();
6219 	clear_port_slave_flag(slave_port_id);
6220 }
6221 
6222 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6223 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6224 				remove, "remove");
6225 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6226 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6227 				bonding, "bonding");
6228 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6229 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6230 				slave, "slave");
6231 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6232 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6233 				slave_id, RTE_UINT16);
6234 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6235 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6236 				port_id, RTE_UINT16);
6237 
6238 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6239 		.f = cmd_remove_bonding_slave_parsed,
6240 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6241 			"Remove a slave device from a bonded device",
6242 		.data = NULL,
6243 		.tokens = {
6244 				(void *)&cmd_removebonding_slave_remove,
6245 				(void *)&cmd_removebonding_slave_bonding,
6246 				(void *)&cmd_removebonding_slave_slave,
6247 				(void *)&cmd_removebonding_slave_slaveid,
6248 				(void *)&cmd_removebonding_slave_port,
6249 				NULL
6250 		}
6251 };
6252 
6253 /* *** CREATE BONDED DEVICE *** */
6254 struct cmd_create_bonded_device_result {
6255 	cmdline_fixed_string_t create;
6256 	cmdline_fixed_string_t bonded;
6257 	cmdline_fixed_string_t device;
6258 	uint8_t mode;
6259 	uint8_t socket;
6260 };
6261 
6262 static int bond_dev_num = 0;
6263 
6264 static void cmd_create_bonded_device_parsed(void *parsed_result,
6265 		__rte_unused  struct cmdline *cl,
6266 		__rte_unused void *data)
6267 {
6268 	struct cmd_create_bonded_device_result *res = parsed_result;
6269 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6270 	int port_id;
6271 	int ret;
6272 
6273 	if (test_done == 0) {
6274 		printf("Please stop forwarding first\n");
6275 		return;
6276 	}
6277 
6278 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6279 			bond_dev_num++);
6280 
6281 	/* Create a new bonded device. */
6282 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6283 	if (port_id < 0) {
6284 		printf("\t Failed to create bonded device.\n");
6285 		return;
6286 	} else {
6287 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6288 				port_id);
6289 
6290 		/* Update number of ports */
6291 		nb_ports = rte_eth_dev_count_avail();
6292 		reconfig(port_id, res->socket);
6293 		ret = rte_eth_promiscuous_enable(port_id);
6294 		if (ret != 0)
6295 			printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6296 				port_id, rte_strerror(-ret));
6297 
6298 		ports[port_id].need_setup = 0;
6299 		ports[port_id].port_status = RTE_PORT_STOPPED;
6300 	}
6301 
6302 }
6303 
6304 cmdline_parse_token_string_t cmd_createbonded_device_create =
6305 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6306 				create, "create");
6307 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6308 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6309 				bonded, "bonded");
6310 cmdline_parse_token_string_t cmd_createbonded_device_device =
6311 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6312 				device, "device");
6313 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6314 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6315 				mode, RTE_UINT8);
6316 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6317 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6318 				socket, RTE_UINT8);
6319 
6320 cmdline_parse_inst_t cmd_create_bonded_device = {
6321 		.f = cmd_create_bonded_device_parsed,
6322 		.help_str = "create bonded device <mode> <socket>: "
6323 			"Create a new bonded device with specific bonding mode and socket",
6324 		.data = NULL,
6325 		.tokens = {
6326 				(void *)&cmd_createbonded_device_create,
6327 				(void *)&cmd_createbonded_device_bonded,
6328 				(void *)&cmd_createbonded_device_device,
6329 				(void *)&cmd_createbonded_device_mode,
6330 				(void *)&cmd_createbonded_device_socket,
6331 				NULL
6332 		}
6333 };
6334 
6335 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6336 struct cmd_set_bond_mac_addr_result {
6337 	cmdline_fixed_string_t set;
6338 	cmdline_fixed_string_t bonding;
6339 	cmdline_fixed_string_t mac_addr;
6340 	uint16_t port_num;
6341 	struct rte_ether_addr address;
6342 };
6343 
6344 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6345 		__rte_unused  struct cmdline *cl,
6346 		__rte_unused void *data)
6347 {
6348 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6349 	int ret;
6350 
6351 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6352 		return;
6353 
6354 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6355 
6356 	/* check the return value and print it if is < 0 */
6357 	if (ret < 0)
6358 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6359 }
6360 
6361 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6362 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6363 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6364 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6365 				"bonding");
6366 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6367 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6368 				"mac_addr");
6369 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6370 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6371 				port_num, RTE_UINT16);
6372 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6373 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6374 
6375 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6376 		.f = cmd_set_bond_mac_addr_parsed,
6377 		.data = (void *) 0,
6378 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6379 		.tokens = {
6380 				(void *)&cmd_set_bond_mac_addr_set,
6381 				(void *)&cmd_set_bond_mac_addr_bonding,
6382 				(void *)&cmd_set_bond_mac_addr_mac,
6383 				(void *)&cmd_set_bond_mac_addr_portnum,
6384 				(void *)&cmd_set_bond_mac_addr_addr,
6385 				NULL
6386 		}
6387 };
6388 
6389 
6390 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6391 struct cmd_set_bond_mon_period_result {
6392 	cmdline_fixed_string_t set;
6393 	cmdline_fixed_string_t bonding;
6394 	cmdline_fixed_string_t mon_period;
6395 	uint16_t port_num;
6396 	uint32_t period_ms;
6397 };
6398 
6399 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6400 		__rte_unused  struct cmdline *cl,
6401 		__rte_unused void *data)
6402 {
6403 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6404 	int ret;
6405 
6406 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6407 
6408 	/* check the return value and print it if is < 0 */
6409 	if (ret < 0)
6410 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6411 }
6412 
6413 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6414 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6415 				set, "set");
6416 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6417 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6418 				bonding, "bonding");
6419 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6420 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6421 				mon_period,	"mon_period");
6422 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6423 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6424 				port_num, RTE_UINT16);
6425 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6426 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6427 				period_ms, RTE_UINT32);
6428 
6429 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6430 		.f = cmd_set_bond_mon_period_parsed,
6431 		.data = (void *) 0,
6432 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6433 		.tokens = {
6434 				(void *)&cmd_set_bond_mon_period_set,
6435 				(void *)&cmd_set_bond_mon_period_bonding,
6436 				(void *)&cmd_set_bond_mon_period_mon_period,
6437 				(void *)&cmd_set_bond_mon_period_portnum,
6438 				(void *)&cmd_set_bond_mon_period_period_ms,
6439 				NULL
6440 		}
6441 };
6442 
6443 
6444 
6445 struct cmd_set_bonding_agg_mode_policy_result {
6446 	cmdline_fixed_string_t set;
6447 	cmdline_fixed_string_t bonding;
6448 	cmdline_fixed_string_t agg_mode;
6449 	uint16_t port_num;
6450 	cmdline_fixed_string_t policy;
6451 };
6452 
6453 
6454 static void
6455 cmd_set_bonding_agg_mode(void *parsed_result,
6456 		__rte_unused struct cmdline *cl,
6457 		__rte_unused void *data)
6458 {
6459 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6460 	uint8_t policy = AGG_BANDWIDTH;
6461 
6462 	if (!strcmp(res->policy, "bandwidth"))
6463 		policy = AGG_BANDWIDTH;
6464 	else if (!strcmp(res->policy, "stable"))
6465 		policy = AGG_STABLE;
6466 	else if (!strcmp(res->policy, "count"))
6467 		policy = AGG_COUNT;
6468 
6469 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6470 }
6471 
6472 
6473 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6474 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6475 				set, "set");
6476 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6477 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6478 				bonding, "bonding");
6479 
6480 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6481 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6482 				agg_mode, "agg_mode");
6483 
6484 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6485 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6486 				port_num, RTE_UINT16);
6487 
6488 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6489 	TOKEN_STRING_INITIALIZER(
6490 			struct cmd_set_bonding_balance_xmit_policy_result,
6491 		policy, "stable#bandwidth#count");
6492 
6493 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6494 	.f = cmd_set_bonding_agg_mode,
6495 	.data = (void *) 0,
6496 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6497 	.tokens = {
6498 			(void *)&cmd_set_bonding_agg_mode_set,
6499 			(void *)&cmd_set_bonding_agg_mode_bonding,
6500 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6501 			(void *)&cmd_set_bonding_agg_mode_portnum,
6502 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6503 			NULL
6504 		}
6505 };
6506 
6507 
6508 #endif /* RTE_NET_BOND */
6509 
6510 /* *** SET FORWARDING MODE *** */
6511 struct cmd_set_fwd_mode_result {
6512 	cmdline_fixed_string_t set;
6513 	cmdline_fixed_string_t fwd;
6514 	cmdline_fixed_string_t mode;
6515 };
6516 
6517 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6518 				    __rte_unused struct cmdline *cl,
6519 				    __rte_unused void *data)
6520 {
6521 	struct cmd_set_fwd_mode_result *res = parsed_result;
6522 
6523 	retry_enabled = 0;
6524 	set_pkt_forwarding_mode(res->mode);
6525 }
6526 
6527 cmdline_parse_token_string_t cmd_setfwd_set =
6528 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6529 cmdline_parse_token_string_t cmd_setfwd_fwd =
6530 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6531 cmdline_parse_token_string_t cmd_setfwd_mode =
6532 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6533 		"" /* defined at init */);
6534 
6535 cmdline_parse_inst_t cmd_set_fwd_mode = {
6536 	.f = cmd_set_fwd_mode_parsed,
6537 	.data = NULL,
6538 	.help_str = NULL, /* defined at init */
6539 	.tokens = {
6540 		(void *)&cmd_setfwd_set,
6541 		(void *)&cmd_setfwd_fwd,
6542 		(void *)&cmd_setfwd_mode,
6543 		NULL,
6544 	},
6545 };
6546 
6547 static void cmd_set_fwd_mode_init(void)
6548 {
6549 	char *modes, *c;
6550 	static char token[128];
6551 	static char help[256];
6552 	cmdline_parse_token_string_t *token_struct;
6553 
6554 	modes = list_pkt_forwarding_modes();
6555 	snprintf(help, sizeof(help), "set fwd %s: "
6556 		"Set packet forwarding mode", modes);
6557 	cmd_set_fwd_mode.help_str = help;
6558 
6559 	/* string token separator is # */
6560 	for (c = token; *modes != '\0'; modes++)
6561 		if (*modes == '|')
6562 			*c++ = '#';
6563 		else
6564 			*c++ = *modes;
6565 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6566 	token_struct->string_data.str = token;
6567 }
6568 
6569 /* *** SET RETRY FORWARDING MODE *** */
6570 struct cmd_set_fwd_retry_mode_result {
6571 	cmdline_fixed_string_t set;
6572 	cmdline_fixed_string_t fwd;
6573 	cmdline_fixed_string_t mode;
6574 	cmdline_fixed_string_t retry;
6575 };
6576 
6577 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6578 			    __rte_unused struct cmdline *cl,
6579 			    __rte_unused void *data)
6580 {
6581 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6582 
6583 	retry_enabled = 1;
6584 	set_pkt_forwarding_mode(res->mode);
6585 }
6586 
6587 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6588 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6589 			set, "set");
6590 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6591 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6592 			fwd, "fwd");
6593 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6594 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6595 			mode,
6596 		"" /* defined at init */);
6597 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6598 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6599 			retry, "retry");
6600 
6601 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6602 	.f = cmd_set_fwd_retry_mode_parsed,
6603 	.data = NULL,
6604 	.help_str = NULL, /* defined at init */
6605 	.tokens = {
6606 		(void *)&cmd_setfwd_retry_set,
6607 		(void *)&cmd_setfwd_retry_fwd,
6608 		(void *)&cmd_setfwd_retry_mode,
6609 		(void *)&cmd_setfwd_retry_retry,
6610 		NULL,
6611 	},
6612 };
6613 
6614 static void cmd_set_fwd_retry_mode_init(void)
6615 {
6616 	char *modes, *c;
6617 	static char token[128];
6618 	static char help[256];
6619 	cmdline_parse_token_string_t *token_struct;
6620 
6621 	modes = list_pkt_forwarding_retry_modes();
6622 	snprintf(help, sizeof(help), "set fwd %s retry: "
6623 		"Set packet forwarding mode with retry", modes);
6624 	cmd_set_fwd_retry_mode.help_str = help;
6625 
6626 	/* string token separator is # */
6627 	for (c = token; *modes != '\0'; modes++)
6628 		if (*modes == '|')
6629 			*c++ = '#';
6630 		else
6631 			*c++ = *modes;
6632 	token_struct = (cmdline_parse_token_string_t *)
6633 		cmd_set_fwd_retry_mode.tokens[2];
6634 	token_struct->string_data.str = token;
6635 }
6636 
6637 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6638 struct cmd_set_burst_tx_retry_result {
6639 	cmdline_fixed_string_t set;
6640 	cmdline_fixed_string_t burst;
6641 	cmdline_fixed_string_t tx;
6642 	cmdline_fixed_string_t delay;
6643 	uint32_t time;
6644 	cmdline_fixed_string_t retry;
6645 	uint32_t retry_num;
6646 };
6647 
6648 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6649 					__rte_unused struct cmdline *cl,
6650 					__rte_unused void *data)
6651 {
6652 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6653 
6654 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6655 		&& !strcmp(res->tx, "tx")) {
6656 		if (!strcmp(res->delay, "delay"))
6657 			burst_tx_delay_time = res->time;
6658 		if (!strcmp(res->retry, "retry"))
6659 			burst_tx_retry_num = res->retry_num;
6660 	}
6661 
6662 }
6663 
6664 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6665 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6666 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6667 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6668 				 "burst");
6669 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6670 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6671 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6672 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6673 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6674 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6675 				 RTE_UINT32);
6676 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6677 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6678 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6679 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6680 				 RTE_UINT32);
6681 
6682 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6683 	.f = cmd_set_burst_tx_retry_parsed,
6684 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6685 	.tokens = {
6686 		(void *)&cmd_set_burst_tx_retry_set,
6687 		(void *)&cmd_set_burst_tx_retry_burst,
6688 		(void *)&cmd_set_burst_tx_retry_tx,
6689 		(void *)&cmd_set_burst_tx_retry_delay,
6690 		(void *)&cmd_set_burst_tx_retry_time,
6691 		(void *)&cmd_set_burst_tx_retry_retry,
6692 		(void *)&cmd_set_burst_tx_retry_retry_num,
6693 		NULL,
6694 	},
6695 };
6696 
6697 /* *** SET PROMISC MODE *** */
6698 struct cmd_set_promisc_mode_result {
6699 	cmdline_fixed_string_t set;
6700 	cmdline_fixed_string_t promisc;
6701 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6702 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6703 	cmdline_fixed_string_t mode;
6704 };
6705 
6706 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6707 					__rte_unused struct cmdline *cl,
6708 					void *allports)
6709 {
6710 	struct cmd_set_promisc_mode_result *res = parsed_result;
6711 	int enable;
6712 	portid_t i;
6713 
6714 	if (!strcmp(res->mode, "on"))
6715 		enable = 1;
6716 	else
6717 		enable = 0;
6718 
6719 	/* all ports */
6720 	if (allports) {
6721 		RTE_ETH_FOREACH_DEV(i)
6722 			eth_set_promisc_mode(i, enable);
6723 	} else {
6724 		eth_set_promisc_mode(res->port_num, enable);
6725 	}
6726 }
6727 
6728 cmdline_parse_token_string_t cmd_setpromisc_set =
6729 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6730 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6731 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6732 				 "promisc");
6733 cmdline_parse_token_string_t cmd_setpromisc_portall =
6734 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6735 				 "all");
6736 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6737 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6738 			      RTE_UINT16);
6739 cmdline_parse_token_string_t cmd_setpromisc_mode =
6740 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6741 				 "on#off");
6742 
6743 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6744 	.f = cmd_set_promisc_mode_parsed,
6745 	.data = (void *)1,
6746 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6747 	.tokens = {
6748 		(void *)&cmd_setpromisc_set,
6749 		(void *)&cmd_setpromisc_promisc,
6750 		(void *)&cmd_setpromisc_portall,
6751 		(void *)&cmd_setpromisc_mode,
6752 		NULL,
6753 	},
6754 };
6755 
6756 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6757 	.f = cmd_set_promisc_mode_parsed,
6758 	.data = (void *)0,
6759 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6760 	.tokens = {
6761 		(void *)&cmd_setpromisc_set,
6762 		(void *)&cmd_setpromisc_promisc,
6763 		(void *)&cmd_setpromisc_portnum,
6764 		(void *)&cmd_setpromisc_mode,
6765 		NULL,
6766 	},
6767 };
6768 
6769 /* *** SET ALLMULTI MODE *** */
6770 struct cmd_set_allmulti_mode_result {
6771 	cmdline_fixed_string_t set;
6772 	cmdline_fixed_string_t allmulti;
6773 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6774 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6775 	cmdline_fixed_string_t mode;
6776 };
6777 
6778 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6779 					__rte_unused struct cmdline *cl,
6780 					void *allports)
6781 {
6782 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6783 	int enable;
6784 	portid_t i;
6785 
6786 	if (!strcmp(res->mode, "on"))
6787 		enable = 1;
6788 	else
6789 		enable = 0;
6790 
6791 	/* all ports */
6792 	if (allports) {
6793 		RTE_ETH_FOREACH_DEV(i) {
6794 			eth_set_allmulticast_mode(i, enable);
6795 		}
6796 	}
6797 	else {
6798 		eth_set_allmulticast_mode(res->port_num, enable);
6799 	}
6800 }
6801 
6802 cmdline_parse_token_string_t cmd_setallmulti_set =
6803 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6804 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6805 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6806 				 "allmulti");
6807 cmdline_parse_token_string_t cmd_setallmulti_portall =
6808 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6809 				 "all");
6810 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6811 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6812 			      RTE_UINT16);
6813 cmdline_parse_token_string_t cmd_setallmulti_mode =
6814 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6815 				 "on#off");
6816 
6817 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6818 	.f = cmd_set_allmulti_mode_parsed,
6819 	.data = (void *)1,
6820 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6821 	.tokens = {
6822 		(void *)&cmd_setallmulti_set,
6823 		(void *)&cmd_setallmulti_allmulti,
6824 		(void *)&cmd_setallmulti_portall,
6825 		(void *)&cmd_setallmulti_mode,
6826 		NULL,
6827 	},
6828 };
6829 
6830 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6831 	.f = cmd_set_allmulti_mode_parsed,
6832 	.data = (void *)0,
6833 	.help_str = "set allmulti <port_id> on|off: "
6834 		"Set allmulti mode on port_id",
6835 	.tokens = {
6836 		(void *)&cmd_setallmulti_set,
6837 		(void *)&cmd_setallmulti_allmulti,
6838 		(void *)&cmd_setallmulti_portnum,
6839 		(void *)&cmd_setallmulti_mode,
6840 		NULL,
6841 	},
6842 };
6843 
6844 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6845 struct cmd_link_flow_ctrl_set_result {
6846 	cmdline_fixed_string_t set;
6847 	cmdline_fixed_string_t flow_ctrl;
6848 	cmdline_fixed_string_t rx;
6849 	cmdline_fixed_string_t rx_lfc_mode;
6850 	cmdline_fixed_string_t tx;
6851 	cmdline_fixed_string_t tx_lfc_mode;
6852 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6853 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6854 	cmdline_fixed_string_t autoneg_str;
6855 	cmdline_fixed_string_t autoneg;
6856 	cmdline_fixed_string_t hw_str;
6857 	uint32_t high_water;
6858 	cmdline_fixed_string_t lw_str;
6859 	uint32_t low_water;
6860 	cmdline_fixed_string_t pt_str;
6861 	uint16_t pause_time;
6862 	cmdline_fixed_string_t xon_str;
6863 	uint16_t send_xon;
6864 	portid_t port_id;
6865 };
6866 
6867 cmdline_parse_token_string_t cmd_lfc_set_set =
6868 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6869 				set, "set");
6870 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6871 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6872 				flow_ctrl, "flow_ctrl");
6873 cmdline_parse_token_string_t cmd_lfc_set_rx =
6874 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6875 				rx, "rx");
6876 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6877 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6878 				rx_lfc_mode, "on#off");
6879 cmdline_parse_token_string_t cmd_lfc_set_tx =
6880 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6881 				tx, "tx");
6882 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6883 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6884 				tx_lfc_mode, "on#off");
6885 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6886 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6887 				hw_str, "high_water");
6888 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6889 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6890 				high_water, RTE_UINT32);
6891 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6892 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6893 				lw_str, "low_water");
6894 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6895 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6896 				low_water, RTE_UINT32);
6897 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6898 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6899 				pt_str, "pause_time");
6900 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6901 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6902 				pause_time, RTE_UINT16);
6903 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6904 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6905 				xon_str, "send_xon");
6906 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6907 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6908 				send_xon, RTE_UINT16);
6909 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6910 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6911 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6912 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6913 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6914 				mac_ctrl_frame_fwd_mode, "on#off");
6915 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6916 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6917 				autoneg_str, "autoneg");
6918 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6919 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6920 				autoneg, "on#off");
6921 cmdline_parse_token_num_t cmd_lfc_set_portid =
6922 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6923 				port_id, RTE_UINT16);
6924 
6925 /* forward declaration */
6926 static void
6927 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6928 			      void *data);
6929 
6930 cmdline_parse_inst_t cmd_link_flow_control_set = {
6931 	.f = cmd_link_flow_ctrl_set_parsed,
6932 	.data = NULL,
6933 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6934 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6935 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6936 	.tokens = {
6937 		(void *)&cmd_lfc_set_set,
6938 		(void *)&cmd_lfc_set_flow_ctrl,
6939 		(void *)&cmd_lfc_set_rx,
6940 		(void *)&cmd_lfc_set_rx_mode,
6941 		(void *)&cmd_lfc_set_tx,
6942 		(void *)&cmd_lfc_set_tx_mode,
6943 		(void *)&cmd_lfc_set_high_water,
6944 		(void *)&cmd_lfc_set_low_water,
6945 		(void *)&cmd_lfc_set_pause_time,
6946 		(void *)&cmd_lfc_set_send_xon,
6947 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6948 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6949 		(void *)&cmd_lfc_set_autoneg_str,
6950 		(void *)&cmd_lfc_set_autoneg,
6951 		(void *)&cmd_lfc_set_portid,
6952 		NULL,
6953 	},
6954 };
6955 
6956 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6957 	.f = cmd_link_flow_ctrl_set_parsed,
6958 	.data = (void *)&cmd_link_flow_control_set_rx,
6959 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6960 		"Change rx flow control parameter",
6961 	.tokens = {
6962 		(void *)&cmd_lfc_set_set,
6963 		(void *)&cmd_lfc_set_flow_ctrl,
6964 		(void *)&cmd_lfc_set_rx,
6965 		(void *)&cmd_lfc_set_rx_mode,
6966 		(void *)&cmd_lfc_set_portid,
6967 		NULL,
6968 	},
6969 };
6970 
6971 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6972 	.f = cmd_link_flow_ctrl_set_parsed,
6973 	.data = (void *)&cmd_link_flow_control_set_tx,
6974 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6975 		"Change tx flow control parameter",
6976 	.tokens = {
6977 		(void *)&cmd_lfc_set_set,
6978 		(void *)&cmd_lfc_set_flow_ctrl,
6979 		(void *)&cmd_lfc_set_tx,
6980 		(void *)&cmd_lfc_set_tx_mode,
6981 		(void *)&cmd_lfc_set_portid,
6982 		NULL,
6983 	},
6984 };
6985 
6986 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6987 	.f = cmd_link_flow_ctrl_set_parsed,
6988 	.data = (void *)&cmd_link_flow_control_set_hw,
6989 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6990 		"Change high water flow control parameter",
6991 	.tokens = {
6992 		(void *)&cmd_lfc_set_set,
6993 		(void *)&cmd_lfc_set_flow_ctrl,
6994 		(void *)&cmd_lfc_set_high_water_str,
6995 		(void *)&cmd_lfc_set_high_water,
6996 		(void *)&cmd_lfc_set_portid,
6997 		NULL,
6998 	},
6999 };
7000 
7001 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7002 	.f = cmd_link_flow_ctrl_set_parsed,
7003 	.data = (void *)&cmd_link_flow_control_set_lw,
7004 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7005 		"Change low water flow control parameter",
7006 	.tokens = {
7007 		(void *)&cmd_lfc_set_set,
7008 		(void *)&cmd_lfc_set_flow_ctrl,
7009 		(void *)&cmd_lfc_set_low_water_str,
7010 		(void *)&cmd_lfc_set_low_water,
7011 		(void *)&cmd_lfc_set_portid,
7012 		NULL,
7013 	},
7014 };
7015 
7016 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7017 	.f = cmd_link_flow_ctrl_set_parsed,
7018 	.data = (void *)&cmd_link_flow_control_set_pt,
7019 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7020 		"Change pause time flow control parameter",
7021 	.tokens = {
7022 		(void *)&cmd_lfc_set_set,
7023 		(void *)&cmd_lfc_set_flow_ctrl,
7024 		(void *)&cmd_lfc_set_pause_time_str,
7025 		(void *)&cmd_lfc_set_pause_time,
7026 		(void *)&cmd_lfc_set_portid,
7027 		NULL,
7028 	},
7029 };
7030 
7031 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7032 	.f = cmd_link_flow_ctrl_set_parsed,
7033 	.data = (void *)&cmd_link_flow_control_set_xon,
7034 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7035 		"Change send_xon flow control parameter",
7036 	.tokens = {
7037 		(void *)&cmd_lfc_set_set,
7038 		(void *)&cmd_lfc_set_flow_ctrl,
7039 		(void *)&cmd_lfc_set_send_xon_str,
7040 		(void *)&cmd_lfc_set_send_xon,
7041 		(void *)&cmd_lfc_set_portid,
7042 		NULL,
7043 	},
7044 };
7045 
7046 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7047 	.f = cmd_link_flow_ctrl_set_parsed,
7048 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7049 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7050 		"Change mac ctrl fwd flow control parameter",
7051 	.tokens = {
7052 		(void *)&cmd_lfc_set_set,
7053 		(void *)&cmd_lfc_set_flow_ctrl,
7054 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7055 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7056 		(void *)&cmd_lfc_set_portid,
7057 		NULL,
7058 	},
7059 };
7060 
7061 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7062 	.f = cmd_link_flow_ctrl_set_parsed,
7063 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7064 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7065 		"Change autoneg flow control parameter",
7066 	.tokens = {
7067 		(void *)&cmd_lfc_set_set,
7068 		(void *)&cmd_lfc_set_flow_ctrl,
7069 		(void *)&cmd_lfc_set_autoneg_str,
7070 		(void *)&cmd_lfc_set_autoneg,
7071 		(void *)&cmd_lfc_set_portid,
7072 		NULL,
7073 	},
7074 };
7075 
7076 static void
7077 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7078 			      __rte_unused struct cmdline *cl,
7079 			      void *data)
7080 {
7081 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7082 	cmdline_parse_inst_t *cmd = data;
7083 	struct rte_eth_fc_conf fc_conf;
7084 	int rx_fc_en = 0;
7085 	int tx_fc_en = 0;
7086 	int ret;
7087 
7088 	/*
7089 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7090 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7091 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7092 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7093 	 */
7094 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7095 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7096 	};
7097 
7098 	/* Partial command line, retrieve current configuration */
7099 	if (cmd) {
7100 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7101 		if (ret != 0) {
7102 			printf("cannot get current flow ctrl parameters, return"
7103 			       "code = %d\n", ret);
7104 			return;
7105 		}
7106 
7107 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7108 		    (fc_conf.mode == RTE_FC_FULL))
7109 			rx_fc_en = 1;
7110 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7111 		    (fc_conf.mode == RTE_FC_FULL))
7112 			tx_fc_en = 1;
7113 	}
7114 
7115 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7116 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7117 
7118 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7119 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7120 
7121 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7122 
7123 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7124 		fc_conf.high_water = res->high_water;
7125 
7126 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7127 		fc_conf.low_water = res->low_water;
7128 
7129 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7130 		fc_conf.pause_time = res->pause_time;
7131 
7132 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7133 		fc_conf.send_xon = res->send_xon;
7134 
7135 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7136 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7137 			fc_conf.mac_ctrl_frame_fwd = 1;
7138 		else
7139 			fc_conf.mac_ctrl_frame_fwd = 0;
7140 	}
7141 
7142 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7143 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7144 
7145 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7146 	if (ret != 0)
7147 		printf("bad flow contrl parameter, return code = %d \n", ret);
7148 }
7149 
7150 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7151 struct cmd_priority_flow_ctrl_set_result {
7152 	cmdline_fixed_string_t set;
7153 	cmdline_fixed_string_t pfc_ctrl;
7154 	cmdline_fixed_string_t rx;
7155 	cmdline_fixed_string_t rx_pfc_mode;
7156 	cmdline_fixed_string_t tx;
7157 	cmdline_fixed_string_t tx_pfc_mode;
7158 	uint32_t high_water;
7159 	uint32_t low_water;
7160 	uint16_t pause_time;
7161 	uint8_t  priority;
7162 	portid_t port_id;
7163 };
7164 
7165 static void
7166 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7167 		       __rte_unused struct cmdline *cl,
7168 		       __rte_unused void *data)
7169 {
7170 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7171 	struct rte_eth_pfc_conf pfc_conf;
7172 	int rx_fc_enable, tx_fc_enable;
7173 	int ret;
7174 
7175 	/*
7176 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7177 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7178 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7179 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7180 	 */
7181 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7182 		{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7183 	};
7184 
7185 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7186 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7187 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7188 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7189 	pfc_conf.fc.high_water = res->high_water;
7190 	pfc_conf.fc.low_water  = res->low_water;
7191 	pfc_conf.fc.pause_time = res->pause_time;
7192 	pfc_conf.priority      = res->priority;
7193 
7194 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7195 	if (ret != 0)
7196 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7197 }
7198 
7199 cmdline_parse_token_string_t cmd_pfc_set_set =
7200 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7201 				set, "set");
7202 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7203 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7204 				pfc_ctrl, "pfc_ctrl");
7205 cmdline_parse_token_string_t cmd_pfc_set_rx =
7206 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7207 				rx, "rx");
7208 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7209 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7210 				rx_pfc_mode, "on#off");
7211 cmdline_parse_token_string_t cmd_pfc_set_tx =
7212 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7213 				tx, "tx");
7214 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7215 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7216 				tx_pfc_mode, "on#off");
7217 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7218 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7219 				high_water, RTE_UINT32);
7220 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7221 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7222 				low_water, RTE_UINT32);
7223 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7224 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7225 				pause_time, RTE_UINT16);
7226 cmdline_parse_token_num_t cmd_pfc_set_priority =
7227 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7228 				priority, RTE_UINT8);
7229 cmdline_parse_token_num_t cmd_pfc_set_portid =
7230 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7231 				port_id, RTE_UINT16);
7232 
7233 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7234 	.f = cmd_priority_flow_ctrl_set_parsed,
7235 	.data = NULL,
7236 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7237 		"<pause_time> <priority> <port_id>: "
7238 		"Configure the Ethernet priority flow control",
7239 	.tokens = {
7240 		(void *)&cmd_pfc_set_set,
7241 		(void *)&cmd_pfc_set_flow_ctrl,
7242 		(void *)&cmd_pfc_set_rx,
7243 		(void *)&cmd_pfc_set_rx_mode,
7244 		(void *)&cmd_pfc_set_tx,
7245 		(void *)&cmd_pfc_set_tx_mode,
7246 		(void *)&cmd_pfc_set_high_water,
7247 		(void *)&cmd_pfc_set_low_water,
7248 		(void *)&cmd_pfc_set_pause_time,
7249 		(void *)&cmd_pfc_set_priority,
7250 		(void *)&cmd_pfc_set_portid,
7251 		NULL,
7252 	},
7253 };
7254 
7255 /* *** RESET CONFIGURATION *** */
7256 struct cmd_reset_result {
7257 	cmdline_fixed_string_t reset;
7258 	cmdline_fixed_string_t def;
7259 };
7260 
7261 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7262 			     struct cmdline *cl,
7263 			     __rte_unused void *data)
7264 {
7265 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7266 	set_def_fwd_config();
7267 }
7268 
7269 cmdline_parse_token_string_t cmd_reset_set =
7270 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7271 cmdline_parse_token_string_t cmd_reset_def =
7272 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7273 				 "default");
7274 
7275 cmdline_parse_inst_t cmd_reset = {
7276 	.f = cmd_reset_parsed,
7277 	.data = NULL,
7278 	.help_str = "set default: Reset default forwarding configuration",
7279 	.tokens = {
7280 		(void *)&cmd_reset_set,
7281 		(void *)&cmd_reset_def,
7282 		NULL,
7283 	},
7284 };
7285 
7286 /* *** START FORWARDING *** */
7287 struct cmd_start_result {
7288 	cmdline_fixed_string_t start;
7289 };
7290 
7291 cmdline_parse_token_string_t cmd_start_start =
7292 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7293 
7294 static void cmd_start_parsed(__rte_unused void *parsed_result,
7295 			     __rte_unused struct cmdline *cl,
7296 			     __rte_unused void *data)
7297 {
7298 	start_packet_forwarding(0);
7299 }
7300 
7301 cmdline_parse_inst_t cmd_start = {
7302 	.f = cmd_start_parsed,
7303 	.data = NULL,
7304 	.help_str = "start: Start packet forwarding",
7305 	.tokens = {
7306 		(void *)&cmd_start_start,
7307 		NULL,
7308 	},
7309 };
7310 
7311 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7312 struct cmd_start_tx_first_result {
7313 	cmdline_fixed_string_t start;
7314 	cmdline_fixed_string_t tx_first;
7315 };
7316 
7317 static void
7318 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7319 			  __rte_unused struct cmdline *cl,
7320 			  __rte_unused void *data)
7321 {
7322 	start_packet_forwarding(1);
7323 }
7324 
7325 cmdline_parse_token_string_t cmd_start_tx_first_start =
7326 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7327 				 "start");
7328 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7329 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7330 				 tx_first, "tx_first");
7331 
7332 cmdline_parse_inst_t cmd_start_tx_first = {
7333 	.f = cmd_start_tx_first_parsed,
7334 	.data = NULL,
7335 	.help_str = "start tx_first: Start packet forwarding, "
7336 		"after sending 1 burst of packets",
7337 	.tokens = {
7338 		(void *)&cmd_start_tx_first_start,
7339 		(void *)&cmd_start_tx_first_tx_first,
7340 		NULL,
7341 	},
7342 };
7343 
7344 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7345 struct cmd_start_tx_first_n_result {
7346 	cmdline_fixed_string_t start;
7347 	cmdline_fixed_string_t tx_first;
7348 	uint32_t tx_num;
7349 };
7350 
7351 static void
7352 cmd_start_tx_first_n_parsed(void *parsed_result,
7353 			  __rte_unused struct cmdline *cl,
7354 			  __rte_unused void *data)
7355 {
7356 	struct cmd_start_tx_first_n_result *res = parsed_result;
7357 
7358 	start_packet_forwarding(res->tx_num);
7359 }
7360 
7361 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7362 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7363 			start, "start");
7364 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7365 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7366 			tx_first, "tx_first");
7367 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7368 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7369 			tx_num, RTE_UINT32);
7370 
7371 cmdline_parse_inst_t cmd_start_tx_first_n = {
7372 	.f = cmd_start_tx_first_n_parsed,
7373 	.data = NULL,
7374 	.help_str = "start tx_first <num>: "
7375 		"packet forwarding, after sending <num> bursts of packets",
7376 	.tokens = {
7377 		(void *)&cmd_start_tx_first_n_start,
7378 		(void *)&cmd_start_tx_first_n_tx_first,
7379 		(void *)&cmd_start_tx_first_n_tx_num,
7380 		NULL,
7381 	},
7382 };
7383 
7384 /* *** SET LINK UP *** */
7385 struct cmd_set_link_up_result {
7386 	cmdline_fixed_string_t set;
7387 	cmdline_fixed_string_t link_up;
7388 	cmdline_fixed_string_t port;
7389 	portid_t port_id;
7390 };
7391 
7392 cmdline_parse_token_string_t cmd_set_link_up_set =
7393 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7394 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7395 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7396 				"link-up");
7397 cmdline_parse_token_string_t cmd_set_link_up_port =
7398 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7399 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7400 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7401 				RTE_UINT16);
7402 
7403 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7404 			     __rte_unused struct cmdline *cl,
7405 			     __rte_unused void *data)
7406 {
7407 	struct cmd_set_link_up_result *res = parsed_result;
7408 	dev_set_link_up(res->port_id);
7409 }
7410 
7411 cmdline_parse_inst_t cmd_set_link_up = {
7412 	.f = cmd_set_link_up_parsed,
7413 	.data = NULL,
7414 	.help_str = "set link-up port <port id>",
7415 	.tokens = {
7416 		(void *)&cmd_set_link_up_set,
7417 		(void *)&cmd_set_link_up_link_up,
7418 		(void *)&cmd_set_link_up_port,
7419 		(void *)&cmd_set_link_up_port_id,
7420 		NULL,
7421 	},
7422 };
7423 
7424 /* *** SET LINK DOWN *** */
7425 struct cmd_set_link_down_result {
7426 	cmdline_fixed_string_t set;
7427 	cmdline_fixed_string_t link_down;
7428 	cmdline_fixed_string_t port;
7429 	portid_t port_id;
7430 };
7431 
7432 cmdline_parse_token_string_t cmd_set_link_down_set =
7433 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7434 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7435 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7436 				"link-down");
7437 cmdline_parse_token_string_t cmd_set_link_down_port =
7438 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7439 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7440 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7441 				RTE_UINT16);
7442 
7443 static void cmd_set_link_down_parsed(
7444 				__rte_unused void *parsed_result,
7445 				__rte_unused struct cmdline *cl,
7446 				__rte_unused void *data)
7447 {
7448 	struct cmd_set_link_down_result *res = parsed_result;
7449 	dev_set_link_down(res->port_id);
7450 }
7451 
7452 cmdline_parse_inst_t cmd_set_link_down = {
7453 	.f = cmd_set_link_down_parsed,
7454 	.data = NULL,
7455 	.help_str = "set link-down port <port id>",
7456 	.tokens = {
7457 		(void *)&cmd_set_link_down_set,
7458 		(void *)&cmd_set_link_down_link_down,
7459 		(void *)&cmd_set_link_down_port,
7460 		(void *)&cmd_set_link_down_port_id,
7461 		NULL,
7462 	},
7463 };
7464 
7465 /* *** SHOW CFG *** */
7466 struct cmd_showcfg_result {
7467 	cmdline_fixed_string_t show;
7468 	cmdline_fixed_string_t cfg;
7469 	cmdline_fixed_string_t what;
7470 };
7471 
7472 static void cmd_showcfg_parsed(void *parsed_result,
7473 			       __rte_unused struct cmdline *cl,
7474 			       __rte_unused void *data)
7475 {
7476 	struct cmd_showcfg_result *res = parsed_result;
7477 	if (!strcmp(res->what, "rxtx"))
7478 		rxtx_config_display();
7479 	else if (!strcmp(res->what, "cores"))
7480 		fwd_lcores_config_display();
7481 	else if (!strcmp(res->what, "fwd"))
7482 		pkt_fwd_config_display(&cur_fwd_config);
7483 	else if (!strcmp(res->what, "rxoffs"))
7484 		show_rx_pkt_offsets();
7485 	else if (!strcmp(res->what, "rxpkts"))
7486 		show_rx_pkt_segments();
7487 	else if (!strcmp(res->what, "txpkts"))
7488 		show_tx_pkt_segments();
7489 	else if (!strcmp(res->what, "txtimes"))
7490 		show_tx_pkt_times();
7491 }
7492 
7493 cmdline_parse_token_string_t cmd_showcfg_show =
7494 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7495 cmdline_parse_token_string_t cmd_showcfg_port =
7496 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7497 cmdline_parse_token_string_t cmd_showcfg_what =
7498 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7499 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7500 
7501 cmdline_parse_inst_t cmd_showcfg = {
7502 	.f = cmd_showcfg_parsed,
7503 	.data = NULL,
7504 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7505 	.tokens = {
7506 		(void *)&cmd_showcfg_show,
7507 		(void *)&cmd_showcfg_port,
7508 		(void *)&cmd_showcfg_what,
7509 		NULL,
7510 	},
7511 };
7512 
7513 /* *** SHOW ALL PORT INFO *** */
7514 struct cmd_showportall_result {
7515 	cmdline_fixed_string_t show;
7516 	cmdline_fixed_string_t port;
7517 	cmdline_fixed_string_t what;
7518 	cmdline_fixed_string_t all;
7519 };
7520 
7521 static void cmd_showportall_parsed(void *parsed_result,
7522 				__rte_unused struct cmdline *cl,
7523 				__rte_unused void *data)
7524 {
7525 	portid_t i;
7526 
7527 	struct cmd_showportall_result *res = parsed_result;
7528 	if (!strcmp(res->show, "clear")) {
7529 		if (!strcmp(res->what, "stats"))
7530 			RTE_ETH_FOREACH_DEV(i)
7531 				nic_stats_clear(i);
7532 		else if (!strcmp(res->what, "xstats"))
7533 			RTE_ETH_FOREACH_DEV(i)
7534 				nic_xstats_clear(i);
7535 	} else if (!strcmp(res->what, "info"))
7536 		RTE_ETH_FOREACH_DEV(i)
7537 			port_infos_display(i);
7538 	else if (!strcmp(res->what, "summary")) {
7539 		port_summary_header_display();
7540 		RTE_ETH_FOREACH_DEV(i)
7541 			port_summary_display(i);
7542 	}
7543 	else if (!strcmp(res->what, "stats"))
7544 		RTE_ETH_FOREACH_DEV(i)
7545 			nic_stats_display(i);
7546 	else if (!strcmp(res->what, "xstats"))
7547 		RTE_ETH_FOREACH_DEV(i)
7548 			nic_xstats_display(i);
7549 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7550 	else if (!strcmp(res->what, "fdir"))
7551 		RTE_ETH_FOREACH_DEV(i)
7552 			fdir_get_infos(i);
7553 #endif
7554 	else if (!strcmp(res->what, "dcb_tc"))
7555 		RTE_ETH_FOREACH_DEV(i)
7556 			port_dcb_info_display(i);
7557 	else if (!strcmp(res->what, "cap"))
7558 		RTE_ETH_FOREACH_DEV(i)
7559 			port_offload_cap_display(i);
7560 }
7561 
7562 cmdline_parse_token_string_t cmd_showportall_show =
7563 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7564 				 "show#clear");
7565 cmdline_parse_token_string_t cmd_showportall_port =
7566 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7567 cmdline_parse_token_string_t cmd_showportall_what =
7568 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7569 				 "info#summary#stats#xstats#fdir#dcb_tc#cap");
7570 cmdline_parse_token_string_t cmd_showportall_all =
7571 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7572 cmdline_parse_inst_t cmd_showportall = {
7573 	.f = cmd_showportall_parsed,
7574 	.data = NULL,
7575 	.help_str = "show|clear port "
7576 		"info|summary|stats|xstats|fdir|dcb_tc|cap all",
7577 	.tokens = {
7578 		(void *)&cmd_showportall_show,
7579 		(void *)&cmd_showportall_port,
7580 		(void *)&cmd_showportall_what,
7581 		(void *)&cmd_showportall_all,
7582 		NULL,
7583 	},
7584 };
7585 
7586 /* *** SHOW PORT INFO *** */
7587 struct cmd_showport_result {
7588 	cmdline_fixed_string_t show;
7589 	cmdline_fixed_string_t port;
7590 	cmdline_fixed_string_t what;
7591 	uint16_t portnum;
7592 };
7593 
7594 static void cmd_showport_parsed(void *parsed_result,
7595 				__rte_unused struct cmdline *cl,
7596 				__rte_unused void *data)
7597 {
7598 	struct cmd_showport_result *res = parsed_result;
7599 	if (!strcmp(res->show, "clear")) {
7600 		if (!strcmp(res->what, "stats"))
7601 			nic_stats_clear(res->portnum);
7602 		else if (!strcmp(res->what, "xstats"))
7603 			nic_xstats_clear(res->portnum);
7604 	} else if (!strcmp(res->what, "info"))
7605 		port_infos_display(res->portnum);
7606 	else if (!strcmp(res->what, "summary")) {
7607 		port_summary_header_display();
7608 		port_summary_display(res->portnum);
7609 	}
7610 	else if (!strcmp(res->what, "stats"))
7611 		nic_stats_display(res->portnum);
7612 	else if (!strcmp(res->what, "xstats"))
7613 		nic_xstats_display(res->portnum);
7614 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7615 	else if (!strcmp(res->what, "fdir"))
7616 		 fdir_get_infos(res->portnum);
7617 #endif
7618 	else if (!strcmp(res->what, "dcb_tc"))
7619 		port_dcb_info_display(res->portnum);
7620 	else if (!strcmp(res->what, "cap"))
7621 		port_offload_cap_display(res->portnum);
7622 }
7623 
7624 cmdline_parse_token_string_t cmd_showport_show =
7625 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7626 				 "show#clear");
7627 cmdline_parse_token_string_t cmd_showport_port =
7628 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7629 cmdline_parse_token_string_t cmd_showport_what =
7630 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7631 				 "info#summary#stats#xstats#fdir#dcb_tc#cap");
7632 cmdline_parse_token_num_t cmd_showport_portnum =
7633 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7634 
7635 cmdline_parse_inst_t cmd_showport = {
7636 	.f = cmd_showport_parsed,
7637 	.data = NULL,
7638 	.help_str = "show|clear port "
7639 		"info|summary|stats|xstats|fdir|dcb_tc|cap "
7640 		"<port_id>",
7641 	.tokens = {
7642 		(void *)&cmd_showport_show,
7643 		(void *)&cmd_showport_port,
7644 		(void *)&cmd_showport_what,
7645 		(void *)&cmd_showport_portnum,
7646 		NULL,
7647 	},
7648 };
7649 
7650 /* *** SHOW DEVICE INFO *** */
7651 struct cmd_showdevice_result {
7652 	cmdline_fixed_string_t show;
7653 	cmdline_fixed_string_t device;
7654 	cmdline_fixed_string_t what;
7655 	cmdline_fixed_string_t identifier;
7656 };
7657 
7658 static void cmd_showdevice_parsed(void *parsed_result,
7659 				__rte_unused struct cmdline *cl,
7660 				__rte_unused void *data)
7661 {
7662 	struct cmd_showdevice_result *res = parsed_result;
7663 	if (!strcmp(res->what, "info")) {
7664 		if (!strcmp(res->identifier, "all"))
7665 			device_infos_display(NULL);
7666 		else
7667 			device_infos_display(res->identifier);
7668 	}
7669 }
7670 
7671 cmdline_parse_token_string_t cmd_showdevice_show =
7672 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7673 				 "show");
7674 cmdline_parse_token_string_t cmd_showdevice_device =
7675 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7676 cmdline_parse_token_string_t cmd_showdevice_what =
7677 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7678 				 "info");
7679 cmdline_parse_token_string_t cmd_showdevice_identifier =
7680 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7681 			identifier, NULL);
7682 
7683 cmdline_parse_inst_t cmd_showdevice = {
7684 	.f = cmd_showdevice_parsed,
7685 	.data = NULL,
7686 	.help_str = "show device info <identifier>|all",
7687 	.tokens = {
7688 		(void *)&cmd_showdevice_show,
7689 		(void *)&cmd_showdevice_device,
7690 		(void *)&cmd_showdevice_what,
7691 		(void *)&cmd_showdevice_identifier,
7692 		NULL,
7693 	},
7694 };
7695 
7696 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7697 struct cmd_showeeprom_result {
7698 	cmdline_fixed_string_t show;
7699 	cmdline_fixed_string_t port;
7700 	uint16_t portnum;
7701 	cmdline_fixed_string_t type;
7702 };
7703 
7704 static void cmd_showeeprom_parsed(void *parsed_result,
7705 		__rte_unused struct cmdline *cl,
7706 		__rte_unused void *data)
7707 {
7708 	struct cmd_showeeprom_result *res = parsed_result;
7709 
7710 	if (!strcmp(res->type, "eeprom"))
7711 		port_eeprom_display(res->portnum);
7712 	else if (!strcmp(res->type, "module_eeprom"))
7713 		port_module_eeprom_display(res->portnum);
7714 	else
7715 		printf("Unknown argument\n");
7716 }
7717 
7718 cmdline_parse_token_string_t cmd_showeeprom_show =
7719 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7720 cmdline_parse_token_string_t cmd_showeeprom_port =
7721 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7722 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7723 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7724 			RTE_UINT16);
7725 cmdline_parse_token_string_t cmd_showeeprom_type =
7726 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7727 
7728 cmdline_parse_inst_t cmd_showeeprom = {
7729 	.f = cmd_showeeprom_parsed,
7730 	.data = NULL,
7731 	.help_str = "show port <port_id> module_eeprom|eeprom",
7732 	.tokens = {
7733 		(void *)&cmd_showeeprom_show,
7734 		(void *)&cmd_showeeprom_port,
7735 		(void *)&cmd_showeeprom_portnum,
7736 		(void *)&cmd_showeeprom_type,
7737 		NULL,
7738 	},
7739 };
7740 
7741 /* *** SHOW QUEUE INFO *** */
7742 struct cmd_showqueue_result {
7743 	cmdline_fixed_string_t show;
7744 	cmdline_fixed_string_t type;
7745 	cmdline_fixed_string_t what;
7746 	uint16_t portnum;
7747 	uint16_t queuenum;
7748 };
7749 
7750 static void
7751 cmd_showqueue_parsed(void *parsed_result,
7752 	__rte_unused struct cmdline *cl,
7753 	__rte_unused void *data)
7754 {
7755 	struct cmd_showqueue_result *res = parsed_result;
7756 
7757 	if (!strcmp(res->type, "rxq"))
7758 		rx_queue_infos_display(res->portnum, res->queuenum);
7759 	else if (!strcmp(res->type, "txq"))
7760 		tx_queue_infos_display(res->portnum, res->queuenum);
7761 }
7762 
7763 cmdline_parse_token_string_t cmd_showqueue_show =
7764 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7765 cmdline_parse_token_string_t cmd_showqueue_type =
7766 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7767 cmdline_parse_token_string_t cmd_showqueue_what =
7768 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7769 cmdline_parse_token_num_t cmd_showqueue_portnum =
7770 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7771 		RTE_UINT16);
7772 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7773 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7774 		RTE_UINT16);
7775 
7776 cmdline_parse_inst_t cmd_showqueue = {
7777 	.f = cmd_showqueue_parsed,
7778 	.data = NULL,
7779 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7780 	.tokens = {
7781 		(void *)&cmd_showqueue_show,
7782 		(void *)&cmd_showqueue_type,
7783 		(void *)&cmd_showqueue_what,
7784 		(void *)&cmd_showqueue_portnum,
7785 		(void *)&cmd_showqueue_queuenum,
7786 		NULL,
7787 	},
7788 };
7789 
7790 /* show/clear fwd engine statistics */
7791 struct fwd_result {
7792 	cmdline_fixed_string_t action;
7793 	cmdline_fixed_string_t fwd;
7794 	cmdline_fixed_string_t stats;
7795 	cmdline_fixed_string_t all;
7796 };
7797 
7798 cmdline_parse_token_string_t cmd_fwd_action =
7799 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7800 cmdline_parse_token_string_t cmd_fwd_fwd =
7801 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7802 cmdline_parse_token_string_t cmd_fwd_stats =
7803 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7804 cmdline_parse_token_string_t cmd_fwd_all =
7805 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7806 
7807 static void
7808 cmd_showfwdall_parsed(void *parsed_result,
7809 		      __rte_unused struct cmdline *cl,
7810 		      __rte_unused void *data)
7811 {
7812 	struct fwd_result *res = parsed_result;
7813 
7814 	if (!strcmp(res->action, "show"))
7815 		fwd_stats_display();
7816 	else
7817 		fwd_stats_reset();
7818 }
7819 
7820 static cmdline_parse_inst_t cmd_showfwdall = {
7821 	.f = cmd_showfwdall_parsed,
7822 	.data = NULL,
7823 	.help_str = "show|clear fwd stats all",
7824 	.tokens = {
7825 		(void *)&cmd_fwd_action,
7826 		(void *)&cmd_fwd_fwd,
7827 		(void *)&cmd_fwd_stats,
7828 		(void *)&cmd_fwd_all,
7829 		NULL,
7830 	},
7831 };
7832 
7833 /* *** READ PORT REGISTER *** */
7834 struct cmd_read_reg_result {
7835 	cmdline_fixed_string_t read;
7836 	cmdline_fixed_string_t reg;
7837 	portid_t port_id;
7838 	uint32_t reg_off;
7839 };
7840 
7841 static void
7842 cmd_read_reg_parsed(void *parsed_result,
7843 		    __rte_unused struct cmdline *cl,
7844 		    __rte_unused void *data)
7845 {
7846 	struct cmd_read_reg_result *res = parsed_result;
7847 	port_reg_display(res->port_id, res->reg_off);
7848 }
7849 
7850 cmdline_parse_token_string_t cmd_read_reg_read =
7851 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7852 cmdline_parse_token_string_t cmd_read_reg_reg =
7853 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7854 cmdline_parse_token_num_t cmd_read_reg_port_id =
7855 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7856 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7857 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7858 
7859 cmdline_parse_inst_t cmd_read_reg = {
7860 	.f = cmd_read_reg_parsed,
7861 	.data = NULL,
7862 	.help_str = "read reg <port_id> <reg_off>",
7863 	.tokens = {
7864 		(void *)&cmd_read_reg_read,
7865 		(void *)&cmd_read_reg_reg,
7866 		(void *)&cmd_read_reg_port_id,
7867 		(void *)&cmd_read_reg_reg_off,
7868 		NULL,
7869 	},
7870 };
7871 
7872 /* *** READ PORT REGISTER BIT FIELD *** */
7873 struct cmd_read_reg_bit_field_result {
7874 	cmdline_fixed_string_t read;
7875 	cmdline_fixed_string_t regfield;
7876 	portid_t port_id;
7877 	uint32_t reg_off;
7878 	uint8_t bit1_pos;
7879 	uint8_t bit2_pos;
7880 };
7881 
7882 static void
7883 cmd_read_reg_bit_field_parsed(void *parsed_result,
7884 			      __rte_unused struct cmdline *cl,
7885 			      __rte_unused void *data)
7886 {
7887 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7888 	port_reg_bit_field_display(res->port_id, res->reg_off,
7889 				   res->bit1_pos, res->bit2_pos);
7890 }
7891 
7892 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7893 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7894 				 "read");
7895 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7896 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7897 				 regfield, "regfield");
7898 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7899 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7900 			      RTE_UINT16);
7901 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7902 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7903 			      RTE_UINT32);
7904 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7905 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7906 			      RTE_UINT8);
7907 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7908 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7909 			      RTE_UINT8);
7910 
7911 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7912 	.f = cmd_read_reg_bit_field_parsed,
7913 	.data = NULL,
7914 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7915 	"Read register bit field between bit_x and bit_y included",
7916 	.tokens = {
7917 		(void *)&cmd_read_reg_bit_field_read,
7918 		(void *)&cmd_read_reg_bit_field_regfield,
7919 		(void *)&cmd_read_reg_bit_field_port_id,
7920 		(void *)&cmd_read_reg_bit_field_reg_off,
7921 		(void *)&cmd_read_reg_bit_field_bit1_pos,
7922 		(void *)&cmd_read_reg_bit_field_bit2_pos,
7923 		NULL,
7924 	},
7925 };
7926 
7927 /* *** READ PORT REGISTER BIT *** */
7928 struct cmd_read_reg_bit_result {
7929 	cmdline_fixed_string_t read;
7930 	cmdline_fixed_string_t regbit;
7931 	portid_t port_id;
7932 	uint32_t reg_off;
7933 	uint8_t bit_pos;
7934 };
7935 
7936 static void
7937 cmd_read_reg_bit_parsed(void *parsed_result,
7938 			__rte_unused struct cmdline *cl,
7939 			__rte_unused void *data)
7940 {
7941 	struct cmd_read_reg_bit_result *res = parsed_result;
7942 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7943 }
7944 
7945 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7946 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7947 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7948 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7949 				 regbit, "regbit");
7950 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7951 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
7952 				 RTE_UINT16);
7953 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7954 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
7955 				 RTE_UINT32);
7956 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7957 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
7958 				 RTE_UINT8);
7959 
7960 cmdline_parse_inst_t cmd_read_reg_bit = {
7961 	.f = cmd_read_reg_bit_parsed,
7962 	.data = NULL,
7963 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7964 	.tokens = {
7965 		(void *)&cmd_read_reg_bit_read,
7966 		(void *)&cmd_read_reg_bit_regbit,
7967 		(void *)&cmd_read_reg_bit_port_id,
7968 		(void *)&cmd_read_reg_bit_reg_off,
7969 		(void *)&cmd_read_reg_bit_bit_pos,
7970 		NULL,
7971 	},
7972 };
7973 
7974 /* *** WRITE PORT REGISTER *** */
7975 struct cmd_write_reg_result {
7976 	cmdline_fixed_string_t write;
7977 	cmdline_fixed_string_t reg;
7978 	portid_t port_id;
7979 	uint32_t reg_off;
7980 	uint32_t value;
7981 };
7982 
7983 static void
7984 cmd_write_reg_parsed(void *parsed_result,
7985 		     __rte_unused struct cmdline *cl,
7986 		     __rte_unused void *data)
7987 {
7988 	struct cmd_write_reg_result *res = parsed_result;
7989 	port_reg_set(res->port_id, res->reg_off, res->value);
7990 }
7991 
7992 cmdline_parse_token_string_t cmd_write_reg_write =
7993 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7994 cmdline_parse_token_string_t cmd_write_reg_reg =
7995 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7996 cmdline_parse_token_num_t cmd_write_reg_port_id =
7997 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
7998 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7999 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8000 cmdline_parse_token_num_t cmd_write_reg_value =
8001 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8002 
8003 cmdline_parse_inst_t cmd_write_reg = {
8004 	.f = cmd_write_reg_parsed,
8005 	.data = NULL,
8006 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8007 	.tokens = {
8008 		(void *)&cmd_write_reg_write,
8009 		(void *)&cmd_write_reg_reg,
8010 		(void *)&cmd_write_reg_port_id,
8011 		(void *)&cmd_write_reg_reg_off,
8012 		(void *)&cmd_write_reg_value,
8013 		NULL,
8014 	},
8015 };
8016 
8017 /* *** WRITE PORT REGISTER BIT FIELD *** */
8018 struct cmd_write_reg_bit_field_result {
8019 	cmdline_fixed_string_t write;
8020 	cmdline_fixed_string_t regfield;
8021 	portid_t port_id;
8022 	uint32_t reg_off;
8023 	uint8_t bit1_pos;
8024 	uint8_t bit2_pos;
8025 	uint32_t value;
8026 };
8027 
8028 static void
8029 cmd_write_reg_bit_field_parsed(void *parsed_result,
8030 			       __rte_unused struct cmdline *cl,
8031 			       __rte_unused void *data)
8032 {
8033 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8034 	port_reg_bit_field_set(res->port_id, res->reg_off,
8035 			  res->bit1_pos, res->bit2_pos, res->value);
8036 }
8037 
8038 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8039 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8040 				 "write");
8041 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8042 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8043 				 regfield, "regfield");
8044 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8045 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8046 			      RTE_UINT16);
8047 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8048 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8049 			      RTE_UINT32);
8050 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8051 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8052 			      RTE_UINT8);
8053 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8054 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8055 			      RTE_UINT8);
8056 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8057 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8058 			      RTE_UINT32);
8059 
8060 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8061 	.f = cmd_write_reg_bit_field_parsed,
8062 	.data = NULL,
8063 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8064 		"<reg_value>: "
8065 		"Set register bit field between bit_x and bit_y included",
8066 	.tokens = {
8067 		(void *)&cmd_write_reg_bit_field_write,
8068 		(void *)&cmd_write_reg_bit_field_regfield,
8069 		(void *)&cmd_write_reg_bit_field_port_id,
8070 		(void *)&cmd_write_reg_bit_field_reg_off,
8071 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8072 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8073 		(void *)&cmd_write_reg_bit_field_value,
8074 		NULL,
8075 	},
8076 };
8077 
8078 /* *** WRITE PORT REGISTER BIT *** */
8079 struct cmd_write_reg_bit_result {
8080 	cmdline_fixed_string_t write;
8081 	cmdline_fixed_string_t regbit;
8082 	portid_t port_id;
8083 	uint32_t reg_off;
8084 	uint8_t bit_pos;
8085 	uint8_t value;
8086 };
8087 
8088 static void
8089 cmd_write_reg_bit_parsed(void *parsed_result,
8090 			 __rte_unused struct cmdline *cl,
8091 			 __rte_unused void *data)
8092 {
8093 	struct cmd_write_reg_bit_result *res = parsed_result;
8094 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8095 }
8096 
8097 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8098 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8099 				 "write");
8100 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8101 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8102 				 regbit, "regbit");
8103 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8104 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8105 				 RTE_UINT16);
8106 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8107 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8108 				 RTE_UINT32);
8109 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8110 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8111 				 RTE_UINT8);
8112 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8113 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8114 				 RTE_UINT8);
8115 
8116 cmdline_parse_inst_t cmd_write_reg_bit = {
8117 	.f = cmd_write_reg_bit_parsed,
8118 	.data = NULL,
8119 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8120 		"0 <= bit_x <= 31",
8121 	.tokens = {
8122 		(void *)&cmd_write_reg_bit_write,
8123 		(void *)&cmd_write_reg_bit_regbit,
8124 		(void *)&cmd_write_reg_bit_port_id,
8125 		(void *)&cmd_write_reg_bit_reg_off,
8126 		(void *)&cmd_write_reg_bit_bit_pos,
8127 		(void *)&cmd_write_reg_bit_value,
8128 		NULL,
8129 	},
8130 };
8131 
8132 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8133 struct cmd_read_rxd_txd_result {
8134 	cmdline_fixed_string_t read;
8135 	cmdline_fixed_string_t rxd_txd;
8136 	portid_t port_id;
8137 	uint16_t queue_id;
8138 	uint16_t desc_id;
8139 };
8140 
8141 static void
8142 cmd_read_rxd_txd_parsed(void *parsed_result,
8143 			__rte_unused struct cmdline *cl,
8144 			__rte_unused void *data)
8145 {
8146 	struct cmd_read_rxd_txd_result *res = parsed_result;
8147 
8148 	if (!strcmp(res->rxd_txd, "rxd"))
8149 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8150 	else if (!strcmp(res->rxd_txd, "txd"))
8151 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8152 }
8153 
8154 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8155 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8156 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8157 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8158 				 "rxd#txd");
8159 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8160 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8161 				 RTE_UINT16);
8162 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8163 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8164 				 RTE_UINT16);
8165 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8166 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8167 				 RTE_UINT16);
8168 
8169 cmdline_parse_inst_t cmd_read_rxd_txd = {
8170 	.f = cmd_read_rxd_txd_parsed,
8171 	.data = NULL,
8172 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8173 	.tokens = {
8174 		(void *)&cmd_read_rxd_txd_read,
8175 		(void *)&cmd_read_rxd_txd_rxd_txd,
8176 		(void *)&cmd_read_rxd_txd_port_id,
8177 		(void *)&cmd_read_rxd_txd_queue_id,
8178 		(void *)&cmd_read_rxd_txd_desc_id,
8179 		NULL,
8180 	},
8181 };
8182 
8183 /* *** QUIT *** */
8184 struct cmd_quit_result {
8185 	cmdline_fixed_string_t quit;
8186 };
8187 
8188 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8189 			    struct cmdline *cl,
8190 			    __rte_unused void *data)
8191 {
8192 	cmdline_quit(cl);
8193 }
8194 
8195 cmdline_parse_token_string_t cmd_quit_quit =
8196 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8197 
8198 cmdline_parse_inst_t cmd_quit = {
8199 	.f = cmd_quit_parsed,
8200 	.data = NULL,
8201 	.help_str = "quit: Exit application",
8202 	.tokens = {
8203 		(void *)&cmd_quit_quit,
8204 		NULL,
8205 	},
8206 };
8207 
8208 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8209 struct cmd_mac_addr_result {
8210 	cmdline_fixed_string_t mac_addr_cmd;
8211 	cmdline_fixed_string_t what;
8212 	uint16_t port_num;
8213 	struct rte_ether_addr address;
8214 };
8215 
8216 static void cmd_mac_addr_parsed(void *parsed_result,
8217 		__rte_unused struct cmdline *cl,
8218 		__rte_unused void *data)
8219 {
8220 	struct cmd_mac_addr_result *res = parsed_result;
8221 	int ret;
8222 
8223 	if (strcmp(res->what, "add") == 0)
8224 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8225 	else if (strcmp(res->what, "set") == 0)
8226 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8227 						       &res->address);
8228 	else
8229 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8230 
8231 	/* check the return value and print it if is < 0 */
8232 	if(ret < 0)
8233 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8234 
8235 }
8236 
8237 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8238 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8239 				"mac_addr");
8240 cmdline_parse_token_string_t cmd_mac_addr_what =
8241 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8242 				"add#remove#set");
8243 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8244 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8245 					RTE_UINT16);
8246 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8247 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8248 
8249 cmdline_parse_inst_t cmd_mac_addr = {
8250 	.f = cmd_mac_addr_parsed,
8251 	.data = (void *)0,
8252 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8253 			"Add/Remove/Set MAC address on port_id",
8254 	.tokens = {
8255 		(void *)&cmd_mac_addr_cmd,
8256 		(void *)&cmd_mac_addr_what,
8257 		(void *)&cmd_mac_addr_portnum,
8258 		(void *)&cmd_mac_addr_addr,
8259 		NULL,
8260 	},
8261 };
8262 
8263 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8264 struct cmd_eth_peer_result {
8265 	cmdline_fixed_string_t set;
8266 	cmdline_fixed_string_t eth_peer;
8267 	portid_t port_id;
8268 	cmdline_fixed_string_t peer_addr;
8269 };
8270 
8271 static void cmd_set_eth_peer_parsed(void *parsed_result,
8272 			__rte_unused struct cmdline *cl,
8273 			__rte_unused void *data)
8274 {
8275 		struct cmd_eth_peer_result *res = parsed_result;
8276 
8277 		if (test_done == 0) {
8278 			printf("Please stop forwarding first\n");
8279 			return;
8280 		}
8281 		if (!strcmp(res->eth_peer, "eth-peer")) {
8282 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8283 			fwd_config_setup();
8284 		}
8285 }
8286 cmdline_parse_token_string_t cmd_eth_peer_set =
8287 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8288 cmdline_parse_token_string_t cmd_eth_peer =
8289 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8290 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8291 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8292 		RTE_UINT16);
8293 cmdline_parse_token_string_t cmd_eth_peer_addr =
8294 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8295 
8296 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8297 	.f = cmd_set_eth_peer_parsed,
8298 	.data = NULL,
8299 	.help_str = "set eth-peer <port_id> <peer_mac>",
8300 	.tokens = {
8301 		(void *)&cmd_eth_peer_set,
8302 		(void *)&cmd_eth_peer,
8303 		(void *)&cmd_eth_peer_port_id,
8304 		(void *)&cmd_eth_peer_addr,
8305 		NULL,
8306 	},
8307 };
8308 
8309 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8310 struct cmd_set_qmap_result {
8311 	cmdline_fixed_string_t set;
8312 	cmdline_fixed_string_t qmap;
8313 	cmdline_fixed_string_t what;
8314 	portid_t port_id;
8315 	uint16_t queue_id;
8316 	uint8_t map_value;
8317 };
8318 
8319 static void
8320 cmd_set_qmap_parsed(void *parsed_result,
8321 		       __rte_unused struct cmdline *cl,
8322 		       __rte_unused void *data)
8323 {
8324 	struct cmd_set_qmap_result *res = parsed_result;
8325 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8326 
8327 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8328 }
8329 
8330 cmdline_parse_token_string_t cmd_setqmap_set =
8331 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8332 				 set, "set");
8333 cmdline_parse_token_string_t cmd_setqmap_qmap =
8334 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8335 				 qmap, "stat_qmap");
8336 cmdline_parse_token_string_t cmd_setqmap_what =
8337 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8338 				 what, "tx#rx");
8339 cmdline_parse_token_num_t cmd_setqmap_portid =
8340 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8341 			      port_id, RTE_UINT16);
8342 cmdline_parse_token_num_t cmd_setqmap_queueid =
8343 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8344 			      queue_id, RTE_UINT16);
8345 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8346 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8347 			      map_value, RTE_UINT8);
8348 
8349 cmdline_parse_inst_t cmd_set_qmap = {
8350 	.f = cmd_set_qmap_parsed,
8351 	.data = NULL,
8352 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8353 		"Set statistics mapping value on tx|rx queue_id of port_id",
8354 	.tokens = {
8355 		(void *)&cmd_setqmap_set,
8356 		(void *)&cmd_setqmap_qmap,
8357 		(void *)&cmd_setqmap_what,
8358 		(void *)&cmd_setqmap_portid,
8359 		(void *)&cmd_setqmap_queueid,
8360 		(void *)&cmd_setqmap_mapvalue,
8361 		NULL,
8362 	},
8363 };
8364 
8365 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8366 struct cmd_set_xstats_hide_zero_result {
8367 	cmdline_fixed_string_t keyword;
8368 	cmdline_fixed_string_t name;
8369 	cmdline_fixed_string_t on_off;
8370 };
8371 
8372 static void
8373 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8374 			__rte_unused struct cmdline *cl,
8375 			__rte_unused void *data)
8376 {
8377 	struct cmd_set_xstats_hide_zero_result *res;
8378 	uint16_t on_off = 0;
8379 
8380 	res = parsed_result;
8381 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8382 	set_xstats_hide_zero(on_off);
8383 }
8384 
8385 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8386 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8387 				 keyword, "set");
8388 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8389 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8390 				 name, "xstats-hide-zero");
8391 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8392 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8393 				 on_off, "on#off");
8394 
8395 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8396 	.f = cmd_set_xstats_hide_zero_parsed,
8397 	.data = NULL,
8398 	.help_str = "set xstats-hide-zero on|off",
8399 	.tokens = {
8400 		(void *)&cmd_set_xstats_hide_zero_keyword,
8401 		(void *)&cmd_set_xstats_hide_zero_name,
8402 		(void *)&cmd_set_xstats_hide_zero_on_off,
8403 		NULL,
8404 	},
8405 };
8406 
8407 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8408 struct cmd_set_record_core_cycles_result {
8409 	cmdline_fixed_string_t keyword;
8410 	cmdline_fixed_string_t name;
8411 	cmdline_fixed_string_t on_off;
8412 };
8413 
8414 static void
8415 cmd_set_record_core_cycles_parsed(void *parsed_result,
8416 			__rte_unused struct cmdline *cl,
8417 			__rte_unused void *data)
8418 {
8419 	struct cmd_set_record_core_cycles_result *res;
8420 	uint16_t on_off = 0;
8421 
8422 	res = parsed_result;
8423 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8424 	set_record_core_cycles(on_off);
8425 }
8426 
8427 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8428 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8429 				 keyword, "set");
8430 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8431 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8432 				 name, "record-core-cycles");
8433 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8434 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8435 				 on_off, "on#off");
8436 
8437 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8438 	.f = cmd_set_record_core_cycles_parsed,
8439 	.data = NULL,
8440 	.help_str = "set record-core-cycles on|off",
8441 	.tokens = {
8442 		(void *)&cmd_set_record_core_cycles_keyword,
8443 		(void *)&cmd_set_record_core_cycles_name,
8444 		(void *)&cmd_set_record_core_cycles_on_off,
8445 		NULL,
8446 	},
8447 };
8448 
8449 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8450 struct cmd_set_record_burst_stats_result {
8451 	cmdline_fixed_string_t keyword;
8452 	cmdline_fixed_string_t name;
8453 	cmdline_fixed_string_t on_off;
8454 };
8455 
8456 static void
8457 cmd_set_record_burst_stats_parsed(void *parsed_result,
8458 			__rte_unused struct cmdline *cl,
8459 			__rte_unused void *data)
8460 {
8461 	struct cmd_set_record_burst_stats_result *res;
8462 	uint16_t on_off = 0;
8463 
8464 	res = parsed_result;
8465 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8466 	set_record_burst_stats(on_off);
8467 }
8468 
8469 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8470 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8471 				 keyword, "set");
8472 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8473 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8474 				 name, "record-burst-stats");
8475 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8476 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8477 				 on_off, "on#off");
8478 
8479 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8480 	.f = cmd_set_record_burst_stats_parsed,
8481 	.data = NULL,
8482 	.help_str = "set record-burst-stats on|off",
8483 	.tokens = {
8484 		(void *)&cmd_set_record_burst_stats_keyword,
8485 		(void *)&cmd_set_record_burst_stats_name,
8486 		(void *)&cmd_set_record_burst_stats_on_off,
8487 		NULL,
8488 	},
8489 };
8490 
8491 /* *** CONFIGURE UNICAST HASH TABLE *** */
8492 struct cmd_set_uc_hash_table {
8493 	cmdline_fixed_string_t set;
8494 	cmdline_fixed_string_t port;
8495 	portid_t port_id;
8496 	cmdline_fixed_string_t what;
8497 	struct rte_ether_addr address;
8498 	cmdline_fixed_string_t mode;
8499 };
8500 
8501 static void
8502 cmd_set_uc_hash_parsed(void *parsed_result,
8503 		       __rte_unused struct cmdline *cl,
8504 		       __rte_unused void *data)
8505 {
8506 	int ret=0;
8507 	struct cmd_set_uc_hash_table *res = parsed_result;
8508 
8509 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8510 
8511 	if (strcmp(res->what, "uta") == 0)
8512 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8513 						&res->address,(uint8_t)is_on);
8514 	if (ret < 0)
8515 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8516 
8517 }
8518 
8519 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8520 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8521 				 set, "set");
8522 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8523 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8524 				 port, "port");
8525 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8526 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8527 			      port_id, RTE_UINT16);
8528 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8529 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8530 				 what, "uta");
8531 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8532 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8533 				address);
8534 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8535 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8536 				 mode, "on#off");
8537 
8538 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8539 	.f = cmd_set_uc_hash_parsed,
8540 	.data = NULL,
8541 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8542 	.tokens = {
8543 		(void *)&cmd_set_uc_hash_set,
8544 		(void *)&cmd_set_uc_hash_port,
8545 		(void *)&cmd_set_uc_hash_portid,
8546 		(void *)&cmd_set_uc_hash_what,
8547 		(void *)&cmd_set_uc_hash_mac,
8548 		(void *)&cmd_set_uc_hash_mode,
8549 		NULL,
8550 	},
8551 };
8552 
8553 struct cmd_set_uc_all_hash_table {
8554 	cmdline_fixed_string_t set;
8555 	cmdline_fixed_string_t port;
8556 	portid_t port_id;
8557 	cmdline_fixed_string_t what;
8558 	cmdline_fixed_string_t value;
8559 	cmdline_fixed_string_t mode;
8560 };
8561 
8562 static void
8563 cmd_set_uc_all_hash_parsed(void *parsed_result,
8564 		       __rte_unused struct cmdline *cl,
8565 		       __rte_unused void *data)
8566 {
8567 	int ret=0;
8568 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8569 
8570 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8571 
8572 	if ((strcmp(res->what, "uta") == 0) &&
8573 		(strcmp(res->value, "all") == 0))
8574 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8575 	if (ret < 0)
8576 		printf("bad unicast hash table parameter,"
8577 			"return code = %d \n", ret);
8578 }
8579 
8580 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8581 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8582 				 set, "set");
8583 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8584 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8585 				 port, "port");
8586 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8587 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8588 			      port_id, RTE_UINT16);
8589 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8590 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8591 				 what, "uta");
8592 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8593 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8594 				value,"all");
8595 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8596 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8597 				 mode, "on#off");
8598 
8599 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8600 	.f = cmd_set_uc_all_hash_parsed,
8601 	.data = NULL,
8602 	.help_str = "set port <port_id> uta all on|off",
8603 	.tokens = {
8604 		(void *)&cmd_set_uc_all_hash_set,
8605 		(void *)&cmd_set_uc_all_hash_port,
8606 		(void *)&cmd_set_uc_all_hash_portid,
8607 		(void *)&cmd_set_uc_all_hash_what,
8608 		(void *)&cmd_set_uc_all_hash_value,
8609 		(void *)&cmd_set_uc_all_hash_mode,
8610 		NULL,
8611 	},
8612 };
8613 
8614 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8615 struct cmd_set_vf_traffic {
8616 	cmdline_fixed_string_t set;
8617 	cmdline_fixed_string_t port;
8618 	portid_t port_id;
8619 	cmdline_fixed_string_t vf;
8620 	uint8_t vf_id;
8621 	cmdline_fixed_string_t what;
8622 	cmdline_fixed_string_t mode;
8623 };
8624 
8625 static void
8626 cmd_set_vf_traffic_parsed(void *parsed_result,
8627 		       __rte_unused struct cmdline *cl,
8628 		       __rte_unused void *data)
8629 {
8630 	struct cmd_set_vf_traffic *res = parsed_result;
8631 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8632 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8633 
8634 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8635 }
8636 
8637 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8638 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8639 				 set, "set");
8640 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8641 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8642 				 port, "port");
8643 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8644 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8645 			      port_id, RTE_UINT16);
8646 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8647 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8648 				 vf, "vf");
8649 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8650 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8651 			      vf_id, RTE_UINT8);
8652 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8653 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8654 				 what, "tx#rx");
8655 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8656 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8657 				 mode, "on#off");
8658 
8659 cmdline_parse_inst_t cmd_set_vf_traffic = {
8660 	.f = cmd_set_vf_traffic_parsed,
8661 	.data = NULL,
8662 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8663 	.tokens = {
8664 		(void *)&cmd_setvf_traffic_set,
8665 		(void *)&cmd_setvf_traffic_port,
8666 		(void *)&cmd_setvf_traffic_portid,
8667 		(void *)&cmd_setvf_traffic_vf,
8668 		(void *)&cmd_setvf_traffic_vfid,
8669 		(void *)&cmd_setvf_traffic_what,
8670 		(void *)&cmd_setvf_traffic_mode,
8671 		NULL,
8672 	},
8673 };
8674 
8675 /* *** CONFIGURE VF RECEIVE MODE *** */
8676 struct cmd_set_vf_rxmode {
8677 	cmdline_fixed_string_t set;
8678 	cmdline_fixed_string_t port;
8679 	portid_t port_id;
8680 	cmdline_fixed_string_t vf;
8681 	uint8_t vf_id;
8682 	cmdline_fixed_string_t what;
8683 	cmdline_fixed_string_t mode;
8684 	cmdline_fixed_string_t on;
8685 };
8686 
8687 static void
8688 cmd_set_vf_rxmode_parsed(void *parsed_result,
8689 		       __rte_unused struct cmdline *cl,
8690 		       __rte_unused void *data)
8691 {
8692 	int ret = -ENOTSUP;
8693 	uint16_t vf_rxmode = 0;
8694 	struct cmd_set_vf_rxmode *res = parsed_result;
8695 
8696 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8697 	if (!strcmp(res->what,"rxmode")) {
8698 		if (!strcmp(res->mode, "AUPE"))
8699 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8700 		else if (!strcmp(res->mode, "ROPE"))
8701 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8702 		else if (!strcmp(res->mode, "BAM"))
8703 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8704 		else if (!strncmp(res->mode, "MPE",3))
8705 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8706 	}
8707 
8708 	RTE_SET_USED(is_on);
8709 
8710 #ifdef RTE_NET_IXGBE
8711 	if (ret == -ENOTSUP)
8712 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8713 						  vf_rxmode, (uint8_t)is_on);
8714 #endif
8715 #ifdef RTE_NET_BNXT
8716 	if (ret == -ENOTSUP)
8717 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8718 						 vf_rxmode, (uint8_t)is_on);
8719 #endif
8720 	if (ret < 0)
8721 		printf("bad VF receive mode parameter, return code = %d \n",
8722 		ret);
8723 }
8724 
8725 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8726 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8727 				 set, "set");
8728 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8729 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8730 				 port, "port");
8731 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8732 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8733 			      port_id, RTE_UINT16);
8734 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8735 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8736 				 vf, "vf");
8737 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8738 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8739 			      vf_id, RTE_UINT8);
8740 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8741 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8742 				 what, "rxmode");
8743 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8744 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8745 				 mode, "AUPE#ROPE#BAM#MPE");
8746 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8747 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8748 				 on, "on#off");
8749 
8750 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8751 	.f = cmd_set_vf_rxmode_parsed,
8752 	.data = NULL,
8753 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8754 		"AUPE|ROPE|BAM|MPE on|off",
8755 	.tokens = {
8756 		(void *)&cmd_set_vf_rxmode_set,
8757 		(void *)&cmd_set_vf_rxmode_port,
8758 		(void *)&cmd_set_vf_rxmode_portid,
8759 		(void *)&cmd_set_vf_rxmode_vf,
8760 		(void *)&cmd_set_vf_rxmode_vfid,
8761 		(void *)&cmd_set_vf_rxmode_what,
8762 		(void *)&cmd_set_vf_rxmode_mode,
8763 		(void *)&cmd_set_vf_rxmode_on,
8764 		NULL,
8765 	},
8766 };
8767 
8768 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8769 struct cmd_vf_mac_addr_result {
8770 	cmdline_fixed_string_t mac_addr_cmd;
8771 	cmdline_fixed_string_t what;
8772 	cmdline_fixed_string_t port;
8773 	uint16_t port_num;
8774 	cmdline_fixed_string_t vf;
8775 	uint8_t vf_num;
8776 	struct rte_ether_addr address;
8777 };
8778 
8779 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8780 		__rte_unused struct cmdline *cl,
8781 		__rte_unused void *data)
8782 {
8783 	struct cmd_vf_mac_addr_result *res = parsed_result;
8784 	int ret = -ENOTSUP;
8785 
8786 	if (strcmp(res->what, "add") != 0)
8787 		return;
8788 
8789 #ifdef RTE_NET_I40E
8790 	if (ret == -ENOTSUP)
8791 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8792 						   &res->address);
8793 #endif
8794 #ifdef RTE_NET_BNXT
8795 	if (ret == -ENOTSUP)
8796 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8797 						res->vf_num);
8798 #endif
8799 
8800 	if(ret < 0)
8801 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8802 
8803 }
8804 
8805 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8806 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8807 				mac_addr_cmd,"mac_addr");
8808 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8809 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8810 				what,"add");
8811 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8812 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8813 				port,"port");
8814 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8815 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8816 				port_num, RTE_UINT16);
8817 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8818 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8819 				vf,"vf");
8820 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8821 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8822 				vf_num, RTE_UINT8);
8823 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8824 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8825 				address);
8826 
8827 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8828 	.f = cmd_vf_mac_addr_parsed,
8829 	.data = (void *)0,
8830 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8831 		"Add MAC address filtering for a VF on port_id",
8832 	.tokens = {
8833 		(void *)&cmd_vf_mac_addr_cmd,
8834 		(void *)&cmd_vf_mac_addr_what,
8835 		(void *)&cmd_vf_mac_addr_port,
8836 		(void *)&cmd_vf_mac_addr_portnum,
8837 		(void *)&cmd_vf_mac_addr_vf,
8838 		(void *)&cmd_vf_mac_addr_vfnum,
8839 		(void *)&cmd_vf_mac_addr_addr,
8840 		NULL,
8841 	},
8842 };
8843 
8844 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8845 struct cmd_vf_rx_vlan_filter {
8846 	cmdline_fixed_string_t rx_vlan;
8847 	cmdline_fixed_string_t what;
8848 	uint16_t vlan_id;
8849 	cmdline_fixed_string_t port;
8850 	portid_t port_id;
8851 	cmdline_fixed_string_t vf;
8852 	uint64_t vf_mask;
8853 };
8854 
8855 static void
8856 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8857 			  __rte_unused struct cmdline *cl,
8858 			  __rte_unused void *data)
8859 {
8860 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8861 	int ret = -ENOTSUP;
8862 
8863 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8864 
8865 #ifdef RTE_NET_IXGBE
8866 	if (ret == -ENOTSUP)
8867 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8868 				res->vlan_id, res->vf_mask, is_add);
8869 #endif
8870 #ifdef RTE_NET_I40E
8871 	if (ret == -ENOTSUP)
8872 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8873 				res->vlan_id, res->vf_mask, is_add);
8874 #endif
8875 #ifdef RTE_NET_BNXT
8876 	if (ret == -ENOTSUP)
8877 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8878 				res->vlan_id, res->vf_mask, is_add);
8879 #endif
8880 
8881 	switch (ret) {
8882 	case 0:
8883 		break;
8884 	case -EINVAL:
8885 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8886 				res->vlan_id, res->vf_mask);
8887 		break;
8888 	case -ENODEV:
8889 		printf("invalid port_id %d\n", res->port_id);
8890 		break;
8891 	case -ENOTSUP:
8892 		printf("function not implemented or supported\n");
8893 		break;
8894 	default:
8895 		printf("programming error: (%s)\n", strerror(-ret));
8896 	}
8897 }
8898 
8899 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8900 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8901 				 rx_vlan, "rx_vlan");
8902 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8903 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8904 				 what, "add#rm");
8905 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8906 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8907 			      vlan_id, RTE_UINT16);
8908 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8909 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8910 				 port, "port");
8911 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8912 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8913 			      port_id, RTE_UINT16);
8914 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8915 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8916 				 vf, "vf");
8917 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8918 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8919 			      vf_mask, RTE_UINT64);
8920 
8921 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8922 	.f = cmd_vf_rx_vlan_filter_parsed,
8923 	.data = NULL,
8924 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8925 		"(vf_mask = hexadecimal VF mask)",
8926 	.tokens = {
8927 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8928 		(void *)&cmd_vf_rx_vlan_filter_what,
8929 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8930 		(void *)&cmd_vf_rx_vlan_filter_port,
8931 		(void *)&cmd_vf_rx_vlan_filter_portid,
8932 		(void *)&cmd_vf_rx_vlan_filter_vf,
8933 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8934 		NULL,
8935 	},
8936 };
8937 
8938 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8939 struct cmd_queue_rate_limit_result {
8940 	cmdline_fixed_string_t set;
8941 	cmdline_fixed_string_t port;
8942 	uint16_t port_num;
8943 	cmdline_fixed_string_t queue;
8944 	uint8_t queue_num;
8945 	cmdline_fixed_string_t rate;
8946 	uint16_t rate_num;
8947 };
8948 
8949 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8950 		__rte_unused struct cmdline *cl,
8951 		__rte_unused void *data)
8952 {
8953 	struct cmd_queue_rate_limit_result *res = parsed_result;
8954 	int ret = 0;
8955 
8956 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8957 		&& (strcmp(res->queue, "queue") == 0)
8958 		&& (strcmp(res->rate, "rate") == 0))
8959 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8960 					res->rate_num);
8961 	if (ret < 0)
8962 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8963 
8964 }
8965 
8966 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8967 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8968 				set, "set");
8969 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8970 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8971 				port, "port");
8972 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8973 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8974 				port_num, RTE_UINT16);
8975 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8976 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8977 				queue, "queue");
8978 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8979 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8980 				queue_num, RTE_UINT8);
8981 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8982 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8983 				rate, "rate");
8984 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8985 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8986 				rate_num, RTE_UINT16);
8987 
8988 cmdline_parse_inst_t cmd_queue_rate_limit = {
8989 	.f = cmd_queue_rate_limit_parsed,
8990 	.data = (void *)0,
8991 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8992 		"Set rate limit for a queue on port_id",
8993 	.tokens = {
8994 		(void *)&cmd_queue_rate_limit_set,
8995 		(void *)&cmd_queue_rate_limit_port,
8996 		(void *)&cmd_queue_rate_limit_portnum,
8997 		(void *)&cmd_queue_rate_limit_queue,
8998 		(void *)&cmd_queue_rate_limit_queuenum,
8999 		(void *)&cmd_queue_rate_limit_rate,
9000 		(void *)&cmd_queue_rate_limit_ratenum,
9001 		NULL,
9002 	},
9003 };
9004 
9005 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9006 struct cmd_vf_rate_limit_result {
9007 	cmdline_fixed_string_t set;
9008 	cmdline_fixed_string_t port;
9009 	uint16_t port_num;
9010 	cmdline_fixed_string_t vf;
9011 	uint8_t vf_num;
9012 	cmdline_fixed_string_t rate;
9013 	uint16_t rate_num;
9014 	cmdline_fixed_string_t q_msk;
9015 	uint64_t q_msk_val;
9016 };
9017 
9018 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9019 		__rte_unused struct cmdline *cl,
9020 		__rte_unused void *data)
9021 {
9022 	struct cmd_vf_rate_limit_result *res = parsed_result;
9023 	int ret = 0;
9024 
9025 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9026 		&& (strcmp(res->vf, "vf") == 0)
9027 		&& (strcmp(res->rate, "rate") == 0)
9028 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9029 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9030 					res->rate_num, res->q_msk_val);
9031 	if (ret < 0)
9032 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9033 
9034 }
9035 
9036 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9037 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9038 				set, "set");
9039 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9040 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9041 				port, "port");
9042 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9043 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9044 				port_num, RTE_UINT16);
9045 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9046 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9047 				vf, "vf");
9048 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9049 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9050 				vf_num, RTE_UINT8);
9051 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9052 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9053 				rate, "rate");
9054 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9055 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9056 				rate_num, RTE_UINT16);
9057 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9058 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9059 				q_msk, "queue_mask");
9060 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9061 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9062 				q_msk_val, RTE_UINT64);
9063 
9064 cmdline_parse_inst_t cmd_vf_rate_limit = {
9065 	.f = cmd_vf_rate_limit_parsed,
9066 	.data = (void *)0,
9067 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9068 		"queue_mask <queue_mask_value>: "
9069 		"Set rate limit for queues of VF on port_id",
9070 	.tokens = {
9071 		(void *)&cmd_vf_rate_limit_set,
9072 		(void *)&cmd_vf_rate_limit_port,
9073 		(void *)&cmd_vf_rate_limit_portnum,
9074 		(void *)&cmd_vf_rate_limit_vf,
9075 		(void *)&cmd_vf_rate_limit_vfnum,
9076 		(void *)&cmd_vf_rate_limit_rate,
9077 		(void *)&cmd_vf_rate_limit_ratenum,
9078 		(void *)&cmd_vf_rate_limit_q_msk,
9079 		(void *)&cmd_vf_rate_limit_q_msk_val,
9080 		NULL,
9081 	},
9082 };
9083 
9084 /* *** CONFIGURE TUNNEL UDP PORT *** */
9085 struct cmd_tunnel_udp_config {
9086 	cmdline_fixed_string_t cmd;
9087 	cmdline_fixed_string_t what;
9088 	uint16_t udp_port;
9089 	portid_t port_id;
9090 };
9091 
9092 static void
9093 cmd_tunnel_udp_config_parsed(void *parsed_result,
9094 			  __rte_unused struct cmdline *cl,
9095 			  __rte_unused void *data)
9096 {
9097 	struct cmd_tunnel_udp_config *res = parsed_result;
9098 	struct rte_eth_udp_tunnel tunnel_udp;
9099 	int ret;
9100 
9101 	tunnel_udp.udp_port = res->udp_port;
9102 
9103 	if (!strcmp(res->cmd, "rx_vxlan_port"))
9104 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9105 
9106 	if (!strcmp(res->what, "add"))
9107 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9108 						      &tunnel_udp);
9109 	else
9110 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9111 							 &tunnel_udp);
9112 
9113 	if (ret < 0)
9114 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9115 }
9116 
9117 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9118 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9119 				cmd, "rx_vxlan_port");
9120 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9121 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9122 				what, "add#rm");
9123 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9124 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9125 				udp_port, RTE_UINT16);
9126 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9127 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9128 				port_id, RTE_UINT16);
9129 
9130 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9131 	.f = cmd_tunnel_udp_config_parsed,
9132 	.data = (void *)0,
9133 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9134 		"Add/Remove a tunneling UDP port filter",
9135 	.tokens = {
9136 		(void *)&cmd_tunnel_udp_config_cmd,
9137 		(void *)&cmd_tunnel_udp_config_what,
9138 		(void *)&cmd_tunnel_udp_config_udp_port,
9139 		(void *)&cmd_tunnel_udp_config_port_id,
9140 		NULL,
9141 	},
9142 };
9143 
9144 struct cmd_config_tunnel_udp_port {
9145 	cmdline_fixed_string_t port;
9146 	cmdline_fixed_string_t config;
9147 	portid_t port_id;
9148 	cmdline_fixed_string_t udp_tunnel_port;
9149 	cmdline_fixed_string_t action;
9150 	cmdline_fixed_string_t tunnel_type;
9151 	uint16_t udp_port;
9152 };
9153 
9154 static void
9155 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9156 			       __rte_unused struct cmdline *cl,
9157 			       __rte_unused void *data)
9158 {
9159 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9160 	struct rte_eth_udp_tunnel tunnel_udp;
9161 	int ret = 0;
9162 
9163 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9164 		return;
9165 
9166 	tunnel_udp.udp_port = res->udp_port;
9167 
9168 	if (!strcmp(res->tunnel_type, "vxlan")) {
9169 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9170 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9171 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9172 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9173 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9174 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9175 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9176 	} else {
9177 		printf("Invalid tunnel type\n");
9178 		return;
9179 	}
9180 
9181 	if (!strcmp(res->action, "add"))
9182 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9183 						      &tunnel_udp);
9184 	else
9185 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9186 							 &tunnel_udp);
9187 
9188 	if (ret < 0)
9189 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9190 }
9191 
9192 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9193 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9194 				 "port");
9195 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9196 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9197 				 "config");
9198 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9199 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9200 			      RTE_UINT16);
9201 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9202 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9203 				 udp_tunnel_port,
9204 				 "udp_tunnel_port");
9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9206 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9207 				 "add#rm");
9208 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9209 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9210 				 "vxlan#geneve#vxlan-gpe#ecpri");
9211 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9212 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9213 			      RTE_UINT16);
9214 
9215 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9216 	.f = cmd_cfg_tunnel_udp_port_parsed,
9217 	.data = NULL,
9218 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9219 		"geneve|vxlan-gpe|ecpri <udp_port>",
9220 	.tokens = {
9221 		(void *)&cmd_config_tunnel_udp_port_port,
9222 		(void *)&cmd_config_tunnel_udp_port_config,
9223 		(void *)&cmd_config_tunnel_udp_port_port_id,
9224 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9225 		(void *)&cmd_config_tunnel_udp_port_action,
9226 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9227 		(void *)&cmd_config_tunnel_udp_port_value,
9228 		NULL,
9229 	},
9230 };
9231 
9232 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9233 struct cmd_set_mirror_mask_result {
9234 	cmdline_fixed_string_t set;
9235 	cmdline_fixed_string_t port;
9236 	portid_t port_id;
9237 	cmdline_fixed_string_t mirror;
9238 	uint8_t rule_id;
9239 	cmdline_fixed_string_t what;
9240 	cmdline_fixed_string_t value;
9241 	cmdline_fixed_string_t dstpool;
9242 	uint8_t dstpool_id;
9243 	cmdline_fixed_string_t on;
9244 };
9245 
9246 cmdline_parse_token_string_t cmd_mirror_mask_set =
9247 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9248 				set, "set");
9249 cmdline_parse_token_string_t cmd_mirror_mask_port =
9250 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9251 				port, "port");
9252 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9253 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9254 				port_id, RTE_UINT16);
9255 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9256 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9257 				mirror, "mirror-rule");
9258 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9259 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9260 				rule_id, RTE_UINT8);
9261 cmdline_parse_token_string_t cmd_mirror_mask_what =
9262 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9263 				what, "pool-mirror-up#pool-mirror-down"
9264 				      "#vlan-mirror");
9265 cmdline_parse_token_string_t cmd_mirror_mask_value =
9266 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9267 				value, NULL);
9268 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9269 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9270 				dstpool, "dst-pool");
9271 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9272 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9273 				dstpool_id, RTE_UINT8);
9274 cmdline_parse_token_string_t cmd_mirror_mask_on =
9275 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9276 				on, "on#off");
9277 
9278 static void
9279 cmd_set_mirror_mask_parsed(void *parsed_result,
9280 		       __rte_unused struct cmdline *cl,
9281 		       __rte_unused void *data)
9282 {
9283 	int ret,nb_item,i;
9284 	struct cmd_set_mirror_mask_result *res = parsed_result;
9285 	struct rte_eth_mirror_conf mr_conf;
9286 
9287 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9288 
9289 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9290 
9291 	mr_conf.dst_pool = res->dstpool_id;
9292 
9293 	if (!strcmp(res->what, "pool-mirror-up")) {
9294 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9295 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9296 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9297 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9298 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9299 	} else if (!strcmp(res->what, "vlan-mirror")) {
9300 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9301 		nb_item = parse_item_list(res->value, "vlan",
9302 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9303 		if (nb_item <= 0)
9304 			return;
9305 
9306 		for (i = 0; i < nb_item; i++) {
9307 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9308 				printf("Invalid vlan_id: must be < 4096\n");
9309 				return;
9310 			}
9311 
9312 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9313 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9314 		}
9315 	}
9316 
9317 	if (!strcmp(res->on, "on"))
9318 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9319 						res->rule_id, 1);
9320 	else
9321 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9322 						res->rule_id, 0);
9323 	if (ret < 0)
9324 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9325 }
9326 
9327 cmdline_parse_inst_t cmd_set_mirror_mask = {
9328 		.f = cmd_set_mirror_mask_parsed,
9329 		.data = NULL,
9330 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9331 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9332 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9333 		.tokens = {
9334 			(void *)&cmd_mirror_mask_set,
9335 			(void *)&cmd_mirror_mask_port,
9336 			(void *)&cmd_mirror_mask_portid,
9337 			(void *)&cmd_mirror_mask_mirror,
9338 			(void *)&cmd_mirror_mask_ruleid,
9339 			(void *)&cmd_mirror_mask_what,
9340 			(void *)&cmd_mirror_mask_value,
9341 			(void *)&cmd_mirror_mask_dstpool,
9342 			(void *)&cmd_mirror_mask_poolid,
9343 			(void *)&cmd_mirror_mask_on,
9344 			NULL,
9345 		},
9346 };
9347 
9348 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9349 struct cmd_set_mirror_link_result {
9350 	cmdline_fixed_string_t set;
9351 	cmdline_fixed_string_t port;
9352 	portid_t port_id;
9353 	cmdline_fixed_string_t mirror;
9354 	uint8_t rule_id;
9355 	cmdline_fixed_string_t what;
9356 	cmdline_fixed_string_t dstpool;
9357 	uint8_t dstpool_id;
9358 	cmdline_fixed_string_t on;
9359 };
9360 
9361 cmdline_parse_token_string_t cmd_mirror_link_set =
9362 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9363 				 set, "set");
9364 cmdline_parse_token_string_t cmd_mirror_link_port =
9365 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9366 				port, "port");
9367 cmdline_parse_token_num_t cmd_mirror_link_portid =
9368 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9369 				port_id, RTE_UINT16);
9370 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9371 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9372 				mirror, "mirror-rule");
9373 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9374 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9375 			    rule_id, RTE_UINT8);
9376 cmdline_parse_token_string_t cmd_mirror_link_what =
9377 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9378 				what, "uplink-mirror#downlink-mirror");
9379 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9380 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9381 				dstpool, "dst-pool");
9382 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9383 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9384 				dstpool_id, RTE_UINT8);
9385 cmdline_parse_token_string_t cmd_mirror_link_on =
9386 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9387 				on, "on#off");
9388 
9389 static void
9390 cmd_set_mirror_link_parsed(void *parsed_result,
9391 		       __rte_unused struct cmdline *cl,
9392 		       __rte_unused void *data)
9393 {
9394 	int ret;
9395 	struct cmd_set_mirror_link_result *res = parsed_result;
9396 	struct rte_eth_mirror_conf mr_conf;
9397 
9398 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9399 	if (!strcmp(res->what, "uplink-mirror"))
9400 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9401 	else
9402 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9403 
9404 	mr_conf.dst_pool = res->dstpool_id;
9405 
9406 	if (!strcmp(res->on, "on"))
9407 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9408 						res->rule_id, 1);
9409 	else
9410 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9411 						res->rule_id, 0);
9412 
9413 	/* check the return value and print it if is < 0 */
9414 	if (ret < 0)
9415 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9416 
9417 }
9418 
9419 cmdline_parse_inst_t cmd_set_mirror_link = {
9420 		.f = cmd_set_mirror_link_parsed,
9421 		.data = NULL,
9422 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9423 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9424 		.tokens = {
9425 			(void *)&cmd_mirror_link_set,
9426 			(void *)&cmd_mirror_link_port,
9427 			(void *)&cmd_mirror_link_portid,
9428 			(void *)&cmd_mirror_link_mirror,
9429 			(void *)&cmd_mirror_link_ruleid,
9430 			(void *)&cmd_mirror_link_what,
9431 			(void *)&cmd_mirror_link_dstpool,
9432 			(void *)&cmd_mirror_link_poolid,
9433 			(void *)&cmd_mirror_link_on,
9434 			NULL,
9435 		},
9436 };
9437 
9438 /* *** RESET VM MIRROR RULE *** */
9439 struct cmd_rm_mirror_rule_result {
9440 	cmdline_fixed_string_t reset;
9441 	cmdline_fixed_string_t port;
9442 	portid_t port_id;
9443 	cmdline_fixed_string_t mirror;
9444 	uint8_t rule_id;
9445 };
9446 
9447 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9448 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9449 				 reset, "reset");
9450 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9451 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9452 				port, "port");
9453 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9454 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9455 				port_id, RTE_UINT16);
9456 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9457 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9458 				mirror, "mirror-rule");
9459 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9460 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9461 				rule_id, RTE_UINT8);
9462 
9463 static void
9464 cmd_reset_mirror_rule_parsed(void *parsed_result,
9465 		       __rte_unused struct cmdline *cl,
9466 		       __rte_unused void *data)
9467 {
9468 	int ret;
9469 	struct cmd_set_mirror_link_result *res = parsed_result;
9470         /* check rule_id */
9471 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9472 	if(ret < 0)
9473 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9474 }
9475 
9476 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9477 		.f = cmd_reset_mirror_rule_parsed,
9478 		.data = NULL,
9479 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9480 		.tokens = {
9481 			(void *)&cmd_rm_mirror_rule_reset,
9482 			(void *)&cmd_rm_mirror_rule_port,
9483 			(void *)&cmd_rm_mirror_rule_portid,
9484 			(void *)&cmd_rm_mirror_rule_mirror,
9485 			(void *)&cmd_rm_mirror_rule_ruleid,
9486 			NULL,
9487 		},
9488 };
9489 
9490 /* ******************************************************************************** */
9491 
9492 struct cmd_dump_result {
9493 	cmdline_fixed_string_t dump;
9494 };
9495 
9496 static void
9497 dump_struct_sizes(void)
9498 {
9499 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9500 	DUMP_SIZE(struct rte_mbuf);
9501 	DUMP_SIZE(struct rte_mempool);
9502 	DUMP_SIZE(struct rte_ring);
9503 #undef DUMP_SIZE
9504 }
9505 
9506 
9507 /* Dump the socket memory statistics on console */
9508 static void
9509 dump_socket_mem(FILE *f)
9510 {
9511 	struct rte_malloc_socket_stats socket_stats;
9512 	unsigned int i;
9513 	size_t total = 0;
9514 	size_t alloc = 0;
9515 	size_t free = 0;
9516 	unsigned int n_alloc = 0;
9517 	unsigned int n_free = 0;
9518 	static size_t last_allocs;
9519 	static size_t last_total;
9520 
9521 
9522 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9523 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9524 		    !socket_stats.heap_totalsz_bytes)
9525 			continue;
9526 		total += socket_stats.heap_totalsz_bytes;
9527 		alloc += socket_stats.heap_allocsz_bytes;
9528 		free += socket_stats.heap_freesz_bytes;
9529 		n_alloc += socket_stats.alloc_count;
9530 		n_free += socket_stats.free_count;
9531 		fprintf(f,
9532 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9533 			i,
9534 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9535 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9536 			(double)socket_stats.heap_allocsz_bytes * 100 /
9537 			(double)socket_stats.heap_totalsz_bytes,
9538 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9539 			socket_stats.alloc_count,
9540 			socket_stats.free_count);
9541 	}
9542 	fprintf(f,
9543 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9544 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9545 		(double)alloc * 100 / (double)total,
9546 		(double)free / (1024 * 1024),
9547 		n_alloc, n_free);
9548 	if (last_allocs)
9549 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9550 			((double)total - (double)last_total) / (1024 * 1024),
9551 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9552 	last_allocs = alloc;
9553 	last_total = total;
9554 }
9555 
9556 static void cmd_dump_parsed(void *parsed_result,
9557 			    __rte_unused struct cmdline *cl,
9558 			    __rte_unused void *data)
9559 {
9560 	struct cmd_dump_result *res = parsed_result;
9561 
9562 	if (!strcmp(res->dump, "dump_physmem"))
9563 		rte_dump_physmem_layout(stdout);
9564 	else if (!strcmp(res->dump, "dump_socket_mem"))
9565 		dump_socket_mem(stdout);
9566 	else if (!strcmp(res->dump, "dump_memzone"))
9567 		rte_memzone_dump(stdout);
9568 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9569 		dump_struct_sizes();
9570 	else if (!strcmp(res->dump, "dump_ring"))
9571 		rte_ring_list_dump(stdout);
9572 	else if (!strcmp(res->dump, "dump_mempool"))
9573 		rte_mempool_list_dump(stdout);
9574 	else if (!strcmp(res->dump, "dump_devargs"))
9575 		rte_devargs_dump(stdout);
9576 	else if (!strcmp(res->dump, "dump_log_types"))
9577 		rte_log_dump(stdout);
9578 }
9579 
9580 cmdline_parse_token_string_t cmd_dump_dump =
9581 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9582 		"dump_physmem#"
9583 		"dump_memzone#"
9584 		"dump_socket_mem#"
9585 		"dump_struct_sizes#"
9586 		"dump_ring#"
9587 		"dump_mempool#"
9588 		"dump_devargs#"
9589 		"dump_log_types");
9590 
9591 cmdline_parse_inst_t cmd_dump = {
9592 	.f = cmd_dump_parsed,  /* function to call */
9593 	.data = NULL,      /* 2nd arg of func */
9594 	.help_str = "Dump status",
9595 	.tokens = {        /* token list, NULL terminated */
9596 		(void *)&cmd_dump_dump,
9597 		NULL,
9598 	},
9599 };
9600 
9601 /* ******************************************************************************** */
9602 
9603 struct cmd_dump_one_result {
9604 	cmdline_fixed_string_t dump;
9605 	cmdline_fixed_string_t name;
9606 };
9607 
9608 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9609 				__rte_unused void *data)
9610 {
9611 	struct cmd_dump_one_result *res = parsed_result;
9612 
9613 	if (!strcmp(res->dump, "dump_ring")) {
9614 		struct rte_ring *r;
9615 		r = rte_ring_lookup(res->name);
9616 		if (r == NULL) {
9617 			cmdline_printf(cl, "Cannot find ring\n");
9618 			return;
9619 		}
9620 		rte_ring_dump(stdout, r);
9621 	} else if (!strcmp(res->dump, "dump_mempool")) {
9622 		struct rte_mempool *mp;
9623 		mp = rte_mempool_lookup(res->name);
9624 		if (mp == NULL) {
9625 			cmdline_printf(cl, "Cannot find mempool\n");
9626 			return;
9627 		}
9628 		rte_mempool_dump(stdout, mp);
9629 	}
9630 }
9631 
9632 cmdline_parse_token_string_t cmd_dump_one_dump =
9633 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9634 				 "dump_ring#dump_mempool");
9635 
9636 cmdline_parse_token_string_t cmd_dump_one_name =
9637 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9638 
9639 cmdline_parse_inst_t cmd_dump_one = {
9640 	.f = cmd_dump_one_parsed,  /* function to call */
9641 	.data = NULL,      /* 2nd arg of func */
9642 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9643 	.tokens = {        /* token list, NULL terminated */
9644 		(void *)&cmd_dump_one_dump,
9645 		(void *)&cmd_dump_one_name,
9646 		NULL,
9647 	},
9648 };
9649 
9650 /* *** queue region set *** */
9651 struct cmd_queue_region_result {
9652 	cmdline_fixed_string_t set;
9653 	cmdline_fixed_string_t port;
9654 	portid_t port_id;
9655 	cmdline_fixed_string_t cmd;
9656 	cmdline_fixed_string_t region;
9657 	uint8_t  region_id;
9658 	cmdline_fixed_string_t queue_start_index;
9659 	uint8_t  queue_id;
9660 	cmdline_fixed_string_t queue_num;
9661 	uint8_t  queue_num_value;
9662 };
9663 
9664 static void
9665 cmd_queue_region_parsed(void *parsed_result,
9666 			__rte_unused struct cmdline *cl,
9667 			__rte_unused void *data)
9668 {
9669 	struct cmd_queue_region_result *res = parsed_result;
9670 	int ret = -ENOTSUP;
9671 #ifdef RTE_NET_I40E
9672 	struct rte_pmd_i40e_queue_region_conf region_conf;
9673 	enum rte_pmd_i40e_queue_region_op op_type;
9674 #endif
9675 
9676 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9677 		return;
9678 
9679 #ifdef RTE_NET_I40E
9680 	memset(&region_conf, 0, sizeof(region_conf));
9681 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9682 	region_conf.region_id = res->region_id;
9683 	region_conf.queue_num = res->queue_num_value;
9684 	region_conf.queue_start_index = res->queue_id;
9685 
9686 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9687 				op_type, &region_conf);
9688 #endif
9689 
9690 	switch (ret) {
9691 	case 0:
9692 		break;
9693 	case -ENOTSUP:
9694 		printf("function not implemented or supported\n");
9695 		break;
9696 	default:
9697 		printf("queue region config error: (%s)\n", strerror(-ret));
9698 	}
9699 }
9700 
9701 cmdline_parse_token_string_t cmd_queue_region_set =
9702 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9703 		set, "set");
9704 cmdline_parse_token_string_t cmd_queue_region_port =
9705 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9706 cmdline_parse_token_num_t cmd_queue_region_port_id =
9707 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9708 				port_id, RTE_UINT16);
9709 cmdline_parse_token_string_t cmd_queue_region_cmd =
9710 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9711 				 cmd, "queue-region");
9712 cmdline_parse_token_string_t cmd_queue_region_id =
9713 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9714 				region, "region_id");
9715 cmdline_parse_token_num_t cmd_queue_region_index =
9716 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9717 				region_id, RTE_UINT8);
9718 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9719 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9720 				queue_start_index, "queue_start_index");
9721 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9722 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9723 				queue_id, RTE_UINT8);
9724 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9725 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9726 				queue_num, "queue_num");
9727 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9728 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9729 				queue_num_value, RTE_UINT8);
9730 
9731 cmdline_parse_inst_t cmd_queue_region = {
9732 	.f = cmd_queue_region_parsed,
9733 	.data = NULL,
9734 	.help_str = "set port <port_id> queue-region region_id <value> "
9735 		"queue_start_index <value> queue_num <value>: Set a queue region",
9736 	.tokens = {
9737 		(void *)&cmd_queue_region_set,
9738 		(void *)&cmd_queue_region_port,
9739 		(void *)&cmd_queue_region_port_id,
9740 		(void *)&cmd_queue_region_cmd,
9741 		(void *)&cmd_queue_region_id,
9742 		(void *)&cmd_queue_region_index,
9743 		(void *)&cmd_queue_region_queue_start_index,
9744 		(void *)&cmd_queue_region_queue_id,
9745 		(void *)&cmd_queue_region_queue_num,
9746 		(void *)&cmd_queue_region_queue_num_value,
9747 		NULL,
9748 	},
9749 };
9750 
9751 /* *** queue region and flowtype set *** */
9752 struct cmd_region_flowtype_result {
9753 	cmdline_fixed_string_t set;
9754 	cmdline_fixed_string_t port;
9755 	portid_t port_id;
9756 	cmdline_fixed_string_t cmd;
9757 	cmdline_fixed_string_t region;
9758 	uint8_t  region_id;
9759 	cmdline_fixed_string_t flowtype;
9760 	uint8_t  flowtype_id;
9761 };
9762 
9763 static void
9764 cmd_region_flowtype_parsed(void *parsed_result,
9765 			__rte_unused struct cmdline *cl,
9766 			__rte_unused void *data)
9767 {
9768 	struct cmd_region_flowtype_result *res = parsed_result;
9769 	int ret = -ENOTSUP;
9770 #ifdef RTE_NET_I40E
9771 	struct rte_pmd_i40e_queue_region_conf region_conf;
9772 	enum rte_pmd_i40e_queue_region_op op_type;
9773 #endif
9774 
9775 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9776 		return;
9777 
9778 #ifdef RTE_NET_I40E
9779 	memset(&region_conf, 0, sizeof(region_conf));
9780 
9781 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9782 	region_conf.region_id = res->region_id;
9783 	region_conf.hw_flowtype = res->flowtype_id;
9784 
9785 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9786 			op_type, &region_conf);
9787 #endif
9788 
9789 	switch (ret) {
9790 	case 0:
9791 		break;
9792 	case -ENOTSUP:
9793 		printf("function not implemented or supported\n");
9794 		break;
9795 	default:
9796 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9797 	}
9798 }
9799 
9800 cmdline_parse_token_string_t cmd_region_flowtype_set =
9801 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9802 				set, "set");
9803 cmdline_parse_token_string_t cmd_region_flowtype_port =
9804 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9805 				port, "port");
9806 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9807 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9808 				port_id, RTE_UINT16);
9809 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9810 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9811 				cmd, "queue-region");
9812 cmdline_parse_token_string_t cmd_region_flowtype_index =
9813 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9814 				region, "region_id");
9815 cmdline_parse_token_num_t cmd_region_flowtype_id =
9816 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9817 				region_id, RTE_UINT8);
9818 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9819 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9820 				flowtype, "flowtype");
9821 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9822 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9823 				flowtype_id, RTE_UINT8);
9824 cmdline_parse_inst_t cmd_region_flowtype = {
9825 	.f = cmd_region_flowtype_parsed,
9826 	.data = NULL,
9827 	.help_str = "set port <port_id> queue-region region_id <value> "
9828 		"flowtype <value>: Set a flowtype region index",
9829 	.tokens = {
9830 		(void *)&cmd_region_flowtype_set,
9831 		(void *)&cmd_region_flowtype_port,
9832 		(void *)&cmd_region_flowtype_port_index,
9833 		(void *)&cmd_region_flowtype_cmd,
9834 		(void *)&cmd_region_flowtype_index,
9835 		(void *)&cmd_region_flowtype_id,
9836 		(void *)&cmd_region_flowtype_flow_index,
9837 		(void *)&cmd_region_flowtype_flow_id,
9838 		NULL,
9839 	},
9840 };
9841 
9842 /* *** User Priority (UP) to queue region (region_id) set *** */
9843 struct cmd_user_priority_region_result {
9844 	cmdline_fixed_string_t set;
9845 	cmdline_fixed_string_t port;
9846 	portid_t port_id;
9847 	cmdline_fixed_string_t cmd;
9848 	cmdline_fixed_string_t user_priority;
9849 	uint8_t  user_priority_id;
9850 	cmdline_fixed_string_t region;
9851 	uint8_t  region_id;
9852 };
9853 
9854 static void
9855 cmd_user_priority_region_parsed(void *parsed_result,
9856 			__rte_unused struct cmdline *cl,
9857 			__rte_unused void *data)
9858 {
9859 	struct cmd_user_priority_region_result *res = parsed_result;
9860 	int ret = -ENOTSUP;
9861 #ifdef RTE_NET_I40E
9862 	struct rte_pmd_i40e_queue_region_conf region_conf;
9863 	enum rte_pmd_i40e_queue_region_op op_type;
9864 #endif
9865 
9866 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9867 		return;
9868 
9869 #ifdef RTE_NET_I40E
9870 	memset(&region_conf, 0, sizeof(region_conf));
9871 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9872 	region_conf.user_priority = res->user_priority_id;
9873 	region_conf.region_id = res->region_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("user_priority region config error: (%s)\n",
9887 				strerror(-ret));
9888 	}
9889 }
9890 
9891 cmdline_parse_token_string_t cmd_user_priority_region_set =
9892 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9893 				set, "set");
9894 cmdline_parse_token_string_t cmd_user_priority_region_port =
9895 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9896 				port, "port");
9897 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9898 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9899 				port_id, RTE_UINT16);
9900 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9901 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9902 				cmd, "queue-region");
9903 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9904 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9905 				user_priority, "UP");
9906 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9907 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9908 				user_priority_id, RTE_UINT8);
9909 cmdline_parse_token_string_t cmd_user_priority_region_region =
9910 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9911 				region, "region_id");
9912 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9913 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9914 				region_id, RTE_UINT8);
9915 
9916 cmdline_parse_inst_t cmd_user_priority_region = {
9917 	.f = cmd_user_priority_region_parsed,
9918 	.data = NULL,
9919 	.help_str = "set port <port_id> queue-region UP <value> "
9920 		"region_id <value>: Set the mapping of User Priority (UP) "
9921 		"to queue region (region_id) ",
9922 	.tokens = {
9923 		(void *)&cmd_user_priority_region_set,
9924 		(void *)&cmd_user_priority_region_port,
9925 		(void *)&cmd_user_priority_region_port_index,
9926 		(void *)&cmd_user_priority_region_cmd,
9927 		(void *)&cmd_user_priority_region_UP,
9928 		(void *)&cmd_user_priority_region_UP_id,
9929 		(void *)&cmd_user_priority_region_region,
9930 		(void *)&cmd_user_priority_region_region_id,
9931 		NULL,
9932 	},
9933 };
9934 
9935 /* *** flush all queue region related configuration *** */
9936 struct cmd_flush_queue_region_result {
9937 	cmdline_fixed_string_t set;
9938 	cmdline_fixed_string_t port;
9939 	portid_t port_id;
9940 	cmdline_fixed_string_t cmd;
9941 	cmdline_fixed_string_t flush;
9942 	cmdline_fixed_string_t what;
9943 };
9944 
9945 static void
9946 cmd_flush_queue_region_parsed(void *parsed_result,
9947 			__rte_unused struct cmdline *cl,
9948 			__rte_unused void *data)
9949 {
9950 	struct cmd_flush_queue_region_result *res = parsed_result;
9951 	int ret = -ENOTSUP;
9952 #ifdef RTE_NET_I40E
9953 	struct rte_pmd_i40e_queue_region_conf region_conf;
9954 	enum rte_pmd_i40e_queue_region_op op_type;
9955 #endif
9956 
9957 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9958 		return;
9959 
9960 #ifdef RTE_NET_I40E
9961 	memset(&region_conf, 0, sizeof(region_conf));
9962 
9963 	if (strcmp(res->what, "on") == 0)
9964 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9965 	else
9966 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9967 
9968 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9969 				op_type, &region_conf);
9970 #endif
9971 
9972 	switch (ret) {
9973 	case 0:
9974 		break;
9975 	case -ENOTSUP:
9976 		printf("function not implemented or supported\n");
9977 		break;
9978 	default:
9979 		printf("queue region config flush error: (%s)\n",
9980 				strerror(-ret));
9981 	}
9982 }
9983 
9984 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9985 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9986 				set, "set");
9987 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9988 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9989 				port, "port");
9990 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9991 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9992 				port_id, RTE_UINT16);
9993 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9994 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9995 				cmd, "queue-region");
9996 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9997 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9998 				flush, "flush");
9999 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10000 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10001 				what, "on#off");
10002 
10003 cmdline_parse_inst_t cmd_flush_queue_region = {
10004 	.f = cmd_flush_queue_region_parsed,
10005 	.data = NULL,
10006 	.help_str = "set port <port_id> queue-region flush on|off"
10007 		": flush all queue region related configuration",
10008 	.tokens = {
10009 		(void *)&cmd_flush_queue_region_set,
10010 		(void *)&cmd_flush_queue_region_port,
10011 		(void *)&cmd_flush_queue_region_port_index,
10012 		(void *)&cmd_flush_queue_region_cmd,
10013 		(void *)&cmd_flush_queue_region_flush,
10014 		(void *)&cmd_flush_queue_region_what,
10015 		NULL,
10016 	},
10017 };
10018 
10019 /* *** get all queue region related configuration info *** */
10020 struct cmd_show_queue_region_info {
10021 	cmdline_fixed_string_t show;
10022 	cmdline_fixed_string_t port;
10023 	portid_t port_id;
10024 	cmdline_fixed_string_t cmd;
10025 };
10026 
10027 static void
10028 cmd_show_queue_region_info_parsed(void *parsed_result,
10029 			__rte_unused struct cmdline *cl,
10030 			__rte_unused void *data)
10031 {
10032 	struct cmd_show_queue_region_info *res = parsed_result;
10033 	int ret = -ENOTSUP;
10034 #ifdef RTE_NET_I40E
10035 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10036 	enum rte_pmd_i40e_queue_region_op op_type;
10037 #endif
10038 
10039 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10040 		return;
10041 
10042 #ifdef RTE_NET_I40E
10043 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10044 
10045 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10046 
10047 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10048 					op_type, &rte_pmd_regions);
10049 
10050 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10051 #endif
10052 
10053 	switch (ret) {
10054 	case 0:
10055 		break;
10056 	case -ENOTSUP:
10057 		printf("function not implemented or supported\n");
10058 		break;
10059 	default:
10060 		printf("queue region config info show error: (%s)\n",
10061 				strerror(-ret));
10062 	}
10063 }
10064 
10065 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10066 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10067 				show, "show");
10068 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10069 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10070 				port, "port");
10071 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10072 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10073 				port_id, RTE_UINT16);
10074 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10075 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10076 				cmd, "queue-region");
10077 
10078 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10079 	.f = cmd_show_queue_region_info_parsed,
10080 	.data = NULL,
10081 	.help_str = "show port <port_id> queue-region"
10082 		": show all queue region related configuration info",
10083 	.tokens = {
10084 		(void *)&cmd_show_queue_region_info_get,
10085 		(void *)&cmd_show_queue_region_info_port,
10086 		(void *)&cmd_show_queue_region_info_port_index,
10087 		(void *)&cmd_show_queue_region_info_cmd,
10088 		NULL,
10089 	},
10090 };
10091 
10092 /* *** Filters Control *** */
10093 
10094 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10095 do { \
10096 	if ((ip_addr).family == AF_INET) \
10097 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10098 	else { \
10099 		printf("invalid parameter.\n"); \
10100 		return; \
10101 	} \
10102 } while (0)
10103 
10104 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10105 do { \
10106 	if ((ip_addr).family == AF_INET6) \
10107 		rte_memcpy(&(ip), \
10108 				 &((ip_addr).addr.ipv6), \
10109 				 sizeof(struct in6_addr)); \
10110 	else { \
10111 		printf("invalid parameter.\n"); \
10112 		return; \
10113 	} \
10114 } while (0)
10115 
10116 #ifdef RTE_NET_I40E
10117 
10118 static uint16_t
10119 str2flowtype(char *string)
10120 {
10121 	uint8_t i = 0;
10122 	static const struct {
10123 		char str[32];
10124 		uint16_t type;
10125 	} flowtype_str[] = {
10126 		{"raw", RTE_ETH_FLOW_RAW},
10127 		{"ipv4", RTE_ETH_FLOW_IPV4},
10128 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10129 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10130 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10131 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10132 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10133 		{"ipv6", RTE_ETH_FLOW_IPV6},
10134 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10135 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10136 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10137 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10138 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10139 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10140 	};
10141 
10142 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10143 		if (!strcmp(flowtype_str[i].str, string))
10144 			return flowtype_str[i].type;
10145 	}
10146 
10147 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10148 		return (uint16_t)atoi(string);
10149 
10150 	return RTE_ETH_FLOW_UNKNOWN;
10151 }
10152 
10153 /* *** deal with flow director filter *** */
10154 struct cmd_flow_director_result {
10155 	cmdline_fixed_string_t flow_director_filter;
10156 	portid_t port_id;
10157 	cmdline_fixed_string_t mode;
10158 	cmdline_fixed_string_t mode_value;
10159 	cmdline_fixed_string_t ops;
10160 	cmdline_fixed_string_t flow;
10161 	cmdline_fixed_string_t flow_type;
10162 	cmdline_fixed_string_t drop;
10163 	cmdline_fixed_string_t queue;
10164 	uint16_t  queue_id;
10165 	cmdline_fixed_string_t fd_id;
10166 	uint32_t  fd_id_value;
10167 	cmdline_fixed_string_t packet;
10168 	char filepath[];
10169 };
10170 
10171 static void
10172 cmd_flow_director_filter_parsed(void *parsed_result,
10173 			  __rte_unused struct cmdline *cl,
10174 			  __rte_unused void *data)
10175 {
10176 	struct cmd_flow_director_result *res = parsed_result;
10177 	int ret = 0;
10178 	struct rte_pmd_i40e_flow_type_mapping
10179 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10180 	struct rte_pmd_i40e_pkt_template_conf conf;
10181 	uint16_t flow_type = str2flowtype(res->flow_type);
10182 	uint16_t i, port = res->port_id;
10183 	uint8_t add;
10184 
10185 	memset(&conf, 0, sizeof(conf));
10186 
10187 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10188 		printf("Invalid flow type specified.\n");
10189 		return;
10190 	}
10191 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10192 						 mapping);
10193 	if (ret)
10194 		return;
10195 	if (mapping[flow_type].pctype == 0ULL) {
10196 		printf("Invalid flow type specified.\n");
10197 		return;
10198 	}
10199 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10200 		if (mapping[flow_type].pctype & (1ULL << i)) {
10201 			conf.input.pctype = i;
10202 			break;
10203 		}
10204 	}
10205 
10206 	conf.input.packet = open_file(res->filepath,
10207 				&conf.input.length);
10208 	if (!conf.input.packet)
10209 		return;
10210 	if (!strcmp(res->drop, "drop"))
10211 		conf.action.behavior =
10212 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10213 	else
10214 		conf.action.behavior =
10215 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10216 	conf.action.report_status =
10217 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10218 	conf.action.rx_queue = res->queue_id;
10219 	conf.soft_id = res->fd_id_value;
10220 	add  = strcmp(res->ops, "del") ? 1 : 0;
10221 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10222 							&conf,
10223 							add);
10224 	if (ret < 0)
10225 		printf("flow director config error: (%s)\n",
10226 		       strerror(-ret));
10227 	close_file(conf.input.packet);
10228 }
10229 
10230 cmdline_parse_token_string_t cmd_flow_director_filter =
10231 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10232 				 flow_director_filter, "flow_director_filter");
10233 cmdline_parse_token_num_t cmd_flow_director_port_id =
10234 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10235 			      port_id, RTE_UINT16);
10236 cmdline_parse_token_string_t cmd_flow_director_ops =
10237 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10238 				 ops, "add#del#update");
10239 cmdline_parse_token_string_t cmd_flow_director_flow =
10240 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10241 				 flow, "flow");
10242 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10243 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10244 		flow_type, NULL);
10245 cmdline_parse_token_string_t cmd_flow_director_drop =
10246 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10247 				 drop, "drop#fwd");
10248 cmdline_parse_token_string_t cmd_flow_director_queue =
10249 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10250 				 queue, "queue");
10251 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10252 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10253 			      queue_id, RTE_UINT16);
10254 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10255 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10256 				 fd_id, "fd_id");
10257 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10258 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10259 			      fd_id_value, RTE_UINT32);
10260 
10261 cmdline_parse_token_string_t cmd_flow_director_mode =
10262 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10263 				 mode, "mode");
10264 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10265 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10266 				 mode_value, "raw");
10267 cmdline_parse_token_string_t cmd_flow_director_packet =
10268 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10269 				 packet, "packet");
10270 cmdline_parse_token_string_t cmd_flow_director_filepath =
10271 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10272 				 filepath, NULL);
10273 
10274 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10275 	.f = cmd_flow_director_filter_parsed,
10276 	.data = NULL,
10277 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10278 		"director entry on NIC",
10279 	.tokens = {
10280 		(void *)&cmd_flow_director_filter,
10281 		(void *)&cmd_flow_director_port_id,
10282 		(void *)&cmd_flow_director_mode,
10283 		(void *)&cmd_flow_director_mode_raw,
10284 		(void *)&cmd_flow_director_ops,
10285 		(void *)&cmd_flow_director_flow,
10286 		(void *)&cmd_flow_director_flow_type,
10287 		(void *)&cmd_flow_director_drop,
10288 		(void *)&cmd_flow_director_queue,
10289 		(void *)&cmd_flow_director_queue_id,
10290 		(void *)&cmd_flow_director_fd_id,
10291 		(void *)&cmd_flow_director_fd_id_value,
10292 		(void *)&cmd_flow_director_packet,
10293 		(void *)&cmd_flow_director_filepath,
10294 		NULL,
10295 	},
10296 };
10297 
10298 #endif /* RTE_NET_I40E */
10299 
10300 /* *** deal with flow director mask *** */
10301 struct cmd_flow_director_mask_result {
10302 	cmdline_fixed_string_t flow_director_mask;
10303 	portid_t port_id;
10304 	cmdline_fixed_string_t mode;
10305 	cmdline_fixed_string_t mode_value;
10306 	cmdline_fixed_string_t vlan;
10307 	uint16_t vlan_mask;
10308 	cmdline_fixed_string_t src_mask;
10309 	cmdline_ipaddr_t ipv4_src;
10310 	cmdline_ipaddr_t ipv6_src;
10311 	uint16_t port_src;
10312 	cmdline_fixed_string_t dst_mask;
10313 	cmdline_ipaddr_t ipv4_dst;
10314 	cmdline_ipaddr_t ipv6_dst;
10315 	uint16_t port_dst;
10316 	cmdline_fixed_string_t mac;
10317 	uint8_t mac_addr_byte_mask;
10318 	cmdline_fixed_string_t tunnel_id;
10319 	uint32_t tunnel_id_mask;
10320 	cmdline_fixed_string_t tunnel_type;
10321 	uint8_t tunnel_type_mask;
10322 };
10323 
10324 static void
10325 cmd_flow_director_mask_parsed(void *parsed_result,
10326 			  __rte_unused struct cmdline *cl,
10327 			  __rte_unused void *data)
10328 {
10329 	struct cmd_flow_director_mask_result *res = parsed_result;
10330 	struct rte_eth_fdir_masks *mask;
10331 	struct rte_port *port;
10332 
10333 	port = &ports[res->port_id];
10334 	/** Check if the port is not started **/
10335 	if (port->port_status != RTE_PORT_STOPPED) {
10336 		printf("Please stop port %d first\n", res->port_id);
10337 		return;
10338 	}
10339 
10340 	mask = &port->dev_conf.fdir_conf.mask;
10341 
10342 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10343 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10344 			printf("Please set mode to MAC-VLAN.\n");
10345 			return;
10346 		}
10347 
10348 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10349 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10350 		if (strcmp(res->mode_value, "Tunnel")) {
10351 			printf("Please set mode to Tunnel.\n");
10352 			return;
10353 		}
10354 
10355 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10356 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10357 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10358 		mask->tunnel_type_mask = res->tunnel_type_mask;
10359 	} else {
10360 		if (strcmp(res->mode_value, "IP")) {
10361 			printf("Please set mode to IP.\n");
10362 			return;
10363 		}
10364 
10365 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10366 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10367 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10368 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10369 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10370 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10371 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10372 	}
10373 
10374 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10375 }
10376 
10377 cmdline_parse_token_string_t cmd_flow_director_mask =
10378 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10379 				 flow_director_mask, "flow_director_mask");
10380 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10381 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10382 			      port_id, RTE_UINT16);
10383 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10384 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10385 				 vlan, "vlan");
10386 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10387 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10388 			      vlan_mask, RTE_UINT16);
10389 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10390 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10391 				 src_mask, "src_mask");
10392 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10393 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10394 				 ipv4_src);
10395 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10396 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10397 				 ipv6_src);
10398 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10399 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10400 			      port_src, RTE_UINT16);
10401 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10402 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10403 				 dst_mask, "dst_mask");
10404 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10405 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10406 				 ipv4_dst);
10407 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10408 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10409 				 ipv6_dst);
10410 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10411 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10412 			      port_dst, RTE_UINT16);
10413 
10414 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10415 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10416 				 mode, "mode");
10417 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10418 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10419 				 mode_value, "IP");
10420 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10421 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10422 				 mode_value, "MAC-VLAN");
10423 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10424 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10425 				 mode_value, "Tunnel");
10426 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10427 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10428 				 mac, "mac");
10429 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10430 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10431 			      mac_addr_byte_mask, RTE_UINT8);
10432 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10433 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10434 				 tunnel_type, "tunnel-type");
10435 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10436 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10437 			      tunnel_type_mask, RTE_UINT8);
10438 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10439 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10440 				 tunnel_id, "tunnel-id");
10441 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10442 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10443 			      tunnel_id_mask, RTE_UINT32);
10444 
10445 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10446 	.f = cmd_flow_director_mask_parsed,
10447 	.data = NULL,
10448 	.help_str = "flow_director_mask ... : "
10449 		"Set IP mode flow director's mask on NIC",
10450 	.tokens = {
10451 		(void *)&cmd_flow_director_mask,
10452 		(void *)&cmd_flow_director_mask_port_id,
10453 		(void *)&cmd_flow_director_mask_mode,
10454 		(void *)&cmd_flow_director_mask_mode_ip,
10455 		(void *)&cmd_flow_director_mask_vlan,
10456 		(void *)&cmd_flow_director_mask_vlan_value,
10457 		(void *)&cmd_flow_director_mask_src,
10458 		(void *)&cmd_flow_director_mask_ipv4_src,
10459 		(void *)&cmd_flow_director_mask_ipv6_src,
10460 		(void *)&cmd_flow_director_mask_port_src,
10461 		(void *)&cmd_flow_director_mask_dst,
10462 		(void *)&cmd_flow_director_mask_ipv4_dst,
10463 		(void *)&cmd_flow_director_mask_ipv6_dst,
10464 		(void *)&cmd_flow_director_mask_port_dst,
10465 		NULL,
10466 	},
10467 };
10468 
10469 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10470 	.f = cmd_flow_director_mask_parsed,
10471 	.data = NULL,
10472 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10473 		"flow director's mask on NIC",
10474 	.tokens = {
10475 		(void *)&cmd_flow_director_mask,
10476 		(void *)&cmd_flow_director_mask_port_id,
10477 		(void *)&cmd_flow_director_mask_mode,
10478 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10479 		(void *)&cmd_flow_director_mask_vlan,
10480 		(void *)&cmd_flow_director_mask_vlan_value,
10481 		NULL,
10482 	},
10483 };
10484 
10485 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10486 	.f = cmd_flow_director_mask_parsed,
10487 	.data = NULL,
10488 	.help_str = "flow_director_mask ... : Set tunnel mode "
10489 		"flow director's mask on NIC",
10490 	.tokens = {
10491 		(void *)&cmd_flow_director_mask,
10492 		(void *)&cmd_flow_director_mask_port_id,
10493 		(void *)&cmd_flow_director_mask_mode,
10494 		(void *)&cmd_flow_director_mask_mode_tunnel,
10495 		(void *)&cmd_flow_director_mask_vlan,
10496 		(void *)&cmd_flow_director_mask_vlan_value,
10497 		(void *)&cmd_flow_director_mask_mac,
10498 		(void *)&cmd_flow_director_mask_mac_value,
10499 		(void *)&cmd_flow_director_mask_tunnel_type,
10500 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10501 		(void *)&cmd_flow_director_mask_tunnel_id,
10502 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10503 		NULL,
10504 	},
10505 };
10506 
10507 /* *** deal with flow director flexible payload configuration *** */
10508 struct cmd_flow_director_flexpayload_result {
10509 	cmdline_fixed_string_t flow_director_flexpayload;
10510 	portid_t port_id;
10511 	cmdline_fixed_string_t payload_layer;
10512 	cmdline_fixed_string_t payload_cfg;
10513 };
10514 
10515 static inline int
10516 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10517 {
10518 	char s[256];
10519 	const char *p, *p0 = q_arg;
10520 	char *end;
10521 	unsigned long int_fld;
10522 	char *str_fld[max_num];
10523 	int i;
10524 	unsigned size;
10525 	int ret = -1;
10526 
10527 	p = strchr(p0, '(');
10528 	if (p == NULL)
10529 		return -1;
10530 	++p;
10531 	p0 = strchr(p, ')');
10532 	if (p0 == NULL)
10533 		return -1;
10534 
10535 	size = p0 - p;
10536 	if (size >= sizeof(s))
10537 		return -1;
10538 
10539 	snprintf(s, sizeof(s), "%.*s", size, p);
10540 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10541 	if (ret < 0 || ret > max_num)
10542 		return -1;
10543 	for (i = 0; i < ret; i++) {
10544 		errno = 0;
10545 		int_fld = strtoul(str_fld[i], &end, 0);
10546 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10547 			return -1;
10548 		offsets[i] = (uint16_t)int_fld;
10549 	}
10550 	return ret;
10551 }
10552 
10553 static void
10554 cmd_flow_director_flxpld_parsed(void *parsed_result,
10555 			  __rte_unused struct cmdline *cl,
10556 			  __rte_unused void *data)
10557 {
10558 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
10559 	struct rte_eth_flex_payload_cfg flex_cfg;
10560 	struct rte_port *port;
10561 	int ret = 0;
10562 
10563 	port = &ports[res->port_id];
10564 	/** Check if the port is not started **/
10565 	if (port->port_status != RTE_PORT_STOPPED) {
10566 		printf("Please stop port %d first\n", res->port_id);
10567 		return;
10568 	}
10569 
10570 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10571 
10572 	if (!strcmp(res->payload_layer, "raw"))
10573 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10574 	else if (!strcmp(res->payload_layer, "l2"))
10575 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10576 	else if (!strcmp(res->payload_layer, "l3"))
10577 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10578 	else if (!strcmp(res->payload_layer, "l4"))
10579 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10580 
10581 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10582 			    RTE_ETH_FDIR_MAX_FLEXLEN);
10583 	if (ret < 0) {
10584 		printf("error: Cannot parse flex payload input.\n");
10585 		return;
10586 	}
10587 
10588 	fdir_set_flex_payload(res->port_id, &flex_cfg);
10589 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10590 }
10591 
10592 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10593 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10594 				 flow_director_flexpayload,
10595 				 "flow_director_flex_payload");
10596 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10597 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10598 			      port_id, RTE_UINT16);
10599 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10600 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10601 				 payload_layer, "raw#l2#l3#l4");
10602 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10603 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10604 				 payload_cfg, NULL);
10605 
10606 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10607 	.f = cmd_flow_director_flxpld_parsed,
10608 	.data = NULL,
10609 	.help_str = "flow_director_flexpayload ... : "
10610 		"Set flow director's flex payload on NIC",
10611 	.tokens = {
10612 		(void *)&cmd_flow_director_flexpayload,
10613 		(void *)&cmd_flow_director_flexpayload_port_id,
10614 		(void *)&cmd_flow_director_flexpayload_payload_layer,
10615 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
10616 		NULL,
10617 	},
10618 };
10619 
10620 /* Generic flow interface command. */
10621 extern cmdline_parse_inst_t cmd_flow;
10622 
10623 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10624 struct cmd_mcast_addr_result {
10625 	cmdline_fixed_string_t mcast_addr_cmd;
10626 	cmdline_fixed_string_t what;
10627 	uint16_t port_num;
10628 	struct rte_ether_addr mc_addr;
10629 };
10630 
10631 static void cmd_mcast_addr_parsed(void *parsed_result,
10632 		__rte_unused struct cmdline *cl,
10633 		__rte_unused void *data)
10634 {
10635 	struct cmd_mcast_addr_result *res = parsed_result;
10636 
10637 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10638 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10639 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10640 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10641 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10642 		return;
10643 	}
10644 	if (strcmp(res->what, "add") == 0)
10645 		mcast_addr_add(res->port_num, &res->mc_addr);
10646 	else
10647 		mcast_addr_remove(res->port_num, &res->mc_addr);
10648 }
10649 
10650 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10651 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10652 				 mcast_addr_cmd, "mcast_addr");
10653 cmdline_parse_token_string_t cmd_mcast_addr_what =
10654 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10655 				 "add#remove");
10656 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10657 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10658 				 RTE_UINT16);
10659 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10660 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10661 
10662 cmdline_parse_inst_t cmd_mcast_addr = {
10663 	.f = cmd_mcast_addr_parsed,
10664 	.data = (void *)0,
10665 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10666 		"Add/Remove multicast MAC address on port_id",
10667 	.tokens = {
10668 		(void *)&cmd_mcast_addr_cmd,
10669 		(void *)&cmd_mcast_addr_what,
10670 		(void *)&cmd_mcast_addr_portnum,
10671 		(void *)&cmd_mcast_addr_addr,
10672 		NULL,
10673 	},
10674 };
10675 
10676 /* vf vlan anti spoof configuration */
10677 
10678 /* Common result structure for vf vlan anti spoof */
10679 struct cmd_vf_vlan_anti_spoof_result {
10680 	cmdline_fixed_string_t set;
10681 	cmdline_fixed_string_t vf;
10682 	cmdline_fixed_string_t vlan;
10683 	cmdline_fixed_string_t antispoof;
10684 	portid_t port_id;
10685 	uint32_t vf_id;
10686 	cmdline_fixed_string_t on_off;
10687 };
10688 
10689 /* Common CLI fields for vf vlan anti spoof enable disable */
10690 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10691 	TOKEN_STRING_INITIALIZER
10692 		(struct cmd_vf_vlan_anti_spoof_result,
10693 		 set, "set");
10694 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10695 	TOKEN_STRING_INITIALIZER
10696 		(struct cmd_vf_vlan_anti_spoof_result,
10697 		 vf, "vf");
10698 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10699 	TOKEN_STRING_INITIALIZER
10700 		(struct cmd_vf_vlan_anti_spoof_result,
10701 		 vlan, "vlan");
10702 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10703 	TOKEN_STRING_INITIALIZER
10704 		(struct cmd_vf_vlan_anti_spoof_result,
10705 		 antispoof, "antispoof");
10706 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10707 	TOKEN_NUM_INITIALIZER
10708 		(struct cmd_vf_vlan_anti_spoof_result,
10709 		 port_id, RTE_UINT16);
10710 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10711 	TOKEN_NUM_INITIALIZER
10712 		(struct cmd_vf_vlan_anti_spoof_result,
10713 		 vf_id, RTE_UINT32);
10714 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10715 	TOKEN_STRING_INITIALIZER
10716 		(struct cmd_vf_vlan_anti_spoof_result,
10717 		 on_off, "on#off");
10718 
10719 static void
10720 cmd_set_vf_vlan_anti_spoof_parsed(
10721 	void *parsed_result,
10722 	__rte_unused struct cmdline *cl,
10723 	__rte_unused void *data)
10724 {
10725 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10726 	int ret = -ENOTSUP;
10727 
10728 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10729 
10730 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10731 		return;
10732 
10733 #ifdef RTE_NET_IXGBE
10734 	if (ret == -ENOTSUP)
10735 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10736 				res->vf_id, is_on);
10737 #endif
10738 #ifdef RTE_NET_I40E
10739 	if (ret == -ENOTSUP)
10740 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10741 				res->vf_id, is_on);
10742 #endif
10743 #ifdef RTE_NET_BNXT
10744 	if (ret == -ENOTSUP)
10745 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10746 				res->vf_id, is_on);
10747 #endif
10748 
10749 	switch (ret) {
10750 	case 0:
10751 		break;
10752 	case -EINVAL:
10753 		printf("invalid vf_id %d\n", res->vf_id);
10754 		break;
10755 	case -ENODEV:
10756 		printf("invalid port_id %d\n", res->port_id);
10757 		break;
10758 	case -ENOTSUP:
10759 		printf("function not implemented\n");
10760 		break;
10761 	default:
10762 		printf("programming error: (%s)\n", strerror(-ret));
10763 	}
10764 }
10765 
10766 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10767 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
10768 	.data = NULL,
10769 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10770 	.tokens = {
10771 		(void *)&cmd_vf_vlan_anti_spoof_set,
10772 		(void *)&cmd_vf_vlan_anti_spoof_vf,
10773 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
10774 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
10775 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
10776 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
10777 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
10778 		NULL,
10779 	},
10780 };
10781 
10782 /* vf mac anti spoof configuration */
10783 
10784 /* Common result structure for vf mac anti spoof */
10785 struct cmd_vf_mac_anti_spoof_result {
10786 	cmdline_fixed_string_t set;
10787 	cmdline_fixed_string_t vf;
10788 	cmdline_fixed_string_t mac;
10789 	cmdline_fixed_string_t antispoof;
10790 	portid_t port_id;
10791 	uint32_t vf_id;
10792 	cmdline_fixed_string_t on_off;
10793 };
10794 
10795 /* Common CLI fields for vf mac anti spoof enable disable */
10796 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10797 	TOKEN_STRING_INITIALIZER
10798 		(struct cmd_vf_mac_anti_spoof_result,
10799 		 set, "set");
10800 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10801 	TOKEN_STRING_INITIALIZER
10802 		(struct cmd_vf_mac_anti_spoof_result,
10803 		 vf, "vf");
10804 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10805 	TOKEN_STRING_INITIALIZER
10806 		(struct cmd_vf_mac_anti_spoof_result,
10807 		 mac, "mac");
10808 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10809 	TOKEN_STRING_INITIALIZER
10810 		(struct cmd_vf_mac_anti_spoof_result,
10811 		 antispoof, "antispoof");
10812 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10813 	TOKEN_NUM_INITIALIZER
10814 		(struct cmd_vf_mac_anti_spoof_result,
10815 		 port_id, RTE_UINT16);
10816 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10817 	TOKEN_NUM_INITIALIZER
10818 		(struct cmd_vf_mac_anti_spoof_result,
10819 		 vf_id, RTE_UINT32);
10820 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10821 	TOKEN_STRING_INITIALIZER
10822 		(struct cmd_vf_mac_anti_spoof_result,
10823 		 on_off, "on#off");
10824 
10825 static void
10826 cmd_set_vf_mac_anti_spoof_parsed(
10827 	void *parsed_result,
10828 	__rte_unused struct cmdline *cl,
10829 	__rte_unused void *data)
10830 {
10831 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10832 	int ret = -ENOTSUP;
10833 
10834 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10835 
10836 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10837 		return;
10838 
10839 #ifdef RTE_NET_IXGBE
10840 	if (ret == -ENOTSUP)
10841 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10842 			res->vf_id, is_on);
10843 #endif
10844 #ifdef RTE_NET_I40E
10845 	if (ret == -ENOTSUP)
10846 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10847 			res->vf_id, is_on);
10848 #endif
10849 #ifdef RTE_NET_BNXT
10850 	if (ret == -ENOTSUP)
10851 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10852 			res->vf_id, is_on);
10853 #endif
10854 
10855 	switch (ret) {
10856 	case 0:
10857 		break;
10858 	case -EINVAL:
10859 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10860 		break;
10861 	case -ENODEV:
10862 		printf("invalid port_id %d\n", res->port_id);
10863 		break;
10864 	case -ENOTSUP:
10865 		printf("function not implemented\n");
10866 		break;
10867 	default:
10868 		printf("programming error: (%s)\n", strerror(-ret));
10869 	}
10870 }
10871 
10872 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10873 	.f = cmd_set_vf_mac_anti_spoof_parsed,
10874 	.data = NULL,
10875 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10876 	.tokens = {
10877 		(void *)&cmd_vf_mac_anti_spoof_set,
10878 		(void *)&cmd_vf_mac_anti_spoof_vf,
10879 		(void *)&cmd_vf_mac_anti_spoof_mac,
10880 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
10881 		(void *)&cmd_vf_mac_anti_spoof_port_id,
10882 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
10883 		(void *)&cmd_vf_mac_anti_spoof_on_off,
10884 		NULL,
10885 	},
10886 };
10887 
10888 /* vf vlan strip queue configuration */
10889 
10890 /* Common result structure for vf mac anti spoof */
10891 struct cmd_vf_vlan_stripq_result {
10892 	cmdline_fixed_string_t set;
10893 	cmdline_fixed_string_t vf;
10894 	cmdline_fixed_string_t vlan;
10895 	cmdline_fixed_string_t stripq;
10896 	portid_t port_id;
10897 	uint16_t vf_id;
10898 	cmdline_fixed_string_t on_off;
10899 };
10900 
10901 /* Common CLI fields for vf vlan strip enable disable */
10902 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10903 	TOKEN_STRING_INITIALIZER
10904 		(struct cmd_vf_vlan_stripq_result,
10905 		 set, "set");
10906 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10907 	TOKEN_STRING_INITIALIZER
10908 		(struct cmd_vf_vlan_stripq_result,
10909 		 vf, "vf");
10910 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10911 	TOKEN_STRING_INITIALIZER
10912 		(struct cmd_vf_vlan_stripq_result,
10913 		 vlan, "vlan");
10914 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10915 	TOKEN_STRING_INITIALIZER
10916 		(struct cmd_vf_vlan_stripq_result,
10917 		 stripq, "stripq");
10918 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10919 	TOKEN_NUM_INITIALIZER
10920 		(struct cmd_vf_vlan_stripq_result,
10921 		 port_id, RTE_UINT16);
10922 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10923 	TOKEN_NUM_INITIALIZER
10924 		(struct cmd_vf_vlan_stripq_result,
10925 		 vf_id, RTE_UINT16);
10926 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10927 	TOKEN_STRING_INITIALIZER
10928 		(struct cmd_vf_vlan_stripq_result,
10929 		 on_off, "on#off");
10930 
10931 static void
10932 cmd_set_vf_vlan_stripq_parsed(
10933 	void *parsed_result,
10934 	__rte_unused struct cmdline *cl,
10935 	__rte_unused void *data)
10936 {
10937 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
10938 	int ret = -ENOTSUP;
10939 
10940 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10941 
10942 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10943 		return;
10944 
10945 #ifdef RTE_NET_IXGBE
10946 	if (ret == -ENOTSUP)
10947 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10948 			res->vf_id, is_on);
10949 #endif
10950 #ifdef RTE_NET_I40E
10951 	if (ret == -ENOTSUP)
10952 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10953 			res->vf_id, is_on);
10954 #endif
10955 #ifdef RTE_NET_BNXT
10956 	if (ret == -ENOTSUP)
10957 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10958 			res->vf_id, is_on);
10959 #endif
10960 
10961 	switch (ret) {
10962 	case 0:
10963 		break;
10964 	case -EINVAL:
10965 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10966 		break;
10967 	case -ENODEV:
10968 		printf("invalid port_id %d\n", res->port_id);
10969 		break;
10970 	case -ENOTSUP:
10971 		printf("function not implemented\n");
10972 		break;
10973 	default:
10974 		printf("programming error: (%s)\n", strerror(-ret));
10975 	}
10976 }
10977 
10978 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10979 	.f = cmd_set_vf_vlan_stripq_parsed,
10980 	.data = NULL,
10981 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10982 	.tokens = {
10983 		(void *)&cmd_vf_vlan_stripq_set,
10984 		(void *)&cmd_vf_vlan_stripq_vf,
10985 		(void *)&cmd_vf_vlan_stripq_vlan,
10986 		(void *)&cmd_vf_vlan_stripq_stripq,
10987 		(void *)&cmd_vf_vlan_stripq_port_id,
10988 		(void *)&cmd_vf_vlan_stripq_vf_id,
10989 		(void *)&cmd_vf_vlan_stripq_on_off,
10990 		NULL,
10991 	},
10992 };
10993 
10994 /* vf vlan insert configuration */
10995 
10996 /* Common result structure for vf vlan insert */
10997 struct cmd_vf_vlan_insert_result {
10998 	cmdline_fixed_string_t set;
10999 	cmdline_fixed_string_t vf;
11000 	cmdline_fixed_string_t vlan;
11001 	cmdline_fixed_string_t insert;
11002 	portid_t port_id;
11003 	uint16_t vf_id;
11004 	uint16_t vlan_id;
11005 };
11006 
11007 /* Common CLI fields for vf vlan insert enable disable */
11008 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11009 	TOKEN_STRING_INITIALIZER
11010 		(struct cmd_vf_vlan_insert_result,
11011 		 set, "set");
11012 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11013 	TOKEN_STRING_INITIALIZER
11014 		(struct cmd_vf_vlan_insert_result,
11015 		 vf, "vf");
11016 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11017 	TOKEN_STRING_INITIALIZER
11018 		(struct cmd_vf_vlan_insert_result,
11019 		 vlan, "vlan");
11020 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11021 	TOKEN_STRING_INITIALIZER
11022 		(struct cmd_vf_vlan_insert_result,
11023 		 insert, "insert");
11024 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11025 	TOKEN_NUM_INITIALIZER
11026 		(struct cmd_vf_vlan_insert_result,
11027 		 port_id, RTE_UINT16);
11028 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11029 	TOKEN_NUM_INITIALIZER
11030 		(struct cmd_vf_vlan_insert_result,
11031 		 vf_id, RTE_UINT16);
11032 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11033 	TOKEN_NUM_INITIALIZER
11034 		(struct cmd_vf_vlan_insert_result,
11035 		 vlan_id, RTE_UINT16);
11036 
11037 static void
11038 cmd_set_vf_vlan_insert_parsed(
11039 	void *parsed_result,
11040 	__rte_unused struct cmdline *cl,
11041 	__rte_unused void *data)
11042 {
11043 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11044 	int ret = -ENOTSUP;
11045 
11046 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11047 		return;
11048 
11049 #ifdef RTE_NET_IXGBE
11050 	if (ret == -ENOTSUP)
11051 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11052 			res->vlan_id);
11053 #endif
11054 #ifdef RTE_NET_I40E
11055 	if (ret == -ENOTSUP)
11056 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11057 			res->vlan_id);
11058 #endif
11059 #ifdef RTE_NET_BNXT
11060 	if (ret == -ENOTSUP)
11061 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11062 			res->vlan_id);
11063 #endif
11064 
11065 	switch (ret) {
11066 	case 0:
11067 		break;
11068 	case -EINVAL:
11069 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11070 		break;
11071 	case -ENODEV:
11072 		printf("invalid port_id %d\n", res->port_id);
11073 		break;
11074 	case -ENOTSUP:
11075 		printf("function not implemented\n");
11076 		break;
11077 	default:
11078 		printf("programming error: (%s)\n", strerror(-ret));
11079 	}
11080 }
11081 
11082 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11083 	.f = cmd_set_vf_vlan_insert_parsed,
11084 	.data = NULL,
11085 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11086 	.tokens = {
11087 		(void *)&cmd_vf_vlan_insert_set,
11088 		(void *)&cmd_vf_vlan_insert_vf,
11089 		(void *)&cmd_vf_vlan_insert_vlan,
11090 		(void *)&cmd_vf_vlan_insert_insert,
11091 		(void *)&cmd_vf_vlan_insert_port_id,
11092 		(void *)&cmd_vf_vlan_insert_vf_id,
11093 		(void *)&cmd_vf_vlan_insert_vlan_id,
11094 		NULL,
11095 	},
11096 };
11097 
11098 /* tx loopback configuration */
11099 
11100 /* Common result structure for tx loopback */
11101 struct cmd_tx_loopback_result {
11102 	cmdline_fixed_string_t set;
11103 	cmdline_fixed_string_t tx;
11104 	cmdline_fixed_string_t loopback;
11105 	portid_t port_id;
11106 	cmdline_fixed_string_t on_off;
11107 };
11108 
11109 /* Common CLI fields for tx loopback enable disable */
11110 cmdline_parse_token_string_t cmd_tx_loopback_set =
11111 	TOKEN_STRING_INITIALIZER
11112 		(struct cmd_tx_loopback_result,
11113 		 set, "set");
11114 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11115 	TOKEN_STRING_INITIALIZER
11116 		(struct cmd_tx_loopback_result,
11117 		 tx, "tx");
11118 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11119 	TOKEN_STRING_INITIALIZER
11120 		(struct cmd_tx_loopback_result,
11121 		 loopback, "loopback");
11122 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11123 	TOKEN_NUM_INITIALIZER
11124 		(struct cmd_tx_loopback_result,
11125 		 port_id, RTE_UINT16);
11126 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11127 	TOKEN_STRING_INITIALIZER
11128 		(struct cmd_tx_loopback_result,
11129 		 on_off, "on#off");
11130 
11131 static void
11132 cmd_set_tx_loopback_parsed(
11133 	void *parsed_result,
11134 	__rte_unused struct cmdline *cl,
11135 	__rte_unused void *data)
11136 {
11137 	struct cmd_tx_loopback_result *res = parsed_result;
11138 	int ret = -ENOTSUP;
11139 
11140 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11141 
11142 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11143 		return;
11144 
11145 #ifdef RTE_NET_IXGBE
11146 	if (ret == -ENOTSUP)
11147 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11148 #endif
11149 #ifdef RTE_NET_I40E
11150 	if (ret == -ENOTSUP)
11151 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11152 #endif
11153 #ifdef RTE_NET_BNXT
11154 	if (ret == -ENOTSUP)
11155 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11156 #endif
11157 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11158 	if (ret == -ENOTSUP)
11159 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11160 #endif
11161 
11162 	switch (ret) {
11163 	case 0:
11164 		break;
11165 	case -EINVAL:
11166 		printf("invalid is_on %d\n", is_on);
11167 		break;
11168 	case -ENODEV:
11169 		printf("invalid port_id %d\n", res->port_id);
11170 		break;
11171 	case -ENOTSUP:
11172 		printf("function not implemented\n");
11173 		break;
11174 	default:
11175 		printf("programming error: (%s)\n", strerror(-ret));
11176 	}
11177 }
11178 
11179 cmdline_parse_inst_t cmd_set_tx_loopback = {
11180 	.f = cmd_set_tx_loopback_parsed,
11181 	.data = NULL,
11182 	.help_str = "set tx loopback <port_id> on|off",
11183 	.tokens = {
11184 		(void *)&cmd_tx_loopback_set,
11185 		(void *)&cmd_tx_loopback_tx,
11186 		(void *)&cmd_tx_loopback_loopback,
11187 		(void *)&cmd_tx_loopback_port_id,
11188 		(void *)&cmd_tx_loopback_on_off,
11189 		NULL,
11190 	},
11191 };
11192 
11193 /* all queues drop enable configuration */
11194 
11195 /* Common result structure for all queues drop enable */
11196 struct cmd_all_queues_drop_en_result {
11197 	cmdline_fixed_string_t set;
11198 	cmdline_fixed_string_t all;
11199 	cmdline_fixed_string_t queues;
11200 	cmdline_fixed_string_t drop;
11201 	portid_t port_id;
11202 	cmdline_fixed_string_t on_off;
11203 };
11204 
11205 /* Common CLI fields for tx loopback enable disable */
11206 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11207 	TOKEN_STRING_INITIALIZER
11208 		(struct cmd_all_queues_drop_en_result,
11209 		 set, "set");
11210 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11211 	TOKEN_STRING_INITIALIZER
11212 		(struct cmd_all_queues_drop_en_result,
11213 		 all, "all");
11214 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11215 	TOKEN_STRING_INITIALIZER
11216 		(struct cmd_all_queues_drop_en_result,
11217 		 queues, "queues");
11218 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11219 	TOKEN_STRING_INITIALIZER
11220 		(struct cmd_all_queues_drop_en_result,
11221 		 drop, "drop");
11222 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11223 	TOKEN_NUM_INITIALIZER
11224 		(struct cmd_all_queues_drop_en_result,
11225 		 port_id, RTE_UINT16);
11226 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11227 	TOKEN_STRING_INITIALIZER
11228 		(struct cmd_all_queues_drop_en_result,
11229 		 on_off, "on#off");
11230 
11231 static void
11232 cmd_set_all_queues_drop_en_parsed(
11233 	void *parsed_result,
11234 	__rte_unused struct cmdline *cl,
11235 	__rte_unused void *data)
11236 {
11237 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11238 	int ret = -ENOTSUP;
11239 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11240 
11241 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11242 		return;
11243 
11244 #ifdef RTE_NET_IXGBE
11245 	if (ret == -ENOTSUP)
11246 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11247 #endif
11248 #ifdef RTE_NET_BNXT
11249 	if (ret == -ENOTSUP)
11250 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11251 #endif
11252 	switch (ret) {
11253 	case 0:
11254 		break;
11255 	case -EINVAL:
11256 		printf("invalid is_on %d\n", is_on);
11257 		break;
11258 	case -ENODEV:
11259 		printf("invalid port_id %d\n", res->port_id);
11260 		break;
11261 	case -ENOTSUP:
11262 		printf("function not implemented\n");
11263 		break;
11264 	default:
11265 		printf("programming error: (%s)\n", strerror(-ret));
11266 	}
11267 }
11268 
11269 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11270 	.f = cmd_set_all_queues_drop_en_parsed,
11271 	.data = NULL,
11272 	.help_str = "set all queues drop <port_id> on|off",
11273 	.tokens = {
11274 		(void *)&cmd_all_queues_drop_en_set,
11275 		(void *)&cmd_all_queues_drop_en_all,
11276 		(void *)&cmd_all_queues_drop_en_queues,
11277 		(void *)&cmd_all_queues_drop_en_drop,
11278 		(void *)&cmd_all_queues_drop_en_port_id,
11279 		(void *)&cmd_all_queues_drop_en_on_off,
11280 		NULL,
11281 	},
11282 };
11283 
11284 /* vf split drop enable configuration */
11285 
11286 /* Common result structure for vf split drop enable */
11287 struct cmd_vf_split_drop_en_result {
11288 	cmdline_fixed_string_t set;
11289 	cmdline_fixed_string_t vf;
11290 	cmdline_fixed_string_t split;
11291 	cmdline_fixed_string_t drop;
11292 	portid_t port_id;
11293 	uint16_t vf_id;
11294 	cmdline_fixed_string_t on_off;
11295 };
11296 
11297 /* Common CLI fields for vf split drop enable disable */
11298 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11299 	TOKEN_STRING_INITIALIZER
11300 		(struct cmd_vf_split_drop_en_result,
11301 		 set, "set");
11302 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11303 	TOKEN_STRING_INITIALIZER
11304 		(struct cmd_vf_split_drop_en_result,
11305 		 vf, "vf");
11306 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11307 	TOKEN_STRING_INITIALIZER
11308 		(struct cmd_vf_split_drop_en_result,
11309 		 split, "split");
11310 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11311 	TOKEN_STRING_INITIALIZER
11312 		(struct cmd_vf_split_drop_en_result,
11313 		 drop, "drop");
11314 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11315 	TOKEN_NUM_INITIALIZER
11316 		(struct cmd_vf_split_drop_en_result,
11317 		 port_id, RTE_UINT16);
11318 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11319 	TOKEN_NUM_INITIALIZER
11320 		(struct cmd_vf_split_drop_en_result,
11321 		 vf_id, RTE_UINT16);
11322 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11323 	TOKEN_STRING_INITIALIZER
11324 		(struct cmd_vf_split_drop_en_result,
11325 		 on_off, "on#off");
11326 
11327 static void
11328 cmd_set_vf_split_drop_en_parsed(
11329 	void *parsed_result,
11330 	__rte_unused struct cmdline *cl,
11331 	__rte_unused void *data)
11332 {
11333 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11334 	int ret = -ENOTSUP;
11335 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11336 
11337 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11338 		return;
11339 
11340 #ifdef RTE_NET_IXGBE
11341 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11342 			is_on);
11343 #endif
11344 	switch (ret) {
11345 	case 0:
11346 		break;
11347 	case -EINVAL:
11348 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11349 		break;
11350 	case -ENODEV:
11351 		printf("invalid port_id %d\n", res->port_id);
11352 		break;
11353 	case -ENOTSUP:
11354 		printf("not supported on port %d\n", res->port_id);
11355 		break;
11356 	default:
11357 		printf("programming error: (%s)\n", strerror(-ret));
11358 	}
11359 }
11360 
11361 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11362 	.f = cmd_set_vf_split_drop_en_parsed,
11363 	.data = NULL,
11364 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11365 	.tokens = {
11366 		(void *)&cmd_vf_split_drop_en_set,
11367 		(void *)&cmd_vf_split_drop_en_vf,
11368 		(void *)&cmd_vf_split_drop_en_split,
11369 		(void *)&cmd_vf_split_drop_en_drop,
11370 		(void *)&cmd_vf_split_drop_en_port_id,
11371 		(void *)&cmd_vf_split_drop_en_vf_id,
11372 		(void *)&cmd_vf_split_drop_en_on_off,
11373 		NULL,
11374 	},
11375 };
11376 
11377 /* vf mac address configuration */
11378 
11379 /* Common result structure for vf mac address */
11380 struct cmd_set_vf_mac_addr_result {
11381 	cmdline_fixed_string_t set;
11382 	cmdline_fixed_string_t vf;
11383 	cmdline_fixed_string_t mac;
11384 	cmdline_fixed_string_t addr;
11385 	portid_t port_id;
11386 	uint16_t vf_id;
11387 	struct rte_ether_addr mac_addr;
11388 
11389 };
11390 
11391 /* Common CLI fields for vf split drop enable disable */
11392 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11393 	TOKEN_STRING_INITIALIZER
11394 		(struct cmd_set_vf_mac_addr_result,
11395 		 set, "set");
11396 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11397 	TOKEN_STRING_INITIALIZER
11398 		(struct cmd_set_vf_mac_addr_result,
11399 		 vf, "vf");
11400 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11401 	TOKEN_STRING_INITIALIZER
11402 		(struct cmd_set_vf_mac_addr_result,
11403 		 mac, "mac");
11404 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11405 	TOKEN_STRING_INITIALIZER
11406 		(struct cmd_set_vf_mac_addr_result,
11407 		 addr, "addr");
11408 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11409 	TOKEN_NUM_INITIALIZER
11410 		(struct cmd_set_vf_mac_addr_result,
11411 		 port_id, RTE_UINT16);
11412 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11413 	TOKEN_NUM_INITIALIZER
11414 		(struct cmd_set_vf_mac_addr_result,
11415 		 vf_id, RTE_UINT16);
11416 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11417 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11418 		 mac_addr);
11419 
11420 static void
11421 cmd_set_vf_mac_addr_parsed(
11422 	void *parsed_result,
11423 	__rte_unused struct cmdline *cl,
11424 	__rte_unused void *data)
11425 {
11426 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11427 	int ret = -ENOTSUP;
11428 
11429 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11430 		return;
11431 
11432 #ifdef RTE_NET_IXGBE
11433 	if (ret == -ENOTSUP)
11434 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11435 				&res->mac_addr);
11436 #endif
11437 #ifdef RTE_NET_I40E
11438 	if (ret == -ENOTSUP)
11439 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11440 				&res->mac_addr);
11441 #endif
11442 #ifdef RTE_NET_BNXT
11443 	if (ret == -ENOTSUP)
11444 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11445 				&res->mac_addr);
11446 #endif
11447 
11448 	switch (ret) {
11449 	case 0:
11450 		break;
11451 	case -EINVAL:
11452 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11453 		break;
11454 	case -ENODEV:
11455 		printf("invalid port_id %d\n", res->port_id);
11456 		break;
11457 	case -ENOTSUP:
11458 		printf("function not implemented\n");
11459 		break;
11460 	default:
11461 		printf("programming error: (%s)\n", strerror(-ret));
11462 	}
11463 }
11464 
11465 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11466 	.f = cmd_set_vf_mac_addr_parsed,
11467 	.data = NULL,
11468 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11469 	.tokens = {
11470 		(void *)&cmd_set_vf_mac_addr_set,
11471 		(void *)&cmd_set_vf_mac_addr_vf,
11472 		(void *)&cmd_set_vf_mac_addr_mac,
11473 		(void *)&cmd_set_vf_mac_addr_addr,
11474 		(void *)&cmd_set_vf_mac_addr_port_id,
11475 		(void *)&cmd_set_vf_mac_addr_vf_id,
11476 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11477 		NULL,
11478 	},
11479 };
11480 
11481 /* MACsec configuration */
11482 
11483 /* Common result structure for MACsec offload enable */
11484 struct cmd_macsec_offload_on_result {
11485 	cmdline_fixed_string_t set;
11486 	cmdline_fixed_string_t macsec;
11487 	cmdline_fixed_string_t offload;
11488 	portid_t port_id;
11489 	cmdline_fixed_string_t on;
11490 	cmdline_fixed_string_t encrypt;
11491 	cmdline_fixed_string_t en_on_off;
11492 	cmdline_fixed_string_t replay_protect;
11493 	cmdline_fixed_string_t rp_on_off;
11494 };
11495 
11496 /* Common CLI fields for MACsec offload disable */
11497 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11498 	TOKEN_STRING_INITIALIZER
11499 		(struct cmd_macsec_offload_on_result,
11500 		 set, "set");
11501 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11502 	TOKEN_STRING_INITIALIZER
11503 		(struct cmd_macsec_offload_on_result,
11504 		 macsec, "macsec");
11505 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11506 	TOKEN_STRING_INITIALIZER
11507 		(struct cmd_macsec_offload_on_result,
11508 		 offload, "offload");
11509 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11510 	TOKEN_NUM_INITIALIZER
11511 		(struct cmd_macsec_offload_on_result,
11512 		 port_id, RTE_UINT16);
11513 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11514 	TOKEN_STRING_INITIALIZER
11515 		(struct cmd_macsec_offload_on_result,
11516 		 on, "on");
11517 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11518 	TOKEN_STRING_INITIALIZER
11519 		(struct cmd_macsec_offload_on_result,
11520 		 encrypt, "encrypt");
11521 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11522 	TOKEN_STRING_INITIALIZER
11523 		(struct cmd_macsec_offload_on_result,
11524 		 en_on_off, "on#off");
11525 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11526 	TOKEN_STRING_INITIALIZER
11527 		(struct cmd_macsec_offload_on_result,
11528 		 replay_protect, "replay-protect");
11529 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11530 	TOKEN_STRING_INITIALIZER
11531 		(struct cmd_macsec_offload_on_result,
11532 		 rp_on_off, "on#off");
11533 
11534 static void
11535 cmd_set_macsec_offload_on_parsed(
11536 	void *parsed_result,
11537 	__rte_unused struct cmdline *cl,
11538 	__rte_unused void *data)
11539 {
11540 	struct cmd_macsec_offload_on_result *res = parsed_result;
11541 	int ret = -ENOTSUP;
11542 	portid_t port_id = res->port_id;
11543 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11544 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11545 	struct rte_eth_dev_info dev_info;
11546 
11547 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11548 		return;
11549 	if (!port_is_stopped(port_id)) {
11550 		printf("Please stop port %d first\n", port_id);
11551 		return;
11552 	}
11553 
11554 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11555 	if (ret != 0)
11556 		return;
11557 
11558 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11559 #ifdef RTE_NET_IXGBE
11560 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11561 #endif
11562 	}
11563 	RTE_SET_USED(en);
11564 	RTE_SET_USED(rp);
11565 
11566 	switch (ret) {
11567 	case 0:
11568 		ports[port_id].dev_conf.txmode.offloads |=
11569 						DEV_TX_OFFLOAD_MACSEC_INSERT;
11570 		cmd_reconfig_device_queue(port_id, 1, 1);
11571 		break;
11572 	case -ENODEV:
11573 		printf("invalid port_id %d\n", port_id);
11574 		break;
11575 	case -ENOTSUP:
11576 		printf("not supported on port %d\n", port_id);
11577 		break;
11578 	default:
11579 		printf("programming error: (%s)\n", strerror(-ret));
11580 	}
11581 }
11582 
11583 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11584 	.f = cmd_set_macsec_offload_on_parsed,
11585 	.data = NULL,
11586 	.help_str = "set macsec offload <port_id> on "
11587 		"encrypt on|off replay-protect on|off",
11588 	.tokens = {
11589 		(void *)&cmd_macsec_offload_on_set,
11590 		(void *)&cmd_macsec_offload_on_macsec,
11591 		(void *)&cmd_macsec_offload_on_offload,
11592 		(void *)&cmd_macsec_offload_on_port_id,
11593 		(void *)&cmd_macsec_offload_on_on,
11594 		(void *)&cmd_macsec_offload_on_encrypt,
11595 		(void *)&cmd_macsec_offload_on_en_on_off,
11596 		(void *)&cmd_macsec_offload_on_replay_protect,
11597 		(void *)&cmd_macsec_offload_on_rp_on_off,
11598 		NULL,
11599 	},
11600 };
11601 
11602 /* Common result structure for MACsec offload disable */
11603 struct cmd_macsec_offload_off_result {
11604 	cmdline_fixed_string_t set;
11605 	cmdline_fixed_string_t macsec;
11606 	cmdline_fixed_string_t offload;
11607 	portid_t port_id;
11608 	cmdline_fixed_string_t off;
11609 };
11610 
11611 /* Common CLI fields for MACsec offload disable */
11612 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11613 	TOKEN_STRING_INITIALIZER
11614 		(struct cmd_macsec_offload_off_result,
11615 		 set, "set");
11616 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11617 	TOKEN_STRING_INITIALIZER
11618 		(struct cmd_macsec_offload_off_result,
11619 		 macsec, "macsec");
11620 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11621 	TOKEN_STRING_INITIALIZER
11622 		(struct cmd_macsec_offload_off_result,
11623 		 offload, "offload");
11624 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11625 	TOKEN_NUM_INITIALIZER
11626 		(struct cmd_macsec_offload_off_result,
11627 		 port_id, RTE_UINT16);
11628 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11629 	TOKEN_STRING_INITIALIZER
11630 		(struct cmd_macsec_offload_off_result,
11631 		 off, "off");
11632 
11633 static void
11634 cmd_set_macsec_offload_off_parsed(
11635 	void *parsed_result,
11636 	__rte_unused struct cmdline *cl,
11637 	__rte_unused void *data)
11638 {
11639 	struct cmd_macsec_offload_off_result *res = parsed_result;
11640 	int ret = -ENOTSUP;
11641 	struct rte_eth_dev_info dev_info;
11642 	portid_t port_id = res->port_id;
11643 
11644 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11645 		return;
11646 	if (!port_is_stopped(port_id)) {
11647 		printf("Please stop port %d first\n", port_id);
11648 		return;
11649 	}
11650 
11651 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11652 	if (ret != 0)
11653 		return;
11654 
11655 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11656 #ifdef RTE_NET_IXGBE
11657 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
11658 #endif
11659 	}
11660 	switch (ret) {
11661 	case 0:
11662 		ports[port_id].dev_conf.txmode.offloads &=
11663 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
11664 		cmd_reconfig_device_queue(port_id, 1, 1);
11665 		break;
11666 	case -ENODEV:
11667 		printf("invalid port_id %d\n", port_id);
11668 		break;
11669 	case -ENOTSUP:
11670 		printf("not supported on port %d\n", port_id);
11671 		break;
11672 	default:
11673 		printf("programming error: (%s)\n", strerror(-ret));
11674 	}
11675 }
11676 
11677 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11678 	.f = cmd_set_macsec_offload_off_parsed,
11679 	.data = NULL,
11680 	.help_str = "set macsec offload <port_id> off",
11681 	.tokens = {
11682 		(void *)&cmd_macsec_offload_off_set,
11683 		(void *)&cmd_macsec_offload_off_macsec,
11684 		(void *)&cmd_macsec_offload_off_offload,
11685 		(void *)&cmd_macsec_offload_off_port_id,
11686 		(void *)&cmd_macsec_offload_off_off,
11687 		NULL,
11688 	},
11689 };
11690 
11691 /* Common result structure for MACsec secure connection configure */
11692 struct cmd_macsec_sc_result {
11693 	cmdline_fixed_string_t set;
11694 	cmdline_fixed_string_t macsec;
11695 	cmdline_fixed_string_t sc;
11696 	cmdline_fixed_string_t tx_rx;
11697 	portid_t port_id;
11698 	struct rte_ether_addr mac;
11699 	uint16_t pi;
11700 };
11701 
11702 /* Common CLI fields for MACsec secure connection configure */
11703 cmdline_parse_token_string_t cmd_macsec_sc_set =
11704 	TOKEN_STRING_INITIALIZER
11705 		(struct cmd_macsec_sc_result,
11706 		 set, "set");
11707 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11708 	TOKEN_STRING_INITIALIZER
11709 		(struct cmd_macsec_sc_result,
11710 		 macsec, "macsec");
11711 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11712 	TOKEN_STRING_INITIALIZER
11713 		(struct cmd_macsec_sc_result,
11714 		 sc, "sc");
11715 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11716 	TOKEN_STRING_INITIALIZER
11717 		(struct cmd_macsec_sc_result,
11718 		 tx_rx, "tx#rx");
11719 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11720 	TOKEN_NUM_INITIALIZER
11721 		(struct cmd_macsec_sc_result,
11722 		 port_id, RTE_UINT16);
11723 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11724 	TOKEN_ETHERADDR_INITIALIZER
11725 		(struct cmd_macsec_sc_result,
11726 		 mac);
11727 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11728 	TOKEN_NUM_INITIALIZER
11729 		(struct cmd_macsec_sc_result,
11730 		 pi, RTE_UINT16);
11731 
11732 static void
11733 cmd_set_macsec_sc_parsed(
11734 	void *parsed_result,
11735 	__rte_unused struct cmdline *cl,
11736 	__rte_unused void *data)
11737 {
11738 	struct cmd_macsec_sc_result *res = parsed_result;
11739 	int ret = -ENOTSUP;
11740 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11741 
11742 #ifdef RTE_NET_IXGBE
11743 	ret = is_tx ?
11744 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11745 				res->mac.addr_bytes) :
11746 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11747 				res->mac.addr_bytes, res->pi);
11748 #endif
11749 	RTE_SET_USED(is_tx);
11750 
11751 	switch (ret) {
11752 	case 0:
11753 		break;
11754 	case -ENODEV:
11755 		printf("invalid port_id %d\n", res->port_id);
11756 		break;
11757 	case -ENOTSUP:
11758 		printf("not supported on port %d\n", res->port_id);
11759 		break;
11760 	default:
11761 		printf("programming error: (%s)\n", strerror(-ret));
11762 	}
11763 }
11764 
11765 cmdline_parse_inst_t cmd_set_macsec_sc = {
11766 	.f = cmd_set_macsec_sc_parsed,
11767 	.data = NULL,
11768 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11769 	.tokens = {
11770 		(void *)&cmd_macsec_sc_set,
11771 		(void *)&cmd_macsec_sc_macsec,
11772 		(void *)&cmd_macsec_sc_sc,
11773 		(void *)&cmd_macsec_sc_tx_rx,
11774 		(void *)&cmd_macsec_sc_port_id,
11775 		(void *)&cmd_macsec_sc_mac,
11776 		(void *)&cmd_macsec_sc_pi,
11777 		NULL,
11778 	},
11779 };
11780 
11781 /* Common result structure for MACsec secure connection configure */
11782 struct cmd_macsec_sa_result {
11783 	cmdline_fixed_string_t set;
11784 	cmdline_fixed_string_t macsec;
11785 	cmdline_fixed_string_t sa;
11786 	cmdline_fixed_string_t tx_rx;
11787 	portid_t port_id;
11788 	uint8_t idx;
11789 	uint8_t an;
11790 	uint32_t pn;
11791 	cmdline_fixed_string_t key;
11792 };
11793 
11794 /* Common CLI fields for MACsec secure connection configure */
11795 cmdline_parse_token_string_t cmd_macsec_sa_set =
11796 	TOKEN_STRING_INITIALIZER
11797 		(struct cmd_macsec_sa_result,
11798 		 set, "set");
11799 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11800 	TOKEN_STRING_INITIALIZER
11801 		(struct cmd_macsec_sa_result,
11802 		 macsec, "macsec");
11803 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11804 	TOKEN_STRING_INITIALIZER
11805 		(struct cmd_macsec_sa_result,
11806 		 sa, "sa");
11807 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11808 	TOKEN_STRING_INITIALIZER
11809 		(struct cmd_macsec_sa_result,
11810 		 tx_rx, "tx#rx");
11811 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11812 	TOKEN_NUM_INITIALIZER
11813 		(struct cmd_macsec_sa_result,
11814 		 port_id, RTE_UINT16);
11815 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11816 	TOKEN_NUM_INITIALIZER
11817 		(struct cmd_macsec_sa_result,
11818 		 idx, RTE_UINT8);
11819 cmdline_parse_token_num_t cmd_macsec_sa_an =
11820 	TOKEN_NUM_INITIALIZER
11821 		(struct cmd_macsec_sa_result,
11822 		 an, RTE_UINT8);
11823 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11824 	TOKEN_NUM_INITIALIZER
11825 		(struct cmd_macsec_sa_result,
11826 		 pn, RTE_UINT32);
11827 cmdline_parse_token_string_t cmd_macsec_sa_key =
11828 	TOKEN_STRING_INITIALIZER
11829 		(struct cmd_macsec_sa_result,
11830 		 key, NULL);
11831 
11832 static void
11833 cmd_set_macsec_sa_parsed(
11834 	void *parsed_result,
11835 	__rte_unused struct cmdline *cl,
11836 	__rte_unused void *data)
11837 {
11838 	struct cmd_macsec_sa_result *res = parsed_result;
11839 	int ret = -ENOTSUP;
11840 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11841 	uint8_t key[16] = { 0 };
11842 	uint8_t xdgt0;
11843 	uint8_t xdgt1;
11844 	int key_len;
11845 	int i;
11846 
11847 	key_len = strlen(res->key) / 2;
11848 	if (key_len > 16)
11849 		key_len = 16;
11850 
11851 	for (i = 0; i < key_len; i++) {
11852 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11853 		if (xdgt0 == 0xFF)
11854 			return;
11855 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11856 		if (xdgt1 == 0xFF)
11857 			return;
11858 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11859 	}
11860 
11861 #ifdef RTE_NET_IXGBE
11862 	ret = is_tx ?
11863 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11864 			res->idx, res->an, res->pn, key) :
11865 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11866 			res->idx, res->an, res->pn, key);
11867 #endif
11868 	RTE_SET_USED(is_tx);
11869 	RTE_SET_USED(key);
11870 
11871 	switch (ret) {
11872 	case 0:
11873 		break;
11874 	case -EINVAL:
11875 		printf("invalid idx %d or an %d\n", res->idx, res->an);
11876 		break;
11877 	case -ENODEV:
11878 		printf("invalid port_id %d\n", res->port_id);
11879 		break;
11880 	case -ENOTSUP:
11881 		printf("not supported on port %d\n", res->port_id);
11882 		break;
11883 	default:
11884 		printf("programming error: (%s)\n", strerror(-ret));
11885 	}
11886 }
11887 
11888 cmdline_parse_inst_t cmd_set_macsec_sa = {
11889 	.f = cmd_set_macsec_sa_parsed,
11890 	.data = NULL,
11891 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11892 	.tokens = {
11893 		(void *)&cmd_macsec_sa_set,
11894 		(void *)&cmd_macsec_sa_macsec,
11895 		(void *)&cmd_macsec_sa_sa,
11896 		(void *)&cmd_macsec_sa_tx_rx,
11897 		(void *)&cmd_macsec_sa_port_id,
11898 		(void *)&cmd_macsec_sa_idx,
11899 		(void *)&cmd_macsec_sa_an,
11900 		(void *)&cmd_macsec_sa_pn,
11901 		(void *)&cmd_macsec_sa_key,
11902 		NULL,
11903 	},
11904 };
11905 
11906 /* VF unicast promiscuous mode configuration */
11907 
11908 /* Common result structure for VF unicast promiscuous mode */
11909 struct cmd_vf_promisc_result {
11910 	cmdline_fixed_string_t set;
11911 	cmdline_fixed_string_t vf;
11912 	cmdline_fixed_string_t promisc;
11913 	portid_t port_id;
11914 	uint32_t vf_id;
11915 	cmdline_fixed_string_t on_off;
11916 };
11917 
11918 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11919 cmdline_parse_token_string_t cmd_vf_promisc_set =
11920 	TOKEN_STRING_INITIALIZER
11921 		(struct cmd_vf_promisc_result,
11922 		 set, "set");
11923 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11924 	TOKEN_STRING_INITIALIZER
11925 		(struct cmd_vf_promisc_result,
11926 		 vf, "vf");
11927 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11928 	TOKEN_STRING_INITIALIZER
11929 		(struct cmd_vf_promisc_result,
11930 		 promisc, "promisc");
11931 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11932 	TOKEN_NUM_INITIALIZER
11933 		(struct cmd_vf_promisc_result,
11934 		 port_id, RTE_UINT16);
11935 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11936 	TOKEN_NUM_INITIALIZER
11937 		(struct cmd_vf_promisc_result,
11938 		 vf_id, RTE_UINT32);
11939 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11940 	TOKEN_STRING_INITIALIZER
11941 		(struct cmd_vf_promisc_result,
11942 		 on_off, "on#off");
11943 
11944 static void
11945 cmd_set_vf_promisc_parsed(
11946 	void *parsed_result,
11947 	__rte_unused struct cmdline *cl,
11948 	__rte_unused void *data)
11949 {
11950 	struct cmd_vf_promisc_result *res = parsed_result;
11951 	int ret = -ENOTSUP;
11952 
11953 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11954 
11955 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11956 		return;
11957 
11958 #ifdef RTE_NET_I40E
11959 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11960 						  res->vf_id, is_on);
11961 #endif
11962 
11963 	switch (ret) {
11964 	case 0:
11965 		break;
11966 	case -EINVAL:
11967 		printf("invalid vf_id %d\n", res->vf_id);
11968 		break;
11969 	case -ENODEV:
11970 		printf("invalid port_id %d\n", res->port_id);
11971 		break;
11972 	case -ENOTSUP:
11973 		printf("function not implemented\n");
11974 		break;
11975 	default:
11976 		printf("programming error: (%s)\n", strerror(-ret));
11977 	}
11978 }
11979 
11980 cmdline_parse_inst_t cmd_set_vf_promisc = {
11981 	.f = cmd_set_vf_promisc_parsed,
11982 	.data = NULL,
11983 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
11984 		"Set unicast promiscuous mode for a VF from the PF",
11985 	.tokens = {
11986 		(void *)&cmd_vf_promisc_set,
11987 		(void *)&cmd_vf_promisc_vf,
11988 		(void *)&cmd_vf_promisc_promisc,
11989 		(void *)&cmd_vf_promisc_port_id,
11990 		(void *)&cmd_vf_promisc_vf_id,
11991 		(void *)&cmd_vf_promisc_on_off,
11992 		NULL,
11993 	},
11994 };
11995 
11996 /* VF multicast promiscuous mode configuration */
11997 
11998 /* Common result structure for VF multicast promiscuous mode */
11999 struct cmd_vf_allmulti_result {
12000 	cmdline_fixed_string_t set;
12001 	cmdline_fixed_string_t vf;
12002 	cmdline_fixed_string_t allmulti;
12003 	portid_t port_id;
12004 	uint32_t vf_id;
12005 	cmdline_fixed_string_t on_off;
12006 };
12007 
12008 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12009 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12010 	TOKEN_STRING_INITIALIZER
12011 		(struct cmd_vf_allmulti_result,
12012 		 set, "set");
12013 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12014 	TOKEN_STRING_INITIALIZER
12015 		(struct cmd_vf_allmulti_result,
12016 		 vf, "vf");
12017 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12018 	TOKEN_STRING_INITIALIZER
12019 		(struct cmd_vf_allmulti_result,
12020 		 allmulti, "allmulti");
12021 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12022 	TOKEN_NUM_INITIALIZER
12023 		(struct cmd_vf_allmulti_result,
12024 		 port_id, RTE_UINT16);
12025 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12026 	TOKEN_NUM_INITIALIZER
12027 		(struct cmd_vf_allmulti_result,
12028 		 vf_id, RTE_UINT32);
12029 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12030 	TOKEN_STRING_INITIALIZER
12031 		(struct cmd_vf_allmulti_result,
12032 		 on_off, "on#off");
12033 
12034 static void
12035 cmd_set_vf_allmulti_parsed(
12036 	void *parsed_result,
12037 	__rte_unused struct cmdline *cl,
12038 	__rte_unused void *data)
12039 {
12040 	struct cmd_vf_allmulti_result *res = parsed_result;
12041 	int ret = -ENOTSUP;
12042 
12043 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12044 
12045 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12046 		return;
12047 
12048 #ifdef RTE_NET_I40E
12049 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12050 						    res->vf_id, is_on);
12051 #endif
12052 
12053 	switch (ret) {
12054 	case 0:
12055 		break;
12056 	case -EINVAL:
12057 		printf("invalid vf_id %d\n", res->vf_id);
12058 		break;
12059 	case -ENODEV:
12060 		printf("invalid port_id %d\n", res->port_id);
12061 		break;
12062 	case -ENOTSUP:
12063 		printf("function not implemented\n");
12064 		break;
12065 	default:
12066 		printf("programming error: (%s)\n", strerror(-ret));
12067 	}
12068 }
12069 
12070 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12071 	.f = cmd_set_vf_allmulti_parsed,
12072 	.data = NULL,
12073 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12074 		"Set multicast promiscuous mode for a VF from the PF",
12075 	.tokens = {
12076 		(void *)&cmd_vf_allmulti_set,
12077 		(void *)&cmd_vf_allmulti_vf,
12078 		(void *)&cmd_vf_allmulti_allmulti,
12079 		(void *)&cmd_vf_allmulti_port_id,
12080 		(void *)&cmd_vf_allmulti_vf_id,
12081 		(void *)&cmd_vf_allmulti_on_off,
12082 		NULL,
12083 	},
12084 };
12085 
12086 /* vf broadcast mode configuration */
12087 
12088 /* Common result structure for vf broadcast */
12089 struct cmd_set_vf_broadcast_result {
12090 	cmdline_fixed_string_t set;
12091 	cmdline_fixed_string_t vf;
12092 	cmdline_fixed_string_t broadcast;
12093 	portid_t port_id;
12094 	uint16_t vf_id;
12095 	cmdline_fixed_string_t on_off;
12096 };
12097 
12098 /* Common CLI fields for vf broadcast enable disable */
12099 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12100 	TOKEN_STRING_INITIALIZER
12101 		(struct cmd_set_vf_broadcast_result,
12102 		 set, "set");
12103 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12104 	TOKEN_STRING_INITIALIZER
12105 		(struct cmd_set_vf_broadcast_result,
12106 		 vf, "vf");
12107 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12108 	TOKEN_STRING_INITIALIZER
12109 		(struct cmd_set_vf_broadcast_result,
12110 		 broadcast, "broadcast");
12111 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12112 	TOKEN_NUM_INITIALIZER
12113 		(struct cmd_set_vf_broadcast_result,
12114 		 port_id, RTE_UINT16);
12115 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12116 	TOKEN_NUM_INITIALIZER
12117 		(struct cmd_set_vf_broadcast_result,
12118 		 vf_id, RTE_UINT16);
12119 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12120 	TOKEN_STRING_INITIALIZER
12121 		(struct cmd_set_vf_broadcast_result,
12122 		 on_off, "on#off");
12123 
12124 static void
12125 cmd_set_vf_broadcast_parsed(
12126 	void *parsed_result,
12127 	__rte_unused struct cmdline *cl,
12128 	__rte_unused void *data)
12129 {
12130 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12131 	int ret = -ENOTSUP;
12132 
12133 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12134 
12135 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12136 		return;
12137 
12138 #ifdef RTE_NET_I40E
12139 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12140 					    res->vf_id, is_on);
12141 #endif
12142 
12143 	switch (ret) {
12144 	case 0:
12145 		break;
12146 	case -EINVAL:
12147 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12148 		break;
12149 	case -ENODEV:
12150 		printf("invalid port_id %d\n", res->port_id);
12151 		break;
12152 	case -ENOTSUP:
12153 		printf("function not implemented\n");
12154 		break;
12155 	default:
12156 		printf("programming error: (%s)\n", strerror(-ret));
12157 	}
12158 }
12159 
12160 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12161 	.f = cmd_set_vf_broadcast_parsed,
12162 	.data = NULL,
12163 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12164 	.tokens = {
12165 		(void *)&cmd_set_vf_broadcast_set,
12166 		(void *)&cmd_set_vf_broadcast_vf,
12167 		(void *)&cmd_set_vf_broadcast_broadcast,
12168 		(void *)&cmd_set_vf_broadcast_port_id,
12169 		(void *)&cmd_set_vf_broadcast_vf_id,
12170 		(void *)&cmd_set_vf_broadcast_on_off,
12171 		NULL,
12172 	},
12173 };
12174 
12175 /* vf vlan tag configuration */
12176 
12177 /* Common result structure for vf vlan tag */
12178 struct cmd_set_vf_vlan_tag_result {
12179 	cmdline_fixed_string_t set;
12180 	cmdline_fixed_string_t vf;
12181 	cmdline_fixed_string_t vlan;
12182 	cmdline_fixed_string_t tag;
12183 	portid_t port_id;
12184 	uint16_t vf_id;
12185 	cmdline_fixed_string_t on_off;
12186 };
12187 
12188 /* Common CLI fields for vf vlan tag enable disable */
12189 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12190 	TOKEN_STRING_INITIALIZER
12191 		(struct cmd_set_vf_vlan_tag_result,
12192 		 set, "set");
12193 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12194 	TOKEN_STRING_INITIALIZER
12195 		(struct cmd_set_vf_vlan_tag_result,
12196 		 vf, "vf");
12197 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12198 	TOKEN_STRING_INITIALIZER
12199 		(struct cmd_set_vf_vlan_tag_result,
12200 		 vlan, "vlan");
12201 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12202 	TOKEN_STRING_INITIALIZER
12203 		(struct cmd_set_vf_vlan_tag_result,
12204 		 tag, "tag");
12205 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12206 	TOKEN_NUM_INITIALIZER
12207 		(struct cmd_set_vf_vlan_tag_result,
12208 		 port_id, RTE_UINT16);
12209 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12210 	TOKEN_NUM_INITIALIZER
12211 		(struct cmd_set_vf_vlan_tag_result,
12212 		 vf_id, RTE_UINT16);
12213 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12214 	TOKEN_STRING_INITIALIZER
12215 		(struct cmd_set_vf_vlan_tag_result,
12216 		 on_off, "on#off");
12217 
12218 static void
12219 cmd_set_vf_vlan_tag_parsed(
12220 	void *parsed_result,
12221 	__rte_unused struct cmdline *cl,
12222 	__rte_unused void *data)
12223 {
12224 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12225 	int ret = -ENOTSUP;
12226 
12227 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12228 
12229 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12230 		return;
12231 
12232 #ifdef RTE_NET_I40E
12233 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12234 					   res->vf_id, is_on);
12235 #endif
12236 
12237 	switch (ret) {
12238 	case 0:
12239 		break;
12240 	case -EINVAL:
12241 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12242 		break;
12243 	case -ENODEV:
12244 		printf("invalid port_id %d\n", res->port_id);
12245 		break;
12246 	case -ENOTSUP:
12247 		printf("function not implemented\n");
12248 		break;
12249 	default:
12250 		printf("programming error: (%s)\n", strerror(-ret));
12251 	}
12252 }
12253 
12254 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12255 	.f = cmd_set_vf_vlan_tag_parsed,
12256 	.data = NULL,
12257 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12258 	.tokens = {
12259 		(void *)&cmd_set_vf_vlan_tag_set,
12260 		(void *)&cmd_set_vf_vlan_tag_vf,
12261 		(void *)&cmd_set_vf_vlan_tag_vlan,
12262 		(void *)&cmd_set_vf_vlan_tag_tag,
12263 		(void *)&cmd_set_vf_vlan_tag_port_id,
12264 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12265 		(void *)&cmd_set_vf_vlan_tag_on_off,
12266 		NULL,
12267 	},
12268 };
12269 
12270 /* Common definition of VF and TC TX bandwidth configuration */
12271 struct cmd_vf_tc_bw_result {
12272 	cmdline_fixed_string_t set;
12273 	cmdline_fixed_string_t vf;
12274 	cmdline_fixed_string_t tc;
12275 	cmdline_fixed_string_t tx;
12276 	cmdline_fixed_string_t min_bw;
12277 	cmdline_fixed_string_t max_bw;
12278 	cmdline_fixed_string_t strict_link_prio;
12279 	portid_t port_id;
12280 	uint16_t vf_id;
12281 	uint8_t tc_no;
12282 	uint32_t bw;
12283 	cmdline_fixed_string_t bw_list;
12284 	uint8_t tc_map;
12285 };
12286 
12287 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12288 	TOKEN_STRING_INITIALIZER
12289 		(struct cmd_vf_tc_bw_result,
12290 		 set, "set");
12291 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12292 	TOKEN_STRING_INITIALIZER
12293 		(struct cmd_vf_tc_bw_result,
12294 		 vf, "vf");
12295 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12296 	TOKEN_STRING_INITIALIZER
12297 		(struct cmd_vf_tc_bw_result,
12298 		 tc, "tc");
12299 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12300 	TOKEN_STRING_INITIALIZER
12301 		(struct cmd_vf_tc_bw_result,
12302 		 tx, "tx");
12303 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12304 	TOKEN_STRING_INITIALIZER
12305 		(struct cmd_vf_tc_bw_result,
12306 		 strict_link_prio, "strict-link-priority");
12307 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12308 	TOKEN_STRING_INITIALIZER
12309 		(struct cmd_vf_tc_bw_result,
12310 		 min_bw, "min-bandwidth");
12311 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12312 	TOKEN_STRING_INITIALIZER
12313 		(struct cmd_vf_tc_bw_result,
12314 		 max_bw, "max-bandwidth");
12315 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12316 	TOKEN_NUM_INITIALIZER
12317 		(struct cmd_vf_tc_bw_result,
12318 		 port_id, RTE_UINT16);
12319 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12320 	TOKEN_NUM_INITIALIZER
12321 		(struct cmd_vf_tc_bw_result,
12322 		 vf_id, RTE_UINT16);
12323 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12324 	TOKEN_NUM_INITIALIZER
12325 		(struct cmd_vf_tc_bw_result,
12326 		 tc_no, RTE_UINT8);
12327 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12328 	TOKEN_NUM_INITIALIZER
12329 		(struct cmd_vf_tc_bw_result,
12330 		 bw, RTE_UINT32);
12331 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12332 	TOKEN_STRING_INITIALIZER
12333 		(struct cmd_vf_tc_bw_result,
12334 		 bw_list, NULL);
12335 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12336 	TOKEN_NUM_INITIALIZER
12337 		(struct cmd_vf_tc_bw_result,
12338 		 tc_map, RTE_UINT8);
12339 
12340 /* VF max bandwidth setting */
12341 static void
12342 cmd_vf_max_bw_parsed(
12343 	void *parsed_result,
12344 	__rte_unused struct cmdline *cl,
12345 	__rte_unused void *data)
12346 {
12347 	struct cmd_vf_tc_bw_result *res = parsed_result;
12348 	int ret = -ENOTSUP;
12349 
12350 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12351 		return;
12352 
12353 #ifdef RTE_NET_I40E
12354 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12355 					 res->vf_id, res->bw);
12356 #endif
12357 
12358 	switch (ret) {
12359 	case 0:
12360 		break;
12361 	case -EINVAL:
12362 		printf("invalid vf_id %d or bandwidth %d\n",
12363 		       res->vf_id, res->bw);
12364 		break;
12365 	case -ENODEV:
12366 		printf("invalid port_id %d\n", res->port_id);
12367 		break;
12368 	case -ENOTSUP:
12369 		printf("function not implemented\n");
12370 		break;
12371 	default:
12372 		printf("programming error: (%s)\n", strerror(-ret));
12373 	}
12374 }
12375 
12376 cmdline_parse_inst_t cmd_vf_max_bw = {
12377 	.f = cmd_vf_max_bw_parsed,
12378 	.data = NULL,
12379 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12380 	.tokens = {
12381 		(void *)&cmd_vf_tc_bw_set,
12382 		(void *)&cmd_vf_tc_bw_vf,
12383 		(void *)&cmd_vf_tc_bw_tx,
12384 		(void *)&cmd_vf_tc_bw_max_bw,
12385 		(void *)&cmd_vf_tc_bw_port_id,
12386 		(void *)&cmd_vf_tc_bw_vf_id,
12387 		(void *)&cmd_vf_tc_bw_bw,
12388 		NULL,
12389 	},
12390 };
12391 
12392 static int
12393 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12394 			   uint8_t *tc_num,
12395 			   char *str)
12396 {
12397 	uint32_t size;
12398 	const char *p, *p0 = str;
12399 	char s[256];
12400 	char *end;
12401 	char *str_fld[16];
12402 	uint16_t i;
12403 	int ret;
12404 
12405 	p = strchr(p0, '(');
12406 	if (p == NULL) {
12407 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12408 		return -1;
12409 	}
12410 	p++;
12411 	p0 = strchr(p, ')');
12412 	if (p0 == NULL) {
12413 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12414 		return -1;
12415 	}
12416 	size = p0 - p;
12417 	if (size >= sizeof(s)) {
12418 		printf("The string size exceeds the internal buffer size\n");
12419 		return -1;
12420 	}
12421 	snprintf(s, sizeof(s), "%.*s", size, p);
12422 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12423 	if (ret <= 0) {
12424 		printf("Failed to get the bandwidth list. ");
12425 		return -1;
12426 	}
12427 	*tc_num = ret;
12428 	for (i = 0; i < ret; i++)
12429 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12430 
12431 	return 0;
12432 }
12433 
12434 /* TC min bandwidth setting */
12435 static void
12436 cmd_vf_tc_min_bw_parsed(
12437 	void *parsed_result,
12438 	__rte_unused struct cmdline *cl,
12439 	__rte_unused void *data)
12440 {
12441 	struct cmd_vf_tc_bw_result *res = parsed_result;
12442 	uint8_t tc_num;
12443 	uint8_t bw[16];
12444 	int ret = -ENOTSUP;
12445 
12446 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12447 		return;
12448 
12449 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12450 	if (ret)
12451 		return;
12452 
12453 #ifdef RTE_NET_I40E
12454 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12455 					      tc_num, bw);
12456 #endif
12457 
12458 	switch (ret) {
12459 	case 0:
12460 		break;
12461 	case -EINVAL:
12462 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12463 		break;
12464 	case -ENODEV:
12465 		printf("invalid port_id %d\n", res->port_id);
12466 		break;
12467 	case -ENOTSUP:
12468 		printf("function not implemented\n");
12469 		break;
12470 	default:
12471 		printf("programming error: (%s)\n", strerror(-ret));
12472 	}
12473 }
12474 
12475 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12476 	.f = cmd_vf_tc_min_bw_parsed,
12477 	.data = NULL,
12478 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12479 		    " <bw1, bw2, ...>",
12480 	.tokens = {
12481 		(void *)&cmd_vf_tc_bw_set,
12482 		(void *)&cmd_vf_tc_bw_vf,
12483 		(void *)&cmd_vf_tc_bw_tc,
12484 		(void *)&cmd_vf_tc_bw_tx,
12485 		(void *)&cmd_vf_tc_bw_min_bw,
12486 		(void *)&cmd_vf_tc_bw_port_id,
12487 		(void *)&cmd_vf_tc_bw_vf_id,
12488 		(void *)&cmd_vf_tc_bw_bw_list,
12489 		NULL,
12490 	},
12491 };
12492 
12493 static void
12494 cmd_tc_min_bw_parsed(
12495 	void *parsed_result,
12496 	__rte_unused struct cmdline *cl,
12497 	__rte_unused void *data)
12498 {
12499 	struct cmd_vf_tc_bw_result *res = parsed_result;
12500 	struct rte_port *port;
12501 	uint8_t tc_num;
12502 	uint8_t bw[16];
12503 	int ret = -ENOTSUP;
12504 
12505 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12506 		return;
12507 
12508 	port = &ports[res->port_id];
12509 	/** Check if the port is not started **/
12510 	if (port->port_status != RTE_PORT_STOPPED) {
12511 		printf("Please stop port %d first\n", res->port_id);
12512 		return;
12513 	}
12514 
12515 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12516 	if (ret)
12517 		return;
12518 
12519 #ifdef RTE_NET_IXGBE
12520 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12521 #endif
12522 
12523 	switch (ret) {
12524 	case 0:
12525 		break;
12526 	case -EINVAL:
12527 		printf("invalid bandwidth\n");
12528 		break;
12529 	case -ENODEV:
12530 		printf("invalid port_id %d\n", res->port_id);
12531 		break;
12532 	case -ENOTSUP:
12533 		printf("function not implemented\n");
12534 		break;
12535 	default:
12536 		printf("programming error: (%s)\n", strerror(-ret));
12537 	}
12538 }
12539 
12540 cmdline_parse_inst_t cmd_tc_min_bw = {
12541 	.f = cmd_tc_min_bw_parsed,
12542 	.data = NULL,
12543 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12544 	.tokens = {
12545 		(void *)&cmd_vf_tc_bw_set,
12546 		(void *)&cmd_vf_tc_bw_tc,
12547 		(void *)&cmd_vf_tc_bw_tx,
12548 		(void *)&cmd_vf_tc_bw_min_bw,
12549 		(void *)&cmd_vf_tc_bw_port_id,
12550 		(void *)&cmd_vf_tc_bw_bw_list,
12551 		NULL,
12552 	},
12553 };
12554 
12555 /* TC max bandwidth setting */
12556 static void
12557 cmd_vf_tc_max_bw_parsed(
12558 	void *parsed_result,
12559 	__rte_unused struct cmdline *cl,
12560 	__rte_unused void *data)
12561 {
12562 	struct cmd_vf_tc_bw_result *res = parsed_result;
12563 	int ret = -ENOTSUP;
12564 
12565 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12566 		return;
12567 
12568 #ifdef RTE_NET_I40E
12569 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12570 					    res->tc_no, res->bw);
12571 #endif
12572 
12573 	switch (ret) {
12574 	case 0:
12575 		break;
12576 	case -EINVAL:
12577 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12578 		       res->vf_id, res->tc_no, res->bw);
12579 		break;
12580 	case -ENODEV:
12581 		printf("invalid port_id %d\n", res->port_id);
12582 		break;
12583 	case -ENOTSUP:
12584 		printf("function not implemented\n");
12585 		break;
12586 	default:
12587 		printf("programming error: (%s)\n", strerror(-ret));
12588 	}
12589 }
12590 
12591 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12592 	.f = cmd_vf_tc_max_bw_parsed,
12593 	.data = NULL,
12594 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12595 		    " <bandwidth>",
12596 	.tokens = {
12597 		(void *)&cmd_vf_tc_bw_set,
12598 		(void *)&cmd_vf_tc_bw_vf,
12599 		(void *)&cmd_vf_tc_bw_tc,
12600 		(void *)&cmd_vf_tc_bw_tx,
12601 		(void *)&cmd_vf_tc_bw_max_bw,
12602 		(void *)&cmd_vf_tc_bw_port_id,
12603 		(void *)&cmd_vf_tc_bw_vf_id,
12604 		(void *)&cmd_vf_tc_bw_tc_no,
12605 		(void *)&cmd_vf_tc_bw_bw,
12606 		NULL,
12607 	},
12608 };
12609 
12610 /** Set VXLAN encapsulation details */
12611 struct cmd_set_vxlan_result {
12612 	cmdline_fixed_string_t set;
12613 	cmdline_fixed_string_t vxlan;
12614 	cmdline_fixed_string_t pos_token;
12615 	cmdline_fixed_string_t ip_version;
12616 	uint32_t vlan_present:1;
12617 	uint32_t vni;
12618 	uint16_t udp_src;
12619 	uint16_t udp_dst;
12620 	cmdline_ipaddr_t ip_src;
12621 	cmdline_ipaddr_t ip_dst;
12622 	uint16_t tci;
12623 	uint8_t tos;
12624 	uint8_t ttl;
12625 	struct rte_ether_addr eth_src;
12626 	struct rte_ether_addr eth_dst;
12627 };
12628 
12629 cmdline_parse_token_string_t cmd_set_vxlan_set =
12630 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12631 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12632 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12633 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12634 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12635 				 "vxlan-tos-ttl");
12636 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12637 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12638 				 "vxlan-with-vlan");
12639 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12640 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12641 				 "ip-version");
12642 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12643 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12644 				 "ipv4#ipv6");
12645 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12646 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12647 				 "vni");
12648 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12649 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12650 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12651 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12652 				 "udp-src");
12653 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12654 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12655 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12656 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12657 				 "udp-dst");
12658 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12659 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12660 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12661 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12662 				 "ip-tos");
12663 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12664 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12665 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12666 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12667 				 "ip-ttl");
12668 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12669 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12670 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12671 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12672 				 "ip-src");
12673 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12674 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12675 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12676 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12677 				 "ip-dst");
12678 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12679 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12680 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12681 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12682 				 "vlan-tci");
12683 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12684 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12685 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12686 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12687 				 "eth-src");
12688 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12689 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12690 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12691 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12692 				 "eth-dst");
12693 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12694 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12695 
12696 static void cmd_set_vxlan_parsed(void *parsed_result,
12697 	__rte_unused struct cmdline *cl,
12698 	__rte_unused void *data)
12699 {
12700 	struct cmd_set_vxlan_result *res = parsed_result;
12701 	union {
12702 		uint32_t vxlan_id;
12703 		uint8_t vni[4];
12704 	} id = {
12705 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12706 	};
12707 
12708 	vxlan_encap_conf.select_tos_ttl = 0;
12709 	if (strcmp(res->vxlan, "vxlan") == 0)
12710 		vxlan_encap_conf.select_vlan = 0;
12711 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12712 		vxlan_encap_conf.select_vlan = 1;
12713 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12714 		vxlan_encap_conf.select_vlan = 0;
12715 		vxlan_encap_conf.select_tos_ttl = 1;
12716 	}
12717 	if (strcmp(res->ip_version, "ipv4") == 0)
12718 		vxlan_encap_conf.select_ipv4 = 1;
12719 	else if (strcmp(res->ip_version, "ipv6") == 0)
12720 		vxlan_encap_conf.select_ipv4 = 0;
12721 	else
12722 		return;
12723 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12724 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12725 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12726 	vxlan_encap_conf.ip_tos = res->tos;
12727 	vxlan_encap_conf.ip_ttl = res->ttl;
12728 	if (vxlan_encap_conf.select_ipv4) {
12729 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12730 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12731 	} else {
12732 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12733 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12734 	}
12735 	if (vxlan_encap_conf.select_vlan)
12736 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12737 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12738 		   RTE_ETHER_ADDR_LEN);
12739 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12740 		   RTE_ETHER_ADDR_LEN);
12741 }
12742 
12743 cmdline_parse_inst_t cmd_set_vxlan = {
12744 	.f = cmd_set_vxlan_parsed,
12745 	.data = NULL,
12746 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12747 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12748 		" eth-src <eth-src> eth-dst <eth-dst>",
12749 	.tokens = {
12750 		(void *)&cmd_set_vxlan_set,
12751 		(void *)&cmd_set_vxlan_vxlan,
12752 		(void *)&cmd_set_vxlan_ip_version,
12753 		(void *)&cmd_set_vxlan_ip_version_value,
12754 		(void *)&cmd_set_vxlan_vni,
12755 		(void *)&cmd_set_vxlan_vni_value,
12756 		(void *)&cmd_set_vxlan_udp_src,
12757 		(void *)&cmd_set_vxlan_udp_src_value,
12758 		(void *)&cmd_set_vxlan_udp_dst,
12759 		(void *)&cmd_set_vxlan_udp_dst_value,
12760 		(void *)&cmd_set_vxlan_ip_src,
12761 		(void *)&cmd_set_vxlan_ip_src_value,
12762 		(void *)&cmd_set_vxlan_ip_dst,
12763 		(void *)&cmd_set_vxlan_ip_dst_value,
12764 		(void *)&cmd_set_vxlan_eth_src,
12765 		(void *)&cmd_set_vxlan_eth_src_value,
12766 		(void *)&cmd_set_vxlan_eth_dst,
12767 		(void *)&cmd_set_vxlan_eth_dst_value,
12768 		NULL,
12769 	},
12770 };
12771 
12772 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12773 	.f = cmd_set_vxlan_parsed,
12774 	.data = NULL,
12775 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12776 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12777 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12778 		" eth-dst <eth-dst>",
12779 	.tokens = {
12780 		(void *)&cmd_set_vxlan_set,
12781 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
12782 		(void *)&cmd_set_vxlan_ip_version,
12783 		(void *)&cmd_set_vxlan_ip_version_value,
12784 		(void *)&cmd_set_vxlan_vni,
12785 		(void *)&cmd_set_vxlan_vni_value,
12786 		(void *)&cmd_set_vxlan_udp_src,
12787 		(void *)&cmd_set_vxlan_udp_src_value,
12788 		(void *)&cmd_set_vxlan_udp_dst,
12789 		(void *)&cmd_set_vxlan_udp_dst_value,
12790 		(void *)&cmd_set_vxlan_ip_tos,
12791 		(void *)&cmd_set_vxlan_ip_tos_value,
12792 		(void *)&cmd_set_vxlan_ip_ttl,
12793 		(void *)&cmd_set_vxlan_ip_ttl_value,
12794 		(void *)&cmd_set_vxlan_ip_src,
12795 		(void *)&cmd_set_vxlan_ip_src_value,
12796 		(void *)&cmd_set_vxlan_ip_dst,
12797 		(void *)&cmd_set_vxlan_ip_dst_value,
12798 		(void *)&cmd_set_vxlan_eth_src,
12799 		(void *)&cmd_set_vxlan_eth_src_value,
12800 		(void *)&cmd_set_vxlan_eth_dst,
12801 		(void *)&cmd_set_vxlan_eth_dst_value,
12802 		NULL,
12803 	},
12804 };
12805 
12806 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12807 	.f = cmd_set_vxlan_parsed,
12808 	.data = NULL,
12809 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12810 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12811 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12812 		" <eth-dst>",
12813 	.tokens = {
12814 		(void *)&cmd_set_vxlan_set,
12815 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
12816 		(void *)&cmd_set_vxlan_ip_version,
12817 		(void *)&cmd_set_vxlan_ip_version_value,
12818 		(void *)&cmd_set_vxlan_vni,
12819 		(void *)&cmd_set_vxlan_vni_value,
12820 		(void *)&cmd_set_vxlan_udp_src,
12821 		(void *)&cmd_set_vxlan_udp_src_value,
12822 		(void *)&cmd_set_vxlan_udp_dst,
12823 		(void *)&cmd_set_vxlan_udp_dst_value,
12824 		(void *)&cmd_set_vxlan_ip_src,
12825 		(void *)&cmd_set_vxlan_ip_src_value,
12826 		(void *)&cmd_set_vxlan_ip_dst,
12827 		(void *)&cmd_set_vxlan_ip_dst_value,
12828 		(void *)&cmd_set_vxlan_vlan,
12829 		(void *)&cmd_set_vxlan_vlan_value,
12830 		(void *)&cmd_set_vxlan_eth_src,
12831 		(void *)&cmd_set_vxlan_eth_src_value,
12832 		(void *)&cmd_set_vxlan_eth_dst,
12833 		(void *)&cmd_set_vxlan_eth_dst_value,
12834 		NULL,
12835 	},
12836 };
12837 
12838 /** Set NVGRE encapsulation details */
12839 struct cmd_set_nvgre_result {
12840 	cmdline_fixed_string_t set;
12841 	cmdline_fixed_string_t nvgre;
12842 	cmdline_fixed_string_t pos_token;
12843 	cmdline_fixed_string_t ip_version;
12844 	uint32_t tni;
12845 	cmdline_ipaddr_t ip_src;
12846 	cmdline_ipaddr_t ip_dst;
12847 	uint16_t tci;
12848 	struct rte_ether_addr eth_src;
12849 	struct rte_ether_addr eth_dst;
12850 };
12851 
12852 cmdline_parse_token_string_t cmd_set_nvgre_set =
12853 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12854 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12855 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12856 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12857 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12858 				 "nvgre-with-vlan");
12859 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12860 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12861 				 "ip-version");
12862 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12863 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12864 				 "ipv4#ipv6");
12865 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12866 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12867 				 "tni");
12868 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12869 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12870 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12871 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12872 				 "ip-src");
12873 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12874 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12875 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12876 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12877 				 "ip-dst");
12878 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12879 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12880 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12881 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12882 				 "vlan-tci");
12883 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12884 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12885 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12886 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12887 				 "eth-src");
12888 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12889 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12890 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12891 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12892 				 "eth-dst");
12893 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12894 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12895 
12896 static void cmd_set_nvgre_parsed(void *parsed_result,
12897 	__rte_unused struct cmdline *cl,
12898 	__rte_unused void *data)
12899 {
12900 	struct cmd_set_nvgre_result *res = parsed_result;
12901 	union {
12902 		uint32_t nvgre_tni;
12903 		uint8_t tni[4];
12904 	} id = {
12905 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12906 	};
12907 
12908 	if (strcmp(res->nvgre, "nvgre") == 0)
12909 		nvgre_encap_conf.select_vlan = 0;
12910 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12911 		nvgre_encap_conf.select_vlan = 1;
12912 	if (strcmp(res->ip_version, "ipv4") == 0)
12913 		nvgre_encap_conf.select_ipv4 = 1;
12914 	else if (strcmp(res->ip_version, "ipv6") == 0)
12915 		nvgre_encap_conf.select_ipv4 = 0;
12916 	else
12917 		return;
12918 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12919 	if (nvgre_encap_conf.select_ipv4) {
12920 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12921 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12922 	} else {
12923 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12924 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12925 	}
12926 	if (nvgre_encap_conf.select_vlan)
12927 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12928 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12929 		   RTE_ETHER_ADDR_LEN);
12930 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12931 		   RTE_ETHER_ADDR_LEN);
12932 }
12933 
12934 cmdline_parse_inst_t cmd_set_nvgre = {
12935 	.f = cmd_set_nvgre_parsed,
12936 	.data = NULL,
12937 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12938 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12939 		" eth-dst <eth-dst>",
12940 	.tokens = {
12941 		(void *)&cmd_set_nvgre_set,
12942 		(void *)&cmd_set_nvgre_nvgre,
12943 		(void *)&cmd_set_nvgre_ip_version,
12944 		(void *)&cmd_set_nvgre_ip_version_value,
12945 		(void *)&cmd_set_nvgre_tni,
12946 		(void *)&cmd_set_nvgre_tni_value,
12947 		(void *)&cmd_set_nvgre_ip_src,
12948 		(void *)&cmd_set_nvgre_ip_src_value,
12949 		(void *)&cmd_set_nvgre_ip_dst,
12950 		(void *)&cmd_set_nvgre_ip_dst_value,
12951 		(void *)&cmd_set_nvgre_eth_src,
12952 		(void *)&cmd_set_nvgre_eth_src_value,
12953 		(void *)&cmd_set_nvgre_eth_dst,
12954 		(void *)&cmd_set_nvgre_eth_dst_value,
12955 		NULL,
12956 	},
12957 };
12958 
12959 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12960 	.f = cmd_set_nvgre_parsed,
12961 	.data = NULL,
12962 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12963 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12964 		" eth-src <eth-src> eth-dst <eth-dst>",
12965 	.tokens = {
12966 		(void *)&cmd_set_nvgre_set,
12967 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
12968 		(void *)&cmd_set_nvgre_ip_version,
12969 		(void *)&cmd_set_nvgre_ip_version_value,
12970 		(void *)&cmd_set_nvgre_tni,
12971 		(void *)&cmd_set_nvgre_tni_value,
12972 		(void *)&cmd_set_nvgre_ip_src,
12973 		(void *)&cmd_set_nvgre_ip_src_value,
12974 		(void *)&cmd_set_nvgre_ip_dst,
12975 		(void *)&cmd_set_nvgre_ip_dst_value,
12976 		(void *)&cmd_set_nvgre_vlan,
12977 		(void *)&cmd_set_nvgre_vlan_value,
12978 		(void *)&cmd_set_nvgre_eth_src,
12979 		(void *)&cmd_set_nvgre_eth_src_value,
12980 		(void *)&cmd_set_nvgre_eth_dst,
12981 		(void *)&cmd_set_nvgre_eth_dst_value,
12982 		NULL,
12983 	},
12984 };
12985 
12986 /** Set L2 encapsulation details */
12987 struct cmd_set_l2_encap_result {
12988 	cmdline_fixed_string_t set;
12989 	cmdline_fixed_string_t l2_encap;
12990 	cmdline_fixed_string_t pos_token;
12991 	cmdline_fixed_string_t ip_version;
12992 	uint32_t vlan_present:1;
12993 	uint16_t tci;
12994 	struct rte_ether_addr eth_src;
12995 	struct rte_ether_addr eth_dst;
12996 };
12997 
12998 cmdline_parse_token_string_t cmd_set_l2_encap_set =
12999 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13000 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13001 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13002 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13003 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13004 				 "l2_encap-with-vlan");
13005 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13006 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13007 				 "ip-version");
13008 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13009 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13010 				 "ipv4#ipv6");
13011 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13012 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13013 				 "vlan-tci");
13014 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13015 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13016 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13017 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13018 				 "eth-src");
13019 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13020 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13021 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13022 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13023 				 "eth-dst");
13024 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13025 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13026 
13027 static void cmd_set_l2_encap_parsed(void *parsed_result,
13028 	__rte_unused struct cmdline *cl,
13029 	__rte_unused void *data)
13030 {
13031 	struct cmd_set_l2_encap_result *res = parsed_result;
13032 
13033 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13034 		l2_encap_conf.select_vlan = 0;
13035 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13036 		l2_encap_conf.select_vlan = 1;
13037 	if (strcmp(res->ip_version, "ipv4") == 0)
13038 		l2_encap_conf.select_ipv4 = 1;
13039 	else if (strcmp(res->ip_version, "ipv6") == 0)
13040 		l2_encap_conf.select_ipv4 = 0;
13041 	else
13042 		return;
13043 	if (l2_encap_conf.select_vlan)
13044 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13045 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13046 		   RTE_ETHER_ADDR_LEN);
13047 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13048 		   RTE_ETHER_ADDR_LEN);
13049 }
13050 
13051 cmdline_parse_inst_t cmd_set_l2_encap = {
13052 	.f = cmd_set_l2_encap_parsed,
13053 	.data = NULL,
13054 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13055 		" eth-src <eth-src> eth-dst <eth-dst>",
13056 	.tokens = {
13057 		(void *)&cmd_set_l2_encap_set,
13058 		(void *)&cmd_set_l2_encap_l2_encap,
13059 		(void *)&cmd_set_l2_encap_ip_version,
13060 		(void *)&cmd_set_l2_encap_ip_version_value,
13061 		(void *)&cmd_set_l2_encap_eth_src,
13062 		(void *)&cmd_set_l2_encap_eth_src_value,
13063 		(void *)&cmd_set_l2_encap_eth_dst,
13064 		(void *)&cmd_set_l2_encap_eth_dst_value,
13065 		NULL,
13066 	},
13067 };
13068 
13069 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13070 	.f = cmd_set_l2_encap_parsed,
13071 	.data = NULL,
13072 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13073 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13074 	.tokens = {
13075 		(void *)&cmd_set_l2_encap_set,
13076 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13077 		(void *)&cmd_set_l2_encap_ip_version,
13078 		(void *)&cmd_set_l2_encap_ip_version_value,
13079 		(void *)&cmd_set_l2_encap_vlan,
13080 		(void *)&cmd_set_l2_encap_vlan_value,
13081 		(void *)&cmd_set_l2_encap_eth_src,
13082 		(void *)&cmd_set_l2_encap_eth_src_value,
13083 		(void *)&cmd_set_l2_encap_eth_dst,
13084 		(void *)&cmd_set_l2_encap_eth_dst_value,
13085 		NULL,
13086 	},
13087 };
13088 
13089 /** Set L2 decapsulation details */
13090 struct cmd_set_l2_decap_result {
13091 	cmdline_fixed_string_t set;
13092 	cmdline_fixed_string_t l2_decap;
13093 	cmdline_fixed_string_t pos_token;
13094 	uint32_t vlan_present:1;
13095 };
13096 
13097 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13098 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13099 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13100 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13101 				 "l2_decap");
13102 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13103 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13104 				 "l2_decap-with-vlan");
13105 
13106 static void cmd_set_l2_decap_parsed(void *parsed_result,
13107 	__rte_unused struct cmdline *cl,
13108 	__rte_unused void *data)
13109 {
13110 	struct cmd_set_l2_decap_result *res = parsed_result;
13111 
13112 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13113 		l2_decap_conf.select_vlan = 0;
13114 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13115 		l2_decap_conf.select_vlan = 1;
13116 }
13117 
13118 cmdline_parse_inst_t cmd_set_l2_decap = {
13119 	.f = cmd_set_l2_decap_parsed,
13120 	.data = NULL,
13121 	.help_str = "set l2_decap",
13122 	.tokens = {
13123 		(void *)&cmd_set_l2_decap_set,
13124 		(void *)&cmd_set_l2_decap_l2_decap,
13125 		NULL,
13126 	},
13127 };
13128 
13129 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13130 	.f = cmd_set_l2_decap_parsed,
13131 	.data = NULL,
13132 	.help_str = "set l2_decap-with-vlan",
13133 	.tokens = {
13134 		(void *)&cmd_set_l2_decap_set,
13135 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13136 		NULL,
13137 	},
13138 };
13139 
13140 /** Set MPLSoGRE encapsulation details */
13141 struct cmd_set_mplsogre_encap_result {
13142 	cmdline_fixed_string_t set;
13143 	cmdline_fixed_string_t mplsogre;
13144 	cmdline_fixed_string_t pos_token;
13145 	cmdline_fixed_string_t ip_version;
13146 	uint32_t vlan_present:1;
13147 	uint32_t label;
13148 	cmdline_ipaddr_t ip_src;
13149 	cmdline_ipaddr_t ip_dst;
13150 	uint16_t tci;
13151 	struct rte_ether_addr eth_src;
13152 	struct rte_ether_addr eth_dst;
13153 };
13154 
13155 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13156 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13157 				 "set");
13158 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13159 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13160 				 "mplsogre_encap");
13161 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13162 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13163 				 mplsogre, "mplsogre_encap-with-vlan");
13164 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13165 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13166 				 pos_token, "ip-version");
13167 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13168 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13169 				 ip_version, "ipv4#ipv6");
13170 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13171 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13172 				 pos_token, "label");
13173 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13174 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13175 			      RTE_UINT32);
13176 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13177 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13178 				 pos_token, "ip-src");
13179 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13180 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13181 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13182 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13183 				 pos_token, "ip-dst");
13184 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13185 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13186 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13187 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13188 				 pos_token, "vlan-tci");
13189 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13190 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13191 			      RTE_UINT16);
13192 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13193 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13194 				 pos_token, "eth-src");
13195 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13196 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13197 				    eth_src);
13198 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13199 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13200 				 pos_token, "eth-dst");
13201 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13202 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13203 				    eth_dst);
13204 
13205 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13206 	__rte_unused struct cmdline *cl,
13207 	__rte_unused void *data)
13208 {
13209 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13210 	union {
13211 		uint32_t mplsogre_label;
13212 		uint8_t label[4];
13213 	} id = {
13214 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13215 	};
13216 
13217 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13218 		mplsogre_encap_conf.select_vlan = 0;
13219 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13220 		mplsogre_encap_conf.select_vlan = 1;
13221 	if (strcmp(res->ip_version, "ipv4") == 0)
13222 		mplsogre_encap_conf.select_ipv4 = 1;
13223 	else if (strcmp(res->ip_version, "ipv6") == 0)
13224 		mplsogre_encap_conf.select_ipv4 = 0;
13225 	else
13226 		return;
13227 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13228 	if (mplsogre_encap_conf.select_ipv4) {
13229 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13230 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13231 	} else {
13232 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13233 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13234 	}
13235 	if (mplsogre_encap_conf.select_vlan)
13236 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13237 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13238 		   RTE_ETHER_ADDR_LEN);
13239 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13240 		   RTE_ETHER_ADDR_LEN);
13241 }
13242 
13243 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13244 	.f = cmd_set_mplsogre_encap_parsed,
13245 	.data = NULL,
13246 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13247 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13248 		" eth-dst <eth-dst>",
13249 	.tokens = {
13250 		(void *)&cmd_set_mplsogre_encap_set,
13251 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13252 		(void *)&cmd_set_mplsogre_encap_ip_version,
13253 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13254 		(void *)&cmd_set_mplsogre_encap_label,
13255 		(void *)&cmd_set_mplsogre_encap_label_value,
13256 		(void *)&cmd_set_mplsogre_encap_ip_src,
13257 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13258 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13259 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13260 		(void *)&cmd_set_mplsogre_encap_eth_src,
13261 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13262 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13263 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13264 		NULL,
13265 	},
13266 };
13267 
13268 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13269 	.f = cmd_set_mplsogre_encap_parsed,
13270 	.data = NULL,
13271 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13272 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13273 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13274 	.tokens = {
13275 		(void *)&cmd_set_mplsogre_encap_set,
13276 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13277 		(void *)&cmd_set_mplsogre_encap_ip_version,
13278 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13279 		(void *)&cmd_set_mplsogre_encap_label,
13280 		(void *)&cmd_set_mplsogre_encap_label_value,
13281 		(void *)&cmd_set_mplsogre_encap_ip_src,
13282 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13283 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13284 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13285 		(void *)&cmd_set_mplsogre_encap_vlan,
13286 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13287 		(void *)&cmd_set_mplsogre_encap_eth_src,
13288 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13289 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13290 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13291 		NULL,
13292 	},
13293 };
13294 
13295 /** Set MPLSoGRE decapsulation details */
13296 struct cmd_set_mplsogre_decap_result {
13297 	cmdline_fixed_string_t set;
13298 	cmdline_fixed_string_t mplsogre;
13299 	cmdline_fixed_string_t pos_token;
13300 	cmdline_fixed_string_t ip_version;
13301 	uint32_t vlan_present:1;
13302 };
13303 
13304 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13305 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13306 				 "set");
13307 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13308 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13309 				 "mplsogre_decap");
13310 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13311 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13312 				 mplsogre, "mplsogre_decap-with-vlan");
13313 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13314 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13315 				 pos_token, "ip-version");
13316 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13317 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13318 				 ip_version, "ipv4#ipv6");
13319 
13320 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13321 	__rte_unused struct cmdline *cl,
13322 	__rte_unused void *data)
13323 {
13324 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13325 
13326 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13327 		mplsogre_decap_conf.select_vlan = 0;
13328 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13329 		mplsogre_decap_conf.select_vlan = 1;
13330 	if (strcmp(res->ip_version, "ipv4") == 0)
13331 		mplsogre_decap_conf.select_ipv4 = 1;
13332 	else if (strcmp(res->ip_version, "ipv6") == 0)
13333 		mplsogre_decap_conf.select_ipv4 = 0;
13334 }
13335 
13336 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13337 	.f = cmd_set_mplsogre_decap_parsed,
13338 	.data = NULL,
13339 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13340 	.tokens = {
13341 		(void *)&cmd_set_mplsogre_decap_set,
13342 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13343 		(void *)&cmd_set_mplsogre_decap_ip_version,
13344 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13345 		NULL,
13346 	},
13347 };
13348 
13349 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13350 	.f = cmd_set_mplsogre_decap_parsed,
13351 	.data = NULL,
13352 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13353 	.tokens = {
13354 		(void *)&cmd_set_mplsogre_decap_set,
13355 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13356 		(void *)&cmd_set_mplsogre_decap_ip_version,
13357 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13358 		NULL,
13359 	},
13360 };
13361 
13362 /** Set MPLSoUDP encapsulation details */
13363 struct cmd_set_mplsoudp_encap_result {
13364 	cmdline_fixed_string_t set;
13365 	cmdline_fixed_string_t mplsoudp;
13366 	cmdline_fixed_string_t pos_token;
13367 	cmdline_fixed_string_t ip_version;
13368 	uint32_t vlan_present:1;
13369 	uint32_t label;
13370 	uint16_t udp_src;
13371 	uint16_t udp_dst;
13372 	cmdline_ipaddr_t ip_src;
13373 	cmdline_ipaddr_t ip_dst;
13374 	uint16_t tci;
13375 	struct rte_ether_addr eth_src;
13376 	struct rte_ether_addr eth_dst;
13377 };
13378 
13379 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13380 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13381 				 "set");
13382 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13383 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13384 				 "mplsoudp_encap");
13385 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13386 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13387 				 mplsoudp, "mplsoudp_encap-with-vlan");
13388 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13389 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13390 				 pos_token, "ip-version");
13391 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13392 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13393 				 ip_version, "ipv4#ipv6");
13394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13395 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13396 				 pos_token, "label");
13397 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13398 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13399 			      RTE_UINT32);
13400 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13401 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13402 				 pos_token, "udp-src");
13403 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13404 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13405 			      RTE_UINT16);
13406 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13407 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13408 				 pos_token, "udp-dst");
13409 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13410 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13411 			      RTE_UINT16);
13412 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13413 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13414 				 pos_token, "ip-src");
13415 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13416 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13417 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13418 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13419 				 pos_token, "ip-dst");
13420 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13421 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13422 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13423 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13424 				 pos_token, "vlan-tci");
13425 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13426 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13427 			      RTE_UINT16);
13428 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13429 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13430 				 pos_token, "eth-src");
13431 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13432 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13433 				    eth_src);
13434 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13435 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13436 				 pos_token, "eth-dst");
13437 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13438 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13439 				    eth_dst);
13440 
13441 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13442 	__rte_unused struct cmdline *cl,
13443 	__rte_unused void *data)
13444 {
13445 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13446 	union {
13447 		uint32_t mplsoudp_label;
13448 		uint8_t label[4];
13449 	} id = {
13450 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13451 	};
13452 
13453 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13454 		mplsoudp_encap_conf.select_vlan = 0;
13455 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13456 		mplsoudp_encap_conf.select_vlan = 1;
13457 	if (strcmp(res->ip_version, "ipv4") == 0)
13458 		mplsoudp_encap_conf.select_ipv4 = 1;
13459 	else if (strcmp(res->ip_version, "ipv6") == 0)
13460 		mplsoudp_encap_conf.select_ipv4 = 0;
13461 	else
13462 		return;
13463 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13464 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13465 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13466 	if (mplsoudp_encap_conf.select_ipv4) {
13467 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13468 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13469 	} else {
13470 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13471 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13472 	}
13473 	if (mplsoudp_encap_conf.select_vlan)
13474 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13475 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13476 		   RTE_ETHER_ADDR_LEN);
13477 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13478 		   RTE_ETHER_ADDR_LEN);
13479 }
13480 
13481 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13482 	.f = cmd_set_mplsoudp_encap_parsed,
13483 	.data = NULL,
13484 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13485 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13486 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13487 	.tokens = {
13488 		(void *)&cmd_set_mplsoudp_encap_set,
13489 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13490 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13491 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13492 		(void *)&cmd_set_mplsoudp_encap_label,
13493 		(void *)&cmd_set_mplsoudp_encap_label_value,
13494 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13495 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13496 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13497 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13498 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13499 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13500 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13501 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13502 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13503 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13504 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13505 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13506 		NULL,
13507 	},
13508 };
13509 
13510 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13511 	.f = cmd_set_mplsoudp_encap_parsed,
13512 	.data = NULL,
13513 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13514 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13515 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13516 		" eth-src <eth-src> eth-dst <eth-dst>",
13517 	.tokens = {
13518 		(void *)&cmd_set_mplsoudp_encap_set,
13519 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13520 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13521 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13522 		(void *)&cmd_set_mplsoudp_encap_label,
13523 		(void *)&cmd_set_mplsoudp_encap_label_value,
13524 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13525 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13526 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13527 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13528 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13529 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13530 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13531 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13532 		(void *)&cmd_set_mplsoudp_encap_vlan,
13533 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13534 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13535 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13536 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13537 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13538 		NULL,
13539 	},
13540 };
13541 
13542 /** Set MPLSoUDP decapsulation details */
13543 struct cmd_set_mplsoudp_decap_result {
13544 	cmdline_fixed_string_t set;
13545 	cmdline_fixed_string_t mplsoudp;
13546 	cmdline_fixed_string_t pos_token;
13547 	cmdline_fixed_string_t ip_version;
13548 	uint32_t vlan_present:1;
13549 };
13550 
13551 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13552 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13553 				 "set");
13554 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13555 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13556 				 "mplsoudp_decap");
13557 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13558 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13559 				 mplsoudp, "mplsoudp_decap-with-vlan");
13560 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13561 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13562 				 pos_token, "ip-version");
13563 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13564 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13565 				 ip_version, "ipv4#ipv6");
13566 
13567 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13568 	__rte_unused struct cmdline *cl,
13569 	__rte_unused void *data)
13570 {
13571 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13572 
13573 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13574 		mplsoudp_decap_conf.select_vlan = 0;
13575 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13576 		mplsoudp_decap_conf.select_vlan = 1;
13577 	if (strcmp(res->ip_version, "ipv4") == 0)
13578 		mplsoudp_decap_conf.select_ipv4 = 1;
13579 	else if (strcmp(res->ip_version, "ipv6") == 0)
13580 		mplsoudp_decap_conf.select_ipv4 = 0;
13581 }
13582 
13583 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13584 	.f = cmd_set_mplsoudp_decap_parsed,
13585 	.data = NULL,
13586 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13587 	.tokens = {
13588 		(void *)&cmd_set_mplsoudp_decap_set,
13589 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13590 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13591 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13592 		NULL,
13593 	},
13594 };
13595 
13596 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13597 	.f = cmd_set_mplsoudp_decap_parsed,
13598 	.data = NULL,
13599 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13600 	.tokens = {
13601 		(void *)&cmd_set_mplsoudp_decap_set,
13602 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13603 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13604 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13605 		NULL,
13606 	},
13607 };
13608 
13609 /* Strict link priority scheduling mode setting */
13610 static void
13611 cmd_strict_link_prio_parsed(
13612 	void *parsed_result,
13613 	__rte_unused struct cmdline *cl,
13614 	__rte_unused void *data)
13615 {
13616 	struct cmd_vf_tc_bw_result *res = parsed_result;
13617 	int ret = -ENOTSUP;
13618 
13619 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13620 		return;
13621 
13622 #ifdef RTE_NET_I40E
13623 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13624 #endif
13625 
13626 	switch (ret) {
13627 	case 0:
13628 		break;
13629 	case -EINVAL:
13630 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13631 		break;
13632 	case -ENODEV:
13633 		printf("invalid port_id %d\n", res->port_id);
13634 		break;
13635 	case -ENOTSUP:
13636 		printf("function not implemented\n");
13637 		break;
13638 	default:
13639 		printf("programming error: (%s)\n", strerror(-ret));
13640 	}
13641 }
13642 
13643 cmdline_parse_inst_t cmd_strict_link_prio = {
13644 	.f = cmd_strict_link_prio_parsed,
13645 	.data = NULL,
13646 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13647 	.tokens = {
13648 		(void *)&cmd_vf_tc_bw_set,
13649 		(void *)&cmd_vf_tc_bw_tx,
13650 		(void *)&cmd_vf_tc_bw_strict_link_prio,
13651 		(void *)&cmd_vf_tc_bw_port_id,
13652 		(void *)&cmd_vf_tc_bw_tc_map,
13653 		NULL,
13654 	},
13655 };
13656 
13657 /* Load dynamic device personalization*/
13658 struct cmd_ddp_add_result {
13659 	cmdline_fixed_string_t ddp;
13660 	cmdline_fixed_string_t add;
13661 	portid_t port_id;
13662 	char filepath[];
13663 };
13664 
13665 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13666 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13667 cmdline_parse_token_string_t cmd_ddp_add_add =
13668 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13669 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13670 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
13671 		RTE_UINT16);
13672 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13673 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13674 
13675 static void
13676 cmd_ddp_add_parsed(
13677 	void *parsed_result,
13678 	__rte_unused struct cmdline *cl,
13679 	__rte_unused void *data)
13680 {
13681 	struct cmd_ddp_add_result *res = parsed_result;
13682 	uint8_t *buff;
13683 	uint32_t size;
13684 	char *filepath;
13685 	char *file_fld[2];
13686 	int file_num;
13687 	int ret = -ENOTSUP;
13688 
13689 	if (!all_ports_stopped()) {
13690 		printf("Please stop all ports first\n");
13691 		return;
13692 	}
13693 
13694 	filepath = strdup(res->filepath);
13695 	if (filepath == NULL) {
13696 		printf("Failed to allocate memory\n");
13697 		return;
13698 	}
13699 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13700 
13701 	buff = open_file(file_fld[0], &size);
13702 	if (!buff) {
13703 		free((void *)filepath);
13704 		return;
13705 	}
13706 
13707 #ifdef RTE_NET_I40E
13708 	if (ret == -ENOTSUP)
13709 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13710 					       buff, size,
13711 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
13712 #endif
13713 
13714 	if (ret == -EEXIST)
13715 		printf("Profile has already existed.\n");
13716 	else if (ret < 0)
13717 		printf("Failed to load profile.\n");
13718 	else if (file_num == 2)
13719 		save_file(file_fld[1], buff, size);
13720 
13721 	close_file(buff);
13722 	free((void *)filepath);
13723 }
13724 
13725 cmdline_parse_inst_t cmd_ddp_add = {
13726 	.f = cmd_ddp_add_parsed,
13727 	.data = NULL,
13728 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
13729 	.tokens = {
13730 		(void *)&cmd_ddp_add_ddp,
13731 		(void *)&cmd_ddp_add_add,
13732 		(void *)&cmd_ddp_add_port_id,
13733 		(void *)&cmd_ddp_add_filepath,
13734 		NULL,
13735 	},
13736 };
13737 
13738 /* Delete dynamic device personalization*/
13739 struct cmd_ddp_del_result {
13740 	cmdline_fixed_string_t ddp;
13741 	cmdline_fixed_string_t del;
13742 	portid_t port_id;
13743 	char filepath[];
13744 };
13745 
13746 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13747 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13748 cmdline_parse_token_string_t cmd_ddp_del_del =
13749 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13750 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13751 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
13752 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13753 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13754 
13755 static void
13756 cmd_ddp_del_parsed(
13757 	void *parsed_result,
13758 	__rte_unused struct cmdline *cl,
13759 	__rte_unused void *data)
13760 {
13761 	struct cmd_ddp_del_result *res = parsed_result;
13762 	uint8_t *buff;
13763 	uint32_t size;
13764 	int ret = -ENOTSUP;
13765 
13766 	if (!all_ports_stopped()) {
13767 		printf("Please stop all ports first\n");
13768 		return;
13769 	}
13770 
13771 	buff = open_file(res->filepath, &size);
13772 	if (!buff)
13773 		return;
13774 
13775 #ifdef RTE_NET_I40E
13776 	if (ret == -ENOTSUP)
13777 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13778 					       buff, size,
13779 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
13780 #endif
13781 
13782 	if (ret == -EACCES)
13783 		printf("Profile does not exist.\n");
13784 	else if (ret < 0)
13785 		printf("Failed to delete profile.\n");
13786 
13787 	close_file(buff);
13788 }
13789 
13790 cmdline_parse_inst_t cmd_ddp_del = {
13791 	.f = cmd_ddp_del_parsed,
13792 	.data = NULL,
13793 	.help_str = "ddp del <port_id> <backup_profile_path>",
13794 	.tokens = {
13795 		(void *)&cmd_ddp_del_ddp,
13796 		(void *)&cmd_ddp_del_del,
13797 		(void *)&cmd_ddp_del_port_id,
13798 		(void *)&cmd_ddp_del_filepath,
13799 		NULL,
13800 	},
13801 };
13802 
13803 /* Get dynamic device personalization profile info */
13804 struct cmd_ddp_info_result {
13805 	cmdline_fixed_string_t ddp;
13806 	cmdline_fixed_string_t get;
13807 	cmdline_fixed_string_t info;
13808 	char filepath[];
13809 };
13810 
13811 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13812 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13813 cmdline_parse_token_string_t cmd_ddp_info_get =
13814 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13815 cmdline_parse_token_string_t cmd_ddp_info_info =
13816 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13817 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13818 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13819 
13820 static void
13821 cmd_ddp_info_parsed(
13822 	void *parsed_result,
13823 	__rte_unused struct cmdline *cl,
13824 	__rte_unused void *data)
13825 {
13826 	struct cmd_ddp_info_result *res = parsed_result;
13827 	uint8_t *pkg;
13828 	uint32_t pkg_size;
13829 	int ret = -ENOTSUP;
13830 #ifdef RTE_NET_I40E
13831 	uint32_t i, j, n;
13832 	uint8_t *buff;
13833 	uint32_t buff_size = 0;
13834 	struct rte_pmd_i40e_profile_info info;
13835 	uint32_t dev_num = 0;
13836 	struct rte_pmd_i40e_ddp_device_id *devs;
13837 	uint32_t proto_num = 0;
13838 	struct rte_pmd_i40e_proto_info *proto = NULL;
13839 	uint32_t pctype_num = 0;
13840 	struct rte_pmd_i40e_ptype_info *pctype;
13841 	uint32_t ptype_num = 0;
13842 	struct rte_pmd_i40e_ptype_info *ptype;
13843 	uint8_t proto_id;
13844 
13845 #endif
13846 
13847 	pkg = open_file(res->filepath, &pkg_size);
13848 	if (!pkg)
13849 		return;
13850 
13851 #ifdef RTE_NET_I40E
13852 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13853 				(uint8_t *)&info, sizeof(info),
13854 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13855 	if (!ret) {
13856 		printf("Global Track id:       0x%x\n", info.track_id);
13857 		printf("Global Version:        %d.%d.%d.%d\n",
13858 			info.version.major,
13859 			info.version.minor,
13860 			info.version.update,
13861 			info.version.draft);
13862 		printf("Global Package name:   %s\n\n", info.name);
13863 	}
13864 
13865 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13866 				(uint8_t *)&info, sizeof(info),
13867 				RTE_PMD_I40E_PKG_INFO_HEADER);
13868 	if (!ret) {
13869 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
13870 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
13871 			info.version.major,
13872 			info.version.minor,
13873 			info.version.update,
13874 			info.version.draft);
13875 		printf("i40e Profile name:     %s\n\n", info.name);
13876 	}
13877 
13878 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13879 				(uint8_t *)&buff_size, sizeof(buff_size),
13880 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13881 	if (!ret && buff_size) {
13882 		buff = (uint8_t *)malloc(buff_size);
13883 		if (buff) {
13884 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13885 						buff, buff_size,
13886 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13887 			if (!ret)
13888 				printf("Package Notes:\n%s\n\n", buff);
13889 			free(buff);
13890 		}
13891 	}
13892 
13893 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13894 				(uint8_t *)&dev_num, sizeof(dev_num),
13895 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13896 	if (!ret && dev_num) {
13897 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13898 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13899 		if (devs) {
13900 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13901 						(uint8_t *)devs, buff_size,
13902 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13903 			if (!ret) {
13904 				printf("List of supported devices:\n");
13905 				for (i = 0; i < dev_num; i++) {
13906 					printf("  %04X:%04X %04X:%04X\n",
13907 						devs[i].vendor_dev_id >> 16,
13908 						devs[i].vendor_dev_id & 0xFFFF,
13909 						devs[i].sub_vendor_dev_id >> 16,
13910 						devs[i].sub_vendor_dev_id & 0xFFFF);
13911 				}
13912 				printf("\n");
13913 			}
13914 			free(devs);
13915 		}
13916 	}
13917 
13918 	/* get information about protocols and packet types */
13919 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13920 		(uint8_t *)&proto_num, sizeof(proto_num),
13921 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13922 	if (ret || !proto_num)
13923 		goto no_print_return;
13924 
13925 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13926 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13927 	if (!proto)
13928 		goto no_print_return;
13929 
13930 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13931 					buff_size,
13932 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13933 	if (!ret) {
13934 		printf("List of used protocols:\n");
13935 		for (i = 0; i < proto_num; i++)
13936 			printf("  %2u: %s\n", proto[i].proto_id,
13937 			       proto[i].name);
13938 		printf("\n");
13939 	}
13940 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13941 		(uint8_t *)&pctype_num, sizeof(pctype_num),
13942 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13943 	if (ret || !pctype_num)
13944 		goto no_print_pctypes;
13945 
13946 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13947 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13948 	if (!pctype)
13949 		goto no_print_pctypes;
13950 
13951 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13952 					buff_size,
13953 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13954 	if (ret) {
13955 		free(pctype);
13956 		goto no_print_pctypes;
13957 	}
13958 
13959 	printf("List of defined packet classification types:\n");
13960 	for (i = 0; i < pctype_num; i++) {
13961 		printf("  %2u:", pctype[i].ptype_id);
13962 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13963 			proto_id = pctype[i].protocols[j];
13964 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13965 				for (n = 0; n < proto_num; n++) {
13966 					if (proto[n].proto_id == proto_id) {
13967 						printf(" %s", proto[n].name);
13968 						break;
13969 					}
13970 				}
13971 			}
13972 		}
13973 		printf("\n");
13974 	}
13975 	printf("\n");
13976 	free(pctype);
13977 
13978 no_print_pctypes:
13979 
13980 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13981 					sizeof(ptype_num),
13982 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13983 	if (ret || !ptype_num)
13984 		goto no_print_return;
13985 
13986 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13987 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13988 	if (!ptype)
13989 		goto no_print_return;
13990 
13991 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13992 					buff_size,
13993 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13994 	if (ret) {
13995 		free(ptype);
13996 		goto no_print_return;
13997 	}
13998 	printf("List of defined packet types:\n");
13999 	for (i = 0; i < ptype_num; i++) {
14000 		printf("  %2u:", ptype[i].ptype_id);
14001 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14002 			proto_id = ptype[i].protocols[j];
14003 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14004 				for (n = 0; n < proto_num; n++) {
14005 					if (proto[n].proto_id == proto_id) {
14006 						printf(" %s", proto[n].name);
14007 						break;
14008 					}
14009 				}
14010 			}
14011 		}
14012 		printf("\n");
14013 	}
14014 	free(ptype);
14015 	printf("\n");
14016 
14017 	ret = 0;
14018 no_print_return:
14019 	if (proto)
14020 		free(proto);
14021 #endif
14022 	if (ret == -ENOTSUP)
14023 		printf("Function not supported in PMD driver\n");
14024 	close_file(pkg);
14025 }
14026 
14027 cmdline_parse_inst_t cmd_ddp_get_info = {
14028 	.f = cmd_ddp_info_parsed,
14029 	.data = NULL,
14030 	.help_str = "ddp get info <profile_path>",
14031 	.tokens = {
14032 		(void *)&cmd_ddp_info_ddp,
14033 		(void *)&cmd_ddp_info_get,
14034 		(void *)&cmd_ddp_info_info,
14035 		(void *)&cmd_ddp_info_filepath,
14036 		NULL,
14037 	},
14038 };
14039 
14040 /* Get dynamic device personalization profile info list*/
14041 #define PROFILE_INFO_SIZE 48
14042 #define MAX_PROFILE_NUM 16
14043 
14044 struct cmd_ddp_get_list_result {
14045 	cmdline_fixed_string_t ddp;
14046 	cmdline_fixed_string_t get;
14047 	cmdline_fixed_string_t list;
14048 	portid_t port_id;
14049 };
14050 
14051 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14052 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14053 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14054 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14055 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14056 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14057 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14058 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14059 		RTE_UINT16);
14060 
14061 static void
14062 cmd_ddp_get_list_parsed(
14063 	__rte_unused void *parsed_result,
14064 	__rte_unused struct cmdline *cl,
14065 	__rte_unused void *data)
14066 {
14067 #ifdef RTE_NET_I40E
14068 	struct cmd_ddp_get_list_result *res = parsed_result;
14069 	struct rte_pmd_i40e_profile_list *p_list;
14070 	struct rte_pmd_i40e_profile_info *p_info;
14071 	uint32_t p_num;
14072 	uint32_t size;
14073 	uint32_t i;
14074 #endif
14075 	int ret = -ENOTSUP;
14076 
14077 #ifdef RTE_NET_I40E
14078 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14079 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14080 	if (!p_list) {
14081 		printf("%s: Failed to malloc buffer\n", __func__);
14082 		return;
14083 	}
14084 
14085 	if (ret == -ENOTSUP)
14086 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14087 						(uint8_t *)p_list, size);
14088 
14089 	if (!ret) {
14090 		p_num = p_list->p_count;
14091 		printf("Profile number is: %d\n\n", p_num);
14092 
14093 		for (i = 0; i < p_num; i++) {
14094 			p_info = &p_list->p_info[i];
14095 			printf("Profile %d:\n", i);
14096 			printf("Track id:     0x%x\n", p_info->track_id);
14097 			printf("Version:      %d.%d.%d.%d\n",
14098 			       p_info->version.major,
14099 			       p_info->version.minor,
14100 			       p_info->version.update,
14101 			       p_info->version.draft);
14102 			printf("Profile name: %s\n\n", p_info->name);
14103 		}
14104 	}
14105 
14106 	free(p_list);
14107 #endif
14108 
14109 	if (ret < 0)
14110 		printf("Failed to get ddp list\n");
14111 }
14112 
14113 cmdline_parse_inst_t cmd_ddp_get_list = {
14114 	.f = cmd_ddp_get_list_parsed,
14115 	.data = NULL,
14116 	.help_str = "ddp get list <port_id>",
14117 	.tokens = {
14118 		(void *)&cmd_ddp_get_list_ddp,
14119 		(void *)&cmd_ddp_get_list_get,
14120 		(void *)&cmd_ddp_get_list_list,
14121 		(void *)&cmd_ddp_get_list_port_id,
14122 		NULL,
14123 	},
14124 };
14125 
14126 /* Configure input set */
14127 struct cmd_cfg_input_set_result {
14128 	cmdline_fixed_string_t port;
14129 	cmdline_fixed_string_t cfg;
14130 	portid_t port_id;
14131 	cmdline_fixed_string_t pctype;
14132 	uint8_t pctype_id;
14133 	cmdline_fixed_string_t inset_type;
14134 	cmdline_fixed_string_t opt;
14135 	cmdline_fixed_string_t field;
14136 	uint8_t field_idx;
14137 };
14138 
14139 static void
14140 cmd_cfg_input_set_parsed(
14141 	__rte_unused void *parsed_result,
14142 	__rte_unused struct cmdline *cl,
14143 	__rte_unused void *data)
14144 {
14145 #ifdef RTE_NET_I40E
14146 	struct cmd_cfg_input_set_result *res = parsed_result;
14147 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14148 	struct rte_pmd_i40e_inset inset;
14149 #endif
14150 	int ret = -ENOTSUP;
14151 
14152 	if (!all_ports_stopped()) {
14153 		printf("Please stop all ports first\n");
14154 		return;
14155 	}
14156 
14157 #ifdef RTE_NET_I40E
14158 	if (!strcmp(res->inset_type, "hash_inset"))
14159 		inset_type = INSET_HASH;
14160 	else if (!strcmp(res->inset_type, "fdir_inset"))
14161 		inset_type = INSET_FDIR;
14162 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14163 		inset_type = INSET_FDIR_FLX;
14164 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14165 				     &inset, inset_type);
14166 	if (ret) {
14167 		printf("Failed to get input set.\n");
14168 		return;
14169 	}
14170 
14171 	if (!strcmp(res->opt, "get")) {
14172 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14173 						   res->field_idx);
14174 		if (ret)
14175 			printf("Field index %d is enabled.\n", res->field_idx);
14176 		else
14177 			printf("Field index %d is disabled.\n", res->field_idx);
14178 		return;
14179 	} else if (!strcmp(res->opt, "set"))
14180 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14181 						   res->field_idx);
14182 	else if (!strcmp(res->opt, "clear"))
14183 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14184 						     res->field_idx);
14185 	if (ret) {
14186 		printf("Failed to configure input set field.\n");
14187 		return;
14188 	}
14189 
14190 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14191 				     &inset, inset_type);
14192 	if (ret) {
14193 		printf("Failed to set input set.\n");
14194 		return;
14195 	}
14196 #endif
14197 
14198 	if (ret == -ENOTSUP)
14199 		printf("Function not supported\n");
14200 }
14201 
14202 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14203 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14204 				 port, "port");
14205 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14206 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14207 				 cfg, "config");
14208 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14209 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14210 			      port_id, RTE_UINT16);
14211 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14212 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14213 				 pctype, "pctype");
14214 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14215 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14216 			      pctype_id, RTE_UINT8);
14217 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14218 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14219 				 inset_type,
14220 				 "hash_inset#fdir_inset#fdir_flx_inset");
14221 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14222 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14223 				 opt, "get#set#clear");
14224 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14225 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14226 				 field, "field");
14227 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14228 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14229 			      field_idx, RTE_UINT8);
14230 
14231 cmdline_parse_inst_t cmd_cfg_input_set = {
14232 	.f = cmd_cfg_input_set_parsed,
14233 	.data = NULL,
14234 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14235 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14236 	.tokens = {
14237 		(void *)&cmd_cfg_input_set_port,
14238 		(void *)&cmd_cfg_input_set_cfg,
14239 		(void *)&cmd_cfg_input_set_port_id,
14240 		(void *)&cmd_cfg_input_set_pctype,
14241 		(void *)&cmd_cfg_input_set_pctype_id,
14242 		(void *)&cmd_cfg_input_set_inset_type,
14243 		(void *)&cmd_cfg_input_set_opt,
14244 		(void *)&cmd_cfg_input_set_field,
14245 		(void *)&cmd_cfg_input_set_field_idx,
14246 		NULL,
14247 	},
14248 };
14249 
14250 /* Clear input set */
14251 struct cmd_clear_input_set_result {
14252 	cmdline_fixed_string_t port;
14253 	cmdline_fixed_string_t cfg;
14254 	portid_t port_id;
14255 	cmdline_fixed_string_t pctype;
14256 	uint8_t pctype_id;
14257 	cmdline_fixed_string_t inset_type;
14258 	cmdline_fixed_string_t clear;
14259 	cmdline_fixed_string_t all;
14260 };
14261 
14262 static void
14263 cmd_clear_input_set_parsed(
14264 	__rte_unused void *parsed_result,
14265 	__rte_unused struct cmdline *cl,
14266 	__rte_unused void *data)
14267 {
14268 #ifdef RTE_NET_I40E
14269 	struct cmd_clear_input_set_result *res = parsed_result;
14270 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14271 	struct rte_pmd_i40e_inset inset;
14272 #endif
14273 	int ret = -ENOTSUP;
14274 
14275 	if (!all_ports_stopped()) {
14276 		printf("Please stop all ports first\n");
14277 		return;
14278 	}
14279 
14280 #ifdef RTE_NET_I40E
14281 	if (!strcmp(res->inset_type, "hash_inset"))
14282 		inset_type = INSET_HASH;
14283 	else if (!strcmp(res->inset_type, "fdir_inset"))
14284 		inset_type = INSET_FDIR;
14285 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14286 		inset_type = INSET_FDIR_FLX;
14287 
14288 	memset(&inset, 0, sizeof(inset));
14289 
14290 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14291 				     &inset, inset_type);
14292 	if (ret) {
14293 		printf("Failed to clear input set.\n");
14294 		return;
14295 	}
14296 
14297 #endif
14298 
14299 	if (ret == -ENOTSUP)
14300 		printf("Function not supported\n");
14301 }
14302 
14303 cmdline_parse_token_string_t cmd_clear_input_set_port =
14304 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14305 				 port, "port");
14306 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14307 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14308 				 cfg, "config");
14309 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14310 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14311 			      port_id, RTE_UINT16);
14312 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14313 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14314 				 pctype, "pctype");
14315 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14316 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14317 			      pctype_id, RTE_UINT8);
14318 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14319 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14320 				 inset_type,
14321 				 "hash_inset#fdir_inset#fdir_flx_inset");
14322 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14323 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14324 				 clear, "clear");
14325 cmdline_parse_token_string_t cmd_clear_input_set_all =
14326 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14327 				 all, "all");
14328 
14329 cmdline_parse_inst_t cmd_clear_input_set = {
14330 	.f = cmd_clear_input_set_parsed,
14331 	.data = NULL,
14332 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14333 		    "fdir_inset|fdir_flx_inset clear all",
14334 	.tokens = {
14335 		(void *)&cmd_clear_input_set_port,
14336 		(void *)&cmd_clear_input_set_cfg,
14337 		(void *)&cmd_clear_input_set_port_id,
14338 		(void *)&cmd_clear_input_set_pctype,
14339 		(void *)&cmd_clear_input_set_pctype_id,
14340 		(void *)&cmd_clear_input_set_inset_type,
14341 		(void *)&cmd_clear_input_set_clear,
14342 		(void *)&cmd_clear_input_set_all,
14343 		NULL,
14344 	},
14345 };
14346 
14347 /* show vf stats */
14348 
14349 /* Common result structure for show vf stats */
14350 struct cmd_show_vf_stats_result {
14351 	cmdline_fixed_string_t show;
14352 	cmdline_fixed_string_t vf;
14353 	cmdline_fixed_string_t stats;
14354 	portid_t port_id;
14355 	uint16_t vf_id;
14356 };
14357 
14358 /* Common CLI fields show vf stats*/
14359 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14360 	TOKEN_STRING_INITIALIZER
14361 		(struct cmd_show_vf_stats_result,
14362 		 show, "show");
14363 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14364 	TOKEN_STRING_INITIALIZER
14365 		(struct cmd_show_vf_stats_result,
14366 		 vf, "vf");
14367 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14368 	TOKEN_STRING_INITIALIZER
14369 		(struct cmd_show_vf_stats_result,
14370 		 stats, "stats");
14371 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14372 	TOKEN_NUM_INITIALIZER
14373 		(struct cmd_show_vf_stats_result,
14374 		 port_id, RTE_UINT16);
14375 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14376 	TOKEN_NUM_INITIALIZER
14377 		(struct cmd_show_vf_stats_result,
14378 		 vf_id, RTE_UINT16);
14379 
14380 static void
14381 cmd_show_vf_stats_parsed(
14382 	void *parsed_result,
14383 	__rte_unused struct cmdline *cl,
14384 	__rte_unused void *data)
14385 {
14386 	struct cmd_show_vf_stats_result *res = parsed_result;
14387 	struct rte_eth_stats stats;
14388 	int ret = -ENOTSUP;
14389 	static const char *nic_stats_border = "########################";
14390 
14391 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14392 		return;
14393 
14394 	memset(&stats, 0, sizeof(stats));
14395 
14396 #ifdef RTE_NET_I40E
14397 	if (ret == -ENOTSUP)
14398 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14399 						res->vf_id,
14400 						&stats);
14401 #endif
14402 #ifdef RTE_NET_BNXT
14403 	if (ret == -ENOTSUP)
14404 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14405 						res->vf_id,
14406 						&stats);
14407 #endif
14408 
14409 	switch (ret) {
14410 	case 0:
14411 		break;
14412 	case -EINVAL:
14413 		printf("invalid vf_id %d\n", res->vf_id);
14414 		break;
14415 	case -ENODEV:
14416 		printf("invalid port_id %d\n", res->port_id);
14417 		break;
14418 	case -ENOTSUP:
14419 		printf("function not implemented\n");
14420 		break;
14421 	default:
14422 		printf("programming error: (%s)\n", strerror(-ret));
14423 	}
14424 
14425 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
14426 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14427 
14428 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
14429 	       "%-"PRIu64"\n",
14430 	       stats.ipackets, stats.imissed, stats.ibytes);
14431 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
14432 	printf("  RX-nombuf:  %-10"PRIu64"\n",
14433 	       stats.rx_nombuf);
14434 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
14435 	       "%-"PRIu64"\n",
14436 	       stats.opackets, stats.oerrors, stats.obytes);
14437 
14438 	printf("  %s############################%s\n",
14439 			       nic_stats_border, nic_stats_border);
14440 }
14441 
14442 cmdline_parse_inst_t cmd_show_vf_stats = {
14443 	.f = cmd_show_vf_stats_parsed,
14444 	.data = NULL,
14445 	.help_str = "show vf stats <port_id> <vf_id>",
14446 	.tokens = {
14447 		(void *)&cmd_show_vf_stats_show,
14448 		(void *)&cmd_show_vf_stats_vf,
14449 		(void *)&cmd_show_vf_stats_stats,
14450 		(void *)&cmd_show_vf_stats_port_id,
14451 		(void *)&cmd_show_vf_stats_vf_id,
14452 		NULL,
14453 	},
14454 };
14455 
14456 /* clear vf stats */
14457 
14458 /* Common result structure for clear vf stats */
14459 struct cmd_clear_vf_stats_result {
14460 	cmdline_fixed_string_t clear;
14461 	cmdline_fixed_string_t vf;
14462 	cmdline_fixed_string_t stats;
14463 	portid_t port_id;
14464 	uint16_t vf_id;
14465 };
14466 
14467 /* Common CLI fields clear vf stats*/
14468 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14469 	TOKEN_STRING_INITIALIZER
14470 		(struct cmd_clear_vf_stats_result,
14471 		 clear, "clear");
14472 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14473 	TOKEN_STRING_INITIALIZER
14474 		(struct cmd_clear_vf_stats_result,
14475 		 vf, "vf");
14476 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14477 	TOKEN_STRING_INITIALIZER
14478 		(struct cmd_clear_vf_stats_result,
14479 		 stats, "stats");
14480 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14481 	TOKEN_NUM_INITIALIZER
14482 		(struct cmd_clear_vf_stats_result,
14483 		 port_id, RTE_UINT16);
14484 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14485 	TOKEN_NUM_INITIALIZER
14486 		(struct cmd_clear_vf_stats_result,
14487 		 vf_id, RTE_UINT16);
14488 
14489 static void
14490 cmd_clear_vf_stats_parsed(
14491 	void *parsed_result,
14492 	__rte_unused struct cmdline *cl,
14493 	__rte_unused void *data)
14494 {
14495 	struct cmd_clear_vf_stats_result *res = parsed_result;
14496 	int ret = -ENOTSUP;
14497 
14498 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14499 		return;
14500 
14501 #ifdef RTE_NET_I40E
14502 	if (ret == -ENOTSUP)
14503 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14504 						  res->vf_id);
14505 #endif
14506 #ifdef RTE_NET_BNXT
14507 	if (ret == -ENOTSUP)
14508 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14509 						  res->vf_id);
14510 #endif
14511 
14512 	switch (ret) {
14513 	case 0:
14514 		break;
14515 	case -EINVAL:
14516 		printf("invalid vf_id %d\n", res->vf_id);
14517 		break;
14518 	case -ENODEV:
14519 		printf("invalid port_id %d\n", res->port_id);
14520 		break;
14521 	case -ENOTSUP:
14522 		printf("function not implemented\n");
14523 		break;
14524 	default:
14525 		printf("programming error: (%s)\n", strerror(-ret));
14526 	}
14527 }
14528 
14529 cmdline_parse_inst_t cmd_clear_vf_stats = {
14530 	.f = cmd_clear_vf_stats_parsed,
14531 	.data = NULL,
14532 	.help_str = "clear vf stats <port_id> <vf_id>",
14533 	.tokens = {
14534 		(void *)&cmd_clear_vf_stats_clear,
14535 		(void *)&cmd_clear_vf_stats_vf,
14536 		(void *)&cmd_clear_vf_stats_stats,
14537 		(void *)&cmd_clear_vf_stats_port_id,
14538 		(void *)&cmd_clear_vf_stats_vf_id,
14539 		NULL,
14540 	},
14541 };
14542 
14543 /* port config pctype mapping reset */
14544 
14545 /* Common result structure for port config pctype mapping reset */
14546 struct cmd_pctype_mapping_reset_result {
14547 	cmdline_fixed_string_t port;
14548 	cmdline_fixed_string_t config;
14549 	portid_t port_id;
14550 	cmdline_fixed_string_t pctype;
14551 	cmdline_fixed_string_t mapping;
14552 	cmdline_fixed_string_t reset;
14553 };
14554 
14555 /* Common CLI fields for port config pctype mapping reset*/
14556 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14557 	TOKEN_STRING_INITIALIZER
14558 		(struct cmd_pctype_mapping_reset_result,
14559 		 port, "port");
14560 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14561 	TOKEN_STRING_INITIALIZER
14562 		(struct cmd_pctype_mapping_reset_result,
14563 		 config, "config");
14564 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14565 	TOKEN_NUM_INITIALIZER
14566 		(struct cmd_pctype_mapping_reset_result,
14567 		 port_id, RTE_UINT16);
14568 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14569 	TOKEN_STRING_INITIALIZER
14570 		(struct cmd_pctype_mapping_reset_result,
14571 		 pctype, "pctype");
14572 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14573 	TOKEN_STRING_INITIALIZER
14574 		(struct cmd_pctype_mapping_reset_result,
14575 		 mapping, "mapping");
14576 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14577 	TOKEN_STRING_INITIALIZER
14578 		(struct cmd_pctype_mapping_reset_result,
14579 		 reset, "reset");
14580 
14581 static void
14582 cmd_pctype_mapping_reset_parsed(
14583 	void *parsed_result,
14584 	__rte_unused struct cmdline *cl,
14585 	__rte_unused void *data)
14586 {
14587 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
14588 	int ret = -ENOTSUP;
14589 
14590 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14591 		return;
14592 
14593 #ifdef RTE_NET_I40E
14594 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14595 #endif
14596 
14597 	switch (ret) {
14598 	case 0:
14599 		break;
14600 	case -ENODEV:
14601 		printf("invalid port_id %d\n", res->port_id);
14602 		break;
14603 	case -ENOTSUP:
14604 		printf("function not implemented\n");
14605 		break;
14606 	default:
14607 		printf("programming error: (%s)\n", strerror(-ret));
14608 	}
14609 }
14610 
14611 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14612 	.f = cmd_pctype_mapping_reset_parsed,
14613 	.data = NULL,
14614 	.help_str = "port config <port_id> pctype mapping reset",
14615 	.tokens = {
14616 		(void *)&cmd_pctype_mapping_reset_port,
14617 		(void *)&cmd_pctype_mapping_reset_config,
14618 		(void *)&cmd_pctype_mapping_reset_port_id,
14619 		(void *)&cmd_pctype_mapping_reset_pctype,
14620 		(void *)&cmd_pctype_mapping_reset_mapping,
14621 		(void *)&cmd_pctype_mapping_reset_reset,
14622 		NULL,
14623 	},
14624 };
14625 
14626 /* show port pctype mapping */
14627 
14628 /* Common result structure for show port pctype mapping */
14629 struct cmd_pctype_mapping_get_result {
14630 	cmdline_fixed_string_t show;
14631 	cmdline_fixed_string_t port;
14632 	portid_t port_id;
14633 	cmdline_fixed_string_t pctype;
14634 	cmdline_fixed_string_t mapping;
14635 };
14636 
14637 /* Common CLI fields for pctype mapping get */
14638 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14639 	TOKEN_STRING_INITIALIZER
14640 		(struct cmd_pctype_mapping_get_result,
14641 		 show, "show");
14642 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14643 	TOKEN_STRING_INITIALIZER
14644 		(struct cmd_pctype_mapping_get_result,
14645 		 port, "port");
14646 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14647 	TOKEN_NUM_INITIALIZER
14648 		(struct cmd_pctype_mapping_get_result,
14649 		 port_id, RTE_UINT16);
14650 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14651 	TOKEN_STRING_INITIALIZER
14652 		(struct cmd_pctype_mapping_get_result,
14653 		 pctype, "pctype");
14654 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14655 	TOKEN_STRING_INITIALIZER
14656 		(struct cmd_pctype_mapping_get_result,
14657 		 mapping, "mapping");
14658 
14659 static void
14660 cmd_pctype_mapping_get_parsed(
14661 	void *parsed_result,
14662 	__rte_unused struct cmdline *cl,
14663 	__rte_unused void *data)
14664 {
14665 	struct cmd_pctype_mapping_get_result *res = parsed_result;
14666 	int ret = -ENOTSUP;
14667 #ifdef RTE_NET_I40E
14668 	struct rte_pmd_i40e_flow_type_mapping
14669 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14670 	int i, j, first_pctype;
14671 #endif
14672 
14673 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14674 		return;
14675 
14676 #ifdef RTE_NET_I40E
14677 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14678 #endif
14679 
14680 	switch (ret) {
14681 	case 0:
14682 		break;
14683 	case -ENODEV:
14684 		printf("invalid port_id %d\n", res->port_id);
14685 		return;
14686 	case -ENOTSUP:
14687 		printf("function not implemented\n");
14688 		return;
14689 	default:
14690 		printf("programming error: (%s)\n", strerror(-ret));
14691 		return;
14692 	}
14693 
14694 #ifdef RTE_NET_I40E
14695 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14696 		if (mapping[i].pctype != 0ULL) {
14697 			first_pctype = 1;
14698 
14699 			printf("pctype: ");
14700 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14701 				if (mapping[i].pctype & (1ULL << j)) {
14702 					printf(first_pctype ?
14703 					       "%02d" : ",%02d", j);
14704 					first_pctype = 0;
14705 				}
14706 			}
14707 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
14708 		}
14709 	}
14710 #endif
14711 }
14712 
14713 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14714 	.f = cmd_pctype_mapping_get_parsed,
14715 	.data = NULL,
14716 	.help_str = "show port <port_id> pctype mapping",
14717 	.tokens = {
14718 		(void *)&cmd_pctype_mapping_get_show,
14719 		(void *)&cmd_pctype_mapping_get_port,
14720 		(void *)&cmd_pctype_mapping_get_port_id,
14721 		(void *)&cmd_pctype_mapping_get_pctype,
14722 		(void *)&cmd_pctype_mapping_get_mapping,
14723 		NULL,
14724 	},
14725 };
14726 
14727 /* port config pctype mapping update */
14728 
14729 /* Common result structure for port config pctype mapping update */
14730 struct cmd_pctype_mapping_update_result {
14731 	cmdline_fixed_string_t port;
14732 	cmdline_fixed_string_t config;
14733 	portid_t port_id;
14734 	cmdline_fixed_string_t pctype;
14735 	cmdline_fixed_string_t mapping;
14736 	cmdline_fixed_string_t update;
14737 	cmdline_fixed_string_t pctype_list;
14738 	uint16_t flow_type;
14739 };
14740 
14741 /* Common CLI fields for pctype mapping update*/
14742 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14743 	TOKEN_STRING_INITIALIZER
14744 		(struct cmd_pctype_mapping_update_result,
14745 		 port, "port");
14746 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14747 	TOKEN_STRING_INITIALIZER
14748 		(struct cmd_pctype_mapping_update_result,
14749 		 config, "config");
14750 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14751 	TOKEN_NUM_INITIALIZER
14752 		(struct cmd_pctype_mapping_update_result,
14753 		 port_id, RTE_UINT16);
14754 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14755 	TOKEN_STRING_INITIALIZER
14756 		(struct cmd_pctype_mapping_update_result,
14757 		 pctype, "pctype");
14758 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14759 	TOKEN_STRING_INITIALIZER
14760 		(struct cmd_pctype_mapping_update_result,
14761 		 mapping, "mapping");
14762 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14763 	TOKEN_STRING_INITIALIZER
14764 		(struct cmd_pctype_mapping_update_result,
14765 		 update, "update");
14766 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14767 	TOKEN_STRING_INITIALIZER
14768 		(struct cmd_pctype_mapping_update_result,
14769 		 pctype_list, NULL);
14770 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14771 	TOKEN_NUM_INITIALIZER
14772 		(struct cmd_pctype_mapping_update_result,
14773 		 flow_type, RTE_UINT16);
14774 
14775 static void
14776 cmd_pctype_mapping_update_parsed(
14777 	void *parsed_result,
14778 	__rte_unused struct cmdline *cl,
14779 	__rte_unused void *data)
14780 {
14781 	struct cmd_pctype_mapping_update_result *res = parsed_result;
14782 	int ret = -ENOTSUP;
14783 #ifdef RTE_NET_I40E
14784 	struct rte_pmd_i40e_flow_type_mapping mapping;
14785 	unsigned int i;
14786 	unsigned int nb_item;
14787 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14788 #endif
14789 
14790 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14791 		return;
14792 
14793 #ifdef RTE_NET_I40E
14794 	nb_item = parse_item_list(res->pctype_list, "pctypes",
14795 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14796 	mapping.flow_type = res->flow_type;
14797 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14798 		mapping.pctype |= (1ULL << pctype_list[i]);
14799 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14800 						&mapping,
14801 						1,
14802 						0);
14803 #endif
14804 
14805 	switch (ret) {
14806 	case 0:
14807 		break;
14808 	case -EINVAL:
14809 		printf("invalid pctype or flow type\n");
14810 		break;
14811 	case -ENODEV:
14812 		printf("invalid port_id %d\n", res->port_id);
14813 		break;
14814 	case -ENOTSUP:
14815 		printf("function not implemented\n");
14816 		break;
14817 	default:
14818 		printf("programming error: (%s)\n", strerror(-ret));
14819 	}
14820 }
14821 
14822 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14823 	.f = cmd_pctype_mapping_update_parsed,
14824 	.data = NULL,
14825 	.help_str = "port config <port_id> pctype mapping update"
14826 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14827 	.tokens = {
14828 		(void *)&cmd_pctype_mapping_update_port,
14829 		(void *)&cmd_pctype_mapping_update_config,
14830 		(void *)&cmd_pctype_mapping_update_port_id,
14831 		(void *)&cmd_pctype_mapping_update_pctype,
14832 		(void *)&cmd_pctype_mapping_update_mapping,
14833 		(void *)&cmd_pctype_mapping_update_update,
14834 		(void *)&cmd_pctype_mapping_update_pc_type,
14835 		(void *)&cmd_pctype_mapping_update_flow_type,
14836 		NULL,
14837 	},
14838 };
14839 
14840 /* ptype mapping get */
14841 
14842 /* Common result structure for ptype mapping get */
14843 struct cmd_ptype_mapping_get_result {
14844 	cmdline_fixed_string_t ptype;
14845 	cmdline_fixed_string_t mapping;
14846 	cmdline_fixed_string_t get;
14847 	portid_t port_id;
14848 	uint8_t valid_only;
14849 };
14850 
14851 /* Common CLI fields for ptype mapping get */
14852 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14853 	TOKEN_STRING_INITIALIZER
14854 		(struct cmd_ptype_mapping_get_result,
14855 		 ptype, "ptype");
14856 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14857 	TOKEN_STRING_INITIALIZER
14858 		(struct cmd_ptype_mapping_get_result,
14859 		 mapping, "mapping");
14860 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14861 	TOKEN_STRING_INITIALIZER
14862 		(struct cmd_ptype_mapping_get_result,
14863 		 get, "get");
14864 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14865 	TOKEN_NUM_INITIALIZER
14866 		(struct cmd_ptype_mapping_get_result,
14867 		 port_id, RTE_UINT16);
14868 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14869 	TOKEN_NUM_INITIALIZER
14870 		(struct cmd_ptype_mapping_get_result,
14871 		 valid_only, RTE_UINT8);
14872 
14873 static void
14874 cmd_ptype_mapping_get_parsed(
14875 	void *parsed_result,
14876 	__rte_unused struct cmdline *cl,
14877 	__rte_unused void *data)
14878 {
14879 	struct cmd_ptype_mapping_get_result *res = parsed_result;
14880 	int ret = -ENOTSUP;
14881 #ifdef RTE_NET_I40E
14882 	int max_ptype_num = 256;
14883 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14884 	uint16_t count;
14885 	int i;
14886 #endif
14887 
14888 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14889 		return;
14890 
14891 #ifdef RTE_NET_I40E
14892 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14893 					mapping,
14894 					max_ptype_num,
14895 					&count,
14896 					res->valid_only);
14897 #endif
14898 
14899 	switch (ret) {
14900 	case 0:
14901 		break;
14902 	case -ENODEV:
14903 		printf("invalid port_id %d\n", res->port_id);
14904 		break;
14905 	case -ENOTSUP:
14906 		printf("function not implemented\n");
14907 		break;
14908 	default:
14909 		printf("programming error: (%s)\n", strerror(-ret));
14910 	}
14911 
14912 #ifdef RTE_NET_I40E
14913 	if (!ret) {
14914 		for (i = 0; i < count; i++)
14915 			printf("%3d\t0x%08x\n",
14916 				mapping[i].hw_ptype, mapping[i].sw_ptype);
14917 	}
14918 #endif
14919 }
14920 
14921 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14922 	.f = cmd_ptype_mapping_get_parsed,
14923 	.data = NULL,
14924 	.help_str = "ptype mapping get <port_id> <valid_only>",
14925 	.tokens = {
14926 		(void *)&cmd_ptype_mapping_get_ptype,
14927 		(void *)&cmd_ptype_mapping_get_mapping,
14928 		(void *)&cmd_ptype_mapping_get_get,
14929 		(void *)&cmd_ptype_mapping_get_port_id,
14930 		(void *)&cmd_ptype_mapping_get_valid_only,
14931 		NULL,
14932 	},
14933 };
14934 
14935 /* ptype mapping replace */
14936 
14937 /* Common result structure for ptype mapping replace */
14938 struct cmd_ptype_mapping_replace_result {
14939 	cmdline_fixed_string_t ptype;
14940 	cmdline_fixed_string_t mapping;
14941 	cmdline_fixed_string_t replace;
14942 	portid_t port_id;
14943 	uint32_t target;
14944 	uint8_t mask;
14945 	uint32_t pkt_type;
14946 };
14947 
14948 /* Common CLI fields for ptype mapping replace */
14949 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14950 	TOKEN_STRING_INITIALIZER
14951 		(struct cmd_ptype_mapping_replace_result,
14952 		 ptype, "ptype");
14953 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14954 	TOKEN_STRING_INITIALIZER
14955 		(struct cmd_ptype_mapping_replace_result,
14956 		 mapping, "mapping");
14957 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14958 	TOKEN_STRING_INITIALIZER
14959 		(struct cmd_ptype_mapping_replace_result,
14960 		 replace, "replace");
14961 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14962 	TOKEN_NUM_INITIALIZER
14963 		(struct cmd_ptype_mapping_replace_result,
14964 		 port_id, RTE_UINT16);
14965 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14966 	TOKEN_NUM_INITIALIZER
14967 		(struct cmd_ptype_mapping_replace_result,
14968 		 target, RTE_UINT32);
14969 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14970 	TOKEN_NUM_INITIALIZER
14971 		(struct cmd_ptype_mapping_replace_result,
14972 		 mask, RTE_UINT8);
14973 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14974 	TOKEN_NUM_INITIALIZER
14975 		(struct cmd_ptype_mapping_replace_result,
14976 		 pkt_type, RTE_UINT32);
14977 
14978 static void
14979 cmd_ptype_mapping_replace_parsed(
14980 	void *parsed_result,
14981 	__rte_unused struct cmdline *cl,
14982 	__rte_unused void *data)
14983 {
14984 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
14985 	int ret = -ENOTSUP;
14986 
14987 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14988 		return;
14989 
14990 #ifdef RTE_NET_I40E
14991 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14992 					res->target,
14993 					res->mask,
14994 					res->pkt_type);
14995 #endif
14996 
14997 	switch (ret) {
14998 	case 0:
14999 		break;
15000 	case -EINVAL:
15001 		printf("invalid ptype 0x%8x or 0x%8x\n",
15002 				res->target, res->pkt_type);
15003 		break;
15004 	case -ENODEV:
15005 		printf("invalid port_id %d\n", res->port_id);
15006 		break;
15007 	case -ENOTSUP:
15008 		printf("function not implemented\n");
15009 		break;
15010 	default:
15011 		printf("programming error: (%s)\n", strerror(-ret));
15012 	}
15013 }
15014 
15015 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15016 	.f = cmd_ptype_mapping_replace_parsed,
15017 	.data = NULL,
15018 	.help_str =
15019 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15020 	.tokens = {
15021 		(void *)&cmd_ptype_mapping_replace_ptype,
15022 		(void *)&cmd_ptype_mapping_replace_mapping,
15023 		(void *)&cmd_ptype_mapping_replace_replace,
15024 		(void *)&cmd_ptype_mapping_replace_port_id,
15025 		(void *)&cmd_ptype_mapping_replace_target,
15026 		(void *)&cmd_ptype_mapping_replace_mask,
15027 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15028 		NULL,
15029 	},
15030 };
15031 
15032 /* ptype mapping reset */
15033 
15034 /* Common result structure for ptype mapping reset */
15035 struct cmd_ptype_mapping_reset_result {
15036 	cmdline_fixed_string_t ptype;
15037 	cmdline_fixed_string_t mapping;
15038 	cmdline_fixed_string_t reset;
15039 	portid_t port_id;
15040 };
15041 
15042 /* Common CLI fields for ptype mapping reset*/
15043 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15044 	TOKEN_STRING_INITIALIZER
15045 		(struct cmd_ptype_mapping_reset_result,
15046 		 ptype, "ptype");
15047 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15048 	TOKEN_STRING_INITIALIZER
15049 		(struct cmd_ptype_mapping_reset_result,
15050 		 mapping, "mapping");
15051 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15052 	TOKEN_STRING_INITIALIZER
15053 		(struct cmd_ptype_mapping_reset_result,
15054 		 reset, "reset");
15055 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15056 	TOKEN_NUM_INITIALIZER
15057 		(struct cmd_ptype_mapping_reset_result,
15058 		 port_id, RTE_UINT16);
15059 
15060 static void
15061 cmd_ptype_mapping_reset_parsed(
15062 	void *parsed_result,
15063 	__rte_unused struct cmdline *cl,
15064 	__rte_unused void *data)
15065 {
15066 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15067 	int ret = -ENOTSUP;
15068 
15069 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15070 		return;
15071 
15072 #ifdef RTE_NET_I40E
15073 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15074 #endif
15075 
15076 	switch (ret) {
15077 	case 0:
15078 		break;
15079 	case -ENODEV:
15080 		printf("invalid port_id %d\n", res->port_id);
15081 		break;
15082 	case -ENOTSUP:
15083 		printf("function not implemented\n");
15084 		break;
15085 	default:
15086 		printf("programming error: (%s)\n", strerror(-ret));
15087 	}
15088 }
15089 
15090 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15091 	.f = cmd_ptype_mapping_reset_parsed,
15092 	.data = NULL,
15093 	.help_str = "ptype mapping reset <port_id>",
15094 	.tokens = {
15095 		(void *)&cmd_ptype_mapping_reset_ptype,
15096 		(void *)&cmd_ptype_mapping_reset_mapping,
15097 		(void *)&cmd_ptype_mapping_reset_reset,
15098 		(void *)&cmd_ptype_mapping_reset_port_id,
15099 		NULL,
15100 	},
15101 };
15102 
15103 /* ptype mapping update */
15104 
15105 /* Common result structure for ptype mapping update */
15106 struct cmd_ptype_mapping_update_result {
15107 	cmdline_fixed_string_t ptype;
15108 	cmdline_fixed_string_t mapping;
15109 	cmdline_fixed_string_t reset;
15110 	portid_t port_id;
15111 	uint8_t hw_ptype;
15112 	uint32_t sw_ptype;
15113 };
15114 
15115 /* Common CLI fields for ptype mapping update*/
15116 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15117 	TOKEN_STRING_INITIALIZER
15118 		(struct cmd_ptype_mapping_update_result,
15119 		 ptype, "ptype");
15120 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15121 	TOKEN_STRING_INITIALIZER
15122 		(struct cmd_ptype_mapping_update_result,
15123 		 mapping, "mapping");
15124 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15125 	TOKEN_STRING_INITIALIZER
15126 		(struct cmd_ptype_mapping_update_result,
15127 		 reset, "update");
15128 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15129 	TOKEN_NUM_INITIALIZER
15130 		(struct cmd_ptype_mapping_update_result,
15131 		 port_id, RTE_UINT16);
15132 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15133 	TOKEN_NUM_INITIALIZER
15134 		(struct cmd_ptype_mapping_update_result,
15135 		 hw_ptype, RTE_UINT8);
15136 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15137 	TOKEN_NUM_INITIALIZER
15138 		(struct cmd_ptype_mapping_update_result,
15139 		 sw_ptype, RTE_UINT32);
15140 
15141 static void
15142 cmd_ptype_mapping_update_parsed(
15143 	void *parsed_result,
15144 	__rte_unused struct cmdline *cl,
15145 	__rte_unused void *data)
15146 {
15147 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15148 	int ret = -ENOTSUP;
15149 #ifdef RTE_NET_I40E
15150 	struct rte_pmd_i40e_ptype_mapping mapping;
15151 #endif
15152 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15153 		return;
15154 
15155 #ifdef RTE_NET_I40E
15156 	mapping.hw_ptype = res->hw_ptype;
15157 	mapping.sw_ptype = res->sw_ptype;
15158 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15159 						&mapping,
15160 						1,
15161 						0);
15162 #endif
15163 
15164 	switch (ret) {
15165 	case 0:
15166 		break;
15167 	case -EINVAL:
15168 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
15169 		break;
15170 	case -ENODEV:
15171 		printf("invalid port_id %d\n", res->port_id);
15172 		break;
15173 	case -ENOTSUP:
15174 		printf("function not implemented\n");
15175 		break;
15176 	default:
15177 		printf("programming error: (%s)\n", strerror(-ret));
15178 	}
15179 }
15180 
15181 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15182 	.f = cmd_ptype_mapping_update_parsed,
15183 	.data = NULL,
15184 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15185 	.tokens = {
15186 		(void *)&cmd_ptype_mapping_update_ptype,
15187 		(void *)&cmd_ptype_mapping_update_mapping,
15188 		(void *)&cmd_ptype_mapping_update_update,
15189 		(void *)&cmd_ptype_mapping_update_port_id,
15190 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15191 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15192 		NULL,
15193 	},
15194 };
15195 
15196 /* Common result structure for file commands */
15197 struct cmd_cmdfile_result {
15198 	cmdline_fixed_string_t load;
15199 	cmdline_fixed_string_t filename;
15200 };
15201 
15202 /* Common CLI fields for file commands */
15203 cmdline_parse_token_string_t cmd_load_cmdfile =
15204 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15205 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15206 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15207 
15208 static void
15209 cmd_load_from_file_parsed(
15210 	void *parsed_result,
15211 	__rte_unused struct cmdline *cl,
15212 	__rte_unused void *data)
15213 {
15214 	struct cmd_cmdfile_result *res = parsed_result;
15215 
15216 	cmdline_read_from_file(res->filename);
15217 }
15218 
15219 cmdline_parse_inst_t cmd_load_from_file = {
15220 	.f = cmd_load_from_file_parsed,
15221 	.data = NULL,
15222 	.help_str = "load <filename>",
15223 	.tokens = {
15224 		(void *)&cmd_load_cmdfile,
15225 		(void *)&cmd_load_cmdfile_filename,
15226 		NULL,
15227 	},
15228 };
15229 
15230 /* Get Rx offloads capabilities */
15231 struct cmd_rx_offload_get_capa_result {
15232 	cmdline_fixed_string_t show;
15233 	cmdline_fixed_string_t port;
15234 	portid_t port_id;
15235 	cmdline_fixed_string_t rx_offload;
15236 	cmdline_fixed_string_t capabilities;
15237 };
15238 
15239 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15240 	TOKEN_STRING_INITIALIZER
15241 		(struct cmd_rx_offload_get_capa_result,
15242 		 show, "show");
15243 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15244 	TOKEN_STRING_INITIALIZER
15245 		(struct cmd_rx_offload_get_capa_result,
15246 		 port, "port");
15247 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15248 	TOKEN_NUM_INITIALIZER
15249 		(struct cmd_rx_offload_get_capa_result,
15250 		 port_id, RTE_UINT16);
15251 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15252 	TOKEN_STRING_INITIALIZER
15253 		(struct cmd_rx_offload_get_capa_result,
15254 		 rx_offload, "rx_offload");
15255 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15256 	TOKEN_STRING_INITIALIZER
15257 		(struct cmd_rx_offload_get_capa_result,
15258 		 capabilities, "capabilities");
15259 
15260 static void
15261 print_rx_offloads(uint64_t offloads)
15262 {
15263 	uint64_t single_offload;
15264 	int begin;
15265 	int end;
15266 	int bit;
15267 
15268 	if (offloads == 0)
15269 		return;
15270 
15271 	begin = __builtin_ctzll(offloads);
15272 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15273 
15274 	single_offload = 1ULL << begin;
15275 	for (bit = begin; bit < end; bit++) {
15276 		if (offloads & single_offload)
15277 			printf(" %s",
15278 			       rte_eth_dev_rx_offload_name(single_offload));
15279 		single_offload <<= 1;
15280 	}
15281 }
15282 
15283 static void
15284 cmd_rx_offload_get_capa_parsed(
15285 	void *parsed_result,
15286 	__rte_unused struct cmdline *cl,
15287 	__rte_unused void *data)
15288 {
15289 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
15290 	struct rte_eth_dev_info dev_info;
15291 	portid_t port_id = res->port_id;
15292 	uint64_t queue_offloads;
15293 	uint64_t port_offloads;
15294 	int ret;
15295 
15296 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15297 	if (ret != 0)
15298 		return;
15299 
15300 	queue_offloads = dev_info.rx_queue_offload_capa;
15301 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15302 
15303 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
15304 	printf("  Per Queue :");
15305 	print_rx_offloads(queue_offloads);
15306 
15307 	printf("\n");
15308 	printf("  Per Port  :");
15309 	print_rx_offloads(port_offloads);
15310 	printf("\n\n");
15311 }
15312 
15313 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15314 	.f = cmd_rx_offload_get_capa_parsed,
15315 	.data = NULL,
15316 	.help_str = "show port <port_id> rx_offload capabilities",
15317 	.tokens = {
15318 		(void *)&cmd_rx_offload_get_capa_show,
15319 		(void *)&cmd_rx_offload_get_capa_port,
15320 		(void *)&cmd_rx_offload_get_capa_port_id,
15321 		(void *)&cmd_rx_offload_get_capa_rx_offload,
15322 		(void *)&cmd_rx_offload_get_capa_capabilities,
15323 		NULL,
15324 	}
15325 };
15326 
15327 /* Get Rx offloads configuration */
15328 struct cmd_rx_offload_get_configuration_result {
15329 	cmdline_fixed_string_t show;
15330 	cmdline_fixed_string_t port;
15331 	portid_t port_id;
15332 	cmdline_fixed_string_t rx_offload;
15333 	cmdline_fixed_string_t configuration;
15334 };
15335 
15336 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15337 	TOKEN_STRING_INITIALIZER
15338 		(struct cmd_rx_offload_get_configuration_result,
15339 		 show, "show");
15340 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15341 	TOKEN_STRING_INITIALIZER
15342 		(struct cmd_rx_offload_get_configuration_result,
15343 		 port, "port");
15344 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15345 	TOKEN_NUM_INITIALIZER
15346 		(struct cmd_rx_offload_get_configuration_result,
15347 		 port_id, RTE_UINT16);
15348 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15349 	TOKEN_STRING_INITIALIZER
15350 		(struct cmd_rx_offload_get_configuration_result,
15351 		 rx_offload, "rx_offload");
15352 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15353 	TOKEN_STRING_INITIALIZER
15354 		(struct cmd_rx_offload_get_configuration_result,
15355 		 configuration, "configuration");
15356 
15357 static void
15358 cmd_rx_offload_get_configuration_parsed(
15359 	void *parsed_result,
15360 	__rte_unused struct cmdline *cl,
15361 	__rte_unused void *data)
15362 {
15363 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15364 	struct rte_eth_dev_info dev_info;
15365 	portid_t port_id = res->port_id;
15366 	struct rte_port *port = &ports[port_id];
15367 	uint64_t port_offloads;
15368 	uint64_t queue_offloads;
15369 	uint16_t nb_rx_queues;
15370 	int q;
15371 	int ret;
15372 
15373 	printf("Rx Offloading Configuration of port %d :\n", port_id);
15374 
15375 	port_offloads = port->dev_conf.rxmode.offloads;
15376 	printf("  Port :");
15377 	print_rx_offloads(port_offloads);
15378 	printf("\n");
15379 
15380 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15381 	if (ret != 0)
15382 		return;
15383 
15384 	nb_rx_queues = dev_info.nb_rx_queues;
15385 	for (q = 0; q < nb_rx_queues; q++) {
15386 		queue_offloads = port->rx_conf[q].offloads;
15387 		printf("  Queue[%2d] :", q);
15388 		print_rx_offloads(queue_offloads);
15389 		printf("\n");
15390 	}
15391 	printf("\n");
15392 }
15393 
15394 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15395 	.f = cmd_rx_offload_get_configuration_parsed,
15396 	.data = NULL,
15397 	.help_str = "show port <port_id> rx_offload configuration",
15398 	.tokens = {
15399 		(void *)&cmd_rx_offload_get_configuration_show,
15400 		(void *)&cmd_rx_offload_get_configuration_port,
15401 		(void *)&cmd_rx_offload_get_configuration_port_id,
15402 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
15403 		(void *)&cmd_rx_offload_get_configuration_configuration,
15404 		NULL,
15405 	}
15406 };
15407 
15408 /* Enable/Disable a per port offloading */
15409 struct cmd_config_per_port_rx_offload_result {
15410 	cmdline_fixed_string_t port;
15411 	cmdline_fixed_string_t config;
15412 	portid_t port_id;
15413 	cmdline_fixed_string_t rx_offload;
15414 	cmdline_fixed_string_t offload;
15415 	cmdline_fixed_string_t on_off;
15416 };
15417 
15418 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15419 	TOKEN_STRING_INITIALIZER
15420 		(struct cmd_config_per_port_rx_offload_result,
15421 		 port, "port");
15422 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15423 	TOKEN_STRING_INITIALIZER
15424 		(struct cmd_config_per_port_rx_offload_result,
15425 		 config, "config");
15426 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15427 	TOKEN_NUM_INITIALIZER
15428 		(struct cmd_config_per_port_rx_offload_result,
15429 		 port_id, RTE_UINT16);
15430 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15431 	TOKEN_STRING_INITIALIZER
15432 		(struct cmd_config_per_port_rx_offload_result,
15433 		 rx_offload, "rx_offload");
15434 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15435 	TOKEN_STRING_INITIALIZER
15436 		(struct cmd_config_per_port_rx_offload_result,
15437 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15438 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15439 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15440 			   "scatter#buffer_split#timestamp#security#"
15441 			   "keep_crc#rss_hash");
15442 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15443 	TOKEN_STRING_INITIALIZER
15444 		(struct cmd_config_per_port_rx_offload_result,
15445 		 on_off, "on#off");
15446 
15447 static uint64_t
15448 search_rx_offload(const char *name)
15449 {
15450 	uint64_t single_offload;
15451 	const char *single_name;
15452 	int found = 0;
15453 	unsigned int bit;
15454 
15455 	single_offload = 1;
15456 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15457 		single_name = rte_eth_dev_rx_offload_name(single_offload);
15458 		if (!strcasecmp(single_name, name)) {
15459 			found = 1;
15460 			break;
15461 		}
15462 		single_offload <<= 1;
15463 	}
15464 
15465 	if (found)
15466 		return single_offload;
15467 
15468 	return 0;
15469 }
15470 
15471 static void
15472 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15473 				__rte_unused struct cmdline *cl,
15474 				__rte_unused void *data)
15475 {
15476 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15477 	portid_t port_id = res->port_id;
15478 	struct rte_eth_dev_info dev_info;
15479 	struct rte_port *port = &ports[port_id];
15480 	uint64_t single_offload;
15481 	uint16_t nb_rx_queues;
15482 	int q;
15483 	int ret;
15484 
15485 	if (port->port_status != RTE_PORT_STOPPED) {
15486 		printf("Error: Can't config offload when Port %d "
15487 		       "is not stopped\n", port_id);
15488 		return;
15489 	}
15490 
15491 	single_offload = search_rx_offload(res->offload);
15492 	if (single_offload == 0) {
15493 		printf("Unknown offload name: %s\n", res->offload);
15494 		return;
15495 	}
15496 
15497 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15498 	if (ret != 0)
15499 		return;
15500 
15501 	nb_rx_queues = dev_info.nb_rx_queues;
15502 	if (!strcmp(res->on_off, "on")) {
15503 		port->dev_conf.rxmode.offloads |= single_offload;
15504 		for (q = 0; q < nb_rx_queues; q++)
15505 			port->rx_conf[q].offloads |= single_offload;
15506 	} else {
15507 		port->dev_conf.rxmode.offloads &= ~single_offload;
15508 		for (q = 0; q < nb_rx_queues; q++)
15509 			port->rx_conf[q].offloads &= ~single_offload;
15510 	}
15511 
15512 	cmd_reconfig_device_queue(port_id, 1, 1);
15513 }
15514 
15515 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15516 	.f = cmd_config_per_port_rx_offload_parsed,
15517 	.data = NULL,
15518 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15519 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15520 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
15521 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
15522 		    "keep_crc|rss_hash on|off",
15523 	.tokens = {
15524 		(void *)&cmd_config_per_port_rx_offload_result_port,
15525 		(void *)&cmd_config_per_port_rx_offload_result_config,
15526 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
15527 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15528 		(void *)&cmd_config_per_port_rx_offload_result_offload,
15529 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
15530 		NULL,
15531 	}
15532 };
15533 
15534 /* Enable/Disable a per queue offloading */
15535 struct cmd_config_per_queue_rx_offload_result {
15536 	cmdline_fixed_string_t port;
15537 	portid_t port_id;
15538 	cmdline_fixed_string_t rxq;
15539 	uint16_t queue_id;
15540 	cmdline_fixed_string_t rx_offload;
15541 	cmdline_fixed_string_t offload;
15542 	cmdline_fixed_string_t on_off;
15543 };
15544 
15545 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15546 	TOKEN_STRING_INITIALIZER
15547 		(struct cmd_config_per_queue_rx_offload_result,
15548 		 port, "port");
15549 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15550 	TOKEN_NUM_INITIALIZER
15551 		(struct cmd_config_per_queue_rx_offload_result,
15552 		 port_id, RTE_UINT16);
15553 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15554 	TOKEN_STRING_INITIALIZER
15555 		(struct cmd_config_per_queue_rx_offload_result,
15556 		 rxq, "rxq");
15557 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15558 	TOKEN_NUM_INITIALIZER
15559 		(struct cmd_config_per_queue_rx_offload_result,
15560 		 queue_id, RTE_UINT16);
15561 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15562 	TOKEN_STRING_INITIALIZER
15563 		(struct cmd_config_per_queue_rx_offload_result,
15564 		 rx_offload, "rx_offload");
15565 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15566 	TOKEN_STRING_INITIALIZER
15567 		(struct cmd_config_per_queue_rx_offload_result,
15568 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15569 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15570 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15571 			   "scatter#buffer_split#timestamp#security#keep_crc");
15572 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15573 	TOKEN_STRING_INITIALIZER
15574 		(struct cmd_config_per_queue_rx_offload_result,
15575 		 on_off, "on#off");
15576 
15577 static void
15578 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15579 				__rte_unused struct cmdline *cl,
15580 				__rte_unused void *data)
15581 {
15582 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15583 	struct rte_eth_dev_info dev_info;
15584 	portid_t port_id = res->port_id;
15585 	uint16_t queue_id = res->queue_id;
15586 	struct rte_port *port = &ports[port_id];
15587 	uint64_t single_offload;
15588 	int ret;
15589 
15590 	if (port->port_status != RTE_PORT_STOPPED) {
15591 		printf("Error: Can't config offload when Port %d "
15592 		       "is not stopped\n", port_id);
15593 		return;
15594 	}
15595 
15596 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15597 	if (ret != 0)
15598 		return;
15599 
15600 	if (queue_id >= dev_info.nb_rx_queues) {
15601 		printf("Error: input queue_id should be 0 ... "
15602 		       "%d\n", dev_info.nb_rx_queues - 1);
15603 		return;
15604 	}
15605 
15606 	single_offload = search_rx_offload(res->offload);
15607 	if (single_offload == 0) {
15608 		printf("Unknown offload name: %s\n", res->offload);
15609 		return;
15610 	}
15611 
15612 	if (!strcmp(res->on_off, "on"))
15613 		port->rx_conf[queue_id].offloads |= single_offload;
15614 	else
15615 		port->rx_conf[queue_id].offloads &= ~single_offload;
15616 
15617 	cmd_reconfig_device_queue(port_id, 1, 1);
15618 }
15619 
15620 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15621 	.f = cmd_config_per_queue_rx_offload_parsed,
15622 	.data = NULL,
15623 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
15624 		    "vlan_strip|ipv4_cksum|"
15625 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15626 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
15627 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
15628 		    "keep_crc on|off",
15629 	.tokens = {
15630 		(void *)&cmd_config_per_queue_rx_offload_result_port,
15631 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
15632 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
15633 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
15634 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
15635 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
15636 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
15637 		NULL,
15638 	}
15639 };
15640 
15641 /* Get Tx offloads capabilities */
15642 struct cmd_tx_offload_get_capa_result {
15643 	cmdline_fixed_string_t show;
15644 	cmdline_fixed_string_t port;
15645 	portid_t port_id;
15646 	cmdline_fixed_string_t tx_offload;
15647 	cmdline_fixed_string_t capabilities;
15648 };
15649 
15650 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
15651 	TOKEN_STRING_INITIALIZER
15652 		(struct cmd_tx_offload_get_capa_result,
15653 		 show, "show");
15654 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
15655 	TOKEN_STRING_INITIALIZER
15656 		(struct cmd_tx_offload_get_capa_result,
15657 		 port, "port");
15658 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
15659 	TOKEN_NUM_INITIALIZER
15660 		(struct cmd_tx_offload_get_capa_result,
15661 		 port_id, RTE_UINT16);
15662 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
15663 	TOKEN_STRING_INITIALIZER
15664 		(struct cmd_tx_offload_get_capa_result,
15665 		 tx_offload, "tx_offload");
15666 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
15667 	TOKEN_STRING_INITIALIZER
15668 		(struct cmd_tx_offload_get_capa_result,
15669 		 capabilities, "capabilities");
15670 
15671 static void
15672 print_tx_offloads(uint64_t offloads)
15673 {
15674 	uint64_t single_offload;
15675 	int begin;
15676 	int end;
15677 	int bit;
15678 
15679 	if (offloads == 0)
15680 		return;
15681 
15682 	begin = __builtin_ctzll(offloads);
15683 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15684 
15685 	single_offload = 1ULL << begin;
15686 	for (bit = begin; bit < end; bit++) {
15687 		if (offloads & single_offload)
15688 			printf(" %s",
15689 			       rte_eth_dev_tx_offload_name(single_offload));
15690 		single_offload <<= 1;
15691 	}
15692 }
15693 
15694 static void
15695 cmd_tx_offload_get_capa_parsed(
15696 	void *parsed_result,
15697 	__rte_unused struct cmdline *cl,
15698 	__rte_unused void *data)
15699 {
15700 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
15701 	struct rte_eth_dev_info dev_info;
15702 	portid_t port_id = res->port_id;
15703 	uint64_t queue_offloads;
15704 	uint64_t port_offloads;
15705 	int ret;
15706 
15707 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15708 	if (ret != 0)
15709 		return;
15710 
15711 	queue_offloads = dev_info.tx_queue_offload_capa;
15712 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
15713 
15714 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
15715 	printf("  Per Queue :");
15716 	print_tx_offloads(queue_offloads);
15717 
15718 	printf("\n");
15719 	printf("  Per Port  :");
15720 	print_tx_offloads(port_offloads);
15721 	printf("\n\n");
15722 }
15723 
15724 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
15725 	.f = cmd_tx_offload_get_capa_parsed,
15726 	.data = NULL,
15727 	.help_str = "show port <port_id> tx_offload capabilities",
15728 	.tokens = {
15729 		(void *)&cmd_tx_offload_get_capa_show,
15730 		(void *)&cmd_tx_offload_get_capa_port,
15731 		(void *)&cmd_tx_offload_get_capa_port_id,
15732 		(void *)&cmd_tx_offload_get_capa_tx_offload,
15733 		(void *)&cmd_tx_offload_get_capa_capabilities,
15734 		NULL,
15735 	}
15736 };
15737 
15738 /* Get Tx offloads configuration */
15739 struct cmd_tx_offload_get_configuration_result {
15740 	cmdline_fixed_string_t show;
15741 	cmdline_fixed_string_t port;
15742 	portid_t port_id;
15743 	cmdline_fixed_string_t tx_offload;
15744 	cmdline_fixed_string_t configuration;
15745 };
15746 
15747 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
15748 	TOKEN_STRING_INITIALIZER
15749 		(struct cmd_tx_offload_get_configuration_result,
15750 		 show, "show");
15751 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
15752 	TOKEN_STRING_INITIALIZER
15753 		(struct cmd_tx_offload_get_configuration_result,
15754 		 port, "port");
15755 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
15756 	TOKEN_NUM_INITIALIZER
15757 		(struct cmd_tx_offload_get_configuration_result,
15758 		 port_id, RTE_UINT16);
15759 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
15760 	TOKEN_STRING_INITIALIZER
15761 		(struct cmd_tx_offload_get_configuration_result,
15762 		 tx_offload, "tx_offload");
15763 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
15764 	TOKEN_STRING_INITIALIZER
15765 		(struct cmd_tx_offload_get_configuration_result,
15766 		 configuration, "configuration");
15767 
15768 static void
15769 cmd_tx_offload_get_configuration_parsed(
15770 	void *parsed_result,
15771 	__rte_unused struct cmdline *cl,
15772 	__rte_unused void *data)
15773 {
15774 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
15775 	struct rte_eth_dev_info dev_info;
15776 	portid_t port_id = res->port_id;
15777 	struct rte_port *port = &ports[port_id];
15778 	uint64_t port_offloads;
15779 	uint64_t queue_offloads;
15780 	uint16_t nb_tx_queues;
15781 	int q;
15782 	int ret;
15783 
15784 	printf("Tx Offloading Configuration of port %d :\n", port_id);
15785 
15786 	port_offloads = port->dev_conf.txmode.offloads;
15787 	printf("  Port :");
15788 	print_tx_offloads(port_offloads);
15789 	printf("\n");
15790 
15791 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15792 	if (ret != 0)
15793 		return;
15794 
15795 	nb_tx_queues = dev_info.nb_tx_queues;
15796 	for (q = 0; q < nb_tx_queues; q++) {
15797 		queue_offloads = port->tx_conf[q].offloads;
15798 		printf("  Queue[%2d] :", q);
15799 		print_tx_offloads(queue_offloads);
15800 		printf("\n");
15801 	}
15802 	printf("\n");
15803 }
15804 
15805 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
15806 	.f = cmd_tx_offload_get_configuration_parsed,
15807 	.data = NULL,
15808 	.help_str = "show port <port_id> tx_offload configuration",
15809 	.tokens = {
15810 		(void *)&cmd_tx_offload_get_configuration_show,
15811 		(void *)&cmd_tx_offload_get_configuration_port,
15812 		(void *)&cmd_tx_offload_get_configuration_port_id,
15813 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
15814 		(void *)&cmd_tx_offload_get_configuration_configuration,
15815 		NULL,
15816 	}
15817 };
15818 
15819 /* Enable/Disable a per port offloading */
15820 struct cmd_config_per_port_tx_offload_result {
15821 	cmdline_fixed_string_t port;
15822 	cmdline_fixed_string_t config;
15823 	portid_t port_id;
15824 	cmdline_fixed_string_t tx_offload;
15825 	cmdline_fixed_string_t offload;
15826 	cmdline_fixed_string_t on_off;
15827 };
15828 
15829 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
15830 	TOKEN_STRING_INITIALIZER
15831 		(struct cmd_config_per_port_tx_offload_result,
15832 		 port, "port");
15833 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
15834 	TOKEN_STRING_INITIALIZER
15835 		(struct cmd_config_per_port_tx_offload_result,
15836 		 config, "config");
15837 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
15838 	TOKEN_NUM_INITIALIZER
15839 		(struct cmd_config_per_port_tx_offload_result,
15840 		 port_id, RTE_UINT16);
15841 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
15842 	TOKEN_STRING_INITIALIZER
15843 		(struct cmd_config_per_port_tx_offload_result,
15844 		 tx_offload, "tx_offload");
15845 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
15846 	TOKEN_STRING_INITIALIZER
15847 		(struct cmd_config_per_port_tx_offload_result,
15848 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15849 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15850 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15851 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15852 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
15853 			  "send_on_timestamp");
15854 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
15855 	TOKEN_STRING_INITIALIZER
15856 		(struct cmd_config_per_port_tx_offload_result,
15857 		 on_off, "on#off");
15858 
15859 static uint64_t
15860 search_tx_offload(const char *name)
15861 {
15862 	uint64_t single_offload;
15863 	const char *single_name;
15864 	int found = 0;
15865 	unsigned int bit;
15866 
15867 	single_offload = 1;
15868 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15869 		single_name = rte_eth_dev_tx_offload_name(single_offload);
15870 		if (single_name == NULL)
15871 			break;
15872 		if (!strcasecmp(single_name, name)) {
15873 			found = 1;
15874 			break;
15875 		} else if (!strcasecmp(single_name, "UNKNOWN"))
15876 			break;
15877 		single_offload <<= 1;
15878 	}
15879 
15880 	if (found)
15881 		return single_offload;
15882 
15883 	return 0;
15884 }
15885 
15886 static void
15887 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
15888 				__rte_unused struct cmdline *cl,
15889 				__rte_unused void *data)
15890 {
15891 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
15892 	portid_t port_id = res->port_id;
15893 	struct rte_eth_dev_info dev_info;
15894 	struct rte_port *port = &ports[port_id];
15895 	uint64_t single_offload;
15896 	uint16_t nb_tx_queues;
15897 	int q;
15898 	int ret;
15899 
15900 	if (port->port_status != RTE_PORT_STOPPED) {
15901 		printf("Error: Can't config offload when Port %d "
15902 		       "is not stopped\n", port_id);
15903 		return;
15904 	}
15905 
15906 	single_offload = search_tx_offload(res->offload);
15907 	if (single_offload == 0) {
15908 		printf("Unknown offload name: %s\n", res->offload);
15909 		return;
15910 	}
15911 
15912 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15913 	if (ret != 0)
15914 		return;
15915 
15916 	nb_tx_queues = dev_info.nb_tx_queues;
15917 	if (!strcmp(res->on_off, "on")) {
15918 		port->dev_conf.txmode.offloads |= single_offload;
15919 		for (q = 0; q < nb_tx_queues; q++)
15920 			port->tx_conf[q].offloads |= single_offload;
15921 	} else {
15922 		port->dev_conf.txmode.offloads &= ~single_offload;
15923 		for (q = 0; q < nb_tx_queues; q++)
15924 			port->tx_conf[q].offloads &= ~single_offload;
15925 	}
15926 
15927 	cmd_reconfig_device_queue(port_id, 1, 1);
15928 }
15929 
15930 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
15931 	.f = cmd_config_per_port_tx_offload_parsed,
15932 	.data = NULL,
15933 	.help_str = "port config <port_id> tx_offload "
15934 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
15935 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
15936 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
15937 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
15938 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
15939 		    "send_on_timestamp on|off",
15940 	.tokens = {
15941 		(void *)&cmd_config_per_port_tx_offload_result_port,
15942 		(void *)&cmd_config_per_port_tx_offload_result_config,
15943 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
15944 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
15945 		(void *)&cmd_config_per_port_tx_offload_result_offload,
15946 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
15947 		NULL,
15948 	}
15949 };
15950 
15951 /* Enable/Disable a per queue offloading */
15952 struct cmd_config_per_queue_tx_offload_result {
15953 	cmdline_fixed_string_t port;
15954 	portid_t port_id;
15955 	cmdline_fixed_string_t txq;
15956 	uint16_t queue_id;
15957 	cmdline_fixed_string_t tx_offload;
15958 	cmdline_fixed_string_t offload;
15959 	cmdline_fixed_string_t on_off;
15960 };
15961 
15962 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
15963 	TOKEN_STRING_INITIALIZER
15964 		(struct cmd_config_per_queue_tx_offload_result,
15965 		 port, "port");
15966 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
15967 	TOKEN_NUM_INITIALIZER
15968 		(struct cmd_config_per_queue_tx_offload_result,
15969 		 port_id, RTE_UINT16);
15970 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
15971 	TOKEN_STRING_INITIALIZER
15972 		(struct cmd_config_per_queue_tx_offload_result,
15973 		 txq, "txq");
15974 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
15975 	TOKEN_NUM_INITIALIZER
15976 		(struct cmd_config_per_queue_tx_offload_result,
15977 		 queue_id, RTE_UINT16);
15978 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
15979 	TOKEN_STRING_INITIALIZER
15980 		(struct cmd_config_per_queue_tx_offload_result,
15981 		 tx_offload, "tx_offload");
15982 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
15983 	TOKEN_STRING_INITIALIZER
15984 		(struct cmd_config_per_queue_tx_offload_result,
15985 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15986 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15987 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15988 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15989 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
15990 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
15991 	TOKEN_STRING_INITIALIZER
15992 		(struct cmd_config_per_queue_tx_offload_result,
15993 		 on_off, "on#off");
15994 
15995 static void
15996 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
15997 				__rte_unused struct cmdline *cl,
15998 				__rte_unused void *data)
15999 {
16000 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16001 	struct rte_eth_dev_info dev_info;
16002 	portid_t port_id = res->port_id;
16003 	uint16_t queue_id = res->queue_id;
16004 	struct rte_port *port = &ports[port_id];
16005 	uint64_t single_offload;
16006 	int ret;
16007 
16008 	if (port->port_status != RTE_PORT_STOPPED) {
16009 		printf("Error: Can't config offload when Port %d "
16010 		       "is not stopped\n", port_id);
16011 		return;
16012 	}
16013 
16014 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16015 	if (ret != 0)
16016 		return;
16017 
16018 	if (queue_id >= dev_info.nb_tx_queues) {
16019 		printf("Error: input queue_id should be 0 ... "
16020 		       "%d\n", dev_info.nb_tx_queues - 1);
16021 		return;
16022 	}
16023 
16024 	single_offload = search_tx_offload(res->offload);
16025 	if (single_offload == 0) {
16026 		printf("Unknown offload name: %s\n", res->offload);
16027 		return;
16028 	}
16029 
16030 	if (!strcmp(res->on_off, "on"))
16031 		port->tx_conf[queue_id].offloads |= single_offload;
16032 	else
16033 		port->tx_conf[queue_id].offloads &= ~single_offload;
16034 
16035 	cmd_reconfig_device_queue(port_id, 1, 1);
16036 }
16037 
16038 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16039 	.f = cmd_config_per_queue_tx_offload_parsed,
16040 	.data = NULL,
16041 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16042 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16043 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16044 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16045 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16046 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16047 		    "on|off",
16048 	.tokens = {
16049 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16050 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16051 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16052 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16053 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16054 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16055 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16056 		NULL,
16057 	}
16058 };
16059 
16060 /* *** configure tx_metadata for specific port *** */
16061 struct cmd_config_tx_metadata_specific_result {
16062 	cmdline_fixed_string_t port;
16063 	cmdline_fixed_string_t keyword;
16064 	uint16_t port_id;
16065 	cmdline_fixed_string_t item;
16066 	uint32_t value;
16067 };
16068 
16069 static void
16070 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16071 				__rte_unused struct cmdline *cl,
16072 				__rte_unused void *data)
16073 {
16074 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16075 
16076 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16077 		return;
16078 	ports[res->port_id].tx_metadata = res->value;
16079 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16080 	if (ports[res->port_id].tx_metadata)
16081 		add_tx_md_callback(res->port_id);
16082 	else
16083 		remove_tx_md_callback(res->port_id);
16084 	rte_flow_dynf_metadata_register();
16085 }
16086 
16087 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16088 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16089 			port, "port");
16090 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16091 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16092 			keyword, "config");
16093 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16094 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16095 			port_id, RTE_UINT16);
16096 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16097 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16098 			item, "tx_metadata");
16099 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16100 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16101 			value, RTE_UINT32);
16102 
16103 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16104 	.f = cmd_config_tx_metadata_specific_parsed,
16105 	.data = NULL,
16106 	.help_str = "port config <port_id> tx_metadata <value>",
16107 	.tokens = {
16108 		(void *)&cmd_config_tx_metadata_specific_port,
16109 		(void *)&cmd_config_tx_metadata_specific_keyword,
16110 		(void *)&cmd_config_tx_metadata_specific_id,
16111 		(void *)&cmd_config_tx_metadata_specific_item,
16112 		(void *)&cmd_config_tx_metadata_specific_value,
16113 		NULL,
16114 	},
16115 };
16116 
16117 /* *** set dynf *** */
16118 struct cmd_config_tx_dynf_specific_result {
16119 	cmdline_fixed_string_t port;
16120 	cmdline_fixed_string_t keyword;
16121 	uint16_t port_id;
16122 	cmdline_fixed_string_t item;
16123 	cmdline_fixed_string_t name;
16124 	cmdline_fixed_string_t value;
16125 };
16126 
16127 static void
16128 cmd_config_dynf_specific_parsed(void *parsed_result,
16129 				__rte_unused struct cmdline *cl,
16130 				__rte_unused void *data)
16131 {
16132 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16133 	struct rte_mbuf_dynflag desc_flag;
16134 	int flag;
16135 	uint64_t old_port_flags;
16136 
16137 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16138 		return;
16139 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16140 	if (flag <= 0) {
16141 		if (strlcpy(desc_flag.name, res->name,
16142 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16143 			printf("Flag name too long\n");
16144 			return;
16145 		}
16146 		desc_flag.flags = 0;
16147 		flag = rte_mbuf_dynflag_register(&desc_flag);
16148 		if (flag < 0) {
16149 			printf("Can't register flag\n");
16150 			return;
16151 		}
16152 		strcpy(dynf_names[flag], desc_flag.name);
16153 	}
16154 	old_port_flags = ports[res->port_id].mbuf_dynf;
16155 	if (!strcmp(res->value, "set")) {
16156 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16157 		if (old_port_flags == 0)
16158 			add_tx_dynf_callback(res->port_id);
16159 	} else {
16160 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16161 		if (ports[res->port_id].mbuf_dynf == 0)
16162 			remove_tx_dynf_callback(res->port_id);
16163 	}
16164 }
16165 
16166 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16167 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16168 			keyword, "port");
16169 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16170 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16171 			keyword, "config");
16172 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16173 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16174 			port_id, RTE_UINT16);
16175 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16176 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16177 			item, "dynf");
16178 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16179 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16180 			name, NULL);
16181 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16182 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16183 			value, "set#clear");
16184 
16185 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16186 	.f = cmd_config_dynf_specific_parsed,
16187 	.data = NULL,
16188 	.help_str = "port config <port id> dynf <name> set|clear",
16189 	.tokens = {
16190 		(void *)&cmd_config_tx_dynf_specific_port,
16191 		(void *)&cmd_config_tx_dynf_specific_keyword,
16192 		(void *)&cmd_config_tx_dynf_specific_port_id,
16193 		(void *)&cmd_config_tx_dynf_specific_item,
16194 		(void *)&cmd_config_tx_dynf_specific_name,
16195 		(void *)&cmd_config_tx_dynf_specific_value,
16196 		NULL,
16197 	},
16198 };
16199 
16200 /* *** display tx_metadata per port configuration *** */
16201 struct cmd_show_tx_metadata_result {
16202 	cmdline_fixed_string_t cmd_show;
16203 	cmdline_fixed_string_t cmd_port;
16204 	cmdline_fixed_string_t cmd_keyword;
16205 	portid_t cmd_pid;
16206 };
16207 
16208 static void
16209 cmd_show_tx_metadata_parsed(void *parsed_result,
16210 		__rte_unused struct cmdline *cl,
16211 		__rte_unused void *data)
16212 {
16213 	struct cmd_show_tx_metadata_result *res = parsed_result;
16214 
16215 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16216 		printf("invalid port id %u\n", res->cmd_pid);
16217 		return;
16218 	}
16219 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16220 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16221 		       ports[res->cmd_pid].tx_metadata);
16222 	}
16223 }
16224 
16225 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16226 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16227 			cmd_show, "show");
16228 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16229 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16230 			cmd_port, "port");
16231 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16232 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16233 			cmd_pid, RTE_UINT16);
16234 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16235 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16236 			cmd_keyword, "tx_metadata");
16237 
16238 cmdline_parse_inst_t cmd_show_tx_metadata = {
16239 	.f = cmd_show_tx_metadata_parsed,
16240 	.data = NULL,
16241 	.help_str = "show port <port_id> tx_metadata",
16242 	.tokens = {
16243 		(void *)&cmd_show_tx_metadata_show,
16244 		(void *)&cmd_show_tx_metadata_port,
16245 		(void *)&cmd_show_tx_metadata_pid,
16246 		(void *)&cmd_show_tx_metadata_keyword,
16247 		NULL,
16248 	},
16249 };
16250 
16251 /* *** show fec capability per port configuration *** */
16252 struct cmd_show_fec_capability_result {
16253 	cmdline_fixed_string_t cmd_show;
16254 	cmdline_fixed_string_t cmd_port;
16255 	cmdline_fixed_string_t cmd_fec;
16256 	cmdline_fixed_string_t cmd_keyword;
16257 	portid_t cmd_pid;
16258 };
16259 
16260 static void
16261 cmd_show_fec_capability_parsed(void *parsed_result,
16262 		__rte_unused struct cmdline *cl,
16263 		__rte_unused void *data)
16264 {
16265 	struct cmd_show_fec_capability_result *res = parsed_result;
16266 	struct rte_eth_fec_capa *speed_fec_capa;
16267 	unsigned int num;
16268 	int ret;
16269 
16270 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16271 		printf("Invalid port id %u\n", res->cmd_pid);
16272 		return;
16273 	}
16274 
16275 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16276 	if (ret == -ENOTSUP) {
16277 		printf("Function not implemented\n");
16278 		return;
16279 	} else if (ret < 0) {
16280 		printf("Get FEC capability failed: %d\n", ret);
16281 		return;
16282 	}
16283 
16284 	num = (unsigned int)ret;
16285 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16286 	if (speed_fec_capa == NULL) {
16287 		printf("Failed to alloc FEC capability buffer\n");
16288 		return;
16289 	}
16290 
16291 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16292 	if (ret < 0) {
16293 		printf("Error getting FEC capability: %d\n", ret);
16294 		goto out;
16295 	}
16296 
16297 	show_fec_capability(num, speed_fec_capa);
16298 out:
16299 	free(speed_fec_capa);
16300 }
16301 
16302 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16303 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16304 			cmd_show, "show");
16305 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16306 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16307 			cmd_port, "port");
16308 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16309 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16310 			cmd_pid, RTE_UINT16);
16311 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16312 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16313 			cmd_fec, "fec");
16314 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16315 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16316 			cmd_keyword, "capabilities");
16317 
16318 cmdline_parse_inst_t cmd_show_capability = {
16319 	.f = cmd_show_fec_capability_parsed,
16320 	.data = NULL,
16321 	.help_str = "show port <port_id> fec capabilities",
16322 	.tokens = {
16323 		(void *)&cmd_show_fec_capability_show,
16324 		(void *)&cmd_show_fec_capability_port,
16325 		(void *)&cmd_show_fec_capability_pid,
16326 		(void *)&cmd_show_fec_capability_fec,
16327 		(void *)&cmd_show_fec_capability_keyword,
16328 		NULL,
16329 	},
16330 };
16331 
16332 /* *** show fec mode per port configuration *** */
16333 struct cmd_show_fec_metadata_result {
16334 	cmdline_fixed_string_t cmd_show;
16335 	cmdline_fixed_string_t cmd_port;
16336 	cmdline_fixed_string_t cmd_keyword;
16337 	portid_t cmd_pid;
16338 };
16339 
16340 static void
16341 cmd_show_fec_mode_parsed(void *parsed_result,
16342 		__rte_unused struct cmdline *cl,
16343 		__rte_unused void *data)
16344 {
16345 #define FEC_NAME_SIZE 16
16346 	struct cmd_show_fec_metadata_result *res = parsed_result;
16347 	uint32_t mode;
16348 	char buf[FEC_NAME_SIZE];
16349 	int ret;
16350 
16351 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16352 		printf("Invalid port id %u\n", res->cmd_pid);
16353 		return;
16354 	}
16355 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
16356 	if (ret == -ENOTSUP) {
16357 		printf("Function not implemented\n");
16358 		return;
16359 	} else if (ret < 0) {
16360 		printf("Get FEC mode failed\n");
16361 		return;
16362 	}
16363 
16364 	switch (mode) {
16365 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16366 		strlcpy(buf, "off", sizeof(buf));
16367 		break;
16368 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16369 		strlcpy(buf, "auto", sizeof(buf));
16370 		break;
16371 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16372 		strlcpy(buf, "baser", sizeof(buf));
16373 		break;
16374 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16375 		strlcpy(buf, "rs", sizeof(buf));
16376 		break;
16377 	default:
16378 		return;
16379 	}
16380 
16381 	printf("%s\n", buf);
16382 }
16383 
16384 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16385 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16386 			cmd_show, "show");
16387 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16388 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16389 			cmd_port, "port");
16390 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16391 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16392 			cmd_pid, RTE_UINT16);
16393 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16394 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16395 			cmd_keyword, "fec_mode");
16396 
16397 cmdline_parse_inst_t cmd_show_fec_mode = {
16398 	.f = cmd_show_fec_mode_parsed,
16399 	.data = NULL,
16400 	.help_str = "show port <port_id> fec_mode",
16401 	.tokens = {
16402 		(void *)&cmd_show_fec_mode_show,
16403 		(void *)&cmd_show_fec_mode_port,
16404 		(void *)&cmd_show_fec_mode_pid,
16405 		(void *)&cmd_show_fec_mode_keyword,
16406 		NULL,
16407 	},
16408 };
16409 
16410 /* *** set fec mode per port configuration *** */
16411 struct cmd_set_port_fec_mode {
16412 	cmdline_fixed_string_t set;
16413 	cmdline_fixed_string_t port;
16414 	portid_t port_id;
16415 	cmdline_fixed_string_t fec_mode;
16416 	cmdline_fixed_string_t fec_value;
16417 };
16418 
16419 /* Common CLI fields for set fec mode */
16420 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16421 	TOKEN_STRING_INITIALIZER
16422 		(struct cmd_set_port_fec_mode,
16423 		 set, "set");
16424 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16425 	TOKEN_STRING_INITIALIZER
16426 		(struct cmd_set_port_fec_mode,
16427 		 port, "port");
16428 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16429 	TOKEN_NUM_INITIALIZER
16430 		(struct cmd_set_port_fec_mode,
16431 		 port_id, RTE_UINT16);
16432 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16433 	TOKEN_STRING_INITIALIZER
16434 		(struct cmd_set_port_fec_mode,
16435 		 fec_mode, "fec_mode");
16436 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16437 	TOKEN_STRING_INITIALIZER
16438 		(struct cmd_set_port_fec_mode,
16439 		 fec_value, NULL);
16440 
16441 static void
16442 cmd_set_port_fec_mode_parsed(
16443 	void *parsed_result,
16444 	__rte_unused struct cmdline *cl,
16445 	__rte_unused void *data)
16446 {
16447 	struct cmd_set_port_fec_mode *res = parsed_result;
16448 	uint16_t port_id = res->port_id;
16449 	uint32_t mode;
16450 	int ret;
16451 
16452 	ret = parse_fec_mode(res->fec_value, &mode);
16453 	if (ret < 0) {
16454 		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16455 			port_id);
16456 		return;
16457 	}
16458 
16459 	ret = rte_eth_fec_set(port_id, mode);
16460 	if (ret == -ENOTSUP) {
16461 		printf("Function not implemented\n");
16462 		return;
16463 	} else if (ret < 0) {
16464 		printf("Set FEC mode failed\n");
16465 		return;
16466 	}
16467 }
16468 
16469 cmdline_parse_inst_t cmd_set_fec_mode = {
16470 	.f = cmd_set_port_fec_mode_parsed,
16471 	.data = NULL,
16472 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16473 	.tokens = {
16474 		(void *)&cmd_set_port_fec_mode_set,
16475 		(void *)&cmd_set_port_fec_mode_port,
16476 		(void *)&cmd_set_port_fec_mode_port_id,
16477 		(void *)&cmd_set_port_fec_mode_str,
16478 		(void *)&cmd_set_port_fec_mode_value,
16479 		NULL,
16480 	},
16481 };
16482 
16483 /* show port supported ptypes */
16484 
16485 /* Common result structure for show port ptypes */
16486 struct cmd_show_port_supported_ptypes_result {
16487 	cmdline_fixed_string_t show;
16488 	cmdline_fixed_string_t port;
16489 	portid_t port_id;
16490 	cmdline_fixed_string_t ptypes;
16491 };
16492 
16493 /* Common CLI fields for show port ptypes */
16494 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16495 	TOKEN_STRING_INITIALIZER
16496 		(struct cmd_show_port_supported_ptypes_result,
16497 		 show, "show");
16498 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16499 	TOKEN_STRING_INITIALIZER
16500 		(struct cmd_show_port_supported_ptypes_result,
16501 		 port, "port");
16502 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16503 	TOKEN_NUM_INITIALIZER
16504 		(struct cmd_show_port_supported_ptypes_result,
16505 		 port_id, RTE_UINT16);
16506 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16507 	TOKEN_STRING_INITIALIZER
16508 		(struct cmd_show_port_supported_ptypes_result,
16509 		 ptypes, "ptypes");
16510 
16511 static void
16512 cmd_show_port_supported_ptypes_parsed(
16513 	void *parsed_result,
16514 	__rte_unused struct cmdline *cl,
16515 	__rte_unused void *data)
16516 {
16517 #define RSVD_PTYPE_MASK       0xf0000000
16518 #define MAX_PTYPES_PER_LAYER  16
16519 #define LTYPE_NAMESIZE        32
16520 #define PTYPE_NAMESIZE        256
16521 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16522 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16523 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16524 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16525 	uint16_t port_id = res->port_id;
16526 	int ret, i;
16527 
16528 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16529 	if (ret < 0)
16530 		return;
16531 
16532 	while (ptype_mask != RSVD_PTYPE_MASK) {
16533 
16534 		switch (ptype_mask) {
16535 		case RTE_PTYPE_L2_MASK:
16536 			strlcpy(ltype, "L2", sizeof(ltype));
16537 			break;
16538 		case RTE_PTYPE_L3_MASK:
16539 			strlcpy(ltype, "L3", sizeof(ltype));
16540 			break;
16541 		case RTE_PTYPE_L4_MASK:
16542 			strlcpy(ltype, "L4", sizeof(ltype));
16543 			break;
16544 		case RTE_PTYPE_TUNNEL_MASK:
16545 			strlcpy(ltype, "Tunnel", sizeof(ltype));
16546 			break;
16547 		case RTE_PTYPE_INNER_L2_MASK:
16548 			strlcpy(ltype, "Inner L2", sizeof(ltype));
16549 			break;
16550 		case RTE_PTYPE_INNER_L3_MASK:
16551 			strlcpy(ltype, "Inner L3", sizeof(ltype));
16552 			break;
16553 		case RTE_PTYPE_INNER_L4_MASK:
16554 			strlcpy(ltype, "Inner L4", sizeof(ltype));
16555 			break;
16556 		default:
16557 			return;
16558 		}
16559 
16560 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16561 						       ptype_mask, ptypes,
16562 						       MAX_PTYPES_PER_LAYER);
16563 
16564 		if (ret > 0)
16565 			printf("Supported %s ptypes:\n", ltype);
16566 		else
16567 			printf("%s ptypes unsupported\n", ltype);
16568 
16569 		for (i = 0; i < ret; ++i) {
16570 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16571 			printf("%s\n", buf);
16572 		}
16573 
16574 		ptype_mask <<= 4;
16575 	}
16576 }
16577 
16578 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16579 	.f = cmd_show_port_supported_ptypes_parsed,
16580 	.data = NULL,
16581 	.help_str = "show port <port_id> ptypes",
16582 	.tokens = {
16583 		(void *)&cmd_show_port_supported_ptypes_show,
16584 		(void *)&cmd_show_port_supported_ptypes_port,
16585 		(void *)&cmd_show_port_supported_ptypes_port_id,
16586 		(void *)&cmd_show_port_supported_ptypes_ptypes,
16587 		NULL,
16588 	},
16589 };
16590 
16591 /* *** display rx/tx descriptor status *** */
16592 struct cmd_show_rx_tx_desc_status_result {
16593 	cmdline_fixed_string_t cmd_show;
16594 	cmdline_fixed_string_t cmd_port;
16595 	cmdline_fixed_string_t cmd_keyword;
16596 	cmdline_fixed_string_t cmd_desc;
16597 	cmdline_fixed_string_t cmd_status;
16598 	portid_t cmd_pid;
16599 	portid_t cmd_qid;
16600 	portid_t cmd_did;
16601 };
16602 
16603 static void
16604 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16605 		__rte_unused struct cmdline *cl,
16606 		__rte_unused void *data)
16607 {
16608 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16609 	int rc;
16610 
16611 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16612 		printf("invalid port id %u\n", res->cmd_pid);
16613 		return;
16614 	}
16615 
16616 	if (!strcmp(res->cmd_keyword, "rxq")) {
16617 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16618 					     res->cmd_did);
16619 		if (rc < 0) {
16620 			printf("Invalid queueid = %d\n", res->cmd_qid);
16621 			return;
16622 		}
16623 		if (rc == RTE_ETH_RX_DESC_AVAIL)
16624 			printf("Desc status = AVAILABLE\n");
16625 		else if (rc == RTE_ETH_RX_DESC_DONE)
16626 			printf("Desc status = DONE\n");
16627 		else
16628 			printf("Desc status = UNAVAILABLE\n");
16629 	} else if (!strcmp(res->cmd_keyword, "txq")) {
16630 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
16631 					     res->cmd_did);
16632 		if (rc < 0) {
16633 			printf("Invalid queueid = %d\n", res->cmd_qid);
16634 			return;
16635 		}
16636 		if (rc == RTE_ETH_TX_DESC_FULL)
16637 			printf("Desc status = FULL\n");
16638 		else if (rc == RTE_ETH_TX_DESC_DONE)
16639 			printf("Desc status = DONE\n");
16640 		else
16641 			printf("Desc status = UNAVAILABLE\n");
16642 	}
16643 }
16644 
16645 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
16646 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16647 			cmd_show, "show");
16648 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
16649 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16650 			cmd_port, "port");
16651 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
16652 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16653 			cmd_pid, RTE_UINT16);
16654 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
16655 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16656 			cmd_keyword, "rxq#txq");
16657 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
16658 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16659 			cmd_qid, RTE_UINT16);
16660 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
16661 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16662 			cmd_desc, "desc");
16663 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
16664 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16665 			cmd_did, RTE_UINT16);
16666 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
16667 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16668 			cmd_status, "status");
16669 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
16670 	.f = cmd_show_rx_tx_desc_status_parsed,
16671 	.data = NULL,
16672 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
16673 		"status",
16674 	.tokens = {
16675 		(void *)&cmd_show_rx_tx_desc_status_show,
16676 		(void *)&cmd_show_rx_tx_desc_status_port,
16677 		(void *)&cmd_show_rx_tx_desc_status_pid,
16678 		(void *)&cmd_show_rx_tx_desc_status_keyword,
16679 		(void *)&cmd_show_rx_tx_desc_status_qid,
16680 		(void *)&cmd_show_rx_tx_desc_status_desc,
16681 		(void *)&cmd_show_rx_tx_desc_status_did,
16682 		(void *)&cmd_show_rx_tx_desc_status_status,
16683 		NULL,
16684 	},
16685 };
16686 
16687 /* Common result structure for set port ptypes */
16688 struct cmd_set_port_ptypes_result {
16689 	cmdline_fixed_string_t set;
16690 	cmdline_fixed_string_t port;
16691 	portid_t port_id;
16692 	cmdline_fixed_string_t ptype_mask;
16693 	uint32_t mask;
16694 };
16695 
16696 /* Common CLI fields for set port ptypes */
16697 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
16698 	TOKEN_STRING_INITIALIZER
16699 		(struct cmd_set_port_ptypes_result,
16700 		 set, "set");
16701 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
16702 	TOKEN_STRING_INITIALIZER
16703 		(struct cmd_set_port_ptypes_result,
16704 		 port, "port");
16705 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
16706 	TOKEN_NUM_INITIALIZER
16707 		(struct cmd_set_port_ptypes_result,
16708 		 port_id, RTE_UINT16);
16709 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
16710 	TOKEN_STRING_INITIALIZER
16711 		(struct cmd_set_port_ptypes_result,
16712 		 ptype_mask, "ptype_mask");
16713 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
16714 	TOKEN_NUM_INITIALIZER
16715 		(struct cmd_set_port_ptypes_result,
16716 		 mask, RTE_UINT32);
16717 
16718 static void
16719 cmd_set_port_ptypes_parsed(
16720 	void *parsed_result,
16721 	__rte_unused struct cmdline *cl,
16722 	__rte_unused void *data)
16723 {
16724 	struct cmd_set_port_ptypes_result *res = parsed_result;
16725 #define PTYPE_NAMESIZE        256
16726 	char ptype_name[PTYPE_NAMESIZE];
16727 	uint16_t port_id = res->port_id;
16728 	uint32_t ptype_mask = res->mask;
16729 	int ret, i;
16730 
16731 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
16732 					       NULL, 0);
16733 	if (ret <= 0) {
16734 		printf("Port %d doesn't support any ptypes.\n", port_id);
16735 		return;
16736 	}
16737 
16738 	uint32_t ptypes[ret];
16739 
16740 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
16741 	if (ret < 0) {
16742 		printf("Unable to set requested ptypes for Port %d\n", port_id);
16743 		return;
16744 	}
16745 
16746 	printf("Successfully set following ptypes for Port %d\n", port_id);
16747 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
16748 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
16749 		printf("%s\n", ptype_name);
16750 	}
16751 
16752 	clear_ptypes = false;
16753 }
16754 
16755 cmdline_parse_inst_t cmd_set_port_ptypes = {
16756 	.f = cmd_set_port_ptypes_parsed,
16757 	.data = NULL,
16758 	.help_str = "set port <port_id> ptype_mask <mask>",
16759 	.tokens = {
16760 		(void *)&cmd_set_port_ptypes_set,
16761 		(void *)&cmd_set_port_ptypes_port,
16762 		(void *)&cmd_set_port_ptypes_port_id,
16763 		(void *)&cmd_set_port_ptypes_mask_str,
16764 		(void *)&cmd_set_port_ptypes_mask_u32,
16765 		NULL,
16766 	},
16767 };
16768 
16769 /* *** display mac addresses added to a port *** */
16770 struct cmd_showport_macs_result {
16771 	cmdline_fixed_string_t cmd_show;
16772 	cmdline_fixed_string_t cmd_port;
16773 	cmdline_fixed_string_t cmd_keyword;
16774 	portid_t cmd_pid;
16775 };
16776 
16777 static void
16778 cmd_showport_macs_parsed(void *parsed_result,
16779 		__rte_unused struct cmdline *cl,
16780 		__rte_unused void *data)
16781 {
16782 	struct cmd_showport_macs_result *res = parsed_result;
16783 
16784 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
16785 		return;
16786 
16787 	if (!strcmp(res->cmd_keyword, "macs"))
16788 		show_macs(res->cmd_pid);
16789 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
16790 		show_mcast_macs(res->cmd_pid);
16791 }
16792 
16793 cmdline_parse_token_string_t cmd_showport_macs_show =
16794 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16795 			cmd_show, "show");
16796 cmdline_parse_token_string_t cmd_showport_macs_port =
16797 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16798 			cmd_port, "port");
16799 cmdline_parse_token_num_t cmd_showport_macs_pid =
16800 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
16801 			cmd_pid, RTE_UINT16);
16802 cmdline_parse_token_string_t cmd_showport_macs_keyword =
16803 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16804 			cmd_keyword, "macs#mcast_macs");
16805 
16806 cmdline_parse_inst_t cmd_showport_macs = {
16807 	.f = cmd_showport_macs_parsed,
16808 	.data = NULL,
16809 	.help_str = "show port <port_id> macs|mcast_macs",
16810 	.tokens = {
16811 		(void *)&cmd_showport_macs_show,
16812 		(void *)&cmd_showport_macs_port,
16813 		(void *)&cmd_showport_macs_pid,
16814 		(void *)&cmd_showport_macs_keyword,
16815 		NULL,
16816 	},
16817 };
16818 
16819 /* ******************************************************************************** */
16820 
16821 /* list of instructions */
16822 cmdline_parse_ctx_t main_ctx[] = {
16823 	(cmdline_parse_inst_t *)&cmd_help_brief,
16824 	(cmdline_parse_inst_t *)&cmd_help_long,
16825 	(cmdline_parse_inst_t *)&cmd_quit,
16826 	(cmdline_parse_inst_t *)&cmd_load_from_file,
16827 	(cmdline_parse_inst_t *)&cmd_showport,
16828 	(cmdline_parse_inst_t *)&cmd_showqueue,
16829 	(cmdline_parse_inst_t *)&cmd_showeeprom,
16830 	(cmdline_parse_inst_t *)&cmd_showportall,
16831 	(cmdline_parse_inst_t *)&cmd_showdevice,
16832 	(cmdline_parse_inst_t *)&cmd_showcfg,
16833 	(cmdline_parse_inst_t *)&cmd_showfwdall,
16834 	(cmdline_parse_inst_t *)&cmd_start,
16835 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
16836 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16837 	(cmdline_parse_inst_t *)&cmd_set_link_up,
16838 	(cmdline_parse_inst_t *)&cmd_set_link_down,
16839 	(cmdline_parse_inst_t *)&cmd_reset,
16840 	(cmdline_parse_inst_t *)&cmd_set_numbers,
16841 	(cmdline_parse_inst_t *)&cmd_set_log,
16842 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
16843 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
16844 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
16845 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
16846 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
16847 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
16848 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16849 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16850 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16851 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16852 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16853 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16854 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16855 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16856 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
16857 	(cmdline_parse_inst_t *)&cmd_set_link_check,
16858 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16859 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
16860 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16861 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
16862 #ifdef RTE_NET_BOND
16863 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16864 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
16865 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16866 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16867 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16868 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
16869 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16870 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16871 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16872 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16873 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16874 #endif
16875 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
16876 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
16877 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16878 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16879 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16880 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16881 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16882 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16883 	(cmdline_parse_inst_t *)&cmd_csum_set,
16884 	(cmdline_parse_inst_t *)&cmd_csum_show,
16885 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
16886 	(cmdline_parse_inst_t *)&cmd_tso_set,
16887 	(cmdline_parse_inst_t *)&cmd_tso_show,
16888 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16889 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16890 	(cmdline_parse_inst_t *)&cmd_gro_enable,
16891 	(cmdline_parse_inst_t *)&cmd_gro_flush,
16892 	(cmdline_parse_inst_t *)&cmd_gro_show,
16893 	(cmdline_parse_inst_t *)&cmd_gso_enable,
16894 	(cmdline_parse_inst_t *)&cmd_gso_size,
16895 	(cmdline_parse_inst_t *)&cmd_gso_show,
16896 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16897 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16898 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16899 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16900 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16901 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16902 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16903 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16904 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16905 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16906 	(cmdline_parse_inst_t *)&cmd_config_dcb,
16907 	(cmdline_parse_inst_t *)&cmd_read_reg,
16908 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16909 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
16910 	(cmdline_parse_inst_t *)&cmd_write_reg,
16911 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16912 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
16913 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16914 	(cmdline_parse_inst_t *)&cmd_stop,
16915 	(cmdline_parse_inst_t *)&cmd_mac_addr,
16916 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16917 	(cmdline_parse_inst_t *)&cmd_set_qmap,
16918 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16919 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
16920 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
16921 	(cmdline_parse_inst_t *)&cmd_operate_port,
16922 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
16923 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
16924 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
16925 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
16926 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
16927 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
16928 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
16929 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
16930 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16931 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
16932 	(cmdline_parse_inst_t *)&cmd_config_mtu,
16933 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16934 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
16935 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16936 	(cmdline_parse_inst_t *)&cmd_config_rss,
16937 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16938 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16939 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
16940 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16941 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
16942 	(cmdline_parse_inst_t *)&cmd_showport_reta,
16943 	(cmdline_parse_inst_t *)&cmd_showport_macs,
16944 	(cmdline_parse_inst_t *)&cmd_config_burst,
16945 	(cmdline_parse_inst_t *)&cmd_config_thresh,
16946 	(cmdline_parse_inst_t *)&cmd_config_threshold,
16947 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16948 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16949 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16950 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16951 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16952 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16953 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
16954 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16955 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16956 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16957 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16958 	(cmdline_parse_inst_t *)&cmd_dump,
16959 	(cmdline_parse_inst_t *)&cmd_dump_one,
16960 #ifdef RTE_NET_I40E
16961 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16962 #endif
16963 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16964 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16965 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16966 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16967 	(cmdline_parse_inst_t *)&cmd_flow,
16968 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16969 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16970 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16971 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16972 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
16973 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
16974 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
16975 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
16976 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16977 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16978 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16979 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16980 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16981 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
16982 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16983 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16984 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16985 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16986 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16987 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16988 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16989 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16990 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16991 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16992 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16993 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16994 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16995 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16996 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16997 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16998 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16999 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17000 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17001 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17002 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
17003 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17004 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17005 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
17006 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
17007 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
17008 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17009 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17010 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
17011 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17012 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
17013 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17014 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
17015 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17016 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17017 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17018 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17019 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17020 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17021 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17022 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17023 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17024 	(cmdline_parse_inst_t *)&cmd_ddp_add,
17025 	(cmdline_parse_inst_t *)&cmd_ddp_del,
17026 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
17027 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
17028 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
17029 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
17030 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
17031 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17032 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17033 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17034 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17035 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17036 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17037 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17038 
17039 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17040 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17041 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17042 	(cmdline_parse_inst_t *)&cmd_queue_region,
17043 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
17044 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
17045 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
17046 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17047 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17048 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17049 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17050 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17051 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17052 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17053 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17054 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17055 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17056 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17057 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17058 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17059 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17060 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17061 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17062 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17063 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17064 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17065 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17066 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17067 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17068 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17069 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17070 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17071 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17072 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17073 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17074 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17075 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17076 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17077 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17078 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17079 #ifdef RTE_LIB_BPF
17080 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17081 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17082 #endif
17083 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17084 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17085 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17086 	(cmdline_parse_inst_t *)&cmd_set_raw,
17087 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
17088 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17089 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17090 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
17091 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
17092 	(cmdline_parse_inst_t *)&cmd_show_capability,
17093 	NULL,
17094 };
17095 
17096 /* read cmdline commands from file */
17097 void
17098 cmdline_read_from_file(const char *filename)
17099 {
17100 	struct cmdline *cl;
17101 
17102 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17103 	if (cl == NULL) {
17104 		printf("Failed to create file based cmdline context: %s\n",
17105 		       filename);
17106 		return;
17107 	}
17108 
17109 	cmdline_interact(cl);
17110 	cmdline_quit(cl);
17111 
17112 	cmdline_free(cl);
17113 
17114 	printf("Read CLI commands from %s\n", filename);
17115 }
17116 
17117 /* prompt function, called from main on MAIN lcore */
17118 void
17119 prompt(void)
17120 {
17121 	/* initialize non-constant commands */
17122 	cmd_set_fwd_mode_init();
17123 	cmd_set_fwd_retry_mode_init();
17124 
17125 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17126 	if (testpmd_cl == NULL)
17127 		return;
17128 	cmdline_interact(testpmd_cl);
17129 	cmdline_stdin_exit(testpmd_cl);
17130 }
17131 
17132 void
17133 prompt_exit(void)
17134 {
17135 	if (testpmd_cl != NULL)
17136 		cmdline_quit(testpmd_cl);
17137 }
17138 
17139 static void
17140 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17141 {
17142 	if (id == (portid_t)RTE_PORT_ALL) {
17143 		portid_t pid;
17144 
17145 		RTE_ETH_FOREACH_DEV(pid) {
17146 			/* check if need_reconfig has been set to 1 */
17147 			if (ports[pid].need_reconfig == 0)
17148 				ports[pid].need_reconfig = dev;
17149 			/* check if need_reconfig_queues has been set to 1 */
17150 			if (ports[pid].need_reconfig_queues == 0)
17151 				ports[pid].need_reconfig_queues = queue;
17152 		}
17153 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17154 		/* check if need_reconfig has been set to 1 */
17155 		if (ports[id].need_reconfig == 0)
17156 			ports[id].need_reconfig = dev;
17157 		/* check if need_reconfig_queues has been set to 1 */
17158 		if (ports[id].need_reconfig_queues == 0)
17159 			ports[id].need_reconfig_queues = queue;
17160 	}
17161 }
17162