xref: /dpdk/app/test-pmd/cmdline.c (revision bafe8a68f033e3d1fd3e7af7dad778b18daa06bc)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5 
6 #include <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <termios.h>
12 #include <unistd.h>
13 #include <inttypes.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 
17 #include <sys/queue.h>
18 
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
21 #include <rte_log.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
28 #include <rte_eal.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
33 #include <rte_ring.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
36 #include <rte_pci.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
41 #include <rte_flow.h>
42 #include <rte_gro.h>
43 #include <rte_mbuf_dyn.h>
44 
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
52 #include <cmdline.h>
53 #ifdef RTE_NET_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
56 #endif
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
59 #endif
60 #ifdef RTE_NET_IXGBE
61 #include <rte_pmd_ixgbe.h>
62 #endif
63 #ifdef RTE_NET_I40E
64 #include <rte_pmd_i40e.h>
65 #endif
66 #ifdef RTE_NET_BNXT
67 #include <rte_pmd_bnxt.h>
68 #endif
69 #include "testpmd.h"
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
72 #include "bpf_cmd.h"
73 
74 static struct cmdline *testpmd_cl;
75 
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
77 
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 	cmdline_fixed_string_t help;
81 };
82 
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
84                                   struct cmdline *cl,
85                                   __rte_unused void *data)
86 {
87 	cmdline_printf(
88 		cl,
89 		"\n"
90 		"Help is available for the following sections:\n\n"
91 		"    help control                    : Start and stop forwarding.\n"
92 		"    help display                    : Displaying port, stats and config "
93 		"information.\n"
94 		"    help config                     : Configuration information.\n"
95 		"    help ports                      : Configuring ports.\n"
96 		"    help registers                  : Reading and setting port registers.\n"
97 		"    help filters                    : Filters configuration help.\n"
98 		"    help traffic_management         : Traffic Management commands.\n"
99 		"    help devices                    : Device related cmds.\n"
100 		"    help all                        : All of the above sections.\n\n"
101 	);
102 
103 }
104 
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 
108 cmdline_parse_inst_t cmd_help_brief = {
109 	.f = cmd_help_brief_parsed,
110 	.data = NULL,
111 	.help_str = "help: Show help",
112 	.tokens = {
113 		(void *)&cmd_help_brief_help,
114 		NULL,
115 	},
116 };
117 
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 	cmdline_fixed_string_t help;
121 	cmdline_fixed_string_t section;
122 };
123 
124 static void cmd_help_long_parsed(void *parsed_result,
125                                  struct cmdline *cl,
126                                  __rte_unused void *data)
127 {
128 	int show_all = 0;
129 	struct cmd_help_long_result *res = parsed_result;
130 
131 	if (!strcmp(res->section, "all"))
132 		show_all = 1;
133 
134 	if (show_all || !strcmp(res->section, "control")) {
135 
136 		cmdline_printf(
137 			cl,
138 			"\n"
139 			"Control forwarding:\n"
140 			"-------------------\n\n"
141 
142 			"start\n"
143 			"    Start packet forwarding with current configuration.\n\n"
144 
145 			"start tx_first\n"
146 			"    Start packet forwarding with current config"
147 			" after sending one burst of packets.\n\n"
148 
149 			"stop\n"
150 			"    Stop packet forwarding, and display accumulated"
151 			" statistics.\n\n"
152 
153 			"quit\n"
154 			"    Quit to prompt.\n\n"
155 		);
156 	}
157 
158 	if (show_all || !strcmp(res->section, "display")) {
159 
160 		cmdline_printf(
161 			cl,
162 			"\n"
163 			"Display:\n"
164 			"--------\n\n"
165 
166 			"show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 			"    Display information for port_id, or all.\n\n"
168 
169 			"show port port_id (module_eeprom|eeprom)\n"
170 			"    Display the module EEPROM or EEPROM information for port_id.\n\n"
171 
172 			"show port X rss reta (size) (mask0,mask1,...)\n"
173 			"    Display the rss redirection table entry indicated"
174 			" by masks on port X. size is used to indicate the"
175 			" hardware supported reta size\n\n"
176 
177 			"show port (port_id) rss-hash [key]\n"
178 			"    Display the RSS hash functions and RSS hash key of port\n\n"
179 
180 			"clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 			"    Clear information for port_id, or all.\n\n"
182 
183 			"show (rxq|txq) info (port_id) (queue_id)\n"
184 			"    Display information for configured RX/TX queue.\n\n"
185 
186 			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 			"    Display the given configuration.\n\n"
188 
189 			"read rxd (port_id) (queue_id) (rxd_id)\n"
190 			"    Display an RX descriptor of a port RX queue.\n\n"
191 
192 			"read txd (port_id) (queue_id) (txd_id)\n"
193 			"    Display a TX descriptor of a port TX queue.\n\n"
194 
195 			"ddp get list (port_id)\n"
196 			"    Get ddp profile info list\n\n"
197 
198 			"ddp get info (profile_path)\n"
199 			"    Get ddp profile information.\n\n"
200 
201 			"show vf stats (port_id) (vf_id)\n"
202 			"    Display a VF's statistics.\n\n"
203 
204 			"clear vf stats (port_id) (vf_id)\n"
205 			"    Reset a VF's statistics.\n\n"
206 
207 			"show port (port_id) pctype mapping\n"
208 			"    Get flow ptype to pctype mapping on a port\n\n"
209 
210 			"show port meter stats (port_id) (meter_id) (clear)\n"
211 			"    Get meter stats on a port\n\n"
212 
213 			"show fwd stats all\n"
214 			"    Display statistics for all fwd engines.\n\n"
215 
216 			"clear fwd stats all\n"
217 			"    Clear statistics for all fwd engines.\n\n"
218 
219 			"show port (port_id) rx_offload capabilities\n"
220 			"    List all per queue and per port Rx offloading"
221 			" capabilities of a port\n\n"
222 
223 			"show port (port_id) rx_offload configuration\n"
224 			"    List port level and all queue level"
225 			" Rx offloading configuration\n\n"
226 
227 			"show port (port_id) tx_offload capabilities\n"
228 			"    List all per queue and per port"
229 			" Tx offloading capabilities of a port\n\n"
230 
231 			"show port (port_id) tx_offload configuration\n"
232 			"    List port level and all queue level"
233 			" Tx offloading configuration\n\n"
234 
235 			"show port (port_id) tx_metadata\n"
236 			"    Show Tx metadata value set"
237 			" for a specific port\n\n"
238 
239 			"show port (port_id) ptypes\n"
240 			"    Show port supported ptypes"
241 			" for a specific port\n\n"
242 
243 			"show device info (<identifier>|all)"
244 			"       Show general information about devices probed.\n\n"
245 
246 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 			"       Show status of rx|tx descriptor.\n\n"
248 
249 			"show port (port_id) rxq (queue_id) desc used count\n"
250 			"    Show current number of filled receive"
251 			" packet descriptors.\n\n"
252 
253 			"show port (port_id) macs|mcast_macs"
254 			"       Display list of mac addresses added to port.\n\n"
255 
256 			"show port (port_id) fec capabilities"
257 			"	Show fec capabilities of a port.\n\n"
258 
259 			"show port (port_id) fec_mode"
260 			"	Show fec mode of a port.\n\n"
261 		);
262 	}
263 
264 	if (show_all || !strcmp(res->section, "config")) {
265 		cmdline_printf(
266 			cl,
267 			"\n"
268 			"Configuration:\n"
269 			"--------------\n"
270 			"Configuration changes only become active when"
271 			" forwarding is started/restarted.\n\n"
272 
273 			"set default\n"
274 			"    Reset forwarding to the default configuration.\n\n"
275 
276 			"set verbose (level)\n"
277 			"    Set the debug verbosity level X.\n\n"
278 
279 			"set log global|(type) (level)\n"
280 			"    Set the log level.\n\n"
281 
282 			"set nbport (num)\n"
283 			"    Set number of ports.\n\n"
284 
285 			"set nbcore (num)\n"
286 			"    Set number of cores.\n\n"
287 
288 			"set coremask (mask)\n"
289 			"    Set the forwarding cores hexadecimal mask.\n\n"
290 
291 			"set portmask (mask)\n"
292 			"    Set the forwarding ports hexadecimal mask.\n\n"
293 
294 			"set burst (num)\n"
295 			"    Set number of packets per burst.\n\n"
296 
297 			"set burst tx delay (microseconds) retry (num)\n"
298 			"    Set the transmit delay time and number of retries,"
299 			" effective when retry is enabled.\n\n"
300 
301 			"set rxoffs (x[,y]*)\n"
302 			"    Set the offset of each packet segment on"
303 			" receiving if split feature is engaged."
304 			" Affects only the queues configured with split"
305 			" offloads.\n\n"
306 
307 			"set rxpkts (x[,y]*)\n"
308 			"    Set the length of each segment to scatter"
309 			" packets on receiving if split feature is engaged."
310 			" Affects only the queues configured with split"
311 			" offloads.\n\n"
312 
313 			"set txpkts (x[,y]*)\n"
314 			"    Set the length of each segment of TXONLY"
315 			" and optionally CSUM packets.\n\n"
316 
317 			"set txsplit (off|on|rand)\n"
318 			"    Set the split policy for the TX packets."
319 			" Right now only applicable for CSUM and TXONLY"
320 			" modes\n\n"
321 
322 			"set txtimes (x, y)\n"
323 			"    Set the scheduling on timestamps"
324 			" timings for the TXONLY mode\n\n"
325 
326 			"set corelist (x[,y]*)\n"
327 			"    Set the list of forwarding cores.\n\n"
328 
329 			"set portlist (x[,y]*)\n"
330 			"    Set the list of forwarding ports.\n\n"
331 
332 			"set port setup on (iterator|event)\n"
333 			"    Select how attached port is retrieved for setup.\n\n"
334 
335 			"set tx loopback (port_id) (on|off)\n"
336 			"    Enable or disable tx loopback.\n\n"
337 
338 			"set all queues drop (port_id) (on|off)\n"
339 			"    Set drop enable bit for all queues.\n\n"
340 
341 			"set vf split drop (port_id) (vf_id) (on|off)\n"
342 			"    Set split drop enable bit for a VF from the PF.\n\n"
343 
344 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
345 			"    Set MAC antispoof for a VF from the PF.\n\n"
346 
347 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
348 			"    Enable MACsec offload.\n\n"
349 
350 			"set macsec offload (port_id) off\n"
351 			"    Disable MACsec offload.\n\n"
352 
353 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
354 			"    Configure MACsec secure connection (SC).\n\n"
355 
356 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
357 			"    Configure MACsec secure association (SA).\n\n"
358 
359 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
360 			"    Set VF broadcast for a VF from the PF.\n\n"
361 
362 			"vlan set stripq (on|off) (port_id,queue_id)\n"
363 			"    Set the VLAN strip for a queue on a port.\n\n"
364 
365 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
366 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
367 
368 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
369 			"    Set VLAN insert for a VF from the PF.\n\n"
370 
371 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
372 			"    Set VLAN antispoof for a VF from the PF.\n\n"
373 
374 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
375 			"    Set VLAN tag for a VF from the PF.\n\n"
376 
377 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
378 			"    Set a VF's max bandwidth(Mbps).\n\n"
379 
380 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
381 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
382 
383 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
384 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
385 
386 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
387 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
388 
389 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
390 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
391 
392 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
393 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
394 
395 			"vlan set (inner|outer) tpid (value) (port_id)\n"
396 			"    Set the VLAN TPID for Packet Filtering on"
397 			" a port\n\n"
398 
399 			"rx_vlan add (vlan_id|all) (port_id)\n"
400 			"    Add a vlan_id, or all identifiers, to the set"
401 			" of VLAN identifiers filtered by port_id.\n\n"
402 
403 			"rx_vlan rm (vlan_id|all) (port_id)\n"
404 			"    Remove a vlan_id, or all identifiers, from the set"
405 			" of VLAN identifiers filtered by port_id.\n\n"
406 
407 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
408 			"    Add a vlan_id, to the set of VLAN identifiers"
409 			"filtered for VF(s) from port_id.\n\n"
410 
411 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
412 			"    Remove a vlan_id, to the set of VLAN identifiers"
413 			"filtered for VF(s) from port_id.\n\n"
414 
415 			"rx_vxlan_port add (udp_port) (port_id)\n"
416 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
417 
418 			"rx_vxlan_port rm (udp_port) (port_id)\n"
419 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
420 
421 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
422 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
423 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
424 
425 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
426 			"    Set port based TX VLAN insertion.\n\n"
427 
428 			"tx_vlan reset (port_id)\n"
429 			"    Disable hardware insertion of a VLAN header in"
430 			" packets sent on a port.\n\n"
431 
432 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
433 			"    Select hardware or software calculation of the"
434 			" checksum when transmitting a packet using the"
435 			" csum forward engine.\n"
436 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
437 			"    outer-ip concerns the outer IP layer in"
438 			"    outer-udp concerns the outer UDP layer in"
439 			" case the packet is recognized as a tunnel packet by"
440 			" the forward engine (vxlan, gre and ipip are supported)\n"
441 			"    Please check the NIC datasheet for HW limits.\n\n"
442 
443 			"csum parse-tunnel (on|off) (tx_port_id)\n"
444 			"    If disabled, treat tunnel packets as non-tunneled"
445 			" packets (treat inner headers as payload). The port\n"
446 			"    argument is the port used for TX in csum forward"
447 			" engine.\n\n"
448 
449 			"csum show (port_id)\n"
450 			"    Display tx checksum offload configuration\n\n"
451 
452 			"tso set (segsize) (portid)\n"
453 			"    Enable TCP Segmentation Offload in csum forward"
454 			" engine.\n"
455 			"    Please check the NIC datasheet for HW limits.\n\n"
456 
457 			"tso show (portid)"
458 			"    Display the status of TCP Segmentation Offload.\n\n"
459 
460 			"set port (port_id) gro on|off\n"
461 			"    Enable or disable Generic Receive Offload in"
462 			" csum forwarding engine.\n\n"
463 
464 			"show port (port_id) gro\n"
465 			"    Display GRO configuration.\n\n"
466 
467 			"set gro flush (cycles)\n"
468 			"    Set the cycle to flush GROed packets from"
469 			" reassembly tables.\n\n"
470 
471 			"set port (port_id) gso (on|off)"
472 			"    Enable or disable Generic Segmentation Offload in"
473 			" csum forwarding engine.\n\n"
474 
475 			"set gso segsz (length)\n"
476 			"    Set max packet length for output GSO segments,"
477 			" including packet header and payload.\n\n"
478 
479 			"show port (port_id) gso\n"
480 			"    Show GSO configuration.\n\n"
481 
482 			"set fwd (%s)\n"
483 			"    Set packet forwarding mode.\n\n"
484 
485 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
486 			"    Add a MAC address on port_id.\n\n"
487 
488 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
489 			"    Remove a MAC address from port_id.\n\n"
490 
491 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 			"    Set the default MAC address for port_id.\n\n"
493 
494 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
495 			"    Add a MAC address for a VF on the port.\n\n"
496 
497 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
498 			"    Set the MAC address for a VF from the PF.\n\n"
499 
500 			"set eth-peer (port_id) (peer_addr)\n"
501 			"    set the peer address for certain port.\n\n"
502 
503 			"set port (port_id) uta (mac_address|all) (on|off)\n"
504 			"    Add/Remove a or all unicast hash filter(s)"
505 			"from port X.\n\n"
506 
507 			"set promisc (port_id|all) (on|off)\n"
508 			"    Set the promiscuous mode on port_id, or all.\n\n"
509 
510 			"set allmulti (port_id|all) (on|off)\n"
511 			"    Set the allmulti mode on port_id, or all.\n\n"
512 
513 			"set vf promisc (port_id) (vf_id) (on|off)\n"
514 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
515 
516 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
517 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
518 
519 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
520 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
521 			" (on|off) autoneg (on|off) (port_id)\n"
522 			"set flow_ctrl rx (on|off) (portid)\n"
523 			"set flow_ctrl tx (on|off) (portid)\n"
524 			"set flow_ctrl high_water (high_water) (portid)\n"
525 			"set flow_ctrl low_water (low_water) (portid)\n"
526 			"set flow_ctrl pause_time (pause_time) (portid)\n"
527 			"set flow_ctrl send_xon (send_xon) (portid)\n"
528 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
529 			"set flow_ctrl autoneg (on|off) (port_id)\n"
530 			"    Set the link flow control parameter on a port.\n\n"
531 
532 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
533 			" (low_water) (pause_time) (priority) (port_id)\n"
534 			"    Set the priority flow control parameter on a"
535 			" port.\n\n"
536 
537 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
538 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
539 			" queue on port.\n"
540 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
541 			" on port 0 to mapping 5.\n\n"
542 
543 			"set xstats-hide-zero on|off\n"
544 			"    Set the option to hide the zero values"
545 			" for xstats display.\n"
546 
547 			"set record-core-cycles on|off\n"
548 			"    Set the option to enable measurement of CPU cycles.\n"
549 
550 			"set record-burst-stats on|off\n"
551 			"    Set the option to enable display of RX and TX bursts.\n"
552 
553 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
554 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
555 
556 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
557 			"|MPE) (on|off)\n"
558 			"    AUPE:accepts untagged VLAN;"
559 			"ROPE:accept unicast hash\n\n"
560 			"    BAM:accepts broadcast packets;"
561 			"MPE:accepts all multicast packets\n\n"
562 			"    Enable/Disable a VF receive mode of a port\n\n"
563 
564 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
565 			"    Set rate limit for a queue of a port\n\n"
566 
567 			"set port (port_id) vf (vf_id) rate (rate_num) "
568 			"queue_mask (queue_mask_value)\n"
569 			"    Set rate limit for queues in VF of a port\n\n"
570 
571 			"set port (port_id) mirror-rule (rule_id)"
572 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
573 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
574 			"   Set pool or vlan type mirror rule on a port.\n"
575 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
576 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
577 			" to pool 0.\n\n"
578 
579 			"set port (port_id) mirror-rule (rule_id)"
580 			" (uplink-mirror|downlink-mirror) dst-pool"
581 			" (pool_id) (on|off)\n"
582 			"   Set uplink or downlink type mirror rule on a port.\n"
583 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
584 			" 0 on' enable mirror income traffic to pool 0.\n\n"
585 
586 			"reset port (port_id) mirror-rule (rule_id)\n"
587 			"   Reset a mirror rule.\n\n"
588 
589 			"set flush_rx (on|off)\n"
590 			"   Flush (default) or don't flush RX streams before"
591 			" forwarding. Mainly used with PCAP drivers.\n\n"
592 
593 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
594 			"   Set the bypass mode for the lowest port on bypass enabled"
595 			" NIC.\n\n"
596 
597 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
598 			"mode (normal|bypass|isolate) (port_id)\n"
599 			"   Set the event required to initiate specified bypass mode for"
600 			" the lowest port on a bypass enabled NIC where:\n"
601 			"       timeout   = enable bypass after watchdog timeout.\n"
602 			"       os_on     = enable bypass when OS/board is powered on.\n"
603 			"       os_off    = enable bypass when OS/board is powered off.\n"
604 			"       power_on  = enable bypass when power supply is turned on.\n"
605 			"       power_off = enable bypass when power supply is turned off."
606 			"\n\n"
607 
608 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
609 			"   Set the bypass watchdog timeout to 'n' seconds"
610 			" where 0 = instant.\n\n"
611 
612 			"show bypass config (port_id)\n"
613 			"   Show the bypass configuration for a bypass enabled NIC"
614 			" using the lowest port on the NIC.\n\n"
615 
616 #ifdef RTE_NET_BOND
617 			"create bonded device (mode) (socket)\n"
618 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
619 
620 			"add bonding slave (slave_id) (port_id)\n"
621 			"	Add a slave device to a bonded device.\n\n"
622 
623 			"remove bonding slave (slave_id) (port_id)\n"
624 			"	Remove a slave device from a bonded device.\n\n"
625 
626 			"set bonding mode (value) (port_id)\n"
627 			"	Set the bonding mode on a bonded device.\n\n"
628 
629 			"set bonding primary (slave_id) (port_id)\n"
630 			"	Set the primary slave for a bonded device.\n\n"
631 
632 			"show bonding config (port_id)\n"
633 			"	Show the bonding config for port_id.\n\n"
634 
635 			"set bonding mac_addr (port_id) (address)\n"
636 			"	Set the MAC address of a bonded device.\n\n"
637 
638 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
639 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
640 
641 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
642 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
643 
644 			"set bonding mon_period (port_id) (value)\n"
645 			"	Set the bonding link status monitoring polling period in ms.\n\n"
646 
647 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
648 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
649 
650 #endif
651 			"set link-up port (port_id)\n"
652 			"	Set link up for a port.\n\n"
653 
654 			"set link-down port (port_id)\n"
655 			"	Set link down for a port.\n\n"
656 
657 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 			"    Load a profile package on a port\n\n"
659 
660 			"ddp del (port_id) (backup_profile_path)\n"
661 			"    Delete a profile package from a port\n\n"
662 
663 			"ptype mapping get (port_id) (valid_only)\n"
664 			"    Get ptype mapping on a port\n\n"
665 
666 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 			"    Replace target with the pkt_type in ptype mapping\n\n"
668 
669 			"ptype mapping reset (port_id)\n"
670 			"    Reset ptype mapping on a port\n\n"
671 
672 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 			"    Update a ptype mapping item on a port\n\n"
674 
675 			"set port (port_id) ptype_mask (ptype_mask)\n"
676 			"    set packet types classification for a specific port\n\n"
677 
678 			"set port (port_id) queue-region region_id (value) "
679 			"queue_start_index (value) queue_num (value)\n"
680 			"    Set a queue region on a port\n\n"
681 
682 			"set port (port_id) queue-region region_id (value) "
683 			"flowtype (value)\n"
684 			"    Set a flowtype region index on a port\n\n"
685 
686 			"set port (port_id) queue-region UP (value) region_id (value)\n"
687 			"    Set the mapping of User Priority to "
688 			"queue region on a port\n\n"
689 
690 			"set port (port_id) queue-region flush (on|off)\n"
691 			"    flush all queue region related configuration\n\n"
692 
693 			"show port meter cap (port_id)\n"
694 			"    Show port meter capability information\n\n"
695 
696 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
697 			"    meter profile add - srtcm rfc 2697\n\n"
698 
699 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
700 			"    meter profile add - trtcm rfc 2698\n\n"
701 
702 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
703 			"    meter profile add - trtcm rfc 4115\n\n"
704 
705 			"del port meter profile (port_id) (profile_id)\n"
706 			"    meter profile delete\n\n"
707 
708 			"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
709 			"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
710 			"(dscp_tbl_entry63)]\n"
711 			"    meter create\n\n"
712 
713 			"enable port meter (port_id) (mtr_id)\n"
714 			"    meter enable\n\n"
715 
716 			"disable port meter (port_id) (mtr_id)\n"
717 			"    meter disable\n\n"
718 
719 			"del port meter (port_id) (mtr_id)\n"
720 			"    meter delete\n\n"
721 
722 			"add port meter policy (port_id) (policy_id) g_actions (actions)\n"
723 			"y_actions (actions) r_actions (actions)\n"
724 			"    meter policy add\n\n"
725 
726 			"del port meter policy (port_id) (policy_id)\n"
727 			"    meter policy delete\n\n"
728 
729 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
730 			"    meter update meter profile\n\n"
731 
732 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
733 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
734 			"    update meter dscp table entries\n\n"
735 
736 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
737 			"(action0) [(action1) (action2)]\n"
738 			"    meter update policer action\n\n"
739 
740 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
741 			"    meter update stats\n\n"
742 
743 			"show port (port_id) queue-region\n"
744 			"    show all queue region related configuration info\n\n"
745 
746 			"set port (port_id) fec_mode auto|off|rs|baser\n"
747 			"    set fec mode for a specific port\n\n"
748 
749 			, list_pkt_forwarding_modes()
750 		);
751 	}
752 
753 	if (show_all || !strcmp(res->section, "ports")) {
754 
755 		cmdline_printf(
756 			cl,
757 			"\n"
758 			"Port Operations:\n"
759 			"----------------\n\n"
760 
761 			"port start (port_id|all)\n"
762 			"    Start all ports or port_id.\n\n"
763 
764 			"port stop (port_id|all)\n"
765 			"    Stop all ports or port_id.\n\n"
766 
767 			"port close (port_id|all)\n"
768 			"    Close all ports or port_id.\n\n"
769 
770 			"port reset (port_id|all)\n"
771 			"    Reset all ports or port_id.\n\n"
772 
773 			"port attach (ident)\n"
774 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
775 
776 			"port detach (port_id)\n"
777 			"    Detach physical or virtual dev by port_id\n\n"
778 
779 			"port config (port_id|all)"
780 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
781 			" duplex (half|full|auto)\n"
782 			"    Set speed and duplex for all ports or port_id\n\n"
783 
784 			"port config (port_id|all) loopback (mode)\n"
785 			"    Set loopback mode for all ports or port_id\n\n"
786 
787 			"port config all (rxq|txq|rxd|txd) (value)\n"
788 			"    Set number for rxq/txq/rxd/txd.\n\n"
789 
790 			"port config all max-pkt-len (value)\n"
791 			"    Set the max packet length.\n\n"
792 
793 			"port config all max-lro-pkt-size (value)\n"
794 			"    Set the max LRO aggregated packet size.\n\n"
795 
796 			"port config all drop-en (on|off)\n"
797 			"    Enable or disable packet drop on all RX queues of all ports when no "
798 			"receive buffers available.\n\n"
799 
800 			"port config all rss (all|default|ip|tcp|udp|sctp|"
801 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
802 			"level-outer|level-inner|<flowtype_id>)\n"
803 			"    Set the RSS mode.\n\n"
804 
805 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
806 			"    Set the RSS redirection table.\n\n"
807 
808 			"port config (port_id) dcb vt (on|off) (traffic_class)"
809 			" pfc (on|off)\n"
810 			"    Set the DCB mode.\n\n"
811 
812 			"port config all burst (value)\n"
813 			"    Set the number of packets per burst.\n\n"
814 
815 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
816 			" (value)\n"
817 			"    Set the ring prefetch/host/writeback threshold"
818 			" for tx/rx queue.\n\n"
819 
820 			"port config all (txfreet|txrst|rxfreet) (value)\n"
821 			"    Set free threshold for rx/tx, or set"
822 			" tx rs bit threshold.\n\n"
823 			"port config mtu X value\n"
824 			"    Set the MTU of port X to a given value\n\n"
825 
826 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
827 			"    Set a rx/tx queue's ring size configuration, the new"
828 			" value will take effect after command that (re-)start the port"
829 			" or command that setup the specific queue\n\n"
830 
831 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
832 			"    Start/stop a rx/tx queue of port X. Only take effect"
833 			" when port X is started\n\n"
834 
835 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
836 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
837 			" take effect when port X is stopped.\n\n"
838 
839 			"port (port_id) (rxq|txq) (queue_id) setup\n"
840 			"    Setup a rx/tx queue of port X.\n\n"
841 
842 			"port config (port_id) pctype mapping reset\n"
843 			"    Reset flow type to pctype mapping on a port\n\n"
844 
845 			"port config (port_id) pctype mapping update"
846 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
847 			"    Update a flow type to pctype mapping item on a port\n\n"
848 
849 			"port config (port_id) pctype (pctype_id) hash_inset|"
850 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
851 			" (field_idx)\n"
852 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 
854 			"port config (port_id) pctype (pctype_id) hash_inset|"
855 			"fdir_inset|fdir_flx_inset clear all"
856 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 
858 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
859 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
860 
861 			"port config <port_id> rx_offload vlan_strip|"
862 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 			"outer_ipv4_cksum|macsec_strip|header_split|"
864 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
865 			"buffer_split|timestamp|security|keep_crc on|off\n"
866 			"     Enable or disable a per port Rx offloading"
867 			" on all Rx queues of a port\n\n"
868 
869 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
870 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
871 			"outer_ipv4_cksum|macsec_strip|header_split|"
872 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
873 			"buffer_split|timestamp|security|keep_crc on|off\n"
874 			"    Enable or disable a per queue Rx offloading"
875 			" only on a specific Rx queue\n\n"
876 
877 			"port config (port_id) tx_offload vlan_insert|"
878 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
881 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 			"security on|off\n"
883 			"    Enable or disable a per port Tx offloading"
884 			" on all Tx queues of a port\n\n"
885 
886 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
887 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
888 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
889 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
890 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 			" on|off\n"
892 			"    Enable or disable a per queue Tx offloading"
893 			" only on a specific Tx queue\n\n"
894 
895 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
896 			"    Load an eBPF program as a callback"
897 			" for particular RX/TX queue\n\n"
898 
899 			"bpf-unload rx|tx (port) (queue)\n"
900 			"    Unload previously loaded eBPF program"
901 			" for particular RX/TX queue\n\n"
902 
903 			"port config (port_id) tx_metadata (value)\n"
904 			"    Set Tx metadata value per port. Testpmd will add this value"
905 			" to any Tx packet sent from this port\n\n"
906 
907 			"port config (port_id) dynf (name) set|clear\n"
908 			"    Register a dynf and Set/clear this flag on Tx. "
909 			"Testpmd will set this value to any Tx packet "
910 			"sent from this port\n\n"
911 
912 			"port cleanup (port_id) txq (queue_id) (free_cnt)\n"
913 			"    Cleanup txq mbufs for a specific Tx queue\n\n"
914 		);
915 	}
916 
917 	if (show_all || !strcmp(res->section, "registers")) {
918 
919 		cmdline_printf(
920 			cl,
921 			"\n"
922 			"Registers:\n"
923 			"----------\n\n"
924 
925 			"read reg (port_id) (address)\n"
926 			"    Display value of a port register.\n\n"
927 
928 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
929 			"    Display a port register bit field.\n\n"
930 
931 			"read regbit (port_id) (address) (bit_x)\n"
932 			"    Display a single port register bit.\n\n"
933 
934 			"write reg (port_id) (address) (value)\n"
935 			"    Set value of a port register.\n\n"
936 
937 			"write regfield (port_id) (address) (bit_x) (bit_y)"
938 			" (value)\n"
939 			"    Set bit field of a port register.\n\n"
940 
941 			"write regbit (port_id) (address) (bit_x) (value)\n"
942 			"    Set single bit value of a port register.\n\n"
943 		);
944 	}
945 	if (show_all || !strcmp(res->section, "filters")) {
946 
947 		cmdline_printf(
948 			cl,
949 			"\n"
950 			"filters:\n"
951 			"--------\n\n"
952 
953 #ifdef RTE_NET_I40E
954 			"flow_director_filter (port_id) mode raw (add|del|update)"
955 			" flow (flow_id) (drop|fwd) queue (queue_id)"
956 			" fd_id (fd_id_value) packet (packet file name)\n"
957 			"    Add/Del a raw type flow director filter.\n\n"
958 #endif
959 
960 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
961 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
962 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
963 			"    Set flow director IP mask.\n\n"
964 
965 			"flow_director_mask (port_id) mode MAC-VLAN"
966 			" vlan (vlan_value)\n"
967 			"    Set flow director MAC-VLAN mask.\n\n"
968 
969 			"flow_director_mask (port_id) mode Tunnel"
970 			" vlan (vlan_value) mac (mac_value)"
971 			" tunnel-type (tunnel_type_value)"
972 			" tunnel-id (tunnel_id_value)\n"
973 			"    Set flow director Tunnel mask.\n\n"
974 
975 			"flow_director_flex_payload (port_id)"
976 			" (raw|l2|l3|l4) (config)\n"
977 			"    Configure flex payload selection.\n\n"
978 
979 			"flow validate {port_id}"
980 			" [group {group_id}] [priority {level}]"
981 			" [ingress] [egress]"
982 			" pattern {item} [/ {item} [...]] / end"
983 			" actions {action} [/ {action} [...]] / end\n"
984 			"    Check whether a flow rule can be created.\n\n"
985 
986 			"flow create {port_id}"
987 			" [group {group_id}] [priority {level}]"
988 			" [ingress] [egress]"
989 			" pattern {item} [/ {item} [...]] / end"
990 			" actions {action} [/ {action} [...]] / end\n"
991 			"    Create a flow rule.\n\n"
992 
993 			"flow destroy {port_id} rule {rule_id} [...]\n"
994 			"    Destroy specific flow rules.\n\n"
995 
996 			"flow flush {port_id}\n"
997 			"    Destroy all flow rules.\n\n"
998 
999 			"flow query {port_id} {rule_id} {action}\n"
1000 			"    Query an existing flow rule.\n\n"
1001 
1002 			"flow list {port_id} [group {group_id}] [...]\n"
1003 			"    List existing flow rules sorted by priority,"
1004 			" filtered by group identifiers.\n\n"
1005 
1006 			"flow isolate {port_id} {boolean}\n"
1007 			"    Restrict ingress traffic to the defined"
1008 			" flow rules\n\n"
1009 
1010 			"flow aged {port_id} [destroy]\n"
1011 			"    List and destroy aged flows"
1012 			" flow rules\n\n"
1013 
1014 			"flow indirect_action {port_id} create"
1015 			" [action_id {indirect_action_id}]"
1016 			" [ingress] [egress]"
1017 			" action {action} / end\n"
1018 			"    Create indirect action.\n\n"
1019 
1020 			"flow indirect_action {port_id} update"
1021 			" {indirect_action_id} action {action} / end\n"
1022 			"    Update indirect action.\n\n"
1023 
1024 			"flow indirect_action {port_id} destroy"
1025 			" action_id {indirect_action_id} [...]\n"
1026 			"    Destroy specific indirect actions.\n\n"
1027 
1028 			"flow indirect_action {port_id} query"
1029 			" {indirect_action_id}\n"
1030 			"    Query an existing indirect action.\n\n"
1031 
1032 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1033 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1034 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1035 			"       Configure the VXLAN encapsulation for flows.\n\n"
1036 
1037 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1038 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1039 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1040 			" eth-dst (eth-dst)\n"
1041 			"       Configure the VXLAN encapsulation for flows.\n\n"
1042 
1043 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1044 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1045 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1046 			" eth-dst (eth-dst)\n"
1047 			"       Configure the VXLAN encapsulation for flows.\n\n"
1048 
1049 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1050 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1051 			" (eth-dst)\n"
1052 			"       Configure the NVGRE encapsulation for flows.\n\n"
1053 
1054 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1055 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1056 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1057 			"       Configure the NVGRE encapsulation for flows.\n\n"
1058 
1059 			"set raw_encap {flow items}\n"
1060 			"	Configure the encapsulation with raw data.\n\n"
1061 
1062 			"set raw_decap {flow items}\n"
1063 			"	Configure the decapsulation with raw data.\n\n"
1064 
1065 		);
1066 	}
1067 
1068 	if (show_all || !strcmp(res->section, "traffic_management")) {
1069 		cmdline_printf(
1070 			cl,
1071 			"\n"
1072 			"Traffic Management:\n"
1073 			"--------------\n"
1074 			"show port tm cap (port_id)\n"
1075 			"       Display the port TM capability.\n\n"
1076 
1077 			"show port tm level cap (port_id) (level_id)\n"
1078 			"       Display the port TM hierarchical level capability.\n\n"
1079 
1080 			"show port tm node cap (port_id) (node_id)\n"
1081 			"       Display the port TM node capability.\n\n"
1082 
1083 			"show port tm node type (port_id) (node_id)\n"
1084 			"       Display the port TM node type.\n\n"
1085 
1086 			"show port tm node stats (port_id) (node_id) (clear)\n"
1087 			"       Display the port TM node stats.\n\n"
1088 
1089 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1090 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1091 			" (packet_length_adjust) (packet_mode)\n"
1092 			"       Add port tm node private shaper profile.\n\n"
1093 
1094 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1095 			"       Delete port tm node private shaper profile.\n\n"
1096 
1097 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1098 			" (shaper_profile_id)\n"
1099 			"       Add/update port tm node shared shaper.\n\n"
1100 
1101 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1102 			"       Delete port tm node shared shaper.\n\n"
1103 
1104 			"set port tm node shaper profile (port_id) (node_id)"
1105 			" (shaper_profile_id)\n"
1106 			"       Set port tm node shaper profile.\n\n"
1107 
1108 			"add port tm node wred profile (port_id) (wred_profile_id)"
1109 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1110 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1111 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1112 			"       Add port tm node wred profile.\n\n"
1113 
1114 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1115 			"       Delete port tm node wred profile.\n\n"
1116 
1117 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1118 			" (priority) (weight) (level_id) (shaper_profile_id)"
1119 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1120 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1121 			"       Add port tm nonleaf node.\n\n"
1122 
1123 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1124 			" (priority) (weight) (level_id) (shaper_profile_id)"
1125 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1126 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1127 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
1128 
1129 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1130 			" (priority) (weight) (level_id) (shaper_profile_id)"
1131 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1132 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1133 			"       Add port tm leaf node.\n\n"
1134 
1135 			"del port tm node (port_id) (node_id)\n"
1136 			"       Delete port tm node.\n\n"
1137 
1138 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1139 			" (priority) (weight)\n"
1140 			"       Set port tm node parent.\n\n"
1141 
1142 			"suspend port tm node (port_id) (node_id)"
1143 			"       Suspend tm node.\n\n"
1144 
1145 			"resume port tm node (port_id) (node_id)"
1146 			"       Resume tm node.\n\n"
1147 
1148 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1149 			"       Commit tm hierarchy.\n\n"
1150 
1151 			"set port tm mark ip_ecn (port) (green) (yellow)"
1152 			" (red)\n"
1153 			"    Enables/Disables the traffic management marking"
1154 			" for IP ECN (Explicit Congestion Notification)"
1155 			" packets on a given port\n\n"
1156 
1157 			"set port tm mark ip_dscp (port) (green) (yellow)"
1158 			" (red)\n"
1159 			"    Enables/Disables the traffic management marking"
1160 			" on the port for IP dscp packets\n\n"
1161 
1162 			"set port tm mark vlan_dei (port) (green) (yellow)"
1163 			" (red)\n"
1164 			"    Enables/Disables the traffic management marking"
1165 			" on the port for VLAN packets with DEI enabled\n\n"
1166 		);
1167 	}
1168 
1169 	if (show_all || !strcmp(res->section, "devices")) {
1170 		cmdline_printf(
1171 			cl,
1172 			"\n"
1173 			"Device Operations:\n"
1174 			"--------------\n"
1175 			"device detach (identifier)\n"
1176 			"       Detach device by identifier.\n\n"
1177 		);
1178 	}
1179 
1180 }
1181 
1182 cmdline_parse_token_string_t cmd_help_long_help =
1183 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1184 
1185 cmdline_parse_token_string_t cmd_help_long_section =
1186 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1187 			"all#control#display#config#"
1188 			"ports#registers#filters#traffic_management#devices");
1189 
1190 cmdline_parse_inst_t cmd_help_long = {
1191 	.f = cmd_help_long_parsed,
1192 	.data = NULL,
1193 	.help_str = "help all|control|display|config|ports|register|"
1194 		"filters|traffic_management|devices: "
1195 		"Show help",
1196 	.tokens = {
1197 		(void *)&cmd_help_long_help,
1198 		(void *)&cmd_help_long_section,
1199 		NULL,
1200 	},
1201 };
1202 
1203 
1204 /* *** start/stop/close all ports *** */
1205 struct cmd_operate_port_result {
1206 	cmdline_fixed_string_t keyword;
1207 	cmdline_fixed_string_t name;
1208 	cmdline_fixed_string_t value;
1209 };
1210 
1211 static void cmd_operate_port_parsed(void *parsed_result,
1212 				__rte_unused struct cmdline *cl,
1213 				__rte_unused void *data)
1214 {
1215 	struct cmd_operate_port_result *res = parsed_result;
1216 
1217 	if (!strcmp(res->name, "start"))
1218 		start_port(RTE_PORT_ALL);
1219 	else if (!strcmp(res->name, "stop"))
1220 		stop_port(RTE_PORT_ALL);
1221 	else if (!strcmp(res->name, "close"))
1222 		close_port(RTE_PORT_ALL);
1223 	else if (!strcmp(res->name, "reset"))
1224 		reset_port(RTE_PORT_ALL);
1225 	else
1226 		printf("Unknown parameter\n");
1227 }
1228 
1229 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1230 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1231 								"port");
1232 cmdline_parse_token_string_t cmd_operate_port_all_port =
1233 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1234 						"start#stop#close#reset");
1235 cmdline_parse_token_string_t cmd_operate_port_all_all =
1236 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1237 
1238 cmdline_parse_inst_t cmd_operate_port = {
1239 	.f = cmd_operate_port_parsed,
1240 	.data = NULL,
1241 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1242 	.tokens = {
1243 		(void *)&cmd_operate_port_all_cmd,
1244 		(void *)&cmd_operate_port_all_port,
1245 		(void *)&cmd_operate_port_all_all,
1246 		NULL,
1247 	},
1248 };
1249 
1250 /* *** start/stop/close specific port *** */
1251 struct cmd_operate_specific_port_result {
1252 	cmdline_fixed_string_t keyword;
1253 	cmdline_fixed_string_t name;
1254 	uint8_t value;
1255 };
1256 
1257 static void cmd_operate_specific_port_parsed(void *parsed_result,
1258 			__rte_unused struct cmdline *cl,
1259 				__rte_unused void *data)
1260 {
1261 	struct cmd_operate_specific_port_result *res = parsed_result;
1262 
1263 	if (!strcmp(res->name, "start"))
1264 		start_port(res->value);
1265 	else if (!strcmp(res->name, "stop"))
1266 		stop_port(res->value);
1267 	else if (!strcmp(res->name, "close"))
1268 		close_port(res->value);
1269 	else if (!strcmp(res->name, "reset"))
1270 		reset_port(res->value);
1271 	else
1272 		printf("Unknown parameter\n");
1273 }
1274 
1275 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1276 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1277 							keyword, "port");
1278 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1279 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1280 						name, "start#stop#close#reset");
1281 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1282 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1283 							value, RTE_UINT8);
1284 
1285 cmdline_parse_inst_t cmd_operate_specific_port = {
1286 	.f = cmd_operate_specific_port_parsed,
1287 	.data = NULL,
1288 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1289 	.tokens = {
1290 		(void *)&cmd_operate_specific_port_cmd,
1291 		(void *)&cmd_operate_specific_port_port,
1292 		(void *)&cmd_operate_specific_port_id,
1293 		NULL,
1294 	},
1295 };
1296 
1297 /* *** enable port setup (after attach) via iterator or event *** */
1298 struct cmd_set_port_setup_on_result {
1299 	cmdline_fixed_string_t set;
1300 	cmdline_fixed_string_t port;
1301 	cmdline_fixed_string_t setup;
1302 	cmdline_fixed_string_t on;
1303 	cmdline_fixed_string_t mode;
1304 };
1305 
1306 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1307 				__rte_unused struct cmdline *cl,
1308 				__rte_unused void *data)
1309 {
1310 	struct cmd_set_port_setup_on_result *res = parsed_result;
1311 
1312 	if (strcmp(res->mode, "event") == 0)
1313 		setup_on_probe_event = true;
1314 	else if (strcmp(res->mode, "iterator") == 0)
1315 		setup_on_probe_event = false;
1316 	else
1317 		printf("Unknown mode\n");
1318 }
1319 
1320 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1321 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1322 			set, "set");
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1324 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1325 			port, "port");
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1327 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1328 			setup, "setup");
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1330 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1331 			on, "on");
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1333 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 			mode, "iterator#event");
1335 
1336 cmdline_parse_inst_t cmd_set_port_setup_on = {
1337 	.f = cmd_set_port_setup_on_parsed,
1338 	.data = NULL,
1339 	.help_str = "set port setup on iterator|event",
1340 	.tokens = {
1341 		(void *)&cmd_set_port_setup_on_set,
1342 		(void *)&cmd_set_port_setup_on_port,
1343 		(void *)&cmd_set_port_setup_on_setup,
1344 		(void *)&cmd_set_port_setup_on_on,
1345 		(void *)&cmd_set_port_setup_on_mode,
1346 		NULL,
1347 	},
1348 };
1349 
1350 /* *** attach a specified port *** */
1351 struct cmd_operate_attach_port_result {
1352 	cmdline_fixed_string_t port;
1353 	cmdline_fixed_string_t keyword;
1354 	cmdline_multi_string_t identifier;
1355 };
1356 
1357 static void cmd_operate_attach_port_parsed(void *parsed_result,
1358 				__rte_unused struct cmdline *cl,
1359 				__rte_unused void *data)
1360 {
1361 	struct cmd_operate_attach_port_result *res = parsed_result;
1362 
1363 	if (!strcmp(res->keyword, "attach"))
1364 		attach_port(res->identifier);
1365 	else
1366 		printf("Unknown parameter\n");
1367 }
1368 
1369 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1370 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1371 			port, "port");
1372 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1373 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1374 			keyword, "attach");
1375 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1376 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 			identifier, TOKEN_STRING_MULTI);
1378 
1379 cmdline_parse_inst_t cmd_operate_attach_port = {
1380 	.f = cmd_operate_attach_port_parsed,
1381 	.data = NULL,
1382 	.help_str = "port attach <identifier>: "
1383 		"(identifier: pci address or virtual dev name)",
1384 	.tokens = {
1385 		(void *)&cmd_operate_attach_port_port,
1386 		(void *)&cmd_operate_attach_port_keyword,
1387 		(void *)&cmd_operate_attach_port_identifier,
1388 		NULL,
1389 	},
1390 };
1391 
1392 /* *** detach a specified port *** */
1393 struct cmd_operate_detach_port_result {
1394 	cmdline_fixed_string_t port;
1395 	cmdline_fixed_string_t keyword;
1396 	portid_t port_id;
1397 };
1398 
1399 static void cmd_operate_detach_port_parsed(void *parsed_result,
1400 				__rte_unused struct cmdline *cl,
1401 				__rte_unused void *data)
1402 {
1403 	struct cmd_operate_detach_port_result *res = parsed_result;
1404 
1405 	if (!strcmp(res->keyword, "detach")) {
1406 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1407 		detach_port_device(res->port_id);
1408 	} else {
1409 		printf("Unknown parameter\n");
1410 	}
1411 }
1412 
1413 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1414 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1415 			port, "port");
1416 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1417 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1418 			keyword, "detach");
1419 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1420 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1421 			port_id, RTE_UINT16);
1422 
1423 cmdline_parse_inst_t cmd_operate_detach_port = {
1424 	.f = cmd_operate_detach_port_parsed,
1425 	.data = NULL,
1426 	.help_str = "port detach <port_id>",
1427 	.tokens = {
1428 		(void *)&cmd_operate_detach_port_port,
1429 		(void *)&cmd_operate_detach_port_keyword,
1430 		(void *)&cmd_operate_detach_port_port_id,
1431 		NULL,
1432 	},
1433 };
1434 
1435 /* *** detach device by identifier *** */
1436 struct cmd_operate_detach_device_result {
1437 	cmdline_fixed_string_t device;
1438 	cmdline_fixed_string_t keyword;
1439 	cmdline_fixed_string_t identifier;
1440 };
1441 
1442 static void cmd_operate_detach_device_parsed(void *parsed_result,
1443 				__rte_unused struct cmdline *cl,
1444 				__rte_unused void *data)
1445 {
1446 	struct cmd_operate_detach_device_result *res = parsed_result;
1447 
1448 	if (!strcmp(res->keyword, "detach"))
1449 		detach_devargs(res->identifier);
1450 	else
1451 		printf("Unknown parameter\n");
1452 }
1453 
1454 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1455 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1456 			device, "device");
1457 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1458 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1459 			keyword, "detach");
1460 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1461 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1462 			identifier, NULL);
1463 
1464 cmdline_parse_inst_t cmd_operate_detach_device = {
1465 	.f = cmd_operate_detach_device_parsed,
1466 	.data = NULL,
1467 	.help_str = "device detach <identifier>:"
1468 		"(identifier: pci address or virtual dev name)",
1469 	.tokens = {
1470 		(void *)&cmd_operate_detach_device_device,
1471 		(void *)&cmd_operate_detach_device_keyword,
1472 		(void *)&cmd_operate_detach_device_identifier,
1473 		NULL,
1474 	},
1475 };
1476 /* *** configure speed for all ports *** */
1477 struct cmd_config_speed_all {
1478 	cmdline_fixed_string_t port;
1479 	cmdline_fixed_string_t keyword;
1480 	cmdline_fixed_string_t all;
1481 	cmdline_fixed_string_t item1;
1482 	cmdline_fixed_string_t item2;
1483 	cmdline_fixed_string_t value1;
1484 	cmdline_fixed_string_t value2;
1485 };
1486 
1487 static int
1488 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1489 {
1490 
1491 	int duplex;
1492 
1493 	if (!strcmp(duplexstr, "half")) {
1494 		duplex = ETH_LINK_HALF_DUPLEX;
1495 	} else if (!strcmp(duplexstr, "full")) {
1496 		duplex = ETH_LINK_FULL_DUPLEX;
1497 	} else if (!strcmp(duplexstr, "auto")) {
1498 		duplex = ETH_LINK_FULL_DUPLEX;
1499 	} else {
1500 		printf("Unknown duplex parameter\n");
1501 		return -1;
1502 	}
1503 
1504 	if (!strcmp(speedstr, "10")) {
1505 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1506 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1507 	} else if (!strcmp(speedstr, "100")) {
1508 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1509 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1510 	} else {
1511 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1512 			printf("Invalid speed/duplex parameters\n");
1513 			return -1;
1514 		}
1515 		if (!strcmp(speedstr, "1000")) {
1516 			*speed = ETH_LINK_SPEED_1G;
1517 		} else if (!strcmp(speedstr, "10000")) {
1518 			*speed = ETH_LINK_SPEED_10G;
1519 		} else if (!strcmp(speedstr, "25000")) {
1520 			*speed = ETH_LINK_SPEED_25G;
1521 		} else if (!strcmp(speedstr, "40000")) {
1522 			*speed = ETH_LINK_SPEED_40G;
1523 		} else if (!strcmp(speedstr, "50000")) {
1524 			*speed = ETH_LINK_SPEED_50G;
1525 		} else if (!strcmp(speedstr, "100000")) {
1526 			*speed = ETH_LINK_SPEED_100G;
1527 		} else if (!strcmp(speedstr, "200000")) {
1528 			*speed = ETH_LINK_SPEED_200G;
1529 		} else if (!strcmp(speedstr, "auto")) {
1530 			*speed = ETH_LINK_SPEED_AUTONEG;
1531 		} else {
1532 			printf("Unknown speed parameter\n");
1533 			return -1;
1534 		}
1535 	}
1536 
1537 	if (*speed != ETH_LINK_SPEED_AUTONEG)
1538 		*speed |= ETH_LINK_SPEED_FIXED;
1539 
1540 	return 0;
1541 }
1542 
1543 static void
1544 cmd_config_speed_all_parsed(void *parsed_result,
1545 			__rte_unused struct cmdline *cl,
1546 			__rte_unused void *data)
1547 {
1548 	struct cmd_config_speed_all *res = parsed_result;
1549 	uint32_t link_speed;
1550 	portid_t pid;
1551 
1552 	if (!all_ports_stopped()) {
1553 		printf("Please stop all ports first\n");
1554 		return;
1555 	}
1556 
1557 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1558 			&link_speed) < 0)
1559 		return;
1560 
1561 	RTE_ETH_FOREACH_DEV(pid) {
1562 		ports[pid].dev_conf.link_speeds = link_speed;
1563 	}
1564 
1565 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1566 }
1567 
1568 cmdline_parse_token_string_t cmd_config_speed_all_port =
1569 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1570 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1571 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1572 							"config");
1573 cmdline_parse_token_string_t cmd_config_speed_all_all =
1574 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1575 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1576 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1577 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1578 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1579 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1580 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1581 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1582 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1583 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1584 						"half#full#auto");
1585 
1586 cmdline_parse_inst_t cmd_config_speed_all = {
1587 	.f = cmd_config_speed_all_parsed,
1588 	.data = NULL,
1589 	.help_str = "port config all speed "
1590 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1591 							"half|full|auto",
1592 	.tokens = {
1593 		(void *)&cmd_config_speed_all_port,
1594 		(void *)&cmd_config_speed_all_keyword,
1595 		(void *)&cmd_config_speed_all_all,
1596 		(void *)&cmd_config_speed_all_item1,
1597 		(void *)&cmd_config_speed_all_value1,
1598 		(void *)&cmd_config_speed_all_item2,
1599 		(void *)&cmd_config_speed_all_value2,
1600 		NULL,
1601 	},
1602 };
1603 
1604 /* *** configure speed for specific port *** */
1605 struct cmd_config_speed_specific {
1606 	cmdline_fixed_string_t port;
1607 	cmdline_fixed_string_t keyword;
1608 	portid_t id;
1609 	cmdline_fixed_string_t item1;
1610 	cmdline_fixed_string_t item2;
1611 	cmdline_fixed_string_t value1;
1612 	cmdline_fixed_string_t value2;
1613 };
1614 
1615 static void
1616 cmd_config_speed_specific_parsed(void *parsed_result,
1617 				__rte_unused struct cmdline *cl,
1618 				__rte_unused void *data)
1619 {
1620 	struct cmd_config_speed_specific *res = parsed_result;
1621 	uint32_t link_speed;
1622 
1623 	if (!all_ports_stopped()) {
1624 		printf("Please stop all ports first\n");
1625 		return;
1626 	}
1627 
1628 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1629 		return;
1630 
1631 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1632 			&link_speed) < 0)
1633 		return;
1634 
1635 	ports[res->id].dev_conf.link_speeds = link_speed;
1636 
1637 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1638 }
1639 
1640 
1641 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1642 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1643 								"port");
1644 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1645 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1646 								"config");
1647 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1648 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1649 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1650 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1651 								"speed");
1652 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1653 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1654 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1655 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1656 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1657 								"duplex");
1658 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1659 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1660 							"half#full#auto");
1661 
1662 cmdline_parse_inst_t cmd_config_speed_specific = {
1663 	.f = cmd_config_speed_specific_parsed,
1664 	.data = NULL,
1665 	.help_str = "port config <port_id> speed "
1666 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1667 							"half|full|auto",
1668 	.tokens = {
1669 		(void *)&cmd_config_speed_specific_port,
1670 		(void *)&cmd_config_speed_specific_keyword,
1671 		(void *)&cmd_config_speed_specific_id,
1672 		(void *)&cmd_config_speed_specific_item1,
1673 		(void *)&cmd_config_speed_specific_value1,
1674 		(void *)&cmd_config_speed_specific_item2,
1675 		(void *)&cmd_config_speed_specific_value2,
1676 		NULL,
1677 	},
1678 };
1679 
1680 /* *** configure loopback for all ports *** */
1681 struct cmd_config_loopback_all {
1682 	cmdline_fixed_string_t port;
1683 	cmdline_fixed_string_t keyword;
1684 	cmdline_fixed_string_t all;
1685 	cmdline_fixed_string_t item;
1686 	uint32_t mode;
1687 };
1688 
1689 static void
1690 cmd_config_loopback_all_parsed(void *parsed_result,
1691 			__rte_unused struct cmdline *cl,
1692 			__rte_unused void *data)
1693 {
1694 	struct cmd_config_loopback_all *res = parsed_result;
1695 	portid_t pid;
1696 
1697 	if (!all_ports_stopped()) {
1698 		printf("Please stop all ports first\n");
1699 		return;
1700 	}
1701 
1702 	RTE_ETH_FOREACH_DEV(pid) {
1703 		ports[pid].dev_conf.lpbk_mode = res->mode;
1704 	}
1705 
1706 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1707 }
1708 
1709 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1710 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1711 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1712 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1713 							"config");
1714 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1715 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1716 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1717 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1718 							"loopback");
1719 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1720 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1721 
1722 cmdline_parse_inst_t cmd_config_loopback_all = {
1723 	.f = cmd_config_loopback_all_parsed,
1724 	.data = NULL,
1725 	.help_str = "port config all loopback <mode>",
1726 	.tokens = {
1727 		(void *)&cmd_config_loopback_all_port,
1728 		(void *)&cmd_config_loopback_all_keyword,
1729 		(void *)&cmd_config_loopback_all_all,
1730 		(void *)&cmd_config_loopback_all_item,
1731 		(void *)&cmd_config_loopback_all_mode,
1732 		NULL,
1733 	},
1734 };
1735 
1736 /* *** configure loopback for specific port *** */
1737 struct cmd_config_loopback_specific {
1738 	cmdline_fixed_string_t port;
1739 	cmdline_fixed_string_t keyword;
1740 	uint16_t port_id;
1741 	cmdline_fixed_string_t item;
1742 	uint32_t mode;
1743 };
1744 
1745 static void
1746 cmd_config_loopback_specific_parsed(void *parsed_result,
1747 				__rte_unused struct cmdline *cl,
1748 				__rte_unused void *data)
1749 {
1750 	struct cmd_config_loopback_specific *res = parsed_result;
1751 
1752 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1753 		return;
1754 
1755 	if (!port_is_stopped(res->port_id)) {
1756 		printf("Please stop port %u first\n", res->port_id);
1757 		return;
1758 	}
1759 
1760 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1761 
1762 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1763 }
1764 
1765 
1766 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1767 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1768 								"port");
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1770 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1771 								"config");
1772 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1773 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1774 								RTE_UINT16);
1775 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1776 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1777 								"loopback");
1778 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1779 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1780 			      RTE_UINT32);
1781 
1782 cmdline_parse_inst_t cmd_config_loopback_specific = {
1783 	.f = cmd_config_loopback_specific_parsed,
1784 	.data = NULL,
1785 	.help_str = "port config <port_id> loopback <mode>",
1786 	.tokens = {
1787 		(void *)&cmd_config_loopback_specific_port,
1788 		(void *)&cmd_config_loopback_specific_keyword,
1789 		(void *)&cmd_config_loopback_specific_id,
1790 		(void *)&cmd_config_loopback_specific_item,
1791 		(void *)&cmd_config_loopback_specific_mode,
1792 		NULL,
1793 	},
1794 };
1795 
1796 /* *** configure txq/rxq, txd/rxd *** */
1797 struct cmd_config_rx_tx {
1798 	cmdline_fixed_string_t port;
1799 	cmdline_fixed_string_t keyword;
1800 	cmdline_fixed_string_t all;
1801 	cmdline_fixed_string_t name;
1802 	uint16_t value;
1803 };
1804 
1805 static void
1806 cmd_config_rx_tx_parsed(void *parsed_result,
1807 			__rte_unused struct cmdline *cl,
1808 			__rte_unused void *data)
1809 {
1810 	struct cmd_config_rx_tx *res = parsed_result;
1811 
1812 	if (!all_ports_stopped()) {
1813 		printf("Please stop all ports first\n");
1814 		return;
1815 	}
1816 	if (!strcmp(res->name, "rxq")) {
1817 		if (!res->value && !nb_txq) {
1818 			printf("Warning: Either rx or tx queues should be non zero\n");
1819 			return;
1820 		}
1821 		if (check_nb_rxq(res->value) != 0)
1822 			return;
1823 		nb_rxq = res->value;
1824 	}
1825 	else if (!strcmp(res->name, "txq")) {
1826 		if (!res->value && !nb_rxq) {
1827 			printf("Warning: Either rx or tx queues should be non zero\n");
1828 			return;
1829 		}
1830 		if (check_nb_txq(res->value) != 0)
1831 			return;
1832 		nb_txq = res->value;
1833 	}
1834 	else if (!strcmp(res->name, "rxd")) {
1835 		if (check_nb_rxd(res->value) != 0)
1836 			return;
1837 		nb_rxd = res->value;
1838 	} else if (!strcmp(res->name, "txd")) {
1839 		if (check_nb_txd(res->value) != 0)
1840 			return;
1841 
1842 		nb_txd = res->value;
1843 	} else {
1844 		printf("Unknown parameter\n");
1845 		return;
1846 	}
1847 
1848 	fwd_config_setup();
1849 
1850 	init_port_config();
1851 
1852 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1853 }
1854 
1855 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1856 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1857 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1858 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1859 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1860 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1861 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1862 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1863 						"rxq#txq#rxd#txd");
1864 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1865 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1866 
1867 cmdline_parse_inst_t cmd_config_rx_tx = {
1868 	.f = cmd_config_rx_tx_parsed,
1869 	.data = NULL,
1870 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1871 	.tokens = {
1872 		(void *)&cmd_config_rx_tx_port,
1873 		(void *)&cmd_config_rx_tx_keyword,
1874 		(void *)&cmd_config_rx_tx_all,
1875 		(void *)&cmd_config_rx_tx_name,
1876 		(void *)&cmd_config_rx_tx_value,
1877 		NULL,
1878 	},
1879 };
1880 
1881 /* *** config max packet length *** */
1882 struct cmd_config_max_pkt_len_result {
1883 	cmdline_fixed_string_t port;
1884 	cmdline_fixed_string_t keyword;
1885 	cmdline_fixed_string_t all;
1886 	cmdline_fixed_string_t name;
1887 	uint32_t value;
1888 };
1889 
1890 static void
1891 cmd_config_max_pkt_len_parsed(void *parsed_result,
1892 				__rte_unused struct cmdline *cl,
1893 				__rte_unused void *data)
1894 {
1895 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1896 	uint32_t max_rx_pkt_len_backup = 0;
1897 	portid_t pid;
1898 	int ret;
1899 
1900 	if (!all_ports_stopped()) {
1901 		printf("Please stop all ports first\n");
1902 		return;
1903 	}
1904 
1905 	RTE_ETH_FOREACH_DEV(pid) {
1906 		struct rte_port *port = &ports[pid];
1907 
1908 		if (!strcmp(res->name, "max-pkt-len")) {
1909 			if (res->value < RTE_ETHER_MIN_LEN) {
1910 				printf("max-pkt-len can not be less than %d\n",
1911 						RTE_ETHER_MIN_LEN);
1912 				return;
1913 			}
1914 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1915 				return;
1916 
1917 			ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1918 			if (ret != 0) {
1919 				printf("rte_eth_dev_info_get() failed for port %u\n",
1920 					pid);
1921 				return;
1922 			}
1923 
1924 			max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1925 
1926 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1927 			if (update_jumbo_frame_offload(pid) != 0)
1928 				port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1929 		} else {
1930 			printf("Unknown parameter\n");
1931 			return;
1932 		}
1933 	}
1934 
1935 	init_port_config();
1936 
1937 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1938 }
1939 
1940 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1941 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1942 								"port");
1943 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1944 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1945 								"config");
1946 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1947 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1948 								"all");
1949 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1950 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1951 								"max-pkt-len");
1952 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1953 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1954 								RTE_UINT32);
1955 
1956 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1957 	.f = cmd_config_max_pkt_len_parsed,
1958 	.data = NULL,
1959 	.help_str = "port config all max-pkt-len <value>",
1960 	.tokens = {
1961 		(void *)&cmd_config_max_pkt_len_port,
1962 		(void *)&cmd_config_max_pkt_len_keyword,
1963 		(void *)&cmd_config_max_pkt_len_all,
1964 		(void *)&cmd_config_max_pkt_len_name,
1965 		(void *)&cmd_config_max_pkt_len_value,
1966 		NULL,
1967 	},
1968 };
1969 
1970 /* *** config max LRO aggregated packet size *** */
1971 struct cmd_config_max_lro_pkt_size_result {
1972 	cmdline_fixed_string_t port;
1973 	cmdline_fixed_string_t keyword;
1974 	cmdline_fixed_string_t all;
1975 	cmdline_fixed_string_t name;
1976 	uint32_t value;
1977 };
1978 
1979 static void
1980 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1981 				__rte_unused struct cmdline *cl,
1982 				__rte_unused void *data)
1983 {
1984 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1985 	portid_t pid;
1986 
1987 	if (!all_ports_stopped()) {
1988 		printf("Please stop all ports first\n");
1989 		return;
1990 	}
1991 
1992 	RTE_ETH_FOREACH_DEV(pid) {
1993 		struct rte_port *port = &ports[pid];
1994 
1995 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1996 			if (res->value ==
1997 					port->dev_conf.rxmode.max_lro_pkt_size)
1998 				return;
1999 
2000 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2001 		} else {
2002 			printf("Unknown parameter\n");
2003 			return;
2004 		}
2005 	}
2006 
2007 	init_port_config();
2008 
2009 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2010 }
2011 
2012 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2013 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2014 				 port, "port");
2015 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2016 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2017 				 keyword, "config");
2018 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2019 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2020 				 all, "all");
2021 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2022 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2023 				 name, "max-lro-pkt-size");
2024 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2025 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2026 			      value, RTE_UINT32);
2027 
2028 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2029 	.f = cmd_config_max_lro_pkt_size_parsed,
2030 	.data = NULL,
2031 	.help_str = "port config all max-lro-pkt-size <value>",
2032 	.tokens = {
2033 		(void *)&cmd_config_max_lro_pkt_size_port,
2034 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2035 		(void *)&cmd_config_max_lro_pkt_size_all,
2036 		(void *)&cmd_config_max_lro_pkt_size_name,
2037 		(void *)&cmd_config_max_lro_pkt_size_value,
2038 		NULL,
2039 	},
2040 };
2041 
2042 /* *** configure port MTU *** */
2043 struct cmd_config_mtu_result {
2044 	cmdline_fixed_string_t port;
2045 	cmdline_fixed_string_t keyword;
2046 	cmdline_fixed_string_t mtu;
2047 	portid_t port_id;
2048 	uint16_t value;
2049 };
2050 
2051 static void
2052 cmd_config_mtu_parsed(void *parsed_result,
2053 		      __rte_unused struct cmdline *cl,
2054 		      __rte_unused void *data)
2055 {
2056 	struct cmd_config_mtu_result *res = parsed_result;
2057 
2058 	if (res->value < RTE_ETHER_MIN_LEN) {
2059 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2060 		return;
2061 	}
2062 	port_mtu_set(res->port_id, res->value);
2063 }
2064 
2065 cmdline_parse_token_string_t cmd_config_mtu_port =
2066 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2067 				 "port");
2068 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2069 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2070 				 "config");
2071 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2072 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2073 				 "mtu");
2074 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2075 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2076 				 RTE_UINT16);
2077 cmdline_parse_token_num_t cmd_config_mtu_value =
2078 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2079 				 RTE_UINT16);
2080 
2081 cmdline_parse_inst_t cmd_config_mtu = {
2082 	.f = cmd_config_mtu_parsed,
2083 	.data = NULL,
2084 	.help_str = "port config mtu <port_id> <value>",
2085 	.tokens = {
2086 		(void *)&cmd_config_mtu_port,
2087 		(void *)&cmd_config_mtu_keyword,
2088 		(void *)&cmd_config_mtu_mtu,
2089 		(void *)&cmd_config_mtu_port_id,
2090 		(void *)&cmd_config_mtu_value,
2091 		NULL,
2092 	},
2093 };
2094 
2095 /* *** configure rx mode *** */
2096 struct cmd_config_rx_mode_flag {
2097 	cmdline_fixed_string_t port;
2098 	cmdline_fixed_string_t keyword;
2099 	cmdline_fixed_string_t all;
2100 	cmdline_fixed_string_t name;
2101 	cmdline_fixed_string_t value;
2102 };
2103 
2104 static void
2105 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2106 				__rte_unused struct cmdline *cl,
2107 				__rte_unused void *data)
2108 {
2109 	struct cmd_config_rx_mode_flag *res = parsed_result;
2110 
2111 	if (!all_ports_stopped()) {
2112 		printf("Please stop all ports first\n");
2113 		return;
2114 	}
2115 
2116 	if (!strcmp(res->name, "drop-en")) {
2117 		if (!strcmp(res->value, "on"))
2118 			rx_drop_en = 1;
2119 		else if (!strcmp(res->value, "off"))
2120 			rx_drop_en = 0;
2121 		else {
2122 			printf("Unknown parameter\n");
2123 			return;
2124 		}
2125 	} else {
2126 		printf("Unknown parameter\n");
2127 		return;
2128 	}
2129 
2130 	init_port_config();
2131 
2132 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2133 }
2134 
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2136 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2138 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2139 								"config");
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2141 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2142 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2143 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2144 					"drop-en");
2145 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2146 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2147 							"on#off");
2148 
2149 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2150 	.f = cmd_config_rx_mode_flag_parsed,
2151 	.data = NULL,
2152 	.help_str = "port config all drop-en on|off",
2153 	.tokens = {
2154 		(void *)&cmd_config_rx_mode_flag_port,
2155 		(void *)&cmd_config_rx_mode_flag_keyword,
2156 		(void *)&cmd_config_rx_mode_flag_all,
2157 		(void *)&cmd_config_rx_mode_flag_name,
2158 		(void *)&cmd_config_rx_mode_flag_value,
2159 		NULL,
2160 	},
2161 };
2162 
2163 /* *** configure rss *** */
2164 struct cmd_config_rss {
2165 	cmdline_fixed_string_t port;
2166 	cmdline_fixed_string_t keyword;
2167 	cmdline_fixed_string_t all;
2168 	cmdline_fixed_string_t name;
2169 	cmdline_fixed_string_t value;
2170 };
2171 
2172 static void
2173 cmd_config_rss_parsed(void *parsed_result,
2174 			__rte_unused struct cmdline *cl,
2175 			__rte_unused void *data)
2176 {
2177 	struct cmd_config_rss *res = parsed_result;
2178 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2179 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2180 	int use_default = 0;
2181 	int all_updated = 1;
2182 	int diag;
2183 	uint16_t i;
2184 	int ret;
2185 
2186 	if (!strcmp(res->value, "all"))
2187 		rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2188 			ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2189 			ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2190 			ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2191 			ETH_RSS_ECPRI;
2192 	else if (!strcmp(res->value, "eth"))
2193 		rss_conf.rss_hf = ETH_RSS_ETH;
2194 	else if (!strcmp(res->value, "vlan"))
2195 		rss_conf.rss_hf = ETH_RSS_VLAN;
2196 	else if (!strcmp(res->value, "ip"))
2197 		rss_conf.rss_hf = ETH_RSS_IP;
2198 	else if (!strcmp(res->value, "udp"))
2199 		rss_conf.rss_hf = ETH_RSS_UDP;
2200 	else if (!strcmp(res->value, "tcp"))
2201 		rss_conf.rss_hf = ETH_RSS_TCP;
2202 	else if (!strcmp(res->value, "sctp"))
2203 		rss_conf.rss_hf = ETH_RSS_SCTP;
2204 	else if (!strcmp(res->value, "ether"))
2205 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2206 	else if (!strcmp(res->value, "port"))
2207 		rss_conf.rss_hf = ETH_RSS_PORT;
2208 	else if (!strcmp(res->value, "vxlan"))
2209 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2210 	else if (!strcmp(res->value, "geneve"))
2211 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2212 	else if (!strcmp(res->value, "nvgre"))
2213 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2214 	else if (!strcmp(res->value, "l3-pre32"))
2215 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2216 	else if (!strcmp(res->value, "l3-pre40"))
2217 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2218 	else if (!strcmp(res->value, "l3-pre48"))
2219 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2220 	else if (!strcmp(res->value, "l3-pre56"))
2221 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2222 	else if (!strcmp(res->value, "l3-pre64"))
2223 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2224 	else if (!strcmp(res->value, "l3-pre96"))
2225 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2226 	else if (!strcmp(res->value, "l3-src-only"))
2227 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2228 	else if (!strcmp(res->value, "l3-dst-only"))
2229 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2230 	else if (!strcmp(res->value, "l4-src-only"))
2231 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2232 	else if (!strcmp(res->value, "l4-dst-only"))
2233 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2234 	else if (!strcmp(res->value, "l2-src-only"))
2235 		rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2236 	else if (!strcmp(res->value, "l2-dst-only"))
2237 		rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2238 	else if (!strcmp(res->value, "l2tpv3"))
2239 		rss_conf.rss_hf = ETH_RSS_L2TPV3;
2240 	else if (!strcmp(res->value, "esp"))
2241 		rss_conf.rss_hf = ETH_RSS_ESP;
2242 	else if (!strcmp(res->value, "ah"))
2243 		rss_conf.rss_hf = ETH_RSS_AH;
2244 	else if (!strcmp(res->value, "pfcp"))
2245 		rss_conf.rss_hf = ETH_RSS_PFCP;
2246 	else if (!strcmp(res->value, "pppoe"))
2247 		rss_conf.rss_hf = ETH_RSS_PPPOE;
2248 	else if (!strcmp(res->value, "gtpu"))
2249 		rss_conf.rss_hf = ETH_RSS_GTPU;
2250 	else if (!strcmp(res->value, "ecpri"))
2251 		rss_conf.rss_hf = ETH_RSS_ECPRI;
2252 	else if (!strcmp(res->value, "mpls"))
2253 		rss_conf.rss_hf = ETH_RSS_MPLS;
2254 	else if (!strcmp(res->value, "none"))
2255 		rss_conf.rss_hf = 0;
2256 	else if (!strcmp(res->value, "level-default")) {
2257 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2258 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2259 	} else if (!strcmp(res->value, "level-outer")) {
2260 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2261 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2262 	} else if (!strcmp(res->value, "level-inner")) {
2263 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2264 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2265 	} else if (!strcmp(res->value, "default"))
2266 		use_default = 1;
2267 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2268 						atoi(res->value) < 64)
2269 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2270 	else {
2271 		printf("Unknown parameter\n");
2272 		return;
2273 	}
2274 	rss_conf.rss_key = NULL;
2275 	/* Update global configuration for RSS types. */
2276 	RTE_ETH_FOREACH_DEV(i) {
2277 		struct rte_eth_rss_conf local_rss_conf;
2278 
2279 		ret = eth_dev_info_get_print_err(i, &dev_info);
2280 		if (ret != 0)
2281 			return;
2282 
2283 		if (use_default)
2284 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2285 
2286 		local_rss_conf = rss_conf;
2287 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2288 			dev_info.flow_type_rss_offloads;
2289 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2290 			printf("Port %u modified RSS hash function based on hardware support,"
2291 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2292 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2293 		}
2294 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2295 		if (diag < 0) {
2296 			all_updated = 0;
2297 			printf("Configuration of RSS hash at ethernet port %d "
2298 				"failed with error (%d): %s.\n",
2299 				i, -diag, strerror(-diag));
2300 		}
2301 	}
2302 	if (all_updated && !use_default) {
2303 		rss_hf = rss_conf.rss_hf;
2304 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2305 	}
2306 }
2307 
2308 cmdline_parse_token_string_t cmd_config_rss_port =
2309 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2310 cmdline_parse_token_string_t cmd_config_rss_keyword =
2311 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2312 cmdline_parse_token_string_t cmd_config_rss_all =
2313 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2314 cmdline_parse_token_string_t cmd_config_rss_name =
2315 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2316 cmdline_parse_token_string_t cmd_config_rss_value =
2317 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2318 
2319 cmdline_parse_inst_t cmd_config_rss = {
2320 	.f = cmd_config_rss_parsed,
2321 	.data = NULL,
2322 	.help_str = "port config all rss "
2323 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2324 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2325 		"level-outer|level-inner|<flowtype_id>",
2326 	.tokens = {
2327 		(void *)&cmd_config_rss_port,
2328 		(void *)&cmd_config_rss_keyword,
2329 		(void *)&cmd_config_rss_all,
2330 		(void *)&cmd_config_rss_name,
2331 		(void *)&cmd_config_rss_value,
2332 		NULL,
2333 	},
2334 };
2335 
2336 /* *** configure rss hash key *** */
2337 struct cmd_config_rss_hash_key {
2338 	cmdline_fixed_string_t port;
2339 	cmdline_fixed_string_t config;
2340 	portid_t port_id;
2341 	cmdline_fixed_string_t rss_hash_key;
2342 	cmdline_fixed_string_t rss_type;
2343 	cmdline_fixed_string_t key;
2344 };
2345 
2346 static uint8_t
2347 hexa_digit_to_value(char hexa_digit)
2348 {
2349 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2350 		return (uint8_t) (hexa_digit - '0');
2351 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2352 		return (uint8_t) ((hexa_digit - 'a') + 10);
2353 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2354 		return (uint8_t) ((hexa_digit - 'A') + 10);
2355 	/* Invalid hexa digit */
2356 	return 0xFF;
2357 }
2358 
2359 static uint8_t
2360 parse_and_check_key_hexa_digit(char *key, int idx)
2361 {
2362 	uint8_t hexa_v;
2363 
2364 	hexa_v = hexa_digit_to_value(key[idx]);
2365 	if (hexa_v == 0xFF)
2366 		printf("invalid key: character %c at position %d is not a "
2367 		       "valid hexa digit\n", key[idx], idx);
2368 	return hexa_v;
2369 }
2370 
2371 static void
2372 cmd_config_rss_hash_key_parsed(void *parsed_result,
2373 			       __rte_unused struct cmdline *cl,
2374 			       __rte_unused void *data)
2375 {
2376 	struct cmd_config_rss_hash_key *res = parsed_result;
2377 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2378 	uint8_t xdgt0;
2379 	uint8_t xdgt1;
2380 	int i;
2381 	struct rte_eth_dev_info dev_info;
2382 	uint8_t hash_key_size;
2383 	uint32_t key_len;
2384 	int ret;
2385 
2386 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2387 	if (ret != 0)
2388 		return;
2389 
2390 	if (dev_info.hash_key_size > 0 &&
2391 			dev_info.hash_key_size <= sizeof(hash_key))
2392 		hash_key_size = dev_info.hash_key_size;
2393 	else {
2394 		printf("dev_info did not provide a valid hash key size\n");
2395 		return;
2396 	}
2397 	/* Check the length of the RSS hash key */
2398 	key_len = strlen(res->key);
2399 	if (key_len != (hash_key_size * 2)) {
2400 		printf("key length: %d invalid - key must be a string of %d"
2401 			   " hexa-decimal numbers\n",
2402 			   (int) key_len, hash_key_size * 2);
2403 		return;
2404 	}
2405 	/* Translate RSS hash key into binary representation */
2406 	for (i = 0; i < hash_key_size; i++) {
2407 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2408 		if (xdgt0 == 0xFF)
2409 			return;
2410 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2411 		if (xdgt1 == 0xFF)
2412 			return;
2413 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2414 	}
2415 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2416 			hash_key_size);
2417 }
2418 
2419 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2420 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2421 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2422 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2423 				 "config");
2424 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2425 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2426 				 RTE_UINT16);
2427 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2428 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2429 				 rss_hash_key, "rss-hash-key");
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2431 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2432 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2433 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2434 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2435 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2436 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2437 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2438 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2439 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2440 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2441 
2442 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2443 	.f = cmd_config_rss_hash_key_parsed,
2444 	.data = NULL,
2445 	.help_str = "port config <port_id> rss-hash-key "
2446 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2447 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2448 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2449 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2450 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2451 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2452 		"<string of hex digits (variable length, NIC dependent)>",
2453 	.tokens = {
2454 		(void *)&cmd_config_rss_hash_key_port,
2455 		(void *)&cmd_config_rss_hash_key_config,
2456 		(void *)&cmd_config_rss_hash_key_port_id,
2457 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2458 		(void *)&cmd_config_rss_hash_key_rss_type,
2459 		(void *)&cmd_config_rss_hash_key_value,
2460 		NULL,
2461 	},
2462 };
2463 
2464 /* *** cleanup txq mbufs *** */
2465 struct cmd_cleanup_txq_mbufs_result {
2466 	cmdline_fixed_string_t port;
2467 	cmdline_fixed_string_t keyword;
2468 	cmdline_fixed_string_t name;
2469 	uint16_t port_id;
2470 	uint16_t queue_id;
2471 	uint32_t free_cnt;
2472 };
2473 
2474 static void
2475 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2476 			     __rte_unused struct cmdline *cl,
2477 			     __rte_unused void *data)
2478 {
2479 	struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2480 	uint16_t port_id = res->port_id;
2481 	uint16_t queue_id = res->queue_id;
2482 	uint32_t free_cnt = res->free_cnt;
2483 	struct rte_eth_txq_info qinfo;
2484 	int ret;
2485 
2486 	if (test_done == 0) {
2487 		printf("Please stop forwarding first\n");
2488 		return;
2489 	}
2490 
2491 	if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2492 		printf("Failed to get port %u Tx queue %u info\n",
2493 		       port_id, queue_id);
2494 		return;
2495 	}
2496 
2497 	if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2498 		printf("Tx queue %u not started\n", queue_id);
2499 		return;
2500 	}
2501 
2502 	ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2503 	if (ret < 0) {
2504 		printf("Failed to cleanup mbuf for port %u Tx queue %u "
2505 		       "error desc: %s(%d)\n",
2506 		       port_id, queue_id, strerror(-ret), ret);
2507 		return;
2508 	}
2509 
2510 	printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2511 	       port_id, queue_id, ret);
2512 }
2513 
2514 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2515 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2516 				 "port");
2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2518 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2519 				 "cleanup");
2520 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2521 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2522 			      RTE_UINT16);
2523 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2524 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2525 				 "txq");
2526 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2527 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2528 			      RTE_UINT16);
2529 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2530 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2531 			      RTE_UINT32);
2532 
2533 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2534 	.f = cmd_cleanup_txq_mbufs_parsed,
2535 	.data = NULL,
2536 	.help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2537 	.tokens = {
2538 		(void *)&cmd_cleanup_txq_mbufs_port,
2539 		(void *)&cmd_cleanup_txq_mbufs_cleanup,
2540 		(void *)&cmd_cleanup_txq_mbufs_port_id,
2541 		(void *)&cmd_cleanup_txq_mbufs_txq,
2542 		(void *)&cmd_cleanup_txq_mbufs_queue_id,
2543 		(void *)&cmd_cleanup_txq_mbufs_free_cnt,
2544 		NULL,
2545 	},
2546 };
2547 
2548 /* *** configure port rxq/txq ring size *** */
2549 struct cmd_config_rxtx_ring_size {
2550 	cmdline_fixed_string_t port;
2551 	cmdline_fixed_string_t config;
2552 	portid_t portid;
2553 	cmdline_fixed_string_t rxtxq;
2554 	uint16_t qid;
2555 	cmdline_fixed_string_t rsize;
2556 	uint16_t size;
2557 };
2558 
2559 static void
2560 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2561 				 __rte_unused struct cmdline *cl,
2562 				 __rte_unused void *data)
2563 {
2564 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2565 	struct rte_port *port;
2566 	uint8_t isrx;
2567 
2568 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2569 		return;
2570 
2571 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2572 		printf("Invalid port id\n");
2573 		return;
2574 	}
2575 
2576 	port = &ports[res->portid];
2577 
2578 	if (!strcmp(res->rxtxq, "rxq"))
2579 		isrx = 1;
2580 	else if (!strcmp(res->rxtxq, "txq"))
2581 		isrx = 0;
2582 	else {
2583 		printf("Unknown parameter\n");
2584 		return;
2585 	}
2586 
2587 	if (isrx && rx_queue_id_is_invalid(res->qid))
2588 		return;
2589 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2590 		return;
2591 
2592 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2593 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2594 		       rx_free_thresh);
2595 		return;
2596 	}
2597 
2598 	if (isrx)
2599 		port->nb_rx_desc[res->qid] = res->size;
2600 	else
2601 		port->nb_tx_desc[res->qid] = res->size;
2602 
2603 	cmd_reconfig_device_queue(res->portid, 0, 1);
2604 }
2605 
2606 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2607 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2608 				 port, "port");
2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2610 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2611 				 config, "config");
2612 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2613 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 				 portid, RTE_UINT16);
2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2616 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2617 				 rxtxq, "rxq#txq");
2618 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2619 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 			      qid, RTE_UINT16);
2621 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2622 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2623 				 rsize, "ring_size");
2624 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2625 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 			      size, RTE_UINT16);
2627 
2628 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2629 	.f = cmd_config_rxtx_ring_size_parsed,
2630 	.data = NULL,
2631 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2632 	.tokens = {
2633 		(void *)&cmd_config_rxtx_ring_size_port,
2634 		(void *)&cmd_config_rxtx_ring_size_config,
2635 		(void *)&cmd_config_rxtx_ring_size_portid,
2636 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2637 		(void *)&cmd_config_rxtx_ring_size_qid,
2638 		(void *)&cmd_config_rxtx_ring_size_rsize,
2639 		(void *)&cmd_config_rxtx_ring_size_size,
2640 		NULL,
2641 	},
2642 };
2643 
2644 /* *** configure port rxq/txq start/stop *** */
2645 struct cmd_config_rxtx_queue {
2646 	cmdline_fixed_string_t port;
2647 	portid_t portid;
2648 	cmdline_fixed_string_t rxtxq;
2649 	uint16_t qid;
2650 	cmdline_fixed_string_t opname;
2651 };
2652 
2653 static void
2654 cmd_config_rxtx_queue_parsed(void *parsed_result,
2655 			__rte_unused struct cmdline *cl,
2656 			__rte_unused void *data)
2657 {
2658 	struct cmd_config_rxtx_queue *res = parsed_result;
2659 	uint8_t isrx;
2660 	uint8_t isstart;
2661 	int ret = 0;
2662 
2663 	if (test_done == 0) {
2664 		printf("Please stop forwarding first\n");
2665 		return;
2666 	}
2667 
2668 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2669 		return;
2670 
2671 	if (port_is_started(res->portid) != 1) {
2672 		printf("Please start port %u first\n", res->portid);
2673 		return;
2674 	}
2675 
2676 	if (!strcmp(res->rxtxq, "rxq"))
2677 		isrx = 1;
2678 	else if (!strcmp(res->rxtxq, "txq"))
2679 		isrx = 0;
2680 	else {
2681 		printf("Unknown parameter\n");
2682 		return;
2683 	}
2684 
2685 	if (isrx && rx_queue_id_is_invalid(res->qid))
2686 		return;
2687 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2688 		return;
2689 
2690 	if (!strcmp(res->opname, "start"))
2691 		isstart = 1;
2692 	else if (!strcmp(res->opname, "stop"))
2693 		isstart = 0;
2694 	else {
2695 		printf("Unknown parameter\n");
2696 		return;
2697 	}
2698 
2699 	if (isstart && isrx)
2700 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2701 	else if (!isstart && isrx)
2702 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2703 	else if (isstart && !isrx)
2704 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2705 	else
2706 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2707 
2708 	if (ret == -ENOTSUP)
2709 		printf("Function not supported in PMD driver\n");
2710 }
2711 
2712 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2713 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2714 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2715 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2716 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2717 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2718 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2719 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2720 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2721 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2722 						"start#stop");
2723 
2724 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2725 	.f = cmd_config_rxtx_queue_parsed,
2726 	.data = NULL,
2727 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2728 	.tokens = {
2729 		(void *)&cmd_config_rxtx_queue_port,
2730 		(void *)&cmd_config_rxtx_queue_portid,
2731 		(void *)&cmd_config_rxtx_queue_rxtxq,
2732 		(void *)&cmd_config_rxtx_queue_qid,
2733 		(void *)&cmd_config_rxtx_queue_opname,
2734 		NULL,
2735 	},
2736 };
2737 
2738 /* *** configure port rxq/txq deferred start on/off *** */
2739 struct cmd_config_deferred_start_rxtx_queue {
2740 	cmdline_fixed_string_t port;
2741 	portid_t port_id;
2742 	cmdline_fixed_string_t rxtxq;
2743 	uint16_t qid;
2744 	cmdline_fixed_string_t opname;
2745 	cmdline_fixed_string_t state;
2746 };
2747 
2748 static void
2749 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2750 			__rte_unused struct cmdline *cl,
2751 			__rte_unused void *data)
2752 {
2753 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2754 	struct rte_port *port;
2755 	uint8_t isrx;
2756 	uint8_t ison;
2757 	uint8_t needreconfig = 0;
2758 
2759 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2760 		return;
2761 
2762 	if (port_is_started(res->port_id) != 0) {
2763 		printf("Please stop port %u first\n", res->port_id);
2764 		return;
2765 	}
2766 
2767 	port = &ports[res->port_id];
2768 
2769 	isrx = !strcmp(res->rxtxq, "rxq");
2770 
2771 	if (isrx && rx_queue_id_is_invalid(res->qid))
2772 		return;
2773 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2774 		return;
2775 
2776 	ison = !strcmp(res->state, "on");
2777 
2778 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2779 		port->rx_conf[res->qid].rx_deferred_start = ison;
2780 		needreconfig = 1;
2781 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2782 		port->tx_conf[res->qid].tx_deferred_start = ison;
2783 		needreconfig = 1;
2784 	}
2785 
2786 	if (needreconfig)
2787 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2788 }
2789 
2790 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2791 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2792 						port, "port");
2793 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2794 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2795 						port_id, RTE_UINT16);
2796 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2797 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2798 						rxtxq, "rxq#txq");
2799 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2800 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 						qid, RTE_UINT16);
2802 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2803 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2804 						opname, "deferred_start");
2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2806 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2807 						state, "on#off");
2808 
2809 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2810 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2811 	.data = NULL,
2812 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2813 	.tokens = {
2814 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2815 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2816 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2817 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2818 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2819 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2820 		NULL,
2821 	},
2822 };
2823 
2824 /* *** configure port rxq/txq setup *** */
2825 struct cmd_setup_rxtx_queue {
2826 	cmdline_fixed_string_t port;
2827 	portid_t portid;
2828 	cmdline_fixed_string_t rxtxq;
2829 	uint16_t qid;
2830 	cmdline_fixed_string_t setup;
2831 };
2832 
2833 /* Common CLI fields for queue setup */
2834 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2835 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2836 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2837 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2838 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2839 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2840 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2841 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2842 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2843 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2844 
2845 static void
2846 cmd_setup_rxtx_queue_parsed(
2847 	void *parsed_result,
2848 	__rte_unused struct cmdline *cl,
2849 	__rte_unused void *data)
2850 {
2851 	struct cmd_setup_rxtx_queue *res = parsed_result;
2852 	struct rte_port *port;
2853 	struct rte_mempool *mp;
2854 	unsigned int socket_id;
2855 	uint8_t isrx = 0;
2856 	int ret;
2857 
2858 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2859 		return;
2860 
2861 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2862 		printf("Invalid port id\n");
2863 		return;
2864 	}
2865 
2866 	if (!strcmp(res->rxtxq, "rxq"))
2867 		isrx = 1;
2868 	else if (!strcmp(res->rxtxq, "txq"))
2869 		isrx = 0;
2870 	else {
2871 		printf("Unknown parameter\n");
2872 		return;
2873 	}
2874 
2875 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2876 		printf("Invalid rx queue\n");
2877 		return;
2878 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2879 		printf("Invalid tx queue\n");
2880 		return;
2881 	}
2882 
2883 	port = &ports[res->portid];
2884 	if (isrx) {
2885 		socket_id = rxring_numa[res->portid];
2886 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2887 			socket_id = port->socket_id;
2888 
2889 		mp = mbuf_pool_find(socket_id, 0);
2890 		if (mp == NULL) {
2891 			printf("Failed to setup RX queue: "
2892 				"No mempool allocation"
2893 				" on the socket %d\n",
2894 				rxring_numa[res->portid]);
2895 			return;
2896 		}
2897 		ret = rx_queue_setup(res->portid,
2898 				     res->qid,
2899 				     port->nb_rx_desc[res->qid],
2900 				     socket_id,
2901 				     &port->rx_conf[res->qid],
2902 				     mp);
2903 		if (ret)
2904 			printf("Failed to setup RX queue\n");
2905 	} else {
2906 		socket_id = txring_numa[res->portid];
2907 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2908 			socket_id = port->socket_id;
2909 
2910 		ret = rte_eth_tx_queue_setup(res->portid,
2911 					     res->qid,
2912 					     port->nb_tx_desc[res->qid],
2913 					     socket_id,
2914 					     &port->tx_conf[res->qid]);
2915 		if (ret)
2916 			printf("Failed to setup TX queue\n");
2917 	}
2918 }
2919 
2920 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2921 	.f = cmd_setup_rxtx_queue_parsed,
2922 	.data = NULL,
2923 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2924 	.tokens = {
2925 		(void *)&cmd_setup_rxtx_queue_port,
2926 		(void *)&cmd_setup_rxtx_queue_portid,
2927 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2928 		(void *)&cmd_setup_rxtx_queue_qid,
2929 		(void *)&cmd_setup_rxtx_queue_setup,
2930 		NULL,
2931 	},
2932 };
2933 
2934 
2935 /* *** Configure RSS RETA *** */
2936 struct cmd_config_rss_reta {
2937 	cmdline_fixed_string_t port;
2938 	cmdline_fixed_string_t keyword;
2939 	portid_t port_id;
2940 	cmdline_fixed_string_t name;
2941 	cmdline_fixed_string_t list_name;
2942 	cmdline_fixed_string_t list_of_items;
2943 };
2944 
2945 static int
2946 parse_reta_config(const char *str,
2947 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2948 		  uint16_t nb_entries)
2949 {
2950 	int i;
2951 	unsigned size;
2952 	uint16_t hash_index, idx, shift;
2953 	uint16_t nb_queue;
2954 	char s[256];
2955 	const char *p, *p0 = str;
2956 	char *end;
2957 	enum fieldnames {
2958 		FLD_HASH_INDEX = 0,
2959 		FLD_QUEUE,
2960 		_NUM_FLD
2961 	};
2962 	unsigned long int_fld[_NUM_FLD];
2963 	char *str_fld[_NUM_FLD];
2964 
2965 	while ((p = strchr(p0,'(')) != NULL) {
2966 		++p;
2967 		if((p0 = strchr(p,')')) == NULL)
2968 			return -1;
2969 
2970 		size = p0 - p;
2971 		if(size >= sizeof(s))
2972 			return -1;
2973 
2974 		snprintf(s, sizeof(s), "%.*s", size, p);
2975 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2976 			return -1;
2977 		for (i = 0; i < _NUM_FLD; i++) {
2978 			errno = 0;
2979 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2980 			if (errno != 0 || end == str_fld[i] ||
2981 					int_fld[i] > 65535)
2982 				return -1;
2983 		}
2984 
2985 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2986 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2987 
2988 		if (hash_index >= nb_entries) {
2989 			printf("Invalid RETA hash index=%d\n", hash_index);
2990 			return -1;
2991 		}
2992 
2993 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2994 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2995 		reta_conf[idx].mask |= (1ULL << shift);
2996 		reta_conf[idx].reta[shift] = nb_queue;
2997 	}
2998 
2999 	return 0;
3000 }
3001 
3002 static void
3003 cmd_set_rss_reta_parsed(void *parsed_result,
3004 			__rte_unused struct cmdline *cl,
3005 			__rte_unused void *data)
3006 {
3007 	int ret;
3008 	struct rte_eth_dev_info dev_info;
3009 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3010 	struct cmd_config_rss_reta *res = parsed_result;
3011 
3012 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3013 	if (ret != 0)
3014 		return;
3015 
3016 	if (dev_info.reta_size == 0) {
3017 		printf("Redirection table size is 0 which is "
3018 					"invalid for RSS\n");
3019 		return;
3020 	} else
3021 		printf("The reta size of port %d is %u\n",
3022 			res->port_id, dev_info.reta_size);
3023 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3024 		printf("Currently do not support more than %u entries of "
3025 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
3026 		return;
3027 	}
3028 
3029 	memset(reta_conf, 0, sizeof(reta_conf));
3030 	if (!strcmp(res->list_name, "reta")) {
3031 		if (parse_reta_config(res->list_of_items, reta_conf,
3032 						dev_info.reta_size)) {
3033 			printf("Invalid RSS Redirection Table "
3034 					"config entered\n");
3035 			return;
3036 		}
3037 		ret = rte_eth_dev_rss_reta_update(res->port_id,
3038 				reta_conf, dev_info.reta_size);
3039 		if (ret != 0)
3040 			printf("Bad redirection table parameter, "
3041 					"return code = %d \n", ret);
3042 	}
3043 }
3044 
3045 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3046 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3047 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3048 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3049 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3050 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3051 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3052 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3053 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3054 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3055 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3056         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3057                                  NULL);
3058 cmdline_parse_inst_t cmd_config_rss_reta = {
3059 	.f = cmd_set_rss_reta_parsed,
3060 	.data = NULL,
3061 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3062 	.tokens = {
3063 		(void *)&cmd_config_rss_reta_port,
3064 		(void *)&cmd_config_rss_reta_keyword,
3065 		(void *)&cmd_config_rss_reta_port_id,
3066 		(void *)&cmd_config_rss_reta_name,
3067 		(void *)&cmd_config_rss_reta_list_name,
3068 		(void *)&cmd_config_rss_reta_list_of_items,
3069 		NULL,
3070 	},
3071 };
3072 
3073 /* *** SHOW PORT RETA INFO *** */
3074 struct cmd_showport_reta {
3075 	cmdline_fixed_string_t show;
3076 	cmdline_fixed_string_t port;
3077 	portid_t port_id;
3078 	cmdline_fixed_string_t rss;
3079 	cmdline_fixed_string_t reta;
3080 	uint16_t size;
3081 	cmdline_fixed_string_t list_of_items;
3082 };
3083 
3084 static int
3085 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3086 			   uint16_t nb_entries,
3087 			   char *str)
3088 {
3089 	uint32_t size;
3090 	const char *p, *p0 = str;
3091 	char s[256];
3092 	char *end;
3093 	char *str_fld[8];
3094 	uint16_t i;
3095 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3096 			RTE_RETA_GROUP_SIZE;
3097 	int ret;
3098 
3099 	p = strchr(p0, '(');
3100 	if (p == NULL)
3101 		return -1;
3102 	p++;
3103 	p0 = strchr(p, ')');
3104 	if (p0 == NULL)
3105 		return -1;
3106 	size = p0 - p;
3107 	if (size >= sizeof(s)) {
3108 		printf("The string size exceeds the internal buffer size\n");
3109 		return -1;
3110 	}
3111 	snprintf(s, sizeof(s), "%.*s", size, p);
3112 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3113 	if (ret <= 0 || ret != num) {
3114 		printf("The bits of masks do not match the number of "
3115 					"reta entries: %u\n", num);
3116 		return -1;
3117 	}
3118 	for (i = 0; i < ret; i++)
3119 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3120 
3121 	return 0;
3122 }
3123 
3124 static void
3125 cmd_showport_reta_parsed(void *parsed_result,
3126 			 __rte_unused struct cmdline *cl,
3127 			 __rte_unused void *data)
3128 {
3129 	struct cmd_showport_reta *res = parsed_result;
3130 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3131 	struct rte_eth_dev_info dev_info;
3132 	uint16_t max_reta_size;
3133 	int ret;
3134 
3135 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3136 	if (ret != 0)
3137 		return;
3138 
3139 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3140 	if (res->size == 0 || res->size > max_reta_size) {
3141 		printf("Invalid redirection table size: %u (1-%u)\n",
3142 			res->size, max_reta_size);
3143 		return;
3144 	}
3145 
3146 	memset(reta_conf, 0, sizeof(reta_conf));
3147 	if (showport_parse_reta_config(reta_conf, res->size,
3148 				res->list_of_items) < 0) {
3149 		printf("Invalid string: %s for reta masks\n",
3150 					res->list_of_items);
3151 		return;
3152 	}
3153 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3154 }
3155 
3156 cmdline_parse_token_string_t cmd_showport_reta_show =
3157 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3158 cmdline_parse_token_string_t cmd_showport_reta_port =
3159 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3160 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3161 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3162 cmdline_parse_token_string_t cmd_showport_reta_rss =
3163 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3164 cmdline_parse_token_string_t cmd_showport_reta_reta =
3165 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3166 cmdline_parse_token_num_t cmd_showport_reta_size =
3167 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3168 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3169 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3170 					list_of_items, NULL);
3171 
3172 cmdline_parse_inst_t cmd_showport_reta = {
3173 	.f = cmd_showport_reta_parsed,
3174 	.data = NULL,
3175 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3176 	.tokens = {
3177 		(void *)&cmd_showport_reta_show,
3178 		(void *)&cmd_showport_reta_port,
3179 		(void *)&cmd_showport_reta_port_id,
3180 		(void *)&cmd_showport_reta_rss,
3181 		(void *)&cmd_showport_reta_reta,
3182 		(void *)&cmd_showport_reta_size,
3183 		(void *)&cmd_showport_reta_list_of_items,
3184 		NULL,
3185 	},
3186 };
3187 
3188 /* *** Show RSS hash configuration *** */
3189 struct cmd_showport_rss_hash {
3190 	cmdline_fixed_string_t show;
3191 	cmdline_fixed_string_t port;
3192 	portid_t port_id;
3193 	cmdline_fixed_string_t rss_hash;
3194 	cmdline_fixed_string_t rss_type;
3195 	cmdline_fixed_string_t key; /* optional argument */
3196 };
3197 
3198 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3199 				__rte_unused struct cmdline *cl,
3200 				void *show_rss_key)
3201 {
3202 	struct cmd_showport_rss_hash *res = parsed_result;
3203 
3204 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3205 }
3206 
3207 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3208 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3209 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3210 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3211 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3212 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3213 				 RTE_UINT16);
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3215 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3216 				 "rss-hash");
3217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3218 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3219 
3220 cmdline_parse_inst_t cmd_showport_rss_hash = {
3221 	.f = cmd_showport_rss_hash_parsed,
3222 	.data = NULL,
3223 	.help_str = "show port <port_id> rss-hash",
3224 	.tokens = {
3225 		(void *)&cmd_showport_rss_hash_show,
3226 		(void *)&cmd_showport_rss_hash_port,
3227 		(void *)&cmd_showport_rss_hash_port_id,
3228 		(void *)&cmd_showport_rss_hash_rss_hash,
3229 		NULL,
3230 	},
3231 };
3232 
3233 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3234 	.f = cmd_showport_rss_hash_parsed,
3235 	.data = (void *)1,
3236 	.help_str = "show port <port_id> rss-hash key",
3237 	.tokens = {
3238 		(void *)&cmd_showport_rss_hash_show,
3239 		(void *)&cmd_showport_rss_hash_port,
3240 		(void *)&cmd_showport_rss_hash_port_id,
3241 		(void *)&cmd_showport_rss_hash_rss_hash,
3242 		(void *)&cmd_showport_rss_hash_rss_key,
3243 		NULL,
3244 	},
3245 };
3246 
3247 /* *** Configure DCB *** */
3248 struct cmd_config_dcb {
3249 	cmdline_fixed_string_t port;
3250 	cmdline_fixed_string_t config;
3251 	portid_t port_id;
3252 	cmdline_fixed_string_t dcb;
3253 	cmdline_fixed_string_t vt;
3254 	cmdline_fixed_string_t vt_en;
3255 	uint8_t num_tcs;
3256 	cmdline_fixed_string_t pfc;
3257 	cmdline_fixed_string_t pfc_en;
3258 };
3259 
3260 static void
3261 cmd_config_dcb_parsed(void *parsed_result,
3262                         __rte_unused struct cmdline *cl,
3263                         __rte_unused void *data)
3264 {
3265 	struct cmd_config_dcb *res = parsed_result;
3266 	portid_t port_id = res->port_id;
3267 	struct rte_port *port;
3268 	uint8_t pfc_en;
3269 	int ret;
3270 
3271 	port = &ports[port_id];
3272 	/** Check if the port is not started **/
3273 	if (port->port_status != RTE_PORT_STOPPED) {
3274 		printf("Please stop port %d first\n", port_id);
3275 		return;
3276 	}
3277 
3278 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3279 		printf("The invalid number of traffic class,"
3280 			" only 4 or 8 allowed.\n");
3281 		return;
3282 	}
3283 
3284 	if (nb_fwd_lcores < res->num_tcs) {
3285 		printf("nb_cores shouldn't be less than number of TCs.\n");
3286 		return;
3287 	}
3288 	if (!strncmp(res->pfc_en, "on", 2))
3289 		pfc_en = 1;
3290 	else
3291 		pfc_en = 0;
3292 
3293 	/* DCB in VT mode */
3294 	if (!strncmp(res->vt_en, "on", 2))
3295 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3296 				(enum rte_eth_nb_tcs)res->num_tcs,
3297 				pfc_en);
3298 	else
3299 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3300 				(enum rte_eth_nb_tcs)res->num_tcs,
3301 				pfc_en);
3302 
3303 
3304 	if (ret != 0) {
3305 		printf("Cannot initialize network ports.\n");
3306 		return;
3307 	}
3308 
3309 	cmd_reconfig_device_queue(port_id, 1, 1);
3310 }
3311 
3312 cmdline_parse_token_string_t cmd_config_dcb_port =
3313         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3314 cmdline_parse_token_string_t cmd_config_dcb_config =
3315         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3316 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3317 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3318 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3319         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3320 cmdline_parse_token_string_t cmd_config_dcb_vt =
3321         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3322 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3323         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3324 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3325 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3326 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3327         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3328 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3329         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3330 
3331 cmdline_parse_inst_t cmd_config_dcb = {
3332 	.f = cmd_config_dcb_parsed,
3333 	.data = NULL,
3334 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3335 	.tokens = {
3336 		(void *)&cmd_config_dcb_port,
3337 		(void *)&cmd_config_dcb_config,
3338 		(void *)&cmd_config_dcb_port_id,
3339 		(void *)&cmd_config_dcb_dcb,
3340 		(void *)&cmd_config_dcb_vt,
3341 		(void *)&cmd_config_dcb_vt_en,
3342 		(void *)&cmd_config_dcb_num_tcs,
3343 		(void *)&cmd_config_dcb_pfc,
3344 		(void *)&cmd_config_dcb_pfc_en,
3345                 NULL,
3346         },
3347 };
3348 
3349 /* *** configure number of packets per burst *** */
3350 struct cmd_config_burst {
3351 	cmdline_fixed_string_t port;
3352 	cmdline_fixed_string_t keyword;
3353 	cmdline_fixed_string_t all;
3354 	cmdline_fixed_string_t name;
3355 	uint16_t value;
3356 };
3357 
3358 static void
3359 cmd_config_burst_parsed(void *parsed_result,
3360 			__rte_unused struct cmdline *cl,
3361 			__rte_unused void *data)
3362 {
3363 	struct cmd_config_burst *res = parsed_result;
3364 	struct rte_eth_dev_info dev_info;
3365 	uint16_t rec_nb_pkts;
3366 	int ret;
3367 
3368 	if (!all_ports_stopped()) {
3369 		printf("Please stop all ports first\n");
3370 		return;
3371 	}
3372 
3373 	if (!strcmp(res->name, "burst")) {
3374 		if (res->value == 0) {
3375 			/* If user gives a value of zero, query the PMD for
3376 			 * its recommended Rx burst size. Testpmd uses a single
3377 			 * size for all ports, so assume all ports are the same
3378 			 * NIC model and use the values from Port 0.
3379 			 */
3380 			ret = eth_dev_info_get_print_err(0, &dev_info);
3381 			if (ret != 0)
3382 				return;
3383 
3384 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3385 
3386 			if (rec_nb_pkts == 0) {
3387 				printf("PMD does not recommend a burst size.\n"
3388 					"User provided value must be between"
3389 					" 1 and %d\n", MAX_PKT_BURST);
3390 				return;
3391 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3392 				printf("PMD recommended burst size of %d"
3393 					" exceeds maximum value of %d\n",
3394 					rec_nb_pkts, MAX_PKT_BURST);
3395 				return;
3396 			}
3397 			printf("Using PMD-provided burst value of %d\n",
3398 				rec_nb_pkts);
3399 			nb_pkt_per_burst = rec_nb_pkts;
3400 		} else if (res->value > MAX_PKT_BURST) {
3401 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3402 			return;
3403 		} else
3404 			nb_pkt_per_burst = res->value;
3405 	} else {
3406 		printf("Unknown parameter\n");
3407 		return;
3408 	}
3409 
3410 	init_port_config();
3411 
3412 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3413 }
3414 
3415 cmdline_parse_token_string_t cmd_config_burst_port =
3416 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3417 cmdline_parse_token_string_t cmd_config_burst_keyword =
3418 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3419 cmdline_parse_token_string_t cmd_config_burst_all =
3420 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3421 cmdline_parse_token_string_t cmd_config_burst_name =
3422 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3423 cmdline_parse_token_num_t cmd_config_burst_value =
3424 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3425 
3426 cmdline_parse_inst_t cmd_config_burst = {
3427 	.f = cmd_config_burst_parsed,
3428 	.data = NULL,
3429 	.help_str = "port config all burst <value>",
3430 	.tokens = {
3431 		(void *)&cmd_config_burst_port,
3432 		(void *)&cmd_config_burst_keyword,
3433 		(void *)&cmd_config_burst_all,
3434 		(void *)&cmd_config_burst_name,
3435 		(void *)&cmd_config_burst_value,
3436 		NULL,
3437 	},
3438 };
3439 
3440 /* *** configure rx/tx queues *** */
3441 struct cmd_config_thresh {
3442 	cmdline_fixed_string_t port;
3443 	cmdline_fixed_string_t keyword;
3444 	cmdline_fixed_string_t all;
3445 	cmdline_fixed_string_t name;
3446 	uint8_t value;
3447 };
3448 
3449 static void
3450 cmd_config_thresh_parsed(void *parsed_result,
3451 			__rte_unused struct cmdline *cl,
3452 			__rte_unused void *data)
3453 {
3454 	struct cmd_config_thresh *res = parsed_result;
3455 
3456 	if (!all_ports_stopped()) {
3457 		printf("Please stop all ports first\n");
3458 		return;
3459 	}
3460 
3461 	if (!strcmp(res->name, "txpt"))
3462 		tx_pthresh = res->value;
3463 	else if(!strcmp(res->name, "txht"))
3464 		tx_hthresh = res->value;
3465 	else if(!strcmp(res->name, "txwt"))
3466 		tx_wthresh = res->value;
3467 	else if(!strcmp(res->name, "rxpt"))
3468 		rx_pthresh = res->value;
3469 	else if(!strcmp(res->name, "rxht"))
3470 		rx_hthresh = res->value;
3471 	else if(!strcmp(res->name, "rxwt"))
3472 		rx_wthresh = res->value;
3473 	else {
3474 		printf("Unknown parameter\n");
3475 		return;
3476 	}
3477 
3478 	init_port_config();
3479 
3480 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3481 }
3482 
3483 cmdline_parse_token_string_t cmd_config_thresh_port =
3484 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3485 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3486 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3487 cmdline_parse_token_string_t cmd_config_thresh_all =
3488 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3489 cmdline_parse_token_string_t cmd_config_thresh_name =
3490 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3491 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3492 cmdline_parse_token_num_t cmd_config_thresh_value =
3493 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3494 
3495 cmdline_parse_inst_t cmd_config_thresh = {
3496 	.f = cmd_config_thresh_parsed,
3497 	.data = NULL,
3498 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3499 	.tokens = {
3500 		(void *)&cmd_config_thresh_port,
3501 		(void *)&cmd_config_thresh_keyword,
3502 		(void *)&cmd_config_thresh_all,
3503 		(void *)&cmd_config_thresh_name,
3504 		(void *)&cmd_config_thresh_value,
3505 		NULL,
3506 	},
3507 };
3508 
3509 /* *** configure free/rs threshold *** */
3510 struct cmd_config_threshold {
3511 	cmdline_fixed_string_t port;
3512 	cmdline_fixed_string_t keyword;
3513 	cmdline_fixed_string_t all;
3514 	cmdline_fixed_string_t name;
3515 	uint16_t value;
3516 };
3517 
3518 static void
3519 cmd_config_threshold_parsed(void *parsed_result,
3520 			__rte_unused struct cmdline *cl,
3521 			__rte_unused void *data)
3522 {
3523 	struct cmd_config_threshold *res = parsed_result;
3524 
3525 	if (!all_ports_stopped()) {
3526 		printf("Please stop all ports first\n");
3527 		return;
3528 	}
3529 
3530 	if (!strcmp(res->name, "txfreet"))
3531 		tx_free_thresh = res->value;
3532 	else if (!strcmp(res->name, "txrst"))
3533 		tx_rs_thresh = res->value;
3534 	else if (!strcmp(res->name, "rxfreet"))
3535 		rx_free_thresh = res->value;
3536 	else {
3537 		printf("Unknown parameter\n");
3538 		return;
3539 	}
3540 
3541 	init_port_config();
3542 
3543 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3544 }
3545 
3546 cmdline_parse_token_string_t cmd_config_threshold_port =
3547 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3548 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3549 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3550 								"config");
3551 cmdline_parse_token_string_t cmd_config_threshold_all =
3552 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3553 cmdline_parse_token_string_t cmd_config_threshold_name =
3554 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3555 						"txfreet#txrst#rxfreet");
3556 cmdline_parse_token_num_t cmd_config_threshold_value =
3557 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3558 
3559 cmdline_parse_inst_t cmd_config_threshold = {
3560 	.f = cmd_config_threshold_parsed,
3561 	.data = NULL,
3562 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3563 	.tokens = {
3564 		(void *)&cmd_config_threshold_port,
3565 		(void *)&cmd_config_threshold_keyword,
3566 		(void *)&cmd_config_threshold_all,
3567 		(void *)&cmd_config_threshold_name,
3568 		(void *)&cmd_config_threshold_value,
3569 		NULL,
3570 	},
3571 };
3572 
3573 /* *** stop *** */
3574 struct cmd_stop_result {
3575 	cmdline_fixed_string_t stop;
3576 };
3577 
3578 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3579 			    __rte_unused struct cmdline *cl,
3580 			    __rte_unused void *data)
3581 {
3582 	stop_packet_forwarding();
3583 }
3584 
3585 cmdline_parse_token_string_t cmd_stop_stop =
3586 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3587 
3588 cmdline_parse_inst_t cmd_stop = {
3589 	.f = cmd_stop_parsed,
3590 	.data = NULL,
3591 	.help_str = "stop: Stop packet forwarding",
3592 	.tokens = {
3593 		(void *)&cmd_stop_stop,
3594 		NULL,
3595 	},
3596 };
3597 
3598 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3599 
3600 unsigned int
3601 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3602 		unsigned int *parsed_items, int check_unique_values)
3603 {
3604 	unsigned int nb_item;
3605 	unsigned int value;
3606 	unsigned int i;
3607 	unsigned int j;
3608 	int value_ok;
3609 	char c;
3610 
3611 	/*
3612 	 * First parse all items in the list and store their value.
3613 	 */
3614 	value = 0;
3615 	nb_item = 0;
3616 	value_ok = 0;
3617 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3618 		c = str[i];
3619 		if ((c >= '0') && (c <= '9')) {
3620 			value = (unsigned int) (value * 10 + (c - '0'));
3621 			value_ok = 1;
3622 			continue;
3623 		}
3624 		if (c != ',') {
3625 			printf("character %c is not a decimal digit\n", c);
3626 			return 0;
3627 		}
3628 		if (! value_ok) {
3629 			printf("No valid value before comma\n");
3630 			return 0;
3631 		}
3632 		if (nb_item < max_items) {
3633 			parsed_items[nb_item] = value;
3634 			value_ok = 0;
3635 			value = 0;
3636 		}
3637 		nb_item++;
3638 	}
3639 	if (nb_item >= max_items) {
3640 		printf("Number of %s = %u > %u (maximum items)\n",
3641 		       item_name, nb_item + 1, max_items);
3642 		return 0;
3643 	}
3644 	parsed_items[nb_item++] = value;
3645 	if (! check_unique_values)
3646 		return nb_item;
3647 
3648 	/*
3649 	 * Then, check that all values in the list are differents.
3650 	 * No optimization here...
3651 	 */
3652 	for (i = 0; i < nb_item; i++) {
3653 		for (j = i + 1; j < nb_item; j++) {
3654 			if (parsed_items[j] == parsed_items[i]) {
3655 				printf("duplicated %s %u at index %u and %u\n",
3656 				       item_name, parsed_items[i], i, j);
3657 				return 0;
3658 			}
3659 		}
3660 	}
3661 	return nb_item;
3662 }
3663 
3664 struct cmd_set_list_result {
3665 	cmdline_fixed_string_t cmd_keyword;
3666 	cmdline_fixed_string_t list_name;
3667 	cmdline_fixed_string_t list_of_items;
3668 };
3669 
3670 static void cmd_set_list_parsed(void *parsed_result,
3671 				__rte_unused struct cmdline *cl,
3672 				__rte_unused void *data)
3673 {
3674 	struct cmd_set_list_result *res;
3675 	union {
3676 		unsigned int lcorelist[RTE_MAX_LCORE];
3677 		unsigned int portlist[RTE_MAX_ETHPORTS];
3678 	} parsed_items;
3679 	unsigned int nb_item;
3680 
3681 	if (test_done == 0) {
3682 		printf("Please stop forwarding first\n");
3683 		return;
3684 	}
3685 
3686 	res = parsed_result;
3687 	if (!strcmp(res->list_name, "corelist")) {
3688 		nb_item = parse_item_list(res->list_of_items, "core",
3689 					  RTE_MAX_LCORE,
3690 					  parsed_items.lcorelist, 1);
3691 		if (nb_item > 0) {
3692 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3693 			fwd_config_setup();
3694 		}
3695 		return;
3696 	}
3697 	if (!strcmp(res->list_name, "portlist")) {
3698 		nb_item = parse_item_list(res->list_of_items, "port",
3699 					  RTE_MAX_ETHPORTS,
3700 					  parsed_items.portlist, 1);
3701 		if (nb_item > 0) {
3702 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3703 			fwd_config_setup();
3704 		}
3705 	}
3706 }
3707 
3708 cmdline_parse_token_string_t cmd_set_list_keyword =
3709 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3710 				 "set");
3711 cmdline_parse_token_string_t cmd_set_list_name =
3712 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3713 				 "corelist#portlist");
3714 cmdline_parse_token_string_t cmd_set_list_of_items =
3715 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3716 				 NULL);
3717 
3718 cmdline_parse_inst_t cmd_set_fwd_list = {
3719 	.f = cmd_set_list_parsed,
3720 	.data = NULL,
3721 	.help_str = "set corelist|portlist <list0[,list1]*>",
3722 	.tokens = {
3723 		(void *)&cmd_set_list_keyword,
3724 		(void *)&cmd_set_list_name,
3725 		(void *)&cmd_set_list_of_items,
3726 		NULL,
3727 	},
3728 };
3729 
3730 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3731 
3732 struct cmd_setmask_result {
3733 	cmdline_fixed_string_t set;
3734 	cmdline_fixed_string_t mask;
3735 	uint64_t hexavalue;
3736 };
3737 
3738 static void cmd_set_mask_parsed(void *parsed_result,
3739 				__rte_unused struct cmdline *cl,
3740 				__rte_unused void *data)
3741 {
3742 	struct cmd_setmask_result *res = parsed_result;
3743 
3744 	if (test_done == 0) {
3745 		printf("Please stop forwarding first\n");
3746 		return;
3747 	}
3748 	if (!strcmp(res->mask, "coremask")) {
3749 		set_fwd_lcores_mask(res->hexavalue);
3750 		fwd_config_setup();
3751 	} else if (!strcmp(res->mask, "portmask")) {
3752 		set_fwd_ports_mask(res->hexavalue);
3753 		fwd_config_setup();
3754 	}
3755 }
3756 
3757 cmdline_parse_token_string_t cmd_setmask_set =
3758 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3759 cmdline_parse_token_string_t cmd_setmask_mask =
3760 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3761 				 "coremask#portmask");
3762 cmdline_parse_token_num_t cmd_setmask_value =
3763 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3764 
3765 cmdline_parse_inst_t cmd_set_fwd_mask = {
3766 	.f = cmd_set_mask_parsed,
3767 	.data = NULL,
3768 	.help_str = "set coremask|portmask <hexadecimal value>",
3769 	.tokens = {
3770 		(void *)&cmd_setmask_set,
3771 		(void *)&cmd_setmask_mask,
3772 		(void *)&cmd_setmask_value,
3773 		NULL,
3774 	},
3775 };
3776 
3777 /*
3778  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3779  */
3780 struct cmd_set_result {
3781 	cmdline_fixed_string_t set;
3782 	cmdline_fixed_string_t what;
3783 	uint16_t value;
3784 };
3785 
3786 static void cmd_set_parsed(void *parsed_result,
3787 			   __rte_unused struct cmdline *cl,
3788 			   __rte_unused void *data)
3789 {
3790 	struct cmd_set_result *res = parsed_result;
3791 	if (!strcmp(res->what, "nbport")) {
3792 		set_fwd_ports_number(res->value);
3793 		fwd_config_setup();
3794 	} else if (!strcmp(res->what, "nbcore")) {
3795 		set_fwd_lcores_number(res->value);
3796 		fwd_config_setup();
3797 	} else if (!strcmp(res->what, "burst"))
3798 		set_nb_pkt_per_burst(res->value);
3799 	else if (!strcmp(res->what, "verbose"))
3800 		set_verbose_level(res->value);
3801 }
3802 
3803 cmdline_parse_token_string_t cmd_set_set =
3804 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3805 cmdline_parse_token_string_t cmd_set_what =
3806 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3807 				 "nbport#nbcore#burst#verbose");
3808 cmdline_parse_token_num_t cmd_set_value =
3809 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3810 
3811 cmdline_parse_inst_t cmd_set_numbers = {
3812 	.f = cmd_set_parsed,
3813 	.data = NULL,
3814 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3815 	.tokens = {
3816 		(void *)&cmd_set_set,
3817 		(void *)&cmd_set_what,
3818 		(void *)&cmd_set_value,
3819 		NULL,
3820 	},
3821 };
3822 
3823 /* *** SET LOG LEVEL CONFIGURATION *** */
3824 
3825 struct cmd_set_log_result {
3826 	cmdline_fixed_string_t set;
3827 	cmdline_fixed_string_t log;
3828 	cmdline_fixed_string_t type;
3829 	uint32_t level;
3830 };
3831 
3832 static void
3833 cmd_set_log_parsed(void *parsed_result,
3834 		   __rte_unused struct cmdline *cl,
3835 		   __rte_unused void *data)
3836 {
3837 	struct cmd_set_log_result *res;
3838 	int ret;
3839 
3840 	res = parsed_result;
3841 	if (!strcmp(res->type, "global"))
3842 		rte_log_set_global_level(res->level);
3843 	else {
3844 		ret = rte_log_set_level_regexp(res->type, res->level);
3845 		if (ret < 0)
3846 			printf("Unable to set log level\n");
3847 	}
3848 }
3849 
3850 cmdline_parse_token_string_t cmd_set_log_set =
3851 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3852 cmdline_parse_token_string_t cmd_set_log_log =
3853 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3854 cmdline_parse_token_string_t cmd_set_log_type =
3855 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3856 cmdline_parse_token_num_t cmd_set_log_level =
3857 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3858 
3859 cmdline_parse_inst_t cmd_set_log = {
3860 	.f = cmd_set_log_parsed,
3861 	.data = NULL,
3862 	.help_str = "set log global|<type> <level>",
3863 	.tokens = {
3864 		(void *)&cmd_set_log_set,
3865 		(void *)&cmd_set_log_log,
3866 		(void *)&cmd_set_log_type,
3867 		(void *)&cmd_set_log_level,
3868 		NULL,
3869 	},
3870 };
3871 
3872 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3873 
3874 struct cmd_set_rxoffs_result {
3875 	cmdline_fixed_string_t cmd_keyword;
3876 	cmdline_fixed_string_t rxoffs;
3877 	cmdline_fixed_string_t seg_offsets;
3878 };
3879 
3880 static void
3881 cmd_set_rxoffs_parsed(void *parsed_result,
3882 		      __rte_unused struct cmdline *cl,
3883 		      __rte_unused void *data)
3884 {
3885 	struct cmd_set_rxoffs_result *res;
3886 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3887 	unsigned int nb_segs;
3888 
3889 	res = parsed_result;
3890 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3891 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3892 	if (nb_segs > 0)
3893 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3894 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3895 }
3896 
3897 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3898 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3899 				 cmd_keyword, "set");
3900 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3901 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3902 				 rxoffs, "rxoffs");
3903 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3904 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3905 				 seg_offsets, NULL);
3906 
3907 cmdline_parse_inst_t cmd_set_rxoffs = {
3908 	.f = cmd_set_rxoffs_parsed,
3909 	.data = NULL,
3910 	.help_str = "set rxoffs <len0[,len1]*>",
3911 	.tokens = {
3912 		(void *)&cmd_set_rxoffs_keyword,
3913 		(void *)&cmd_set_rxoffs_name,
3914 		(void *)&cmd_set_rxoffs_offsets,
3915 		NULL,
3916 	},
3917 };
3918 
3919 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3920 
3921 struct cmd_set_rxpkts_result {
3922 	cmdline_fixed_string_t cmd_keyword;
3923 	cmdline_fixed_string_t rxpkts;
3924 	cmdline_fixed_string_t seg_lengths;
3925 };
3926 
3927 static void
3928 cmd_set_rxpkts_parsed(void *parsed_result,
3929 		      __rte_unused struct cmdline *cl,
3930 		      __rte_unused void *data)
3931 {
3932 	struct cmd_set_rxpkts_result *res;
3933 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3934 	unsigned int nb_segs;
3935 
3936 	res = parsed_result;
3937 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3938 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3939 	if (nb_segs > 0)
3940 		set_rx_pkt_segments(seg_lengths, nb_segs);
3941 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3942 }
3943 
3944 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3945 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3946 				 cmd_keyword, "set");
3947 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3948 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3949 				 rxpkts, "rxpkts");
3950 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3951 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3952 				 seg_lengths, NULL);
3953 
3954 cmdline_parse_inst_t cmd_set_rxpkts = {
3955 	.f = cmd_set_rxpkts_parsed,
3956 	.data = NULL,
3957 	.help_str = "set rxpkts <len0[,len1]*>",
3958 	.tokens = {
3959 		(void *)&cmd_set_rxpkts_keyword,
3960 		(void *)&cmd_set_rxpkts_name,
3961 		(void *)&cmd_set_rxpkts_lengths,
3962 		NULL,
3963 	},
3964 };
3965 
3966 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3967 
3968 struct cmd_set_txpkts_result {
3969 	cmdline_fixed_string_t cmd_keyword;
3970 	cmdline_fixed_string_t txpkts;
3971 	cmdline_fixed_string_t seg_lengths;
3972 };
3973 
3974 static void
3975 cmd_set_txpkts_parsed(void *parsed_result,
3976 		      __rte_unused struct cmdline *cl,
3977 		      __rte_unused void *data)
3978 {
3979 	struct cmd_set_txpkts_result *res;
3980 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3981 	unsigned int nb_segs;
3982 
3983 	res = parsed_result;
3984 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3985 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3986 	if (nb_segs > 0)
3987 		set_tx_pkt_segments(seg_lengths, nb_segs);
3988 }
3989 
3990 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3991 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3992 				 cmd_keyword, "set");
3993 cmdline_parse_token_string_t cmd_set_txpkts_name =
3994 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3995 				 txpkts, "txpkts");
3996 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3997 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3998 				 seg_lengths, NULL);
3999 
4000 cmdline_parse_inst_t cmd_set_txpkts = {
4001 	.f = cmd_set_txpkts_parsed,
4002 	.data = NULL,
4003 	.help_str = "set txpkts <len0[,len1]*>",
4004 	.tokens = {
4005 		(void *)&cmd_set_txpkts_keyword,
4006 		(void *)&cmd_set_txpkts_name,
4007 		(void *)&cmd_set_txpkts_lengths,
4008 		NULL,
4009 	},
4010 };
4011 
4012 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4013 
4014 struct cmd_set_txsplit_result {
4015 	cmdline_fixed_string_t cmd_keyword;
4016 	cmdline_fixed_string_t txsplit;
4017 	cmdline_fixed_string_t mode;
4018 };
4019 
4020 static void
4021 cmd_set_txsplit_parsed(void *parsed_result,
4022 		      __rte_unused struct cmdline *cl,
4023 		      __rte_unused void *data)
4024 {
4025 	struct cmd_set_txsplit_result *res;
4026 
4027 	res = parsed_result;
4028 	set_tx_pkt_split(res->mode);
4029 }
4030 
4031 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4032 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4033 				 cmd_keyword, "set");
4034 cmdline_parse_token_string_t cmd_set_txsplit_name =
4035 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4036 				 txsplit, "txsplit");
4037 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4038 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4039 				 mode, NULL);
4040 
4041 cmdline_parse_inst_t cmd_set_txsplit = {
4042 	.f = cmd_set_txsplit_parsed,
4043 	.data = NULL,
4044 	.help_str = "set txsplit on|off|rand",
4045 	.tokens = {
4046 		(void *)&cmd_set_txsplit_keyword,
4047 		(void *)&cmd_set_txsplit_name,
4048 		(void *)&cmd_set_txsplit_mode,
4049 		NULL,
4050 	},
4051 };
4052 
4053 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4054 
4055 struct cmd_set_txtimes_result {
4056 	cmdline_fixed_string_t cmd_keyword;
4057 	cmdline_fixed_string_t txtimes;
4058 	cmdline_fixed_string_t tx_times;
4059 };
4060 
4061 static void
4062 cmd_set_txtimes_parsed(void *parsed_result,
4063 		       __rte_unused struct cmdline *cl,
4064 		       __rte_unused void *data)
4065 {
4066 	struct cmd_set_txtimes_result *res;
4067 	unsigned int tx_times[2] = {0, 0};
4068 	unsigned int n_times;
4069 
4070 	res = parsed_result;
4071 	n_times = parse_item_list(res->tx_times, "tx times",
4072 				  2, tx_times, 0);
4073 	if (n_times == 2)
4074 		set_tx_pkt_times(tx_times);
4075 }
4076 
4077 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4078 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4079 				 cmd_keyword, "set");
4080 cmdline_parse_token_string_t cmd_set_txtimes_name =
4081 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4082 				 txtimes, "txtimes");
4083 cmdline_parse_token_string_t cmd_set_txtimes_value =
4084 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4085 				 tx_times, NULL);
4086 
4087 cmdline_parse_inst_t cmd_set_txtimes = {
4088 	.f = cmd_set_txtimes_parsed,
4089 	.data = NULL,
4090 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
4091 	.tokens = {
4092 		(void *)&cmd_set_txtimes_keyword,
4093 		(void *)&cmd_set_txtimes_name,
4094 		(void *)&cmd_set_txtimes_value,
4095 		NULL,
4096 	},
4097 };
4098 
4099 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4100 struct cmd_rx_vlan_filter_all_result {
4101 	cmdline_fixed_string_t rx_vlan;
4102 	cmdline_fixed_string_t what;
4103 	cmdline_fixed_string_t all;
4104 	portid_t port_id;
4105 };
4106 
4107 static void
4108 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4109 			      __rte_unused struct cmdline *cl,
4110 			      __rte_unused void *data)
4111 {
4112 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4113 
4114 	if (!strcmp(res->what, "add"))
4115 		rx_vlan_all_filter_set(res->port_id, 1);
4116 	else
4117 		rx_vlan_all_filter_set(res->port_id, 0);
4118 }
4119 
4120 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4121 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4122 				 rx_vlan, "rx_vlan");
4123 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4124 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4125 				 what, "add#rm");
4126 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4127 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4128 				 all, "all");
4129 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4130 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4131 			      port_id, RTE_UINT16);
4132 
4133 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4134 	.f = cmd_rx_vlan_filter_all_parsed,
4135 	.data = NULL,
4136 	.help_str = "rx_vlan add|rm all <port_id>: "
4137 		"Add/Remove all identifiers to/from the set of VLAN "
4138 		"identifiers filtered by a port",
4139 	.tokens = {
4140 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4141 		(void *)&cmd_rx_vlan_filter_all_what,
4142 		(void *)&cmd_rx_vlan_filter_all_all,
4143 		(void *)&cmd_rx_vlan_filter_all_portid,
4144 		NULL,
4145 	},
4146 };
4147 
4148 /* *** VLAN OFFLOAD SET ON A PORT *** */
4149 struct cmd_vlan_offload_result {
4150 	cmdline_fixed_string_t vlan;
4151 	cmdline_fixed_string_t set;
4152 	cmdline_fixed_string_t vlan_type;
4153 	cmdline_fixed_string_t what;
4154 	cmdline_fixed_string_t on;
4155 	cmdline_fixed_string_t port_id;
4156 };
4157 
4158 static void
4159 cmd_vlan_offload_parsed(void *parsed_result,
4160 			  __rte_unused struct cmdline *cl,
4161 			  __rte_unused void *data)
4162 {
4163 	int on;
4164 	struct cmd_vlan_offload_result *res = parsed_result;
4165 	char *str;
4166 	int i, len = 0;
4167 	portid_t port_id = 0;
4168 	unsigned int tmp;
4169 
4170 	str = res->port_id;
4171 	len = strnlen(str, STR_TOKEN_SIZE);
4172 	i = 0;
4173 	/* Get port_id first */
4174 	while(i < len){
4175 		if(str[i] == ',')
4176 			break;
4177 
4178 		i++;
4179 	}
4180 	str[i]='\0';
4181 	tmp = strtoul(str, NULL, 0);
4182 	/* If port_id greater that what portid_t can represent, return */
4183 	if(tmp >= RTE_MAX_ETHPORTS)
4184 		return;
4185 	port_id = (portid_t)tmp;
4186 
4187 	if (!strcmp(res->on, "on"))
4188 		on = 1;
4189 	else
4190 		on = 0;
4191 
4192 	if (!strcmp(res->what, "strip"))
4193 		rx_vlan_strip_set(port_id,  on);
4194 	else if(!strcmp(res->what, "stripq")){
4195 		uint16_t queue_id = 0;
4196 
4197 		/* No queue_id, return */
4198 		if(i + 1 >= len) {
4199 			printf("must specify (port,queue_id)\n");
4200 			return;
4201 		}
4202 		tmp = strtoul(str + i + 1, NULL, 0);
4203 		/* If queue_id greater that what 16-bits can represent, return */
4204 		if(tmp > 0xffff)
4205 			return;
4206 
4207 		queue_id = (uint16_t)tmp;
4208 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4209 	}
4210 	else if (!strcmp(res->what, "filter"))
4211 		rx_vlan_filter_set(port_id, on);
4212 	else if (!strcmp(res->what, "qinq_strip"))
4213 		rx_vlan_qinq_strip_set(port_id, on);
4214 	else
4215 		vlan_extend_set(port_id, on);
4216 
4217 	return;
4218 }
4219 
4220 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4221 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4222 				 vlan, "vlan");
4223 cmdline_parse_token_string_t cmd_vlan_offload_set =
4224 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4225 				 set, "set");
4226 cmdline_parse_token_string_t cmd_vlan_offload_what =
4227 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4228 				what, "strip#filter#qinq_strip#extend#stripq");
4229 cmdline_parse_token_string_t cmd_vlan_offload_on =
4230 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4231 			      on, "on#off");
4232 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4233 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4234 			      port_id, NULL);
4235 
4236 cmdline_parse_inst_t cmd_vlan_offload = {
4237 	.f = cmd_vlan_offload_parsed,
4238 	.data = NULL,
4239 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4240 		"<port_id[,queue_id]>: "
4241 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4242 	.tokens = {
4243 		(void *)&cmd_vlan_offload_vlan,
4244 		(void *)&cmd_vlan_offload_set,
4245 		(void *)&cmd_vlan_offload_what,
4246 		(void *)&cmd_vlan_offload_on,
4247 		(void *)&cmd_vlan_offload_portid,
4248 		NULL,
4249 	},
4250 };
4251 
4252 /* *** VLAN TPID SET ON A PORT *** */
4253 struct cmd_vlan_tpid_result {
4254 	cmdline_fixed_string_t vlan;
4255 	cmdline_fixed_string_t set;
4256 	cmdline_fixed_string_t vlan_type;
4257 	cmdline_fixed_string_t what;
4258 	uint16_t tp_id;
4259 	portid_t port_id;
4260 };
4261 
4262 static void
4263 cmd_vlan_tpid_parsed(void *parsed_result,
4264 			  __rte_unused struct cmdline *cl,
4265 			  __rte_unused void *data)
4266 {
4267 	struct cmd_vlan_tpid_result *res = parsed_result;
4268 	enum rte_vlan_type vlan_type;
4269 
4270 	if (!strcmp(res->vlan_type, "inner"))
4271 		vlan_type = ETH_VLAN_TYPE_INNER;
4272 	else if (!strcmp(res->vlan_type, "outer"))
4273 		vlan_type = ETH_VLAN_TYPE_OUTER;
4274 	else {
4275 		printf("Unknown vlan type\n");
4276 		return;
4277 	}
4278 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4279 }
4280 
4281 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4282 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4283 				 vlan, "vlan");
4284 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4285 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4286 				 set, "set");
4287 cmdline_parse_token_string_t cmd_vlan_type =
4288 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4289 				 vlan_type, "inner#outer");
4290 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4291 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4292 				 what, "tpid");
4293 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4294 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4295 			      tp_id, RTE_UINT16);
4296 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4297 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4298 			      port_id, RTE_UINT16);
4299 
4300 cmdline_parse_inst_t cmd_vlan_tpid = {
4301 	.f = cmd_vlan_tpid_parsed,
4302 	.data = NULL,
4303 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4304 		"Set the VLAN Ether type",
4305 	.tokens = {
4306 		(void *)&cmd_vlan_tpid_vlan,
4307 		(void *)&cmd_vlan_tpid_set,
4308 		(void *)&cmd_vlan_type,
4309 		(void *)&cmd_vlan_tpid_what,
4310 		(void *)&cmd_vlan_tpid_tpid,
4311 		(void *)&cmd_vlan_tpid_portid,
4312 		NULL,
4313 	},
4314 };
4315 
4316 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4317 struct cmd_rx_vlan_filter_result {
4318 	cmdline_fixed_string_t rx_vlan;
4319 	cmdline_fixed_string_t what;
4320 	uint16_t vlan_id;
4321 	portid_t port_id;
4322 };
4323 
4324 static void
4325 cmd_rx_vlan_filter_parsed(void *parsed_result,
4326 			  __rte_unused struct cmdline *cl,
4327 			  __rte_unused void *data)
4328 {
4329 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4330 
4331 	if (!strcmp(res->what, "add"))
4332 		rx_vft_set(res->port_id, res->vlan_id, 1);
4333 	else
4334 		rx_vft_set(res->port_id, res->vlan_id, 0);
4335 }
4336 
4337 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4338 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4339 				 rx_vlan, "rx_vlan");
4340 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4341 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4342 				 what, "add#rm");
4343 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4344 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4345 			      vlan_id, RTE_UINT16);
4346 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4347 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4348 			      port_id, RTE_UINT16);
4349 
4350 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4351 	.f = cmd_rx_vlan_filter_parsed,
4352 	.data = NULL,
4353 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4354 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4355 		"identifiers filtered by a port",
4356 	.tokens = {
4357 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4358 		(void *)&cmd_rx_vlan_filter_what,
4359 		(void *)&cmd_rx_vlan_filter_vlanid,
4360 		(void *)&cmd_rx_vlan_filter_portid,
4361 		NULL,
4362 	},
4363 };
4364 
4365 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4366 struct cmd_tx_vlan_set_result {
4367 	cmdline_fixed_string_t tx_vlan;
4368 	cmdline_fixed_string_t set;
4369 	portid_t port_id;
4370 	uint16_t vlan_id;
4371 };
4372 
4373 static void
4374 cmd_tx_vlan_set_parsed(void *parsed_result,
4375 		       __rte_unused struct cmdline *cl,
4376 		       __rte_unused void *data)
4377 {
4378 	struct cmd_tx_vlan_set_result *res = parsed_result;
4379 
4380 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4381 		return;
4382 
4383 	if (!port_is_stopped(res->port_id)) {
4384 		printf("Please stop port %d first\n", res->port_id);
4385 		return;
4386 	}
4387 
4388 	tx_vlan_set(res->port_id, res->vlan_id);
4389 
4390 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4391 }
4392 
4393 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4394 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4395 				 tx_vlan, "tx_vlan");
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4397 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4398 				 set, "set");
4399 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4400 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4401 			      port_id, RTE_UINT16);
4402 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4403 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4404 			      vlan_id, RTE_UINT16);
4405 
4406 cmdline_parse_inst_t cmd_tx_vlan_set = {
4407 	.f = cmd_tx_vlan_set_parsed,
4408 	.data = NULL,
4409 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4410 		"Enable hardware insertion of a single VLAN header "
4411 		"with a given TAG Identifier in packets sent on a port",
4412 	.tokens = {
4413 		(void *)&cmd_tx_vlan_set_tx_vlan,
4414 		(void *)&cmd_tx_vlan_set_set,
4415 		(void *)&cmd_tx_vlan_set_portid,
4416 		(void *)&cmd_tx_vlan_set_vlanid,
4417 		NULL,
4418 	},
4419 };
4420 
4421 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4422 struct cmd_tx_vlan_set_qinq_result {
4423 	cmdline_fixed_string_t tx_vlan;
4424 	cmdline_fixed_string_t set;
4425 	portid_t port_id;
4426 	uint16_t vlan_id;
4427 	uint16_t vlan_id_outer;
4428 };
4429 
4430 static void
4431 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4432 			    __rte_unused struct cmdline *cl,
4433 			    __rte_unused void *data)
4434 {
4435 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4436 
4437 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4438 		return;
4439 
4440 	if (!port_is_stopped(res->port_id)) {
4441 		printf("Please stop port %d first\n", res->port_id);
4442 		return;
4443 	}
4444 
4445 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4446 
4447 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4448 }
4449 
4450 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4451 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4452 		tx_vlan, "tx_vlan");
4453 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4454 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4455 		set, "set");
4456 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4457 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4458 		port_id, RTE_UINT16);
4459 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4460 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4461 		vlan_id, RTE_UINT16);
4462 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4463 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4464 		vlan_id_outer, RTE_UINT16);
4465 
4466 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4467 	.f = cmd_tx_vlan_set_qinq_parsed,
4468 	.data = NULL,
4469 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4470 		"Enable hardware insertion of double VLAN header "
4471 		"with given TAG Identifiers in packets sent on a port",
4472 	.tokens = {
4473 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4474 		(void *)&cmd_tx_vlan_set_qinq_set,
4475 		(void *)&cmd_tx_vlan_set_qinq_portid,
4476 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4477 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4478 		NULL,
4479 	},
4480 };
4481 
4482 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4483 struct cmd_tx_vlan_set_pvid_result {
4484 	cmdline_fixed_string_t tx_vlan;
4485 	cmdline_fixed_string_t set;
4486 	cmdline_fixed_string_t pvid;
4487 	portid_t port_id;
4488 	uint16_t vlan_id;
4489 	cmdline_fixed_string_t mode;
4490 };
4491 
4492 static void
4493 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4494 			    __rte_unused struct cmdline *cl,
4495 			    __rte_unused void *data)
4496 {
4497 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4498 
4499 	if (strcmp(res->mode, "on") == 0)
4500 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4501 	else
4502 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4503 }
4504 
4505 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4506 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4507 				 tx_vlan, "tx_vlan");
4508 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4509 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4510 				 set, "set");
4511 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4512 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4513 				 pvid, "pvid");
4514 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4515 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4516 			     port_id, RTE_UINT16);
4517 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4518 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4519 			      vlan_id, RTE_UINT16);
4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4521 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4522 				 mode, "on#off");
4523 
4524 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4525 	.f = cmd_tx_vlan_set_pvid_parsed,
4526 	.data = NULL,
4527 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4528 	.tokens = {
4529 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4530 		(void *)&cmd_tx_vlan_set_pvid_set,
4531 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4532 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4533 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4534 		(void *)&cmd_tx_vlan_set_pvid_mode,
4535 		NULL,
4536 	},
4537 };
4538 
4539 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4540 struct cmd_tx_vlan_reset_result {
4541 	cmdline_fixed_string_t tx_vlan;
4542 	cmdline_fixed_string_t reset;
4543 	portid_t port_id;
4544 };
4545 
4546 static void
4547 cmd_tx_vlan_reset_parsed(void *parsed_result,
4548 			 __rte_unused struct cmdline *cl,
4549 			 __rte_unused void *data)
4550 {
4551 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4552 
4553 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4554 		return;
4555 
4556 	if (!port_is_stopped(res->port_id)) {
4557 		printf("Please stop port %d first\n", res->port_id);
4558 		return;
4559 	}
4560 
4561 	tx_vlan_reset(res->port_id);
4562 
4563 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4564 }
4565 
4566 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4567 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4568 				 tx_vlan, "tx_vlan");
4569 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4570 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4571 				 reset, "reset");
4572 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4573 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4574 			      port_id, RTE_UINT16);
4575 
4576 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4577 	.f = cmd_tx_vlan_reset_parsed,
4578 	.data = NULL,
4579 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4580 		"VLAN header in packets sent on a port",
4581 	.tokens = {
4582 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4583 		(void *)&cmd_tx_vlan_reset_reset,
4584 		(void *)&cmd_tx_vlan_reset_portid,
4585 		NULL,
4586 	},
4587 };
4588 
4589 
4590 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4591 struct cmd_csum_result {
4592 	cmdline_fixed_string_t csum;
4593 	cmdline_fixed_string_t mode;
4594 	cmdline_fixed_string_t proto;
4595 	cmdline_fixed_string_t hwsw;
4596 	portid_t port_id;
4597 };
4598 
4599 static void
4600 csum_show(int port_id)
4601 {
4602 	struct rte_eth_dev_info dev_info;
4603 	uint64_t tx_offloads;
4604 	int ret;
4605 
4606 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4607 	printf("Parse tunnel is %s\n",
4608 		(ports[port_id].parse_tunnel) ? "on" : "off");
4609 	printf("IP checksum offload is %s\n",
4610 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4611 	printf("UDP checksum offload is %s\n",
4612 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4613 	printf("TCP checksum offload is %s\n",
4614 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4615 	printf("SCTP checksum offload is %s\n",
4616 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4617 	printf("Outer-Ip checksum offload is %s\n",
4618 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4619 	printf("Outer-Udp checksum offload is %s\n",
4620 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4621 
4622 	/* display warnings if configuration is not supported by the NIC */
4623 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4624 	if (ret != 0)
4625 		return;
4626 
4627 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4628 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4629 		printf("Warning: hardware IP checksum enabled but not "
4630 			"supported by port %d\n", port_id);
4631 	}
4632 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4633 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4634 		printf("Warning: hardware UDP checksum enabled but not "
4635 			"supported by port %d\n", port_id);
4636 	}
4637 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4638 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4639 		printf("Warning: hardware TCP checksum enabled but not "
4640 			"supported by port %d\n", port_id);
4641 	}
4642 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4643 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4644 		printf("Warning: hardware SCTP checksum enabled but not "
4645 			"supported by port %d\n", port_id);
4646 	}
4647 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4648 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4649 		printf("Warning: hardware outer IP checksum enabled but not "
4650 			"supported by port %d\n", port_id);
4651 	}
4652 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4653 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4654 			== 0) {
4655 		printf("Warning: hardware outer UDP checksum enabled but not "
4656 			"supported by port %d\n", port_id);
4657 	}
4658 }
4659 
4660 static void
4661 cmd_config_queue_tx_offloads(struct rte_port *port)
4662 {
4663 	int k;
4664 
4665 	/* Apply queue tx offloads configuration */
4666 	for (k = 0; k < port->dev_info.max_rx_queues; k++)
4667 		port->tx_conf[k].offloads =
4668 			port->dev_conf.txmode.offloads;
4669 }
4670 
4671 static void
4672 cmd_csum_parsed(void *parsed_result,
4673 		       __rte_unused struct cmdline *cl,
4674 		       __rte_unused void *data)
4675 {
4676 	struct cmd_csum_result *res = parsed_result;
4677 	int hw = 0;
4678 	uint64_t csum_offloads = 0;
4679 	struct rte_eth_dev_info dev_info;
4680 	int ret;
4681 
4682 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4683 		printf("invalid port %d\n", res->port_id);
4684 		return;
4685 	}
4686 	if (!port_is_stopped(res->port_id)) {
4687 		printf("Please stop port %d first\n", res->port_id);
4688 		return;
4689 	}
4690 
4691 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4692 	if (ret != 0)
4693 		return;
4694 
4695 	if (!strcmp(res->mode, "set")) {
4696 
4697 		if (!strcmp(res->hwsw, "hw"))
4698 			hw = 1;
4699 
4700 		if (!strcmp(res->proto, "ip")) {
4701 			if (hw == 0 || (dev_info.tx_offload_capa &
4702 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4703 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4704 			} else {
4705 				printf("IP checksum offload is not supported "
4706 				       "by port %u\n", res->port_id);
4707 			}
4708 		} else if (!strcmp(res->proto, "udp")) {
4709 			if (hw == 0 || (dev_info.tx_offload_capa &
4710 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4711 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4712 			} else {
4713 				printf("UDP checksum offload is not supported "
4714 				       "by port %u\n", res->port_id);
4715 			}
4716 		} else if (!strcmp(res->proto, "tcp")) {
4717 			if (hw == 0 || (dev_info.tx_offload_capa &
4718 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4719 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4720 			} else {
4721 				printf("TCP checksum offload is not supported "
4722 				       "by port %u\n", res->port_id);
4723 			}
4724 		} else if (!strcmp(res->proto, "sctp")) {
4725 			if (hw == 0 || (dev_info.tx_offload_capa &
4726 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4727 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4728 			} else {
4729 				printf("SCTP checksum offload is not supported "
4730 				       "by port %u\n", res->port_id);
4731 			}
4732 		} else if (!strcmp(res->proto, "outer-ip")) {
4733 			if (hw == 0 || (dev_info.tx_offload_capa &
4734 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4735 				csum_offloads |=
4736 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4737 			} else {
4738 				printf("Outer IP checksum offload is not "
4739 				       "supported by port %u\n", res->port_id);
4740 			}
4741 		} else if (!strcmp(res->proto, "outer-udp")) {
4742 			if (hw == 0 || (dev_info.tx_offload_capa &
4743 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4744 				csum_offloads |=
4745 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4746 			} else {
4747 				printf("Outer UDP checksum offload is not "
4748 				       "supported by port %u\n", res->port_id);
4749 			}
4750 		}
4751 
4752 		if (hw) {
4753 			ports[res->port_id].dev_conf.txmode.offloads |=
4754 							csum_offloads;
4755 		} else {
4756 			ports[res->port_id].dev_conf.txmode.offloads &=
4757 							(~csum_offloads);
4758 		}
4759 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4760 	}
4761 	csum_show(res->port_id);
4762 
4763 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4764 }
4765 
4766 cmdline_parse_token_string_t cmd_csum_csum =
4767 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4768 				csum, "csum");
4769 cmdline_parse_token_string_t cmd_csum_mode =
4770 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4771 				mode, "set");
4772 cmdline_parse_token_string_t cmd_csum_proto =
4773 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4774 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4775 cmdline_parse_token_string_t cmd_csum_hwsw =
4776 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4777 				hwsw, "hw#sw");
4778 cmdline_parse_token_num_t cmd_csum_portid =
4779 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4780 				port_id, RTE_UINT16);
4781 
4782 cmdline_parse_inst_t cmd_csum_set = {
4783 	.f = cmd_csum_parsed,
4784 	.data = NULL,
4785 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4786 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4787 		"using csum forward engine",
4788 	.tokens = {
4789 		(void *)&cmd_csum_csum,
4790 		(void *)&cmd_csum_mode,
4791 		(void *)&cmd_csum_proto,
4792 		(void *)&cmd_csum_hwsw,
4793 		(void *)&cmd_csum_portid,
4794 		NULL,
4795 	},
4796 };
4797 
4798 cmdline_parse_token_string_t cmd_csum_mode_show =
4799 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4800 				mode, "show");
4801 
4802 cmdline_parse_inst_t cmd_csum_show = {
4803 	.f = cmd_csum_parsed,
4804 	.data = NULL,
4805 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4806 	.tokens = {
4807 		(void *)&cmd_csum_csum,
4808 		(void *)&cmd_csum_mode_show,
4809 		(void *)&cmd_csum_portid,
4810 		NULL,
4811 	},
4812 };
4813 
4814 /* Enable/disable tunnel parsing */
4815 struct cmd_csum_tunnel_result {
4816 	cmdline_fixed_string_t csum;
4817 	cmdline_fixed_string_t parse;
4818 	cmdline_fixed_string_t onoff;
4819 	portid_t port_id;
4820 };
4821 
4822 static void
4823 cmd_csum_tunnel_parsed(void *parsed_result,
4824 		       __rte_unused struct cmdline *cl,
4825 		       __rte_unused void *data)
4826 {
4827 	struct cmd_csum_tunnel_result *res = parsed_result;
4828 
4829 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4830 		return;
4831 
4832 	if (!strcmp(res->onoff, "on"))
4833 		ports[res->port_id].parse_tunnel = 1;
4834 	else
4835 		ports[res->port_id].parse_tunnel = 0;
4836 
4837 	csum_show(res->port_id);
4838 }
4839 
4840 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4841 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4842 				csum, "csum");
4843 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4844 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4845 				parse, "parse-tunnel");
4846 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4847 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4848 				onoff, "on#off");
4849 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4850 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4851 				port_id, RTE_UINT16);
4852 
4853 cmdline_parse_inst_t cmd_csum_tunnel = {
4854 	.f = cmd_csum_tunnel_parsed,
4855 	.data = NULL,
4856 	.help_str = "csum parse-tunnel on|off <port_id>: "
4857 		"Enable/Disable parsing of tunnels for csum engine",
4858 	.tokens = {
4859 		(void *)&cmd_csum_tunnel_csum,
4860 		(void *)&cmd_csum_tunnel_parse,
4861 		(void *)&cmd_csum_tunnel_onoff,
4862 		(void *)&cmd_csum_tunnel_portid,
4863 		NULL,
4864 	},
4865 };
4866 
4867 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4868 struct cmd_tso_set_result {
4869 	cmdline_fixed_string_t tso;
4870 	cmdline_fixed_string_t mode;
4871 	uint16_t tso_segsz;
4872 	portid_t port_id;
4873 };
4874 
4875 static void
4876 cmd_tso_set_parsed(void *parsed_result,
4877 		       __rte_unused struct cmdline *cl,
4878 		       __rte_unused void *data)
4879 {
4880 	struct cmd_tso_set_result *res = parsed_result;
4881 	struct rte_eth_dev_info dev_info;
4882 	int ret;
4883 
4884 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4885 		return;
4886 	if (!port_is_stopped(res->port_id)) {
4887 		printf("Please stop port %d first\n", res->port_id);
4888 		return;
4889 	}
4890 
4891 	if (!strcmp(res->mode, "set"))
4892 		ports[res->port_id].tso_segsz = res->tso_segsz;
4893 
4894 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4895 	if (ret != 0)
4896 		return;
4897 
4898 	if ((ports[res->port_id].tso_segsz != 0) &&
4899 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4900 		printf("Error: TSO is not supported by port %d\n",
4901 		       res->port_id);
4902 		return;
4903 	}
4904 
4905 	if (ports[res->port_id].tso_segsz == 0) {
4906 		ports[res->port_id].dev_conf.txmode.offloads &=
4907 						~DEV_TX_OFFLOAD_TCP_TSO;
4908 		printf("TSO for non-tunneled packets is disabled\n");
4909 	} else {
4910 		ports[res->port_id].dev_conf.txmode.offloads |=
4911 						DEV_TX_OFFLOAD_TCP_TSO;
4912 		printf("TSO segment size for non-tunneled packets is %d\n",
4913 			ports[res->port_id].tso_segsz);
4914 	}
4915 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4916 
4917 	/* display warnings if configuration is not supported by the NIC */
4918 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4919 	if (ret != 0)
4920 		return;
4921 
4922 	if ((ports[res->port_id].tso_segsz != 0) &&
4923 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4924 		printf("Warning: TSO enabled but not "
4925 			"supported by port %d\n", res->port_id);
4926 	}
4927 
4928 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4929 }
4930 
4931 cmdline_parse_token_string_t cmd_tso_set_tso =
4932 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4933 				tso, "tso");
4934 cmdline_parse_token_string_t cmd_tso_set_mode =
4935 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4936 				mode, "set");
4937 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4938 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4939 				tso_segsz, RTE_UINT16);
4940 cmdline_parse_token_num_t cmd_tso_set_portid =
4941 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4942 				port_id, RTE_UINT16);
4943 
4944 cmdline_parse_inst_t cmd_tso_set = {
4945 	.f = cmd_tso_set_parsed,
4946 	.data = NULL,
4947 	.help_str = "tso set <tso_segsz> <port_id>: "
4948 		"Set TSO segment size of non-tunneled packets for csum engine "
4949 		"(0 to disable)",
4950 	.tokens = {
4951 		(void *)&cmd_tso_set_tso,
4952 		(void *)&cmd_tso_set_mode,
4953 		(void *)&cmd_tso_set_tso_segsz,
4954 		(void *)&cmd_tso_set_portid,
4955 		NULL,
4956 	},
4957 };
4958 
4959 cmdline_parse_token_string_t cmd_tso_show_mode =
4960 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4961 				mode, "show");
4962 
4963 
4964 cmdline_parse_inst_t cmd_tso_show = {
4965 	.f = cmd_tso_set_parsed,
4966 	.data = NULL,
4967 	.help_str = "tso show <port_id>: "
4968 		"Show TSO segment size of non-tunneled packets for csum engine",
4969 	.tokens = {
4970 		(void *)&cmd_tso_set_tso,
4971 		(void *)&cmd_tso_show_mode,
4972 		(void *)&cmd_tso_set_portid,
4973 		NULL,
4974 	},
4975 };
4976 
4977 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4978 struct cmd_tunnel_tso_set_result {
4979 	cmdline_fixed_string_t tso;
4980 	cmdline_fixed_string_t mode;
4981 	uint16_t tso_segsz;
4982 	portid_t port_id;
4983 };
4984 
4985 static struct rte_eth_dev_info
4986 check_tunnel_tso_nic_support(portid_t port_id)
4987 {
4988 	struct rte_eth_dev_info dev_info;
4989 
4990 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4991 		return dev_info;
4992 
4993 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4994 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4995 		       "not enabled for port %d\n", port_id);
4996 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4997 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4998 		       "not enabled for port %d\n", port_id);
4999 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5000 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
5001 		       "not enabled for port %d\n", port_id);
5002 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5003 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5004 		       "not enabled for port %d\n", port_id);
5005 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5006 		printf("Warning: IP TUNNEL TSO not supported therefore "
5007 		       "not enabled for port %d\n", port_id);
5008 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5009 		printf("Warning: UDP TUNNEL TSO not supported therefore "
5010 		       "not enabled for port %d\n", port_id);
5011 	return dev_info;
5012 }
5013 
5014 static void
5015 cmd_tunnel_tso_set_parsed(void *parsed_result,
5016 			  __rte_unused struct cmdline *cl,
5017 			  __rte_unused void *data)
5018 {
5019 	struct cmd_tunnel_tso_set_result *res = parsed_result;
5020 	struct rte_eth_dev_info dev_info;
5021 
5022 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5023 		return;
5024 	if (!port_is_stopped(res->port_id)) {
5025 		printf("Please stop port %d first\n", res->port_id);
5026 		return;
5027 	}
5028 
5029 	if (!strcmp(res->mode, "set"))
5030 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5031 
5032 	dev_info = check_tunnel_tso_nic_support(res->port_id);
5033 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
5034 		ports[res->port_id].dev_conf.txmode.offloads &=
5035 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5036 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
5037 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5038 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5039 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
5040 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
5041 		printf("TSO for tunneled packets is disabled\n");
5042 	} else {
5043 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5044 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5045 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5046 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5047 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
5048 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5049 
5050 		ports[res->port_id].dev_conf.txmode.offloads |=
5051 			(tso_offloads & dev_info.tx_offload_capa);
5052 		printf("TSO segment size for tunneled packets is %d\n",
5053 			ports[res->port_id].tunnel_tso_segsz);
5054 
5055 		/* Below conditions are needed to make it work:
5056 		 * (1) tunnel TSO is supported by the NIC;
5057 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5058 		 * are recognized;
5059 		 * (3) for tunneled pkts with outer L3 of IPv4,
5060 		 * "csum set outer-ip" must be set to hw, because after tso,
5061 		 * total_len of outer IP header is changed, and the checksum
5062 		 * of outer IP header calculated by sw should be wrong; that
5063 		 * is not necessary for IPv6 tunneled pkts because there's no
5064 		 * checksum in IP header anymore.
5065 		 */
5066 
5067 		if (!ports[res->port_id].parse_tunnel)
5068 			printf("Warning: csum parse_tunnel must be set "
5069 				"so that tunneled packets are recognized\n");
5070 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
5071 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5072 			printf("Warning: csum set outer-ip must be set to hw "
5073 				"if outer L3 is IPv4; not necessary for IPv6\n");
5074 	}
5075 
5076 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
5077 	cmd_reconfig_device_queue(res->port_id, 1, 1);
5078 }
5079 
5080 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5081 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5082 				tso, "tunnel_tso");
5083 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5084 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5085 				mode, "set");
5086 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5087 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5088 				tso_segsz, RTE_UINT16);
5089 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5090 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5091 				port_id, RTE_UINT16);
5092 
5093 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5094 	.f = cmd_tunnel_tso_set_parsed,
5095 	.data = NULL,
5096 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5097 		"Set TSO segment size of tunneled packets for csum engine "
5098 		"(0 to disable)",
5099 	.tokens = {
5100 		(void *)&cmd_tunnel_tso_set_tso,
5101 		(void *)&cmd_tunnel_tso_set_mode,
5102 		(void *)&cmd_tunnel_tso_set_tso_segsz,
5103 		(void *)&cmd_tunnel_tso_set_portid,
5104 		NULL,
5105 	},
5106 };
5107 
5108 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5109 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5110 				mode, "show");
5111 
5112 
5113 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5114 	.f = cmd_tunnel_tso_set_parsed,
5115 	.data = NULL,
5116 	.help_str = "tunnel_tso show <port_id> "
5117 		"Show TSO segment size of tunneled packets for csum engine",
5118 	.tokens = {
5119 		(void *)&cmd_tunnel_tso_set_tso,
5120 		(void *)&cmd_tunnel_tso_show_mode,
5121 		(void *)&cmd_tunnel_tso_set_portid,
5122 		NULL,
5123 	},
5124 };
5125 
5126 /* *** SET GRO FOR A PORT *** */
5127 struct cmd_gro_enable_result {
5128 	cmdline_fixed_string_t cmd_set;
5129 	cmdline_fixed_string_t cmd_port;
5130 	cmdline_fixed_string_t cmd_keyword;
5131 	cmdline_fixed_string_t cmd_onoff;
5132 	portid_t cmd_pid;
5133 };
5134 
5135 static void
5136 cmd_gro_enable_parsed(void *parsed_result,
5137 		__rte_unused struct cmdline *cl,
5138 		__rte_unused void *data)
5139 {
5140 	struct cmd_gro_enable_result *res;
5141 
5142 	res = parsed_result;
5143 	if (!strcmp(res->cmd_keyword, "gro"))
5144 		setup_gro(res->cmd_onoff, res->cmd_pid);
5145 }
5146 
5147 cmdline_parse_token_string_t cmd_gro_enable_set =
5148 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5149 			cmd_set, "set");
5150 cmdline_parse_token_string_t cmd_gro_enable_port =
5151 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5152 			cmd_keyword, "port");
5153 cmdline_parse_token_num_t cmd_gro_enable_pid =
5154 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5155 			cmd_pid, RTE_UINT16);
5156 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5157 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5158 			cmd_keyword, "gro");
5159 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5160 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5161 			cmd_onoff, "on#off");
5162 
5163 cmdline_parse_inst_t cmd_gro_enable = {
5164 	.f = cmd_gro_enable_parsed,
5165 	.data = NULL,
5166 	.help_str = "set port <port_id> gro on|off",
5167 	.tokens = {
5168 		(void *)&cmd_gro_enable_set,
5169 		(void *)&cmd_gro_enable_port,
5170 		(void *)&cmd_gro_enable_pid,
5171 		(void *)&cmd_gro_enable_keyword,
5172 		(void *)&cmd_gro_enable_onoff,
5173 		NULL,
5174 	},
5175 };
5176 
5177 /* *** DISPLAY GRO CONFIGURATION *** */
5178 struct cmd_gro_show_result {
5179 	cmdline_fixed_string_t cmd_show;
5180 	cmdline_fixed_string_t cmd_port;
5181 	cmdline_fixed_string_t cmd_keyword;
5182 	portid_t cmd_pid;
5183 };
5184 
5185 static void
5186 cmd_gro_show_parsed(void *parsed_result,
5187 		__rte_unused struct cmdline *cl,
5188 		__rte_unused void *data)
5189 {
5190 	struct cmd_gro_show_result *res;
5191 
5192 	res = parsed_result;
5193 	if (!strcmp(res->cmd_keyword, "gro"))
5194 		show_gro(res->cmd_pid);
5195 }
5196 
5197 cmdline_parse_token_string_t cmd_gro_show_show =
5198 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5199 			cmd_show, "show");
5200 cmdline_parse_token_string_t cmd_gro_show_port =
5201 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5202 			cmd_port, "port");
5203 cmdline_parse_token_num_t cmd_gro_show_pid =
5204 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5205 			cmd_pid, RTE_UINT16);
5206 cmdline_parse_token_string_t cmd_gro_show_keyword =
5207 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5208 			cmd_keyword, "gro");
5209 
5210 cmdline_parse_inst_t cmd_gro_show = {
5211 	.f = cmd_gro_show_parsed,
5212 	.data = NULL,
5213 	.help_str = "show port <port_id> gro",
5214 	.tokens = {
5215 		(void *)&cmd_gro_show_show,
5216 		(void *)&cmd_gro_show_port,
5217 		(void *)&cmd_gro_show_pid,
5218 		(void *)&cmd_gro_show_keyword,
5219 		NULL,
5220 	},
5221 };
5222 
5223 /* *** SET FLUSH CYCLES FOR GRO *** */
5224 struct cmd_gro_flush_result {
5225 	cmdline_fixed_string_t cmd_set;
5226 	cmdline_fixed_string_t cmd_keyword;
5227 	cmdline_fixed_string_t cmd_flush;
5228 	uint8_t cmd_cycles;
5229 };
5230 
5231 static void
5232 cmd_gro_flush_parsed(void *parsed_result,
5233 		__rte_unused struct cmdline *cl,
5234 		__rte_unused void *data)
5235 {
5236 	struct cmd_gro_flush_result *res;
5237 
5238 	res = parsed_result;
5239 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5240 			(!strcmp(res->cmd_flush, "flush")))
5241 		setup_gro_flush_cycles(res->cmd_cycles);
5242 }
5243 
5244 cmdline_parse_token_string_t cmd_gro_flush_set =
5245 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5246 			cmd_set, "set");
5247 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5248 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5249 			cmd_keyword, "gro");
5250 cmdline_parse_token_string_t cmd_gro_flush_flush =
5251 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5252 			cmd_flush, "flush");
5253 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5254 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5255 			cmd_cycles, RTE_UINT8);
5256 
5257 cmdline_parse_inst_t cmd_gro_flush = {
5258 	.f = cmd_gro_flush_parsed,
5259 	.data = NULL,
5260 	.help_str = "set gro flush <cycles>",
5261 	.tokens = {
5262 		(void *)&cmd_gro_flush_set,
5263 		(void *)&cmd_gro_flush_keyword,
5264 		(void *)&cmd_gro_flush_flush,
5265 		(void *)&cmd_gro_flush_cycles,
5266 		NULL,
5267 	},
5268 };
5269 
5270 /* *** ENABLE/DISABLE GSO *** */
5271 struct cmd_gso_enable_result {
5272 	cmdline_fixed_string_t cmd_set;
5273 	cmdline_fixed_string_t cmd_port;
5274 	cmdline_fixed_string_t cmd_keyword;
5275 	cmdline_fixed_string_t cmd_mode;
5276 	portid_t cmd_pid;
5277 };
5278 
5279 static void
5280 cmd_gso_enable_parsed(void *parsed_result,
5281 		__rte_unused struct cmdline *cl,
5282 		__rte_unused void *data)
5283 {
5284 	struct cmd_gso_enable_result *res;
5285 
5286 	res = parsed_result;
5287 	if (!strcmp(res->cmd_keyword, "gso"))
5288 		setup_gso(res->cmd_mode, res->cmd_pid);
5289 }
5290 
5291 cmdline_parse_token_string_t cmd_gso_enable_set =
5292 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5293 			cmd_set, "set");
5294 cmdline_parse_token_string_t cmd_gso_enable_port =
5295 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5296 			cmd_port, "port");
5297 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5298 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5299 			cmd_keyword, "gso");
5300 cmdline_parse_token_string_t cmd_gso_enable_mode =
5301 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5302 			cmd_mode, "on#off");
5303 cmdline_parse_token_num_t cmd_gso_enable_pid =
5304 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5305 			cmd_pid, RTE_UINT16);
5306 
5307 cmdline_parse_inst_t cmd_gso_enable = {
5308 	.f = cmd_gso_enable_parsed,
5309 	.data = NULL,
5310 	.help_str = "set port <port_id> gso on|off",
5311 	.tokens = {
5312 		(void *)&cmd_gso_enable_set,
5313 		(void *)&cmd_gso_enable_port,
5314 		(void *)&cmd_gso_enable_pid,
5315 		(void *)&cmd_gso_enable_keyword,
5316 		(void *)&cmd_gso_enable_mode,
5317 		NULL,
5318 	},
5319 };
5320 
5321 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5322 struct cmd_gso_size_result {
5323 	cmdline_fixed_string_t cmd_set;
5324 	cmdline_fixed_string_t cmd_keyword;
5325 	cmdline_fixed_string_t cmd_segsz;
5326 	uint16_t cmd_size;
5327 };
5328 
5329 static void
5330 cmd_gso_size_parsed(void *parsed_result,
5331 		       __rte_unused struct cmdline *cl,
5332 		       __rte_unused void *data)
5333 {
5334 	struct cmd_gso_size_result *res = parsed_result;
5335 
5336 	if (test_done == 0) {
5337 		printf("Before setting GSO segsz, please first"
5338 				" stop forwarding\n");
5339 		return;
5340 	}
5341 
5342 	if (!strcmp(res->cmd_keyword, "gso") &&
5343 			!strcmp(res->cmd_segsz, "segsz")) {
5344 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5345 			printf("gso_size should be larger than %zu."
5346 					" Please input a legal value\n",
5347 					RTE_GSO_SEG_SIZE_MIN);
5348 		else
5349 			gso_max_segment_size = res->cmd_size;
5350 	}
5351 }
5352 
5353 cmdline_parse_token_string_t cmd_gso_size_set =
5354 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5355 				cmd_set, "set");
5356 cmdline_parse_token_string_t cmd_gso_size_keyword =
5357 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5358 				cmd_keyword, "gso");
5359 cmdline_parse_token_string_t cmd_gso_size_segsz =
5360 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5361 				cmd_segsz, "segsz");
5362 cmdline_parse_token_num_t cmd_gso_size_size =
5363 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5364 				cmd_size, RTE_UINT16);
5365 
5366 cmdline_parse_inst_t cmd_gso_size = {
5367 	.f = cmd_gso_size_parsed,
5368 	.data = NULL,
5369 	.help_str = "set gso segsz <length>",
5370 	.tokens = {
5371 		(void *)&cmd_gso_size_set,
5372 		(void *)&cmd_gso_size_keyword,
5373 		(void *)&cmd_gso_size_segsz,
5374 		(void *)&cmd_gso_size_size,
5375 		NULL,
5376 	},
5377 };
5378 
5379 /* *** SHOW GSO CONFIGURATION *** */
5380 struct cmd_gso_show_result {
5381 	cmdline_fixed_string_t cmd_show;
5382 	cmdline_fixed_string_t cmd_port;
5383 	cmdline_fixed_string_t cmd_keyword;
5384 	portid_t cmd_pid;
5385 };
5386 
5387 static void
5388 cmd_gso_show_parsed(void *parsed_result,
5389 		       __rte_unused struct cmdline *cl,
5390 		       __rte_unused void *data)
5391 {
5392 	struct cmd_gso_show_result *res = parsed_result;
5393 
5394 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5395 		printf("invalid port id %u\n", res->cmd_pid);
5396 		return;
5397 	}
5398 	if (!strcmp(res->cmd_keyword, "gso")) {
5399 		if (gso_ports[res->cmd_pid].enable) {
5400 			printf("Max GSO'd packet size: %uB\n"
5401 					"Supported GSO types: TCP/IPv4, "
5402 					"UDP/IPv4, VxLAN with inner "
5403 					"TCP/IPv4 packet, GRE with inner "
5404 					"TCP/IPv4 packet\n",
5405 					gso_max_segment_size);
5406 		} else
5407 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5408 	}
5409 }
5410 
5411 cmdline_parse_token_string_t cmd_gso_show_show =
5412 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5413 		cmd_show, "show");
5414 cmdline_parse_token_string_t cmd_gso_show_port =
5415 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5416 		cmd_port, "port");
5417 cmdline_parse_token_string_t cmd_gso_show_keyword =
5418 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5419 				cmd_keyword, "gso");
5420 cmdline_parse_token_num_t cmd_gso_show_pid =
5421 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5422 				cmd_pid, RTE_UINT16);
5423 
5424 cmdline_parse_inst_t cmd_gso_show = {
5425 	.f = cmd_gso_show_parsed,
5426 	.data = NULL,
5427 	.help_str = "show port <port_id> gso",
5428 	.tokens = {
5429 		(void *)&cmd_gso_show_show,
5430 		(void *)&cmd_gso_show_port,
5431 		(void *)&cmd_gso_show_pid,
5432 		(void *)&cmd_gso_show_keyword,
5433 		NULL,
5434 	},
5435 };
5436 
5437 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5438 struct cmd_set_flush_rx {
5439 	cmdline_fixed_string_t set;
5440 	cmdline_fixed_string_t flush_rx;
5441 	cmdline_fixed_string_t mode;
5442 };
5443 
5444 static void
5445 cmd_set_flush_rx_parsed(void *parsed_result,
5446 		__rte_unused struct cmdline *cl,
5447 		__rte_unused void *data)
5448 {
5449 	struct cmd_set_flush_rx *res = parsed_result;
5450 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5451 }
5452 
5453 cmdline_parse_token_string_t cmd_setflushrx_set =
5454 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5455 			set, "set");
5456 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5457 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5458 			flush_rx, "flush_rx");
5459 cmdline_parse_token_string_t cmd_setflushrx_mode =
5460 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5461 			mode, "on#off");
5462 
5463 
5464 cmdline_parse_inst_t cmd_set_flush_rx = {
5465 	.f = cmd_set_flush_rx_parsed,
5466 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5467 	.data = NULL,
5468 	.tokens = {
5469 		(void *)&cmd_setflushrx_set,
5470 		(void *)&cmd_setflushrx_flush_rx,
5471 		(void *)&cmd_setflushrx_mode,
5472 		NULL,
5473 	},
5474 };
5475 
5476 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5477 struct cmd_set_link_check {
5478 	cmdline_fixed_string_t set;
5479 	cmdline_fixed_string_t link_check;
5480 	cmdline_fixed_string_t mode;
5481 };
5482 
5483 static void
5484 cmd_set_link_check_parsed(void *parsed_result,
5485 		__rte_unused struct cmdline *cl,
5486 		__rte_unused void *data)
5487 {
5488 	struct cmd_set_link_check *res = parsed_result;
5489 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5490 }
5491 
5492 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5493 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5494 			set, "set");
5495 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5496 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5497 			link_check, "link_check");
5498 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5499 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5500 			mode, "on#off");
5501 
5502 
5503 cmdline_parse_inst_t cmd_set_link_check = {
5504 	.f = cmd_set_link_check_parsed,
5505 	.help_str = "set link_check on|off: Enable/Disable link status check "
5506 	            "when starting/stopping a port",
5507 	.data = NULL,
5508 	.tokens = {
5509 		(void *)&cmd_setlinkcheck_set,
5510 		(void *)&cmd_setlinkcheck_link_check,
5511 		(void *)&cmd_setlinkcheck_mode,
5512 		NULL,
5513 	},
5514 };
5515 
5516 /* *** SET NIC BYPASS MODE *** */
5517 struct cmd_set_bypass_mode_result {
5518 	cmdline_fixed_string_t set;
5519 	cmdline_fixed_string_t bypass;
5520 	cmdline_fixed_string_t mode;
5521 	cmdline_fixed_string_t value;
5522 	portid_t port_id;
5523 };
5524 
5525 static void
5526 cmd_set_bypass_mode_parsed(void *parsed_result,
5527 		__rte_unused struct cmdline *cl,
5528 		__rte_unused void *data)
5529 {
5530 	struct cmd_set_bypass_mode_result *res = parsed_result;
5531 	portid_t port_id = res->port_id;
5532 	int32_t rc = -EINVAL;
5533 
5534 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5535 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5536 
5537 	if (!strcmp(res->value, "bypass"))
5538 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5539 	else if (!strcmp(res->value, "isolate"))
5540 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5541 	else
5542 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5543 
5544 	/* Set the bypass mode for the relevant port. */
5545 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5546 #endif
5547 	if (rc != 0)
5548 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5549 }
5550 
5551 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5552 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5553 			set, "set");
5554 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5555 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5556 			bypass, "bypass");
5557 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5558 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5559 			mode, "mode");
5560 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5561 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5562 			value, "normal#bypass#isolate");
5563 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5564 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5565 				port_id, RTE_UINT16);
5566 
5567 cmdline_parse_inst_t cmd_set_bypass_mode = {
5568 	.f = cmd_set_bypass_mode_parsed,
5569 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5570 	            "Set the NIC bypass mode for port_id",
5571 	.data = NULL,
5572 	.tokens = {
5573 		(void *)&cmd_setbypass_mode_set,
5574 		(void *)&cmd_setbypass_mode_bypass,
5575 		(void *)&cmd_setbypass_mode_mode,
5576 		(void *)&cmd_setbypass_mode_value,
5577 		(void *)&cmd_setbypass_mode_port,
5578 		NULL,
5579 	},
5580 };
5581 
5582 /* *** SET NIC BYPASS EVENT *** */
5583 struct cmd_set_bypass_event_result {
5584 	cmdline_fixed_string_t set;
5585 	cmdline_fixed_string_t bypass;
5586 	cmdline_fixed_string_t event;
5587 	cmdline_fixed_string_t event_value;
5588 	cmdline_fixed_string_t mode;
5589 	cmdline_fixed_string_t mode_value;
5590 	portid_t port_id;
5591 };
5592 
5593 static void
5594 cmd_set_bypass_event_parsed(void *parsed_result,
5595 		__rte_unused struct cmdline *cl,
5596 		__rte_unused void *data)
5597 {
5598 	int32_t rc = -EINVAL;
5599 	struct cmd_set_bypass_event_result *res = parsed_result;
5600 	portid_t port_id = res->port_id;
5601 
5602 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5603 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5604 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5605 
5606 	if (!strcmp(res->event_value, "timeout"))
5607 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5608 	else if (!strcmp(res->event_value, "os_on"))
5609 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5610 	else if (!strcmp(res->event_value, "os_off"))
5611 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5612 	else if (!strcmp(res->event_value, "power_on"))
5613 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5614 	else if (!strcmp(res->event_value, "power_off"))
5615 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5616 	else
5617 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5618 
5619 	if (!strcmp(res->mode_value, "bypass"))
5620 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5621 	else if (!strcmp(res->mode_value, "isolate"))
5622 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5623 	else
5624 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5625 
5626 	/* Set the watchdog timeout. */
5627 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5628 
5629 		rc = -EINVAL;
5630 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5631 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5632 							   bypass_timeout);
5633 		}
5634 		if (rc != 0) {
5635 			printf("Failed to set timeout value %u "
5636 			"for port %d, errto code: %d.\n",
5637 			bypass_timeout, port_id, rc);
5638 		}
5639 	}
5640 
5641 	/* Set the bypass event to transition to bypass mode. */
5642 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5643 					      bypass_mode);
5644 #endif
5645 
5646 	if (rc != 0)
5647 		printf("\t Failed to set bypass event for port = %d.\n",
5648 		       port_id);
5649 }
5650 
5651 cmdline_parse_token_string_t cmd_setbypass_event_set =
5652 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5653 			set, "set");
5654 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5655 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5656 			bypass, "bypass");
5657 cmdline_parse_token_string_t cmd_setbypass_event_event =
5658 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5659 			event, "event");
5660 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5661 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5662 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5663 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5664 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5665 			mode, "mode");
5666 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5667 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5668 			mode_value, "normal#bypass#isolate");
5669 cmdline_parse_token_num_t cmd_setbypass_event_port =
5670 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5671 				port_id, RTE_UINT16);
5672 
5673 cmdline_parse_inst_t cmd_set_bypass_event = {
5674 	.f = cmd_set_bypass_event_parsed,
5675 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5676 		"power_off mode normal|bypass|isolate <port_id>: "
5677 		"Set the NIC bypass event mode for port_id",
5678 	.data = NULL,
5679 	.tokens = {
5680 		(void *)&cmd_setbypass_event_set,
5681 		(void *)&cmd_setbypass_event_bypass,
5682 		(void *)&cmd_setbypass_event_event,
5683 		(void *)&cmd_setbypass_event_event_value,
5684 		(void *)&cmd_setbypass_event_mode,
5685 		(void *)&cmd_setbypass_event_mode_value,
5686 		(void *)&cmd_setbypass_event_port,
5687 		NULL,
5688 	},
5689 };
5690 
5691 
5692 /* *** SET NIC BYPASS TIMEOUT *** */
5693 struct cmd_set_bypass_timeout_result {
5694 	cmdline_fixed_string_t set;
5695 	cmdline_fixed_string_t bypass;
5696 	cmdline_fixed_string_t timeout;
5697 	cmdline_fixed_string_t value;
5698 };
5699 
5700 static void
5701 cmd_set_bypass_timeout_parsed(void *parsed_result,
5702 		__rte_unused struct cmdline *cl,
5703 		__rte_unused void *data)
5704 {
5705 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5706 
5707 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5708 	if (!strcmp(res->value, "1.5"))
5709 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5710 	else if (!strcmp(res->value, "2"))
5711 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5712 	else if (!strcmp(res->value, "3"))
5713 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5714 	else if (!strcmp(res->value, "4"))
5715 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5716 	else if (!strcmp(res->value, "8"))
5717 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5718 	else if (!strcmp(res->value, "16"))
5719 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5720 	else if (!strcmp(res->value, "32"))
5721 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5722 	else
5723 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5724 #endif
5725 }
5726 
5727 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5728 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5729 			set, "set");
5730 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5731 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5732 			bypass, "bypass");
5733 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5734 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5735 			timeout, "timeout");
5736 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5737 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5738 			value, "0#1.5#2#3#4#8#16#32");
5739 
5740 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5741 	.f = cmd_set_bypass_timeout_parsed,
5742 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5743 		"Set the NIC bypass watchdog timeout in seconds",
5744 	.data = NULL,
5745 	.tokens = {
5746 		(void *)&cmd_setbypass_timeout_set,
5747 		(void *)&cmd_setbypass_timeout_bypass,
5748 		(void *)&cmd_setbypass_timeout_timeout,
5749 		(void *)&cmd_setbypass_timeout_value,
5750 		NULL,
5751 	},
5752 };
5753 
5754 /* *** SHOW NIC BYPASS MODE *** */
5755 struct cmd_show_bypass_config_result {
5756 	cmdline_fixed_string_t show;
5757 	cmdline_fixed_string_t bypass;
5758 	cmdline_fixed_string_t config;
5759 	portid_t port_id;
5760 };
5761 
5762 static void
5763 cmd_show_bypass_config_parsed(void *parsed_result,
5764 		__rte_unused struct cmdline *cl,
5765 		__rte_unused void *data)
5766 {
5767 	struct cmd_show_bypass_config_result *res = parsed_result;
5768 	portid_t port_id = res->port_id;
5769 	int rc = -EINVAL;
5770 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5771 	uint32_t event_mode;
5772 	uint32_t bypass_mode;
5773 	uint32_t timeout = bypass_timeout;
5774 	unsigned int i;
5775 
5776 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5777 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5778 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5779 		{"UNKNOWN", "normal", "bypass", "isolate"};
5780 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5781 		"NONE",
5782 		"OS/board on",
5783 		"power supply on",
5784 		"OS/board off",
5785 		"power supply off",
5786 		"timeout"};
5787 
5788 	/* Display the bypass mode.*/
5789 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5790 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5791 		return;
5792 	}
5793 	else {
5794 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5795 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5796 
5797 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5798 	}
5799 
5800 	/* Display the bypass timeout.*/
5801 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5802 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5803 
5804 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5805 
5806 	/* Display the bypass events and associated modes. */
5807 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5808 
5809 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5810 			printf("\tFailed to get bypass mode for event = %s\n",
5811 				events[i]);
5812 		} else {
5813 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5814 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5815 
5816 			printf("\tbypass event: %-16s = %s\n", events[i],
5817 				modes[event_mode]);
5818 		}
5819 	}
5820 #endif
5821 	if (rc != 0)
5822 		printf("\tFailed to get bypass configuration for port = %d\n",
5823 		       port_id);
5824 }
5825 
5826 cmdline_parse_token_string_t cmd_showbypass_config_show =
5827 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5828 			show, "show");
5829 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5830 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5831 			bypass, "bypass");
5832 cmdline_parse_token_string_t cmd_showbypass_config_config =
5833 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5834 			config, "config");
5835 cmdline_parse_token_num_t cmd_showbypass_config_port =
5836 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5837 				port_id, RTE_UINT16);
5838 
5839 cmdline_parse_inst_t cmd_show_bypass_config = {
5840 	.f = cmd_show_bypass_config_parsed,
5841 	.help_str = "show bypass config <port_id>: "
5842 	            "Show the NIC bypass config for port_id",
5843 	.data = NULL,
5844 	.tokens = {
5845 		(void *)&cmd_showbypass_config_show,
5846 		(void *)&cmd_showbypass_config_bypass,
5847 		(void *)&cmd_showbypass_config_config,
5848 		(void *)&cmd_showbypass_config_port,
5849 		NULL,
5850 	},
5851 };
5852 
5853 #ifdef RTE_NET_BOND
5854 /* *** SET BONDING MODE *** */
5855 struct cmd_set_bonding_mode_result {
5856 	cmdline_fixed_string_t set;
5857 	cmdline_fixed_string_t bonding;
5858 	cmdline_fixed_string_t mode;
5859 	uint8_t value;
5860 	portid_t port_id;
5861 };
5862 
5863 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5864 		__rte_unused  struct cmdline *cl,
5865 		__rte_unused void *data)
5866 {
5867 	struct cmd_set_bonding_mode_result *res = parsed_result;
5868 	portid_t port_id = res->port_id;
5869 
5870 	/* Set the bonding mode for the relevant port. */
5871 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5872 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5873 }
5874 
5875 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5876 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5877 		set, "set");
5878 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5880 		bonding, "bonding");
5881 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5883 		mode, "mode");
5884 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5885 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5886 		value, RTE_UINT8);
5887 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5888 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5889 		port_id, RTE_UINT16);
5890 
5891 cmdline_parse_inst_t cmd_set_bonding_mode = {
5892 		.f = cmd_set_bonding_mode_parsed,
5893 		.help_str = "set bonding mode <mode_value> <port_id>: "
5894 			"Set the bonding mode for port_id",
5895 		.data = NULL,
5896 		.tokens = {
5897 				(void *) &cmd_setbonding_mode_set,
5898 				(void *) &cmd_setbonding_mode_bonding,
5899 				(void *) &cmd_setbonding_mode_mode,
5900 				(void *) &cmd_setbonding_mode_value,
5901 				(void *) &cmd_setbonding_mode_port,
5902 				NULL
5903 		}
5904 };
5905 
5906 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5907 struct cmd_set_bonding_lacp_dedicated_queues_result {
5908 	cmdline_fixed_string_t set;
5909 	cmdline_fixed_string_t bonding;
5910 	cmdline_fixed_string_t lacp;
5911 	cmdline_fixed_string_t dedicated_queues;
5912 	portid_t port_id;
5913 	cmdline_fixed_string_t mode;
5914 };
5915 
5916 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5917 		__rte_unused  struct cmdline *cl,
5918 		__rte_unused void *data)
5919 {
5920 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5921 	portid_t port_id = res->port_id;
5922 	struct rte_port *port;
5923 
5924 	port = &ports[port_id];
5925 
5926 	/** Check if the port is not started **/
5927 	if (port->port_status != RTE_PORT_STOPPED) {
5928 		printf("Please stop port %d first\n", port_id);
5929 		return;
5930 	}
5931 
5932 	if (!strcmp(res->mode, "enable")) {
5933 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5934 			printf("Dedicate queues for LACP control packets"
5935 					" enabled\n");
5936 		else
5937 			printf("Enabling dedicate queues for LACP control "
5938 					"packets on port %d failed\n", port_id);
5939 	} else if (!strcmp(res->mode, "disable")) {
5940 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5941 			printf("Dedicated queues for LACP control packets "
5942 					"disabled\n");
5943 		else
5944 			printf("Disabling dedicated queues for LACP control "
5945 					"traffic on port %d failed\n", port_id);
5946 	}
5947 }
5948 
5949 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5951 		set, "set");
5952 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5953 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5954 		bonding, "bonding");
5955 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5956 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5957 		lacp, "lacp");
5958 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5959 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5960 		dedicated_queues, "dedicated_queues");
5961 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5962 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5963 		port_id, RTE_UINT16);
5964 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5966 		mode, "enable#disable");
5967 
5968 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5969 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5970 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5971 			"enable|disable: "
5972 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5973 		.data = NULL,
5974 		.tokens = {
5975 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5976 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5977 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5978 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5979 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5980 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5981 			NULL
5982 		}
5983 };
5984 
5985 /* *** SET BALANCE XMIT POLICY *** */
5986 struct cmd_set_bonding_balance_xmit_policy_result {
5987 	cmdline_fixed_string_t set;
5988 	cmdline_fixed_string_t bonding;
5989 	cmdline_fixed_string_t balance_xmit_policy;
5990 	portid_t port_id;
5991 	cmdline_fixed_string_t policy;
5992 };
5993 
5994 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5995 		__rte_unused  struct cmdline *cl,
5996 		__rte_unused void *data)
5997 {
5998 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5999 	portid_t port_id = res->port_id;
6000 	uint8_t policy;
6001 
6002 	if (!strcmp(res->policy, "l2")) {
6003 		policy = BALANCE_XMIT_POLICY_LAYER2;
6004 	} else if (!strcmp(res->policy, "l23")) {
6005 		policy = BALANCE_XMIT_POLICY_LAYER23;
6006 	} else if (!strcmp(res->policy, "l34")) {
6007 		policy = BALANCE_XMIT_POLICY_LAYER34;
6008 	} else {
6009 		printf("\t Invalid xmit policy selection");
6010 		return;
6011 	}
6012 
6013 	/* Set the bonding mode for the relevant port. */
6014 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6015 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6016 				port_id);
6017 	}
6018 }
6019 
6020 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6021 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6022 		set, "set");
6023 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6024 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6025 		bonding, "bonding");
6026 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6027 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6028 		balance_xmit_policy, "balance_xmit_policy");
6029 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6030 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6031 		port_id, RTE_UINT16);
6032 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6034 		policy, "l2#l23#l34");
6035 
6036 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6037 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
6038 		.help_str = "set bonding balance_xmit_policy <port_id> "
6039 			"l2|l23|l34: "
6040 			"Set the bonding balance_xmit_policy for port_id",
6041 		.data = NULL,
6042 		.tokens = {
6043 				(void *)&cmd_setbonding_balance_xmit_policy_set,
6044 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
6045 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6046 				(void *)&cmd_setbonding_balance_xmit_policy_port,
6047 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
6048 				NULL
6049 		}
6050 };
6051 
6052 /* *** SHOW NIC BONDING CONFIGURATION *** */
6053 struct cmd_show_bonding_config_result {
6054 	cmdline_fixed_string_t show;
6055 	cmdline_fixed_string_t bonding;
6056 	cmdline_fixed_string_t config;
6057 	portid_t port_id;
6058 };
6059 
6060 static void cmd_show_bonding_config_parsed(void *parsed_result,
6061 		__rte_unused  struct cmdline *cl,
6062 		__rte_unused void *data)
6063 {
6064 	struct cmd_show_bonding_config_result *res = parsed_result;
6065 	int bonding_mode, agg_mode;
6066 	portid_t slaves[RTE_MAX_ETHPORTS];
6067 	int num_slaves, num_active_slaves;
6068 	int primary_id;
6069 	int i;
6070 	portid_t port_id = res->port_id;
6071 
6072 	/* Display the bonding mode.*/
6073 	bonding_mode = rte_eth_bond_mode_get(port_id);
6074 	if (bonding_mode < 0) {
6075 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
6076 		return;
6077 	} else
6078 		printf("\tBonding mode: %d\n", bonding_mode);
6079 
6080 	if (bonding_mode == BONDING_MODE_BALANCE) {
6081 		int balance_xmit_policy;
6082 
6083 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6084 		if (balance_xmit_policy < 0) {
6085 			printf("\tFailed to get balance xmit policy for port = %d\n",
6086 					port_id);
6087 			return;
6088 		} else {
6089 			printf("\tBalance Xmit Policy: ");
6090 
6091 			switch (balance_xmit_policy) {
6092 			case BALANCE_XMIT_POLICY_LAYER2:
6093 				printf("BALANCE_XMIT_POLICY_LAYER2");
6094 				break;
6095 			case BALANCE_XMIT_POLICY_LAYER23:
6096 				printf("BALANCE_XMIT_POLICY_LAYER23");
6097 				break;
6098 			case BALANCE_XMIT_POLICY_LAYER34:
6099 				printf("BALANCE_XMIT_POLICY_LAYER34");
6100 				break;
6101 			}
6102 			printf("\n");
6103 		}
6104 	}
6105 
6106 	if (bonding_mode == BONDING_MODE_8023AD) {
6107 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6108 		printf("\tIEEE802.3AD Aggregator Mode: ");
6109 		switch (agg_mode) {
6110 		case AGG_BANDWIDTH:
6111 			printf("bandwidth");
6112 			break;
6113 		case AGG_STABLE:
6114 			printf("stable");
6115 			break;
6116 		case AGG_COUNT:
6117 			printf("count");
6118 			break;
6119 		}
6120 		printf("\n");
6121 	}
6122 
6123 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6124 
6125 	if (num_slaves < 0) {
6126 		printf("\tFailed to get slave list for port = %d\n", port_id);
6127 		return;
6128 	}
6129 	if (num_slaves > 0) {
6130 		printf("\tSlaves (%d): [", num_slaves);
6131 		for (i = 0; i < num_slaves - 1; i++)
6132 			printf("%d ", slaves[i]);
6133 
6134 		printf("%d]\n", slaves[num_slaves - 1]);
6135 	} else {
6136 		printf("\tSlaves: []\n");
6137 
6138 	}
6139 
6140 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6141 			RTE_MAX_ETHPORTS);
6142 
6143 	if (num_active_slaves < 0) {
6144 		printf("\tFailed to get active slave list for port = %d\n", port_id);
6145 		return;
6146 	}
6147 	if (num_active_slaves > 0) {
6148 		printf("\tActive Slaves (%d): [", num_active_slaves);
6149 		for (i = 0; i < num_active_slaves - 1; i++)
6150 			printf("%d ", slaves[i]);
6151 
6152 		printf("%d]\n", slaves[num_active_slaves - 1]);
6153 
6154 	} else {
6155 		printf("\tActive Slaves: []\n");
6156 
6157 	}
6158 
6159 	primary_id = rte_eth_bond_primary_get(port_id);
6160 	if (primary_id < 0) {
6161 		printf("\tFailed to get primary slave for port = %d\n", port_id);
6162 		return;
6163 	} else
6164 		printf("\tPrimary: [%d]\n", primary_id);
6165 
6166 }
6167 
6168 cmdline_parse_token_string_t cmd_showbonding_config_show =
6169 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6170 		show, "show");
6171 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6172 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6173 		bonding, "bonding");
6174 cmdline_parse_token_string_t cmd_showbonding_config_config =
6175 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6176 		config, "config");
6177 cmdline_parse_token_num_t cmd_showbonding_config_port =
6178 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6179 		port_id, RTE_UINT16);
6180 
6181 cmdline_parse_inst_t cmd_show_bonding_config = {
6182 		.f = cmd_show_bonding_config_parsed,
6183 		.help_str = "show bonding config <port_id>: "
6184 			"Show the bonding config for port_id",
6185 		.data = NULL,
6186 		.tokens = {
6187 				(void *)&cmd_showbonding_config_show,
6188 				(void *)&cmd_showbonding_config_bonding,
6189 				(void *)&cmd_showbonding_config_config,
6190 				(void *)&cmd_showbonding_config_port,
6191 				NULL
6192 		}
6193 };
6194 
6195 /* *** SET BONDING PRIMARY *** */
6196 struct cmd_set_bonding_primary_result {
6197 	cmdline_fixed_string_t set;
6198 	cmdline_fixed_string_t bonding;
6199 	cmdline_fixed_string_t primary;
6200 	portid_t slave_id;
6201 	portid_t port_id;
6202 };
6203 
6204 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6205 		__rte_unused  struct cmdline *cl,
6206 		__rte_unused void *data)
6207 {
6208 	struct cmd_set_bonding_primary_result *res = parsed_result;
6209 	portid_t master_port_id = res->port_id;
6210 	portid_t slave_port_id = res->slave_id;
6211 
6212 	/* Set the primary slave for a bonded device. */
6213 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6214 		printf("\t Failed to set primary slave for port = %d.\n",
6215 				master_port_id);
6216 		return;
6217 	}
6218 	init_port_config();
6219 }
6220 
6221 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6222 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6223 		set, "set");
6224 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6225 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6226 		bonding, "bonding");
6227 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6229 		primary, "primary");
6230 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6231 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6232 		slave_id, RTE_UINT16);
6233 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6234 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6235 		port_id, RTE_UINT16);
6236 
6237 cmdline_parse_inst_t cmd_set_bonding_primary = {
6238 		.f = cmd_set_bonding_primary_parsed,
6239 		.help_str = "set bonding primary <slave_id> <port_id>: "
6240 			"Set the primary slave for port_id",
6241 		.data = NULL,
6242 		.tokens = {
6243 				(void *)&cmd_setbonding_primary_set,
6244 				(void *)&cmd_setbonding_primary_bonding,
6245 				(void *)&cmd_setbonding_primary_primary,
6246 				(void *)&cmd_setbonding_primary_slave,
6247 				(void *)&cmd_setbonding_primary_port,
6248 				NULL
6249 		}
6250 };
6251 
6252 /* *** ADD SLAVE *** */
6253 struct cmd_add_bonding_slave_result {
6254 	cmdline_fixed_string_t add;
6255 	cmdline_fixed_string_t bonding;
6256 	cmdline_fixed_string_t slave;
6257 	portid_t slave_id;
6258 	portid_t port_id;
6259 };
6260 
6261 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6262 		__rte_unused  struct cmdline *cl,
6263 		__rte_unused void *data)
6264 {
6265 	struct cmd_add_bonding_slave_result *res = parsed_result;
6266 	portid_t master_port_id = res->port_id;
6267 	portid_t slave_port_id = res->slave_id;
6268 
6269 	/* add the slave for a bonded device. */
6270 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6271 		printf("\t Failed to add slave %d to master port = %d.\n",
6272 				slave_port_id, master_port_id);
6273 		return;
6274 	}
6275 	init_port_config();
6276 	set_port_slave_flag(slave_port_id);
6277 }
6278 
6279 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6280 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6281 		add, "add");
6282 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6283 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6284 		bonding, "bonding");
6285 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6286 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6287 		slave, "slave");
6288 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6289 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6290 		slave_id, RTE_UINT16);
6291 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6292 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6293 		port_id, RTE_UINT16);
6294 
6295 cmdline_parse_inst_t cmd_add_bonding_slave = {
6296 		.f = cmd_add_bonding_slave_parsed,
6297 		.help_str = "add bonding slave <slave_id> <port_id>: "
6298 			"Add a slave device to a bonded device",
6299 		.data = NULL,
6300 		.tokens = {
6301 				(void *)&cmd_addbonding_slave_add,
6302 				(void *)&cmd_addbonding_slave_bonding,
6303 				(void *)&cmd_addbonding_slave_slave,
6304 				(void *)&cmd_addbonding_slave_slaveid,
6305 				(void *)&cmd_addbonding_slave_port,
6306 				NULL
6307 		}
6308 };
6309 
6310 /* *** REMOVE SLAVE *** */
6311 struct cmd_remove_bonding_slave_result {
6312 	cmdline_fixed_string_t remove;
6313 	cmdline_fixed_string_t bonding;
6314 	cmdline_fixed_string_t slave;
6315 	portid_t slave_id;
6316 	portid_t port_id;
6317 };
6318 
6319 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6320 		__rte_unused  struct cmdline *cl,
6321 		__rte_unused void *data)
6322 {
6323 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6324 	portid_t master_port_id = res->port_id;
6325 	portid_t slave_port_id = res->slave_id;
6326 
6327 	/* remove the slave from a bonded device. */
6328 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6329 		printf("\t Failed to remove slave %d from master port = %d.\n",
6330 				slave_port_id, master_port_id);
6331 		return;
6332 	}
6333 	init_port_config();
6334 	clear_port_slave_flag(slave_port_id);
6335 }
6336 
6337 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6338 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6339 				remove, "remove");
6340 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6341 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6342 				bonding, "bonding");
6343 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6344 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6345 				slave, "slave");
6346 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6347 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6348 				slave_id, RTE_UINT16);
6349 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6350 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6351 				port_id, RTE_UINT16);
6352 
6353 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6354 		.f = cmd_remove_bonding_slave_parsed,
6355 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6356 			"Remove a slave device from a bonded device",
6357 		.data = NULL,
6358 		.tokens = {
6359 				(void *)&cmd_removebonding_slave_remove,
6360 				(void *)&cmd_removebonding_slave_bonding,
6361 				(void *)&cmd_removebonding_slave_slave,
6362 				(void *)&cmd_removebonding_slave_slaveid,
6363 				(void *)&cmd_removebonding_slave_port,
6364 				NULL
6365 		}
6366 };
6367 
6368 /* *** CREATE BONDED DEVICE *** */
6369 struct cmd_create_bonded_device_result {
6370 	cmdline_fixed_string_t create;
6371 	cmdline_fixed_string_t bonded;
6372 	cmdline_fixed_string_t device;
6373 	uint8_t mode;
6374 	uint8_t socket;
6375 };
6376 
6377 static int bond_dev_num = 0;
6378 
6379 static void cmd_create_bonded_device_parsed(void *parsed_result,
6380 		__rte_unused  struct cmdline *cl,
6381 		__rte_unused void *data)
6382 {
6383 	struct cmd_create_bonded_device_result *res = parsed_result;
6384 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6385 	int port_id;
6386 	int ret;
6387 
6388 	if (test_done == 0) {
6389 		printf("Please stop forwarding first\n");
6390 		return;
6391 	}
6392 
6393 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6394 			bond_dev_num++);
6395 
6396 	/* Create a new bonded device. */
6397 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6398 	if (port_id < 0) {
6399 		printf("\t Failed to create bonded device.\n");
6400 		return;
6401 	} else {
6402 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6403 				port_id);
6404 
6405 		/* Update number of ports */
6406 		nb_ports = rte_eth_dev_count_avail();
6407 		reconfig(port_id, res->socket);
6408 		ret = rte_eth_promiscuous_enable(port_id);
6409 		if (ret != 0)
6410 			printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6411 				port_id, rte_strerror(-ret));
6412 
6413 		ports[port_id].need_setup = 0;
6414 		ports[port_id].port_status = RTE_PORT_STOPPED;
6415 	}
6416 
6417 }
6418 
6419 cmdline_parse_token_string_t cmd_createbonded_device_create =
6420 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6421 				create, "create");
6422 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6423 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6424 				bonded, "bonded");
6425 cmdline_parse_token_string_t cmd_createbonded_device_device =
6426 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6427 				device, "device");
6428 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6429 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6430 				mode, RTE_UINT8);
6431 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6432 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6433 				socket, RTE_UINT8);
6434 
6435 cmdline_parse_inst_t cmd_create_bonded_device = {
6436 		.f = cmd_create_bonded_device_parsed,
6437 		.help_str = "create bonded device <mode> <socket>: "
6438 			"Create a new bonded device with specific bonding mode and socket",
6439 		.data = NULL,
6440 		.tokens = {
6441 				(void *)&cmd_createbonded_device_create,
6442 				(void *)&cmd_createbonded_device_bonded,
6443 				(void *)&cmd_createbonded_device_device,
6444 				(void *)&cmd_createbonded_device_mode,
6445 				(void *)&cmd_createbonded_device_socket,
6446 				NULL
6447 		}
6448 };
6449 
6450 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6451 struct cmd_set_bond_mac_addr_result {
6452 	cmdline_fixed_string_t set;
6453 	cmdline_fixed_string_t bonding;
6454 	cmdline_fixed_string_t mac_addr;
6455 	uint16_t port_num;
6456 	struct rte_ether_addr address;
6457 };
6458 
6459 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6460 		__rte_unused  struct cmdline *cl,
6461 		__rte_unused void *data)
6462 {
6463 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6464 	int ret;
6465 
6466 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6467 		return;
6468 
6469 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6470 
6471 	/* check the return value and print it if is < 0 */
6472 	if (ret < 0)
6473 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6474 }
6475 
6476 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6477 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6478 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6479 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6480 				"bonding");
6481 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6482 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6483 				"mac_addr");
6484 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6485 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6486 				port_num, RTE_UINT16);
6487 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6488 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6489 
6490 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6491 		.f = cmd_set_bond_mac_addr_parsed,
6492 		.data = (void *) 0,
6493 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6494 		.tokens = {
6495 				(void *)&cmd_set_bond_mac_addr_set,
6496 				(void *)&cmd_set_bond_mac_addr_bonding,
6497 				(void *)&cmd_set_bond_mac_addr_mac,
6498 				(void *)&cmd_set_bond_mac_addr_portnum,
6499 				(void *)&cmd_set_bond_mac_addr_addr,
6500 				NULL
6501 		}
6502 };
6503 
6504 
6505 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6506 struct cmd_set_bond_mon_period_result {
6507 	cmdline_fixed_string_t set;
6508 	cmdline_fixed_string_t bonding;
6509 	cmdline_fixed_string_t mon_period;
6510 	uint16_t port_num;
6511 	uint32_t period_ms;
6512 };
6513 
6514 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6515 		__rte_unused  struct cmdline *cl,
6516 		__rte_unused void *data)
6517 {
6518 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6519 	int ret;
6520 
6521 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6522 
6523 	/* check the return value and print it if is < 0 */
6524 	if (ret < 0)
6525 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6526 }
6527 
6528 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6529 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6530 				set, "set");
6531 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6532 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6533 				bonding, "bonding");
6534 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6535 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6536 				mon_period,	"mon_period");
6537 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6538 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6539 				port_num, RTE_UINT16);
6540 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6541 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6542 				period_ms, RTE_UINT32);
6543 
6544 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6545 		.f = cmd_set_bond_mon_period_parsed,
6546 		.data = (void *) 0,
6547 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6548 		.tokens = {
6549 				(void *)&cmd_set_bond_mon_period_set,
6550 				(void *)&cmd_set_bond_mon_period_bonding,
6551 				(void *)&cmd_set_bond_mon_period_mon_period,
6552 				(void *)&cmd_set_bond_mon_period_portnum,
6553 				(void *)&cmd_set_bond_mon_period_period_ms,
6554 				NULL
6555 		}
6556 };
6557 
6558 
6559 
6560 struct cmd_set_bonding_agg_mode_policy_result {
6561 	cmdline_fixed_string_t set;
6562 	cmdline_fixed_string_t bonding;
6563 	cmdline_fixed_string_t agg_mode;
6564 	uint16_t port_num;
6565 	cmdline_fixed_string_t policy;
6566 };
6567 
6568 
6569 static void
6570 cmd_set_bonding_agg_mode(void *parsed_result,
6571 		__rte_unused struct cmdline *cl,
6572 		__rte_unused void *data)
6573 {
6574 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6575 	uint8_t policy = AGG_BANDWIDTH;
6576 
6577 	if (!strcmp(res->policy, "bandwidth"))
6578 		policy = AGG_BANDWIDTH;
6579 	else if (!strcmp(res->policy, "stable"))
6580 		policy = AGG_STABLE;
6581 	else if (!strcmp(res->policy, "count"))
6582 		policy = AGG_COUNT;
6583 
6584 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6585 }
6586 
6587 
6588 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6589 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6590 				set, "set");
6591 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6592 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6593 				bonding, "bonding");
6594 
6595 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6596 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6597 				agg_mode, "agg_mode");
6598 
6599 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6600 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6601 				port_num, RTE_UINT16);
6602 
6603 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6604 	TOKEN_STRING_INITIALIZER(
6605 			struct cmd_set_bonding_balance_xmit_policy_result,
6606 		policy, "stable#bandwidth#count");
6607 
6608 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6609 	.f = cmd_set_bonding_agg_mode,
6610 	.data = (void *) 0,
6611 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6612 	.tokens = {
6613 			(void *)&cmd_set_bonding_agg_mode_set,
6614 			(void *)&cmd_set_bonding_agg_mode_bonding,
6615 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6616 			(void *)&cmd_set_bonding_agg_mode_portnum,
6617 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6618 			NULL
6619 		}
6620 };
6621 
6622 
6623 #endif /* RTE_NET_BOND */
6624 
6625 /* *** SET FORWARDING MODE *** */
6626 struct cmd_set_fwd_mode_result {
6627 	cmdline_fixed_string_t set;
6628 	cmdline_fixed_string_t fwd;
6629 	cmdline_fixed_string_t mode;
6630 };
6631 
6632 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6633 				    __rte_unused struct cmdline *cl,
6634 				    __rte_unused void *data)
6635 {
6636 	struct cmd_set_fwd_mode_result *res = parsed_result;
6637 
6638 	retry_enabled = 0;
6639 	set_pkt_forwarding_mode(res->mode);
6640 }
6641 
6642 cmdline_parse_token_string_t cmd_setfwd_set =
6643 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6644 cmdline_parse_token_string_t cmd_setfwd_fwd =
6645 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6646 cmdline_parse_token_string_t cmd_setfwd_mode =
6647 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6648 		"" /* defined at init */);
6649 
6650 cmdline_parse_inst_t cmd_set_fwd_mode = {
6651 	.f = cmd_set_fwd_mode_parsed,
6652 	.data = NULL,
6653 	.help_str = NULL, /* defined at init */
6654 	.tokens = {
6655 		(void *)&cmd_setfwd_set,
6656 		(void *)&cmd_setfwd_fwd,
6657 		(void *)&cmd_setfwd_mode,
6658 		NULL,
6659 	},
6660 };
6661 
6662 static void cmd_set_fwd_mode_init(void)
6663 {
6664 	char *modes, *c;
6665 	static char token[128];
6666 	static char help[256];
6667 	cmdline_parse_token_string_t *token_struct;
6668 
6669 	modes = list_pkt_forwarding_modes();
6670 	snprintf(help, sizeof(help), "set fwd %s: "
6671 		"Set packet forwarding mode", modes);
6672 	cmd_set_fwd_mode.help_str = help;
6673 
6674 	/* string token separator is # */
6675 	for (c = token; *modes != '\0'; modes++)
6676 		if (*modes == '|')
6677 			*c++ = '#';
6678 		else
6679 			*c++ = *modes;
6680 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6681 	token_struct->string_data.str = token;
6682 }
6683 
6684 /* *** SET RETRY FORWARDING MODE *** */
6685 struct cmd_set_fwd_retry_mode_result {
6686 	cmdline_fixed_string_t set;
6687 	cmdline_fixed_string_t fwd;
6688 	cmdline_fixed_string_t mode;
6689 	cmdline_fixed_string_t retry;
6690 };
6691 
6692 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6693 			    __rte_unused struct cmdline *cl,
6694 			    __rte_unused void *data)
6695 {
6696 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6697 
6698 	retry_enabled = 1;
6699 	set_pkt_forwarding_mode(res->mode);
6700 }
6701 
6702 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6703 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6704 			set, "set");
6705 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6706 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6707 			fwd, "fwd");
6708 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6709 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6710 			mode,
6711 		"" /* defined at init */);
6712 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6713 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6714 			retry, "retry");
6715 
6716 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6717 	.f = cmd_set_fwd_retry_mode_parsed,
6718 	.data = NULL,
6719 	.help_str = NULL, /* defined at init */
6720 	.tokens = {
6721 		(void *)&cmd_setfwd_retry_set,
6722 		(void *)&cmd_setfwd_retry_fwd,
6723 		(void *)&cmd_setfwd_retry_mode,
6724 		(void *)&cmd_setfwd_retry_retry,
6725 		NULL,
6726 	},
6727 };
6728 
6729 static void cmd_set_fwd_retry_mode_init(void)
6730 {
6731 	char *modes, *c;
6732 	static char token[128];
6733 	static char help[256];
6734 	cmdline_parse_token_string_t *token_struct;
6735 
6736 	modes = list_pkt_forwarding_retry_modes();
6737 	snprintf(help, sizeof(help), "set fwd %s retry: "
6738 		"Set packet forwarding mode with retry", modes);
6739 	cmd_set_fwd_retry_mode.help_str = help;
6740 
6741 	/* string token separator is # */
6742 	for (c = token; *modes != '\0'; modes++)
6743 		if (*modes == '|')
6744 			*c++ = '#';
6745 		else
6746 			*c++ = *modes;
6747 	token_struct = (cmdline_parse_token_string_t *)
6748 		cmd_set_fwd_retry_mode.tokens[2];
6749 	token_struct->string_data.str = token;
6750 }
6751 
6752 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6753 struct cmd_set_burst_tx_retry_result {
6754 	cmdline_fixed_string_t set;
6755 	cmdline_fixed_string_t burst;
6756 	cmdline_fixed_string_t tx;
6757 	cmdline_fixed_string_t delay;
6758 	uint32_t time;
6759 	cmdline_fixed_string_t retry;
6760 	uint32_t retry_num;
6761 };
6762 
6763 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6764 					__rte_unused struct cmdline *cl,
6765 					__rte_unused void *data)
6766 {
6767 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6768 
6769 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6770 		&& !strcmp(res->tx, "tx")) {
6771 		if (!strcmp(res->delay, "delay"))
6772 			burst_tx_delay_time = res->time;
6773 		if (!strcmp(res->retry, "retry"))
6774 			burst_tx_retry_num = res->retry_num;
6775 	}
6776 
6777 }
6778 
6779 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6780 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6781 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6782 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6783 				 "burst");
6784 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6785 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6786 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6787 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6788 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6789 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6790 				 RTE_UINT32);
6791 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6792 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6793 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6794 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6795 				 RTE_UINT32);
6796 
6797 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6798 	.f = cmd_set_burst_tx_retry_parsed,
6799 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6800 	.tokens = {
6801 		(void *)&cmd_set_burst_tx_retry_set,
6802 		(void *)&cmd_set_burst_tx_retry_burst,
6803 		(void *)&cmd_set_burst_tx_retry_tx,
6804 		(void *)&cmd_set_burst_tx_retry_delay,
6805 		(void *)&cmd_set_burst_tx_retry_time,
6806 		(void *)&cmd_set_burst_tx_retry_retry,
6807 		(void *)&cmd_set_burst_tx_retry_retry_num,
6808 		NULL,
6809 	},
6810 };
6811 
6812 /* *** SET PROMISC MODE *** */
6813 struct cmd_set_promisc_mode_result {
6814 	cmdline_fixed_string_t set;
6815 	cmdline_fixed_string_t promisc;
6816 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6817 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6818 	cmdline_fixed_string_t mode;
6819 };
6820 
6821 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6822 					__rte_unused struct cmdline *cl,
6823 					void *allports)
6824 {
6825 	struct cmd_set_promisc_mode_result *res = parsed_result;
6826 	int enable;
6827 	portid_t i;
6828 
6829 	if (!strcmp(res->mode, "on"))
6830 		enable = 1;
6831 	else
6832 		enable = 0;
6833 
6834 	/* all ports */
6835 	if (allports) {
6836 		RTE_ETH_FOREACH_DEV(i)
6837 			eth_set_promisc_mode(i, enable);
6838 	} else {
6839 		eth_set_promisc_mode(res->port_num, enable);
6840 	}
6841 }
6842 
6843 cmdline_parse_token_string_t cmd_setpromisc_set =
6844 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6845 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6846 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6847 				 "promisc");
6848 cmdline_parse_token_string_t cmd_setpromisc_portall =
6849 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6850 				 "all");
6851 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6852 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6853 			      RTE_UINT16);
6854 cmdline_parse_token_string_t cmd_setpromisc_mode =
6855 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6856 				 "on#off");
6857 
6858 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6859 	.f = cmd_set_promisc_mode_parsed,
6860 	.data = (void *)1,
6861 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6862 	.tokens = {
6863 		(void *)&cmd_setpromisc_set,
6864 		(void *)&cmd_setpromisc_promisc,
6865 		(void *)&cmd_setpromisc_portall,
6866 		(void *)&cmd_setpromisc_mode,
6867 		NULL,
6868 	},
6869 };
6870 
6871 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6872 	.f = cmd_set_promisc_mode_parsed,
6873 	.data = (void *)0,
6874 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6875 	.tokens = {
6876 		(void *)&cmd_setpromisc_set,
6877 		(void *)&cmd_setpromisc_promisc,
6878 		(void *)&cmd_setpromisc_portnum,
6879 		(void *)&cmd_setpromisc_mode,
6880 		NULL,
6881 	},
6882 };
6883 
6884 /* *** SET ALLMULTI MODE *** */
6885 struct cmd_set_allmulti_mode_result {
6886 	cmdline_fixed_string_t set;
6887 	cmdline_fixed_string_t allmulti;
6888 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6889 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6890 	cmdline_fixed_string_t mode;
6891 };
6892 
6893 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6894 					__rte_unused struct cmdline *cl,
6895 					void *allports)
6896 {
6897 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6898 	int enable;
6899 	portid_t i;
6900 
6901 	if (!strcmp(res->mode, "on"))
6902 		enable = 1;
6903 	else
6904 		enable = 0;
6905 
6906 	/* all ports */
6907 	if (allports) {
6908 		RTE_ETH_FOREACH_DEV(i) {
6909 			eth_set_allmulticast_mode(i, enable);
6910 		}
6911 	}
6912 	else {
6913 		eth_set_allmulticast_mode(res->port_num, enable);
6914 	}
6915 }
6916 
6917 cmdline_parse_token_string_t cmd_setallmulti_set =
6918 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6919 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6920 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6921 				 "allmulti");
6922 cmdline_parse_token_string_t cmd_setallmulti_portall =
6923 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6924 				 "all");
6925 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6926 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6927 			      RTE_UINT16);
6928 cmdline_parse_token_string_t cmd_setallmulti_mode =
6929 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6930 				 "on#off");
6931 
6932 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6933 	.f = cmd_set_allmulti_mode_parsed,
6934 	.data = (void *)1,
6935 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6936 	.tokens = {
6937 		(void *)&cmd_setallmulti_set,
6938 		(void *)&cmd_setallmulti_allmulti,
6939 		(void *)&cmd_setallmulti_portall,
6940 		(void *)&cmd_setallmulti_mode,
6941 		NULL,
6942 	},
6943 };
6944 
6945 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6946 	.f = cmd_set_allmulti_mode_parsed,
6947 	.data = (void *)0,
6948 	.help_str = "set allmulti <port_id> on|off: "
6949 		"Set allmulti mode on port_id",
6950 	.tokens = {
6951 		(void *)&cmd_setallmulti_set,
6952 		(void *)&cmd_setallmulti_allmulti,
6953 		(void *)&cmd_setallmulti_portnum,
6954 		(void *)&cmd_setallmulti_mode,
6955 		NULL,
6956 	},
6957 };
6958 
6959 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6960 struct cmd_link_flow_ctrl_set_result {
6961 	cmdline_fixed_string_t set;
6962 	cmdline_fixed_string_t flow_ctrl;
6963 	cmdline_fixed_string_t rx;
6964 	cmdline_fixed_string_t rx_lfc_mode;
6965 	cmdline_fixed_string_t tx;
6966 	cmdline_fixed_string_t tx_lfc_mode;
6967 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6968 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6969 	cmdline_fixed_string_t autoneg_str;
6970 	cmdline_fixed_string_t autoneg;
6971 	cmdline_fixed_string_t hw_str;
6972 	uint32_t high_water;
6973 	cmdline_fixed_string_t lw_str;
6974 	uint32_t low_water;
6975 	cmdline_fixed_string_t pt_str;
6976 	uint16_t pause_time;
6977 	cmdline_fixed_string_t xon_str;
6978 	uint16_t send_xon;
6979 	portid_t port_id;
6980 };
6981 
6982 cmdline_parse_token_string_t cmd_lfc_set_set =
6983 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6984 				set, "set");
6985 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6986 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6987 				flow_ctrl, "flow_ctrl");
6988 cmdline_parse_token_string_t cmd_lfc_set_rx =
6989 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6990 				rx, "rx");
6991 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6992 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6993 				rx_lfc_mode, "on#off");
6994 cmdline_parse_token_string_t cmd_lfc_set_tx =
6995 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6996 				tx, "tx");
6997 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6998 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6999 				tx_lfc_mode, "on#off");
7000 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7001 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7002 				hw_str, "high_water");
7003 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7004 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7005 				high_water, RTE_UINT32);
7006 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7007 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7008 				lw_str, "low_water");
7009 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7010 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7011 				low_water, RTE_UINT32);
7012 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7013 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7014 				pt_str, "pause_time");
7015 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7016 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7017 				pause_time, RTE_UINT16);
7018 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7019 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7020 				xon_str, "send_xon");
7021 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7022 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7023 				send_xon, RTE_UINT16);
7024 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7025 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7026 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7027 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7028 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7029 				mac_ctrl_frame_fwd_mode, "on#off");
7030 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7031 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7032 				autoneg_str, "autoneg");
7033 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7034 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7035 				autoneg, "on#off");
7036 cmdline_parse_token_num_t cmd_lfc_set_portid =
7037 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7038 				port_id, RTE_UINT16);
7039 
7040 /* forward declaration */
7041 static void
7042 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7043 			      void *data);
7044 
7045 cmdline_parse_inst_t cmd_link_flow_control_set = {
7046 	.f = cmd_link_flow_ctrl_set_parsed,
7047 	.data = NULL,
7048 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7049 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7050 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
7051 	.tokens = {
7052 		(void *)&cmd_lfc_set_set,
7053 		(void *)&cmd_lfc_set_flow_ctrl,
7054 		(void *)&cmd_lfc_set_rx,
7055 		(void *)&cmd_lfc_set_rx_mode,
7056 		(void *)&cmd_lfc_set_tx,
7057 		(void *)&cmd_lfc_set_tx_mode,
7058 		(void *)&cmd_lfc_set_high_water,
7059 		(void *)&cmd_lfc_set_low_water,
7060 		(void *)&cmd_lfc_set_pause_time,
7061 		(void *)&cmd_lfc_set_send_xon,
7062 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7063 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7064 		(void *)&cmd_lfc_set_autoneg_str,
7065 		(void *)&cmd_lfc_set_autoneg,
7066 		(void *)&cmd_lfc_set_portid,
7067 		NULL,
7068 	},
7069 };
7070 
7071 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7072 	.f = cmd_link_flow_ctrl_set_parsed,
7073 	.data = (void *)&cmd_link_flow_control_set_rx,
7074 	.help_str = "set flow_ctrl rx on|off <port_id>: "
7075 		"Change rx flow control parameter",
7076 	.tokens = {
7077 		(void *)&cmd_lfc_set_set,
7078 		(void *)&cmd_lfc_set_flow_ctrl,
7079 		(void *)&cmd_lfc_set_rx,
7080 		(void *)&cmd_lfc_set_rx_mode,
7081 		(void *)&cmd_lfc_set_portid,
7082 		NULL,
7083 	},
7084 };
7085 
7086 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7087 	.f = cmd_link_flow_ctrl_set_parsed,
7088 	.data = (void *)&cmd_link_flow_control_set_tx,
7089 	.help_str = "set flow_ctrl tx on|off <port_id>: "
7090 		"Change tx flow control parameter",
7091 	.tokens = {
7092 		(void *)&cmd_lfc_set_set,
7093 		(void *)&cmd_lfc_set_flow_ctrl,
7094 		(void *)&cmd_lfc_set_tx,
7095 		(void *)&cmd_lfc_set_tx_mode,
7096 		(void *)&cmd_lfc_set_portid,
7097 		NULL,
7098 	},
7099 };
7100 
7101 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7102 	.f = cmd_link_flow_ctrl_set_parsed,
7103 	.data = (void *)&cmd_link_flow_control_set_hw,
7104 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
7105 		"Change high water flow control parameter",
7106 	.tokens = {
7107 		(void *)&cmd_lfc_set_set,
7108 		(void *)&cmd_lfc_set_flow_ctrl,
7109 		(void *)&cmd_lfc_set_high_water_str,
7110 		(void *)&cmd_lfc_set_high_water,
7111 		(void *)&cmd_lfc_set_portid,
7112 		NULL,
7113 	},
7114 };
7115 
7116 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7117 	.f = cmd_link_flow_ctrl_set_parsed,
7118 	.data = (void *)&cmd_link_flow_control_set_lw,
7119 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7120 		"Change low water flow control parameter",
7121 	.tokens = {
7122 		(void *)&cmd_lfc_set_set,
7123 		(void *)&cmd_lfc_set_flow_ctrl,
7124 		(void *)&cmd_lfc_set_low_water_str,
7125 		(void *)&cmd_lfc_set_low_water,
7126 		(void *)&cmd_lfc_set_portid,
7127 		NULL,
7128 	},
7129 };
7130 
7131 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7132 	.f = cmd_link_flow_ctrl_set_parsed,
7133 	.data = (void *)&cmd_link_flow_control_set_pt,
7134 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7135 		"Change pause time flow control parameter",
7136 	.tokens = {
7137 		(void *)&cmd_lfc_set_set,
7138 		(void *)&cmd_lfc_set_flow_ctrl,
7139 		(void *)&cmd_lfc_set_pause_time_str,
7140 		(void *)&cmd_lfc_set_pause_time,
7141 		(void *)&cmd_lfc_set_portid,
7142 		NULL,
7143 	},
7144 };
7145 
7146 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7147 	.f = cmd_link_flow_ctrl_set_parsed,
7148 	.data = (void *)&cmd_link_flow_control_set_xon,
7149 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7150 		"Change send_xon flow control parameter",
7151 	.tokens = {
7152 		(void *)&cmd_lfc_set_set,
7153 		(void *)&cmd_lfc_set_flow_ctrl,
7154 		(void *)&cmd_lfc_set_send_xon_str,
7155 		(void *)&cmd_lfc_set_send_xon,
7156 		(void *)&cmd_lfc_set_portid,
7157 		NULL,
7158 	},
7159 };
7160 
7161 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7162 	.f = cmd_link_flow_ctrl_set_parsed,
7163 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7164 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7165 		"Change mac ctrl fwd flow control parameter",
7166 	.tokens = {
7167 		(void *)&cmd_lfc_set_set,
7168 		(void *)&cmd_lfc_set_flow_ctrl,
7169 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7170 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7171 		(void *)&cmd_lfc_set_portid,
7172 		NULL,
7173 	},
7174 };
7175 
7176 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7177 	.f = cmd_link_flow_ctrl_set_parsed,
7178 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7179 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7180 		"Change autoneg flow control parameter",
7181 	.tokens = {
7182 		(void *)&cmd_lfc_set_set,
7183 		(void *)&cmd_lfc_set_flow_ctrl,
7184 		(void *)&cmd_lfc_set_autoneg_str,
7185 		(void *)&cmd_lfc_set_autoneg,
7186 		(void *)&cmd_lfc_set_portid,
7187 		NULL,
7188 	},
7189 };
7190 
7191 static void
7192 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7193 			      __rte_unused struct cmdline *cl,
7194 			      void *data)
7195 {
7196 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7197 	cmdline_parse_inst_t *cmd = data;
7198 	struct rte_eth_fc_conf fc_conf;
7199 	int rx_fc_en = 0;
7200 	int tx_fc_en = 0;
7201 	int ret;
7202 
7203 	/*
7204 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7205 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7206 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7207 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7208 	 */
7209 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7210 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7211 	};
7212 
7213 	/* Partial command line, retrieve current configuration */
7214 	if (cmd) {
7215 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7216 		if (ret != 0) {
7217 			printf("cannot get current flow ctrl parameters, return"
7218 			       "code = %d\n", ret);
7219 			return;
7220 		}
7221 
7222 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7223 		    (fc_conf.mode == RTE_FC_FULL))
7224 			rx_fc_en = 1;
7225 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7226 		    (fc_conf.mode == RTE_FC_FULL))
7227 			tx_fc_en = 1;
7228 	}
7229 
7230 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7231 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7232 
7233 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7234 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7235 
7236 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7237 
7238 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7239 		fc_conf.high_water = res->high_water;
7240 
7241 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7242 		fc_conf.low_water = res->low_water;
7243 
7244 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7245 		fc_conf.pause_time = res->pause_time;
7246 
7247 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7248 		fc_conf.send_xon = res->send_xon;
7249 
7250 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7251 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7252 			fc_conf.mac_ctrl_frame_fwd = 1;
7253 		else
7254 			fc_conf.mac_ctrl_frame_fwd = 0;
7255 	}
7256 
7257 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7258 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7259 
7260 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7261 	if (ret != 0)
7262 		printf("bad flow contrl parameter, return code = %d \n", ret);
7263 }
7264 
7265 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7266 struct cmd_priority_flow_ctrl_set_result {
7267 	cmdline_fixed_string_t set;
7268 	cmdline_fixed_string_t pfc_ctrl;
7269 	cmdline_fixed_string_t rx;
7270 	cmdline_fixed_string_t rx_pfc_mode;
7271 	cmdline_fixed_string_t tx;
7272 	cmdline_fixed_string_t tx_pfc_mode;
7273 	uint32_t high_water;
7274 	uint32_t low_water;
7275 	uint16_t pause_time;
7276 	uint8_t  priority;
7277 	portid_t port_id;
7278 };
7279 
7280 static void
7281 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7282 		       __rte_unused struct cmdline *cl,
7283 		       __rte_unused void *data)
7284 {
7285 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7286 	struct rte_eth_pfc_conf pfc_conf;
7287 	int rx_fc_enable, tx_fc_enable;
7288 	int ret;
7289 
7290 	/*
7291 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7292 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7293 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7294 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7295 	 */
7296 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7297 		{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7298 	};
7299 
7300 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7301 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7302 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7303 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7304 	pfc_conf.fc.high_water = res->high_water;
7305 	pfc_conf.fc.low_water  = res->low_water;
7306 	pfc_conf.fc.pause_time = res->pause_time;
7307 	pfc_conf.priority      = res->priority;
7308 
7309 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7310 	if (ret != 0)
7311 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7312 }
7313 
7314 cmdline_parse_token_string_t cmd_pfc_set_set =
7315 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7316 				set, "set");
7317 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7318 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7319 				pfc_ctrl, "pfc_ctrl");
7320 cmdline_parse_token_string_t cmd_pfc_set_rx =
7321 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7322 				rx, "rx");
7323 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7324 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7325 				rx_pfc_mode, "on#off");
7326 cmdline_parse_token_string_t cmd_pfc_set_tx =
7327 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7328 				tx, "tx");
7329 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7330 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7331 				tx_pfc_mode, "on#off");
7332 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7333 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7334 				high_water, RTE_UINT32);
7335 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7336 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7337 				low_water, RTE_UINT32);
7338 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7339 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7340 				pause_time, RTE_UINT16);
7341 cmdline_parse_token_num_t cmd_pfc_set_priority =
7342 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7343 				priority, RTE_UINT8);
7344 cmdline_parse_token_num_t cmd_pfc_set_portid =
7345 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7346 				port_id, RTE_UINT16);
7347 
7348 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7349 	.f = cmd_priority_flow_ctrl_set_parsed,
7350 	.data = NULL,
7351 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7352 		"<pause_time> <priority> <port_id>: "
7353 		"Configure the Ethernet priority flow control",
7354 	.tokens = {
7355 		(void *)&cmd_pfc_set_set,
7356 		(void *)&cmd_pfc_set_flow_ctrl,
7357 		(void *)&cmd_pfc_set_rx,
7358 		(void *)&cmd_pfc_set_rx_mode,
7359 		(void *)&cmd_pfc_set_tx,
7360 		(void *)&cmd_pfc_set_tx_mode,
7361 		(void *)&cmd_pfc_set_high_water,
7362 		(void *)&cmd_pfc_set_low_water,
7363 		(void *)&cmd_pfc_set_pause_time,
7364 		(void *)&cmd_pfc_set_priority,
7365 		(void *)&cmd_pfc_set_portid,
7366 		NULL,
7367 	},
7368 };
7369 
7370 /* *** RESET CONFIGURATION *** */
7371 struct cmd_reset_result {
7372 	cmdline_fixed_string_t reset;
7373 	cmdline_fixed_string_t def;
7374 };
7375 
7376 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7377 			     struct cmdline *cl,
7378 			     __rte_unused void *data)
7379 {
7380 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7381 	set_def_fwd_config();
7382 }
7383 
7384 cmdline_parse_token_string_t cmd_reset_set =
7385 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7386 cmdline_parse_token_string_t cmd_reset_def =
7387 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7388 				 "default");
7389 
7390 cmdline_parse_inst_t cmd_reset = {
7391 	.f = cmd_reset_parsed,
7392 	.data = NULL,
7393 	.help_str = "set default: Reset default forwarding configuration",
7394 	.tokens = {
7395 		(void *)&cmd_reset_set,
7396 		(void *)&cmd_reset_def,
7397 		NULL,
7398 	},
7399 };
7400 
7401 /* *** START FORWARDING *** */
7402 struct cmd_start_result {
7403 	cmdline_fixed_string_t start;
7404 };
7405 
7406 cmdline_parse_token_string_t cmd_start_start =
7407 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7408 
7409 static void cmd_start_parsed(__rte_unused void *parsed_result,
7410 			     __rte_unused struct cmdline *cl,
7411 			     __rte_unused void *data)
7412 {
7413 	start_packet_forwarding(0);
7414 }
7415 
7416 cmdline_parse_inst_t cmd_start = {
7417 	.f = cmd_start_parsed,
7418 	.data = NULL,
7419 	.help_str = "start: Start packet forwarding",
7420 	.tokens = {
7421 		(void *)&cmd_start_start,
7422 		NULL,
7423 	},
7424 };
7425 
7426 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7427 struct cmd_start_tx_first_result {
7428 	cmdline_fixed_string_t start;
7429 	cmdline_fixed_string_t tx_first;
7430 };
7431 
7432 static void
7433 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7434 			  __rte_unused struct cmdline *cl,
7435 			  __rte_unused void *data)
7436 {
7437 	start_packet_forwarding(1);
7438 }
7439 
7440 cmdline_parse_token_string_t cmd_start_tx_first_start =
7441 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7442 				 "start");
7443 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7444 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7445 				 tx_first, "tx_first");
7446 
7447 cmdline_parse_inst_t cmd_start_tx_first = {
7448 	.f = cmd_start_tx_first_parsed,
7449 	.data = NULL,
7450 	.help_str = "start tx_first: Start packet forwarding, "
7451 		"after sending 1 burst of packets",
7452 	.tokens = {
7453 		(void *)&cmd_start_tx_first_start,
7454 		(void *)&cmd_start_tx_first_tx_first,
7455 		NULL,
7456 	},
7457 };
7458 
7459 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7460 struct cmd_start_tx_first_n_result {
7461 	cmdline_fixed_string_t start;
7462 	cmdline_fixed_string_t tx_first;
7463 	uint32_t tx_num;
7464 };
7465 
7466 static void
7467 cmd_start_tx_first_n_parsed(void *parsed_result,
7468 			  __rte_unused struct cmdline *cl,
7469 			  __rte_unused void *data)
7470 {
7471 	struct cmd_start_tx_first_n_result *res = parsed_result;
7472 
7473 	start_packet_forwarding(res->tx_num);
7474 }
7475 
7476 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7477 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7478 			start, "start");
7479 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7480 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7481 			tx_first, "tx_first");
7482 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7483 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7484 			tx_num, RTE_UINT32);
7485 
7486 cmdline_parse_inst_t cmd_start_tx_first_n = {
7487 	.f = cmd_start_tx_first_n_parsed,
7488 	.data = NULL,
7489 	.help_str = "start tx_first <num>: "
7490 		"packet forwarding, after sending <num> bursts of packets",
7491 	.tokens = {
7492 		(void *)&cmd_start_tx_first_n_start,
7493 		(void *)&cmd_start_tx_first_n_tx_first,
7494 		(void *)&cmd_start_tx_first_n_tx_num,
7495 		NULL,
7496 	},
7497 };
7498 
7499 /* *** SET LINK UP *** */
7500 struct cmd_set_link_up_result {
7501 	cmdline_fixed_string_t set;
7502 	cmdline_fixed_string_t link_up;
7503 	cmdline_fixed_string_t port;
7504 	portid_t port_id;
7505 };
7506 
7507 cmdline_parse_token_string_t cmd_set_link_up_set =
7508 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7509 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7510 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7511 				"link-up");
7512 cmdline_parse_token_string_t cmd_set_link_up_port =
7513 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7514 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7515 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7516 				RTE_UINT16);
7517 
7518 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7519 			     __rte_unused struct cmdline *cl,
7520 			     __rte_unused void *data)
7521 {
7522 	struct cmd_set_link_up_result *res = parsed_result;
7523 	dev_set_link_up(res->port_id);
7524 }
7525 
7526 cmdline_parse_inst_t cmd_set_link_up = {
7527 	.f = cmd_set_link_up_parsed,
7528 	.data = NULL,
7529 	.help_str = "set link-up port <port id>",
7530 	.tokens = {
7531 		(void *)&cmd_set_link_up_set,
7532 		(void *)&cmd_set_link_up_link_up,
7533 		(void *)&cmd_set_link_up_port,
7534 		(void *)&cmd_set_link_up_port_id,
7535 		NULL,
7536 	},
7537 };
7538 
7539 /* *** SET LINK DOWN *** */
7540 struct cmd_set_link_down_result {
7541 	cmdline_fixed_string_t set;
7542 	cmdline_fixed_string_t link_down;
7543 	cmdline_fixed_string_t port;
7544 	portid_t port_id;
7545 };
7546 
7547 cmdline_parse_token_string_t cmd_set_link_down_set =
7548 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7549 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7550 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7551 				"link-down");
7552 cmdline_parse_token_string_t cmd_set_link_down_port =
7553 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7554 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7555 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7556 				RTE_UINT16);
7557 
7558 static void cmd_set_link_down_parsed(
7559 				__rte_unused void *parsed_result,
7560 				__rte_unused struct cmdline *cl,
7561 				__rte_unused void *data)
7562 {
7563 	struct cmd_set_link_down_result *res = parsed_result;
7564 	dev_set_link_down(res->port_id);
7565 }
7566 
7567 cmdline_parse_inst_t cmd_set_link_down = {
7568 	.f = cmd_set_link_down_parsed,
7569 	.data = NULL,
7570 	.help_str = "set link-down port <port id>",
7571 	.tokens = {
7572 		(void *)&cmd_set_link_down_set,
7573 		(void *)&cmd_set_link_down_link_down,
7574 		(void *)&cmd_set_link_down_port,
7575 		(void *)&cmd_set_link_down_port_id,
7576 		NULL,
7577 	},
7578 };
7579 
7580 /* *** SHOW CFG *** */
7581 struct cmd_showcfg_result {
7582 	cmdline_fixed_string_t show;
7583 	cmdline_fixed_string_t cfg;
7584 	cmdline_fixed_string_t what;
7585 };
7586 
7587 static void cmd_showcfg_parsed(void *parsed_result,
7588 			       __rte_unused struct cmdline *cl,
7589 			       __rte_unused void *data)
7590 {
7591 	struct cmd_showcfg_result *res = parsed_result;
7592 	if (!strcmp(res->what, "rxtx"))
7593 		rxtx_config_display();
7594 	else if (!strcmp(res->what, "cores"))
7595 		fwd_lcores_config_display();
7596 	else if (!strcmp(res->what, "fwd"))
7597 		pkt_fwd_config_display(&cur_fwd_config);
7598 	else if (!strcmp(res->what, "rxoffs"))
7599 		show_rx_pkt_offsets();
7600 	else if (!strcmp(res->what, "rxpkts"))
7601 		show_rx_pkt_segments();
7602 	else if (!strcmp(res->what, "txpkts"))
7603 		show_tx_pkt_segments();
7604 	else if (!strcmp(res->what, "txtimes"))
7605 		show_tx_pkt_times();
7606 }
7607 
7608 cmdline_parse_token_string_t cmd_showcfg_show =
7609 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7610 cmdline_parse_token_string_t cmd_showcfg_port =
7611 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7612 cmdline_parse_token_string_t cmd_showcfg_what =
7613 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7614 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7615 
7616 cmdline_parse_inst_t cmd_showcfg = {
7617 	.f = cmd_showcfg_parsed,
7618 	.data = NULL,
7619 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7620 	.tokens = {
7621 		(void *)&cmd_showcfg_show,
7622 		(void *)&cmd_showcfg_port,
7623 		(void *)&cmd_showcfg_what,
7624 		NULL,
7625 	},
7626 };
7627 
7628 /* *** SHOW ALL PORT INFO *** */
7629 struct cmd_showportall_result {
7630 	cmdline_fixed_string_t show;
7631 	cmdline_fixed_string_t port;
7632 	cmdline_fixed_string_t what;
7633 	cmdline_fixed_string_t all;
7634 };
7635 
7636 static void cmd_showportall_parsed(void *parsed_result,
7637 				__rte_unused struct cmdline *cl,
7638 				__rte_unused void *data)
7639 {
7640 	portid_t i;
7641 
7642 	struct cmd_showportall_result *res = parsed_result;
7643 	if (!strcmp(res->show, "clear")) {
7644 		if (!strcmp(res->what, "stats"))
7645 			RTE_ETH_FOREACH_DEV(i)
7646 				nic_stats_clear(i);
7647 		else if (!strcmp(res->what, "xstats"))
7648 			RTE_ETH_FOREACH_DEV(i)
7649 				nic_xstats_clear(i);
7650 	} else if (!strcmp(res->what, "info"))
7651 		RTE_ETH_FOREACH_DEV(i)
7652 			port_infos_display(i);
7653 	else if (!strcmp(res->what, "summary")) {
7654 		port_summary_header_display();
7655 		RTE_ETH_FOREACH_DEV(i)
7656 			port_summary_display(i);
7657 	}
7658 	else if (!strcmp(res->what, "stats"))
7659 		RTE_ETH_FOREACH_DEV(i)
7660 			nic_stats_display(i);
7661 	else if (!strcmp(res->what, "xstats"))
7662 		RTE_ETH_FOREACH_DEV(i)
7663 			nic_xstats_display(i);
7664 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7665 	else if (!strcmp(res->what, "fdir"))
7666 		RTE_ETH_FOREACH_DEV(i)
7667 			fdir_get_infos(i);
7668 #endif
7669 	else if (!strcmp(res->what, "dcb_tc"))
7670 		RTE_ETH_FOREACH_DEV(i)
7671 			port_dcb_info_display(i);
7672 }
7673 
7674 cmdline_parse_token_string_t cmd_showportall_show =
7675 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7676 				 "show#clear");
7677 cmdline_parse_token_string_t cmd_showportall_port =
7678 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7679 cmdline_parse_token_string_t cmd_showportall_what =
7680 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7681 				 "info#summary#stats#xstats#fdir#dcb_tc");
7682 cmdline_parse_token_string_t cmd_showportall_all =
7683 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7684 cmdline_parse_inst_t cmd_showportall = {
7685 	.f = cmd_showportall_parsed,
7686 	.data = NULL,
7687 	.help_str = "show|clear port "
7688 		"info|summary|stats|xstats|fdir|dcb_tc all",
7689 	.tokens = {
7690 		(void *)&cmd_showportall_show,
7691 		(void *)&cmd_showportall_port,
7692 		(void *)&cmd_showportall_what,
7693 		(void *)&cmd_showportall_all,
7694 		NULL,
7695 	},
7696 };
7697 
7698 /* *** SHOW PORT INFO *** */
7699 struct cmd_showport_result {
7700 	cmdline_fixed_string_t show;
7701 	cmdline_fixed_string_t port;
7702 	cmdline_fixed_string_t what;
7703 	uint16_t portnum;
7704 };
7705 
7706 static void cmd_showport_parsed(void *parsed_result,
7707 				__rte_unused struct cmdline *cl,
7708 				__rte_unused void *data)
7709 {
7710 	struct cmd_showport_result *res = parsed_result;
7711 	if (!strcmp(res->show, "clear")) {
7712 		if (!strcmp(res->what, "stats"))
7713 			nic_stats_clear(res->portnum);
7714 		else if (!strcmp(res->what, "xstats"))
7715 			nic_xstats_clear(res->portnum);
7716 	} else if (!strcmp(res->what, "info"))
7717 		port_infos_display(res->portnum);
7718 	else if (!strcmp(res->what, "summary")) {
7719 		port_summary_header_display();
7720 		port_summary_display(res->portnum);
7721 	}
7722 	else if (!strcmp(res->what, "stats"))
7723 		nic_stats_display(res->portnum);
7724 	else if (!strcmp(res->what, "xstats"))
7725 		nic_xstats_display(res->portnum);
7726 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7727 	else if (!strcmp(res->what, "fdir"))
7728 		 fdir_get_infos(res->portnum);
7729 #endif
7730 	else if (!strcmp(res->what, "dcb_tc"))
7731 		port_dcb_info_display(res->portnum);
7732 }
7733 
7734 cmdline_parse_token_string_t cmd_showport_show =
7735 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7736 				 "show#clear");
7737 cmdline_parse_token_string_t cmd_showport_port =
7738 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7739 cmdline_parse_token_string_t cmd_showport_what =
7740 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7741 				 "info#summary#stats#xstats#fdir#dcb_tc");
7742 cmdline_parse_token_num_t cmd_showport_portnum =
7743 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7744 
7745 cmdline_parse_inst_t cmd_showport = {
7746 	.f = cmd_showport_parsed,
7747 	.data = NULL,
7748 	.help_str = "show|clear port "
7749 		"info|summary|stats|xstats|fdir|dcb_tc "
7750 		"<port_id>",
7751 	.tokens = {
7752 		(void *)&cmd_showport_show,
7753 		(void *)&cmd_showport_port,
7754 		(void *)&cmd_showport_what,
7755 		(void *)&cmd_showport_portnum,
7756 		NULL,
7757 	},
7758 };
7759 
7760 /* *** SHOW DEVICE INFO *** */
7761 struct cmd_showdevice_result {
7762 	cmdline_fixed_string_t show;
7763 	cmdline_fixed_string_t device;
7764 	cmdline_fixed_string_t what;
7765 	cmdline_fixed_string_t identifier;
7766 };
7767 
7768 static void cmd_showdevice_parsed(void *parsed_result,
7769 				__rte_unused struct cmdline *cl,
7770 				__rte_unused void *data)
7771 {
7772 	struct cmd_showdevice_result *res = parsed_result;
7773 	if (!strcmp(res->what, "info")) {
7774 		if (!strcmp(res->identifier, "all"))
7775 			device_infos_display(NULL);
7776 		else
7777 			device_infos_display(res->identifier);
7778 	}
7779 }
7780 
7781 cmdline_parse_token_string_t cmd_showdevice_show =
7782 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7783 				 "show");
7784 cmdline_parse_token_string_t cmd_showdevice_device =
7785 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7786 cmdline_parse_token_string_t cmd_showdevice_what =
7787 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7788 				 "info");
7789 cmdline_parse_token_string_t cmd_showdevice_identifier =
7790 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7791 			identifier, NULL);
7792 
7793 cmdline_parse_inst_t cmd_showdevice = {
7794 	.f = cmd_showdevice_parsed,
7795 	.data = NULL,
7796 	.help_str = "show device info <identifier>|all",
7797 	.tokens = {
7798 		(void *)&cmd_showdevice_show,
7799 		(void *)&cmd_showdevice_device,
7800 		(void *)&cmd_showdevice_what,
7801 		(void *)&cmd_showdevice_identifier,
7802 		NULL,
7803 	},
7804 };
7805 
7806 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7807 struct cmd_showeeprom_result {
7808 	cmdline_fixed_string_t show;
7809 	cmdline_fixed_string_t port;
7810 	uint16_t portnum;
7811 	cmdline_fixed_string_t type;
7812 };
7813 
7814 static void cmd_showeeprom_parsed(void *parsed_result,
7815 		__rte_unused struct cmdline *cl,
7816 		__rte_unused void *data)
7817 {
7818 	struct cmd_showeeprom_result *res = parsed_result;
7819 
7820 	if (!strcmp(res->type, "eeprom"))
7821 		port_eeprom_display(res->portnum);
7822 	else if (!strcmp(res->type, "module_eeprom"))
7823 		port_module_eeprom_display(res->portnum);
7824 	else
7825 		printf("Unknown argument\n");
7826 }
7827 
7828 cmdline_parse_token_string_t cmd_showeeprom_show =
7829 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7830 cmdline_parse_token_string_t cmd_showeeprom_port =
7831 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7832 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7833 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7834 			RTE_UINT16);
7835 cmdline_parse_token_string_t cmd_showeeprom_type =
7836 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7837 
7838 cmdline_parse_inst_t cmd_showeeprom = {
7839 	.f = cmd_showeeprom_parsed,
7840 	.data = NULL,
7841 	.help_str = "show port <port_id> module_eeprom|eeprom",
7842 	.tokens = {
7843 		(void *)&cmd_showeeprom_show,
7844 		(void *)&cmd_showeeprom_port,
7845 		(void *)&cmd_showeeprom_portnum,
7846 		(void *)&cmd_showeeprom_type,
7847 		NULL,
7848 	},
7849 };
7850 
7851 /* *** SHOW QUEUE INFO *** */
7852 struct cmd_showqueue_result {
7853 	cmdline_fixed_string_t show;
7854 	cmdline_fixed_string_t type;
7855 	cmdline_fixed_string_t what;
7856 	uint16_t portnum;
7857 	uint16_t queuenum;
7858 };
7859 
7860 static void
7861 cmd_showqueue_parsed(void *parsed_result,
7862 	__rte_unused struct cmdline *cl,
7863 	__rte_unused void *data)
7864 {
7865 	struct cmd_showqueue_result *res = parsed_result;
7866 
7867 	if (!strcmp(res->type, "rxq"))
7868 		rx_queue_infos_display(res->portnum, res->queuenum);
7869 	else if (!strcmp(res->type, "txq"))
7870 		tx_queue_infos_display(res->portnum, res->queuenum);
7871 }
7872 
7873 cmdline_parse_token_string_t cmd_showqueue_show =
7874 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7875 cmdline_parse_token_string_t cmd_showqueue_type =
7876 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7877 cmdline_parse_token_string_t cmd_showqueue_what =
7878 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7879 cmdline_parse_token_num_t cmd_showqueue_portnum =
7880 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7881 		RTE_UINT16);
7882 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7883 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7884 		RTE_UINT16);
7885 
7886 cmdline_parse_inst_t cmd_showqueue = {
7887 	.f = cmd_showqueue_parsed,
7888 	.data = NULL,
7889 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7890 	.tokens = {
7891 		(void *)&cmd_showqueue_show,
7892 		(void *)&cmd_showqueue_type,
7893 		(void *)&cmd_showqueue_what,
7894 		(void *)&cmd_showqueue_portnum,
7895 		(void *)&cmd_showqueue_queuenum,
7896 		NULL,
7897 	},
7898 };
7899 
7900 /* show/clear fwd engine statistics */
7901 struct fwd_result {
7902 	cmdline_fixed_string_t action;
7903 	cmdline_fixed_string_t fwd;
7904 	cmdline_fixed_string_t stats;
7905 	cmdline_fixed_string_t all;
7906 };
7907 
7908 cmdline_parse_token_string_t cmd_fwd_action =
7909 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7910 cmdline_parse_token_string_t cmd_fwd_fwd =
7911 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7912 cmdline_parse_token_string_t cmd_fwd_stats =
7913 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7914 cmdline_parse_token_string_t cmd_fwd_all =
7915 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7916 
7917 static void
7918 cmd_showfwdall_parsed(void *parsed_result,
7919 		      __rte_unused struct cmdline *cl,
7920 		      __rte_unused void *data)
7921 {
7922 	struct fwd_result *res = parsed_result;
7923 
7924 	if (!strcmp(res->action, "show"))
7925 		fwd_stats_display();
7926 	else
7927 		fwd_stats_reset();
7928 }
7929 
7930 static cmdline_parse_inst_t cmd_showfwdall = {
7931 	.f = cmd_showfwdall_parsed,
7932 	.data = NULL,
7933 	.help_str = "show|clear fwd stats all",
7934 	.tokens = {
7935 		(void *)&cmd_fwd_action,
7936 		(void *)&cmd_fwd_fwd,
7937 		(void *)&cmd_fwd_stats,
7938 		(void *)&cmd_fwd_all,
7939 		NULL,
7940 	},
7941 };
7942 
7943 /* *** READ PORT REGISTER *** */
7944 struct cmd_read_reg_result {
7945 	cmdline_fixed_string_t read;
7946 	cmdline_fixed_string_t reg;
7947 	portid_t port_id;
7948 	uint32_t reg_off;
7949 };
7950 
7951 static void
7952 cmd_read_reg_parsed(void *parsed_result,
7953 		    __rte_unused struct cmdline *cl,
7954 		    __rte_unused void *data)
7955 {
7956 	struct cmd_read_reg_result *res = parsed_result;
7957 	port_reg_display(res->port_id, res->reg_off);
7958 }
7959 
7960 cmdline_parse_token_string_t cmd_read_reg_read =
7961 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7962 cmdline_parse_token_string_t cmd_read_reg_reg =
7963 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7964 cmdline_parse_token_num_t cmd_read_reg_port_id =
7965 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7966 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7967 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7968 
7969 cmdline_parse_inst_t cmd_read_reg = {
7970 	.f = cmd_read_reg_parsed,
7971 	.data = NULL,
7972 	.help_str = "read reg <port_id> <reg_off>",
7973 	.tokens = {
7974 		(void *)&cmd_read_reg_read,
7975 		(void *)&cmd_read_reg_reg,
7976 		(void *)&cmd_read_reg_port_id,
7977 		(void *)&cmd_read_reg_reg_off,
7978 		NULL,
7979 	},
7980 };
7981 
7982 /* *** READ PORT REGISTER BIT FIELD *** */
7983 struct cmd_read_reg_bit_field_result {
7984 	cmdline_fixed_string_t read;
7985 	cmdline_fixed_string_t regfield;
7986 	portid_t port_id;
7987 	uint32_t reg_off;
7988 	uint8_t bit1_pos;
7989 	uint8_t bit2_pos;
7990 };
7991 
7992 static void
7993 cmd_read_reg_bit_field_parsed(void *parsed_result,
7994 			      __rte_unused struct cmdline *cl,
7995 			      __rte_unused void *data)
7996 {
7997 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7998 	port_reg_bit_field_display(res->port_id, res->reg_off,
7999 				   res->bit1_pos, res->bit2_pos);
8000 }
8001 
8002 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8003 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8004 				 "read");
8005 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8006 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8007 				 regfield, "regfield");
8008 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8009 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8010 			      RTE_UINT16);
8011 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8012 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8013 			      RTE_UINT32);
8014 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8015 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8016 			      RTE_UINT8);
8017 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8018 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8019 			      RTE_UINT8);
8020 
8021 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8022 	.f = cmd_read_reg_bit_field_parsed,
8023 	.data = NULL,
8024 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8025 	"Read register bit field between bit_x and bit_y included",
8026 	.tokens = {
8027 		(void *)&cmd_read_reg_bit_field_read,
8028 		(void *)&cmd_read_reg_bit_field_regfield,
8029 		(void *)&cmd_read_reg_bit_field_port_id,
8030 		(void *)&cmd_read_reg_bit_field_reg_off,
8031 		(void *)&cmd_read_reg_bit_field_bit1_pos,
8032 		(void *)&cmd_read_reg_bit_field_bit2_pos,
8033 		NULL,
8034 	},
8035 };
8036 
8037 /* *** READ PORT REGISTER BIT *** */
8038 struct cmd_read_reg_bit_result {
8039 	cmdline_fixed_string_t read;
8040 	cmdline_fixed_string_t regbit;
8041 	portid_t port_id;
8042 	uint32_t reg_off;
8043 	uint8_t bit_pos;
8044 };
8045 
8046 static void
8047 cmd_read_reg_bit_parsed(void *parsed_result,
8048 			__rte_unused struct cmdline *cl,
8049 			__rte_unused void *data)
8050 {
8051 	struct cmd_read_reg_bit_result *res = parsed_result;
8052 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8053 }
8054 
8055 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8056 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8057 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8058 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8059 				 regbit, "regbit");
8060 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8061 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8062 				 RTE_UINT16);
8063 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8064 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8065 				 RTE_UINT32);
8066 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8067 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8068 				 RTE_UINT8);
8069 
8070 cmdline_parse_inst_t cmd_read_reg_bit = {
8071 	.f = cmd_read_reg_bit_parsed,
8072 	.data = NULL,
8073 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8074 	.tokens = {
8075 		(void *)&cmd_read_reg_bit_read,
8076 		(void *)&cmd_read_reg_bit_regbit,
8077 		(void *)&cmd_read_reg_bit_port_id,
8078 		(void *)&cmd_read_reg_bit_reg_off,
8079 		(void *)&cmd_read_reg_bit_bit_pos,
8080 		NULL,
8081 	},
8082 };
8083 
8084 /* *** WRITE PORT REGISTER *** */
8085 struct cmd_write_reg_result {
8086 	cmdline_fixed_string_t write;
8087 	cmdline_fixed_string_t reg;
8088 	portid_t port_id;
8089 	uint32_t reg_off;
8090 	uint32_t value;
8091 };
8092 
8093 static void
8094 cmd_write_reg_parsed(void *parsed_result,
8095 		     __rte_unused struct cmdline *cl,
8096 		     __rte_unused void *data)
8097 {
8098 	struct cmd_write_reg_result *res = parsed_result;
8099 	port_reg_set(res->port_id, res->reg_off, res->value);
8100 }
8101 
8102 cmdline_parse_token_string_t cmd_write_reg_write =
8103 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8104 cmdline_parse_token_string_t cmd_write_reg_reg =
8105 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8106 cmdline_parse_token_num_t cmd_write_reg_port_id =
8107 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8108 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8109 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8110 cmdline_parse_token_num_t cmd_write_reg_value =
8111 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8112 
8113 cmdline_parse_inst_t cmd_write_reg = {
8114 	.f = cmd_write_reg_parsed,
8115 	.data = NULL,
8116 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8117 	.tokens = {
8118 		(void *)&cmd_write_reg_write,
8119 		(void *)&cmd_write_reg_reg,
8120 		(void *)&cmd_write_reg_port_id,
8121 		(void *)&cmd_write_reg_reg_off,
8122 		(void *)&cmd_write_reg_value,
8123 		NULL,
8124 	},
8125 };
8126 
8127 /* *** WRITE PORT REGISTER BIT FIELD *** */
8128 struct cmd_write_reg_bit_field_result {
8129 	cmdline_fixed_string_t write;
8130 	cmdline_fixed_string_t regfield;
8131 	portid_t port_id;
8132 	uint32_t reg_off;
8133 	uint8_t bit1_pos;
8134 	uint8_t bit2_pos;
8135 	uint32_t value;
8136 };
8137 
8138 static void
8139 cmd_write_reg_bit_field_parsed(void *parsed_result,
8140 			       __rte_unused struct cmdline *cl,
8141 			       __rte_unused void *data)
8142 {
8143 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8144 	port_reg_bit_field_set(res->port_id, res->reg_off,
8145 			  res->bit1_pos, res->bit2_pos, res->value);
8146 }
8147 
8148 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8149 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8150 				 "write");
8151 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8152 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8153 				 regfield, "regfield");
8154 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8155 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8156 			      RTE_UINT16);
8157 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8158 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8159 			      RTE_UINT32);
8160 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8161 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8162 			      RTE_UINT8);
8163 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8164 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8165 			      RTE_UINT8);
8166 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8167 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8168 			      RTE_UINT32);
8169 
8170 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8171 	.f = cmd_write_reg_bit_field_parsed,
8172 	.data = NULL,
8173 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8174 		"<reg_value>: "
8175 		"Set register bit field between bit_x and bit_y included",
8176 	.tokens = {
8177 		(void *)&cmd_write_reg_bit_field_write,
8178 		(void *)&cmd_write_reg_bit_field_regfield,
8179 		(void *)&cmd_write_reg_bit_field_port_id,
8180 		(void *)&cmd_write_reg_bit_field_reg_off,
8181 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8182 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8183 		(void *)&cmd_write_reg_bit_field_value,
8184 		NULL,
8185 	},
8186 };
8187 
8188 /* *** WRITE PORT REGISTER BIT *** */
8189 struct cmd_write_reg_bit_result {
8190 	cmdline_fixed_string_t write;
8191 	cmdline_fixed_string_t regbit;
8192 	portid_t port_id;
8193 	uint32_t reg_off;
8194 	uint8_t bit_pos;
8195 	uint8_t value;
8196 };
8197 
8198 static void
8199 cmd_write_reg_bit_parsed(void *parsed_result,
8200 			 __rte_unused struct cmdline *cl,
8201 			 __rte_unused void *data)
8202 {
8203 	struct cmd_write_reg_bit_result *res = parsed_result;
8204 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8205 }
8206 
8207 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8208 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8209 				 "write");
8210 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8211 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8212 				 regbit, "regbit");
8213 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8214 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8215 				 RTE_UINT16);
8216 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8217 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8218 				 RTE_UINT32);
8219 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8220 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8221 				 RTE_UINT8);
8222 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8223 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8224 				 RTE_UINT8);
8225 
8226 cmdline_parse_inst_t cmd_write_reg_bit = {
8227 	.f = cmd_write_reg_bit_parsed,
8228 	.data = NULL,
8229 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8230 		"0 <= bit_x <= 31",
8231 	.tokens = {
8232 		(void *)&cmd_write_reg_bit_write,
8233 		(void *)&cmd_write_reg_bit_regbit,
8234 		(void *)&cmd_write_reg_bit_port_id,
8235 		(void *)&cmd_write_reg_bit_reg_off,
8236 		(void *)&cmd_write_reg_bit_bit_pos,
8237 		(void *)&cmd_write_reg_bit_value,
8238 		NULL,
8239 	},
8240 };
8241 
8242 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8243 struct cmd_read_rxd_txd_result {
8244 	cmdline_fixed_string_t read;
8245 	cmdline_fixed_string_t rxd_txd;
8246 	portid_t port_id;
8247 	uint16_t queue_id;
8248 	uint16_t desc_id;
8249 };
8250 
8251 static void
8252 cmd_read_rxd_txd_parsed(void *parsed_result,
8253 			__rte_unused struct cmdline *cl,
8254 			__rte_unused void *data)
8255 {
8256 	struct cmd_read_rxd_txd_result *res = parsed_result;
8257 
8258 	if (!strcmp(res->rxd_txd, "rxd"))
8259 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8260 	else if (!strcmp(res->rxd_txd, "txd"))
8261 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8262 }
8263 
8264 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8265 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8266 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8267 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8268 				 "rxd#txd");
8269 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8270 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8271 				 RTE_UINT16);
8272 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8273 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8274 				 RTE_UINT16);
8275 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8276 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8277 				 RTE_UINT16);
8278 
8279 cmdline_parse_inst_t cmd_read_rxd_txd = {
8280 	.f = cmd_read_rxd_txd_parsed,
8281 	.data = NULL,
8282 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8283 	.tokens = {
8284 		(void *)&cmd_read_rxd_txd_read,
8285 		(void *)&cmd_read_rxd_txd_rxd_txd,
8286 		(void *)&cmd_read_rxd_txd_port_id,
8287 		(void *)&cmd_read_rxd_txd_queue_id,
8288 		(void *)&cmd_read_rxd_txd_desc_id,
8289 		NULL,
8290 	},
8291 };
8292 
8293 /* *** QUIT *** */
8294 struct cmd_quit_result {
8295 	cmdline_fixed_string_t quit;
8296 };
8297 
8298 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8299 			    struct cmdline *cl,
8300 			    __rte_unused void *data)
8301 {
8302 	cmdline_quit(cl);
8303 }
8304 
8305 cmdline_parse_token_string_t cmd_quit_quit =
8306 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8307 
8308 cmdline_parse_inst_t cmd_quit = {
8309 	.f = cmd_quit_parsed,
8310 	.data = NULL,
8311 	.help_str = "quit: Exit application",
8312 	.tokens = {
8313 		(void *)&cmd_quit_quit,
8314 		NULL,
8315 	},
8316 };
8317 
8318 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8319 struct cmd_mac_addr_result {
8320 	cmdline_fixed_string_t mac_addr_cmd;
8321 	cmdline_fixed_string_t what;
8322 	uint16_t port_num;
8323 	struct rte_ether_addr address;
8324 };
8325 
8326 static void cmd_mac_addr_parsed(void *parsed_result,
8327 		__rte_unused struct cmdline *cl,
8328 		__rte_unused void *data)
8329 {
8330 	struct cmd_mac_addr_result *res = parsed_result;
8331 	int ret;
8332 
8333 	if (strcmp(res->what, "add") == 0)
8334 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8335 	else if (strcmp(res->what, "set") == 0)
8336 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8337 						       &res->address);
8338 	else
8339 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8340 
8341 	/* check the return value and print it if is < 0 */
8342 	if(ret < 0)
8343 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8344 
8345 }
8346 
8347 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8348 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8349 				"mac_addr");
8350 cmdline_parse_token_string_t cmd_mac_addr_what =
8351 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8352 				"add#remove#set");
8353 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8354 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8355 					RTE_UINT16);
8356 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8357 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8358 
8359 cmdline_parse_inst_t cmd_mac_addr = {
8360 	.f = cmd_mac_addr_parsed,
8361 	.data = (void *)0,
8362 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8363 			"Add/Remove/Set MAC address on port_id",
8364 	.tokens = {
8365 		(void *)&cmd_mac_addr_cmd,
8366 		(void *)&cmd_mac_addr_what,
8367 		(void *)&cmd_mac_addr_portnum,
8368 		(void *)&cmd_mac_addr_addr,
8369 		NULL,
8370 	},
8371 };
8372 
8373 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8374 struct cmd_eth_peer_result {
8375 	cmdline_fixed_string_t set;
8376 	cmdline_fixed_string_t eth_peer;
8377 	portid_t port_id;
8378 	cmdline_fixed_string_t peer_addr;
8379 };
8380 
8381 static void cmd_set_eth_peer_parsed(void *parsed_result,
8382 			__rte_unused struct cmdline *cl,
8383 			__rte_unused void *data)
8384 {
8385 		struct cmd_eth_peer_result *res = parsed_result;
8386 
8387 		if (test_done == 0) {
8388 			printf("Please stop forwarding first\n");
8389 			return;
8390 		}
8391 		if (!strcmp(res->eth_peer, "eth-peer")) {
8392 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8393 			fwd_config_setup();
8394 		}
8395 }
8396 cmdline_parse_token_string_t cmd_eth_peer_set =
8397 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8398 cmdline_parse_token_string_t cmd_eth_peer =
8399 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8400 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8401 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8402 		RTE_UINT16);
8403 cmdline_parse_token_string_t cmd_eth_peer_addr =
8404 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8405 
8406 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8407 	.f = cmd_set_eth_peer_parsed,
8408 	.data = NULL,
8409 	.help_str = "set eth-peer <port_id> <peer_mac>",
8410 	.tokens = {
8411 		(void *)&cmd_eth_peer_set,
8412 		(void *)&cmd_eth_peer,
8413 		(void *)&cmd_eth_peer_port_id,
8414 		(void *)&cmd_eth_peer_addr,
8415 		NULL,
8416 	},
8417 };
8418 
8419 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8420 struct cmd_set_qmap_result {
8421 	cmdline_fixed_string_t set;
8422 	cmdline_fixed_string_t qmap;
8423 	cmdline_fixed_string_t what;
8424 	portid_t port_id;
8425 	uint16_t queue_id;
8426 	uint8_t map_value;
8427 };
8428 
8429 static void
8430 cmd_set_qmap_parsed(void *parsed_result,
8431 		       __rte_unused struct cmdline *cl,
8432 		       __rte_unused void *data)
8433 {
8434 	struct cmd_set_qmap_result *res = parsed_result;
8435 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8436 
8437 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8438 }
8439 
8440 cmdline_parse_token_string_t cmd_setqmap_set =
8441 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8442 				 set, "set");
8443 cmdline_parse_token_string_t cmd_setqmap_qmap =
8444 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8445 				 qmap, "stat_qmap");
8446 cmdline_parse_token_string_t cmd_setqmap_what =
8447 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8448 				 what, "tx#rx");
8449 cmdline_parse_token_num_t cmd_setqmap_portid =
8450 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8451 			      port_id, RTE_UINT16);
8452 cmdline_parse_token_num_t cmd_setqmap_queueid =
8453 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8454 			      queue_id, RTE_UINT16);
8455 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8456 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8457 			      map_value, RTE_UINT8);
8458 
8459 cmdline_parse_inst_t cmd_set_qmap = {
8460 	.f = cmd_set_qmap_parsed,
8461 	.data = NULL,
8462 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8463 		"Set statistics mapping value on tx|rx queue_id of port_id",
8464 	.tokens = {
8465 		(void *)&cmd_setqmap_set,
8466 		(void *)&cmd_setqmap_qmap,
8467 		(void *)&cmd_setqmap_what,
8468 		(void *)&cmd_setqmap_portid,
8469 		(void *)&cmd_setqmap_queueid,
8470 		(void *)&cmd_setqmap_mapvalue,
8471 		NULL,
8472 	},
8473 };
8474 
8475 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8476 struct cmd_set_xstats_hide_zero_result {
8477 	cmdline_fixed_string_t keyword;
8478 	cmdline_fixed_string_t name;
8479 	cmdline_fixed_string_t on_off;
8480 };
8481 
8482 static void
8483 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8484 			__rte_unused struct cmdline *cl,
8485 			__rte_unused void *data)
8486 {
8487 	struct cmd_set_xstats_hide_zero_result *res;
8488 	uint16_t on_off = 0;
8489 
8490 	res = parsed_result;
8491 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8492 	set_xstats_hide_zero(on_off);
8493 }
8494 
8495 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8496 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8497 				 keyword, "set");
8498 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8499 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8500 				 name, "xstats-hide-zero");
8501 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8502 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8503 				 on_off, "on#off");
8504 
8505 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8506 	.f = cmd_set_xstats_hide_zero_parsed,
8507 	.data = NULL,
8508 	.help_str = "set xstats-hide-zero on|off",
8509 	.tokens = {
8510 		(void *)&cmd_set_xstats_hide_zero_keyword,
8511 		(void *)&cmd_set_xstats_hide_zero_name,
8512 		(void *)&cmd_set_xstats_hide_zero_on_off,
8513 		NULL,
8514 	},
8515 };
8516 
8517 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8518 struct cmd_set_record_core_cycles_result {
8519 	cmdline_fixed_string_t keyword;
8520 	cmdline_fixed_string_t name;
8521 	cmdline_fixed_string_t on_off;
8522 };
8523 
8524 static void
8525 cmd_set_record_core_cycles_parsed(void *parsed_result,
8526 			__rte_unused struct cmdline *cl,
8527 			__rte_unused void *data)
8528 {
8529 	struct cmd_set_record_core_cycles_result *res;
8530 	uint16_t on_off = 0;
8531 
8532 	res = parsed_result;
8533 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8534 	set_record_core_cycles(on_off);
8535 }
8536 
8537 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8538 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8539 				 keyword, "set");
8540 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8541 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8542 				 name, "record-core-cycles");
8543 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8544 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8545 				 on_off, "on#off");
8546 
8547 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8548 	.f = cmd_set_record_core_cycles_parsed,
8549 	.data = NULL,
8550 	.help_str = "set record-core-cycles on|off",
8551 	.tokens = {
8552 		(void *)&cmd_set_record_core_cycles_keyword,
8553 		(void *)&cmd_set_record_core_cycles_name,
8554 		(void *)&cmd_set_record_core_cycles_on_off,
8555 		NULL,
8556 	},
8557 };
8558 
8559 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8560 struct cmd_set_record_burst_stats_result {
8561 	cmdline_fixed_string_t keyword;
8562 	cmdline_fixed_string_t name;
8563 	cmdline_fixed_string_t on_off;
8564 };
8565 
8566 static void
8567 cmd_set_record_burst_stats_parsed(void *parsed_result,
8568 			__rte_unused struct cmdline *cl,
8569 			__rte_unused void *data)
8570 {
8571 	struct cmd_set_record_burst_stats_result *res;
8572 	uint16_t on_off = 0;
8573 
8574 	res = parsed_result;
8575 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8576 	set_record_burst_stats(on_off);
8577 }
8578 
8579 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8580 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8581 				 keyword, "set");
8582 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8583 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8584 				 name, "record-burst-stats");
8585 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8586 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8587 				 on_off, "on#off");
8588 
8589 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8590 	.f = cmd_set_record_burst_stats_parsed,
8591 	.data = NULL,
8592 	.help_str = "set record-burst-stats on|off",
8593 	.tokens = {
8594 		(void *)&cmd_set_record_burst_stats_keyword,
8595 		(void *)&cmd_set_record_burst_stats_name,
8596 		(void *)&cmd_set_record_burst_stats_on_off,
8597 		NULL,
8598 	},
8599 };
8600 
8601 /* *** CONFIGURE UNICAST HASH TABLE *** */
8602 struct cmd_set_uc_hash_table {
8603 	cmdline_fixed_string_t set;
8604 	cmdline_fixed_string_t port;
8605 	portid_t port_id;
8606 	cmdline_fixed_string_t what;
8607 	struct rte_ether_addr address;
8608 	cmdline_fixed_string_t mode;
8609 };
8610 
8611 static void
8612 cmd_set_uc_hash_parsed(void *parsed_result,
8613 		       __rte_unused struct cmdline *cl,
8614 		       __rte_unused void *data)
8615 {
8616 	int ret=0;
8617 	struct cmd_set_uc_hash_table *res = parsed_result;
8618 
8619 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8620 
8621 	if (strcmp(res->what, "uta") == 0)
8622 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8623 						&res->address,(uint8_t)is_on);
8624 	if (ret < 0)
8625 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8626 
8627 }
8628 
8629 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8630 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8631 				 set, "set");
8632 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8633 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8634 				 port, "port");
8635 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8636 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8637 			      port_id, RTE_UINT16);
8638 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8639 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8640 				 what, "uta");
8641 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8642 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8643 				address);
8644 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8645 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8646 				 mode, "on#off");
8647 
8648 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8649 	.f = cmd_set_uc_hash_parsed,
8650 	.data = NULL,
8651 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8652 	.tokens = {
8653 		(void *)&cmd_set_uc_hash_set,
8654 		(void *)&cmd_set_uc_hash_port,
8655 		(void *)&cmd_set_uc_hash_portid,
8656 		(void *)&cmd_set_uc_hash_what,
8657 		(void *)&cmd_set_uc_hash_mac,
8658 		(void *)&cmd_set_uc_hash_mode,
8659 		NULL,
8660 	},
8661 };
8662 
8663 struct cmd_set_uc_all_hash_table {
8664 	cmdline_fixed_string_t set;
8665 	cmdline_fixed_string_t port;
8666 	portid_t port_id;
8667 	cmdline_fixed_string_t what;
8668 	cmdline_fixed_string_t value;
8669 	cmdline_fixed_string_t mode;
8670 };
8671 
8672 static void
8673 cmd_set_uc_all_hash_parsed(void *parsed_result,
8674 		       __rte_unused struct cmdline *cl,
8675 		       __rte_unused void *data)
8676 {
8677 	int ret=0;
8678 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8679 
8680 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8681 
8682 	if ((strcmp(res->what, "uta") == 0) &&
8683 		(strcmp(res->value, "all") == 0))
8684 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8685 	if (ret < 0)
8686 		printf("bad unicast hash table parameter,"
8687 			"return code = %d \n", ret);
8688 }
8689 
8690 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8691 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8692 				 set, "set");
8693 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8694 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8695 				 port, "port");
8696 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8697 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8698 			      port_id, RTE_UINT16);
8699 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8700 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8701 				 what, "uta");
8702 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8703 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8704 				value,"all");
8705 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8706 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8707 				 mode, "on#off");
8708 
8709 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8710 	.f = cmd_set_uc_all_hash_parsed,
8711 	.data = NULL,
8712 	.help_str = "set port <port_id> uta all on|off",
8713 	.tokens = {
8714 		(void *)&cmd_set_uc_all_hash_set,
8715 		(void *)&cmd_set_uc_all_hash_port,
8716 		(void *)&cmd_set_uc_all_hash_portid,
8717 		(void *)&cmd_set_uc_all_hash_what,
8718 		(void *)&cmd_set_uc_all_hash_value,
8719 		(void *)&cmd_set_uc_all_hash_mode,
8720 		NULL,
8721 	},
8722 };
8723 
8724 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8725 struct cmd_set_vf_traffic {
8726 	cmdline_fixed_string_t set;
8727 	cmdline_fixed_string_t port;
8728 	portid_t port_id;
8729 	cmdline_fixed_string_t vf;
8730 	uint8_t vf_id;
8731 	cmdline_fixed_string_t what;
8732 	cmdline_fixed_string_t mode;
8733 };
8734 
8735 static void
8736 cmd_set_vf_traffic_parsed(void *parsed_result,
8737 		       __rte_unused struct cmdline *cl,
8738 		       __rte_unused void *data)
8739 {
8740 	struct cmd_set_vf_traffic *res = parsed_result;
8741 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8742 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8743 
8744 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8745 }
8746 
8747 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8748 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8749 				 set, "set");
8750 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8751 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8752 				 port, "port");
8753 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8754 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8755 			      port_id, RTE_UINT16);
8756 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8757 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8758 				 vf, "vf");
8759 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8760 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8761 			      vf_id, RTE_UINT8);
8762 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8763 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8764 				 what, "tx#rx");
8765 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8766 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8767 				 mode, "on#off");
8768 
8769 cmdline_parse_inst_t cmd_set_vf_traffic = {
8770 	.f = cmd_set_vf_traffic_parsed,
8771 	.data = NULL,
8772 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8773 	.tokens = {
8774 		(void *)&cmd_setvf_traffic_set,
8775 		(void *)&cmd_setvf_traffic_port,
8776 		(void *)&cmd_setvf_traffic_portid,
8777 		(void *)&cmd_setvf_traffic_vf,
8778 		(void *)&cmd_setvf_traffic_vfid,
8779 		(void *)&cmd_setvf_traffic_what,
8780 		(void *)&cmd_setvf_traffic_mode,
8781 		NULL,
8782 	},
8783 };
8784 
8785 /* *** CONFIGURE VF RECEIVE MODE *** */
8786 struct cmd_set_vf_rxmode {
8787 	cmdline_fixed_string_t set;
8788 	cmdline_fixed_string_t port;
8789 	portid_t port_id;
8790 	cmdline_fixed_string_t vf;
8791 	uint8_t vf_id;
8792 	cmdline_fixed_string_t what;
8793 	cmdline_fixed_string_t mode;
8794 	cmdline_fixed_string_t on;
8795 };
8796 
8797 static void
8798 cmd_set_vf_rxmode_parsed(void *parsed_result,
8799 		       __rte_unused struct cmdline *cl,
8800 		       __rte_unused void *data)
8801 {
8802 	int ret = -ENOTSUP;
8803 	uint16_t vf_rxmode = 0;
8804 	struct cmd_set_vf_rxmode *res = parsed_result;
8805 
8806 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8807 	if (!strcmp(res->what,"rxmode")) {
8808 		if (!strcmp(res->mode, "AUPE"))
8809 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8810 		else if (!strcmp(res->mode, "ROPE"))
8811 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8812 		else if (!strcmp(res->mode, "BAM"))
8813 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8814 		else if (!strncmp(res->mode, "MPE",3))
8815 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8816 	}
8817 
8818 	RTE_SET_USED(is_on);
8819 
8820 #ifdef RTE_NET_IXGBE
8821 	if (ret == -ENOTSUP)
8822 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8823 						  vf_rxmode, (uint8_t)is_on);
8824 #endif
8825 #ifdef RTE_NET_BNXT
8826 	if (ret == -ENOTSUP)
8827 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8828 						 vf_rxmode, (uint8_t)is_on);
8829 #endif
8830 	if (ret < 0)
8831 		printf("bad VF receive mode parameter, return code = %d \n",
8832 		ret);
8833 }
8834 
8835 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8836 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8837 				 set, "set");
8838 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8839 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8840 				 port, "port");
8841 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8842 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8843 			      port_id, RTE_UINT16);
8844 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8845 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8846 				 vf, "vf");
8847 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8848 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8849 			      vf_id, RTE_UINT8);
8850 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8851 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8852 				 what, "rxmode");
8853 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8854 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8855 				 mode, "AUPE#ROPE#BAM#MPE");
8856 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8857 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8858 				 on, "on#off");
8859 
8860 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8861 	.f = cmd_set_vf_rxmode_parsed,
8862 	.data = NULL,
8863 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8864 		"AUPE|ROPE|BAM|MPE on|off",
8865 	.tokens = {
8866 		(void *)&cmd_set_vf_rxmode_set,
8867 		(void *)&cmd_set_vf_rxmode_port,
8868 		(void *)&cmd_set_vf_rxmode_portid,
8869 		(void *)&cmd_set_vf_rxmode_vf,
8870 		(void *)&cmd_set_vf_rxmode_vfid,
8871 		(void *)&cmd_set_vf_rxmode_what,
8872 		(void *)&cmd_set_vf_rxmode_mode,
8873 		(void *)&cmd_set_vf_rxmode_on,
8874 		NULL,
8875 	},
8876 };
8877 
8878 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8879 struct cmd_vf_mac_addr_result {
8880 	cmdline_fixed_string_t mac_addr_cmd;
8881 	cmdline_fixed_string_t what;
8882 	cmdline_fixed_string_t port;
8883 	uint16_t port_num;
8884 	cmdline_fixed_string_t vf;
8885 	uint8_t vf_num;
8886 	struct rte_ether_addr address;
8887 };
8888 
8889 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8890 		__rte_unused struct cmdline *cl,
8891 		__rte_unused void *data)
8892 {
8893 	struct cmd_vf_mac_addr_result *res = parsed_result;
8894 	int ret = -ENOTSUP;
8895 
8896 	if (strcmp(res->what, "add") != 0)
8897 		return;
8898 
8899 #ifdef RTE_NET_I40E
8900 	if (ret == -ENOTSUP)
8901 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8902 						   &res->address);
8903 #endif
8904 #ifdef RTE_NET_BNXT
8905 	if (ret == -ENOTSUP)
8906 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8907 						res->vf_num);
8908 #endif
8909 
8910 	if(ret < 0)
8911 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8912 
8913 }
8914 
8915 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8916 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8917 				mac_addr_cmd,"mac_addr");
8918 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8919 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8920 				what,"add");
8921 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8922 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8923 				port,"port");
8924 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8925 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8926 				port_num, RTE_UINT16);
8927 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8928 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8929 				vf,"vf");
8930 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8931 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8932 				vf_num, RTE_UINT8);
8933 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8934 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8935 				address);
8936 
8937 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8938 	.f = cmd_vf_mac_addr_parsed,
8939 	.data = (void *)0,
8940 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8941 		"Add MAC address filtering for a VF on port_id",
8942 	.tokens = {
8943 		(void *)&cmd_vf_mac_addr_cmd,
8944 		(void *)&cmd_vf_mac_addr_what,
8945 		(void *)&cmd_vf_mac_addr_port,
8946 		(void *)&cmd_vf_mac_addr_portnum,
8947 		(void *)&cmd_vf_mac_addr_vf,
8948 		(void *)&cmd_vf_mac_addr_vfnum,
8949 		(void *)&cmd_vf_mac_addr_addr,
8950 		NULL,
8951 	},
8952 };
8953 
8954 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8955 struct cmd_vf_rx_vlan_filter {
8956 	cmdline_fixed_string_t rx_vlan;
8957 	cmdline_fixed_string_t what;
8958 	uint16_t vlan_id;
8959 	cmdline_fixed_string_t port;
8960 	portid_t port_id;
8961 	cmdline_fixed_string_t vf;
8962 	uint64_t vf_mask;
8963 };
8964 
8965 static void
8966 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8967 			  __rte_unused struct cmdline *cl,
8968 			  __rte_unused void *data)
8969 {
8970 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8971 	int ret = -ENOTSUP;
8972 
8973 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8974 
8975 #ifdef RTE_NET_IXGBE
8976 	if (ret == -ENOTSUP)
8977 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8978 				res->vlan_id, res->vf_mask, is_add);
8979 #endif
8980 #ifdef RTE_NET_I40E
8981 	if (ret == -ENOTSUP)
8982 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8983 				res->vlan_id, res->vf_mask, is_add);
8984 #endif
8985 #ifdef RTE_NET_BNXT
8986 	if (ret == -ENOTSUP)
8987 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8988 				res->vlan_id, res->vf_mask, is_add);
8989 #endif
8990 
8991 	switch (ret) {
8992 	case 0:
8993 		break;
8994 	case -EINVAL:
8995 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8996 				res->vlan_id, res->vf_mask);
8997 		break;
8998 	case -ENODEV:
8999 		printf("invalid port_id %d\n", res->port_id);
9000 		break;
9001 	case -ENOTSUP:
9002 		printf("function not implemented or supported\n");
9003 		break;
9004 	default:
9005 		printf("programming error: (%s)\n", strerror(-ret));
9006 	}
9007 }
9008 
9009 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9010 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9011 				 rx_vlan, "rx_vlan");
9012 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9013 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9014 				 what, "add#rm");
9015 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9016 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9017 			      vlan_id, RTE_UINT16);
9018 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9019 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9020 				 port, "port");
9021 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9022 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9023 			      port_id, RTE_UINT16);
9024 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9025 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9026 				 vf, "vf");
9027 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9028 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9029 			      vf_mask, RTE_UINT64);
9030 
9031 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9032 	.f = cmd_vf_rx_vlan_filter_parsed,
9033 	.data = NULL,
9034 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9035 		"(vf_mask = hexadecimal VF mask)",
9036 	.tokens = {
9037 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9038 		(void *)&cmd_vf_rx_vlan_filter_what,
9039 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
9040 		(void *)&cmd_vf_rx_vlan_filter_port,
9041 		(void *)&cmd_vf_rx_vlan_filter_portid,
9042 		(void *)&cmd_vf_rx_vlan_filter_vf,
9043 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
9044 		NULL,
9045 	},
9046 };
9047 
9048 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9049 struct cmd_queue_rate_limit_result {
9050 	cmdline_fixed_string_t set;
9051 	cmdline_fixed_string_t port;
9052 	uint16_t port_num;
9053 	cmdline_fixed_string_t queue;
9054 	uint8_t queue_num;
9055 	cmdline_fixed_string_t rate;
9056 	uint16_t rate_num;
9057 };
9058 
9059 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9060 		__rte_unused struct cmdline *cl,
9061 		__rte_unused void *data)
9062 {
9063 	struct cmd_queue_rate_limit_result *res = parsed_result;
9064 	int ret = 0;
9065 
9066 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9067 		&& (strcmp(res->queue, "queue") == 0)
9068 		&& (strcmp(res->rate, "rate") == 0))
9069 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
9070 					res->rate_num);
9071 	if (ret < 0)
9072 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9073 
9074 }
9075 
9076 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9077 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9078 				set, "set");
9079 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9080 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9081 				port, "port");
9082 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9083 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9084 				port_num, RTE_UINT16);
9085 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9086 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9087 				queue, "queue");
9088 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9089 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9090 				queue_num, RTE_UINT8);
9091 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9092 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9093 				rate, "rate");
9094 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9095 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9096 				rate_num, RTE_UINT16);
9097 
9098 cmdline_parse_inst_t cmd_queue_rate_limit = {
9099 	.f = cmd_queue_rate_limit_parsed,
9100 	.data = (void *)0,
9101 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9102 		"Set rate limit for a queue on port_id",
9103 	.tokens = {
9104 		(void *)&cmd_queue_rate_limit_set,
9105 		(void *)&cmd_queue_rate_limit_port,
9106 		(void *)&cmd_queue_rate_limit_portnum,
9107 		(void *)&cmd_queue_rate_limit_queue,
9108 		(void *)&cmd_queue_rate_limit_queuenum,
9109 		(void *)&cmd_queue_rate_limit_rate,
9110 		(void *)&cmd_queue_rate_limit_ratenum,
9111 		NULL,
9112 	},
9113 };
9114 
9115 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9116 struct cmd_vf_rate_limit_result {
9117 	cmdline_fixed_string_t set;
9118 	cmdline_fixed_string_t port;
9119 	uint16_t port_num;
9120 	cmdline_fixed_string_t vf;
9121 	uint8_t vf_num;
9122 	cmdline_fixed_string_t rate;
9123 	uint16_t rate_num;
9124 	cmdline_fixed_string_t q_msk;
9125 	uint64_t q_msk_val;
9126 };
9127 
9128 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9129 		__rte_unused struct cmdline *cl,
9130 		__rte_unused void *data)
9131 {
9132 	struct cmd_vf_rate_limit_result *res = parsed_result;
9133 	int ret = 0;
9134 
9135 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9136 		&& (strcmp(res->vf, "vf") == 0)
9137 		&& (strcmp(res->rate, "rate") == 0)
9138 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9139 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9140 					res->rate_num, res->q_msk_val);
9141 	if (ret < 0)
9142 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9143 
9144 }
9145 
9146 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9147 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9148 				set, "set");
9149 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9150 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9151 				port, "port");
9152 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9153 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9154 				port_num, RTE_UINT16);
9155 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9156 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9157 				vf, "vf");
9158 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9159 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9160 				vf_num, RTE_UINT8);
9161 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9162 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9163 				rate, "rate");
9164 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9165 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9166 				rate_num, RTE_UINT16);
9167 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9168 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9169 				q_msk, "queue_mask");
9170 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9171 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9172 				q_msk_val, RTE_UINT64);
9173 
9174 cmdline_parse_inst_t cmd_vf_rate_limit = {
9175 	.f = cmd_vf_rate_limit_parsed,
9176 	.data = (void *)0,
9177 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9178 		"queue_mask <queue_mask_value>: "
9179 		"Set rate limit for queues of VF on port_id",
9180 	.tokens = {
9181 		(void *)&cmd_vf_rate_limit_set,
9182 		(void *)&cmd_vf_rate_limit_port,
9183 		(void *)&cmd_vf_rate_limit_portnum,
9184 		(void *)&cmd_vf_rate_limit_vf,
9185 		(void *)&cmd_vf_rate_limit_vfnum,
9186 		(void *)&cmd_vf_rate_limit_rate,
9187 		(void *)&cmd_vf_rate_limit_ratenum,
9188 		(void *)&cmd_vf_rate_limit_q_msk,
9189 		(void *)&cmd_vf_rate_limit_q_msk_val,
9190 		NULL,
9191 	},
9192 };
9193 
9194 /* *** CONFIGURE TUNNEL UDP PORT *** */
9195 struct cmd_tunnel_udp_config {
9196 	cmdline_fixed_string_t rx_vxlan_port;
9197 	cmdline_fixed_string_t what;
9198 	uint16_t udp_port;
9199 	portid_t port_id;
9200 };
9201 
9202 static void
9203 cmd_tunnel_udp_config_parsed(void *parsed_result,
9204 			  __rte_unused struct cmdline *cl,
9205 			  __rte_unused void *data)
9206 {
9207 	struct cmd_tunnel_udp_config *res = parsed_result;
9208 	struct rte_eth_udp_tunnel tunnel_udp;
9209 	int ret;
9210 
9211 	tunnel_udp.udp_port = res->udp_port;
9212 	tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9213 
9214 	if (!strcmp(res->what, "add"))
9215 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9216 						      &tunnel_udp);
9217 	else
9218 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9219 							 &tunnel_udp);
9220 
9221 	if (ret < 0)
9222 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9223 }
9224 
9225 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9226 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9227 				rx_vxlan_port, "rx_vxlan_port");
9228 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9229 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9230 				what, "add#rm");
9231 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9232 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9233 				udp_port, RTE_UINT16);
9234 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9235 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9236 				port_id, RTE_UINT16);
9237 
9238 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9239 	.f = cmd_tunnel_udp_config_parsed,
9240 	.data = (void *)0,
9241 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9242 		"Add/Remove a tunneling UDP port filter",
9243 	.tokens = {
9244 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9245 		(void *)&cmd_tunnel_udp_config_what,
9246 		(void *)&cmd_tunnel_udp_config_udp_port,
9247 		(void *)&cmd_tunnel_udp_config_port_id,
9248 		NULL,
9249 	},
9250 };
9251 
9252 struct cmd_config_tunnel_udp_port {
9253 	cmdline_fixed_string_t port;
9254 	cmdline_fixed_string_t config;
9255 	portid_t port_id;
9256 	cmdline_fixed_string_t udp_tunnel_port;
9257 	cmdline_fixed_string_t action;
9258 	cmdline_fixed_string_t tunnel_type;
9259 	uint16_t udp_port;
9260 };
9261 
9262 static void
9263 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9264 			       __rte_unused struct cmdline *cl,
9265 			       __rte_unused void *data)
9266 {
9267 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9268 	struct rte_eth_udp_tunnel tunnel_udp;
9269 	int ret = 0;
9270 
9271 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9272 		return;
9273 
9274 	tunnel_udp.udp_port = res->udp_port;
9275 
9276 	if (!strcmp(res->tunnel_type, "vxlan")) {
9277 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9278 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9279 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9280 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9281 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9282 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9283 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9284 	} else {
9285 		printf("Invalid tunnel type\n");
9286 		return;
9287 	}
9288 
9289 	if (!strcmp(res->action, "add"))
9290 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9291 						      &tunnel_udp);
9292 	else
9293 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9294 							 &tunnel_udp);
9295 
9296 	if (ret < 0)
9297 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9298 }
9299 
9300 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9301 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9302 				 "port");
9303 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9304 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9305 				 "config");
9306 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9307 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9308 			      RTE_UINT16);
9309 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9310 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9311 				 udp_tunnel_port,
9312 				 "udp_tunnel_port");
9313 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9314 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9315 				 "add#rm");
9316 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9317 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9318 				 "vxlan#geneve#vxlan-gpe#ecpri");
9319 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9320 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9321 			      RTE_UINT16);
9322 
9323 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9324 	.f = cmd_cfg_tunnel_udp_port_parsed,
9325 	.data = NULL,
9326 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9327 		"geneve|vxlan-gpe|ecpri <udp_port>",
9328 	.tokens = {
9329 		(void *)&cmd_config_tunnel_udp_port_port,
9330 		(void *)&cmd_config_tunnel_udp_port_config,
9331 		(void *)&cmd_config_tunnel_udp_port_port_id,
9332 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9333 		(void *)&cmd_config_tunnel_udp_port_action,
9334 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9335 		(void *)&cmd_config_tunnel_udp_port_value,
9336 		NULL,
9337 	},
9338 };
9339 
9340 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9341 struct cmd_set_mirror_mask_result {
9342 	cmdline_fixed_string_t set;
9343 	cmdline_fixed_string_t port;
9344 	portid_t port_id;
9345 	cmdline_fixed_string_t mirror;
9346 	uint8_t rule_id;
9347 	cmdline_fixed_string_t what;
9348 	cmdline_fixed_string_t value;
9349 	cmdline_fixed_string_t dstpool;
9350 	uint8_t dstpool_id;
9351 	cmdline_fixed_string_t on;
9352 };
9353 
9354 cmdline_parse_token_string_t cmd_mirror_mask_set =
9355 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9356 				set, "set");
9357 cmdline_parse_token_string_t cmd_mirror_mask_port =
9358 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9359 				port, "port");
9360 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9361 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9362 				port_id, RTE_UINT16);
9363 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9364 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9365 				mirror, "mirror-rule");
9366 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9367 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9368 				rule_id, RTE_UINT8);
9369 cmdline_parse_token_string_t cmd_mirror_mask_what =
9370 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9371 				what, "pool-mirror-up#pool-mirror-down"
9372 				      "#vlan-mirror");
9373 cmdline_parse_token_string_t cmd_mirror_mask_value =
9374 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9375 				value, NULL);
9376 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9377 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9378 				dstpool, "dst-pool");
9379 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9380 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9381 				dstpool_id, RTE_UINT8);
9382 cmdline_parse_token_string_t cmd_mirror_mask_on =
9383 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9384 				on, "on#off");
9385 
9386 static void
9387 cmd_set_mirror_mask_parsed(void *parsed_result,
9388 		       __rte_unused struct cmdline *cl,
9389 		       __rte_unused void *data)
9390 {
9391 	int ret,nb_item,i;
9392 	struct cmd_set_mirror_mask_result *res = parsed_result;
9393 	struct rte_eth_mirror_conf mr_conf;
9394 
9395 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9396 
9397 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9398 
9399 	mr_conf.dst_pool = res->dstpool_id;
9400 
9401 	if (!strcmp(res->what, "pool-mirror-up")) {
9402 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9403 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9404 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9405 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9406 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9407 	} else if (!strcmp(res->what, "vlan-mirror")) {
9408 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9409 		nb_item = parse_item_list(res->value, "vlan",
9410 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9411 		if (nb_item <= 0)
9412 			return;
9413 
9414 		for (i = 0; i < nb_item; i++) {
9415 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9416 				printf("Invalid vlan_id: must be < 4096\n");
9417 				return;
9418 			}
9419 
9420 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9421 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9422 		}
9423 	}
9424 
9425 	if (!strcmp(res->on, "on"))
9426 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9427 						res->rule_id, 1);
9428 	else
9429 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9430 						res->rule_id, 0);
9431 	if (ret < 0)
9432 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9433 }
9434 
9435 cmdline_parse_inst_t cmd_set_mirror_mask = {
9436 		.f = cmd_set_mirror_mask_parsed,
9437 		.data = NULL,
9438 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9439 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9440 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9441 		.tokens = {
9442 			(void *)&cmd_mirror_mask_set,
9443 			(void *)&cmd_mirror_mask_port,
9444 			(void *)&cmd_mirror_mask_portid,
9445 			(void *)&cmd_mirror_mask_mirror,
9446 			(void *)&cmd_mirror_mask_ruleid,
9447 			(void *)&cmd_mirror_mask_what,
9448 			(void *)&cmd_mirror_mask_value,
9449 			(void *)&cmd_mirror_mask_dstpool,
9450 			(void *)&cmd_mirror_mask_poolid,
9451 			(void *)&cmd_mirror_mask_on,
9452 			NULL,
9453 		},
9454 };
9455 
9456 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9457 struct cmd_set_mirror_link_result {
9458 	cmdline_fixed_string_t set;
9459 	cmdline_fixed_string_t port;
9460 	portid_t port_id;
9461 	cmdline_fixed_string_t mirror;
9462 	uint8_t rule_id;
9463 	cmdline_fixed_string_t what;
9464 	cmdline_fixed_string_t dstpool;
9465 	uint8_t dstpool_id;
9466 	cmdline_fixed_string_t on;
9467 };
9468 
9469 cmdline_parse_token_string_t cmd_mirror_link_set =
9470 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9471 				 set, "set");
9472 cmdline_parse_token_string_t cmd_mirror_link_port =
9473 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9474 				port, "port");
9475 cmdline_parse_token_num_t cmd_mirror_link_portid =
9476 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9477 				port_id, RTE_UINT16);
9478 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9479 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9480 				mirror, "mirror-rule");
9481 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9482 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9483 			    rule_id, RTE_UINT8);
9484 cmdline_parse_token_string_t cmd_mirror_link_what =
9485 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9486 				what, "uplink-mirror#downlink-mirror");
9487 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9488 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9489 				dstpool, "dst-pool");
9490 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9491 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9492 				dstpool_id, RTE_UINT8);
9493 cmdline_parse_token_string_t cmd_mirror_link_on =
9494 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9495 				on, "on#off");
9496 
9497 static void
9498 cmd_set_mirror_link_parsed(void *parsed_result,
9499 		       __rte_unused struct cmdline *cl,
9500 		       __rte_unused void *data)
9501 {
9502 	int ret;
9503 	struct cmd_set_mirror_link_result *res = parsed_result;
9504 	struct rte_eth_mirror_conf mr_conf;
9505 
9506 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9507 	if (!strcmp(res->what, "uplink-mirror"))
9508 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9509 	else
9510 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9511 
9512 	mr_conf.dst_pool = res->dstpool_id;
9513 
9514 	if (!strcmp(res->on, "on"))
9515 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9516 						res->rule_id, 1);
9517 	else
9518 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9519 						res->rule_id, 0);
9520 
9521 	/* check the return value and print it if is < 0 */
9522 	if (ret < 0)
9523 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9524 
9525 }
9526 
9527 cmdline_parse_inst_t cmd_set_mirror_link = {
9528 		.f = cmd_set_mirror_link_parsed,
9529 		.data = NULL,
9530 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9531 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9532 		.tokens = {
9533 			(void *)&cmd_mirror_link_set,
9534 			(void *)&cmd_mirror_link_port,
9535 			(void *)&cmd_mirror_link_portid,
9536 			(void *)&cmd_mirror_link_mirror,
9537 			(void *)&cmd_mirror_link_ruleid,
9538 			(void *)&cmd_mirror_link_what,
9539 			(void *)&cmd_mirror_link_dstpool,
9540 			(void *)&cmd_mirror_link_poolid,
9541 			(void *)&cmd_mirror_link_on,
9542 			NULL,
9543 		},
9544 };
9545 
9546 /* *** RESET VM MIRROR RULE *** */
9547 struct cmd_rm_mirror_rule_result {
9548 	cmdline_fixed_string_t reset;
9549 	cmdline_fixed_string_t port;
9550 	portid_t port_id;
9551 	cmdline_fixed_string_t mirror;
9552 	uint8_t rule_id;
9553 };
9554 
9555 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9556 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9557 				 reset, "reset");
9558 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9559 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9560 				port, "port");
9561 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9562 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9563 				port_id, RTE_UINT16);
9564 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9565 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9566 				mirror, "mirror-rule");
9567 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9568 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9569 				rule_id, RTE_UINT8);
9570 
9571 static void
9572 cmd_reset_mirror_rule_parsed(void *parsed_result,
9573 		       __rte_unused struct cmdline *cl,
9574 		       __rte_unused void *data)
9575 {
9576 	int ret;
9577 	struct cmd_set_mirror_link_result *res = parsed_result;
9578         /* check rule_id */
9579 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9580 	if(ret < 0)
9581 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9582 }
9583 
9584 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9585 		.f = cmd_reset_mirror_rule_parsed,
9586 		.data = NULL,
9587 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9588 		.tokens = {
9589 			(void *)&cmd_rm_mirror_rule_reset,
9590 			(void *)&cmd_rm_mirror_rule_port,
9591 			(void *)&cmd_rm_mirror_rule_portid,
9592 			(void *)&cmd_rm_mirror_rule_mirror,
9593 			(void *)&cmd_rm_mirror_rule_ruleid,
9594 			NULL,
9595 		},
9596 };
9597 
9598 /* ******************************************************************************** */
9599 
9600 struct cmd_dump_result {
9601 	cmdline_fixed_string_t dump;
9602 };
9603 
9604 static void
9605 dump_struct_sizes(void)
9606 {
9607 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9608 	DUMP_SIZE(struct rte_mbuf);
9609 	DUMP_SIZE(struct rte_mempool);
9610 	DUMP_SIZE(struct rte_ring);
9611 #undef DUMP_SIZE
9612 }
9613 
9614 
9615 /* Dump the socket memory statistics on console */
9616 static void
9617 dump_socket_mem(FILE *f)
9618 {
9619 	struct rte_malloc_socket_stats socket_stats;
9620 	unsigned int i;
9621 	size_t total = 0;
9622 	size_t alloc = 0;
9623 	size_t free = 0;
9624 	unsigned int n_alloc = 0;
9625 	unsigned int n_free = 0;
9626 	static size_t last_allocs;
9627 	static size_t last_total;
9628 
9629 
9630 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9631 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9632 		    !socket_stats.heap_totalsz_bytes)
9633 			continue;
9634 		total += socket_stats.heap_totalsz_bytes;
9635 		alloc += socket_stats.heap_allocsz_bytes;
9636 		free += socket_stats.heap_freesz_bytes;
9637 		n_alloc += socket_stats.alloc_count;
9638 		n_free += socket_stats.free_count;
9639 		fprintf(f,
9640 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9641 			i,
9642 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9643 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9644 			(double)socket_stats.heap_allocsz_bytes * 100 /
9645 			(double)socket_stats.heap_totalsz_bytes,
9646 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9647 			socket_stats.alloc_count,
9648 			socket_stats.free_count);
9649 	}
9650 	fprintf(f,
9651 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9652 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9653 		(double)alloc * 100 / (double)total,
9654 		(double)free / (1024 * 1024),
9655 		n_alloc, n_free);
9656 	if (last_allocs)
9657 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9658 			((double)total - (double)last_total) / (1024 * 1024),
9659 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9660 	last_allocs = alloc;
9661 	last_total = total;
9662 }
9663 
9664 static void cmd_dump_parsed(void *parsed_result,
9665 			    __rte_unused struct cmdline *cl,
9666 			    __rte_unused void *data)
9667 {
9668 	struct cmd_dump_result *res = parsed_result;
9669 
9670 	if (!strcmp(res->dump, "dump_physmem"))
9671 		rte_dump_physmem_layout(stdout);
9672 	else if (!strcmp(res->dump, "dump_socket_mem"))
9673 		dump_socket_mem(stdout);
9674 	else if (!strcmp(res->dump, "dump_memzone"))
9675 		rte_memzone_dump(stdout);
9676 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9677 		dump_struct_sizes();
9678 	else if (!strcmp(res->dump, "dump_ring"))
9679 		rte_ring_list_dump(stdout);
9680 	else if (!strcmp(res->dump, "dump_mempool"))
9681 		rte_mempool_list_dump(stdout);
9682 	else if (!strcmp(res->dump, "dump_devargs"))
9683 		rte_devargs_dump(stdout);
9684 	else if (!strcmp(res->dump, "dump_log_types"))
9685 		rte_log_dump(stdout);
9686 }
9687 
9688 cmdline_parse_token_string_t cmd_dump_dump =
9689 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9690 		"dump_physmem#"
9691 		"dump_memzone#"
9692 		"dump_socket_mem#"
9693 		"dump_struct_sizes#"
9694 		"dump_ring#"
9695 		"dump_mempool#"
9696 		"dump_devargs#"
9697 		"dump_log_types");
9698 
9699 cmdline_parse_inst_t cmd_dump = {
9700 	.f = cmd_dump_parsed,  /* function to call */
9701 	.data = NULL,      /* 2nd arg of func */
9702 	.help_str = "Dump status",
9703 	.tokens = {        /* token list, NULL terminated */
9704 		(void *)&cmd_dump_dump,
9705 		NULL,
9706 	},
9707 };
9708 
9709 /* ******************************************************************************** */
9710 
9711 struct cmd_dump_one_result {
9712 	cmdline_fixed_string_t dump;
9713 	cmdline_fixed_string_t name;
9714 };
9715 
9716 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9717 				__rte_unused void *data)
9718 {
9719 	struct cmd_dump_one_result *res = parsed_result;
9720 
9721 	if (!strcmp(res->dump, "dump_ring")) {
9722 		struct rte_ring *r;
9723 		r = rte_ring_lookup(res->name);
9724 		if (r == NULL) {
9725 			cmdline_printf(cl, "Cannot find ring\n");
9726 			return;
9727 		}
9728 		rte_ring_dump(stdout, r);
9729 	} else if (!strcmp(res->dump, "dump_mempool")) {
9730 		struct rte_mempool *mp;
9731 		mp = rte_mempool_lookup(res->name);
9732 		if (mp == NULL) {
9733 			cmdline_printf(cl, "Cannot find mempool\n");
9734 			return;
9735 		}
9736 		rte_mempool_dump(stdout, mp);
9737 	}
9738 }
9739 
9740 cmdline_parse_token_string_t cmd_dump_one_dump =
9741 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9742 				 "dump_ring#dump_mempool");
9743 
9744 cmdline_parse_token_string_t cmd_dump_one_name =
9745 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9746 
9747 cmdline_parse_inst_t cmd_dump_one = {
9748 	.f = cmd_dump_one_parsed,  /* function to call */
9749 	.data = NULL,      /* 2nd arg of func */
9750 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9751 	.tokens = {        /* token list, NULL terminated */
9752 		(void *)&cmd_dump_one_dump,
9753 		(void *)&cmd_dump_one_name,
9754 		NULL,
9755 	},
9756 };
9757 
9758 /* *** queue region set *** */
9759 struct cmd_queue_region_result {
9760 	cmdline_fixed_string_t set;
9761 	cmdline_fixed_string_t port;
9762 	portid_t port_id;
9763 	cmdline_fixed_string_t cmd;
9764 	cmdline_fixed_string_t region;
9765 	uint8_t  region_id;
9766 	cmdline_fixed_string_t queue_start_index;
9767 	uint8_t  queue_id;
9768 	cmdline_fixed_string_t queue_num;
9769 	uint8_t  queue_num_value;
9770 };
9771 
9772 static void
9773 cmd_queue_region_parsed(void *parsed_result,
9774 			__rte_unused struct cmdline *cl,
9775 			__rte_unused void *data)
9776 {
9777 	struct cmd_queue_region_result *res = parsed_result;
9778 	int ret = -ENOTSUP;
9779 #ifdef RTE_NET_I40E
9780 	struct rte_pmd_i40e_queue_region_conf region_conf;
9781 	enum rte_pmd_i40e_queue_region_op op_type;
9782 #endif
9783 
9784 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9785 		return;
9786 
9787 #ifdef RTE_NET_I40E
9788 	memset(&region_conf, 0, sizeof(region_conf));
9789 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9790 	region_conf.region_id = res->region_id;
9791 	region_conf.queue_num = res->queue_num_value;
9792 	region_conf.queue_start_index = res->queue_id;
9793 
9794 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9795 				op_type, &region_conf);
9796 #endif
9797 
9798 	switch (ret) {
9799 	case 0:
9800 		break;
9801 	case -ENOTSUP:
9802 		printf("function not implemented or supported\n");
9803 		break;
9804 	default:
9805 		printf("queue region config error: (%s)\n", strerror(-ret));
9806 	}
9807 }
9808 
9809 cmdline_parse_token_string_t cmd_queue_region_set =
9810 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9811 		set, "set");
9812 cmdline_parse_token_string_t cmd_queue_region_port =
9813 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9814 cmdline_parse_token_num_t cmd_queue_region_port_id =
9815 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9816 				port_id, RTE_UINT16);
9817 cmdline_parse_token_string_t cmd_queue_region_cmd =
9818 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9819 				 cmd, "queue-region");
9820 cmdline_parse_token_string_t cmd_queue_region_id =
9821 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9822 				region, "region_id");
9823 cmdline_parse_token_num_t cmd_queue_region_index =
9824 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9825 				region_id, RTE_UINT8);
9826 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9827 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9828 				queue_start_index, "queue_start_index");
9829 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9830 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9831 				queue_id, RTE_UINT8);
9832 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9833 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9834 				queue_num, "queue_num");
9835 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9836 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9837 				queue_num_value, RTE_UINT8);
9838 
9839 cmdline_parse_inst_t cmd_queue_region = {
9840 	.f = cmd_queue_region_parsed,
9841 	.data = NULL,
9842 	.help_str = "set port <port_id> queue-region region_id <value> "
9843 		"queue_start_index <value> queue_num <value>: Set a queue region",
9844 	.tokens = {
9845 		(void *)&cmd_queue_region_set,
9846 		(void *)&cmd_queue_region_port,
9847 		(void *)&cmd_queue_region_port_id,
9848 		(void *)&cmd_queue_region_cmd,
9849 		(void *)&cmd_queue_region_id,
9850 		(void *)&cmd_queue_region_index,
9851 		(void *)&cmd_queue_region_queue_start_index,
9852 		(void *)&cmd_queue_region_queue_id,
9853 		(void *)&cmd_queue_region_queue_num,
9854 		(void *)&cmd_queue_region_queue_num_value,
9855 		NULL,
9856 	},
9857 };
9858 
9859 /* *** queue region and flowtype set *** */
9860 struct cmd_region_flowtype_result {
9861 	cmdline_fixed_string_t set;
9862 	cmdline_fixed_string_t port;
9863 	portid_t port_id;
9864 	cmdline_fixed_string_t cmd;
9865 	cmdline_fixed_string_t region;
9866 	uint8_t  region_id;
9867 	cmdline_fixed_string_t flowtype;
9868 	uint8_t  flowtype_id;
9869 };
9870 
9871 static void
9872 cmd_region_flowtype_parsed(void *parsed_result,
9873 			__rte_unused struct cmdline *cl,
9874 			__rte_unused void *data)
9875 {
9876 	struct cmd_region_flowtype_result *res = parsed_result;
9877 	int ret = -ENOTSUP;
9878 #ifdef RTE_NET_I40E
9879 	struct rte_pmd_i40e_queue_region_conf region_conf;
9880 	enum rte_pmd_i40e_queue_region_op op_type;
9881 #endif
9882 
9883 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9884 		return;
9885 
9886 #ifdef RTE_NET_I40E
9887 	memset(&region_conf, 0, sizeof(region_conf));
9888 
9889 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9890 	region_conf.region_id = res->region_id;
9891 	region_conf.hw_flowtype = res->flowtype_id;
9892 
9893 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9894 			op_type, &region_conf);
9895 #endif
9896 
9897 	switch (ret) {
9898 	case 0:
9899 		break;
9900 	case -ENOTSUP:
9901 		printf("function not implemented or supported\n");
9902 		break;
9903 	default:
9904 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9905 	}
9906 }
9907 
9908 cmdline_parse_token_string_t cmd_region_flowtype_set =
9909 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9910 				set, "set");
9911 cmdline_parse_token_string_t cmd_region_flowtype_port =
9912 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9913 				port, "port");
9914 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9915 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9916 				port_id, RTE_UINT16);
9917 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9918 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9919 				cmd, "queue-region");
9920 cmdline_parse_token_string_t cmd_region_flowtype_index =
9921 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9922 				region, "region_id");
9923 cmdline_parse_token_num_t cmd_region_flowtype_id =
9924 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9925 				region_id, RTE_UINT8);
9926 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9927 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9928 				flowtype, "flowtype");
9929 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9930 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9931 				flowtype_id, RTE_UINT8);
9932 cmdline_parse_inst_t cmd_region_flowtype = {
9933 	.f = cmd_region_flowtype_parsed,
9934 	.data = NULL,
9935 	.help_str = "set port <port_id> queue-region region_id <value> "
9936 		"flowtype <value>: Set a flowtype region index",
9937 	.tokens = {
9938 		(void *)&cmd_region_flowtype_set,
9939 		(void *)&cmd_region_flowtype_port,
9940 		(void *)&cmd_region_flowtype_port_index,
9941 		(void *)&cmd_region_flowtype_cmd,
9942 		(void *)&cmd_region_flowtype_index,
9943 		(void *)&cmd_region_flowtype_id,
9944 		(void *)&cmd_region_flowtype_flow_index,
9945 		(void *)&cmd_region_flowtype_flow_id,
9946 		NULL,
9947 	},
9948 };
9949 
9950 /* *** User Priority (UP) to queue region (region_id) set *** */
9951 struct cmd_user_priority_region_result {
9952 	cmdline_fixed_string_t set;
9953 	cmdline_fixed_string_t port;
9954 	portid_t port_id;
9955 	cmdline_fixed_string_t cmd;
9956 	cmdline_fixed_string_t user_priority;
9957 	uint8_t  user_priority_id;
9958 	cmdline_fixed_string_t region;
9959 	uint8_t  region_id;
9960 };
9961 
9962 static void
9963 cmd_user_priority_region_parsed(void *parsed_result,
9964 			__rte_unused struct cmdline *cl,
9965 			__rte_unused void *data)
9966 {
9967 	struct cmd_user_priority_region_result *res = parsed_result;
9968 	int ret = -ENOTSUP;
9969 #ifdef RTE_NET_I40E
9970 	struct rte_pmd_i40e_queue_region_conf region_conf;
9971 	enum rte_pmd_i40e_queue_region_op op_type;
9972 #endif
9973 
9974 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9975 		return;
9976 
9977 #ifdef RTE_NET_I40E
9978 	memset(&region_conf, 0, sizeof(region_conf));
9979 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9980 	region_conf.user_priority = res->user_priority_id;
9981 	region_conf.region_id = res->region_id;
9982 
9983 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9984 				op_type, &region_conf);
9985 #endif
9986 
9987 	switch (ret) {
9988 	case 0:
9989 		break;
9990 	case -ENOTSUP:
9991 		printf("function not implemented or supported\n");
9992 		break;
9993 	default:
9994 		printf("user_priority region config error: (%s)\n",
9995 				strerror(-ret));
9996 	}
9997 }
9998 
9999 cmdline_parse_token_string_t cmd_user_priority_region_set =
10000 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10001 				set, "set");
10002 cmdline_parse_token_string_t cmd_user_priority_region_port =
10003 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10004 				port, "port");
10005 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10006 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10007 				port_id, RTE_UINT16);
10008 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10009 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10010 				cmd, "queue-region");
10011 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10012 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10013 				user_priority, "UP");
10014 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10015 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10016 				user_priority_id, RTE_UINT8);
10017 cmdline_parse_token_string_t cmd_user_priority_region_region =
10018 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10019 				region, "region_id");
10020 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10021 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10022 				region_id, RTE_UINT8);
10023 
10024 cmdline_parse_inst_t cmd_user_priority_region = {
10025 	.f = cmd_user_priority_region_parsed,
10026 	.data = NULL,
10027 	.help_str = "set port <port_id> queue-region UP <value> "
10028 		"region_id <value>: Set the mapping of User Priority (UP) "
10029 		"to queue region (region_id) ",
10030 	.tokens = {
10031 		(void *)&cmd_user_priority_region_set,
10032 		(void *)&cmd_user_priority_region_port,
10033 		(void *)&cmd_user_priority_region_port_index,
10034 		(void *)&cmd_user_priority_region_cmd,
10035 		(void *)&cmd_user_priority_region_UP,
10036 		(void *)&cmd_user_priority_region_UP_id,
10037 		(void *)&cmd_user_priority_region_region,
10038 		(void *)&cmd_user_priority_region_region_id,
10039 		NULL,
10040 	},
10041 };
10042 
10043 /* *** flush all queue region related configuration *** */
10044 struct cmd_flush_queue_region_result {
10045 	cmdline_fixed_string_t set;
10046 	cmdline_fixed_string_t port;
10047 	portid_t port_id;
10048 	cmdline_fixed_string_t cmd;
10049 	cmdline_fixed_string_t flush;
10050 	cmdline_fixed_string_t what;
10051 };
10052 
10053 static void
10054 cmd_flush_queue_region_parsed(void *parsed_result,
10055 			__rte_unused struct cmdline *cl,
10056 			__rte_unused void *data)
10057 {
10058 	struct cmd_flush_queue_region_result *res = parsed_result;
10059 	int ret = -ENOTSUP;
10060 #ifdef RTE_NET_I40E
10061 	struct rte_pmd_i40e_queue_region_conf region_conf;
10062 	enum rte_pmd_i40e_queue_region_op op_type;
10063 #endif
10064 
10065 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10066 		return;
10067 
10068 #ifdef RTE_NET_I40E
10069 	memset(&region_conf, 0, sizeof(region_conf));
10070 
10071 	if (strcmp(res->what, "on") == 0)
10072 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10073 	else
10074 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10075 
10076 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10077 				op_type, &region_conf);
10078 #endif
10079 
10080 	switch (ret) {
10081 	case 0:
10082 		break;
10083 	case -ENOTSUP:
10084 		printf("function not implemented or supported\n");
10085 		break;
10086 	default:
10087 		printf("queue region config flush error: (%s)\n",
10088 				strerror(-ret));
10089 	}
10090 }
10091 
10092 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10093 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10094 				set, "set");
10095 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10096 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10097 				port, "port");
10098 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10099 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10100 				port_id, RTE_UINT16);
10101 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10102 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10103 				cmd, "queue-region");
10104 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10105 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10106 				flush, "flush");
10107 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10108 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10109 				what, "on#off");
10110 
10111 cmdline_parse_inst_t cmd_flush_queue_region = {
10112 	.f = cmd_flush_queue_region_parsed,
10113 	.data = NULL,
10114 	.help_str = "set port <port_id> queue-region flush on|off"
10115 		": flush all queue region related configuration",
10116 	.tokens = {
10117 		(void *)&cmd_flush_queue_region_set,
10118 		(void *)&cmd_flush_queue_region_port,
10119 		(void *)&cmd_flush_queue_region_port_index,
10120 		(void *)&cmd_flush_queue_region_cmd,
10121 		(void *)&cmd_flush_queue_region_flush,
10122 		(void *)&cmd_flush_queue_region_what,
10123 		NULL,
10124 	},
10125 };
10126 
10127 /* *** get all queue region related configuration info *** */
10128 struct cmd_show_queue_region_info {
10129 	cmdline_fixed_string_t show;
10130 	cmdline_fixed_string_t port;
10131 	portid_t port_id;
10132 	cmdline_fixed_string_t cmd;
10133 };
10134 
10135 static void
10136 cmd_show_queue_region_info_parsed(void *parsed_result,
10137 			__rte_unused struct cmdline *cl,
10138 			__rte_unused void *data)
10139 {
10140 	struct cmd_show_queue_region_info *res = parsed_result;
10141 	int ret = -ENOTSUP;
10142 #ifdef RTE_NET_I40E
10143 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10144 	enum rte_pmd_i40e_queue_region_op op_type;
10145 #endif
10146 
10147 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10148 		return;
10149 
10150 #ifdef RTE_NET_I40E
10151 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10152 
10153 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10154 
10155 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10156 					op_type, &rte_pmd_regions);
10157 
10158 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10159 #endif
10160 
10161 	switch (ret) {
10162 	case 0:
10163 		break;
10164 	case -ENOTSUP:
10165 		printf("function not implemented or supported\n");
10166 		break;
10167 	default:
10168 		printf("queue region config info show error: (%s)\n",
10169 				strerror(-ret));
10170 	}
10171 }
10172 
10173 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10174 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10175 				show, "show");
10176 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10177 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10178 				port, "port");
10179 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10180 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10181 				port_id, RTE_UINT16);
10182 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10183 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10184 				cmd, "queue-region");
10185 
10186 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10187 	.f = cmd_show_queue_region_info_parsed,
10188 	.data = NULL,
10189 	.help_str = "show port <port_id> queue-region"
10190 		": show all queue region related configuration info",
10191 	.tokens = {
10192 		(void *)&cmd_show_queue_region_info_get,
10193 		(void *)&cmd_show_queue_region_info_port,
10194 		(void *)&cmd_show_queue_region_info_port_index,
10195 		(void *)&cmd_show_queue_region_info_cmd,
10196 		NULL,
10197 	},
10198 };
10199 
10200 /* *** Filters Control *** */
10201 
10202 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10203 do { \
10204 	if ((ip_addr).family == AF_INET) \
10205 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10206 	else { \
10207 		printf("invalid parameter.\n"); \
10208 		return; \
10209 	} \
10210 } while (0)
10211 
10212 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10213 do { \
10214 	if ((ip_addr).family == AF_INET6) \
10215 		rte_memcpy(&(ip), \
10216 				 &((ip_addr).addr.ipv6), \
10217 				 sizeof(struct in6_addr)); \
10218 	else { \
10219 		printf("invalid parameter.\n"); \
10220 		return; \
10221 	} \
10222 } while (0)
10223 
10224 #ifdef RTE_NET_I40E
10225 
10226 static uint16_t
10227 str2flowtype(char *string)
10228 {
10229 	uint8_t i = 0;
10230 	static const struct {
10231 		char str[32];
10232 		uint16_t type;
10233 	} flowtype_str[] = {
10234 		{"raw", RTE_ETH_FLOW_RAW},
10235 		{"ipv4", RTE_ETH_FLOW_IPV4},
10236 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10237 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10238 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10239 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10240 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10241 		{"ipv6", RTE_ETH_FLOW_IPV6},
10242 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10243 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10244 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10245 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10246 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10247 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10248 	};
10249 
10250 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10251 		if (!strcmp(flowtype_str[i].str, string))
10252 			return flowtype_str[i].type;
10253 	}
10254 
10255 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10256 		return (uint16_t)atoi(string);
10257 
10258 	return RTE_ETH_FLOW_UNKNOWN;
10259 }
10260 
10261 /* *** deal with flow director filter *** */
10262 struct cmd_flow_director_result {
10263 	cmdline_fixed_string_t flow_director_filter;
10264 	portid_t port_id;
10265 	cmdline_fixed_string_t mode;
10266 	cmdline_fixed_string_t mode_value;
10267 	cmdline_fixed_string_t ops;
10268 	cmdline_fixed_string_t flow;
10269 	cmdline_fixed_string_t flow_type;
10270 	cmdline_fixed_string_t drop;
10271 	cmdline_fixed_string_t queue;
10272 	uint16_t  queue_id;
10273 	cmdline_fixed_string_t fd_id;
10274 	uint32_t  fd_id_value;
10275 	cmdline_fixed_string_t packet;
10276 	char filepath[];
10277 };
10278 
10279 static void
10280 cmd_flow_director_filter_parsed(void *parsed_result,
10281 			  __rte_unused struct cmdline *cl,
10282 			  __rte_unused void *data)
10283 {
10284 	struct cmd_flow_director_result *res = parsed_result;
10285 	int ret = 0;
10286 	struct rte_pmd_i40e_flow_type_mapping
10287 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10288 	struct rte_pmd_i40e_pkt_template_conf conf;
10289 	uint16_t flow_type = str2flowtype(res->flow_type);
10290 	uint16_t i, port = res->port_id;
10291 	uint8_t add;
10292 
10293 	memset(&conf, 0, sizeof(conf));
10294 
10295 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10296 		printf("Invalid flow type specified.\n");
10297 		return;
10298 	}
10299 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10300 						 mapping);
10301 	if (ret)
10302 		return;
10303 	if (mapping[flow_type].pctype == 0ULL) {
10304 		printf("Invalid flow type specified.\n");
10305 		return;
10306 	}
10307 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10308 		if (mapping[flow_type].pctype & (1ULL << i)) {
10309 			conf.input.pctype = i;
10310 			break;
10311 		}
10312 	}
10313 
10314 	conf.input.packet = open_file(res->filepath,
10315 				&conf.input.length);
10316 	if (!conf.input.packet)
10317 		return;
10318 	if (!strcmp(res->drop, "drop"))
10319 		conf.action.behavior =
10320 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10321 	else
10322 		conf.action.behavior =
10323 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10324 	conf.action.report_status =
10325 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10326 	conf.action.rx_queue = res->queue_id;
10327 	conf.soft_id = res->fd_id_value;
10328 	add  = strcmp(res->ops, "del") ? 1 : 0;
10329 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10330 							&conf,
10331 							add);
10332 	if (ret < 0)
10333 		printf("flow director config error: (%s)\n",
10334 		       strerror(-ret));
10335 	close_file(conf.input.packet);
10336 }
10337 
10338 cmdline_parse_token_string_t cmd_flow_director_filter =
10339 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10340 				 flow_director_filter, "flow_director_filter");
10341 cmdline_parse_token_num_t cmd_flow_director_port_id =
10342 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10343 			      port_id, RTE_UINT16);
10344 cmdline_parse_token_string_t cmd_flow_director_ops =
10345 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10346 				 ops, "add#del#update");
10347 cmdline_parse_token_string_t cmd_flow_director_flow =
10348 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10349 				 flow, "flow");
10350 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10351 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10352 		flow_type, NULL);
10353 cmdline_parse_token_string_t cmd_flow_director_drop =
10354 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10355 				 drop, "drop#fwd");
10356 cmdline_parse_token_string_t cmd_flow_director_queue =
10357 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10358 				 queue, "queue");
10359 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10360 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10361 			      queue_id, RTE_UINT16);
10362 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10363 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10364 				 fd_id, "fd_id");
10365 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10366 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10367 			      fd_id_value, RTE_UINT32);
10368 
10369 cmdline_parse_token_string_t cmd_flow_director_mode =
10370 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10371 				 mode, "mode");
10372 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10373 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10374 				 mode_value, "raw");
10375 cmdline_parse_token_string_t cmd_flow_director_packet =
10376 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10377 				 packet, "packet");
10378 cmdline_parse_token_string_t cmd_flow_director_filepath =
10379 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10380 				 filepath, NULL);
10381 
10382 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10383 	.f = cmd_flow_director_filter_parsed,
10384 	.data = NULL,
10385 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10386 		"director entry on NIC",
10387 	.tokens = {
10388 		(void *)&cmd_flow_director_filter,
10389 		(void *)&cmd_flow_director_port_id,
10390 		(void *)&cmd_flow_director_mode,
10391 		(void *)&cmd_flow_director_mode_raw,
10392 		(void *)&cmd_flow_director_ops,
10393 		(void *)&cmd_flow_director_flow,
10394 		(void *)&cmd_flow_director_flow_type,
10395 		(void *)&cmd_flow_director_drop,
10396 		(void *)&cmd_flow_director_queue,
10397 		(void *)&cmd_flow_director_queue_id,
10398 		(void *)&cmd_flow_director_fd_id,
10399 		(void *)&cmd_flow_director_fd_id_value,
10400 		(void *)&cmd_flow_director_packet,
10401 		(void *)&cmd_flow_director_filepath,
10402 		NULL,
10403 	},
10404 };
10405 
10406 #endif /* RTE_NET_I40E */
10407 
10408 /* *** deal with flow director mask *** */
10409 struct cmd_flow_director_mask_result {
10410 	cmdline_fixed_string_t flow_director_mask;
10411 	portid_t port_id;
10412 	cmdline_fixed_string_t mode;
10413 	cmdline_fixed_string_t mode_value;
10414 	cmdline_fixed_string_t vlan;
10415 	uint16_t vlan_mask;
10416 	cmdline_fixed_string_t src_mask;
10417 	cmdline_ipaddr_t ipv4_src;
10418 	cmdline_ipaddr_t ipv6_src;
10419 	uint16_t port_src;
10420 	cmdline_fixed_string_t dst_mask;
10421 	cmdline_ipaddr_t ipv4_dst;
10422 	cmdline_ipaddr_t ipv6_dst;
10423 	uint16_t port_dst;
10424 	cmdline_fixed_string_t mac;
10425 	uint8_t mac_addr_byte_mask;
10426 	cmdline_fixed_string_t tunnel_id;
10427 	uint32_t tunnel_id_mask;
10428 	cmdline_fixed_string_t tunnel_type;
10429 	uint8_t tunnel_type_mask;
10430 };
10431 
10432 static void
10433 cmd_flow_director_mask_parsed(void *parsed_result,
10434 			  __rte_unused struct cmdline *cl,
10435 			  __rte_unused void *data)
10436 {
10437 	struct cmd_flow_director_mask_result *res = parsed_result;
10438 	struct rte_eth_fdir_masks *mask;
10439 	struct rte_port *port;
10440 
10441 	port = &ports[res->port_id];
10442 	/** Check if the port is not started **/
10443 	if (port->port_status != RTE_PORT_STOPPED) {
10444 		printf("Please stop port %d first\n", res->port_id);
10445 		return;
10446 	}
10447 
10448 	mask = &port->dev_conf.fdir_conf.mask;
10449 
10450 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10451 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10452 			printf("Please set mode to MAC-VLAN.\n");
10453 			return;
10454 		}
10455 
10456 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10457 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10458 		if (strcmp(res->mode_value, "Tunnel")) {
10459 			printf("Please set mode to Tunnel.\n");
10460 			return;
10461 		}
10462 
10463 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10464 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10465 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10466 		mask->tunnel_type_mask = res->tunnel_type_mask;
10467 	} else {
10468 		if (strcmp(res->mode_value, "IP")) {
10469 			printf("Please set mode to IP.\n");
10470 			return;
10471 		}
10472 
10473 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10474 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10475 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10476 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10477 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10478 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10479 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10480 	}
10481 
10482 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10483 }
10484 
10485 cmdline_parse_token_string_t cmd_flow_director_mask =
10486 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10487 				 flow_director_mask, "flow_director_mask");
10488 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10489 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10490 			      port_id, RTE_UINT16);
10491 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10492 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10493 				 vlan, "vlan");
10494 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10495 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10496 			      vlan_mask, RTE_UINT16);
10497 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10498 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10499 				 src_mask, "src_mask");
10500 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10501 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10502 				 ipv4_src);
10503 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10504 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10505 				 ipv6_src);
10506 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10507 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10508 			      port_src, RTE_UINT16);
10509 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10510 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10511 				 dst_mask, "dst_mask");
10512 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10513 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10514 				 ipv4_dst);
10515 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10516 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10517 				 ipv6_dst);
10518 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10519 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10520 			      port_dst, RTE_UINT16);
10521 
10522 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10523 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10524 				 mode, "mode");
10525 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10526 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10527 				 mode_value, "IP");
10528 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10529 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10530 				 mode_value, "MAC-VLAN");
10531 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10532 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10533 				 mode_value, "Tunnel");
10534 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10535 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10536 				 mac, "mac");
10537 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10538 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10539 			      mac_addr_byte_mask, RTE_UINT8);
10540 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10541 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10542 				 tunnel_type, "tunnel-type");
10543 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10544 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10545 			      tunnel_type_mask, RTE_UINT8);
10546 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10547 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10548 				 tunnel_id, "tunnel-id");
10549 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10550 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10551 			      tunnel_id_mask, RTE_UINT32);
10552 
10553 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10554 	.f = cmd_flow_director_mask_parsed,
10555 	.data = NULL,
10556 	.help_str = "flow_director_mask ... : "
10557 		"Set IP mode flow director's mask on NIC",
10558 	.tokens = {
10559 		(void *)&cmd_flow_director_mask,
10560 		(void *)&cmd_flow_director_mask_port_id,
10561 		(void *)&cmd_flow_director_mask_mode,
10562 		(void *)&cmd_flow_director_mask_mode_ip,
10563 		(void *)&cmd_flow_director_mask_vlan,
10564 		(void *)&cmd_flow_director_mask_vlan_value,
10565 		(void *)&cmd_flow_director_mask_src,
10566 		(void *)&cmd_flow_director_mask_ipv4_src,
10567 		(void *)&cmd_flow_director_mask_ipv6_src,
10568 		(void *)&cmd_flow_director_mask_port_src,
10569 		(void *)&cmd_flow_director_mask_dst,
10570 		(void *)&cmd_flow_director_mask_ipv4_dst,
10571 		(void *)&cmd_flow_director_mask_ipv6_dst,
10572 		(void *)&cmd_flow_director_mask_port_dst,
10573 		NULL,
10574 	},
10575 };
10576 
10577 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10578 	.f = cmd_flow_director_mask_parsed,
10579 	.data = NULL,
10580 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10581 		"flow director's mask on NIC",
10582 	.tokens = {
10583 		(void *)&cmd_flow_director_mask,
10584 		(void *)&cmd_flow_director_mask_port_id,
10585 		(void *)&cmd_flow_director_mask_mode,
10586 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10587 		(void *)&cmd_flow_director_mask_vlan,
10588 		(void *)&cmd_flow_director_mask_vlan_value,
10589 		NULL,
10590 	},
10591 };
10592 
10593 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10594 	.f = cmd_flow_director_mask_parsed,
10595 	.data = NULL,
10596 	.help_str = "flow_director_mask ... : Set tunnel mode "
10597 		"flow director's mask on NIC",
10598 	.tokens = {
10599 		(void *)&cmd_flow_director_mask,
10600 		(void *)&cmd_flow_director_mask_port_id,
10601 		(void *)&cmd_flow_director_mask_mode,
10602 		(void *)&cmd_flow_director_mask_mode_tunnel,
10603 		(void *)&cmd_flow_director_mask_vlan,
10604 		(void *)&cmd_flow_director_mask_vlan_value,
10605 		(void *)&cmd_flow_director_mask_mac,
10606 		(void *)&cmd_flow_director_mask_mac_value,
10607 		(void *)&cmd_flow_director_mask_tunnel_type,
10608 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10609 		(void *)&cmd_flow_director_mask_tunnel_id,
10610 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10611 		NULL,
10612 	},
10613 };
10614 
10615 /* *** deal with flow director flexible payload configuration *** */
10616 struct cmd_flow_director_flexpayload_result {
10617 	cmdline_fixed_string_t flow_director_flexpayload;
10618 	portid_t port_id;
10619 	cmdline_fixed_string_t payload_layer;
10620 	cmdline_fixed_string_t payload_cfg;
10621 };
10622 
10623 static inline int
10624 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10625 {
10626 	char s[256];
10627 	const char *p, *p0 = q_arg;
10628 	char *end;
10629 	unsigned long int_fld;
10630 	char *str_fld[max_num];
10631 	int i;
10632 	unsigned size;
10633 	int ret = -1;
10634 
10635 	p = strchr(p0, '(');
10636 	if (p == NULL)
10637 		return -1;
10638 	++p;
10639 	p0 = strchr(p, ')');
10640 	if (p0 == NULL)
10641 		return -1;
10642 
10643 	size = p0 - p;
10644 	if (size >= sizeof(s))
10645 		return -1;
10646 
10647 	snprintf(s, sizeof(s), "%.*s", size, p);
10648 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10649 	if (ret < 0 || ret > max_num)
10650 		return -1;
10651 	for (i = 0; i < ret; i++) {
10652 		errno = 0;
10653 		int_fld = strtoul(str_fld[i], &end, 0);
10654 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10655 			return -1;
10656 		offsets[i] = (uint16_t)int_fld;
10657 	}
10658 	return ret;
10659 }
10660 
10661 static void
10662 cmd_flow_director_flxpld_parsed(void *parsed_result,
10663 			  __rte_unused struct cmdline *cl,
10664 			  __rte_unused void *data)
10665 {
10666 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
10667 	struct rte_eth_flex_payload_cfg flex_cfg;
10668 	struct rte_port *port;
10669 	int ret = 0;
10670 
10671 	port = &ports[res->port_id];
10672 	/** Check if the port is not started **/
10673 	if (port->port_status != RTE_PORT_STOPPED) {
10674 		printf("Please stop port %d first\n", res->port_id);
10675 		return;
10676 	}
10677 
10678 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10679 
10680 	if (!strcmp(res->payload_layer, "raw"))
10681 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10682 	else if (!strcmp(res->payload_layer, "l2"))
10683 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10684 	else if (!strcmp(res->payload_layer, "l3"))
10685 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10686 	else if (!strcmp(res->payload_layer, "l4"))
10687 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10688 
10689 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10690 			    RTE_ETH_FDIR_MAX_FLEXLEN);
10691 	if (ret < 0) {
10692 		printf("error: Cannot parse flex payload input.\n");
10693 		return;
10694 	}
10695 
10696 	fdir_set_flex_payload(res->port_id, &flex_cfg);
10697 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10698 }
10699 
10700 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10701 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10702 				 flow_director_flexpayload,
10703 				 "flow_director_flex_payload");
10704 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10705 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10706 			      port_id, RTE_UINT16);
10707 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10708 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10709 				 payload_layer, "raw#l2#l3#l4");
10710 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10711 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10712 				 payload_cfg, NULL);
10713 
10714 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10715 	.f = cmd_flow_director_flxpld_parsed,
10716 	.data = NULL,
10717 	.help_str = "flow_director_flexpayload ... : "
10718 		"Set flow director's flex payload on NIC",
10719 	.tokens = {
10720 		(void *)&cmd_flow_director_flexpayload,
10721 		(void *)&cmd_flow_director_flexpayload_port_id,
10722 		(void *)&cmd_flow_director_flexpayload_payload_layer,
10723 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
10724 		NULL,
10725 	},
10726 };
10727 
10728 /* Generic flow interface command. */
10729 extern cmdline_parse_inst_t cmd_flow;
10730 
10731 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10732 struct cmd_mcast_addr_result {
10733 	cmdline_fixed_string_t mcast_addr_cmd;
10734 	cmdline_fixed_string_t what;
10735 	uint16_t port_num;
10736 	struct rte_ether_addr mc_addr;
10737 };
10738 
10739 static void cmd_mcast_addr_parsed(void *parsed_result,
10740 		__rte_unused struct cmdline *cl,
10741 		__rte_unused void *data)
10742 {
10743 	struct cmd_mcast_addr_result *res = parsed_result;
10744 
10745 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10746 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10747 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10748 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10749 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10750 		return;
10751 	}
10752 	if (strcmp(res->what, "add") == 0)
10753 		mcast_addr_add(res->port_num, &res->mc_addr);
10754 	else
10755 		mcast_addr_remove(res->port_num, &res->mc_addr);
10756 }
10757 
10758 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10759 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10760 				 mcast_addr_cmd, "mcast_addr");
10761 cmdline_parse_token_string_t cmd_mcast_addr_what =
10762 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10763 				 "add#remove");
10764 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10765 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10766 				 RTE_UINT16);
10767 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10768 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10769 
10770 cmdline_parse_inst_t cmd_mcast_addr = {
10771 	.f = cmd_mcast_addr_parsed,
10772 	.data = (void *)0,
10773 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10774 		"Add/Remove multicast MAC address on port_id",
10775 	.tokens = {
10776 		(void *)&cmd_mcast_addr_cmd,
10777 		(void *)&cmd_mcast_addr_what,
10778 		(void *)&cmd_mcast_addr_portnum,
10779 		(void *)&cmd_mcast_addr_addr,
10780 		NULL,
10781 	},
10782 };
10783 
10784 /* vf vlan anti spoof configuration */
10785 
10786 /* Common result structure for vf vlan anti spoof */
10787 struct cmd_vf_vlan_anti_spoof_result {
10788 	cmdline_fixed_string_t set;
10789 	cmdline_fixed_string_t vf;
10790 	cmdline_fixed_string_t vlan;
10791 	cmdline_fixed_string_t antispoof;
10792 	portid_t port_id;
10793 	uint32_t vf_id;
10794 	cmdline_fixed_string_t on_off;
10795 };
10796 
10797 /* Common CLI fields for vf vlan anti spoof enable disable */
10798 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10799 	TOKEN_STRING_INITIALIZER
10800 		(struct cmd_vf_vlan_anti_spoof_result,
10801 		 set, "set");
10802 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10803 	TOKEN_STRING_INITIALIZER
10804 		(struct cmd_vf_vlan_anti_spoof_result,
10805 		 vf, "vf");
10806 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10807 	TOKEN_STRING_INITIALIZER
10808 		(struct cmd_vf_vlan_anti_spoof_result,
10809 		 vlan, "vlan");
10810 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10811 	TOKEN_STRING_INITIALIZER
10812 		(struct cmd_vf_vlan_anti_spoof_result,
10813 		 antispoof, "antispoof");
10814 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10815 	TOKEN_NUM_INITIALIZER
10816 		(struct cmd_vf_vlan_anti_spoof_result,
10817 		 port_id, RTE_UINT16);
10818 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10819 	TOKEN_NUM_INITIALIZER
10820 		(struct cmd_vf_vlan_anti_spoof_result,
10821 		 vf_id, RTE_UINT32);
10822 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10823 	TOKEN_STRING_INITIALIZER
10824 		(struct cmd_vf_vlan_anti_spoof_result,
10825 		 on_off, "on#off");
10826 
10827 static void
10828 cmd_set_vf_vlan_anti_spoof_parsed(
10829 	void *parsed_result,
10830 	__rte_unused struct cmdline *cl,
10831 	__rte_unused void *data)
10832 {
10833 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10834 	int ret = -ENOTSUP;
10835 
10836 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10837 
10838 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10839 		return;
10840 
10841 #ifdef RTE_NET_IXGBE
10842 	if (ret == -ENOTSUP)
10843 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10844 				res->vf_id, is_on);
10845 #endif
10846 #ifdef RTE_NET_I40E
10847 	if (ret == -ENOTSUP)
10848 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10849 				res->vf_id, is_on);
10850 #endif
10851 #ifdef RTE_NET_BNXT
10852 	if (ret == -ENOTSUP)
10853 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10854 				res->vf_id, is_on);
10855 #endif
10856 
10857 	switch (ret) {
10858 	case 0:
10859 		break;
10860 	case -EINVAL:
10861 		printf("invalid vf_id %d\n", res->vf_id);
10862 		break;
10863 	case -ENODEV:
10864 		printf("invalid port_id %d\n", res->port_id);
10865 		break;
10866 	case -ENOTSUP:
10867 		printf("function not implemented\n");
10868 		break;
10869 	default:
10870 		printf("programming error: (%s)\n", strerror(-ret));
10871 	}
10872 }
10873 
10874 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10875 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
10876 	.data = NULL,
10877 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10878 	.tokens = {
10879 		(void *)&cmd_vf_vlan_anti_spoof_set,
10880 		(void *)&cmd_vf_vlan_anti_spoof_vf,
10881 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
10882 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
10883 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
10884 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
10885 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
10886 		NULL,
10887 	},
10888 };
10889 
10890 /* vf mac anti spoof configuration */
10891 
10892 /* Common result structure for vf mac anti spoof */
10893 struct cmd_vf_mac_anti_spoof_result {
10894 	cmdline_fixed_string_t set;
10895 	cmdline_fixed_string_t vf;
10896 	cmdline_fixed_string_t mac;
10897 	cmdline_fixed_string_t antispoof;
10898 	portid_t port_id;
10899 	uint32_t vf_id;
10900 	cmdline_fixed_string_t on_off;
10901 };
10902 
10903 /* Common CLI fields for vf mac anti spoof enable disable */
10904 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10905 	TOKEN_STRING_INITIALIZER
10906 		(struct cmd_vf_mac_anti_spoof_result,
10907 		 set, "set");
10908 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10909 	TOKEN_STRING_INITIALIZER
10910 		(struct cmd_vf_mac_anti_spoof_result,
10911 		 vf, "vf");
10912 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10913 	TOKEN_STRING_INITIALIZER
10914 		(struct cmd_vf_mac_anti_spoof_result,
10915 		 mac, "mac");
10916 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10917 	TOKEN_STRING_INITIALIZER
10918 		(struct cmd_vf_mac_anti_spoof_result,
10919 		 antispoof, "antispoof");
10920 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10921 	TOKEN_NUM_INITIALIZER
10922 		(struct cmd_vf_mac_anti_spoof_result,
10923 		 port_id, RTE_UINT16);
10924 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10925 	TOKEN_NUM_INITIALIZER
10926 		(struct cmd_vf_mac_anti_spoof_result,
10927 		 vf_id, RTE_UINT32);
10928 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10929 	TOKEN_STRING_INITIALIZER
10930 		(struct cmd_vf_mac_anti_spoof_result,
10931 		 on_off, "on#off");
10932 
10933 static void
10934 cmd_set_vf_mac_anti_spoof_parsed(
10935 	void *parsed_result,
10936 	__rte_unused struct cmdline *cl,
10937 	__rte_unused void *data)
10938 {
10939 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10940 	int ret = -ENOTSUP;
10941 
10942 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10943 
10944 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10945 		return;
10946 
10947 #ifdef RTE_NET_IXGBE
10948 	if (ret == -ENOTSUP)
10949 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10950 			res->vf_id, is_on);
10951 #endif
10952 #ifdef RTE_NET_I40E
10953 	if (ret == -ENOTSUP)
10954 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10955 			res->vf_id, is_on);
10956 #endif
10957 #ifdef RTE_NET_BNXT
10958 	if (ret == -ENOTSUP)
10959 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10960 			res->vf_id, is_on);
10961 #endif
10962 
10963 	switch (ret) {
10964 	case 0:
10965 		break;
10966 	case -EINVAL:
10967 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10968 		break;
10969 	case -ENODEV:
10970 		printf("invalid port_id %d\n", res->port_id);
10971 		break;
10972 	case -ENOTSUP:
10973 		printf("function not implemented\n");
10974 		break;
10975 	default:
10976 		printf("programming error: (%s)\n", strerror(-ret));
10977 	}
10978 }
10979 
10980 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10981 	.f = cmd_set_vf_mac_anti_spoof_parsed,
10982 	.data = NULL,
10983 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10984 	.tokens = {
10985 		(void *)&cmd_vf_mac_anti_spoof_set,
10986 		(void *)&cmd_vf_mac_anti_spoof_vf,
10987 		(void *)&cmd_vf_mac_anti_spoof_mac,
10988 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
10989 		(void *)&cmd_vf_mac_anti_spoof_port_id,
10990 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
10991 		(void *)&cmd_vf_mac_anti_spoof_on_off,
10992 		NULL,
10993 	},
10994 };
10995 
10996 /* vf vlan strip queue configuration */
10997 
10998 /* Common result structure for vf mac anti spoof */
10999 struct cmd_vf_vlan_stripq_result {
11000 	cmdline_fixed_string_t set;
11001 	cmdline_fixed_string_t vf;
11002 	cmdline_fixed_string_t vlan;
11003 	cmdline_fixed_string_t stripq;
11004 	portid_t port_id;
11005 	uint16_t vf_id;
11006 	cmdline_fixed_string_t on_off;
11007 };
11008 
11009 /* Common CLI fields for vf vlan strip enable disable */
11010 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11011 	TOKEN_STRING_INITIALIZER
11012 		(struct cmd_vf_vlan_stripq_result,
11013 		 set, "set");
11014 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11015 	TOKEN_STRING_INITIALIZER
11016 		(struct cmd_vf_vlan_stripq_result,
11017 		 vf, "vf");
11018 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11019 	TOKEN_STRING_INITIALIZER
11020 		(struct cmd_vf_vlan_stripq_result,
11021 		 vlan, "vlan");
11022 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11023 	TOKEN_STRING_INITIALIZER
11024 		(struct cmd_vf_vlan_stripq_result,
11025 		 stripq, "stripq");
11026 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11027 	TOKEN_NUM_INITIALIZER
11028 		(struct cmd_vf_vlan_stripq_result,
11029 		 port_id, RTE_UINT16);
11030 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11031 	TOKEN_NUM_INITIALIZER
11032 		(struct cmd_vf_vlan_stripq_result,
11033 		 vf_id, RTE_UINT16);
11034 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11035 	TOKEN_STRING_INITIALIZER
11036 		(struct cmd_vf_vlan_stripq_result,
11037 		 on_off, "on#off");
11038 
11039 static void
11040 cmd_set_vf_vlan_stripq_parsed(
11041 	void *parsed_result,
11042 	__rte_unused struct cmdline *cl,
11043 	__rte_unused void *data)
11044 {
11045 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
11046 	int ret = -ENOTSUP;
11047 
11048 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11049 
11050 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11051 		return;
11052 
11053 #ifdef RTE_NET_IXGBE
11054 	if (ret == -ENOTSUP)
11055 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11056 			res->vf_id, is_on);
11057 #endif
11058 #ifdef RTE_NET_I40E
11059 	if (ret == -ENOTSUP)
11060 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11061 			res->vf_id, is_on);
11062 #endif
11063 #ifdef RTE_NET_BNXT
11064 	if (ret == -ENOTSUP)
11065 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11066 			res->vf_id, is_on);
11067 #endif
11068 
11069 	switch (ret) {
11070 	case 0:
11071 		break;
11072 	case -EINVAL:
11073 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11074 		break;
11075 	case -ENODEV:
11076 		printf("invalid port_id %d\n", res->port_id);
11077 		break;
11078 	case -ENOTSUP:
11079 		printf("function not implemented\n");
11080 		break;
11081 	default:
11082 		printf("programming error: (%s)\n", strerror(-ret));
11083 	}
11084 }
11085 
11086 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11087 	.f = cmd_set_vf_vlan_stripq_parsed,
11088 	.data = NULL,
11089 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11090 	.tokens = {
11091 		(void *)&cmd_vf_vlan_stripq_set,
11092 		(void *)&cmd_vf_vlan_stripq_vf,
11093 		(void *)&cmd_vf_vlan_stripq_vlan,
11094 		(void *)&cmd_vf_vlan_stripq_stripq,
11095 		(void *)&cmd_vf_vlan_stripq_port_id,
11096 		(void *)&cmd_vf_vlan_stripq_vf_id,
11097 		(void *)&cmd_vf_vlan_stripq_on_off,
11098 		NULL,
11099 	},
11100 };
11101 
11102 /* vf vlan insert configuration */
11103 
11104 /* Common result structure for vf vlan insert */
11105 struct cmd_vf_vlan_insert_result {
11106 	cmdline_fixed_string_t set;
11107 	cmdline_fixed_string_t vf;
11108 	cmdline_fixed_string_t vlan;
11109 	cmdline_fixed_string_t insert;
11110 	portid_t port_id;
11111 	uint16_t vf_id;
11112 	uint16_t vlan_id;
11113 };
11114 
11115 /* Common CLI fields for vf vlan insert enable disable */
11116 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11117 	TOKEN_STRING_INITIALIZER
11118 		(struct cmd_vf_vlan_insert_result,
11119 		 set, "set");
11120 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11121 	TOKEN_STRING_INITIALIZER
11122 		(struct cmd_vf_vlan_insert_result,
11123 		 vf, "vf");
11124 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11125 	TOKEN_STRING_INITIALIZER
11126 		(struct cmd_vf_vlan_insert_result,
11127 		 vlan, "vlan");
11128 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11129 	TOKEN_STRING_INITIALIZER
11130 		(struct cmd_vf_vlan_insert_result,
11131 		 insert, "insert");
11132 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11133 	TOKEN_NUM_INITIALIZER
11134 		(struct cmd_vf_vlan_insert_result,
11135 		 port_id, RTE_UINT16);
11136 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11137 	TOKEN_NUM_INITIALIZER
11138 		(struct cmd_vf_vlan_insert_result,
11139 		 vf_id, RTE_UINT16);
11140 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11141 	TOKEN_NUM_INITIALIZER
11142 		(struct cmd_vf_vlan_insert_result,
11143 		 vlan_id, RTE_UINT16);
11144 
11145 static void
11146 cmd_set_vf_vlan_insert_parsed(
11147 	void *parsed_result,
11148 	__rte_unused struct cmdline *cl,
11149 	__rte_unused void *data)
11150 {
11151 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11152 	int ret = -ENOTSUP;
11153 
11154 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11155 		return;
11156 
11157 #ifdef RTE_NET_IXGBE
11158 	if (ret == -ENOTSUP)
11159 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11160 			res->vlan_id);
11161 #endif
11162 #ifdef RTE_NET_I40E
11163 	if (ret == -ENOTSUP)
11164 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11165 			res->vlan_id);
11166 #endif
11167 #ifdef RTE_NET_BNXT
11168 	if (ret == -ENOTSUP)
11169 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11170 			res->vlan_id);
11171 #endif
11172 
11173 	switch (ret) {
11174 	case 0:
11175 		break;
11176 	case -EINVAL:
11177 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11178 		break;
11179 	case -ENODEV:
11180 		printf("invalid port_id %d\n", res->port_id);
11181 		break;
11182 	case -ENOTSUP:
11183 		printf("function not implemented\n");
11184 		break;
11185 	default:
11186 		printf("programming error: (%s)\n", strerror(-ret));
11187 	}
11188 }
11189 
11190 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11191 	.f = cmd_set_vf_vlan_insert_parsed,
11192 	.data = NULL,
11193 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11194 	.tokens = {
11195 		(void *)&cmd_vf_vlan_insert_set,
11196 		(void *)&cmd_vf_vlan_insert_vf,
11197 		(void *)&cmd_vf_vlan_insert_vlan,
11198 		(void *)&cmd_vf_vlan_insert_insert,
11199 		(void *)&cmd_vf_vlan_insert_port_id,
11200 		(void *)&cmd_vf_vlan_insert_vf_id,
11201 		(void *)&cmd_vf_vlan_insert_vlan_id,
11202 		NULL,
11203 	},
11204 };
11205 
11206 /* tx loopback configuration */
11207 
11208 /* Common result structure for tx loopback */
11209 struct cmd_tx_loopback_result {
11210 	cmdline_fixed_string_t set;
11211 	cmdline_fixed_string_t tx;
11212 	cmdline_fixed_string_t loopback;
11213 	portid_t port_id;
11214 	cmdline_fixed_string_t on_off;
11215 };
11216 
11217 /* Common CLI fields for tx loopback enable disable */
11218 cmdline_parse_token_string_t cmd_tx_loopback_set =
11219 	TOKEN_STRING_INITIALIZER
11220 		(struct cmd_tx_loopback_result,
11221 		 set, "set");
11222 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11223 	TOKEN_STRING_INITIALIZER
11224 		(struct cmd_tx_loopback_result,
11225 		 tx, "tx");
11226 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11227 	TOKEN_STRING_INITIALIZER
11228 		(struct cmd_tx_loopback_result,
11229 		 loopback, "loopback");
11230 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11231 	TOKEN_NUM_INITIALIZER
11232 		(struct cmd_tx_loopback_result,
11233 		 port_id, RTE_UINT16);
11234 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11235 	TOKEN_STRING_INITIALIZER
11236 		(struct cmd_tx_loopback_result,
11237 		 on_off, "on#off");
11238 
11239 static void
11240 cmd_set_tx_loopback_parsed(
11241 	void *parsed_result,
11242 	__rte_unused struct cmdline *cl,
11243 	__rte_unused void *data)
11244 {
11245 	struct cmd_tx_loopback_result *res = parsed_result;
11246 	int ret = -ENOTSUP;
11247 
11248 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11249 
11250 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11251 		return;
11252 
11253 #ifdef RTE_NET_IXGBE
11254 	if (ret == -ENOTSUP)
11255 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11256 #endif
11257 #ifdef RTE_NET_I40E
11258 	if (ret == -ENOTSUP)
11259 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11260 #endif
11261 #ifdef RTE_NET_BNXT
11262 	if (ret == -ENOTSUP)
11263 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11264 #endif
11265 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11266 	if (ret == -ENOTSUP)
11267 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11268 #endif
11269 
11270 	switch (ret) {
11271 	case 0:
11272 		break;
11273 	case -EINVAL:
11274 		printf("invalid is_on %d\n", is_on);
11275 		break;
11276 	case -ENODEV:
11277 		printf("invalid port_id %d\n", res->port_id);
11278 		break;
11279 	case -ENOTSUP:
11280 		printf("function not implemented\n");
11281 		break;
11282 	default:
11283 		printf("programming error: (%s)\n", strerror(-ret));
11284 	}
11285 }
11286 
11287 cmdline_parse_inst_t cmd_set_tx_loopback = {
11288 	.f = cmd_set_tx_loopback_parsed,
11289 	.data = NULL,
11290 	.help_str = "set tx loopback <port_id> on|off",
11291 	.tokens = {
11292 		(void *)&cmd_tx_loopback_set,
11293 		(void *)&cmd_tx_loopback_tx,
11294 		(void *)&cmd_tx_loopback_loopback,
11295 		(void *)&cmd_tx_loopback_port_id,
11296 		(void *)&cmd_tx_loopback_on_off,
11297 		NULL,
11298 	},
11299 };
11300 
11301 /* all queues drop enable configuration */
11302 
11303 /* Common result structure for all queues drop enable */
11304 struct cmd_all_queues_drop_en_result {
11305 	cmdline_fixed_string_t set;
11306 	cmdline_fixed_string_t all;
11307 	cmdline_fixed_string_t queues;
11308 	cmdline_fixed_string_t drop;
11309 	portid_t port_id;
11310 	cmdline_fixed_string_t on_off;
11311 };
11312 
11313 /* Common CLI fields for tx loopback enable disable */
11314 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11315 	TOKEN_STRING_INITIALIZER
11316 		(struct cmd_all_queues_drop_en_result,
11317 		 set, "set");
11318 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11319 	TOKEN_STRING_INITIALIZER
11320 		(struct cmd_all_queues_drop_en_result,
11321 		 all, "all");
11322 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11323 	TOKEN_STRING_INITIALIZER
11324 		(struct cmd_all_queues_drop_en_result,
11325 		 queues, "queues");
11326 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11327 	TOKEN_STRING_INITIALIZER
11328 		(struct cmd_all_queues_drop_en_result,
11329 		 drop, "drop");
11330 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11331 	TOKEN_NUM_INITIALIZER
11332 		(struct cmd_all_queues_drop_en_result,
11333 		 port_id, RTE_UINT16);
11334 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11335 	TOKEN_STRING_INITIALIZER
11336 		(struct cmd_all_queues_drop_en_result,
11337 		 on_off, "on#off");
11338 
11339 static void
11340 cmd_set_all_queues_drop_en_parsed(
11341 	void *parsed_result,
11342 	__rte_unused struct cmdline *cl,
11343 	__rte_unused void *data)
11344 {
11345 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11346 	int ret = -ENOTSUP;
11347 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11348 
11349 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11350 		return;
11351 
11352 #ifdef RTE_NET_IXGBE
11353 	if (ret == -ENOTSUP)
11354 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11355 #endif
11356 #ifdef RTE_NET_BNXT
11357 	if (ret == -ENOTSUP)
11358 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11359 #endif
11360 	switch (ret) {
11361 	case 0:
11362 		break;
11363 	case -EINVAL:
11364 		printf("invalid is_on %d\n", is_on);
11365 		break;
11366 	case -ENODEV:
11367 		printf("invalid port_id %d\n", res->port_id);
11368 		break;
11369 	case -ENOTSUP:
11370 		printf("function not implemented\n");
11371 		break;
11372 	default:
11373 		printf("programming error: (%s)\n", strerror(-ret));
11374 	}
11375 }
11376 
11377 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11378 	.f = cmd_set_all_queues_drop_en_parsed,
11379 	.data = NULL,
11380 	.help_str = "set all queues drop <port_id> on|off",
11381 	.tokens = {
11382 		(void *)&cmd_all_queues_drop_en_set,
11383 		(void *)&cmd_all_queues_drop_en_all,
11384 		(void *)&cmd_all_queues_drop_en_queues,
11385 		(void *)&cmd_all_queues_drop_en_drop,
11386 		(void *)&cmd_all_queues_drop_en_port_id,
11387 		(void *)&cmd_all_queues_drop_en_on_off,
11388 		NULL,
11389 	},
11390 };
11391 
11392 /* vf split drop enable configuration */
11393 
11394 /* Common result structure for vf split drop enable */
11395 struct cmd_vf_split_drop_en_result {
11396 	cmdline_fixed_string_t set;
11397 	cmdline_fixed_string_t vf;
11398 	cmdline_fixed_string_t split;
11399 	cmdline_fixed_string_t drop;
11400 	portid_t port_id;
11401 	uint16_t vf_id;
11402 	cmdline_fixed_string_t on_off;
11403 };
11404 
11405 /* Common CLI fields for vf split drop enable disable */
11406 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11407 	TOKEN_STRING_INITIALIZER
11408 		(struct cmd_vf_split_drop_en_result,
11409 		 set, "set");
11410 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11411 	TOKEN_STRING_INITIALIZER
11412 		(struct cmd_vf_split_drop_en_result,
11413 		 vf, "vf");
11414 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11415 	TOKEN_STRING_INITIALIZER
11416 		(struct cmd_vf_split_drop_en_result,
11417 		 split, "split");
11418 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11419 	TOKEN_STRING_INITIALIZER
11420 		(struct cmd_vf_split_drop_en_result,
11421 		 drop, "drop");
11422 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11423 	TOKEN_NUM_INITIALIZER
11424 		(struct cmd_vf_split_drop_en_result,
11425 		 port_id, RTE_UINT16);
11426 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11427 	TOKEN_NUM_INITIALIZER
11428 		(struct cmd_vf_split_drop_en_result,
11429 		 vf_id, RTE_UINT16);
11430 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11431 	TOKEN_STRING_INITIALIZER
11432 		(struct cmd_vf_split_drop_en_result,
11433 		 on_off, "on#off");
11434 
11435 static void
11436 cmd_set_vf_split_drop_en_parsed(
11437 	void *parsed_result,
11438 	__rte_unused struct cmdline *cl,
11439 	__rte_unused void *data)
11440 {
11441 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11442 	int ret = -ENOTSUP;
11443 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11444 
11445 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11446 		return;
11447 
11448 #ifdef RTE_NET_IXGBE
11449 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11450 			is_on);
11451 #endif
11452 	switch (ret) {
11453 	case 0:
11454 		break;
11455 	case -EINVAL:
11456 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11457 		break;
11458 	case -ENODEV:
11459 		printf("invalid port_id %d\n", res->port_id);
11460 		break;
11461 	case -ENOTSUP:
11462 		printf("not supported on port %d\n", res->port_id);
11463 		break;
11464 	default:
11465 		printf("programming error: (%s)\n", strerror(-ret));
11466 	}
11467 }
11468 
11469 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11470 	.f = cmd_set_vf_split_drop_en_parsed,
11471 	.data = NULL,
11472 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11473 	.tokens = {
11474 		(void *)&cmd_vf_split_drop_en_set,
11475 		(void *)&cmd_vf_split_drop_en_vf,
11476 		(void *)&cmd_vf_split_drop_en_split,
11477 		(void *)&cmd_vf_split_drop_en_drop,
11478 		(void *)&cmd_vf_split_drop_en_port_id,
11479 		(void *)&cmd_vf_split_drop_en_vf_id,
11480 		(void *)&cmd_vf_split_drop_en_on_off,
11481 		NULL,
11482 	},
11483 };
11484 
11485 /* vf mac address configuration */
11486 
11487 /* Common result structure for vf mac address */
11488 struct cmd_set_vf_mac_addr_result {
11489 	cmdline_fixed_string_t set;
11490 	cmdline_fixed_string_t vf;
11491 	cmdline_fixed_string_t mac;
11492 	cmdline_fixed_string_t addr;
11493 	portid_t port_id;
11494 	uint16_t vf_id;
11495 	struct rte_ether_addr mac_addr;
11496 
11497 };
11498 
11499 /* Common CLI fields for vf split drop enable disable */
11500 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11501 	TOKEN_STRING_INITIALIZER
11502 		(struct cmd_set_vf_mac_addr_result,
11503 		 set, "set");
11504 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11505 	TOKEN_STRING_INITIALIZER
11506 		(struct cmd_set_vf_mac_addr_result,
11507 		 vf, "vf");
11508 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11509 	TOKEN_STRING_INITIALIZER
11510 		(struct cmd_set_vf_mac_addr_result,
11511 		 mac, "mac");
11512 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11513 	TOKEN_STRING_INITIALIZER
11514 		(struct cmd_set_vf_mac_addr_result,
11515 		 addr, "addr");
11516 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11517 	TOKEN_NUM_INITIALIZER
11518 		(struct cmd_set_vf_mac_addr_result,
11519 		 port_id, RTE_UINT16);
11520 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11521 	TOKEN_NUM_INITIALIZER
11522 		(struct cmd_set_vf_mac_addr_result,
11523 		 vf_id, RTE_UINT16);
11524 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11525 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11526 		 mac_addr);
11527 
11528 static void
11529 cmd_set_vf_mac_addr_parsed(
11530 	void *parsed_result,
11531 	__rte_unused struct cmdline *cl,
11532 	__rte_unused void *data)
11533 {
11534 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11535 	int ret = -ENOTSUP;
11536 
11537 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11538 		return;
11539 
11540 #ifdef RTE_NET_IXGBE
11541 	if (ret == -ENOTSUP)
11542 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11543 				&res->mac_addr);
11544 #endif
11545 #ifdef RTE_NET_I40E
11546 	if (ret == -ENOTSUP)
11547 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11548 				&res->mac_addr);
11549 #endif
11550 #ifdef RTE_NET_BNXT
11551 	if (ret == -ENOTSUP)
11552 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11553 				&res->mac_addr);
11554 #endif
11555 
11556 	switch (ret) {
11557 	case 0:
11558 		break;
11559 	case -EINVAL:
11560 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11561 		break;
11562 	case -ENODEV:
11563 		printf("invalid port_id %d\n", res->port_id);
11564 		break;
11565 	case -ENOTSUP:
11566 		printf("function not implemented\n");
11567 		break;
11568 	default:
11569 		printf("programming error: (%s)\n", strerror(-ret));
11570 	}
11571 }
11572 
11573 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11574 	.f = cmd_set_vf_mac_addr_parsed,
11575 	.data = NULL,
11576 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11577 	.tokens = {
11578 		(void *)&cmd_set_vf_mac_addr_set,
11579 		(void *)&cmd_set_vf_mac_addr_vf,
11580 		(void *)&cmd_set_vf_mac_addr_mac,
11581 		(void *)&cmd_set_vf_mac_addr_addr,
11582 		(void *)&cmd_set_vf_mac_addr_port_id,
11583 		(void *)&cmd_set_vf_mac_addr_vf_id,
11584 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11585 		NULL,
11586 	},
11587 };
11588 
11589 /* MACsec configuration */
11590 
11591 /* Common result structure for MACsec offload enable */
11592 struct cmd_macsec_offload_on_result {
11593 	cmdline_fixed_string_t set;
11594 	cmdline_fixed_string_t macsec;
11595 	cmdline_fixed_string_t offload;
11596 	portid_t port_id;
11597 	cmdline_fixed_string_t on;
11598 	cmdline_fixed_string_t encrypt;
11599 	cmdline_fixed_string_t en_on_off;
11600 	cmdline_fixed_string_t replay_protect;
11601 	cmdline_fixed_string_t rp_on_off;
11602 };
11603 
11604 /* Common CLI fields for MACsec offload disable */
11605 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11606 	TOKEN_STRING_INITIALIZER
11607 		(struct cmd_macsec_offload_on_result,
11608 		 set, "set");
11609 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11610 	TOKEN_STRING_INITIALIZER
11611 		(struct cmd_macsec_offload_on_result,
11612 		 macsec, "macsec");
11613 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11614 	TOKEN_STRING_INITIALIZER
11615 		(struct cmd_macsec_offload_on_result,
11616 		 offload, "offload");
11617 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11618 	TOKEN_NUM_INITIALIZER
11619 		(struct cmd_macsec_offload_on_result,
11620 		 port_id, RTE_UINT16);
11621 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11622 	TOKEN_STRING_INITIALIZER
11623 		(struct cmd_macsec_offload_on_result,
11624 		 on, "on");
11625 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11626 	TOKEN_STRING_INITIALIZER
11627 		(struct cmd_macsec_offload_on_result,
11628 		 encrypt, "encrypt");
11629 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11630 	TOKEN_STRING_INITIALIZER
11631 		(struct cmd_macsec_offload_on_result,
11632 		 en_on_off, "on#off");
11633 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11634 	TOKEN_STRING_INITIALIZER
11635 		(struct cmd_macsec_offload_on_result,
11636 		 replay_protect, "replay-protect");
11637 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11638 	TOKEN_STRING_INITIALIZER
11639 		(struct cmd_macsec_offload_on_result,
11640 		 rp_on_off, "on#off");
11641 
11642 static void
11643 cmd_set_macsec_offload_on_parsed(
11644 	void *parsed_result,
11645 	__rte_unused struct cmdline *cl,
11646 	__rte_unused void *data)
11647 {
11648 	struct cmd_macsec_offload_on_result *res = parsed_result;
11649 	int ret = -ENOTSUP;
11650 	portid_t port_id = res->port_id;
11651 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11652 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11653 	struct rte_eth_dev_info dev_info;
11654 
11655 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11656 		return;
11657 	if (!port_is_stopped(port_id)) {
11658 		printf("Please stop port %d first\n", port_id);
11659 		return;
11660 	}
11661 
11662 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11663 	if (ret != 0)
11664 		return;
11665 
11666 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11667 #ifdef RTE_NET_IXGBE
11668 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11669 #endif
11670 	}
11671 	RTE_SET_USED(en);
11672 	RTE_SET_USED(rp);
11673 
11674 	switch (ret) {
11675 	case 0:
11676 		ports[port_id].dev_conf.txmode.offloads |=
11677 						DEV_TX_OFFLOAD_MACSEC_INSERT;
11678 		cmd_reconfig_device_queue(port_id, 1, 1);
11679 		break;
11680 	case -ENODEV:
11681 		printf("invalid port_id %d\n", port_id);
11682 		break;
11683 	case -ENOTSUP:
11684 		printf("not supported on port %d\n", port_id);
11685 		break;
11686 	default:
11687 		printf("programming error: (%s)\n", strerror(-ret));
11688 	}
11689 }
11690 
11691 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11692 	.f = cmd_set_macsec_offload_on_parsed,
11693 	.data = NULL,
11694 	.help_str = "set macsec offload <port_id> on "
11695 		"encrypt on|off replay-protect on|off",
11696 	.tokens = {
11697 		(void *)&cmd_macsec_offload_on_set,
11698 		(void *)&cmd_macsec_offload_on_macsec,
11699 		(void *)&cmd_macsec_offload_on_offload,
11700 		(void *)&cmd_macsec_offload_on_port_id,
11701 		(void *)&cmd_macsec_offload_on_on,
11702 		(void *)&cmd_macsec_offload_on_encrypt,
11703 		(void *)&cmd_macsec_offload_on_en_on_off,
11704 		(void *)&cmd_macsec_offload_on_replay_protect,
11705 		(void *)&cmd_macsec_offload_on_rp_on_off,
11706 		NULL,
11707 	},
11708 };
11709 
11710 /* Common result structure for MACsec offload disable */
11711 struct cmd_macsec_offload_off_result {
11712 	cmdline_fixed_string_t set;
11713 	cmdline_fixed_string_t macsec;
11714 	cmdline_fixed_string_t offload;
11715 	portid_t port_id;
11716 	cmdline_fixed_string_t off;
11717 };
11718 
11719 /* Common CLI fields for MACsec offload disable */
11720 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11721 	TOKEN_STRING_INITIALIZER
11722 		(struct cmd_macsec_offload_off_result,
11723 		 set, "set");
11724 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11725 	TOKEN_STRING_INITIALIZER
11726 		(struct cmd_macsec_offload_off_result,
11727 		 macsec, "macsec");
11728 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11729 	TOKEN_STRING_INITIALIZER
11730 		(struct cmd_macsec_offload_off_result,
11731 		 offload, "offload");
11732 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11733 	TOKEN_NUM_INITIALIZER
11734 		(struct cmd_macsec_offload_off_result,
11735 		 port_id, RTE_UINT16);
11736 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11737 	TOKEN_STRING_INITIALIZER
11738 		(struct cmd_macsec_offload_off_result,
11739 		 off, "off");
11740 
11741 static void
11742 cmd_set_macsec_offload_off_parsed(
11743 	void *parsed_result,
11744 	__rte_unused struct cmdline *cl,
11745 	__rte_unused void *data)
11746 {
11747 	struct cmd_macsec_offload_off_result *res = parsed_result;
11748 	int ret = -ENOTSUP;
11749 	struct rte_eth_dev_info dev_info;
11750 	portid_t port_id = res->port_id;
11751 
11752 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11753 		return;
11754 	if (!port_is_stopped(port_id)) {
11755 		printf("Please stop port %d first\n", port_id);
11756 		return;
11757 	}
11758 
11759 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11760 	if (ret != 0)
11761 		return;
11762 
11763 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11764 #ifdef RTE_NET_IXGBE
11765 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
11766 #endif
11767 	}
11768 	switch (ret) {
11769 	case 0:
11770 		ports[port_id].dev_conf.txmode.offloads &=
11771 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
11772 		cmd_reconfig_device_queue(port_id, 1, 1);
11773 		break;
11774 	case -ENODEV:
11775 		printf("invalid port_id %d\n", port_id);
11776 		break;
11777 	case -ENOTSUP:
11778 		printf("not supported on port %d\n", port_id);
11779 		break;
11780 	default:
11781 		printf("programming error: (%s)\n", strerror(-ret));
11782 	}
11783 }
11784 
11785 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11786 	.f = cmd_set_macsec_offload_off_parsed,
11787 	.data = NULL,
11788 	.help_str = "set macsec offload <port_id> off",
11789 	.tokens = {
11790 		(void *)&cmd_macsec_offload_off_set,
11791 		(void *)&cmd_macsec_offload_off_macsec,
11792 		(void *)&cmd_macsec_offload_off_offload,
11793 		(void *)&cmd_macsec_offload_off_port_id,
11794 		(void *)&cmd_macsec_offload_off_off,
11795 		NULL,
11796 	},
11797 };
11798 
11799 /* Common result structure for MACsec secure connection configure */
11800 struct cmd_macsec_sc_result {
11801 	cmdline_fixed_string_t set;
11802 	cmdline_fixed_string_t macsec;
11803 	cmdline_fixed_string_t sc;
11804 	cmdline_fixed_string_t tx_rx;
11805 	portid_t port_id;
11806 	struct rte_ether_addr mac;
11807 	uint16_t pi;
11808 };
11809 
11810 /* Common CLI fields for MACsec secure connection configure */
11811 cmdline_parse_token_string_t cmd_macsec_sc_set =
11812 	TOKEN_STRING_INITIALIZER
11813 		(struct cmd_macsec_sc_result,
11814 		 set, "set");
11815 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11816 	TOKEN_STRING_INITIALIZER
11817 		(struct cmd_macsec_sc_result,
11818 		 macsec, "macsec");
11819 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11820 	TOKEN_STRING_INITIALIZER
11821 		(struct cmd_macsec_sc_result,
11822 		 sc, "sc");
11823 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11824 	TOKEN_STRING_INITIALIZER
11825 		(struct cmd_macsec_sc_result,
11826 		 tx_rx, "tx#rx");
11827 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11828 	TOKEN_NUM_INITIALIZER
11829 		(struct cmd_macsec_sc_result,
11830 		 port_id, RTE_UINT16);
11831 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11832 	TOKEN_ETHERADDR_INITIALIZER
11833 		(struct cmd_macsec_sc_result,
11834 		 mac);
11835 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11836 	TOKEN_NUM_INITIALIZER
11837 		(struct cmd_macsec_sc_result,
11838 		 pi, RTE_UINT16);
11839 
11840 static void
11841 cmd_set_macsec_sc_parsed(
11842 	void *parsed_result,
11843 	__rte_unused struct cmdline *cl,
11844 	__rte_unused void *data)
11845 {
11846 	struct cmd_macsec_sc_result *res = parsed_result;
11847 	int ret = -ENOTSUP;
11848 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11849 
11850 #ifdef RTE_NET_IXGBE
11851 	ret = is_tx ?
11852 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11853 				res->mac.addr_bytes) :
11854 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11855 				res->mac.addr_bytes, res->pi);
11856 #endif
11857 	RTE_SET_USED(is_tx);
11858 
11859 	switch (ret) {
11860 	case 0:
11861 		break;
11862 	case -ENODEV:
11863 		printf("invalid port_id %d\n", res->port_id);
11864 		break;
11865 	case -ENOTSUP:
11866 		printf("not supported on port %d\n", res->port_id);
11867 		break;
11868 	default:
11869 		printf("programming error: (%s)\n", strerror(-ret));
11870 	}
11871 }
11872 
11873 cmdline_parse_inst_t cmd_set_macsec_sc = {
11874 	.f = cmd_set_macsec_sc_parsed,
11875 	.data = NULL,
11876 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11877 	.tokens = {
11878 		(void *)&cmd_macsec_sc_set,
11879 		(void *)&cmd_macsec_sc_macsec,
11880 		(void *)&cmd_macsec_sc_sc,
11881 		(void *)&cmd_macsec_sc_tx_rx,
11882 		(void *)&cmd_macsec_sc_port_id,
11883 		(void *)&cmd_macsec_sc_mac,
11884 		(void *)&cmd_macsec_sc_pi,
11885 		NULL,
11886 	},
11887 };
11888 
11889 /* Common result structure for MACsec secure connection configure */
11890 struct cmd_macsec_sa_result {
11891 	cmdline_fixed_string_t set;
11892 	cmdline_fixed_string_t macsec;
11893 	cmdline_fixed_string_t sa;
11894 	cmdline_fixed_string_t tx_rx;
11895 	portid_t port_id;
11896 	uint8_t idx;
11897 	uint8_t an;
11898 	uint32_t pn;
11899 	cmdline_fixed_string_t key;
11900 };
11901 
11902 /* Common CLI fields for MACsec secure connection configure */
11903 cmdline_parse_token_string_t cmd_macsec_sa_set =
11904 	TOKEN_STRING_INITIALIZER
11905 		(struct cmd_macsec_sa_result,
11906 		 set, "set");
11907 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11908 	TOKEN_STRING_INITIALIZER
11909 		(struct cmd_macsec_sa_result,
11910 		 macsec, "macsec");
11911 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11912 	TOKEN_STRING_INITIALIZER
11913 		(struct cmd_macsec_sa_result,
11914 		 sa, "sa");
11915 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11916 	TOKEN_STRING_INITIALIZER
11917 		(struct cmd_macsec_sa_result,
11918 		 tx_rx, "tx#rx");
11919 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11920 	TOKEN_NUM_INITIALIZER
11921 		(struct cmd_macsec_sa_result,
11922 		 port_id, RTE_UINT16);
11923 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11924 	TOKEN_NUM_INITIALIZER
11925 		(struct cmd_macsec_sa_result,
11926 		 idx, RTE_UINT8);
11927 cmdline_parse_token_num_t cmd_macsec_sa_an =
11928 	TOKEN_NUM_INITIALIZER
11929 		(struct cmd_macsec_sa_result,
11930 		 an, RTE_UINT8);
11931 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11932 	TOKEN_NUM_INITIALIZER
11933 		(struct cmd_macsec_sa_result,
11934 		 pn, RTE_UINT32);
11935 cmdline_parse_token_string_t cmd_macsec_sa_key =
11936 	TOKEN_STRING_INITIALIZER
11937 		(struct cmd_macsec_sa_result,
11938 		 key, NULL);
11939 
11940 static void
11941 cmd_set_macsec_sa_parsed(
11942 	void *parsed_result,
11943 	__rte_unused struct cmdline *cl,
11944 	__rte_unused void *data)
11945 {
11946 	struct cmd_macsec_sa_result *res = parsed_result;
11947 	int ret = -ENOTSUP;
11948 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11949 	uint8_t key[16] = { 0 };
11950 	uint8_t xdgt0;
11951 	uint8_t xdgt1;
11952 	int key_len;
11953 	int i;
11954 
11955 	key_len = strlen(res->key) / 2;
11956 	if (key_len > 16)
11957 		key_len = 16;
11958 
11959 	for (i = 0; i < key_len; i++) {
11960 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11961 		if (xdgt0 == 0xFF)
11962 			return;
11963 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11964 		if (xdgt1 == 0xFF)
11965 			return;
11966 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11967 	}
11968 
11969 #ifdef RTE_NET_IXGBE
11970 	ret = is_tx ?
11971 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11972 			res->idx, res->an, res->pn, key) :
11973 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11974 			res->idx, res->an, res->pn, key);
11975 #endif
11976 	RTE_SET_USED(is_tx);
11977 	RTE_SET_USED(key);
11978 
11979 	switch (ret) {
11980 	case 0:
11981 		break;
11982 	case -EINVAL:
11983 		printf("invalid idx %d or an %d\n", res->idx, res->an);
11984 		break;
11985 	case -ENODEV:
11986 		printf("invalid port_id %d\n", res->port_id);
11987 		break;
11988 	case -ENOTSUP:
11989 		printf("not supported on port %d\n", res->port_id);
11990 		break;
11991 	default:
11992 		printf("programming error: (%s)\n", strerror(-ret));
11993 	}
11994 }
11995 
11996 cmdline_parse_inst_t cmd_set_macsec_sa = {
11997 	.f = cmd_set_macsec_sa_parsed,
11998 	.data = NULL,
11999 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12000 	.tokens = {
12001 		(void *)&cmd_macsec_sa_set,
12002 		(void *)&cmd_macsec_sa_macsec,
12003 		(void *)&cmd_macsec_sa_sa,
12004 		(void *)&cmd_macsec_sa_tx_rx,
12005 		(void *)&cmd_macsec_sa_port_id,
12006 		(void *)&cmd_macsec_sa_idx,
12007 		(void *)&cmd_macsec_sa_an,
12008 		(void *)&cmd_macsec_sa_pn,
12009 		(void *)&cmd_macsec_sa_key,
12010 		NULL,
12011 	},
12012 };
12013 
12014 /* VF unicast promiscuous mode configuration */
12015 
12016 /* Common result structure for VF unicast promiscuous mode */
12017 struct cmd_vf_promisc_result {
12018 	cmdline_fixed_string_t set;
12019 	cmdline_fixed_string_t vf;
12020 	cmdline_fixed_string_t promisc;
12021 	portid_t port_id;
12022 	uint32_t vf_id;
12023 	cmdline_fixed_string_t on_off;
12024 };
12025 
12026 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12027 cmdline_parse_token_string_t cmd_vf_promisc_set =
12028 	TOKEN_STRING_INITIALIZER
12029 		(struct cmd_vf_promisc_result,
12030 		 set, "set");
12031 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12032 	TOKEN_STRING_INITIALIZER
12033 		(struct cmd_vf_promisc_result,
12034 		 vf, "vf");
12035 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12036 	TOKEN_STRING_INITIALIZER
12037 		(struct cmd_vf_promisc_result,
12038 		 promisc, "promisc");
12039 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12040 	TOKEN_NUM_INITIALIZER
12041 		(struct cmd_vf_promisc_result,
12042 		 port_id, RTE_UINT16);
12043 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12044 	TOKEN_NUM_INITIALIZER
12045 		(struct cmd_vf_promisc_result,
12046 		 vf_id, RTE_UINT32);
12047 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12048 	TOKEN_STRING_INITIALIZER
12049 		(struct cmd_vf_promisc_result,
12050 		 on_off, "on#off");
12051 
12052 static void
12053 cmd_set_vf_promisc_parsed(
12054 	void *parsed_result,
12055 	__rte_unused struct cmdline *cl,
12056 	__rte_unused void *data)
12057 {
12058 	struct cmd_vf_promisc_result *res = parsed_result;
12059 	int ret = -ENOTSUP;
12060 
12061 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12062 
12063 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12064 		return;
12065 
12066 #ifdef RTE_NET_I40E
12067 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12068 						  res->vf_id, is_on);
12069 #endif
12070 
12071 	switch (ret) {
12072 	case 0:
12073 		break;
12074 	case -EINVAL:
12075 		printf("invalid vf_id %d\n", res->vf_id);
12076 		break;
12077 	case -ENODEV:
12078 		printf("invalid port_id %d\n", res->port_id);
12079 		break;
12080 	case -ENOTSUP:
12081 		printf("function not implemented\n");
12082 		break;
12083 	default:
12084 		printf("programming error: (%s)\n", strerror(-ret));
12085 	}
12086 }
12087 
12088 cmdline_parse_inst_t cmd_set_vf_promisc = {
12089 	.f = cmd_set_vf_promisc_parsed,
12090 	.data = NULL,
12091 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
12092 		"Set unicast promiscuous mode for a VF from the PF",
12093 	.tokens = {
12094 		(void *)&cmd_vf_promisc_set,
12095 		(void *)&cmd_vf_promisc_vf,
12096 		(void *)&cmd_vf_promisc_promisc,
12097 		(void *)&cmd_vf_promisc_port_id,
12098 		(void *)&cmd_vf_promisc_vf_id,
12099 		(void *)&cmd_vf_promisc_on_off,
12100 		NULL,
12101 	},
12102 };
12103 
12104 /* VF multicast promiscuous mode configuration */
12105 
12106 /* Common result structure for VF multicast promiscuous mode */
12107 struct cmd_vf_allmulti_result {
12108 	cmdline_fixed_string_t set;
12109 	cmdline_fixed_string_t vf;
12110 	cmdline_fixed_string_t allmulti;
12111 	portid_t port_id;
12112 	uint32_t vf_id;
12113 	cmdline_fixed_string_t on_off;
12114 };
12115 
12116 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12117 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12118 	TOKEN_STRING_INITIALIZER
12119 		(struct cmd_vf_allmulti_result,
12120 		 set, "set");
12121 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12122 	TOKEN_STRING_INITIALIZER
12123 		(struct cmd_vf_allmulti_result,
12124 		 vf, "vf");
12125 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12126 	TOKEN_STRING_INITIALIZER
12127 		(struct cmd_vf_allmulti_result,
12128 		 allmulti, "allmulti");
12129 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12130 	TOKEN_NUM_INITIALIZER
12131 		(struct cmd_vf_allmulti_result,
12132 		 port_id, RTE_UINT16);
12133 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12134 	TOKEN_NUM_INITIALIZER
12135 		(struct cmd_vf_allmulti_result,
12136 		 vf_id, RTE_UINT32);
12137 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12138 	TOKEN_STRING_INITIALIZER
12139 		(struct cmd_vf_allmulti_result,
12140 		 on_off, "on#off");
12141 
12142 static void
12143 cmd_set_vf_allmulti_parsed(
12144 	void *parsed_result,
12145 	__rte_unused struct cmdline *cl,
12146 	__rte_unused void *data)
12147 {
12148 	struct cmd_vf_allmulti_result *res = parsed_result;
12149 	int ret = -ENOTSUP;
12150 
12151 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12152 
12153 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12154 		return;
12155 
12156 #ifdef RTE_NET_I40E
12157 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12158 						    res->vf_id, is_on);
12159 #endif
12160 
12161 	switch (ret) {
12162 	case 0:
12163 		break;
12164 	case -EINVAL:
12165 		printf("invalid vf_id %d\n", res->vf_id);
12166 		break;
12167 	case -ENODEV:
12168 		printf("invalid port_id %d\n", res->port_id);
12169 		break;
12170 	case -ENOTSUP:
12171 		printf("function not implemented\n");
12172 		break;
12173 	default:
12174 		printf("programming error: (%s)\n", strerror(-ret));
12175 	}
12176 }
12177 
12178 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12179 	.f = cmd_set_vf_allmulti_parsed,
12180 	.data = NULL,
12181 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12182 		"Set multicast promiscuous mode for a VF from the PF",
12183 	.tokens = {
12184 		(void *)&cmd_vf_allmulti_set,
12185 		(void *)&cmd_vf_allmulti_vf,
12186 		(void *)&cmd_vf_allmulti_allmulti,
12187 		(void *)&cmd_vf_allmulti_port_id,
12188 		(void *)&cmd_vf_allmulti_vf_id,
12189 		(void *)&cmd_vf_allmulti_on_off,
12190 		NULL,
12191 	},
12192 };
12193 
12194 /* vf broadcast mode configuration */
12195 
12196 /* Common result structure for vf broadcast */
12197 struct cmd_set_vf_broadcast_result {
12198 	cmdline_fixed_string_t set;
12199 	cmdline_fixed_string_t vf;
12200 	cmdline_fixed_string_t broadcast;
12201 	portid_t port_id;
12202 	uint16_t vf_id;
12203 	cmdline_fixed_string_t on_off;
12204 };
12205 
12206 /* Common CLI fields for vf broadcast enable disable */
12207 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12208 	TOKEN_STRING_INITIALIZER
12209 		(struct cmd_set_vf_broadcast_result,
12210 		 set, "set");
12211 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12212 	TOKEN_STRING_INITIALIZER
12213 		(struct cmd_set_vf_broadcast_result,
12214 		 vf, "vf");
12215 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12216 	TOKEN_STRING_INITIALIZER
12217 		(struct cmd_set_vf_broadcast_result,
12218 		 broadcast, "broadcast");
12219 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12220 	TOKEN_NUM_INITIALIZER
12221 		(struct cmd_set_vf_broadcast_result,
12222 		 port_id, RTE_UINT16);
12223 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12224 	TOKEN_NUM_INITIALIZER
12225 		(struct cmd_set_vf_broadcast_result,
12226 		 vf_id, RTE_UINT16);
12227 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12228 	TOKEN_STRING_INITIALIZER
12229 		(struct cmd_set_vf_broadcast_result,
12230 		 on_off, "on#off");
12231 
12232 static void
12233 cmd_set_vf_broadcast_parsed(
12234 	void *parsed_result,
12235 	__rte_unused struct cmdline *cl,
12236 	__rte_unused void *data)
12237 {
12238 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12239 	int ret = -ENOTSUP;
12240 
12241 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12242 
12243 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12244 		return;
12245 
12246 #ifdef RTE_NET_I40E
12247 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12248 					    res->vf_id, is_on);
12249 #endif
12250 
12251 	switch (ret) {
12252 	case 0:
12253 		break;
12254 	case -EINVAL:
12255 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12256 		break;
12257 	case -ENODEV:
12258 		printf("invalid port_id %d\n", res->port_id);
12259 		break;
12260 	case -ENOTSUP:
12261 		printf("function not implemented\n");
12262 		break;
12263 	default:
12264 		printf("programming error: (%s)\n", strerror(-ret));
12265 	}
12266 }
12267 
12268 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12269 	.f = cmd_set_vf_broadcast_parsed,
12270 	.data = NULL,
12271 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12272 	.tokens = {
12273 		(void *)&cmd_set_vf_broadcast_set,
12274 		(void *)&cmd_set_vf_broadcast_vf,
12275 		(void *)&cmd_set_vf_broadcast_broadcast,
12276 		(void *)&cmd_set_vf_broadcast_port_id,
12277 		(void *)&cmd_set_vf_broadcast_vf_id,
12278 		(void *)&cmd_set_vf_broadcast_on_off,
12279 		NULL,
12280 	},
12281 };
12282 
12283 /* vf vlan tag configuration */
12284 
12285 /* Common result structure for vf vlan tag */
12286 struct cmd_set_vf_vlan_tag_result {
12287 	cmdline_fixed_string_t set;
12288 	cmdline_fixed_string_t vf;
12289 	cmdline_fixed_string_t vlan;
12290 	cmdline_fixed_string_t tag;
12291 	portid_t port_id;
12292 	uint16_t vf_id;
12293 	cmdline_fixed_string_t on_off;
12294 };
12295 
12296 /* Common CLI fields for vf vlan tag enable disable */
12297 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12298 	TOKEN_STRING_INITIALIZER
12299 		(struct cmd_set_vf_vlan_tag_result,
12300 		 set, "set");
12301 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12302 	TOKEN_STRING_INITIALIZER
12303 		(struct cmd_set_vf_vlan_tag_result,
12304 		 vf, "vf");
12305 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12306 	TOKEN_STRING_INITIALIZER
12307 		(struct cmd_set_vf_vlan_tag_result,
12308 		 vlan, "vlan");
12309 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12310 	TOKEN_STRING_INITIALIZER
12311 		(struct cmd_set_vf_vlan_tag_result,
12312 		 tag, "tag");
12313 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12314 	TOKEN_NUM_INITIALIZER
12315 		(struct cmd_set_vf_vlan_tag_result,
12316 		 port_id, RTE_UINT16);
12317 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12318 	TOKEN_NUM_INITIALIZER
12319 		(struct cmd_set_vf_vlan_tag_result,
12320 		 vf_id, RTE_UINT16);
12321 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12322 	TOKEN_STRING_INITIALIZER
12323 		(struct cmd_set_vf_vlan_tag_result,
12324 		 on_off, "on#off");
12325 
12326 static void
12327 cmd_set_vf_vlan_tag_parsed(
12328 	void *parsed_result,
12329 	__rte_unused struct cmdline *cl,
12330 	__rte_unused void *data)
12331 {
12332 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12333 	int ret = -ENOTSUP;
12334 
12335 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12336 
12337 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12338 		return;
12339 
12340 #ifdef RTE_NET_I40E
12341 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12342 					   res->vf_id, is_on);
12343 #endif
12344 
12345 	switch (ret) {
12346 	case 0:
12347 		break;
12348 	case -EINVAL:
12349 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12350 		break;
12351 	case -ENODEV:
12352 		printf("invalid port_id %d\n", res->port_id);
12353 		break;
12354 	case -ENOTSUP:
12355 		printf("function not implemented\n");
12356 		break;
12357 	default:
12358 		printf("programming error: (%s)\n", strerror(-ret));
12359 	}
12360 }
12361 
12362 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12363 	.f = cmd_set_vf_vlan_tag_parsed,
12364 	.data = NULL,
12365 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12366 	.tokens = {
12367 		(void *)&cmd_set_vf_vlan_tag_set,
12368 		(void *)&cmd_set_vf_vlan_tag_vf,
12369 		(void *)&cmd_set_vf_vlan_tag_vlan,
12370 		(void *)&cmd_set_vf_vlan_tag_tag,
12371 		(void *)&cmd_set_vf_vlan_tag_port_id,
12372 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12373 		(void *)&cmd_set_vf_vlan_tag_on_off,
12374 		NULL,
12375 	},
12376 };
12377 
12378 /* Common definition of VF and TC TX bandwidth configuration */
12379 struct cmd_vf_tc_bw_result {
12380 	cmdline_fixed_string_t set;
12381 	cmdline_fixed_string_t vf;
12382 	cmdline_fixed_string_t tc;
12383 	cmdline_fixed_string_t tx;
12384 	cmdline_fixed_string_t min_bw;
12385 	cmdline_fixed_string_t max_bw;
12386 	cmdline_fixed_string_t strict_link_prio;
12387 	portid_t port_id;
12388 	uint16_t vf_id;
12389 	uint8_t tc_no;
12390 	uint32_t bw;
12391 	cmdline_fixed_string_t bw_list;
12392 	uint8_t tc_map;
12393 };
12394 
12395 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12396 	TOKEN_STRING_INITIALIZER
12397 		(struct cmd_vf_tc_bw_result,
12398 		 set, "set");
12399 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12400 	TOKEN_STRING_INITIALIZER
12401 		(struct cmd_vf_tc_bw_result,
12402 		 vf, "vf");
12403 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12404 	TOKEN_STRING_INITIALIZER
12405 		(struct cmd_vf_tc_bw_result,
12406 		 tc, "tc");
12407 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12408 	TOKEN_STRING_INITIALIZER
12409 		(struct cmd_vf_tc_bw_result,
12410 		 tx, "tx");
12411 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12412 	TOKEN_STRING_INITIALIZER
12413 		(struct cmd_vf_tc_bw_result,
12414 		 strict_link_prio, "strict-link-priority");
12415 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12416 	TOKEN_STRING_INITIALIZER
12417 		(struct cmd_vf_tc_bw_result,
12418 		 min_bw, "min-bandwidth");
12419 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12420 	TOKEN_STRING_INITIALIZER
12421 		(struct cmd_vf_tc_bw_result,
12422 		 max_bw, "max-bandwidth");
12423 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12424 	TOKEN_NUM_INITIALIZER
12425 		(struct cmd_vf_tc_bw_result,
12426 		 port_id, RTE_UINT16);
12427 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12428 	TOKEN_NUM_INITIALIZER
12429 		(struct cmd_vf_tc_bw_result,
12430 		 vf_id, RTE_UINT16);
12431 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12432 	TOKEN_NUM_INITIALIZER
12433 		(struct cmd_vf_tc_bw_result,
12434 		 tc_no, RTE_UINT8);
12435 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12436 	TOKEN_NUM_INITIALIZER
12437 		(struct cmd_vf_tc_bw_result,
12438 		 bw, RTE_UINT32);
12439 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12440 	TOKEN_STRING_INITIALIZER
12441 		(struct cmd_vf_tc_bw_result,
12442 		 bw_list, NULL);
12443 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12444 	TOKEN_NUM_INITIALIZER
12445 		(struct cmd_vf_tc_bw_result,
12446 		 tc_map, RTE_UINT8);
12447 
12448 /* VF max bandwidth setting */
12449 static void
12450 cmd_vf_max_bw_parsed(
12451 	void *parsed_result,
12452 	__rte_unused struct cmdline *cl,
12453 	__rte_unused void *data)
12454 {
12455 	struct cmd_vf_tc_bw_result *res = parsed_result;
12456 	int ret = -ENOTSUP;
12457 
12458 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12459 		return;
12460 
12461 #ifdef RTE_NET_I40E
12462 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12463 					 res->vf_id, res->bw);
12464 #endif
12465 
12466 	switch (ret) {
12467 	case 0:
12468 		break;
12469 	case -EINVAL:
12470 		printf("invalid vf_id %d or bandwidth %d\n",
12471 		       res->vf_id, res->bw);
12472 		break;
12473 	case -ENODEV:
12474 		printf("invalid port_id %d\n", res->port_id);
12475 		break;
12476 	case -ENOTSUP:
12477 		printf("function not implemented\n");
12478 		break;
12479 	default:
12480 		printf("programming error: (%s)\n", strerror(-ret));
12481 	}
12482 }
12483 
12484 cmdline_parse_inst_t cmd_vf_max_bw = {
12485 	.f = cmd_vf_max_bw_parsed,
12486 	.data = NULL,
12487 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12488 	.tokens = {
12489 		(void *)&cmd_vf_tc_bw_set,
12490 		(void *)&cmd_vf_tc_bw_vf,
12491 		(void *)&cmd_vf_tc_bw_tx,
12492 		(void *)&cmd_vf_tc_bw_max_bw,
12493 		(void *)&cmd_vf_tc_bw_port_id,
12494 		(void *)&cmd_vf_tc_bw_vf_id,
12495 		(void *)&cmd_vf_tc_bw_bw,
12496 		NULL,
12497 	},
12498 };
12499 
12500 static int
12501 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12502 			   uint8_t *tc_num,
12503 			   char *str)
12504 {
12505 	uint32_t size;
12506 	const char *p, *p0 = str;
12507 	char s[256];
12508 	char *end;
12509 	char *str_fld[16];
12510 	uint16_t i;
12511 	int ret;
12512 
12513 	p = strchr(p0, '(');
12514 	if (p == NULL) {
12515 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12516 		return -1;
12517 	}
12518 	p++;
12519 	p0 = strchr(p, ')');
12520 	if (p0 == NULL) {
12521 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12522 		return -1;
12523 	}
12524 	size = p0 - p;
12525 	if (size >= sizeof(s)) {
12526 		printf("The string size exceeds the internal buffer size\n");
12527 		return -1;
12528 	}
12529 	snprintf(s, sizeof(s), "%.*s", size, p);
12530 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12531 	if (ret <= 0) {
12532 		printf("Failed to get the bandwidth list. ");
12533 		return -1;
12534 	}
12535 	*tc_num = ret;
12536 	for (i = 0; i < ret; i++)
12537 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12538 
12539 	return 0;
12540 }
12541 
12542 /* TC min bandwidth setting */
12543 static void
12544 cmd_vf_tc_min_bw_parsed(
12545 	void *parsed_result,
12546 	__rte_unused struct cmdline *cl,
12547 	__rte_unused void *data)
12548 {
12549 	struct cmd_vf_tc_bw_result *res = parsed_result;
12550 	uint8_t tc_num;
12551 	uint8_t bw[16];
12552 	int ret = -ENOTSUP;
12553 
12554 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12555 		return;
12556 
12557 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12558 	if (ret)
12559 		return;
12560 
12561 #ifdef RTE_NET_I40E
12562 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12563 					      tc_num, bw);
12564 #endif
12565 
12566 	switch (ret) {
12567 	case 0:
12568 		break;
12569 	case -EINVAL:
12570 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12571 		break;
12572 	case -ENODEV:
12573 		printf("invalid port_id %d\n", res->port_id);
12574 		break;
12575 	case -ENOTSUP:
12576 		printf("function not implemented\n");
12577 		break;
12578 	default:
12579 		printf("programming error: (%s)\n", strerror(-ret));
12580 	}
12581 }
12582 
12583 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12584 	.f = cmd_vf_tc_min_bw_parsed,
12585 	.data = NULL,
12586 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12587 		    " <bw1, bw2, ...>",
12588 	.tokens = {
12589 		(void *)&cmd_vf_tc_bw_set,
12590 		(void *)&cmd_vf_tc_bw_vf,
12591 		(void *)&cmd_vf_tc_bw_tc,
12592 		(void *)&cmd_vf_tc_bw_tx,
12593 		(void *)&cmd_vf_tc_bw_min_bw,
12594 		(void *)&cmd_vf_tc_bw_port_id,
12595 		(void *)&cmd_vf_tc_bw_vf_id,
12596 		(void *)&cmd_vf_tc_bw_bw_list,
12597 		NULL,
12598 	},
12599 };
12600 
12601 static void
12602 cmd_tc_min_bw_parsed(
12603 	void *parsed_result,
12604 	__rte_unused struct cmdline *cl,
12605 	__rte_unused void *data)
12606 {
12607 	struct cmd_vf_tc_bw_result *res = parsed_result;
12608 	struct rte_port *port;
12609 	uint8_t tc_num;
12610 	uint8_t bw[16];
12611 	int ret = -ENOTSUP;
12612 
12613 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12614 		return;
12615 
12616 	port = &ports[res->port_id];
12617 	/** Check if the port is not started **/
12618 	if (port->port_status != RTE_PORT_STOPPED) {
12619 		printf("Please stop port %d first\n", res->port_id);
12620 		return;
12621 	}
12622 
12623 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12624 	if (ret)
12625 		return;
12626 
12627 #ifdef RTE_NET_IXGBE
12628 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12629 #endif
12630 
12631 	switch (ret) {
12632 	case 0:
12633 		break;
12634 	case -EINVAL:
12635 		printf("invalid bandwidth\n");
12636 		break;
12637 	case -ENODEV:
12638 		printf("invalid port_id %d\n", res->port_id);
12639 		break;
12640 	case -ENOTSUP:
12641 		printf("function not implemented\n");
12642 		break;
12643 	default:
12644 		printf("programming error: (%s)\n", strerror(-ret));
12645 	}
12646 }
12647 
12648 cmdline_parse_inst_t cmd_tc_min_bw = {
12649 	.f = cmd_tc_min_bw_parsed,
12650 	.data = NULL,
12651 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12652 	.tokens = {
12653 		(void *)&cmd_vf_tc_bw_set,
12654 		(void *)&cmd_vf_tc_bw_tc,
12655 		(void *)&cmd_vf_tc_bw_tx,
12656 		(void *)&cmd_vf_tc_bw_min_bw,
12657 		(void *)&cmd_vf_tc_bw_port_id,
12658 		(void *)&cmd_vf_tc_bw_bw_list,
12659 		NULL,
12660 	},
12661 };
12662 
12663 /* TC max bandwidth setting */
12664 static void
12665 cmd_vf_tc_max_bw_parsed(
12666 	void *parsed_result,
12667 	__rte_unused struct cmdline *cl,
12668 	__rte_unused void *data)
12669 {
12670 	struct cmd_vf_tc_bw_result *res = parsed_result;
12671 	int ret = -ENOTSUP;
12672 
12673 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12674 		return;
12675 
12676 #ifdef RTE_NET_I40E
12677 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12678 					    res->tc_no, res->bw);
12679 #endif
12680 
12681 	switch (ret) {
12682 	case 0:
12683 		break;
12684 	case -EINVAL:
12685 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12686 		       res->vf_id, res->tc_no, res->bw);
12687 		break;
12688 	case -ENODEV:
12689 		printf("invalid port_id %d\n", res->port_id);
12690 		break;
12691 	case -ENOTSUP:
12692 		printf("function not implemented\n");
12693 		break;
12694 	default:
12695 		printf("programming error: (%s)\n", strerror(-ret));
12696 	}
12697 }
12698 
12699 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12700 	.f = cmd_vf_tc_max_bw_parsed,
12701 	.data = NULL,
12702 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12703 		    " <bandwidth>",
12704 	.tokens = {
12705 		(void *)&cmd_vf_tc_bw_set,
12706 		(void *)&cmd_vf_tc_bw_vf,
12707 		(void *)&cmd_vf_tc_bw_tc,
12708 		(void *)&cmd_vf_tc_bw_tx,
12709 		(void *)&cmd_vf_tc_bw_max_bw,
12710 		(void *)&cmd_vf_tc_bw_port_id,
12711 		(void *)&cmd_vf_tc_bw_vf_id,
12712 		(void *)&cmd_vf_tc_bw_tc_no,
12713 		(void *)&cmd_vf_tc_bw_bw,
12714 		NULL,
12715 	},
12716 };
12717 
12718 /** Set VXLAN encapsulation details */
12719 struct cmd_set_vxlan_result {
12720 	cmdline_fixed_string_t set;
12721 	cmdline_fixed_string_t vxlan;
12722 	cmdline_fixed_string_t pos_token;
12723 	cmdline_fixed_string_t ip_version;
12724 	uint32_t vlan_present:1;
12725 	uint32_t vni;
12726 	uint16_t udp_src;
12727 	uint16_t udp_dst;
12728 	cmdline_ipaddr_t ip_src;
12729 	cmdline_ipaddr_t ip_dst;
12730 	uint16_t tci;
12731 	uint8_t tos;
12732 	uint8_t ttl;
12733 	struct rte_ether_addr eth_src;
12734 	struct rte_ether_addr eth_dst;
12735 };
12736 
12737 cmdline_parse_token_string_t cmd_set_vxlan_set =
12738 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12739 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12740 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12741 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12742 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12743 				 "vxlan-tos-ttl");
12744 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12745 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12746 				 "vxlan-with-vlan");
12747 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12748 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12749 				 "ip-version");
12750 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12751 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12752 				 "ipv4#ipv6");
12753 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12754 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12755 				 "vni");
12756 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12757 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12758 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12759 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12760 				 "udp-src");
12761 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12762 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12763 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12764 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12765 				 "udp-dst");
12766 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12767 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12768 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12769 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12770 				 "ip-tos");
12771 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12772 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12773 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12774 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12775 				 "ip-ttl");
12776 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12777 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12778 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12779 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12780 				 "ip-src");
12781 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12782 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12783 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12784 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12785 				 "ip-dst");
12786 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12787 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12788 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12789 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12790 				 "vlan-tci");
12791 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12792 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12793 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12794 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12795 				 "eth-src");
12796 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12797 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12798 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12799 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12800 				 "eth-dst");
12801 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12802 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12803 
12804 static void cmd_set_vxlan_parsed(void *parsed_result,
12805 	__rte_unused struct cmdline *cl,
12806 	__rte_unused void *data)
12807 {
12808 	struct cmd_set_vxlan_result *res = parsed_result;
12809 	union {
12810 		uint32_t vxlan_id;
12811 		uint8_t vni[4];
12812 	} id = {
12813 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12814 	};
12815 
12816 	vxlan_encap_conf.select_tos_ttl = 0;
12817 	if (strcmp(res->vxlan, "vxlan") == 0)
12818 		vxlan_encap_conf.select_vlan = 0;
12819 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12820 		vxlan_encap_conf.select_vlan = 1;
12821 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12822 		vxlan_encap_conf.select_vlan = 0;
12823 		vxlan_encap_conf.select_tos_ttl = 1;
12824 	}
12825 	if (strcmp(res->ip_version, "ipv4") == 0)
12826 		vxlan_encap_conf.select_ipv4 = 1;
12827 	else if (strcmp(res->ip_version, "ipv6") == 0)
12828 		vxlan_encap_conf.select_ipv4 = 0;
12829 	else
12830 		return;
12831 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12832 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12833 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12834 	vxlan_encap_conf.ip_tos = res->tos;
12835 	vxlan_encap_conf.ip_ttl = res->ttl;
12836 	if (vxlan_encap_conf.select_ipv4) {
12837 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12838 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12839 	} else {
12840 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12841 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12842 	}
12843 	if (vxlan_encap_conf.select_vlan)
12844 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12845 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12846 		   RTE_ETHER_ADDR_LEN);
12847 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12848 		   RTE_ETHER_ADDR_LEN);
12849 }
12850 
12851 cmdline_parse_inst_t cmd_set_vxlan = {
12852 	.f = cmd_set_vxlan_parsed,
12853 	.data = NULL,
12854 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12855 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12856 		" eth-src <eth-src> eth-dst <eth-dst>",
12857 	.tokens = {
12858 		(void *)&cmd_set_vxlan_set,
12859 		(void *)&cmd_set_vxlan_vxlan,
12860 		(void *)&cmd_set_vxlan_ip_version,
12861 		(void *)&cmd_set_vxlan_ip_version_value,
12862 		(void *)&cmd_set_vxlan_vni,
12863 		(void *)&cmd_set_vxlan_vni_value,
12864 		(void *)&cmd_set_vxlan_udp_src,
12865 		(void *)&cmd_set_vxlan_udp_src_value,
12866 		(void *)&cmd_set_vxlan_udp_dst,
12867 		(void *)&cmd_set_vxlan_udp_dst_value,
12868 		(void *)&cmd_set_vxlan_ip_src,
12869 		(void *)&cmd_set_vxlan_ip_src_value,
12870 		(void *)&cmd_set_vxlan_ip_dst,
12871 		(void *)&cmd_set_vxlan_ip_dst_value,
12872 		(void *)&cmd_set_vxlan_eth_src,
12873 		(void *)&cmd_set_vxlan_eth_src_value,
12874 		(void *)&cmd_set_vxlan_eth_dst,
12875 		(void *)&cmd_set_vxlan_eth_dst_value,
12876 		NULL,
12877 	},
12878 };
12879 
12880 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12881 	.f = cmd_set_vxlan_parsed,
12882 	.data = NULL,
12883 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12884 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12885 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12886 		" eth-dst <eth-dst>",
12887 	.tokens = {
12888 		(void *)&cmd_set_vxlan_set,
12889 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
12890 		(void *)&cmd_set_vxlan_ip_version,
12891 		(void *)&cmd_set_vxlan_ip_version_value,
12892 		(void *)&cmd_set_vxlan_vni,
12893 		(void *)&cmd_set_vxlan_vni_value,
12894 		(void *)&cmd_set_vxlan_udp_src,
12895 		(void *)&cmd_set_vxlan_udp_src_value,
12896 		(void *)&cmd_set_vxlan_udp_dst,
12897 		(void *)&cmd_set_vxlan_udp_dst_value,
12898 		(void *)&cmd_set_vxlan_ip_tos,
12899 		(void *)&cmd_set_vxlan_ip_tos_value,
12900 		(void *)&cmd_set_vxlan_ip_ttl,
12901 		(void *)&cmd_set_vxlan_ip_ttl_value,
12902 		(void *)&cmd_set_vxlan_ip_src,
12903 		(void *)&cmd_set_vxlan_ip_src_value,
12904 		(void *)&cmd_set_vxlan_ip_dst,
12905 		(void *)&cmd_set_vxlan_ip_dst_value,
12906 		(void *)&cmd_set_vxlan_eth_src,
12907 		(void *)&cmd_set_vxlan_eth_src_value,
12908 		(void *)&cmd_set_vxlan_eth_dst,
12909 		(void *)&cmd_set_vxlan_eth_dst_value,
12910 		NULL,
12911 	},
12912 };
12913 
12914 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12915 	.f = cmd_set_vxlan_parsed,
12916 	.data = NULL,
12917 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12918 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12919 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12920 		" <eth-dst>",
12921 	.tokens = {
12922 		(void *)&cmd_set_vxlan_set,
12923 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
12924 		(void *)&cmd_set_vxlan_ip_version,
12925 		(void *)&cmd_set_vxlan_ip_version_value,
12926 		(void *)&cmd_set_vxlan_vni,
12927 		(void *)&cmd_set_vxlan_vni_value,
12928 		(void *)&cmd_set_vxlan_udp_src,
12929 		(void *)&cmd_set_vxlan_udp_src_value,
12930 		(void *)&cmd_set_vxlan_udp_dst,
12931 		(void *)&cmd_set_vxlan_udp_dst_value,
12932 		(void *)&cmd_set_vxlan_ip_src,
12933 		(void *)&cmd_set_vxlan_ip_src_value,
12934 		(void *)&cmd_set_vxlan_ip_dst,
12935 		(void *)&cmd_set_vxlan_ip_dst_value,
12936 		(void *)&cmd_set_vxlan_vlan,
12937 		(void *)&cmd_set_vxlan_vlan_value,
12938 		(void *)&cmd_set_vxlan_eth_src,
12939 		(void *)&cmd_set_vxlan_eth_src_value,
12940 		(void *)&cmd_set_vxlan_eth_dst,
12941 		(void *)&cmd_set_vxlan_eth_dst_value,
12942 		NULL,
12943 	},
12944 };
12945 
12946 /** Set NVGRE encapsulation details */
12947 struct cmd_set_nvgre_result {
12948 	cmdline_fixed_string_t set;
12949 	cmdline_fixed_string_t nvgre;
12950 	cmdline_fixed_string_t pos_token;
12951 	cmdline_fixed_string_t ip_version;
12952 	uint32_t tni;
12953 	cmdline_ipaddr_t ip_src;
12954 	cmdline_ipaddr_t ip_dst;
12955 	uint16_t tci;
12956 	struct rte_ether_addr eth_src;
12957 	struct rte_ether_addr eth_dst;
12958 };
12959 
12960 cmdline_parse_token_string_t cmd_set_nvgre_set =
12961 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12962 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12963 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12964 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12965 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12966 				 "nvgre-with-vlan");
12967 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12968 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12969 				 "ip-version");
12970 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12971 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12972 				 "ipv4#ipv6");
12973 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12974 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12975 				 "tni");
12976 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12977 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12978 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12979 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12980 				 "ip-src");
12981 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12982 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12983 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12984 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12985 				 "ip-dst");
12986 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12987 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12988 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12989 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12990 				 "vlan-tci");
12991 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12992 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12993 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12994 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12995 				 "eth-src");
12996 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12997 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12998 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12999 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13000 				 "eth-dst");
13001 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13002 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13003 
13004 static void cmd_set_nvgre_parsed(void *parsed_result,
13005 	__rte_unused struct cmdline *cl,
13006 	__rte_unused void *data)
13007 {
13008 	struct cmd_set_nvgre_result *res = parsed_result;
13009 	union {
13010 		uint32_t nvgre_tni;
13011 		uint8_t tni[4];
13012 	} id = {
13013 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13014 	};
13015 
13016 	if (strcmp(res->nvgre, "nvgre") == 0)
13017 		nvgre_encap_conf.select_vlan = 0;
13018 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13019 		nvgre_encap_conf.select_vlan = 1;
13020 	if (strcmp(res->ip_version, "ipv4") == 0)
13021 		nvgre_encap_conf.select_ipv4 = 1;
13022 	else if (strcmp(res->ip_version, "ipv6") == 0)
13023 		nvgre_encap_conf.select_ipv4 = 0;
13024 	else
13025 		return;
13026 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13027 	if (nvgre_encap_conf.select_ipv4) {
13028 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13029 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13030 	} else {
13031 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13032 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13033 	}
13034 	if (nvgre_encap_conf.select_vlan)
13035 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13036 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13037 		   RTE_ETHER_ADDR_LEN);
13038 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13039 		   RTE_ETHER_ADDR_LEN);
13040 }
13041 
13042 cmdline_parse_inst_t cmd_set_nvgre = {
13043 	.f = cmd_set_nvgre_parsed,
13044 	.data = NULL,
13045 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13046 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13047 		" eth-dst <eth-dst>",
13048 	.tokens = {
13049 		(void *)&cmd_set_nvgre_set,
13050 		(void *)&cmd_set_nvgre_nvgre,
13051 		(void *)&cmd_set_nvgre_ip_version,
13052 		(void *)&cmd_set_nvgre_ip_version_value,
13053 		(void *)&cmd_set_nvgre_tni,
13054 		(void *)&cmd_set_nvgre_tni_value,
13055 		(void *)&cmd_set_nvgre_ip_src,
13056 		(void *)&cmd_set_nvgre_ip_src_value,
13057 		(void *)&cmd_set_nvgre_ip_dst,
13058 		(void *)&cmd_set_nvgre_ip_dst_value,
13059 		(void *)&cmd_set_nvgre_eth_src,
13060 		(void *)&cmd_set_nvgre_eth_src_value,
13061 		(void *)&cmd_set_nvgre_eth_dst,
13062 		(void *)&cmd_set_nvgre_eth_dst_value,
13063 		NULL,
13064 	},
13065 };
13066 
13067 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13068 	.f = cmd_set_nvgre_parsed,
13069 	.data = NULL,
13070 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13071 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13072 		" eth-src <eth-src> eth-dst <eth-dst>",
13073 	.tokens = {
13074 		(void *)&cmd_set_nvgre_set,
13075 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
13076 		(void *)&cmd_set_nvgre_ip_version,
13077 		(void *)&cmd_set_nvgre_ip_version_value,
13078 		(void *)&cmd_set_nvgre_tni,
13079 		(void *)&cmd_set_nvgre_tni_value,
13080 		(void *)&cmd_set_nvgre_ip_src,
13081 		(void *)&cmd_set_nvgre_ip_src_value,
13082 		(void *)&cmd_set_nvgre_ip_dst,
13083 		(void *)&cmd_set_nvgre_ip_dst_value,
13084 		(void *)&cmd_set_nvgre_vlan,
13085 		(void *)&cmd_set_nvgre_vlan_value,
13086 		(void *)&cmd_set_nvgre_eth_src,
13087 		(void *)&cmd_set_nvgre_eth_src_value,
13088 		(void *)&cmd_set_nvgre_eth_dst,
13089 		(void *)&cmd_set_nvgre_eth_dst_value,
13090 		NULL,
13091 	},
13092 };
13093 
13094 /** Set L2 encapsulation details */
13095 struct cmd_set_l2_encap_result {
13096 	cmdline_fixed_string_t set;
13097 	cmdline_fixed_string_t l2_encap;
13098 	cmdline_fixed_string_t pos_token;
13099 	cmdline_fixed_string_t ip_version;
13100 	uint32_t vlan_present:1;
13101 	uint16_t tci;
13102 	struct rte_ether_addr eth_src;
13103 	struct rte_ether_addr eth_dst;
13104 };
13105 
13106 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13107 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13108 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13109 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13110 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13111 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13112 				 "l2_encap-with-vlan");
13113 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13114 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13115 				 "ip-version");
13116 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13117 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13118 				 "ipv4#ipv6");
13119 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13120 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13121 				 "vlan-tci");
13122 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13123 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13124 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13125 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13126 				 "eth-src");
13127 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13128 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13129 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13130 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13131 				 "eth-dst");
13132 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13133 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13134 
13135 static void cmd_set_l2_encap_parsed(void *parsed_result,
13136 	__rte_unused struct cmdline *cl,
13137 	__rte_unused void *data)
13138 {
13139 	struct cmd_set_l2_encap_result *res = parsed_result;
13140 
13141 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13142 		l2_encap_conf.select_vlan = 0;
13143 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13144 		l2_encap_conf.select_vlan = 1;
13145 	if (strcmp(res->ip_version, "ipv4") == 0)
13146 		l2_encap_conf.select_ipv4 = 1;
13147 	else if (strcmp(res->ip_version, "ipv6") == 0)
13148 		l2_encap_conf.select_ipv4 = 0;
13149 	else
13150 		return;
13151 	if (l2_encap_conf.select_vlan)
13152 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13153 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13154 		   RTE_ETHER_ADDR_LEN);
13155 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13156 		   RTE_ETHER_ADDR_LEN);
13157 }
13158 
13159 cmdline_parse_inst_t cmd_set_l2_encap = {
13160 	.f = cmd_set_l2_encap_parsed,
13161 	.data = NULL,
13162 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13163 		" eth-src <eth-src> eth-dst <eth-dst>",
13164 	.tokens = {
13165 		(void *)&cmd_set_l2_encap_set,
13166 		(void *)&cmd_set_l2_encap_l2_encap,
13167 		(void *)&cmd_set_l2_encap_ip_version,
13168 		(void *)&cmd_set_l2_encap_ip_version_value,
13169 		(void *)&cmd_set_l2_encap_eth_src,
13170 		(void *)&cmd_set_l2_encap_eth_src_value,
13171 		(void *)&cmd_set_l2_encap_eth_dst,
13172 		(void *)&cmd_set_l2_encap_eth_dst_value,
13173 		NULL,
13174 	},
13175 };
13176 
13177 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13178 	.f = cmd_set_l2_encap_parsed,
13179 	.data = NULL,
13180 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13181 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13182 	.tokens = {
13183 		(void *)&cmd_set_l2_encap_set,
13184 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13185 		(void *)&cmd_set_l2_encap_ip_version,
13186 		(void *)&cmd_set_l2_encap_ip_version_value,
13187 		(void *)&cmd_set_l2_encap_vlan,
13188 		(void *)&cmd_set_l2_encap_vlan_value,
13189 		(void *)&cmd_set_l2_encap_eth_src,
13190 		(void *)&cmd_set_l2_encap_eth_src_value,
13191 		(void *)&cmd_set_l2_encap_eth_dst,
13192 		(void *)&cmd_set_l2_encap_eth_dst_value,
13193 		NULL,
13194 	},
13195 };
13196 
13197 /** Set L2 decapsulation details */
13198 struct cmd_set_l2_decap_result {
13199 	cmdline_fixed_string_t set;
13200 	cmdline_fixed_string_t l2_decap;
13201 	cmdline_fixed_string_t pos_token;
13202 	uint32_t vlan_present:1;
13203 };
13204 
13205 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13206 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13207 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13208 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13209 				 "l2_decap");
13210 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13211 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13212 				 "l2_decap-with-vlan");
13213 
13214 static void cmd_set_l2_decap_parsed(void *parsed_result,
13215 	__rte_unused struct cmdline *cl,
13216 	__rte_unused void *data)
13217 {
13218 	struct cmd_set_l2_decap_result *res = parsed_result;
13219 
13220 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13221 		l2_decap_conf.select_vlan = 0;
13222 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13223 		l2_decap_conf.select_vlan = 1;
13224 }
13225 
13226 cmdline_parse_inst_t cmd_set_l2_decap = {
13227 	.f = cmd_set_l2_decap_parsed,
13228 	.data = NULL,
13229 	.help_str = "set l2_decap",
13230 	.tokens = {
13231 		(void *)&cmd_set_l2_decap_set,
13232 		(void *)&cmd_set_l2_decap_l2_decap,
13233 		NULL,
13234 	},
13235 };
13236 
13237 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13238 	.f = cmd_set_l2_decap_parsed,
13239 	.data = NULL,
13240 	.help_str = "set l2_decap-with-vlan",
13241 	.tokens = {
13242 		(void *)&cmd_set_l2_decap_set,
13243 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13244 		NULL,
13245 	},
13246 };
13247 
13248 /** Set MPLSoGRE encapsulation details */
13249 struct cmd_set_mplsogre_encap_result {
13250 	cmdline_fixed_string_t set;
13251 	cmdline_fixed_string_t mplsogre;
13252 	cmdline_fixed_string_t pos_token;
13253 	cmdline_fixed_string_t ip_version;
13254 	uint32_t vlan_present:1;
13255 	uint32_t label;
13256 	cmdline_ipaddr_t ip_src;
13257 	cmdline_ipaddr_t ip_dst;
13258 	uint16_t tci;
13259 	struct rte_ether_addr eth_src;
13260 	struct rte_ether_addr eth_dst;
13261 };
13262 
13263 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13264 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13265 				 "set");
13266 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13267 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13268 				 "mplsogre_encap");
13269 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13270 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13271 				 mplsogre, "mplsogre_encap-with-vlan");
13272 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13273 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13274 				 pos_token, "ip-version");
13275 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13276 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13277 				 ip_version, "ipv4#ipv6");
13278 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13279 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13280 				 pos_token, "label");
13281 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13282 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13283 			      RTE_UINT32);
13284 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13285 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13286 				 pos_token, "ip-src");
13287 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13288 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13289 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13290 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13291 				 pos_token, "ip-dst");
13292 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13293 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13294 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13295 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13296 				 pos_token, "vlan-tci");
13297 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13298 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13299 			      RTE_UINT16);
13300 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13301 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13302 				 pos_token, "eth-src");
13303 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13304 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13305 				    eth_src);
13306 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13307 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13308 				 pos_token, "eth-dst");
13309 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13310 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13311 				    eth_dst);
13312 
13313 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13314 	__rte_unused struct cmdline *cl,
13315 	__rte_unused void *data)
13316 {
13317 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13318 	union {
13319 		uint32_t mplsogre_label;
13320 		uint8_t label[4];
13321 	} id = {
13322 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13323 	};
13324 
13325 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13326 		mplsogre_encap_conf.select_vlan = 0;
13327 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13328 		mplsogre_encap_conf.select_vlan = 1;
13329 	if (strcmp(res->ip_version, "ipv4") == 0)
13330 		mplsogre_encap_conf.select_ipv4 = 1;
13331 	else if (strcmp(res->ip_version, "ipv6") == 0)
13332 		mplsogre_encap_conf.select_ipv4 = 0;
13333 	else
13334 		return;
13335 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13336 	if (mplsogre_encap_conf.select_ipv4) {
13337 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13338 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13339 	} else {
13340 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13341 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13342 	}
13343 	if (mplsogre_encap_conf.select_vlan)
13344 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13345 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13346 		   RTE_ETHER_ADDR_LEN);
13347 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13348 		   RTE_ETHER_ADDR_LEN);
13349 }
13350 
13351 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13352 	.f = cmd_set_mplsogre_encap_parsed,
13353 	.data = NULL,
13354 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13355 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13356 		" eth-dst <eth-dst>",
13357 	.tokens = {
13358 		(void *)&cmd_set_mplsogre_encap_set,
13359 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13360 		(void *)&cmd_set_mplsogre_encap_ip_version,
13361 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13362 		(void *)&cmd_set_mplsogre_encap_label,
13363 		(void *)&cmd_set_mplsogre_encap_label_value,
13364 		(void *)&cmd_set_mplsogre_encap_ip_src,
13365 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13366 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13367 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13368 		(void *)&cmd_set_mplsogre_encap_eth_src,
13369 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13370 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13371 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13372 		NULL,
13373 	},
13374 };
13375 
13376 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13377 	.f = cmd_set_mplsogre_encap_parsed,
13378 	.data = NULL,
13379 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13380 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13381 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13382 	.tokens = {
13383 		(void *)&cmd_set_mplsogre_encap_set,
13384 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13385 		(void *)&cmd_set_mplsogre_encap_ip_version,
13386 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13387 		(void *)&cmd_set_mplsogre_encap_label,
13388 		(void *)&cmd_set_mplsogre_encap_label_value,
13389 		(void *)&cmd_set_mplsogre_encap_ip_src,
13390 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13391 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13392 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13393 		(void *)&cmd_set_mplsogre_encap_vlan,
13394 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13395 		(void *)&cmd_set_mplsogre_encap_eth_src,
13396 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13397 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13398 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13399 		NULL,
13400 	},
13401 };
13402 
13403 /** Set MPLSoGRE decapsulation details */
13404 struct cmd_set_mplsogre_decap_result {
13405 	cmdline_fixed_string_t set;
13406 	cmdline_fixed_string_t mplsogre;
13407 	cmdline_fixed_string_t pos_token;
13408 	cmdline_fixed_string_t ip_version;
13409 	uint32_t vlan_present:1;
13410 };
13411 
13412 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13413 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13414 				 "set");
13415 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13416 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13417 				 "mplsogre_decap");
13418 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13419 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13420 				 mplsogre, "mplsogre_decap-with-vlan");
13421 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13422 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13423 				 pos_token, "ip-version");
13424 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13425 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13426 				 ip_version, "ipv4#ipv6");
13427 
13428 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13429 	__rte_unused struct cmdline *cl,
13430 	__rte_unused void *data)
13431 {
13432 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13433 
13434 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13435 		mplsogre_decap_conf.select_vlan = 0;
13436 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13437 		mplsogre_decap_conf.select_vlan = 1;
13438 	if (strcmp(res->ip_version, "ipv4") == 0)
13439 		mplsogre_decap_conf.select_ipv4 = 1;
13440 	else if (strcmp(res->ip_version, "ipv6") == 0)
13441 		mplsogre_decap_conf.select_ipv4 = 0;
13442 }
13443 
13444 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13445 	.f = cmd_set_mplsogre_decap_parsed,
13446 	.data = NULL,
13447 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13448 	.tokens = {
13449 		(void *)&cmd_set_mplsogre_decap_set,
13450 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13451 		(void *)&cmd_set_mplsogre_decap_ip_version,
13452 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13453 		NULL,
13454 	},
13455 };
13456 
13457 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13458 	.f = cmd_set_mplsogre_decap_parsed,
13459 	.data = NULL,
13460 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13461 	.tokens = {
13462 		(void *)&cmd_set_mplsogre_decap_set,
13463 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13464 		(void *)&cmd_set_mplsogre_decap_ip_version,
13465 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13466 		NULL,
13467 	},
13468 };
13469 
13470 /** Set MPLSoUDP encapsulation details */
13471 struct cmd_set_mplsoudp_encap_result {
13472 	cmdline_fixed_string_t set;
13473 	cmdline_fixed_string_t mplsoudp;
13474 	cmdline_fixed_string_t pos_token;
13475 	cmdline_fixed_string_t ip_version;
13476 	uint32_t vlan_present:1;
13477 	uint32_t label;
13478 	uint16_t udp_src;
13479 	uint16_t udp_dst;
13480 	cmdline_ipaddr_t ip_src;
13481 	cmdline_ipaddr_t ip_dst;
13482 	uint16_t tci;
13483 	struct rte_ether_addr eth_src;
13484 	struct rte_ether_addr eth_dst;
13485 };
13486 
13487 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13488 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13489 				 "set");
13490 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13491 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13492 				 "mplsoudp_encap");
13493 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13494 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13495 				 mplsoudp, "mplsoudp_encap-with-vlan");
13496 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13497 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13498 				 pos_token, "ip-version");
13499 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13500 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13501 				 ip_version, "ipv4#ipv6");
13502 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13503 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13504 				 pos_token, "label");
13505 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13506 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13507 			      RTE_UINT32);
13508 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13509 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13510 				 pos_token, "udp-src");
13511 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13512 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13513 			      RTE_UINT16);
13514 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13515 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13516 				 pos_token, "udp-dst");
13517 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13518 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13519 			      RTE_UINT16);
13520 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13521 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13522 				 pos_token, "ip-src");
13523 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13524 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13525 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13526 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13527 				 pos_token, "ip-dst");
13528 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13529 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13530 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13531 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13532 				 pos_token, "vlan-tci");
13533 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13534 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13535 			      RTE_UINT16);
13536 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13537 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13538 				 pos_token, "eth-src");
13539 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13540 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13541 				    eth_src);
13542 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13543 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13544 				 pos_token, "eth-dst");
13545 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13546 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13547 				    eth_dst);
13548 
13549 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13550 	__rte_unused struct cmdline *cl,
13551 	__rte_unused void *data)
13552 {
13553 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13554 	union {
13555 		uint32_t mplsoudp_label;
13556 		uint8_t label[4];
13557 	} id = {
13558 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13559 	};
13560 
13561 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13562 		mplsoudp_encap_conf.select_vlan = 0;
13563 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13564 		mplsoudp_encap_conf.select_vlan = 1;
13565 	if (strcmp(res->ip_version, "ipv4") == 0)
13566 		mplsoudp_encap_conf.select_ipv4 = 1;
13567 	else if (strcmp(res->ip_version, "ipv6") == 0)
13568 		mplsoudp_encap_conf.select_ipv4 = 0;
13569 	else
13570 		return;
13571 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13572 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13573 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13574 	if (mplsoudp_encap_conf.select_ipv4) {
13575 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13576 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13577 	} else {
13578 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13579 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13580 	}
13581 	if (mplsoudp_encap_conf.select_vlan)
13582 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13583 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13584 		   RTE_ETHER_ADDR_LEN);
13585 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13586 		   RTE_ETHER_ADDR_LEN);
13587 }
13588 
13589 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13590 	.f = cmd_set_mplsoudp_encap_parsed,
13591 	.data = NULL,
13592 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13593 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13594 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13595 	.tokens = {
13596 		(void *)&cmd_set_mplsoudp_encap_set,
13597 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13598 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13599 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13600 		(void *)&cmd_set_mplsoudp_encap_label,
13601 		(void *)&cmd_set_mplsoudp_encap_label_value,
13602 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13603 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13604 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13605 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13606 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13607 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13608 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13609 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13610 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13611 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13612 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13613 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13614 		NULL,
13615 	},
13616 };
13617 
13618 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13619 	.f = cmd_set_mplsoudp_encap_parsed,
13620 	.data = NULL,
13621 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13622 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13623 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13624 		" eth-src <eth-src> eth-dst <eth-dst>",
13625 	.tokens = {
13626 		(void *)&cmd_set_mplsoudp_encap_set,
13627 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13628 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13629 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13630 		(void *)&cmd_set_mplsoudp_encap_label,
13631 		(void *)&cmd_set_mplsoudp_encap_label_value,
13632 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13633 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13634 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13635 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13636 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13637 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13638 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13639 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13640 		(void *)&cmd_set_mplsoudp_encap_vlan,
13641 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13642 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13643 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13644 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13645 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13646 		NULL,
13647 	},
13648 };
13649 
13650 /** Set MPLSoUDP decapsulation details */
13651 struct cmd_set_mplsoudp_decap_result {
13652 	cmdline_fixed_string_t set;
13653 	cmdline_fixed_string_t mplsoudp;
13654 	cmdline_fixed_string_t pos_token;
13655 	cmdline_fixed_string_t ip_version;
13656 	uint32_t vlan_present:1;
13657 };
13658 
13659 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13660 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13661 				 "set");
13662 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13663 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13664 				 "mplsoudp_decap");
13665 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13666 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13667 				 mplsoudp, "mplsoudp_decap-with-vlan");
13668 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13669 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13670 				 pos_token, "ip-version");
13671 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13672 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13673 				 ip_version, "ipv4#ipv6");
13674 
13675 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13676 	__rte_unused struct cmdline *cl,
13677 	__rte_unused void *data)
13678 {
13679 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13680 
13681 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13682 		mplsoudp_decap_conf.select_vlan = 0;
13683 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13684 		mplsoudp_decap_conf.select_vlan = 1;
13685 	if (strcmp(res->ip_version, "ipv4") == 0)
13686 		mplsoudp_decap_conf.select_ipv4 = 1;
13687 	else if (strcmp(res->ip_version, "ipv6") == 0)
13688 		mplsoudp_decap_conf.select_ipv4 = 0;
13689 }
13690 
13691 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13692 	.f = cmd_set_mplsoudp_decap_parsed,
13693 	.data = NULL,
13694 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13695 	.tokens = {
13696 		(void *)&cmd_set_mplsoudp_decap_set,
13697 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13698 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13699 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13700 		NULL,
13701 	},
13702 };
13703 
13704 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13705 	.f = cmd_set_mplsoudp_decap_parsed,
13706 	.data = NULL,
13707 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13708 	.tokens = {
13709 		(void *)&cmd_set_mplsoudp_decap_set,
13710 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13711 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13712 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13713 		NULL,
13714 	},
13715 };
13716 
13717 /** Set connection tracking object common details */
13718 struct cmd_set_conntrack_common_result {
13719 	cmdline_fixed_string_t set;
13720 	cmdline_fixed_string_t conntrack;
13721 	cmdline_fixed_string_t common;
13722 	cmdline_fixed_string_t peer;
13723 	cmdline_fixed_string_t is_orig;
13724 	cmdline_fixed_string_t enable;
13725 	cmdline_fixed_string_t live;
13726 	cmdline_fixed_string_t sack;
13727 	cmdline_fixed_string_t cack;
13728 	cmdline_fixed_string_t last_dir;
13729 	cmdline_fixed_string_t liberal;
13730 	cmdline_fixed_string_t state;
13731 	cmdline_fixed_string_t max_ack_win;
13732 	cmdline_fixed_string_t retrans;
13733 	cmdline_fixed_string_t last_win;
13734 	cmdline_fixed_string_t last_seq;
13735 	cmdline_fixed_string_t last_ack;
13736 	cmdline_fixed_string_t last_end;
13737 	cmdline_fixed_string_t last_index;
13738 	uint8_t stat;
13739 	uint8_t factor;
13740 	uint16_t peer_port;
13741 	uint32_t is_original;
13742 	uint32_t en;
13743 	uint32_t is_live;
13744 	uint32_t s_ack;
13745 	uint32_t c_ack;
13746 	uint32_t ld;
13747 	uint32_t lb;
13748 	uint8_t re_num;
13749 	uint8_t li;
13750 	uint16_t lw;
13751 	uint32_t ls;
13752 	uint32_t la;
13753 	uint32_t le;
13754 };
13755 
13756 cmdline_parse_token_string_t cmd_set_conntrack_set =
13757 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13758 				 set, "set");
13759 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13760 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13761 				 conntrack, "conntrack");
13762 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13763 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13764 				 common, "com");
13765 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13766 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13767 				 peer, "peer");
13768 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13769 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13770 			      peer_port, RTE_UINT16);
13771 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13772 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13773 				 is_orig, "is_orig");
13774 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13775 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13776 			      is_original, RTE_UINT32);
13777 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13778 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13779 				 enable, "enable");
13780 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13781 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13782 			      en, RTE_UINT32);
13783 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13784 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13785 				 live, "live");
13786 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13787 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13788 			      is_live, RTE_UINT32);
13789 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13790 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13791 				 sack, "sack");
13792 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13793 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13794 			      s_ack, RTE_UINT32);
13795 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13796 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13797 				 cack, "cack");
13798 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13799 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13800 			      c_ack, RTE_UINT32);
13801 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13802 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13803 				 last_dir, "last_dir");
13804 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13805 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13806 			      ld, RTE_UINT32);
13807 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13808 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13809 				 liberal, "liberal");
13810 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13811 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13812 			      lb, RTE_UINT32);
13813 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13814 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13815 				 state, "state");
13816 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13817 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13818 			      stat, RTE_UINT8);
13819 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13820 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13821 				 max_ack_win, "max_ack_win");
13822 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13823 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13824 			      factor, RTE_UINT8);
13825 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13826 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13827 				 retrans, "r_lim");
13828 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13829 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13830 			      re_num, RTE_UINT8);
13831 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13832 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13833 				 last_win, "last_win");
13834 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13835 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13836 			      lw, RTE_UINT16);
13837 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13838 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13839 				 last_seq, "last_seq");
13840 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13841 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13842 			      ls, RTE_UINT32);
13843 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13844 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13845 				 last_ack, "last_ack");
13846 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13847 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13848 			      la, RTE_UINT32);
13849 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13850 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13851 				 last_end, "last_end");
13852 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13853 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13854 			      le, RTE_UINT32);
13855 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13856 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13857 				 last_index, "last_index");
13858 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13859 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13860 			      li, RTE_UINT8);
13861 
13862 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13863 	__rte_unused struct cmdline *cl,
13864 	__rte_unused void *data)
13865 {
13866 	struct cmd_set_conntrack_common_result *res = parsed_result;
13867 
13868 	/* No need to swap to big endian. */
13869 	conntrack_context.peer_port = res->peer_port;
13870 	conntrack_context.is_original_dir = res->is_original;
13871 	conntrack_context.enable = res->en;
13872 	conntrack_context.live_connection = res->is_live;
13873 	conntrack_context.selective_ack = res->s_ack;
13874 	conntrack_context.challenge_ack_passed = res->c_ack;
13875 	conntrack_context.last_direction = res->ld;
13876 	conntrack_context.liberal_mode = res->lb;
13877 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13878 	conntrack_context.max_ack_window = res->factor;
13879 	conntrack_context.retransmission_limit = res->re_num;
13880 	conntrack_context.last_window = res->lw;
13881 	conntrack_context.last_index =
13882 		(enum rte_flow_conntrack_tcp_last_index)res->li;
13883 	conntrack_context.last_seq = res->ls;
13884 	conntrack_context.last_ack = res->la;
13885 	conntrack_context.last_end = res->le;
13886 }
13887 
13888 cmdline_parse_inst_t cmd_set_conntrack_common = {
13889 	.f = cmd_set_conntrack_common_parsed,
13890 	.data = NULL,
13891 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13892 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13893 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13894 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13895 		" last_index <flag>",
13896 	.tokens = {
13897 		(void *)&cmd_set_conntrack_set,
13898 		(void *)&cmd_set_conntrack_conntrack,
13899 		(void *)&cmd_set_conntrack_common_com,
13900 		(void *)&cmd_set_conntrack_common_peer,
13901 		(void *)&cmd_set_conntrack_common_peer_value,
13902 		(void *)&cmd_set_conntrack_common_is_orig,
13903 		(void *)&cmd_set_conntrack_common_is_orig_value,
13904 		(void *)&cmd_set_conntrack_common_enable,
13905 		(void *)&cmd_set_conntrack_common_enable_value,
13906 		(void *)&cmd_set_conntrack_common_live,
13907 		(void *)&cmd_set_conntrack_common_live_value,
13908 		(void *)&cmd_set_conntrack_common_sack,
13909 		(void *)&cmd_set_conntrack_common_sack_value,
13910 		(void *)&cmd_set_conntrack_common_cack,
13911 		(void *)&cmd_set_conntrack_common_cack_value,
13912 		(void *)&cmd_set_conntrack_common_last_dir,
13913 		(void *)&cmd_set_conntrack_common_last_dir_value,
13914 		(void *)&cmd_set_conntrack_common_liberal,
13915 		(void *)&cmd_set_conntrack_common_liberal_value,
13916 		(void *)&cmd_set_conntrack_common_state,
13917 		(void *)&cmd_set_conntrack_common_state_value,
13918 		(void *)&cmd_set_conntrack_common_max_ackwin,
13919 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
13920 		(void *)&cmd_set_conntrack_common_retrans,
13921 		(void *)&cmd_set_conntrack_common_retrans_value,
13922 		(void *)&cmd_set_conntrack_common_last_win,
13923 		(void *)&cmd_set_conntrack_common_last_win_value,
13924 		(void *)&cmd_set_conntrack_common_last_seq,
13925 		(void *)&cmd_set_conntrack_common_last_seq_value,
13926 		(void *)&cmd_set_conntrack_common_last_ack,
13927 		(void *)&cmd_set_conntrack_common_last_ack_value,
13928 		(void *)&cmd_set_conntrack_common_last_end,
13929 		(void *)&cmd_set_conntrack_common_last_end_value,
13930 		(void *)&cmd_set_conntrack_common_last_index,
13931 		(void *)&cmd_set_conntrack_common_last_index_value,
13932 		NULL,
13933 	},
13934 };
13935 
13936 /** Set connection tracking object both directions' details */
13937 struct cmd_set_conntrack_dir_result {
13938 	cmdline_fixed_string_t set;
13939 	cmdline_fixed_string_t conntrack;
13940 	cmdline_fixed_string_t dir;
13941 	cmdline_fixed_string_t scale;
13942 	cmdline_fixed_string_t fin;
13943 	cmdline_fixed_string_t ack_seen;
13944 	cmdline_fixed_string_t unack;
13945 	cmdline_fixed_string_t sent_end;
13946 	cmdline_fixed_string_t reply_end;
13947 	cmdline_fixed_string_t max_win;
13948 	cmdline_fixed_string_t max_ack;
13949 	uint32_t factor;
13950 	uint32_t f;
13951 	uint32_t as;
13952 	uint32_t un;
13953 	uint32_t se;
13954 	uint32_t re;
13955 	uint32_t mw;
13956 	uint32_t ma;
13957 };
13958 
13959 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
13960 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13961 				 set, "set");
13962 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
13963 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13964 				 conntrack, "conntrack");
13965 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
13966 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13967 				 dir, "orig#rply");
13968 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
13969 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13970 				 scale, "scale");
13971 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
13972 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13973 			      factor, RTE_UINT32);
13974 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
13975 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13976 				 fin, "fin");
13977 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
13978 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13979 			      f, RTE_UINT32);
13980 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
13981 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13982 				 ack_seen, "acked");
13983 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
13984 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13985 			      as, RTE_UINT32);
13986 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
13987 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13988 				 unack, "unack_data");
13989 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
13990 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13991 			      un, RTE_UINT32);
13992 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
13993 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13994 				 sent_end, "sent_end");
13995 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
13996 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13997 			      se, RTE_UINT32);
13998 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
13999 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14000 				 reply_end, "reply_end");
14001 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14002 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14003 			      re, RTE_UINT32);
14004 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14005 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14006 				 max_win, "max_win");
14007 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14008 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14009 			      mw, RTE_UINT32);
14010 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14011 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14012 				 max_ack, "max_ack");
14013 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14014 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14015 			      ma, RTE_UINT32);
14016 
14017 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14018 	__rte_unused struct cmdline *cl,
14019 	__rte_unused void *data)
14020 {
14021 	struct cmd_set_conntrack_dir_result *res = parsed_result;
14022 	struct rte_flow_tcp_dir_param *dir = NULL;
14023 
14024 	if (strcmp(res->dir, "orig") == 0)
14025 		dir = &conntrack_context.original_dir;
14026 	else if (strcmp(res->dir, "rply") == 0)
14027 		dir = &conntrack_context.reply_dir;
14028 	else
14029 		return;
14030 	dir->scale = res->factor;
14031 	dir->close_initiated = res->f;
14032 	dir->last_ack_seen = res->as;
14033 	dir->data_unacked = res->un;
14034 	dir->sent_end = res->se;
14035 	dir->reply_end = res->re;
14036 	dir->max_ack = res->ma;
14037 	dir->max_win = res->mw;
14038 }
14039 
14040 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14041 	.f = cmd_set_conntrack_dir_parsed,
14042 	.data = NULL,
14043 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14044 		    " acked <seen> unack_data <unack> sent_end <sent>"
14045 		    " reply_end <reply> max_win <win> max_ack <ack>",
14046 	.tokens = {
14047 		(void *)&cmd_set_conntrack_set,
14048 		(void *)&cmd_set_conntrack_conntrack,
14049 		(void *)&cmd_set_conntrack_dir_dir,
14050 		(void *)&cmd_set_conntrack_dir_scale,
14051 		(void *)&cmd_set_conntrack_dir_scale_value,
14052 		(void *)&cmd_set_conntrack_dir_fin,
14053 		(void *)&cmd_set_conntrack_dir_fin_value,
14054 		(void *)&cmd_set_conntrack_dir_ack,
14055 		(void *)&cmd_set_conntrack_dir_ack_value,
14056 		(void *)&cmd_set_conntrack_dir_unack_data,
14057 		(void *)&cmd_set_conntrack_dir_unack_data_value,
14058 		(void *)&cmd_set_conntrack_dir_sent_end,
14059 		(void *)&cmd_set_conntrack_dir_sent_end_value,
14060 		(void *)&cmd_set_conntrack_dir_reply_end,
14061 		(void *)&cmd_set_conntrack_dir_reply_end_value,
14062 		(void *)&cmd_set_conntrack_dir_max_win,
14063 		(void *)&cmd_set_conntrack_dir_max_win_value,
14064 		(void *)&cmd_set_conntrack_dir_max_ack,
14065 		(void *)&cmd_set_conntrack_dir_max_ack_value,
14066 		NULL,
14067 	},
14068 };
14069 
14070 /* Strict link priority scheduling mode setting */
14071 static void
14072 cmd_strict_link_prio_parsed(
14073 	void *parsed_result,
14074 	__rte_unused struct cmdline *cl,
14075 	__rte_unused void *data)
14076 {
14077 	struct cmd_vf_tc_bw_result *res = parsed_result;
14078 	int ret = -ENOTSUP;
14079 
14080 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14081 		return;
14082 
14083 #ifdef RTE_NET_I40E
14084 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14085 #endif
14086 
14087 	switch (ret) {
14088 	case 0:
14089 		break;
14090 	case -EINVAL:
14091 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14092 		break;
14093 	case -ENODEV:
14094 		printf("invalid port_id %d\n", res->port_id);
14095 		break;
14096 	case -ENOTSUP:
14097 		printf("function not implemented\n");
14098 		break;
14099 	default:
14100 		printf("programming error: (%s)\n", strerror(-ret));
14101 	}
14102 }
14103 
14104 cmdline_parse_inst_t cmd_strict_link_prio = {
14105 	.f = cmd_strict_link_prio_parsed,
14106 	.data = NULL,
14107 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14108 	.tokens = {
14109 		(void *)&cmd_vf_tc_bw_set,
14110 		(void *)&cmd_vf_tc_bw_tx,
14111 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14112 		(void *)&cmd_vf_tc_bw_port_id,
14113 		(void *)&cmd_vf_tc_bw_tc_map,
14114 		NULL,
14115 	},
14116 };
14117 
14118 /* Load dynamic device personalization*/
14119 struct cmd_ddp_add_result {
14120 	cmdline_fixed_string_t ddp;
14121 	cmdline_fixed_string_t add;
14122 	portid_t port_id;
14123 	char filepath[];
14124 };
14125 
14126 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14127 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14128 cmdline_parse_token_string_t cmd_ddp_add_add =
14129 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14130 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14131 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14132 		RTE_UINT16);
14133 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14134 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14135 
14136 static void
14137 cmd_ddp_add_parsed(
14138 	void *parsed_result,
14139 	__rte_unused struct cmdline *cl,
14140 	__rte_unused void *data)
14141 {
14142 	struct cmd_ddp_add_result *res = parsed_result;
14143 	uint8_t *buff;
14144 	uint32_t size;
14145 	char *filepath;
14146 	char *file_fld[2];
14147 	int file_num;
14148 	int ret = -ENOTSUP;
14149 
14150 	if (!all_ports_stopped()) {
14151 		printf("Please stop all ports first\n");
14152 		return;
14153 	}
14154 
14155 	filepath = strdup(res->filepath);
14156 	if (filepath == NULL) {
14157 		printf("Failed to allocate memory\n");
14158 		return;
14159 	}
14160 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14161 
14162 	buff = open_file(file_fld[0], &size);
14163 	if (!buff) {
14164 		free((void *)filepath);
14165 		return;
14166 	}
14167 
14168 #ifdef RTE_NET_I40E
14169 	if (ret == -ENOTSUP)
14170 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14171 					       buff, size,
14172 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14173 #endif
14174 
14175 	if (ret == -EEXIST)
14176 		printf("Profile has already existed.\n");
14177 	else if (ret < 0)
14178 		printf("Failed to load profile.\n");
14179 	else if (file_num == 2)
14180 		save_file(file_fld[1], buff, size);
14181 
14182 	close_file(buff);
14183 	free((void *)filepath);
14184 }
14185 
14186 cmdline_parse_inst_t cmd_ddp_add = {
14187 	.f = cmd_ddp_add_parsed,
14188 	.data = NULL,
14189 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14190 	.tokens = {
14191 		(void *)&cmd_ddp_add_ddp,
14192 		(void *)&cmd_ddp_add_add,
14193 		(void *)&cmd_ddp_add_port_id,
14194 		(void *)&cmd_ddp_add_filepath,
14195 		NULL,
14196 	},
14197 };
14198 
14199 /* Delete dynamic device personalization*/
14200 struct cmd_ddp_del_result {
14201 	cmdline_fixed_string_t ddp;
14202 	cmdline_fixed_string_t del;
14203 	portid_t port_id;
14204 	char filepath[];
14205 };
14206 
14207 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14208 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14209 cmdline_parse_token_string_t cmd_ddp_del_del =
14210 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14211 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14212 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14213 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14214 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14215 
14216 static void
14217 cmd_ddp_del_parsed(
14218 	void *parsed_result,
14219 	__rte_unused struct cmdline *cl,
14220 	__rte_unused void *data)
14221 {
14222 	struct cmd_ddp_del_result *res = parsed_result;
14223 	uint8_t *buff;
14224 	uint32_t size;
14225 	int ret = -ENOTSUP;
14226 
14227 	if (!all_ports_stopped()) {
14228 		printf("Please stop all ports first\n");
14229 		return;
14230 	}
14231 
14232 	buff = open_file(res->filepath, &size);
14233 	if (!buff)
14234 		return;
14235 
14236 #ifdef RTE_NET_I40E
14237 	if (ret == -ENOTSUP)
14238 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14239 					       buff, size,
14240 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14241 #endif
14242 
14243 	if (ret == -EACCES)
14244 		printf("Profile does not exist.\n");
14245 	else if (ret < 0)
14246 		printf("Failed to delete profile.\n");
14247 
14248 	close_file(buff);
14249 }
14250 
14251 cmdline_parse_inst_t cmd_ddp_del = {
14252 	.f = cmd_ddp_del_parsed,
14253 	.data = NULL,
14254 	.help_str = "ddp del <port_id> <backup_profile_path>",
14255 	.tokens = {
14256 		(void *)&cmd_ddp_del_ddp,
14257 		(void *)&cmd_ddp_del_del,
14258 		(void *)&cmd_ddp_del_port_id,
14259 		(void *)&cmd_ddp_del_filepath,
14260 		NULL,
14261 	},
14262 };
14263 
14264 /* Get dynamic device personalization profile info */
14265 struct cmd_ddp_info_result {
14266 	cmdline_fixed_string_t ddp;
14267 	cmdline_fixed_string_t get;
14268 	cmdline_fixed_string_t info;
14269 	char filepath[];
14270 };
14271 
14272 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14273 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14274 cmdline_parse_token_string_t cmd_ddp_info_get =
14275 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14276 cmdline_parse_token_string_t cmd_ddp_info_info =
14277 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14278 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14279 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14280 
14281 static void
14282 cmd_ddp_info_parsed(
14283 	void *parsed_result,
14284 	__rte_unused struct cmdline *cl,
14285 	__rte_unused void *data)
14286 {
14287 	struct cmd_ddp_info_result *res = parsed_result;
14288 	uint8_t *pkg;
14289 	uint32_t pkg_size;
14290 	int ret = -ENOTSUP;
14291 #ifdef RTE_NET_I40E
14292 	uint32_t i, j, n;
14293 	uint8_t *buff;
14294 	uint32_t buff_size = 0;
14295 	struct rte_pmd_i40e_profile_info info;
14296 	uint32_t dev_num = 0;
14297 	struct rte_pmd_i40e_ddp_device_id *devs;
14298 	uint32_t proto_num = 0;
14299 	struct rte_pmd_i40e_proto_info *proto = NULL;
14300 	uint32_t pctype_num = 0;
14301 	struct rte_pmd_i40e_ptype_info *pctype;
14302 	uint32_t ptype_num = 0;
14303 	struct rte_pmd_i40e_ptype_info *ptype;
14304 	uint8_t proto_id;
14305 
14306 #endif
14307 
14308 	pkg = open_file(res->filepath, &pkg_size);
14309 	if (!pkg)
14310 		return;
14311 
14312 #ifdef RTE_NET_I40E
14313 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14314 				(uint8_t *)&info, sizeof(info),
14315 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14316 	if (!ret) {
14317 		printf("Global Track id:       0x%x\n", info.track_id);
14318 		printf("Global Version:        %d.%d.%d.%d\n",
14319 			info.version.major,
14320 			info.version.minor,
14321 			info.version.update,
14322 			info.version.draft);
14323 		printf("Global Package name:   %s\n\n", info.name);
14324 	}
14325 
14326 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14327 				(uint8_t *)&info, sizeof(info),
14328 				RTE_PMD_I40E_PKG_INFO_HEADER);
14329 	if (!ret) {
14330 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14331 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14332 			info.version.major,
14333 			info.version.minor,
14334 			info.version.update,
14335 			info.version.draft);
14336 		printf("i40e Profile name:     %s\n\n", info.name);
14337 	}
14338 
14339 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14340 				(uint8_t *)&buff_size, sizeof(buff_size),
14341 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14342 	if (!ret && buff_size) {
14343 		buff = (uint8_t *)malloc(buff_size);
14344 		if (buff) {
14345 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14346 						buff, buff_size,
14347 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14348 			if (!ret)
14349 				printf("Package Notes:\n%s\n\n", buff);
14350 			free(buff);
14351 		}
14352 	}
14353 
14354 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14355 				(uint8_t *)&dev_num, sizeof(dev_num),
14356 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14357 	if (!ret && dev_num) {
14358 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14359 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14360 		if (devs) {
14361 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14362 						(uint8_t *)devs, buff_size,
14363 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14364 			if (!ret) {
14365 				printf("List of supported devices:\n");
14366 				for (i = 0; i < dev_num; i++) {
14367 					printf("  %04X:%04X %04X:%04X\n",
14368 						devs[i].vendor_dev_id >> 16,
14369 						devs[i].vendor_dev_id & 0xFFFF,
14370 						devs[i].sub_vendor_dev_id >> 16,
14371 						devs[i].sub_vendor_dev_id & 0xFFFF);
14372 				}
14373 				printf("\n");
14374 			}
14375 			free(devs);
14376 		}
14377 	}
14378 
14379 	/* get information about protocols and packet types */
14380 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14381 		(uint8_t *)&proto_num, sizeof(proto_num),
14382 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14383 	if (ret || !proto_num)
14384 		goto no_print_return;
14385 
14386 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14387 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14388 	if (!proto)
14389 		goto no_print_return;
14390 
14391 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14392 					buff_size,
14393 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14394 	if (!ret) {
14395 		printf("List of used protocols:\n");
14396 		for (i = 0; i < proto_num; i++)
14397 			printf("  %2u: %s\n", proto[i].proto_id,
14398 			       proto[i].name);
14399 		printf("\n");
14400 	}
14401 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14402 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14403 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14404 	if (ret || !pctype_num)
14405 		goto no_print_pctypes;
14406 
14407 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14408 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14409 	if (!pctype)
14410 		goto no_print_pctypes;
14411 
14412 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14413 					buff_size,
14414 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14415 	if (ret) {
14416 		free(pctype);
14417 		goto no_print_pctypes;
14418 	}
14419 
14420 	printf("List of defined packet classification types:\n");
14421 	for (i = 0; i < pctype_num; i++) {
14422 		printf("  %2u:", pctype[i].ptype_id);
14423 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14424 			proto_id = pctype[i].protocols[j];
14425 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14426 				for (n = 0; n < proto_num; n++) {
14427 					if (proto[n].proto_id == proto_id) {
14428 						printf(" %s", proto[n].name);
14429 						break;
14430 					}
14431 				}
14432 			}
14433 		}
14434 		printf("\n");
14435 	}
14436 	printf("\n");
14437 	free(pctype);
14438 
14439 no_print_pctypes:
14440 
14441 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14442 					sizeof(ptype_num),
14443 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14444 	if (ret || !ptype_num)
14445 		goto no_print_return;
14446 
14447 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14448 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14449 	if (!ptype)
14450 		goto no_print_return;
14451 
14452 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14453 					buff_size,
14454 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14455 	if (ret) {
14456 		free(ptype);
14457 		goto no_print_return;
14458 	}
14459 	printf("List of defined packet types:\n");
14460 	for (i = 0; i < ptype_num; i++) {
14461 		printf("  %2u:", ptype[i].ptype_id);
14462 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14463 			proto_id = ptype[i].protocols[j];
14464 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14465 				for (n = 0; n < proto_num; n++) {
14466 					if (proto[n].proto_id == proto_id) {
14467 						printf(" %s", proto[n].name);
14468 						break;
14469 					}
14470 				}
14471 			}
14472 		}
14473 		printf("\n");
14474 	}
14475 	free(ptype);
14476 	printf("\n");
14477 
14478 	ret = 0;
14479 no_print_return:
14480 	if (proto)
14481 		free(proto);
14482 #endif
14483 	if (ret == -ENOTSUP)
14484 		printf("Function not supported in PMD driver\n");
14485 	close_file(pkg);
14486 }
14487 
14488 cmdline_parse_inst_t cmd_ddp_get_info = {
14489 	.f = cmd_ddp_info_parsed,
14490 	.data = NULL,
14491 	.help_str = "ddp get info <profile_path>",
14492 	.tokens = {
14493 		(void *)&cmd_ddp_info_ddp,
14494 		(void *)&cmd_ddp_info_get,
14495 		(void *)&cmd_ddp_info_info,
14496 		(void *)&cmd_ddp_info_filepath,
14497 		NULL,
14498 	},
14499 };
14500 
14501 /* Get dynamic device personalization profile info list*/
14502 #define PROFILE_INFO_SIZE 48
14503 #define MAX_PROFILE_NUM 16
14504 
14505 struct cmd_ddp_get_list_result {
14506 	cmdline_fixed_string_t ddp;
14507 	cmdline_fixed_string_t get;
14508 	cmdline_fixed_string_t list;
14509 	portid_t port_id;
14510 };
14511 
14512 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14513 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14514 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14515 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14516 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14517 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14518 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14519 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14520 		RTE_UINT16);
14521 
14522 static void
14523 cmd_ddp_get_list_parsed(
14524 	__rte_unused void *parsed_result,
14525 	__rte_unused struct cmdline *cl,
14526 	__rte_unused void *data)
14527 {
14528 #ifdef RTE_NET_I40E
14529 	struct cmd_ddp_get_list_result *res = parsed_result;
14530 	struct rte_pmd_i40e_profile_list *p_list;
14531 	struct rte_pmd_i40e_profile_info *p_info;
14532 	uint32_t p_num;
14533 	uint32_t size;
14534 	uint32_t i;
14535 #endif
14536 	int ret = -ENOTSUP;
14537 
14538 #ifdef RTE_NET_I40E
14539 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14540 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14541 	if (!p_list) {
14542 		printf("%s: Failed to malloc buffer\n", __func__);
14543 		return;
14544 	}
14545 
14546 	if (ret == -ENOTSUP)
14547 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14548 						(uint8_t *)p_list, size);
14549 
14550 	if (!ret) {
14551 		p_num = p_list->p_count;
14552 		printf("Profile number is: %d\n\n", p_num);
14553 
14554 		for (i = 0; i < p_num; i++) {
14555 			p_info = &p_list->p_info[i];
14556 			printf("Profile %d:\n", i);
14557 			printf("Track id:     0x%x\n", p_info->track_id);
14558 			printf("Version:      %d.%d.%d.%d\n",
14559 			       p_info->version.major,
14560 			       p_info->version.minor,
14561 			       p_info->version.update,
14562 			       p_info->version.draft);
14563 			printf("Profile name: %s\n\n", p_info->name);
14564 		}
14565 	}
14566 
14567 	free(p_list);
14568 #endif
14569 
14570 	if (ret < 0)
14571 		printf("Failed to get ddp list\n");
14572 }
14573 
14574 cmdline_parse_inst_t cmd_ddp_get_list = {
14575 	.f = cmd_ddp_get_list_parsed,
14576 	.data = NULL,
14577 	.help_str = "ddp get list <port_id>",
14578 	.tokens = {
14579 		(void *)&cmd_ddp_get_list_ddp,
14580 		(void *)&cmd_ddp_get_list_get,
14581 		(void *)&cmd_ddp_get_list_list,
14582 		(void *)&cmd_ddp_get_list_port_id,
14583 		NULL,
14584 	},
14585 };
14586 
14587 /* Configure input set */
14588 struct cmd_cfg_input_set_result {
14589 	cmdline_fixed_string_t port;
14590 	cmdline_fixed_string_t cfg;
14591 	portid_t port_id;
14592 	cmdline_fixed_string_t pctype;
14593 	uint8_t pctype_id;
14594 	cmdline_fixed_string_t inset_type;
14595 	cmdline_fixed_string_t opt;
14596 	cmdline_fixed_string_t field;
14597 	uint8_t field_idx;
14598 };
14599 
14600 static void
14601 cmd_cfg_input_set_parsed(
14602 	__rte_unused void *parsed_result,
14603 	__rte_unused struct cmdline *cl,
14604 	__rte_unused void *data)
14605 {
14606 #ifdef RTE_NET_I40E
14607 	struct cmd_cfg_input_set_result *res = parsed_result;
14608 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14609 	struct rte_pmd_i40e_inset inset;
14610 #endif
14611 	int ret = -ENOTSUP;
14612 
14613 	if (!all_ports_stopped()) {
14614 		printf("Please stop all ports first\n");
14615 		return;
14616 	}
14617 
14618 #ifdef RTE_NET_I40E
14619 	if (!strcmp(res->inset_type, "hash_inset"))
14620 		inset_type = INSET_HASH;
14621 	else if (!strcmp(res->inset_type, "fdir_inset"))
14622 		inset_type = INSET_FDIR;
14623 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14624 		inset_type = INSET_FDIR_FLX;
14625 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14626 				     &inset, inset_type);
14627 	if (ret) {
14628 		printf("Failed to get input set.\n");
14629 		return;
14630 	}
14631 
14632 	if (!strcmp(res->opt, "get")) {
14633 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14634 						   res->field_idx);
14635 		if (ret)
14636 			printf("Field index %d is enabled.\n", res->field_idx);
14637 		else
14638 			printf("Field index %d is disabled.\n", res->field_idx);
14639 		return;
14640 	} else if (!strcmp(res->opt, "set"))
14641 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14642 						   res->field_idx);
14643 	else if (!strcmp(res->opt, "clear"))
14644 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14645 						     res->field_idx);
14646 	if (ret) {
14647 		printf("Failed to configure input set field.\n");
14648 		return;
14649 	}
14650 
14651 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14652 				     &inset, inset_type);
14653 	if (ret) {
14654 		printf("Failed to set input set.\n");
14655 		return;
14656 	}
14657 #endif
14658 
14659 	if (ret == -ENOTSUP)
14660 		printf("Function not supported\n");
14661 }
14662 
14663 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14664 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14665 				 port, "port");
14666 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14667 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14668 				 cfg, "config");
14669 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14670 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14671 			      port_id, RTE_UINT16);
14672 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14673 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14674 				 pctype, "pctype");
14675 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14676 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14677 			      pctype_id, RTE_UINT8);
14678 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14679 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14680 				 inset_type,
14681 				 "hash_inset#fdir_inset#fdir_flx_inset");
14682 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14683 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14684 				 opt, "get#set#clear");
14685 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14686 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14687 				 field, "field");
14688 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14689 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14690 			      field_idx, RTE_UINT8);
14691 
14692 cmdline_parse_inst_t cmd_cfg_input_set = {
14693 	.f = cmd_cfg_input_set_parsed,
14694 	.data = NULL,
14695 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14696 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14697 	.tokens = {
14698 		(void *)&cmd_cfg_input_set_port,
14699 		(void *)&cmd_cfg_input_set_cfg,
14700 		(void *)&cmd_cfg_input_set_port_id,
14701 		(void *)&cmd_cfg_input_set_pctype,
14702 		(void *)&cmd_cfg_input_set_pctype_id,
14703 		(void *)&cmd_cfg_input_set_inset_type,
14704 		(void *)&cmd_cfg_input_set_opt,
14705 		(void *)&cmd_cfg_input_set_field,
14706 		(void *)&cmd_cfg_input_set_field_idx,
14707 		NULL,
14708 	},
14709 };
14710 
14711 /* Clear input set */
14712 struct cmd_clear_input_set_result {
14713 	cmdline_fixed_string_t port;
14714 	cmdline_fixed_string_t cfg;
14715 	portid_t port_id;
14716 	cmdline_fixed_string_t pctype;
14717 	uint8_t pctype_id;
14718 	cmdline_fixed_string_t inset_type;
14719 	cmdline_fixed_string_t clear;
14720 	cmdline_fixed_string_t all;
14721 };
14722 
14723 static void
14724 cmd_clear_input_set_parsed(
14725 	__rte_unused void *parsed_result,
14726 	__rte_unused struct cmdline *cl,
14727 	__rte_unused void *data)
14728 {
14729 #ifdef RTE_NET_I40E
14730 	struct cmd_clear_input_set_result *res = parsed_result;
14731 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14732 	struct rte_pmd_i40e_inset inset;
14733 #endif
14734 	int ret = -ENOTSUP;
14735 
14736 	if (!all_ports_stopped()) {
14737 		printf("Please stop all ports first\n");
14738 		return;
14739 	}
14740 
14741 #ifdef RTE_NET_I40E
14742 	if (!strcmp(res->inset_type, "hash_inset"))
14743 		inset_type = INSET_HASH;
14744 	else if (!strcmp(res->inset_type, "fdir_inset"))
14745 		inset_type = INSET_FDIR;
14746 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14747 		inset_type = INSET_FDIR_FLX;
14748 
14749 	memset(&inset, 0, sizeof(inset));
14750 
14751 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14752 				     &inset, inset_type);
14753 	if (ret) {
14754 		printf("Failed to clear input set.\n");
14755 		return;
14756 	}
14757 
14758 #endif
14759 
14760 	if (ret == -ENOTSUP)
14761 		printf("Function not supported\n");
14762 }
14763 
14764 cmdline_parse_token_string_t cmd_clear_input_set_port =
14765 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14766 				 port, "port");
14767 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14768 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14769 				 cfg, "config");
14770 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14771 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14772 			      port_id, RTE_UINT16);
14773 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14774 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14775 				 pctype, "pctype");
14776 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14777 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14778 			      pctype_id, RTE_UINT8);
14779 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14780 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14781 				 inset_type,
14782 				 "hash_inset#fdir_inset#fdir_flx_inset");
14783 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14784 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14785 				 clear, "clear");
14786 cmdline_parse_token_string_t cmd_clear_input_set_all =
14787 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14788 				 all, "all");
14789 
14790 cmdline_parse_inst_t cmd_clear_input_set = {
14791 	.f = cmd_clear_input_set_parsed,
14792 	.data = NULL,
14793 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14794 		    "fdir_inset|fdir_flx_inset clear all",
14795 	.tokens = {
14796 		(void *)&cmd_clear_input_set_port,
14797 		(void *)&cmd_clear_input_set_cfg,
14798 		(void *)&cmd_clear_input_set_port_id,
14799 		(void *)&cmd_clear_input_set_pctype,
14800 		(void *)&cmd_clear_input_set_pctype_id,
14801 		(void *)&cmd_clear_input_set_inset_type,
14802 		(void *)&cmd_clear_input_set_clear,
14803 		(void *)&cmd_clear_input_set_all,
14804 		NULL,
14805 	},
14806 };
14807 
14808 /* show vf stats */
14809 
14810 /* Common result structure for show vf stats */
14811 struct cmd_show_vf_stats_result {
14812 	cmdline_fixed_string_t show;
14813 	cmdline_fixed_string_t vf;
14814 	cmdline_fixed_string_t stats;
14815 	portid_t port_id;
14816 	uint16_t vf_id;
14817 };
14818 
14819 /* Common CLI fields show vf stats*/
14820 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14821 	TOKEN_STRING_INITIALIZER
14822 		(struct cmd_show_vf_stats_result,
14823 		 show, "show");
14824 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14825 	TOKEN_STRING_INITIALIZER
14826 		(struct cmd_show_vf_stats_result,
14827 		 vf, "vf");
14828 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14829 	TOKEN_STRING_INITIALIZER
14830 		(struct cmd_show_vf_stats_result,
14831 		 stats, "stats");
14832 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14833 	TOKEN_NUM_INITIALIZER
14834 		(struct cmd_show_vf_stats_result,
14835 		 port_id, RTE_UINT16);
14836 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14837 	TOKEN_NUM_INITIALIZER
14838 		(struct cmd_show_vf_stats_result,
14839 		 vf_id, RTE_UINT16);
14840 
14841 static void
14842 cmd_show_vf_stats_parsed(
14843 	void *parsed_result,
14844 	__rte_unused struct cmdline *cl,
14845 	__rte_unused void *data)
14846 {
14847 	struct cmd_show_vf_stats_result *res = parsed_result;
14848 	struct rte_eth_stats stats;
14849 	int ret = -ENOTSUP;
14850 	static const char *nic_stats_border = "########################";
14851 
14852 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14853 		return;
14854 
14855 	memset(&stats, 0, sizeof(stats));
14856 
14857 #ifdef RTE_NET_I40E
14858 	if (ret == -ENOTSUP)
14859 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14860 						res->vf_id,
14861 						&stats);
14862 #endif
14863 #ifdef RTE_NET_BNXT
14864 	if (ret == -ENOTSUP)
14865 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14866 						res->vf_id,
14867 						&stats);
14868 #endif
14869 
14870 	switch (ret) {
14871 	case 0:
14872 		break;
14873 	case -EINVAL:
14874 		printf("invalid vf_id %d\n", res->vf_id);
14875 		break;
14876 	case -ENODEV:
14877 		printf("invalid port_id %d\n", res->port_id);
14878 		break;
14879 	case -ENOTSUP:
14880 		printf("function not implemented\n");
14881 		break;
14882 	default:
14883 		printf("programming error: (%s)\n", strerror(-ret));
14884 	}
14885 
14886 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
14887 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14888 
14889 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
14890 	       "%-"PRIu64"\n",
14891 	       stats.ipackets, stats.imissed, stats.ibytes);
14892 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
14893 	printf("  RX-nombuf:  %-10"PRIu64"\n",
14894 	       stats.rx_nombuf);
14895 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
14896 	       "%-"PRIu64"\n",
14897 	       stats.opackets, stats.oerrors, stats.obytes);
14898 
14899 	printf("  %s############################%s\n",
14900 			       nic_stats_border, nic_stats_border);
14901 }
14902 
14903 cmdline_parse_inst_t cmd_show_vf_stats = {
14904 	.f = cmd_show_vf_stats_parsed,
14905 	.data = NULL,
14906 	.help_str = "show vf stats <port_id> <vf_id>",
14907 	.tokens = {
14908 		(void *)&cmd_show_vf_stats_show,
14909 		(void *)&cmd_show_vf_stats_vf,
14910 		(void *)&cmd_show_vf_stats_stats,
14911 		(void *)&cmd_show_vf_stats_port_id,
14912 		(void *)&cmd_show_vf_stats_vf_id,
14913 		NULL,
14914 	},
14915 };
14916 
14917 /* clear vf stats */
14918 
14919 /* Common result structure for clear vf stats */
14920 struct cmd_clear_vf_stats_result {
14921 	cmdline_fixed_string_t clear;
14922 	cmdline_fixed_string_t vf;
14923 	cmdline_fixed_string_t stats;
14924 	portid_t port_id;
14925 	uint16_t vf_id;
14926 };
14927 
14928 /* Common CLI fields clear vf stats*/
14929 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14930 	TOKEN_STRING_INITIALIZER
14931 		(struct cmd_clear_vf_stats_result,
14932 		 clear, "clear");
14933 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14934 	TOKEN_STRING_INITIALIZER
14935 		(struct cmd_clear_vf_stats_result,
14936 		 vf, "vf");
14937 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14938 	TOKEN_STRING_INITIALIZER
14939 		(struct cmd_clear_vf_stats_result,
14940 		 stats, "stats");
14941 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14942 	TOKEN_NUM_INITIALIZER
14943 		(struct cmd_clear_vf_stats_result,
14944 		 port_id, RTE_UINT16);
14945 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14946 	TOKEN_NUM_INITIALIZER
14947 		(struct cmd_clear_vf_stats_result,
14948 		 vf_id, RTE_UINT16);
14949 
14950 static void
14951 cmd_clear_vf_stats_parsed(
14952 	void *parsed_result,
14953 	__rte_unused struct cmdline *cl,
14954 	__rte_unused void *data)
14955 {
14956 	struct cmd_clear_vf_stats_result *res = parsed_result;
14957 	int ret = -ENOTSUP;
14958 
14959 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14960 		return;
14961 
14962 #ifdef RTE_NET_I40E
14963 	if (ret == -ENOTSUP)
14964 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14965 						  res->vf_id);
14966 #endif
14967 #ifdef RTE_NET_BNXT
14968 	if (ret == -ENOTSUP)
14969 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14970 						  res->vf_id);
14971 #endif
14972 
14973 	switch (ret) {
14974 	case 0:
14975 		break;
14976 	case -EINVAL:
14977 		printf("invalid vf_id %d\n", res->vf_id);
14978 		break;
14979 	case -ENODEV:
14980 		printf("invalid port_id %d\n", res->port_id);
14981 		break;
14982 	case -ENOTSUP:
14983 		printf("function not implemented\n");
14984 		break;
14985 	default:
14986 		printf("programming error: (%s)\n", strerror(-ret));
14987 	}
14988 }
14989 
14990 cmdline_parse_inst_t cmd_clear_vf_stats = {
14991 	.f = cmd_clear_vf_stats_parsed,
14992 	.data = NULL,
14993 	.help_str = "clear vf stats <port_id> <vf_id>",
14994 	.tokens = {
14995 		(void *)&cmd_clear_vf_stats_clear,
14996 		(void *)&cmd_clear_vf_stats_vf,
14997 		(void *)&cmd_clear_vf_stats_stats,
14998 		(void *)&cmd_clear_vf_stats_port_id,
14999 		(void *)&cmd_clear_vf_stats_vf_id,
15000 		NULL,
15001 	},
15002 };
15003 
15004 /* port config pctype mapping reset */
15005 
15006 /* Common result structure for port config pctype mapping reset */
15007 struct cmd_pctype_mapping_reset_result {
15008 	cmdline_fixed_string_t port;
15009 	cmdline_fixed_string_t config;
15010 	portid_t port_id;
15011 	cmdline_fixed_string_t pctype;
15012 	cmdline_fixed_string_t mapping;
15013 	cmdline_fixed_string_t reset;
15014 };
15015 
15016 /* Common CLI fields for port config pctype mapping reset*/
15017 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15018 	TOKEN_STRING_INITIALIZER
15019 		(struct cmd_pctype_mapping_reset_result,
15020 		 port, "port");
15021 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15022 	TOKEN_STRING_INITIALIZER
15023 		(struct cmd_pctype_mapping_reset_result,
15024 		 config, "config");
15025 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15026 	TOKEN_NUM_INITIALIZER
15027 		(struct cmd_pctype_mapping_reset_result,
15028 		 port_id, RTE_UINT16);
15029 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15030 	TOKEN_STRING_INITIALIZER
15031 		(struct cmd_pctype_mapping_reset_result,
15032 		 pctype, "pctype");
15033 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15034 	TOKEN_STRING_INITIALIZER
15035 		(struct cmd_pctype_mapping_reset_result,
15036 		 mapping, "mapping");
15037 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15038 	TOKEN_STRING_INITIALIZER
15039 		(struct cmd_pctype_mapping_reset_result,
15040 		 reset, "reset");
15041 
15042 static void
15043 cmd_pctype_mapping_reset_parsed(
15044 	void *parsed_result,
15045 	__rte_unused struct cmdline *cl,
15046 	__rte_unused void *data)
15047 {
15048 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15049 	int ret = -ENOTSUP;
15050 
15051 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15052 		return;
15053 
15054 #ifdef RTE_NET_I40E
15055 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15056 #endif
15057 
15058 	switch (ret) {
15059 	case 0:
15060 		break;
15061 	case -ENODEV:
15062 		printf("invalid port_id %d\n", res->port_id);
15063 		break;
15064 	case -ENOTSUP:
15065 		printf("function not implemented\n");
15066 		break;
15067 	default:
15068 		printf("programming error: (%s)\n", strerror(-ret));
15069 	}
15070 }
15071 
15072 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15073 	.f = cmd_pctype_mapping_reset_parsed,
15074 	.data = NULL,
15075 	.help_str = "port config <port_id> pctype mapping reset",
15076 	.tokens = {
15077 		(void *)&cmd_pctype_mapping_reset_port,
15078 		(void *)&cmd_pctype_mapping_reset_config,
15079 		(void *)&cmd_pctype_mapping_reset_port_id,
15080 		(void *)&cmd_pctype_mapping_reset_pctype,
15081 		(void *)&cmd_pctype_mapping_reset_mapping,
15082 		(void *)&cmd_pctype_mapping_reset_reset,
15083 		NULL,
15084 	},
15085 };
15086 
15087 /* show port pctype mapping */
15088 
15089 /* Common result structure for show port pctype mapping */
15090 struct cmd_pctype_mapping_get_result {
15091 	cmdline_fixed_string_t show;
15092 	cmdline_fixed_string_t port;
15093 	portid_t port_id;
15094 	cmdline_fixed_string_t pctype;
15095 	cmdline_fixed_string_t mapping;
15096 };
15097 
15098 /* Common CLI fields for pctype mapping get */
15099 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15100 	TOKEN_STRING_INITIALIZER
15101 		(struct cmd_pctype_mapping_get_result,
15102 		 show, "show");
15103 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15104 	TOKEN_STRING_INITIALIZER
15105 		(struct cmd_pctype_mapping_get_result,
15106 		 port, "port");
15107 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15108 	TOKEN_NUM_INITIALIZER
15109 		(struct cmd_pctype_mapping_get_result,
15110 		 port_id, RTE_UINT16);
15111 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15112 	TOKEN_STRING_INITIALIZER
15113 		(struct cmd_pctype_mapping_get_result,
15114 		 pctype, "pctype");
15115 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15116 	TOKEN_STRING_INITIALIZER
15117 		(struct cmd_pctype_mapping_get_result,
15118 		 mapping, "mapping");
15119 
15120 static void
15121 cmd_pctype_mapping_get_parsed(
15122 	void *parsed_result,
15123 	__rte_unused struct cmdline *cl,
15124 	__rte_unused void *data)
15125 {
15126 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15127 	int ret = -ENOTSUP;
15128 #ifdef RTE_NET_I40E
15129 	struct rte_pmd_i40e_flow_type_mapping
15130 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15131 	int i, j, first_pctype;
15132 #endif
15133 
15134 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15135 		return;
15136 
15137 #ifdef RTE_NET_I40E
15138 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15139 #endif
15140 
15141 	switch (ret) {
15142 	case 0:
15143 		break;
15144 	case -ENODEV:
15145 		printf("invalid port_id %d\n", res->port_id);
15146 		return;
15147 	case -ENOTSUP:
15148 		printf("function not implemented\n");
15149 		return;
15150 	default:
15151 		printf("programming error: (%s)\n", strerror(-ret));
15152 		return;
15153 	}
15154 
15155 #ifdef RTE_NET_I40E
15156 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15157 		if (mapping[i].pctype != 0ULL) {
15158 			first_pctype = 1;
15159 
15160 			printf("pctype: ");
15161 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15162 				if (mapping[i].pctype & (1ULL << j)) {
15163 					printf(first_pctype ?
15164 					       "%02d" : ",%02d", j);
15165 					first_pctype = 0;
15166 				}
15167 			}
15168 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15169 		}
15170 	}
15171 #endif
15172 }
15173 
15174 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15175 	.f = cmd_pctype_mapping_get_parsed,
15176 	.data = NULL,
15177 	.help_str = "show port <port_id> pctype mapping",
15178 	.tokens = {
15179 		(void *)&cmd_pctype_mapping_get_show,
15180 		(void *)&cmd_pctype_mapping_get_port,
15181 		(void *)&cmd_pctype_mapping_get_port_id,
15182 		(void *)&cmd_pctype_mapping_get_pctype,
15183 		(void *)&cmd_pctype_mapping_get_mapping,
15184 		NULL,
15185 	},
15186 };
15187 
15188 /* port config pctype mapping update */
15189 
15190 /* Common result structure for port config pctype mapping update */
15191 struct cmd_pctype_mapping_update_result {
15192 	cmdline_fixed_string_t port;
15193 	cmdline_fixed_string_t config;
15194 	portid_t port_id;
15195 	cmdline_fixed_string_t pctype;
15196 	cmdline_fixed_string_t mapping;
15197 	cmdline_fixed_string_t update;
15198 	cmdline_fixed_string_t pctype_list;
15199 	uint16_t flow_type;
15200 };
15201 
15202 /* Common CLI fields for pctype mapping update*/
15203 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15204 	TOKEN_STRING_INITIALIZER
15205 		(struct cmd_pctype_mapping_update_result,
15206 		 port, "port");
15207 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15208 	TOKEN_STRING_INITIALIZER
15209 		(struct cmd_pctype_mapping_update_result,
15210 		 config, "config");
15211 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15212 	TOKEN_NUM_INITIALIZER
15213 		(struct cmd_pctype_mapping_update_result,
15214 		 port_id, RTE_UINT16);
15215 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15216 	TOKEN_STRING_INITIALIZER
15217 		(struct cmd_pctype_mapping_update_result,
15218 		 pctype, "pctype");
15219 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15220 	TOKEN_STRING_INITIALIZER
15221 		(struct cmd_pctype_mapping_update_result,
15222 		 mapping, "mapping");
15223 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15224 	TOKEN_STRING_INITIALIZER
15225 		(struct cmd_pctype_mapping_update_result,
15226 		 update, "update");
15227 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15228 	TOKEN_STRING_INITIALIZER
15229 		(struct cmd_pctype_mapping_update_result,
15230 		 pctype_list, NULL);
15231 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15232 	TOKEN_NUM_INITIALIZER
15233 		(struct cmd_pctype_mapping_update_result,
15234 		 flow_type, RTE_UINT16);
15235 
15236 static void
15237 cmd_pctype_mapping_update_parsed(
15238 	void *parsed_result,
15239 	__rte_unused struct cmdline *cl,
15240 	__rte_unused void *data)
15241 {
15242 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15243 	int ret = -ENOTSUP;
15244 #ifdef RTE_NET_I40E
15245 	struct rte_pmd_i40e_flow_type_mapping mapping;
15246 	unsigned int i;
15247 	unsigned int nb_item;
15248 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15249 #endif
15250 
15251 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15252 		return;
15253 
15254 #ifdef RTE_NET_I40E
15255 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15256 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15257 	mapping.flow_type = res->flow_type;
15258 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15259 		mapping.pctype |= (1ULL << pctype_list[i]);
15260 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15261 						&mapping,
15262 						1,
15263 						0);
15264 #endif
15265 
15266 	switch (ret) {
15267 	case 0:
15268 		break;
15269 	case -EINVAL:
15270 		printf("invalid pctype or flow type\n");
15271 		break;
15272 	case -ENODEV:
15273 		printf("invalid port_id %d\n", res->port_id);
15274 		break;
15275 	case -ENOTSUP:
15276 		printf("function not implemented\n");
15277 		break;
15278 	default:
15279 		printf("programming error: (%s)\n", strerror(-ret));
15280 	}
15281 }
15282 
15283 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15284 	.f = cmd_pctype_mapping_update_parsed,
15285 	.data = NULL,
15286 	.help_str = "port config <port_id> pctype mapping update"
15287 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15288 	.tokens = {
15289 		(void *)&cmd_pctype_mapping_update_port,
15290 		(void *)&cmd_pctype_mapping_update_config,
15291 		(void *)&cmd_pctype_mapping_update_port_id,
15292 		(void *)&cmd_pctype_mapping_update_pctype,
15293 		(void *)&cmd_pctype_mapping_update_mapping,
15294 		(void *)&cmd_pctype_mapping_update_update,
15295 		(void *)&cmd_pctype_mapping_update_pc_type,
15296 		(void *)&cmd_pctype_mapping_update_flow_type,
15297 		NULL,
15298 	},
15299 };
15300 
15301 /* ptype mapping get */
15302 
15303 /* Common result structure for ptype mapping get */
15304 struct cmd_ptype_mapping_get_result {
15305 	cmdline_fixed_string_t ptype;
15306 	cmdline_fixed_string_t mapping;
15307 	cmdline_fixed_string_t get;
15308 	portid_t port_id;
15309 	uint8_t valid_only;
15310 };
15311 
15312 /* Common CLI fields for ptype mapping get */
15313 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15314 	TOKEN_STRING_INITIALIZER
15315 		(struct cmd_ptype_mapping_get_result,
15316 		 ptype, "ptype");
15317 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15318 	TOKEN_STRING_INITIALIZER
15319 		(struct cmd_ptype_mapping_get_result,
15320 		 mapping, "mapping");
15321 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15322 	TOKEN_STRING_INITIALIZER
15323 		(struct cmd_ptype_mapping_get_result,
15324 		 get, "get");
15325 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15326 	TOKEN_NUM_INITIALIZER
15327 		(struct cmd_ptype_mapping_get_result,
15328 		 port_id, RTE_UINT16);
15329 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15330 	TOKEN_NUM_INITIALIZER
15331 		(struct cmd_ptype_mapping_get_result,
15332 		 valid_only, RTE_UINT8);
15333 
15334 static void
15335 cmd_ptype_mapping_get_parsed(
15336 	void *parsed_result,
15337 	__rte_unused struct cmdline *cl,
15338 	__rte_unused void *data)
15339 {
15340 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15341 	int ret = -ENOTSUP;
15342 #ifdef RTE_NET_I40E
15343 	int max_ptype_num = 256;
15344 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15345 	uint16_t count;
15346 	int i;
15347 #endif
15348 
15349 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15350 		return;
15351 
15352 #ifdef RTE_NET_I40E
15353 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15354 					mapping,
15355 					max_ptype_num,
15356 					&count,
15357 					res->valid_only);
15358 #endif
15359 
15360 	switch (ret) {
15361 	case 0:
15362 		break;
15363 	case -ENODEV:
15364 		printf("invalid port_id %d\n", res->port_id);
15365 		break;
15366 	case -ENOTSUP:
15367 		printf("function not implemented\n");
15368 		break;
15369 	default:
15370 		printf("programming error: (%s)\n", strerror(-ret));
15371 	}
15372 
15373 #ifdef RTE_NET_I40E
15374 	if (!ret) {
15375 		for (i = 0; i < count; i++)
15376 			printf("%3d\t0x%08x\n",
15377 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15378 	}
15379 #endif
15380 }
15381 
15382 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15383 	.f = cmd_ptype_mapping_get_parsed,
15384 	.data = NULL,
15385 	.help_str = "ptype mapping get <port_id> <valid_only>",
15386 	.tokens = {
15387 		(void *)&cmd_ptype_mapping_get_ptype,
15388 		(void *)&cmd_ptype_mapping_get_mapping,
15389 		(void *)&cmd_ptype_mapping_get_get,
15390 		(void *)&cmd_ptype_mapping_get_port_id,
15391 		(void *)&cmd_ptype_mapping_get_valid_only,
15392 		NULL,
15393 	},
15394 };
15395 
15396 /* ptype mapping replace */
15397 
15398 /* Common result structure for ptype mapping replace */
15399 struct cmd_ptype_mapping_replace_result {
15400 	cmdline_fixed_string_t ptype;
15401 	cmdline_fixed_string_t mapping;
15402 	cmdline_fixed_string_t replace;
15403 	portid_t port_id;
15404 	uint32_t target;
15405 	uint8_t mask;
15406 	uint32_t pkt_type;
15407 };
15408 
15409 /* Common CLI fields for ptype mapping replace */
15410 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15411 	TOKEN_STRING_INITIALIZER
15412 		(struct cmd_ptype_mapping_replace_result,
15413 		 ptype, "ptype");
15414 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15415 	TOKEN_STRING_INITIALIZER
15416 		(struct cmd_ptype_mapping_replace_result,
15417 		 mapping, "mapping");
15418 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15419 	TOKEN_STRING_INITIALIZER
15420 		(struct cmd_ptype_mapping_replace_result,
15421 		 replace, "replace");
15422 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15423 	TOKEN_NUM_INITIALIZER
15424 		(struct cmd_ptype_mapping_replace_result,
15425 		 port_id, RTE_UINT16);
15426 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15427 	TOKEN_NUM_INITIALIZER
15428 		(struct cmd_ptype_mapping_replace_result,
15429 		 target, RTE_UINT32);
15430 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15431 	TOKEN_NUM_INITIALIZER
15432 		(struct cmd_ptype_mapping_replace_result,
15433 		 mask, RTE_UINT8);
15434 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15435 	TOKEN_NUM_INITIALIZER
15436 		(struct cmd_ptype_mapping_replace_result,
15437 		 pkt_type, RTE_UINT32);
15438 
15439 static void
15440 cmd_ptype_mapping_replace_parsed(
15441 	void *parsed_result,
15442 	__rte_unused struct cmdline *cl,
15443 	__rte_unused void *data)
15444 {
15445 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15446 	int ret = -ENOTSUP;
15447 
15448 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15449 		return;
15450 
15451 #ifdef RTE_NET_I40E
15452 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15453 					res->target,
15454 					res->mask,
15455 					res->pkt_type);
15456 #endif
15457 
15458 	switch (ret) {
15459 	case 0:
15460 		break;
15461 	case -EINVAL:
15462 		printf("invalid ptype 0x%8x or 0x%8x\n",
15463 				res->target, res->pkt_type);
15464 		break;
15465 	case -ENODEV:
15466 		printf("invalid port_id %d\n", res->port_id);
15467 		break;
15468 	case -ENOTSUP:
15469 		printf("function not implemented\n");
15470 		break;
15471 	default:
15472 		printf("programming error: (%s)\n", strerror(-ret));
15473 	}
15474 }
15475 
15476 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15477 	.f = cmd_ptype_mapping_replace_parsed,
15478 	.data = NULL,
15479 	.help_str =
15480 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15481 	.tokens = {
15482 		(void *)&cmd_ptype_mapping_replace_ptype,
15483 		(void *)&cmd_ptype_mapping_replace_mapping,
15484 		(void *)&cmd_ptype_mapping_replace_replace,
15485 		(void *)&cmd_ptype_mapping_replace_port_id,
15486 		(void *)&cmd_ptype_mapping_replace_target,
15487 		(void *)&cmd_ptype_mapping_replace_mask,
15488 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15489 		NULL,
15490 	},
15491 };
15492 
15493 /* ptype mapping reset */
15494 
15495 /* Common result structure for ptype mapping reset */
15496 struct cmd_ptype_mapping_reset_result {
15497 	cmdline_fixed_string_t ptype;
15498 	cmdline_fixed_string_t mapping;
15499 	cmdline_fixed_string_t reset;
15500 	portid_t port_id;
15501 };
15502 
15503 /* Common CLI fields for ptype mapping reset*/
15504 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15505 	TOKEN_STRING_INITIALIZER
15506 		(struct cmd_ptype_mapping_reset_result,
15507 		 ptype, "ptype");
15508 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15509 	TOKEN_STRING_INITIALIZER
15510 		(struct cmd_ptype_mapping_reset_result,
15511 		 mapping, "mapping");
15512 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15513 	TOKEN_STRING_INITIALIZER
15514 		(struct cmd_ptype_mapping_reset_result,
15515 		 reset, "reset");
15516 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15517 	TOKEN_NUM_INITIALIZER
15518 		(struct cmd_ptype_mapping_reset_result,
15519 		 port_id, RTE_UINT16);
15520 
15521 static void
15522 cmd_ptype_mapping_reset_parsed(
15523 	void *parsed_result,
15524 	__rte_unused struct cmdline *cl,
15525 	__rte_unused void *data)
15526 {
15527 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15528 	int ret = -ENOTSUP;
15529 
15530 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15531 		return;
15532 
15533 #ifdef RTE_NET_I40E
15534 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15535 #endif
15536 
15537 	switch (ret) {
15538 	case 0:
15539 		break;
15540 	case -ENODEV:
15541 		printf("invalid port_id %d\n", res->port_id);
15542 		break;
15543 	case -ENOTSUP:
15544 		printf("function not implemented\n");
15545 		break;
15546 	default:
15547 		printf("programming error: (%s)\n", strerror(-ret));
15548 	}
15549 }
15550 
15551 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15552 	.f = cmd_ptype_mapping_reset_parsed,
15553 	.data = NULL,
15554 	.help_str = "ptype mapping reset <port_id>",
15555 	.tokens = {
15556 		(void *)&cmd_ptype_mapping_reset_ptype,
15557 		(void *)&cmd_ptype_mapping_reset_mapping,
15558 		(void *)&cmd_ptype_mapping_reset_reset,
15559 		(void *)&cmd_ptype_mapping_reset_port_id,
15560 		NULL,
15561 	},
15562 };
15563 
15564 /* ptype mapping update */
15565 
15566 /* Common result structure for ptype mapping update */
15567 struct cmd_ptype_mapping_update_result {
15568 	cmdline_fixed_string_t ptype;
15569 	cmdline_fixed_string_t mapping;
15570 	cmdline_fixed_string_t reset;
15571 	portid_t port_id;
15572 	uint8_t hw_ptype;
15573 	uint32_t sw_ptype;
15574 };
15575 
15576 /* Common CLI fields for ptype mapping update*/
15577 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15578 	TOKEN_STRING_INITIALIZER
15579 		(struct cmd_ptype_mapping_update_result,
15580 		 ptype, "ptype");
15581 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15582 	TOKEN_STRING_INITIALIZER
15583 		(struct cmd_ptype_mapping_update_result,
15584 		 mapping, "mapping");
15585 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15586 	TOKEN_STRING_INITIALIZER
15587 		(struct cmd_ptype_mapping_update_result,
15588 		 reset, "update");
15589 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15590 	TOKEN_NUM_INITIALIZER
15591 		(struct cmd_ptype_mapping_update_result,
15592 		 port_id, RTE_UINT16);
15593 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15594 	TOKEN_NUM_INITIALIZER
15595 		(struct cmd_ptype_mapping_update_result,
15596 		 hw_ptype, RTE_UINT8);
15597 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15598 	TOKEN_NUM_INITIALIZER
15599 		(struct cmd_ptype_mapping_update_result,
15600 		 sw_ptype, RTE_UINT32);
15601 
15602 static void
15603 cmd_ptype_mapping_update_parsed(
15604 	void *parsed_result,
15605 	__rte_unused struct cmdline *cl,
15606 	__rte_unused void *data)
15607 {
15608 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15609 	int ret = -ENOTSUP;
15610 #ifdef RTE_NET_I40E
15611 	struct rte_pmd_i40e_ptype_mapping mapping;
15612 #endif
15613 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15614 		return;
15615 
15616 #ifdef RTE_NET_I40E
15617 	mapping.hw_ptype = res->hw_ptype;
15618 	mapping.sw_ptype = res->sw_ptype;
15619 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15620 						&mapping,
15621 						1,
15622 						0);
15623 #endif
15624 
15625 	switch (ret) {
15626 	case 0:
15627 		break;
15628 	case -EINVAL:
15629 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
15630 		break;
15631 	case -ENODEV:
15632 		printf("invalid port_id %d\n", res->port_id);
15633 		break;
15634 	case -ENOTSUP:
15635 		printf("function not implemented\n");
15636 		break;
15637 	default:
15638 		printf("programming error: (%s)\n", strerror(-ret));
15639 	}
15640 }
15641 
15642 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15643 	.f = cmd_ptype_mapping_update_parsed,
15644 	.data = NULL,
15645 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15646 	.tokens = {
15647 		(void *)&cmd_ptype_mapping_update_ptype,
15648 		(void *)&cmd_ptype_mapping_update_mapping,
15649 		(void *)&cmd_ptype_mapping_update_update,
15650 		(void *)&cmd_ptype_mapping_update_port_id,
15651 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15652 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15653 		NULL,
15654 	},
15655 };
15656 
15657 /* Common result structure for file commands */
15658 struct cmd_cmdfile_result {
15659 	cmdline_fixed_string_t load;
15660 	cmdline_fixed_string_t filename;
15661 };
15662 
15663 /* Common CLI fields for file commands */
15664 cmdline_parse_token_string_t cmd_load_cmdfile =
15665 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15666 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15667 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15668 
15669 static void
15670 cmd_load_from_file_parsed(
15671 	void *parsed_result,
15672 	__rte_unused struct cmdline *cl,
15673 	__rte_unused void *data)
15674 {
15675 	struct cmd_cmdfile_result *res = parsed_result;
15676 
15677 	cmdline_read_from_file(res->filename);
15678 }
15679 
15680 cmdline_parse_inst_t cmd_load_from_file = {
15681 	.f = cmd_load_from_file_parsed,
15682 	.data = NULL,
15683 	.help_str = "load <filename>",
15684 	.tokens = {
15685 		(void *)&cmd_load_cmdfile,
15686 		(void *)&cmd_load_cmdfile_filename,
15687 		NULL,
15688 	},
15689 };
15690 
15691 /* Get Rx offloads capabilities */
15692 struct cmd_rx_offload_get_capa_result {
15693 	cmdline_fixed_string_t show;
15694 	cmdline_fixed_string_t port;
15695 	portid_t port_id;
15696 	cmdline_fixed_string_t rx_offload;
15697 	cmdline_fixed_string_t capabilities;
15698 };
15699 
15700 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15701 	TOKEN_STRING_INITIALIZER
15702 		(struct cmd_rx_offload_get_capa_result,
15703 		 show, "show");
15704 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15705 	TOKEN_STRING_INITIALIZER
15706 		(struct cmd_rx_offload_get_capa_result,
15707 		 port, "port");
15708 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15709 	TOKEN_NUM_INITIALIZER
15710 		(struct cmd_rx_offload_get_capa_result,
15711 		 port_id, RTE_UINT16);
15712 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15713 	TOKEN_STRING_INITIALIZER
15714 		(struct cmd_rx_offload_get_capa_result,
15715 		 rx_offload, "rx_offload");
15716 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15717 	TOKEN_STRING_INITIALIZER
15718 		(struct cmd_rx_offload_get_capa_result,
15719 		 capabilities, "capabilities");
15720 
15721 static void
15722 print_rx_offloads(uint64_t offloads)
15723 {
15724 	uint64_t single_offload;
15725 	int begin;
15726 	int end;
15727 	int bit;
15728 
15729 	if (offloads == 0)
15730 		return;
15731 
15732 	begin = __builtin_ctzll(offloads);
15733 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15734 
15735 	single_offload = 1ULL << begin;
15736 	for (bit = begin; bit < end; bit++) {
15737 		if (offloads & single_offload)
15738 			printf(" %s",
15739 			       rte_eth_dev_rx_offload_name(single_offload));
15740 		single_offload <<= 1;
15741 	}
15742 }
15743 
15744 static void
15745 cmd_rx_offload_get_capa_parsed(
15746 	void *parsed_result,
15747 	__rte_unused struct cmdline *cl,
15748 	__rte_unused void *data)
15749 {
15750 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
15751 	struct rte_eth_dev_info dev_info;
15752 	portid_t port_id = res->port_id;
15753 	uint64_t queue_offloads;
15754 	uint64_t port_offloads;
15755 	int ret;
15756 
15757 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15758 	if (ret != 0)
15759 		return;
15760 
15761 	queue_offloads = dev_info.rx_queue_offload_capa;
15762 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15763 
15764 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
15765 	printf("  Per Queue :");
15766 	print_rx_offloads(queue_offloads);
15767 
15768 	printf("\n");
15769 	printf("  Per Port  :");
15770 	print_rx_offloads(port_offloads);
15771 	printf("\n\n");
15772 }
15773 
15774 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15775 	.f = cmd_rx_offload_get_capa_parsed,
15776 	.data = NULL,
15777 	.help_str = "show port <port_id> rx_offload capabilities",
15778 	.tokens = {
15779 		(void *)&cmd_rx_offload_get_capa_show,
15780 		(void *)&cmd_rx_offload_get_capa_port,
15781 		(void *)&cmd_rx_offload_get_capa_port_id,
15782 		(void *)&cmd_rx_offload_get_capa_rx_offload,
15783 		(void *)&cmd_rx_offload_get_capa_capabilities,
15784 		NULL,
15785 	}
15786 };
15787 
15788 /* Get Rx offloads configuration */
15789 struct cmd_rx_offload_get_configuration_result {
15790 	cmdline_fixed_string_t show;
15791 	cmdline_fixed_string_t port;
15792 	portid_t port_id;
15793 	cmdline_fixed_string_t rx_offload;
15794 	cmdline_fixed_string_t configuration;
15795 };
15796 
15797 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15798 	TOKEN_STRING_INITIALIZER
15799 		(struct cmd_rx_offload_get_configuration_result,
15800 		 show, "show");
15801 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15802 	TOKEN_STRING_INITIALIZER
15803 		(struct cmd_rx_offload_get_configuration_result,
15804 		 port, "port");
15805 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15806 	TOKEN_NUM_INITIALIZER
15807 		(struct cmd_rx_offload_get_configuration_result,
15808 		 port_id, RTE_UINT16);
15809 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15810 	TOKEN_STRING_INITIALIZER
15811 		(struct cmd_rx_offload_get_configuration_result,
15812 		 rx_offload, "rx_offload");
15813 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15814 	TOKEN_STRING_INITIALIZER
15815 		(struct cmd_rx_offload_get_configuration_result,
15816 		 configuration, "configuration");
15817 
15818 static void
15819 cmd_rx_offload_get_configuration_parsed(
15820 	void *parsed_result,
15821 	__rte_unused struct cmdline *cl,
15822 	__rte_unused void *data)
15823 {
15824 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15825 	struct rte_eth_dev_info dev_info;
15826 	portid_t port_id = res->port_id;
15827 	struct rte_port *port = &ports[port_id];
15828 	uint64_t port_offloads;
15829 	uint64_t queue_offloads;
15830 	uint16_t nb_rx_queues;
15831 	int q;
15832 	int ret;
15833 
15834 	printf("Rx Offloading Configuration of port %d :\n", port_id);
15835 
15836 	port_offloads = port->dev_conf.rxmode.offloads;
15837 	printf("  Port :");
15838 	print_rx_offloads(port_offloads);
15839 	printf("\n");
15840 
15841 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15842 	if (ret != 0)
15843 		return;
15844 
15845 	nb_rx_queues = dev_info.nb_rx_queues;
15846 	for (q = 0; q < nb_rx_queues; q++) {
15847 		queue_offloads = port->rx_conf[q].offloads;
15848 		printf("  Queue[%2d] :", q);
15849 		print_rx_offloads(queue_offloads);
15850 		printf("\n");
15851 	}
15852 	printf("\n");
15853 }
15854 
15855 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15856 	.f = cmd_rx_offload_get_configuration_parsed,
15857 	.data = NULL,
15858 	.help_str = "show port <port_id> rx_offload configuration",
15859 	.tokens = {
15860 		(void *)&cmd_rx_offload_get_configuration_show,
15861 		(void *)&cmd_rx_offload_get_configuration_port,
15862 		(void *)&cmd_rx_offload_get_configuration_port_id,
15863 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
15864 		(void *)&cmd_rx_offload_get_configuration_configuration,
15865 		NULL,
15866 	}
15867 };
15868 
15869 /* Enable/Disable a per port offloading */
15870 struct cmd_config_per_port_rx_offload_result {
15871 	cmdline_fixed_string_t port;
15872 	cmdline_fixed_string_t config;
15873 	portid_t port_id;
15874 	cmdline_fixed_string_t rx_offload;
15875 	cmdline_fixed_string_t offload;
15876 	cmdline_fixed_string_t on_off;
15877 };
15878 
15879 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15880 	TOKEN_STRING_INITIALIZER
15881 		(struct cmd_config_per_port_rx_offload_result,
15882 		 port, "port");
15883 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15884 	TOKEN_STRING_INITIALIZER
15885 		(struct cmd_config_per_port_rx_offload_result,
15886 		 config, "config");
15887 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15888 	TOKEN_NUM_INITIALIZER
15889 		(struct cmd_config_per_port_rx_offload_result,
15890 		 port_id, RTE_UINT16);
15891 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15892 	TOKEN_STRING_INITIALIZER
15893 		(struct cmd_config_per_port_rx_offload_result,
15894 		 rx_offload, "rx_offload");
15895 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15896 	TOKEN_STRING_INITIALIZER
15897 		(struct cmd_config_per_port_rx_offload_result,
15898 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15899 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15900 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15901 			   "scatter#buffer_split#timestamp#security#"
15902 			   "keep_crc#rss_hash");
15903 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15904 	TOKEN_STRING_INITIALIZER
15905 		(struct cmd_config_per_port_rx_offload_result,
15906 		 on_off, "on#off");
15907 
15908 static uint64_t
15909 search_rx_offload(const char *name)
15910 {
15911 	uint64_t single_offload;
15912 	const char *single_name;
15913 	int found = 0;
15914 	unsigned int bit;
15915 
15916 	single_offload = 1;
15917 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15918 		single_name = rte_eth_dev_rx_offload_name(single_offload);
15919 		if (!strcasecmp(single_name, name)) {
15920 			found = 1;
15921 			break;
15922 		}
15923 		single_offload <<= 1;
15924 	}
15925 
15926 	if (found)
15927 		return single_offload;
15928 
15929 	return 0;
15930 }
15931 
15932 static void
15933 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15934 				__rte_unused struct cmdline *cl,
15935 				__rte_unused void *data)
15936 {
15937 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15938 	portid_t port_id = res->port_id;
15939 	struct rte_eth_dev_info dev_info;
15940 	struct rte_port *port = &ports[port_id];
15941 	uint64_t single_offload;
15942 	uint16_t nb_rx_queues;
15943 	int q;
15944 	int ret;
15945 
15946 	if (port->port_status != RTE_PORT_STOPPED) {
15947 		printf("Error: Can't config offload when Port %d "
15948 		       "is not stopped\n", port_id);
15949 		return;
15950 	}
15951 
15952 	single_offload = search_rx_offload(res->offload);
15953 	if (single_offload == 0) {
15954 		printf("Unknown offload name: %s\n", res->offload);
15955 		return;
15956 	}
15957 
15958 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15959 	if (ret != 0)
15960 		return;
15961 
15962 	nb_rx_queues = dev_info.nb_rx_queues;
15963 	if (!strcmp(res->on_off, "on")) {
15964 		port->dev_conf.rxmode.offloads |= single_offload;
15965 		for (q = 0; q < nb_rx_queues; q++)
15966 			port->rx_conf[q].offloads |= single_offload;
15967 	} else {
15968 		port->dev_conf.rxmode.offloads &= ~single_offload;
15969 		for (q = 0; q < nb_rx_queues; q++)
15970 			port->rx_conf[q].offloads &= ~single_offload;
15971 	}
15972 
15973 	cmd_reconfig_device_queue(port_id, 1, 1);
15974 }
15975 
15976 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15977 	.f = cmd_config_per_port_rx_offload_parsed,
15978 	.data = NULL,
15979 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15980 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15981 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
15982 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
15983 		    "keep_crc|rss_hash on|off",
15984 	.tokens = {
15985 		(void *)&cmd_config_per_port_rx_offload_result_port,
15986 		(void *)&cmd_config_per_port_rx_offload_result_config,
15987 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
15988 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15989 		(void *)&cmd_config_per_port_rx_offload_result_offload,
15990 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
15991 		NULL,
15992 	}
15993 };
15994 
15995 /* Enable/Disable a per queue offloading */
15996 struct cmd_config_per_queue_rx_offload_result {
15997 	cmdline_fixed_string_t port;
15998 	portid_t port_id;
15999 	cmdline_fixed_string_t rxq;
16000 	uint16_t queue_id;
16001 	cmdline_fixed_string_t rx_offload;
16002 	cmdline_fixed_string_t offload;
16003 	cmdline_fixed_string_t on_off;
16004 };
16005 
16006 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16007 	TOKEN_STRING_INITIALIZER
16008 		(struct cmd_config_per_queue_rx_offload_result,
16009 		 port, "port");
16010 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16011 	TOKEN_NUM_INITIALIZER
16012 		(struct cmd_config_per_queue_rx_offload_result,
16013 		 port_id, RTE_UINT16);
16014 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16015 	TOKEN_STRING_INITIALIZER
16016 		(struct cmd_config_per_queue_rx_offload_result,
16017 		 rxq, "rxq");
16018 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16019 	TOKEN_NUM_INITIALIZER
16020 		(struct cmd_config_per_queue_rx_offload_result,
16021 		 queue_id, RTE_UINT16);
16022 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16023 	TOKEN_STRING_INITIALIZER
16024 		(struct cmd_config_per_queue_rx_offload_result,
16025 		 rx_offload, "rx_offload");
16026 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16027 	TOKEN_STRING_INITIALIZER
16028 		(struct cmd_config_per_queue_rx_offload_result,
16029 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16030 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16031 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16032 			   "scatter#buffer_split#timestamp#security#keep_crc");
16033 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16034 	TOKEN_STRING_INITIALIZER
16035 		(struct cmd_config_per_queue_rx_offload_result,
16036 		 on_off, "on#off");
16037 
16038 static void
16039 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16040 				__rte_unused struct cmdline *cl,
16041 				__rte_unused void *data)
16042 {
16043 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16044 	struct rte_eth_dev_info dev_info;
16045 	portid_t port_id = res->port_id;
16046 	uint16_t queue_id = res->queue_id;
16047 	struct rte_port *port = &ports[port_id];
16048 	uint64_t single_offload;
16049 	int ret;
16050 
16051 	if (port->port_status != RTE_PORT_STOPPED) {
16052 		printf("Error: Can't config offload when Port %d "
16053 		       "is not stopped\n", port_id);
16054 		return;
16055 	}
16056 
16057 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16058 	if (ret != 0)
16059 		return;
16060 
16061 	if (queue_id >= dev_info.nb_rx_queues) {
16062 		printf("Error: input queue_id should be 0 ... "
16063 		       "%d\n", dev_info.nb_rx_queues - 1);
16064 		return;
16065 	}
16066 
16067 	single_offload = search_rx_offload(res->offload);
16068 	if (single_offload == 0) {
16069 		printf("Unknown offload name: %s\n", res->offload);
16070 		return;
16071 	}
16072 
16073 	if (!strcmp(res->on_off, "on"))
16074 		port->rx_conf[queue_id].offloads |= single_offload;
16075 	else
16076 		port->rx_conf[queue_id].offloads &= ~single_offload;
16077 
16078 	cmd_reconfig_device_queue(port_id, 1, 1);
16079 }
16080 
16081 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16082 	.f = cmd_config_per_queue_rx_offload_parsed,
16083 	.data = NULL,
16084 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
16085 		    "vlan_strip|ipv4_cksum|"
16086 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16087 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16088 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16089 		    "keep_crc on|off",
16090 	.tokens = {
16091 		(void *)&cmd_config_per_queue_rx_offload_result_port,
16092 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
16093 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
16094 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16095 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16096 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
16097 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
16098 		NULL,
16099 	}
16100 };
16101 
16102 /* Get Tx offloads capabilities */
16103 struct cmd_tx_offload_get_capa_result {
16104 	cmdline_fixed_string_t show;
16105 	cmdline_fixed_string_t port;
16106 	portid_t port_id;
16107 	cmdline_fixed_string_t tx_offload;
16108 	cmdline_fixed_string_t capabilities;
16109 };
16110 
16111 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16112 	TOKEN_STRING_INITIALIZER
16113 		(struct cmd_tx_offload_get_capa_result,
16114 		 show, "show");
16115 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16116 	TOKEN_STRING_INITIALIZER
16117 		(struct cmd_tx_offload_get_capa_result,
16118 		 port, "port");
16119 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16120 	TOKEN_NUM_INITIALIZER
16121 		(struct cmd_tx_offload_get_capa_result,
16122 		 port_id, RTE_UINT16);
16123 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16124 	TOKEN_STRING_INITIALIZER
16125 		(struct cmd_tx_offload_get_capa_result,
16126 		 tx_offload, "tx_offload");
16127 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16128 	TOKEN_STRING_INITIALIZER
16129 		(struct cmd_tx_offload_get_capa_result,
16130 		 capabilities, "capabilities");
16131 
16132 static void
16133 print_tx_offloads(uint64_t offloads)
16134 {
16135 	uint64_t single_offload;
16136 	int begin;
16137 	int end;
16138 	int bit;
16139 
16140 	if (offloads == 0)
16141 		return;
16142 
16143 	begin = __builtin_ctzll(offloads);
16144 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16145 
16146 	single_offload = 1ULL << begin;
16147 	for (bit = begin; bit < end; bit++) {
16148 		if (offloads & single_offload)
16149 			printf(" %s",
16150 			       rte_eth_dev_tx_offload_name(single_offload));
16151 		single_offload <<= 1;
16152 	}
16153 }
16154 
16155 static void
16156 cmd_tx_offload_get_capa_parsed(
16157 	void *parsed_result,
16158 	__rte_unused struct cmdline *cl,
16159 	__rte_unused void *data)
16160 {
16161 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
16162 	struct rte_eth_dev_info dev_info;
16163 	portid_t port_id = res->port_id;
16164 	uint64_t queue_offloads;
16165 	uint64_t port_offloads;
16166 	int ret;
16167 
16168 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16169 	if (ret != 0)
16170 		return;
16171 
16172 	queue_offloads = dev_info.tx_queue_offload_capa;
16173 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16174 
16175 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
16176 	printf("  Per Queue :");
16177 	print_tx_offloads(queue_offloads);
16178 
16179 	printf("\n");
16180 	printf("  Per Port  :");
16181 	print_tx_offloads(port_offloads);
16182 	printf("\n\n");
16183 }
16184 
16185 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16186 	.f = cmd_tx_offload_get_capa_parsed,
16187 	.data = NULL,
16188 	.help_str = "show port <port_id> tx_offload capabilities",
16189 	.tokens = {
16190 		(void *)&cmd_tx_offload_get_capa_show,
16191 		(void *)&cmd_tx_offload_get_capa_port,
16192 		(void *)&cmd_tx_offload_get_capa_port_id,
16193 		(void *)&cmd_tx_offload_get_capa_tx_offload,
16194 		(void *)&cmd_tx_offload_get_capa_capabilities,
16195 		NULL,
16196 	}
16197 };
16198 
16199 /* Get Tx offloads configuration */
16200 struct cmd_tx_offload_get_configuration_result {
16201 	cmdline_fixed_string_t show;
16202 	cmdline_fixed_string_t port;
16203 	portid_t port_id;
16204 	cmdline_fixed_string_t tx_offload;
16205 	cmdline_fixed_string_t configuration;
16206 };
16207 
16208 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16209 	TOKEN_STRING_INITIALIZER
16210 		(struct cmd_tx_offload_get_configuration_result,
16211 		 show, "show");
16212 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16213 	TOKEN_STRING_INITIALIZER
16214 		(struct cmd_tx_offload_get_configuration_result,
16215 		 port, "port");
16216 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16217 	TOKEN_NUM_INITIALIZER
16218 		(struct cmd_tx_offload_get_configuration_result,
16219 		 port_id, RTE_UINT16);
16220 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16221 	TOKEN_STRING_INITIALIZER
16222 		(struct cmd_tx_offload_get_configuration_result,
16223 		 tx_offload, "tx_offload");
16224 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16225 	TOKEN_STRING_INITIALIZER
16226 		(struct cmd_tx_offload_get_configuration_result,
16227 		 configuration, "configuration");
16228 
16229 static void
16230 cmd_tx_offload_get_configuration_parsed(
16231 	void *parsed_result,
16232 	__rte_unused struct cmdline *cl,
16233 	__rte_unused void *data)
16234 {
16235 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16236 	struct rte_eth_dev_info dev_info;
16237 	portid_t port_id = res->port_id;
16238 	struct rte_port *port = &ports[port_id];
16239 	uint64_t port_offloads;
16240 	uint64_t queue_offloads;
16241 	uint16_t nb_tx_queues;
16242 	int q;
16243 	int ret;
16244 
16245 	printf("Tx Offloading Configuration of port %d :\n", port_id);
16246 
16247 	port_offloads = port->dev_conf.txmode.offloads;
16248 	printf("  Port :");
16249 	print_tx_offloads(port_offloads);
16250 	printf("\n");
16251 
16252 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16253 	if (ret != 0)
16254 		return;
16255 
16256 	nb_tx_queues = dev_info.nb_tx_queues;
16257 	for (q = 0; q < nb_tx_queues; q++) {
16258 		queue_offloads = port->tx_conf[q].offloads;
16259 		printf("  Queue[%2d] :", q);
16260 		print_tx_offloads(queue_offloads);
16261 		printf("\n");
16262 	}
16263 	printf("\n");
16264 }
16265 
16266 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16267 	.f = cmd_tx_offload_get_configuration_parsed,
16268 	.data = NULL,
16269 	.help_str = "show port <port_id> tx_offload configuration",
16270 	.tokens = {
16271 		(void *)&cmd_tx_offload_get_configuration_show,
16272 		(void *)&cmd_tx_offload_get_configuration_port,
16273 		(void *)&cmd_tx_offload_get_configuration_port_id,
16274 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
16275 		(void *)&cmd_tx_offload_get_configuration_configuration,
16276 		NULL,
16277 	}
16278 };
16279 
16280 /* Enable/Disable a per port offloading */
16281 struct cmd_config_per_port_tx_offload_result {
16282 	cmdline_fixed_string_t port;
16283 	cmdline_fixed_string_t config;
16284 	portid_t port_id;
16285 	cmdline_fixed_string_t tx_offload;
16286 	cmdline_fixed_string_t offload;
16287 	cmdline_fixed_string_t on_off;
16288 };
16289 
16290 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16291 	TOKEN_STRING_INITIALIZER
16292 		(struct cmd_config_per_port_tx_offload_result,
16293 		 port, "port");
16294 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16295 	TOKEN_STRING_INITIALIZER
16296 		(struct cmd_config_per_port_tx_offload_result,
16297 		 config, "config");
16298 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16299 	TOKEN_NUM_INITIALIZER
16300 		(struct cmd_config_per_port_tx_offload_result,
16301 		 port_id, RTE_UINT16);
16302 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16303 	TOKEN_STRING_INITIALIZER
16304 		(struct cmd_config_per_port_tx_offload_result,
16305 		 tx_offload, "tx_offload");
16306 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16307 	TOKEN_STRING_INITIALIZER
16308 		(struct cmd_config_per_port_tx_offload_result,
16309 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16310 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16311 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16312 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16313 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16314 			  "send_on_timestamp");
16315 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16316 	TOKEN_STRING_INITIALIZER
16317 		(struct cmd_config_per_port_tx_offload_result,
16318 		 on_off, "on#off");
16319 
16320 static uint64_t
16321 search_tx_offload(const char *name)
16322 {
16323 	uint64_t single_offload;
16324 	const char *single_name;
16325 	int found = 0;
16326 	unsigned int bit;
16327 
16328 	single_offload = 1;
16329 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16330 		single_name = rte_eth_dev_tx_offload_name(single_offload);
16331 		if (single_name == NULL)
16332 			break;
16333 		if (!strcasecmp(single_name, name)) {
16334 			found = 1;
16335 			break;
16336 		} else if (!strcasecmp(single_name, "UNKNOWN"))
16337 			break;
16338 		single_offload <<= 1;
16339 	}
16340 
16341 	if (found)
16342 		return single_offload;
16343 
16344 	return 0;
16345 }
16346 
16347 static void
16348 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16349 				__rte_unused struct cmdline *cl,
16350 				__rte_unused void *data)
16351 {
16352 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16353 	portid_t port_id = res->port_id;
16354 	struct rte_eth_dev_info dev_info;
16355 	struct rte_port *port = &ports[port_id];
16356 	uint64_t single_offload;
16357 	uint16_t nb_tx_queues;
16358 	int q;
16359 	int ret;
16360 
16361 	if (port->port_status != RTE_PORT_STOPPED) {
16362 		printf("Error: Can't config offload when Port %d "
16363 		       "is not stopped\n", port_id);
16364 		return;
16365 	}
16366 
16367 	single_offload = search_tx_offload(res->offload);
16368 	if (single_offload == 0) {
16369 		printf("Unknown offload name: %s\n", res->offload);
16370 		return;
16371 	}
16372 
16373 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16374 	if (ret != 0)
16375 		return;
16376 
16377 	nb_tx_queues = dev_info.nb_tx_queues;
16378 	if (!strcmp(res->on_off, "on")) {
16379 		port->dev_conf.txmode.offloads |= single_offload;
16380 		for (q = 0; q < nb_tx_queues; q++)
16381 			port->tx_conf[q].offloads |= single_offload;
16382 	} else {
16383 		port->dev_conf.txmode.offloads &= ~single_offload;
16384 		for (q = 0; q < nb_tx_queues; q++)
16385 			port->tx_conf[q].offloads &= ~single_offload;
16386 	}
16387 
16388 	cmd_reconfig_device_queue(port_id, 1, 1);
16389 }
16390 
16391 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16392 	.f = cmd_config_per_port_tx_offload_parsed,
16393 	.data = NULL,
16394 	.help_str = "port config <port_id> tx_offload "
16395 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16396 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16397 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16398 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16399 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16400 		    "send_on_timestamp on|off",
16401 	.tokens = {
16402 		(void *)&cmd_config_per_port_tx_offload_result_port,
16403 		(void *)&cmd_config_per_port_tx_offload_result_config,
16404 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
16405 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16406 		(void *)&cmd_config_per_port_tx_offload_result_offload,
16407 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
16408 		NULL,
16409 	}
16410 };
16411 
16412 /* Enable/Disable a per queue offloading */
16413 struct cmd_config_per_queue_tx_offload_result {
16414 	cmdline_fixed_string_t port;
16415 	portid_t port_id;
16416 	cmdline_fixed_string_t txq;
16417 	uint16_t queue_id;
16418 	cmdline_fixed_string_t tx_offload;
16419 	cmdline_fixed_string_t offload;
16420 	cmdline_fixed_string_t on_off;
16421 };
16422 
16423 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16424 	TOKEN_STRING_INITIALIZER
16425 		(struct cmd_config_per_queue_tx_offload_result,
16426 		 port, "port");
16427 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16428 	TOKEN_NUM_INITIALIZER
16429 		(struct cmd_config_per_queue_tx_offload_result,
16430 		 port_id, RTE_UINT16);
16431 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16432 	TOKEN_STRING_INITIALIZER
16433 		(struct cmd_config_per_queue_tx_offload_result,
16434 		 txq, "txq");
16435 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16436 	TOKEN_NUM_INITIALIZER
16437 		(struct cmd_config_per_queue_tx_offload_result,
16438 		 queue_id, RTE_UINT16);
16439 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16440 	TOKEN_STRING_INITIALIZER
16441 		(struct cmd_config_per_queue_tx_offload_result,
16442 		 tx_offload, "tx_offload");
16443 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16444 	TOKEN_STRING_INITIALIZER
16445 		(struct cmd_config_per_queue_tx_offload_result,
16446 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16447 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16448 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16449 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16450 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
16451 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16452 	TOKEN_STRING_INITIALIZER
16453 		(struct cmd_config_per_queue_tx_offload_result,
16454 		 on_off, "on#off");
16455 
16456 static void
16457 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16458 				__rte_unused struct cmdline *cl,
16459 				__rte_unused void *data)
16460 {
16461 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16462 	struct rte_eth_dev_info dev_info;
16463 	portid_t port_id = res->port_id;
16464 	uint16_t queue_id = res->queue_id;
16465 	struct rte_port *port = &ports[port_id];
16466 	uint64_t single_offload;
16467 	int ret;
16468 
16469 	if (port->port_status != RTE_PORT_STOPPED) {
16470 		printf("Error: Can't config offload when Port %d "
16471 		       "is not stopped\n", port_id);
16472 		return;
16473 	}
16474 
16475 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16476 	if (ret != 0)
16477 		return;
16478 
16479 	if (queue_id >= dev_info.nb_tx_queues) {
16480 		printf("Error: input queue_id should be 0 ... "
16481 		       "%d\n", dev_info.nb_tx_queues - 1);
16482 		return;
16483 	}
16484 
16485 	single_offload = search_tx_offload(res->offload);
16486 	if (single_offload == 0) {
16487 		printf("Unknown offload name: %s\n", res->offload);
16488 		return;
16489 	}
16490 
16491 	if (!strcmp(res->on_off, "on"))
16492 		port->tx_conf[queue_id].offloads |= single_offload;
16493 	else
16494 		port->tx_conf[queue_id].offloads &= ~single_offload;
16495 
16496 	cmd_reconfig_device_queue(port_id, 1, 1);
16497 }
16498 
16499 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16500 	.f = cmd_config_per_queue_tx_offload_parsed,
16501 	.data = NULL,
16502 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16503 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16504 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16505 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16506 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16507 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16508 		    "on|off",
16509 	.tokens = {
16510 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16511 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16512 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16513 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16514 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16515 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16516 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16517 		NULL,
16518 	}
16519 };
16520 
16521 /* *** configure tx_metadata for specific port *** */
16522 struct cmd_config_tx_metadata_specific_result {
16523 	cmdline_fixed_string_t port;
16524 	cmdline_fixed_string_t keyword;
16525 	uint16_t port_id;
16526 	cmdline_fixed_string_t item;
16527 	uint32_t value;
16528 };
16529 
16530 static void
16531 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16532 				__rte_unused struct cmdline *cl,
16533 				__rte_unused void *data)
16534 {
16535 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16536 
16537 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16538 		return;
16539 	ports[res->port_id].tx_metadata = res->value;
16540 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16541 	if (ports[res->port_id].tx_metadata)
16542 		add_tx_md_callback(res->port_id);
16543 	else
16544 		remove_tx_md_callback(res->port_id);
16545 	rte_flow_dynf_metadata_register();
16546 }
16547 
16548 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16549 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16550 			port, "port");
16551 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16552 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16553 			keyword, "config");
16554 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16555 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16556 			port_id, RTE_UINT16);
16557 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16558 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16559 			item, "tx_metadata");
16560 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16561 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16562 			value, RTE_UINT32);
16563 
16564 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16565 	.f = cmd_config_tx_metadata_specific_parsed,
16566 	.data = NULL,
16567 	.help_str = "port config <port_id> tx_metadata <value>",
16568 	.tokens = {
16569 		(void *)&cmd_config_tx_metadata_specific_port,
16570 		(void *)&cmd_config_tx_metadata_specific_keyword,
16571 		(void *)&cmd_config_tx_metadata_specific_id,
16572 		(void *)&cmd_config_tx_metadata_specific_item,
16573 		(void *)&cmd_config_tx_metadata_specific_value,
16574 		NULL,
16575 	},
16576 };
16577 
16578 /* *** set dynf *** */
16579 struct cmd_config_tx_dynf_specific_result {
16580 	cmdline_fixed_string_t port;
16581 	cmdline_fixed_string_t keyword;
16582 	uint16_t port_id;
16583 	cmdline_fixed_string_t item;
16584 	cmdline_fixed_string_t name;
16585 	cmdline_fixed_string_t value;
16586 };
16587 
16588 static void
16589 cmd_config_dynf_specific_parsed(void *parsed_result,
16590 				__rte_unused struct cmdline *cl,
16591 				__rte_unused void *data)
16592 {
16593 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16594 	struct rte_mbuf_dynflag desc_flag;
16595 	int flag;
16596 	uint64_t old_port_flags;
16597 
16598 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16599 		return;
16600 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16601 	if (flag <= 0) {
16602 		if (strlcpy(desc_flag.name, res->name,
16603 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16604 			printf("Flag name too long\n");
16605 			return;
16606 		}
16607 		desc_flag.flags = 0;
16608 		flag = rte_mbuf_dynflag_register(&desc_flag);
16609 		if (flag < 0) {
16610 			printf("Can't register flag\n");
16611 			return;
16612 		}
16613 		strcpy(dynf_names[flag], desc_flag.name);
16614 	}
16615 	old_port_flags = ports[res->port_id].mbuf_dynf;
16616 	if (!strcmp(res->value, "set")) {
16617 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16618 		if (old_port_flags == 0)
16619 			add_tx_dynf_callback(res->port_id);
16620 	} else {
16621 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16622 		if (ports[res->port_id].mbuf_dynf == 0)
16623 			remove_tx_dynf_callback(res->port_id);
16624 	}
16625 }
16626 
16627 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16628 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16629 			keyword, "port");
16630 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16631 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16632 			keyword, "config");
16633 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16634 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16635 			port_id, RTE_UINT16);
16636 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16637 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16638 			item, "dynf");
16639 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16640 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16641 			name, NULL);
16642 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16643 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16644 			value, "set#clear");
16645 
16646 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16647 	.f = cmd_config_dynf_specific_parsed,
16648 	.data = NULL,
16649 	.help_str = "port config <port id> dynf <name> set|clear",
16650 	.tokens = {
16651 		(void *)&cmd_config_tx_dynf_specific_port,
16652 		(void *)&cmd_config_tx_dynf_specific_keyword,
16653 		(void *)&cmd_config_tx_dynf_specific_port_id,
16654 		(void *)&cmd_config_tx_dynf_specific_item,
16655 		(void *)&cmd_config_tx_dynf_specific_name,
16656 		(void *)&cmd_config_tx_dynf_specific_value,
16657 		NULL,
16658 	},
16659 };
16660 
16661 /* *** display tx_metadata per port configuration *** */
16662 struct cmd_show_tx_metadata_result {
16663 	cmdline_fixed_string_t cmd_show;
16664 	cmdline_fixed_string_t cmd_port;
16665 	cmdline_fixed_string_t cmd_keyword;
16666 	portid_t cmd_pid;
16667 };
16668 
16669 static void
16670 cmd_show_tx_metadata_parsed(void *parsed_result,
16671 		__rte_unused struct cmdline *cl,
16672 		__rte_unused void *data)
16673 {
16674 	struct cmd_show_tx_metadata_result *res = parsed_result;
16675 
16676 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16677 		printf("invalid port id %u\n", res->cmd_pid);
16678 		return;
16679 	}
16680 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16681 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16682 		       ports[res->cmd_pid].tx_metadata);
16683 	}
16684 }
16685 
16686 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16687 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16688 			cmd_show, "show");
16689 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16690 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16691 			cmd_port, "port");
16692 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16693 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16694 			cmd_pid, RTE_UINT16);
16695 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16696 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16697 			cmd_keyword, "tx_metadata");
16698 
16699 cmdline_parse_inst_t cmd_show_tx_metadata = {
16700 	.f = cmd_show_tx_metadata_parsed,
16701 	.data = NULL,
16702 	.help_str = "show port <port_id> tx_metadata",
16703 	.tokens = {
16704 		(void *)&cmd_show_tx_metadata_show,
16705 		(void *)&cmd_show_tx_metadata_port,
16706 		(void *)&cmd_show_tx_metadata_pid,
16707 		(void *)&cmd_show_tx_metadata_keyword,
16708 		NULL,
16709 	},
16710 };
16711 
16712 /* *** show fec capability per port configuration *** */
16713 struct cmd_show_fec_capability_result {
16714 	cmdline_fixed_string_t cmd_show;
16715 	cmdline_fixed_string_t cmd_port;
16716 	cmdline_fixed_string_t cmd_fec;
16717 	cmdline_fixed_string_t cmd_keyword;
16718 	portid_t cmd_pid;
16719 };
16720 
16721 static void
16722 cmd_show_fec_capability_parsed(void *parsed_result,
16723 		__rte_unused struct cmdline *cl,
16724 		__rte_unused void *data)
16725 {
16726 	struct cmd_show_fec_capability_result *res = parsed_result;
16727 	struct rte_eth_fec_capa *speed_fec_capa;
16728 	unsigned int num;
16729 	int ret;
16730 
16731 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16732 		printf("Invalid port id %u\n", res->cmd_pid);
16733 		return;
16734 	}
16735 
16736 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16737 	if (ret == -ENOTSUP) {
16738 		printf("Function not implemented\n");
16739 		return;
16740 	} else if (ret < 0) {
16741 		printf("Get FEC capability failed: %d\n", ret);
16742 		return;
16743 	}
16744 
16745 	num = (unsigned int)ret;
16746 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16747 	if (speed_fec_capa == NULL) {
16748 		printf("Failed to alloc FEC capability buffer\n");
16749 		return;
16750 	}
16751 
16752 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16753 	if (ret < 0) {
16754 		printf("Error getting FEC capability: %d\n", ret);
16755 		goto out;
16756 	}
16757 
16758 	show_fec_capability(num, speed_fec_capa);
16759 out:
16760 	free(speed_fec_capa);
16761 }
16762 
16763 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16764 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16765 			cmd_show, "show");
16766 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16767 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16768 			cmd_port, "port");
16769 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16770 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16771 			cmd_pid, RTE_UINT16);
16772 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16773 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16774 			cmd_fec, "fec");
16775 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16776 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16777 			cmd_keyword, "capabilities");
16778 
16779 cmdline_parse_inst_t cmd_show_capability = {
16780 	.f = cmd_show_fec_capability_parsed,
16781 	.data = NULL,
16782 	.help_str = "show port <port_id> fec capabilities",
16783 	.tokens = {
16784 		(void *)&cmd_show_fec_capability_show,
16785 		(void *)&cmd_show_fec_capability_port,
16786 		(void *)&cmd_show_fec_capability_pid,
16787 		(void *)&cmd_show_fec_capability_fec,
16788 		(void *)&cmd_show_fec_capability_keyword,
16789 		NULL,
16790 	},
16791 };
16792 
16793 /* *** show fec mode per port configuration *** */
16794 struct cmd_show_fec_metadata_result {
16795 	cmdline_fixed_string_t cmd_show;
16796 	cmdline_fixed_string_t cmd_port;
16797 	cmdline_fixed_string_t cmd_keyword;
16798 	portid_t cmd_pid;
16799 };
16800 
16801 static void
16802 cmd_show_fec_mode_parsed(void *parsed_result,
16803 		__rte_unused struct cmdline *cl,
16804 		__rte_unused void *data)
16805 {
16806 #define FEC_NAME_SIZE 16
16807 	struct cmd_show_fec_metadata_result *res = parsed_result;
16808 	uint32_t mode;
16809 	char buf[FEC_NAME_SIZE];
16810 	int ret;
16811 
16812 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16813 		printf("Invalid port id %u\n", res->cmd_pid);
16814 		return;
16815 	}
16816 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
16817 	if (ret == -ENOTSUP) {
16818 		printf("Function not implemented\n");
16819 		return;
16820 	} else if (ret < 0) {
16821 		printf("Get FEC mode failed\n");
16822 		return;
16823 	}
16824 
16825 	switch (mode) {
16826 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16827 		strlcpy(buf, "off", sizeof(buf));
16828 		break;
16829 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16830 		strlcpy(buf, "auto", sizeof(buf));
16831 		break;
16832 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16833 		strlcpy(buf, "baser", sizeof(buf));
16834 		break;
16835 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16836 		strlcpy(buf, "rs", sizeof(buf));
16837 		break;
16838 	default:
16839 		return;
16840 	}
16841 
16842 	printf("%s\n", buf);
16843 }
16844 
16845 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16846 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16847 			cmd_show, "show");
16848 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16849 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16850 			cmd_port, "port");
16851 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16852 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16853 			cmd_pid, RTE_UINT16);
16854 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16855 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16856 			cmd_keyword, "fec_mode");
16857 
16858 cmdline_parse_inst_t cmd_show_fec_mode = {
16859 	.f = cmd_show_fec_mode_parsed,
16860 	.data = NULL,
16861 	.help_str = "show port <port_id> fec_mode",
16862 	.tokens = {
16863 		(void *)&cmd_show_fec_mode_show,
16864 		(void *)&cmd_show_fec_mode_port,
16865 		(void *)&cmd_show_fec_mode_pid,
16866 		(void *)&cmd_show_fec_mode_keyword,
16867 		NULL,
16868 	},
16869 };
16870 
16871 /* *** set fec mode per port configuration *** */
16872 struct cmd_set_port_fec_mode {
16873 	cmdline_fixed_string_t set;
16874 	cmdline_fixed_string_t port;
16875 	portid_t port_id;
16876 	cmdline_fixed_string_t fec_mode;
16877 	cmdline_fixed_string_t fec_value;
16878 };
16879 
16880 /* Common CLI fields for set fec mode */
16881 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16882 	TOKEN_STRING_INITIALIZER
16883 		(struct cmd_set_port_fec_mode,
16884 		 set, "set");
16885 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16886 	TOKEN_STRING_INITIALIZER
16887 		(struct cmd_set_port_fec_mode,
16888 		 port, "port");
16889 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16890 	TOKEN_NUM_INITIALIZER
16891 		(struct cmd_set_port_fec_mode,
16892 		 port_id, RTE_UINT16);
16893 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16894 	TOKEN_STRING_INITIALIZER
16895 		(struct cmd_set_port_fec_mode,
16896 		 fec_mode, "fec_mode");
16897 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16898 	TOKEN_STRING_INITIALIZER
16899 		(struct cmd_set_port_fec_mode,
16900 		 fec_value, NULL);
16901 
16902 static void
16903 cmd_set_port_fec_mode_parsed(
16904 	void *parsed_result,
16905 	__rte_unused struct cmdline *cl,
16906 	__rte_unused void *data)
16907 {
16908 	struct cmd_set_port_fec_mode *res = parsed_result;
16909 	uint16_t port_id = res->port_id;
16910 	uint32_t mode;
16911 	int ret;
16912 
16913 	ret = parse_fec_mode(res->fec_value, &mode);
16914 	if (ret < 0) {
16915 		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16916 			port_id);
16917 		return;
16918 	}
16919 
16920 	ret = rte_eth_fec_set(port_id, mode);
16921 	if (ret == -ENOTSUP) {
16922 		printf("Function not implemented\n");
16923 		return;
16924 	} else if (ret < 0) {
16925 		printf("Set FEC mode failed\n");
16926 		return;
16927 	}
16928 }
16929 
16930 cmdline_parse_inst_t cmd_set_fec_mode = {
16931 	.f = cmd_set_port_fec_mode_parsed,
16932 	.data = NULL,
16933 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16934 	.tokens = {
16935 		(void *)&cmd_set_port_fec_mode_set,
16936 		(void *)&cmd_set_port_fec_mode_port,
16937 		(void *)&cmd_set_port_fec_mode_port_id,
16938 		(void *)&cmd_set_port_fec_mode_str,
16939 		(void *)&cmd_set_port_fec_mode_value,
16940 		NULL,
16941 	},
16942 };
16943 
16944 /* show port supported ptypes */
16945 
16946 /* Common result structure for show port ptypes */
16947 struct cmd_show_port_supported_ptypes_result {
16948 	cmdline_fixed_string_t show;
16949 	cmdline_fixed_string_t port;
16950 	portid_t port_id;
16951 	cmdline_fixed_string_t ptypes;
16952 };
16953 
16954 /* Common CLI fields for show port ptypes */
16955 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16956 	TOKEN_STRING_INITIALIZER
16957 		(struct cmd_show_port_supported_ptypes_result,
16958 		 show, "show");
16959 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16960 	TOKEN_STRING_INITIALIZER
16961 		(struct cmd_show_port_supported_ptypes_result,
16962 		 port, "port");
16963 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16964 	TOKEN_NUM_INITIALIZER
16965 		(struct cmd_show_port_supported_ptypes_result,
16966 		 port_id, RTE_UINT16);
16967 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16968 	TOKEN_STRING_INITIALIZER
16969 		(struct cmd_show_port_supported_ptypes_result,
16970 		 ptypes, "ptypes");
16971 
16972 static void
16973 cmd_show_port_supported_ptypes_parsed(
16974 	void *parsed_result,
16975 	__rte_unused struct cmdline *cl,
16976 	__rte_unused void *data)
16977 {
16978 #define RSVD_PTYPE_MASK       0xf0000000
16979 #define MAX_PTYPES_PER_LAYER  16
16980 #define LTYPE_NAMESIZE        32
16981 #define PTYPE_NAMESIZE        256
16982 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16983 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16984 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16985 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16986 	uint16_t port_id = res->port_id;
16987 	int ret, i;
16988 
16989 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16990 	if (ret < 0)
16991 		return;
16992 
16993 	while (ptype_mask != RSVD_PTYPE_MASK) {
16994 
16995 		switch (ptype_mask) {
16996 		case RTE_PTYPE_L2_MASK:
16997 			strlcpy(ltype, "L2", sizeof(ltype));
16998 			break;
16999 		case RTE_PTYPE_L3_MASK:
17000 			strlcpy(ltype, "L3", sizeof(ltype));
17001 			break;
17002 		case RTE_PTYPE_L4_MASK:
17003 			strlcpy(ltype, "L4", sizeof(ltype));
17004 			break;
17005 		case RTE_PTYPE_TUNNEL_MASK:
17006 			strlcpy(ltype, "Tunnel", sizeof(ltype));
17007 			break;
17008 		case RTE_PTYPE_INNER_L2_MASK:
17009 			strlcpy(ltype, "Inner L2", sizeof(ltype));
17010 			break;
17011 		case RTE_PTYPE_INNER_L3_MASK:
17012 			strlcpy(ltype, "Inner L3", sizeof(ltype));
17013 			break;
17014 		case RTE_PTYPE_INNER_L4_MASK:
17015 			strlcpy(ltype, "Inner L4", sizeof(ltype));
17016 			break;
17017 		default:
17018 			return;
17019 		}
17020 
17021 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17022 						       ptype_mask, ptypes,
17023 						       MAX_PTYPES_PER_LAYER);
17024 
17025 		if (ret > 0)
17026 			printf("Supported %s ptypes:\n", ltype);
17027 		else
17028 			printf("%s ptypes unsupported\n", ltype);
17029 
17030 		for (i = 0; i < ret; ++i) {
17031 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17032 			printf("%s\n", buf);
17033 		}
17034 
17035 		ptype_mask <<= 4;
17036 	}
17037 }
17038 
17039 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17040 	.f = cmd_show_port_supported_ptypes_parsed,
17041 	.data = NULL,
17042 	.help_str = "show port <port_id> ptypes",
17043 	.tokens = {
17044 		(void *)&cmd_show_port_supported_ptypes_show,
17045 		(void *)&cmd_show_port_supported_ptypes_port,
17046 		(void *)&cmd_show_port_supported_ptypes_port_id,
17047 		(void *)&cmd_show_port_supported_ptypes_ptypes,
17048 		NULL,
17049 	},
17050 };
17051 
17052 /* *** display rx/tx descriptor status *** */
17053 struct cmd_show_rx_tx_desc_status_result {
17054 	cmdline_fixed_string_t cmd_show;
17055 	cmdline_fixed_string_t cmd_port;
17056 	cmdline_fixed_string_t cmd_keyword;
17057 	cmdline_fixed_string_t cmd_desc;
17058 	cmdline_fixed_string_t cmd_status;
17059 	portid_t cmd_pid;
17060 	portid_t cmd_qid;
17061 	portid_t cmd_did;
17062 };
17063 
17064 static void
17065 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17066 		__rte_unused struct cmdline *cl,
17067 		__rte_unused void *data)
17068 {
17069 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17070 	int rc;
17071 
17072 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17073 		printf("invalid port id %u\n", res->cmd_pid);
17074 		return;
17075 	}
17076 
17077 	if (!strcmp(res->cmd_keyword, "rxq")) {
17078 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17079 					     res->cmd_did);
17080 		if (rc < 0) {
17081 			printf("Invalid input: queue id = %d, desc id = %d\n",
17082 			       res->cmd_qid, res->cmd_did);
17083 			return;
17084 		}
17085 		if (rc == RTE_ETH_RX_DESC_AVAIL)
17086 			printf("Desc status = AVAILABLE\n");
17087 		else if (rc == RTE_ETH_RX_DESC_DONE)
17088 			printf("Desc status = DONE\n");
17089 		else
17090 			printf("Desc status = UNAVAILABLE\n");
17091 	} else if (!strcmp(res->cmd_keyword, "txq")) {
17092 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17093 					     res->cmd_did);
17094 		if (rc < 0) {
17095 			printf("Invalid input: queue id = %d, desc id = %d\n",
17096 			       res->cmd_qid, res->cmd_did);
17097 			return;
17098 		}
17099 		if (rc == RTE_ETH_TX_DESC_FULL)
17100 			printf("Desc status = FULL\n");
17101 		else if (rc == RTE_ETH_TX_DESC_DONE)
17102 			printf("Desc status = DONE\n");
17103 		else
17104 			printf("Desc status = UNAVAILABLE\n");
17105 	}
17106 }
17107 
17108 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17109 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17110 			cmd_show, "show");
17111 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17112 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17113 			cmd_port, "port");
17114 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17115 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17116 			cmd_pid, RTE_UINT16);
17117 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17118 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17119 			cmd_keyword, "rxq#txq");
17120 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17121 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17122 			cmd_qid, RTE_UINT16);
17123 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17124 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17125 			cmd_desc, "desc");
17126 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17127 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17128 			cmd_did, RTE_UINT16);
17129 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17130 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17131 			cmd_status, "status");
17132 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17133 	.f = cmd_show_rx_tx_desc_status_parsed,
17134 	.data = NULL,
17135 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17136 		"status",
17137 	.tokens = {
17138 		(void *)&cmd_show_rx_tx_desc_status_show,
17139 		(void *)&cmd_show_rx_tx_desc_status_port,
17140 		(void *)&cmd_show_rx_tx_desc_status_pid,
17141 		(void *)&cmd_show_rx_tx_desc_status_keyword,
17142 		(void *)&cmd_show_rx_tx_desc_status_qid,
17143 		(void *)&cmd_show_rx_tx_desc_status_desc,
17144 		(void *)&cmd_show_rx_tx_desc_status_did,
17145 		(void *)&cmd_show_rx_tx_desc_status_status,
17146 		NULL,
17147 	},
17148 };
17149 
17150 /* *** display rx queue desc used count *** */
17151 struct cmd_show_rx_queue_desc_used_count_result {
17152 	cmdline_fixed_string_t cmd_show;
17153 	cmdline_fixed_string_t cmd_port;
17154 	cmdline_fixed_string_t cmd_rxq;
17155 	cmdline_fixed_string_t cmd_desc;
17156 	cmdline_fixed_string_t cmd_used;
17157 	cmdline_fixed_string_t cmd_count;
17158 	portid_t cmd_pid;
17159 	portid_t cmd_qid;
17160 };
17161 
17162 static void
17163 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17164 		__rte_unused struct cmdline *cl,
17165 		__rte_unused void *data)
17166 {
17167 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17168 	int rc;
17169 
17170 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17171 		printf("invalid port id %u\n", res->cmd_pid);
17172 		return;
17173 	}
17174 
17175 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17176 	if (rc < 0) {
17177 		printf("Invalid queueid = %d\n", res->cmd_qid);
17178 		return;
17179 	}
17180 	printf("Used desc count = %d\n", rc);
17181 }
17182 
17183 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17184 	TOKEN_STRING_INITIALIZER
17185 		(struct cmd_show_rx_queue_desc_used_count_result,
17186 		 cmd_show, "show");
17187 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17188 	TOKEN_STRING_INITIALIZER
17189 		(struct cmd_show_rx_queue_desc_used_count_result,
17190 		 cmd_port, "port");
17191 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17192 	TOKEN_NUM_INITIALIZER
17193 		(struct cmd_show_rx_queue_desc_used_count_result,
17194 		 cmd_pid, RTE_UINT16);
17195 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17196 	TOKEN_STRING_INITIALIZER
17197 		(struct cmd_show_rx_queue_desc_used_count_result,
17198 		 cmd_rxq, "rxq");
17199 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17200 	TOKEN_NUM_INITIALIZER
17201 		(struct cmd_show_rx_queue_desc_used_count_result,
17202 		 cmd_qid, RTE_UINT16);
17203 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17204 	TOKEN_STRING_INITIALIZER
17205 		(struct cmd_show_rx_queue_desc_used_count_result,
17206 		 cmd_count, "desc");
17207 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17208 	TOKEN_STRING_INITIALIZER
17209 		(struct cmd_show_rx_queue_desc_used_count_result,
17210 		 cmd_count, "used");
17211 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17212 	TOKEN_STRING_INITIALIZER
17213 		(struct cmd_show_rx_queue_desc_used_count_result,
17214 		 cmd_count, "count");
17215 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17216 	.f = cmd_show_rx_queue_desc_used_count_parsed,
17217 	.data = NULL,
17218 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
17219 	.tokens = {
17220 		(void *)&cmd_show_rx_queue_desc_used_count_show,
17221 		(void *)&cmd_show_rx_queue_desc_used_count_port,
17222 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
17223 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
17224 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
17225 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
17226 		(void *)&cmd_show_rx_queue_desc_used_count_used,
17227 		(void *)&cmd_show_rx_queue_desc_used_count_count,
17228 		NULL,
17229 	},
17230 };
17231 
17232 /* Common result structure for set port ptypes */
17233 struct cmd_set_port_ptypes_result {
17234 	cmdline_fixed_string_t set;
17235 	cmdline_fixed_string_t port;
17236 	portid_t port_id;
17237 	cmdline_fixed_string_t ptype_mask;
17238 	uint32_t mask;
17239 };
17240 
17241 /* Common CLI fields for set port ptypes */
17242 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17243 	TOKEN_STRING_INITIALIZER
17244 		(struct cmd_set_port_ptypes_result,
17245 		 set, "set");
17246 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17247 	TOKEN_STRING_INITIALIZER
17248 		(struct cmd_set_port_ptypes_result,
17249 		 port, "port");
17250 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17251 	TOKEN_NUM_INITIALIZER
17252 		(struct cmd_set_port_ptypes_result,
17253 		 port_id, RTE_UINT16);
17254 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17255 	TOKEN_STRING_INITIALIZER
17256 		(struct cmd_set_port_ptypes_result,
17257 		 ptype_mask, "ptype_mask");
17258 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17259 	TOKEN_NUM_INITIALIZER
17260 		(struct cmd_set_port_ptypes_result,
17261 		 mask, RTE_UINT32);
17262 
17263 static void
17264 cmd_set_port_ptypes_parsed(
17265 	void *parsed_result,
17266 	__rte_unused struct cmdline *cl,
17267 	__rte_unused void *data)
17268 {
17269 	struct cmd_set_port_ptypes_result *res = parsed_result;
17270 #define PTYPE_NAMESIZE        256
17271 	char ptype_name[PTYPE_NAMESIZE];
17272 	uint16_t port_id = res->port_id;
17273 	uint32_t ptype_mask = res->mask;
17274 	int ret, i;
17275 
17276 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17277 					       NULL, 0);
17278 	if (ret <= 0) {
17279 		printf("Port %d doesn't support any ptypes.\n", port_id);
17280 		return;
17281 	}
17282 
17283 	uint32_t ptypes[ret];
17284 
17285 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17286 	if (ret < 0) {
17287 		printf("Unable to set requested ptypes for Port %d\n", port_id);
17288 		return;
17289 	}
17290 
17291 	printf("Successfully set following ptypes for Port %d\n", port_id);
17292 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17293 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17294 		printf("%s\n", ptype_name);
17295 	}
17296 
17297 	clear_ptypes = false;
17298 }
17299 
17300 cmdline_parse_inst_t cmd_set_port_ptypes = {
17301 	.f = cmd_set_port_ptypes_parsed,
17302 	.data = NULL,
17303 	.help_str = "set port <port_id> ptype_mask <mask>",
17304 	.tokens = {
17305 		(void *)&cmd_set_port_ptypes_set,
17306 		(void *)&cmd_set_port_ptypes_port,
17307 		(void *)&cmd_set_port_ptypes_port_id,
17308 		(void *)&cmd_set_port_ptypes_mask_str,
17309 		(void *)&cmd_set_port_ptypes_mask_u32,
17310 		NULL,
17311 	},
17312 };
17313 
17314 /* *** display mac addresses added to a port *** */
17315 struct cmd_showport_macs_result {
17316 	cmdline_fixed_string_t cmd_show;
17317 	cmdline_fixed_string_t cmd_port;
17318 	cmdline_fixed_string_t cmd_keyword;
17319 	portid_t cmd_pid;
17320 };
17321 
17322 static void
17323 cmd_showport_macs_parsed(void *parsed_result,
17324 		__rte_unused struct cmdline *cl,
17325 		__rte_unused void *data)
17326 {
17327 	struct cmd_showport_macs_result *res = parsed_result;
17328 
17329 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17330 		return;
17331 
17332 	if (!strcmp(res->cmd_keyword, "macs"))
17333 		show_macs(res->cmd_pid);
17334 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17335 		show_mcast_macs(res->cmd_pid);
17336 }
17337 
17338 cmdline_parse_token_string_t cmd_showport_macs_show =
17339 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17340 			cmd_show, "show");
17341 cmdline_parse_token_string_t cmd_showport_macs_port =
17342 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17343 			cmd_port, "port");
17344 cmdline_parse_token_num_t cmd_showport_macs_pid =
17345 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17346 			cmd_pid, RTE_UINT16);
17347 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17348 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17349 			cmd_keyword, "macs#mcast_macs");
17350 
17351 cmdline_parse_inst_t cmd_showport_macs = {
17352 	.f = cmd_showport_macs_parsed,
17353 	.data = NULL,
17354 	.help_str = "show port <port_id> macs|mcast_macs",
17355 	.tokens = {
17356 		(void *)&cmd_showport_macs_show,
17357 		(void *)&cmd_showport_macs_port,
17358 		(void *)&cmd_showport_macs_pid,
17359 		(void *)&cmd_showport_macs_keyword,
17360 		NULL,
17361 	},
17362 };
17363 
17364 /* ******************************************************************************** */
17365 
17366 /* list of instructions */
17367 cmdline_parse_ctx_t main_ctx[] = {
17368 	(cmdline_parse_inst_t *)&cmd_help_brief,
17369 	(cmdline_parse_inst_t *)&cmd_help_long,
17370 	(cmdline_parse_inst_t *)&cmd_quit,
17371 	(cmdline_parse_inst_t *)&cmd_load_from_file,
17372 	(cmdline_parse_inst_t *)&cmd_showport,
17373 	(cmdline_parse_inst_t *)&cmd_showqueue,
17374 	(cmdline_parse_inst_t *)&cmd_showeeprom,
17375 	(cmdline_parse_inst_t *)&cmd_showportall,
17376 	(cmdline_parse_inst_t *)&cmd_showdevice,
17377 	(cmdline_parse_inst_t *)&cmd_showcfg,
17378 	(cmdline_parse_inst_t *)&cmd_showfwdall,
17379 	(cmdline_parse_inst_t *)&cmd_start,
17380 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
17381 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17382 	(cmdline_parse_inst_t *)&cmd_set_link_up,
17383 	(cmdline_parse_inst_t *)&cmd_set_link_down,
17384 	(cmdline_parse_inst_t *)&cmd_reset,
17385 	(cmdline_parse_inst_t *)&cmd_set_numbers,
17386 	(cmdline_parse_inst_t *)&cmd_set_log,
17387 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
17388 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
17389 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
17390 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
17391 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
17392 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
17393 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17394 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17395 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17396 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17397 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17398 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17399 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17400 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17401 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
17402 	(cmdline_parse_inst_t *)&cmd_set_link_check,
17403 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17404 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
17405 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17406 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
17407 #ifdef RTE_NET_BOND
17408 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17409 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
17410 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17411 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17412 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17413 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
17414 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17415 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17416 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17417 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17418 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17419 #endif
17420 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
17421 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
17422 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17423 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17424 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17425 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17426 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17427 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17428 	(cmdline_parse_inst_t *)&cmd_csum_set,
17429 	(cmdline_parse_inst_t *)&cmd_csum_show,
17430 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
17431 	(cmdline_parse_inst_t *)&cmd_tso_set,
17432 	(cmdline_parse_inst_t *)&cmd_tso_show,
17433 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17434 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17435 	(cmdline_parse_inst_t *)&cmd_gro_enable,
17436 	(cmdline_parse_inst_t *)&cmd_gro_flush,
17437 	(cmdline_parse_inst_t *)&cmd_gro_show,
17438 	(cmdline_parse_inst_t *)&cmd_gso_enable,
17439 	(cmdline_parse_inst_t *)&cmd_gso_size,
17440 	(cmdline_parse_inst_t *)&cmd_gso_show,
17441 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17442 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17443 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17444 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17445 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17446 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17447 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17448 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17449 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17450 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17451 	(cmdline_parse_inst_t *)&cmd_config_dcb,
17452 	(cmdline_parse_inst_t *)&cmd_read_reg,
17453 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17454 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
17455 	(cmdline_parse_inst_t *)&cmd_write_reg,
17456 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17457 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
17458 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17459 	(cmdline_parse_inst_t *)&cmd_stop,
17460 	(cmdline_parse_inst_t *)&cmd_mac_addr,
17461 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17462 	(cmdline_parse_inst_t *)&cmd_set_qmap,
17463 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17464 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17465 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17466 	(cmdline_parse_inst_t *)&cmd_operate_port,
17467 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
17468 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
17469 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
17470 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
17471 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17472 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
17473 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
17474 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
17475 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17476 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
17477 	(cmdline_parse_inst_t *)&cmd_config_mtu,
17478 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17479 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17480 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17481 	(cmdline_parse_inst_t *)&cmd_config_rss,
17482 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17483 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17484 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17485 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17486 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
17487 	(cmdline_parse_inst_t *)&cmd_showport_reta,
17488 	(cmdline_parse_inst_t *)&cmd_showport_macs,
17489 	(cmdline_parse_inst_t *)&cmd_config_burst,
17490 	(cmdline_parse_inst_t *)&cmd_config_thresh,
17491 	(cmdline_parse_inst_t *)&cmd_config_threshold,
17492 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17493 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17494 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17495 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17496 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17497 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17498 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
17499 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17500 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17501 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17502 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17503 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17504 	(cmdline_parse_inst_t *)&cmd_dump,
17505 	(cmdline_parse_inst_t *)&cmd_dump_one,
17506 #ifdef RTE_NET_I40E
17507 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17508 #endif
17509 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17510 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17511 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17512 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17513 	(cmdline_parse_inst_t *)&cmd_flow,
17514 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17515 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17516 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17517 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17518 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
17519 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
17520 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
17521 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
17522 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17523 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17524 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17525 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17526 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17527 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
17528 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17529 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17530 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17531 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17532 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17533 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17534 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17535 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17536 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17537 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17538 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17539 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17540 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17541 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17542 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17543 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17544 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17545 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17546 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17547 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17548 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
17549 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17550 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17551 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
17552 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
17553 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
17554 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17555 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17556 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
17557 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17558 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
17559 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17560 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
17561 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17562 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17563 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17564 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17565 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17566 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17567 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17568 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17569 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17570 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17571 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17572 	(cmdline_parse_inst_t *)&cmd_ddp_add,
17573 	(cmdline_parse_inst_t *)&cmd_ddp_del,
17574 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
17575 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
17576 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
17577 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
17578 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
17579 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17580 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17581 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17582 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17583 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17584 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17585 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17586 
17587 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17588 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17589 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17590 	(cmdline_parse_inst_t *)&cmd_queue_region,
17591 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
17592 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
17593 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
17594 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17595 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17596 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17597 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17598 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17599 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17600 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17601 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17602 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17603 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17604 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17605 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17606 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17607 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17608 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17609 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17610 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17611 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17612 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17613 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17614 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17615 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17616 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17617 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17618 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17619 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17620 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17621 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17622 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17623 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17624 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17625 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17626 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17627 #ifdef RTE_LIB_BPF
17628 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17629 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17630 #endif
17631 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17632 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17633 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17634 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17635 	(cmdline_parse_inst_t *)&cmd_set_raw,
17636 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
17637 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17638 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17639 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
17640 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
17641 	(cmdline_parse_inst_t *)&cmd_show_capability,
17642 	NULL,
17643 };
17644 
17645 /* read cmdline commands from file */
17646 void
17647 cmdline_read_from_file(const char *filename)
17648 {
17649 	struct cmdline *cl;
17650 
17651 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17652 	if (cl == NULL) {
17653 		printf("Failed to create file based cmdline context: %s\n",
17654 		       filename);
17655 		return;
17656 	}
17657 
17658 	cmdline_interact(cl);
17659 	cmdline_quit(cl);
17660 
17661 	cmdline_free(cl);
17662 
17663 	printf("Read CLI commands from %s\n", filename);
17664 }
17665 
17666 /* prompt function, called from main on MAIN lcore */
17667 void
17668 prompt(void)
17669 {
17670 	int ret;
17671 	/* initialize non-constant commands */
17672 	cmd_set_fwd_mode_init();
17673 	cmd_set_fwd_retry_mode_init();
17674 
17675 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17676 	if (testpmd_cl == NULL)
17677 		return;
17678 
17679 	ret = atexit(prompt_exit);
17680 	if (ret != 0)
17681 		printf("Cannot set exit function for cmdline\n");
17682 
17683 	cmdline_interact(testpmd_cl);
17684 	if (ret != 0)
17685 		cmdline_stdin_exit(testpmd_cl);
17686 }
17687 
17688 void
17689 prompt_exit(void)
17690 {
17691 	if (testpmd_cl != NULL) {
17692 		cmdline_quit(testpmd_cl);
17693 		cmdline_stdin_exit(testpmd_cl);
17694 	}
17695 }
17696 
17697 static void
17698 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17699 {
17700 	if (id == (portid_t)RTE_PORT_ALL) {
17701 		portid_t pid;
17702 
17703 		RTE_ETH_FOREACH_DEV(pid) {
17704 			/* check if need_reconfig has been set to 1 */
17705 			if (ports[pid].need_reconfig == 0)
17706 				ports[pid].need_reconfig = dev;
17707 			/* check if need_reconfig_queues has been set to 1 */
17708 			if (ports[pid].need_reconfig_queues == 0)
17709 				ports[pid].need_reconfig_queues = queue;
17710 		}
17711 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17712 		/* check if need_reconfig has been set to 1 */
17713 		if (ports[id].need_reconfig == 0)
17714 			ports[id].need_reconfig = dev;
17715 		/* check if need_reconfig_queues has been set to 1 */
17716 		if (ports[id].need_reconfig_queues == 0)
17717 			ports[id].need_reconfig_queues = queue;
17718 	}
17719 }
17720