xref: /dpdk/app/test-pmd/cmdline.c (revision b8a0fbab)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5 
6 #include <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include <inttypes.h>
13 #include <sys/queue.h>
14 
15 #include <rte_common.h>
16 #include <rte_byteorder.h>
17 #include <rte_log.h>
18 #include <rte_debug.h>
19 #include <rte_cycles.h>
20 #include <rte_memory.h>
21 #include <rte_memzone.h>
22 #include <rte_malloc.h>
23 #include <rte_launch.h>
24 #include <rte_eal.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
27 #include <rte_atomic.h>
28 #include <rte_branch_prediction.h>
29 #include <rte_ring.h>
30 #include <rte_mempool.h>
31 #include <rte_interrupts.h>
32 #include <rte_pci.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_string_fns.h>
36 #include <rte_devargs.h>
37 #include <rte_flow.h>
38 #include <rte_gro.h>
39 #include <rte_mbuf_dyn.h>
40 
41 #include <cmdline_rdline.h>
42 #include <cmdline_parse.h>
43 #include <cmdline_parse_num.h>
44 #include <cmdline_parse_string.h>
45 #include <cmdline_parse_ipaddr.h>
46 #include <cmdline_parse_etheraddr.h>
47 #include <cmdline_socket.h>
48 #include <cmdline.h>
49 #ifdef RTE_NET_BOND
50 #include <rte_eth_bond.h>
51 #include <rte_eth_bond_8023ad.h>
52 #endif
53 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
54 #include <rte_pmd_dpaa.h>
55 #endif
56 #ifdef RTE_NET_IXGBE
57 #include <rte_pmd_ixgbe.h>
58 #endif
59 #ifdef RTE_NET_I40E
60 #include <rte_pmd_i40e.h>
61 #endif
62 #ifdef RTE_NET_BNXT
63 #include <rte_pmd_bnxt.h>
64 #endif
65 #include "testpmd.h"
66 #include "cmdline_mtr.h"
67 #include "cmdline_tm.h"
68 #include "bpf_cmd.h"
69 
70 static struct cmdline *testpmd_cl;
71 
72 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
73 
74 /* *** Help command with introduction. *** */
75 struct cmd_help_brief_result {
76 	cmdline_fixed_string_t help;
77 };
78 
79 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
80                                   struct cmdline *cl,
81                                   __rte_unused void *data)
82 {
83 	cmdline_printf(
84 		cl,
85 		"\n"
86 		"Help is available for the following sections:\n\n"
87 		"    help control                    : Start and stop forwarding.\n"
88 		"    help display                    : Displaying port, stats and config "
89 		"information.\n"
90 		"    help config                     : Configuration information.\n"
91 		"    help ports                      : Configuring ports.\n"
92 		"    help registers                  : Reading and setting port registers.\n"
93 		"    help filters                    : Filters configuration help.\n"
94 		"    help traffic_management         : Traffic Management commands.\n"
95 		"    help devices                    : Device related cmds.\n"
96 		"    help all                        : All of the above sections.\n\n"
97 	);
98 
99 }
100 
101 cmdline_parse_token_string_t cmd_help_brief_help =
102 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
103 
104 cmdline_parse_inst_t cmd_help_brief = {
105 	.f = cmd_help_brief_parsed,
106 	.data = NULL,
107 	.help_str = "help: Show help",
108 	.tokens = {
109 		(void *)&cmd_help_brief_help,
110 		NULL,
111 	},
112 };
113 
114 /* *** Help command with help sections. *** */
115 struct cmd_help_long_result {
116 	cmdline_fixed_string_t help;
117 	cmdline_fixed_string_t section;
118 };
119 
120 static void cmd_help_long_parsed(void *parsed_result,
121                                  struct cmdline *cl,
122                                  __rte_unused void *data)
123 {
124 	int show_all = 0;
125 	struct cmd_help_long_result *res = parsed_result;
126 
127 	if (!strcmp(res->section, "all"))
128 		show_all = 1;
129 
130 	if (show_all || !strcmp(res->section, "control")) {
131 
132 		cmdline_printf(
133 			cl,
134 			"\n"
135 			"Control forwarding:\n"
136 			"-------------------\n\n"
137 
138 			"start\n"
139 			"    Start packet forwarding with current configuration.\n\n"
140 
141 			"start tx_first\n"
142 			"    Start packet forwarding with current config"
143 			" after sending one burst of packets.\n\n"
144 
145 			"stop\n"
146 			"    Stop packet forwarding, and display accumulated"
147 			" statistics.\n\n"
148 
149 			"quit\n"
150 			"    Quit to prompt.\n\n"
151 		);
152 	}
153 
154 	if (show_all || !strcmp(res->section, "display")) {
155 
156 		cmdline_printf(
157 			cl,
158 			"\n"
159 			"Display:\n"
160 			"--------\n\n"
161 
162 			"show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
163 			"    Display information for port_id, or all.\n\n"
164 
165 			"show port port_id (module_eeprom|eeprom)\n"
166 			"    Display the module EEPROM or EEPROM information for port_id.\n\n"
167 
168 			"show port X rss reta (size) (mask0,mask1,...)\n"
169 			"    Display the rss redirection table entry indicated"
170 			" by masks on port X. size is used to indicate the"
171 			" hardware supported reta size\n\n"
172 
173 			"show port (port_id) rss-hash [key]\n"
174 			"    Display the RSS hash functions and RSS hash key of port\n\n"
175 
176 			"clear port (info|stats|xstats|fdir) (port_id|all)\n"
177 			"    Clear information for port_id, or all.\n\n"
178 
179 			"show (rxq|txq) info (port_id) (queue_id)\n"
180 			"    Display information for configured RX/TX queue.\n\n"
181 
182 			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
183 			"    Display the given configuration.\n\n"
184 
185 			"read rxd (port_id) (queue_id) (rxd_id)\n"
186 			"    Display an RX descriptor of a port RX queue.\n\n"
187 
188 			"read txd (port_id) (queue_id) (txd_id)\n"
189 			"    Display a TX descriptor of a port TX queue.\n\n"
190 
191 			"ddp get list (port_id)\n"
192 			"    Get ddp profile info list\n\n"
193 
194 			"ddp get info (profile_path)\n"
195 			"    Get ddp profile information.\n\n"
196 
197 			"show vf stats (port_id) (vf_id)\n"
198 			"    Display a VF's statistics.\n\n"
199 
200 			"clear vf stats (port_id) (vf_id)\n"
201 			"    Reset a VF's statistics.\n\n"
202 
203 			"show port (port_id) pctype mapping\n"
204 			"    Get flow ptype to pctype mapping on a port\n\n"
205 
206 			"show port meter stats (port_id) (meter_id) (clear)\n"
207 			"    Get meter stats on a port\n\n"
208 
209 			"show fwd stats all\n"
210 			"    Display statistics for all fwd engines.\n\n"
211 
212 			"clear fwd stats all\n"
213 			"    Clear statistics for all fwd engines.\n\n"
214 
215 			"show port (port_id) rx_offload capabilities\n"
216 			"    List all per queue and per port Rx offloading"
217 			" capabilities of a port\n\n"
218 
219 			"show port (port_id) rx_offload configuration\n"
220 			"    List port level and all queue level"
221 			" Rx offloading configuration\n\n"
222 
223 			"show port (port_id) tx_offload capabilities\n"
224 			"    List all per queue and per port"
225 			" Tx offloading capabilities of a port\n\n"
226 
227 			"show port (port_id) tx_offload configuration\n"
228 			"    List port level and all queue level"
229 			" Tx offloading configuration\n\n"
230 
231 			"show port (port_id) tx_metadata\n"
232 			"    Show Tx metadata value set"
233 			" for a specific port\n\n"
234 
235 			"show port (port_id) ptypes\n"
236 			"    Show port supported ptypes"
237 			" for a specific port\n\n"
238 
239 			"show device info (<identifier>|all)"
240 			"       Show general information about devices probed.\n\n"
241 
242 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 			"       Show status of rx|tx descriptor.\n\n"
244 
245 			"show port (port_id) rxq (queue_id) desc used count\n"
246 			"    Show current number of filled receive"
247 			" packet descriptors.\n\n"
248 
249 			"show port (port_id) macs|mcast_macs"
250 			"       Display list of mac addresses added to port.\n\n"
251 
252 			"show port (port_id) fec capabilities"
253 			"	Show fec capabilities of a port.\n\n"
254 
255 			"show port (port_id) fec_mode"
256 			"	Show fec mode of a port.\n\n"
257 
258 			"show port (port_id) flow_ctrl"
259 			"	Show flow control info of a port.\n\n"
260 		);
261 	}
262 
263 	if (show_all || !strcmp(res->section, "config")) {
264 		cmdline_printf(
265 			cl,
266 			"\n"
267 			"Configuration:\n"
268 			"--------------\n"
269 			"Configuration changes only become active when"
270 			" forwarding is started/restarted.\n\n"
271 
272 			"set default\n"
273 			"    Reset forwarding to the default configuration.\n\n"
274 
275 			"set verbose (level)\n"
276 			"    Set the debug verbosity level X.\n\n"
277 
278 			"set log global|(type) (level)\n"
279 			"    Set the log level.\n\n"
280 
281 			"set nbport (num)\n"
282 			"    Set number of ports.\n\n"
283 
284 			"set nbcore (num)\n"
285 			"    Set number of cores.\n\n"
286 
287 			"set coremask (mask)\n"
288 			"    Set the forwarding cores hexadecimal mask.\n\n"
289 
290 			"set portmask (mask)\n"
291 			"    Set the forwarding ports hexadecimal mask.\n\n"
292 
293 			"set burst (num)\n"
294 			"    Set number of packets per burst.\n\n"
295 
296 			"set burst tx delay (microseconds) retry (num)\n"
297 			"    Set the transmit delay time and number of retries,"
298 			" effective when retry is enabled.\n\n"
299 
300 			"set rxoffs (x[,y]*)\n"
301 			"    Set the offset of each packet segment on"
302 			" receiving if split feature is engaged."
303 			" Affects only the queues configured with split"
304 			" offloads.\n\n"
305 
306 			"set rxpkts (x[,y]*)\n"
307 			"    Set the length of each segment to scatter"
308 			" packets on receiving if split feature is engaged."
309 			" Affects only the queues configured with split"
310 			" offloads.\n\n"
311 
312 			"set txpkts (x[,y]*)\n"
313 			"    Set the length of each segment of TXONLY"
314 			" and optionally CSUM packets.\n\n"
315 
316 			"set txsplit (off|on|rand)\n"
317 			"    Set the split policy for the TX packets."
318 			" Right now only applicable for CSUM and TXONLY"
319 			" modes\n\n"
320 
321 			"set txtimes (x, y)\n"
322 			"    Set the scheduling on timestamps"
323 			" timings for the TXONLY mode\n\n"
324 
325 			"set corelist (x[,y]*)\n"
326 			"    Set the list of forwarding cores.\n\n"
327 
328 			"set portlist (x[,y]*)\n"
329 			"    Set the list of forwarding ports.\n\n"
330 
331 			"set port setup on (iterator|event)\n"
332 			"    Select how attached port is retrieved for setup.\n\n"
333 
334 			"set tx loopback (port_id) (on|off)\n"
335 			"    Enable or disable tx loopback.\n\n"
336 
337 			"set all queues drop (port_id) (on|off)\n"
338 			"    Set drop enable bit for all queues.\n\n"
339 
340 			"set vf split drop (port_id) (vf_id) (on|off)\n"
341 			"    Set split drop enable bit for a VF from the PF.\n\n"
342 
343 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
344 			"    Set MAC antispoof for a VF from the PF.\n\n"
345 
346 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
347 			"    Enable MACsec offload.\n\n"
348 
349 			"set macsec offload (port_id) off\n"
350 			"    Disable MACsec offload.\n\n"
351 
352 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
353 			"    Configure MACsec secure connection (SC).\n\n"
354 
355 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
356 			"    Configure MACsec secure association (SA).\n\n"
357 
358 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
359 			"    Set VF broadcast for a VF from the PF.\n\n"
360 
361 			"vlan set stripq (on|off) (port_id,queue_id)\n"
362 			"    Set the VLAN strip for a queue on a port.\n\n"
363 
364 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
365 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
366 
367 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
368 			"    Set VLAN insert for a VF from the PF.\n\n"
369 
370 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
371 			"    Set VLAN antispoof for a VF from the PF.\n\n"
372 
373 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
374 			"    Set VLAN tag for a VF from the PF.\n\n"
375 
376 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
377 			"    Set a VF's max bandwidth(Mbps).\n\n"
378 
379 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
380 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
381 
382 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
383 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
384 
385 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
386 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
387 
388 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
389 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
390 
391 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
392 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
393 
394 			"vlan set (inner|outer) tpid (value) (port_id)\n"
395 			"    Set the VLAN TPID for Packet Filtering on"
396 			" a port\n\n"
397 
398 			"rx_vlan add (vlan_id|all) (port_id)\n"
399 			"    Add a vlan_id, or all identifiers, to the set"
400 			" of VLAN identifiers filtered by port_id.\n\n"
401 
402 			"rx_vlan rm (vlan_id|all) (port_id)\n"
403 			"    Remove a vlan_id, or all identifiers, from the set"
404 			" of VLAN identifiers filtered by port_id.\n\n"
405 
406 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
407 			"    Add a vlan_id, to the set of VLAN identifiers"
408 			"filtered for VF(s) from port_id.\n\n"
409 
410 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
411 			"    Remove a vlan_id, to the set of VLAN identifiers"
412 			"filtered for VF(s) from port_id.\n\n"
413 
414 			"rx_vxlan_port add (udp_port) (port_id)\n"
415 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
416 
417 			"rx_vxlan_port rm (udp_port) (port_id)\n"
418 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
419 
420 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
421 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
422 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
423 
424 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
425 			"    Set port based TX VLAN insertion.\n\n"
426 
427 			"tx_vlan reset (port_id)\n"
428 			"    Disable hardware insertion of a VLAN header in"
429 			" packets sent on a port.\n\n"
430 
431 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
432 			"    Select hardware or software calculation of the"
433 			" checksum when transmitting a packet using the"
434 			" csum forward engine.\n"
435 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
436 			"    outer-ip concerns the outer IP layer in"
437 			"    outer-udp concerns the outer UDP layer in"
438 			" case the packet is recognized as a tunnel packet by"
439 			" the forward engine (vxlan, gre and ipip are supported)\n"
440 			"    Please check the NIC datasheet for HW limits.\n\n"
441 
442 			"csum parse-tunnel (on|off) (tx_port_id)\n"
443 			"    If disabled, treat tunnel packets as non-tunneled"
444 			" packets (treat inner headers as payload). The port\n"
445 			"    argument is the port used for TX in csum forward"
446 			" engine.\n\n"
447 
448 			"csum show (port_id)\n"
449 			"    Display tx checksum offload configuration\n\n"
450 
451 			"tso set (segsize) (portid)\n"
452 			"    Enable TCP Segmentation Offload in csum forward"
453 			" engine.\n"
454 			"    Please check the NIC datasheet for HW limits.\n\n"
455 
456 			"tso show (portid)"
457 			"    Display the status of TCP Segmentation Offload.\n\n"
458 
459 			"set port (port_id) gro on|off\n"
460 			"    Enable or disable Generic Receive Offload in"
461 			" csum forwarding engine.\n\n"
462 
463 			"show port (port_id) gro\n"
464 			"    Display GRO configuration.\n\n"
465 
466 			"set gro flush (cycles)\n"
467 			"    Set the cycle to flush GROed packets from"
468 			" reassembly tables.\n\n"
469 
470 			"set port (port_id) gso (on|off)"
471 			"    Enable or disable Generic Segmentation Offload in"
472 			" csum forwarding engine.\n\n"
473 
474 			"set gso segsz (length)\n"
475 			"    Set max packet length for output GSO segments,"
476 			" including packet header and payload.\n\n"
477 
478 			"show port (port_id) gso\n"
479 			"    Show GSO configuration.\n\n"
480 
481 			"set fwd (%s)\n"
482 			"    Set packet forwarding mode.\n\n"
483 
484 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 			"    Add a MAC address on port_id.\n\n"
486 
487 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 			"    Remove a MAC address from port_id.\n\n"
489 
490 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 			"    Set the default MAC address for port_id.\n\n"
492 
493 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
494 			"    Add a MAC address for a VF on the port.\n\n"
495 
496 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
497 			"    Set the MAC address for a VF from the PF.\n\n"
498 
499 			"set eth-peer (port_id) (peer_addr)\n"
500 			"    set the peer address for certain port.\n\n"
501 
502 			"set port (port_id) uta (mac_address|all) (on|off)\n"
503 			"    Add/Remove a or all unicast hash filter(s)"
504 			"from port X.\n\n"
505 
506 			"set promisc (port_id|all) (on|off)\n"
507 			"    Set the promiscuous mode on port_id, or all.\n\n"
508 
509 			"set allmulti (port_id|all) (on|off)\n"
510 			"    Set the allmulti mode on port_id, or all.\n\n"
511 
512 			"set vf promisc (port_id) (vf_id) (on|off)\n"
513 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
514 
515 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
516 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
517 
518 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
519 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
520 			" (on|off) autoneg (on|off) (port_id)\n"
521 			"set flow_ctrl rx (on|off) (portid)\n"
522 			"set flow_ctrl tx (on|off) (portid)\n"
523 			"set flow_ctrl high_water (high_water) (portid)\n"
524 			"set flow_ctrl low_water (low_water) (portid)\n"
525 			"set flow_ctrl pause_time (pause_time) (portid)\n"
526 			"set flow_ctrl send_xon (send_xon) (portid)\n"
527 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
528 			"set flow_ctrl autoneg (on|off) (port_id)\n"
529 			"    Set the link flow control parameter on a port.\n\n"
530 
531 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
532 			" (low_water) (pause_time) (priority) (port_id)\n"
533 			"    Set the priority flow control parameter on a"
534 			" port.\n\n"
535 
536 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
537 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
538 			" queue on port.\n"
539 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
540 			" on port 0 to mapping 5.\n\n"
541 
542 			"set xstats-hide-zero on|off\n"
543 			"    Set the option to hide the zero values"
544 			" for xstats display.\n"
545 
546 			"set record-core-cycles on|off\n"
547 			"    Set the option to enable measurement of CPU cycles.\n"
548 
549 			"set record-burst-stats on|off\n"
550 			"    Set the option to enable display of RX and TX bursts.\n"
551 
552 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
553 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
554 
555 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
556 			"|MPE) (on|off)\n"
557 			"    AUPE:accepts untagged VLAN;"
558 			"ROPE:accept unicast hash\n\n"
559 			"    BAM:accepts broadcast packets;"
560 			"MPE:accepts all multicast packets\n\n"
561 			"    Enable/Disable a VF receive mode of a port\n\n"
562 
563 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
564 			"    Set rate limit for a queue of a port\n\n"
565 
566 			"set port (port_id) vf (vf_id) rate (rate_num) "
567 			"queue_mask (queue_mask_value)\n"
568 			"    Set rate limit for queues in VF of a port\n\n"
569 
570 			"set port (port_id) mirror-rule (rule_id)"
571 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
572 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
573 			"   Set pool or vlan type mirror rule on a port.\n"
574 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
575 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
576 			" to pool 0.\n\n"
577 
578 			"set port (port_id) mirror-rule (rule_id)"
579 			" (uplink-mirror|downlink-mirror) dst-pool"
580 			" (pool_id) (on|off)\n"
581 			"   Set uplink or downlink type mirror rule on a port.\n"
582 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
583 			" 0 on' enable mirror income traffic to pool 0.\n\n"
584 
585 			"reset port (port_id) mirror-rule (rule_id)\n"
586 			"   Reset a mirror rule.\n\n"
587 
588 			"set flush_rx (on|off)\n"
589 			"   Flush (default) or don't flush RX streams before"
590 			" forwarding. Mainly used with PCAP drivers.\n\n"
591 
592 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
593 			"   Set the bypass mode for the lowest port on bypass enabled"
594 			" NIC.\n\n"
595 
596 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
597 			"mode (normal|bypass|isolate) (port_id)\n"
598 			"   Set the event required to initiate specified bypass mode for"
599 			" the lowest port on a bypass enabled NIC where:\n"
600 			"       timeout   = enable bypass after watchdog timeout.\n"
601 			"       os_on     = enable bypass when OS/board is powered on.\n"
602 			"       os_off    = enable bypass when OS/board is powered off.\n"
603 			"       power_on  = enable bypass when power supply is turned on.\n"
604 			"       power_off = enable bypass when power supply is turned off."
605 			"\n\n"
606 
607 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
608 			"   Set the bypass watchdog timeout to 'n' seconds"
609 			" where 0 = instant.\n\n"
610 
611 			"show bypass config (port_id)\n"
612 			"   Show the bypass configuration for a bypass enabled NIC"
613 			" using the lowest port on the NIC.\n\n"
614 
615 #ifdef RTE_NET_BOND
616 			"create bonded device (mode) (socket)\n"
617 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
618 
619 			"add bonding slave (slave_id) (port_id)\n"
620 			"	Add a slave device to a bonded device.\n\n"
621 
622 			"remove bonding slave (slave_id) (port_id)\n"
623 			"	Remove a slave device from a bonded device.\n\n"
624 
625 			"set bonding mode (value) (port_id)\n"
626 			"	Set the bonding mode on a bonded device.\n\n"
627 
628 			"set bonding primary (slave_id) (port_id)\n"
629 			"	Set the primary slave for a bonded device.\n\n"
630 
631 			"show bonding config (port_id)\n"
632 			"	Show the bonding config for port_id.\n\n"
633 
634 			"set bonding mac_addr (port_id) (address)\n"
635 			"	Set the MAC address of a bonded device.\n\n"
636 
637 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
638 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
639 
640 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
641 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
642 
643 			"set bonding mon_period (port_id) (value)\n"
644 			"	Set the bonding link status monitoring polling period in ms.\n\n"
645 
646 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
647 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
648 
649 #endif
650 			"set link-up port (port_id)\n"
651 			"	Set link up for a port.\n\n"
652 
653 			"set link-down port (port_id)\n"
654 			"	Set link down for a port.\n\n"
655 
656 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
657 			"    Load a profile package on a port\n\n"
658 
659 			"ddp del (port_id) (backup_profile_path)\n"
660 			"    Delete a profile package from a port\n\n"
661 
662 			"ptype mapping get (port_id) (valid_only)\n"
663 			"    Get ptype mapping on a port\n\n"
664 
665 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
666 			"    Replace target with the pkt_type in ptype mapping\n\n"
667 
668 			"ptype mapping reset (port_id)\n"
669 			"    Reset ptype mapping on a port\n\n"
670 
671 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
672 			"    Update a ptype mapping item on a port\n\n"
673 
674 			"set port (port_id) ptype_mask (ptype_mask)\n"
675 			"    set packet types classification for a specific port\n\n"
676 
677 			"set port (port_id) queue-region region_id (value) "
678 			"queue_start_index (value) queue_num (value)\n"
679 			"    Set a queue region on a port\n\n"
680 
681 			"set port (port_id) queue-region region_id (value) "
682 			"flowtype (value)\n"
683 			"    Set a flowtype region index on a port\n\n"
684 
685 			"set port (port_id) queue-region UP (value) region_id (value)\n"
686 			"    Set the mapping of User Priority to "
687 			"queue region on a port\n\n"
688 
689 			"set port (port_id) queue-region flush (on|off)\n"
690 			"    flush all queue region related configuration\n\n"
691 
692 			"show port meter cap (port_id)\n"
693 			"    Show port meter capability information\n\n"
694 
695 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
696 			"    meter profile add - srtcm rfc 2697\n\n"
697 
698 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
699 			"    meter profile add - trtcm rfc 2698\n\n"
700 
701 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
702 			"    meter profile add - trtcm rfc 4115\n\n"
703 
704 			"del port meter profile (port_id) (profile_id)\n"
705 			"    meter profile delete\n\n"
706 
707 			"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
708 			"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
709 			"(dscp_tbl_entry63)]\n"
710 			"    meter create\n\n"
711 
712 			"enable port meter (port_id) (mtr_id)\n"
713 			"    meter enable\n\n"
714 
715 			"disable port meter (port_id) (mtr_id)\n"
716 			"    meter disable\n\n"
717 
718 			"del port meter (port_id) (mtr_id)\n"
719 			"    meter delete\n\n"
720 
721 			"add port meter policy (port_id) (policy_id) g_actions (actions)\n"
722 			"y_actions (actions) r_actions (actions)\n"
723 			"    meter policy add\n\n"
724 
725 			"del port meter policy (port_id) (policy_id)\n"
726 			"    meter policy delete\n\n"
727 
728 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
729 			"    meter update meter profile\n\n"
730 
731 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
732 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
733 			"    update meter dscp table entries\n\n"
734 
735 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
736 			"(action0) [(action1) (action2)]\n"
737 			"    meter update policer action\n\n"
738 
739 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
740 			"    meter update stats\n\n"
741 
742 			"show port (port_id) queue-region\n"
743 			"    show all queue region related configuration info\n\n"
744 
745 			"set port (port_id) fec_mode auto|off|rs|baser\n"
746 			"    set fec mode for a specific port\n\n"
747 
748 			, list_pkt_forwarding_modes()
749 		);
750 	}
751 
752 	if (show_all || !strcmp(res->section, "ports")) {
753 
754 		cmdline_printf(
755 			cl,
756 			"\n"
757 			"Port Operations:\n"
758 			"----------------\n\n"
759 
760 			"port start (port_id|all)\n"
761 			"    Start all ports or port_id.\n\n"
762 
763 			"port stop (port_id|all)\n"
764 			"    Stop all ports or port_id.\n\n"
765 
766 			"port close (port_id|all)\n"
767 			"    Close all ports or port_id.\n\n"
768 
769 			"port reset (port_id|all)\n"
770 			"    Reset all ports or port_id.\n\n"
771 
772 			"port attach (ident)\n"
773 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
774 
775 			"port detach (port_id)\n"
776 			"    Detach physical or virtual dev by port_id\n\n"
777 
778 			"port config (port_id|all)"
779 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
780 			" duplex (half|full|auto)\n"
781 			"    Set speed and duplex for all ports or port_id\n\n"
782 
783 			"port config (port_id|all) loopback (mode)\n"
784 			"    Set loopback mode for all ports or port_id\n\n"
785 
786 			"port config all (rxq|txq|rxd|txd) (value)\n"
787 			"    Set number for rxq/txq/rxd/txd.\n\n"
788 
789 			"port config all max-pkt-len (value)\n"
790 			"    Set the max packet length.\n\n"
791 
792 			"port config all max-lro-pkt-size (value)\n"
793 			"    Set the max LRO aggregated packet size.\n\n"
794 
795 			"port config all drop-en (on|off)\n"
796 			"    Enable or disable packet drop on all RX queues of all ports when no "
797 			"receive buffers available.\n\n"
798 
799 			"port config all rss (all|default|ip|tcp|udp|sctp|"
800 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
801 			"level-outer|level-inner|<flowtype_id>)\n"
802 			"    Set the RSS mode.\n\n"
803 
804 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
805 			"    Set the RSS redirection table.\n\n"
806 
807 			"port config (port_id) dcb vt (on|off) (traffic_class)"
808 			" pfc (on|off)\n"
809 			"    Set the DCB mode.\n\n"
810 
811 			"port config all burst (value)\n"
812 			"    Set the number of packets per burst.\n\n"
813 
814 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
815 			" (value)\n"
816 			"    Set the ring prefetch/host/writeback threshold"
817 			" for tx/rx queue.\n\n"
818 
819 			"port config all (txfreet|txrst|rxfreet) (value)\n"
820 			"    Set free threshold for rx/tx, or set"
821 			" tx rs bit threshold.\n\n"
822 			"port config mtu X value\n"
823 			"    Set the MTU of port X to a given value\n\n"
824 
825 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
826 			"    Set a rx/tx queue's ring size configuration, the new"
827 			" value will take effect after command that (re-)start the port"
828 			" or command that setup the specific queue\n\n"
829 
830 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
831 			"    Start/stop a rx/tx queue of port X. Only take effect"
832 			" when port X is started\n\n"
833 
834 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
835 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
836 			" take effect when port X is stopped.\n\n"
837 
838 			"port (port_id) (rxq|txq) (queue_id) setup\n"
839 			"    Setup a rx/tx queue of port X.\n\n"
840 
841 			"port config (port_id) pctype mapping reset\n"
842 			"    Reset flow type to pctype mapping on a port\n\n"
843 
844 			"port config (port_id) pctype mapping update"
845 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 			"    Update a flow type to pctype mapping item on a port\n\n"
847 
848 			"port config (port_id) pctype (pctype_id) hash_inset|"
849 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
850 			" (field_idx)\n"
851 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
852 
853 			"port config (port_id) pctype (pctype_id) hash_inset|"
854 			"fdir_inset|fdir_flx_inset clear all"
855 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
856 
857 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
858 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
859 
860 			"port config <port_id> rx_offload vlan_strip|"
861 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 			"outer_ipv4_cksum|macsec_strip|header_split|"
863 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
864 			"buffer_split|timestamp|security|keep_crc on|off\n"
865 			"     Enable or disable a per port Rx offloading"
866 			" on all Rx queues of a port\n\n"
867 
868 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 			"outer_ipv4_cksum|macsec_strip|header_split|"
871 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
872 			"buffer_split|timestamp|security|keep_crc on|off\n"
873 			"    Enable or disable a per queue Rx offloading"
874 			" only on a specific Rx queue\n\n"
875 
876 			"port config (port_id) tx_offload vlan_insert|"
877 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
881 			"security on|off\n"
882 			"    Enable or disable a per port Tx offloading"
883 			" on all Tx queues of a port\n\n"
884 
885 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
890 			" on|off\n"
891 			"    Enable or disable a per queue Tx offloading"
892 			" only on a specific Tx queue\n\n"
893 
894 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 			"    Load an eBPF program as a callback"
896 			" for particular RX/TX queue\n\n"
897 
898 			"bpf-unload rx|tx (port) (queue)\n"
899 			"    Unload previously loaded eBPF program"
900 			" for particular RX/TX queue\n\n"
901 
902 			"port config (port_id) tx_metadata (value)\n"
903 			"    Set Tx metadata value per port. Testpmd will add this value"
904 			" to any Tx packet sent from this port\n\n"
905 
906 			"port config (port_id) dynf (name) set|clear\n"
907 			"    Register a dynf and Set/clear this flag on Tx. "
908 			"Testpmd will set this value to any Tx packet "
909 			"sent from this port\n\n"
910 
911 			"port cleanup (port_id) txq (queue_id) (free_cnt)\n"
912 			"    Cleanup txq mbufs for a specific Tx queue\n\n"
913 		);
914 	}
915 
916 	if (show_all || !strcmp(res->section, "registers")) {
917 
918 		cmdline_printf(
919 			cl,
920 			"\n"
921 			"Registers:\n"
922 			"----------\n\n"
923 
924 			"read reg (port_id) (address)\n"
925 			"    Display value of a port register.\n\n"
926 
927 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
928 			"    Display a port register bit field.\n\n"
929 
930 			"read regbit (port_id) (address) (bit_x)\n"
931 			"    Display a single port register bit.\n\n"
932 
933 			"write reg (port_id) (address) (value)\n"
934 			"    Set value of a port register.\n\n"
935 
936 			"write regfield (port_id) (address) (bit_x) (bit_y)"
937 			" (value)\n"
938 			"    Set bit field of a port register.\n\n"
939 
940 			"write regbit (port_id) (address) (bit_x) (value)\n"
941 			"    Set single bit value of a port register.\n\n"
942 		);
943 	}
944 	if (show_all || !strcmp(res->section, "filters")) {
945 
946 		cmdline_printf(
947 			cl,
948 			"\n"
949 			"filters:\n"
950 			"--------\n\n"
951 
952 #ifdef RTE_NET_I40E
953 			"flow_director_filter (port_id) mode raw (add|del|update)"
954 			" flow (flow_id) (drop|fwd) queue (queue_id)"
955 			" fd_id (fd_id_value) packet (packet file name)\n"
956 			"    Add/Del a raw type flow director filter.\n\n"
957 #endif
958 
959 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
960 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
961 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
962 			"    Set flow director IP mask.\n\n"
963 
964 			"flow_director_mask (port_id) mode MAC-VLAN"
965 			" vlan (vlan_value)\n"
966 			"    Set flow director MAC-VLAN mask.\n\n"
967 
968 			"flow_director_mask (port_id) mode Tunnel"
969 			" vlan (vlan_value) mac (mac_value)"
970 			" tunnel-type (tunnel_type_value)"
971 			" tunnel-id (tunnel_id_value)\n"
972 			"    Set flow director Tunnel mask.\n\n"
973 
974 			"flow_director_flex_payload (port_id)"
975 			" (raw|l2|l3|l4) (config)\n"
976 			"    Configure flex payload selection.\n\n"
977 
978 			"flow validate {port_id}"
979 			" [group {group_id}] [priority {level}]"
980 			" [ingress] [egress]"
981 			" pattern {item} [/ {item} [...]] / end"
982 			" actions {action} [/ {action} [...]] / end\n"
983 			"    Check whether a flow rule can be created.\n\n"
984 
985 			"flow create {port_id}"
986 			" [group {group_id}] [priority {level}]"
987 			" [ingress] [egress]"
988 			" pattern {item} [/ {item} [...]] / end"
989 			" actions {action} [/ {action} [...]] / end\n"
990 			"    Create a flow rule.\n\n"
991 
992 			"flow destroy {port_id} rule {rule_id} [...]\n"
993 			"    Destroy specific flow rules.\n\n"
994 
995 			"flow flush {port_id}\n"
996 			"    Destroy all flow rules.\n\n"
997 
998 			"flow query {port_id} {rule_id} {action}\n"
999 			"    Query an existing flow rule.\n\n"
1000 
1001 			"flow list {port_id} [group {group_id}] [...]\n"
1002 			"    List existing flow rules sorted by priority,"
1003 			" filtered by group identifiers.\n\n"
1004 
1005 			"flow isolate {port_id} {boolean}\n"
1006 			"    Restrict ingress traffic to the defined"
1007 			" flow rules\n\n"
1008 
1009 			"flow aged {port_id} [destroy]\n"
1010 			"    List and destroy aged flows"
1011 			" flow rules\n\n"
1012 
1013 			"flow indirect_action {port_id} create"
1014 			" [action_id {indirect_action_id}]"
1015 			" [ingress] [egress]"
1016 			" action {action} / end\n"
1017 			"    Create indirect action.\n\n"
1018 
1019 			"flow indirect_action {port_id} update"
1020 			" {indirect_action_id} action {action} / end\n"
1021 			"    Update indirect action.\n\n"
1022 
1023 			"flow indirect_action {port_id} destroy"
1024 			" action_id {indirect_action_id} [...]\n"
1025 			"    Destroy specific indirect actions.\n\n"
1026 
1027 			"flow indirect_action {port_id} query"
1028 			" {indirect_action_id}\n"
1029 			"    Query an existing indirect action.\n\n"
1030 
1031 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1032 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1033 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1034 			"       Configure the VXLAN encapsulation for flows.\n\n"
1035 
1036 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1037 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1038 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1039 			" eth-dst (eth-dst)\n"
1040 			"       Configure the VXLAN encapsulation for flows.\n\n"
1041 
1042 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1043 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1044 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1045 			" eth-dst (eth-dst)\n"
1046 			"       Configure the VXLAN encapsulation for flows.\n\n"
1047 
1048 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1049 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1050 			" (eth-dst)\n"
1051 			"       Configure the NVGRE encapsulation for flows.\n\n"
1052 
1053 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1054 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1055 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1056 			"       Configure the NVGRE encapsulation for flows.\n\n"
1057 
1058 			"set raw_encap {flow items}\n"
1059 			"	Configure the encapsulation with raw data.\n\n"
1060 
1061 			"set raw_decap {flow items}\n"
1062 			"	Configure the decapsulation with raw data.\n\n"
1063 
1064 		);
1065 	}
1066 
1067 	if (show_all || !strcmp(res->section, "traffic_management")) {
1068 		cmdline_printf(
1069 			cl,
1070 			"\n"
1071 			"Traffic Management:\n"
1072 			"--------------\n"
1073 			"show port tm cap (port_id)\n"
1074 			"       Display the port TM capability.\n\n"
1075 
1076 			"show port tm level cap (port_id) (level_id)\n"
1077 			"       Display the port TM hierarchical level capability.\n\n"
1078 
1079 			"show port tm node cap (port_id) (node_id)\n"
1080 			"       Display the port TM node capability.\n\n"
1081 
1082 			"show port tm node type (port_id) (node_id)\n"
1083 			"       Display the port TM node type.\n\n"
1084 
1085 			"show port tm node stats (port_id) (node_id) (clear)\n"
1086 			"       Display the port TM node stats.\n\n"
1087 
1088 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1089 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1090 			" (packet_length_adjust) (packet_mode)\n"
1091 			"       Add port tm node private shaper profile.\n\n"
1092 
1093 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1094 			"       Delete port tm node private shaper profile.\n\n"
1095 
1096 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1097 			" (shaper_profile_id)\n"
1098 			"       Add/update port tm node shared shaper.\n\n"
1099 
1100 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1101 			"       Delete port tm node shared shaper.\n\n"
1102 
1103 			"set port tm node shaper profile (port_id) (node_id)"
1104 			" (shaper_profile_id)\n"
1105 			"       Set port tm node shaper profile.\n\n"
1106 
1107 			"add port tm node wred profile (port_id) (wred_profile_id)"
1108 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1109 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1110 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1111 			"       Add port tm node wred profile.\n\n"
1112 
1113 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1114 			"       Delete port tm node wred profile.\n\n"
1115 
1116 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1117 			" (priority) (weight) (level_id) (shaper_profile_id)"
1118 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1119 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 			"       Add port tm nonleaf node.\n\n"
1121 
1122 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1123 			" (priority) (weight) (level_id) (shaper_profile_id)"
1124 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1125 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1126 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
1127 
1128 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1129 			" (priority) (weight) (level_id) (shaper_profile_id)"
1130 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1131 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1132 			"       Add port tm leaf node.\n\n"
1133 
1134 			"del port tm node (port_id) (node_id)\n"
1135 			"       Delete port tm node.\n\n"
1136 
1137 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1138 			" (priority) (weight)\n"
1139 			"       Set port tm node parent.\n\n"
1140 
1141 			"suspend port tm node (port_id) (node_id)"
1142 			"       Suspend tm node.\n\n"
1143 
1144 			"resume port tm node (port_id) (node_id)"
1145 			"       Resume tm node.\n\n"
1146 
1147 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1148 			"       Commit tm hierarchy.\n\n"
1149 
1150 			"set port tm mark ip_ecn (port) (green) (yellow)"
1151 			" (red)\n"
1152 			"    Enables/Disables the traffic management marking"
1153 			" for IP ECN (Explicit Congestion Notification)"
1154 			" packets on a given port\n\n"
1155 
1156 			"set port tm mark ip_dscp (port) (green) (yellow)"
1157 			" (red)\n"
1158 			"    Enables/Disables the traffic management marking"
1159 			" on the port for IP dscp packets\n\n"
1160 
1161 			"set port tm mark vlan_dei (port) (green) (yellow)"
1162 			" (red)\n"
1163 			"    Enables/Disables the traffic management marking"
1164 			" on the port for VLAN packets with DEI enabled\n\n"
1165 		);
1166 	}
1167 
1168 	if (show_all || !strcmp(res->section, "devices")) {
1169 		cmdline_printf(
1170 			cl,
1171 			"\n"
1172 			"Device Operations:\n"
1173 			"--------------\n"
1174 			"device detach (identifier)\n"
1175 			"       Detach device by identifier.\n\n"
1176 		);
1177 	}
1178 
1179 }
1180 
1181 cmdline_parse_token_string_t cmd_help_long_help =
1182 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1183 
1184 cmdline_parse_token_string_t cmd_help_long_section =
1185 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1186 			"all#control#display#config#"
1187 			"ports#registers#filters#traffic_management#devices");
1188 
1189 cmdline_parse_inst_t cmd_help_long = {
1190 	.f = cmd_help_long_parsed,
1191 	.data = NULL,
1192 	.help_str = "help all|control|display|config|ports|register|"
1193 		"filters|traffic_management|devices: "
1194 		"Show help",
1195 	.tokens = {
1196 		(void *)&cmd_help_long_help,
1197 		(void *)&cmd_help_long_section,
1198 		NULL,
1199 	},
1200 };
1201 
1202 
1203 /* *** start/stop/close all ports *** */
1204 struct cmd_operate_port_result {
1205 	cmdline_fixed_string_t keyword;
1206 	cmdline_fixed_string_t name;
1207 	cmdline_fixed_string_t value;
1208 };
1209 
1210 static void cmd_operate_port_parsed(void *parsed_result,
1211 				__rte_unused struct cmdline *cl,
1212 				__rte_unused void *data)
1213 {
1214 	struct cmd_operate_port_result *res = parsed_result;
1215 
1216 	if (!strcmp(res->name, "start"))
1217 		start_port(RTE_PORT_ALL);
1218 	else if (!strcmp(res->name, "stop"))
1219 		stop_port(RTE_PORT_ALL);
1220 	else if (!strcmp(res->name, "close"))
1221 		close_port(RTE_PORT_ALL);
1222 	else if (!strcmp(res->name, "reset"))
1223 		reset_port(RTE_PORT_ALL);
1224 	else
1225 		fprintf(stderr, "Unknown parameter\n");
1226 }
1227 
1228 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1229 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1230 								"port");
1231 cmdline_parse_token_string_t cmd_operate_port_all_port =
1232 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1233 						"start#stop#close#reset");
1234 cmdline_parse_token_string_t cmd_operate_port_all_all =
1235 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1236 
1237 cmdline_parse_inst_t cmd_operate_port = {
1238 	.f = cmd_operate_port_parsed,
1239 	.data = NULL,
1240 	.help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1241 	.tokens = {
1242 		(void *)&cmd_operate_port_all_cmd,
1243 		(void *)&cmd_operate_port_all_port,
1244 		(void *)&cmd_operate_port_all_all,
1245 		NULL,
1246 	},
1247 };
1248 
1249 /* *** start/stop/close specific port *** */
1250 struct cmd_operate_specific_port_result {
1251 	cmdline_fixed_string_t keyword;
1252 	cmdline_fixed_string_t name;
1253 	uint8_t value;
1254 };
1255 
1256 static void cmd_operate_specific_port_parsed(void *parsed_result,
1257 			__rte_unused struct cmdline *cl,
1258 				__rte_unused void *data)
1259 {
1260 	struct cmd_operate_specific_port_result *res = parsed_result;
1261 
1262 	if (!strcmp(res->name, "start"))
1263 		start_port(res->value);
1264 	else if (!strcmp(res->name, "stop"))
1265 		stop_port(res->value);
1266 	else if (!strcmp(res->name, "close"))
1267 		close_port(res->value);
1268 	else if (!strcmp(res->name, "reset"))
1269 		reset_port(res->value);
1270 	else
1271 		fprintf(stderr, "Unknown parameter\n");
1272 }
1273 
1274 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1275 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1276 							keyword, "port");
1277 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1278 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1279 						name, "start#stop#close#reset");
1280 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1281 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1282 							value, RTE_UINT8);
1283 
1284 cmdline_parse_inst_t cmd_operate_specific_port = {
1285 	.f = cmd_operate_specific_port_parsed,
1286 	.data = NULL,
1287 	.help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1288 	.tokens = {
1289 		(void *)&cmd_operate_specific_port_cmd,
1290 		(void *)&cmd_operate_specific_port_port,
1291 		(void *)&cmd_operate_specific_port_id,
1292 		NULL,
1293 	},
1294 };
1295 
1296 /* *** enable port setup (after attach) via iterator or event *** */
1297 struct cmd_set_port_setup_on_result {
1298 	cmdline_fixed_string_t set;
1299 	cmdline_fixed_string_t port;
1300 	cmdline_fixed_string_t setup;
1301 	cmdline_fixed_string_t on;
1302 	cmdline_fixed_string_t mode;
1303 };
1304 
1305 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1306 				__rte_unused struct cmdline *cl,
1307 				__rte_unused void *data)
1308 {
1309 	struct cmd_set_port_setup_on_result *res = parsed_result;
1310 
1311 	if (strcmp(res->mode, "event") == 0)
1312 		setup_on_probe_event = true;
1313 	else if (strcmp(res->mode, "iterator") == 0)
1314 		setup_on_probe_event = false;
1315 	else
1316 		fprintf(stderr, "Unknown mode\n");
1317 }
1318 
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1320 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 			set, "set");
1322 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1323 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1324 			port, "port");
1325 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1326 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1327 			setup, "setup");
1328 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1329 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1330 			on, "on");
1331 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1332 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1333 			mode, "iterator#event");
1334 
1335 cmdline_parse_inst_t cmd_set_port_setup_on = {
1336 	.f = cmd_set_port_setup_on_parsed,
1337 	.data = NULL,
1338 	.help_str = "set port setup on iterator|event",
1339 	.tokens = {
1340 		(void *)&cmd_set_port_setup_on_set,
1341 		(void *)&cmd_set_port_setup_on_port,
1342 		(void *)&cmd_set_port_setup_on_setup,
1343 		(void *)&cmd_set_port_setup_on_on,
1344 		(void *)&cmd_set_port_setup_on_mode,
1345 		NULL,
1346 	},
1347 };
1348 
1349 /* *** attach a specified port *** */
1350 struct cmd_operate_attach_port_result {
1351 	cmdline_fixed_string_t port;
1352 	cmdline_fixed_string_t keyword;
1353 	cmdline_multi_string_t identifier;
1354 };
1355 
1356 static void cmd_operate_attach_port_parsed(void *parsed_result,
1357 				__rte_unused struct cmdline *cl,
1358 				__rte_unused void *data)
1359 {
1360 	struct cmd_operate_attach_port_result *res = parsed_result;
1361 
1362 	if (!strcmp(res->keyword, "attach"))
1363 		attach_port(res->identifier);
1364 	else
1365 		fprintf(stderr, "Unknown parameter\n");
1366 }
1367 
1368 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1369 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1370 			port, "port");
1371 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1372 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1373 			keyword, "attach");
1374 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1375 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1376 			identifier, TOKEN_STRING_MULTI);
1377 
1378 cmdline_parse_inst_t cmd_operate_attach_port = {
1379 	.f = cmd_operate_attach_port_parsed,
1380 	.data = NULL,
1381 	.help_str = "port attach <identifier>: "
1382 		"(identifier: pci address or virtual dev name)",
1383 	.tokens = {
1384 		(void *)&cmd_operate_attach_port_port,
1385 		(void *)&cmd_operate_attach_port_keyword,
1386 		(void *)&cmd_operate_attach_port_identifier,
1387 		NULL,
1388 	},
1389 };
1390 
1391 /* *** detach a specified port *** */
1392 struct cmd_operate_detach_port_result {
1393 	cmdline_fixed_string_t port;
1394 	cmdline_fixed_string_t keyword;
1395 	portid_t port_id;
1396 };
1397 
1398 static void cmd_operate_detach_port_parsed(void *parsed_result,
1399 				__rte_unused struct cmdline *cl,
1400 				__rte_unused void *data)
1401 {
1402 	struct cmd_operate_detach_port_result *res = parsed_result;
1403 
1404 	if (!strcmp(res->keyword, "detach")) {
1405 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1406 		detach_port_device(res->port_id);
1407 	} else {
1408 		fprintf(stderr, "Unknown parameter\n");
1409 	}
1410 }
1411 
1412 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1413 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1414 			port, "port");
1415 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1416 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1417 			keyword, "detach");
1418 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1419 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1420 			port_id, RTE_UINT16);
1421 
1422 cmdline_parse_inst_t cmd_operate_detach_port = {
1423 	.f = cmd_operate_detach_port_parsed,
1424 	.data = NULL,
1425 	.help_str = "port detach <port_id>",
1426 	.tokens = {
1427 		(void *)&cmd_operate_detach_port_port,
1428 		(void *)&cmd_operate_detach_port_keyword,
1429 		(void *)&cmd_operate_detach_port_port_id,
1430 		NULL,
1431 	},
1432 };
1433 
1434 /* *** detach device by identifier *** */
1435 struct cmd_operate_detach_device_result {
1436 	cmdline_fixed_string_t device;
1437 	cmdline_fixed_string_t keyword;
1438 	cmdline_fixed_string_t identifier;
1439 };
1440 
1441 static void cmd_operate_detach_device_parsed(void *parsed_result,
1442 				__rte_unused struct cmdline *cl,
1443 				__rte_unused void *data)
1444 {
1445 	struct cmd_operate_detach_device_result *res = parsed_result;
1446 
1447 	if (!strcmp(res->keyword, "detach"))
1448 		detach_devargs(res->identifier);
1449 	else
1450 		fprintf(stderr, "Unknown parameter\n");
1451 }
1452 
1453 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1454 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1455 			device, "device");
1456 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1457 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1458 			keyword, "detach");
1459 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1460 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1461 			identifier, NULL);
1462 
1463 cmdline_parse_inst_t cmd_operate_detach_device = {
1464 	.f = cmd_operate_detach_device_parsed,
1465 	.data = NULL,
1466 	.help_str = "device detach <identifier>:"
1467 		"(identifier: pci address or virtual dev name)",
1468 	.tokens = {
1469 		(void *)&cmd_operate_detach_device_device,
1470 		(void *)&cmd_operate_detach_device_keyword,
1471 		(void *)&cmd_operate_detach_device_identifier,
1472 		NULL,
1473 	},
1474 };
1475 /* *** configure speed for all ports *** */
1476 struct cmd_config_speed_all {
1477 	cmdline_fixed_string_t port;
1478 	cmdline_fixed_string_t keyword;
1479 	cmdline_fixed_string_t all;
1480 	cmdline_fixed_string_t item1;
1481 	cmdline_fixed_string_t item2;
1482 	cmdline_fixed_string_t value1;
1483 	cmdline_fixed_string_t value2;
1484 };
1485 
1486 static int
1487 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1488 {
1489 
1490 	int duplex;
1491 
1492 	if (!strcmp(duplexstr, "half")) {
1493 		duplex = ETH_LINK_HALF_DUPLEX;
1494 	} else if (!strcmp(duplexstr, "full")) {
1495 		duplex = ETH_LINK_FULL_DUPLEX;
1496 	} else if (!strcmp(duplexstr, "auto")) {
1497 		duplex = ETH_LINK_FULL_DUPLEX;
1498 	} else {
1499 		fprintf(stderr, "Unknown duplex parameter\n");
1500 		return -1;
1501 	}
1502 
1503 	if (!strcmp(speedstr, "10")) {
1504 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1505 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1506 	} else if (!strcmp(speedstr, "100")) {
1507 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1508 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1509 	} else {
1510 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1511 			fprintf(stderr, "Invalid speed/duplex parameters\n");
1512 			return -1;
1513 		}
1514 		if (!strcmp(speedstr, "1000")) {
1515 			*speed = ETH_LINK_SPEED_1G;
1516 		} else if (!strcmp(speedstr, "10000")) {
1517 			*speed = ETH_LINK_SPEED_10G;
1518 		} else if (!strcmp(speedstr, "25000")) {
1519 			*speed = ETH_LINK_SPEED_25G;
1520 		} else if (!strcmp(speedstr, "40000")) {
1521 			*speed = ETH_LINK_SPEED_40G;
1522 		} else if (!strcmp(speedstr, "50000")) {
1523 			*speed = ETH_LINK_SPEED_50G;
1524 		} else if (!strcmp(speedstr, "100000")) {
1525 			*speed = ETH_LINK_SPEED_100G;
1526 		} else if (!strcmp(speedstr, "200000")) {
1527 			*speed = ETH_LINK_SPEED_200G;
1528 		} else if (!strcmp(speedstr, "auto")) {
1529 			*speed = ETH_LINK_SPEED_AUTONEG;
1530 		} else {
1531 			fprintf(stderr, "Unknown speed parameter\n");
1532 			return -1;
1533 		}
1534 	}
1535 
1536 	if (*speed != ETH_LINK_SPEED_AUTONEG)
1537 		*speed |= ETH_LINK_SPEED_FIXED;
1538 
1539 	return 0;
1540 }
1541 
1542 static void
1543 cmd_config_speed_all_parsed(void *parsed_result,
1544 			__rte_unused struct cmdline *cl,
1545 			__rte_unused void *data)
1546 {
1547 	struct cmd_config_speed_all *res = parsed_result;
1548 	uint32_t link_speed;
1549 	portid_t pid;
1550 
1551 	if (!all_ports_stopped()) {
1552 		fprintf(stderr, "Please stop all ports first\n");
1553 		return;
1554 	}
1555 
1556 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1557 			&link_speed) < 0)
1558 		return;
1559 
1560 	RTE_ETH_FOREACH_DEV(pid) {
1561 		ports[pid].dev_conf.link_speeds = link_speed;
1562 	}
1563 
1564 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1565 }
1566 
1567 cmdline_parse_token_string_t cmd_config_speed_all_port =
1568 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1569 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1570 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1571 							"config");
1572 cmdline_parse_token_string_t cmd_config_speed_all_all =
1573 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1574 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1575 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1576 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1577 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1578 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1579 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1580 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1581 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1582 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1583 						"half#full#auto");
1584 
1585 cmdline_parse_inst_t cmd_config_speed_all = {
1586 	.f = cmd_config_speed_all_parsed,
1587 	.data = NULL,
1588 	.help_str = "port config all speed "
1589 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1590 							"half|full|auto",
1591 	.tokens = {
1592 		(void *)&cmd_config_speed_all_port,
1593 		(void *)&cmd_config_speed_all_keyword,
1594 		(void *)&cmd_config_speed_all_all,
1595 		(void *)&cmd_config_speed_all_item1,
1596 		(void *)&cmd_config_speed_all_value1,
1597 		(void *)&cmd_config_speed_all_item2,
1598 		(void *)&cmd_config_speed_all_value2,
1599 		NULL,
1600 	},
1601 };
1602 
1603 /* *** configure speed for specific port *** */
1604 struct cmd_config_speed_specific {
1605 	cmdline_fixed_string_t port;
1606 	cmdline_fixed_string_t keyword;
1607 	portid_t id;
1608 	cmdline_fixed_string_t item1;
1609 	cmdline_fixed_string_t item2;
1610 	cmdline_fixed_string_t value1;
1611 	cmdline_fixed_string_t value2;
1612 };
1613 
1614 static void
1615 cmd_config_speed_specific_parsed(void *parsed_result,
1616 				__rte_unused struct cmdline *cl,
1617 				__rte_unused void *data)
1618 {
1619 	struct cmd_config_speed_specific *res = parsed_result;
1620 	uint32_t link_speed;
1621 
1622 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1623 		return;
1624 
1625 	if (!port_is_stopped(res->id)) {
1626 		fprintf(stderr, "Please stop port %d first\n", res->id);
1627 		return;
1628 	}
1629 
1630 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1631 			&link_speed) < 0)
1632 		return;
1633 
1634 	ports[res->id].dev_conf.link_speeds = link_speed;
1635 
1636 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1637 }
1638 
1639 
1640 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1641 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1642 								"port");
1643 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1644 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1645 								"config");
1646 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1647 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1648 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1649 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1650 								"speed");
1651 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1652 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1653 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1654 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1655 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1656 								"duplex");
1657 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1658 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1659 							"half#full#auto");
1660 
1661 cmdline_parse_inst_t cmd_config_speed_specific = {
1662 	.f = cmd_config_speed_specific_parsed,
1663 	.data = NULL,
1664 	.help_str = "port config <port_id> speed "
1665 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1666 							"half|full|auto",
1667 	.tokens = {
1668 		(void *)&cmd_config_speed_specific_port,
1669 		(void *)&cmd_config_speed_specific_keyword,
1670 		(void *)&cmd_config_speed_specific_id,
1671 		(void *)&cmd_config_speed_specific_item1,
1672 		(void *)&cmd_config_speed_specific_value1,
1673 		(void *)&cmd_config_speed_specific_item2,
1674 		(void *)&cmd_config_speed_specific_value2,
1675 		NULL,
1676 	},
1677 };
1678 
1679 /* *** configure loopback for all ports *** */
1680 struct cmd_config_loopback_all {
1681 	cmdline_fixed_string_t port;
1682 	cmdline_fixed_string_t keyword;
1683 	cmdline_fixed_string_t all;
1684 	cmdline_fixed_string_t item;
1685 	uint32_t mode;
1686 };
1687 
1688 static void
1689 cmd_config_loopback_all_parsed(void *parsed_result,
1690 			__rte_unused struct cmdline *cl,
1691 			__rte_unused void *data)
1692 {
1693 	struct cmd_config_loopback_all *res = parsed_result;
1694 	portid_t pid;
1695 
1696 	if (!all_ports_stopped()) {
1697 		fprintf(stderr, "Please stop all ports first\n");
1698 		return;
1699 	}
1700 
1701 	RTE_ETH_FOREACH_DEV(pid) {
1702 		ports[pid].dev_conf.lpbk_mode = res->mode;
1703 	}
1704 
1705 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1706 }
1707 
1708 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1709 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1710 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1711 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1712 							"config");
1713 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1714 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1715 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1716 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1717 							"loopback");
1718 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1719 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1720 
1721 cmdline_parse_inst_t cmd_config_loopback_all = {
1722 	.f = cmd_config_loopback_all_parsed,
1723 	.data = NULL,
1724 	.help_str = "port config all loopback <mode>",
1725 	.tokens = {
1726 		(void *)&cmd_config_loopback_all_port,
1727 		(void *)&cmd_config_loopback_all_keyword,
1728 		(void *)&cmd_config_loopback_all_all,
1729 		(void *)&cmd_config_loopback_all_item,
1730 		(void *)&cmd_config_loopback_all_mode,
1731 		NULL,
1732 	},
1733 };
1734 
1735 /* *** configure loopback for specific port *** */
1736 struct cmd_config_loopback_specific {
1737 	cmdline_fixed_string_t port;
1738 	cmdline_fixed_string_t keyword;
1739 	uint16_t port_id;
1740 	cmdline_fixed_string_t item;
1741 	uint32_t mode;
1742 };
1743 
1744 static void
1745 cmd_config_loopback_specific_parsed(void *parsed_result,
1746 				__rte_unused struct cmdline *cl,
1747 				__rte_unused void *data)
1748 {
1749 	struct cmd_config_loopback_specific *res = parsed_result;
1750 
1751 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1752 		return;
1753 
1754 	if (!port_is_stopped(res->port_id)) {
1755 		fprintf(stderr, "Please stop port %u first\n", res->port_id);
1756 		return;
1757 	}
1758 
1759 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1760 
1761 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1762 }
1763 
1764 
1765 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1766 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1767 								"port");
1768 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1769 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1770 								"config");
1771 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1772 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1773 								RTE_UINT16);
1774 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1775 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1776 								"loopback");
1777 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1778 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1779 			      RTE_UINT32);
1780 
1781 cmdline_parse_inst_t cmd_config_loopback_specific = {
1782 	.f = cmd_config_loopback_specific_parsed,
1783 	.data = NULL,
1784 	.help_str = "port config <port_id> loopback <mode>",
1785 	.tokens = {
1786 		(void *)&cmd_config_loopback_specific_port,
1787 		(void *)&cmd_config_loopback_specific_keyword,
1788 		(void *)&cmd_config_loopback_specific_id,
1789 		(void *)&cmd_config_loopback_specific_item,
1790 		(void *)&cmd_config_loopback_specific_mode,
1791 		NULL,
1792 	},
1793 };
1794 
1795 /* *** configure txq/rxq, txd/rxd *** */
1796 struct cmd_config_rx_tx {
1797 	cmdline_fixed_string_t port;
1798 	cmdline_fixed_string_t keyword;
1799 	cmdline_fixed_string_t all;
1800 	cmdline_fixed_string_t name;
1801 	uint16_t value;
1802 };
1803 
1804 static void
1805 cmd_config_rx_tx_parsed(void *parsed_result,
1806 			__rte_unused struct cmdline *cl,
1807 			__rte_unused void *data)
1808 {
1809 	struct cmd_config_rx_tx *res = parsed_result;
1810 
1811 	if (!all_ports_stopped()) {
1812 		fprintf(stderr, "Please stop all ports first\n");
1813 		return;
1814 	}
1815 	if (!strcmp(res->name, "rxq")) {
1816 		if (!res->value && !nb_txq) {
1817 			fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1818 			return;
1819 		}
1820 		if (check_nb_rxq(res->value) != 0)
1821 			return;
1822 		nb_rxq = res->value;
1823 	}
1824 	else if (!strcmp(res->name, "txq")) {
1825 		if (!res->value && !nb_rxq) {
1826 			fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1827 			return;
1828 		}
1829 		if (check_nb_txq(res->value) != 0)
1830 			return;
1831 		nb_txq = res->value;
1832 	}
1833 	else if (!strcmp(res->name, "rxd")) {
1834 		if (check_nb_rxd(res->value) != 0)
1835 			return;
1836 		nb_rxd = res->value;
1837 	} else if (!strcmp(res->name, "txd")) {
1838 		if (check_nb_txd(res->value) != 0)
1839 			return;
1840 
1841 		nb_txd = res->value;
1842 	} else {
1843 		fprintf(stderr, "Unknown parameter\n");
1844 		return;
1845 	}
1846 
1847 	fwd_config_setup();
1848 
1849 	init_port_config();
1850 
1851 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1852 }
1853 
1854 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1855 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1856 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1857 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1858 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1859 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1860 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1861 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1862 						"rxq#txq#rxd#txd");
1863 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1864 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1865 
1866 cmdline_parse_inst_t cmd_config_rx_tx = {
1867 	.f = cmd_config_rx_tx_parsed,
1868 	.data = NULL,
1869 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1870 	.tokens = {
1871 		(void *)&cmd_config_rx_tx_port,
1872 		(void *)&cmd_config_rx_tx_keyword,
1873 		(void *)&cmd_config_rx_tx_all,
1874 		(void *)&cmd_config_rx_tx_name,
1875 		(void *)&cmd_config_rx_tx_value,
1876 		NULL,
1877 	},
1878 };
1879 
1880 /* *** config max packet length *** */
1881 struct cmd_config_max_pkt_len_result {
1882 	cmdline_fixed_string_t port;
1883 	cmdline_fixed_string_t keyword;
1884 	cmdline_fixed_string_t all;
1885 	cmdline_fixed_string_t name;
1886 	uint32_t value;
1887 };
1888 
1889 static void
1890 cmd_config_max_pkt_len_parsed(void *parsed_result,
1891 				__rte_unused struct cmdline *cl,
1892 				__rte_unused void *data)
1893 {
1894 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1895 	uint32_t max_rx_pkt_len_backup = 0;
1896 	portid_t pid;
1897 	int ret;
1898 
1899 	if (!all_ports_stopped()) {
1900 		fprintf(stderr, "Please stop all ports first\n");
1901 		return;
1902 	}
1903 
1904 	RTE_ETH_FOREACH_DEV(pid) {
1905 		struct rte_port *port = &ports[pid];
1906 
1907 		if (!strcmp(res->name, "max-pkt-len")) {
1908 			if (res->value < RTE_ETHER_MIN_LEN) {
1909 				fprintf(stderr,
1910 					"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 				fprintf(stderr,
1920 					"rte_eth_dev_info_get() failed for port %u\n",
1921 					pid);
1922 				return;
1923 			}
1924 
1925 			max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1926 
1927 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1928 			if (update_jumbo_frame_offload(pid) != 0)
1929 				port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1930 		} else {
1931 			fprintf(stderr, "Unknown parameter\n");
1932 			return;
1933 		}
1934 	}
1935 
1936 	init_port_config();
1937 
1938 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1939 }
1940 
1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1942 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1943 								"port");
1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1945 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1946 								"config");
1947 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1948 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1949 								"all");
1950 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1951 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1952 								"max-pkt-len");
1953 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1954 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1955 								RTE_UINT32);
1956 
1957 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1958 	.f = cmd_config_max_pkt_len_parsed,
1959 	.data = NULL,
1960 	.help_str = "port config all max-pkt-len <value>",
1961 	.tokens = {
1962 		(void *)&cmd_config_max_pkt_len_port,
1963 		(void *)&cmd_config_max_pkt_len_keyword,
1964 		(void *)&cmd_config_max_pkt_len_all,
1965 		(void *)&cmd_config_max_pkt_len_name,
1966 		(void *)&cmd_config_max_pkt_len_value,
1967 		NULL,
1968 	},
1969 };
1970 
1971 /* *** config max LRO aggregated packet size *** */
1972 struct cmd_config_max_lro_pkt_size_result {
1973 	cmdline_fixed_string_t port;
1974 	cmdline_fixed_string_t keyword;
1975 	cmdline_fixed_string_t all;
1976 	cmdline_fixed_string_t name;
1977 	uint32_t value;
1978 };
1979 
1980 static void
1981 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1982 				__rte_unused struct cmdline *cl,
1983 				__rte_unused void *data)
1984 {
1985 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1986 	portid_t pid;
1987 
1988 	if (!all_ports_stopped()) {
1989 		fprintf(stderr, "Please stop all ports first\n");
1990 		return;
1991 	}
1992 
1993 	RTE_ETH_FOREACH_DEV(pid) {
1994 		struct rte_port *port = &ports[pid];
1995 
1996 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1997 			if (res->value ==
1998 					port->dev_conf.rxmode.max_lro_pkt_size)
1999 				return;
2000 
2001 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2002 		} else {
2003 			fprintf(stderr, "Unknown parameter\n");
2004 			return;
2005 		}
2006 	}
2007 
2008 	init_port_config();
2009 
2010 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2011 }
2012 
2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2014 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2015 				 port, "port");
2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2017 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 				 keyword, "config");
2019 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2020 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2021 				 all, "all");
2022 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2023 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2024 				 name, "max-lro-pkt-size");
2025 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2026 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2027 			      value, RTE_UINT32);
2028 
2029 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2030 	.f = cmd_config_max_lro_pkt_size_parsed,
2031 	.data = NULL,
2032 	.help_str = "port config all max-lro-pkt-size <value>",
2033 	.tokens = {
2034 		(void *)&cmd_config_max_lro_pkt_size_port,
2035 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2036 		(void *)&cmd_config_max_lro_pkt_size_all,
2037 		(void *)&cmd_config_max_lro_pkt_size_name,
2038 		(void *)&cmd_config_max_lro_pkt_size_value,
2039 		NULL,
2040 	},
2041 };
2042 
2043 /* *** configure port MTU *** */
2044 struct cmd_config_mtu_result {
2045 	cmdline_fixed_string_t port;
2046 	cmdline_fixed_string_t keyword;
2047 	cmdline_fixed_string_t mtu;
2048 	portid_t port_id;
2049 	uint16_t value;
2050 };
2051 
2052 static void
2053 cmd_config_mtu_parsed(void *parsed_result,
2054 		      __rte_unused struct cmdline *cl,
2055 		      __rte_unused void *data)
2056 {
2057 	struct cmd_config_mtu_result *res = parsed_result;
2058 
2059 	if (res->value < RTE_ETHER_MIN_LEN) {
2060 		fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2061 		return;
2062 	}
2063 	port_mtu_set(res->port_id, res->value);
2064 }
2065 
2066 cmdline_parse_token_string_t cmd_config_mtu_port =
2067 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2068 				 "port");
2069 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2070 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2071 				 "config");
2072 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2073 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2074 				 "mtu");
2075 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2076 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2077 				 RTE_UINT16);
2078 cmdline_parse_token_num_t cmd_config_mtu_value =
2079 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2080 				 RTE_UINT16);
2081 
2082 cmdline_parse_inst_t cmd_config_mtu = {
2083 	.f = cmd_config_mtu_parsed,
2084 	.data = NULL,
2085 	.help_str = "port config mtu <port_id> <value>",
2086 	.tokens = {
2087 		(void *)&cmd_config_mtu_port,
2088 		(void *)&cmd_config_mtu_keyword,
2089 		(void *)&cmd_config_mtu_mtu,
2090 		(void *)&cmd_config_mtu_port_id,
2091 		(void *)&cmd_config_mtu_value,
2092 		NULL,
2093 	},
2094 };
2095 
2096 /* *** configure rx mode *** */
2097 struct cmd_config_rx_mode_flag {
2098 	cmdline_fixed_string_t port;
2099 	cmdline_fixed_string_t keyword;
2100 	cmdline_fixed_string_t all;
2101 	cmdline_fixed_string_t name;
2102 	cmdline_fixed_string_t value;
2103 };
2104 
2105 static void
2106 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2107 				__rte_unused struct cmdline *cl,
2108 				__rte_unused void *data)
2109 {
2110 	struct cmd_config_rx_mode_flag *res = parsed_result;
2111 
2112 	if (!all_ports_stopped()) {
2113 		fprintf(stderr, "Please stop all ports first\n");
2114 		return;
2115 	}
2116 
2117 	if (!strcmp(res->name, "drop-en")) {
2118 		if (!strcmp(res->value, "on"))
2119 			rx_drop_en = 1;
2120 		else if (!strcmp(res->value, "off"))
2121 			rx_drop_en = 0;
2122 		else {
2123 			fprintf(stderr, "Unknown parameter\n");
2124 			return;
2125 		}
2126 	} else {
2127 		fprintf(stderr, "Unknown parameter\n");
2128 		return;
2129 	}
2130 
2131 	init_port_config();
2132 
2133 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2134 }
2135 
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2137 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2139 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2140 								"config");
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2142 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2143 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2144 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2145 					"drop-en");
2146 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2147 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2148 							"on#off");
2149 
2150 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2151 	.f = cmd_config_rx_mode_flag_parsed,
2152 	.data = NULL,
2153 	.help_str = "port config all drop-en on|off",
2154 	.tokens = {
2155 		(void *)&cmd_config_rx_mode_flag_port,
2156 		(void *)&cmd_config_rx_mode_flag_keyword,
2157 		(void *)&cmd_config_rx_mode_flag_all,
2158 		(void *)&cmd_config_rx_mode_flag_name,
2159 		(void *)&cmd_config_rx_mode_flag_value,
2160 		NULL,
2161 	},
2162 };
2163 
2164 /* *** configure rss *** */
2165 struct cmd_config_rss {
2166 	cmdline_fixed_string_t port;
2167 	cmdline_fixed_string_t keyword;
2168 	cmdline_fixed_string_t all;
2169 	cmdline_fixed_string_t name;
2170 	cmdline_fixed_string_t value;
2171 };
2172 
2173 static void
2174 cmd_config_rss_parsed(void *parsed_result,
2175 			__rte_unused struct cmdline *cl,
2176 			__rte_unused void *data)
2177 {
2178 	struct cmd_config_rss *res = parsed_result;
2179 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2180 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2181 	int use_default = 0;
2182 	int all_updated = 1;
2183 	int diag;
2184 	uint16_t i;
2185 	int ret;
2186 
2187 	if (!strcmp(res->value, "all"))
2188 		rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2189 			ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2190 			ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2191 			ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2192 			ETH_RSS_ECPRI;
2193 	else if (!strcmp(res->value, "eth"))
2194 		rss_conf.rss_hf = ETH_RSS_ETH;
2195 	else if (!strcmp(res->value, "vlan"))
2196 		rss_conf.rss_hf = ETH_RSS_VLAN;
2197 	else if (!strcmp(res->value, "ip"))
2198 		rss_conf.rss_hf = ETH_RSS_IP;
2199 	else if (!strcmp(res->value, "udp"))
2200 		rss_conf.rss_hf = ETH_RSS_UDP;
2201 	else if (!strcmp(res->value, "tcp"))
2202 		rss_conf.rss_hf = ETH_RSS_TCP;
2203 	else if (!strcmp(res->value, "sctp"))
2204 		rss_conf.rss_hf = ETH_RSS_SCTP;
2205 	else if (!strcmp(res->value, "ether"))
2206 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2207 	else if (!strcmp(res->value, "port"))
2208 		rss_conf.rss_hf = ETH_RSS_PORT;
2209 	else if (!strcmp(res->value, "vxlan"))
2210 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2211 	else if (!strcmp(res->value, "geneve"))
2212 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2213 	else if (!strcmp(res->value, "nvgre"))
2214 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2215 	else if (!strcmp(res->value, "l3-pre32"))
2216 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2217 	else if (!strcmp(res->value, "l3-pre40"))
2218 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2219 	else if (!strcmp(res->value, "l3-pre48"))
2220 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2221 	else if (!strcmp(res->value, "l3-pre56"))
2222 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2223 	else if (!strcmp(res->value, "l3-pre64"))
2224 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2225 	else if (!strcmp(res->value, "l3-pre96"))
2226 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2227 	else if (!strcmp(res->value, "l3-src-only"))
2228 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2229 	else if (!strcmp(res->value, "l3-dst-only"))
2230 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2231 	else if (!strcmp(res->value, "l4-src-only"))
2232 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2233 	else if (!strcmp(res->value, "l4-dst-only"))
2234 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2235 	else if (!strcmp(res->value, "l2-src-only"))
2236 		rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2237 	else if (!strcmp(res->value, "l2-dst-only"))
2238 		rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2239 	else if (!strcmp(res->value, "l2tpv3"))
2240 		rss_conf.rss_hf = ETH_RSS_L2TPV3;
2241 	else if (!strcmp(res->value, "esp"))
2242 		rss_conf.rss_hf = ETH_RSS_ESP;
2243 	else if (!strcmp(res->value, "ah"))
2244 		rss_conf.rss_hf = ETH_RSS_AH;
2245 	else if (!strcmp(res->value, "pfcp"))
2246 		rss_conf.rss_hf = ETH_RSS_PFCP;
2247 	else if (!strcmp(res->value, "pppoe"))
2248 		rss_conf.rss_hf = ETH_RSS_PPPOE;
2249 	else if (!strcmp(res->value, "gtpu"))
2250 		rss_conf.rss_hf = ETH_RSS_GTPU;
2251 	else if (!strcmp(res->value, "ecpri"))
2252 		rss_conf.rss_hf = ETH_RSS_ECPRI;
2253 	else if (!strcmp(res->value, "mpls"))
2254 		rss_conf.rss_hf = ETH_RSS_MPLS;
2255 	else if (!strcmp(res->value, "ipv4-chksum"))
2256 		rss_conf.rss_hf = ETH_RSS_IPV4_CHKSUM;
2257 	else if (!strcmp(res->value, "none"))
2258 		rss_conf.rss_hf = 0;
2259 	else if (!strcmp(res->value, "level-default")) {
2260 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2261 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2262 	} else if (!strcmp(res->value, "level-outer")) {
2263 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2264 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2265 	} else if (!strcmp(res->value, "level-inner")) {
2266 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2267 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2268 	} else if (!strcmp(res->value, "default"))
2269 		use_default = 1;
2270 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2271 						atoi(res->value) < 64)
2272 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2273 	else {
2274 		fprintf(stderr, "Unknown parameter\n");
2275 		return;
2276 	}
2277 	rss_conf.rss_key = NULL;
2278 	/* Update global configuration for RSS types. */
2279 	RTE_ETH_FOREACH_DEV(i) {
2280 		struct rte_eth_rss_conf local_rss_conf;
2281 
2282 		ret = eth_dev_info_get_print_err(i, &dev_info);
2283 		if (ret != 0)
2284 			return;
2285 
2286 		if (use_default)
2287 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2288 
2289 		local_rss_conf = rss_conf;
2290 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2291 			dev_info.flow_type_rss_offloads;
2292 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2293 			printf("Port %u modified RSS hash function based on hardware support,"
2294 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2295 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2296 		}
2297 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2298 		if (diag < 0) {
2299 			all_updated = 0;
2300 			fprintf(stderr,
2301 				"Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2302 				i, -diag, strerror(-diag));
2303 		}
2304 	}
2305 	if (all_updated && !use_default) {
2306 		rss_hf = rss_conf.rss_hf;
2307 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2308 	}
2309 }
2310 
2311 cmdline_parse_token_string_t cmd_config_rss_port =
2312 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2313 cmdline_parse_token_string_t cmd_config_rss_keyword =
2314 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2315 cmdline_parse_token_string_t cmd_config_rss_all =
2316 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2317 cmdline_parse_token_string_t cmd_config_rss_name =
2318 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2319 cmdline_parse_token_string_t cmd_config_rss_value =
2320 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2321 
2322 cmdline_parse_inst_t cmd_config_rss = {
2323 	.f = cmd_config_rss_parsed,
2324 	.data = NULL,
2325 	.help_str = "port config all rss "
2326 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2327 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2328 		"level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2329 	.tokens = {
2330 		(void *)&cmd_config_rss_port,
2331 		(void *)&cmd_config_rss_keyword,
2332 		(void *)&cmd_config_rss_all,
2333 		(void *)&cmd_config_rss_name,
2334 		(void *)&cmd_config_rss_value,
2335 		NULL,
2336 	},
2337 };
2338 
2339 /* *** configure rss hash key *** */
2340 struct cmd_config_rss_hash_key {
2341 	cmdline_fixed_string_t port;
2342 	cmdline_fixed_string_t config;
2343 	portid_t port_id;
2344 	cmdline_fixed_string_t rss_hash_key;
2345 	cmdline_fixed_string_t rss_type;
2346 	cmdline_fixed_string_t key;
2347 };
2348 
2349 static uint8_t
2350 hexa_digit_to_value(char hexa_digit)
2351 {
2352 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2353 		return (uint8_t) (hexa_digit - '0');
2354 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2355 		return (uint8_t) ((hexa_digit - 'a') + 10);
2356 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2357 		return (uint8_t) ((hexa_digit - 'A') + 10);
2358 	/* Invalid hexa digit */
2359 	return 0xFF;
2360 }
2361 
2362 static uint8_t
2363 parse_and_check_key_hexa_digit(char *key, int idx)
2364 {
2365 	uint8_t hexa_v;
2366 
2367 	hexa_v = hexa_digit_to_value(key[idx]);
2368 	if (hexa_v == 0xFF)
2369 		fprintf(stderr,
2370 			"invalid key: character %c at position %d is not a valid hexa digit\n",
2371 			key[idx], idx);
2372 	return hexa_v;
2373 }
2374 
2375 static void
2376 cmd_config_rss_hash_key_parsed(void *parsed_result,
2377 			       __rte_unused struct cmdline *cl,
2378 			       __rte_unused void *data)
2379 {
2380 	struct cmd_config_rss_hash_key *res = parsed_result;
2381 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2382 	uint8_t xdgt0;
2383 	uint8_t xdgt1;
2384 	int i;
2385 	struct rte_eth_dev_info dev_info;
2386 	uint8_t hash_key_size;
2387 	uint32_t key_len;
2388 	int ret;
2389 
2390 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2391 	if (ret != 0)
2392 		return;
2393 
2394 	if (dev_info.hash_key_size > 0 &&
2395 			dev_info.hash_key_size <= sizeof(hash_key))
2396 		hash_key_size = dev_info.hash_key_size;
2397 	else {
2398 		fprintf(stderr,
2399 			"dev_info did not provide a valid hash key size\n");
2400 		return;
2401 	}
2402 	/* Check the length of the RSS hash key */
2403 	key_len = strlen(res->key);
2404 	if (key_len != (hash_key_size * 2)) {
2405 		fprintf(stderr,
2406 			"key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2407 			(int)key_len, hash_key_size * 2);
2408 		return;
2409 	}
2410 	/* Translate RSS hash key into binary representation */
2411 	for (i = 0; i < hash_key_size; i++) {
2412 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2413 		if (xdgt0 == 0xFF)
2414 			return;
2415 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2416 		if (xdgt1 == 0xFF)
2417 			return;
2418 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2419 	}
2420 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2421 			hash_key_size);
2422 }
2423 
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2425 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2426 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2427 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2428 				 "config");
2429 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2430 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2431 				 RTE_UINT16);
2432 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2433 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2434 				 rss_hash_key, "rss-hash-key");
2435 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2436 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2437 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2438 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2439 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2440 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2441 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2442 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2443 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2444 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2445 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2446 
2447 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2448 	.f = cmd_config_rss_hash_key_parsed,
2449 	.data = NULL,
2450 	.help_str = "port config <port_id> rss-hash-key "
2451 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2452 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2453 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2454 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2455 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2456 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2457 		"<string of hex digits (variable length, NIC dependent)>",
2458 	.tokens = {
2459 		(void *)&cmd_config_rss_hash_key_port,
2460 		(void *)&cmd_config_rss_hash_key_config,
2461 		(void *)&cmd_config_rss_hash_key_port_id,
2462 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2463 		(void *)&cmd_config_rss_hash_key_rss_type,
2464 		(void *)&cmd_config_rss_hash_key_value,
2465 		NULL,
2466 	},
2467 };
2468 
2469 /* *** cleanup txq mbufs *** */
2470 struct cmd_cleanup_txq_mbufs_result {
2471 	cmdline_fixed_string_t port;
2472 	cmdline_fixed_string_t keyword;
2473 	cmdline_fixed_string_t name;
2474 	uint16_t port_id;
2475 	uint16_t queue_id;
2476 	uint32_t free_cnt;
2477 };
2478 
2479 static void
2480 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2481 			     __rte_unused struct cmdline *cl,
2482 			     __rte_unused void *data)
2483 {
2484 	struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2485 	uint16_t port_id = res->port_id;
2486 	uint16_t queue_id = res->queue_id;
2487 	uint32_t free_cnt = res->free_cnt;
2488 	struct rte_eth_txq_info qinfo;
2489 	int ret;
2490 
2491 	if (test_done == 0) {
2492 		fprintf(stderr, "Please stop forwarding first\n");
2493 		return;
2494 	}
2495 
2496 	if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2497 		fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2498 			port_id, queue_id);
2499 		return;
2500 	}
2501 
2502 	if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2503 		fprintf(stderr, "Tx queue %u not started\n", queue_id);
2504 		return;
2505 	}
2506 
2507 	ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2508 	if (ret < 0) {
2509 		fprintf(stderr,
2510 			"Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2511 			port_id, queue_id, strerror(-ret), ret);
2512 		return;
2513 	}
2514 
2515 	printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2516 	       port_id, queue_id, ret);
2517 }
2518 
2519 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2520 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2521 				 "port");
2522 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2523 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2524 				 "cleanup");
2525 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2526 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2527 			      RTE_UINT16);
2528 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2529 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2530 				 "txq");
2531 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2532 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2533 			      RTE_UINT16);
2534 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2535 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2536 			      RTE_UINT32);
2537 
2538 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2539 	.f = cmd_cleanup_txq_mbufs_parsed,
2540 	.data = NULL,
2541 	.help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2542 	.tokens = {
2543 		(void *)&cmd_cleanup_txq_mbufs_port,
2544 		(void *)&cmd_cleanup_txq_mbufs_cleanup,
2545 		(void *)&cmd_cleanup_txq_mbufs_port_id,
2546 		(void *)&cmd_cleanup_txq_mbufs_txq,
2547 		(void *)&cmd_cleanup_txq_mbufs_queue_id,
2548 		(void *)&cmd_cleanup_txq_mbufs_free_cnt,
2549 		NULL,
2550 	},
2551 };
2552 
2553 /* *** configure port rxq/txq ring size *** */
2554 struct cmd_config_rxtx_ring_size {
2555 	cmdline_fixed_string_t port;
2556 	cmdline_fixed_string_t config;
2557 	portid_t portid;
2558 	cmdline_fixed_string_t rxtxq;
2559 	uint16_t qid;
2560 	cmdline_fixed_string_t rsize;
2561 	uint16_t size;
2562 };
2563 
2564 static void
2565 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2566 				 __rte_unused struct cmdline *cl,
2567 				 __rte_unused void *data)
2568 {
2569 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2570 	struct rte_port *port;
2571 	uint8_t isrx;
2572 
2573 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2574 		return;
2575 
2576 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2577 		fprintf(stderr, "Invalid port id\n");
2578 		return;
2579 	}
2580 
2581 	port = &ports[res->portid];
2582 
2583 	if (!strcmp(res->rxtxq, "rxq"))
2584 		isrx = 1;
2585 	else if (!strcmp(res->rxtxq, "txq"))
2586 		isrx = 0;
2587 	else {
2588 		fprintf(stderr, "Unknown parameter\n");
2589 		return;
2590 	}
2591 
2592 	if (isrx && rx_queue_id_is_invalid(res->qid))
2593 		return;
2594 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2595 		return;
2596 
2597 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2598 		fprintf(stderr,
2599 			"Invalid rx ring_size, must > rx_free_thresh: %d\n",
2600 			rx_free_thresh);
2601 		return;
2602 	}
2603 
2604 	if (isrx)
2605 		port->nb_rx_desc[res->qid] = res->size;
2606 	else
2607 		port->nb_tx_desc[res->qid] = res->size;
2608 
2609 	cmd_reconfig_device_queue(res->portid, 0, 1);
2610 }
2611 
2612 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2613 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 				 port, "port");
2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2616 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2617 				 config, "config");
2618 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2619 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 				 portid, RTE_UINT16);
2621 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2622 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2623 				 rxtxq, "rxq#txq");
2624 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2625 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 			      qid, RTE_UINT16);
2627 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2628 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2629 				 rsize, "ring_size");
2630 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2631 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2632 			      size, RTE_UINT16);
2633 
2634 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2635 	.f = cmd_config_rxtx_ring_size_parsed,
2636 	.data = NULL,
2637 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2638 	.tokens = {
2639 		(void *)&cmd_config_rxtx_ring_size_port,
2640 		(void *)&cmd_config_rxtx_ring_size_config,
2641 		(void *)&cmd_config_rxtx_ring_size_portid,
2642 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2643 		(void *)&cmd_config_rxtx_ring_size_qid,
2644 		(void *)&cmd_config_rxtx_ring_size_rsize,
2645 		(void *)&cmd_config_rxtx_ring_size_size,
2646 		NULL,
2647 	},
2648 };
2649 
2650 /* *** configure port rxq/txq start/stop *** */
2651 struct cmd_config_rxtx_queue {
2652 	cmdline_fixed_string_t port;
2653 	portid_t portid;
2654 	cmdline_fixed_string_t rxtxq;
2655 	uint16_t qid;
2656 	cmdline_fixed_string_t opname;
2657 };
2658 
2659 static void
2660 cmd_config_rxtx_queue_parsed(void *parsed_result,
2661 			__rte_unused struct cmdline *cl,
2662 			__rte_unused void *data)
2663 {
2664 	struct cmd_config_rxtx_queue *res = parsed_result;
2665 	uint8_t isrx;
2666 	uint8_t isstart;
2667 	int ret = 0;
2668 
2669 	if (test_done == 0) {
2670 		fprintf(stderr, "Please stop forwarding first\n");
2671 		return;
2672 	}
2673 
2674 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2675 		return;
2676 
2677 	if (port_is_started(res->portid) != 1) {
2678 		fprintf(stderr, "Please start port %u first\n", res->portid);
2679 		return;
2680 	}
2681 
2682 	if (!strcmp(res->rxtxq, "rxq"))
2683 		isrx = 1;
2684 	else if (!strcmp(res->rxtxq, "txq"))
2685 		isrx = 0;
2686 	else {
2687 		fprintf(stderr, "Unknown parameter\n");
2688 		return;
2689 	}
2690 
2691 	if (isrx && rx_queue_id_is_invalid(res->qid))
2692 		return;
2693 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2694 		return;
2695 
2696 	if (!strcmp(res->opname, "start"))
2697 		isstart = 1;
2698 	else if (!strcmp(res->opname, "stop"))
2699 		isstart = 0;
2700 	else {
2701 		fprintf(stderr, "Unknown parameter\n");
2702 		return;
2703 	}
2704 
2705 	if (isstart && isrx)
2706 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2707 	else if (!isstart && isrx)
2708 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2709 	else if (isstart && !isrx)
2710 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2711 	else
2712 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2713 
2714 	if (ret == -ENOTSUP)
2715 		fprintf(stderr, "Function not supported in PMD driver\n");
2716 }
2717 
2718 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2719 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2720 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2721 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2722 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2723 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2724 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2725 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2726 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2727 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2728 						"start#stop");
2729 
2730 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2731 	.f = cmd_config_rxtx_queue_parsed,
2732 	.data = NULL,
2733 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2734 	.tokens = {
2735 		(void *)&cmd_config_rxtx_queue_port,
2736 		(void *)&cmd_config_rxtx_queue_portid,
2737 		(void *)&cmd_config_rxtx_queue_rxtxq,
2738 		(void *)&cmd_config_rxtx_queue_qid,
2739 		(void *)&cmd_config_rxtx_queue_opname,
2740 		NULL,
2741 	},
2742 };
2743 
2744 /* *** configure port rxq/txq deferred start on/off *** */
2745 struct cmd_config_deferred_start_rxtx_queue {
2746 	cmdline_fixed_string_t port;
2747 	portid_t port_id;
2748 	cmdline_fixed_string_t rxtxq;
2749 	uint16_t qid;
2750 	cmdline_fixed_string_t opname;
2751 	cmdline_fixed_string_t state;
2752 };
2753 
2754 static void
2755 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2756 			__rte_unused struct cmdline *cl,
2757 			__rte_unused void *data)
2758 {
2759 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2760 	struct rte_port *port;
2761 	uint8_t isrx;
2762 	uint8_t ison;
2763 	uint8_t needreconfig = 0;
2764 
2765 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2766 		return;
2767 
2768 	if (port_is_started(res->port_id) != 0) {
2769 		fprintf(stderr, "Please stop port %u first\n", res->port_id);
2770 		return;
2771 	}
2772 
2773 	port = &ports[res->port_id];
2774 
2775 	isrx = !strcmp(res->rxtxq, "rxq");
2776 
2777 	if (isrx && rx_queue_id_is_invalid(res->qid))
2778 		return;
2779 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2780 		return;
2781 
2782 	ison = !strcmp(res->state, "on");
2783 
2784 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2785 		port->rx_conf[res->qid].rx_deferred_start = ison;
2786 		needreconfig = 1;
2787 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2788 		port->tx_conf[res->qid].tx_deferred_start = ison;
2789 		needreconfig = 1;
2790 	}
2791 
2792 	if (needreconfig)
2793 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2794 }
2795 
2796 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2797 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2798 						port, "port");
2799 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2800 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 						port_id, RTE_UINT16);
2802 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2803 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2804 						rxtxq, "rxq#txq");
2805 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2806 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2807 						qid, RTE_UINT16);
2808 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2809 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2810 						opname, "deferred_start");
2811 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2812 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2813 						state, "on#off");
2814 
2815 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2816 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2817 	.data = NULL,
2818 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2819 	.tokens = {
2820 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2821 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2822 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2823 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2824 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2825 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2826 		NULL,
2827 	},
2828 };
2829 
2830 /* *** configure port rxq/txq setup *** */
2831 struct cmd_setup_rxtx_queue {
2832 	cmdline_fixed_string_t port;
2833 	portid_t portid;
2834 	cmdline_fixed_string_t rxtxq;
2835 	uint16_t qid;
2836 	cmdline_fixed_string_t setup;
2837 };
2838 
2839 /* Common CLI fields for queue setup */
2840 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2841 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2842 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2843 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2844 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2845 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2846 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2847 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2848 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2849 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2850 
2851 static void
2852 cmd_setup_rxtx_queue_parsed(
2853 	void *parsed_result,
2854 	__rte_unused struct cmdline *cl,
2855 	__rte_unused void *data)
2856 {
2857 	struct cmd_setup_rxtx_queue *res = parsed_result;
2858 	struct rte_port *port;
2859 	struct rte_mempool *mp;
2860 	unsigned int socket_id;
2861 	uint8_t isrx = 0;
2862 	int ret;
2863 
2864 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2865 		return;
2866 
2867 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2868 		fprintf(stderr, "Invalid port id\n");
2869 		return;
2870 	}
2871 
2872 	if (!strcmp(res->rxtxq, "rxq"))
2873 		isrx = 1;
2874 	else if (!strcmp(res->rxtxq, "txq"))
2875 		isrx = 0;
2876 	else {
2877 		fprintf(stderr, "Unknown parameter\n");
2878 		return;
2879 	}
2880 
2881 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2882 		fprintf(stderr, "Invalid rx queue\n");
2883 		return;
2884 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2885 		fprintf(stderr, "Invalid tx queue\n");
2886 		return;
2887 	}
2888 
2889 	port = &ports[res->portid];
2890 	if (isrx) {
2891 		socket_id = rxring_numa[res->portid];
2892 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2893 			socket_id = port->socket_id;
2894 
2895 		mp = mbuf_pool_find(socket_id, 0);
2896 		if (mp == NULL) {
2897 			fprintf(stderr,
2898 				"Failed to setup RX queue: No mempool allocation on the socket %d\n",
2899 				rxring_numa[res->portid]);
2900 			return;
2901 		}
2902 		ret = rx_queue_setup(res->portid,
2903 				     res->qid,
2904 				     port->nb_rx_desc[res->qid],
2905 				     socket_id,
2906 				     &port->rx_conf[res->qid],
2907 				     mp);
2908 		if (ret)
2909 			fprintf(stderr, "Failed to setup RX queue\n");
2910 	} else {
2911 		socket_id = txring_numa[res->portid];
2912 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2913 			socket_id = port->socket_id;
2914 
2915 		if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2916 			fprintf(stderr,
2917 				"Failed to setup TX queue: not enough descriptors\n");
2918 			return;
2919 		}
2920 		ret = rte_eth_tx_queue_setup(res->portid,
2921 					     res->qid,
2922 					     port->nb_tx_desc[res->qid],
2923 					     socket_id,
2924 					     &port->tx_conf[res->qid]);
2925 		if (ret)
2926 			fprintf(stderr, "Failed to setup TX queue\n");
2927 	}
2928 }
2929 
2930 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2931 	.f = cmd_setup_rxtx_queue_parsed,
2932 	.data = NULL,
2933 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2934 	.tokens = {
2935 		(void *)&cmd_setup_rxtx_queue_port,
2936 		(void *)&cmd_setup_rxtx_queue_portid,
2937 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2938 		(void *)&cmd_setup_rxtx_queue_qid,
2939 		(void *)&cmd_setup_rxtx_queue_setup,
2940 		NULL,
2941 	},
2942 };
2943 
2944 
2945 /* *** Configure RSS RETA *** */
2946 struct cmd_config_rss_reta {
2947 	cmdline_fixed_string_t port;
2948 	cmdline_fixed_string_t keyword;
2949 	portid_t port_id;
2950 	cmdline_fixed_string_t name;
2951 	cmdline_fixed_string_t list_name;
2952 	cmdline_fixed_string_t list_of_items;
2953 };
2954 
2955 static int
2956 parse_reta_config(const char *str,
2957 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2958 		  uint16_t nb_entries)
2959 {
2960 	int i;
2961 	unsigned size;
2962 	uint16_t hash_index, idx, shift;
2963 	uint16_t nb_queue;
2964 	char s[256];
2965 	const char *p, *p0 = str;
2966 	char *end;
2967 	enum fieldnames {
2968 		FLD_HASH_INDEX = 0,
2969 		FLD_QUEUE,
2970 		_NUM_FLD
2971 	};
2972 	unsigned long int_fld[_NUM_FLD];
2973 	char *str_fld[_NUM_FLD];
2974 
2975 	while ((p = strchr(p0,'(')) != NULL) {
2976 		++p;
2977 		if((p0 = strchr(p,')')) == NULL)
2978 			return -1;
2979 
2980 		size = p0 - p;
2981 		if(size >= sizeof(s))
2982 			return -1;
2983 
2984 		snprintf(s, sizeof(s), "%.*s", size, p);
2985 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2986 			return -1;
2987 		for (i = 0; i < _NUM_FLD; i++) {
2988 			errno = 0;
2989 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2990 			if (errno != 0 || end == str_fld[i] ||
2991 					int_fld[i] > 65535)
2992 				return -1;
2993 		}
2994 
2995 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2996 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2997 
2998 		if (hash_index >= nb_entries) {
2999 			fprintf(stderr, "Invalid RETA hash index=%d\n",
3000 				hash_index);
3001 			return -1;
3002 		}
3003 
3004 		idx = hash_index / RTE_RETA_GROUP_SIZE;
3005 		shift = hash_index % RTE_RETA_GROUP_SIZE;
3006 		reta_conf[idx].mask |= (1ULL << shift);
3007 		reta_conf[idx].reta[shift] = nb_queue;
3008 	}
3009 
3010 	return 0;
3011 }
3012 
3013 static void
3014 cmd_set_rss_reta_parsed(void *parsed_result,
3015 			__rte_unused struct cmdline *cl,
3016 			__rte_unused void *data)
3017 {
3018 	int ret;
3019 	struct rte_eth_dev_info dev_info;
3020 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3021 	struct cmd_config_rss_reta *res = parsed_result;
3022 
3023 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3024 	if (ret != 0)
3025 		return;
3026 
3027 	if (dev_info.reta_size == 0) {
3028 		fprintf(stderr,
3029 			"Redirection table size is 0 which is invalid for RSS\n");
3030 		return;
3031 	} else
3032 		printf("The reta size of port %d is %u\n",
3033 			res->port_id, dev_info.reta_size);
3034 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3035 		fprintf(stderr,
3036 			"Currently do not support more than %u entries of redirection table\n",
3037 			ETH_RSS_RETA_SIZE_512);
3038 		return;
3039 	}
3040 
3041 	memset(reta_conf, 0, sizeof(reta_conf));
3042 	if (!strcmp(res->list_name, "reta")) {
3043 		if (parse_reta_config(res->list_of_items, reta_conf,
3044 						dev_info.reta_size)) {
3045 			fprintf(stderr,
3046 				"Invalid RSS Redirection Table config entered\n");
3047 			return;
3048 		}
3049 		ret = rte_eth_dev_rss_reta_update(res->port_id,
3050 				reta_conf, dev_info.reta_size);
3051 		if (ret != 0)
3052 			fprintf(stderr,
3053 				"Bad redirection table parameter, return code = %d\n",
3054 				ret);
3055 	}
3056 }
3057 
3058 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3059 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3060 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3061 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3062 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3063 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3064 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3065 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3066 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3067 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3068 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3069         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3070                                  NULL);
3071 cmdline_parse_inst_t cmd_config_rss_reta = {
3072 	.f = cmd_set_rss_reta_parsed,
3073 	.data = NULL,
3074 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3075 	.tokens = {
3076 		(void *)&cmd_config_rss_reta_port,
3077 		(void *)&cmd_config_rss_reta_keyword,
3078 		(void *)&cmd_config_rss_reta_port_id,
3079 		(void *)&cmd_config_rss_reta_name,
3080 		(void *)&cmd_config_rss_reta_list_name,
3081 		(void *)&cmd_config_rss_reta_list_of_items,
3082 		NULL,
3083 	},
3084 };
3085 
3086 /* *** SHOW PORT RETA INFO *** */
3087 struct cmd_showport_reta {
3088 	cmdline_fixed_string_t show;
3089 	cmdline_fixed_string_t port;
3090 	portid_t port_id;
3091 	cmdline_fixed_string_t rss;
3092 	cmdline_fixed_string_t reta;
3093 	uint16_t size;
3094 	cmdline_fixed_string_t list_of_items;
3095 };
3096 
3097 static int
3098 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3099 			   uint16_t nb_entries,
3100 			   char *str)
3101 {
3102 	uint32_t size;
3103 	const char *p, *p0 = str;
3104 	char s[256];
3105 	char *end;
3106 	char *str_fld[8];
3107 	uint16_t i;
3108 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3109 			RTE_RETA_GROUP_SIZE;
3110 	int ret;
3111 
3112 	p = strchr(p0, '(');
3113 	if (p == NULL)
3114 		return -1;
3115 	p++;
3116 	p0 = strchr(p, ')');
3117 	if (p0 == NULL)
3118 		return -1;
3119 	size = p0 - p;
3120 	if (size >= sizeof(s)) {
3121 		fprintf(stderr,
3122 			"The string size exceeds the internal buffer size\n");
3123 		return -1;
3124 	}
3125 	snprintf(s, sizeof(s), "%.*s", size, p);
3126 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3127 	if (ret <= 0 || ret != num) {
3128 		fprintf(stderr,
3129 			"The bits of masks do not match the number of reta entries: %u\n",
3130 			num);
3131 		return -1;
3132 	}
3133 	for (i = 0; i < ret; i++)
3134 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3135 
3136 	return 0;
3137 }
3138 
3139 static void
3140 cmd_showport_reta_parsed(void *parsed_result,
3141 			 __rte_unused struct cmdline *cl,
3142 			 __rte_unused void *data)
3143 {
3144 	struct cmd_showport_reta *res = parsed_result;
3145 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3146 	struct rte_eth_dev_info dev_info;
3147 	uint16_t max_reta_size;
3148 	int ret;
3149 
3150 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3151 	if (ret != 0)
3152 		return;
3153 
3154 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3155 	if (res->size == 0 || res->size > max_reta_size) {
3156 		fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3157 			res->size, max_reta_size);
3158 		return;
3159 	}
3160 
3161 	memset(reta_conf, 0, sizeof(reta_conf));
3162 	if (showport_parse_reta_config(reta_conf, res->size,
3163 				res->list_of_items) < 0) {
3164 		fprintf(stderr, "Invalid string: %s for reta masks\n",
3165 			res->list_of_items);
3166 		return;
3167 	}
3168 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3169 }
3170 
3171 cmdline_parse_token_string_t cmd_showport_reta_show =
3172 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3173 cmdline_parse_token_string_t cmd_showport_reta_port =
3174 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3175 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3176 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3177 cmdline_parse_token_string_t cmd_showport_reta_rss =
3178 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3179 cmdline_parse_token_string_t cmd_showport_reta_reta =
3180 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3181 cmdline_parse_token_num_t cmd_showport_reta_size =
3182 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3183 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3184 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3185 					list_of_items, NULL);
3186 
3187 cmdline_parse_inst_t cmd_showport_reta = {
3188 	.f = cmd_showport_reta_parsed,
3189 	.data = NULL,
3190 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3191 	.tokens = {
3192 		(void *)&cmd_showport_reta_show,
3193 		(void *)&cmd_showport_reta_port,
3194 		(void *)&cmd_showport_reta_port_id,
3195 		(void *)&cmd_showport_reta_rss,
3196 		(void *)&cmd_showport_reta_reta,
3197 		(void *)&cmd_showport_reta_size,
3198 		(void *)&cmd_showport_reta_list_of_items,
3199 		NULL,
3200 	},
3201 };
3202 
3203 /* *** Show RSS hash configuration *** */
3204 struct cmd_showport_rss_hash {
3205 	cmdline_fixed_string_t show;
3206 	cmdline_fixed_string_t port;
3207 	portid_t port_id;
3208 	cmdline_fixed_string_t rss_hash;
3209 	cmdline_fixed_string_t rss_type;
3210 	cmdline_fixed_string_t key; /* optional argument */
3211 };
3212 
3213 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3214 				__rte_unused struct cmdline *cl,
3215 				void *show_rss_key)
3216 {
3217 	struct cmd_showport_rss_hash *res = parsed_result;
3218 
3219 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3220 }
3221 
3222 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3223 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3224 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3225 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3226 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3227 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3228 				 RTE_UINT16);
3229 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3230 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3231 				 "rss-hash");
3232 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3233 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3234 
3235 cmdline_parse_inst_t cmd_showport_rss_hash = {
3236 	.f = cmd_showport_rss_hash_parsed,
3237 	.data = NULL,
3238 	.help_str = "show port <port_id> rss-hash",
3239 	.tokens = {
3240 		(void *)&cmd_showport_rss_hash_show,
3241 		(void *)&cmd_showport_rss_hash_port,
3242 		(void *)&cmd_showport_rss_hash_port_id,
3243 		(void *)&cmd_showport_rss_hash_rss_hash,
3244 		NULL,
3245 	},
3246 };
3247 
3248 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3249 	.f = cmd_showport_rss_hash_parsed,
3250 	.data = (void *)1,
3251 	.help_str = "show port <port_id> rss-hash key",
3252 	.tokens = {
3253 		(void *)&cmd_showport_rss_hash_show,
3254 		(void *)&cmd_showport_rss_hash_port,
3255 		(void *)&cmd_showport_rss_hash_port_id,
3256 		(void *)&cmd_showport_rss_hash_rss_hash,
3257 		(void *)&cmd_showport_rss_hash_rss_key,
3258 		NULL,
3259 	},
3260 };
3261 
3262 /* *** Configure DCB *** */
3263 struct cmd_config_dcb {
3264 	cmdline_fixed_string_t port;
3265 	cmdline_fixed_string_t config;
3266 	portid_t port_id;
3267 	cmdline_fixed_string_t dcb;
3268 	cmdline_fixed_string_t vt;
3269 	cmdline_fixed_string_t vt_en;
3270 	uint8_t num_tcs;
3271 	cmdline_fixed_string_t pfc;
3272 	cmdline_fixed_string_t pfc_en;
3273 };
3274 
3275 static void
3276 cmd_config_dcb_parsed(void *parsed_result,
3277                         __rte_unused struct cmdline *cl,
3278                         __rte_unused void *data)
3279 {
3280 	struct cmd_config_dcb *res = parsed_result;
3281 	struct rte_eth_dcb_info dcb_info;
3282 	portid_t port_id = res->port_id;
3283 	struct rte_port *port;
3284 	uint8_t pfc_en;
3285 	int ret;
3286 
3287 	port = &ports[port_id];
3288 	/** Check if the port is not started **/
3289 	if (port->port_status != RTE_PORT_STOPPED) {
3290 		fprintf(stderr, "Please stop port %d first\n", port_id);
3291 		return;
3292 	}
3293 
3294 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3295 		fprintf(stderr,
3296 			"The invalid number of traffic class, only 4 or 8 allowed.\n");
3297 		return;
3298 	}
3299 
3300 	if (nb_fwd_lcores < res->num_tcs) {
3301 		fprintf(stderr,
3302 			"nb_cores shouldn't be less than number of TCs.\n");
3303 		return;
3304 	}
3305 
3306 	/* Check whether the port supports the report of DCB info. */
3307 	ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3308 	if (ret == -ENOTSUP) {
3309 		fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3310 		return;
3311 	}
3312 
3313 	if (!strncmp(res->pfc_en, "on", 2))
3314 		pfc_en = 1;
3315 	else
3316 		pfc_en = 0;
3317 
3318 	/* DCB in VT mode */
3319 	if (!strncmp(res->vt_en, "on", 2))
3320 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3321 				(enum rte_eth_nb_tcs)res->num_tcs,
3322 				pfc_en);
3323 	else
3324 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3325 				(enum rte_eth_nb_tcs)res->num_tcs,
3326 				pfc_en);
3327 	if (ret != 0) {
3328 		fprintf(stderr, "Cannot initialize network ports.\n");
3329 		return;
3330 	}
3331 
3332 	fwd_config_setup();
3333 
3334 	cmd_reconfig_device_queue(port_id, 1, 1);
3335 }
3336 
3337 cmdline_parse_token_string_t cmd_config_dcb_port =
3338         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3339 cmdline_parse_token_string_t cmd_config_dcb_config =
3340         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3341 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3342 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3343 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3344         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3345 cmdline_parse_token_string_t cmd_config_dcb_vt =
3346         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3347 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3348         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3349 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3350 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3351 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3352         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3353 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3354         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3355 
3356 cmdline_parse_inst_t cmd_config_dcb = {
3357 	.f = cmd_config_dcb_parsed,
3358 	.data = NULL,
3359 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3360 	.tokens = {
3361 		(void *)&cmd_config_dcb_port,
3362 		(void *)&cmd_config_dcb_config,
3363 		(void *)&cmd_config_dcb_port_id,
3364 		(void *)&cmd_config_dcb_dcb,
3365 		(void *)&cmd_config_dcb_vt,
3366 		(void *)&cmd_config_dcb_vt_en,
3367 		(void *)&cmd_config_dcb_num_tcs,
3368 		(void *)&cmd_config_dcb_pfc,
3369 		(void *)&cmd_config_dcb_pfc_en,
3370                 NULL,
3371         },
3372 };
3373 
3374 /* *** configure number of packets per burst *** */
3375 struct cmd_config_burst {
3376 	cmdline_fixed_string_t port;
3377 	cmdline_fixed_string_t keyword;
3378 	cmdline_fixed_string_t all;
3379 	cmdline_fixed_string_t name;
3380 	uint16_t value;
3381 };
3382 
3383 static void
3384 cmd_config_burst_parsed(void *parsed_result,
3385 			__rte_unused struct cmdline *cl,
3386 			__rte_unused void *data)
3387 {
3388 	struct cmd_config_burst *res = parsed_result;
3389 	struct rte_eth_dev_info dev_info;
3390 	uint16_t rec_nb_pkts;
3391 	int ret;
3392 
3393 	if (!all_ports_stopped()) {
3394 		fprintf(stderr, "Please stop all ports first\n");
3395 		return;
3396 	}
3397 
3398 	if (!strcmp(res->name, "burst")) {
3399 		if (res->value == 0) {
3400 			/* If user gives a value of zero, query the PMD for
3401 			 * its recommended Rx burst size. Testpmd uses a single
3402 			 * size for all ports, so assume all ports are the same
3403 			 * NIC model and use the values from Port 0.
3404 			 */
3405 			ret = eth_dev_info_get_print_err(0, &dev_info);
3406 			if (ret != 0)
3407 				return;
3408 
3409 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3410 
3411 			if (rec_nb_pkts == 0) {
3412 				printf("PMD does not recommend a burst size.\n"
3413 					"User provided value must be between"
3414 					" 1 and %d\n", MAX_PKT_BURST);
3415 				return;
3416 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3417 				printf("PMD recommended burst size of %d"
3418 					" exceeds maximum value of %d\n",
3419 					rec_nb_pkts, MAX_PKT_BURST);
3420 				return;
3421 			}
3422 			printf("Using PMD-provided burst value of %d\n",
3423 				rec_nb_pkts);
3424 			nb_pkt_per_burst = rec_nb_pkts;
3425 		} else if (res->value > MAX_PKT_BURST) {
3426 			fprintf(stderr, "burst must be >= 1 && <= %d\n",
3427 				MAX_PKT_BURST);
3428 			return;
3429 		} else
3430 			nb_pkt_per_burst = res->value;
3431 	} else {
3432 		fprintf(stderr, "Unknown parameter\n");
3433 		return;
3434 	}
3435 
3436 	init_port_config();
3437 
3438 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3439 }
3440 
3441 cmdline_parse_token_string_t cmd_config_burst_port =
3442 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3443 cmdline_parse_token_string_t cmd_config_burst_keyword =
3444 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3445 cmdline_parse_token_string_t cmd_config_burst_all =
3446 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3447 cmdline_parse_token_string_t cmd_config_burst_name =
3448 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3449 cmdline_parse_token_num_t cmd_config_burst_value =
3450 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3451 
3452 cmdline_parse_inst_t cmd_config_burst = {
3453 	.f = cmd_config_burst_parsed,
3454 	.data = NULL,
3455 	.help_str = "port config all burst <value>",
3456 	.tokens = {
3457 		(void *)&cmd_config_burst_port,
3458 		(void *)&cmd_config_burst_keyword,
3459 		(void *)&cmd_config_burst_all,
3460 		(void *)&cmd_config_burst_name,
3461 		(void *)&cmd_config_burst_value,
3462 		NULL,
3463 	},
3464 };
3465 
3466 /* *** configure rx/tx queues *** */
3467 struct cmd_config_thresh {
3468 	cmdline_fixed_string_t port;
3469 	cmdline_fixed_string_t keyword;
3470 	cmdline_fixed_string_t all;
3471 	cmdline_fixed_string_t name;
3472 	uint8_t value;
3473 };
3474 
3475 static void
3476 cmd_config_thresh_parsed(void *parsed_result,
3477 			__rte_unused struct cmdline *cl,
3478 			__rte_unused void *data)
3479 {
3480 	struct cmd_config_thresh *res = parsed_result;
3481 
3482 	if (!all_ports_stopped()) {
3483 		fprintf(stderr, "Please stop all ports first\n");
3484 		return;
3485 	}
3486 
3487 	if (!strcmp(res->name, "txpt"))
3488 		tx_pthresh = res->value;
3489 	else if(!strcmp(res->name, "txht"))
3490 		tx_hthresh = res->value;
3491 	else if(!strcmp(res->name, "txwt"))
3492 		tx_wthresh = res->value;
3493 	else if(!strcmp(res->name, "rxpt"))
3494 		rx_pthresh = res->value;
3495 	else if(!strcmp(res->name, "rxht"))
3496 		rx_hthresh = res->value;
3497 	else if(!strcmp(res->name, "rxwt"))
3498 		rx_wthresh = res->value;
3499 	else {
3500 		fprintf(stderr, "Unknown parameter\n");
3501 		return;
3502 	}
3503 
3504 	init_port_config();
3505 
3506 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3507 }
3508 
3509 cmdline_parse_token_string_t cmd_config_thresh_port =
3510 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3511 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3512 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3513 cmdline_parse_token_string_t cmd_config_thresh_all =
3514 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3515 cmdline_parse_token_string_t cmd_config_thresh_name =
3516 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3517 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3518 cmdline_parse_token_num_t cmd_config_thresh_value =
3519 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3520 
3521 cmdline_parse_inst_t cmd_config_thresh = {
3522 	.f = cmd_config_thresh_parsed,
3523 	.data = NULL,
3524 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3525 	.tokens = {
3526 		(void *)&cmd_config_thresh_port,
3527 		(void *)&cmd_config_thresh_keyword,
3528 		(void *)&cmd_config_thresh_all,
3529 		(void *)&cmd_config_thresh_name,
3530 		(void *)&cmd_config_thresh_value,
3531 		NULL,
3532 	},
3533 };
3534 
3535 /* *** configure free/rs threshold *** */
3536 struct cmd_config_threshold {
3537 	cmdline_fixed_string_t port;
3538 	cmdline_fixed_string_t keyword;
3539 	cmdline_fixed_string_t all;
3540 	cmdline_fixed_string_t name;
3541 	uint16_t value;
3542 };
3543 
3544 static void
3545 cmd_config_threshold_parsed(void *parsed_result,
3546 			__rte_unused struct cmdline *cl,
3547 			__rte_unused void *data)
3548 {
3549 	struct cmd_config_threshold *res = parsed_result;
3550 
3551 	if (!all_ports_stopped()) {
3552 		fprintf(stderr, "Please stop all ports first\n");
3553 		return;
3554 	}
3555 
3556 	if (!strcmp(res->name, "txfreet"))
3557 		tx_free_thresh = res->value;
3558 	else if (!strcmp(res->name, "txrst"))
3559 		tx_rs_thresh = res->value;
3560 	else if (!strcmp(res->name, "rxfreet"))
3561 		rx_free_thresh = res->value;
3562 	else {
3563 		fprintf(stderr, "Unknown parameter\n");
3564 		return;
3565 	}
3566 
3567 	init_port_config();
3568 
3569 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3570 }
3571 
3572 cmdline_parse_token_string_t cmd_config_threshold_port =
3573 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3574 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3575 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3576 								"config");
3577 cmdline_parse_token_string_t cmd_config_threshold_all =
3578 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3579 cmdline_parse_token_string_t cmd_config_threshold_name =
3580 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3581 						"txfreet#txrst#rxfreet");
3582 cmdline_parse_token_num_t cmd_config_threshold_value =
3583 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3584 
3585 cmdline_parse_inst_t cmd_config_threshold = {
3586 	.f = cmd_config_threshold_parsed,
3587 	.data = NULL,
3588 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3589 	.tokens = {
3590 		(void *)&cmd_config_threshold_port,
3591 		(void *)&cmd_config_threshold_keyword,
3592 		(void *)&cmd_config_threshold_all,
3593 		(void *)&cmd_config_threshold_name,
3594 		(void *)&cmd_config_threshold_value,
3595 		NULL,
3596 	},
3597 };
3598 
3599 /* *** stop *** */
3600 struct cmd_stop_result {
3601 	cmdline_fixed_string_t stop;
3602 };
3603 
3604 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3605 			    __rte_unused struct cmdline *cl,
3606 			    __rte_unused void *data)
3607 {
3608 	stop_packet_forwarding();
3609 }
3610 
3611 cmdline_parse_token_string_t cmd_stop_stop =
3612 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3613 
3614 cmdline_parse_inst_t cmd_stop = {
3615 	.f = cmd_stop_parsed,
3616 	.data = NULL,
3617 	.help_str = "stop: Stop packet forwarding",
3618 	.tokens = {
3619 		(void *)&cmd_stop_stop,
3620 		NULL,
3621 	},
3622 };
3623 
3624 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3625 
3626 unsigned int
3627 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3628 		unsigned int *parsed_items, int check_unique_values)
3629 {
3630 	unsigned int nb_item;
3631 	unsigned int value;
3632 	unsigned int i;
3633 	unsigned int j;
3634 	int value_ok;
3635 	char c;
3636 
3637 	/*
3638 	 * First parse all items in the list and store their value.
3639 	 */
3640 	value = 0;
3641 	nb_item = 0;
3642 	value_ok = 0;
3643 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3644 		c = str[i];
3645 		if ((c >= '0') && (c <= '9')) {
3646 			value = (unsigned int) (value * 10 + (c - '0'));
3647 			value_ok = 1;
3648 			continue;
3649 		}
3650 		if (c != ',') {
3651 			fprintf(stderr, "character %c is not a decimal digit\n", c);
3652 			return 0;
3653 		}
3654 		if (! value_ok) {
3655 			fprintf(stderr, "No valid value before comma\n");
3656 			return 0;
3657 		}
3658 		if (nb_item < max_items) {
3659 			parsed_items[nb_item] = value;
3660 			value_ok = 0;
3661 			value = 0;
3662 		}
3663 		nb_item++;
3664 	}
3665 	if (nb_item >= max_items) {
3666 		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3667 			item_name, nb_item + 1, max_items);
3668 		return 0;
3669 	}
3670 	parsed_items[nb_item++] = value;
3671 	if (! check_unique_values)
3672 		return nb_item;
3673 
3674 	/*
3675 	 * Then, check that all values in the list are differents.
3676 	 * No optimization here...
3677 	 */
3678 	for (i = 0; i < nb_item; i++) {
3679 		for (j = i + 1; j < nb_item; j++) {
3680 			if (parsed_items[j] == parsed_items[i]) {
3681 				fprintf(stderr,
3682 					"duplicated %s %u at index %u and %u\n",
3683 					item_name, parsed_items[i], i, j);
3684 				return 0;
3685 			}
3686 		}
3687 	}
3688 	return nb_item;
3689 }
3690 
3691 struct cmd_set_list_result {
3692 	cmdline_fixed_string_t cmd_keyword;
3693 	cmdline_fixed_string_t list_name;
3694 	cmdline_fixed_string_t list_of_items;
3695 };
3696 
3697 static void cmd_set_list_parsed(void *parsed_result,
3698 				__rte_unused struct cmdline *cl,
3699 				__rte_unused void *data)
3700 {
3701 	struct cmd_set_list_result *res;
3702 	union {
3703 		unsigned int lcorelist[RTE_MAX_LCORE];
3704 		unsigned int portlist[RTE_MAX_ETHPORTS];
3705 	} parsed_items;
3706 	unsigned int nb_item;
3707 
3708 	if (test_done == 0) {
3709 		fprintf(stderr, "Please stop forwarding first\n");
3710 		return;
3711 	}
3712 
3713 	res = parsed_result;
3714 	if (!strcmp(res->list_name, "corelist")) {
3715 		nb_item = parse_item_list(res->list_of_items, "core",
3716 					  RTE_MAX_LCORE,
3717 					  parsed_items.lcorelist, 1);
3718 		if (nb_item > 0) {
3719 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3720 			fwd_config_setup();
3721 		}
3722 		return;
3723 	}
3724 	if (!strcmp(res->list_name, "portlist")) {
3725 		nb_item = parse_item_list(res->list_of_items, "port",
3726 					  RTE_MAX_ETHPORTS,
3727 					  parsed_items.portlist, 1);
3728 		if (nb_item > 0) {
3729 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3730 			fwd_config_setup();
3731 		}
3732 	}
3733 }
3734 
3735 cmdline_parse_token_string_t cmd_set_list_keyword =
3736 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3737 				 "set");
3738 cmdline_parse_token_string_t cmd_set_list_name =
3739 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3740 				 "corelist#portlist");
3741 cmdline_parse_token_string_t cmd_set_list_of_items =
3742 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3743 				 NULL);
3744 
3745 cmdline_parse_inst_t cmd_set_fwd_list = {
3746 	.f = cmd_set_list_parsed,
3747 	.data = NULL,
3748 	.help_str = "set corelist|portlist <list0[,list1]*>",
3749 	.tokens = {
3750 		(void *)&cmd_set_list_keyword,
3751 		(void *)&cmd_set_list_name,
3752 		(void *)&cmd_set_list_of_items,
3753 		NULL,
3754 	},
3755 };
3756 
3757 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3758 
3759 struct cmd_setmask_result {
3760 	cmdline_fixed_string_t set;
3761 	cmdline_fixed_string_t mask;
3762 	uint64_t hexavalue;
3763 };
3764 
3765 static void cmd_set_mask_parsed(void *parsed_result,
3766 				__rte_unused struct cmdline *cl,
3767 				__rte_unused void *data)
3768 {
3769 	struct cmd_setmask_result *res = parsed_result;
3770 
3771 	if (test_done == 0) {
3772 		fprintf(stderr, "Please stop forwarding first\n");
3773 		return;
3774 	}
3775 	if (!strcmp(res->mask, "coremask")) {
3776 		set_fwd_lcores_mask(res->hexavalue);
3777 		fwd_config_setup();
3778 	} else if (!strcmp(res->mask, "portmask")) {
3779 		set_fwd_ports_mask(res->hexavalue);
3780 		fwd_config_setup();
3781 	}
3782 }
3783 
3784 cmdline_parse_token_string_t cmd_setmask_set =
3785 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3786 cmdline_parse_token_string_t cmd_setmask_mask =
3787 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3788 				 "coremask#portmask");
3789 cmdline_parse_token_num_t cmd_setmask_value =
3790 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3791 
3792 cmdline_parse_inst_t cmd_set_fwd_mask = {
3793 	.f = cmd_set_mask_parsed,
3794 	.data = NULL,
3795 	.help_str = "set coremask|portmask <hexadecimal value>",
3796 	.tokens = {
3797 		(void *)&cmd_setmask_set,
3798 		(void *)&cmd_setmask_mask,
3799 		(void *)&cmd_setmask_value,
3800 		NULL,
3801 	},
3802 };
3803 
3804 /*
3805  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3806  */
3807 struct cmd_set_result {
3808 	cmdline_fixed_string_t set;
3809 	cmdline_fixed_string_t what;
3810 	uint16_t value;
3811 };
3812 
3813 static void cmd_set_parsed(void *parsed_result,
3814 			   __rte_unused struct cmdline *cl,
3815 			   __rte_unused void *data)
3816 {
3817 	struct cmd_set_result *res = parsed_result;
3818 	if (!strcmp(res->what, "nbport")) {
3819 		set_fwd_ports_number(res->value);
3820 		fwd_config_setup();
3821 	} else if (!strcmp(res->what, "nbcore")) {
3822 		set_fwd_lcores_number(res->value);
3823 		fwd_config_setup();
3824 	} else if (!strcmp(res->what, "burst"))
3825 		set_nb_pkt_per_burst(res->value);
3826 	else if (!strcmp(res->what, "verbose"))
3827 		set_verbose_level(res->value);
3828 }
3829 
3830 cmdline_parse_token_string_t cmd_set_set =
3831 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3832 cmdline_parse_token_string_t cmd_set_what =
3833 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3834 				 "nbport#nbcore#burst#verbose");
3835 cmdline_parse_token_num_t cmd_set_value =
3836 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3837 
3838 cmdline_parse_inst_t cmd_set_numbers = {
3839 	.f = cmd_set_parsed,
3840 	.data = NULL,
3841 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3842 	.tokens = {
3843 		(void *)&cmd_set_set,
3844 		(void *)&cmd_set_what,
3845 		(void *)&cmd_set_value,
3846 		NULL,
3847 	},
3848 };
3849 
3850 /* *** SET LOG LEVEL CONFIGURATION *** */
3851 
3852 struct cmd_set_log_result {
3853 	cmdline_fixed_string_t set;
3854 	cmdline_fixed_string_t log;
3855 	cmdline_fixed_string_t type;
3856 	uint32_t level;
3857 };
3858 
3859 static void
3860 cmd_set_log_parsed(void *parsed_result,
3861 		   __rte_unused struct cmdline *cl,
3862 		   __rte_unused void *data)
3863 {
3864 	struct cmd_set_log_result *res;
3865 	int ret;
3866 
3867 	res = parsed_result;
3868 	if (!strcmp(res->type, "global"))
3869 		rte_log_set_global_level(res->level);
3870 	else {
3871 		ret = rte_log_set_level_regexp(res->type, res->level);
3872 		if (ret < 0)
3873 			fprintf(stderr, "Unable to set log level\n");
3874 	}
3875 }
3876 
3877 cmdline_parse_token_string_t cmd_set_log_set =
3878 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3879 cmdline_parse_token_string_t cmd_set_log_log =
3880 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3881 cmdline_parse_token_string_t cmd_set_log_type =
3882 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3883 cmdline_parse_token_num_t cmd_set_log_level =
3884 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3885 
3886 cmdline_parse_inst_t cmd_set_log = {
3887 	.f = cmd_set_log_parsed,
3888 	.data = NULL,
3889 	.help_str = "set log global|<type> <level>",
3890 	.tokens = {
3891 		(void *)&cmd_set_log_set,
3892 		(void *)&cmd_set_log_log,
3893 		(void *)&cmd_set_log_type,
3894 		(void *)&cmd_set_log_level,
3895 		NULL,
3896 	},
3897 };
3898 
3899 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3900 
3901 struct cmd_set_rxoffs_result {
3902 	cmdline_fixed_string_t cmd_keyword;
3903 	cmdline_fixed_string_t rxoffs;
3904 	cmdline_fixed_string_t seg_offsets;
3905 };
3906 
3907 static void
3908 cmd_set_rxoffs_parsed(void *parsed_result,
3909 		      __rte_unused struct cmdline *cl,
3910 		      __rte_unused void *data)
3911 {
3912 	struct cmd_set_rxoffs_result *res;
3913 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3914 	unsigned int nb_segs;
3915 
3916 	res = parsed_result;
3917 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3918 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3919 	if (nb_segs > 0)
3920 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3921 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3922 }
3923 
3924 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3925 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3926 				 cmd_keyword, "set");
3927 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3928 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3929 				 rxoffs, "rxoffs");
3930 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3931 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3932 				 seg_offsets, NULL);
3933 
3934 cmdline_parse_inst_t cmd_set_rxoffs = {
3935 	.f = cmd_set_rxoffs_parsed,
3936 	.data = NULL,
3937 	.help_str = "set rxoffs <len0[,len1]*>",
3938 	.tokens = {
3939 		(void *)&cmd_set_rxoffs_keyword,
3940 		(void *)&cmd_set_rxoffs_name,
3941 		(void *)&cmd_set_rxoffs_offsets,
3942 		NULL,
3943 	},
3944 };
3945 
3946 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3947 
3948 struct cmd_set_rxpkts_result {
3949 	cmdline_fixed_string_t cmd_keyword;
3950 	cmdline_fixed_string_t rxpkts;
3951 	cmdline_fixed_string_t seg_lengths;
3952 };
3953 
3954 static void
3955 cmd_set_rxpkts_parsed(void *parsed_result,
3956 		      __rte_unused struct cmdline *cl,
3957 		      __rte_unused void *data)
3958 {
3959 	struct cmd_set_rxpkts_result *res;
3960 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3961 	unsigned int nb_segs;
3962 
3963 	res = parsed_result;
3964 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3965 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3966 	if (nb_segs > 0)
3967 		set_rx_pkt_segments(seg_lengths, nb_segs);
3968 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3969 }
3970 
3971 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3972 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3973 				 cmd_keyword, "set");
3974 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3975 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3976 				 rxpkts, "rxpkts");
3977 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3978 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3979 				 seg_lengths, NULL);
3980 
3981 cmdline_parse_inst_t cmd_set_rxpkts = {
3982 	.f = cmd_set_rxpkts_parsed,
3983 	.data = NULL,
3984 	.help_str = "set rxpkts <len0[,len1]*>",
3985 	.tokens = {
3986 		(void *)&cmd_set_rxpkts_keyword,
3987 		(void *)&cmd_set_rxpkts_name,
3988 		(void *)&cmd_set_rxpkts_lengths,
3989 		NULL,
3990 	},
3991 };
3992 
3993 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3994 
3995 struct cmd_set_txpkts_result {
3996 	cmdline_fixed_string_t cmd_keyword;
3997 	cmdline_fixed_string_t txpkts;
3998 	cmdline_fixed_string_t seg_lengths;
3999 };
4000 
4001 static void
4002 cmd_set_txpkts_parsed(void *parsed_result,
4003 		      __rte_unused struct cmdline *cl,
4004 		      __rte_unused void *data)
4005 {
4006 	struct cmd_set_txpkts_result *res;
4007 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4008 	unsigned int nb_segs;
4009 
4010 	res = parsed_result;
4011 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4012 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4013 	if (nb_segs > 0)
4014 		set_tx_pkt_segments(seg_lengths, nb_segs);
4015 }
4016 
4017 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4018 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4019 				 cmd_keyword, "set");
4020 cmdline_parse_token_string_t cmd_set_txpkts_name =
4021 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4022 				 txpkts, "txpkts");
4023 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4024 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4025 				 seg_lengths, NULL);
4026 
4027 cmdline_parse_inst_t cmd_set_txpkts = {
4028 	.f = cmd_set_txpkts_parsed,
4029 	.data = NULL,
4030 	.help_str = "set txpkts <len0[,len1]*>",
4031 	.tokens = {
4032 		(void *)&cmd_set_txpkts_keyword,
4033 		(void *)&cmd_set_txpkts_name,
4034 		(void *)&cmd_set_txpkts_lengths,
4035 		NULL,
4036 	},
4037 };
4038 
4039 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4040 
4041 struct cmd_set_txsplit_result {
4042 	cmdline_fixed_string_t cmd_keyword;
4043 	cmdline_fixed_string_t txsplit;
4044 	cmdline_fixed_string_t mode;
4045 };
4046 
4047 static void
4048 cmd_set_txsplit_parsed(void *parsed_result,
4049 		      __rte_unused struct cmdline *cl,
4050 		      __rte_unused void *data)
4051 {
4052 	struct cmd_set_txsplit_result *res;
4053 
4054 	res = parsed_result;
4055 	set_tx_pkt_split(res->mode);
4056 }
4057 
4058 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4059 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4060 				 cmd_keyword, "set");
4061 cmdline_parse_token_string_t cmd_set_txsplit_name =
4062 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4063 				 txsplit, "txsplit");
4064 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4065 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4066 				 mode, NULL);
4067 
4068 cmdline_parse_inst_t cmd_set_txsplit = {
4069 	.f = cmd_set_txsplit_parsed,
4070 	.data = NULL,
4071 	.help_str = "set txsplit on|off|rand",
4072 	.tokens = {
4073 		(void *)&cmd_set_txsplit_keyword,
4074 		(void *)&cmd_set_txsplit_name,
4075 		(void *)&cmd_set_txsplit_mode,
4076 		NULL,
4077 	},
4078 };
4079 
4080 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4081 
4082 struct cmd_set_txtimes_result {
4083 	cmdline_fixed_string_t cmd_keyword;
4084 	cmdline_fixed_string_t txtimes;
4085 	cmdline_fixed_string_t tx_times;
4086 };
4087 
4088 static void
4089 cmd_set_txtimes_parsed(void *parsed_result,
4090 		       __rte_unused struct cmdline *cl,
4091 		       __rte_unused void *data)
4092 {
4093 	struct cmd_set_txtimes_result *res;
4094 	unsigned int tx_times[2] = {0, 0};
4095 	unsigned int n_times;
4096 
4097 	res = parsed_result;
4098 	n_times = parse_item_list(res->tx_times, "tx times",
4099 				  2, tx_times, 0);
4100 	if (n_times == 2)
4101 		set_tx_pkt_times(tx_times);
4102 }
4103 
4104 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4105 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4106 				 cmd_keyword, "set");
4107 cmdline_parse_token_string_t cmd_set_txtimes_name =
4108 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4109 				 txtimes, "txtimes");
4110 cmdline_parse_token_string_t cmd_set_txtimes_value =
4111 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4112 				 tx_times, NULL);
4113 
4114 cmdline_parse_inst_t cmd_set_txtimes = {
4115 	.f = cmd_set_txtimes_parsed,
4116 	.data = NULL,
4117 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
4118 	.tokens = {
4119 		(void *)&cmd_set_txtimes_keyword,
4120 		(void *)&cmd_set_txtimes_name,
4121 		(void *)&cmd_set_txtimes_value,
4122 		NULL,
4123 	},
4124 };
4125 
4126 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4127 struct cmd_rx_vlan_filter_all_result {
4128 	cmdline_fixed_string_t rx_vlan;
4129 	cmdline_fixed_string_t what;
4130 	cmdline_fixed_string_t all;
4131 	portid_t port_id;
4132 };
4133 
4134 static void
4135 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4136 			      __rte_unused struct cmdline *cl,
4137 			      __rte_unused void *data)
4138 {
4139 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4140 
4141 	if (!strcmp(res->what, "add"))
4142 		rx_vlan_all_filter_set(res->port_id, 1);
4143 	else
4144 		rx_vlan_all_filter_set(res->port_id, 0);
4145 }
4146 
4147 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4148 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4149 				 rx_vlan, "rx_vlan");
4150 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4151 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4152 				 what, "add#rm");
4153 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4154 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4155 				 all, "all");
4156 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4157 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4158 			      port_id, RTE_UINT16);
4159 
4160 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4161 	.f = cmd_rx_vlan_filter_all_parsed,
4162 	.data = NULL,
4163 	.help_str = "rx_vlan add|rm all <port_id>: "
4164 		"Add/Remove all identifiers to/from the set of VLAN "
4165 		"identifiers filtered by a port",
4166 	.tokens = {
4167 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4168 		(void *)&cmd_rx_vlan_filter_all_what,
4169 		(void *)&cmd_rx_vlan_filter_all_all,
4170 		(void *)&cmd_rx_vlan_filter_all_portid,
4171 		NULL,
4172 	},
4173 };
4174 
4175 /* *** VLAN OFFLOAD SET ON A PORT *** */
4176 struct cmd_vlan_offload_result {
4177 	cmdline_fixed_string_t vlan;
4178 	cmdline_fixed_string_t set;
4179 	cmdline_fixed_string_t vlan_type;
4180 	cmdline_fixed_string_t what;
4181 	cmdline_fixed_string_t on;
4182 	cmdline_fixed_string_t port_id;
4183 };
4184 
4185 static void
4186 cmd_vlan_offload_parsed(void *parsed_result,
4187 			  __rte_unused struct cmdline *cl,
4188 			  __rte_unused void *data)
4189 {
4190 	int on;
4191 	struct cmd_vlan_offload_result *res = parsed_result;
4192 	char *str;
4193 	int i, len = 0;
4194 	portid_t port_id = 0;
4195 	unsigned int tmp;
4196 
4197 	str = res->port_id;
4198 	len = strnlen(str, STR_TOKEN_SIZE);
4199 	i = 0;
4200 	/* Get port_id first */
4201 	while(i < len){
4202 		if(str[i] == ',')
4203 			break;
4204 
4205 		i++;
4206 	}
4207 	str[i]='\0';
4208 	tmp = strtoul(str, NULL, 0);
4209 	/* If port_id greater that what portid_t can represent, return */
4210 	if(tmp >= RTE_MAX_ETHPORTS)
4211 		return;
4212 	port_id = (portid_t)tmp;
4213 
4214 	if (!strcmp(res->on, "on"))
4215 		on = 1;
4216 	else
4217 		on = 0;
4218 
4219 	if (!strcmp(res->what, "strip"))
4220 		rx_vlan_strip_set(port_id,  on);
4221 	else if(!strcmp(res->what, "stripq")){
4222 		uint16_t queue_id = 0;
4223 
4224 		/* No queue_id, return */
4225 		if(i + 1 >= len) {
4226 			fprintf(stderr, "must specify (port,queue_id)\n");
4227 			return;
4228 		}
4229 		tmp = strtoul(str + i + 1, NULL, 0);
4230 		/* If queue_id greater that what 16-bits can represent, return */
4231 		if(tmp > 0xffff)
4232 			return;
4233 
4234 		queue_id = (uint16_t)tmp;
4235 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4236 	}
4237 	else if (!strcmp(res->what, "filter"))
4238 		rx_vlan_filter_set(port_id, on);
4239 	else if (!strcmp(res->what, "qinq_strip"))
4240 		rx_vlan_qinq_strip_set(port_id, on);
4241 	else
4242 		vlan_extend_set(port_id, on);
4243 
4244 	return;
4245 }
4246 
4247 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4248 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4249 				 vlan, "vlan");
4250 cmdline_parse_token_string_t cmd_vlan_offload_set =
4251 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4252 				 set, "set");
4253 cmdline_parse_token_string_t cmd_vlan_offload_what =
4254 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4255 				what, "strip#filter#qinq_strip#extend#stripq");
4256 cmdline_parse_token_string_t cmd_vlan_offload_on =
4257 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4258 			      on, "on#off");
4259 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4260 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4261 			      port_id, NULL);
4262 
4263 cmdline_parse_inst_t cmd_vlan_offload = {
4264 	.f = cmd_vlan_offload_parsed,
4265 	.data = NULL,
4266 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4267 		"<port_id[,queue_id]>: "
4268 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4269 	.tokens = {
4270 		(void *)&cmd_vlan_offload_vlan,
4271 		(void *)&cmd_vlan_offload_set,
4272 		(void *)&cmd_vlan_offload_what,
4273 		(void *)&cmd_vlan_offload_on,
4274 		(void *)&cmd_vlan_offload_portid,
4275 		NULL,
4276 	},
4277 };
4278 
4279 /* *** VLAN TPID SET ON A PORT *** */
4280 struct cmd_vlan_tpid_result {
4281 	cmdline_fixed_string_t vlan;
4282 	cmdline_fixed_string_t set;
4283 	cmdline_fixed_string_t vlan_type;
4284 	cmdline_fixed_string_t what;
4285 	uint16_t tp_id;
4286 	portid_t port_id;
4287 };
4288 
4289 static void
4290 cmd_vlan_tpid_parsed(void *parsed_result,
4291 			  __rte_unused struct cmdline *cl,
4292 			  __rte_unused void *data)
4293 {
4294 	struct cmd_vlan_tpid_result *res = parsed_result;
4295 	enum rte_vlan_type vlan_type;
4296 
4297 	if (!strcmp(res->vlan_type, "inner"))
4298 		vlan_type = ETH_VLAN_TYPE_INNER;
4299 	else if (!strcmp(res->vlan_type, "outer"))
4300 		vlan_type = ETH_VLAN_TYPE_OUTER;
4301 	else {
4302 		fprintf(stderr, "Unknown vlan type\n");
4303 		return;
4304 	}
4305 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4306 }
4307 
4308 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4309 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4310 				 vlan, "vlan");
4311 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4312 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4313 				 set, "set");
4314 cmdline_parse_token_string_t cmd_vlan_type =
4315 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4316 				 vlan_type, "inner#outer");
4317 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4318 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4319 				 what, "tpid");
4320 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4321 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4322 			      tp_id, RTE_UINT16);
4323 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4324 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4325 			      port_id, RTE_UINT16);
4326 
4327 cmdline_parse_inst_t cmd_vlan_tpid = {
4328 	.f = cmd_vlan_tpid_parsed,
4329 	.data = NULL,
4330 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4331 		"Set the VLAN Ether type",
4332 	.tokens = {
4333 		(void *)&cmd_vlan_tpid_vlan,
4334 		(void *)&cmd_vlan_tpid_set,
4335 		(void *)&cmd_vlan_type,
4336 		(void *)&cmd_vlan_tpid_what,
4337 		(void *)&cmd_vlan_tpid_tpid,
4338 		(void *)&cmd_vlan_tpid_portid,
4339 		NULL,
4340 	},
4341 };
4342 
4343 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4344 struct cmd_rx_vlan_filter_result {
4345 	cmdline_fixed_string_t rx_vlan;
4346 	cmdline_fixed_string_t what;
4347 	uint16_t vlan_id;
4348 	portid_t port_id;
4349 };
4350 
4351 static void
4352 cmd_rx_vlan_filter_parsed(void *parsed_result,
4353 			  __rte_unused struct cmdline *cl,
4354 			  __rte_unused void *data)
4355 {
4356 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4357 
4358 	if (!strcmp(res->what, "add"))
4359 		rx_vft_set(res->port_id, res->vlan_id, 1);
4360 	else
4361 		rx_vft_set(res->port_id, res->vlan_id, 0);
4362 }
4363 
4364 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4365 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4366 				 rx_vlan, "rx_vlan");
4367 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4368 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4369 				 what, "add#rm");
4370 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4371 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4372 			      vlan_id, RTE_UINT16);
4373 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4374 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4375 			      port_id, RTE_UINT16);
4376 
4377 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4378 	.f = cmd_rx_vlan_filter_parsed,
4379 	.data = NULL,
4380 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4381 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4382 		"identifiers filtered by a port",
4383 	.tokens = {
4384 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4385 		(void *)&cmd_rx_vlan_filter_what,
4386 		(void *)&cmd_rx_vlan_filter_vlanid,
4387 		(void *)&cmd_rx_vlan_filter_portid,
4388 		NULL,
4389 	},
4390 };
4391 
4392 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4393 struct cmd_tx_vlan_set_result {
4394 	cmdline_fixed_string_t tx_vlan;
4395 	cmdline_fixed_string_t set;
4396 	portid_t port_id;
4397 	uint16_t vlan_id;
4398 };
4399 
4400 static void
4401 cmd_tx_vlan_set_parsed(void *parsed_result,
4402 		       __rte_unused struct cmdline *cl,
4403 		       __rte_unused void *data)
4404 {
4405 	struct cmd_tx_vlan_set_result *res = parsed_result;
4406 
4407 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4408 		return;
4409 
4410 	if (!port_is_stopped(res->port_id)) {
4411 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4412 		return;
4413 	}
4414 
4415 	tx_vlan_set(res->port_id, res->vlan_id);
4416 
4417 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4418 }
4419 
4420 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4421 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4422 				 tx_vlan, "tx_vlan");
4423 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4424 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4425 				 set, "set");
4426 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4427 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4428 			      port_id, RTE_UINT16);
4429 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4430 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4431 			      vlan_id, RTE_UINT16);
4432 
4433 cmdline_parse_inst_t cmd_tx_vlan_set = {
4434 	.f = cmd_tx_vlan_set_parsed,
4435 	.data = NULL,
4436 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4437 		"Enable hardware insertion of a single VLAN header "
4438 		"with a given TAG Identifier in packets sent on a port",
4439 	.tokens = {
4440 		(void *)&cmd_tx_vlan_set_tx_vlan,
4441 		(void *)&cmd_tx_vlan_set_set,
4442 		(void *)&cmd_tx_vlan_set_portid,
4443 		(void *)&cmd_tx_vlan_set_vlanid,
4444 		NULL,
4445 	},
4446 };
4447 
4448 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4449 struct cmd_tx_vlan_set_qinq_result {
4450 	cmdline_fixed_string_t tx_vlan;
4451 	cmdline_fixed_string_t set;
4452 	portid_t port_id;
4453 	uint16_t vlan_id;
4454 	uint16_t vlan_id_outer;
4455 };
4456 
4457 static void
4458 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4459 			    __rte_unused struct cmdline *cl,
4460 			    __rte_unused void *data)
4461 {
4462 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4463 
4464 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4465 		return;
4466 
4467 	if (!port_is_stopped(res->port_id)) {
4468 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4469 		return;
4470 	}
4471 
4472 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4473 
4474 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4475 }
4476 
4477 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4478 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4479 		tx_vlan, "tx_vlan");
4480 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4481 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4482 		set, "set");
4483 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4484 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4485 		port_id, RTE_UINT16);
4486 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4487 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4488 		vlan_id, RTE_UINT16);
4489 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4490 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4491 		vlan_id_outer, RTE_UINT16);
4492 
4493 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4494 	.f = cmd_tx_vlan_set_qinq_parsed,
4495 	.data = NULL,
4496 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4497 		"Enable hardware insertion of double VLAN header "
4498 		"with given TAG Identifiers in packets sent on a port",
4499 	.tokens = {
4500 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4501 		(void *)&cmd_tx_vlan_set_qinq_set,
4502 		(void *)&cmd_tx_vlan_set_qinq_portid,
4503 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4504 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4505 		NULL,
4506 	},
4507 };
4508 
4509 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4510 struct cmd_tx_vlan_set_pvid_result {
4511 	cmdline_fixed_string_t tx_vlan;
4512 	cmdline_fixed_string_t set;
4513 	cmdline_fixed_string_t pvid;
4514 	portid_t port_id;
4515 	uint16_t vlan_id;
4516 	cmdline_fixed_string_t mode;
4517 };
4518 
4519 static void
4520 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4521 			    __rte_unused struct cmdline *cl,
4522 			    __rte_unused void *data)
4523 {
4524 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4525 
4526 	if (strcmp(res->mode, "on") == 0)
4527 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4528 	else
4529 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4530 }
4531 
4532 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4533 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4534 				 tx_vlan, "tx_vlan");
4535 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4536 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4537 				 set, "set");
4538 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4539 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4540 				 pvid, "pvid");
4541 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4542 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4543 			     port_id, RTE_UINT16);
4544 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4545 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4546 			      vlan_id, RTE_UINT16);
4547 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4548 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4549 				 mode, "on#off");
4550 
4551 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4552 	.f = cmd_tx_vlan_set_pvid_parsed,
4553 	.data = NULL,
4554 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4555 	.tokens = {
4556 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4557 		(void *)&cmd_tx_vlan_set_pvid_set,
4558 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4559 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4560 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4561 		(void *)&cmd_tx_vlan_set_pvid_mode,
4562 		NULL,
4563 	},
4564 };
4565 
4566 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4567 struct cmd_tx_vlan_reset_result {
4568 	cmdline_fixed_string_t tx_vlan;
4569 	cmdline_fixed_string_t reset;
4570 	portid_t port_id;
4571 };
4572 
4573 static void
4574 cmd_tx_vlan_reset_parsed(void *parsed_result,
4575 			 __rte_unused struct cmdline *cl,
4576 			 __rte_unused void *data)
4577 {
4578 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4579 
4580 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4581 		return;
4582 
4583 	if (!port_is_stopped(res->port_id)) {
4584 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4585 		return;
4586 	}
4587 
4588 	tx_vlan_reset(res->port_id);
4589 
4590 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4591 }
4592 
4593 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4594 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4595 				 tx_vlan, "tx_vlan");
4596 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4597 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4598 				 reset, "reset");
4599 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4600 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4601 			      port_id, RTE_UINT16);
4602 
4603 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4604 	.f = cmd_tx_vlan_reset_parsed,
4605 	.data = NULL,
4606 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4607 		"VLAN header in packets sent on a port",
4608 	.tokens = {
4609 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4610 		(void *)&cmd_tx_vlan_reset_reset,
4611 		(void *)&cmd_tx_vlan_reset_portid,
4612 		NULL,
4613 	},
4614 };
4615 
4616 
4617 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4618 struct cmd_csum_result {
4619 	cmdline_fixed_string_t csum;
4620 	cmdline_fixed_string_t mode;
4621 	cmdline_fixed_string_t proto;
4622 	cmdline_fixed_string_t hwsw;
4623 	portid_t port_id;
4624 };
4625 
4626 static void
4627 csum_show(int port_id)
4628 {
4629 	struct rte_eth_dev_info dev_info;
4630 	uint64_t tx_offloads;
4631 	int ret;
4632 
4633 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4634 	printf("Parse tunnel is %s\n",
4635 		(ports[port_id].parse_tunnel) ? "on" : "off");
4636 	printf("IP checksum offload is %s\n",
4637 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4638 	printf("UDP checksum offload is %s\n",
4639 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4640 	printf("TCP checksum offload is %s\n",
4641 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4642 	printf("SCTP checksum offload is %s\n",
4643 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4644 	printf("Outer-Ip checksum offload is %s\n",
4645 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4646 	printf("Outer-Udp checksum offload is %s\n",
4647 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4648 
4649 	/* display warnings if configuration is not supported by the NIC */
4650 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4651 	if (ret != 0)
4652 		return;
4653 
4654 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4655 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4656 		fprintf(stderr,
4657 			"Warning: hardware IP checksum enabled but not supported by port %d\n",
4658 			port_id);
4659 	}
4660 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4661 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4662 		fprintf(stderr,
4663 			"Warning: hardware UDP checksum enabled but not supported by port %d\n",
4664 			port_id);
4665 	}
4666 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4667 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4668 		fprintf(stderr,
4669 			"Warning: hardware TCP checksum enabled but not supported by port %d\n",
4670 			port_id);
4671 	}
4672 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4673 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4674 		fprintf(stderr,
4675 			"Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4676 			port_id);
4677 	}
4678 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4679 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4680 		fprintf(stderr,
4681 			"Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4682 			port_id);
4683 	}
4684 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4685 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4686 			== 0) {
4687 		fprintf(stderr,
4688 			"Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4689 			port_id);
4690 	}
4691 }
4692 
4693 static void
4694 cmd_config_queue_tx_offloads(struct rte_port *port)
4695 {
4696 	int k;
4697 
4698 	/* Apply queue tx offloads configuration */
4699 	for (k = 0; k < port->dev_info.max_tx_queues; k++)
4700 		port->tx_conf[k].offloads =
4701 			port->dev_conf.txmode.offloads;
4702 }
4703 
4704 static void
4705 cmd_csum_parsed(void *parsed_result,
4706 		       __rte_unused struct cmdline *cl,
4707 		       __rte_unused void *data)
4708 {
4709 	struct cmd_csum_result *res = parsed_result;
4710 	int hw = 0;
4711 	uint64_t csum_offloads = 0;
4712 	struct rte_eth_dev_info dev_info;
4713 	int ret;
4714 
4715 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4716 		fprintf(stderr, "invalid port %d\n", res->port_id);
4717 		return;
4718 	}
4719 	if (!port_is_stopped(res->port_id)) {
4720 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4721 		return;
4722 	}
4723 
4724 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4725 	if (ret != 0)
4726 		return;
4727 
4728 	if (!strcmp(res->mode, "set")) {
4729 
4730 		if (!strcmp(res->hwsw, "hw"))
4731 			hw = 1;
4732 
4733 		if (!strcmp(res->proto, "ip")) {
4734 			if (hw == 0 || (dev_info.tx_offload_capa &
4735 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4736 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4737 			} else {
4738 				fprintf(stderr,
4739 					"IP checksum offload is not supported by port %u\n",
4740 					res->port_id);
4741 			}
4742 		} else if (!strcmp(res->proto, "udp")) {
4743 			if (hw == 0 || (dev_info.tx_offload_capa &
4744 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4745 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4746 			} else {
4747 				fprintf(stderr,
4748 					"UDP checksum offload is not supported by port %u\n",
4749 					res->port_id);
4750 			}
4751 		} else if (!strcmp(res->proto, "tcp")) {
4752 			if (hw == 0 || (dev_info.tx_offload_capa &
4753 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4754 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4755 			} else {
4756 				fprintf(stderr,
4757 					"TCP checksum offload is not supported by port %u\n",
4758 					res->port_id);
4759 			}
4760 		} else if (!strcmp(res->proto, "sctp")) {
4761 			if (hw == 0 || (dev_info.tx_offload_capa &
4762 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4763 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4764 			} else {
4765 				fprintf(stderr,
4766 					"SCTP checksum offload is not supported by port %u\n",
4767 					res->port_id);
4768 			}
4769 		} else if (!strcmp(res->proto, "outer-ip")) {
4770 			if (hw == 0 || (dev_info.tx_offload_capa &
4771 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4772 				csum_offloads |=
4773 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4774 			} else {
4775 				fprintf(stderr,
4776 					"Outer IP checksum offload is not supported by port %u\n",
4777 					res->port_id);
4778 			}
4779 		} else if (!strcmp(res->proto, "outer-udp")) {
4780 			if (hw == 0 || (dev_info.tx_offload_capa &
4781 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4782 				csum_offloads |=
4783 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4784 			} else {
4785 				fprintf(stderr,
4786 					"Outer UDP checksum offload is not supported by port %u\n",
4787 					res->port_id);
4788 			}
4789 		}
4790 
4791 		if (hw) {
4792 			ports[res->port_id].dev_conf.txmode.offloads |=
4793 							csum_offloads;
4794 		} else {
4795 			ports[res->port_id].dev_conf.txmode.offloads &=
4796 							(~csum_offloads);
4797 		}
4798 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4799 	}
4800 	csum_show(res->port_id);
4801 
4802 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4803 }
4804 
4805 cmdline_parse_token_string_t cmd_csum_csum =
4806 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4807 				csum, "csum");
4808 cmdline_parse_token_string_t cmd_csum_mode =
4809 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4810 				mode, "set");
4811 cmdline_parse_token_string_t cmd_csum_proto =
4812 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4813 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4814 cmdline_parse_token_string_t cmd_csum_hwsw =
4815 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4816 				hwsw, "hw#sw");
4817 cmdline_parse_token_num_t cmd_csum_portid =
4818 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4819 				port_id, RTE_UINT16);
4820 
4821 cmdline_parse_inst_t cmd_csum_set = {
4822 	.f = cmd_csum_parsed,
4823 	.data = NULL,
4824 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4825 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4826 		"using csum forward engine",
4827 	.tokens = {
4828 		(void *)&cmd_csum_csum,
4829 		(void *)&cmd_csum_mode,
4830 		(void *)&cmd_csum_proto,
4831 		(void *)&cmd_csum_hwsw,
4832 		(void *)&cmd_csum_portid,
4833 		NULL,
4834 	},
4835 };
4836 
4837 cmdline_parse_token_string_t cmd_csum_mode_show =
4838 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4839 				mode, "show");
4840 
4841 cmdline_parse_inst_t cmd_csum_show = {
4842 	.f = cmd_csum_parsed,
4843 	.data = NULL,
4844 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4845 	.tokens = {
4846 		(void *)&cmd_csum_csum,
4847 		(void *)&cmd_csum_mode_show,
4848 		(void *)&cmd_csum_portid,
4849 		NULL,
4850 	},
4851 };
4852 
4853 /* Enable/disable tunnel parsing */
4854 struct cmd_csum_tunnel_result {
4855 	cmdline_fixed_string_t csum;
4856 	cmdline_fixed_string_t parse;
4857 	cmdline_fixed_string_t onoff;
4858 	portid_t port_id;
4859 };
4860 
4861 static void
4862 cmd_csum_tunnel_parsed(void *parsed_result,
4863 		       __rte_unused struct cmdline *cl,
4864 		       __rte_unused void *data)
4865 {
4866 	struct cmd_csum_tunnel_result *res = parsed_result;
4867 
4868 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4869 		return;
4870 
4871 	if (!strcmp(res->onoff, "on"))
4872 		ports[res->port_id].parse_tunnel = 1;
4873 	else
4874 		ports[res->port_id].parse_tunnel = 0;
4875 
4876 	csum_show(res->port_id);
4877 }
4878 
4879 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4880 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4881 				csum, "csum");
4882 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4883 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4884 				parse, "parse-tunnel");
4885 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4886 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4887 				onoff, "on#off");
4888 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4889 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4890 				port_id, RTE_UINT16);
4891 
4892 cmdline_parse_inst_t cmd_csum_tunnel = {
4893 	.f = cmd_csum_tunnel_parsed,
4894 	.data = NULL,
4895 	.help_str = "csum parse-tunnel on|off <port_id>: "
4896 		"Enable/Disable parsing of tunnels for csum engine",
4897 	.tokens = {
4898 		(void *)&cmd_csum_tunnel_csum,
4899 		(void *)&cmd_csum_tunnel_parse,
4900 		(void *)&cmd_csum_tunnel_onoff,
4901 		(void *)&cmd_csum_tunnel_portid,
4902 		NULL,
4903 	},
4904 };
4905 
4906 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4907 struct cmd_tso_set_result {
4908 	cmdline_fixed_string_t tso;
4909 	cmdline_fixed_string_t mode;
4910 	uint16_t tso_segsz;
4911 	portid_t port_id;
4912 };
4913 
4914 static void
4915 cmd_tso_set_parsed(void *parsed_result,
4916 		       __rte_unused struct cmdline *cl,
4917 		       __rte_unused void *data)
4918 {
4919 	struct cmd_tso_set_result *res = parsed_result;
4920 	struct rte_eth_dev_info dev_info;
4921 	int ret;
4922 
4923 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4924 		return;
4925 	if (!port_is_stopped(res->port_id)) {
4926 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4927 		return;
4928 	}
4929 
4930 	if (!strcmp(res->mode, "set"))
4931 		ports[res->port_id].tso_segsz = res->tso_segsz;
4932 
4933 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4934 	if (ret != 0)
4935 		return;
4936 
4937 	if ((ports[res->port_id].tso_segsz != 0) &&
4938 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4939 		fprintf(stderr, "Error: TSO is not supported by port %d\n",
4940 			res->port_id);
4941 		return;
4942 	}
4943 
4944 	if (ports[res->port_id].tso_segsz == 0) {
4945 		ports[res->port_id].dev_conf.txmode.offloads &=
4946 						~DEV_TX_OFFLOAD_TCP_TSO;
4947 		printf("TSO for non-tunneled packets is disabled\n");
4948 	} else {
4949 		ports[res->port_id].dev_conf.txmode.offloads |=
4950 						DEV_TX_OFFLOAD_TCP_TSO;
4951 		printf("TSO segment size for non-tunneled packets is %d\n",
4952 			ports[res->port_id].tso_segsz);
4953 	}
4954 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4955 
4956 	/* display warnings if configuration is not supported by the NIC */
4957 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4958 	if (ret != 0)
4959 		return;
4960 
4961 	if ((ports[res->port_id].tso_segsz != 0) &&
4962 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4963 		fprintf(stderr,
4964 			"Warning: TSO enabled but not supported by port %d\n",
4965 			res->port_id);
4966 	}
4967 
4968 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4969 }
4970 
4971 cmdline_parse_token_string_t cmd_tso_set_tso =
4972 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4973 				tso, "tso");
4974 cmdline_parse_token_string_t cmd_tso_set_mode =
4975 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4976 				mode, "set");
4977 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4978 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4979 				tso_segsz, RTE_UINT16);
4980 cmdline_parse_token_num_t cmd_tso_set_portid =
4981 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4982 				port_id, RTE_UINT16);
4983 
4984 cmdline_parse_inst_t cmd_tso_set = {
4985 	.f = cmd_tso_set_parsed,
4986 	.data = NULL,
4987 	.help_str = "tso set <tso_segsz> <port_id>: "
4988 		"Set TSO segment size of non-tunneled packets for csum engine "
4989 		"(0 to disable)",
4990 	.tokens = {
4991 		(void *)&cmd_tso_set_tso,
4992 		(void *)&cmd_tso_set_mode,
4993 		(void *)&cmd_tso_set_tso_segsz,
4994 		(void *)&cmd_tso_set_portid,
4995 		NULL,
4996 	},
4997 };
4998 
4999 cmdline_parse_token_string_t cmd_tso_show_mode =
5000 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5001 				mode, "show");
5002 
5003 
5004 cmdline_parse_inst_t cmd_tso_show = {
5005 	.f = cmd_tso_set_parsed,
5006 	.data = NULL,
5007 	.help_str = "tso show <port_id>: "
5008 		"Show TSO segment size of non-tunneled packets for csum engine",
5009 	.tokens = {
5010 		(void *)&cmd_tso_set_tso,
5011 		(void *)&cmd_tso_show_mode,
5012 		(void *)&cmd_tso_set_portid,
5013 		NULL,
5014 	},
5015 };
5016 
5017 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5018 struct cmd_tunnel_tso_set_result {
5019 	cmdline_fixed_string_t tso;
5020 	cmdline_fixed_string_t mode;
5021 	uint16_t tso_segsz;
5022 	portid_t port_id;
5023 };
5024 
5025 static struct rte_eth_dev_info
5026 check_tunnel_tso_nic_support(portid_t port_id)
5027 {
5028 	struct rte_eth_dev_info dev_info;
5029 
5030 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5031 		return dev_info;
5032 
5033 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5034 		fprintf(stderr,
5035 			"Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5036 			port_id);
5037 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5038 		fprintf(stderr,
5039 			"Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5040 			port_id);
5041 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5042 		fprintf(stderr,
5043 			"Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5044 			port_id);
5045 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5046 		fprintf(stderr,
5047 			"Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5048 			port_id);
5049 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5050 		fprintf(stderr,
5051 			"Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5052 			port_id);
5053 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5054 		fprintf(stderr,
5055 			"Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5056 			port_id);
5057 	return dev_info;
5058 }
5059 
5060 static void
5061 cmd_tunnel_tso_set_parsed(void *parsed_result,
5062 			  __rte_unused struct cmdline *cl,
5063 			  __rte_unused void *data)
5064 {
5065 	struct cmd_tunnel_tso_set_result *res = parsed_result;
5066 	struct rte_eth_dev_info dev_info;
5067 
5068 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5069 		return;
5070 	if (!port_is_stopped(res->port_id)) {
5071 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
5072 		return;
5073 	}
5074 
5075 	if (!strcmp(res->mode, "set"))
5076 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5077 
5078 	dev_info = check_tunnel_tso_nic_support(res->port_id);
5079 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
5080 		ports[res->port_id].dev_conf.txmode.offloads &=
5081 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5082 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
5083 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5084 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5085 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
5086 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
5087 		printf("TSO for tunneled packets is disabled\n");
5088 	} else {
5089 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5090 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5091 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5092 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5093 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
5094 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5095 
5096 		ports[res->port_id].dev_conf.txmode.offloads |=
5097 			(tso_offloads & dev_info.tx_offload_capa);
5098 		printf("TSO segment size for tunneled packets is %d\n",
5099 			ports[res->port_id].tunnel_tso_segsz);
5100 
5101 		/* Below conditions are needed to make it work:
5102 		 * (1) tunnel TSO is supported by the NIC;
5103 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5104 		 * are recognized;
5105 		 * (3) for tunneled pkts with outer L3 of IPv4,
5106 		 * "csum set outer-ip" must be set to hw, because after tso,
5107 		 * total_len of outer IP header is changed, and the checksum
5108 		 * of outer IP header calculated by sw should be wrong; that
5109 		 * is not necessary for IPv6 tunneled pkts because there's no
5110 		 * checksum in IP header anymore.
5111 		 */
5112 
5113 		if (!ports[res->port_id].parse_tunnel)
5114 			fprintf(stderr,
5115 				"Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5116 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
5117 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5118 			fprintf(stderr,
5119 				"Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5120 	}
5121 
5122 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
5123 	cmd_reconfig_device_queue(res->port_id, 1, 1);
5124 }
5125 
5126 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5127 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5128 				tso, "tunnel_tso");
5129 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5130 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5131 				mode, "set");
5132 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5133 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5134 				tso_segsz, RTE_UINT16);
5135 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5136 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5137 				port_id, RTE_UINT16);
5138 
5139 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5140 	.f = cmd_tunnel_tso_set_parsed,
5141 	.data = NULL,
5142 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5143 		"Set TSO segment size of tunneled packets for csum engine "
5144 		"(0 to disable)",
5145 	.tokens = {
5146 		(void *)&cmd_tunnel_tso_set_tso,
5147 		(void *)&cmd_tunnel_tso_set_mode,
5148 		(void *)&cmd_tunnel_tso_set_tso_segsz,
5149 		(void *)&cmd_tunnel_tso_set_portid,
5150 		NULL,
5151 	},
5152 };
5153 
5154 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5155 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5156 				mode, "show");
5157 
5158 
5159 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5160 	.f = cmd_tunnel_tso_set_parsed,
5161 	.data = NULL,
5162 	.help_str = "tunnel_tso show <port_id> "
5163 		"Show TSO segment size of tunneled packets for csum engine",
5164 	.tokens = {
5165 		(void *)&cmd_tunnel_tso_set_tso,
5166 		(void *)&cmd_tunnel_tso_show_mode,
5167 		(void *)&cmd_tunnel_tso_set_portid,
5168 		NULL,
5169 	},
5170 };
5171 
5172 /* *** SET GRO FOR A PORT *** */
5173 struct cmd_gro_enable_result {
5174 	cmdline_fixed_string_t cmd_set;
5175 	cmdline_fixed_string_t cmd_port;
5176 	cmdline_fixed_string_t cmd_keyword;
5177 	cmdline_fixed_string_t cmd_onoff;
5178 	portid_t cmd_pid;
5179 };
5180 
5181 static void
5182 cmd_gro_enable_parsed(void *parsed_result,
5183 		__rte_unused struct cmdline *cl,
5184 		__rte_unused void *data)
5185 {
5186 	struct cmd_gro_enable_result *res;
5187 
5188 	res = parsed_result;
5189 	if (!strcmp(res->cmd_keyword, "gro"))
5190 		setup_gro(res->cmd_onoff, res->cmd_pid);
5191 }
5192 
5193 cmdline_parse_token_string_t cmd_gro_enable_set =
5194 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5195 			cmd_set, "set");
5196 cmdline_parse_token_string_t cmd_gro_enable_port =
5197 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5198 			cmd_keyword, "port");
5199 cmdline_parse_token_num_t cmd_gro_enable_pid =
5200 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5201 			cmd_pid, RTE_UINT16);
5202 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5203 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5204 			cmd_keyword, "gro");
5205 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5206 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5207 			cmd_onoff, "on#off");
5208 
5209 cmdline_parse_inst_t cmd_gro_enable = {
5210 	.f = cmd_gro_enable_parsed,
5211 	.data = NULL,
5212 	.help_str = "set port <port_id> gro on|off",
5213 	.tokens = {
5214 		(void *)&cmd_gro_enable_set,
5215 		(void *)&cmd_gro_enable_port,
5216 		(void *)&cmd_gro_enable_pid,
5217 		(void *)&cmd_gro_enable_keyword,
5218 		(void *)&cmd_gro_enable_onoff,
5219 		NULL,
5220 	},
5221 };
5222 
5223 /* *** DISPLAY GRO CONFIGURATION *** */
5224 struct cmd_gro_show_result {
5225 	cmdline_fixed_string_t cmd_show;
5226 	cmdline_fixed_string_t cmd_port;
5227 	cmdline_fixed_string_t cmd_keyword;
5228 	portid_t cmd_pid;
5229 };
5230 
5231 static void
5232 cmd_gro_show_parsed(void *parsed_result,
5233 		__rte_unused struct cmdline *cl,
5234 		__rte_unused void *data)
5235 {
5236 	struct cmd_gro_show_result *res;
5237 
5238 	res = parsed_result;
5239 	if (!strcmp(res->cmd_keyword, "gro"))
5240 		show_gro(res->cmd_pid);
5241 }
5242 
5243 cmdline_parse_token_string_t cmd_gro_show_show =
5244 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5245 			cmd_show, "show");
5246 cmdline_parse_token_string_t cmd_gro_show_port =
5247 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5248 			cmd_port, "port");
5249 cmdline_parse_token_num_t cmd_gro_show_pid =
5250 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5251 			cmd_pid, RTE_UINT16);
5252 cmdline_parse_token_string_t cmd_gro_show_keyword =
5253 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5254 			cmd_keyword, "gro");
5255 
5256 cmdline_parse_inst_t cmd_gro_show = {
5257 	.f = cmd_gro_show_parsed,
5258 	.data = NULL,
5259 	.help_str = "show port <port_id> gro",
5260 	.tokens = {
5261 		(void *)&cmd_gro_show_show,
5262 		(void *)&cmd_gro_show_port,
5263 		(void *)&cmd_gro_show_pid,
5264 		(void *)&cmd_gro_show_keyword,
5265 		NULL,
5266 	},
5267 };
5268 
5269 /* *** SET FLUSH CYCLES FOR GRO *** */
5270 struct cmd_gro_flush_result {
5271 	cmdline_fixed_string_t cmd_set;
5272 	cmdline_fixed_string_t cmd_keyword;
5273 	cmdline_fixed_string_t cmd_flush;
5274 	uint8_t cmd_cycles;
5275 };
5276 
5277 static void
5278 cmd_gro_flush_parsed(void *parsed_result,
5279 		__rte_unused struct cmdline *cl,
5280 		__rte_unused void *data)
5281 {
5282 	struct cmd_gro_flush_result *res;
5283 
5284 	res = parsed_result;
5285 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5286 			(!strcmp(res->cmd_flush, "flush")))
5287 		setup_gro_flush_cycles(res->cmd_cycles);
5288 }
5289 
5290 cmdline_parse_token_string_t cmd_gro_flush_set =
5291 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5292 			cmd_set, "set");
5293 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5294 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5295 			cmd_keyword, "gro");
5296 cmdline_parse_token_string_t cmd_gro_flush_flush =
5297 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5298 			cmd_flush, "flush");
5299 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5300 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5301 			cmd_cycles, RTE_UINT8);
5302 
5303 cmdline_parse_inst_t cmd_gro_flush = {
5304 	.f = cmd_gro_flush_parsed,
5305 	.data = NULL,
5306 	.help_str = "set gro flush <cycles>",
5307 	.tokens = {
5308 		(void *)&cmd_gro_flush_set,
5309 		(void *)&cmd_gro_flush_keyword,
5310 		(void *)&cmd_gro_flush_flush,
5311 		(void *)&cmd_gro_flush_cycles,
5312 		NULL,
5313 	},
5314 };
5315 
5316 /* *** ENABLE/DISABLE GSO *** */
5317 struct cmd_gso_enable_result {
5318 	cmdline_fixed_string_t cmd_set;
5319 	cmdline_fixed_string_t cmd_port;
5320 	cmdline_fixed_string_t cmd_keyword;
5321 	cmdline_fixed_string_t cmd_mode;
5322 	portid_t cmd_pid;
5323 };
5324 
5325 static void
5326 cmd_gso_enable_parsed(void *parsed_result,
5327 		__rte_unused struct cmdline *cl,
5328 		__rte_unused void *data)
5329 {
5330 	struct cmd_gso_enable_result *res;
5331 
5332 	res = parsed_result;
5333 	if (!strcmp(res->cmd_keyword, "gso"))
5334 		setup_gso(res->cmd_mode, res->cmd_pid);
5335 }
5336 
5337 cmdline_parse_token_string_t cmd_gso_enable_set =
5338 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5339 			cmd_set, "set");
5340 cmdline_parse_token_string_t cmd_gso_enable_port =
5341 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5342 			cmd_port, "port");
5343 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5344 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5345 			cmd_keyword, "gso");
5346 cmdline_parse_token_string_t cmd_gso_enable_mode =
5347 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5348 			cmd_mode, "on#off");
5349 cmdline_parse_token_num_t cmd_gso_enable_pid =
5350 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5351 			cmd_pid, RTE_UINT16);
5352 
5353 cmdline_parse_inst_t cmd_gso_enable = {
5354 	.f = cmd_gso_enable_parsed,
5355 	.data = NULL,
5356 	.help_str = "set port <port_id> gso on|off",
5357 	.tokens = {
5358 		(void *)&cmd_gso_enable_set,
5359 		(void *)&cmd_gso_enable_port,
5360 		(void *)&cmd_gso_enable_pid,
5361 		(void *)&cmd_gso_enable_keyword,
5362 		(void *)&cmd_gso_enable_mode,
5363 		NULL,
5364 	},
5365 };
5366 
5367 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5368 struct cmd_gso_size_result {
5369 	cmdline_fixed_string_t cmd_set;
5370 	cmdline_fixed_string_t cmd_keyword;
5371 	cmdline_fixed_string_t cmd_segsz;
5372 	uint16_t cmd_size;
5373 };
5374 
5375 static void
5376 cmd_gso_size_parsed(void *parsed_result,
5377 		       __rte_unused struct cmdline *cl,
5378 		       __rte_unused void *data)
5379 {
5380 	struct cmd_gso_size_result *res = parsed_result;
5381 
5382 	if (test_done == 0) {
5383 		fprintf(stderr,
5384 			"Before setting GSO segsz, please first stop forwarding\n");
5385 		return;
5386 	}
5387 
5388 	if (!strcmp(res->cmd_keyword, "gso") &&
5389 			!strcmp(res->cmd_segsz, "segsz")) {
5390 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5391 			fprintf(stderr,
5392 				"gso_size should be larger than %zu. Please input a legal value\n",
5393 				RTE_GSO_SEG_SIZE_MIN);
5394 		else
5395 			gso_max_segment_size = res->cmd_size;
5396 	}
5397 }
5398 
5399 cmdline_parse_token_string_t cmd_gso_size_set =
5400 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5401 				cmd_set, "set");
5402 cmdline_parse_token_string_t cmd_gso_size_keyword =
5403 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5404 				cmd_keyword, "gso");
5405 cmdline_parse_token_string_t cmd_gso_size_segsz =
5406 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5407 				cmd_segsz, "segsz");
5408 cmdline_parse_token_num_t cmd_gso_size_size =
5409 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5410 				cmd_size, RTE_UINT16);
5411 
5412 cmdline_parse_inst_t cmd_gso_size = {
5413 	.f = cmd_gso_size_parsed,
5414 	.data = NULL,
5415 	.help_str = "set gso segsz <length>",
5416 	.tokens = {
5417 		(void *)&cmd_gso_size_set,
5418 		(void *)&cmd_gso_size_keyword,
5419 		(void *)&cmd_gso_size_segsz,
5420 		(void *)&cmd_gso_size_size,
5421 		NULL,
5422 	},
5423 };
5424 
5425 /* *** SHOW GSO CONFIGURATION *** */
5426 struct cmd_gso_show_result {
5427 	cmdline_fixed_string_t cmd_show;
5428 	cmdline_fixed_string_t cmd_port;
5429 	cmdline_fixed_string_t cmd_keyword;
5430 	portid_t cmd_pid;
5431 };
5432 
5433 static void
5434 cmd_gso_show_parsed(void *parsed_result,
5435 		       __rte_unused struct cmdline *cl,
5436 		       __rte_unused void *data)
5437 {
5438 	struct cmd_gso_show_result *res = parsed_result;
5439 
5440 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5441 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5442 		return;
5443 	}
5444 	if (!strcmp(res->cmd_keyword, "gso")) {
5445 		if (gso_ports[res->cmd_pid].enable) {
5446 			printf("Max GSO'd packet size: %uB\n"
5447 					"Supported GSO types: TCP/IPv4, "
5448 					"UDP/IPv4, VxLAN with inner "
5449 					"TCP/IPv4 packet, GRE with inner "
5450 					"TCP/IPv4 packet\n",
5451 					gso_max_segment_size);
5452 		} else
5453 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5454 	}
5455 }
5456 
5457 cmdline_parse_token_string_t cmd_gso_show_show =
5458 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5459 		cmd_show, "show");
5460 cmdline_parse_token_string_t cmd_gso_show_port =
5461 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5462 		cmd_port, "port");
5463 cmdline_parse_token_string_t cmd_gso_show_keyword =
5464 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5465 				cmd_keyword, "gso");
5466 cmdline_parse_token_num_t cmd_gso_show_pid =
5467 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5468 				cmd_pid, RTE_UINT16);
5469 
5470 cmdline_parse_inst_t cmd_gso_show = {
5471 	.f = cmd_gso_show_parsed,
5472 	.data = NULL,
5473 	.help_str = "show port <port_id> gso",
5474 	.tokens = {
5475 		(void *)&cmd_gso_show_show,
5476 		(void *)&cmd_gso_show_port,
5477 		(void *)&cmd_gso_show_pid,
5478 		(void *)&cmd_gso_show_keyword,
5479 		NULL,
5480 	},
5481 };
5482 
5483 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5484 struct cmd_set_flush_rx {
5485 	cmdline_fixed_string_t set;
5486 	cmdline_fixed_string_t flush_rx;
5487 	cmdline_fixed_string_t mode;
5488 };
5489 
5490 static void
5491 cmd_set_flush_rx_parsed(void *parsed_result,
5492 		__rte_unused struct cmdline *cl,
5493 		__rte_unused void *data)
5494 {
5495 	struct cmd_set_flush_rx *res = parsed_result;
5496 
5497 	if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5498 		printf("multi-process doesn't support to flush Rx queues.\n");
5499 		return;
5500 	}
5501 
5502 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5503 }
5504 
5505 cmdline_parse_token_string_t cmd_setflushrx_set =
5506 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5507 			set, "set");
5508 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5509 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5510 			flush_rx, "flush_rx");
5511 cmdline_parse_token_string_t cmd_setflushrx_mode =
5512 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5513 			mode, "on#off");
5514 
5515 
5516 cmdline_parse_inst_t cmd_set_flush_rx = {
5517 	.f = cmd_set_flush_rx_parsed,
5518 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5519 	.data = NULL,
5520 	.tokens = {
5521 		(void *)&cmd_setflushrx_set,
5522 		(void *)&cmd_setflushrx_flush_rx,
5523 		(void *)&cmd_setflushrx_mode,
5524 		NULL,
5525 	},
5526 };
5527 
5528 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5529 struct cmd_set_link_check {
5530 	cmdline_fixed_string_t set;
5531 	cmdline_fixed_string_t link_check;
5532 	cmdline_fixed_string_t mode;
5533 };
5534 
5535 static void
5536 cmd_set_link_check_parsed(void *parsed_result,
5537 		__rte_unused struct cmdline *cl,
5538 		__rte_unused void *data)
5539 {
5540 	struct cmd_set_link_check *res = parsed_result;
5541 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5542 }
5543 
5544 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5545 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5546 			set, "set");
5547 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5548 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5549 			link_check, "link_check");
5550 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5551 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5552 			mode, "on#off");
5553 
5554 
5555 cmdline_parse_inst_t cmd_set_link_check = {
5556 	.f = cmd_set_link_check_parsed,
5557 	.help_str = "set link_check on|off: Enable/Disable link status check "
5558 	            "when starting/stopping a port",
5559 	.data = NULL,
5560 	.tokens = {
5561 		(void *)&cmd_setlinkcheck_set,
5562 		(void *)&cmd_setlinkcheck_link_check,
5563 		(void *)&cmd_setlinkcheck_mode,
5564 		NULL,
5565 	},
5566 };
5567 
5568 /* *** SET NIC BYPASS MODE *** */
5569 struct cmd_set_bypass_mode_result {
5570 	cmdline_fixed_string_t set;
5571 	cmdline_fixed_string_t bypass;
5572 	cmdline_fixed_string_t mode;
5573 	cmdline_fixed_string_t value;
5574 	portid_t port_id;
5575 };
5576 
5577 static void
5578 cmd_set_bypass_mode_parsed(void *parsed_result,
5579 		__rte_unused struct cmdline *cl,
5580 		__rte_unused void *data)
5581 {
5582 	struct cmd_set_bypass_mode_result *res = parsed_result;
5583 	portid_t port_id = res->port_id;
5584 	int32_t rc = -EINVAL;
5585 
5586 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5587 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5588 
5589 	if (!strcmp(res->value, "bypass"))
5590 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5591 	else if (!strcmp(res->value, "isolate"))
5592 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5593 	else
5594 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5595 
5596 	/* Set the bypass mode for the relevant port. */
5597 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5598 #endif
5599 	if (rc != 0)
5600 		fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5601 			port_id);
5602 }
5603 
5604 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5605 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5606 			set, "set");
5607 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5608 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5609 			bypass, "bypass");
5610 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5611 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5612 			mode, "mode");
5613 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5614 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5615 			value, "normal#bypass#isolate");
5616 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5617 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5618 				port_id, RTE_UINT16);
5619 
5620 cmdline_parse_inst_t cmd_set_bypass_mode = {
5621 	.f = cmd_set_bypass_mode_parsed,
5622 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5623 	            "Set the NIC bypass mode for port_id",
5624 	.data = NULL,
5625 	.tokens = {
5626 		(void *)&cmd_setbypass_mode_set,
5627 		(void *)&cmd_setbypass_mode_bypass,
5628 		(void *)&cmd_setbypass_mode_mode,
5629 		(void *)&cmd_setbypass_mode_value,
5630 		(void *)&cmd_setbypass_mode_port,
5631 		NULL,
5632 	},
5633 };
5634 
5635 /* *** SET NIC BYPASS EVENT *** */
5636 struct cmd_set_bypass_event_result {
5637 	cmdline_fixed_string_t set;
5638 	cmdline_fixed_string_t bypass;
5639 	cmdline_fixed_string_t event;
5640 	cmdline_fixed_string_t event_value;
5641 	cmdline_fixed_string_t mode;
5642 	cmdline_fixed_string_t mode_value;
5643 	portid_t port_id;
5644 };
5645 
5646 static void
5647 cmd_set_bypass_event_parsed(void *parsed_result,
5648 		__rte_unused struct cmdline *cl,
5649 		__rte_unused void *data)
5650 {
5651 	int32_t rc = -EINVAL;
5652 	struct cmd_set_bypass_event_result *res = parsed_result;
5653 	portid_t port_id = res->port_id;
5654 
5655 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5656 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5657 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5658 
5659 	if (!strcmp(res->event_value, "timeout"))
5660 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5661 	else if (!strcmp(res->event_value, "os_on"))
5662 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5663 	else if (!strcmp(res->event_value, "os_off"))
5664 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5665 	else if (!strcmp(res->event_value, "power_on"))
5666 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5667 	else if (!strcmp(res->event_value, "power_off"))
5668 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5669 	else
5670 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5671 
5672 	if (!strcmp(res->mode_value, "bypass"))
5673 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5674 	else if (!strcmp(res->mode_value, "isolate"))
5675 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5676 	else
5677 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5678 
5679 	/* Set the watchdog timeout. */
5680 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5681 
5682 		rc = -EINVAL;
5683 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5684 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5685 							   bypass_timeout);
5686 		}
5687 		if (rc != 0) {
5688 			fprintf(stderr,
5689 				"Failed to set timeout value %u for port %d, errto code: %d.\n",
5690 				bypass_timeout, port_id, rc);
5691 		}
5692 	}
5693 
5694 	/* Set the bypass event to transition to bypass mode. */
5695 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5696 					      bypass_mode);
5697 #endif
5698 
5699 	if (rc != 0)
5700 		fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5701 			port_id);
5702 }
5703 
5704 cmdline_parse_token_string_t cmd_setbypass_event_set =
5705 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5706 			set, "set");
5707 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5708 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5709 			bypass, "bypass");
5710 cmdline_parse_token_string_t cmd_setbypass_event_event =
5711 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5712 			event, "event");
5713 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5714 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5715 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5716 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5717 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5718 			mode, "mode");
5719 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5720 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5721 			mode_value, "normal#bypass#isolate");
5722 cmdline_parse_token_num_t cmd_setbypass_event_port =
5723 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5724 				port_id, RTE_UINT16);
5725 
5726 cmdline_parse_inst_t cmd_set_bypass_event = {
5727 	.f = cmd_set_bypass_event_parsed,
5728 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5729 		"power_off mode normal|bypass|isolate <port_id>: "
5730 		"Set the NIC bypass event mode for port_id",
5731 	.data = NULL,
5732 	.tokens = {
5733 		(void *)&cmd_setbypass_event_set,
5734 		(void *)&cmd_setbypass_event_bypass,
5735 		(void *)&cmd_setbypass_event_event,
5736 		(void *)&cmd_setbypass_event_event_value,
5737 		(void *)&cmd_setbypass_event_mode,
5738 		(void *)&cmd_setbypass_event_mode_value,
5739 		(void *)&cmd_setbypass_event_port,
5740 		NULL,
5741 	},
5742 };
5743 
5744 
5745 /* *** SET NIC BYPASS TIMEOUT *** */
5746 struct cmd_set_bypass_timeout_result {
5747 	cmdline_fixed_string_t set;
5748 	cmdline_fixed_string_t bypass;
5749 	cmdline_fixed_string_t timeout;
5750 	cmdline_fixed_string_t value;
5751 };
5752 
5753 static void
5754 cmd_set_bypass_timeout_parsed(void *parsed_result,
5755 		__rte_unused struct cmdline *cl,
5756 		__rte_unused void *data)
5757 {
5758 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5759 
5760 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5761 	if (!strcmp(res->value, "1.5"))
5762 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5763 	else if (!strcmp(res->value, "2"))
5764 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5765 	else if (!strcmp(res->value, "3"))
5766 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5767 	else if (!strcmp(res->value, "4"))
5768 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5769 	else if (!strcmp(res->value, "8"))
5770 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5771 	else if (!strcmp(res->value, "16"))
5772 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5773 	else if (!strcmp(res->value, "32"))
5774 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5775 	else
5776 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5777 #endif
5778 }
5779 
5780 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5781 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5782 			set, "set");
5783 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5784 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5785 			bypass, "bypass");
5786 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5787 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5788 			timeout, "timeout");
5789 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5790 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5791 			value, "0#1.5#2#3#4#8#16#32");
5792 
5793 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5794 	.f = cmd_set_bypass_timeout_parsed,
5795 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5796 		"Set the NIC bypass watchdog timeout in seconds",
5797 	.data = NULL,
5798 	.tokens = {
5799 		(void *)&cmd_setbypass_timeout_set,
5800 		(void *)&cmd_setbypass_timeout_bypass,
5801 		(void *)&cmd_setbypass_timeout_timeout,
5802 		(void *)&cmd_setbypass_timeout_value,
5803 		NULL,
5804 	},
5805 };
5806 
5807 /* *** SHOW NIC BYPASS MODE *** */
5808 struct cmd_show_bypass_config_result {
5809 	cmdline_fixed_string_t show;
5810 	cmdline_fixed_string_t bypass;
5811 	cmdline_fixed_string_t config;
5812 	portid_t port_id;
5813 };
5814 
5815 static void
5816 cmd_show_bypass_config_parsed(void *parsed_result,
5817 		__rte_unused struct cmdline *cl,
5818 		__rte_unused void *data)
5819 {
5820 	struct cmd_show_bypass_config_result *res = parsed_result;
5821 	portid_t port_id = res->port_id;
5822 	int rc = -EINVAL;
5823 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5824 	uint32_t event_mode;
5825 	uint32_t bypass_mode;
5826 	uint32_t timeout = bypass_timeout;
5827 	unsigned int i;
5828 
5829 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5830 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5831 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5832 		{"UNKNOWN", "normal", "bypass", "isolate"};
5833 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5834 		"NONE",
5835 		"OS/board on",
5836 		"power supply on",
5837 		"OS/board off",
5838 		"power supply off",
5839 		"timeout"};
5840 
5841 	/* Display the bypass mode.*/
5842 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5843 		fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5844 			port_id);
5845 		return;
5846 	}
5847 	else {
5848 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5849 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5850 
5851 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5852 	}
5853 
5854 	/* Display the bypass timeout.*/
5855 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5856 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5857 
5858 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5859 
5860 	/* Display the bypass events and associated modes. */
5861 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5862 
5863 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5864 			fprintf(stderr,
5865 				"\tFailed to get bypass mode for event = %s\n",
5866 				events[i]);
5867 		} else {
5868 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5869 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5870 
5871 			printf("\tbypass event: %-16s = %s\n", events[i],
5872 				modes[event_mode]);
5873 		}
5874 	}
5875 #endif
5876 	if (rc != 0)
5877 		fprintf(stderr,
5878 			"\tFailed to get bypass configuration for port = %d\n",
5879 		       port_id);
5880 }
5881 
5882 cmdline_parse_token_string_t cmd_showbypass_config_show =
5883 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5884 			show, "show");
5885 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5886 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5887 			bypass, "bypass");
5888 cmdline_parse_token_string_t cmd_showbypass_config_config =
5889 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5890 			config, "config");
5891 cmdline_parse_token_num_t cmd_showbypass_config_port =
5892 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5893 				port_id, RTE_UINT16);
5894 
5895 cmdline_parse_inst_t cmd_show_bypass_config = {
5896 	.f = cmd_show_bypass_config_parsed,
5897 	.help_str = "show bypass config <port_id>: "
5898 	            "Show the NIC bypass config for port_id",
5899 	.data = NULL,
5900 	.tokens = {
5901 		(void *)&cmd_showbypass_config_show,
5902 		(void *)&cmd_showbypass_config_bypass,
5903 		(void *)&cmd_showbypass_config_config,
5904 		(void *)&cmd_showbypass_config_port,
5905 		NULL,
5906 	},
5907 };
5908 
5909 #ifdef RTE_NET_BOND
5910 /* *** SET BONDING MODE *** */
5911 struct cmd_set_bonding_mode_result {
5912 	cmdline_fixed_string_t set;
5913 	cmdline_fixed_string_t bonding;
5914 	cmdline_fixed_string_t mode;
5915 	uint8_t value;
5916 	portid_t port_id;
5917 };
5918 
5919 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5920 		__rte_unused  struct cmdline *cl,
5921 		__rte_unused void *data)
5922 {
5923 	struct cmd_set_bonding_mode_result *res = parsed_result;
5924 	portid_t port_id = res->port_id;
5925 
5926 	/* Set the bonding mode for the relevant port. */
5927 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5928 		fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5929 			port_id);
5930 }
5931 
5932 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5933 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5934 		set, "set");
5935 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5936 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5937 		bonding, "bonding");
5938 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5940 		mode, "mode");
5941 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5942 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5943 		value, RTE_UINT8);
5944 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5945 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5946 		port_id, RTE_UINT16);
5947 
5948 cmdline_parse_inst_t cmd_set_bonding_mode = {
5949 		.f = cmd_set_bonding_mode_parsed,
5950 		.help_str = "set bonding mode <mode_value> <port_id>: "
5951 			"Set the bonding mode for port_id",
5952 		.data = NULL,
5953 		.tokens = {
5954 				(void *) &cmd_setbonding_mode_set,
5955 				(void *) &cmd_setbonding_mode_bonding,
5956 				(void *) &cmd_setbonding_mode_mode,
5957 				(void *) &cmd_setbonding_mode_value,
5958 				(void *) &cmd_setbonding_mode_port,
5959 				NULL
5960 		}
5961 };
5962 
5963 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5964 struct cmd_set_bonding_lacp_dedicated_queues_result {
5965 	cmdline_fixed_string_t set;
5966 	cmdline_fixed_string_t bonding;
5967 	cmdline_fixed_string_t lacp;
5968 	cmdline_fixed_string_t dedicated_queues;
5969 	portid_t port_id;
5970 	cmdline_fixed_string_t mode;
5971 };
5972 
5973 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5974 		__rte_unused  struct cmdline *cl,
5975 		__rte_unused void *data)
5976 {
5977 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5978 	portid_t port_id = res->port_id;
5979 	struct rte_port *port;
5980 
5981 	port = &ports[port_id];
5982 
5983 	/** Check if the port is not started **/
5984 	if (port->port_status != RTE_PORT_STOPPED) {
5985 		fprintf(stderr, "Please stop port %d first\n", port_id);
5986 		return;
5987 	}
5988 
5989 	if (!strcmp(res->mode, "enable")) {
5990 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5991 			printf("Dedicate queues for LACP control packets"
5992 					" enabled\n");
5993 		else
5994 			printf("Enabling dedicate queues for LACP control "
5995 					"packets on port %d failed\n", port_id);
5996 	} else if (!strcmp(res->mode, "disable")) {
5997 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5998 			printf("Dedicated queues for LACP control packets "
5999 					"disabled\n");
6000 		else
6001 			printf("Disabling dedicated queues for LACP control "
6002 					"traffic on port %d failed\n", port_id);
6003 	}
6004 }
6005 
6006 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6007 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6008 		set, "set");
6009 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6011 		bonding, "bonding");
6012 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6014 		lacp, "lacp");
6015 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6017 		dedicated_queues, "dedicated_queues");
6018 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6019 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6020 		port_id, RTE_UINT16);
6021 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6023 		mode, "enable#disable");
6024 
6025 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6026 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6027 		.help_str = "set bonding lacp dedicated_queues <port_id> "
6028 			"enable|disable: "
6029 			"Enable/disable dedicated queues for LACP control traffic for port_id",
6030 		.data = NULL,
6031 		.tokens = {
6032 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
6033 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6034 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6035 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6036 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6037 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6038 			NULL
6039 		}
6040 };
6041 
6042 /* *** SET BALANCE XMIT POLICY *** */
6043 struct cmd_set_bonding_balance_xmit_policy_result {
6044 	cmdline_fixed_string_t set;
6045 	cmdline_fixed_string_t bonding;
6046 	cmdline_fixed_string_t balance_xmit_policy;
6047 	portid_t port_id;
6048 	cmdline_fixed_string_t policy;
6049 };
6050 
6051 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6052 		__rte_unused  struct cmdline *cl,
6053 		__rte_unused void *data)
6054 {
6055 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6056 	portid_t port_id = res->port_id;
6057 	uint8_t policy;
6058 
6059 	if (!strcmp(res->policy, "l2")) {
6060 		policy = BALANCE_XMIT_POLICY_LAYER2;
6061 	} else if (!strcmp(res->policy, "l23")) {
6062 		policy = BALANCE_XMIT_POLICY_LAYER23;
6063 	} else if (!strcmp(res->policy, "l34")) {
6064 		policy = BALANCE_XMIT_POLICY_LAYER34;
6065 	} else {
6066 		fprintf(stderr, "\t Invalid xmit policy selection");
6067 		return;
6068 	}
6069 
6070 	/* Set the bonding mode for the relevant port. */
6071 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6072 		fprintf(stderr,
6073 			"\t Failed to set bonding balance xmit policy for port = %d.\n",
6074 			port_id);
6075 	}
6076 }
6077 
6078 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6079 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6080 		set, "set");
6081 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6082 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6083 		bonding, "bonding");
6084 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6086 		balance_xmit_policy, "balance_xmit_policy");
6087 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6088 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6089 		port_id, RTE_UINT16);
6090 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6092 		policy, "l2#l23#l34");
6093 
6094 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6095 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
6096 		.help_str = "set bonding balance_xmit_policy <port_id> "
6097 			"l2|l23|l34: "
6098 			"Set the bonding balance_xmit_policy for port_id",
6099 		.data = NULL,
6100 		.tokens = {
6101 				(void *)&cmd_setbonding_balance_xmit_policy_set,
6102 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
6103 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6104 				(void *)&cmd_setbonding_balance_xmit_policy_port,
6105 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
6106 				NULL
6107 		}
6108 };
6109 
6110 /* *** SHOW NIC BONDING CONFIGURATION *** */
6111 struct cmd_show_bonding_config_result {
6112 	cmdline_fixed_string_t show;
6113 	cmdline_fixed_string_t bonding;
6114 	cmdline_fixed_string_t config;
6115 	portid_t port_id;
6116 };
6117 
6118 static void cmd_show_bonding_config_parsed(void *parsed_result,
6119 		__rte_unused  struct cmdline *cl,
6120 		__rte_unused void *data)
6121 {
6122 	struct cmd_show_bonding_config_result *res = parsed_result;
6123 	int bonding_mode, agg_mode;
6124 	portid_t slaves[RTE_MAX_ETHPORTS];
6125 	int num_slaves, num_active_slaves;
6126 	int primary_id;
6127 	int i;
6128 	portid_t port_id = res->port_id;
6129 
6130 	/* Display the bonding mode.*/
6131 	bonding_mode = rte_eth_bond_mode_get(port_id);
6132 	if (bonding_mode < 0) {
6133 		fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6134 			port_id);
6135 		return;
6136 	} else
6137 		printf("\tBonding mode: %d\n", bonding_mode);
6138 
6139 	if (bonding_mode == BONDING_MODE_BALANCE) {
6140 		int balance_xmit_policy;
6141 
6142 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6143 		if (balance_xmit_policy < 0) {
6144 			fprintf(stderr,
6145 				"\tFailed to get balance xmit policy for port = %d\n",
6146 				port_id);
6147 			return;
6148 		} else {
6149 			printf("\tBalance Xmit Policy: ");
6150 
6151 			switch (balance_xmit_policy) {
6152 			case BALANCE_XMIT_POLICY_LAYER2:
6153 				printf("BALANCE_XMIT_POLICY_LAYER2");
6154 				break;
6155 			case BALANCE_XMIT_POLICY_LAYER23:
6156 				printf("BALANCE_XMIT_POLICY_LAYER23");
6157 				break;
6158 			case BALANCE_XMIT_POLICY_LAYER34:
6159 				printf("BALANCE_XMIT_POLICY_LAYER34");
6160 				break;
6161 			}
6162 			printf("\n");
6163 		}
6164 	}
6165 
6166 	if (bonding_mode == BONDING_MODE_8023AD) {
6167 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6168 		printf("\tIEEE802.3AD Aggregator Mode: ");
6169 		switch (agg_mode) {
6170 		case AGG_BANDWIDTH:
6171 			printf("bandwidth");
6172 			break;
6173 		case AGG_STABLE:
6174 			printf("stable");
6175 			break;
6176 		case AGG_COUNT:
6177 			printf("count");
6178 			break;
6179 		}
6180 		printf("\n");
6181 	}
6182 
6183 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6184 
6185 	if (num_slaves < 0) {
6186 		fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6187 			port_id);
6188 		return;
6189 	}
6190 	if (num_slaves > 0) {
6191 		printf("\tSlaves (%d): [", num_slaves);
6192 		for (i = 0; i < num_slaves - 1; i++)
6193 			printf("%d ", slaves[i]);
6194 
6195 		printf("%d]\n", slaves[num_slaves - 1]);
6196 	} else {
6197 		printf("\tSlaves: []\n");
6198 
6199 	}
6200 
6201 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6202 			RTE_MAX_ETHPORTS);
6203 
6204 	if (num_active_slaves < 0) {
6205 		fprintf(stderr,
6206 			"\tFailed to get active slave list for port = %d\n",
6207 			port_id);
6208 		return;
6209 	}
6210 	if (num_active_slaves > 0) {
6211 		printf("\tActive Slaves (%d): [", num_active_slaves);
6212 		for (i = 0; i < num_active_slaves - 1; i++)
6213 			printf("%d ", slaves[i]);
6214 
6215 		printf("%d]\n", slaves[num_active_slaves - 1]);
6216 
6217 	} else {
6218 		printf("\tActive Slaves: []\n");
6219 
6220 	}
6221 
6222 	primary_id = rte_eth_bond_primary_get(port_id);
6223 	if (primary_id < 0) {
6224 		fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6225 			port_id);
6226 		return;
6227 	} else
6228 		printf("\tPrimary: [%d]\n", primary_id);
6229 
6230 }
6231 
6232 cmdline_parse_token_string_t cmd_showbonding_config_show =
6233 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6234 		show, "show");
6235 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6236 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6237 		bonding, "bonding");
6238 cmdline_parse_token_string_t cmd_showbonding_config_config =
6239 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6240 		config, "config");
6241 cmdline_parse_token_num_t cmd_showbonding_config_port =
6242 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6243 		port_id, RTE_UINT16);
6244 
6245 cmdline_parse_inst_t cmd_show_bonding_config = {
6246 		.f = cmd_show_bonding_config_parsed,
6247 		.help_str = "show bonding config <port_id>: "
6248 			"Show the bonding config for port_id",
6249 		.data = NULL,
6250 		.tokens = {
6251 				(void *)&cmd_showbonding_config_show,
6252 				(void *)&cmd_showbonding_config_bonding,
6253 				(void *)&cmd_showbonding_config_config,
6254 				(void *)&cmd_showbonding_config_port,
6255 				NULL
6256 		}
6257 };
6258 
6259 /* *** SET BONDING PRIMARY *** */
6260 struct cmd_set_bonding_primary_result {
6261 	cmdline_fixed_string_t set;
6262 	cmdline_fixed_string_t bonding;
6263 	cmdline_fixed_string_t primary;
6264 	portid_t slave_id;
6265 	portid_t port_id;
6266 };
6267 
6268 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6269 		__rte_unused  struct cmdline *cl,
6270 		__rte_unused void *data)
6271 {
6272 	struct cmd_set_bonding_primary_result *res = parsed_result;
6273 	portid_t master_port_id = res->port_id;
6274 	portid_t slave_port_id = res->slave_id;
6275 
6276 	/* Set the primary slave for a bonded device. */
6277 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6278 		fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6279 			master_port_id);
6280 		return;
6281 	}
6282 	init_port_config();
6283 }
6284 
6285 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6287 		set, "set");
6288 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6289 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6290 		bonding, "bonding");
6291 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6292 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6293 		primary, "primary");
6294 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6295 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6296 		slave_id, RTE_UINT16);
6297 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6298 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6299 		port_id, RTE_UINT16);
6300 
6301 cmdline_parse_inst_t cmd_set_bonding_primary = {
6302 		.f = cmd_set_bonding_primary_parsed,
6303 		.help_str = "set bonding primary <slave_id> <port_id>: "
6304 			"Set the primary slave for port_id",
6305 		.data = NULL,
6306 		.tokens = {
6307 				(void *)&cmd_setbonding_primary_set,
6308 				(void *)&cmd_setbonding_primary_bonding,
6309 				(void *)&cmd_setbonding_primary_primary,
6310 				(void *)&cmd_setbonding_primary_slave,
6311 				(void *)&cmd_setbonding_primary_port,
6312 				NULL
6313 		}
6314 };
6315 
6316 /* *** ADD SLAVE *** */
6317 struct cmd_add_bonding_slave_result {
6318 	cmdline_fixed_string_t add;
6319 	cmdline_fixed_string_t bonding;
6320 	cmdline_fixed_string_t slave;
6321 	portid_t slave_id;
6322 	portid_t port_id;
6323 };
6324 
6325 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6326 		__rte_unused  struct cmdline *cl,
6327 		__rte_unused void *data)
6328 {
6329 	struct cmd_add_bonding_slave_result *res = parsed_result;
6330 	portid_t master_port_id = res->port_id;
6331 	portid_t slave_port_id = res->slave_id;
6332 
6333 	/* add the slave for a bonded device. */
6334 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6335 		fprintf(stderr,
6336 			"\t Failed to add slave %d to master port = %d.\n",
6337 			slave_port_id, master_port_id);
6338 		return;
6339 	}
6340 	init_port_config();
6341 	set_port_slave_flag(slave_port_id);
6342 }
6343 
6344 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6345 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6346 		add, "add");
6347 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6348 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6349 		bonding, "bonding");
6350 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6351 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6352 		slave, "slave");
6353 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6354 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6355 		slave_id, RTE_UINT16);
6356 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6357 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6358 		port_id, RTE_UINT16);
6359 
6360 cmdline_parse_inst_t cmd_add_bonding_slave = {
6361 		.f = cmd_add_bonding_slave_parsed,
6362 		.help_str = "add bonding slave <slave_id> <port_id>: "
6363 			"Add a slave device to a bonded device",
6364 		.data = NULL,
6365 		.tokens = {
6366 				(void *)&cmd_addbonding_slave_add,
6367 				(void *)&cmd_addbonding_slave_bonding,
6368 				(void *)&cmd_addbonding_slave_slave,
6369 				(void *)&cmd_addbonding_slave_slaveid,
6370 				(void *)&cmd_addbonding_slave_port,
6371 				NULL
6372 		}
6373 };
6374 
6375 /* *** REMOVE SLAVE *** */
6376 struct cmd_remove_bonding_slave_result {
6377 	cmdline_fixed_string_t remove;
6378 	cmdline_fixed_string_t bonding;
6379 	cmdline_fixed_string_t slave;
6380 	portid_t slave_id;
6381 	portid_t port_id;
6382 };
6383 
6384 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6385 		__rte_unused  struct cmdline *cl,
6386 		__rte_unused void *data)
6387 {
6388 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6389 	portid_t master_port_id = res->port_id;
6390 	portid_t slave_port_id = res->slave_id;
6391 
6392 	/* remove the slave from a bonded device. */
6393 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6394 		fprintf(stderr,
6395 			"\t Failed to remove slave %d from master port = %d.\n",
6396 			slave_port_id, master_port_id);
6397 		return;
6398 	}
6399 	init_port_config();
6400 	clear_port_slave_flag(slave_port_id);
6401 }
6402 
6403 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6404 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6405 				remove, "remove");
6406 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6407 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6408 				bonding, "bonding");
6409 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6410 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6411 				slave, "slave");
6412 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6413 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6414 				slave_id, RTE_UINT16);
6415 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6416 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6417 				port_id, RTE_UINT16);
6418 
6419 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6420 		.f = cmd_remove_bonding_slave_parsed,
6421 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6422 			"Remove a slave device from a bonded device",
6423 		.data = NULL,
6424 		.tokens = {
6425 				(void *)&cmd_removebonding_slave_remove,
6426 				(void *)&cmd_removebonding_slave_bonding,
6427 				(void *)&cmd_removebonding_slave_slave,
6428 				(void *)&cmd_removebonding_slave_slaveid,
6429 				(void *)&cmd_removebonding_slave_port,
6430 				NULL
6431 		}
6432 };
6433 
6434 /* *** CREATE BONDED DEVICE *** */
6435 struct cmd_create_bonded_device_result {
6436 	cmdline_fixed_string_t create;
6437 	cmdline_fixed_string_t bonded;
6438 	cmdline_fixed_string_t device;
6439 	uint8_t mode;
6440 	uint8_t socket;
6441 };
6442 
6443 static int bond_dev_num = 0;
6444 
6445 static void cmd_create_bonded_device_parsed(void *parsed_result,
6446 		__rte_unused  struct cmdline *cl,
6447 		__rte_unused void *data)
6448 {
6449 	struct cmd_create_bonded_device_result *res = parsed_result;
6450 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6451 	int port_id;
6452 	int ret;
6453 
6454 	if (test_done == 0) {
6455 		fprintf(stderr, "Please stop forwarding first\n");
6456 		return;
6457 	}
6458 
6459 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6460 			bond_dev_num++);
6461 
6462 	/* Create a new bonded device. */
6463 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6464 	if (port_id < 0) {
6465 		fprintf(stderr, "\t Failed to create bonded device.\n");
6466 		return;
6467 	} else {
6468 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6469 				port_id);
6470 
6471 		/* Update number of ports */
6472 		nb_ports = rte_eth_dev_count_avail();
6473 		reconfig(port_id, res->socket);
6474 		ret = rte_eth_promiscuous_enable(port_id);
6475 		if (ret != 0)
6476 			fprintf(stderr,
6477 				"Failed to enable promiscuous mode for port %u: %s - ignore\n",
6478 				port_id, rte_strerror(-ret));
6479 
6480 		ports[port_id].need_setup = 0;
6481 		ports[port_id].port_status = RTE_PORT_STOPPED;
6482 	}
6483 
6484 }
6485 
6486 cmdline_parse_token_string_t cmd_createbonded_device_create =
6487 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6488 				create, "create");
6489 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6490 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6491 				bonded, "bonded");
6492 cmdline_parse_token_string_t cmd_createbonded_device_device =
6493 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6494 				device, "device");
6495 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6496 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6497 				mode, RTE_UINT8);
6498 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6499 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6500 				socket, RTE_UINT8);
6501 
6502 cmdline_parse_inst_t cmd_create_bonded_device = {
6503 		.f = cmd_create_bonded_device_parsed,
6504 		.help_str = "create bonded device <mode> <socket>: "
6505 			"Create a new bonded device with specific bonding mode and socket",
6506 		.data = NULL,
6507 		.tokens = {
6508 				(void *)&cmd_createbonded_device_create,
6509 				(void *)&cmd_createbonded_device_bonded,
6510 				(void *)&cmd_createbonded_device_device,
6511 				(void *)&cmd_createbonded_device_mode,
6512 				(void *)&cmd_createbonded_device_socket,
6513 				NULL
6514 		}
6515 };
6516 
6517 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6518 struct cmd_set_bond_mac_addr_result {
6519 	cmdline_fixed_string_t set;
6520 	cmdline_fixed_string_t bonding;
6521 	cmdline_fixed_string_t mac_addr;
6522 	uint16_t port_num;
6523 	struct rte_ether_addr address;
6524 };
6525 
6526 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6527 		__rte_unused  struct cmdline *cl,
6528 		__rte_unused void *data)
6529 {
6530 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6531 	int ret;
6532 
6533 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6534 		return;
6535 
6536 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6537 
6538 	/* check the return value and print it if is < 0 */
6539 	if (ret < 0)
6540 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6541 			strerror(-ret));
6542 }
6543 
6544 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6545 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6546 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6547 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6548 				"bonding");
6549 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6550 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6551 				"mac_addr");
6552 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6553 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6554 				port_num, RTE_UINT16);
6555 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6556 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6557 
6558 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6559 		.f = cmd_set_bond_mac_addr_parsed,
6560 		.data = (void *) 0,
6561 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6562 		.tokens = {
6563 				(void *)&cmd_set_bond_mac_addr_set,
6564 				(void *)&cmd_set_bond_mac_addr_bonding,
6565 				(void *)&cmd_set_bond_mac_addr_mac,
6566 				(void *)&cmd_set_bond_mac_addr_portnum,
6567 				(void *)&cmd_set_bond_mac_addr_addr,
6568 				NULL
6569 		}
6570 };
6571 
6572 
6573 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6574 struct cmd_set_bond_mon_period_result {
6575 	cmdline_fixed_string_t set;
6576 	cmdline_fixed_string_t bonding;
6577 	cmdline_fixed_string_t mon_period;
6578 	uint16_t port_num;
6579 	uint32_t period_ms;
6580 };
6581 
6582 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6583 		__rte_unused  struct cmdline *cl,
6584 		__rte_unused void *data)
6585 {
6586 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6587 	int ret;
6588 
6589 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6590 
6591 	/* check the return value and print it if is < 0 */
6592 	if (ret < 0)
6593 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6594 			strerror(-ret));
6595 }
6596 
6597 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6598 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6599 				set, "set");
6600 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6601 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6602 				bonding, "bonding");
6603 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6604 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6605 				mon_period,	"mon_period");
6606 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6607 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6608 				port_num, RTE_UINT16);
6609 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6610 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6611 				period_ms, RTE_UINT32);
6612 
6613 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6614 		.f = cmd_set_bond_mon_period_parsed,
6615 		.data = (void *) 0,
6616 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6617 		.tokens = {
6618 				(void *)&cmd_set_bond_mon_period_set,
6619 				(void *)&cmd_set_bond_mon_period_bonding,
6620 				(void *)&cmd_set_bond_mon_period_mon_period,
6621 				(void *)&cmd_set_bond_mon_period_portnum,
6622 				(void *)&cmd_set_bond_mon_period_period_ms,
6623 				NULL
6624 		}
6625 };
6626 
6627 
6628 
6629 struct cmd_set_bonding_agg_mode_policy_result {
6630 	cmdline_fixed_string_t set;
6631 	cmdline_fixed_string_t bonding;
6632 	cmdline_fixed_string_t agg_mode;
6633 	uint16_t port_num;
6634 	cmdline_fixed_string_t policy;
6635 };
6636 
6637 
6638 static void
6639 cmd_set_bonding_agg_mode(void *parsed_result,
6640 		__rte_unused struct cmdline *cl,
6641 		__rte_unused void *data)
6642 {
6643 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6644 	uint8_t policy = AGG_BANDWIDTH;
6645 
6646 	if (!strcmp(res->policy, "bandwidth"))
6647 		policy = AGG_BANDWIDTH;
6648 	else if (!strcmp(res->policy, "stable"))
6649 		policy = AGG_STABLE;
6650 	else if (!strcmp(res->policy, "count"))
6651 		policy = AGG_COUNT;
6652 
6653 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6654 }
6655 
6656 
6657 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6658 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6659 				set, "set");
6660 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6661 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6662 				bonding, "bonding");
6663 
6664 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6665 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6666 				agg_mode, "agg_mode");
6667 
6668 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6669 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6670 				port_num, RTE_UINT16);
6671 
6672 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6673 	TOKEN_STRING_INITIALIZER(
6674 			struct cmd_set_bonding_balance_xmit_policy_result,
6675 		policy, "stable#bandwidth#count");
6676 
6677 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6678 	.f = cmd_set_bonding_agg_mode,
6679 	.data = (void *) 0,
6680 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6681 	.tokens = {
6682 			(void *)&cmd_set_bonding_agg_mode_set,
6683 			(void *)&cmd_set_bonding_agg_mode_bonding,
6684 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6685 			(void *)&cmd_set_bonding_agg_mode_portnum,
6686 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6687 			NULL
6688 		}
6689 };
6690 
6691 
6692 #endif /* RTE_NET_BOND */
6693 
6694 /* *** SET FORWARDING MODE *** */
6695 struct cmd_set_fwd_mode_result {
6696 	cmdline_fixed_string_t set;
6697 	cmdline_fixed_string_t fwd;
6698 	cmdline_fixed_string_t mode;
6699 };
6700 
6701 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6702 				    __rte_unused struct cmdline *cl,
6703 				    __rte_unused void *data)
6704 {
6705 	struct cmd_set_fwd_mode_result *res = parsed_result;
6706 
6707 	retry_enabled = 0;
6708 	set_pkt_forwarding_mode(res->mode);
6709 }
6710 
6711 cmdline_parse_token_string_t cmd_setfwd_set =
6712 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6713 cmdline_parse_token_string_t cmd_setfwd_fwd =
6714 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6715 cmdline_parse_token_string_t cmd_setfwd_mode =
6716 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6717 		"" /* defined at init */);
6718 
6719 cmdline_parse_inst_t cmd_set_fwd_mode = {
6720 	.f = cmd_set_fwd_mode_parsed,
6721 	.data = NULL,
6722 	.help_str = NULL, /* defined at init */
6723 	.tokens = {
6724 		(void *)&cmd_setfwd_set,
6725 		(void *)&cmd_setfwd_fwd,
6726 		(void *)&cmd_setfwd_mode,
6727 		NULL,
6728 	},
6729 };
6730 
6731 static void cmd_set_fwd_mode_init(void)
6732 {
6733 	char *modes, *c;
6734 	static char token[128];
6735 	static char help[256];
6736 	cmdline_parse_token_string_t *token_struct;
6737 
6738 	modes = list_pkt_forwarding_modes();
6739 	snprintf(help, sizeof(help), "set fwd %s: "
6740 		"Set packet forwarding mode", modes);
6741 	cmd_set_fwd_mode.help_str = help;
6742 
6743 	/* string token separator is # */
6744 	for (c = token; *modes != '\0'; modes++)
6745 		if (*modes == '|')
6746 			*c++ = '#';
6747 		else
6748 			*c++ = *modes;
6749 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6750 	token_struct->string_data.str = token;
6751 }
6752 
6753 /* *** SET RETRY FORWARDING MODE *** */
6754 struct cmd_set_fwd_retry_mode_result {
6755 	cmdline_fixed_string_t set;
6756 	cmdline_fixed_string_t fwd;
6757 	cmdline_fixed_string_t mode;
6758 	cmdline_fixed_string_t retry;
6759 };
6760 
6761 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6762 			    __rte_unused struct cmdline *cl,
6763 			    __rte_unused void *data)
6764 {
6765 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6766 
6767 	retry_enabled = 1;
6768 	set_pkt_forwarding_mode(res->mode);
6769 }
6770 
6771 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6772 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6773 			set, "set");
6774 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6775 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6776 			fwd, "fwd");
6777 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6778 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6779 			mode,
6780 		"" /* defined at init */);
6781 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6782 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6783 			retry, "retry");
6784 
6785 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6786 	.f = cmd_set_fwd_retry_mode_parsed,
6787 	.data = NULL,
6788 	.help_str = NULL, /* defined at init */
6789 	.tokens = {
6790 		(void *)&cmd_setfwd_retry_set,
6791 		(void *)&cmd_setfwd_retry_fwd,
6792 		(void *)&cmd_setfwd_retry_mode,
6793 		(void *)&cmd_setfwd_retry_retry,
6794 		NULL,
6795 	},
6796 };
6797 
6798 static void cmd_set_fwd_retry_mode_init(void)
6799 {
6800 	char *modes, *c;
6801 	static char token[128];
6802 	static char help[256];
6803 	cmdline_parse_token_string_t *token_struct;
6804 
6805 	modes = list_pkt_forwarding_retry_modes();
6806 	snprintf(help, sizeof(help), "set fwd %s retry: "
6807 		"Set packet forwarding mode with retry", modes);
6808 	cmd_set_fwd_retry_mode.help_str = help;
6809 
6810 	/* string token separator is # */
6811 	for (c = token; *modes != '\0'; modes++)
6812 		if (*modes == '|')
6813 			*c++ = '#';
6814 		else
6815 			*c++ = *modes;
6816 	token_struct = (cmdline_parse_token_string_t *)
6817 		cmd_set_fwd_retry_mode.tokens[2];
6818 	token_struct->string_data.str = token;
6819 }
6820 
6821 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6822 struct cmd_set_burst_tx_retry_result {
6823 	cmdline_fixed_string_t set;
6824 	cmdline_fixed_string_t burst;
6825 	cmdline_fixed_string_t tx;
6826 	cmdline_fixed_string_t delay;
6827 	uint32_t time;
6828 	cmdline_fixed_string_t retry;
6829 	uint32_t retry_num;
6830 };
6831 
6832 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6833 					__rte_unused struct cmdline *cl,
6834 					__rte_unused void *data)
6835 {
6836 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6837 
6838 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6839 		&& !strcmp(res->tx, "tx")) {
6840 		if (!strcmp(res->delay, "delay"))
6841 			burst_tx_delay_time = res->time;
6842 		if (!strcmp(res->retry, "retry"))
6843 			burst_tx_retry_num = res->retry_num;
6844 	}
6845 
6846 }
6847 
6848 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6849 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6850 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6851 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6852 				 "burst");
6853 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6854 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6855 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6856 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6857 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6858 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6859 				 RTE_UINT32);
6860 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6861 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6862 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6863 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6864 				 RTE_UINT32);
6865 
6866 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6867 	.f = cmd_set_burst_tx_retry_parsed,
6868 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6869 	.tokens = {
6870 		(void *)&cmd_set_burst_tx_retry_set,
6871 		(void *)&cmd_set_burst_tx_retry_burst,
6872 		(void *)&cmd_set_burst_tx_retry_tx,
6873 		(void *)&cmd_set_burst_tx_retry_delay,
6874 		(void *)&cmd_set_burst_tx_retry_time,
6875 		(void *)&cmd_set_burst_tx_retry_retry,
6876 		(void *)&cmd_set_burst_tx_retry_retry_num,
6877 		NULL,
6878 	},
6879 };
6880 
6881 /* *** SET PROMISC MODE *** */
6882 struct cmd_set_promisc_mode_result {
6883 	cmdline_fixed_string_t set;
6884 	cmdline_fixed_string_t promisc;
6885 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6886 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6887 	cmdline_fixed_string_t mode;
6888 };
6889 
6890 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6891 					__rte_unused struct cmdline *cl,
6892 					void *allports)
6893 {
6894 	struct cmd_set_promisc_mode_result *res = parsed_result;
6895 	int enable;
6896 	portid_t i;
6897 
6898 	if (!strcmp(res->mode, "on"))
6899 		enable = 1;
6900 	else
6901 		enable = 0;
6902 
6903 	/* all ports */
6904 	if (allports) {
6905 		RTE_ETH_FOREACH_DEV(i)
6906 			eth_set_promisc_mode(i, enable);
6907 	} else {
6908 		eth_set_promisc_mode(res->port_num, enable);
6909 	}
6910 }
6911 
6912 cmdline_parse_token_string_t cmd_setpromisc_set =
6913 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6914 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6915 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6916 				 "promisc");
6917 cmdline_parse_token_string_t cmd_setpromisc_portall =
6918 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6919 				 "all");
6920 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6921 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6922 			      RTE_UINT16);
6923 cmdline_parse_token_string_t cmd_setpromisc_mode =
6924 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6925 				 "on#off");
6926 
6927 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6928 	.f = cmd_set_promisc_mode_parsed,
6929 	.data = (void *)1,
6930 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6931 	.tokens = {
6932 		(void *)&cmd_setpromisc_set,
6933 		(void *)&cmd_setpromisc_promisc,
6934 		(void *)&cmd_setpromisc_portall,
6935 		(void *)&cmd_setpromisc_mode,
6936 		NULL,
6937 	},
6938 };
6939 
6940 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6941 	.f = cmd_set_promisc_mode_parsed,
6942 	.data = (void *)0,
6943 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6944 	.tokens = {
6945 		(void *)&cmd_setpromisc_set,
6946 		(void *)&cmd_setpromisc_promisc,
6947 		(void *)&cmd_setpromisc_portnum,
6948 		(void *)&cmd_setpromisc_mode,
6949 		NULL,
6950 	},
6951 };
6952 
6953 /* *** SET ALLMULTI MODE *** */
6954 struct cmd_set_allmulti_mode_result {
6955 	cmdline_fixed_string_t set;
6956 	cmdline_fixed_string_t allmulti;
6957 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6958 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6959 	cmdline_fixed_string_t mode;
6960 };
6961 
6962 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6963 					__rte_unused struct cmdline *cl,
6964 					void *allports)
6965 {
6966 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6967 	int enable;
6968 	portid_t i;
6969 
6970 	if (!strcmp(res->mode, "on"))
6971 		enable = 1;
6972 	else
6973 		enable = 0;
6974 
6975 	/* all ports */
6976 	if (allports) {
6977 		RTE_ETH_FOREACH_DEV(i) {
6978 			eth_set_allmulticast_mode(i, enable);
6979 		}
6980 	}
6981 	else {
6982 		eth_set_allmulticast_mode(res->port_num, enable);
6983 	}
6984 }
6985 
6986 cmdline_parse_token_string_t cmd_setallmulti_set =
6987 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6988 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6989 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6990 				 "allmulti");
6991 cmdline_parse_token_string_t cmd_setallmulti_portall =
6992 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6993 				 "all");
6994 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6995 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6996 			      RTE_UINT16);
6997 cmdline_parse_token_string_t cmd_setallmulti_mode =
6998 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6999 				 "on#off");
7000 
7001 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7002 	.f = cmd_set_allmulti_mode_parsed,
7003 	.data = (void *)1,
7004 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7005 	.tokens = {
7006 		(void *)&cmd_setallmulti_set,
7007 		(void *)&cmd_setallmulti_allmulti,
7008 		(void *)&cmd_setallmulti_portall,
7009 		(void *)&cmd_setallmulti_mode,
7010 		NULL,
7011 	},
7012 };
7013 
7014 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7015 	.f = cmd_set_allmulti_mode_parsed,
7016 	.data = (void *)0,
7017 	.help_str = "set allmulti <port_id> on|off: "
7018 		"Set allmulti mode on port_id",
7019 	.tokens = {
7020 		(void *)&cmd_setallmulti_set,
7021 		(void *)&cmd_setallmulti_allmulti,
7022 		(void *)&cmd_setallmulti_portnum,
7023 		(void *)&cmd_setallmulti_mode,
7024 		NULL,
7025 	},
7026 };
7027 
7028 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7029 struct cmd_link_flow_ctrl_show {
7030 	cmdline_fixed_string_t show;
7031 	cmdline_fixed_string_t port;
7032 	portid_t port_id;
7033 	cmdline_fixed_string_t flow_ctrl;
7034 };
7035 
7036 cmdline_parse_token_string_t cmd_lfc_show_show =
7037 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7038 				show, "show");
7039 cmdline_parse_token_string_t cmd_lfc_show_port =
7040 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7041 				port, "port");
7042 cmdline_parse_token_num_t cmd_lfc_show_portid =
7043 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7044 				port_id, RTE_UINT16);
7045 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7046 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7047 				flow_ctrl, "flow_ctrl");
7048 
7049 static void
7050 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7051 			      __rte_unused struct cmdline *cl,
7052 			      __rte_unused void *data)
7053 {
7054 	struct cmd_link_flow_ctrl_show *res = parsed_result;
7055 	static const char *info_border = "*********************";
7056 	struct rte_eth_fc_conf fc_conf;
7057 	bool rx_fc_en = false;
7058 	bool tx_fc_en = false;
7059 	int ret;
7060 
7061 	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7062 	if (ret != 0) {
7063 		fprintf(stderr,
7064 			"Failed to get current flow ctrl information: err = %d\n",
7065 			ret);
7066 		return;
7067 	}
7068 
7069 	if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7070 		rx_fc_en = true;
7071 	if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7072 		tx_fc_en = true;
7073 
7074 	printf("\n%s Flow control infos for port %-2d %s\n",
7075 		info_border, res->port_id, info_border);
7076 	printf("FC mode:\n");
7077 	printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
7078 	printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
7079 	printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7080 	printf("Pause time: 0x%x\n", fc_conf.pause_time);
7081 	printf("High waterline: 0x%x\n", fc_conf.high_water);
7082 	printf("Low waterline: 0x%x\n", fc_conf.low_water);
7083 	printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7084 	printf("Forward MAC control frames: %s\n",
7085 		fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7086 	printf("\n%s**************   End  ***********%s\n",
7087 		info_border, info_border);
7088 }
7089 
7090 cmdline_parse_inst_t cmd_link_flow_control_show = {
7091 	.f = cmd_link_flow_ctrl_show_parsed,
7092 	.data = NULL,
7093 	.help_str = "show port <port_id> flow_ctrl",
7094 	.tokens = {
7095 		(void *)&cmd_lfc_show_show,
7096 		(void *)&cmd_lfc_show_port,
7097 		(void *)&cmd_lfc_show_portid,
7098 		(void *)&cmd_lfc_show_flow_ctrl,
7099 		NULL,
7100 	},
7101 };
7102 
7103 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7104 struct cmd_link_flow_ctrl_set_result {
7105 	cmdline_fixed_string_t set;
7106 	cmdline_fixed_string_t flow_ctrl;
7107 	cmdline_fixed_string_t rx;
7108 	cmdline_fixed_string_t rx_lfc_mode;
7109 	cmdline_fixed_string_t tx;
7110 	cmdline_fixed_string_t tx_lfc_mode;
7111 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
7112 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7113 	cmdline_fixed_string_t autoneg_str;
7114 	cmdline_fixed_string_t autoneg;
7115 	cmdline_fixed_string_t hw_str;
7116 	uint32_t high_water;
7117 	cmdline_fixed_string_t lw_str;
7118 	uint32_t low_water;
7119 	cmdline_fixed_string_t pt_str;
7120 	uint16_t pause_time;
7121 	cmdline_fixed_string_t xon_str;
7122 	uint16_t send_xon;
7123 	portid_t port_id;
7124 };
7125 
7126 cmdline_parse_token_string_t cmd_lfc_set_set =
7127 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7128 				set, "set");
7129 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7130 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7131 				flow_ctrl, "flow_ctrl");
7132 cmdline_parse_token_string_t cmd_lfc_set_rx =
7133 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7134 				rx, "rx");
7135 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7136 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7137 				rx_lfc_mode, "on#off");
7138 cmdline_parse_token_string_t cmd_lfc_set_tx =
7139 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7140 				tx, "tx");
7141 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7142 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7143 				tx_lfc_mode, "on#off");
7144 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7145 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7146 				hw_str, "high_water");
7147 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7148 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7149 				high_water, RTE_UINT32);
7150 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7151 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7152 				lw_str, "low_water");
7153 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7154 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7155 				low_water, RTE_UINT32);
7156 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7157 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7158 				pt_str, "pause_time");
7159 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7160 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7161 				pause_time, RTE_UINT16);
7162 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7163 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7164 				xon_str, "send_xon");
7165 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7166 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7167 				send_xon, RTE_UINT16);
7168 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7169 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7170 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7171 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7172 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7173 				mac_ctrl_frame_fwd_mode, "on#off");
7174 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7175 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7176 				autoneg_str, "autoneg");
7177 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7178 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7179 				autoneg, "on#off");
7180 cmdline_parse_token_num_t cmd_lfc_set_portid =
7181 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7182 				port_id, RTE_UINT16);
7183 
7184 /* forward declaration */
7185 static void
7186 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7187 			      void *data);
7188 
7189 cmdline_parse_inst_t cmd_link_flow_control_set = {
7190 	.f = cmd_link_flow_ctrl_set_parsed,
7191 	.data = NULL,
7192 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7193 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7194 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
7195 	.tokens = {
7196 		(void *)&cmd_lfc_set_set,
7197 		(void *)&cmd_lfc_set_flow_ctrl,
7198 		(void *)&cmd_lfc_set_rx,
7199 		(void *)&cmd_lfc_set_rx_mode,
7200 		(void *)&cmd_lfc_set_tx,
7201 		(void *)&cmd_lfc_set_tx_mode,
7202 		(void *)&cmd_lfc_set_high_water,
7203 		(void *)&cmd_lfc_set_low_water,
7204 		(void *)&cmd_lfc_set_pause_time,
7205 		(void *)&cmd_lfc_set_send_xon,
7206 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7207 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7208 		(void *)&cmd_lfc_set_autoneg_str,
7209 		(void *)&cmd_lfc_set_autoneg,
7210 		(void *)&cmd_lfc_set_portid,
7211 		NULL,
7212 	},
7213 };
7214 
7215 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7216 	.f = cmd_link_flow_ctrl_set_parsed,
7217 	.data = (void *)&cmd_link_flow_control_set_rx,
7218 	.help_str = "set flow_ctrl rx on|off <port_id>: "
7219 		"Change rx flow control parameter",
7220 	.tokens = {
7221 		(void *)&cmd_lfc_set_set,
7222 		(void *)&cmd_lfc_set_flow_ctrl,
7223 		(void *)&cmd_lfc_set_rx,
7224 		(void *)&cmd_lfc_set_rx_mode,
7225 		(void *)&cmd_lfc_set_portid,
7226 		NULL,
7227 	},
7228 };
7229 
7230 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7231 	.f = cmd_link_flow_ctrl_set_parsed,
7232 	.data = (void *)&cmd_link_flow_control_set_tx,
7233 	.help_str = "set flow_ctrl tx on|off <port_id>: "
7234 		"Change tx flow control parameter",
7235 	.tokens = {
7236 		(void *)&cmd_lfc_set_set,
7237 		(void *)&cmd_lfc_set_flow_ctrl,
7238 		(void *)&cmd_lfc_set_tx,
7239 		(void *)&cmd_lfc_set_tx_mode,
7240 		(void *)&cmd_lfc_set_portid,
7241 		NULL,
7242 	},
7243 };
7244 
7245 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7246 	.f = cmd_link_flow_ctrl_set_parsed,
7247 	.data = (void *)&cmd_link_flow_control_set_hw,
7248 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
7249 		"Change high water flow control parameter",
7250 	.tokens = {
7251 		(void *)&cmd_lfc_set_set,
7252 		(void *)&cmd_lfc_set_flow_ctrl,
7253 		(void *)&cmd_lfc_set_high_water_str,
7254 		(void *)&cmd_lfc_set_high_water,
7255 		(void *)&cmd_lfc_set_portid,
7256 		NULL,
7257 	},
7258 };
7259 
7260 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7261 	.f = cmd_link_flow_ctrl_set_parsed,
7262 	.data = (void *)&cmd_link_flow_control_set_lw,
7263 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7264 		"Change low water flow control parameter",
7265 	.tokens = {
7266 		(void *)&cmd_lfc_set_set,
7267 		(void *)&cmd_lfc_set_flow_ctrl,
7268 		(void *)&cmd_lfc_set_low_water_str,
7269 		(void *)&cmd_lfc_set_low_water,
7270 		(void *)&cmd_lfc_set_portid,
7271 		NULL,
7272 	},
7273 };
7274 
7275 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7276 	.f = cmd_link_flow_ctrl_set_parsed,
7277 	.data = (void *)&cmd_link_flow_control_set_pt,
7278 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7279 		"Change pause time flow control parameter",
7280 	.tokens = {
7281 		(void *)&cmd_lfc_set_set,
7282 		(void *)&cmd_lfc_set_flow_ctrl,
7283 		(void *)&cmd_lfc_set_pause_time_str,
7284 		(void *)&cmd_lfc_set_pause_time,
7285 		(void *)&cmd_lfc_set_portid,
7286 		NULL,
7287 	},
7288 };
7289 
7290 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7291 	.f = cmd_link_flow_ctrl_set_parsed,
7292 	.data = (void *)&cmd_link_flow_control_set_xon,
7293 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7294 		"Change send_xon flow control parameter",
7295 	.tokens = {
7296 		(void *)&cmd_lfc_set_set,
7297 		(void *)&cmd_lfc_set_flow_ctrl,
7298 		(void *)&cmd_lfc_set_send_xon_str,
7299 		(void *)&cmd_lfc_set_send_xon,
7300 		(void *)&cmd_lfc_set_portid,
7301 		NULL,
7302 	},
7303 };
7304 
7305 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7306 	.f = cmd_link_flow_ctrl_set_parsed,
7307 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7308 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7309 		"Change mac ctrl fwd flow control parameter",
7310 	.tokens = {
7311 		(void *)&cmd_lfc_set_set,
7312 		(void *)&cmd_lfc_set_flow_ctrl,
7313 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7314 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7315 		(void *)&cmd_lfc_set_portid,
7316 		NULL,
7317 	},
7318 };
7319 
7320 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7321 	.f = cmd_link_flow_ctrl_set_parsed,
7322 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7323 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7324 		"Change autoneg flow control parameter",
7325 	.tokens = {
7326 		(void *)&cmd_lfc_set_set,
7327 		(void *)&cmd_lfc_set_flow_ctrl,
7328 		(void *)&cmd_lfc_set_autoneg_str,
7329 		(void *)&cmd_lfc_set_autoneg,
7330 		(void *)&cmd_lfc_set_portid,
7331 		NULL,
7332 	},
7333 };
7334 
7335 static void
7336 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7337 			      __rte_unused struct cmdline *cl,
7338 			      void *data)
7339 {
7340 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7341 	cmdline_parse_inst_t *cmd = data;
7342 	struct rte_eth_fc_conf fc_conf;
7343 	int rx_fc_en = 0;
7344 	int tx_fc_en = 0;
7345 	int ret;
7346 
7347 	/*
7348 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7349 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7350 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7351 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7352 	 */
7353 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7354 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7355 	};
7356 
7357 	/* Partial command line, retrieve current configuration */
7358 	if (cmd) {
7359 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7360 		if (ret != 0) {
7361 			fprintf(stderr,
7362 				"cannot get current flow ctrl parameters, return code = %d\n",
7363 				ret);
7364 			return;
7365 		}
7366 
7367 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7368 		    (fc_conf.mode == RTE_FC_FULL))
7369 			rx_fc_en = 1;
7370 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7371 		    (fc_conf.mode == RTE_FC_FULL))
7372 			tx_fc_en = 1;
7373 	}
7374 
7375 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7376 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7377 
7378 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7379 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7380 
7381 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7382 
7383 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7384 		fc_conf.high_water = res->high_water;
7385 
7386 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7387 		fc_conf.low_water = res->low_water;
7388 
7389 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7390 		fc_conf.pause_time = res->pause_time;
7391 
7392 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7393 		fc_conf.send_xon = res->send_xon;
7394 
7395 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7396 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7397 			fc_conf.mac_ctrl_frame_fwd = 1;
7398 		else
7399 			fc_conf.mac_ctrl_frame_fwd = 0;
7400 	}
7401 
7402 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7403 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7404 
7405 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7406 	if (ret != 0)
7407 		fprintf(stderr,
7408 			"bad flow control parameter, return code = %d\n",
7409 			ret);
7410 }
7411 
7412 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7413 struct cmd_priority_flow_ctrl_set_result {
7414 	cmdline_fixed_string_t set;
7415 	cmdline_fixed_string_t pfc_ctrl;
7416 	cmdline_fixed_string_t rx;
7417 	cmdline_fixed_string_t rx_pfc_mode;
7418 	cmdline_fixed_string_t tx;
7419 	cmdline_fixed_string_t tx_pfc_mode;
7420 	uint32_t high_water;
7421 	uint32_t low_water;
7422 	uint16_t pause_time;
7423 	uint8_t  priority;
7424 	portid_t port_id;
7425 };
7426 
7427 static void
7428 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7429 		       __rte_unused struct cmdline *cl,
7430 		       __rte_unused void *data)
7431 {
7432 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7433 	struct rte_eth_pfc_conf pfc_conf;
7434 	int rx_fc_enable, tx_fc_enable;
7435 	int ret;
7436 
7437 	/*
7438 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7439 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7440 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7441 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7442 	 */
7443 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7444 		{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7445 	};
7446 
7447 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7448 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7449 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7450 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7451 	pfc_conf.fc.high_water = res->high_water;
7452 	pfc_conf.fc.low_water  = res->low_water;
7453 	pfc_conf.fc.pause_time = res->pause_time;
7454 	pfc_conf.priority      = res->priority;
7455 
7456 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7457 	if (ret != 0)
7458 		fprintf(stderr,
7459 			"bad priority flow control parameter, return code = %d\n",
7460 			ret);
7461 }
7462 
7463 cmdline_parse_token_string_t cmd_pfc_set_set =
7464 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7465 				set, "set");
7466 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7467 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7468 				pfc_ctrl, "pfc_ctrl");
7469 cmdline_parse_token_string_t cmd_pfc_set_rx =
7470 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7471 				rx, "rx");
7472 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7473 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7474 				rx_pfc_mode, "on#off");
7475 cmdline_parse_token_string_t cmd_pfc_set_tx =
7476 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7477 				tx, "tx");
7478 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7479 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7480 				tx_pfc_mode, "on#off");
7481 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7482 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7483 				high_water, RTE_UINT32);
7484 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7485 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7486 				low_water, RTE_UINT32);
7487 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7488 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7489 				pause_time, RTE_UINT16);
7490 cmdline_parse_token_num_t cmd_pfc_set_priority =
7491 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7492 				priority, RTE_UINT8);
7493 cmdline_parse_token_num_t cmd_pfc_set_portid =
7494 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7495 				port_id, RTE_UINT16);
7496 
7497 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7498 	.f = cmd_priority_flow_ctrl_set_parsed,
7499 	.data = NULL,
7500 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7501 		"<pause_time> <priority> <port_id>: "
7502 		"Configure the Ethernet priority flow control",
7503 	.tokens = {
7504 		(void *)&cmd_pfc_set_set,
7505 		(void *)&cmd_pfc_set_flow_ctrl,
7506 		(void *)&cmd_pfc_set_rx,
7507 		(void *)&cmd_pfc_set_rx_mode,
7508 		(void *)&cmd_pfc_set_tx,
7509 		(void *)&cmd_pfc_set_tx_mode,
7510 		(void *)&cmd_pfc_set_high_water,
7511 		(void *)&cmd_pfc_set_low_water,
7512 		(void *)&cmd_pfc_set_pause_time,
7513 		(void *)&cmd_pfc_set_priority,
7514 		(void *)&cmd_pfc_set_portid,
7515 		NULL,
7516 	},
7517 };
7518 
7519 /* *** RESET CONFIGURATION *** */
7520 struct cmd_reset_result {
7521 	cmdline_fixed_string_t reset;
7522 	cmdline_fixed_string_t def;
7523 };
7524 
7525 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7526 			     struct cmdline *cl,
7527 			     __rte_unused void *data)
7528 {
7529 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7530 	set_def_fwd_config();
7531 }
7532 
7533 cmdline_parse_token_string_t cmd_reset_set =
7534 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7535 cmdline_parse_token_string_t cmd_reset_def =
7536 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7537 				 "default");
7538 
7539 cmdline_parse_inst_t cmd_reset = {
7540 	.f = cmd_reset_parsed,
7541 	.data = NULL,
7542 	.help_str = "set default: Reset default forwarding configuration",
7543 	.tokens = {
7544 		(void *)&cmd_reset_set,
7545 		(void *)&cmd_reset_def,
7546 		NULL,
7547 	},
7548 };
7549 
7550 /* *** START FORWARDING *** */
7551 struct cmd_start_result {
7552 	cmdline_fixed_string_t start;
7553 };
7554 
7555 cmdline_parse_token_string_t cmd_start_start =
7556 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7557 
7558 static void cmd_start_parsed(__rte_unused void *parsed_result,
7559 			     __rte_unused struct cmdline *cl,
7560 			     __rte_unused void *data)
7561 {
7562 	start_packet_forwarding(0);
7563 }
7564 
7565 cmdline_parse_inst_t cmd_start = {
7566 	.f = cmd_start_parsed,
7567 	.data = NULL,
7568 	.help_str = "start: Start packet forwarding",
7569 	.tokens = {
7570 		(void *)&cmd_start_start,
7571 		NULL,
7572 	},
7573 };
7574 
7575 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7576 struct cmd_start_tx_first_result {
7577 	cmdline_fixed_string_t start;
7578 	cmdline_fixed_string_t tx_first;
7579 };
7580 
7581 static void
7582 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7583 			  __rte_unused struct cmdline *cl,
7584 			  __rte_unused void *data)
7585 {
7586 	start_packet_forwarding(1);
7587 }
7588 
7589 cmdline_parse_token_string_t cmd_start_tx_first_start =
7590 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7591 				 "start");
7592 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7593 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7594 				 tx_first, "tx_first");
7595 
7596 cmdline_parse_inst_t cmd_start_tx_first = {
7597 	.f = cmd_start_tx_first_parsed,
7598 	.data = NULL,
7599 	.help_str = "start tx_first: Start packet forwarding, "
7600 		"after sending 1 burst of packets",
7601 	.tokens = {
7602 		(void *)&cmd_start_tx_first_start,
7603 		(void *)&cmd_start_tx_first_tx_first,
7604 		NULL,
7605 	},
7606 };
7607 
7608 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7609 struct cmd_start_tx_first_n_result {
7610 	cmdline_fixed_string_t start;
7611 	cmdline_fixed_string_t tx_first;
7612 	uint32_t tx_num;
7613 };
7614 
7615 static void
7616 cmd_start_tx_first_n_parsed(void *parsed_result,
7617 			  __rte_unused struct cmdline *cl,
7618 			  __rte_unused void *data)
7619 {
7620 	struct cmd_start_tx_first_n_result *res = parsed_result;
7621 
7622 	start_packet_forwarding(res->tx_num);
7623 }
7624 
7625 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7626 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7627 			start, "start");
7628 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7629 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7630 			tx_first, "tx_first");
7631 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7632 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7633 			tx_num, RTE_UINT32);
7634 
7635 cmdline_parse_inst_t cmd_start_tx_first_n = {
7636 	.f = cmd_start_tx_first_n_parsed,
7637 	.data = NULL,
7638 	.help_str = "start tx_first <num>: "
7639 		"packet forwarding, after sending <num> bursts of packets",
7640 	.tokens = {
7641 		(void *)&cmd_start_tx_first_n_start,
7642 		(void *)&cmd_start_tx_first_n_tx_first,
7643 		(void *)&cmd_start_tx_first_n_tx_num,
7644 		NULL,
7645 	},
7646 };
7647 
7648 /* *** SET LINK UP *** */
7649 struct cmd_set_link_up_result {
7650 	cmdline_fixed_string_t set;
7651 	cmdline_fixed_string_t link_up;
7652 	cmdline_fixed_string_t port;
7653 	portid_t port_id;
7654 };
7655 
7656 cmdline_parse_token_string_t cmd_set_link_up_set =
7657 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7658 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7659 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7660 				"link-up");
7661 cmdline_parse_token_string_t cmd_set_link_up_port =
7662 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7663 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7664 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7665 				RTE_UINT16);
7666 
7667 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7668 			     __rte_unused struct cmdline *cl,
7669 			     __rte_unused void *data)
7670 {
7671 	struct cmd_set_link_up_result *res = parsed_result;
7672 	dev_set_link_up(res->port_id);
7673 }
7674 
7675 cmdline_parse_inst_t cmd_set_link_up = {
7676 	.f = cmd_set_link_up_parsed,
7677 	.data = NULL,
7678 	.help_str = "set link-up port <port id>",
7679 	.tokens = {
7680 		(void *)&cmd_set_link_up_set,
7681 		(void *)&cmd_set_link_up_link_up,
7682 		(void *)&cmd_set_link_up_port,
7683 		(void *)&cmd_set_link_up_port_id,
7684 		NULL,
7685 	},
7686 };
7687 
7688 /* *** SET LINK DOWN *** */
7689 struct cmd_set_link_down_result {
7690 	cmdline_fixed_string_t set;
7691 	cmdline_fixed_string_t link_down;
7692 	cmdline_fixed_string_t port;
7693 	portid_t port_id;
7694 };
7695 
7696 cmdline_parse_token_string_t cmd_set_link_down_set =
7697 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7698 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7699 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7700 				"link-down");
7701 cmdline_parse_token_string_t cmd_set_link_down_port =
7702 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7703 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7704 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7705 				RTE_UINT16);
7706 
7707 static void cmd_set_link_down_parsed(
7708 				__rte_unused void *parsed_result,
7709 				__rte_unused struct cmdline *cl,
7710 				__rte_unused void *data)
7711 {
7712 	struct cmd_set_link_down_result *res = parsed_result;
7713 	dev_set_link_down(res->port_id);
7714 }
7715 
7716 cmdline_parse_inst_t cmd_set_link_down = {
7717 	.f = cmd_set_link_down_parsed,
7718 	.data = NULL,
7719 	.help_str = "set link-down port <port id>",
7720 	.tokens = {
7721 		(void *)&cmd_set_link_down_set,
7722 		(void *)&cmd_set_link_down_link_down,
7723 		(void *)&cmd_set_link_down_port,
7724 		(void *)&cmd_set_link_down_port_id,
7725 		NULL,
7726 	},
7727 };
7728 
7729 /* *** SHOW CFG *** */
7730 struct cmd_showcfg_result {
7731 	cmdline_fixed_string_t show;
7732 	cmdline_fixed_string_t cfg;
7733 	cmdline_fixed_string_t what;
7734 };
7735 
7736 static void cmd_showcfg_parsed(void *parsed_result,
7737 			       __rte_unused struct cmdline *cl,
7738 			       __rte_unused void *data)
7739 {
7740 	struct cmd_showcfg_result *res = parsed_result;
7741 	if (!strcmp(res->what, "rxtx"))
7742 		rxtx_config_display();
7743 	else if (!strcmp(res->what, "cores"))
7744 		fwd_lcores_config_display();
7745 	else if (!strcmp(res->what, "fwd"))
7746 		pkt_fwd_config_display(&cur_fwd_config);
7747 	else if (!strcmp(res->what, "rxoffs"))
7748 		show_rx_pkt_offsets();
7749 	else if (!strcmp(res->what, "rxpkts"))
7750 		show_rx_pkt_segments();
7751 	else if (!strcmp(res->what, "txpkts"))
7752 		show_tx_pkt_segments();
7753 	else if (!strcmp(res->what, "txtimes"))
7754 		show_tx_pkt_times();
7755 }
7756 
7757 cmdline_parse_token_string_t cmd_showcfg_show =
7758 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7759 cmdline_parse_token_string_t cmd_showcfg_port =
7760 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7761 cmdline_parse_token_string_t cmd_showcfg_what =
7762 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7763 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7764 
7765 cmdline_parse_inst_t cmd_showcfg = {
7766 	.f = cmd_showcfg_parsed,
7767 	.data = NULL,
7768 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7769 	.tokens = {
7770 		(void *)&cmd_showcfg_show,
7771 		(void *)&cmd_showcfg_port,
7772 		(void *)&cmd_showcfg_what,
7773 		NULL,
7774 	},
7775 };
7776 
7777 /* *** SHOW ALL PORT INFO *** */
7778 struct cmd_showportall_result {
7779 	cmdline_fixed_string_t show;
7780 	cmdline_fixed_string_t port;
7781 	cmdline_fixed_string_t what;
7782 	cmdline_fixed_string_t all;
7783 };
7784 
7785 static void cmd_showportall_parsed(void *parsed_result,
7786 				__rte_unused struct cmdline *cl,
7787 				__rte_unused void *data)
7788 {
7789 	portid_t i;
7790 
7791 	struct cmd_showportall_result *res = parsed_result;
7792 	if (!strcmp(res->show, "clear")) {
7793 		if (!strcmp(res->what, "stats"))
7794 			RTE_ETH_FOREACH_DEV(i)
7795 				nic_stats_clear(i);
7796 		else if (!strcmp(res->what, "xstats"))
7797 			RTE_ETH_FOREACH_DEV(i)
7798 				nic_xstats_clear(i);
7799 	} else if (!strcmp(res->what, "info"))
7800 		RTE_ETH_FOREACH_DEV(i)
7801 			port_infos_display(i);
7802 	else if (!strcmp(res->what, "summary")) {
7803 		port_summary_header_display();
7804 		RTE_ETH_FOREACH_DEV(i)
7805 			port_summary_display(i);
7806 	}
7807 	else if (!strcmp(res->what, "stats"))
7808 		RTE_ETH_FOREACH_DEV(i)
7809 			nic_stats_display(i);
7810 	else if (!strcmp(res->what, "xstats"))
7811 		RTE_ETH_FOREACH_DEV(i)
7812 			nic_xstats_display(i);
7813 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7814 	else if (!strcmp(res->what, "fdir"))
7815 		RTE_ETH_FOREACH_DEV(i)
7816 			fdir_get_infos(i);
7817 #endif
7818 	else if (!strcmp(res->what, "dcb_tc"))
7819 		RTE_ETH_FOREACH_DEV(i)
7820 			port_dcb_info_display(i);
7821 }
7822 
7823 cmdline_parse_token_string_t cmd_showportall_show =
7824 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7825 				 "show#clear");
7826 cmdline_parse_token_string_t cmd_showportall_port =
7827 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7828 cmdline_parse_token_string_t cmd_showportall_what =
7829 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7830 				 "info#summary#stats#xstats#fdir#dcb_tc");
7831 cmdline_parse_token_string_t cmd_showportall_all =
7832 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7833 cmdline_parse_inst_t cmd_showportall = {
7834 	.f = cmd_showportall_parsed,
7835 	.data = NULL,
7836 	.help_str = "show|clear port "
7837 		"info|summary|stats|xstats|fdir|dcb_tc all",
7838 	.tokens = {
7839 		(void *)&cmd_showportall_show,
7840 		(void *)&cmd_showportall_port,
7841 		(void *)&cmd_showportall_what,
7842 		(void *)&cmd_showportall_all,
7843 		NULL,
7844 	},
7845 };
7846 
7847 /* *** SHOW PORT INFO *** */
7848 struct cmd_showport_result {
7849 	cmdline_fixed_string_t show;
7850 	cmdline_fixed_string_t port;
7851 	cmdline_fixed_string_t what;
7852 	uint16_t portnum;
7853 };
7854 
7855 static void cmd_showport_parsed(void *parsed_result,
7856 				__rte_unused struct cmdline *cl,
7857 				__rte_unused void *data)
7858 {
7859 	struct cmd_showport_result *res = parsed_result;
7860 	if (!strcmp(res->show, "clear")) {
7861 		if (!strcmp(res->what, "stats"))
7862 			nic_stats_clear(res->portnum);
7863 		else if (!strcmp(res->what, "xstats"))
7864 			nic_xstats_clear(res->portnum);
7865 	} else if (!strcmp(res->what, "info"))
7866 		port_infos_display(res->portnum);
7867 	else if (!strcmp(res->what, "summary")) {
7868 		port_summary_header_display();
7869 		port_summary_display(res->portnum);
7870 	}
7871 	else if (!strcmp(res->what, "stats"))
7872 		nic_stats_display(res->portnum);
7873 	else if (!strcmp(res->what, "xstats"))
7874 		nic_xstats_display(res->portnum);
7875 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7876 	else if (!strcmp(res->what, "fdir"))
7877 		 fdir_get_infos(res->portnum);
7878 #endif
7879 	else if (!strcmp(res->what, "dcb_tc"))
7880 		port_dcb_info_display(res->portnum);
7881 }
7882 
7883 cmdline_parse_token_string_t cmd_showport_show =
7884 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7885 				 "show#clear");
7886 cmdline_parse_token_string_t cmd_showport_port =
7887 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7888 cmdline_parse_token_string_t cmd_showport_what =
7889 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7890 				 "info#summary#stats#xstats#fdir#dcb_tc");
7891 cmdline_parse_token_num_t cmd_showport_portnum =
7892 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7893 
7894 cmdline_parse_inst_t cmd_showport = {
7895 	.f = cmd_showport_parsed,
7896 	.data = NULL,
7897 	.help_str = "show|clear port "
7898 		"info|summary|stats|xstats|fdir|dcb_tc "
7899 		"<port_id>",
7900 	.tokens = {
7901 		(void *)&cmd_showport_show,
7902 		(void *)&cmd_showport_port,
7903 		(void *)&cmd_showport_what,
7904 		(void *)&cmd_showport_portnum,
7905 		NULL,
7906 	},
7907 };
7908 
7909 /* *** SHOW DEVICE INFO *** */
7910 struct cmd_showdevice_result {
7911 	cmdline_fixed_string_t show;
7912 	cmdline_fixed_string_t device;
7913 	cmdline_fixed_string_t what;
7914 	cmdline_fixed_string_t identifier;
7915 };
7916 
7917 static void cmd_showdevice_parsed(void *parsed_result,
7918 				__rte_unused struct cmdline *cl,
7919 				__rte_unused void *data)
7920 {
7921 	struct cmd_showdevice_result *res = parsed_result;
7922 	if (!strcmp(res->what, "info")) {
7923 		if (!strcmp(res->identifier, "all"))
7924 			device_infos_display(NULL);
7925 		else
7926 			device_infos_display(res->identifier);
7927 	}
7928 }
7929 
7930 cmdline_parse_token_string_t cmd_showdevice_show =
7931 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7932 				 "show");
7933 cmdline_parse_token_string_t cmd_showdevice_device =
7934 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7935 cmdline_parse_token_string_t cmd_showdevice_what =
7936 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7937 				 "info");
7938 cmdline_parse_token_string_t cmd_showdevice_identifier =
7939 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7940 			identifier, NULL);
7941 
7942 cmdline_parse_inst_t cmd_showdevice = {
7943 	.f = cmd_showdevice_parsed,
7944 	.data = NULL,
7945 	.help_str = "show device info <identifier>|all",
7946 	.tokens = {
7947 		(void *)&cmd_showdevice_show,
7948 		(void *)&cmd_showdevice_device,
7949 		(void *)&cmd_showdevice_what,
7950 		(void *)&cmd_showdevice_identifier,
7951 		NULL,
7952 	},
7953 };
7954 
7955 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7956 struct cmd_showeeprom_result {
7957 	cmdline_fixed_string_t show;
7958 	cmdline_fixed_string_t port;
7959 	uint16_t portnum;
7960 	cmdline_fixed_string_t type;
7961 };
7962 
7963 static void cmd_showeeprom_parsed(void *parsed_result,
7964 		__rte_unused struct cmdline *cl,
7965 		__rte_unused void *data)
7966 {
7967 	struct cmd_showeeprom_result *res = parsed_result;
7968 
7969 	if (!strcmp(res->type, "eeprom"))
7970 		port_eeprom_display(res->portnum);
7971 	else if (!strcmp(res->type, "module_eeprom"))
7972 		port_module_eeprom_display(res->portnum);
7973 	else
7974 		fprintf(stderr, "Unknown argument\n");
7975 }
7976 
7977 cmdline_parse_token_string_t cmd_showeeprom_show =
7978 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7979 cmdline_parse_token_string_t cmd_showeeprom_port =
7980 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7981 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7982 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7983 			RTE_UINT16);
7984 cmdline_parse_token_string_t cmd_showeeprom_type =
7985 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7986 
7987 cmdline_parse_inst_t cmd_showeeprom = {
7988 	.f = cmd_showeeprom_parsed,
7989 	.data = NULL,
7990 	.help_str = "show port <port_id> module_eeprom|eeprom",
7991 	.tokens = {
7992 		(void *)&cmd_showeeprom_show,
7993 		(void *)&cmd_showeeprom_port,
7994 		(void *)&cmd_showeeprom_portnum,
7995 		(void *)&cmd_showeeprom_type,
7996 		NULL,
7997 	},
7998 };
7999 
8000 /* *** SHOW QUEUE INFO *** */
8001 struct cmd_showqueue_result {
8002 	cmdline_fixed_string_t show;
8003 	cmdline_fixed_string_t type;
8004 	cmdline_fixed_string_t what;
8005 	uint16_t portnum;
8006 	uint16_t queuenum;
8007 };
8008 
8009 static void
8010 cmd_showqueue_parsed(void *parsed_result,
8011 	__rte_unused struct cmdline *cl,
8012 	__rte_unused void *data)
8013 {
8014 	struct cmd_showqueue_result *res = parsed_result;
8015 
8016 	if (!strcmp(res->type, "rxq"))
8017 		rx_queue_infos_display(res->portnum, res->queuenum);
8018 	else if (!strcmp(res->type, "txq"))
8019 		tx_queue_infos_display(res->portnum, res->queuenum);
8020 }
8021 
8022 cmdline_parse_token_string_t cmd_showqueue_show =
8023 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8024 cmdline_parse_token_string_t cmd_showqueue_type =
8025 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8026 cmdline_parse_token_string_t cmd_showqueue_what =
8027 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8028 cmdline_parse_token_num_t cmd_showqueue_portnum =
8029 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8030 		RTE_UINT16);
8031 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8032 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8033 		RTE_UINT16);
8034 
8035 cmdline_parse_inst_t cmd_showqueue = {
8036 	.f = cmd_showqueue_parsed,
8037 	.data = NULL,
8038 	.help_str = "show rxq|txq info <port_id> <queue_id>",
8039 	.tokens = {
8040 		(void *)&cmd_showqueue_show,
8041 		(void *)&cmd_showqueue_type,
8042 		(void *)&cmd_showqueue_what,
8043 		(void *)&cmd_showqueue_portnum,
8044 		(void *)&cmd_showqueue_queuenum,
8045 		NULL,
8046 	},
8047 };
8048 
8049 /* show/clear fwd engine statistics */
8050 struct fwd_result {
8051 	cmdline_fixed_string_t action;
8052 	cmdline_fixed_string_t fwd;
8053 	cmdline_fixed_string_t stats;
8054 	cmdline_fixed_string_t all;
8055 };
8056 
8057 cmdline_parse_token_string_t cmd_fwd_action =
8058 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8059 cmdline_parse_token_string_t cmd_fwd_fwd =
8060 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8061 cmdline_parse_token_string_t cmd_fwd_stats =
8062 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8063 cmdline_parse_token_string_t cmd_fwd_all =
8064 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8065 
8066 static void
8067 cmd_showfwdall_parsed(void *parsed_result,
8068 		      __rte_unused struct cmdline *cl,
8069 		      __rte_unused void *data)
8070 {
8071 	struct fwd_result *res = parsed_result;
8072 
8073 	if (!strcmp(res->action, "show"))
8074 		fwd_stats_display();
8075 	else
8076 		fwd_stats_reset();
8077 }
8078 
8079 static cmdline_parse_inst_t cmd_showfwdall = {
8080 	.f = cmd_showfwdall_parsed,
8081 	.data = NULL,
8082 	.help_str = "show|clear fwd stats all",
8083 	.tokens = {
8084 		(void *)&cmd_fwd_action,
8085 		(void *)&cmd_fwd_fwd,
8086 		(void *)&cmd_fwd_stats,
8087 		(void *)&cmd_fwd_all,
8088 		NULL,
8089 	},
8090 };
8091 
8092 /* *** READ PORT REGISTER *** */
8093 struct cmd_read_reg_result {
8094 	cmdline_fixed_string_t read;
8095 	cmdline_fixed_string_t reg;
8096 	portid_t port_id;
8097 	uint32_t reg_off;
8098 };
8099 
8100 static void
8101 cmd_read_reg_parsed(void *parsed_result,
8102 		    __rte_unused struct cmdline *cl,
8103 		    __rte_unused void *data)
8104 {
8105 	struct cmd_read_reg_result *res = parsed_result;
8106 	port_reg_display(res->port_id, res->reg_off);
8107 }
8108 
8109 cmdline_parse_token_string_t cmd_read_reg_read =
8110 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8111 cmdline_parse_token_string_t cmd_read_reg_reg =
8112 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8113 cmdline_parse_token_num_t cmd_read_reg_port_id =
8114 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8115 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8116 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8117 
8118 cmdline_parse_inst_t cmd_read_reg = {
8119 	.f = cmd_read_reg_parsed,
8120 	.data = NULL,
8121 	.help_str = "read reg <port_id> <reg_off>",
8122 	.tokens = {
8123 		(void *)&cmd_read_reg_read,
8124 		(void *)&cmd_read_reg_reg,
8125 		(void *)&cmd_read_reg_port_id,
8126 		(void *)&cmd_read_reg_reg_off,
8127 		NULL,
8128 	},
8129 };
8130 
8131 /* *** READ PORT REGISTER BIT FIELD *** */
8132 struct cmd_read_reg_bit_field_result {
8133 	cmdline_fixed_string_t read;
8134 	cmdline_fixed_string_t regfield;
8135 	portid_t port_id;
8136 	uint32_t reg_off;
8137 	uint8_t bit1_pos;
8138 	uint8_t bit2_pos;
8139 };
8140 
8141 static void
8142 cmd_read_reg_bit_field_parsed(void *parsed_result,
8143 			      __rte_unused struct cmdline *cl,
8144 			      __rte_unused void *data)
8145 {
8146 	struct cmd_read_reg_bit_field_result *res = parsed_result;
8147 	port_reg_bit_field_display(res->port_id, res->reg_off,
8148 				   res->bit1_pos, res->bit2_pos);
8149 }
8150 
8151 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8152 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8153 				 "read");
8154 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8155 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8156 				 regfield, "regfield");
8157 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8158 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8159 			      RTE_UINT16);
8160 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8161 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8162 			      RTE_UINT32);
8163 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8164 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8165 			      RTE_UINT8);
8166 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8167 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8168 			      RTE_UINT8);
8169 
8170 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8171 	.f = cmd_read_reg_bit_field_parsed,
8172 	.data = NULL,
8173 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8174 	"Read register bit field between bit_x and bit_y included",
8175 	.tokens = {
8176 		(void *)&cmd_read_reg_bit_field_read,
8177 		(void *)&cmd_read_reg_bit_field_regfield,
8178 		(void *)&cmd_read_reg_bit_field_port_id,
8179 		(void *)&cmd_read_reg_bit_field_reg_off,
8180 		(void *)&cmd_read_reg_bit_field_bit1_pos,
8181 		(void *)&cmd_read_reg_bit_field_bit2_pos,
8182 		NULL,
8183 	},
8184 };
8185 
8186 /* *** READ PORT REGISTER BIT *** */
8187 struct cmd_read_reg_bit_result {
8188 	cmdline_fixed_string_t read;
8189 	cmdline_fixed_string_t regbit;
8190 	portid_t port_id;
8191 	uint32_t reg_off;
8192 	uint8_t bit_pos;
8193 };
8194 
8195 static void
8196 cmd_read_reg_bit_parsed(void *parsed_result,
8197 			__rte_unused struct cmdline *cl,
8198 			__rte_unused void *data)
8199 {
8200 	struct cmd_read_reg_bit_result *res = parsed_result;
8201 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8202 }
8203 
8204 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8205 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8206 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8207 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8208 				 regbit, "regbit");
8209 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8210 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8211 				 RTE_UINT16);
8212 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8213 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8214 				 RTE_UINT32);
8215 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8216 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8217 				 RTE_UINT8);
8218 
8219 cmdline_parse_inst_t cmd_read_reg_bit = {
8220 	.f = cmd_read_reg_bit_parsed,
8221 	.data = NULL,
8222 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8223 	.tokens = {
8224 		(void *)&cmd_read_reg_bit_read,
8225 		(void *)&cmd_read_reg_bit_regbit,
8226 		(void *)&cmd_read_reg_bit_port_id,
8227 		(void *)&cmd_read_reg_bit_reg_off,
8228 		(void *)&cmd_read_reg_bit_bit_pos,
8229 		NULL,
8230 	},
8231 };
8232 
8233 /* *** WRITE PORT REGISTER *** */
8234 struct cmd_write_reg_result {
8235 	cmdline_fixed_string_t write;
8236 	cmdline_fixed_string_t reg;
8237 	portid_t port_id;
8238 	uint32_t reg_off;
8239 	uint32_t value;
8240 };
8241 
8242 static void
8243 cmd_write_reg_parsed(void *parsed_result,
8244 		     __rte_unused struct cmdline *cl,
8245 		     __rte_unused void *data)
8246 {
8247 	struct cmd_write_reg_result *res = parsed_result;
8248 	port_reg_set(res->port_id, res->reg_off, res->value);
8249 }
8250 
8251 cmdline_parse_token_string_t cmd_write_reg_write =
8252 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8253 cmdline_parse_token_string_t cmd_write_reg_reg =
8254 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8255 cmdline_parse_token_num_t cmd_write_reg_port_id =
8256 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8257 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8258 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8259 cmdline_parse_token_num_t cmd_write_reg_value =
8260 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8261 
8262 cmdline_parse_inst_t cmd_write_reg = {
8263 	.f = cmd_write_reg_parsed,
8264 	.data = NULL,
8265 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8266 	.tokens = {
8267 		(void *)&cmd_write_reg_write,
8268 		(void *)&cmd_write_reg_reg,
8269 		(void *)&cmd_write_reg_port_id,
8270 		(void *)&cmd_write_reg_reg_off,
8271 		(void *)&cmd_write_reg_value,
8272 		NULL,
8273 	},
8274 };
8275 
8276 /* *** WRITE PORT REGISTER BIT FIELD *** */
8277 struct cmd_write_reg_bit_field_result {
8278 	cmdline_fixed_string_t write;
8279 	cmdline_fixed_string_t regfield;
8280 	portid_t port_id;
8281 	uint32_t reg_off;
8282 	uint8_t bit1_pos;
8283 	uint8_t bit2_pos;
8284 	uint32_t value;
8285 };
8286 
8287 static void
8288 cmd_write_reg_bit_field_parsed(void *parsed_result,
8289 			       __rte_unused struct cmdline *cl,
8290 			       __rte_unused void *data)
8291 {
8292 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8293 	port_reg_bit_field_set(res->port_id, res->reg_off,
8294 			  res->bit1_pos, res->bit2_pos, res->value);
8295 }
8296 
8297 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8298 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8299 				 "write");
8300 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8301 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8302 				 regfield, "regfield");
8303 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8304 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8305 			      RTE_UINT16);
8306 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8307 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8308 			      RTE_UINT32);
8309 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8310 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8311 			      RTE_UINT8);
8312 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8313 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8314 			      RTE_UINT8);
8315 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8316 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8317 			      RTE_UINT32);
8318 
8319 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8320 	.f = cmd_write_reg_bit_field_parsed,
8321 	.data = NULL,
8322 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8323 		"<reg_value>: "
8324 		"Set register bit field between bit_x and bit_y included",
8325 	.tokens = {
8326 		(void *)&cmd_write_reg_bit_field_write,
8327 		(void *)&cmd_write_reg_bit_field_regfield,
8328 		(void *)&cmd_write_reg_bit_field_port_id,
8329 		(void *)&cmd_write_reg_bit_field_reg_off,
8330 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8331 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8332 		(void *)&cmd_write_reg_bit_field_value,
8333 		NULL,
8334 	},
8335 };
8336 
8337 /* *** WRITE PORT REGISTER BIT *** */
8338 struct cmd_write_reg_bit_result {
8339 	cmdline_fixed_string_t write;
8340 	cmdline_fixed_string_t regbit;
8341 	portid_t port_id;
8342 	uint32_t reg_off;
8343 	uint8_t bit_pos;
8344 	uint8_t value;
8345 };
8346 
8347 static void
8348 cmd_write_reg_bit_parsed(void *parsed_result,
8349 			 __rte_unused struct cmdline *cl,
8350 			 __rte_unused void *data)
8351 {
8352 	struct cmd_write_reg_bit_result *res = parsed_result;
8353 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8354 }
8355 
8356 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8357 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8358 				 "write");
8359 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8360 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8361 				 regbit, "regbit");
8362 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8363 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8364 				 RTE_UINT16);
8365 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8366 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8367 				 RTE_UINT32);
8368 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8369 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8370 				 RTE_UINT8);
8371 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8372 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8373 				 RTE_UINT8);
8374 
8375 cmdline_parse_inst_t cmd_write_reg_bit = {
8376 	.f = cmd_write_reg_bit_parsed,
8377 	.data = NULL,
8378 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8379 		"0 <= bit_x <= 31",
8380 	.tokens = {
8381 		(void *)&cmd_write_reg_bit_write,
8382 		(void *)&cmd_write_reg_bit_regbit,
8383 		(void *)&cmd_write_reg_bit_port_id,
8384 		(void *)&cmd_write_reg_bit_reg_off,
8385 		(void *)&cmd_write_reg_bit_bit_pos,
8386 		(void *)&cmd_write_reg_bit_value,
8387 		NULL,
8388 	},
8389 };
8390 
8391 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8392 struct cmd_read_rxd_txd_result {
8393 	cmdline_fixed_string_t read;
8394 	cmdline_fixed_string_t rxd_txd;
8395 	portid_t port_id;
8396 	uint16_t queue_id;
8397 	uint16_t desc_id;
8398 };
8399 
8400 static void
8401 cmd_read_rxd_txd_parsed(void *parsed_result,
8402 			__rte_unused struct cmdline *cl,
8403 			__rte_unused void *data)
8404 {
8405 	struct cmd_read_rxd_txd_result *res = parsed_result;
8406 
8407 	if (!strcmp(res->rxd_txd, "rxd"))
8408 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8409 	else if (!strcmp(res->rxd_txd, "txd"))
8410 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8411 }
8412 
8413 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8414 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8415 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8416 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8417 				 "rxd#txd");
8418 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8419 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8420 				 RTE_UINT16);
8421 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8422 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8423 				 RTE_UINT16);
8424 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8425 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8426 				 RTE_UINT16);
8427 
8428 cmdline_parse_inst_t cmd_read_rxd_txd = {
8429 	.f = cmd_read_rxd_txd_parsed,
8430 	.data = NULL,
8431 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8432 	.tokens = {
8433 		(void *)&cmd_read_rxd_txd_read,
8434 		(void *)&cmd_read_rxd_txd_rxd_txd,
8435 		(void *)&cmd_read_rxd_txd_port_id,
8436 		(void *)&cmd_read_rxd_txd_queue_id,
8437 		(void *)&cmd_read_rxd_txd_desc_id,
8438 		NULL,
8439 	},
8440 };
8441 
8442 /* *** QUIT *** */
8443 struct cmd_quit_result {
8444 	cmdline_fixed_string_t quit;
8445 };
8446 
8447 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8448 			    struct cmdline *cl,
8449 			    __rte_unused void *data)
8450 {
8451 	cmdline_quit(cl);
8452 }
8453 
8454 cmdline_parse_token_string_t cmd_quit_quit =
8455 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8456 
8457 cmdline_parse_inst_t cmd_quit = {
8458 	.f = cmd_quit_parsed,
8459 	.data = NULL,
8460 	.help_str = "quit: Exit application",
8461 	.tokens = {
8462 		(void *)&cmd_quit_quit,
8463 		NULL,
8464 	},
8465 };
8466 
8467 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8468 struct cmd_mac_addr_result {
8469 	cmdline_fixed_string_t mac_addr_cmd;
8470 	cmdline_fixed_string_t what;
8471 	uint16_t port_num;
8472 	struct rte_ether_addr address;
8473 };
8474 
8475 static void cmd_mac_addr_parsed(void *parsed_result,
8476 		__rte_unused struct cmdline *cl,
8477 		__rte_unused void *data)
8478 {
8479 	struct cmd_mac_addr_result *res = parsed_result;
8480 	int ret;
8481 
8482 	if (strcmp(res->what, "add") == 0)
8483 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8484 	else if (strcmp(res->what, "set") == 0)
8485 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8486 						       &res->address);
8487 	else
8488 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8489 
8490 	/* check the return value and print it if is < 0 */
8491 	if(ret < 0)
8492 		fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8493 
8494 }
8495 
8496 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8497 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8498 				"mac_addr");
8499 cmdline_parse_token_string_t cmd_mac_addr_what =
8500 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8501 				"add#remove#set");
8502 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8503 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8504 					RTE_UINT16);
8505 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8506 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8507 
8508 cmdline_parse_inst_t cmd_mac_addr = {
8509 	.f = cmd_mac_addr_parsed,
8510 	.data = (void *)0,
8511 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8512 			"Add/Remove/Set MAC address on port_id",
8513 	.tokens = {
8514 		(void *)&cmd_mac_addr_cmd,
8515 		(void *)&cmd_mac_addr_what,
8516 		(void *)&cmd_mac_addr_portnum,
8517 		(void *)&cmd_mac_addr_addr,
8518 		NULL,
8519 	},
8520 };
8521 
8522 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8523 struct cmd_eth_peer_result {
8524 	cmdline_fixed_string_t set;
8525 	cmdline_fixed_string_t eth_peer;
8526 	portid_t port_id;
8527 	cmdline_fixed_string_t peer_addr;
8528 };
8529 
8530 static void cmd_set_eth_peer_parsed(void *parsed_result,
8531 			__rte_unused struct cmdline *cl,
8532 			__rte_unused void *data)
8533 {
8534 		struct cmd_eth_peer_result *res = parsed_result;
8535 
8536 		if (test_done == 0) {
8537 			fprintf(stderr, "Please stop forwarding first\n");
8538 			return;
8539 		}
8540 		if (!strcmp(res->eth_peer, "eth-peer")) {
8541 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8542 			fwd_config_setup();
8543 		}
8544 }
8545 cmdline_parse_token_string_t cmd_eth_peer_set =
8546 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8547 cmdline_parse_token_string_t cmd_eth_peer =
8548 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8549 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8550 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8551 		RTE_UINT16);
8552 cmdline_parse_token_string_t cmd_eth_peer_addr =
8553 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8554 
8555 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8556 	.f = cmd_set_eth_peer_parsed,
8557 	.data = NULL,
8558 	.help_str = "set eth-peer <port_id> <peer_mac>",
8559 	.tokens = {
8560 		(void *)&cmd_eth_peer_set,
8561 		(void *)&cmd_eth_peer,
8562 		(void *)&cmd_eth_peer_port_id,
8563 		(void *)&cmd_eth_peer_addr,
8564 		NULL,
8565 	},
8566 };
8567 
8568 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8569 struct cmd_set_qmap_result {
8570 	cmdline_fixed_string_t set;
8571 	cmdline_fixed_string_t qmap;
8572 	cmdline_fixed_string_t what;
8573 	portid_t port_id;
8574 	uint16_t queue_id;
8575 	uint8_t map_value;
8576 };
8577 
8578 static void
8579 cmd_set_qmap_parsed(void *parsed_result,
8580 		       __rte_unused struct cmdline *cl,
8581 		       __rte_unused void *data)
8582 {
8583 	struct cmd_set_qmap_result *res = parsed_result;
8584 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8585 
8586 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8587 }
8588 
8589 cmdline_parse_token_string_t cmd_setqmap_set =
8590 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8591 				 set, "set");
8592 cmdline_parse_token_string_t cmd_setqmap_qmap =
8593 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8594 				 qmap, "stat_qmap");
8595 cmdline_parse_token_string_t cmd_setqmap_what =
8596 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8597 				 what, "tx#rx");
8598 cmdline_parse_token_num_t cmd_setqmap_portid =
8599 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8600 			      port_id, RTE_UINT16);
8601 cmdline_parse_token_num_t cmd_setqmap_queueid =
8602 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8603 			      queue_id, RTE_UINT16);
8604 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8605 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8606 			      map_value, RTE_UINT8);
8607 
8608 cmdline_parse_inst_t cmd_set_qmap = {
8609 	.f = cmd_set_qmap_parsed,
8610 	.data = NULL,
8611 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8612 		"Set statistics mapping value on tx|rx queue_id of port_id",
8613 	.tokens = {
8614 		(void *)&cmd_setqmap_set,
8615 		(void *)&cmd_setqmap_qmap,
8616 		(void *)&cmd_setqmap_what,
8617 		(void *)&cmd_setqmap_portid,
8618 		(void *)&cmd_setqmap_queueid,
8619 		(void *)&cmd_setqmap_mapvalue,
8620 		NULL,
8621 	},
8622 };
8623 
8624 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8625 struct cmd_set_xstats_hide_zero_result {
8626 	cmdline_fixed_string_t keyword;
8627 	cmdline_fixed_string_t name;
8628 	cmdline_fixed_string_t on_off;
8629 };
8630 
8631 static void
8632 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8633 			__rte_unused struct cmdline *cl,
8634 			__rte_unused void *data)
8635 {
8636 	struct cmd_set_xstats_hide_zero_result *res;
8637 	uint16_t on_off = 0;
8638 
8639 	res = parsed_result;
8640 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8641 	set_xstats_hide_zero(on_off);
8642 }
8643 
8644 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8645 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8646 				 keyword, "set");
8647 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8648 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8649 				 name, "xstats-hide-zero");
8650 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8651 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8652 				 on_off, "on#off");
8653 
8654 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8655 	.f = cmd_set_xstats_hide_zero_parsed,
8656 	.data = NULL,
8657 	.help_str = "set xstats-hide-zero on|off",
8658 	.tokens = {
8659 		(void *)&cmd_set_xstats_hide_zero_keyword,
8660 		(void *)&cmd_set_xstats_hide_zero_name,
8661 		(void *)&cmd_set_xstats_hide_zero_on_off,
8662 		NULL,
8663 	},
8664 };
8665 
8666 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8667 struct cmd_set_record_core_cycles_result {
8668 	cmdline_fixed_string_t keyword;
8669 	cmdline_fixed_string_t name;
8670 	cmdline_fixed_string_t on_off;
8671 };
8672 
8673 static void
8674 cmd_set_record_core_cycles_parsed(void *parsed_result,
8675 			__rte_unused struct cmdline *cl,
8676 			__rte_unused void *data)
8677 {
8678 	struct cmd_set_record_core_cycles_result *res;
8679 	uint16_t on_off = 0;
8680 
8681 	res = parsed_result;
8682 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8683 	set_record_core_cycles(on_off);
8684 }
8685 
8686 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8687 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8688 				 keyword, "set");
8689 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8690 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8691 				 name, "record-core-cycles");
8692 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8693 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8694 				 on_off, "on#off");
8695 
8696 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8697 	.f = cmd_set_record_core_cycles_parsed,
8698 	.data = NULL,
8699 	.help_str = "set record-core-cycles on|off",
8700 	.tokens = {
8701 		(void *)&cmd_set_record_core_cycles_keyword,
8702 		(void *)&cmd_set_record_core_cycles_name,
8703 		(void *)&cmd_set_record_core_cycles_on_off,
8704 		NULL,
8705 	},
8706 };
8707 
8708 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8709 struct cmd_set_record_burst_stats_result {
8710 	cmdline_fixed_string_t keyword;
8711 	cmdline_fixed_string_t name;
8712 	cmdline_fixed_string_t on_off;
8713 };
8714 
8715 static void
8716 cmd_set_record_burst_stats_parsed(void *parsed_result,
8717 			__rte_unused struct cmdline *cl,
8718 			__rte_unused void *data)
8719 {
8720 	struct cmd_set_record_burst_stats_result *res;
8721 	uint16_t on_off = 0;
8722 
8723 	res = parsed_result;
8724 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8725 	set_record_burst_stats(on_off);
8726 }
8727 
8728 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8729 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8730 				 keyword, "set");
8731 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8732 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8733 				 name, "record-burst-stats");
8734 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8735 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8736 				 on_off, "on#off");
8737 
8738 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8739 	.f = cmd_set_record_burst_stats_parsed,
8740 	.data = NULL,
8741 	.help_str = "set record-burst-stats on|off",
8742 	.tokens = {
8743 		(void *)&cmd_set_record_burst_stats_keyword,
8744 		(void *)&cmd_set_record_burst_stats_name,
8745 		(void *)&cmd_set_record_burst_stats_on_off,
8746 		NULL,
8747 	},
8748 };
8749 
8750 /* *** CONFIGURE UNICAST HASH TABLE *** */
8751 struct cmd_set_uc_hash_table {
8752 	cmdline_fixed_string_t set;
8753 	cmdline_fixed_string_t port;
8754 	portid_t port_id;
8755 	cmdline_fixed_string_t what;
8756 	struct rte_ether_addr address;
8757 	cmdline_fixed_string_t mode;
8758 };
8759 
8760 static void
8761 cmd_set_uc_hash_parsed(void *parsed_result,
8762 		       __rte_unused struct cmdline *cl,
8763 		       __rte_unused void *data)
8764 {
8765 	int ret=0;
8766 	struct cmd_set_uc_hash_table *res = parsed_result;
8767 
8768 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8769 
8770 	if (strcmp(res->what, "uta") == 0)
8771 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8772 						&res->address,(uint8_t)is_on);
8773 	if (ret < 0)
8774 		fprintf(stderr,
8775 			"bad unicast hash table parameter, return code = %d\n",
8776 			ret);
8777 
8778 }
8779 
8780 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8781 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8782 				 set, "set");
8783 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8784 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8785 				 port, "port");
8786 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8787 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8788 			      port_id, RTE_UINT16);
8789 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8790 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8791 				 what, "uta");
8792 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8793 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8794 				address);
8795 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8796 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8797 				 mode, "on#off");
8798 
8799 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8800 	.f = cmd_set_uc_hash_parsed,
8801 	.data = NULL,
8802 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8803 	.tokens = {
8804 		(void *)&cmd_set_uc_hash_set,
8805 		(void *)&cmd_set_uc_hash_port,
8806 		(void *)&cmd_set_uc_hash_portid,
8807 		(void *)&cmd_set_uc_hash_what,
8808 		(void *)&cmd_set_uc_hash_mac,
8809 		(void *)&cmd_set_uc_hash_mode,
8810 		NULL,
8811 	},
8812 };
8813 
8814 struct cmd_set_uc_all_hash_table {
8815 	cmdline_fixed_string_t set;
8816 	cmdline_fixed_string_t port;
8817 	portid_t port_id;
8818 	cmdline_fixed_string_t what;
8819 	cmdline_fixed_string_t value;
8820 	cmdline_fixed_string_t mode;
8821 };
8822 
8823 static void
8824 cmd_set_uc_all_hash_parsed(void *parsed_result,
8825 		       __rte_unused struct cmdline *cl,
8826 		       __rte_unused void *data)
8827 {
8828 	int ret=0;
8829 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8830 
8831 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8832 
8833 	if ((strcmp(res->what, "uta") == 0) &&
8834 		(strcmp(res->value, "all") == 0))
8835 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8836 	if (ret < 0)
8837 		fprintf(stderr,
8838 			"bad unicast hash table parameter, return code = %d\n",
8839 			ret);
8840 }
8841 
8842 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8843 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8844 				 set, "set");
8845 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8846 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8847 				 port, "port");
8848 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8849 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8850 			      port_id, RTE_UINT16);
8851 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8852 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8853 				 what, "uta");
8854 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8855 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8856 				value,"all");
8857 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8858 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8859 				 mode, "on#off");
8860 
8861 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8862 	.f = cmd_set_uc_all_hash_parsed,
8863 	.data = NULL,
8864 	.help_str = "set port <port_id> uta all on|off",
8865 	.tokens = {
8866 		(void *)&cmd_set_uc_all_hash_set,
8867 		(void *)&cmd_set_uc_all_hash_port,
8868 		(void *)&cmd_set_uc_all_hash_portid,
8869 		(void *)&cmd_set_uc_all_hash_what,
8870 		(void *)&cmd_set_uc_all_hash_value,
8871 		(void *)&cmd_set_uc_all_hash_mode,
8872 		NULL,
8873 	},
8874 };
8875 
8876 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8877 struct cmd_set_vf_traffic {
8878 	cmdline_fixed_string_t set;
8879 	cmdline_fixed_string_t port;
8880 	portid_t port_id;
8881 	cmdline_fixed_string_t vf;
8882 	uint8_t vf_id;
8883 	cmdline_fixed_string_t what;
8884 	cmdline_fixed_string_t mode;
8885 };
8886 
8887 static void
8888 cmd_set_vf_traffic_parsed(void *parsed_result,
8889 		       __rte_unused struct cmdline *cl,
8890 		       __rte_unused void *data)
8891 {
8892 	struct cmd_set_vf_traffic *res = parsed_result;
8893 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8894 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8895 
8896 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8897 }
8898 
8899 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8900 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8901 				 set, "set");
8902 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8903 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8904 				 port, "port");
8905 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8906 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8907 			      port_id, RTE_UINT16);
8908 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8909 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8910 				 vf, "vf");
8911 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8912 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8913 			      vf_id, RTE_UINT8);
8914 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8915 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8916 				 what, "tx#rx");
8917 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8918 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8919 				 mode, "on#off");
8920 
8921 cmdline_parse_inst_t cmd_set_vf_traffic = {
8922 	.f = cmd_set_vf_traffic_parsed,
8923 	.data = NULL,
8924 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8925 	.tokens = {
8926 		(void *)&cmd_setvf_traffic_set,
8927 		(void *)&cmd_setvf_traffic_port,
8928 		(void *)&cmd_setvf_traffic_portid,
8929 		(void *)&cmd_setvf_traffic_vf,
8930 		(void *)&cmd_setvf_traffic_vfid,
8931 		(void *)&cmd_setvf_traffic_what,
8932 		(void *)&cmd_setvf_traffic_mode,
8933 		NULL,
8934 	},
8935 };
8936 
8937 /* *** CONFIGURE VF RECEIVE MODE *** */
8938 struct cmd_set_vf_rxmode {
8939 	cmdline_fixed_string_t set;
8940 	cmdline_fixed_string_t port;
8941 	portid_t port_id;
8942 	cmdline_fixed_string_t vf;
8943 	uint8_t vf_id;
8944 	cmdline_fixed_string_t what;
8945 	cmdline_fixed_string_t mode;
8946 	cmdline_fixed_string_t on;
8947 };
8948 
8949 static void
8950 cmd_set_vf_rxmode_parsed(void *parsed_result,
8951 		       __rte_unused struct cmdline *cl,
8952 		       __rte_unused void *data)
8953 {
8954 	int ret = -ENOTSUP;
8955 	uint16_t vf_rxmode = 0;
8956 	struct cmd_set_vf_rxmode *res = parsed_result;
8957 
8958 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8959 	if (!strcmp(res->what,"rxmode")) {
8960 		if (!strcmp(res->mode, "AUPE"))
8961 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8962 		else if (!strcmp(res->mode, "ROPE"))
8963 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8964 		else if (!strcmp(res->mode, "BAM"))
8965 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8966 		else if (!strncmp(res->mode, "MPE",3))
8967 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8968 	}
8969 
8970 	RTE_SET_USED(is_on);
8971 
8972 #ifdef RTE_NET_IXGBE
8973 	if (ret == -ENOTSUP)
8974 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8975 						  vf_rxmode, (uint8_t)is_on);
8976 #endif
8977 #ifdef RTE_NET_BNXT
8978 	if (ret == -ENOTSUP)
8979 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8980 						 vf_rxmode, (uint8_t)is_on);
8981 #endif
8982 	if (ret < 0)
8983 		fprintf(stderr,
8984 			"bad VF receive mode parameter, return code = %d\n",
8985 			ret);
8986 }
8987 
8988 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8989 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8990 				 set, "set");
8991 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8992 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8993 				 port, "port");
8994 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8995 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8996 			      port_id, RTE_UINT16);
8997 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8998 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8999 				 vf, "vf");
9000 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9001 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9002 			      vf_id, RTE_UINT8);
9003 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9004 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9005 				 what, "rxmode");
9006 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9007 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9008 				 mode, "AUPE#ROPE#BAM#MPE");
9009 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9010 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9011 				 on, "on#off");
9012 
9013 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9014 	.f = cmd_set_vf_rxmode_parsed,
9015 	.data = NULL,
9016 	.help_str = "set port <port_id> vf <vf_id> rxmode "
9017 		"AUPE|ROPE|BAM|MPE on|off",
9018 	.tokens = {
9019 		(void *)&cmd_set_vf_rxmode_set,
9020 		(void *)&cmd_set_vf_rxmode_port,
9021 		(void *)&cmd_set_vf_rxmode_portid,
9022 		(void *)&cmd_set_vf_rxmode_vf,
9023 		(void *)&cmd_set_vf_rxmode_vfid,
9024 		(void *)&cmd_set_vf_rxmode_what,
9025 		(void *)&cmd_set_vf_rxmode_mode,
9026 		(void *)&cmd_set_vf_rxmode_on,
9027 		NULL,
9028 	},
9029 };
9030 
9031 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9032 struct cmd_vf_mac_addr_result {
9033 	cmdline_fixed_string_t mac_addr_cmd;
9034 	cmdline_fixed_string_t what;
9035 	cmdline_fixed_string_t port;
9036 	uint16_t port_num;
9037 	cmdline_fixed_string_t vf;
9038 	uint8_t vf_num;
9039 	struct rte_ether_addr address;
9040 };
9041 
9042 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9043 		__rte_unused struct cmdline *cl,
9044 		__rte_unused void *data)
9045 {
9046 	struct cmd_vf_mac_addr_result *res = parsed_result;
9047 	int ret = -ENOTSUP;
9048 
9049 	if (strcmp(res->what, "add") != 0)
9050 		return;
9051 
9052 #ifdef RTE_NET_I40E
9053 	if (ret == -ENOTSUP)
9054 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9055 						   &res->address);
9056 #endif
9057 #ifdef RTE_NET_BNXT
9058 	if (ret == -ENOTSUP)
9059 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9060 						res->vf_num);
9061 #endif
9062 
9063 	if(ret < 0)
9064 		fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9065 
9066 }
9067 
9068 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9069 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9070 				mac_addr_cmd,"mac_addr");
9071 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9072 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9073 				what,"add");
9074 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9075 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9076 				port,"port");
9077 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9078 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9079 				port_num, RTE_UINT16);
9080 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9081 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9082 				vf,"vf");
9083 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9084 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9085 				vf_num, RTE_UINT8);
9086 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9087 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9088 				address);
9089 
9090 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9091 	.f = cmd_vf_mac_addr_parsed,
9092 	.data = (void *)0,
9093 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9094 		"Add MAC address filtering for a VF on port_id",
9095 	.tokens = {
9096 		(void *)&cmd_vf_mac_addr_cmd,
9097 		(void *)&cmd_vf_mac_addr_what,
9098 		(void *)&cmd_vf_mac_addr_port,
9099 		(void *)&cmd_vf_mac_addr_portnum,
9100 		(void *)&cmd_vf_mac_addr_vf,
9101 		(void *)&cmd_vf_mac_addr_vfnum,
9102 		(void *)&cmd_vf_mac_addr_addr,
9103 		NULL,
9104 	},
9105 };
9106 
9107 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9108 struct cmd_vf_rx_vlan_filter {
9109 	cmdline_fixed_string_t rx_vlan;
9110 	cmdline_fixed_string_t what;
9111 	uint16_t vlan_id;
9112 	cmdline_fixed_string_t port;
9113 	portid_t port_id;
9114 	cmdline_fixed_string_t vf;
9115 	uint64_t vf_mask;
9116 };
9117 
9118 static void
9119 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9120 			  __rte_unused struct cmdline *cl,
9121 			  __rte_unused void *data)
9122 {
9123 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
9124 	int ret = -ENOTSUP;
9125 
9126 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9127 
9128 #ifdef RTE_NET_IXGBE
9129 	if (ret == -ENOTSUP)
9130 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9131 				res->vlan_id, res->vf_mask, is_add);
9132 #endif
9133 #ifdef RTE_NET_I40E
9134 	if (ret == -ENOTSUP)
9135 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9136 				res->vlan_id, res->vf_mask, is_add);
9137 #endif
9138 #ifdef RTE_NET_BNXT
9139 	if (ret == -ENOTSUP)
9140 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9141 				res->vlan_id, res->vf_mask, is_add);
9142 #endif
9143 
9144 	switch (ret) {
9145 	case 0:
9146 		break;
9147 	case -EINVAL:
9148 		fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9149 			res->vlan_id, res->vf_mask);
9150 		break;
9151 	case -ENODEV:
9152 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
9153 		break;
9154 	case -ENOTSUP:
9155 		fprintf(stderr, "function not implemented or supported\n");
9156 		break;
9157 	default:
9158 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9159 	}
9160 }
9161 
9162 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9163 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9164 				 rx_vlan, "rx_vlan");
9165 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9166 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9167 				 what, "add#rm");
9168 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9169 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9170 			      vlan_id, RTE_UINT16);
9171 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9172 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9173 				 port, "port");
9174 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9175 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9176 			      port_id, RTE_UINT16);
9177 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9178 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9179 				 vf, "vf");
9180 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9181 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9182 			      vf_mask, RTE_UINT64);
9183 
9184 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9185 	.f = cmd_vf_rx_vlan_filter_parsed,
9186 	.data = NULL,
9187 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9188 		"(vf_mask = hexadecimal VF mask)",
9189 	.tokens = {
9190 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9191 		(void *)&cmd_vf_rx_vlan_filter_what,
9192 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
9193 		(void *)&cmd_vf_rx_vlan_filter_port,
9194 		(void *)&cmd_vf_rx_vlan_filter_portid,
9195 		(void *)&cmd_vf_rx_vlan_filter_vf,
9196 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
9197 		NULL,
9198 	},
9199 };
9200 
9201 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9202 struct cmd_queue_rate_limit_result {
9203 	cmdline_fixed_string_t set;
9204 	cmdline_fixed_string_t port;
9205 	uint16_t port_num;
9206 	cmdline_fixed_string_t queue;
9207 	uint8_t queue_num;
9208 	cmdline_fixed_string_t rate;
9209 	uint16_t rate_num;
9210 };
9211 
9212 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9213 		__rte_unused struct cmdline *cl,
9214 		__rte_unused void *data)
9215 {
9216 	struct cmd_queue_rate_limit_result *res = parsed_result;
9217 	int ret = 0;
9218 
9219 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9220 		&& (strcmp(res->queue, "queue") == 0)
9221 		&& (strcmp(res->rate, "rate") == 0))
9222 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
9223 					res->rate_num);
9224 	if (ret < 0)
9225 		fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9226 			strerror(-ret));
9227 
9228 }
9229 
9230 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9231 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9232 				set, "set");
9233 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9234 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9235 				port, "port");
9236 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9237 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9238 				port_num, RTE_UINT16);
9239 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9240 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9241 				queue, "queue");
9242 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9243 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9244 				queue_num, RTE_UINT8);
9245 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9246 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9247 				rate, "rate");
9248 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9249 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9250 				rate_num, RTE_UINT16);
9251 
9252 cmdline_parse_inst_t cmd_queue_rate_limit = {
9253 	.f = cmd_queue_rate_limit_parsed,
9254 	.data = (void *)0,
9255 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9256 		"Set rate limit for a queue on port_id",
9257 	.tokens = {
9258 		(void *)&cmd_queue_rate_limit_set,
9259 		(void *)&cmd_queue_rate_limit_port,
9260 		(void *)&cmd_queue_rate_limit_portnum,
9261 		(void *)&cmd_queue_rate_limit_queue,
9262 		(void *)&cmd_queue_rate_limit_queuenum,
9263 		(void *)&cmd_queue_rate_limit_rate,
9264 		(void *)&cmd_queue_rate_limit_ratenum,
9265 		NULL,
9266 	},
9267 };
9268 
9269 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9270 struct cmd_vf_rate_limit_result {
9271 	cmdline_fixed_string_t set;
9272 	cmdline_fixed_string_t port;
9273 	uint16_t port_num;
9274 	cmdline_fixed_string_t vf;
9275 	uint8_t vf_num;
9276 	cmdline_fixed_string_t rate;
9277 	uint16_t rate_num;
9278 	cmdline_fixed_string_t q_msk;
9279 	uint64_t q_msk_val;
9280 };
9281 
9282 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9283 		__rte_unused struct cmdline *cl,
9284 		__rte_unused void *data)
9285 {
9286 	struct cmd_vf_rate_limit_result *res = parsed_result;
9287 	int ret = 0;
9288 
9289 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9290 		&& (strcmp(res->vf, "vf") == 0)
9291 		&& (strcmp(res->rate, "rate") == 0)
9292 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9293 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9294 					res->rate_num, res->q_msk_val);
9295 	if (ret < 0)
9296 		fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9297 			strerror(-ret));
9298 
9299 }
9300 
9301 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9302 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9303 				set, "set");
9304 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9305 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9306 				port, "port");
9307 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9308 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9309 				port_num, RTE_UINT16);
9310 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9311 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9312 				vf, "vf");
9313 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9314 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9315 				vf_num, RTE_UINT8);
9316 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9317 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9318 				rate, "rate");
9319 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9320 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9321 				rate_num, RTE_UINT16);
9322 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9323 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9324 				q_msk, "queue_mask");
9325 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9326 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9327 				q_msk_val, RTE_UINT64);
9328 
9329 cmdline_parse_inst_t cmd_vf_rate_limit = {
9330 	.f = cmd_vf_rate_limit_parsed,
9331 	.data = (void *)0,
9332 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9333 		"queue_mask <queue_mask_value>: "
9334 		"Set rate limit for queues of VF on port_id",
9335 	.tokens = {
9336 		(void *)&cmd_vf_rate_limit_set,
9337 		(void *)&cmd_vf_rate_limit_port,
9338 		(void *)&cmd_vf_rate_limit_portnum,
9339 		(void *)&cmd_vf_rate_limit_vf,
9340 		(void *)&cmd_vf_rate_limit_vfnum,
9341 		(void *)&cmd_vf_rate_limit_rate,
9342 		(void *)&cmd_vf_rate_limit_ratenum,
9343 		(void *)&cmd_vf_rate_limit_q_msk,
9344 		(void *)&cmd_vf_rate_limit_q_msk_val,
9345 		NULL,
9346 	},
9347 };
9348 
9349 /* *** CONFIGURE TUNNEL UDP PORT *** */
9350 struct cmd_tunnel_udp_config {
9351 	cmdline_fixed_string_t rx_vxlan_port;
9352 	cmdline_fixed_string_t what;
9353 	uint16_t udp_port;
9354 	portid_t port_id;
9355 };
9356 
9357 static void
9358 cmd_tunnel_udp_config_parsed(void *parsed_result,
9359 			  __rte_unused struct cmdline *cl,
9360 			  __rte_unused void *data)
9361 {
9362 	struct cmd_tunnel_udp_config *res = parsed_result;
9363 	struct rte_eth_udp_tunnel tunnel_udp;
9364 	int ret;
9365 
9366 	tunnel_udp.udp_port = res->udp_port;
9367 	tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9368 
9369 	if (!strcmp(res->what, "add"))
9370 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9371 						      &tunnel_udp);
9372 	else
9373 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9374 							 &tunnel_udp);
9375 
9376 	if (ret < 0)
9377 		fprintf(stderr, "udp tunneling add error: (%s)\n",
9378 			strerror(-ret));
9379 }
9380 
9381 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9382 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9383 				rx_vxlan_port, "rx_vxlan_port");
9384 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9385 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9386 				what, "add#rm");
9387 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9388 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9389 				udp_port, RTE_UINT16);
9390 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9391 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9392 				port_id, RTE_UINT16);
9393 
9394 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9395 	.f = cmd_tunnel_udp_config_parsed,
9396 	.data = (void *)0,
9397 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9398 		"Add/Remove a tunneling UDP port filter",
9399 	.tokens = {
9400 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9401 		(void *)&cmd_tunnel_udp_config_what,
9402 		(void *)&cmd_tunnel_udp_config_udp_port,
9403 		(void *)&cmd_tunnel_udp_config_port_id,
9404 		NULL,
9405 	},
9406 };
9407 
9408 struct cmd_config_tunnel_udp_port {
9409 	cmdline_fixed_string_t port;
9410 	cmdline_fixed_string_t config;
9411 	portid_t port_id;
9412 	cmdline_fixed_string_t udp_tunnel_port;
9413 	cmdline_fixed_string_t action;
9414 	cmdline_fixed_string_t tunnel_type;
9415 	uint16_t udp_port;
9416 };
9417 
9418 static void
9419 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9420 			       __rte_unused struct cmdline *cl,
9421 			       __rte_unused void *data)
9422 {
9423 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9424 	struct rte_eth_udp_tunnel tunnel_udp;
9425 	int ret = 0;
9426 
9427 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9428 		return;
9429 
9430 	tunnel_udp.udp_port = res->udp_port;
9431 
9432 	if (!strcmp(res->tunnel_type, "vxlan")) {
9433 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9434 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9435 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9436 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9437 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9438 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9439 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9440 	} else {
9441 		fprintf(stderr, "Invalid tunnel type\n");
9442 		return;
9443 	}
9444 
9445 	if (!strcmp(res->action, "add"))
9446 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9447 						      &tunnel_udp);
9448 	else
9449 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9450 							 &tunnel_udp);
9451 
9452 	if (ret < 0)
9453 		fprintf(stderr, "udp tunneling port add error: (%s)\n",
9454 			strerror(-ret));
9455 }
9456 
9457 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9458 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9459 				 "port");
9460 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9461 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9462 				 "config");
9463 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9464 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9465 			      RTE_UINT16);
9466 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9467 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9468 				 udp_tunnel_port,
9469 				 "udp_tunnel_port");
9470 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9471 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9472 				 "add#rm");
9473 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9474 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9475 				 "vxlan#geneve#vxlan-gpe#ecpri");
9476 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9477 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9478 			      RTE_UINT16);
9479 
9480 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9481 	.f = cmd_cfg_tunnel_udp_port_parsed,
9482 	.data = NULL,
9483 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9484 		"geneve|vxlan-gpe|ecpri <udp_port>",
9485 	.tokens = {
9486 		(void *)&cmd_config_tunnel_udp_port_port,
9487 		(void *)&cmd_config_tunnel_udp_port_config,
9488 		(void *)&cmd_config_tunnel_udp_port_port_id,
9489 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9490 		(void *)&cmd_config_tunnel_udp_port_action,
9491 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9492 		(void *)&cmd_config_tunnel_udp_port_value,
9493 		NULL,
9494 	},
9495 };
9496 
9497 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9498 struct cmd_set_mirror_mask_result {
9499 	cmdline_fixed_string_t set;
9500 	cmdline_fixed_string_t port;
9501 	portid_t port_id;
9502 	cmdline_fixed_string_t mirror;
9503 	uint8_t rule_id;
9504 	cmdline_fixed_string_t what;
9505 	cmdline_fixed_string_t value;
9506 	cmdline_fixed_string_t dstpool;
9507 	uint8_t dstpool_id;
9508 	cmdline_fixed_string_t on;
9509 };
9510 
9511 cmdline_parse_token_string_t cmd_mirror_mask_set =
9512 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9513 				set, "set");
9514 cmdline_parse_token_string_t cmd_mirror_mask_port =
9515 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9516 				port, "port");
9517 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9518 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9519 				port_id, RTE_UINT16);
9520 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9521 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9522 				mirror, "mirror-rule");
9523 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9524 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9525 				rule_id, RTE_UINT8);
9526 cmdline_parse_token_string_t cmd_mirror_mask_what =
9527 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9528 				what, "pool-mirror-up#pool-mirror-down"
9529 				      "#vlan-mirror");
9530 cmdline_parse_token_string_t cmd_mirror_mask_value =
9531 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9532 				value, NULL);
9533 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9534 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9535 				dstpool, "dst-pool");
9536 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9537 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9538 				dstpool_id, RTE_UINT8);
9539 cmdline_parse_token_string_t cmd_mirror_mask_on =
9540 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9541 				on, "on#off");
9542 
9543 static void
9544 cmd_set_mirror_mask_parsed(void *parsed_result,
9545 		       __rte_unused struct cmdline *cl,
9546 		       __rte_unused void *data)
9547 {
9548 	int ret,nb_item,i;
9549 	struct cmd_set_mirror_mask_result *res = parsed_result;
9550 	struct rte_eth_mirror_conf mr_conf;
9551 
9552 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9553 
9554 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9555 
9556 	mr_conf.dst_pool = res->dstpool_id;
9557 
9558 	if (!strcmp(res->what, "pool-mirror-up")) {
9559 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9560 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9561 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9562 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9563 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9564 	} else if (!strcmp(res->what, "vlan-mirror")) {
9565 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9566 		nb_item = parse_item_list(res->value, "vlan",
9567 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9568 		if (nb_item <= 0)
9569 			return;
9570 
9571 		for (i = 0; i < nb_item; i++) {
9572 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9573 				fprintf(stderr,
9574 					"Invalid vlan_id: must be < 4096\n");
9575 				return;
9576 			}
9577 
9578 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9579 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9580 		}
9581 	}
9582 
9583 	if (!strcmp(res->on, "on"))
9584 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9585 						res->rule_id, 1);
9586 	else
9587 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9588 						res->rule_id, 0);
9589 	if (ret < 0)
9590 		fprintf(stderr, "mirror rule add error: (%s)\n",
9591 			strerror(-ret));
9592 }
9593 
9594 cmdline_parse_inst_t cmd_set_mirror_mask = {
9595 		.f = cmd_set_mirror_mask_parsed,
9596 		.data = NULL,
9597 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9598 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9599 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9600 		.tokens = {
9601 			(void *)&cmd_mirror_mask_set,
9602 			(void *)&cmd_mirror_mask_port,
9603 			(void *)&cmd_mirror_mask_portid,
9604 			(void *)&cmd_mirror_mask_mirror,
9605 			(void *)&cmd_mirror_mask_ruleid,
9606 			(void *)&cmd_mirror_mask_what,
9607 			(void *)&cmd_mirror_mask_value,
9608 			(void *)&cmd_mirror_mask_dstpool,
9609 			(void *)&cmd_mirror_mask_poolid,
9610 			(void *)&cmd_mirror_mask_on,
9611 			NULL,
9612 		},
9613 };
9614 
9615 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9616 struct cmd_set_mirror_link_result {
9617 	cmdline_fixed_string_t set;
9618 	cmdline_fixed_string_t port;
9619 	portid_t port_id;
9620 	cmdline_fixed_string_t mirror;
9621 	uint8_t rule_id;
9622 	cmdline_fixed_string_t what;
9623 	cmdline_fixed_string_t dstpool;
9624 	uint8_t dstpool_id;
9625 	cmdline_fixed_string_t on;
9626 };
9627 
9628 cmdline_parse_token_string_t cmd_mirror_link_set =
9629 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9630 				 set, "set");
9631 cmdline_parse_token_string_t cmd_mirror_link_port =
9632 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9633 				port, "port");
9634 cmdline_parse_token_num_t cmd_mirror_link_portid =
9635 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9636 				port_id, RTE_UINT16);
9637 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9638 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9639 				mirror, "mirror-rule");
9640 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9641 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9642 			    rule_id, RTE_UINT8);
9643 cmdline_parse_token_string_t cmd_mirror_link_what =
9644 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9645 				what, "uplink-mirror#downlink-mirror");
9646 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9647 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9648 				dstpool, "dst-pool");
9649 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9650 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9651 				dstpool_id, RTE_UINT8);
9652 cmdline_parse_token_string_t cmd_mirror_link_on =
9653 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9654 				on, "on#off");
9655 
9656 static void
9657 cmd_set_mirror_link_parsed(void *parsed_result,
9658 		       __rte_unused struct cmdline *cl,
9659 		       __rte_unused void *data)
9660 {
9661 	int ret;
9662 	struct cmd_set_mirror_link_result *res = parsed_result;
9663 	struct rte_eth_mirror_conf mr_conf;
9664 
9665 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9666 	if (!strcmp(res->what, "uplink-mirror"))
9667 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9668 	else
9669 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9670 
9671 	mr_conf.dst_pool = res->dstpool_id;
9672 
9673 	if (!strcmp(res->on, "on"))
9674 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9675 						res->rule_id, 1);
9676 	else
9677 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9678 						res->rule_id, 0);
9679 
9680 	/* check the return value and print it if is < 0 */
9681 	if (ret < 0)
9682 		fprintf(stderr, "mirror rule add error: (%s)\n",
9683 			strerror(-ret));
9684 
9685 }
9686 
9687 cmdline_parse_inst_t cmd_set_mirror_link = {
9688 		.f = cmd_set_mirror_link_parsed,
9689 		.data = NULL,
9690 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9691 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9692 		.tokens = {
9693 			(void *)&cmd_mirror_link_set,
9694 			(void *)&cmd_mirror_link_port,
9695 			(void *)&cmd_mirror_link_portid,
9696 			(void *)&cmd_mirror_link_mirror,
9697 			(void *)&cmd_mirror_link_ruleid,
9698 			(void *)&cmd_mirror_link_what,
9699 			(void *)&cmd_mirror_link_dstpool,
9700 			(void *)&cmd_mirror_link_poolid,
9701 			(void *)&cmd_mirror_link_on,
9702 			NULL,
9703 		},
9704 };
9705 
9706 /* *** RESET VM MIRROR RULE *** */
9707 struct cmd_rm_mirror_rule_result {
9708 	cmdline_fixed_string_t reset;
9709 	cmdline_fixed_string_t port;
9710 	portid_t port_id;
9711 	cmdline_fixed_string_t mirror;
9712 	uint8_t rule_id;
9713 };
9714 
9715 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9716 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9717 				 reset, "reset");
9718 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9719 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9720 				port, "port");
9721 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9722 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9723 				port_id, RTE_UINT16);
9724 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9725 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9726 				mirror, "mirror-rule");
9727 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9728 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9729 				rule_id, RTE_UINT8);
9730 
9731 static void
9732 cmd_reset_mirror_rule_parsed(void *parsed_result,
9733 		       __rte_unused struct cmdline *cl,
9734 		       __rte_unused void *data)
9735 {
9736 	int ret;
9737 	struct cmd_set_mirror_link_result *res = parsed_result;
9738         /* check rule_id */
9739 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9740 	if(ret < 0)
9741 		fprintf(stderr, "mirror rule remove error: (%s)\n",
9742 			strerror(-ret));
9743 }
9744 
9745 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9746 		.f = cmd_reset_mirror_rule_parsed,
9747 		.data = NULL,
9748 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9749 		.tokens = {
9750 			(void *)&cmd_rm_mirror_rule_reset,
9751 			(void *)&cmd_rm_mirror_rule_port,
9752 			(void *)&cmd_rm_mirror_rule_portid,
9753 			(void *)&cmd_rm_mirror_rule_mirror,
9754 			(void *)&cmd_rm_mirror_rule_ruleid,
9755 			NULL,
9756 		},
9757 };
9758 
9759 /* ******************************************************************************** */
9760 
9761 struct cmd_dump_result {
9762 	cmdline_fixed_string_t dump;
9763 };
9764 
9765 static void
9766 dump_struct_sizes(void)
9767 {
9768 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9769 	DUMP_SIZE(struct rte_mbuf);
9770 	DUMP_SIZE(struct rte_mempool);
9771 	DUMP_SIZE(struct rte_ring);
9772 #undef DUMP_SIZE
9773 }
9774 
9775 
9776 /* Dump the socket memory statistics on console */
9777 static void
9778 dump_socket_mem(FILE *f)
9779 {
9780 	struct rte_malloc_socket_stats socket_stats;
9781 	unsigned int i;
9782 	size_t total = 0;
9783 	size_t alloc = 0;
9784 	size_t free = 0;
9785 	unsigned int n_alloc = 0;
9786 	unsigned int n_free = 0;
9787 	static size_t last_allocs;
9788 	static size_t last_total;
9789 
9790 
9791 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9792 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9793 		    !socket_stats.heap_totalsz_bytes)
9794 			continue;
9795 		total += socket_stats.heap_totalsz_bytes;
9796 		alloc += socket_stats.heap_allocsz_bytes;
9797 		free += socket_stats.heap_freesz_bytes;
9798 		n_alloc += socket_stats.alloc_count;
9799 		n_free += socket_stats.free_count;
9800 		fprintf(f,
9801 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9802 			i,
9803 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9804 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9805 			(double)socket_stats.heap_allocsz_bytes * 100 /
9806 			(double)socket_stats.heap_totalsz_bytes,
9807 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9808 			socket_stats.alloc_count,
9809 			socket_stats.free_count);
9810 	}
9811 	fprintf(f,
9812 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9813 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9814 		total ? ((double)alloc * 100 / (double)total) : 0,
9815 		(double)free / (1024 * 1024),
9816 		n_alloc, n_free);
9817 	if (last_allocs)
9818 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9819 			((double)total - (double)last_total) / (1024 * 1024),
9820 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9821 	last_allocs = alloc;
9822 	last_total = total;
9823 }
9824 
9825 static void cmd_dump_parsed(void *parsed_result,
9826 			    __rte_unused struct cmdline *cl,
9827 			    __rte_unused void *data)
9828 {
9829 	struct cmd_dump_result *res = parsed_result;
9830 
9831 	if (!strcmp(res->dump, "dump_physmem"))
9832 		rte_dump_physmem_layout(stdout);
9833 	else if (!strcmp(res->dump, "dump_socket_mem"))
9834 		dump_socket_mem(stdout);
9835 	else if (!strcmp(res->dump, "dump_memzone"))
9836 		rte_memzone_dump(stdout);
9837 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9838 		dump_struct_sizes();
9839 	else if (!strcmp(res->dump, "dump_ring"))
9840 		rte_ring_list_dump(stdout);
9841 	else if (!strcmp(res->dump, "dump_mempool"))
9842 		rte_mempool_list_dump(stdout);
9843 	else if (!strcmp(res->dump, "dump_devargs"))
9844 		rte_devargs_dump(stdout);
9845 	else if (!strcmp(res->dump, "dump_log_types"))
9846 		rte_log_dump(stdout);
9847 }
9848 
9849 cmdline_parse_token_string_t cmd_dump_dump =
9850 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9851 		"dump_physmem#"
9852 		"dump_memzone#"
9853 		"dump_socket_mem#"
9854 		"dump_struct_sizes#"
9855 		"dump_ring#"
9856 		"dump_mempool#"
9857 		"dump_devargs#"
9858 		"dump_log_types");
9859 
9860 cmdline_parse_inst_t cmd_dump = {
9861 	.f = cmd_dump_parsed,  /* function to call */
9862 	.data = NULL,      /* 2nd arg of func */
9863 	.help_str = "Dump status",
9864 	.tokens = {        /* token list, NULL terminated */
9865 		(void *)&cmd_dump_dump,
9866 		NULL,
9867 	},
9868 };
9869 
9870 /* ******************************************************************************** */
9871 
9872 struct cmd_dump_one_result {
9873 	cmdline_fixed_string_t dump;
9874 	cmdline_fixed_string_t name;
9875 };
9876 
9877 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9878 				__rte_unused void *data)
9879 {
9880 	struct cmd_dump_one_result *res = parsed_result;
9881 
9882 	if (!strcmp(res->dump, "dump_ring")) {
9883 		struct rte_ring *r;
9884 		r = rte_ring_lookup(res->name);
9885 		if (r == NULL) {
9886 			cmdline_printf(cl, "Cannot find ring\n");
9887 			return;
9888 		}
9889 		rte_ring_dump(stdout, r);
9890 	} else if (!strcmp(res->dump, "dump_mempool")) {
9891 		struct rte_mempool *mp;
9892 		mp = rte_mempool_lookup(res->name);
9893 		if (mp == NULL) {
9894 			cmdline_printf(cl, "Cannot find mempool\n");
9895 			return;
9896 		}
9897 		rte_mempool_dump(stdout, mp);
9898 	}
9899 }
9900 
9901 cmdline_parse_token_string_t cmd_dump_one_dump =
9902 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9903 				 "dump_ring#dump_mempool");
9904 
9905 cmdline_parse_token_string_t cmd_dump_one_name =
9906 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9907 
9908 cmdline_parse_inst_t cmd_dump_one = {
9909 	.f = cmd_dump_one_parsed,  /* function to call */
9910 	.data = NULL,      /* 2nd arg of func */
9911 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9912 	.tokens = {        /* token list, NULL terminated */
9913 		(void *)&cmd_dump_one_dump,
9914 		(void *)&cmd_dump_one_name,
9915 		NULL,
9916 	},
9917 };
9918 
9919 /* *** queue region set *** */
9920 struct cmd_queue_region_result {
9921 	cmdline_fixed_string_t set;
9922 	cmdline_fixed_string_t port;
9923 	portid_t port_id;
9924 	cmdline_fixed_string_t cmd;
9925 	cmdline_fixed_string_t region;
9926 	uint8_t  region_id;
9927 	cmdline_fixed_string_t queue_start_index;
9928 	uint8_t  queue_id;
9929 	cmdline_fixed_string_t queue_num;
9930 	uint8_t  queue_num_value;
9931 };
9932 
9933 static void
9934 cmd_queue_region_parsed(void *parsed_result,
9935 			__rte_unused struct cmdline *cl,
9936 			__rte_unused void *data)
9937 {
9938 	struct cmd_queue_region_result *res = parsed_result;
9939 	int ret = -ENOTSUP;
9940 #ifdef RTE_NET_I40E
9941 	struct rte_pmd_i40e_queue_region_conf region_conf;
9942 	enum rte_pmd_i40e_queue_region_op op_type;
9943 #endif
9944 
9945 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9946 		return;
9947 
9948 #ifdef RTE_NET_I40E
9949 	memset(&region_conf, 0, sizeof(region_conf));
9950 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9951 	region_conf.region_id = res->region_id;
9952 	region_conf.queue_num = res->queue_num_value;
9953 	region_conf.queue_start_index = res->queue_id;
9954 
9955 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9956 				op_type, &region_conf);
9957 #endif
9958 
9959 	switch (ret) {
9960 	case 0:
9961 		break;
9962 	case -ENOTSUP:
9963 		fprintf(stderr, "function not implemented or supported\n");
9964 		break;
9965 	default:
9966 		fprintf(stderr, "queue region config error: (%s)\n",
9967 			strerror(-ret));
9968 	}
9969 }
9970 
9971 cmdline_parse_token_string_t cmd_queue_region_set =
9972 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9973 		set, "set");
9974 cmdline_parse_token_string_t cmd_queue_region_port =
9975 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9976 cmdline_parse_token_num_t cmd_queue_region_port_id =
9977 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9978 				port_id, RTE_UINT16);
9979 cmdline_parse_token_string_t cmd_queue_region_cmd =
9980 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9981 				 cmd, "queue-region");
9982 cmdline_parse_token_string_t cmd_queue_region_id =
9983 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9984 				region, "region_id");
9985 cmdline_parse_token_num_t cmd_queue_region_index =
9986 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9987 				region_id, RTE_UINT8);
9988 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9989 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9990 				queue_start_index, "queue_start_index");
9991 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9992 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9993 				queue_id, RTE_UINT8);
9994 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9995 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9996 				queue_num, "queue_num");
9997 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9998 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9999 				queue_num_value, RTE_UINT8);
10000 
10001 cmdline_parse_inst_t cmd_queue_region = {
10002 	.f = cmd_queue_region_parsed,
10003 	.data = NULL,
10004 	.help_str = "set port <port_id> queue-region region_id <value> "
10005 		"queue_start_index <value> queue_num <value>: Set a queue region",
10006 	.tokens = {
10007 		(void *)&cmd_queue_region_set,
10008 		(void *)&cmd_queue_region_port,
10009 		(void *)&cmd_queue_region_port_id,
10010 		(void *)&cmd_queue_region_cmd,
10011 		(void *)&cmd_queue_region_id,
10012 		(void *)&cmd_queue_region_index,
10013 		(void *)&cmd_queue_region_queue_start_index,
10014 		(void *)&cmd_queue_region_queue_id,
10015 		(void *)&cmd_queue_region_queue_num,
10016 		(void *)&cmd_queue_region_queue_num_value,
10017 		NULL,
10018 	},
10019 };
10020 
10021 /* *** queue region and flowtype set *** */
10022 struct cmd_region_flowtype_result {
10023 	cmdline_fixed_string_t set;
10024 	cmdline_fixed_string_t port;
10025 	portid_t port_id;
10026 	cmdline_fixed_string_t cmd;
10027 	cmdline_fixed_string_t region;
10028 	uint8_t  region_id;
10029 	cmdline_fixed_string_t flowtype;
10030 	uint8_t  flowtype_id;
10031 };
10032 
10033 static void
10034 cmd_region_flowtype_parsed(void *parsed_result,
10035 			__rte_unused struct cmdline *cl,
10036 			__rte_unused void *data)
10037 {
10038 	struct cmd_region_flowtype_result *res = parsed_result;
10039 	int ret = -ENOTSUP;
10040 #ifdef RTE_NET_I40E
10041 	struct rte_pmd_i40e_queue_region_conf region_conf;
10042 	enum rte_pmd_i40e_queue_region_op op_type;
10043 #endif
10044 
10045 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10046 		return;
10047 
10048 #ifdef RTE_NET_I40E
10049 	memset(&region_conf, 0, sizeof(region_conf));
10050 
10051 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10052 	region_conf.region_id = res->region_id;
10053 	region_conf.hw_flowtype = res->flowtype_id;
10054 
10055 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10056 			op_type, &region_conf);
10057 #endif
10058 
10059 	switch (ret) {
10060 	case 0:
10061 		break;
10062 	case -ENOTSUP:
10063 		fprintf(stderr, "function not implemented or supported\n");
10064 		break;
10065 	default:
10066 		fprintf(stderr, "region flowtype config error: (%s)\n",
10067 			strerror(-ret));
10068 	}
10069 }
10070 
10071 cmdline_parse_token_string_t cmd_region_flowtype_set =
10072 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10073 				set, "set");
10074 cmdline_parse_token_string_t cmd_region_flowtype_port =
10075 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10076 				port, "port");
10077 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10078 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10079 				port_id, RTE_UINT16);
10080 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10081 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10082 				cmd, "queue-region");
10083 cmdline_parse_token_string_t cmd_region_flowtype_index =
10084 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10085 				region, "region_id");
10086 cmdline_parse_token_num_t cmd_region_flowtype_id =
10087 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10088 				region_id, RTE_UINT8);
10089 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10090 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10091 				flowtype, "flowtype");
10092 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10093 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10094 				flowtype_id, RTE_UINT8);
10095 cmdline_parse_inst_t cmd_region_flowtype = {
10096 	.f = cmd_region_flowtype_parsed,
10097 	.data = NULL,
10098 	.help_str = "set port <port_id> queue-region region_id <value> "
10099 		"flowtype <value>: Set a flowtype region index",
10100 	.tokens = {
10101 		(void *)&cmd_region_flowtype_set,
10102 		(void *)&cmd_region_flowtype_port,
10103 		(void *)&cmd_region_flowtype_port_index,
10104 		(void *)&cmd_region_flowtype_cmd,
10105 		(void *)&cmd_region_flowtype_index,
10106 		(void *)&cmd_region_flowtype_id,
10107 		(void *)&cmd_region_flowtype_flow_index,
10108 		(void *)&cmd_region_flowtype_flow_id,
10109 		NULL,
10110 	},
10111 };
10112 
10113 /* *** User Priority (UP) to queue region (region_id) set *** */
10114 struct cmd_user_priority_region_result {
10115 	cmdline_fixed_string_t set;
10116 	cmdline_fixed_string_t port;
10117 	portid_t port_id;
10118 	cmdline_fixed_string_t cmd;
10119 	cmdline_fixed_string_t user_priority;
10120 	uint8_t  user_priority_id;
10121 	cmdline_fixed_string_t region;
10122 	uint8_t  region_id;
10123 };
10124 
10125 static void
10126 cmd_user_priority_region_parsed(void *parsed_result,
10127 			__rte_unused struct cmdline *cl,
10128 			__rte_unused void *data)
10129 {
10130 	struct cmd_user_priority_region_result *res = parsed_result;
10131 	int ret = -ENOTSUP;
10132 #ifdef RTE_NET_I40E
10133 	struct rte_pmd_i40e_queue_region_conf region_conf;
10134 	enum rte_pmd_i40e_queue_region_op op_type;
10135 #endif
10136 
10137 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10138 		return;
10139 
10140 #ifdef RTE_NET_I40E
10141 	memset(&region_conf, 0, sizeof(region_conf));
10142 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10143 	region_conf.user_priority = res->user_priority_id;
10144 	region_conf.region_id = res->region_id;
10145 
10146 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10147 				op_type, &region_conf);
10148 #endif
10149 
10150 	switch (ret) {
10151 	case 0:
10152 		break;
10153 	case -ENOTSUP:
10154 		fprintf(stderr, "function not implemented or supported\n");
10155 		break;
10156 	default:
10157 		fprintf(stderr, "user_priority region config error: (%s)\n",
10158 			strerror(-ret));
10159 	}
10160 }
10161 
10162 cmdline_parse_token_string_t cmd_user_priority_region_set =
10163 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10164 				set, "set");
10165 cmdline_parse_token_string_t cmd_user_priority_region_port =
10166 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10167 				port, "port");
10168 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10169 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10170 				port_id, RTE_UINT16);
10171 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10172 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10173 				cmd, "queue-region");
10174 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10175 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10176 				user_priority, "UP");
10177 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10178 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10179 				user_priority_id, RTE_UINT8);
10180 cmdline_parse_token_string_t cmd_user_priority_region_region =
10181 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10182 				region, "region_id");
10183 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10184 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10185 				region_id, RTE_UINT8);
10186 
10187 cmdline_parse_inst_t cmd_user_priority_region = {
10188 	.f = cmd_user_priority_region_parsed,
10189 	.data = NULL,
10190 	.help_str = "set port <port_id> queue-region UP <value> "
10191 		"region_id <value>: Set the mapping of User Priority (UP) "
10192 		"to queue region (region_id) ",
10193 	.tokens = {
10194 		(void *)&cmd_user_priority_region_set,
10195 		(void *)&cmd_user_priority_region_port,
10196 		(void *)&cmd_user_priority_region_port_index,
10197 		(void *)&cmd_user_priority_region_cmd,
10198 		(void *)&cmd_user_priority_region_UP,
10199 		(void *)&cmd_user_priority_region_UP_id,
10200 		(void *)&cmd_user_priority_region_region,
10201 		(void *)&cmd_user_priority_region_region_id,
10202 		NULL,
10203 	},
10204 };
10205 
10206 /* *** flush all queue region related configuration *** */
10207 struct cmd_flush_queue_region_result {
10208 	cmdline_fixed_string_t set;
10209 	cmdline_fixed_string_t port;
10210 	portid_t port_id;
10211 	cmdline_fixed_string_t cmd;
10212 	cmdline_fixed_string_t flush;
10213 	cmdline_fixed_string_t what;
10214 };
10215 
10216 static void
10217 cmd_flush_queue_region_parsed(void *parsed_result,
10218 			__rte_unused struct cmdline *cl,
10219 			__rte_unused void *data)
10220 {
10221 	struct cmd_flush_queue_region_result *res = parsed_result;
10222 	int ret = -ENOTSUP;
10223 #ifdef RTE_NET_I40E
10224 	struct rte_pmd_i40e_queue_region_conf region_conf;
10225 	enum rte_pmd_i40e_queue_region_op op_type;
10226 #endif
10227 
10228 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10229 		return;
10230 
10231 #ifdef RTE_NET_I40E
10232 	memset(&region_conf, 0, sizeof(region_conf));
10233 
10234 	if (strcmp(res->what, "on") == 0)
10235 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10236 	else
10237 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10238 
10239 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10240 				op_type, &region_conf);
10241 #endif
10242 
10243 	switch (ret) {
10244 	case 0:
10245 		break;
10246 	case -ENOTSUP:
10247 		fprintf(stderr, "function not implemented or supported\n");
10248 		break;
10249 	default:
10250 		fprintf(stderr, "queue region config flush error: (%s)\n",
10251 			strerror(-ret));
10252 	}
10253 }
10254 
10255 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10256 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10257 				set, "set");
10258 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10259 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10260 				port, "port");
10261 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10262 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10263 				port_id, RTE_UINT16);
10264 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10265 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10266 				cmd, "queue-region");
10267 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10268 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10269 				flush, "flush");
10270 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10271 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10272 				what, "on#off");
10273 
10274 cmdline_parse_inst_t cmd_flush_queue_region = {
10275 	.f = cmd_flush_queue_region_parsed,
10276 	.data = NULL,
10277 	.help_str = "set port <port_id> queue-region flush on|off"
10278 		": flush all queue region related configuration",
10279 	.tokens = {
10280 		(void *)&cmd_flush_queue_region_set,
10281 		(void *)&cmd_flush_queue_region_port,
10282 		(void *)&cmd_flush_queue_region_port_index,
10283 		(void *)&cmd_flush_queue_region_cmd,
10284 		(void *)&cmd_flush_queue_region_flush,
10285 		(void *)&cmd_flush_queue_region_what,
10286 		NULL,
10287 	},
10288 };
10289 
10290 /* *** get all queue region related configuration info *** */
10291 struct cmd_show_queue_region_info {
10292 	cmdline_fixed_string_t show;
10293 	cmdline_fixed_string_t port;
10294 	portid_t port_id;
10295 	cmdline_fixed_string_t cmd;
10296 };
10297 
10298 static void
10299 cmd_show_queue_region_info_parsed(void *parsed_result,
10300 			__rte_unused struct cmdline *cl,
10301 			__rte_unused void *data)
10302 {
10303 	struct cmd_show_queue_region_info *res = parsed_result;
10304 	int ret = -ENOTSUP;
10305 #ifdef RTE_NET_I40E
10306 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10307 	enum rte_pmd_i40e_queue_region_op op_type;
10308 #endif
10309 
10310 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10311 		return;
10312 
10313 #ifdef RTE_NET_I40E
10314 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10315 
10316 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10317 
10318 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10319 					op_type, &rte_pmd_regions);
10320 
10321 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10322 #endif
10323 
10324 	switch (ret) {
10325 	case 0:
10326 		break;
10327 	case -ENOTSUP:
10328 		fprintf(stderr, "function not implemented or supported\n");
10329 		break;
10330 	default:
10331 		fprintf(stderr, "queue region config info show error: (%s)\n",
10332 			strerror(-ret));
10333 	}
10334 }
10335 
10336 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10337 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10338 				show, "show");
10339 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10340 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10341 				port, "port");
10342 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10343 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10344 				port_id, RTE_UINT16);
10345 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10346 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10347 				cmd, "queue-region");
10348 
10349 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10350 	.f = cmd_show_queue_region_info_parsed,
10351 	.data = NULL,
10352 	.help_str = "show port <port_id> queue-region"
10353 		": show all queue region related configuration info",
10354 	.tokens = {
10355 		(void *)&cmd_show_queue_region_info_get,
10356 		(void *)&cmd_show_queue_region_info_port,
10357 		(void *)&cmd_show_queue_region_info_port_index,
10358 		(void *)&cmd_show_queue_region_info_cmd,
10359 		NULL,
10360 	},
10361 };
10362 
10363 /* *** Filters Control *** */
10364 
10365 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10366 do { \
10367 	if ((ip_addr).family == AF_INET) \
10368 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10369 	else { \
10370 		fprintf(stderr, "invalid parameter.\n"); \
10371 		return; \
10372 	} \
10373 } while (0)
10374 
10375 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10376 do { \
10377 	if ((ip_addr).family == AF_INET6) \
10378 		rte_memcpy(&(ip), \
10379 				 &((ip_addr).addr.ipv6), \
10380 				 sizeof(struct in6_addr)); \
10381 	else { \
10382 		fprintf(stderr, "invalid parameter.\n"); \
10383 		return; \
10384 	} \
10385 } while (0)
10386 
10387 #ifdef RTE_NET_I40E
10388 
10389 static uint16_t
10390 str2flowtype(char *string)
10391 {
10392 	uint8_t i = 0;
10393 	static const struct {
10394 		char str[32];
10395 		uint16_t type;
10396 	} flowtype_str[] = {
10397 		{"raw", RTE_ETH_FLOW_RAW},
10398 		{"ipv4", RTE_ETH_FLOW_IPV4},
10399 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10400 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10401 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10402 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10403 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10404 		{"ipv6", RTE_ETH_FLOW_IPV6},
10405 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10406 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10407 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10408 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10409 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10410 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10411 	};
10412 
10413 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10414 		if (!strcmp(flowtype_str[i].str, string))
10415 			return flowtype_str[i].type;
10416 	}
10417 
10418 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10419 		return (uint16_t)atoi(string);
10420 
10421 	return RTE_ETH_FLOW_UNKNOWN;
10422 }
10423 
10424 /* *** deal with flow director filter *** */
10425 struct cmd_flow_director_result {
10426 	cmdline_fixed_string_t flow_director_filter;
10427 	portid_t port_id;
10428 	cmdline_fixed_string_t mode;
10429 	cmdline_fixed_string_t mode_value;
10430 	cmdline_fixed_string_t ops;
10431 	cmdline_fixed_string_t flow;
10432 	cmdline_fixed_string_t flow_type;
10433 	cmdline_fixed_string_t drop;
10434 	cmdline_fixed_string_t queue;
10435 	uint16_t  queue_id;
10436 	cmdline_fixed_string_t fd_id;
10437 	uint32_t  fd_id_value;
10438 	cmdline_fixed_string_t packet;
10439 	char filepath[];
10440 };
10441 
10442 static void
10443 cmd_flow_director_filter_parsed(void *parsed_result,
10444 			  __rte_unused struct cmdline *cl,
10445 			  __rte_unused void *data)
10446 {
10447 	struct cmd_flow_director_result *res = parsed_result;
10448 	int ret = 0;
10449 	struct rte_pmd_i40e_flow_type_mapping
10450 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10451 	struct rte_pmd_i40e_pkt_template_conf conf;
10452 	uint16_t flow_type = str2flowtype(res->flow_type);
10453 	uint16_t i, port = res->port_id;
10454 	uint8_t add;
10455 
10456 	memset(&conf, 0, sizeof(conf));
10457 
10458 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10459 		fprintf(stderr, "Invalid flow type specified.\n");
10460 		return;
10461 	}
10462 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10463 						 mapping);
10464 	if (ret)
10465 		return;
10466 	if (mapping[flow_type].pctype == 0ULL) {
10467 		fprintf(stderr, "Invalid flow type specified.\n");
10468 		return;
10469 	}
10470 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10471 		if (mapping[flow_type].pctype & (1ULL << i)) {
10472 			conf.input.pctype = i;
10473 			break;
10474 		}
10475 	}
10476 
10477 	conf.input.packet = open_file(res->filepath,
10478 				&conf.input.length);
10479 	if (!conf.input.packet)
10480 		return;
10481 	if (!strcmp(res->drop, "drop"))
10482 		conf.action.behavior =
10483 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10484 	else
10485 		conf.action.behavior =
10486 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10487 	conf.action.report_status =
10488 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10489 	conf.action.rx_queue = res->queue_id;
10490 	conf.soft_id = res->fd_id_value;
10491 	add  = strcmp(res->ops, "del") ? 1 : 0;
10492 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10493 							&conf,
10494 							add);
10495 	if (ret < 0)
10496 		fprintf(stderr, "flow director config error: (%s)\n",
10497 			strerror(-ret));
10498 	close_file(conf.input.packet);
10499 }
10500 
10501 cmdline_parse_token_string_t cmd_flow_director_filter =
10502 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10503 				 flow_director_filter, "flow_director_filter");
10504 cmdline_parse_token_num_t cmd_flow_director_port_id =
10505 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10506 			      port_id, RTE_UINT16);
10507 cmdline_parse_token_string_t cmd_flow_director_ops =
10508 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10509 				 ops, "add#del#update");
10510 cmdline_parse_token_string_t cmd_flow_director_flow =
10511 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10512 				 flow, "flow");
10513 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10514 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10515 		flow_type, NULL);
10516 cmdline_parse_token_string_t cmd_flow_director_drop =
10517 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10518 				 drop, "drop#fwd");
10519 cmdline_parse_token_string_t cmd_flow_director_queue =
10520 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10521 				 queue, "queue");
10522 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10523 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10524 			      queue_id, RTE_UINT16);
10525 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10526 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10527 				 fd_id, "fd_id");
10528 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10529 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10530 			      fd_id_value, RTE_UINT32);
10531 
10532 cmdline_parse_token_string_t cmd_flow_director_mode =
10533 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10534 				 mode, "mode");
10535 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10536 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10537 				 mode_value, "raw");
10538 cmdline_parse_token_string_t cmd_flow_director_packet =
10539 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10540 				 packet, "packet");
10541 cmdline_parse_token_string_t cmd_flow_director_filepath =
10542 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10543 				 filepath, NULL);
10544 
10545 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10546 	.f = cmd_flow_director_filter_parsed,
10547 	.data = NULL,
10548 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10549 		"director entry on NIC",
10550 	.tokens = {
10551 		(void *)&cmd_flow_director_filter,
10552 		(void *)&cmd_flow_director_port_id,
10553 		(void *)&cmd_flow_director_mode,
10554 		(void *)&cmd_flow_director_mode_raw,
10555 		(void *)&cmd_flow_director_ops,
10556 		(void *)&cmd_flow_director_flow,
10557 		(void *)&cmd_flow_director_flow_type,
10558 		(void *)&cmd_flow_director_drop,
10559 		(void *)&cmd_flow_director_queue,
10560 		(void *)&cmd_flow_director_queue_id,
10561 		(void *)&cmd_flow_director_fd_id,
10562 		(void *)&cmd_flow_director_fd_id_value,
10563 		(void *)&cmd_flow_director_packet,
10564 		(void *)&cmd_flow_director_filepath,
10565 		NULL,
10566 	},
10567 };
10568 
10569 #endif /* RTE_NET_I40E */
10570 
10571 /* *** deal with flow director mask *** */
10572 struct cmd_flow_director_mask_result {
10573 	cmdline_fixed_string_t flow_director_mask;
10574 	portid_t port_id;
10575 	cmdline_fixed_string_t mode;
10576 	cmdline_fixed_string_t mode_value;
10577 	cmdline_fixed_string_t vlan;
10578 	uint16_t vlan_mask;
10579 	cmdline_fixed_string_t src_mask;
10580 	cmdline_ipaddr_t ipv4_src;
10581 	cmdline_ipaddr_t ipv6_src;
10582 	uint16_t port_src;
10583 	cmdline_fixed_string_t dst_mask;
10584 	cmdline_ipaddr_t ipv4_dst;
10585 	cmdline_ipaddr_t ipv6_dst;
10586 	uint16_t port_dst;
10587 	cmdline_fixed_string_t mac;
10588 	uint8_t mac_addr_byte_mask;
10589 	cmdline_fixed_string_t tunnel_id;
10590 	uint32_t tunnel_id_mask;
10591 	cmdline_fixed_string_t tunnel_type;
10592 	uint8_t tunnel_type_mask;
10593 };
10594 
10595 static void
10596 cmd_flow_director_mask_parsed(void *parsed_result,
10597 			  __rte_unused struct cmdline *cl,
10598 			  __rte_unused void *data)
10599 {
10600 	struct cmd_flow_director_mask_result *res = parsed_result;
10601 	struct rte_eth_fdir_masks *mask;
10602 	struct rte_port *port;
10603 
10604 	port = &ports[res->port_id];
10605 	/** Check if the port is not started **/
10606 	if (port->port_status != RTE_PORT_STOPPED) {
10607 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
10608 		return;
10609 	}
10610 
10611 	mask = &port->dev_conf.fdir_conf.mask;
10612 
10613 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10614 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10615 			fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10616 			return;
10617 		}
10618 
10619 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10620 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10621 		if (strcmp(res->mode_value, "Tunnel")) {
10622 			fprintf(stderr, "Please set mode to Tunnel.\n");
10623 			return;
10624 		}
10625 
10626 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10627 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10628 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10629 		mask->tunnel_type_mask = res->tunnel_type_mask;
10630 	} else {
10631 		if (strcmp(res->mode_value, "IP")) {
10632 			fprintf(stderr, "Please set mode to IP.\n");
10633 			return;
10634 		}
10635 
10636 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10637 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10638 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10639 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10640 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10641 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10642 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10643 	}
10644 
10645 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10646 }
10647 
10648 cmdline_parse_token_string_t cmd_flow_director_mask =
10649 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10650 				 flow_director_mask, "flow_director_mask");
10651 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10652 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10653 			      port_id, RTE_UINT16);
10654 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10655 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10656 				 vlan, "vlan");
10657 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10658 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10659 			      vlan_mask, RTE_UINT16);
10660 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10661 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10662 				 src_mask, "src_mask");
10663 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10664 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10665 				 ipv4_src);
10666 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10667 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10668 				 ipv6_src);
10669 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10670 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10671 			      port_src, RTE_UINT16);
10672 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10673 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10674 				 dst_mask, "dst_mask");
10675 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10676 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10677 				 ipv4_dst);
10678 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10679 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10680 				 ipv6_dst);
10681 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10682 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10683 			      port_dst, RTE_UINT16);
10684 
10685 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10686 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10687 				 mode, "mode");
10688 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10689 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10690 				 mode_value, "IP");
10691 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10692 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10693 				 mode_value, "MAC-VLAN");
10694 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10695 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10696 				 mode_value, "Tunnel");
10697 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10698 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10699 				 mac, "mac");
10700 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10701 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10702 			      mac_addr_byte_mask, RTE_UINT8);
10703 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10704 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10705 				 tunnel_type, "tunnel-type");
10706 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10707 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10708 			      tunnel_type_mask, RTE_UINT8);
10709 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10710 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10711 				 tunnel_id, "tunnel-id");
10712 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10713 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10714 			      tunnel_id_mask, RTE_UINT32);
10715 
10716 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10717 	.f = cmd_flow_director_mask_parsed,
10718 	.data = NULL,
10719 	.help_str = "flow_director_mask ... : "
10720 		"Set IP mode flow director's mask on NIC",
10721 	.tokens = {
10722 		(void *)&cmd_flow_director_mask,
10723 		(void *)&cmd_flow_director_mask_port_id,
10724 		(void *)&cmd_flow_director_mask_mode,
10725 		(void *)&cmd_flow_director_mask_mode_ip,
10726 		(void *)&cmd_flow_director_mask_vlan,
10727 		(void *)&cmd_flow_director_mask_vlan_value,
10728 		(void *)&cmd_flow_director_mask_src,
10729 		(void *)&cmd_flow_director_mask_ipv4_src,
10730 		(void *)&cmd_flow_director_mask_ipv6_src,
10731 		(void *)&cmd_flow_director_mask_port_src,
10732 		(void *)&cmd_flow_director_mask_dst,
10733 		(void *)&cmd_flow_director_mask_ipv4_dst,
10734 		(void *)&cmd_flow_director_mask_ipv6_dst,
10735 		(void *)&cmd_flow_director_mask_port_dst,
10736 		NULL,
10737 	},
10738 };
10739 
10740 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10741 	.f = cmd_flow_director_mask_parsed,
10742 	.data = NULL,
10743 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10744 		"flow director's mask on NIC",
10745 	.tokens = {
10746 		(void *)&cmd_flow_director_mask,
10747 		(void *)&cmd_flow_director_mask_port_id,
10748 		(void *)&cmd_flow_director_mask_mode,
10749 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10750 		(void *)&cmd_flow_director_mask_vlan,
10751 		(void *)&cmd_flow_director_mask_vlan_value,
10752 		NULL,
10753 	},
10754 };
10755 
10756 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10757 	.f = cmd_flow_director_mask_parsed,
10758 	.data = NULL,
10759 	.help_str = "flow_director_mask ... : Set tunnel mode "
10760 		"flow director's mask on NIC",
10761 	.tokens = {
10762 		(void *)&cmd_flow_director_mask,
10763 		(void *)&cmd_flow_director_mask_port_id,
10764 		(void *)&cmd_flow_director_mask_mode,
10765 		(void *)&cmd_flow_director_mask_mode_tunnel,
10766 		(void *)&cmd_flow_director_mask_vlan,
10767 		(void *)&cmd_flow_director_mask_vlan_value,
10768 		(void *)&cmd_flow_director_mask_mac,
10769 		(void *)&cmd_flow_director_mask_mac_value,
10770 		(void *)&cmd_flow_director_mask_tunnel_type,
10771 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10772 		(void *)&cmd_flow_director_mask_tunnel_id,
10773 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10774 		NULL,
10775 	},
10776 };
10777 
10778 /* *** deal with flow director flexible payload configuration *** */
10779 struct cmd_flow_director_flexpayload_result {
10780 	cmdline_fixed_string_t flow_director_flexpayload;
10781 	portid_t port_id;
10782 	cmdline_fixed_string_t payload_layer;
10783 	cmdline_fixed_string_t payload_cfg;
10784 };
10785 
10786 static inline int
10787 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10788 {
10789 	char s[256];
10790 	const char *p, *p0 = q_arg;
10791 	char *end;
10792 	unsigned long int_fld;
10793 	char *str_fld[max_num];
10794 	int i;
10795 	unsigned size;
10796 	int ret = -1;
10797 
10798 	p = strchr(p0, '(');
10799 	if (p == NULL)
10800 		return -1;
10801 	++p;
10802 	p0 = strchr(p, ')');
10803 	if (p0 == NULL)
10804 		return -1;
10805 
10806 	size = p0 - p;
10807 	if (size >= sizeof(s))
10808 		return -1;
10809 
10810 	snprintf(s, sizeof(s), "%.*s", size, p);
10811 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10812 	if (ret < 0 || ret > max_num)
10813 		return -1;
10814 	for (i = 0; i < ret; i++) {
10815 		errno = 0;
10816 		int_fld = strtoul(str_fld[i], &end, 0);
10817 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10818 			return -1;
10819 		offsets[i] = (uint16_t)int_fld;
10820 	}
10821 	return ret;
10822 }
10823 
10824 static void
10825 cmd_flow_director_flxpld_parsed(void *parsed_result,
10826 			  __rte_unused struct cmdline *cl,
10827 			  __rte_unused void *data)
10828 {
10829 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
10830 	struct rte_eth_flex_payload_cfg flex_cfg;
10831 	struct rte_port *port;
10832 	int ret = 0;
10833 
10834 	port = &ports[res->port_id];
10835 	/** Check if the port is not started **/
10836 	if (port->port_status != RTE_PORT_STOPPED) {
10837 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
10838 		return;
10839 	}
10840 
10841 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10842 
10843 	if (!strcmp(res->payload_layer, "raw"))
10844 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10845 	else if (!strcmp(res->payload_layer, "l2"))
10846 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10847 	else if (!strcmp(res->payload_layer, "l3"))
10848 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10849 	else if (!strcmp(res->payload_layer, "l4"))
10850 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10851 
10852 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10853 			    RTE_ETH_FDIR_MAX_FLEXLEN);
10854 	if (ret < 0) {
10855 		fprintf(stderr, "error: Cannot parse flex payload input.\n");
10856 		return;
10857 	}
10858 
10859 	fdir_set_flex_payload(res->port_id, &flex_cfg);
10860 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10861 }
10862 
10863 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10864 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10865 				 flow_director_flexpayload,
10866 				 "flow_director_flex_payload");
10867 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10868 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10869 			      port_id, RTE_UINT16);
10870 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10871 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10872 				 payload_layer, "raw#l2#l3#l4");
10873 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10874 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10875 				 payload_cfg, NULL);
10876 
10877 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10878 	.f = cmd_flow_director_flxpld_parsed,
10879 	.data = NULL,
10880 	.help_str = "flow_director_flexpayload ... : "
10881 		"Set flow director's flex payload on NIC",
10882 	.tokens = {
10883 		(void *)&cmd_flow_director_flexpayload,
10884 		(void *)&cmd_flow_director_flexpayload_port_id,
10885 		(void *)&cmd_flow_director_flexpayload_payload_layer,
10886 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
10887 		NULL,
10888 	},
10889 };
10890 
10891 /* Generic flow interface command. */
10892 extern cmdline_parse_inst_t cmd_flow;
10893 
10894 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10895 struct cmd_mcast_addr_result {
10896 	cmdline_fixed_string_t mcast_addr_cmd;
10897 	cmdline_fixed_string_t what;
10898 	uint16_t port_num;
10899 	struct rte_ether_addr mc_addr;
10900 };
10901 
10902 static void cmd_mcast_addr_parsed(void *parsed_result,
10903 		__rte_unused struct cmdline *cl,
10904 		__rte_unused void *data)
10905 {
10906 	struct cmd_mcast_addr_result *res = parsed_result;
10907 
10908 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10909 		fprintf(stderr,
10910 			"Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10911 			RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10912 		return;
10913 	}
10914 	if (strcmp(res->what, "add") == 0)
10915 		mcast_addr_add(res->port_num, &res->mc_addr);
10916 	else
10917 		mcast_addr_remove(res->port_num, &res->mc_addr);
10918 }
10919 
10920 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10921 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10922 				 mcast_addr_cmd, "mcast_addr");
10923 cmdline_parse_token_string_t cmd_mcast_addr_what =
10924 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10925 				 "add#remove");
10926 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10927 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10928 				 RTE_UINT16);
10929 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10930 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10931 
10932 cmdline_parse_inst_t cmd_mcast_addr = {
10933 	.f = cmd_mcast_addr_parsed,
10934 	.data = (void *)0,
10935 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10936 		"Add/Remove multicast MAC address on port_id",
10937 	.tokens = {
10938 		(void *)&cmd_mcast_addr_cmd,
10939 		(void *)&cmd_mcast_addr_what,
10940 		(void *)&cmd_mcast_addr_portnum,
10941 		(void *)&cmd_mcast_addr_addr,
10942 		NULL,
10943 	},
10944 };
10945 
10946 /* vf vlan anti spoof configuration */
10947 
10948 /* Common result structure for vf vlan anti spoof */
10949 struct cmd_vf_vlan_anti_spoof_result {
10950 	cmdline_fixed_string_t set;
10951 	cmdline_fixed_string_t vf;
10952 	cmdline_fixed_string_t vlan;
10953 	cmdline_fixed_string_t antispoof;
10954 	portid_t port_id;
10955 	uint32_t vf_id;
10956 	cmdline_fixed_string_t on_off;
10957 };
10958 
10959 /* Common CLI fields for vf vlan anti spoof enable disable */
10960 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10961 	TOKEN_STRING_INITIALIZER
10962 		(struct cmd_vf_vlan_anti_spoof_result,
10963 		 set, "set");
10964 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10965 	TOKEN_STRING_INITIALIZER
10966 		(struct cmd_vf_vlan_anti_spoof_result,
10967 		 vf, "vf");
10968 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10969 	TOKEN_STRING_INITIALIZER
10970 		(struct cmd_vf_vlan_anti_spoof_result,
10971 		 vlan, "vlan");
10972 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10973 	TOKEN_STRING_INITIALIZER
10974 		(struct cmd_vf_vlan_anti_spoof_result,
10975 		 antispoof, "antispoof");
10976 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10977 	TOKEN_NUM_INITIALIZER
10978 		(struct cmd_vf_vlan_anti_spoof_result,
10979 		 port_id, RTE_UINT16);
10980 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10981 	TOKEN_NUM_INITIALIZER
10982 		(struct cmd_vf_vlan_anti_spoof_result,
10983 		 vf_id, RTE_UINT32);
10984 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10985 	TOKEN_STRING_INITIALIZER
10986 		(struct cmd_vf_vlan_anti_spoof_result,
10987 		 on_off, "on#off");
10988 
10989 static void
10990 cmd_set_vf_vlan_anti_spoof_parsed(
10991 	void *parsed_result,
10992 	__rte_unused struct cmdline *cl,
10993 	__rte_unused void *data)
10994 {
10995 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10996 	int ret = -ENOTSUP;
10997 
10998 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10999 
11000 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11001 		return;
11002 
11003 #ifdef RTE_NET_IXGBE
11004 	if (ret == -ENOTSUP)
11005 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11006 				res->vf_id, is_on);
11007 #endif
11008 #ifdef RTE_NET_I40E
11009 	if (ret == -ENOTSUP)
11010 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11011 				res->vf_id, is_on);
11012 #endif
11013 #ifdef RTE_NET_BNXT
11014 	if (ret == -ENOTSUP)
11015 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11016 				res->vf_id, is_on);
11017 #endif
11018 
11019 	switch (ret) {
11020 	case 0:
11021 		break;
11022 	case -EINVAL:
11023 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11024 		break;
11025 	case -ENODEV:
11026 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11027 		break;
11028 	case -ENOTSUP:
11029 		fprintf(stderr, "function not implemented\n");
11030 		break;
11031 	default:
11032 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11033 	}
11034 }
11035 
11036 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11037 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
11038 	.data = NULL,
11039 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11040 	.tokens = {
11041 		(void *)&cmd_vf_vlan_anti_spoof_set,
11042 		(void *)&cmd_vf_vlan_anti_spoof_vf,
11043 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
11044 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
11045 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
11046 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
11047 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
11048 		NULL,
11049 	},
11050 };
11051 
11052 /* vf mac anti spoof configuration */
11053 
11054 /* Common result structure for vf mac anti spoof */
11055 struct cmd_vf_mac_anti_spoof_result {
11056 	cmdline_fixed_string_t set;
11057 	cmdline_fixed_string_t vf;
11058 	cmdline_fixed_string_t mac;
11059 	cmdline_fixed_string_t antispoof;
11060 	portid_t port_id;
11061 	uint32_t vf_id;
11062 	cmdline_fixed_string_t on_off;
11063 };
11064 
11065 /* Common CLI fields for vf mac anti spoof enable disable */
11066 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11067 	TOKEN_STRING_INITIALIZER
11068 		(struct cmd_vf_mac_anti_spoof_result,
11069 		 set, "set");
11070 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11071 	TOKEN_STRING_INITIALIZER
11072 		(struct cmd_vf_mac_anti_spoof_result,
11073 		 vf, "vf");
11074 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11075 	TOKEN_STRING_INITIALIZER
11076 		(struct cmd_vf_mac_anti_spoof_result,
11077 		 mac, "mac");
11078 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11079 	TOKEN_STRING_INITIALIZER
11080 		(struct cmd_vf_mac_anti_spoof_result,
11081 		 antispoof, "antispoof");
11082 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11083 	TOKEN_NUM_INITIALIZER
11084 		(struct cmd_vf_mac_anti_spoof_result,
11085 		 port_id, RTE_UINT16);
11086 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11087 	TOKEN_NUM_INITIALIZER
11088 		(struct cmd_vf_mac_anti_spoof_result,
11089 		 vf_id, RTE_UINT32);
11090 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11091 	TOKEN_STRING_INITIALIZER
11092 		(struct cmd_vf_mac_anti_spoof_result,
11093 		 on_off, "on#off");
11094 
11095 static void
11096 cmd_set_vf_mac_anti_spoof_parsed(
11097 	void *parsed_result,
11098 	__rte_unused struct cmdline *cl,
11099 	__rte_unused void *data)
11100 {
11101 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11102 	int ret = -ENOTSUP;
11103 
11104 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11105 
11106 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11107 		return;
11108 
11109 #ifdef RTE_NET_IXGBE
11110 	if (ret == -ENOTSUP)
11111 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11112 			res->vf_id, is_on);
11113 #endif
11114 #ifdef RTE_NET_I40E
11115 	if (ret == -ENOTSUP)
11116 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11117 			res->vf_id, is_on);
11118 #endif
11119 #ifdef RTE_NET_BNXT
11120 	if (ret == -ENOTSUP)
11121 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11122 			res->vf_id, is_on);
11123 #endif
11124 
11125 	switch (ret) {
11126 	case 0:
11127 		break;
11128 	case -EINVAL:
11129 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11130 			res->vf_id, is_on);
11131 		break;
11132 	case -ENODEV:
11133 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11134 		break;
11135 	case -ENOTSUP:
11136 		fprintf(stderr, "function not implemented\n");
11137 		break;
11138 	default:
11139 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11140 	}
11141 }
11142 
11143 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11144 	.f = cmd_set_vf_mac_anti_spoof_parsed,
11145 	.data = NULL,
11146 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11147 	.tokens = {
11148 		(void *)&cmd_vf_mac_anti_spoof_set,
11149 		(void *)&cmd_vf_mac_anti_spoof_vf,
11150 		(void *)&cmd_vf_mac_anti_spoof_mac,
11151 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
11152 		(void *)&cmd_vf_mac_anti_spoof_port_id,
11153 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
11154 		(void *)&cmd_vf_mac_anti_spoof_on_off,
11155 		NULL,
11156 	},
11157 };
11158 
11159 /* vf vlan strip queue configuration */
11160 
11161 /* Common result structure for vf mac anti spoof */
11162 struct cmd_vf_vlan_stripq_result {
11163 	cmdline_fixed_string_t set;
11164 	cmdline_fixed_string_t vf;
11165 	cmdline_fixed_string_t vlan;
11166 	cmdline_fixed_string_t stripq;
11167 	portid_t port_id;
11168 	uint16_t vf_id;
11169 	cmdline_fixed_string_t on_off;
11170 };
11171 
11172 /* Common CLI fields for vf vlan strip enable disable */
11173 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11174 	TOKEN_STRING_INITIALIZER
11175 		(struct cmd_vf_vlan_stripq_result,
11176 		 set, "set");
11177 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11178 	TOKEN_STRING_INITIALIZER
11179 		(struct cmd_vf_vlan_stripq_result,
11180 		 vf, "vf");
11181 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11182 	TOKEN_STRING_INITIALIZER
11183 		(struct cmd_vf_vlan_stripq_result,
11184 		 vlan, "vlan");
11185 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11186 	TOKEN_STRING_INITIALIZER
11187 		(struct cmd_vf_vlan_stripq_result,
11188 		 stripq, "stripq");
11189 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11190 	TOKEN_NUM_INITIALIZER
11191 		(struct cmd_vf_vlan_stripq_result,
11192 		 port_id, RTE_UINT16);
11193 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11194 	TOKEN_NUM_INITIALIZER
11195 		(struct cmd_vf_vlan_stripq_result,
11196 		 vf_id, RTE_UINT16);
11197 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11198 	TOKEN_STRING_INITIALIZER
11199 		(struct cmd_vf_vlan_stripq_result,
11200 		 on_off, "on#off");
11201 
11202 static void
11203 cmd_set_vf_vlan_stripq_parsed(
11204 	void *parsed_result,
11205 	__rte_unused struct cmdline *cl,
11206 	__rte_unused void *data)
11207 {
11208 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
11209 	int ret = -ENOTSUP;
11210 
11211 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11212 
11213 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11214 		return;
11215 
11216 #ifdef RTE_NET_IXGBE
11217 	if (ret == -ENOTSUP)
11218 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11219 			res->vf_id, is_on);
11220 #endif
11221 #ifdef RTE_NET_I40E
11222 	if (ret == -ENOTSUP)
11223 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11224 			res->vf_id, is_on);
11225 #endif
11226 #ifdef RTE_NET_BNXT
11227 	if (ret == -ENOTSUP)
11228 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11229 			res->vf_id, is_on);
11230 #endif
11231 
11232 	switch (ret) {
11233 	case 0:
11234 		break;
11235 	case -EINVAL:
11236 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11237 			res->vf_id, is_on);
11238 		break;
11239 	case -ENODEV:
11240 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11241 		break;
11242 	case -ENOTSUP:
11243 		fprintf(stderr, "function not implemented\n");
11244 		break;
11245 	default:
11246 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11247 	}
11248 }
11249 
11250 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11251 	.f = cmd_set_vf_vlan_stripq_parsed,
11252 	.data = NULL,
11253 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11254 	.tokens = {
11255 		(void *)&cmd_vf_vlan_stripq_set,
11256 		(void *)&cmd_vf_vlan_stripq_vf,
11257 		(void *)&cmd_vf_vlan_stripq_vlan,
11258 		(void *)&cmd_vf_vlan_stripq_stripq,
11259 		(void *)&cmd_vf_vlan_stripq_port_id,
11260 		(void *)&cmd_vf_vlan_stripq_vf_id,
11261 		(void *)&cmd_vf_vlan_stripq_on_off,
11262 		NULL,
11263 	},
11264 };
11265 
11266 /* vf vlan insert configuration */
11267 
11268 /* Common result structure for vf vlan insert */
11269 struct cmd_vf_vlan_insert_result {
11270 	cmdline_fixed_string_t set;
11271 	cmdline_fixed_string_t vf;
11272 	cmdline_fixed_string_t vlan;
11273 	cmdline_fixed_string_t insert;
11274 	portid_t port_id;
11275 	uint16_t vf_id;
11276 	uint16_t vlan_id;
11277 };
11278 
11279 /* Common CLI fields for vf vlan insert enable disable */
11280 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11281 	TOKEN_STRING_INITIALIZER
11282 		(struct cmd_vf_vlan_insert_result,
11283 		 set, "set");
11284 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11285 	TOKEN_STRING_INITIALIZER
11286 		(struct cmd_vf_vlan_insert_result,
11287 		 vf, "vf");
11288 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11289 	TOKEN_STRING_INITIALIZER
11290 		(struct cmd_vf_vlan_insert_result,
11291 		 vlan, "vlan");
11292 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11293 	TOKEN_STRING_INITIALIZER
11294 		(struct cmd_vf_vlan_insert_result,
11295 		 insert, "insert");
11296 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11297 	TOKEN_NUM_INITIALIZER
11298 		(struct cmd_vf_vlan_insert_result,
11299 		 port_id, RTE_UINT16);
11300 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11301 	TOKEN_NUM_INITIALIZER
11302 		(struct cmd_vf_vlan_insert_result,
11303 		 vf_id, RTE_UINT16);
11304 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11305 	TOKEN_NUM_INITIALIZER
11306 		(struct cmd_vf_vlan_insert_result,
11307 		 vlan_id, RTE_UINT16);
11308 
11309 static void
11310 cmd_set_vf_vlan_insert_parsed(
11311 	void *parsed_result,
11312 	__rte_unused struct cmdline *cl,
11313 	__rte_unused void *data)
11314 {
11315 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11316 	int ret = -ENOTSUP;
11317 
11318 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11319 		return;
11320 
11321 #ifdef RTE_NET_IXGBE
11322 	if (ret == -ENOTSUP)
11323 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11324 			res->vlan_id);
11325 #endif
11326 #ifdef RTE_NET_I40E
11327 	if (ret == -ENOTSUP)
11328 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11329 			res->vlan_id);
11330 #endif
11331 #ifdef RTE_NET_BNXT
11332 	if (ret == -ENOTSUP)
11333 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11334 			res->vlan_id);
11335 #endif
11336 
11337 	switch (ret) {
11338 	case 0:
11339 		break;
11340 	case -EINVAL:
11341 		fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11342 			res->vf_id, res->vlan_id);
11343 		break;
11344 	case -ENODEV:
11345 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11346 		break;
11347 	case -ENOTSUP:
11348 		fprintf(stderr, "function not implemented\n");
11349 		break;
11350 	default:
11351 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11352 	}
11353 }
11354 
11355 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11356 	.f = cmd_set_vf_vlan_insert_parsed,
11357 	.data = NULL,
11358 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11359 	.tokens = {
11360 		(void *)&cmd_vf_vlan_insert_set,
11361 		(void *)&cmd_vf_vlan_insert_vf,
11362 		(void *)&cmd_vf_vlan_insert_vlan,
11363 		(void *)&cmd_vf_vlan_insert_insert,
11364 		(void *)&cmd_vf_vlan_insert_port_id,
11365 		(void *)&cmd_vf_vlan_insert_vf_id,
11366 		(void *)&cmd_vf_vlan_insert_vlan_id,
11367 		NULL,
11368 	},
11369 };
11370 
11371 /* tx loopback configuration */
11372 
11373 /* Common result structure for tx loopback */
11374 struct cmd_tx_loopback_result {
11375 	cmdline_fixed_string_t set;
11376 	cmdline_fixed_string_t tx;
11377 	cmdline_fixed_string_t loopback;
11378 	portid_t port_id;
11379 	cmdline_fixed_string_t on_off;
11380 };
11381 
11382 /* Common CLI fields for tx loopback enable disable */
11383 cmdline_parse_token_string_t cmd_tx_loopback_set =
11384 	TOKEN_STRING_INITIALIZER
11385 		(struct cmd_tx_loopback_result,
11386 		 set, "set");
11387 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11388 	TOKEN_STRING_INITIALIZER
11389 		(struct cmd_tx_loopback_result,
11390 		 tx, "tx");
11391 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11392 	TOKEN_STRING_INITIALIZER
11393 		(struct cmd_tx_loopback_result,
11394 		 loopback, "loopback");
11395 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11396 	TOKEN_NUM_INITIALIZER
11397 		(struct cmd_tx_loopback_result,
11398 		 port_id, RTE_UINT16);
11399 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11400 	TOKEN_STRING_INITIALIZER
11401 		(struct cmd_tx_loopback_result,
11402 		 on_off, "on#off");
11403 
11404 static void
11405 cmd_set_tx_loopback_parsed(
11406 	void *parsed_result,
11407 	__rte_unused struct cmdline *cl,
11408 	__rte_unused void *data)
11409 {
11410 	struct cmd_tx_loopback_result *res = parsed_result;
11411 	int ret = -ENOTSUP;
11412 
11413 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11414 
11415 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11416 		return;
11417 
11418 #ifdef RTE_NET_IXGBE
11419 	if (ret == -ENOTSUP)
11420 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11421 #endif
11422 #ifdef RTE_NET_I40E
11423 	if (ret == -ENOTSUP)
11424 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11425 #endif
11426 #ifdef RTE_NET_BNXT
11427 	if (ret == -ENOTSUP)
11428 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11429 #endif
11430 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11431 	if (ret == -ENOTSUP)
11432 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11433 #endif
11434 
11435 	switch (ret) {
11436 	case 0:
11437 		break;
11438 	case -EINVAL:
11439 		fprintf(stderr, "invalid is_on %d\n", is_on);
11440 		break;
11441 	case -ENODEV:
11442 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11443 		break;
11444 	case -ENOTSUP:
11445 		fprintf(stderr, "function not implemented\n");
11446 		break;
11447 	default:
11448 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11449 	}
11450 }
11451 
11452 cmdline_parse_inst_t cmd_set_tx_loopback = {
11453 	.f = cmd_set_tx_loopback_parsed,
11454 	.data = NULL,
11455 	.help_str = "set tx loopback <port_id> on|off",
11456 	.tokens = {
11457 		(void *)&cmd_tx_loopback_set,
11458 		(void *)&cmd_tx_loopback_tx,
11459 		(void *)&cmd_tx_loopback_loopback,
11460 		(void *)&cmd_tx_loopback_port_id,
11461 		(void *)&cmd_tx_loopback_on_off,
11462 		NULL,
11463 	},
11464 };
11465 
11466 /* all queues drop enable configuration */
11467 
11468 /* Common result structure for all queues drop enable */
11469 struct cmd_all_queues_drop_en_result {
11470 	cmdline_fixed_string_t set;
11471 	cmdline_fixed_string_t all;
11472 	cmdline_fixed_string_t queues;
11473 	cmdline_fixed_string_t drop;
11474 	portid_t port_id;
11475 	cmdline_fixed_string_t on_off;
11476 };
11477 
11478 /* Common CLI fields for tx loopback enable disable */
11479 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11480 	TOKEN_STRING_INITIALIZER
11481 		(struct cmd_all_queues_drop_en_result,
11482 		 set, "set");
11483 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11484 	TOKEN_STRING_INITIALIZER
11485 		(struct cmd_all_queues_drop_en_result,
11486 		 all, "all");
11487 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11488 	TOKEN_STRING_INITIALIZER
11489 		(struct cmd_all_queues_drop_en_result,
11490 		 queues, "queues");
11491 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11492 	TOKEN_STRING_INITIALIZER
11493 		(struct cmd_all_queues_drop_en_result,
11494 		 drop, "drop");
11495 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11496 	TOKEN_NUM_INITIALIZER
11497 		(struct cmd_all_queues_drop_en_result,
11498 		 port_id, RTE_UINT16);
11499 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11500 	TOKEN_STRING_INITIALIZER
11501 		(struct cmd_all_queues_drop_en_result,
11502 		 on_off, "on#off");
11503 
11504 static void
11505 cmd_set_all_queues_drop_en_parsed(
11506 	void *parsed_result,
11507 	__rte_unused struct cmdline *cl,
11508 	__rte_unused void *data)
11509 {
11510 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11511 	int ret = -ENOTSUP;
11512 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11513 
11514 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11515 		return;
11516 
11517 #ifdef RTE_NET_IXGBE
11518 	if (ret == -ENOTSUP)
11519 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11520 #endif
11521 #ifdef RTE_NET_BNXT
11522 	if (ret == -ENOTSUP)
11523 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11524 #endif
11525 	switch (ret) {
11526 	case 0:
11527 		break;
11528 	case -EINVAL:
11529 		fprintf(stderr, "invalid is_on %d\n", is_on);
11530 		break;
11531 	case -ENODEV:
11532 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11533 		break;
11534 	case -ENOTSUP:
11535 		fprintf(stderr, "function not implemented\n");
11536 		break;
11537 	default:
11538 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11539 	}
11540 }
11541 
11542 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11543 	.f = cmd_set_all_queues_drop_en_parsed,
11544 	.data = NULL,
11545 	.help_str = "set all queues drop <port_id> on|off",
11546 	.tokens = {
11547 		(void *)&cmd_all_queues_drop_en_set,
11548 		(void *)&cmd_all_queues_drop_en_all,
11549 		(void *)&cmd_all_queues_drop_en_queues,
11550 		(void *)&cmd_all_queues_drop_en_drop,
11551 		(void *)&cmd_all_queues_drop_en_port_id,
11552 		(void *)&cmd_all_queues_drop_en_on_off,
11553 		NULL,
11554 	},
11555 };
11556 
11557 /* vf split drop enable configuration */
11558 
11559 /* Common result structure for vf split drop enable */
11560 struct cmd_vf_split_drop_en_result {
11561 	cmdline_fixed_string_t set;
11562 	cmdline_fixed_string_t vf;
11563 	cmdline_fixed_string_t split;
11564 	cmdline_fixed_string_t drop;
11565 	portid_t port_id;
11566 	uint16_t vf_id;
11567 	cmdline_fixed_string_t on_off;
11568 };
11569 
11570 /* Common CLI fields for vf split drop enable disable */
11571 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11572 	TOKEN_STRING_INITIALIZER
11573 		(struct cmd_vf_split_drop_en_result,
11574 		 set, "set");
11575 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11576 	TOKEN_STRING_INITIALIZER
11577 		(struct cmd_vf_split_drop_en_result,
11578 		 vf, "vf");
11579 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11580 	TOKEN_STRING_INITIALIZER
11581 		(struct cmd_vf_split_drop_en_result,
11582 		 split, "split");
11583 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11584 	TOKEN_STRING_INITIALIZER
11585 		(struct cmd_vf_split_drop_en_result,
11586 		 drop, "drop");
11587 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11588 	TOKEN_NUM_INITIALIZER
11589 		(struct cmd_vf_split_drop_en_result,
11590 		 port_id, RTE_UINT16);
11591 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11592 	TOKEN_NUM_INITIALIZER
11593 		(struct cmd_vf_split_drop_en_result,
11594 		 vf_id, RTE_UINT16);
11595 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11596 	TOKEN_STRING_INITIALIZER
11597 		(struct cmd_vf_split_drop_en_result,
11598 		 on_off, "on#off");
11599 
11600 static void
11601 cmd_set_vf_split_drop_en_parsed(
11602 	void *parsed_result,
11603 	__rte_unused struct cmdline *cl,
11604 	__rte_unused void *data)
11605 {
11606 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11607 	int ret = -ENOTSUP;
11608 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11609 
11610 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11611 		return;
11612 
11613 #ifdef RTE_NET_IXGBE
11614 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11615 			is_on);
11616 #endif
11617 	switch (ret) {
11618 	case 0:
11619 		break;
11620 	case -EINVAL:
11621 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11622 			res->vf_id, is_on);
11623 		break;
11624 	case -ENODEV:
11625 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11626 		break;
11627 	case -ENOTSUP:
11628 		fprintf(stderr, "not supported on port %d\n", res->port_id);
11629 		break;
11630 	default:
11631 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11632 	}
11633 }
11634 
11635 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11636 	.f = cmd_set_vf_split_drop_en_parsed,
11637 	.data = NULL,
11638 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11639 	.tokens = {
11640 		(void *)&cmd_vf_split_drop_en_set,
11641 		(void *)&cmd_vf_split_drop_en_vf,
11642 		(void *)&cmd_vf_split_drop_en_split,
11643 		(void *)&cmd_vf_split_drop_en_drop,
11644 		(void *)&cmd_vf_split_drop_en_port_id,
11645 		(void *)&cmd_vf_split_drop_en_vf_id,
11646 		(void *)&cmd_vf_split_drop_en_on_off,
11647 		NULL,
11648 	},
11649 };
11650 
11651 /* vf mac address configuration */
11652 
11653 /* Common result structure for vf mac address */
11654 struct cmd_set_vf_mac_addr_result {
11655 	cmdline_fixed_string_t set;
11656 	cmdline_fixed_string_t vf;
11657 	cmdline_fixed_string_t mac;
11658 	cmdline_fixed_string_t addr;
11659 	portid_t port_id;
11660 	uint16_t vf_id;
11661 	struct rte_ether_addr mac_addr;
11662 
11663 };
11664 
11665 /* Common CLI fields for vf split drop enable disable */
11666 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11667 	TOKEN_STRING_INITIALIZER
11668 		(struct cmd_set_vf_mac_addr_result,
11669 		 set, "set");
11670 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11671 	TOKEN_STRING_INITIALIZER
11672 		(struct cmd_set_vf_mac_addr_result,
11673 		 vf, "vf");
11674 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11675 	TOKEN_STRING_INITIALIZER
11676 		(struct cmd_set_vf_mac_addr_result,
11677 		 mac, "mac");
11678 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11679 	TOKEN_STRING_INITIALIZER
11680 		(struct cmd_set_vf_mac_addr_result,
11681 		 addr, "addr");
11682 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11683 	TOKEN_NUM_INITIALIZER
11684 		(struct cmd_set_vf_mac_addr_result,
11685 		 port_id, RTE_UINT16);
11686 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11687 	TOKEN_NUM_INITIALIZER
11688 		(struct cmd_set_vf_mac_addr_result,
11689 		 vf_id, RTE_UINT16);
11690 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11691 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11692 		 mac_addr);
11693 
11694 static void
11695 cmd_set_vf_mac_addr_parsed(
11696 	void *parsed_result,
11697 	__rte_unused struct cmdline *cl,
11698 	__rte_unused void *data)
11699 {
11700 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11701 	int ret = -ENOTSUP;
11702 
11703 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11704 		return;
11705 
11706 #ifdef RTE_NET_IXGBE
11707 	if (ret == -ENOTSUP)
11708 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11709 				&res->mac_addr);
11710 #endif
11711 #ifdef RTE_NET_I40E
11712 	if (ret == -ENOTSUP)
11713 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11714 				&res->mac_addr);
11715 #endif
11716 #ifdef RTE_NET_BNXT
11717 	if (ret == -ENOTSUP)
11718 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11719 				&res->mac_addr);
11720 #endif
11721 
11722 	switch (ret) {
11723 	case 0:
11724 		break;
11725 	case -EINVAL:
11726 		fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11727 		break;
11728 	case -ENODEV:
11729 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11730 		break;
11731 	case -ENOTSUP:
11732 		fprintf(stderr, "function not implemented\n");
11733 		break;
11734 	default:
11735 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11736 	}
11737 }
11738 
11739 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11740 	.f = cmd_set_vf_mac_addr_parsed,
11741 	.data = NULL,
11742 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11743 	.tokens = {
11744 		(void *)&cmd_set_vf_mac_addr_set,
11745 		(void *)&cmd_set_vf_mac_addr_vf,
11746 		(void *)&cmd_set_vf_mac_addr_mac,
11747 		(void *)&cmd_set_vf_mac_addr_addr,
11748 		(void *)&cmd_set_vf_mac_addr_port_id,
11749 		(void *)&cmd_set_vf_mac_addr_vf_id,
11750 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11751 		NULL,
11752 	},
11753 };
11754 
11755 /* MACsec configuration */
11756 
11757 /* Common result structure for MACsec offload enable */
11758 struct cmd_macsec_offload_on_result {
11759 	cmdline_fixed_string_t set;
11760 	cmdline_fixed_string_t macsec;
11761 	cmdline_fixed_string_t offload;
11762 	portid_t port_id;
11763 	cmdline_fixed_string_t on;
11764 	cmdline_fixed_string_t encrypt;
11765 	cmdline_fixed_string_t en_on_off;
11766 	cmdline_fixed_string_t replay_protect;
11767 	cmdline_fixed_string_t rp_on_off;
11768 };
11769 
11770 /* Common CLI fields for MACsec offload disable */
11771 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11772 	TOKEN_STRING_INITIALIZER
11773 		(struct cmd_macsec_offload_on_result,
11774 		 set, "set");
11775 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11776 	TOKEN_STRING_INITIALIZER
11777 		(struct cmd_macsec_offload_on_result,
11778 		 macsec, "macsec");
11779 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11780 	TOKEN_STRING_INITIALIZER
11781 		(struct cmd_macsec_offload_on_result,
11782 		 offload, "offload");
11783 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11784 	TOKEN_NUM_INITIALIZER
11785 		(struct cmd_macsec_offload_on_result,
11786 		 port_id, RTE_UINT16);
11787 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11788 	TOKEN_STRING_INITIALIZER
11789 		(struct cmd_macsec_offload_on_result,
11790 		 on, "on");
11791 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11792 	TOKEN_STRING_INITIALIZER
11793 		(struct cmd_macsec_offload_on_result,
11794 		 encrypt, "encrypt");
11795 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11796 	TOKEN_STRING_INITIALIZER
11797 		(struct cmd_macsec_offload_on_result,
11798 		 en_on_off, "on#off");
11799 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11800 	TOKEN_STRING_INITIALIZER
11801 		(struct cmd_macsec_offload_on_result,
11802 		 replay_protect, "replay-protect");
11803 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11804 	TOKEN_STRING_INITIALIZER
11805 		(struct cmd_macsec_offload_on_result,
11806 		 rp_on_off, "on#off");
11807 
11808 static void
11809 cmd_set_macsec_offload_on_parsed(
11810 	void *parsed_result,
11811 	__rte_unused struct cmdline *cl,
11812 	__rte_unused void *data)
11813 {
11814 	struct cmd_macsec_offload_on_result *res = parsed_result;
11815 	int ret = -ENOTSUP;
11816 	portid_t port_id = res->port_id;
11817 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11818 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11819 	struct rte_eth_dev_info dev_info;
11820 
11821 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11822 		return;
11823 	if (!port_is_stopped(port_id)) {
11824 		fprintf(stderr, "Please stop port %d first\n", port_id);
11825 		return;
11826 	}
11827 
11828 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11829 	if (ret != 0)
11830 		return;
11831 
11832 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11833 #ifdef RTE_NET_IXGBE
11834 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11835 #endif
11836 	}
11837 	RTE_SET_USED(en);
11838 	RTE_SET_USED(rp);
11839 
11840 	switch (ret) {
11841 	case 0:
11842 		ports[port_id].dev_conf.txmode.offloads |=
11843 						DEV_TX_OFFLOAD_MACSEC_INSERT;
11844 		cmd_reconfig_device_queue(port_id, 1, 1);
11845 		break;
11846 	case -ENODEV:
11847 		fprintf(stderr, "invalid port_id %d\n", port_id);
11848 		break;
11849 	case -ENOTSUP:
11850 		fprintf(stderr, "not supported on port %d\n", port_id);
11851 		break;
11852 	default:
11853 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11854 	}
11855 }
11856 
11857 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11858 	.f = cmd_set_macsec_offload_on_parsed,
11859 	.data = NULL,
11860 	.help_str = "set macsec offload <port_id> on "
11861 		"encrypt on|off replay-protect on|off",
11862 	.tokens = {
11863 		(void *)&cmd_macsec_offload_on_set,
11864 		(void *)&cmd_macsec_offload_on_macsec,
11865 		(void *)&cmd_macsec_offload_on_offload,
11866 		(void *)&cmd_macsec_offload_on_port_id,
11867 		(void *)&cmd_macsec_offload_on_on,
11868 		(void *)&cmd_macsec_offload_on_encrypt,
11869 		(void *)&cmd_macsec_offload_on_en_on_off,
11870 		(void *)&cmd_macsec_offload_on_replay_protect,
11871 		(void *)&cmd_macsec_offload_on_rp_on_off,
11872 		NULL,
11873 	},
11874 };
11875 
11876 /* Common result structure for MACsec offload disable */
11877 struct cmd_macsec_offload_off_result {
11878 	cmdline_fixed_string_t set;
11879 	cmdline_fixed_string_t macsec;
11880 	cmdline_fixed_string_t offload;
11881 	portid_t port_id;
11882 	cmdline_fixed_string_t off;
11883 };
11884 
11885 /* Common CLI fields for MACsec offload disable */
11886 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11887 	TOKEN_STRING_INITIALIZER
11888 		(struct cmd_macsec_offload_off_result,
11889 		 set, "set");
11890 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11891 	TOKEN_STRING_INITIALIZER
11892 		(struct cmd_macsec_offload_off_result,
11893 		 macsec, "macsec");
11894 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11895 	TOKEN_STRING_INITIALIZER
11896 		(struct cmd_macsec_offload_off_result,
11897 		 offload, "offload");
11898 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11899 	TOKEN_NUM_INITIALIZER
11900 		(struct cmd_macsec_offload_off_result,
11901 		 port_id, RTE_UINT16);
11902 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11903 	TOKEN_STRING_INITIALIZER
11904 		(struct cmd_macsec_offload_off_result,
11905 		 off, "off");
11906 
11907 static void
11908 cmd_set_macsec_offload_off_parsed(
11909 	void *parsed_result,
11910 	__rte_unused struct cmdline *cl,
11911 	__rte_unused void *data)
11912 {
11913 	struct cmd_macsec_offload_off_result *res = parsed_result;
11914 	int ret = -ENOTSUP;
11915 	struct rte_eth_dev_info dev_info;
11916 	portid_t port_id = res->port_id;
11917 
11918 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11919 		return;
11920 	if (!port_is_stopped(port_id)) {
11921 		fprintf(stderr, "Please stop port %d first\n", port_id);
11922 		return;
11923 	}
11924 
11925 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11926 	if (ret != 0)
11927 		return;
11928 
11929 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11930 #ifdef RTE_NET_IXGBE
11931 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
11932 #endif
11933 	}
11934 	switch (ret) {
11935 	case 0:
11936 		ports[port_id].dev_conf.txmode.offloads &=
11937 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
11938 		cmd_reconfig_device_queue(port_id, 1, 1);
11939 		break;
11940 	case -ENODEV:
11941 		fprintf(stderr, "invalid port_id %d\n", port_id);
11942 		break;
11943 	case -ENOTSUP:
11944 		fprintf(stderr, "not supported on port %d\n", port_id);
11945 		break;
11946 	default:
11947 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11948 	}
11949 }
11950 
11951 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11952 	.f = cmd_set_macsec_offload_off_parsed,
11953 	.data = NULL,
11954 	.help_str = "set macsec offload <port_id> off",
11955 	.tokens = {
11956 		(void *)&cmd_macsec_offload_off_set,
11957 		(void *)&cmd_macsec_offload_off_macsec,
11958 		(void *)&cmd_macsec_offload_off_offload,
11959 		(void *)&cmd_macsec_offload_off_port_id,
11960 		(void *)&cmd_macsec_offload_off_off,
11961 		NULL,
11962 	},
11963 };
11964 
11965 /* Common result structure for MACsec secure connection configure */
11966 struct cmd_macsec_sc_result {
11967 	cmdline_fixed_string_t set;
11968 	cmdline_fixed_string_t macsec;
11969 	cmdline_fixed_string_t sc;
11970 	cmdline_fixed_string_t tx_rx;
11971 	portid_t port_id;
11972 	struct rte_ether_addr mac;
11973 	uint16_t pi;
11974 };
11975 
11976 /* Common CLI fields for MACsec secure connection configure */
11977 cmdline_parse_token_string_t cmd_macsec_sc_set =
11978 	TOKEN_STRING_INITIALIZER
11979 		(struct cmd_macsec_sc_result,
11980 		 set, "set");
11981 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11982 	TOKEN_STRING_INITIALIZER
11983 		(struct cmd_macsec_sc_result,
11984 		 macsec, "macsec");
11985 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11986 	TOKEN_STRING_INITIALIZER
11987 		(struct cmd_macsec_sc_result,
11988 		 sc, "sc");
11989 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11990 	TOKEN_STRING_INITIALIZER
11991 		(struct cmd_macsec_sc_result,
11992 		 tx_rx, "tx#rx");
11993 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11994 	TOKEN_NUM_INITIALIZER
11995 		(struct cmd_macsec_sc_result,
11996 		 port_id, RTE_UINT16);
11997 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11998 	TOKEN_ETHERADDR_INITIALIZER
11999 		(struct cmd_macsec_sc_result,
12000 		 mac);
12001 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12002 	TOKEN_NUM_INITIALIZER
12003 		(struct cmd_macsec_sc_result,
12004 		 pi, RTE_UINT16);
12005 
12006 static void
12007 cmd_set_macsec_sc_parsed(
12008 	void *parsed_result,
12009 	__rte_unused struct cmdline *cl,
12010 	__rte_unused void *data)
12011 {
12012 	struct cmd_macsec_sc_result *res = parsed_result;
12013 	int ret = -ENOTSUP;
12014 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12015 
12016 #ifdef RTE_NET_IXGBE
12017 	ret = is_tx ?
12018 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12019 				res->mac.addr_bytes) :
12020 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12021 				res->mac.addr_bytes, res->pi);
12022 #endif
12023 	RTE_SET_USED(is_tx);
12024 
12025 	switch (ret) {
12026 	case 0:
12027 		break;
12028 	case -ENODEV:
12029 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12030 		break;
12031 	case -ENOTSUP:
12032 		fprintf(stderr, "not supported on port %d\n", res->port_id);
12033 		break;
12034 	default:
12035 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12036 	}
12037 }
12038 
12039 cmdline_parse_inst_t cmd_set_macsec_sc = {
12040 	.f = cmd_set_macsec_sc_parsed,
12041 	.data = NULL,
12042 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12043 	.tokens = {
12044 		(void *)&cmd_macsec_sc_set,
12045 		(void *)&cmd_macsec_sc_macsec,
12046 		(void *)&cmd_macsec_sc_sc,
12047 		(void *)&cmd_macsec_sc_tx_rx,
12048 		(void *)&cmd_macsec_sc_port_id,
12049 		(void *)&cmd_macsec_sc_mac,
12050 		(void *)&cmd_macsec_sc_pi,
12051 		NULL,
12052 	},
12053 };
12054 
12055 /* Common result structure for MACsec secure connection configure */
12056 struct cmd_macsec_sa_result {
12057 	cmdline_fixed_string_t set;
12058 	cmdline_fixed_string_t macsec;
12059 	cmdline_fixed_string_t sa;
12060 	cmdline_fixed_string_t tx_rx;
12061 	portid_t port_id;
12062 	uint8_t idx;
12063 	uint8_t an;
12064 	uint32_t pn;
12065 	cmdline_fixed_string_t key;
12066 };
12067 
12068 /* Common CLI fields for MACsec secure connection configure */
12069 cmdline_parse_token_string_t cmd_macsec_sa_set =
12070 	TOKEN_STRING_INITIALIZER
12071 		(struct cmd_macsec_sa_result,
12072 		 set, "set");
12073 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12074 	TOKEN_STRING_INITIALIZER
12075 		(struct cmd_macsec_sa_result,
12076 		 macsec, "macsec");
12077 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12078 	TOKEN_STRING_INITIALIZER
12079 		(struct cmd_macsec_sa_result,
12080 		 sa, "sa");
12081 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12082 	TOKEN_STRING_INITIALIZER
12083 		(struct cmd_macsec_sa_result,
12084 		 tx_rx, "tx#rx");
12085 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12086 	TOKEN_NUM_INITIALIZER
12087 		(struct cmd_macsec_sa_result,
12088 		 port_id, RTE_UINT16);
12089 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12090 	TOKEN_NUM_INITIALIZER
12091 		(struct cmd_macsec_sa_result,
12092 		 idx, RTE_UINT8);
12093 cmdline_parse_token_num_t cmd_macsec_sa_an =
12094 	TOKEN_NUM_INITIALIZER
12095 		(struct cmd_macsec_sa_result,
12096 		 an, RTE_UINT8);
12097 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12098 	TOKEN_NUM_INITIALIZER
12099 		(struct cmd_macsec_sa_result,
12100 		 pn, RTE_UINT32);
12101 cmdline_parse_token_string_t cmd_macsec_sa_key =
12102 	TOKEN_STRING_INITIALIZER
12103 		(struct cmd_macsec_sa_result,
12104 		 key, NULL);
12105 
12106 static void
12107 cmd_set_macsec_sa_parsed(
12108 	void *parsed_result,
12109 	__rte_unused struct cmdline *cl,
12110 	__rte_unused void *data)
12111 {
12112 	struct cmd_macsec_sa_result *res = parsed_result;
12113 	int ret = -ENOTSUP;
12114 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12115 	uint8_t key[16] = { 0 };
12116 	uint8_t xdgt0;
12117 	uint8_t xdgt1;
12118 	int key_len;
12119 	int i;
12120 
12121 	key_len = strlen(res->key) / 2;
12122 	if (key_len > 16)
12123 		key_len = 16;
12124 
12125 	for (i = 0; i < key_len; i++) {
12126 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12127 		if (xdgt0 == 0xFF)
12128 			return;
12129 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12130 		if (xdgt1 == 0xFF)
12131 			return;
12132 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12133 	}
12134 
12135 #ifdef RTE_NET_IXGBE
12136 	ret = is_tx ?
12137 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12138 			res->idx, res->an, res->pn, key) :
12139 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12140 			res->idx, res->an, res->pn, key);
12141 #endif
12142 	RTE_SET_USED(is_tx);
12143 	RTE_SET_USED(key);
12144 
12145 	switch (ret) {
12146 	case 0:
12147 		break;
12148 	case -EINVAL:
12149 		fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12150 		break;
12151 	case -ENODEV:
12152 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12153 		break;
12154 	case -ENOTSUP:
12155 		fprintf(stderr, "not supported on port %d\n", res->port_id);
12156 		break;
12157 	default:
12158 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12159 	}
12160 }
12161 
12162 cmdline_parse_inst_t cmd_set_macsec_sa = {
12163 	.f = cmd_set_macsec_sa_parsed,
12164 	.data = NULL,
12165 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12166 	.tokens = {
12167 		(void *)&cmd_macsec_sa_set,
12168 		(void *)&cmd_macsec_sa_macsec,
12169 		(void *)&cmd_macsec_sa_sa,
12170 		(void *)&cmd_macsec_sa_tx_rx,
12171 		(void *)&cmd_macsec_sa_port_id,
12172 		(void *)&cmd_macsec_sa_idx,
12173 		(void *)&cmd_macsec_sa_an,
12174 		(void *)&cmd_macsec_sa_pn,
12175 		(void *)&cmd_macsec_sa_key,
12176 		NULL,
12177 	},
12178 };
12179 
12180 /* VF unicast promiscuous mode configuration */
12181 
12182 /* Common result structure for VF unicast promiscuous mode */
12183 struct cmd_vf_promisc_result {
12184 	cmdline_fixed_string_t set;
12185 	cmdline_fixed_string_t vf;
12186 	cmdline_fixed_string_t promisc;
12187 	portid_t port_id;
12188 	uint32_t vf_id;
12189 	cmdline_fixed_string_t on_off;
12190 };
12191 
12192 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12193 cmdline_parse_token_string_t cmd_vf_promisc_set =
12194 	TOKEN_STRING_INITIALIZER
12195 		(struct cmd_vf_promisc_result,
12196 		 set, "set");
12197 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12198 	TOKEN_STRING_INITIALIZER
12199 		(struct cmd_vf_promisc_result,
12200 		 vf, "vf");
12201 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12202 	TOKEN_STRING_INITIALIZER
12203 		(struct cmd_vf_promisc_result,
12204 		 promisc, "promisc");
12205 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12206 	TOKEN_NUM_INITIALIZER
12207 		(struct cmd_vf_promisc_result,
12208 		 port_id, RTE_UINT16);
12209 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12210 	TOKEN_NUM_INITIALIZER
12211 		(struct cmd_vf_promisc_result,
12212 		 vf_id, RTE_UINT32);
12213 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12214 	TOKEN_STRING_INITIALIZER
12215 		(struct cmd_vf_promisc_result,
12216 		 on_off, "on#off");
12217 
12218 static void
12219 cmd_set_vf_promisc_parsed(
12220 	void *parsed_result,
12221 	__rte_unused struct cmdline *cl,
12222 	__rte_unused void *data)
12223 {
12224 	struct cmd_vf_promisc_result *res = parsed_result;
12225 	int ret = -ENOTSUP;
12226 
12227 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12228 
12229 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12230 		return;
12231 
12232 #ifdef RTE_NET_I40E
12233 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12234 						  res->vf_id, is_on);
12235 #endif
12236 
12237 	switch (ret) {
12238 	case 0:
12239 		break;
12240 	case -EINVAL:
12241 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12242 		break;
12243 	case -ENODEV:
12244 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12245 		break;
12246 	case -ENOTSUP:
12247 		fprintf(stderr, "function not implemented\n");
12248 		break;
12249 	default:
12250 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12251 	}
12252 }
12253 
12254 cmdline_parse_inst_t cmd_set_vf_promisc = {
12255 	.f = cmd_set_vf_promisc_parsed,
12256 	.data = NULL,
12257 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
12258 		"Set unicast promiscuous mode for a VF from the PF",
12259 	.tokens = {
12260 		(void *)&cmd_vf_promisc_set,
12261 		(void *)&cmd_vf_promisc_vf,
12262 		(void *)&cmd_vf_promisc_promisc,
12263 		(void *)&cmd_vf_promisc_port_id,
12264 		(void *)&cmd_vf_promisc_vf_id,
12265 		(void *)&cmd_vf_promisc_on_off,
12266 		NULL,
12267 	},
12268 };
12269 
12270 /* VF multicast promiscuous mode configuration */
12271 
12272 /* Common result structure for VF multicast promiscuous mode */
12273 struct cmd_vf_allmulti_result {
12274 	cmdline_fixed_string_t set;
12275 	cmdline_fixed_string_t vf;
12276 	cmdline_fixed_string_t allmulti;
12277 	portid_t port_id;
12278 	uint32_t vf_id;
12279 	cmdline_fixed_string_t on_off;
12280 };
12281 
12282 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12283 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12284 	TOKEN_STRING_INITIALIZER
12285 		(struct cmd_vf_allmulti_result,
12286 		 set, "set");
12287 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12288 	TOKEN_STRING_INITIALIZER
12289 		(struct cmd_vf_allmulti_result,
12290 		 vf, "vf");
12291 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12292 	TOKEN_STRING_INITIALIZER
12293 		(struct cmd_vf_allmulti_result,
12294 		 allmulti, "allmulti");
12295 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12296 	TOKEN_NUM_INITIALIZER
12297 		(struct cmd_vf_allmulti_result,
12298 		 port_id, RTE_UINT16);
12299 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12300 	TOKEN_NUM_INITIALIZER
12301 		(struct cmd_vf_allmulti_result,
12302 		 vf_id, RTE_UINT32);
12303 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12304 	TOKEN_STRING_INITIALIZER
12305 		(struct cmd_vf_allmulti_result,
12306 		 on_off, "on#off");
12307 
12308 static void
12309 cmd_set_vf_allmulti_parsed(
12310 	void *parsed_result,
12311 	__rte_unused struct cmdline *cl,
12312 	__rte_unused void *data)
12313 {
12314 	struct cmd_vf_allmulti_result *res = parsed_result;
12315 	int ret = -ENOTSUP;
12316 
12317 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12318 
12319 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12320 		return;
12321 
12322 #ifdef RTE_NET_I40E
12323 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12324 						    res->vf_id, is_on);
12325 #endif
12326 
12327 	switch (ret) {
12328 	case 0:
12329 		break;
12330 	case -EINVAL:
12331 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12332 		break;
12333 	case -ENODEV:
12334 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12335 		break;
12336 	case -ENOTSUP:
12337 		fprintf(stderr, "function not implemented\n");
12338 		break;
12339 	default:
12340 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12341 	}
12342 }
12343 
12344 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12345 	.f = cmd_set_vf_allmulti_parsed,
12346 	.data = NULL,
12347 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12348 		"Set multicast promiscuous mode for a VF from the PF",
12349 	.tokens = {
12350 		(void *)&cmd_vf_allmulti_set,
12351 		(void *)&cmd_vf_allmulti_vf,
12352 		(void *)&cmd_vf_allmulti_allmulti,
12353 		(void *)&cmd_vf_allmulti_port_id,
12354 		(void *)&cmd_vf_allmulti_vf_id,
12355 		(void *)&cmd_vf_allmulti_on_off,
12356 		NULL,
12357 	},
12358 };
12359 
12360 /* vf broadcast mode configuration */
12361 
12362 /* Common result structure for vf broadcast */
12363 struct cmd_set_vf_broadcast_result {
12364 	cmdline_fixed_string_t set;
12365 	cmdline_fixed_string_t vf;
12366 	cmdline_fixed_string_t broadcast;
12367 	portid_t port_id;
12368 	uint16_t vf_id;
12369 	cmdline_fixed_string_t on_off;
12370 };
12371 
12372 /* Common CLI fields for vf broadcast enable disable */
12373 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12374 	TOKEN_STRING_INITIALIZER
12375 		(struct cmd_set_vf_broadcast_result,
12376 		 set, "set");
12377 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12378 	TOKEN_STRING_INITIALIZER
12379 		(struct cmd_set_vf_broadcast_result,
12380 		 vf, "vf");
12381 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12382 	TOKEN_STRING_INITIALIZER
12383 		(struct cmd_set_vf_broadcast_result,
12384 		 broadcast, "broadcast");
12385 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12386 	TOKEN_NUM_INITIALIZER
12387 		(struct cmd_set_vf_broadcast_result,
12388 		 port_id, RTE_UINT16);
12389 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12390 	TOKEN_NUM_INITIALIZER
12391 		(struct cmd_set_vf_broadcast_result,
12392 		 vf_id, RTE_UINT16);
12393 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12394 	TOKEN_STRING_INITIALIZER
12395 		(struct cmd_set_vf_broadcast_result,
12396 		 on_off, "on#off");
12397 
12398 static void
12399 cmd_set_vf_broadcast_parsed(
12400 	void *parsed_result,
12401 	__rte_unused struct cmdline *cl,
12402 	__rte_unused void *data)
12403 {
12404 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12405 	int ret = -ENOTSUP;
12406 
12407 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12408 
12409 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12410 		return;
12411 
12412 #ifdef RTE_NET_I40E
12413 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12414 					    res->vf_id, is_on);
12415 #endif
12416 
12417 	switch (ret) {
12418 	case 0:
12419 		break;
12420 	case -EINVAL:
12421 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12422 			res->vf_id, is_on);
12423 		break;
12424 	case -ENODEV:
12425 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12426 		break;
12427 	case -ENOTSUP:
12428 		fprintf(stderr, "function not implemented\n");
12429 		break;
12430 	default:
12431 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12432 	}
12433 }
12434 
12435 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12436 	.f = cmd_set_vf_broadcast_parsed,
12437 	.data = NULL,
12438 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12439 	.tokens = {
12440 		(void *)&cmd_set_vf_broadcast_set,
12441 		(void *)&cmd_set_vf_broadcast_vf,
12442 		(void *)&cmd_set_vf_broadcast_broadcast,
12443 		(void *)&cmd_set_vf_broadcast_port_id,
12444 		(void *)&cmd_set_vf_broadcast_vf_id,
12445 		(void *)&cmd_set_vf_broadcast_on_off,
12446 		NULL,
12447 	},
12448 };
12449 
12450 /* vf vlan tag configuration */
12451 
12452 /* Common result structure for vf vlan tag */
12453 struct cmd_set_vf_vlan_tag_result {
12454 	cmdline_fixed_string_t set;
12455 	cmdline_fixed_string_t vf;
12456 	cmdline_fixed_string_t vlan;
12457 	cmdline_fixed_string_t tag;
12458 	portid_t port_id;
12459 	uint16_t vf_id;
12460 	cmdline_fixed_string_t on_off;
12461 };
12462 
12463 /* Common CLI fields for vf vlan tag enable disable */
12464 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12465 	TOKEN_STRING_INITIALIZER
12466 		(struct cmd_set_vf_vlan_tag_result,
12467 		 set, "set");
12468 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12469 	TOKEN_STRING_INITIALIZER
12470 		(struct cmd_set_vf_vlan_tag_result,
12471 		 vf, "vf");
12472 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12473 	TOKEN_STRING_INITIALIZER
12474 		(struct cmd_set_vf_vlan_tag_result,
12475 		 vlan, "vlan");
12476 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12477 	TOKEN_STRING_INITIALIZER
12478 		(struct cmd_set_vf_vlan_tag_result,
12479 		 tag, "tag");
12480 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12481 	TOKEN_NUM_INITIALIZER
12482 		(struct cmd_set_vf_vlan_tag_result,
12483 		 port_id, RTE_UINT16);
12484 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12485 	TOKEN_NUM_INITIALIZER
12486 		(struct cmd_set_vf_vlan_tag_result,
12487 		 vf_id, RTE_UINT16);
12488 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12489 	TOKEN_STRING_INITIALIZER
12490 		(struct cmd_set_vf_vlan_tag_result,
12491 		 on_off, "on#off");
12492 
12493 static void
12494 cmd_set_vf_vlan_tag_parsed(
12495 	void *parsed_result,
12496 	__rte_unused struct cmdline *cl,
12497 	__rte_unused void *data)
12498 {
12499 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12500 	int ret = -ENOTSUP;
12501 
12502 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12503 
12504 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12505 		return;
12506 
12507 #ifdef RTE_NET_I40E
12508 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12509 					   res->vf_id, is_on);
12510 #endif
12511 
12512 	switch (ret) {
12513 	case 0:
12514 		break;
12515 	case -EINVAL:
12516 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12517 			res->vf_id, is_on);
12518 		break;
12519 	case -ENODEV:
12520 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12521 		break;
12522 	case -ENOTSUP:
12523 		fprintf(stderr, "function not implemented\n");
12524 		break;
12525 	default:
12526 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12527 	}
12528 }
12529 
12530 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12531 	.f = cmd_set_vf_vlan_tag_parsed,
12532 	.data = NULL,
12533 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12534 	.tokens = {
12535 		(void *)&cmd_set_vf_vlan_tag_set,
12536 		(void *)&cmd_set_vf_vlan_tag_vf,
12537 		(void *)&cmd_set_vf_vlan_tag_vlan,
12538 		(void *)&cmd_set_vf_vlan_tag_tag,
12539 		(void *)&cmd_set_vf_vlan_tag_port_id,
12540 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12541 		(void *)&cmd_set_vf_vlan_tag_on_off,
12542 		NULL,
12543 	},
12544 };
12545 
12546 /* Common definition of VF and TC TX bandwidth configuration */
12547 struct cmd_vf_tc_bw_result {
12548 	cmdline_fixed_string_t set;
12549 	cmdline_fixed_string_t vf;
12550 	cmdline_fixed_string_t tc;
12551 	cmdline_fixed_string_t tx;
12552 	cmdline_fixed_string_t min_bw;
12553 	cmdline_fixed_string_t max_bw;
12554 	cmdline_fixed_string_t strict_link_prio;
12555 	portid_t port_id;
12556 	uint16_t vf_id;
12557 	uint8_t tc_no;
12558 	uint32_t bw;
12559 	cmdline_fixed_string_t bw_list;
12560 	uint8_t tc_map;
12561 };
12562 
12563 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12564 	TOKEN_STRING_INITIALIZER
12565 		(struct cmd_vf_tc_bw_result,
12566 		 set, "set");
12567 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12568 	TOKEN_STRING_INITIALIZER
12569 		(struct cmd_vf_tc_bw_result,
12570 		 vf, "vf");
12571 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12572 	TOKEN_STRING_INITIALIZER
12573 		(struct cmd_vf_tc_bw_result,
12574 		 tc, "tc");
12575 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12576 	TOKEN_STRING_INITIALIZER
12577 		(struct cmd_vf_tc_bw_result,
12578 		 tx, "tx");
12579 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12580 	TOKEN_STRING_INITIALIZER
12581 		(struct cmd_vf_tc_bw_result,
12582 		 strict_link_prio, "strict-link-priority");
12583 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12584 	TOKEN_STRING_INITIALIZER
12585 		(struct cmd_vf_tc_bw_result,
12586 		 min_bw, "min-bandwidth");
12587 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12588 	TOKEN_STRING_INITIALIZER
12589 		(struct cmd_vf_tc_bw_result,
12590 		 max_bw, "max-bandwidth");
12591 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12592 	TOKEN_NUM_INITIALIZER
12593 		(struct cmd_vf_tc_bw_result,
12594 		 port_id, RTE_UINT16);
12595 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12596 	TOKEN_NUM_INITIALIZER
12597 		(struct cmd_vf_tc_bw_result,
12598 		 vf_id, RTE_UINT16);
12599 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12600 	TOKEN_NUM_INITIALIZER
12601 		(struct cmd_vf_tc_bw_result,
12602 		 tc_no, RTE_UINT8);
12603 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12604 	TOKEN_NUM_INITIALIZER
12605 		(struct cmd_vf_tc_bw_result,
12606 		 bw, RTE_UINT32);
12607 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12608 	TOKEN_STRING_INITIALIZER
12609 		(struct cmd_vf_tc_bw_result,
12610 		 bw_list, NULL);
12611 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12612 	TOKEN_NUM_INITIALIZER
12613 		(struct cmd_vf_tc_bw_result,
12614 		 tc_map, RTE_UINT8);
12615 
12616 /* VF max bandwidth setting */
12617 static void
12618 cmd_vf_max_bw_parsed(
12619 	void *parsed_result,
12620 	__rte_unused struct cmdline *cl,
12621 	__rte_unused void *data)
12622 {
12623 	struct cmd_vf_tc_bw_result *res = parsed_result;
12624 	int ret = -ENOTSUP;
12625 
12626 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12627 		return;
12628 
12629 #ifdef RTE_NET_I40E
12630 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12631 					 res->vf_id, res->bw);
12632 #endif
12633 
12634 	switch (ret) {
12635 	case 0:
12636 		break;
12637 	case -EINVAL:
12638 		fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12639 			res->vf_id, res->bw);
12640 		break;
12641 	case -ENODEV:
12642 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12643 		break;
12644 	case -ENOTSUP:
12645 		fprintf(stderr, "function not implemented\n");
12646 		break;
12647 	default:
12648 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12649 	}
12650 }
12651 
12652 cmdline_parse_inst_t cmd_vf_max_bw = {
12653 	.f = cmd_vf_max_bw_parsed,
12654 	.data = NULL,
12655 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12656 	.tokens = {
12657 		(void *)&cmd_vf_tc_bw_set,
12658 		(void *)&cmd_vf_tc_bw_vf,
12659 		(void *)&cmd_vf_tc_bw_tx,
12660 		(void *)&cmd_vf_tc_bw_max_bw,
12661 		(void *)&cmd_vf_tc_bw_port_id,
12662 		(void *)&cmd_vf_tc_bw_vf_id,
12663 		(void *)&cmd_vf_tc_bw_bw,
12664 		NULL,
12665 	},
12666 };
12667 
12668 static int
12669 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12670 			   uint8_t *tc_num,
12671 			   char *str)
12672 {
12673 	uint32_t size;
12674 	const char *p, *p0 = str;
12675 	char s[256];
12676 	char *end;
12677 	char *str_fld[16];
12678 	uint16_t i;
12679 	int ret;
12680 
12681 	p = strchr(p0, '(');
12682 	if (p == NULL) {
12683 		fprintf(stderr,
12684 			"The bandwidth-list should be '(bw1, bw2, ...)'\n");
12685 		return -1;
12686 	}
12687 	p++;
12688 	p0 = strchr(p, ')');
12689 	if (p0 == NULL) {
12690 		fprintf(stderr,
12691 			"The bandwidth-list should be '(bw1, bw2, ...)'\n");
12692 		return -1;
12693 	}
12694 	size = p0 - p;
12695 	if (size >= sizeof(s)) {
12696 		fprintf(stderr,
12697 			"The string size exceeds the internal buffer size\n");
12698 		return -1;
12699 	}
12700 	snprintf(s, sizeof(s), "%.*s", size, p);
12701 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12702 	if (ret <= 0) {
12703 		fprintf(stderr, "Failed to get the bandwidth list.\n");
12704 		return -1;
12705 	}
12706 	*tc_num = ret;
12707 	for (i = 0; i < ret; i++)
12708 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12709 
12710 	return 0;
12711 }
12712 
12713 /* TC min bandwidth setting */
12714 static void
12715 cmd_vf_tc_min_bw_parsed(
12716 	void *parsed_result,
12717 	__rte_unused struct cmdline *cl,
12718 	__rte_unused void *data)
12719 {
12720 	struct cmd_vf_tc_bw_result *res = parsed_result;
12721 	uint8_t tc_num;
12722 	uint8_t bw[16];
12723 	int ret = -ENOTSUP;
12724 
12725 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12726 		return;
12727 
12728 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12729 	if (ret)
12730 		return;
12731 
12732 #ifdef RTE_NET_I40E
12733 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12734 					      tc_num, bw);
12735 #endif
12736 
12737 	switch (ret) {
12738 	case 0:
12739 		break;
12740 	case -EINVAL:
12741 		fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12742 		break;
12743 	case -ENODEV:
12744 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12745 		break;
12746 	case -ENOTSUP:
12747 		fprintf(stderr, "function not implemented\n");
12748 		break;
12749 	default:
12750 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12751 	}
12752 }
12753 
12754 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12755 	.f = cmd_vf_tc_min_bw_parsed,
12756 	.data = NULL,
12757 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12758 		    " <bw1, bw2, ...>",
12759 	.tokens = {
12760 		(void *)&cmd_vf_tc_bw_set,
12761 		(void *)&cmd_vf_tc_bw_vf,
12762 		(void *)&cmd_vf_tc_bw_tc,
12763 		(void *)&cmd_vf_tc_bw_tx,
12764 		(void *)&cmd_vf_tc_bw_min_bw,
12765 		(void *)&cmd_vf_tc_bw_port_id,
12766 		(void *)&cmd_vf_tc_bw_vf_id,
12767 		(void *)&cmd_vf_tc_bw_bw_list,
12768 		NULL,
12769 	},
12770 };
12771 
12772 static void
12773 cmd_tc_min_bw_parsed(
12774 	void *parsed_result,
12775 	__rte_unused struct cmdline *cl,
12776 	__rte_unused void *data)
12777 {
12778 	struct cmd_vf_tc_bw_result *res = parsed_result;
12779 	struct rte_port *port;
12780 	uint8_t tc_num;
12781 	uint8_t bw[16];
12782 	int ret = -ENOTSUP;
12783 
12784 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12785 		return;
12786 
12787 	port = &ports[res->port_id];
12788 	/** Check if the port is not started **/
12789 	if (port->port_status != RTE_PORT_STOPPED) {
12790 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
12791 		return;
12792 	}
12793 
12794 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12795 	if (ret)
12796 		return;
12797 
12798 #ifdef RTE_NET_IXGBE
12799 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12800 #endif
12801 
12802 	switch (ret) {
12803 	case 0:
12804 		break;
12805 	case -EINVAL:
12806 		fprintf(stderr, "invalid bandwidth\n");
12807 		break;
12808 	case -ENODEV:
12809 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12810 		break;
12811 	case -ENOTSUP:
12812 		fprintf(stderr, "function not implemented\n");
12813 		break;
12814 	default:
12815 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12816 	}
12817 }
12818 
12819 cmdline_parse_inst_t cmd_tc_min_bw = {
12820 	.f = cmd_tc_min_bw_parsed,
12821 	.data = NULL,
12822 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12823 	.tokens = {
12824 		(void *)&cmd_vf_tc_bw_set,
12825 		(void *)&cmd_vf_tc_bw_tc,
12826 		(void *)&cmd_vf_tc_bw_tx,
12827 		(void *)&cmd_vf_tc_bw_min_bw,
12828 		(void *)&cmd_vf_tc_bw_port_id,
12829 		(void *)&cmd_vf_tc_bw_bw_list,
12830 		NULL,
12831 	},
12832 };
12833 
12834 /* TC max bandwidth setting */
12835 static void
12836 cmd_vf_tc_max_bw_parsed(
12837 	void *parsed_result,
12838 	__rte_unused struct cmdline *cl,
12839 	__rte_unused void *data)
12840 {
12841 	struct cmd_vf_tc_bw_result *res = parsed_result;
12842 	int ret = -ENOTSUP;
12843 
12844 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12845 		return;
12846 
12847 #ifdef RTE_NET_I40E
12848 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12849 					    res->tc_no, res->bw);
12850 #endif
12851 
12852 	switch (ret) {
12853 	case 0:
12854 		break;
12855 	case -EINVAL:
12856 		fprintf(stderr,
12857 			"invalid vf_id %d, tc_no %d or bandwidth %d\n",
12858 			res->vf_id, res->tc_no, res->bw);
12859 		break;
12860 	case -ENODEV:
12861 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12862 		break;
12863 	case -ENOTSUP:
12864 		fprintf(stderr, "function not implemented\n");
12865 		break;
12866 	default:
12867 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12868 	}
12869 }
12870 
12871 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12872 	.f = cmd_vf_tc_max_bw_parsed,
12873 	.data = NULL,
12874 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12875 		    " <bandwidth>",
12876 	.tokens = {
12877 		(void *)&cmd_vf_tc_bw_set,
12878 		(void *)&cmd_vf_tc_bw_vf,
12879 		(void *)&cmd_vf_tc_bw_tc,
12880 		(void *)&cmd_vf_tc_bw_tx,
12881 		(void *)&cmd_vf_tc_bw_max_bw,
12882 		(void *)&cmd_vf_tc_bw_port_id,
12883 		(void *)&cmd_vf_tc_bw_vf_id,
12884 		(void *)&cmd_vf_tc_bw_tc_no,
12885 		(void *)&cmd_vf_tc_bw_bw,
12886 		NULL,
12887 	},
12888 };
12889 
12890 /** Set VXLAN encapsulation details */
12891 struct cmd_set_vxlan_result {
12892 	cmdline_fixed_string_t set;
12893 	cmdline_fixed_string_t vxlan;
12894 	cmdline_fixed_string_t pos_token;
12895 	cmdline_fixed_string_t ip_version;
12896 	uint32_t vlan_present:1;
12897 	uint32_t vni;
12898 	uint16_t udp_src;
12899 	uint16_t udp_dst;
12900 	cmdline_ipaddr_t ip_src;
12901 	cmdline_ipaddr_t ip_dst;
12902 	uint16_t tci;
12903 	uint8_t tos;
12904 	uint8_t ttl;
12905 	struct rte_ether_addr eth_src;
12906 	struct rte_ether_addr eth_dst;
12907 };
12908 
12909 cmdline_parse_token_string_t cmd_set_vxlan_set =
12910 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12911 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12912 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12913 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12914 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12915 				 "vxlan-tos-ttl");
12916 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12917 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12918 				 "vxlan-with-vlan");
12919 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12920 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12921 				 "ip-version");
12922 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12923 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12924 				 "ipv4#ipv6");
12925 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12926 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12927 				 "vni");
12928 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12929 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12930 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12931 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12932 				 "udp-src");
12933 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12934 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12935 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12936 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12937 				 "udp-dst");
12938 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12939 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12940 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12941 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12942 				 "ip-tos");
12943 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12944 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12945 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12946 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12947 				 "ip-ttl");
12948 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12949 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12950 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12951 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12952 				 "ip-src");
12953 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12954 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12955 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12956 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12957 				 "ip-dst");
12958 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12959 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12960 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12961 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12962 				 "vlan-tci");
12963 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12964 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12965 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12966 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12967 				 "eth-src");
12968 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12969 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12970 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12971 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12972 				 "eth-dst");
12973 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12974 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12975 
12976 static void cmd_set_vxlan_parsed(void *parsed_result,
12977 	__rte_unused struct cmdline *cl,
12978 	__rte_unused void *data)
12979 {
12980 	struct cmd_set_vxlan_result *res = parsed_result;
12981 	union {
12982 		uint32_t vxlan_id;
12983 		uint8_t vni[4];
12984 	} id = {
12985 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12986 	};
12987 
12988 	vxlan_encap_conf.select_tos_ttl = 0;
12989 	if (strcmp(res->vxlan, "vxlan") == 0)
12990 		vxlan_encap_conf.select_vlan = 0;
12991 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12992 		vxlan_encap_conf.select_vlan = 1;
12993 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12994 		vxlan_encap_conf.select_vlan = 0;
12995 		vxlan_encap_conf.select_tos_ttl = 1;
12996 	}
12997 	if (strcmp(res->ip_version, "ipv4") == 0)
12998 		vxlan_encap_conf.select_ipv4 = 1;
12999 	else if (strcmp(res->ip_version, "ipv6") == 0)
13000 		vxlan_encap_conf.select_ipv4 = 0;
13001 	else
13002 		return;
13003 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13004 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13005 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13006 	vxlan_encap_conf.ip_tos = res->tos;
13007 	vxlan_encap_conf.ip_ttl = res->ttl;
13008 	if (vxlan_encap_conf.select_ipv4) {
13009 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13010 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13011 	} else {
13012 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13013 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13014 	}
13015 	if (vxlan_encap_conf.select_vlan)
13016 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13017 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13018 		   RTE_ETHER_ADDR_LEN);
13019 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13020 		   RTE_ETHER_ADDR_LEN);
13021 }
13022 
13023 cmdline_parse_inst_t cmd_set_vxlan = {
13024 	.f = cmd_set_vxlan_parsed,
13025 	.data = NULL,
13026 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13027 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13028 		" eth-src <eth-src> eth-dst <eth-dst>",
13029 	.tokens = {
13030 		(void *)&cmd_set_vxlan_set,
13031 		(void *)&cmd_set_vxlan_vxlan,
13032 		(void *)&cmd_set_vxlan_ip_version,
13033 		(void *)&cmd_set_vxlan_ip_version_value,
13034 		(void *)&cmd_set_vxlan_vni,
13035 		(void *)&cmd_set_vxlan_vni_value,
13036 		(void *)&cmd_set_vxlan_udp_src,
13037 		(void *)&cmd_set_vxlan_udp_src_value,
13038 		(void *)&cmd_set_vxlan_udp_dst,
13039 		(void *)&cmd_set_vxlan_udp_dst_value,
13040 		(void *)&cmd_set_vxlan_ip_src,
13041 		(void *)&cmd_set_vxlan_ip_src_value,
13042 		(void *)&cmd_set_vxlan_ip_dst,
13043 		(void *)&cmd_set_vxlan_ip_dst_value,
13044 		(void *)&cmd_set_vxlan_eth_src,
13045 		(void *)&cmd_set_vxlan_eth_src_value,
13046 		(void *)&cmd_set_vxlan_eth_dst,
13047 		(void *)&cmd_set_vxlan_eth_dst_value,
13048 		NULL,
13049 	},
13050 };
13051 
13052 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13053 	.f = cmd_set_vxlan_parsed,
13054 	.data = NULL,
13055 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13056 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13057 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13058 		" eth-dst <eth-dst>",
13059 	.tokens = {
13060 		(void *)&cmd_set_vxlan_set,
13061 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
13062 		(void *)&cmd_set_vxlan_ip_version,
13063 		(void *)&cmd_set_vxlan_ip_version_value,
13064 		(void *)&cmd_set_vxlan_vni,
13065 		(void *)&cmd_set_vxlan_vni_value,
13066 		(void *)&cmd_set_vxlan_udp_src,
13067 		(void *)&cmd_set_vxlan_udp_src_value,
13068 		(void *)&cmd_set_vxlan_udp_dst,
13069 		(void *)&cmd_set_vxlan_udp_dst_value,
13070 		(void *)&cmd_set_vxlan_ip_tos,
13071 		(void *)&cmd_set_vxlan_ip_tos_value,
13072 		(void *)&cmd_set_vxlan_ip_ttl,
13073 		(void *)&cmd_set_vxlan_ip_ttl_value,
13074 		(void *)&cmd_set_vxlan_ip_src,
13075 		(void *)&cmd_set_vxlan_ip_src_value,
13076 		(void *)&cmd_set_vxlan_ip_dst,
13077 		(void *)&cmd_set_vxlan_ip_dst_value,
13078 		(void *)&cmd_set_vxlan_eth_src,
13079 		(void *)&cmd_set_vxlan_eth_src_value,
13080 		(void *)&cmd_set_vxlan_eth_dst,
13081 		(void *)&cmd_set_vxlan_eth_dst_value,
13082 		NULL,
13083 	},
13084 };
13085 
13086 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13087 	.f = cmd_set_vxlan_parsed,
13088 	.data = NULL,
13089 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13090 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13091 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13092 		" <eth-dst>",
13093 	.tokens = {
13094 		(void *)&cmd_set_vxlan_set,
13095 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
13096 		(void *)&cmd_set_vxlan_ip_version,
13097 		(void *)&cmd_set_vxlan_ip_version_value,
13098 		(void *)&cmd_set_vxlan_vni,
13099 		(void *)&cmd_set_vxlan_vni_value,
13100 		(void *)&cmd_set_vxlan_udp_src,
13101 		(void *)&cmd_set_vxlan_udp_src_value,
13102 		(void *)&cmd_set_vxlan_udp_dst,
13103 		(void *)&cmd_set_vxlan_udp_dst_value,
13104 		(void *)&cmd_set_vxlan_ip_src,
13105 		(void *)&cmd_set_vxlan_ip_src_value,
13106 		(void *)&cmd_set_vxlan_ip_dst,
13107 		(void *)&cmd_set_vxlan_ip_dst_value,
13108 		(void *)&cmd_set_vxlan_vlan,
13109 		(void *)&cmd_set_vxlan_vlan_value,
13110 		(void *)&cmd_set_vxlan_eth_src,
13111 		(void *)&cmd_set_vxlan_eth_src_value,
13112 		(void *)&cmd_set_vxlan_eth_dst,
13113 		(void *)&cmd_set_vxlan_eth_dst_value,
13114 		NULL,
13115 	},
13116 };
13117 
13118 /** Set NVGRE encapsulation details */
13119 struct cmd_set_nvgre_result {
13120 	cmdline_fixed_string_t set;
13121 	cmdline_fixed_string_t nvgre;
13122 	cmdline_fixed_string_t pos_token;
13123 	cmdline_fixed_string_t ip_version;
13124 	uint32_t tni;
13125 	cmdline_ipaddr_t ip_src;
13126 	cmdline_ipaddr_t ip_dst;
13127 	uint16_t tci;
13128 	struct rte_ether_addr eth_src;
13129 	struct rte_ether_addr eth_dst;
13130 };
13131 
13132 cmdline_parse_token_string_t cmd_set_nvgre_set =
13133 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13134 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13135 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13136 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13137 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13138 				 "nvgre-with-vlan");
13139 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13140 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13141 				 "ip-version");
13142 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13143 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13144 				 "ipv4#ipv6");
13145 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13146 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13147 				 "tni");
13148 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13149 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13150 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13151 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13152 				 "ip-src");
13153 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13154 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13155 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13156 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13157 				 "ip-dst");
13158 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13159 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13160 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13161 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13162 				 "vlan-tci");
13163 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13164 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13165 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13166 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13167 				 "eth-src");
13168 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13169 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13170 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13171 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13172 				 "eth-dst");
13173 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13174 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13175 
13176 static void cmd_set_nvgre_parsed(void *parsed_result,
13177 	__rte_unused struct cmdline *cl,
13178 	__rte_unused void *data)
13179 {
13180 	struct cmd_set_nvgre_result *res = parsed_result;
13181 	union {
13182 		uint32_t nvgre_tni;
13183 		uint8_t tni[4];
13184 	} id = {
13185 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13186 	};
13187 
13188 	if (strcmp(res->nvgre, "nvgre") == 0)
13189 		nvgre_encap_conf.select_vlan = 0;
13190 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13191 		nvgre_encap_conf.select_vlan = 1;
13192 	if (strcmp(res->ip_version, "ipv4") == 0)
13193 		nvgre_encap_conf.select_ipv4 = 1;
13194 	else if (strcmp(res->ip_version, "ipv6") == 0)
13195 		nvgre_encap_conf.select_ipv4 = 0;
13196 	else
13197 		return;
13198 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13199 	if (nvgre_encap_conf.select_ipv4) {
13200 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13201 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13202 	} else {
13203 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13204 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13205 	}
13206 	if (nvgre_encap_conf.select_vlan)
13207 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13208 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13209 		   RTE_ETHER_ADDR_LEN);
13210 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13211 		   RTE_ETHER_ADDR_LEN);
13212 }
13213 
13214 cmdline_parse_inst_t cmd_set_nvgre = {
13215 	.f = cmd_set_nvgre_parsed,
13216 	.data = NULL,
13217 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13218 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13219 		" eth-dst <eth-dst>",
13220 	.tokens = {
13221 		(void *)&cmd_set_nvgre_set,
13222 		(void *)&cmd_set_nvgre_nvgre,
13223 		(void *)&cmd_set_nvgre_ip_version,
13224 		(void *)&cmd_set_nvgre_ip_version_value,
13225 		(void *)&cmd_set_nvgre_tni,
13226 		(void *)&cmd_set_nvgre_tni_value,
13227 		(void *)&cmd_set_nvgre_ip_src,
13228 		(void *)&cmd_set_nvgre_ip_src_value,
13229 		(void *)&cmd_set_nvgre_ip_dst,
13230 		(void *)&cmd_set_nvgre_ip_dst_value,
13231 		(void *)&cmd_set_nvgre_eth_src,
13232 		(void *)&cmd_set_nvgre_eth_src_value,
13233 		(void *)&cmd_set_nvgre_eth_dst,
13234 		(void *)&cmd_set_nvgre_eth_dst_value,
13235 		NULL,
13236 	},
13237 };
13238 
13239 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13240 	.f = cmd_set_nvgre_parsed,
13241 	.data = NULL,
13242 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13243 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13244 		" eth-src <eth-src> eth-dst <eth-dst>",
13245 	.tokens = {
13246 		(void *)&cmd_set_nvgre_set,
13247 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
13248 		(void *)&cmd_set_nvgre_ip_version,
13249 		(void *)&cmd_set_nvgre_ip_version_value,
13250 		(void *)&cmd_set_nvgre_tni,
13251 		(void *)&cmd_set_nvgre_tni_value,
13252 		(void *)&cmd_set_nvgre_ip_src,
13253 		(void *)&cmd_set_nvgre_ip_src_value,
13254 		(void *)&cmd_set_nvgre_ip_dst,
13255 		(void *)&cmd_set_nvgre_ip_dst_value,
13256 		(void *)&cmd_set_nvgre_vlan,
13257 		(void *)&cmd_set_nvgre_vlan_value,
13258 		(void *)&cmd_set_nvgre_eth_src,
13259 		(void *)&cmd_set_nvgre_eth_src_value,
13260 		(void *)&cmd_set_nvgre_eth_dst,
13261 		(void *)&cmd_set_nvgre_eth_dst_value,
13262 		NULL,
13263 	},
13264 };
13265 
13266 /** Set L2 encapsulation details */
13267 struct cmd_set_l2_encap_result {
13268 	cmdline_fixed_string_t set;
13269 	cmdline_fixed_string_t l2_encap;
13270 	cmdline_fixed_string_t pos_token;
13271 	cmdline_fixed_string_t ip_version;
13272 	uint32_t vlan_present:1;
13273 	uint16_t tci;
13274 	struct rte_ether_addr eth_src;
13275 	struct rte_ether_addr eth_dst;
13276 };
13277 
13278 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13279 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13280 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13281 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13282 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13283 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13284 				 "l2_encap-with-vlan");
13285 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13286 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13287 				 "ip-version");
13288 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13289 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13290 				 "ipv4#ipv6");
13291 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13292 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13293 				 "vlan-tci");
13294 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13295 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13296 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13297 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13298 				 "eth-src");
13299 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13300 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13301 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13302 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13303 				 "eth-dst");
13304 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13305 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13306 
13307 static void cmd_set_l2_encap_parsed(void *parsed_result,
13308 	__rte_unused struct cmdline *cl,
13309 	__rte_unused void *data)
13310 {
13311 	struct cmd_set_l2_encap_result *res = parsed_result;
13312 
13313 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13314 		l2_encap_conf.select_vlan = 0;
13315 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13316 		l2_encap_conf.select_vlan = 1;
13317 	if (strcmp(res->ip_version, "ipv4") == 0)
13318 		l2_encap_conf.select_ipv4 = 1;
13319 	else if (strcmp(res->ip_version, "ipv6") == 0)
13320 		l2_encap_conf.select_ipv4 = 0;
13321 	else
13322 		return;
13323 	if (l2_encap_conf.select_vlan)
13324 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13325 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13326 		   RTE_ETHER_ADDR_LEN);
13327 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13328 		   RTE_ETHER_ADDR_LEN);
13329 }
13330 
13331 cmdline_parse_inst_t cmd_set_l2_encap = {
13332 	.f = cmd_set_l2_encap_parsed,
13333 	.data = NULL,
13334 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13335 		" eth-src <eth-src> eth-dst <eth-dst>",
13336 	.tokens = {
13337 		(void *)&cmd_set_l2_encap_set,
13338 		(void *)&cmd_set_l2_encap_l2_encap,
13339 		(void *)&cmd_set_l2_encap_ip_version,
13340 		(void *)&cmd_set_l2_encap_ip_version_value,
13341 		(void *)&cmd_set_l2_encap_eth_src,
13342 		(void *)&cmd_set_l2_encap_eth_src_value,
13343 		(void *)&cmd_set_l2_encap_eth_dst,
13344 		(void *)&cmd_set_l2_encap_eth_dst_value,
13345 		NULL,
13346 	},
13347 };
13348 
13349 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13350 	.f = cmd_set_l2_encap_parsed,
13351 	.data = NULL,
13352 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13353 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13354 	.tokens = {
13355 		(void *)&cmd_set_l2_encap_set,
13356 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13357 		(void *)&cmd_set_l2_encap_ip_version,
13358 		(void *)&cmd_set_l2_encap_ip_version_value,
13359 		(void *)&cmd_set_l2_encap_vlan,
13360 		(void *)&cmd_set_l2_encap_vlan_value,
13361 		(void *)&cmd_set_l2_encap_eth_src,
13362 		(void *)&cmd_set_l2_encap_eth_src_value,
13363 		(void *)&cmd_set_l2_encap_eth_dst,
13364 		(void *)&cmd_set_l2_encap_eth_dst_value,
13365 		NULL,
13366 	},
13367 };
13368 
13369 /** Set L2 decapsulation details */
13370 struct cmd_set_l2_decap_result {
13371 	cmdline_fixed_string_t set;
13372 	cmdline_fixed_string_t l2_decap;
13373 	cmdline_fixed_string_t pos_token;
13374 	uint32_t vlan_present:1;
13375 };
13376 
13377 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13378 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13379 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13380 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13381 				 "l2_decap");
13382 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13383 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13384 				 "l2_decap-with-vlan");
13385 
13386 static void cmd_set_l2_decap_parsed(void *parsed_result,
13387 	__rte_unused struct cmdline *cl,
13388 	__rte_unused void *data)
13389 {
13390 	struct cmd_set_l2_decap_result *res = parsed_result;
13391 
13392 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13393 		l2_decap_conf.select_vlan = 0;
13394 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13395 		l2_decap_conf.select_vlan = 1;
13396 }
13397 
13398 cmdline_parse_inst_t cmd_set_l2_decap = {
13399 	.f = cmd_set_l2_decap_parsed,
13400 	.data = NULL,
13401 	.help_str = "set l2_decap",
13402 	.tokens = {
13403 		(void *)&cmd_set_l2_decap_set,
13404 		(void *)&cmd_set_l2_decap_l2_decap,
13405 		NULL,
13406 	},
13407 };
13408 
13409 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13410 	.f = cmd_set_l2_decap_parsed,
13411 	.data = NULL,
13412 	.help_str = "set l2_decap-with-vlan",
13413 	.tokens = {
13414 		(void *)&cmd_set_l2_decap_set,
13415 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13416 		NULL,
13417 	},
13418 };
13419 
13420 /** Set MPLSoGRE encapsulation details */
13421 struct cmd_set_mplsogre_encap_result {
13422 	cmdline_fixed_string_t set;
13423 	cmdline_fixed_string_t mplsogre;
13424 	cmdline_fixed_string_t pos_token;
13425 	cmdline_fixed_string_t ip_version;
13426 	uint32_t vlan_present:1;
13427 	uint32_t label;
13428 	cmdline_ipaddr_t ip_src;
13429 	cmdline_ipaddr_t ip_dst;
13430 	uint16_t tci;
13431 	struct rte_ether_addr eth_src;
13432 	struct rte_ether_addr eth_dst;
13433 };
13434 
13435 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13436 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13437 				 "set");
13438 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13439 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13440 				 "mplsogre_encap");
13441 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13442 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13443 				 mplsogre, "mplsogre_encap-with-vlan");
13444 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13445 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13446 				 pos_token, "ip-version");
13447 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13448 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13449 				 ip_version, "ipv4#ipv6");
13450 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13451 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13452 				 pos_token, "label");
13453 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13454 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13455 			      RTE_UINT32);
13456 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13457 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13458 				 pos_token, "ip-src");
13459 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13460 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13461 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13462 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13463 				 pos_token, "ip-dst");
13464 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13465 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13466 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13467 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13468 				 pos_token, "vlan-tci");
13469 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13470 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13471 			      RTE_UINT16);
13472 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13473 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13474 				 pos_token, "eth-src");
13475 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13476 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13477 				    eth_src);
13478 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13479 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13480 				 pos_token, "eth-dst");
13481 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13482 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13483 				    eth_dst);
13484 
13485 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13486 	__rte_unused struct cmdline *cl,
13487 	__rte_unused void *data)
13488 {
13489 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13490 	union {
13491 		uint32_t mplsogre_label;
13492 		uint8_t label[4];
13493 	} id = {
13494 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13495 	};
13496 
13497 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13498 		mplsogre_encap_conf.select_vlan = 0;
13499 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13500 		mplsogre_encap_conf.select_vlan = 1;
13501 	if (strcmp(res->ip_version, "ipv4") == 0)
13502 		mplsogre_encap_conf.select_ipv4 = 1;
13503 	else if (strcmp(res->ip_version, "ipv6") == 0)
13504 		mplsogre_encap_conf.select_ipv4 = 0;
13505 	else
13506 		return;
13507 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13508 	if (mplsogre_encap_conf.select_ipv4) {
13509 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13510 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13511 	} else {
13512 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13513 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13514 	}
13515 	if (mplsogre_encap_conf.select_vlan)
13516 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13517 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13518 		   RTE_ETHER_ADDR_LEN);
13519 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13520 		   RTE_ETHER_ADDR_LEN);
13521 }
13522 
13523 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13524 	.f = cmd_set_mplsogre_encap_parsed,
13525 	.data = NULL,
13526 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13527 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13528 		" eth-dst <eth-dst>",
13529 	.tokens = {
13530 		(void *)&cmd_set_mplsogre_encap_set,
13531 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13532 		(void *)&cmd_set_mplsogre_encap_ip_version,
13533 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13534 		(void *)&cmd_set_mplsogre_encap_label,
13535 		(void *)&cmd_set_mplsogre_encap_label_value,
13536 		(void *)&cmd_set_mplsogre_encap_ip_src,
13537 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13538 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13539 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13540 		(void *)&cmd_set_mplsogre_encap_eth_src,
13541 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13542 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13543 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13544 		NULL,
13545 	},
13546 };
13547 
13548 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13549 	.f = cmd_set_mplsogre_encap_parsed,
13550 	.data = NULL,
13551 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13552 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13553 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13554 	.tokens = {
13555 		(void *)&cmd_set_mplsogre_encap_set,
13556 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13557 		(void *)&cmd_set_mplsogre_encap_ip_version,
13558 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13559 		(void *)&cmd_set_mplsogre_encap_label,
13560 		(void *)&cmd_set_mplsogre_encap_label_value,
13561 		(void *)&cmd_set_mplsogre_encap_ip_src,
13562 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13563 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13564 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13565 		(void *)&cmd_set_mplsogre_encap_vlan,
13566 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13567 		(void *)&cmd_set_mplsogre_encap_eth_src,
13568 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13569 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13570 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13571 		NULL,
13572 	},
13573 };
13574 
13575 /** Set MPLSoGRE decapsulation details */
13576 struct cmd_set_mplsogre_decap_result {
13577 	cmdline_fixed_string_t set;
13578 	cmdline_fixed_string_t mplsogre;
13579 	cmdline_fixed_string_t pos_token;
13580 	cmdline_fixed_string_t ip_version;
13581 	uint32_t vlan_present:1;
13582 };
13583 
13584 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13585 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13586 				 "set");
13587 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13588 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13589 				 "mplsogre_decap");
13590 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13591 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13592 				 mplsogre, "mplsogre_decap-with-vlan");
13593 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13594 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13595 				 pos_token, "ip-version");
13596 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13597 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13598 				 ip_version, "ipv4#ipv6");
13599 
13600 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13601 	__rte_unused struct cmdline *cl,
13602 	__rte_unused void *data)
13603 {
13604 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13605 
13606 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13607 		mplsogre_decap_conf.select_vlan = 0;
13608 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13609 		mplsogre_decap_conf.select_vlan = 1;
13610 	if (strcmp(res->ip_version, "ipv4") == 0)
13611 		mplsogre_decap_conf.select_ipv4 = 1;
13612 	else if (strcmp(res->ip_version, "ipv6") == 0)
13613 		mplsogre_decap_conf.select_ipv4 = 0;
13614 }
13615 
13616 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13617 	.f = cmd_set_mplsogre_decap_parsed,
13618 	.data = NULL,
13619 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13620 	.tokens = {
13621 		(void *)&cmd_set_mplsogre_decap_set,
13622 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13623 		(void *)&cmd_set_mplsogre_decap_ip_version,
13624 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13625 		NULL,
13626 	},
13627 };
13628 
13629 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13630 	.f = cmd_set_mplsogre_decap_parsed,
13631 	.data = NULL,
13632 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13633 	.tokens = {
13634 		(void *)&cmd_set_mplsogre_decap_set,
13635 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13636 		(void *)&cmd_set_mplsogre_decap_ip_version,
13637 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13638 		NULL,
13639 	},
13640 };
13641 
13642 /** Set MPLSoUDP encapsulation details */
13643 struct cmd_set_mplsoudp_encap_result {
13644 	cmdline_fixed_string_t set;
13645 	cmdline_fixed_string_t mplsoudp;
13646 	cmdline_fixed_string_t pos_token;
13647 	cmdline_fixed_string_t ip_version;
13648 	uint32_t vlan_present:1;
13649 	uint32_t label;
13650 	uint16_t udp_src;
13651 	uint16_t udp_dst;
13652 	cmdline_ipaddr_t ip_src;
13653 	cmdline_ipaddr_t ip_dst;
13654 	uint16_t tci;
13655 	struct rte_ether_addr eth_src;
13656 	struct rte_ether_addr eth_dst;
13657 };
13658 
13659 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13660 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13661 				 "set");
13662 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13663 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13664 				 "mplsoudp_encap");
13665 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13666 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13667 				 mplsoudp, "mplsoudp_encap-with-vlan");
13668 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13669 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13670 				 pos_token, "ip-version");
13671 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13672 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13673 				 ip_version, "ipv4#ipv6");
13674 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13675 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13676 				 pos_token, "label");
13677 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13678 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13679 			      RTE_UINT32);
13680 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13681 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13682 				 pos_token, "udp-src");
13683 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13684 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13685 			      RTE_UINT16);
13686 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13687 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13688 				 pos_token, "udp-dst");
13689 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13690 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13691 			      RTE_UINT16);
13692 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13693 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13694 				 pos_token, "ip-src");
13695 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13696 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13697 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13698 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13699 				 pos_token, "ip-dst");
13700 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13701 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13702 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13703 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13704 				 pos_token, "vlan-tci");
13705 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13706 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13707 			      RTE_UINT16);
13708 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13709 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13710 				 pos_token, "eth-src");
13711 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13712 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13713 				    eth_src);
13714 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13715 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13716 				 pos_token, "eth-dst");
13717 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13718 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13719 				    eth_dst);
13720 
13721 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13722 	__rte_unused struct cmdline *cl,
13723 	__rte_unused void *data)
13724 {
13725 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13726 	union {
13727 		uint32_t mplsoudp_label;
13728 		uint8_t label[4];
13729 	} id = {
13730 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13731 	};
13732 
13733 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13734 		mplsoudp_encap_conf.select_vlan = 0;
13735 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13736 		mplsoudp_encap_conf.select_vlan = 1;
13737 	if (strcmp(res->ip_version, "ipv4") == 0)
13738 		mplsoudp_encap_conf.select_ipv4 = 1;
13739 	else if (strcmp(res->ip_version, "ipv6") == 0)
13740 		mplsoudp_encap_conf.select_ipv4 = 0;
13741 	else
13742 		return;
13743 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13744 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13745 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13746 	if (mplsoudp_encap_conf.select_ipv4) {
13747 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13748 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13749 	} else {
13750 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13751 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13752 	}
13753 	if (mplsoudp_encap_conf.select_vlan)
13754 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13755 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13756 		   RTE_ETHER_ADDR_LEN);
13757 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13758 		   RTE_ETHER_ADDR_LEN);
13759 }
13760 
13761 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13762 	.f = cmd_set_mplsoudp_encap_parsed,
13763 	.data = NULL,
13764 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13765 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13766 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13767 	.tokens = {
13768 		(void *)&cmd_set_mplsoudp_encap_set,
13769 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13770 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13771 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13772 		(void *)&cmd_set_mplsoudp_encap_label,
13773 		(void *)&cmd_set_mplsoudp_encap_label_value,
13774 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13775 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13776 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13777 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13778 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13779 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13780 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13781 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13782 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13783 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13784 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13785 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13786 		NULL,
13787 	},
13788 };
13789 
13790 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13791 	.f = cmd_set_mplsoudp_encap_parsed,
13792 	.data = NULL,
13793 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13794 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13795 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13796 		" eth-src <eth-src> eth-dst <eth-dst>",
13797 	.tokens = {
13798 		(void *)&cmd_set_mplsoudp_encap_set,
13799 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13800 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13801 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13802 		(void *)&cmd_set_mplsoudp_encap_label,
13803 		(void *)&cmd_set_mplsoudp_encap_label_value,
13804 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13805 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13806 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13807 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13808 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13809 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13810 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13811 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13812 		(void *)&cmd_set_mplsoudp_encap_vlan,
13813 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13814 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13815 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13816 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13817 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13818 		NULL,
13819 	},
13820 };
13821 
13822 /** Set MPLSoUDP decapsulation details */
13823 struct cmd_set_mplsoudp_decap_result {
13824 	cmdline_fixed_string_t set;
13825 	cmdline_fixed_string_t mplsoudp;
13826 	cmdline_fixed_string_t pos_token;
13827 	cmdline_fixed_string_t ip_version;
13828 	uint32_t vlan_present:1;
13829 };
13830 
13831 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13832 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13833 				 "set");
13834 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13835 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13836 				 "mplsoudp_decap");
13837 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13838 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13839 				 mplsoudp, "mplsoudp_decap-with-vlan");
13840 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13841 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13842 				 pos_token, "ip-version");
13843 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13844 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13845 				 ip_version, "ipv4#ipv6");
13846 
13847 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13848 	__rte_unused struct cmdline *cl,
13849 	__rte_unused void *data)
13850 {
13851 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13852 
13853 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13854 		mplsoudp_decap_conf.select_vlan = 0;
13855 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13856 		mplsoudp_decap_conf.select_vlan = 1;
13857 	if (strcmp(res->ip_version, "ipv4") == 0)
13858 		mplsoudp_decap_conf.select_ipv4 = 1;
13859 	else if (strcmp(res->ip_version, "ipv6") == 0)
13860 		mplsoudp_decap_conf.select_ipv4 = 0;
13861 }
13862 
13863 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13864 	.f = cmd_set_mplsoudp_decap_parsed,
13865 	.data = NULL,
13866 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13867 	.tokens = {
13868 		(void *)&cmd_set_mplsoudp_decap_set,
13869 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13870 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13871 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13872 		NULL,
13873 	},
13874 };
13875 
13876 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13877 	.f = cmd_set_mplsoudp_decap_parsed,
13878 	.data = NULL,
13879 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13880 	.tokens = {
13881 		(void *)&cmd_set_mplsoudp_decap_set,
13882 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13883 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13884 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13885 		NULL,
13886 	},
13887 };
13888 
13889 /** Set connection tracking object common details */
13890 struct cmd_set_conntrack_common_result {
13891 	cmdline_fixed_string_t set;
13892 	cmdline_fixed_string_t conntrack;
13893 	cmdline_fixed_string_t common;
13894 	cmdline_fixed_string_t peer;
13895 	cmdline_fixed_string_t is_orig;
13896 	cmdline_fixed_string_t enable;
13897 	cmdline_fixed_string_t live;
13898 	cmdline_fixed_string_t sack;
13899 	cmdline_fixed_string_t cack;
13900 	cmdline_fixed_string_t last_dir;
13901 	cmdline_fixed_string_t liberal;
13902 	cmdline_fixed_string_t state;
13903 	cmdline_fixed_string_t max_ack_win;
13904 	cmdline_fixed_string_t retrans;
13905 	cmdline_fixed_string_t last_win;
13906 	cmdline_fixed_string_t last_seq;
13907 	cmdline_fixed_string_t last_ack;
13908 	cmdline_fixed_string_t last_end;
13909 	cmdline_fixed_string_t last_index;
13910 	uint8_t stat;
13911 	uint8_t factor;
13912 	uint16_t peer_port;
13913 	uint32_t is_original;
13914 	uint32_t en;
13915 	uint32_t is_live;
13916 	uint32_t s_ack;
13917 	uint32_t c_ack;
13918 	uint32_t ld;
13919 	uint32_t lb;
13920 	uint8_t re_num;
13921 	uint8_t li;
13922 	uint16_t lw;
13923 	uint32_t ls;
13924 	uint32_t la;
13925 	uint32_t le;
13926 };
13927 
13928 cmdline_parse_token_string_t cmd_set_conntrack_set =
13929 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13930 				 set, "set");
13931 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13932 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13933 				 conntrack, "conntrack");
13934 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13935 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13936 				 common, "com");
13937 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13938 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13939 				 peer, "peer");
13940 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13941 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13942 			      peer_port, RTE_UINT16);
13943 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13944 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13945 				 is_orig, "is_orig");
13946 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13947 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13948 			      is_original, RTE_UINT32);
13949 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13950 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13951 				 enable, "enable");
13952 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13953 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13954 			      en, RTE_UINT32);
13955 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13956 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13957 				 live, "live");
13958 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13959 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13960 			      is_live, RTE_UINT32);
13961 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13962 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13963 				 sack, "sack");
13964 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13965 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13966 			      s_ack, RTE_UINT32);
13967 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13968 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13969 				 cack, "cack");
13970 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13971 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13972 			      c_ack, RTE_UINT32);
13973 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13974 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13975 				 last_dir, "last_dir");
13976 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13977 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13978 			      ld, RTE_UINT32);
13979 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13980 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13981 				 liberal, "liberal");
13982 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13983 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13984 			      lb, RTE_UINT32);
13985 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13986 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13987 				 state, "state");
13988 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13989 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13990 			      stat, RTE_UINT8);
13991 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13992 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13993 				 max_ack_win, "max_ack_win");
13994 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13995 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13996 			      factor, RTE_UINT8);
13997 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13998 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13999 				 retrans, "r_lim");
14000 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14001 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14002 			      re_num, RTE_UINT8);
14003 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14004 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14005 				 last_win, "last_win");
14006 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14007 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14008 			      lw, RTE_UINT16);
14009 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14010 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14011 				 last_seq, "last_seq");
14012 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14013 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14014 			      ls, RTE_UINT32);
14015 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14016 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14017 				 last_ack, "last_ack");
14018 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14019 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14020 			      la, RTE_UINT32);
14021 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14022 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14023 				 last_end, "last_end");
14024 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14025 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14026 			      le, RTE_UINT32);
14027 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14028 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14029 				 last_index, "last_index");
14030 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14031 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14032 			      li, RTE_UINT8);
14033 
14034 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14035 	__rte_unused struct cmdline *cl,
14036 	__rte_unused void *data)
14037 {
14038 	struct cmd_set_conntrack_common_result *res = parsed_result;
14039 
14040 	/* No need to swap to big endian. */
14041 	conntrack_context.peer_port = res->peer_port;
14042 	conntrack_context.is_original_dir = res->is_original;
14043 	conntrack_context.enable = res->en;
14044 	conntrack_context.live_connection = res->is_live;
14045 	conntrack_context.selective_ack = res->s_ack;
14046 	conntrack_context.challenge_ack_passed = res->c_ack;
14047 	conntrack_context.last_direction = res->ld;
14048 	conntrack_context.liberal_mode = res->lb;
14049 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14050 	conntrack_context.max_ack_window = res->factor;
14051 	conntrack_context.retransmission_limit = res->re_num;
14052 	conntrack_context.last_window = res->lw;
14053 	conntrack_context.last_index =
14054 		(enum rte_flow_conntrack_tcp_last_index)res->li;
14055 	conntrack_context.last_seq = res->ls;
14056 	conntrack_context.last_ack = res->la;
14057 	conntrack_context.last_end = res->le;
14058 }
14059 
14060 cmdline_parse_inst_t cmd_set_conntrack_common = {
14061 	.f = cmd_set_conntrack_common_parsed,
14062 	.data = NULL,
14063 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14064 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14065 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14066 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14067 		" last_index <flag>",
14068 	.tokens = {
14069 		(void *)&cmd_set_conntrack_set,
14070 		(void *)&cmd_set_conntrack_conntrack,
14071 		(void *)&cmd_set_conntrack_common_com,
14072 		(void *)&cmd_set_conntrack_common_peer,
14073 		(void *)&cmd_set_conntrack_common_peer_value,
14074 		(void *)&cmd_set_conntrack_common_is_orig,
14075 		(void *)&cmd_set_conntrack_common_is_orig_value,
14076 		(void *)&cmd_set_conntrack_common_enable,
14077 		(void *)&cmd_set_conntrack_common_enable_value,
14078 		(void *)&cmd_set_conntrack_common_live,
14079 		(void *)&cmd_set_conntrack_common_live_value,
14080 		(void *)&cmd_set_conntrack_common_sack,
14081 		(void *)&cmd_set_conntrack_common_sack_value,
14082 		(void *)&cmd_set_conntrack_common_cack,
14083 		(void *)&cmd_set_conntrack_common_cack_value,
14084 		(void *)&cmd_set_conntrack_common_last_dir,
14085 		(void *)&cmd_set_conntrack_common_last_dir_value,
14086 		(void *)&cmd_set_conntrack_common_liberal,
14087 		(void *)&cmd_set_conntrack_common_liberal_value,
14088 		(void *)&cmd_set_conntrack_common_state,
14089 		(void *)&cmd_set_conntrack_common_state_value,
14090 		(void *)&cmd_set_conntrack_common_max_ackwin,
14091 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
14092 		(void *)&cmd_set_conntrack_common_retrans,
14093 		(void *)&cmd_set_conntrack_common_retrans_value,
14094 		(void *)&cmd_set_conntrack_common_last_win,
14095 		(void *)&cmd_set_conntrack_common_last_win_value,
14096 		(void *)&cmd_set_conntrack_common_last_seq,
14097 		(void *)&cmd_set_conntrack_common_last_seq_value,
14098 		(void *)&cmd_set_conntrack_common_last_ack,
14099 		(void *)&cmd_set_conntrack_common_last_ack_value,
14100 		(void *)&cmd_set_conntrack_common_last_end,
14101 		(void *)&cmd_set_conntrack_common_last_end_value,
14102 		(void *)&cmd_set_conntrack_common_last_index,
14103 		(void *)&cmd_set_conntrack_common_last_index_value,
14104 		NULL,
14105 	},
14106 };
14107 
14108 /** Set connection tracking object both directions' details */
14109 struct cmd_set_conntrack_dir_result {
14110 	cmdline_fixed_string_t set;
14111 	cmdline_fixed_string_t conntrack;
14112 	cmdline_fixed_string_t dir;
14113 	cmdline_fixed_string_t scale;
14114 	cmdline_fixed_string_t fin;
14115 	cmdline_fixed_string_t ack_seen;
14116 	cmdline_fixed_string_t unack;
14117 	cmdline_fixed_string_t sent_end;
14118 	cmdline_fixed_string_t reply_end;
14119 	cmdline_fixed_string_t max_win;
14120 	cmdline_fixed_string_t max_ack;
14121 	uint32_t factor;
14122 	uint32_t f;
14123 	uint32_t as;
14124 	uint32_t un;
14125 	uint32_t se;
14126 	uint32_t re;
14127 	uint32_t mw;
14128 	uint32_t ma;
14129 };
14130 
14131 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14132 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14133 				 set, "set");
14134 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14135 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14136 				 conntrack, "conntrack");
14137 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14138 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14139 				 dir, "orig#rply");
14140 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14141 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14142 				 scale, "scale");
14143 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14144 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14145 			      factor, RTE_UINT32);
14146 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14147 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14148 				 fin, "fin");
14149 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14150 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14151 			      f, RTE_UINT32);
14152 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14153 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14154 				 ack_seen, "acked");
14155 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14156 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14157 			      as, RTE_UINT32);
14158 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14159 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14160 				 unack, "unack_data");
14161 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14162 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14163 			      un, RTE_UINT32);
14164 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14165 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14166 				 sent_end, "sent_end");
14167 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14168 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14169 			      se, RTE_UINT32);
14170 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14171 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14172 				 reply_end, "reply_end");
14173 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14174 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14175 			      re, RTE_UINT32);
14176 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14177 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14178 				 max_win, "max_win");
14179 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14180 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14181 			      mw, RTE_UINT32);
14182 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14183 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14184 				 max_ack, "max_ack");
14185 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14186 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14187 			      ma, RTE_UINT32);
14188 
14189 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14190 	__rte_unused struct cmdline *cl,
14191 	__rte_unused void *data)
14192 {
14193 	struct cmd_set_conntrack_dir_result *res = parsed_result;
14194 	struct rte_flow_tcp_dir_param *dir = NULL;
14195 
14196 	if (strcmp(res->dir, "orig") == 0)
14197 		dir = &conntrack_context.original_dir;
14198 	else if (strcmp(res->dir, "rply") == 0)
14199 		dir = &conntrack_context.reply_dir;
14200 	else
14201 		return;
14202 	dir->scale = res->factor;
14203 	dir->close_initiated = res->f;
14204 	dir->last_ack_seen = res->as;
14205 	dir->data_unacked = res->un;
14206 	dir->sent_end = res->se;
14207 	dir->reply_end = res->re;
14208 	dir->max_ack = res->ma;
14209 	dir->max_win = res->mw;
14210 }
14211 
14212 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14213 	.f = cmd_set_conntrack_dir_parsed,
14214 	.data = NULL,
14215 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14216 		    " acked <seen> unack_data <unack> sent_end <sent>"
14217 		    " reply_end <reply> max_win <win> max_ack <ack>",
14218 	.tokens = {
14219 		(void *)&cmd_set_conntrack_set,
14220 		(void *)&cmd_set_conntrack_conntrack,
14221 		(void *)&cmd_set_conntrack_dir_dir,
14222 		(void *)&cmd_set_conntrack_dir_scale,
14223 		(void *)&cmd_set_conntrack_dir_scale_value,
14224 		(void *)&cmd_set_conntrack_dir_fin,
14225 		(void *)&cmd_set_conntrack_dir_fin_value,
14226 		(void *)&cmd_set_conntrack_dir_ack,
14227 		(void *)&cmd_set_conntrack_dir_ack_value,
14228 		(void *)&cmd_set_conntrack_dir_unack_data,
14229 		(void *)&cmd_set_conntrack_dir_unack_data_value,
14230 		(void *)&cmd_set_conntrack_dir_sent_end,
14231 		(void *)&cmd_set_conntrack_dir_sent_end_value,
14232 		(void *)&cmd_set_conntrack_dir_reply_end,
14233 		(void *)&cmd_set_conntrack_dir_reply_end_value,
14234 		(void *)&cmd_set_conntrack_dir_max_win,
14235 		(void *)&cmd_set_conntrack_dir_max_win_value,
14236 		(void *)&cmd_set_conntrack_dir_max_ack,
14237 		(void *)&cmd_set_conntrack_dir_max_ack_value,
14238 		NULL,
14239 	},
14240 };
14241 
14242 /* Strict link priority scheduling mode setting */
14243 static void
14244 cmd_strict_link_prio_parsed(
14245 	void *parsed_result,
14246 	__rte_unused struct cmdline *cl,
14247 	__rte_unused void *data)
14248 {
14249 	struct cmd_vf_tc_bw_result *res = parsed_result;
14250 	int ret = -ENOTSUP;
14251 
14252 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14253 		return;
14254 
14255 #ifdef RTE_NET_I40E
14256 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14257 #endif
14258 
14259 	switch (ret) {
14260 	case 0:
14261 		break;
14262 	case -EINVAL:
14263 		fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14264 		break;
14265 	case -ENODEV:
14266 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
14267 		break;
14268 	case -ENOTSUP:
14269 		fprintf(stderr, "function not implemented\n");
14270 		break;
14271 	default:
14272 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14273 	}
14274 }
14275 
14276 cmdline_parse_inst_t cmd_strict_link_prio = {
14277 	.f = cmd_strict_link_prio_parsed,
14278 	.data = NULL,
14279 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14280 	.tokens = {
14281 		(void *)&cmd_vf_tc_bw_set,
14282 		(void *)&cmd_vf_tc_bw_tx,
14283 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14284 		(void *)&cmd_vf_tc_bw_port_id,
14285 		(void *)&cmd_vf_tc_bw_tc_map,
14286 		NULL,
14287 	},
14288 };
14289 
14290 /* Load dynamic device personalization*/
14291 struct cmd_ddp_add_result {
14292 	cmdline_fixed_string_t ddp;
14293 	cmdline_fixed_string_t add;
14294 	portid_t port_id;
14295 	char filepath[];
14296 };
14297 
14298 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14299 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14300 cmdline_parse_token_string_t cmd_ddp_add_add =
14301 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14302 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14303 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14304 		RTE_UINT16);
14305 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14306 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14307 
14308 static void
14309 cmd_ddp_add_parsed(
14310 	void *parsed_result,
14311 	__rte_unused struct cmdline *cl,
14312 	__rte_unused void *data)
14313 {
14314 	struct cmd_ddp_add_result *res = parsed_result;
14315 	uint8_t *buff;
14316 	uint32_t size;
14317 	char *filepath;
14318 	char *file_fld[2];
14319 	int file_num;
14320 	int ret = -ENOTSUP;
14321 
14322 	if (!all_ports_stopped()) {
14323 		fprintf(stderr, "Please stop all ports first\n");
14324 		return;
14325 	}
14326 
14327 	filepath = strdup(res->filepath);
14328 	if (filepath == NULL) {
14329 		fprintf(stderr, "Failed to allocate memory\n");
14330 		return;
14331 	}
14332 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14333 
14334 	buff = open_file(file_fld[0], &size);
14335 	if (!buff) {
14336 		free((void *)filepath);
14337 		return;
14338 	}
14339 
14340 #ifdef RTE_NET_I40E
14341 	if (ret == -ENOTSUP)
14342 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14343 					       buff, size,
14344 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14345 #endif
14346 
14347 	if (ret == -EEXIST)
14348 		fprintf(stderr, "Profile has already existed.\n");
14349 	else if (ret < 0)
14350 		fprintf(stderr, "Failed to load profile.\n");
14351 	else if (file_num == 2)
14352 		save_file(file_fld[1], buff, size);
14353 
14354 	close_file(buff);
14355 	free((void *)filepath);
14356 }
14357 
14358 cmdline_parse_inst_t cmd_ddp_add = {
14359 	.f = cmd_ddp_add_parsed,
14360 	.data = NULL,
14361 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14362 	.tokens = {
14363 		(void *)&cmd_ddp_add_ddp,
14364 		(void *)&cmd_ddp_add_add,
14365 		(void *)&cmd_ddp_add_port_id,
14366 		(void *)&cmd_ddp_add_filepath,
14367 		NULL,
14368 	},
14369 };
14370 
14371 /* Delete dynamic device personalization*/
14372 struct cmd_ddp_del_result {
14373 	cmdline_fixed_string_t ddp;
14374 	cmdline_fixed_string_t del;
14375 	portid_t port_id;
14376 	char filepath[];
14377 };
14378 
14379 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14380 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14381 cmdline_parse_token_string_t cmd_ddp_del_del =
14382 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14383 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14384 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14385 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14386 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14387 
14388 static void
14389 cmd_ddp_del_parsed(
14390 	void *parsed_result,
14391 	__rte_unused struct cmdline *cl,
14392 	__rte_unused void *data)
14393 {
14394 	struct cmd_ddp_del_result *res = parsed_result;
14395 	uint8_t *buff;
14396 	uint32_t size;
14397 	int ret = -ENOTSUP;
14398 
14399 	if (!all_ports_stopped()) {
14400 		fprintf(stderr, "Please stop all ports first\n");
14401 		return;
14402 	}
14403 
14404 	buff = open_file(res->filepath, &size);
14405 	if (!buff)
14406 		return;
14407 
14408 #ifdef RTE_NET_I40E
14409 	if (ret == -ENOTSUP)
14410 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14411 					       buff, size,
14412 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14413 #endif
14414 
14415 	if (ret == -EACCES)
14416 		fprintf(stderr, "Profile does not exist.\n");
14417 	else if (ret < 0)
14418 		fprintf(stderr, "Failed to delete profile.\n");
14419 
14420 	close_file(buff);
14421 }
14422 
14423 cmdline_parse_inst_t cmd_ddp_del = {
14424 	.f = cmd_ddp_del_parsed,
14425 	.data = NULL,
14426 	.help_str = "ddp del <port_id> <backup_profile_path>",
14427 	.tokens = {
14428 		(void *)&cmd_ddp_del_ddp,
14429 		(void *)&cmd_ddp_del_del,
14430 		(void *)&cmd_ddp_del_port_id,
14431 		(void *)&cmd_ddp_del_filepath,
14432 		NULL,
14433 	},
14434 };
14435 
14436 /* Get dynamic device personalization profile info */
14437 struct cmd_ddp_info_result {
14438 	cmdline_fixed_string_t ddp;
14439 	cmdline_fixed_string_t get;
14440 	cmdline_fixed_string_t info;
14441 	char filepath[];
14442 };
14443 
14444 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14445 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14446 cmdline_parse_token_string_t cmd_ddp_info_get =
14447 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14448 cmdline_parse_token_string_t cmd_ddp_info_info =
14449 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14450 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14451 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14452 
14453 static void
14454 cmd_ddp_info_parsed(
14455 	void *parsed_result,
14456 	__rte_unused struct cmdline *cl,
14457 	__rte_unused void *data)
14458 {
14459 	struct cmd_ddp_info_result *res = parsed_result;
14460 	uint8_t *pkg;
14461 	uint32_t pkg_size;
14462 	int ret = -ENOTSUP;
14463 #ifdef RTE_NET_I40E
14464 	uint32_t i, j, n;
14465 	uint8_t *buff;
14466 	uint32_t buff_size = 0;
14467 	struct rte_pmd_i40e_profile_info info;
14468 	uint32_t dev_num = 0;
14469 	struct rte_pmd_i40e_ddp_device_id *devs;
14470 	uint32_t proto_num = 0;
14471 	struct rte_pmd_i40e_proto_info *proto = NULL;
14472 	uint32_t pctype_num = 0;
14473 	struct rte_pmd_i40e_ptype_info *pctype;
14474 	uint32_t ptype_num = 0;
14475 	struct rte_pmd_i40e_ptype_info *ptype;
14476 	uint8_t proto_id;
14477 
14478 #endif
14479 
14480 	pkg = open_file(res->filepath, &pkg_size);
14481 	if (!pkg)
14482 		return;
14483 
14484 #ifdef RTE_NET_I40E
14485 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14486 				(uint8_t *)&info, sizeof(info),
14487 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14488 	if (!ret) {
14489 		printf("Global Track id:       0x%x\n", info.track_id);
14490 		printf("Global Version:        %d.%d.%d.%d\n",
14491 			info.version.major,
14492 			info.version.minor,
14493 			info.version.update,
14494 			info.version.draft);
14495 		printf("Global Package name:   %s\n\n", info.name);
14496 	}
14497 
14498 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14499 				(uint8_t *)&info, sizeof(info),
14500 				RTE_PMD_I40E_PKG_INFO_HEADER);
14501 	if (!ret) {
14502 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14503 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14504 			info.version.major,
14505 			info.version.minor,
14506 			info.version.update,
14507 			info.version.draft);
14508 		printf("i40e Profile name:     %s\n\n", info.name);
14509 	}
14510 
14511 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14512 				(uint8_t *)&buff_size, sizeof(buff_size),
14513 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14514 	if (!ret && buff_size) {
14515 		buff = (uint8_t *)malloc(buff_size);
14516 		if (buff) {
14517 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14518 						buff, buff_size,
14519 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14520 			if (!ret)
14521 				printf("Package Notes:\n%s\n\n", buff);
14522 			free(buff);
14523 		}
14524 	}
14525 
14526 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14527 				(uint8_t *)&dev_num, sizeof(dev_num),
14528 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14529 	if (!ret && dev_num) {
14530 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14531 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14532 		if (devs) {
14533 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14534 						(uint8_t *)devs, buff_size,
14535 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14536 			if (!ret) {
14537 				printf("List of supported devices:\n");
14538 				for (i = 0; i < dev_num; i++) {
14539 					printf("  %04X:%04X %04X:%04X\n",
14540 						devs[i].vendor_dev_id >> 16,
14541 						devs[i].vendor_dev_id & 0xFFFF,
14542 						devs[i].sub_vendor_dev_id >> 16,
14543 						devs[i].sub_vendor_dev_id & 0xFFFF);
14544 				}
14545 				printf("\n");
14546 			}
14547 			free(devs);
14548 		}
14549 	}
14550 
14551 	/* get information about protocols and packet types */
14552 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14553 		(uint8_t *)&proto_num, sizeof(proto_num),
14554 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14555 	if (ret || !proto_num)
14556 		goto no_print_return;
14557 
14558 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14559 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14560 	if (!proto)
14561 		goto no_print_return;
14562 
14563 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14564 					buff_size,
14565 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14566 	if (!ret) {
14567 		printf("List of used protocols:\n");
14568 		for (i = 0; i < proto_num; i++)
14569 			printf("  %2u: %s\n", proto[i].proto_id,
14570 			       proto[i].name);
14571 		printf("\n");
14572 	}
14573 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14574 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14575 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14576 	if (ret || !pctype_num)
14577 		goto no_print_pctypes;
14578 
14579 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14580 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14581 	if (!pctype)
14582 		goto no_print_pctypes;
14583 
14584 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14585 					buff_size,
14586 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14587 	if (ret) {
14588 		free(pctype);
14589 		goto no_print_pctypes;
14590 	}
14591 
14592 	printf("List of defined packet classification types:\n");
14593 	for (i = 0; i < pctype_num; i++) {
14594 		printf("  %2u:", pctype[i].ptype_id);
14595 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14596 			proto_id = pctype[i].protocols[j];
14597 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14598 				for (n = 0; n < proto_num; n++) {
14599 					if (proto[n].proto_id == proto_id) {
14600 						printf(" %s", proto[n].name);
14601 						break;
14602 					}
14603 				}
14604 			}
14605 		}
14606 		printf("\n");
14607 	}
14608 	printf("\n");
14609 	free(pctype);
14610 
14611 no_print_pctypes:
14612 
14613 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14614 					sizeof(ptype_num),
14615 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14616 	if (ret || !ptype_num)
14617 		goto no_print_return;
14618 
14619 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14620 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14621 	if (!ptype)
14622 		goto no_print_return;
14623 
14624 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14625 					buff_size,
14626 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14627 	if (ret) {
14628 		free(ptype);
14629 		goto no_print_return;
14630 	}
14631 	printf("List of defined packet types:\n");
14632 	for (i = 0; i < ptype_num; i++) {
14633 		printf("  %2u:", ptype[i].ptype_id);
14634 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14635 			proto_id = ptype[i].protocols[j];
14636 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14637 				for (n = 0; n < proto_num; n++) {
14638 					if (proto[n].proto_id == proto_id) {
14639 						printf(" %s", proto[n].name);
14640 						break;
14641 					}
14642 				}
14643 			}
14644 		}
14645 		printf("\n");
14646 	}
14647 	free(ptype);
14648 	printf("\n");
14649 
14650 	ret = 0;
14651 no_print_return:
14652 	if (proto)
14653 		free(proto);
14654 #endif
14655 	if (ret == -ENOTSUP)
14656 		fprintf(stderr, "Function not supported in PMD driver\n");
14657 	close_file(pkg);
14658 }
14659 
14660 cmdline_parse_inst_t cmd_ddp_get_info = {
14661 	.f = cmd_ddp_info_parsed,
14662 	.data = NULL,
14663 	.help_str = "ddp get info <profile_path>",
14664 	.tokens = {
14665 		(void *)&cmd_ddp_info_ddp,
14666 		(void *)&cmd_ddp_info_get,
14667 		(void *)&cmd_ddp_info_info,
14668 		(void *)&cmd_ddp_info_filepath,
14669 		NULL,
14670 	},
14671 };
14672 
14673 /* Get dynamic device personalization profile info list*/
14674 #define PROFILE_INFO_SIZE 48
14675 #define MAX_PROFILE_NUM 16
14676 
14677 struct cmd_ddp_get_list_result {
14678 	cmdline_fixed_string_t ddp;
14679 	cmdline_fixed_string_t get;
14680 	cmdline_fixed_string_t list;
14681 	portid_t port_id;
14682 };
14683 
14684 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14685 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14686 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14687 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14688 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14689 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14690 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14691 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14692 		RTE_UINT16);
14693 
14694 static void
14695 cmd_ddp_get_list_parsed(
14696 	__rte_unused void *parsed_result,
14697 	__rte_unused struct cmdline *cl,
14698 	__rte_unused void *data)
14699 {
14700 #ifdef RTE_NET_I40E
14701 	struct cmd_ddp_get_list_result *res = parsed_result;
14702 	struct rte_pmd_i40e_profile_list *p_list;
14703 	struct rte_pmd_i40e_profile_info *p_info;
14704 	uint32_t p_num;
14705 	uint32_t size;
14706 	uint32_t i;
14707 #endif
14708 	int ret = -ENOTSUP;
14709 
14710 #ifdef RTE_NET_I40E
14711 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14712 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14713 	if (!p_list) {
14714 		fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14715 		return;
14716 	}
14717 
14718 	if (ret == -ENOTSUP)
14719 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14720 						(uint8_t *)p_list, size);
14721 
14722 	if (!ret) {
14723 		p_num = p_list->p_count;
14724 		printf("Profile number is: %d\n\n", p_num);
14725 
14726 		for (i = 0; i < p_num; i++) {
14727 			p_info = &p_list->p_info[i];
14728 			printf("Profile %d:\n", i);
14729 			printf("Track id:     0x%x\n", p_info->track_id);
14730 			printf("Version:      %d.%d.%d.%d\n",
14731 			       p_info->version.major,
14732 			       p_info->version.minor,
14733 			       p_info->version.update,
14734 			       p_info->version.draft);
14735 			printf("Profile name: %s\n\n", p_info->name);
14736 		}
14737 	}
14738 
14739 	free(p_list);
14740 #endif
14741 
14742 	if (ret < 0)
14743 		fprintf(stderr, "Failed to get ddp list\n");
14744 }
14745 
14746 cmdline_parse_inst_t cmd_ddp_get_list = {
14747 	.f = cmd_ddp_get_list_parsed,
14748 	.data = NULL,
14749 	.help_str = "ddp get list <port_id>",
14750 	.tokens = {
14751 		(void *)&cmd_ddp_get_list_ddp,
14752 		(void *)&cmd_ddp_get_list_get,
14753 		(void *)&cmd_ddp_get_list_list,
14754 		(void *)&cmd_ddp_get_list_port_id,
14755 		NULL,
14756 	},
14757 };
14758 
14759 /* Configure input set */
14760 struct cmd_cfg_input_set_result {
14761 	cmdline_fixed_string_t port;
14762 	cmdline_fixed_string_t cfg;
14763 	portid_t port_id;
14764 	cmdline_fixed_string_t pctype;
14765 	uint8_t pctype_id;
14766 	cmdline_fixed_string_t inset_type;
14767 	cmdline_fixed_string_t opt;
14768 	cmdline_fixed_string_t field;
14769 	uint8_t field_idx;
14770 };
14771 
14772 static void
14773 cmd_cfg_input_set_parsed(
14774 	__rte_unused void *parsed_result,
14775 	__rte_unused struct cmdline *cl,
14776 	__rte_unused void *data)
14777 {
14778 #ifdef RTE_NET_I40E
14779 	struct cmd_cfg_input_set_result *res = parsed_result;
14780 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14781 	struct rte_pmd_i40e_inset inset;
14782 #endif
14783 	int ret = -ENOTSUP;
14784 
14785 	if (!all_ports_stopped()) {
14786 		fprintf(stderr, "Please stop all ports first\n");
14787 		return;
14788 	}
14789 
14790 #ifdef RTE_NET_I40E
14791 	if (!strcmp(res->inset_type, "hash_inset"))
14792 		inset_type = INSET_HASH;
14793 	else if (!strcmp(res->inset_type, "fdir_inset"))
14794 		inset_type = INSET_FDIR;
14795 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14796 		inset_type = INSET_FDIR_FLX;
14797 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14798 				     &inset, inset_type);
14799 	if (ret) {
14800 		fprintf(stderr, "Failed to get input set.\n");
14801 		return;
14802 	}
14803 
14804 	if (!strcmp(res->opt, "get")) {
14805 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14806 						   res->field_idx);
14807 		if (ret)
14808 			printf("Field index %d is enabled.\n", res->field_idx);
14809 		else
14810 			printf("Field index %d is disabled.\n", res->field_idx);
14811 		return;
14812 	} else if (!strcmp(res->opt, "set"))
14813 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14814 						   res->field_idx);
14815 	else if (!strcmp(res->opt, "clear"))
14816 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14817 						     res->field_idx);
14818 	if (ret) {
14819 		fprintf(stderr, "Failed to configure input set field.\n");
14820 		return;
14821 	}
14822 
14823 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14824 				     &inset, inset_type);
14825 	if (ret) {
14826 		fprintf(stderr, "Failed to set input set.\n");
14827 		return;
14828 	}
14829 #endif
14830 
14831 	if (ret == -ENOTSUP)
14832 		fprintf(stderr, "Function not supported\n");
14833 }
14834 
14835 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14836 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14837 				 port, "port");
14838 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14839 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14840 				 cfg, "config");
14841 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14842 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14843 			      port_id, RTE_UINT16);
14844 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14845 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14846 				 pctype, "pctype");
14847 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14848 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14849 			      pctype_id, RTE_UINT8);
14850 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14851 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14852 				 inset_type,
14853 				 "hash_inset#fdir_inset#fdir_flx_inset");
14854 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14855 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14856 				 opt, "get#set#clear");
14857 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14858 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14859 				 field, "field");
14860 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14861 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14862 			      field_idx, RTE_UINT8);
14863 
14864 cmdline_parse_inst_t cmd_cfg_input_set = {
14865 	.f = cmd_cfg_input_set_parsed,
14866 	.data = NULL,
14867 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14868 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14869 	.tokens = {
14870 		(void *)&cmd_cfg_input_set_port,
14871 		(void *)&cmd_cfg_input_set_cfg,
14872 		(void *)&cmd_cfg_input_set_port_id,
14873 		(void *)&cmd_cfg_input_set_pctype,
14874 		(void *)&cmd_cfg_input_set_pctype_id,
14875 		(void *)&cmd_cfg_input_set_inset_type,
14876 		(void *)&cmd_cfg_input_set_opt,
14877 		(void *)&cmd_cfg_input_set_field,
14878 		(void *)&cmd_cfg_input_set_field_idx,
14879 		NULL,
14880 	},
14881 };
14882 
14883 /* Clear input set */
14884 struct cmd_clear_input_set_result {
14885 	cmdline_fixed_string_t port;
14886 	cmdline_fixed_string_t cfg;
14887 	portid_t port_id;
14888 	cmdline_fixed_string_t pctype;
14889 	uint8_t pctype_id;
14890 	cmdline_fixed_string_t inset_type;
14891 	cmdline_fixed_string_t clear;
14892 	cmdline_fixed_string_t all;
14893 };
14894 
14895 static void
14896 cmd_clear_input_set_parsed(
14897 	__rte_unused void *parsed_result,
14898 	__rte_unused struct cmdline *cl,
14899 	__rte_unused void *data)
14900 {
14901 #ifdef RTE_NET_I40E
14902 	struct cmd_clear_input_set_result *res = parsed_result;
14903 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14904 	struct rte_pmd_i40e_inset inset;
14905 #endif
14906 	int ret = -ENOTSUP;
14907 
14908 	if (!all_ports_stopped()) {
14909 		fprintf(stderr, "Please stop all ports first\n");
14910 		return;
14911 	}
14912 
14913 #ifdef RTE_NET_I40E
14914 	if (!strcmp(res->inset_type, "hash_inset"))
14915 		inset_type = INSET_HASH;
14916 	else if (!strcmp(res->inset_type, "fdir_inset"))
14917 		inset_type = INSET_FDIR;
14918 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14919 		inset_type = INSET_FDIR_FLX;
14920 
14921 	memset(&inset, 0, sizeof(inset));
14922 
14923 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14924 				     &inset, inset_type);
14925 	if (ret) {
14926 		fprintf(stderr, "Failed to clear input set.\n");
14927 		return;
14928 	}
14929 
14930 #endif
14931 
14932 	if (ret == -ENOTSUP)
14933 		fprintf(stderr, "Function not supported\n");
14934 }
14935 
14936 cmdline_parse_token_string_t cmd_clear_input_set_port =
14937 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14938 				 port, "port");
14939 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14940 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14941 				 cfg, "config");
14942 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14943 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14944 			      port_id, RTE_UINT16);
14945 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14946 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14947 				 pctype, "pctype");
14948 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14949 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14950 			      pctype_id, RTE_UINT8);
14951 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14952 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14953 				 inset_type,
14954 				 "hash_inset#fdir_inset#fdir_flx_inset");
14955 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14956 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14957 				 clear, "clear");
14958 cmdline_parse_token_string_t cmd_clear_input_set_all =
14959 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14960 				 all, "all");
14961 
14962 cmdline_parse_inst_t cmd_clear_input_set = {
14963 	.f = cmd_clear_input_set_parsed,
14964 	.data = NULL,
14965 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14966 		    "fdir_inset|fdir_flx_inset clear all",
14967 	.tokens = {
14968 		(void *)&cmd_clear_input_set_port,
14969 		(void *)&cmd_clear_input_set_cfg,
14970 		(void *)&cmd_clear_input_set_port_id,
14971 		(void *)&cmd_clear_input_set_pctype,
14972 		(void *)&cmd_clear_input_set_pctype_id,
14973 		(void *)&cmd_clear_input_set_inset_type,
14974 		(void *)&cmd_clear_input_set_clear,
14975 		(void *)&cmd_clear_input_set_all,
14976 		NULL,
14977 	},
14978 };
14979 
14980 /* show vf stats */
14981 
14982 /* Common result structure for show vf stats */
14983 struct cmd_show_vf_stats_result {
14984 	cmdline_fixed_string_t show;
14985 	cmdline_fixed_string_t vf;
14986 	cmdline_fixed_string_t stats;
14987 	portid_t port_id;
14988 	uint16_t vf_id;
14989 };
14990 
14991 /* Common CLI fields show vf stats*/
14992 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14993 	TOKEN_STRING_INITIALIZER
14994 		(struct cmd_show_vf_stats_result,
14995 		 show, "show");
14996 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14997 	TOKEN_STRING_INITIALIZER
14998 		(struct cmd_show_vf_stats_result,
14999 		 vf, "vf");
15000 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15001 	TOKEN_STRING_INITIALIZER
15002 		(struct cmd_show_vf_stats_result,
15003 		 stats, "stats");
15004 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15005 	TOKEN_NUM_INITIALIZER
15006 		(struct cmd_show_vf_stats_result,
15007 		 port_id, RTE_UINT16);
15008 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15009 	TOKEN_NUM_INITIALIZER
15010 		(struct cmd_show_vf_stats_result,
15011 		 vf_id, RTE_UINT16);
15012 
15013 static void
15014 cmd_show_vf_stats_parsed(
15015 	void *parsed_result,
15016 	__rte_unused struct cmdline *cl,
15017 	__rte_unused void *data)
15018 {
15019 	struct cmd_show_vf_stats_result *res = parsed_result;
15020 	struct rte_eth_stats stats;
15021 	int ret = -ENOTSUP;
15022 	static const char *nic_stats_border = "########################";
15023 
15024 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15025 		return;
15026 
15027 	memset(&stats, 0, sizeof(stats));
15028 
15029 #ifdef RTE_NET_I40E
15030 	if (ret == -ENOTSUP)
15031 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15032 						res->vf_id,
15033 						&stats);
15034 #endif
15035 #ifdef RTE_NET_BNXT
15036 	if (ret == -ENOTSUP)
15037 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15038 						res->vf_id,
15039 						&stats);
15040 #endif
15041 
15042 	switch (ret) {
15043 	case 0:
15044 		break;
15045 	case -EINVAL:
15046 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15047 		break;
15048 	case -ENODEV:
15049 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15050 		break;
15051 	case -ENOTSUP:
15052 		fprintf(stderr, "function not implemented\n");
15053 		break;
15054 	default:
15055 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15056 	}
15057 
15058 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
15059 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15060 
15061 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
15062 	       "%-"PRIu64"\n",
15063 	       stats.ipackets, stats.imissed, stats.ibytes);
15064 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
15065 	printf("  RX-nombuf:  %-10"PRIu64"\n",
15066 	       stats.rx_nombuf);
15067 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
15068 	       "%-"PRIu64"\n",
15069 	       stats.opackets, stats.oerrors, stats.obytes);
15070 
15071 	printf("  %s############################%s\n",
15072 			       nic_stats_border, nic_stats_border);
15073 }
15074 
15075 cmdline_parse_inst_t cmd_show_vf_stats = {
15076 	.f = cmd_show_vf_stats_parsed,
15077 	.data = NULL,
15078 	.help_str = "show vf stats <port_id> <vf_id>",
15079 	.tokens = {
15080 		(void *)&cmd_show_vf_stats_show,
15081 		(void *)&cmd_show_vf_stats_vf,
15082 		(void *)&cmd_show_vf_stats_stats,
15083 		(void *)&cmd_show_vf_stats_port_id,
15084 		(void *)&cmd_show_vf_stats_vf_id,
15085 		NULL,
15086 	},
15087 };
15088 
15089 /* clear vf stats */
15090 
15091 /* Common result structure for clear vf stats */
15092 struct cmd_clear_vf_stats_result {
15093 	cmdline_fixed_string_t clear;
15094 	cmdline_fixed_string_t vf;
15095 	cmdline_fixed_string_t stats;
15096 	portid_t port_id;
15097 	uint16_t vf_id;
15098 };
15099 
15100 /* Common CLI fields clear vf stats*/
15101 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15102 	TOKEN_STRING_INITIALIZER
15103 		(struct cmd_clear_vf_stats_result,
15104 		 clear, "clear");
15105 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15106 	TOKEN_STRING_INITIALIZER
15107 		(struct cmd_clear_vf_stats_result,
15108 		 vf, "vf");
15109 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15110 	TOKEN_STRING_INITIALIZER
15111 		(struct cmd_clear_vf_stats_result,
15112 		 stats, "stats");
15113 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15114 	TOKEN_NUM_INITIALIZER
15115 		(struct cmd_clear_vf_stats_result,
15116 		 port_id, RTE_UINT16);
15117 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15118 	TOKEN_NUM_INITIALIZER
15119 		(struct cmd_clear_vf_stats_result,
15120 		 vf_id, RTE_UINT16);
15121 
15122 static void
15123 cmd_clear_vf_stats_parsed(
15124 	void *parsed_result,
15125 	__rte_unused struct cmdline *cl,
15126 	__rte_unused void *data)
15127 {
15128 	struct cmd_clear_vf_stats_result *res = parsed_result;
15129 	int ret = -ENOTSUP;
15130 
15131 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15132 		return;
15133 
15134 #ifdef RTE_NET_I40E
15135 	if (ret == -ENOTSUP)
15136 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15137 						  res->vf_id);
15138 #endif
15139 #ifdef RTE_NET_BNXT
15140 	if (ret == -ENOTSUP)
15141 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15142 						  res->vf_id);
15143 #endif
15144 
15145 	switch (ret) {
15146 	case 0:
15147 		break;
15148 	case -EINVAL:
15149 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15150 		break;
15151 	case -ENODEV:
15152 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15153 		break;
15154 	case -ENOTSUP:
15155 		fprintf(stderr, "function not implemented\n");
15156 		break;
15157 	default:
15158 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15159 	}
15160 }
15161 
15162 cmdline_parse_inst_t cmd_clear_vf_stats = {
15163 	.f = cmd_clear_vf_stats_parsed,
15164 	.data = NULL,
15165 	.help_str = "clear vf stats <port_id> <vf_id>",
15166 	.tokens = {
15167 		(void *)&cmd_clear_vf_stats_clear,
15168 		(void *)&cmd_clear_vf_stats_vf,
15169 		(void *)&cmd_clear_vf_stats_stats,
15170 		(void *)&cmd_clear_vf_stats_port_id,
15171 		(void *)&cmd_clear_vf_stats_vf_id,
15172 		NULL,
15173 	},
15174 };
15175 
15176 /* port config pctype mapping reset */
15177 
15178 /* Common result structure for port config pctype mapping reset */
15179 struct cmd_pctype_mapping_reset_result {
15180 	cmdline_fixed_string_t port;
15181 	cmdline_fixed_string_t config;
15182 	portid_t port_id;
15183 	cmdline_fixed_string_t pctype;
15184 	cmdline_fixed_string_t mapping;
15185 	cmdline_fixed_string_t reset;
15186 };
15187 
15188 /* Common CLI fields for port config pctype mapping reset*/
15189 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15190 	TOKEN_STRING_INITIALIZER
15191 		(struct cmd_pctype_mapping_reset_result,
15192 		 port, "port");
15193 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15194 	TOKEN_STRING_INITIALIZER
15195 		(struct cmd_pctype_mapping_reset_result,
15196 		 config, "config");
15197 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15198 	TOKEN_NUM_INITIALIZER
15199 		(struct cmd_pctype_mapping_reset_result,
15200 		 port_id, RTE_UINT16);
15201 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15202 	TOKEN_STRING_INITIALIZER
15203 		(struct cmd_pctype_mapping_reset_result,
15204 		 pctype, "pctype");
15205 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15206 	TOKEN_STRING_INITIALIZER
15207 		(struct cmd_pctype_mapping_reset_result,
15208 		 mapping, "mapping");
15209 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15210 	TOKEN_STRING_INITIALIZER
15211 		(struct cmd_pctype_mapping_reset_result,
15212 		 reset, "reset");
15213 
15214 static void
15215 cmd_pctype_mapping_reset_parsed(
15216 	void *parsed_result,
15217 	__rte_unused struct cmdline *cl,
15218 	__rte_unused void *data)
15219 {
15220 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15221 	int ret = -ENOTSUP;
15222 
15223 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15224 		return;
15225 
15226 #ifdef RTE_NET_I40E
15227 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15228 #endif
15229 
15230 	switch (ret) {
15231 	case 0:
15232 		break;
15233 	case -ENODEV:
15234 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15235 		break;
15236 	case -ENOTSUP:
15237 		fprintf(stderr, "function not implemented\n");
15238 		break;
15239 	default:
15240 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15241 	}
15242 }
15243 
15244 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15245 	.f = cmd_pctype_mapping_reset_parsed,
15246 	.data = NULL,
15247 	.help_str = "port config <port_id> pctype mapping reset",
15248 	.tokens = {
15249 		(void *)&cmd_pctype_mapping_reset_port,
15250 		(void *)&cmd_pctype_mapping_reset_config,
15251 		(void *)&cmd_pctype_mapping_reset_port_id,
15252 		(void *)&cmd_pctype_mapping_reset_pctype,
15253 		(void *)&cmd_pctype_mapping_reset_mapping,
15254 		(void *)&cmd_pctype_mapping_reset_reset,
15255 		NULL,
15256 	},
15257 };
15258 
15259 /* show port pctype mapping */
15260 
15261 /* Common result structure for show port pctype mapping */
15262 struct cmd_pctype_mapping_get_result {
15263 	cmdline_fixed_string_t show;
15264 	cmdline_fixed_string_t port;
15265 	portid_t port_id;
15266 	cmdline_fixed_string_t pctype;
15267 	cmdline_fixed_string_t mapping;
15268 };
15269 
15270 /* Common CLI fields for pctype mapping get */
15271 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15272 	TOKEN_STRING_INITIALIZER
15273 		(struct cmd_pctype_mapping_get_result,
15274 		 show, "show");
15275 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15276 	TOKEN_STRING_INITIALIZER
15277 		(struct cmd_pctype_mapping_get_result,
15278 		 port, "port");
15279 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15280 	TOKEN_NUM_INITIALIZER
15281 		(struct cmd_pctype_mapping_get_result,
15282 		 port_id, RTE_UINT16);
15283 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15284 	TOKEN_STRING_INITIALIZER
15285 		(struct cmd_pctype_mapping_get_result,
15286 		 pctype, "pctype");
15287 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15288 	TOKEN_STRING_INITIALIZER
15289 		(struct cmd_pctype_mapping_get_result,
15290 		 mapping, "mapping");
15291 
15292 static void
15293 cmd_pctype_mapping_get_parsed(
15294 	void *parsed_result,
15295 	__rte_unused struct cmdline *cl,
15296 	__rte_unused void *data)
15297 {
15298 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15299 	int ret = -ENOTSUP;
15300 #ifdef RTE_NET_I40E
15301 	struct rte_pmd_i40e_flow_type_mapping
15302 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15303 	int i, j, first_pctype;
15304 #endif
15305 
15306 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15307 		return;
15308 
15309 #ifdef RTE_NET_I40E
15310 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15311 #endif
15312 
15313 	switch (ret) {
15314 	case 0:
15315 		break;
15316 	case -ENODEV:
15317 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15318 		return;
15319 	case -ENOTSUP:
15320 		fprintf(stderr, "function not implemented\n");
15321 		return;
15322 	default:
15323 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15324 		return;
15325 	}
15326 
15327 #ifdef RTE_NET_I40E
15328 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15329 		if (mapping[i].pctype != 0ULL) {
15330 			first_pctype = 1;
15331 
15332 			printf("pctype: ");
15333 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15334 				if (mapping[i].pctype & (1ULL << j)) {
15335 					printf(first_pctype ?
15336 					       "%02d" : ",%02d", j);
15337 					first_pctype = 0;
15338 				}
15339 			}
15340 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15341 		}
15342 	}
15343 #endif
15344 }
15345 
15346 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15347 	.f = cmd_pctype_mapping_get_parsed,
15348 	.data = NULL,
15349 	.help_str = "show port <port_id> pctype mapping",
15350 	.tokens = {
15351 		(void *)&cmd_pctype_mapping_get_show,
15352 		(void *)&cmd_pctype_mapping_get_port,
15353 		(void *)&cmd_pctype_mapping_get_port_id,
15354 		(void *)&cmd_pctype_mapping_get_pctype,
15355 		(void *)&cmd_pctype_mapping_get_mapping,
15356 		NULL,
15357 	},
15358 };
15359 
15360 /* port config pctype mapping update */
15361 
15362 /* Common result structure for port config pctype mapping update */
15363 struct cmd_pctype_mapping_update_result {
15364 	cmdline_fixed_string_t port;
15365 	cmdline_fixed_string_t config;
15366 	portid_t port_id;
15367 	cmdline_fixed_string_t pctype;
15368 	cmdline_fixed_string_t mapping;
15369 	cmdline_fixed_string_t update;
15370 	cmdline_fixed_string_t pctype_list;
15371 	uint16_t flow_type;
15372 };
15373 
15374 /* Common CLI fields for pctype mapping update*/
15375 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15376 	TOKEN_STRING_INITIALIZER
15377 		(struct cmd_pctype_mapping_update_result,
15378 		 port, "port");
15379 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15380 	TOKEN_STRING_INITIALIZER
15381 		(struct cmd_pctype_mapping_update_result,
15382 		 config, "config");
15383 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15384 	TOKEN_NUM_INITIALIZER
15385 		(struct cmd_pctype_mapping_update_result,
15386 		 port_id, RTE_UINT16);
15387 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15388 	TOKEN_STRING_INITIALIZER
15389 		(struct cmd_pctype_mapping_update_result,
15390 		 pctype, "pctype");
15391 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15392 	TOKEN_STRING_INITIALIZER
15393 		(struct cmd_pctype_mapping_update_result,
15394 		 mapping, "mapping");
15395 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15396 	TOKEN_STRING_INITIALIZER
15397 		(struct cmd_pctype_mapping_update_result,
15398 		 update, "update");
15399 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15400 	TOKEN_STRING_INITIALIZER
15401 		(struct cmd_pctype_mapping_update_result,
15402 		 pctype_list, NULL);
15403 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15404 	TOKEN_NUM_INITIALIZER
15405 		(struct cmd_pctype_mapping_update_result,
15406 		 flow_type, RTE_UINT16);
15407 
15408 static void
15409 cmd_pctype_mapping_update_parsed(
15410 	void *parsed_result,
15411 	__rte_unused struct cmdline *cl,
15412 	__rte_unused void *data)
15413 {
15414 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15415 	int ret = -ENOTSUP;
15416 #ifdef RTE_NET_I40E
15417 	struct rte_pmd_i40e_flow_type_mapping mapping;
15418 	unsigned int i;
15419 	unsigned int nb_item;
15420 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15421 #endif
15422 
15423 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15424 		return;
15425 
15426 #ifdef RTE_NET_I40E
15427 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15428 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15429 	mapping.flow_type = res->flow_type;
15430 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15431 		mapping.pctype |= (1ULL << pctype_list[i]);
15432 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15433 						&mapping,
15434 						1,
15435 						0);
15436 #endif
15437 
15438 	switch (ret) {
15439 	case 0:
15440 		break;
15441 	case -EINVAL:
15442 		fprintf(stderr, "invalid pctype or flow type\n");
15443 		break;
15444 	case -ENODEV:
15445 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15446 		break;
15447 	case -ENOTSUP:
15448 		fprintf(stderr, "function not implemented\n");
15449 		break;
15450 	default:
15451 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15452 	}
15453 }
15454 
15455 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15456 	.f = cmd_pctype_mapping_update_parsed,
15457 	.data = NULL,
15458 	.help_str = "port config <port_id> pctype mapping update"
15459 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15460 	.tokens = {
15461 		(void *)&cmd_pctype_mapping_update_port,
15462 		(void *)&cmd_pctype_mapping_update_config,
15463 		(void *)&cmd_pctype_mapping_update_port_id,
15464 		(void *)&cmd_pctype_mapping_update_pctype,
15465 		(void *)&cmd_pctype_mapping_update_mapping,
15466 		(void *)&cmd_pctype_mapping_update_update,
15467 		(void *)&cmd_pctype_mapping_update_pc_type,
15468 		(void *)&cmd_pctype_mapping_update_flow_type,
15469 		NULL,
15470 	},
15471 };
15472 
15473 /* ptype mapping get */
15474 
15475 /* Common result structure for ptype mapping get */
15476 struct cmd_ptype_mapping_get_result {
15477 	cmdline_fixed_string_t ptype;
15478 	cmdline_fixed_string_t mapping;
15479 	cmdline_fixed_string_t get;
15480 	portid_t port_id;
15481 	uint8_t valid_only;
15482 };
15483 
15484 /* Common CLI fields for ptype mapping get */
15485 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15486 	TOKEN_STRING_INITIALIZER
15487 		(struct cmd_ptype_mapping_get_result,
15488 		 ptype, "ptype");
15489 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15490 	TOKEN_STRING_INITIALIZER
15491 		(struct cmd_ptype_mapping_get_result,
15492 		 mapping, "mapping");
15493 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15494 	TOKEN_STRING_INITIALIZER
15495 		(struct cmd_ptype_mapping_get_result,
15496 		 get, "get");
15497 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15498 	TOKEN_NUM_INITIALIZER
15499 		(struct cmd_ptype_mapping_get_result,
15500 		 port_id, RTE_UINT16);
15501 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15502 	TOKEN_NUM_INITIALIZER
15503 		(struct cmd_ptype_mapping_get_result,
15504 		 valid_only, RTE_UINT8);
15505 
15506 static void
15507 cmd_ptype_mapping_get_parsed(
15508 	void *parsed_result,
15509 	__rte_unused struct cmdline *cl,
15510 	__rte_unused void *data)
15511 {
15512 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15513 	int ret = -ENOTSUP;
15514 #ifdef RTE_NET_I40E
15515 	int max_ptype_num = 256;
15516 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15517 	uint16_t count;
15518 	int i;
15519 #endif
15520 
15521 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15522 		return;
15523 
15524 #ifdef RTE_NET_I40E
15525 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15526 					mapping,
15527 					max_ptype_num,
15528 					&count,
15529 					res->valid_only);
15530 #endif
15531 
15532 	switch (ret) {
15533 	case 0:
15534 		break;
15535 	case -ENODEV:
15536 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15537 		break;
15538 	case -ENOTSUP:
15539 		fprintf(stderr, "function not implemented\n");
15540 		break;
15541 	default:
15542 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15543 	}
15544 
15545 #ifdef RTE_NET_I40E
15546 	if (!ret) {
15547 		for (i = 0; i < count; i++)
15548 			printf("%3d\t0x%08x\n",
15549 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15550 	}
15551 #endif
15552 }
15553 
15554 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15555 	.f = cmd_ptype_mapping_get_parsed,
15556 	.data = NULL,
15557 	.help_str = "ptype mapping get <port_id> <valid_only>",
15558 	.tokens = {
15559 		(void *)&cmd_ptype_mapping_get_ptype,
15560 		(void *)&cmd_ptype_mapping_get_mapping,
15561 		(void *)&cmd_ptype_mapping_get_get,
15562 		(void *)&cmd_ptype_mapping_get_port_id,
15563 		(void *)&cmd_ptype_mapping_get_valid_only,
15564 		NULL,
15565 	},
15566 };
15567 
15568 /* ptype mapping replace */
15569 
15570 /* Common result structure for ptype mapping replace */
15571 struct cmd_ptype_mapping_replace_result {
15572 	cmdline_fixed_string_t ptype;
15573 	cmdline_fixed_string_t mapping;
15574 	cmdline_fixed_string_t replace;
15575 	portid_t port_id;
15576 	uint32_t target;
15577 	uint8_t mask;
15578 	uint32_t pkt_type;
15579 };
15580 
15581 /* Common CLI fields for ptype mapping replace */
15582 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15583 	TOKEN_STRING_INITIALIZER
15584 		(struct cmd_ptype_mapping_replace_result,
15585 		 ptype, "ptype");
15586 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15587 	TOKEN_STRING_INITIALIZER
15588 		(struct cmd_ptype_mapping_replace_result,
15589 		 mapping, "mapping");
15590 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15591 	TOKEN_STRING_INITIALIZER
15592 		(struct cmd_ptype_mapping_replace_result,
15593 		 replace, "replace");
15594 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15595 	TOKEN_NUM_INITIALIZER
15596 		(struct cmd_ptype_mapping_replace_result,
15597 		 port_id, RTE_UINT16);
15598 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15599 	TOKEN_NUM_INITIALIZER
15600 		(struct cmd_ptype_mapping_replace_result,
15601 		 target, RTE_UINT32);
15602 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15603 	TOKEN_NUM_INITIALIZER
15604 		(struct cmd_ptype_mapping_replace_result,
15605 		 mask, RTE_UINT8);
15606 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15607 	TOKEN_NUM_INITIALIZER
15608 		(struct cmd_ptype_mapping_replace_result,
15609 		 pkt_type, RTE_UINT32);
15610 
15611 static void
15612 cmd_ptype_mapping_replace_parsed(
15613 	void *parsed_result,
15614 	__rte_unused struct cmdline *cl,
15615 	__rte_unused void *data)
15616 {
15617 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15618 	int ret = -ENOTSUP;
15619 
15620 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15621 		return;
15622 
15623 #ifdef RTE_NET_I40E
15624 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15625 					res->target,
15626 					res->mask,
15627 					res->pkt_type);
15628 #endif
15629 
15630 	switch (ret) {
15631 	case 0:
15632 		break;
15633 	case -EINVAL:
15634 		fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15635 			res->target, res->pkt_type);
15636 		break;
15637 	case -ENODEV:
15638 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15639 		break;
15640 	case -ENOTSUP:
15641 		fprintf(stderr, "function not implemented\n");
15642 		break;
15643 	default:
15644 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15645 	}
15646 }
15647 
15648 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15649 	.f = cmd_ptype_mapping_replace_parsed,
15650 	.data = NULL,
15651 	.help_str =
15652 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15653 	.tokens = {
15654 		(void *)&cmd_ptype_mapping_replace_ptype,
15655 		(void *)&cmd_ptype_mapping_replace_mapping,
15656 		(void *)&cmd_ptype_mapping_replace_replace,
15657 		(void *)&cmd_ptype_mapping_replace_port_id,
15658 		(void *)&cmd_ptype_mapping_replace_target,
15659 		(void *)&cmd_ptype_mapping_replace_mask,
15660 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15661 		NULL,
15662 	},
15663 };
15664 
15665 /* ptype mapping reset */
15666 
15667 /* Common result structure for ptype mapping reset */
15668 struct cmd_ptype_mapping_reset_result {
15669 	cmdline_fixed_string_t ptype;
15670 	cmdline_fixed_string_t mapping;
15671 	cmdline_fixed_string_t reset;
15672 	portid_t port_id;
15673 };
15674 
15675 /* Common CLI fields for ptype mapping reset*/
15676 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15677 	TOKEN_STRING_INITIALIZER
15678 		(struct cmd_ptype_mapping_reset_result,
15679 		 ptype, "ptype");
15680 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15681 	TOKEN_STRING_INITIALIZER
15682 		(struct cmd_ptype_mapping_reset_result,
15683 		 mapping, "mapping");
15684 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15685 	TOKEN_STRING_INITIALIZER
15686 		(struct cmd_ptype_mapping_reset_result,
15687 		 reset, "reset");
15688 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15689 	TOKEN_NUM_INITIALIZER
15690 		(struct cmd_ptype_mapping_reset_result,
15691 		 port_id, RTE_UINT16);
15692 
15693 static void
15694 cmd_ptype_mapping_reset_parsed(
15695 	void *parsed_result,
15696 	__rte_unused struct cmdline *cl,
15697 	__rte_unused void *data)
15698 {
15699 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15700 	int ret = -ENOTSUP;
15701 
15702 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15703 		return;
15704 
15705 #ifdef RTE_NET_I40E
15706 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15707 #endif
15708 
15709 	switch (ret) {
15710 	case 0:
15711 		break;
15712 	case -ENODEV:
15713 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15714 		break;
15715 	case -ENOTSUP:
15716 		fprintf(stderr, "function not implemented\n");
15717 		break;
15718 	default:
15719 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15720 	}
15721 }
15722 
15723 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15724 	.f = cmd_ptype_mapping_reset_parsed,
15725 	.data = NULL,
15726 	.help_str = "ptype mapping reset <port_id>",
15727 	.tokens = {
15728 		(void *)&cmd_ptype_mapping_reset_ptype,
15729 		(void *)&cmd_ptype_mapping_reset_mapping,
15730 		(void *)&cmd_ptype_mapping_reset_reset,
15731 		(void *)&cmd_ptype_mapping_reset_port_id,
15732 		NULL,
15733 	},
15734 };
15735 
15736 /* ptype mapping update */
15737 
15738 /* Common result structure for ptype mapping update */
15739 struct cmd_ptype_mapping_update_result {
15740 	cmdline_fixed_string_t ptype;
15741 	cmdline_fixed_string_t mapping;
15742 	cmdline_fixed_string_t reset;
15743 	portid_t port_id;
15744 	uint8_t hw_ptype;
15745 	uint32_t sw_ptype;
15746 };
15747 
15748 /* Common CLI fields for ptype mapping update*/
15749 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15750 	TOKEN_STRING_INITIALIZER
15751 		(struct cmd_ptype_mapping_update_result,
15752 		 ptype, "ptype");
15753 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15754 	TOKEN_STRING_INITIALIZER
15755 		(struct cmd_ptype_mapping_update_result,
15756 		 mapping, "mapping");
15757 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15758 	TOKEN_STRING_INITIALIZER
15759 		(struct cmd_ptype_mapping_update_result,
15760 		 reset, "update");
15761 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15762 	TOKEN_NUM_INITIALIZER
15763 		(struct cmd_ptype_mapping_update_result,
15764 		 port_id, RTE_UINT16);
15765 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15766 	TOKEN_NUM_INITIALIZER
15767 		(struct cmd_ptype_mapping_update_result,
15768 		 hw_ptype, RTE_UINT8);
15769 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15770 	TOKEN_NUM_INITIALIZER
15771 		(struct cmd_ptype_mapping_update_result,
15772 		 sw_ptype, RTE_UINT32);
15773 
15774 static void
15775 cmd_ptype_mapping_update_parsed(
15776 	void *parsed_result,
15777 	__rte_unused struct cmdline *cl,
15778 	__rte_unused void *data)
15779 {
15780 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15781 	int ret = -ENOTSUP;
15782 #ifdef RTE_NET_I40E
15783 	struct rte_pmd_i40e_ptype_mapping mapping;
15784 #endif
15785 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15786 		return;
15787 
15788 #ifdef RTE_NET_I40E
15789 	mapping.hw_ptype = res->hw_ptype;
15790 	mapping.sw_ptype = res->sw_ptype;
15791 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15792 						&mapping,
15793 						1,
15794 						0);
15795 #endif
15796 
15797 	switch (ret) {
15798 	case 0:
15799 		break;
15800 	case -EINVAL:
15801 		fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15802 		break;
15803 	case -ENODEV:
15804 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15805 		break;
15806 	case -ENOTSUP:
15807 		fprintf(stderr, "function not implemented\n");
15808 		break;
15809 	default:
15810 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15811 	}
15812 }
15813 
15814 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15815 	.f = cmd_ptype_mapping_update_parsed,
15816 	.data = NULL,
15817 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15818 	.tokens = {
15819 		(void *)&cmd_ptype_mapping_update_ptype,
15820 		(void *)&cmd_ptype_mapping_update_mapping,
15821 		(void *)&cmd_ptype_mapping_update_update,
15822 		(void *)&cmd_ptype_mapping_update_port_id,
15823 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15824 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15825 		NULL,
15826 	},
15827 };
15828 
15829 /* Common result structure for file commands */
15830 struct cmd_cmdfile_result {
15831 	cmdline_fixed_string_t load;
15832 	cmdline_fixed_string_t filename;
15833 };
15834 
15835 /* Common CLI fields for file commands */
15836 cmdline_parse_token_string_t cmd_load_cmdfile =
15837 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15838 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15839 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15840 
15841 static void
15842 cmd_load_from_file_parsed(
15843 	void *parsed_result,
15844 	__rte_unused struct cmdline *cl,
15845 	__rte_unused void *data)
15846 {
15847 	struct cmd_cmdfile_result *res = parsed_result;
15848 
15849 	cmdline_read_from_file(res->filename);
15850 }
15851 
15852 cmdline_parse_inst_t cmd_load_from_file = {
15853 	.f = cmd_load_from_file_parsed,
15854 	.data = NULL,
15855 	.help_str = "load <filename>",
15856 	.tokens = {
15857 		(void *)&cmd_load_cmdfile,
15858 		(void *)&cmd_load_cmdfile_filename,
15859 		NULL,
15860 	},
15861 };
15862 
15863 /* Get Rx offloads capabilities */
15864 struct cmd_rx_offload_get_capa_result {
15865 	cmdline_fixed_string_t show;
15866 	cmdline_fixed_string_t port;
15867 	portid_t port_id;
15868 	cmdline_fixed_string_t rx_offload;
15869 	cmdline_fixed_string_t capabilities;
15870 };
15871 
15872 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15873 	TOKEN_STRING_INITIALIZER
15874 		(struct cmd_rx_offload_get_capa_result,
15875 		 show, "show");
15876 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15877 	TOKEN_STRING_INITIALIZER
15878 		(struct cmd_rx_offload_get_capa_result,
15879 		 port, "port");
15880 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15881 	TOKEN_NUM_INITIALIZER
15882 		(struct cmd_rx_offload_get_capa_result,
15883 		 port_id, RTE_UINT16);
15884 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15885 	TOKEN_STRING_INITIALIZER
15886 		(struct cmd_rx_offload_get_capa_result,
15887 		 rx_offload, "rx_offload");
15888 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15889 	TOKEN_STRING_INITIALIZER
15890 		(struct cmd_rx_offload_get_capa_result,
15891 		 capabilities, "capabilities");
15892 
15893 static void
15894 print_rx_offloads(uint64_t offloads)
15895 {
15896 	uint64_t single_offload;
15897 	int begin;
15898 	int end;
15899 	int bit;
15900 
15901 	if (offloads == 0)
15902 		return;
15903 
15904 	begin = __builtin_ctzll(offloads);
15905 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15906 
15907 	single_offload = 1ULL << begin;
15908 	for (bit = begin; bit < end; bit++) {
15909 		if (offloads & single_offload)
15910 			printf(" %s",
15911 			       rte_eth_dev_rx_offload_name(single_offload));
15912 		single_offload <<= 1;
15913 	}
15914 }
15915 
15916 static void
15917 cmd_rx_offload_get_capa_parsed(
15918 	void *parsed_result,
15919 	__rte_unused struct cmdline *cl,
15920 	__rte_unused void *data)
15921 {
15922 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
15923 	struct rte_eth_dev_info dev_info;
15924 	portid_t port_id = res->port_id;
15925 	uint64_t queue_offloads;
15926 	uint64_t port_offloads;
15927 	int ret;
15928 
15929 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15930 	if (ret != 0)
15931 		return;
15932 
15933 	queue_offloads = dev_info.rx_queue_offload_capa;
15934 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15935 
15936 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
15937 	printf("  Per Queue :");
15938 	print_rx_offloads(queue_offloads);
15939 
15940 	printf("\n");
15941 	printf("  Per Port  :");
15942 	print_rx_offloads(port_offloads);
15943 	printf("\n\n");
15944 }
15945 
15946 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15947 	.f = cmd_rx_offload_get_capa_parsed,
15948 	.data = NULL,
15949 	.help_str = "show port <port_id> rx_offload capabilities",
15950 	.tokens = {
15951 		(void *)&cmd_rx_offload_get_capa_show,
15952 		(void *)&cmd_rx_offload_get_capa_port,
15953 		(void *)&cmd_rx_offload_get_capa_port_id,
15954 		(void *)&cmd_rx_offload_get_capa_rx_offload,
15955 		(void *)&cmd_rx_offload_get_capa_capabilities,
15956 		NULL,
15957 	}
15958 };
15959 
15960 /* Get Rx offloads configuration */
15961 struct cmd_rx_offload_get_configuration_result {
15962 	cmdline_fixed_string_t show;
15963 	cmdline_fixed_string_t port;
15964 	portid_t port_id;
15965 	cmdline_fixed_string_t rx_offload;
15966 	cmdline_fixed_string_t configuration;
15967 };
15968 
15969 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15970 	TOKEN_STRING_INITIALIZER
15971 		(struct cmd_rx_offload_get_configuration_result,
15972 		 show, "show");
15973 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15974 	TOKEN_STRING_INITIALIZER
15975 		(struct cmd_rx_offload_get_configuration_result,
15976 		 port, "port");
15977 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15978 	TOKEN_NUM_INITIALIZER
15979 		(struct cmd_rx_offload_get_configuration_result,
15980 		 port_id, RTE_UINT16);
15981 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15982 	TOKEN_STRING_INITIALIZER
15983 		(struct cmd_rx_offload_get_configuration_result,
15984 		 rx_offload, "rx_offload");
15985 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15986 	TOKEN_STRING_INITIALIZER
15987 		(struct cmd_rx_offload_get_configuration_result,
15988 		 configuration, "configuration");
15989 
15990 static void
15991 cmd_rx_offload_get_configuration_parsed(
15992 	void *parsed_result,
15993 	__rte_unused struct cmdline *cl,
15994 	__rte_unused void *data)
15995 {
15996 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15997 	struct rte_eth_dev_info dev_info;
15998 	portid_t port_id = res->port_id;
15999 	struct rte_port *port = &ports[port_id];
16000 	uint64_t port_offloads;
16001 	uint64_t queue_offloads;
16002 	uint16_t nb_rx_queues;
16003 	int q;
16004 	int ret;
16005 
16006 	printf("Rx Offloading Configuration of port %d :\n", port_id);
16007 
16008 	port_offloads = port->dev_conf.rxmode.offloads;
16009 	printf("  Port :");
16010 	print_rx_offloads(port_offloads);
16011 	printf("\n");
16012 
16013 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16014 	if (ret != 0)
16015 		return;
16016 
16017 	nb_rx_queues = dev_info.nb_rx_queues;
16018 	for (q = 0; q < nb_rx_queues; q++) {
16019 		queue_offloads = port->rx_conf[q].offloads;
16020 		printf("  Queue[%2d] :", q);
16021 		print_rx_offloads(queue_offloads);
16022 		printf("\n");
16023 	}
16024 	printf("\n");
16025 }
16026 
16027 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16028 	.f = cmd_rx_offload_get_configuration_parsed,
16029 	.data = NULL,
16030 	.help_str = "show port <port_id> rx_offload configuration",
16031 	.tokens = {
16032 		(void *)&cmd_rx_offload_get_configuration_show,
16033 		(void *)&cmd_rx_offload_get_configuration_port,
16034 		(void *)&cmd_rx_offload_get_configuration_port_id,
16035 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
16036 		(void *)&cmd_rx_offload_get_configuration_configuration,
16037 		NULL,
16038 	}
16039 };
16040 
16041 /* Enable/Disable a per port offloading */
16042 struct cmd_config_per_port_rx_offload_result {
16043 	cmdline_fixed_string_t port;
16044 	cmdline_fixed_string_t config;
16045 	portid_t port_id;
16046 	cmdline_fixed_string_t rx_offload;
16047 	cmdline_fixed_string_t offload;
16048 	cmdline_fixed_string_t on_off;
16049 };
16050 
16051 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16052 	TOKEN_STRING_INITIALIZER
16053 		(struct cmd_config_per_port_rx_offload_result,
16054 		 port, "port");
16055 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16056 	TOKEN_STRING_INITIALIZER
16057 		(struct cmd_config_per_port_rx_offload_result,
16058 		 config, "config");
16059 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16060 	TOKEN_NUM_INITIALIZER
16061 		(struct cmd_config_per_port_rx_offload_result,
16062 		 port_id, RTE_UINT16);
16063 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16064 	TOKEN_STRING_INITIALIZER
16065 		(struct cmd_config_per_port_rx_offload_result,
16066 		 rx_offload, "rx_offload");
16067 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16068 	TOKEN_STRING_INITIALIZER
16069 		(struct cmd_config_per_port_rx_offload_result,
16070 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16071 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16072 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16073 			   "scatter#buffer_split#timestamp#security#"
16074 			   "keep_crc#rss_hash");
16075 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16076 	TOKEN_STRING_INITIALIZER
16077 		(struct cmd_config_per_port_rx_offload_result,
16078 		 on_off, "on#off");
16079 
16080 static uint64_t
16081 search_rx_offload(const char *name)
16082 {
16083 	uint64_t single_offload;
16084 	const char *single_name;
16085 	int found = 0;
16086 	unsigned int bit;
16087 
16088 	single_offload = 1;
16089 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16090 		single_name = rte_eth_dev_rx_offload_name(single_offload);
16091 		if (!strcasecmp(single_name, name)) {
16092 			found = 1;
16093 			break;
16094 		}
16095 		single_offload <<= 1;
16096 	}
16097 
16098 	if (found)
16099 		return single_offload;
16100 
16101 	return 0;
16102 }
16103 
16104 static void
16105 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16106 				__rte_unused struct cmdline *cl,
16107 				__rte_unused void *data)
16108 {
16109 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16110 	portid_t port_id = res->port_id;
16111 	struct rte_eth_dev_info dev_info;
16112 	struct rte_port *port = &ports[port_id];
16113 	uint64_t single_offload;
16114 	uint16_t nb_rx_queues;
16115 	int q;
16116 	int ret;
16117 
16118 	if (port->port_status != RTE_PORT_STOPPED) {
16119 		fprintf(stderr,
16120 			"Error: Can't config offload when Port %d is not stopped\n",
16121 			port_id);
16122 		return;
16123 	}
16124 
16125 	single_offload = search_rx_offload(res->offload);
16126 	if (single_offload == 0) {
16127 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16128 		return;
16129 	}
16130 
16131 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16132 	if (ret != 0)
16133 		return;
16134 
16135 	nb_rx_queues = dev_info.nb_rx_queues;
16136 	if (!strcmp(res->on_off, "on")) {
16137 		port->dev_conf.rxmode.offloads |= single_offload;
16138 		for (q = 0; q < nb_rx_queues; q++)
16139 			port->rx_conf[q].offloads |= single_offload;
16140 	} else {
16141 		port->dev_conf.rxmode.offloads &= ~single_offload;
16142 		for (q = 0; q < nb_rx_queues; q++)
16143 			port->rx_conf[q].offloads &= ~single_offload;
16144 	}
16145 
16146 	cmd_reconfig_device_queue(port_id, 1, 1);
16147 }
16148 
16149 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16150 	.f = cmd_config_per_port_rx_offload_parsed,
16151 	.data = NULL,
16152 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16153 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16154 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16155 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16156 		    "keep_crc|rss_hash on|off",
16157 	.tokens = {
16158 		(void *)&cmd_config_per_port_rx_offload_result_port,
16159 		(void *)&cmd_config_per_port_rx_offload_result_config,
16160 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
16161 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16162 		(void *)&cmd_config_per_port_rx_offload_result_offload,
16163 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
16164 		NULL,
16165 	}
16166 };
16167 
16168 /* Enable/Disable a per queue offloading */
16169 struct cmd_config_per_queue_rx_offload_result {
16170 	cmdline_fixed_string_t port;
16171 	portid_t port_id;
16172 	cmdline_fixed_string_t rxq;
16173 	uint16_t queue_id;
16174 	cmdline_fixed_string_t rx_offload;
16175 	cmdline_fixed_string_t offload;
16176 	cmdline_fixed_string_t on_off;
16177 };
16178 
16179 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16180 	TOKEN_STRING_INITIALIZER
16181 		(struct cmd_config_per_queue_rx_offload_result,
16182 		 port, "port");
16183 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16184 	TOKEN_NUM_INITIALIZER
16185 		(struct cmd_config_per_queue_rx_offload_result,
16186 		 port_id, RTE_UINT16);
16187 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16188 	TOKEN_STRING_INITIALIZER
16189 		(struct cmd_config_per_queue_rx_offload_result,
16190 		 rxq, "rxq");
16191 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16192 	TOKEN_NUM_INITIALIZER
16193 		(struct cmd_config_per_queue_rx_offload_result,
16194 		 queue_id, RTE_UINT16);
16195 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16196 	TOKEN_STRING_INITIALIZER
16197 		(struct cmd_config_per_queue_rx_offload_result,
16198 		 rx_offload, "rx_offload");
16199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16200 	TOKEN_STRING_INITIALIZER
16201 		(struct cmd_config_per_queue_rx_offload_result,
16202 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16203 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16204 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16205 			   "scatter#buffer_split#timestamp#security#keep_crc");
16206 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16207 	TOKEN_STRING_INITIALIZER
16208 		(struct cmd_config_per_queue_rx_offload_result,
16209 		 on_off, "on#off");
16210 
16211 static void
16212 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16213 				__rte_unused struct cmdline *cl,
16214 				__rte_unused void *data)
16215 {
16216 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16217 	struct rte_eth_dev_info dev_info;
16218 	portid_t port_id = res->port_id;
16219 	uint16_t queue_id = res->queue_id;
16220 	struct rte_port *port = &ports[port_id];
16221 	uint64_t single_offload;
16222 	int ret;
16223 
16224 	if (port->port_status != RTE_PORT_STOPPED) {
16225 		fprintf(stderr,
16226 			"Error: Can't config offload when Port %d is not stopped\n",
16227 			port_id);
16228 		return;
16229 	}
16230 
16231 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16232 	if (ret != 0)
16233 		return;
16234 
16235 	if (queue_id >= dev_info.nb_rx_queues) {
16236 		fprintf(stderr,
16237 			"Error: input queue_id should be 0 ... %d\n",
16238 			dev_info.nb_rx_queues - 1);
16239 		return;
16240 	}
16241 
16242 	single_offload = search_rx_offload(res->offload);
16243 	if (single_offload == 0) {
16244 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16245 		return;
16246 	}
16247 
16248 	if (!strcmp(res->on_off, "on"))
16249 		port->rx_conf[queue_id].offloads |= single_offload;
16250 	else
16251 		port->rx_conf[queue_id].offloads &= ~single_offload;
16252 
16253 	cmd_reconfig_device_queue(port_id, 1, 1);
16254 }
16255 
16256 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16257 	.f = cmd_config_per_queue_rx_offload_parsed,
16258 	.data = NULL,
16259 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
16260 		    "vlan_strip|ipv4_cksum|"
16261 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16262 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16263 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16264 		    "keep_crc on|off",
16265 	.tokens = {
16266 		(void *)&cmd_config_per_queue_rx_offload_result_port,
16267 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
16268 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
16269 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16270 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16271 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
16272 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
16273 		NULL,
16274 	}
16275 };
16276 
16277 /* Get Tx offloads capabilities */
16278 struct cmd_tx_offload_get_capa_result {
16279 	cmdline_fixed_string_t show;
16280 	cmdline_fixed_string_t port;
16281 	portid_t port_id;
16282 	cmdline_fixed_string_t tx_offload;
16283 	cmdline_fixed_string_t capabilities;
16284 };
16285 
16286 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16287 	TOKEN_STRING_INITIALIZER
16288 		(struct cmd_tx_offload_get_capa_result,
16289 		 show, "show");
16290 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16291 	TOKEN_STRING_INITIALIZER
16292 		(struct cmd_tx_offload_get_capa_result,
16293 		 port, "port");
16294 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16295 	TOKEN_NUM_INITIALIZER
16296 		(struct cmd_tx_offload_get_capa_result,
16297 		 port_id, RTE_UINT16);
16298 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16299 	TOKEN_STRING_INITIALIZER
16300 		(struct cmd_tx_offload_get_capa_result,
16301 		 tx_offload, "tx_offload");
16302 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16303 	TOKEN_STRING_INITIALIZER
16304 		(struct cmd_tx_offload_get_capa_result,
16305 		 capabilities, "capabilities");
16306 
16307 static void
16308 print_tx_offloads(uint64_t offloads)
16309 {
16310 	uint64_t single_offload;
16311 	int begin;
16312 	int end;
16313 	int bit;
16314 
16315 	if (offloads == 0)
16316 		return;
16317 
16318 	begin = __builtin_ctzll(offloads);
16319 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16320 
16321 	single_offload = 1ULL << begin;
16322 	for (bit = begin; bit < end; bit++) {
16323 		if (offloads & single_offload)
16324 			printf(" %s",
16325 			       rte_eth_dev_tx_offload_name(single_offload));
16326 		single_offload <<= 1;
16327 	}
16328 }
16329 
16330 static void
16331 cmd_tx_offload_get_capa_parsed(
16332 	void *parsed_result,
16333 	__rte_unused struct cmdline *cl,
16334 	__rte_unused void *data)
16335 {
16336 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
16337 	struct rte_eth_dev_info dev_info;
16338 	portid_t port_id = res->port_id;
16339 	uint64_t queue_offloads;
16340 	uint64_t port_offloads;
16341 	int ret;
16342 
16343 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16344 	if (ret != 0)
16345 		return;
16346 
16347 	queue_offloads = dev_info.tx_queue_offload_capa;
16348 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16349 
16350 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
16351 	printf("  Per Queue :");
16352 	print_tx_offloads(queue_offloads);
16353 
16354 	printf("\n");
16355 	printf("  Per Port  :");
16356 	print_tx_offloads(port_offloads);
16357 	printf("\n\n");
16358 }
16359 
16360 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16361 	.f = cmd_tx_offload_get_capa_parsed,
16362 	.data = NULL,
16363 	.help_str = "show port <port_id> tx_offload capabilities",
16364 	.tokens = {
16365 		(void *)&cmd_tx_offload_get_capa_show,
16366 		(void *)&cmd_tx_offload_get_capa_port,
16367 		(void *)&cmd_tx_offload_get_capa_port_id,
16368 		(void *)&cmd_tx_offload_get_capa_tx_offload,
16369 		(void *)&cmd_tx_offload_get_capa_capabilities,
16370 		NULL,
16371 	}
16372 };
16373 
16374 /* Get Tx offloads configuration */
16375 struct cmd_tx_offload_get_configuration_result {
16376 	cmdline_fixed_string_t show;
16377 	cmdline_fixed_string_t port;
16378 	portid_t port_id;
16379 	cmdline_fixed_string_t tx_offload;
16380 	cmdline_fixed_string_t configuration;
16381 };
16382 
16383 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16384 	TOKEN_STRING_INITIALIZER
16385 		(struct cmd_tx_offload_get_configuration_result,
16386 		 show, "show");
16387 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16388 	TOKEN_STRING_INITIALIZER
16389 		(struct cmd_tx_offload_get_configuration_result,
16390 		 port, "port");
16391 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16392 	TOKEN_NUM_INITIALIZER
16393 		(struct cmd_tx_offload_get_configuration_result,
16394 		 port_id, RTE_UINT16);
16395 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16396 	TOKEN_STRING_INITIALIZER
16397 		(struct cmd_tx_offload_get_configuration_result,
16398 		 tx_offload, "tx_offload");
16399 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16400 	TOKEN_STRING_INITIALIZER
16401 		(struct cmd_tx_offload_get_configuration_result,
16402 		 configuration, "configuration");
16403 
16404 static void
16405 cmd_tx_offload_get_configuration_parsed(
16406 	void *parsed_result,
16407 	__rte_unused struct cmdline *cl,
16408 	__rte_unused void *data)
16409 {
16410 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16411 	struct rte_eth_dev_info dev_info;
16412 	portid_t port_id = res->port_id;
16413 	struct rte_port *port = &ports[port_id];
16414 	uint64_t port_offloads;
16415 	uint64_t queue_offloads;
16416 	uint16_t nb_tx_queues;
16417 	int q;
16418 	int ret;
16419 
16420 	printf("Tx Offloading Configuration of port %d :\n", port_id);
16421 
16422 	port_offloads = port->dev_conf.txmode.offloads;
16423 	printf("  Port :");
16424 	print_tx_offloads(port_offloads);
16425 	printf("\n");
16426 
16427 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16428 	if (ret != 0)
16429 		return;
16430 
16431 	nb_tx_queues = dev_info.nb_tx_queues;
16432 	for (q = 0; q < nb_tx_queues; q++) {
16433 		queue_offloads = port->tx_conf[q].offloads;
16434 		printf("  Queue[%2d] :", q);
16435 		print_tx_offloads(queue_offloads);
16436 		printf("\n");
16437 	}
16438 	printf("\n");
16439 }
16440 
16441 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16442 	.f = cmd_tx_offload_get_configuration_parsed,
16443 	.data = NULL,
16444 	.help_str = "show port <port_id> tx_offload configuration",
16445 	.tokens = {
16446 		(void *)&cmd_tx_offload_get_configuration_show,
16447 		(void *)&cmd_tx_offload_get_configuration_port,
16448 		(void *)&cmd_tx_offload_get_configuration_port_id,
16449 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
16450 		(void *)&cmd_tx_offload_get_configuration_configuration,
16451 		NULL,
16452 	}
16453 };
16454 
16455 /* Enable/Disable a per port offloading */
16456 struct cmd_config_per_port_tx_offload_result {
16457 	cmdline_fixed_string_t port;
16458 	cmdline_fixed_string_t config;
16459 	portid_t port_id;
16460 	cmdline_fixed_string_t tx_offload;
16461 	cmdline_fixed_string_t offload;
16462 	cmdline_fixed_string_t on_off;
16463 };
16464 
16465 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16466 	TOKEN_STRING_INITIALIZER
16467 		(struct cmd_config_per_port_tx_offload_result,
16468 		 port, "port");
16469 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16470 	TOKEN_STRING_INITIALIZER
16471 		(struct cmd_config_per_port_tx_offload_result,
16472 		 config, "config");
16473 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16474 	TOKEN_NUM_INITIALIZER
16475 		(struct cmd_config_per_port_tx_offload_result,
16476 		 port_id, RTE_UINT16);
16477 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16478 	TOKEN_STRING_INITIALIZER
16479 		(struct cmd_config_per_port_tx_offload_result,
16480 		 tx_offload, "tx_offload");
16481 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16482 	TOKEN_STRING_INITIALIZER
16483 		(struct cmd_config_per_port_tx_offload_result,
16484 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16485 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16486 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16487 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16488 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16489 			  "send_on_timestamp");
16490 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16491 	TOKEN_STRING_INITIALIZER
16492 		(struct cmd_config_per_port_tx_offload_result,
16493 		 on_off, "on#off");
16494 
16495 static uint64_t
16496 search_tx_offload(const char *name)
16497 {
16498 	uint64_t single_offload;
16499 	const char *single_name;
16500 	int found = 0;
16501 	unsigned int bit;
16502 
16503 	single_offload = 1;
16504 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16505 		single_name = rte_eth_dev_tx_offload_name(single_offload);
16506 		if (single_name == NULL)
16507 			break;
16508 		if (!strcasecmp(single_name, name)) {
16509 			found = 1;
16510 			break;
16511 		} else if (!strcasecmp(single_name, "UNKNOWN"))
16512 			break;
16513 		single_offload <<= 1;
16514 	}
16515 
16516 	if (found)
16517 		return single_offload;
16518 
16519 	return 0;
16520 }
16521 
16522 static void
16523 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16524 				__rte_unused struct cmdline *cl,
16525 				__rte_unused void *data)
16526 {
16527 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16528 	portid_t port_id = res->port_id;
16529 	struct rte_eth_dev_info dev_info;
16530 	struct rte_port *port = &ports[port_id];
16531 	uint64_t single_offload;
16532 	uint16_t nb_tx_queues;
16533 	int q;
16534 	int ret;
16535 
16536 	if (port->port_status != RTE_PORT_STOPPED) {
16537 		fprintf(stderr,
16538 			"Error: Can't config offload when Port %d is not stopped\n",
16539 			port_id);
16540 		return;
16541 	}
16542 
16543 	single_offload = search_tx_offload(res->offload);
16544 	if (single_offload == 0) {
16545 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16546 		return;
16547 	}
16548 
16549 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16550 	if (ret != 0)
16551 		return;
16552 
16553 	nb_tx_queues = dev_info.nb_tx_queues;
16554 	if (!strcmp(res->on_off, "on")) {
16555 		port->dev_conf.txmode.offloads |= single_offload;
16556 		for (q = 0; q < nb_tx_queues; q++)
16557 			port->tx_conf[q].offloads |= single_offload;
16558 	} else {
16559 		port->dev_conf.txmode.offloads &= ~single_offload;
16560 		for (q = 0; q < nb_tx_queues; q++)
16561 			port->tx_conf[q].offloads &= ~single_offload;
16562 	}
16563 
16564 	cmd_reconfig_device_queue(port_id, 1, 1);
16565 }
16566 
16567 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16568 	.f = cmd_config_per_port_tx_offload_parsed,
16569 	.data = NULL,
16570 	.help_str = "port config <port_id> tx_offload "
16571 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16572 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16573 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16574 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16575 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16576 		    "send_on_timestamp on|off",
16577 	.tokens = {
16578 		(void *)&cmd_config_per_port_tx_offload_result_port,
16579 		(void *)&cmd_config_per_port_tx_offload_result_config,
16580 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
16581 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16582 		(void *)&cmd_config_per_port_tx_offload_result_offload,
16583 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
16584 		NULL,
16585 	}
16586 };
16587 
16588 /* Enable/Disable a per queue offloading */
16589 struct cmd_config_per_queue_tx_offload_result {
16590 	cmdline_fixed_string_t port;
16591 	portid_t port_id;
16592 	cmdline_fixed_string_t txq;
16593 	uint16_t queue_id;
16594 	cmdline_fixed_string_t tx_offload;
16595 	cmdline_fixed_string_t offload;
16596 	cmdline_fixed_string_t on_off;
16597 };
16598 
16599 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16600 	TOKEN_STRING_INITIALIZER
16601 		(struct cmd_config_per_queue_tx_offload_result,
16602 		 port, "port");
16603 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16604 	TOKEN_NUM_INITIALIZER
16605 		(struct cmd_config_per_queue_tx_offload_result,
16606 		 port_id, RTE_UINT16);
16607 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16608 	TOKEN_STRING_INITIALIZER
16609 		(struct cmd_config_per_queue_tx_offload_result,
16610 		 txq, "txq");
16611 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16612 	TOKEN_NUM_INITIALIZER
16613 		(struct cmd_config_per_queue_tx_offload_result,
16614 		 queue_id, RTE_UINT16);
16615 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16616 	TOKEN_STRING_INITIALIZER
16617 		(struct cmd_config_per_queue_tx_offload_result,
16618 		 tx_offload, "tx_offload");
16619 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16620 	TOKEN_STRING_INITIALIZER
16621 		(struct cmd_config_per_queue_tx_offload_result,
16622 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16623 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16624 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16625 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16626 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
16627 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16628 	TOKEN_STRING_INITIALIZER
16629 		(struct cmd_config_per_queue_tx_offload_result,
16630 		 on_off, "on#off");
16631 
16632 static void
16633 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16634 				__rte_unused struct cmdline *cl,
16635 				__rte_unused void *data)
16636 {
16637 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16638 	struct rte_eth_dev_info dev_info;
16639 	portid_t port_id = res->port_id;
16640 	uint16_t queue_id = res->queue_id;
16641 	struct rte_port *port = &ports[port_id];
16642 	uint64_t single_offload;
16643 	int ret;
16644 
16645 	if (port->port_status != RTE_PORT_STOPPED) {
16646 		fprintf(stderr,
16647 			"Error: Can't config offload when Port %d is not stopped\n",
16648 			port_id);
16649 		return;
16650 	}
16651 
16652 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16653 	if (ret != 0)
16654 		return;
16655 
16656 	if (queue_id >= dev_info.nb_tx_queues) {
16657 		fprintf(stderr,
16658 			"Error: input queue_id should be 0 ... %d\n",
16659 			dev_info.nb_tx_queues - 1);
16660 		return;
16661 	}
16662 
16663 	single_offload = search_tx_offload(res->offload);
16664 	if (single_offload == 0) {
16665 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16666 		return;
16667 	}
16668 
16669 	if (!strcmp(res->on_off, "on"))
16670 		port->tx_conf[queue_id].offloads |= single_offload;
16671 	else
16672 		port->tx_conf[queue_id].offloads &= ~single_offload;
16673 
16674 	cmd_reconfig_device_queue(port_id, 1, 1);
16675 }
16676 
16677 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16678 	.f = cmd_config_per_queue_tx_offload_parsed,
16679 	.data = NULL,
16680 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16681 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16682 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16683 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16684 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16685 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16686 		    "on|off",
16687 	.tokens = {
16688 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16689 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16690 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16691 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16692 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16693 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16694 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16695 		NULL,
16696 	}
16697 };
16698 
16699 /* *** configure tx_metadata for specific port *** */
16700 struct cmd_config_tx_metadata_specific_result {
16701 	cmdline_fixed_string_t port;
16702 	cmdline_fixed_string_t keyword;
16703 	uint16_t port_id;
16704 	cmdline_fixed_string_t item;
16705 	uint32_t value;
16706 };
16707 
16708 static void
16709 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16710 				__rte_unused struct cmdline *cl,
16711 				__rte_unused void *data)
16712 {
16713 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16714 
16715 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16716 		return;
16717 	ports[res->port_id].tx_metadata = res->value;
16718 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16719 	if (ports[res->port_id].tx_metadata)
16720 		add_tx_md_callback(res->port_id);
16721 	else
16722 		remove_tx_md_callback(res->port_id);
16723 	rte_flow_dynf_metadata_register();
16724 }
16725 
16726 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16727 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16728 			port, "port");
16729 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16730 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16731 			keyword, "config");
16732 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16733 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16734 			port_id, RTE_UINT16);
16735 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16736 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16737 			item, "tx_metadata");
16738 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16739 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16740 			value, RTE_UINT32);
16741 
16742 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16743 	.f = cmd_config_tx_metadata_specific_parsed,
16744 	.data = NULL,
16745 	.help_str = "port config <port_id> tx_metadata <value>",
16746 	.tokens = {
16747 		(void *)&cmd_config_tx_metadata_specific_port,
16748 		(void *)&cmd_config_tx_metadata_specific_keyword,
16749 		(void *)&cmd_config_tx_metadata_specific_id,
16750 		(void *)&cmd_config_tx_metadata_specific_item,
16751 		(void *)&cmd_config_tx_metadata_specific_value,
16752 		NULL,
16753 	},
16754 };
16755 
16756 /* *** set dynf *** */
16757 struct cmd_config_tx_dynf_specific_result {
16758 	cmdline_fixed_string_t port;
16759 	cmdline_fixed_string_t keyword;
16760 	uint16_t port_id;
16761 	cmdline_fixed_string_t item;
16762 	cmdline_fixed_string_t name;
16763 	cmdline_fixed_string_t value;
16764 };
16765 
16766 static void
16767 cmd_config_dynf_specific_parsed(void *parsed_result,
16768 				__rte_unused struct cmdline *cl,
16769 				__rte_unused void *data)
16770 {
16771 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16772 	struct rte_mbuf_dynflag desc_flag;
16773 	int flag;
16774 	uint64_t old_port_flags;
16775 
16776 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16777 		return;
16778 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16779 	if (flag <= 0) {
16780 		if (strlcpy(desc_flag.name, res->name,
16781 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16782 			fprintf(stderr, "Flag name too long\n");
16783 			return;
16784 		}
16785 		desc_flag.flags = 0;
16786 		flag = rte_mbuf_dynflag_register(&desc_flag);
16787 		if (flag < 0) {
16788 			fprintf(stderr, "Can't register flag\n");
16789 			return;
16790 		}
16791 		strcpy(dynf_names[flag], desc_flag.name);
16792 	}
16793 	old_port_flags = ports[res->port_id].mbuf_dynf;
16794 	if (!strcmp(res->value, "set")) {
16795 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16796 		if (old_port_flags == 0)
16797 			add_tx_dynf_callback(res->port_id);
16798 	} else {
16799 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16800 		if (ports[res->port_id].mbuf_dynf == 0)
16801 			remove_tx_dynf_callback(res->port_id);
16802 	}
16803 }
16804 
16805 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16806 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16807 			keyword, "port");
16808 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16809 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16810 			keyword, "config");
16811 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16812 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16813 			port_id, RTE_UINT16);
16814 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16815 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16816 			item, "dynf");
16817 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16818 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16819 			name, NULL);
16820 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16821 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16822 			value, "set#clear");
16823 
16824 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16825 	.f = cmd_config_dynf_specific_parsed,
16826 	.data = NULL,
16827 	.help_str = "port config <port id> dynf <name> set|clear",
16828 	.tokens = {
16829 		(void *)&cmd_config_tx_dynf_specific_port,
16830 		(void *)&cmd_config_tx_dynf_specific_keyword,
16831 		(void *)&cmd_config_tx_dynf_specific_port_id,
16832 		(void *)&cmd_config_tx_dynf_specific_item,
16833 		(void *)&cmd_config_tx_dynf_specific_name,
16834 		(void *)&cmd_config_tx_dynf_specific_value,
16835 		NULL,
16836 	},
16837 };
16838 
16839 /* *** display tx_metadata per port configuration *** */
16840 struct cmd_show_tx_metadata_result {
16841 	cmdline_fixed_string_t cmd_show;
16842 	cmdline_fixed_string_t cmd_port;
16843 	cmdline_fixed_string_t cmd_keyword;
16844 	portid_t cmd_pid;
16845 };
16846 
16847 static void
16848 cmd_show_tx_metadata_parsed(void *parsed_result,
16849 		__rte_unused struct cmdline *cl,
16850 		__rte_unused void *data)
16851 {
16852 	struct cmd_show_tx_metadata_result *res = parsed_result;
16853 
16854 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16855 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16856 		return;
16857 	}
16858 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16859 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16860 		       ports[res->cmd_pid].tx_metadata);
16861 	}
16862 }
16863 
16864 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16865 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16866 			cmd_show, "show");
16867 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16868 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16869 			cmd_port, "port");
16870 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16871 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16872 			cmd_pid, RTE_UINT16);
16873 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16874 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16875 			cmd_keyword, "tx_metadata");
16876 
16877 cmdline_parse_inst_t cmd_show_tx_metadata = {
16878 	.f = cmd_show_tx_metadata_parsed,
16879 	.data = NULL,
16880 	.help_str = "show port <port_id> tx_metadata",
16881 	.tokens = {
16882 		(void *)&cmd_show_tx_metadata_show,
16883 		(void *)&cmd_show_tx_metadata_port,
16884 		(void *)&cmd_show_tx_metadata_pid,
16885 		(void *)&cmd_show_tx_metadata_keyword,
16886 		NULL,
16887 	},
16888 };
16889 
16890 /* *** show fec capability per port configuration *** */
16891 struct cmd_show_fec_capability_result {
16892 	cmdline_fixed_string_t cmd_show;
16893 	cmdline_fixed_string_t cmd_port;
16894 	cmdline_fixed_string_t cmd_fec;
16895 	cmdline_fixed_string_t cmd_keyword;
16896 	portid_t cmd_pid;
16897 };
16898 
16899 static void
16900 cmd_show_fec_capability_parsed(void *parsed_result,
16901 		__rte_unused struct cmdline *cl,
16902 		__rte_unused void *data)
16903 {
16904 	struct cmd_show_fec_capability_result *res = parsed_result;
16905 	struct rte_eth_fec_capa *speed_fec_capa;
16906 	unsigned int num;
16907 	int ret;
16908 
16909 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16910 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16911 		return;
16912 	}
16913 
16914 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16915 	if (ret == -ENOTSUP) {
16916 		fprintf(stderr, "Function not implemented\n");
16917 		return;
16918 	} else if (ret < 0) {
16919 		fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16920 		return;
16921 	}
16922 
16923 	num = (unsigned int)ret;
16924 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16925 	if (speed_fec_capa == NULL) {
16926 		fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16927 		return;
16928 	}
16929 
16930 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16931 	if (ret < 0) {
16932 		fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16933 		goto out;
16934 	}
16935 
16936 	show_fec_capability(num, speed_fec_capa);
16937 out:
16938 	free(speed_fec_capa);
16939 }
16940 
16941 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16942 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16943 			cmd_show, "show");
16944 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16945 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16946 			cmd_port, "port");
16947 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16948 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16949 			cmd_pid, RTE_UINT16);
16950 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16951 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16952 			cmd_fec, "fec");
16953 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16954 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16955 			cmd_keyword, "capabilities");
16956 
16957 cmdline_parse_inst_t cmd_show_capability = {
16958 	.f = cmd_show_fec_capability_parsed,
16959 	.data = NULL,
16960 	.help_str = "show port <port_id> fec capabilities",
16961 	.tokens = {
16962 		(void *)&cmd_show_fec_capability_show,
16963 		(void *)&cmd_show_fec_capability_port,
16964 		(void *)&cmd_show_fec_capability_pid,
16965 		(void *)&cmd_show_fec_capability_fec,
16966 		(void *)&cmd_show_fec_capability_keyword,
16967 		NULL,
16968 	},
16969 };
16970 
16971 /* *** show fec mode per port configuration *** */
16972 struct cmd_show_fec_metadata_result {
16973 	cmdline_fixed_string_t cmd_show;
16974 	cmdline_fixed_string_t cmd_port;
16975 	cmdline_fixed_string_t cmd_keyword;
16976 	portid_t cmd_pid;
16977 };
16978 
16979 static void
16980 cmd_show_fec_mode_parsed(void *parsed_result,
16981 		__rte_unused struct cmdline *cl,
16982 		__rte_unused void *data)
16983 {
16984 #define FEC_NAME_SIZE 16
16985 	struct cmd_show_fec_metadata_result *res = parsed_result;
16986 	uint32_t mode;
16987 	char buf[FEC_NAME_SIZE];
16988 	int ret;
16989 
16990 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16991 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16992 		return;
16993 	}
16994 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
16995 	if (ret == -ENOTSUP) {
16996 		fprintf(stderr, "Function not implemented\n");
16997 		return;
16998 	} else if (ret < 0) {
16999 		fprintf(stderr, "Get FEC mode failed\n");
17000 		return;
17001 	}
17002 
17003 	switch (mode) {
17004 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17005 		strlcpy(buf, "off", sizeof(buf));
17006 		break;
17007 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17008 		strlcpy(buf, "auto", sizeof(buf));
17009 		break;
17010 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17011 		strlcpy(buf, "baser", sizeof(buf));
17012 		break;
17013 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17014 		strlcpy(buf, "rs", sizeof(buf));
17015 		break;
17016 	default:
17017 		return;
17018 	}
17019 
17020 	printf("%s\n", buf);
17021 }
17022 
17023 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17024 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17025 			cmd_show, "show");
17026 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17027 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17028 			cmd_port, "port");
17029 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17030 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17031 			cmd_pid, RTE_UINT16);
17032 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17033 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17034 			cmd_keyword, "fec_mode");
17035 
17036 cmdline_parse_inst_t cmd_show_fec_mode = {
17037 	.f = cmd_show_fec_mode_parsed,
17038 	.data = NULL,
17039 	.help_str = "show port <port_id> fec_mode",
17040 	.tokens = {
17041 		(void *)&cmd_show_fec_mode_show,
17042 		(void *)&cmd_show_fec_mode_port,
17043 		(void *)&cmd_show_fec_mode_pid,
17044 		(void *)&cmd_show_fec_mode_keyword,
17045 		NULL,
17046 	},
17047 };
17048 
17049 /* *** set fec mode per port configuration *** */
17050 struct cmd_set_port_fec_mode {
17051 	cmdline_fixed_string_t set;
17052 	cmdline_fixed_string_t port;
17053 	portid_t port_id;
17054 	cmdline_fixed_string_t fec_mode;
17055 	cmdline_fixed_string_t fec_value;
17056 };
17057 
17058 /* Common CLI fields for set fec mode */
17059 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17060 	TOKEN_STRING_INITIALIZER
17061 		(struct cmd_set_port_fec_mode,
17062 		 set, "set");
17063 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17064 	TOKEN_STRING_INITIALIZER
17065 		(struct cmd_set_port_fec_mode,
17066 		 port, "port");
17067 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17068 	TOKEN_NUM_INITIALIZER
17069 		(struct cmd_set_port_fec_mode,
17070 		 port_id, RTE_UINT16);
17071 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17072 	TOKEN_STRING_INITIALIZER
17073 		(struct cmd_set_port_fec_mode,
17074 		 fec_mode, "fec_mode");
17075 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17076 	TOKEN_STRING_INITIALIZER
17077 		(struct cmd_set_port_fec_mode,
17078 		 fec_value, NULL);
17079 
17080 static void
17081 cmd_set_port_fec_mode_parsed(
17082 	void *parsed_result,
17083 	__rte_unused struct cmdline *cl,
17084 	__rte_unused void *data)
17085 {
17086 	struct cmd_set_port_fec_mode *res = parsed_result;
17087 	uint16_t port_id = res->port_id;
17088 	uint32_t fec_capa;
17089 	int ret;
17090 
17091 	ret = parse_fec_mode(res->fec_value, &fec_capa);
17092 	if (ret < 0) {
17093 		fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17094 				res->fec_value,	port_id);
17095 		return;
17096 	}
17097 
17098 	ret = rte_eth_fec_set(port_id, fec_capa);
17099 	if (ret == -ENOTSUP) {
17100 		fprintf(stderr, "Function not implemented\n");
17101 		return;
17102 	} else if (ret < 0) {
17103 		fprintf(stderr, "Set FEC mode failed\n");
17104 		return;
17105 	}
17106 }
17107 
17108 cmdline_parse_inst_t cmd_set_fec_mode = {
17109 	.f = cmd_set_port_fec_mode_parsed,
17110 	.data = NULL,
17111 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17112 	.tokens = {
17113 		(void *)&cmd_set_port_fec_mode_set,
17114 		(void *)&cmd_set_port_fec_mode_port,
17115 		(void *)&cmd_set_port_fec_mode_port_id,
17116 		(void *)&cmd_set_port_fec_mode_str,
17117 		(void *)&cmd_set_port_fec_mode_value,
17118 		NULL,
17119 	},
17120 };
17121 
17122 /* show port supported ptypes */
17123 
17124 /* Common result structure for show port ptypes */
17125 struct cmd_show_port_supported_ptypes_result {
17126 	cmdline_fixed_string_t show;
17127 	cmdline_fixed_string_t port;
17128 	portid_t port_id;
17129 	cmdline_fixed_string_t ptypes;
17130 };
17131 
17132 /* Common CLI fields for show port ptypes */
17133 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17134 	TOKEN_STRING_INITIALIZER
17135 		(struct cmd_show_port_supported_ptypes_result,
17136 		 show, "show");
17137 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17138 	TOKEN_STRING_INITIALIZER
17139 		(struct cmd_show_port_supported_ptypes_result,
17140 		 port, "port");
17141 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17142 	TOKEN_NUM_INITIALIZER
17143 		(struct cmd_show_port_supported_ptypes_result,
17144 		 port_id, RTE_UINT16);
17145 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17146 	TOKEN_STRING_INITIALIZER
17147 		(struct cmd_show_port_supported_ptypes_result,
17148 		 ptypes, "ptypes");
17149 
17150 static void
17151 cmd_show_port_supported_ptypes_parsed(
17152 	void *parsed_result,
17153 	__rte_unused struct cmdline *cl,
17154 	__rte_unused void *data)
17155 {
17156 #define RSVD_PTYPE_MASK       0xf0000000
17157 #define MAX_PTYPES_PER_LAYER  16
17158 #define LTYPE_NAMESIZE        32
17159 #define PTYPE_NAMESIZE        256
17160 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17161 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17162 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17163 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17164 	uint16_t port_id = res->port_id;
17165 	int ret, i;
17166 
17167 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17168 	if (ret < 0)
17169 		return;
17170 
17171 	while (ptype_mask != RSVD_PTYPE_MASK) {
17172 
17173 		switch (ptype_mask) {
17174 		case RTE_PTYPE_L2_MASK:
17175 			strlcpy(ltype, "L2", sizeof(ltype));
17176 			break;
17177 		case RTE_PTYPE_L3_MASK:
17178 			strlcpy(ltype, "L3", sizeof(ltype));
17179 			break;
17180 		case RTE_PTYPE_L4_MASK:
17181 			strlcpy(ltype, "L4", sizeof(ltype));
17182 			break;
17183 		case RTE_PTYPE_TUNNEL_MASK:
17184 			strlcpy(ltype, "Tunnel", sizeof(ltype));
17185 			break;
17186 		case RTE_PTYPE_INNER_L2_MASK:
17187 			strlcpy(ltype, "Inner L2", sizeof(ltype));
17188 			break;
17189 		case RTE_PTYPE_INNER_L3_MASK:
17190 			strlcpy(ltype, "Inner L3", sizeof(ltype));
17191 			break;
17192 		case RTE_PTYPE_INNER_L4_MASK:
17193 			strlcpy(ltype, "Inner L4", sizeof(ltype));
17194 			break;
17195 		default:
17196 			return;
17197 		}
17198 
17199 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17200 						       ptype_mask, ptypes,
17201 						       MAX_PTYPES_PER_LAYER);
17202 
17203 		if (ret > 0)
17204 			printf("Supported %s ptypes:\n", ltype);
17205 		else
17206 			printf("%s ptypes unsupported\n", ltype);
17207 
17208 		for (i = 0; i < ret; ++i) {
17209 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17210 			printf("%s\n", buf);
17211 		}
17212 
17213 		ptype_mask <<= 4;
17214 	}
17215 }
17216 
17217 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17218 	.f = cmd_show_port_supported_ptypes_parsed,
17219 	.data = NULL,
17220 	.help_str = "show port <port_id> ptypes",
17221 	.tokens = {
17222 		(void *)&cmd_show_port_supported_ptypes_show,
17223 		(void *)&cmd_show_port_supported_ptypes_port,
17224 		(void *)&cmd_show_port_supported_ptypes_port_id,
17225 		(void *)&cmd_show_port_supported_ptypes_ptypes,
17226 		NULL,
17227 	},
17228 };
17229 
17230 /* *** display rx/tx descriptor status *** */
17231 struct cmd_show_rx_tx_desc_status_result {
17232 	cmdline_fixed_string_t cmd_show;
17233 	cmdline_fixed_string_t cmd_port;
17234 	cmdline_fixed_string_t cmd_keyword;
17235 	cmdline_fixed_string_t cmd_desc;
17236 	cmdline_fixed_string_t cmd_status;
17237 	portid_t cmd_pid;
17238 	portid_t cmd_qid;
17239 	portid_t cmd_did;
17240 };
17241 
17242 static void
17243 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17244 		__rte_unused struct cmdline *cl,
17245 		__rte_unused void *data)
17246 {
17247 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17248 	int rc;
17249 
17250 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17251 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17252 		return;
17253 	}
17254 
17255 	if (!strcmp(res->cmd_keyword, "rxq")) {
17256 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17257 					     res->cmd_did);
17258 		if (rc < 0) {
17259 			fprintf(stderr,
17260 				"Invalid input: queue id = %d, desc id = %d\n",
17261 				res->cmd_qid, res->cmd_did);
17262 			return;
17263 		}
17264 		if (rc == RTE_ETH_RX_DESC_AVAIL)
17265 			printf("Desc status = AVAILABLE\n");
17266 		else if (rc == RTE_ETH_RX_DESC_DONE)
17267 			printf("Desc status = DONE\n");
17268 		else
17269 			printf("Desc status = UNAVAILABLE\n");
17270 	} else if (!strcmp(res->cmd_keyword, "txq")) {
17271 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17272 					     res->cmd_did);
17273 		if (rc < 0) {
17274 			fprintf(stderr,
17275 				"Invalid input: queue id = %d, desc id = %d\n",
17276 				res->cmd_qid, res->cmd_did);
17277 			return;
17278 		}
17279 		if (rc == RTE_ETH_TX_DESC_FULL)
17280 			printf("Desc status = FULL\n");
17281 		else if (rc == RTE_ETH_TX_DESC_DONE)
17282 			printf("Desc status = DONE\n");
17283 		else
17284 			printf("Desc status = UNAVAILABLE\n");
17285 	}
17286 }
17287 
17288 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17289 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17290 			cmd_show, "show");
17291 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17292 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17293 			cmd_port, "port");
17294 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17295 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17296 			cmd_pid, RTE_UINT16);
17297 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17298 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17299 			cmd_keyword, "rxq#txq");
17300 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17301 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17302 			cmd_qid, RTE_UINT16);
17303 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17304 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17305 			cmd_desc, "desc");
17306 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17307 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17308 			cmd_did, RTE_UINT16);
17309 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17310 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17311 			cmd_status, "status");
17312 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17313 	.f = cmd_show_rx_tx_desc_status_parsed,
17314 	.data = NULL,
17315 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17316 		"status",
17317 	.tokens = {
17318 		(void *)&cmd_show_rx_tx_desc_status_show,
17319 		(void *)&cmd_show_rx_tx_desc_status_port,
17320 		(void *)&cmd_show_rx_tx_desc_status_pid,
17321 		(void *)&cmd_show_rx_tx_desc_status_keyword,
17322 		(void *)&cmd_show_rx_tx_desc_status_qid,
17323 		(void *)&cmd_show_rx_tx_desc_status_desc,
17324 		(void *)&cmd_show_rx_tx_desc_status_did,
17325 		(void *)&cmd_show_rx_tx_desc_status_status,
17326 		NULL,
17327 	},
17328 };
17329 
17330 /* *** display rx queue desc used count *** */
17331 struct cmd_show_rx_queue_desc_used_count_result {
17332 	cmdline_fixed_string_t cmd_show;
17333 	cmdline_fixed_string_t cmd_port;
17334 	cmdline_fixed_string_t cmd_rxq;
17335 	cmdline_fixed_string_t cmd_desc;
17336 	cmdline_fixed_string_t cmd_used;
17337 	cmdline_fixed_string_t cmd_count;
17338 	portid_t cmd_pid;
17339 	portid_t cmd_qid;
17340 };
17341 
17342 static void
17343 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17344 		__rte_unused struct cmdline *cl,
17345 		__rte_unused void *data)
17346 {
17347 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17348 	int rc;
17349 
17350 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17351 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17352 		return;
17353 	}
17354 
17355 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17356 	if (rc < 0) {
17357 		fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17358 		return;
17359 	}
17360 	printf("Used desc count = %d\n", rc);
17361 }
17362 
17363 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17364 	TOKEN_STRING_INITIALIZER
17365 		(struct cmd_show_rx_queue_desc_used_count_result,
17366 		 cmd_show, "show");
17367 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17368 	TOKEN_STRING_INITIALIZER
17369 		(struct cmd_show_rx_queue_desc_used_count_result,
17370 		 cmd_port, "port");
17371 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17372 	TOKEN_NUM_INITIALIZER
17373 		(struct cmd_show_rx_queue_desc_used_count_result,
17374 		 cmd_pid, RTE_UINT16);
17375 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17376 	TOKEN_STRING_INITIALIZER
17377 		(struct cmd_show_rx_queue_desc_used_count_result,
17378 		 cmd_rxq, "rxq");
17379 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17380 	TOKEN_NUM_INITIALIZER
17381 		(struct cmd_show_rx_queue_desc_used_count_result,
17382 		 cmd_qid, RTE_UINT16);
17383 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17384 	TOKEN_STRING_INITIALIZER
17385 		(struct cmd_show_rx_queue_desc_used_count_result,
17386 		 cmd_count, "desc");
17387 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17388 	TOKEN_STRING_INITIALIZER
17389 		(struct cmd_show_rx_queue_desc_used_count_result,
17390 		 cmd_count, "used");
17391 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17392 	TOKEN_STRING_INITIALIZER
17393 		(struct cmd_show_rx_queue_desc_used_count_result,
17394 		 cmd_count, "count");
17395 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17396 	.f = cmd_show_rx_queue_desc_used_count_parsed,
17397 	.data = NULL,
17398 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
17399 	.tokens = {
17400 		(void *)&cmd_show_rx_queue_desc_used_count_show,
17401 		(void *)&cmd_show_rx_queue_desc_used_count_port,
17402 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
17403 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
17404 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
17405 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
17406 		(void *)&cmd_show_rx_queue_desc_used_count_used,
17407 		(void *)&cmd_show_rx_queue_desc_used_count_count,
17408 		NULL,
17409 	},
17410 };
17411 
17412 /* Common result structure for set port ptypes */
17413 struct cmd_set_port_ptypes_result {
17414 	cmdline_fixed_string_t set;
17415 	cmdline_fixed_string_t port;
17416 	portid_t port_id;
17417 	cmdline_fixed_string_t ptype_mask;
17418 	uint32_t mask;
17419 };
17420 
17421 /* Common CLI fields for set port ptypes */
17422 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17423 	TOKEN_STRING_INITIALIZER
17424 		(struct cmd_set_port_ptypes_result,
17425 		 set, "set");
17426 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17427 	TOKEN_STRING_INITIALIZER
17428 		(struct cmd_set_port_ptypes_result,
17429 		 port, "port");
17430 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17431 	TOKEN_NUM_INITIALIZER
17432 		(struct cmd_set_port_ptypes_result,
17433 		 port_id, RTE_UINT16);
17434 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17435 	TOKEN_STRING_INITIALIZER
17436 		(struct cmd_set_port_ptypes_result,
17437 		 ptype_mask, "ptype_mask");
17438 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17439 	TOKEN_NUM_INITIALIZER
17440 		(struct cmd_set_port_ptypes_result,
17441 		 mask, RTE_UINT32);
17442 
17443 static void
17444 cmd_set_port_ptypes_parsed(
17445 	void *parsed_result,
17446 	__rte_unused struct cmdline *cl,
17447 	__rte_unused void *data)
17448 {
17449 	struct cmd_set_port_ptypes_result *res = parsed_result;
17450 #define PTYPE_NAMESIZE        256
17451 	char ptype_name[PTYPE_NAMESIZE];
17452 	uint16_t port_id = res->port_id;
17453 	uint32_t ptype_mask = res->mask;
17454 	int ret, i;
17455 
17456 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17457 					       NULL, 0);
17458 	if (ret <= 0) {
17459 		fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17460 			port_id);
17461 		return;
17462 	}
17463 
17464 	uint32_t ptypes[ret];
17465 
17466 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17467 	if (ret < 0) {
17468 		fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17469 			port_id);
17470 		return;
17471 	}
17472 
17473 	printf("Successfully set following ptypes for Port %d\n", port_id);
17474 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17475 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17476 		printf("%s\n", ptype_name);
17477 	}
17478 
17479 	clear_ptypes = false;
17480 }
17481 
17482 cmdline_parse_inst_t cmd_set_port_ptypes = {
17483 	.f = cmd_set_port_ptypes_parsed,
17484 	.data = NULL,
17485 	.help_str = "set port <port_id> ptype_mask <mask>",
17486 	.tokens = {
17487 		(void *)&cmd_set_port_ptypes_set,
17488 		(void *)&cmd_set_port_ptypes_port,
17489 		(void *)&cmd_set_port_ptypes_port_id,
17490 		(void *)&cmd_set_port_ptypes_mask_str,
17491 		(void *)&cmd_set_port_ptypes_mask_u32,
17492 		NULL,
17493 	},
17494 };
17495 
17496 /* *** display mac addresses added to a port *** */
17497 struct cmd_showport_macs_result {
17498 	cmdline_fixed_string_t cmd_show;
17499 	cmdline_fixed_string_t cmd_port;
17500 	cmdline_fixed_string_t cmd_keyword;
17501 	portid_t cmd_pid;
17502 };
17503 
17504 static void
17505 cmd_showport_macs_parsed(void *parsed_result,
17506 		__rte_unused struct cmdline *cl,
17507 		__rte_unused void *data)
17508 {
17509 	struct cmd_showport_macs_result *res = parsed_result;
17510 
17511 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17512 		return;
17513 
17514 	if (!strcmp(res->cmd_keyword, "macs"))
17515 		show_macs(res->cmd_pid);
17516 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17517 		show_mcast_macs(res->cmd_pid);
17518 }
17519 
17520 cmdline_parse_token_string_t cmd_showport_macs_show =
17521 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17522 			cmd_show, "show");
17523 cmdline_parse_token_string_t cmd_showport_macs_port =
17524 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17525 			cmd_port, "port");
17526 cmdline_parse_token_num_t cmd_showport_macs_pid =
17527 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17528 			cmd_pid, RTE_UINT16);
17529 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17530 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17531 			cmd_keyword, "macs#mcast_macs");
17532 
17533 cmdline_parse_inst_t cmd_showport_macs = {
17534 	.f = cmd_showport_macs_parsed,
17535 	.data = NULL,
17536 	.help_str = "show port <port_id> macs|mcast_macs",
17537 	.tokens = {
17538 		(void *)&cmd_showport_macs_show,
17539 		(void *)&cmd_showport_macs_port,
17540 		(void *)&cmd_showport_macs_pid,
17541 		(void *)&cmd_showport_macs_keyword,
17542 		NULL,
17543 	},
17544 };
17545 
17546 /* ******************************************************************************** */
17547 
17548 /* list of instructions */
17549 cmdline_parse_ctx_t main_ctx[] = {
17550 	(cmdline_parse_inst_t *)&cmd_help_brief,
17551 	(cmdline_parse_inst_t *)&cmd_help_long,
17552 	(cmdline_parse_inst_t *)&cmd_quit,
17553 	(cmdline_parse_inst_t *)&cmd_load_from_file,
17554 	(cmdline_parse_inst_t *)&cmd_showport,
17555 	(cmdline_parse_inst_t *)&cmd_showqueue,
17556 	(cmdline_parse_inst_t *)&cmd_showeeprom,
17557 	(cmdline_parse_inst_t *)&cmd_showportall,
17558 	(cmdline_parse_inst_t *)&cmd_showdevice,
17559 	(cmdline_parse_inst_t *)&cmd_showcfg,
17560 	(cmdline_parse_inst_t *)&cmd_showfwdall,
17561 	(cmdline_parse_inst_t *)&cmd_start,
17562 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
17563 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17564 	(cmdline_parse_inst_t *)&cmd_set_link_up,
17565 	(cmdline_parse_inst_t *)&cmd_set_link_down,
17566 	(cmdline_parse_inst_t *)&cmd_reset,
17567 	(cmdline_parse_inst_t *)&cmd_set_numbers,
17568 	(cmdline_parse_inst_t *)&cmd_set_log,
17569 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
17570 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
17571 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
17572 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
17573 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
17574 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
17575 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17576 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17577 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17578 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17579 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17580 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17581 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17582 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17583 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
17584 	(cmdline_parse_inst_t *)&cmd_set_link_check,
17585 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17586 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
17587 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17588 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
17589 #ifdef RTE_NET_BOND
17590 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17591 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
17592 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17593 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17594 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17595 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
17596 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17597 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17598 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17599 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17600 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17601 #endif
17602 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
17603 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
17604 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17605 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17606 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17607 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17608 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17609 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17610 	(cmdline_parse_inst_t *)&cmd_csum_set,
17611 	(cmdline_parse_inst_t *)&cmd_csum_show,
17612 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
17613 	(cmdline_parse_inst_t *)&cmd_tso_set,
17614 	(cmdline_parse_inst_t *)&cmd_tso_show,
17615 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17616 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17617 	(cmdline_parse_inst_t *)&cmd_gro_enable,
17618 	(cmdline_parse_inst_t *)&cmd_gro_flush,
17619 	(cmdline_parse_inst_t *)&cmd_gro_show,
17620 	(cmdline_parse_inst_t *)&cmd_gso_enable,
17621 	(cmdline_parse_inst_t *)&cmd_gso_size,
17622 	(cmdline_parse_inst_t *)&cmd_gso_show,
17623 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17624 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17625 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17626 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17627 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17628 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17629 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17630 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17631 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17632 	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17633 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17634 	(cmdline_parse_inst_t *)&cmd_config_dcb,
17635 	(cmdline_parse_inst_t *)&cmd_read_reg,
17636 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17637 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
17638 	(cmdline_parse_inst_t *)&cmd_write_reg,
17639 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17640 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
17641 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17642 	(cmdline_parse_inst_t *)&cmd_stop,
17643 	(cmdline_parse_inst_t *)&cmd_mac_addr,
17644 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17645 	(cmdline_parse_inst_t *)&cmd_set_qmap,
17646 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17647 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17648 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17649 	(cmdline_parse_inst_t *)&cmd_operate_port,
17650 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
17651 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
17652 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
17653 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
17654 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17655 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
17656 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
17657 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
17658 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17659 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
17660 	(cmdline_parse_inst_t *)&cmd_config_mtu,
17661 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17662 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17663 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17664 	(cmdline_parse_inst_t *)&cmd_config_rss,
17665 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17666 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17667 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17668 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17669 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
17670 	(cmdline_parse_inst_t *)&cmd_showport_reta,
17671 	(cmdline_parse_inst_t *)&cmd_showport_macs,
17672 	(cmdline_parse_inst_t *)&cmd_config_burst,
17673 	(cmdline_parse_inst_t *)&cmd_config_thresh,
17674 	(cmdline_parse_inst_t *)&cmd_config_threshold,
17675 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17676 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17677 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17678 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17679 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17680 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17681 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
17682 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17683 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17684 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17685 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17686 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17687 	(cmdline_parse_inst_t *)&cmd_dump,
17688 	(cmdline_parse_inst_t *)&cmd_dump_one,
17689 #ifdef RTE_NET_I40E
17690 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17691 #endif
17692 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17693 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17694 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17695 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17696 	(cmdline_parse_inst_t *)&cmd_flow,
17697 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17698 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17699 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17700 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17701 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
17702 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
17703 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
17704 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
17705 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17706 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17707 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17708 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17709 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17710 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
17711 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17712 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17713 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17714 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17715 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17716 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17717 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17718 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17719 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17720 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17721 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17722 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17723 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17724 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17725 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17726 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17727 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17728 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17729 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17730 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17731 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
17732 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17733 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17734 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
17735 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
17736 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
17737 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17738 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17739 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
17740 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17741 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
17742 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17743 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
17744 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17745 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17746 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17747 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17748 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17749 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17750 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17751 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17752 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17753 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17754 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17755 	(cmdline_parse_inst_t *)&cmd_ddp_add,
17756 	(cmdline_parse_inst_t *)&cmd_ddp_del,
17757 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
17758 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
17759 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
17760 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
17761 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
17762 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17763 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17764 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17765 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17766 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17767 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17768 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17769 
17770 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17771 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17772 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17773 	(cmdline_parse_inst_t *)&cmd_queue_region,
17774 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
17775 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
17776 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
17777 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17778 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17779 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17780 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17781 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17782 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17783 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17784 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17785 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17786 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17787 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17788 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17789 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17790 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17791 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17792 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17793 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17794 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17795 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17796 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17797 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17798 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17799 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17800 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17801 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17802 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17803 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17804 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17805 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17806 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17807 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17808 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17809 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17810 #ifdef RTE_LIB_BPF
17811 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17812 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17813 #endif
17814 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17815 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17816 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17817 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17818 	(cmdline_parse_inst_t *)&cmd_set_raw,
17819 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
17820 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17821 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17822 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
17823 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
17824 	(cmdline_parse_inst_t *)&cmd_show_capability,
17825 	NULL,
17826 };
17827 
17828 /* read cmdline commands from file */
17829 void
17830 cmdline_read_from_file(const char *filename)
17831 {
17832 	struct cmdline *cl;
17833 
17834 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17835 	if (cl == NULL) {
17836 		fprintf(stderr,
17837 			"Failed to create file based cmdline context: %s\n",
17838 			filename);
17839 		return;
17840 	}
17841 
17842 	cmdline_interact(cl);
17843 	cmdline_quit(cl);
17844 
17845 	cmdline_free(cl);
17846 
17847 	printf("Read CLI commands from %s\n", filename);
17848 }
17849 
17850 /* prompt function, called from main on MAIN lcore */
17851 void
17852 prompt(void)
17853 {
17854 	int ret;
17855 	/* initialize non-constant commands */
17856 	cmd_set_fwd_mode_init();
17857 	cmd_set_fwd_retry_mode_init();
17858 
17859 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17860 	if (testpmd_cl == NULL)
17861 		return;
17862 
17863 	ret = atexit(prompt_exit);
17864 	if (ret != 0)
17865 		fprintf(stderr, "Cannot set exit function for cmdline\n");
17866 
17867 	cmdline_interact(testpmd_cl);
17868 	if (ret != 0)
17869 		cmdline_stdin_exit(testpmd_cl);
17870 }
17871 
17872 void
17873 prompt_exit(void)
17874 {
17875 	if (testpmd_cl != NULL) {
17876 		cmdline_quit(testpmd_cl);
17877 		cmdline_stdin_exit(testpmd_cl);
17878 	}
17879 }
17880 
17881 static void
17882 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17883 {
17884 	if (id == (portid_t)RTE_PORT_ALL) {
17885 		portid_t pid;
17886 
17887 		RTE_ETH_FOREACH_DEV(pid) {
17888 			/* check if need_reconfig has been set to 1 */
17889 			if (ports[pid].need_reconfig == 0)
17890 				ports[pid].need_reconfig = dev;
17891 			/* check if need_reconfig_queues has been set to 1 */
17892 			if (ports[pid].need_reconfig_queues == 0)
17893 				ports[pid].need_reconfig_queues = queue;
17894 		}
17895 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17896 		/* check if need_reconfig has been set to 1 */
17897 		if (ports[id].need_reconfig == 0)
17898 			ports[id].need_reconfig = dev;
17899 		/* check if need_reconfig_queues has been set to 1 */
17900 		if (ports[id].need_reconfig_queues == 0)
17901 			ports[id].need_reconfig_queues = queue;
17902 	}
17903 }
17904