xref: /dpdk/app/test-pmd/cmdline.c (revision 29fd052d)
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_branch_prediction.h>
28 #include <rte_ring.h>
29 #include <rte_mempool.h>
30 #include <rte_interrupts.h>
31 #include <rte_pci.h>
32 #include <rte_ether.h>
33 #include <rte_ethdev.h>
34 #include <rte_string_fns.h>
35 #include <rte_devargs.h>
36 #include <rte_flow.h>
37 #ifdef RTE_LIB_GRO
38 #include <rte_gro.h>
39 #endif
40 #include <rte_mbuf_dyn.h>
41 
42 #include <cmdline_rdline.h>
43 #include <cmdline_parse.h>
44 #include <cmdline_parse_num.h>
45 #include <cmdline_parse_string.h>
46 #include <cmdline_parse_ipaddr.h>
47 #include <cmdline_parse_etheraddr.h>
48 #include <cmdline_socket.h>
49 #include <cmdline.h>
50 #ifdef RTE_NET_BOND
51 #include <rte_eth_bond.h>
52 #include <rte_eth_bond_8023ad.h>
53 #endif
54 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
55 #include <rte_pmd_dpaa.h>
56 #endif
57 #ifdef RTE_NET_IXGBE
58 #include <rte_pmd_ixgbe.h>
59 #endif
60 #ifdef RTE_NET_I40E
61 #include <rte_pmd_i40e.h>
62 #endif
63 #ifdef RTE_NET_BNXT
64 #include <rte_pmd_bnxt.h>
65 #endif
66 #include "testpmd.h"
67 #include "cmdline_mtr.h"
68 #include "cmdline_tm.h"
69 #include "bpf_cmd.h"
70 
71 static struct cmdline *testpmd_cl;
72 
73 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
74 
75 /* *** Help command with introduction. *** */
76 struct cmd_help_brief_result {
77 	cmdline_fixed_string_t help;
78 };
79 
80 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
81                                   struct cmdline *cl,
82                                   __rte_unused void *data)
83 {
84 	cmdline_printf(
85 		cl,
86 		"\n"
87 		"Help is available for the following sections:\n\n"
88 		"    help control                    : Start and stop forwarding.\n"
89 		"    help display                    : Displaying port, stats and config "
90 		"information.\n"
91 		"    help config                     : Configuration information.\n"
92 		"    help ports                      : Configuring ports.\n"
93 		"    help registers                  : Reading and setting port registers.\n"
94 		"    help filters                    : Filters configuration help.\n"
95 		"    help traffic_management         : Traffic Management commands.\n"
96 		"    help devices                    : Device related cmds.\n"
97 		"    help all                        : All of the above sections.\n\n"
98 	);
99 
100 }
101 
102 cmdline_parse_token_string_t cmd_help_brief_help =
103 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 
105 cmdline_parse_inst_t cmd_help_brief = {
106 	.f = cmd_help_brief_parsed,
107 	.data = NULL,
108 	.help_str = "help: Show help",
109 	.tokens = {
110 		(void *)&cmd_help_brief_help,
111 		NULL,
112 	},
113 };
114 
115 /* *** Help command with help sections. *** */
116 struct cmd_help_long_result {
117 	cmdline_fixed_string_t help;
118 	cmdline_fixed_string_t section;
119 };
120 
121 static void cmd_help_long_parsed(void *parsed_result,
122                                  struct cmdline *cl,
123                                  __rte_unused void *data)
124 {
125 	int show_all = 0;
126 	struct cmd_help_long_result *res = parsed_result;
127 
128 	if (!strcmp(res->section, "all"))
129 		show_all = 1;
130 
131 	if (show_all || !strcmp(res->section, "control")) {
132 
133 		cmdline_printf(
134 			cl,
135 			"\n"
136 			"Control forwarding:\n"
137 			"-------------------\n\n"
138 
139 			"start\n"
140 			"    Start packet forwarding with current configuration.\n\n"
141 
142 			"start tx_first\n"
143 			"    Start packet forwarding with current config"
144 			" after sending one burst of packets.\n\n"
145 
146 			"stop\n"
147 			"    Stop packet forwarding, and display accumulated"
148 			" statistics.\n\n"
149 
150 			"quit\n"
151 			"    Quit to prompt.\n\n"
152 		);
153 	}
154 
155 	if (show_all || !strcmp(res->section, "display")) {
156 
157 		cmdline_printf(
158 			cl,
159 			"\n"
160 			"Display:\n"
161 			"--------\n\n"
162 
163 			"show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
164 			"    Display information for port_id, or all.\n\n"
165 
166 			"show port info (port_id) representor\n"
167 			"    Show supported representors for a specific port\n\n"
168 
169 			"show port port_id (module_eeprom|eeprom)\n"
170 			"    Display the module EEPROM or EEPROM information for port_id.\n\n"
171 
172 			"show port X rss reta (size) (mask0,mask1,...)\n"
173 			"    Display the rss redirection table entry indicated"
174 			" by masks on port X. size is used to indicate the"
175 			" hardware supported reta size\n\n"
176 
177 			"show port (port_id) rss-hash [key]\n"
178 			"    Display the RSS hash functions and RSS hash key of port\n\n"
179 
180 			"clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 			"    Clear information for port_id, or all.\n\n"
182 
183 			"show (rxq|txq) info (port_id) (queue_id)\n"
184 			"    Display information for configured RX/TX queue.\n\n"
185 
186 			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 			"    Display the given configuration.\n\n"
188 
189 			"read rxd (port_id) (queue_id) (rxd_id)\n"
190 			"    Display an RX descriptor of a port RX queue.\n\n"
191 
192 			"read txd (port_id) (queue_id) (txd_id)\n"
193 			"    Display a TX descriptor of a port TX queue.\n\n"
194 
195 			"ddp get list (port_id)\n"
196 			"    Get ddp profile info list\n\n"
197 
198 			"ddp get info (profile_path)\n"
199 			"    Get ddp profile information.\n\n"
200 
201 			"show vf stats (port_id) (vf_id)\n"
202 			"    Display a VF's statistics.\n\n"
203 
204 			"clear vf stats (port_id) (vf_id)\n"
205 			"    Reset a VF's statistics.\n\n"
206 
207 			"show port (port_id) pctype mapping\n"
208 			"    Get flow ptype to pctype mapping on a port\n\n"
209 
210 			"show port meter stats (port_id) (meter_id) (clear)\n"
211 			"    Get meter stats on a port\n\n"
212 
213 			"show fwd stats all\n"
214 			"    Display statistics for all fwd engines.\n\n"
215 
216 			"clear fwd stats all\n"
217 			"    Clear statistics for all fwd engines.\n\n"
218 
219 			"show port (port_id) rx_offload capabilities\n"
220 			"    List all per queue and per port Rx offloading"
221 			" capabilities of a port\n\n"
222 
223 			"show port (port_id) rx_offload configuration\n"
224 			"    List port level and all queue level"
225 			" Rx offloading configuration\n\n"
226 
227 			"show port (port_id) tx_offload capabilities\n"
228 			"    List all per queue and per port"
229 			" Tx offloading capabilities of a port\n\n"
230 
231 			"show port (port_id) tx_offload configuration\n"
232 			"    List port level and all queue level"
233 			" Tx offloading configuration\n\n"
234 
235 			"show port (port_id) tx_metadata\n"
236 			"    Show Tx metadata value set"
237 			" for a specific port\n\n"
238 
239 			"show port (port_id) ptypes\n"
240 			"    Show port supported ptypes"
241 			" for a specific port\n\n"
242 
243 			"show device info (<identifier>|all)"
244 			"       Show general information about devices probed.\n\n"
245 
246 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 			"       Show status of rx|tx descriptor.\n\n"
248 
249 			"show port (port_id) rxq (queue_id) desc used count\n"
250 			"    Show current number of filled receive"
251 			" packet descriptors.\n\n"
252 
253 			"show port (port_id) macs|mcast_macs"
254 			"       Display list of mac addresses added to port.\n\n"
255 
256 			"show port (port_id) flow transfer proxy\n"
257 			"	Display proxy port to manage transfer flows\n\n"
258 
259 			"show port (port_id) fec capabilities"
260 			"	Show fec capabilities of a port.\n\n"
261 
262 			"show port (port_id) fec_mode"
263 			"	Show fec mode of a port.\n\n"
264 
265 			"show port (port_id) flow_ctrl"
266 			"	Show flow control info of a port.\n\n"
267 		);
268 	}
269 
270 	if (show_all || !strcmp(res->section, "config")) {
271 		cmdline_printf(
272 			cl,
273 			"\n"
274 			"Configuration:\n"
275 			"--------------\n"
276 			"Configuration changes only become active when"
277 			" forwarding is started/restarted.\n\n"
278 
279 			"set default\n"
280 			"    Reset forwarding to the default configuration.\n\n"
281 
282 			"set verbose (level)\n"
283 			"    Set the debug verbosity level X.\n\n"
284 
285 			"set log global|(type) (level)\n"
286 			"    Set the log level.\n\n"
287 
288 			"set nbport (num)\n"
289 			"    Set number of ports.\n\n"
290 
291 			"set nbcore (num)\n"
292 			"    Set number of cores.\n\n"
293 
294 			"set coremask (mask)\n"
295 			"    Set the forwarding cores hexadecimal mask.\n\n"
296 
297 			"set portmask (mask)\n"
298 			"    Set the forwarding ports hexadecimal mask.\n\n"
299 
300 			"set burst (num)\n"
301 			"    Set number of packets per burst.\n\n"
302 
303 			"set burst tx delay (microseconds) retry (num)\n"
304 			"    Set the transmit delay time and number of retries,"
305 			" effective when retry is enabled.\n\n"
306 
307 			"set rxoffs (x[,y]*)\n"
308 			"    Set the offset of each packet segment on"
309 			" receiving if split feature is engaged."
310 			" Affects only the queues configured with split"
311 			" offloads.\n\n"
312 
313 			"set rxpkts (x[,y]*)\n"
314 			"    Set the length of each segment to scatter"
315 			" packets on receiving if split feature is engaged."
316 			" Affects only the queues configured with split"
317 			" offloads.\n\n"
318 
319 			"set txpkts (x[,y]*)\n"
320 			"    Set the length of each segment of TXONLY"
321 			" and optionally CSUM packets.\n\n"
322 
323 			"set txsplit (off|on|rand)\n"
324 			"    Set the split policy for the TX packets."
325 			" Right now only applicable for CSUM and TXONLY"
326 			" modes\n\n"
327 
328 			"set txtimes (x, y)\n"
329 			"    Set the scheduling on timestamps"
330 			" timings for the TXONLY mode\n\n"
331 
332 			"set corelist (x[,y]*)\n"
333 			"    Set the list of forwarding cores.\n\n"
334 
335 			"set portlist (x[,y]*)\n"
336 			"    Set the list of forwarding ports.\n\n"
337 
338 			"set port setup on (iterator|event)\n"
339 			"    Select how attached port is retrieved for setup.\n\n"
340 
341 			"set tx loopback (port_id) (on|off)\n"
342 			"    Enable or disable tx loopback.\n\n"
343 
344 			"set all queues drop (port_id) (on|off)\n"
345 			"    Set drop enable bit for all queues.\n\n"
346 
347 			"set vf split drop (port_id) (vf_id) (on|off)\n"
348 			"    Set split drop enable bit for a VF from the PF.\n\n"
349 
350 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
351 			"    Set MAC antispoof for a VF from the PF.\n\n"
352 
353 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
354 			"    Enable MACsec offload.\n\n"
355 
356 			"set macsec offload (port_id) off\n"
357 			"    Disable MACsec offload.\n\n"
358 
359 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
360 			"    Configure MACsec secure connection (SC).\n\n"
361 
362 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
363 			"    Configure MACsec secure association (SA).\n\n"
364 
365 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
366 			"    Set VF broadcast for a VF from the PF.\n\n"
367 
368 			"vlan set stripq (on|off) (port_id,queue_id)\n"
369 			"    Set the VLAN strip for a queue on a port.\n\n"
370 
371 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
372 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
373 
374 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
375 			"    Set VLAN insert for a VF from the PF.\n\n"
376 
377 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
378 			"    Set VLAN antispoof for a VF from the PF.\n\n"
379 
380 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
381 			"    Set VLAN tag for a VF from the PF.\n\n"
382 
383 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
384 			"    Set a VF's max bandwidth(Mbps).\n\n"
385 
386 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
387 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
388 
389 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
390 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
391 
392 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
393 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
394 
395 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
396 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
397 
398 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
399 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
400 
401 			"vlan set (inner|outer) tpid (value) (port_id)\n"
402 			"    Set the VLAN TPID for Packet Filtering on"
403 			" a port\n\n"
404 
405 			"rx_vlan add (vlan_id|all) (port_id)\n"
406 			"    Add a vlan_id, or all identifiers, to the set"
407 			" of VLAN identifiers filtered by port_id.\n\n"
408 
409 			"rx_vlan rm (vlan_id|all) (port_id)\n"
410 			"    Remove a vlan_id, or all identifiers, from the set"
411 			" of VLAN identifiers filtered by port_id.\n\n"
412 
413 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
414 			"    Add a vlan_id, to the set of VLAN identifiers"
415 			"filtered for VF(s) from port_id.\n\n"
416 
417 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
418 			"    Remove a vlan_id, to the set of VLAN identifiers"
419 			"filtered for VF(s) from port_id.\n\n"
420 
421 			"rx_vxlan_port add (udp_port) (port_id)\n"
422 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
423 
424 			"rx_vxlan_port rm (udp_port) (port_id)\n"
425 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
426 
427 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
429 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
430 
431 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
432 			"    Set port based TX VLAN insertion.\n\n"
433 
434 			"tx_vlan reset (port_id)\n"
435 			"    Disable hardware insertion of a VLAN header in"
436 			" packets sent on a port.\n\n"
437 
438 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 			"    Select hardware or software calculation of the"
440 			" checksum when transmitting a packet using the"
441 			" csum forward engine.\n"
442 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
443 			"    outer-ip concerns the outer IP layer in"
444 			"    outer-udp concerns the outer UDP layer in"
445 			" case the packet is recognized as a tunnel packet by"
446 			" the forward engine (vxlan, gre and ipip are supported)\n"
447 			"    Please check the NIC datasheet for HW limits.\n\n"
448 
449 			"csum parse-tunnel (on|off) (tx_port_id)\n"
450 			"    If disabled, treat tunnel packets as non-tunneled"
451 			" packets (treat inner headers as payload). The port\n"
452 			"    argument is the port used for TX in csum forward"
453 			" engine.\n\n"
454 
455 			"csum show (port_id)\n"
456 			"    Display tx checksum offload configuration\n\n"
457 
458 			"tso set (segsize) (portid)\n"
459 			"    Enable TCP Segmentation Offload in csum forward"
460 			" engine.\n"
461 			"    Please check the NIC datasheet for HW limits.\n\n"
462 
463 			"tso show (portid)"
464 			"    Display the status of TCP Segmentation Offload.\n\n"
465 
466 #ifdef RTE_LIB_GRO
467 			"set port (port_id) gro on|off\n"
468 			"    Enable or disable Generic Receive Offload in"
469 			" csum forwarding engine.\n\n"
470 
471 			"show port (port_id) gro\n"
472 			"    Display GRO configuration.\n\n"
473 
474 			"set gro flush (cycles)\n"
475 			"    Set the cycle to flush GROed packets from"
476 			" reassembly tables.\n\n"
477 #endif
478 
479 #ifdef RTE_LIB_GSO
480 			"set port (port_id) gso (on|off)"
481 			"    Enable or disable Generic Segmentation Offload in"
482 			" csum forwarding engine.\n\n"
483 
484 			"set gso segsz (length)\n"
485 			"    Set max packet length for output GSO segments,"
486 			" including packet header and payload.\n\n"
487 
488 			"show port (port_id) gso\n"
489 			"    Show GSO configuration.\n\n"
490 #endif
491 
492 			"set fwd (%s)\n"
493 			"    Set packet forwarding mode.\n\n"
494 
495 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
496 			"    Add a MAC address on port_id.\n\n"
497 
498 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
499 			"    Remove a MAC address from port_id.\n\n"
500 
501 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
502 			"    Set the default MAC address for port_id.\n\n"
503 
504 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
505 			"    Add a MAC address for a VF on the port.\n\n"
506 
507 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
508 			"    Set the MAC address for a VF from the PF.\n\n"
509 
510 			"set eth-peer (port_id) (peer_addr)\n"
511 			"    set the peer address for certain port.\n\n"
512 
513 			"set port (port_id) uta (mac_address|all) (on|off)\n"
514 			"    Add/Remove a or all unicast hash filter(s)"
515 			"from port X.\n\n"
516 
517 			"set promisc (port_id|all) (on|off)\n"
518 			"    Set the promiscuous mode on port_id, or all.\n\n"
519 
520 			"set allmulti (port_id|all) (on|off)\n"
521 			"    Set the allmulti mode on port_id, or all.\n\n"
522 
523 			"set vf promisc (port_id) (vf_id) (on|off)\n"
524 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
525 
526 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
527 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
528 
529 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
530 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
531 			" (on|off) autoneg (on|off) (port_id)\n"
532 			"set flow_ctrl rx (on|off) (portid)\n"
533 			"set flow_ctrl tx (on|off) (portid)\n"
534 			"set flow_ctrl high_water (high_water) (portid)\n"
535 			"set flow_ctrl low_water (low_water) (portid)\n"
536 			"set flow_ctrl pause_time (pause_time) (portid)\n"
537 			"set flow_ctrl send_xon (send_xon) (portid)\n"
538 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
539 			"set flow_ctrl autoneg (on|off) (port_id)\n"
540 			"    Set the link flow control parameter on a port.\n\n"
541 
542 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
543 			" (low_water) (pause_time) (priority) (port_id)\n"
544 			"    Set the priority flow control parameter on a"
545 			" port.\n\n"
546 
547 			"set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
548 			" (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
549 			"    Set the queue priority flow control parameter on a"
550 			" given Rx and Tx queues of a port.\n\n"
551 
552 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
553 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
554 			" queue on port.\n"
555 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
556 			" on port 0 to mapping 5.\n\n"
557 
558 			"set xstats-hide-zero on|off\n"
559 			"    Set the option to hide the zero values"
560 			" for xstats display.\n"
561 
562 			"set record-core-cycles on|off\n"
563 			"    Set the option to enable measurement of CPU cycles.\n"
564 
565 			"set record-burst-stats on|off\n"
566 			"    Set the option to enable display of RX and TX bursts.\n"
567 
568 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
569 			"    Enable/Disable a VF receive/transmit from a port\n\n"
570 
571 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
572 			"|MPE) (on|off)\n"
573 			"    AUPE:accepts untagged VLAN;"
574 			"ROPE:accept unicast hash\n\n"
575 			"    BAM:accepts broadcast packets;"
576 			"MPE:accepts all multicast packets\n\n"
577 			"    Enable/Disable a VF receive mode of a port\n\n"
578 
579 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
580 			"    Set rate limit for a queue of a port\n\n"
581 
582 			"set port (port_id) vf (vf_id) rate (rate_num) "
583 			"queue_mask (queue_mask_value)\n"
584 			"    Set rate limit for queues in VF of a port\n\n"
585 
586 			"set flush_rx (on|off)\n"
587 			"   Flush (default) or don't flush RX streams before"
588 			" forwarding. Mainly used with PCAP drivers.\n\n"
589 
590 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
591 			"   Set the bypass mode for the lowest port on bypass enabled"
592 			" NIC.\n\n"
593 
594 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
595 			"mode (normal|bypass|isolate) (port_id)\n"
596 			"   Set the event required to initiate specified bypass mode for"
597 			" the lowest port on a bypass enabled NIC where:\n"
598 			"       timeout   = enable bypass after watchdog timeout.\n"
599 			"       os_on     = enable bypass when OS/board is powered on.\n"
600 			"       os_off    = enable bypass when OS/board is powered off.\n"
601 			"       power_on  = enable bypass when power supply is turned on.\n"
602 			"       power_off = enable bypass when power supply is turned off."
603 			"\n\n"
604 
605 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
606 			"   Set the bypass watchdog timeout to 'n' seconds"
607 			" where 0 = instant.\n\n"
608 
609 			"show bypass config (port_id)\n"
610 			"   Show the bypass configuration for a bypass enabled NIC"
611 			" using the lowest port on the NIC.\n\n"
612 
613 #ifdef RTE_NET_BOND
614 			"create bonded device (mode) (socket)\n"
615 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
616 
617 			"add bonding slave (slave_id) (port_id)\n"
618 			"	Add a slave device to a bonded device.\n\n"
619 
620 			"remove bonding slave (slave_id) (port_id)\n"
621 			"	Remove a slave device from a bonded device.\n\n"
622 
623 			"set bonding mode (value) (port_id)\n"
624 			"	Set the bonding mode on a bonded device.\n\n"
625 
626 			"set bonding primary (slave_id) (port_id)\n"
627 			"	Set the primary slave for a bonded device.\n\n"
628 
629 			"show bonding config (port_id)\n"
630 			"	Show the bonding config for port_id.\n\n"
631 
632 			"show bonding lacp info (port_id)\n"
633 			"	Show the bonding lacp information for port_id.\n\n"
634 
635 			"set bonding mac_addr (port_id) (address)\n"
636 			"	Set the MAC address of a bonded device.\n\n"
637 
638 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
639 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
640 
641 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
642 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
643 
644 			"set bonding mon_period (port_id) (value)\n"
645 			"	Set the bonding link status monitoring polling period in ms.\n\n"
646 
647 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
648 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
649 
650 #endif
651 			"set link-up port (port_id)\n"
652 			"	Set link up for a port.\n\n"
653 
654 			"set link-down port (port_id)\n"
655 			"	Set link down for a port.\n\n"
656 
657 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 			"    Load a profile package on a port\n\n"
659 
660 			"ddp del (port_id) (backup_profile_path)\n"
661 			"    Delete a profile package from a port\n\n"
662 
663 			"ptype mapping get (port_id) (valid_only)\n"
664 			"    Get ptype mapping on a port\n\n"
665 
666 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 			"    Replace target with the pkt_type in ptype mapping\n\n"
668 
669 			"ptype mapping reset (port_id)\n"
670 			"    Reset ptype mapping on a port\n\n"
671 
672 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 			"    Update a ptype mapping item on a port\n\n"
674 
675 			"set port (port_id) ptype_mask (ptype_mask)\n"
676 			"    set packet types classification for a specific port\n\n"
677 
678 			"set port (port_id) queue-region region_id (value) "
679 			"queue_start_index (value) queue_num (value)\n"
680 			"    Set a queue region on a port\n\n"
681 
682 			"set port (port_id) queue-region region_id (value) "
683 			"flowtype (value)\n"
684 			"    Set a flowtype region index on a port\n\n"
685 
686 			"set port (port_id) queue-region UP (value) region_id (value)\n"
687 			"    Set the mapping of User Priority to "
688 			"queue region on a port\n\n"
689 
690 			"set port (port_id) queue-region flush (on|off)\n"
691 			"    flush all queue region related configuration\n\n"
692 
693 			"show port meter cap (port_id)\n"
694 			"    Show port meter capability information\n\n"
695 
696 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
697 			"    meter profile add - srtcm rfc 2697\n\n"
698 
699 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
700 			"    meter profile add - trtcm rfc 2698\n\n"
701 
702 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
703 			"    meter profile add - trtcm rfc 4115\n\n"
704 
705 			"del port meter profile (port_id) (profile_id)\n"
706 			"    meter profile delete\n\n"
707 
708 			"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
709 			"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
710 			"(dscp_tbl_entry63)]\n"
711 			"    meter create\n\n"
712 
713 			"enable port meter (port_id) (mtr_id)\n"
714 			"    meter enable\n\n"
715 
716 			"disable port meter (port_id) (mtr_id)\n"
717 			"    meter disable\n\n"
718 
719 			"del port meter (port_id) (mtr_id)\n"
720 			"    meter delete\n\n"
721 
722 			"add port meter policy (port_id) (policy_id) g_actions (actions)\n"
723 			"y_actions (actions) r_actions (actions)\n"
724 			"    meter policy add\n\n"
725 
726 			"del port meter policy (port_id) (policy_id)\n"
727 			"    meter policy delete\n\n"
728 
729 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
730 			"    meter update meter profile\n\n"
731 
732 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
733 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
734 			"    update meter dscp table entries\n\n"
735 
736 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
737 			"(action0) [(action1) (action2)]\n"
738 			"    meter update policer action\n\n"
739 
740 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
741 			"    meter update stats\n\n"
742 
743 			"show port (port_id) queue-region\n"
744 			"    show all queue region related configuration info\n\n"
745 
746 			"set port (port_id) fec_mode auto|off|rs|baser\n"
747 			"    set fec mode for a specific port\n\n"
748 
749 			, list_pkt_forwarding_modes()
750 		);
751 	}
752 
753 	if (show_all || !strcmp(res->section, "ports")) {
754 
755 		cmdline_printf(
756 			cl,
757 			"\n"
758 			"Port Operations:\n"
759 			"----------------\n\n"
760 
761 			"port start (port_id|all)\n"
762 			"    Start all ports or port_id.\n\n"
763 
764 			"port stop (port_id|all)\n"
765 			"    Stop all ports or port_id.\n\n"
766 
767 			"port close (port_id|all)\n"
768 			"    Close all ports or port_id.\n\n"
769 
770 			"port reset (port_id|all)\n"
771 			"    Reset all ports or port_id.\n\n"
772 
773 			"port attach (ident)\n"
774 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
775 
776 			"port detach (port_id)\n"
777 			"    Detach physical or virtual dev by port_id\n\n"
778 
779 			"port config (port_id|all)"
780 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
781 			" duplex (half|full|auto)\n"
782 			"    Set speed and duplex for all ports or port_id\n\n"
783 
784 			"port config (port_id|all) loopback (mode)\n"
785 			"    Set loopback mode for all ports or port_id\n\n"
786 
787 			"port config all (rxq|txq|rxd|txd) (value)\n"
788 			"    Set number for rxq/txq/rxd/txd.\n\n"
789 
790 			"port config all max-pkt-len (value)\n"
791 			"    Set the max packet length.\n\n"
792 
793 			"port config all max-lro-pkt-size (value)\n"
794 			"    Set the max LRO aggregated packet size.\n\n"
795 
796 			"port config all drop-en (on|off)\n"
797 			"    Enable or disable packet drop on all RX queues of all ports when no "
798 			"receive buffers available.\n\n"
799 
800 			"port config all rss (all|default|ip|tcp|udp|sctp|"
801 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|"
802 			"none|level-default|level-outer|level-inner|<flowtype_id>)\n"
803 			"    Set the RSS mode.\n\n"
804 
805 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
806 			"    Set the RSS redirection table.\n\n"
807 
808 			"port config (port_id) dcb vt (on|off) (traffic_class)"
809 			" pfc (on|off)\n"
810 			"    Set the DCB mode.\n\n"
811 
812 			"port config all burst (value)\n"
813 			"    Set the number of packets per burst.\n\n"
814 
815 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
816 			" (value)\n"
817 			"    Set the ring prefetch/host/writeback threshold"
818 			" for tx/rx queue.\n\n"
819 
820 			"port config all (txfreet|txrst|rxfreet) (value)\n"
821 			"    Set free threshold for rx/tx, or set"
822 			" tx rs bit threshold.\n\n"
823 			"port config mtu X value\n"
824 			"    Set the MTU of port X to a given value\n\n"
825 
826 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
827 			"    Set a rx/tx queue's ring size configuration, the new"
828 			" value will take effect after command that (re-)start the port"
829 			" or command that setup the specific queue\n\n"
830 
831 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
832 			"    Start/stop a rx/tx queue of port X. Only take effect"
833 			" when port X is started\n\n"
834 
835 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
836 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
837 			" take effect when port X is stopped.\n\n"
838 
839 			"port (port_id) (rxq|txq) (queue_id) setup\n"
840 			"    Setup a rx/tx queue of port X.\n\n"
841 
842 			"port config (port_id) pctype mapping reset\n"
843 			"    Reset flow type to pctype mapping on a port\n\n"
844 
845 			"port config (port_id) pctype mapping update"
846 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
847 			"    Update a flow type to pctype mapping item on a port\n\n"
848 
849 			"port config (port_id) pctype (pctype_id) hash_inset|"
850 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
851 			" (field_idx)\n"
852 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 
854 			"port config (port_id) pctype (pctype_id) hash_inset|"
855 			"fdir_inset|fdir_flx_inset clear all"
856 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 
858 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
859 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
860 
861 			"port config <port_id> rx_offload vlan_strip|"
862 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 			"outer_ipv4_cksum|macsec_strip|header_split|"
864 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
865 			"buffer_split|timestamp|security|keep_crc on|off\n"
866 			"     Enable or disable a per port Rx offloading"
867 			" on all Rx queues of a port\n\n"
868 
869 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
870 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
871 			"outer_ipv4_cksum|macsec_strip|header_split|"
872 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
873 			"buffer_split|timestamp|security|keep_crc on|off\n"
874 			"    Enable or disable a per queue Rx offloading"
875 			" only on a specific Rx queue\n\n"
876 
877 			"port config (port_id) tx_offload vlan_insert|"
878 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
881 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 			"security on|off\n"
883 			"    Enable or disable a per port Tx offloading"
884 			" on all Tx queues of a port\n\n"
885 
886 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
887 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
888 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
889 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
890 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 			" on|off\n"
892 			"    Enable or disable a per queue Tx offloading"
893 			" only on a specific Tx queue\n\n"
894 
895 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
896 			"    Load an eBPF program as a callback"
897 			" for particular RX/TX queue\n\n"
898 
899 			"bpf-unload rx|tx (port) (queue)\n"
900 			"    Unload previously loaded eBPF program"
901 			" for particular RX/TX queue\n\n"
902 
903 			"port config (port_id) tx_metadata (value)\n"
904 			"    Set Tx metadata value per port. Testpmd will add this value"
905 			" to any Tx packet sent from this port\n\n"
906 
907 			"port config (port_id) dynf (name) set|clear\n"
908 			"    Register a dynf and Set/clear this flag on Tx. "
909 			"Testpmd will set this value to any Tx packet "
910 			"sent from this port\n\n"
911 
912 			"port cleanup (port_id) txq (queue_id) (free_cnt)\n"
913 			"    Cleanup txq mbufs for a specific Tx queue\n\n"
914 		);
915 	}
916 
917 	if (show_all || !strcmp(res->section, "registers")) {
918 
919 		cmdline_printf(
920 			cl,
921 			"\n"
922 			"Registers:\n"
923 			"----------\n\n"
924 
925 			"read reg (port_id) (address)\n"
926 			"    Display value of a port register.\n\n"
927 
928 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
929 			"    Display a port register bit field.\n\n"
930 
931 			"read regbit (port_id) (address) (bit_x)\n"
932 			"    Display a single port register bit.\n\n"
933 
934 			"write reg (port_id) (address) (value)\n"
935 			"    Set value of a port register.\n\n"
936 
937 			"write regfield (port_id) (address) (bit_x) (bit_y)"
938 			" (value)\n"
939 			"    Set bit field of a port register.\n\n"
940 
941 			"write regbit (port_id) (address) (bit_x) (value)\n"
942 			"    Set single bit value of a port register.\n\n"
943 		);
944 	}
945 	if (show_all || !strcmp(res->section, "filters")) {
946 
947 		cmdline_printf(
948 			cl,
949 			"\n"
950 			"filters:\n"
951 			"--------\n\n"
952 
953 #ifdef RTE_NET_I40E
954 			"flow_director_filter (port_id) mode raw (add|del|update)"
955 			" flow (flow_id) (drop|fwd) queue (queue_id)"
956 			" fd_id (fd_id_value) packet (packet file name)\n"
957 			"    Add/Del a raw type flow director filter.\n\n"
958 #endif
959 
960 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
961 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
962 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
963 			"    Set flow director IP mask.\n\n"
964 
965 			"flow_director_mask (port_id) mode MAC-VLAN"
966 			" vlan (vlan_value)\n"
967 			"    Set flow director MAC-VLAN mask.\n\n"
968 
969 			"flow_director_mask (port_id) mode Tunnel"
970 			" vlan (vlan_value) mac (mac_value)"
971 			" tunnel-type (tunnel_type_value)"
972 			" tunnel-id (tunnel_id_value)\n"
973 			"    Set flow director Tunnel mask.\n\n"
974 
975 			"flow_director_flex_payload (port_id)"
976 			" (raw|l2|l3|l4) (config)\n"
977 			"    Configure flex payload selection.\n\n"
978 
979 			"flow validate {port_id}"
980 			" [group {group_id}] [priority {level}]"
981 			" [ingress] [egress]"
982 			" pattern {item} [/ {item} [...]] / end"
983 			" actions {action} [/ {action} [...]] / end\n"
984 			"    Check whether a flow rule can be created.\n\n"
985 
986 			"flow create {port_id}"
987 			" [group {group_id}] [priority {level}]"
988 			" [ingress] [egress]"
989 			" pattern {item} [/ {item} [...]] / end"
990 			" actions {action} [/ {action} [...]] / end\n"
991 			"    Create a flow rule.\n\n"
992 
993 			"flow destroy {port_id} rule {rule_id} [...]\n"
994 			"    Destroy specific flow rules.\n\n"
995 
996 			"flow flush {port_id}\n"
997 			"    Destroy all flow rules.\n\n"
998 
999 			"flow query {port_id} {rule_id} {action}\n"
1000 			"    Query an existing flow rule.\n\n"
1001 
1002 			"flow list {port_id} [group {group_id}] [...]\n"
1003 			"    List existing flow rules sorted by priority,"
1004 			" filtered by group identifiers.\n\n"
1005 
1006 			"flow isolate {port_id} {boolean}\n"
1007 			"    Restrict ingress traffic to the defined"
1008 			" flow rules\n\n"
1009 
1010 			"flow aged {port_id} [destroy]\n"
1011 			"    List and destroy aged flows"
1012 			" flow rules\n\n"
1013 
1014 			"flow indirect_action {port_id} create"
1015 			" [action_id {indirect_action_id}]"
1016 			" [ingress] [egress]"
1017 			" action {action} / end\n"
1018 			"    Create indirect action.\n\n"
1019 
1020 			"flow indirect_action {port_id} update"
1021 			" {indirect_action_id} action {action} / end\n"
1022 			"    Update indirect action.\n\n"
1023 
1024 			"flow indirect_action {port_id} destroy"
1025 			" action_id {indirect_action_id} [...]\n"
1026 			"    Destroy specific indirect actions.\n\n"
1027 
1028 			"flow indirect_action {port_id} query"
1029 			" {indirect_action_id}\n"
1030 			"    Query an existing indirect action.\n\n"
1031 
1032 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1033 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1034 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1035 			"       Configure the VXLAN encapsulation for flows.\n\n"
1036 
1037 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1038 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1039 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1040 			" eth-dst (eth-dst)\n"
1041 			"       Configure the VXLAN encapsulation for flows.\n\n"
1042 
1043 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1044 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1045 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1046 			" eth-dst (eth-dst)\n"
1047 			"       Configure the VXLAN encapsulation for flows.\n\n"
1048 
1049 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1050 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1051 			" (eth-dst)\n"
1052 			"       Configure the NVGRE encapsulation for flows.\n\n"
1053 
1054 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1055 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1056 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1057 			"       Configure the NVGRE encapsulation for flows.\n\n"
1058 
1059 			"set raw_encap {flow items}\n"
1060 			"	Configure the encapsulation with raw data.\n\n"
1061 
1062 			"set raw_decap {flow items}\n"
1063 			"	Configure the decapsulation with raw data.\n\n"
1064 
1065 		);
1066 	}
1067 
1068 	if (show_all || !strcmp(res->section, "traffic_management")) {
1069 		cmdline_printf(
1070 			cl,
1071 			"\n"
1072 			"Traffic Management:\n"
1073 			"--------------\n"
1074 			"show port tm cap (port_id)\n"
1075 			"       Display the port TM capability.\n\n"
1076 
1077 			"show port tm level cap (port_id) (level_id)\n"
1078 			"       Display the port TM hierarchical level capability.\n\n"
1079 
1080 			"show port tm node cap (port_id) (node_id)\n"
1081 			"       Display the port TM node capability.\n\n"
1082 
1083 			"show port tm node type (port_id) (node_id)\n"
1084 			"       Display the port TM node type.\n\n"
1085 
1086 			"show port tm node stats (port_id) (node_id) (clear)\n"
1087 			"       Display the port TM node stats.\n\n"
1088 
1089 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1090 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1091 			" (packet_length_adjust) (packet_mode)\n"
1092 			"       Add port tm node private shaper profile.\n\n"
1093 
1094 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1095 			"       Delete port tm node private shaper profile.\n\n"
1096 
1097 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1098 			" (shaper_profile_id)\n"
1099 			"       Add/update port tm node shared shaper.\n\n"
1100 
1101 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1102 			"       Delete port tm node shared shaper.\n\n"
1103 
1104 			"set port tm node shaper profile (port_id) (node_id)"
1105 			" (shaper_profile_id)\n"
1106 			"       Set port tm node shaper profile.\n\n"
1107 
1108 			"add port tm node wred profile (port_id) (wred_profile_id)"
1109 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1110 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1111 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1112 			"       Add port tm node wred profile.\n\n"
1113 
1114 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1115 			"       Delete port tm node wred profile.\n\n"
1116 
1117 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1118 			" (priority) (weight) (level_id) (shaper_profile_id)"
1119 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1120 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1121 			"       Add port tm nonleaf node.\n\n"
1122 
1123 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1124 			" (priority) (weight) (level_id) (shaper_profile_id)"
1125 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1126 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1127 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
1128 
1129 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1130 			" (priority) (weight) (level_id) (shaper_profile_id)"
1131 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1132 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1133 			"       Add port tm leaf node.\n\n"
1134 
1135 			"del port tm node (port_id) (node_id)\n"
1136 			"       Delete port tm node.\n\n"
1137 
1138 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1139 			" (priority) (weight)\n"
1140 			"       Set port tm node parent.\n\n"
1141 
1142 			"suspend port tm node (port_id) (node_id)"
1143 			"       Suspend tm node.\n\n"
1144 
1145 			"resume port tm node (port_id) (node_id)"
1146 			"       Resume tm node.\n\n"
1147 
1148 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1149 			"       Commit tm hierarchy.\n\n"
1150 
1151 			"set port tm mark ip_ecn (port) (green) (yellow)"
1152 			" (red)\n"
1153 			"    Enables/Disables the traffic management marking"
1154 			" for IP ECN (Explicit Congestion Notification)"
1155 			" packets on a given port\n\n"
1156 
1157 			"set port tm mark ip_dscp (port) (green) (yellow)"
1158 			" (red)\n"
1159 			"    Enables/Disables the traffic management marking"
1160 			" on the port for IP dscp packets\n\n"
1161 
1162 			"set port tm mark vlan_dei (port) (green) (yellow)"
1163 			" (red)\n"
1164 			"    Enables/Disables the traffic management marking"
1165 			" on the port for VLAN packets with DEI enabled\n\n"
1166 		);
1167 	}
1168 
1169 	if (show_all || !strcmp(res->section, "devices")) {
1170 		cmdline_printf(
1171 			cl,
1172 			"\n"
1173 			"Device Operations:\n"
1174 			"--------------\n"
1175 			"device detach (identifier)\n"
1176 			"       Detach device by identifier.\n\n"
1177 		);
1178 	}
1179 
1180 }
1181 
1182 cmdline_parse_token_string_t cmd_help_long_help =
1183 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1184 
1185 cmdline_parse_token_string_t cmd_help_long_section =
1186 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1187 			"all#control#display#config#"
1188 			"ports#registers#filters#traffic_management#devices");
1189 
1190 cmdline_parse_inst_t cmd_help_long = {
1191 	.f = cmd_help_long_parsed,
1192 	.data = NULL,
1193 	.help_str = "help all|control|display|config|ports|register|"
1194 		"filters|traffic_management|devices: "
1195 		"Show help",
1196 	.tokens = {
1197 		(void *)&cmd_help_long_help,
1198 		(void *)&cmd_help_long_section,
1199 		NULL,
1200 	},
1201 };
1202 
1203 
1204 /* *** start/stop/close all ports *** */
1205 struct cmd_operate_port_result {
1206 	cmdline_fixed_string_t keyword;
1207 	cmdline_fixed_string_t name;
1208 	cmdline_fixed_string_t value;
1209 };
1210 
1211 static void cmd_operate_port_parsed(void *parsed_result,
1212 				__rte_unused struct cmdline *cl,
1213 				__rte_unused void *data)
1214 {
1215 	struct cmd_operate_port_result *res = parsed_result;
1216 
1217 	if (!strcmp(res->name, "start"))
1218 		start_port(RTE_PORT_ALL);
1219 	else if (!strcmp(res->name, "stop"))
1220 		stop_port(RTE_PORT_ALL);
1221 	else if (!strcmp(res->name, "close"))
1222 		close_port(RTE_PORT_ALL);
1223 	else if (!strcmp(res->name, "reset"))
1224 		reset_port(RTE_PORT_ALL);
1225 	else
1226 		fprintf(stderr, "Unknown parameter\n");
1227 }
1228 
1229 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1230 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1231 								"port");
1232 cmdline_parse_token_string_t cmd_operate_port_all_port =
1233 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1234 						"start#stop#close#reset");
1235 cmdline_parse_token_string_t cmd_operate_port_all_all =
1236 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1237 
1238 cmdline_parse_inst_t cmd_operate_port = {
1239 	.f = cmd_operate_port_parsed,
1240 	.data = NULL,
1241 	.help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1242 	.tokens = {
1243 		(void *)&cmd_operate_port_all_cmd,
1244 		(void *)&cmd_operate_port_all_port,
1245 		(void *)&cmd_operate_port_all_all,
1246 		NULL,
1247 	},
1248 };
1249 
1250 /* *** start/stop/close specific port *** */
1251 struct cmd_operate_specific_port_result {
1252 	cmdline_fixed_string_t keyword;
1253 	cmdline_fixed_string_t name;
1254 	uint8_t value;
1255 };
1256 
1257 static void cmd_operate_specific_port_parsed(void *parsed_result,
1258 			__rte_unused struct cmdline *cl,
1259 				__rte_unused void *data)
1260 {
1261 	struct cmd_operate_specific_port_result *res = parsed_result;
1262 
1263 	if (!strcmp(res->name, "start"))
1264 		start_port(res->value);
1265 	else if (!strcmp(res->name, "stop"))
1266 		stop_port(res->value);
1267 	else if (!strcmp(res->name, "close"))
1268 		close_port(res->value);
1269 	else if (!strcmp(res->name, "reset"))
1270 		reset_port(res->value);
1271 	else
1272 		fprintf(stderr, "Unknown parameter\n");
1273 }
1274 
1275 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1276 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1277 							keyword, "port");
1278 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1279 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1280 						name, "start#stop#close#reset");
1281 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1282 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1283 							value, RTE_UINT8);
1284 
1285 cmdline_parse_inst_t cmd_operate_specific_port = {
1286 	.f = cmd_operate_specific_port_parsed,
1287 	.data = NULL,
1288 	.help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1289 	.tokens = {
1290 		(void *)&cmd_operate_specific_port_cmd,
1291 		(void *)&cmd_operate_specific_port_port,
1292 		(void *)&cmd_operate_specific_port_id,
1293 		NULL,
1294 	},
1295 };
1296 
1297 /* *** enable port setup (after attach) via iterator or event *** */
1298 struct cmd_set_port_setup_on_result {
1299 	cmdline_fixed_string_t set;
1300 	cmdline_fixed_string_t port;
1301 	cmdline_fixed_string_t setup;
1302 	cmdline_fixed_string_t on;
1303 	cmdline_fixed_string_t mode;
1304 };
1305 
1306 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1307 				__rte_unused struct cmdline *cl,
1308 				__rte_unused void *data)
1309 {
1310 	struct cmd_set_port_setup_on_result *res = parsed_result;
1311 
1312 	if (strcmp(res->mode, "event") == 0)
1313 		setup_on_probe_event = true;
1314 	else if (strcmp(res->mode, "iterator") == 0)
1315 		setup_on_probe_event = false;
1316 	else
1317 		fprintf(stderr, "Unknown mode\n");
1318 }
1319 
1320 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1321 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1322 			set, "set");
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1324 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1325 			port, "port");
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1327 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1328 			setup, "setup");
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1330 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1331 			on, "on");
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1333 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 			mode, "iterator#event");
1335 
1336 cmdline_parse_inst_t cmd_set_port_setup_on = {
1337 	.f = cmd_set_port_setup_on_parsed,
1338 	.data = NULL,
1339 	.help_str = "set port setup on iterator|event",
1340 	.tokens = {
1341 		(void *)&cmd_set_port_setup_on_set,
1342 		(void *)&cmd_set_port_setup_on_port,
1343 		(void *)&cmd_set_port_setup_on_setup,
1344 		(void *)&cmd_set_port_setup_on_on,
1345 		(void *)&cmd_set_port_setup_on_mode,
1346 		NULL,
1347 	},
1348 };
1349 
1350 /* *** attach a specified port *** */
1351 struct cmd_operate_attach_port_result {
1352 	cmdline_fixed_string_t port;
1353 	cmdline_fixed_string_t keyword;
1354 	cmdline_multi_string_t identifier;
1355 };
1356 
1357 static void cmd_operate_attach_port_parsed(void *parsed_result,
1358 				__rte_unused struct cmdline *cl,
1359 				__rte_unused void *data)
1360 {
1361 	struct cmd_operate_attach_port_result *res = parsed_result;
1362 
1363 	if (!strcmp(res->keyword, "attach"))
1364 		attach_port(res->identifier);
1365 	else
1366 		fprintf(stderr, "Unknown parameter\n");
1367 }
1368 
1369 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1370 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1371 			port, "port");
1372 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1373 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1374 			keyword, "attach");
1375 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1376 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 			identifier, TOKEN_STRING_MULTI);
1378 
1379 cmdline_parse_inst_t cmd_operate_attach_port = {
1380 	.f = cmd_operate_attach_port_parsed,
1381 	.data = NULL,
1382 	.help_str = "port attach <identifier>: "
1383 		"(identifier: pci address or virtual dev name)",
1384 	.tokens = {
1385 		(void *)&cmd_operate_attach_port_port,
1386 		(void *)&cmd_operate_attach_port_keyword,
1387 		(void *)&cmd_operate_attach_port_identifier,
1388 		NULL,
1389 	},
1390 };
1391 
1392 /* *** detach a specified port *** */
1393 struct cmd_operate_detach_port_result {
1394 	cmdline_fixed_string_t port;
1395 	cmdline_fixed_string_t keyword;
1396 	portid_t port_id;
1397 };
1398 
1399 static void cmd_operate_detach_port_parsed(void *parsed_result,
1400 				__rte_unused struct cmdline *cl,
1401 				__rte_unused void *data)
1402 {
1403 	struct cmd_operate_detach_port_result *res = parsed_result;
1404 
1405 	if (!strcmp(res->keyword, "detach")) {
1406 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1407 		detach_port_device(res->port_id);
1408 	} else {
1409 		fprintf(stderr, "Unknown parameter\n");
1410 	}
1411 }
1412 
1413 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1414 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1415 			port, "port");
1416 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1417 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1418 			keyword, "detach");
1419 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1420 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1421 			port_id, RTE_UINT16);
1422 
1423 cmdline_parse_inst_t cmd_operate_detach_port = {
1424 	.f = cmd_operate_detach_port_parsed,
1425 	.data = NULL,
1426 	.help_str = "port detach <port_id>",
1427 	.tokens = {
1428 		(void *)&cmd_operate_detach_port_port,
1429 		(void *)&cmd_operate_detach_port_keyword,
1430 		(void *)&cmd_operate_detach_port_port_id,
1431 		NULL,
1432 	},
1433 };
1434 
1435 /* *** detach device by identifier *** */
1436 struct cmd_operate_detach_device_result {
1437 	cmdline_fixed_string_t device;
1438 	cmdline_fixed_string_t keyword;
1439 	cmdline_fixed_string_t identifier;
1440 };
1441 
1442 static void cmd_operate_detach_device_parsed(void *parsed_result,
1443 				__rte_unused struct cmdline *cl,
1444 				__rte_unused void *data)
1445 {
1446 	struct cmd_operate_detach_device_result *res = parsed_result;
1447 
1448 	if (!strcmp(res->keyword, "detach"))
1449 		detach_devargs(res->identifier);
1450 	else
1451 		fprintf(stderr, "Unknown parameter\n");
1452 }
1453 
1454 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1455 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1456 			device, "device");
1457 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1458 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1459 			keyword, "detach");
1460 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1461 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1462 			identifier, NULL);
1463 
1464 cmdline_parse_inst_t cmd_operate_detach_device = {
1465 	.f = cmd_operate_detach_device_parsed,
1466 	.data = NULL,
1467 	.help_str = "device detach <identifier>:"
1468 		"(identifier: pci address or virtual dev name)",
1469 	.tokens = {
1470 		(void *)&cmd_operate_detach_device_device,
1471 		(void *)&cmd_operate_detach_device_keyword,
1472 		(void *)&cmd_operate_detach_device_identifier,
1473 		NULL,
1474 	},
1475 };
1476 /* *** configure speed for all ports *** */
1477 struct cmd_config_speed_all {
1478 	cmdline_fixed_string_t port;
1479 	cmdline_fixed_string_t keyword;
1480 	cmdline_fixed_string_t all;
1481 	cmdline_fixed_string_t item1;
1482 	cmdline_fixed_string_t item2;
1483 	cmdline_fixed_string_t value1;
1484 	cmdline_fixed_string_t value2;
1485 };
1486 
1487 static int
1488 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1489 {
1490 
1491 	int duplex;
1492 
1493 	if (!strcmp(duplexstr, "half")) {
1494 		duplex = RTE_ETH_LINK_HALF_DUPLEX;
1495 	} else if (!strcmp(duplexstr, "full")) {
1496 		duplex = RTE_ETH_LINK_FULL_DUPLEX;
1497 	} else if (!strcmp(duplexstr, "auto")) {
1498 		duplex = RTE_ETH_LINK_FULL_DUPLEX;
1499 	} else {
1500 		fprintf(stderr, "Unknown duplex parameter\n");
1501 		return -1;
1502 	}
1503 
1504 	if (!strcmp(speedstr, "10")) {
1505 		*speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1506 				RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1507 	} else if (!strcmp(speedstr, "100")) {
1508 		*speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1509 				RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1510 	} else {
1511 		if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1512 			fprintf(stderr, "Invalid speed/duplex parameters\n");
1513 			return -1;
1514 		}
1515 		if (!strcmp(speedstr, "1000")) {
1516 			*speed = RTE_ETH_LINK_SPEED_1G;
1517 		} else if (!strcmp(speedstr, "10000")) {
1518 			*speed = RTE_ETH_LINK_SPEED_10G;
1519 		} else if (!strcmp(speedstr, "25000")) {
1520 			*speed = RTE_ETH_LINK_SPEED_25G;
1521 		} else if (!strcmp(speedstr, "40000")) {
1522 			*speed = RTE_ETH_LINK_SPEED_40G;
1523 		} else if (!strcmp(speedstr, "50000")) {
1524 			*speed = RTE_ETH_LINK_SPEED_50G;
1525 		} else if (!strcmp(speedstr, "100000")) {
1526 			*speed = RTE_ETH_LINK_SPEED_100G;
1527 		} else if (!strcmp(speedstr, "200000")) {
1528 			*speed = RTE_ETH_LINK_SPEED_200G;
1529 		} else if (!strcmp(speedstr, "auto")) {
1530 			*speed = RTE_ETH_LINK_SPEED_AUTONEG;
1531 		} else {
1532 			fprintf(stderr, "Unknown speed parameter\n");
1533 			return -1;
1534 		}
1535 	}
1536 
1537 	if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1538 		*speed |= RTE_ETH_LINK_SPEED_FIXED;
1539 
1540 	return 0;
1541 }
1542 
1543 static void
1544 cmd_config_speed_all_parsed(void *parsed_result,
1545 			__rte_unused struct cmdline *cl,
1546 			__rte_unused void *data)
1547 {
1548 	struct cmd_config_speed_all *res = parsed_result;
1549 	uint32_t link_speed;
1550 	portid_t pid;
1551 
1552 	if (!all_ports_stopped()) {
1553 		fprintf(stderr, "Please stop all ports first\n");
1554 		return;
1555 	}
1556 
1557 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1558 			&link_speed) < 0)
1559 		return;
1560 
1561 	RTE_ETH_FOREACH_DEV(pid) {
1562 		ports[pid].dev_conf.link_speeds = link_speed;
1563 	}
1564 
1565 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1566 }
1567 
1568 cmdline_parse_token_string_t cmd_config_speed_all_port =
1569 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1570 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1571 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1572 							"config");
1573 cmdline_parse_token_string_t cmd_config_speed_all_all =
1574 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1575 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1576 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1577 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1578 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1579 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1580 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1581 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1582 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1583 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1584 						"half#full#auto");
1585 
1586 cmdline_parse_inst_t cmd_config_speed_all = {
1587 	.f = cmd_config_speed_all_parsed,
1588 	.data = NULL,
1589 	.help_str = "port config all speed "
1590 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1591 							"half|full|auto",
1592 	.tokens = {
1593 		(void *)&cmd_config_speed_all_port,
1594 		(void *)&cmd_config_speed_all_keyword,
1595 		(void *)&cmd_config_speed_all_all,
1596 		(void *)&cmd_config_speed_all_item1,
1597 		(void *)&cmd_config_speed_all_value1,
1598 		(void *)&cmd_config_speed_all_item2,
1599 		(void *)&cmd_config_speed_all_value2,
1600 		NULL,
1601 	},
1602 };
1603 
1604 /* *** configure speed for specific port *** */
1605 struct cmd_config_speed_specific {
1606 	cmdline_fixed_string_t port;
1607 	cmdline_fixed_string_t keyword;
1608 	portid_t id;
1609 	cmdline_fixed_string_t item1;
1610 	cmdline_fixed_string_t item2;
1611 	cmdline_fixed_string_t value1;
1612 	cmdline_fixed_string_t value2;
1613 };
1614 
1615 static void
1616 cmd_config_speed_specific_parsed(void *parsed_result,
1617 				__rte_unused struct cmdline *cl,
1618 				__rte_unused void *data)
1619 {
1620 	struct cmd_config_speed_specific *res = parsed_result;
1621 	uint32_t link_speed;
1622 
1623 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1624 		return;
1625 
1626 	if (!port_is_stopped(res->id)) {
1627 		fprintf(stderr, "Please stop port %d first\n", res->id);
1628 		return;
1629 	}
1630 
1631 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1632 			&link_speed) < 0)
1633 		return;
1634 
1635 	ports[res->id].dev_conf.link_speeds = link_speed;
1636 
1637 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1638 }
1639 
1640 
1641 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1642 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1643 								"port");
1644 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1645 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1646 								"config");
1647 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1648 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1649 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1650 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1651 								"speed");
1652 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1653 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1654 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1655 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1656 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1657 								"duplex");
1658 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1659 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1660 							"half#full#auto");
1661 
1662 cmdline_parse_inst_t cmd_config_speed_specific = {
1663 	.f = cmd_config_speed_specific_parsed,
1664 	.data = NULL,
1665 	.help_str = "port config <port_id> speed "
1666 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1667 							"half|full|auto",
1668 	.tokens = {
1669 		(void *)&cmd_config_speed_specific_port,
1670 		(void *)&cmd_config_speed_specific_keyword,
1671 		(void *)&cmd_config_speed_specific_id,
1672 		(void *)&cmd_config_speed_specific_item1,
1673 		(void *)&cmd_config_speed_specific_value1,
1674 		(void *)&cmd_config_speed_specific_item2,
1675 		(void *)&cmd_config_speed_specific_value2,
1676 		NULL,
1677 	},
1678 };
1679 
1680 /* *** configure loopback for all ports *** */
1681 struct cmd_config_loopback_all {
1682 	cmdline_fixed_string_t port;
1683 	cmdline_fixed_string_t keyword;
1684 	cmdline_fixed_string_t all;
1685 	cmdline_fixed_string_t item;
1686 	uint32_t mode;
1687 };
1688 
1689 static void
1690 cmd_config_loopback_all_parsed(void *parsed_result,
1691 			__rte_unused struct cmdline *cl,
1692 			__rte_unused void *data)
1693 {
1694 	struct cmd_config_loopback_all *res = parsed_result;
1695 	portid_t pid;
1696 
1697 	if (!all_ports_stopped()) {
1698 		fprintf(stderr, "Please stop all ports first\n");
1699 		return;
1700 	}
1701 
1702 	RTE_ETH_FOREACH_DEV(pid) {
1703 		ports[pid].dev_conf.lpbk_mode = res->mode;
1704 	}
1705 
1706 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1707 }
1708 
1709 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1710 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1711 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1712 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1713 							"config");
1714 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1715 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1716 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1717 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1718 							"loopback");
1719 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1720 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1721 
1722 cmdline_parse_inst_t cmd_config_loopback_all = {
1723 	.f = cmd_config_loopback_all_parsed,
1724 	.data = NULL,
1725 	.help_str = "port config all loopback <mode>",
1726 	.tokens = {
1727 		(void *)&cmd_config_loopback_all_port,
1728 		(void *)&cmd_config_loopback_all_keyword,
1729 		(void *)&cmd_config_loopback_all_all,
1730 		(void *)&cmd_config_loopback_all_item,
1731 		(void *)&cmd_config_loopback_all_mode,
1732 		NULL,
1733 	},
1734 };
1735 
1736 /* *** configure loopback for specific port *** */
1737 struct cmd_config_loopback_specific {
1738 	cmdline_fixed_string_t port;
1739 	cmdline_fixed_string_t keyword;
1740 	uint16_t port_id;
1741 	cmdline_fixed_string_t item;
1742 	uint32_t mode;
1743 };
1744 
1745 static void
1746 cmd_config_loopback_specific_parsed(void *parsed_result,
1747 				__rte_unused struct cmdline *cl,
1748 				__rte_unused void *data)
1749 {
1750 	struct cmd_config_loopback_specific *res = parsed_result;
1751 
1752 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1753 		return;
1754 
1755 	if (!port_is_stopped(res->port_id)) {
1756 		fprintf(stderr, "Please stop port %u first\n", res->port_id);
1757 		return;
1758 	}
1759 
1760 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1761 
1762 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1763 }
1764 
1765 
1766 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1767 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1768 								"port");
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1770 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1771 								"config");
1772 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1773 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1774 								RTE_UINT16);
1775 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1776 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1777 								"loopback");
1778 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1779 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1780 			      RTE_UINT32);
1781 
1782 cmdline_parse_inst_t cmd_config_loopback_specific = {
1783 	.f = cmd_config_loopback_specific_parsed,
1784 	.data = NULL,
1785 	.help_str = "port config <port_id> loopback <mode>",
1786 	.tokens = {
1787 		(void *)&cmd_config_loopback_specific_port,
1788 		(void *)&cmd_config_loopback_specific_keyword,
1789 		(void *)&cmd_config_loopback_specific_id,
1790 		(void *)&cmd_config_loopback_specific_item,
1791 		(void *)&cmd_config_loopback_specific_mode,
1792 		NULL,
1793 	},
1794 };
1795 
1796 /* *** configure txq/rxq, txd/rxd *** */
1797 struct cmd_config_rx_tx {
1798 	cmdline_fixed_string_t port;
1799 	cmdline_fixed_string_t keyword;
1800 	cmdline_fixed_string_t all;
1801 	cmdline_fixed_string_t name;
1802 	uint16_t value;
1803 };
1804 
1805 static void
1806 cmd_config_rx_tx_parsed(void *parsed_result,
1807 			__rte_unused struct cmdline *cl,
1808 			__rte_unused void *data)
1809 {
1810 	struct cmd_config_rx_tx *res = parsed_result;
1811 
1812 	if (!all_ports_stopped()) {
1813 		fprintf(stderr, "Please stop all ports first\n");
1814 		return;
1815 	}
1816 	if (!strcmp(res->name, "rxq")) {
1817 		if (!res->value && !nb_txq) {
1818 			fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1819 			return;
1820 		}
1821 		if (check_nb_rxq(res->value) != 0)
1822 			return;
1823 		nb_rxq = res->value;
1824 	}
1825 	else if (!strcmp(res->name, "txq")) {
1826 		if (!res->value && !nb_rxq) {
1827 			fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1828 			return;
1829 		}
1830 		if (check_nb_txq(res->value) != 0)
1831 			return;
1832 		nb_txq = res->value;
1833 	}
1834 	else if (!strcmp(res->name, "rxd")) {
1835 		if (check_nb_rxd(res->value) != 0)
1836 			return;
1837 		nb_rxd = res->value;
1838 	} else if (!strcmp(res->name, "txd")) {
1839 		if (check_nb_txd(res->value) != 0)
1840 			return;
1841 
1842 		nb_txd = res->value;
1843 	} else {
1844 		fprintf(stderr, "Unknown parameter\n");
1845 		return;
1846 	}
1847 
1848 	fwd_config_setup();
1849 
1850 	init_port_config();
1851 
1852 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1853 }
1854 
1855 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1856 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1857 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1858 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1859 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1860 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1861 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1862 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1863 						"rxq#txq#rxd#txd");
1864 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1865 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1866 
1867 cmdline_parse_inst_t cmd_config_rx_tx = {
1868 	.f = cmd_config_rx_tx_parsed,
1869 	.data = NULL,
1870 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1871 	.tokens = {
1872 		(void *)&cmd_config_rx_tx_port,
1873 		(void *)&cmd_config_rx_tx_keyword,
1874 		(void *)&cmd_config_rx_tx_all,
1875 		(void *)&cmd_config_rx_tx_name,
1876 		(void *)&cmd_config_rx_tx_value,
1877 		NULL,
1878 	},
1879 };
1880 
1881 /* *** config max packet length *** */
1882 struct cmd_config_max_pkt_len_result {
1883 	cmdline_fixed_string_t port;
1884 	cmdline_fixed_string_t keyword;
1885 	cmdline_fixed_string_t all;
1886 	cmdline_fixed_string_t name;
1887 	uint32_t value;
1888 };
1889 
1890 static void
1891 cmd_config_max_pkt_len_parsed(void *parsed_result,
1892 				__rte_unused struct cmdline *cl,
1893 				__rte_unused void *data)
1894 {
1895 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1896 	portid_t port_id;
1897 	int ret;
1898 
1899 	if (strcmp(res->name, "max-pkt-len") != 0) {
1900 		printf("Unknown parameter\n");
1901 		return;
1902 	}
1903 
1904 	if (!all_ports_stopped()) {
1905 		fprintf(stderr, "Please stop all ports first\n");
1906 		return;
1907 	}
1908 
1909 	RTE_ETH_FOREACH_DEV(port_id) {
1910 		struct rte_port *port = &ports[port_id];
1911 
1912 		if (res->value < RTE_ETHER_MIN_LEN) {
1913 			fprintf(stderr,
1914 				"max-pkt-len can not be less than %d\n",
1915 				RTE_ETHER_MIN_LEN);
1916 			return;
1917 		}
1918 
1919 		ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1920 		if (ret != 0) {
1921 			fprintf(stderr,
1922 				"rte_eth_dev_info_get() failed for port %u\n",
1923 				port_id);
1924 			return;
1925 		}
1926 
1927 		update_mtu_from_frame_size(port_id, res->value);
1928 	}
1929 
1930 	init_port_config();
1931 
1932 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1933 }
1934 
1935 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1936 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1937 								"port");
1938 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1939 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1940 								"config");
1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1942 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1943 								"all");
1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1945 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1946 								"max-pkt-len");
1947 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1948 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1949 								RTE_UINT32);
1950 
1951 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1952 	.f = cmd_config_max_pkt_len_parsed,
1953 	.data = NULL,
1954 	.help_str = "port config all max-pkt-len <value>",
1955 	.tokens = {
1956 		(void *)&cmd_config_max_pkt_len_port,
1957 		(void *)&cmd_config_max_pkt_len_keyword,
1958 		(void *)&cmd_config_max_pkt_len_all,
1959 		(void *)&cmd_config_max_pkt_len_name,
1960 		(void *)&cmd_config_max_pkt_len_value,
1961 		NULL,
1962 	},
1963 };
1964 
1965 /* *** config max LRO aggregated packet size *** */
1966 struct cmd_config_max_lro_pkt_size_result {
1967 	cmdline_fixed_string_t port;
1968 	cmdline_fixed_string_t keyword;
1969 	cmdline_fixed_string_t all;
1970 	cmdline_fixed_string_t name;
1971 	uint32_t value;
1972 };
1973 
1974 static void
1975 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1976 				__rte_unused struct cmdline *cl,
1977 				__rte_unused void *data)
1978 {
1979 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1980 	portid_t pid;
1981 
1982 	if (!all_ports_stopped()) {
1983 		fprintf(stderr, "Please stop all ports first\n");
1984 		return;
1985 	}
1986 
1987 	RTE_ETH_FOREACH_DEV(pid) {
1988 		struct rte_port *port = &ports[pid];
1989 
1990 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1991 			if (res->value ==
1992 					port->dev_conf.rxmode.max_lro_pkt_size)
1993 				return;
1994 
1995 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1996 		} else {
1997 			fprintf(stderr, "Unknown parameter\n");
1998 			return;
1999 		}
2000 	}
2001 
2002 	init_port_config();
2003 
2004 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2005 }
2006 
2007 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2008 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2009 				 port, "port");
2010 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2011 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2012 				 keyword, "config");
2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2014 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2015 				 all, "all");
2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2017 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 				 name, "max-lro-pkt-size");
2019 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2020 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2021 			      value, RTE_UINT32);
2022 
2023 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2024 	.f = cmd_config_max_lro_pkt_size_parsed,
2025 	.data = NULL,
2026 	.help_str = "port config all max-lro-pkt-size <value>",
2027 	.tokens = {
2028 		(void *)&cmd_config_max_lro_pkt_size_port,
2029 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2030 		(void *)&cmd_config_max_lro_pkt_size_all,
2031 		(void *)&cmd_config_max_lro_pkt_size_name,
2032 		(void *)&cmd_config_max_lro_pkt_size_value,
2033 		NULL,
2034 	},
2035 };
2036 
2037 /* *** configure port MTU *** */
2038 struct cmd_config_mtu_result {
2039 	cmdline_fixed_string_t port;
2040 	cmdline_fixed_string_t keyword;
2041 	cmdline_fixed_string_t mtu;
2042 	portid_t port_id;
2043 	uint16_t value;
2044 };
2045 
2046 static void
2047 cmd_config_mtu_parsed(void *parsed_result,
2048 		      __rte_unused struct cmdline *cl,
2049 		      __rte_unused void *data)
2050 {
2051 	struct cmd_config_mtu_result *res = parsed_result;
2052 
2053 	if (res->value < RTE_ETHER_MIN_LEN) {
2054 		fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2055 		return;
2056 	}
2057 	port_mtu_set(res->port_id, res->value);
2058 }
2059 
2060 cmdline_parse_token_string_t cmd_config_mtu_port =
2061 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2062 				 "port");
2063 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2064 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2065 				 "config");
2066 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2067 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2068 				 "mtu");
2069 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2070 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2071 				 RTE_UINT16);
2072 cmdline_parse_token_num_t cmd_config_mtu_value =
2073 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2074 				 RTE_UINT16);
2075 
2076 cmdline_parse_inst_t cmd_config_mtu = {
2077 	.f = cmd_config_mtu_parsed,
2078 	.data = NULL,
2079 	.help_str = "port config mtu <port_id> <value>",
2080 	.tokens = {
2081 		(void *)&cmd_config_mtu_port,
2082 		(void *)&cmd_config_mtu_keyword,
2083 		(void *)&cmd_config_mtu_mtu,
2084 		(void *)&cmd_config_mtu_port_id,
2085 		(void *)&cmd_config_mtu_value,
2086 		NULL,
2087 	},
2088 };
2089 
2090 /* *** configure rx mode *** */
2091 struct cmd_config_rx_mode_flag {
2092 	cmdline_fixed_string_t port;
2093 	cmdline_fixed_string_t keyword;
2094 	cmdline_fixed_string_t all;
2095 	cmdline_fixed_string_t name;
2096 	cmdline_fixed_string_t value;
2097 };
2098 
2099 static void
2100 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2101 				__rte_unused struct cmdline *cl,
2102 				__rte_unused void *data)
2103 {
2104 	struct cmd_config_rx_mode_flag *res = parsed_result;
2105 
2106 	if (!all_ports_stopped()) {
2107 		fprintf(stderr, "Please stop all ports first\n");
2108 		return;
2109 	}
2110 
2111 	if (!strcmp(res->name, "drop-en")) {
2112 		if (!strcmp(res->value, "on"))
2113 			rx_drop_en = 1;
2114 		else if (!strcmp(res->value, "off"))
2115 			rx_drop_en = 0;
2116 		else {
2117 			fprintf(stderr, "Unknown parameter\n");
2118 			return;
2119 		}
2120 	} else {
2121 		fprintf(stderr, "Unknown parameter\n");
2122 		return;
2123 	}
2124 
2125 	init_port_config();
2126 
2127 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2128 }
2129 
2130 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2131 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2132 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2133 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2134 								"config");
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2136 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2138 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2139 					"drop-en");
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2141 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2142 							"on#off");
2143 
2144 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2145 	.f = cmd_config_rx_mode_flag_parsed,
2146 	.data = NULL,
2147 	.help_str = "port config all drop-en on|off",
2148 	.tokens = {
2149 		(void *)&cmd_config_rx_mode_flag_port,
2150 		(void *)&cmd_config_rx_mode_flag_keyword,
2151 		(void *)&cmd_config_rx_mode_flag_all,
2152 		(void *)&cmd_config_rx_mode_flag_name,
2153 		(void *)&cmd_config_rx_mode_flag_value,
2154 		NULL,
2155 	},
2156 };
2157 
2158 /* *** configure rss *** */
2159 struct cmd_config_rss {
2160 	cmdline_fixed_string_t port;
2161 	cmdline_fixed_string_t keyword;
2162 	cmdline_fixed_string_t all;
2163 	cmdline_fixed_string_t name;
2164 	cmdline_fixed_string_t value;
2165 };
2166 
2167 static void
2168 cmd_config_rss_parsed(void *parsed_result,
2169 			__rte_unused struct cmdline *cl,
2170 			__rte_unused void *data)
2171 {
2172 	struct cmd_config_rss *res = parsed_result;
2173 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2174 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2175 	int use_default = 0;
2176 	int all_updated = 1;
2177 	int diag;
2178 	uint16_t i;
2179 	int ret;
2180 
2181 	if (!strcmp(res->value, "all"))
2182 		rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2183 			RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2184 			RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2185 			RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2186 			RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2;
2187 	else if (!strcmp(res->value, "eth"))
2188 		rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2189 	else if (!strcmp(res->value, "vlan"))
2190 		rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2191 	else if (!strcmp(res->value, "ip"))
2192 		rss_conf.rss_hf = RTE_ETH_RSS_IP;
2193 	else if (!strcmp(res->value, "udp"))
2194 		rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2195 	else if (!strcmp(res->value, "tcp"))
2196 		rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2197 	else if (!strcmp(res->value, "sctp"))
2198 		rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2199 	else if (!strcmp(res->value, "ether"))
2200 		rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2201 	else if (!strcmp(res->value, "port"))
2202 		rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2203 	else if (!strcmp(res->value, "vxlan"))
2204 		rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2205 	else if (!strcmp(res->value, "geneve"))
2206 		rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2207 	else if (!strcmp(res->value, "nvgre"))
2208 		rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2209 	else if (!strcmp(res->value, "l3-pre32"))
2210 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2211 	else if (!strcmp(res->value, "l3-pre40"))
2212 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2213 	else if (!strcmp(res->value, "l3-pre48"))
2214 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2215 	else if (!strcmp(res->value, "l3-pre56"))
2216 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2217 	else if (!strcmp(res->value, "l3-pre64"))
2218 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2219 	else if (!strcmp(res->value, "l3-pre96"))
2220 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2221 	else if (!strcmp(res->value, "l3-src-only"))
2222 		rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2223 	else if (!strcmp(res->value, "l3-dst-only"))
2224 		rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2225 	else if (!strcmp(res->value, "l4-src-only"))
2226 		rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2227 	else if (!strcmp(res->value, "l4-dst-only"))
2228 		rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2229 	else if (!strcmp(res->value, "l2-src-only"))
2230 		rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2231 	else if (!strcmp(res->value, "l2-dst-only"))
2232 		rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2233 	else if (!strcmp(res->value, "l2tpv3"))
2234 		rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2235 	else if (!strcmp(res->value, "esp"))
2236 		rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2237 	else if (!strcmp(res->value, "ah"))
2238 		rss_conf.rss_hf = RTE_ETH_RSS_AH;
2239 	else if (!strcmp(res->value, "pfcp"))
2240 		rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2241 	else if (!strcmp(res->value, "pppoe"))
2242 		rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2243 	else if (!strcmp(res->value, "gtpu"))
2244 		rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2245 	else if (!strcmp(res->value, "ecpri"))
2246 		rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2247 	else if (!strcmp(res->value, "mpls"))
2248 		rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2249 	else if (!strcmp(res->value, "ipv4-chksum"))
2250 		rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2251 	else if (!strcmp(res->value, "l2tpv2"))
2252 		rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2;
2253 	else if (!strcmp(res->value, "none"))
2254 		rss_conf.rss_hf = 0;
2255 	else if (!strcmp(res->value, "level-default")) {
2256 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2257 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2258 	} else if (!strcmp(res->value, "level-outer")) {
2259 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2260 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2261 	} else if (!strcmp(res->value, "level-inner")) {
2262 		rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2263 		rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2264 	} else if (!strcmp(res->value, "default"))
2265 		use_default = 1;
2266 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2267 						atoi(res->value) < 64)
2268 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2269 	else {
2270 		fprintf(stderr, "Unknown parameter\n");
2271 		return;
2272 	}
2273 	rss_conf.rss_key = NULL;
2274 	/* Update global configuration for RSS types. */
2275 	RTE_ETH_FOREACH_DEV(i) {
2276 		struct rte_eth_rss_conf local_rss_conf;
2277 
2278 		ret = eth_dev_info_get_print_err(i, &dev_info);
2279 		if (ret != 0)
2280 			return;
2281 
2282 		if (use_default)
2283 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2284 
2285 		local_rss_conf = rss_conf;
2286 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2287 			dev_info.flow_type_rss_offloads;
2288 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2289 			printf("Port %u modified RSS hash function based on hardware support,"
2290 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2291 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2292 		}
2293 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2294 		if (diag < 0) {
2295 			all_updated = 0;
2296 			fprintf(stderr,
2297 				"Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2298 				i, -diag, strerror(-diag));
2299 		}
2300 	}
2301 	if (all_updated && !use_default) {
2302 		rss_hf = rss_conf.rss_hf;
2303 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2304 	}
2305 }
2306 
2307 cmdline_parse_token_string_t cmd_config_rss_port =
2308 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2309 cmdline_parse_token_string_t cmd_config_rss_keyword =
2310 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2311 cmdline_parse_token_string_t cmd_config_rss_all =
2312 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2313 cmdline_parse_token_string_t cmd_config_rss_name =
2314 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2315 cmdline_parse_token_string_t cmd_config_rss_value =
2316 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2317 
2318 cmdline_parse_inst_t cmd_config_rss = {
2319 	.f = cmd_config_rss_parsed,
2320 	.data = NULL,
2321 	.help_str = "port config all rss "
2322 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2323 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|"
2324 		"none|level-default|level-outer|level-inner|<flowtype_id>",
2325 	.tokens = {
2326 		(void *)&cmd_config_rss_port,
2327 		(void *)&cmd_config_rss_keyword,
2328 		(void *)&cmd_config_rss_all,
2329 		(void *)&cmd_config_rss_name,
2330 		(void *)&cmd_config_rss_value,
2331 		NULL,
2332 	},
2333 };
2334 
2335 /* *** configure rss hash key *** */
2336 struct cmd_config_rss_hash_key {
2337 	cmdline_fixed_string_t port;
2338 	cmdline_fixed_string_t config;
2339 	portid_t port_id;
2340 	cmdline_fixed_string_t rss_hash_key;
2341 	cmdline_fixed_string_t rss_type;
2342 	cmdline_fixed_string_t key;
2343 };
2344 
2345 static uint8_t
2346 hexa_digit_to_value(char hexa_digit)
2347 {
2348 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2349 		return (uint8_t) (hexa_digit - '0');
2350 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2351 		return (uint8_t) ((hexa_digit - 'a') + 10);
2352 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2353 		return (uint8_t) ((hexa_digit - 'A') + 10);
2354 	/* Invalid hexa digit */
2355 	return 0xFF;
2356 }
2357 
2358 static uint8_t
2359 parse_and_check_key_hexa_digit(char *key, int idx)
2360 {
2361 	uint8_t hexa_v;
2362 
2363 	hexa_v = hexa_digit_to_value(key[idx]);
2364 	if (hexa_v == 0xFF)
2365 		fprintf(stderr,
2366 			"invalid key: character %c at position %d is not a valid hexa digit\n",
2367 			key[idx], idx);
2368 	return hexa_v;
2369 }
2370 
2371 static void
2372 cmd_config_rss_hash_key_parsed(void *parsed_result,
2373 			       __rte_unused struct cmdline *cl,
2374 			       __rte_unused void *data)
2375 {
2376 	struct cmd_config_rss_hash_key *res = parsed_result;
2377 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2378 	uint8_t xdgt0;
2379 	uint8_t xdgt1;
2380 	int i;
2381 	struct rte_eth_dev_info dev_info;
2382 	uint8_t hash_key_size;
2383 	uint32_t key_len;
2384 	int ret;
2385 
2386 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2387 	if (ret != 0)
2388 		return;
2389 
2390 	if (dev_info.hash_key_size > 0 &&
2391 			dev_info.hash_key_size <= sizeof(hash_key))
2392 		hash_key_size = dev_info.hash_key_size;
2393 	else {
2394 		fprintf(stderr,
2395 			"dev_info did not provide a valid hash key size\n");
2396 		return;
2397 	}
2398 	/* Check the length of the RSS hash key */
2399 	key_len = strlen(res->key);
2400 	if (key_len != (hash_key_size * 2)) {
2401 		fprintf(stderr,
2402 			"key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2403 			(int)key_len, hash_key_size * 2);
2404 		return;
2405 	}
2406 	/* Translate RSS hash key into binary representation */
2407 	for (i = 0; i < hash_key_size; i++) {
2408 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2409 		if (xdgt0 == 0xFF)
2410 			return;
2411 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2412 		if (xdgt1 == 0xFF)
2413 			return;
2414 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2415 	}
2416 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2417 			hash_key_size);
2418 }
2419 
2420 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2421 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2422 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2423 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2424 				 "config");
2425 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2426 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2427 				 RTE_UINT16);
2428 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2429 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2430 				 rss_hash_key, "rss-hash-key");
2431 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2432 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2433 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2434 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2435 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2436 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2437 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2438 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2439 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2440 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2441 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2442 
2443 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2444 	.f = cmd_config_rss_hash_key_parsed,
2445 	.data = NULL,
2446 	.help_str = "port config <port_id> rss-hash-key "
2447 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2448 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2449 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2450 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2451 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2452 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2453 		"<string of hex digits (variable length, NIC dependent)>",
2454 	.tokens = {
2455 		(void *)&cmd_config_rss_hash_key_port,
2456 		(void *)&cmd_config_rss_hash_key_config,
2457 		(void *)&cmd_config_rss_hash_key_port_id,
2458 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2459 		(void *)&cmd_config_rss_hash_key_rss_type,
2460 		(void *)&cmd_config_rss_hash_key_value,
2461 		NULL,
2462 	},
2463 };
2464 
2465 /* *** cleanup txq mbufs *** */
2466 struct cmd_cleanup_txq_mbufs_result {
2467 	cmdline_fixed_string_t port;
2468 	cmdline_fixed_string_t keyword;
2469 	cmdline_fixed_string_t name;
2470 	uint16_t port_id;
2471 	uint16_t queue_id;
2472 	uint32_t free_cnt;
2473 };
2474 
2475 static void
2476 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2477 			     __rte_unused struct cmdline *cl,
2478 			     __rte_unused void *data)
2479 {
2480 	struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2481 	uint16_t port_id = res->port_id;
2482 	uint16_t queue_id = res->queue_id;
2483 	uint32_t free_cnt = res->free_cnt;
2484 	struct rte_eth_txq_info qinfo;
2485 	int ret;
2486 
2487 	if (test_done == 0) {
2488 		fprintf(stderr, "Please stop forwarding first\n");
2489 		return;
2490 	}
2491 
2492 	if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2493 		fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2494 			port_id, queue_id);
2495 		return;
2496 	}
2497 
2498 	if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2499 		fprintf(stderr, "Tx queue %u not started\n", queue_id);
2500 		return;
2501 	}
2502 
2503 	ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2504 	if (ret < 0) {
2505 		fprintf(stderr,
2506 			"Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2507 			port_id, queue_id, strerror(-ret), ret);
2508 		return;
2509 	}
2510 
2511 	printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2512 	       port_id, queue_id, ret);
2513 }
2514 
2515 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2516 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2517 				 "port");
2518 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2519 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2520 				 "cleanup");
2521 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2522 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2523 			      RTE_UINT16);
2524 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2525 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2526 				 "txq");
2527 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2528 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2529 			      RTE_UINT16);
2530 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2531 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2532 			      RTE_UINT32);
2533 
2534 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2535 	.f = cmd_cleanup_txq_mbufs_parsed,
2536 	.data = NULL,
2537 	.help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2538 	.tokens = {
2539 		(void *)&cmd_cleanup_txq_mbufs_port,
2540 		(void *)&cmd_cleanup_txq_mbufs_cleanup,
2541 		(void *)&cmd_cleanup_txq_mbufs_port_id,
2542 		(void *)&cmd_cleanup_txq_mbufs_txq,
2543 		(void *)&cmd_cleanup_txq_mbufs_queue_id,
2544 		(void *)&cmd_cleanup_txq_mbufs_free_cnt,
2545 		NULL,
2546 	},
2547 };
2548 
2549 /* *** configure port rxq/txq ring size *** */
2550 struct cmd_config_rxtx_ring_size {
2551 	cmdline_fixed_string_t port;
2552 	cmdline_fixed_string_t config;
2553 	portid_t portid;
2554 	cmdline_fixed_string_t rxtxq;
2555 	uint16_t qid;
2556 	cmdline_fixed_string_t rsize;
2557 	uint16_t size;
2558 };
2559 
2560 static void
2561 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2562 				 __rte_unused struct cmdline *cl,
2563 				 __rte_unused void *data)
2564 {
2565 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2566 	struct rte_port *port;
2567 	uint8_t isrx;
2568 
2569 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2570 		return;
2571 
2572 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2573 		fprintf(stderr, "Invalid port id\n");
2574 		return;
2575 	}
2576 
2577 	port = &ports[res->portid];
2578 
2579 	if (!strcmp(res->rxtxq, "rxq"))
2580 		isrx = 1;
2581 	else if (!strcmp(res->rxtxq, "txq"))
2582 		isrx = 0;
2583 	else {
2584 		fprintf(stderr, "Unknown parameter\n");
2585 		return;
2586 	}
2587 
2588 	if (isrx && rx_queue_id_is_invalid(res->qid))
2589 		return;
2590 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2591 		return;
2592 
2593 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2594 		fprintf(stderr,
2595 			"Invalid rx ring_size, must > rx_free_thresh: %d\n",
2596 			rx_free_thresh);
2597 		return;
2598 	}
2599 
2600 	if (isrx)
2601 		port->nb_rx_desc[res->qid] = res->size;
2602 	else
2603 		port->nb_tx_desc[res->qid] = res->size;
2604 
2605 	cmd_reconfig_device_queue(res->portid, 0, 1);
2606 }
2607 
2608 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2609 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 				 port, "port");
2611 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2612 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2613 				 config, "config");
2614 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2615 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 				 portid, RTE_UINT16);
2617 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2618 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2619 				 rxtxq, "rxq#txq");
2620 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2621 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2622 			      qid, RTE_UINT16);
2623 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2624 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2625 				 rsize, "ring_size");
2626 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2627 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2628 			      size, RTE_UINT16);
2629 
2630 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2631 	.f = cmd_config_rxtx_ring_size_parsed,
2632 	.data = NULL,
2633 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2634 	.tokens = {
2635 		(void *)&cmd_config_rxtx_ring_size_port,
2636 		(void *)&cmd_config_rxtx_ring_size_config,
2637 		(void *)&cmd_config_rxtx_ring_size_portid,
2638 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2639 		(void *)&cmd_config_rxtx_ring_size_qid,
2640 		(void *)&cmd_config_rxtx_ring_size_rsize,
2641 		(void *)&cmd_config_rxtx_ring_size_size,
2642 		NULL,
2643 	},
2644 };
2645 
2646 /* *** configure port rxq/txq start/stop *** */
2647 struct cmd_config_rxtx_queue {
2648 	cmdline_fixed_string_t port;
2649 	portid_t portid;
2650 	cmdline_fixed_string_t rxtxq;
2651 	uint16_t qid;
2652 	cmdline_fixed_string_t opname;
2653 };
2654 
2655 static void
2656 cmd_config_rxtx_queue_parsed(void *parsed_result,
2657 			__rte_unused struct cmdline *cl,
2658 			__rte_unused void *data)
2659 {
2660 	struct cmd_config_rxtx_queue *res = parsed_result;
2661 	uint8_t isrx;
2662 	uint8_t isstart;
2663 	int ret = 0;
2664 
2665 	if (test_done == 0) {
2666 		fprintf(stderr, "Please stop forwarding first\n");
2667 		return;
2668 	}
2669 
2670 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2671 		return;
2672 
2673 	if (port_is_started(res->portid) != 1) {
2674 		fprintf(stderr, "Please start port %u first\n", res->portid);
2675 		return;
2676 	}
2677 
2678 	if (!strcmp(res->rxtxq, "rxq"))
2679 		isrx = 1;
2680 	else if (!strcmp(res->rxtxq, "txq"))
2681 		isrx = 0;
2682 	else {
2683 		fprintf(stderr, "Unknown parameter\n");
2684 		return;
2685 	}
2686 
2687 	if (isrx && rx_queue_id_is_invalid(res->qid))
2688 		return;
2689 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2690 		return;
2691 
2692 	if (!strcmp(res->opname, "start"))
2693 		isstart = 1;
2694 	else if (!strcmp(res->opname, "stop"))
2695 		isstart = 0;
2696 	else {
2697 		fprintf(stderr, "Unknown parameter\n");
2698 		return;
2699 	}
2700 
2701 	if (isstart && isrx)
2702 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2703 	else if (!isstart && isrx)
2704 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2705 	else if (isstart && !isrx)
2706 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2707 	else
2708 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2709 
2710 	if (ret == -ENOTSUP)
2711 		fprintf(stderr, "Function not supported in PMD\n");
2712 }
2713 
2714 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2715 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2716 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2717 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2718 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2719 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2720 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2721 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2722 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2723 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2724 						"start#stop");
2725 
2726 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2727 	.f = cmd_config_rxtx_queue_parsed,
2728 	.data = NULL,
2729 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2730 	.tokens = {
2731 		(void *)&cmd_config_rxtx_queue_port,
2732 		(void *)&cmd_config_rxtx_queue_portid,
2733 		(void *)&cmd_config_rxtx_queue_rxtxq,
2734 		(void *)&cmd_config_rxtx_queue_qid,
2735 		(void *)&cmd_config_rxtx_queue_opname,
2736 		NULL,
2737 	},
2738 };
2739 
2740 /* *** configure port rxq/txq deferred start on/off *** */
2741 struct cmd_config_deferred_start_rxtx_queue {
2742 	cmdline_fixed_string_t port;
2743 	portid_t port_id;
2744 	cmdline_fixed_string_t rxtxq;
2745 	uint16_t qid;
2746 	cmdline_fixed_string_t opname;
2747 	cmdline_fixed_string_t state;
2748 };
2749 
2750 static void
2751 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2752 			__rte_unused struct cmdline *cl,
2753 			__rte_unused void *data)
2754 {
2755 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2756 	struct rte_port *port;
2757 	uint8_t isrx;
2758 	uint8_t ison;
2759 	uint8_t needreconfig = 0;
2760 
2761 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2762 		return;
2763 
2764 	if (port_is_started(res->port_id) != 0) {
2765 		fprintf(stderr, "Please stop port %u first\n", res->port_id);
2766 		return;
2767 	}
2768 
2769 	port = &ports[res->port_id];
2770 
2771 	isrx = !strcmp(res->rxtxq, "rxq");
2772 
2773 	if (isrx && rx_queue_id_is_invalid(res->qid))
2774 		return;
2775 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2776 		return;
2777 
2778 	ison = !strcmp(res->state, "on");
2779 
2780 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2781 		port->rx_conf[res->qid].rx_deferred_start = ison;
2782 		needreconfig = 1;
2783 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2784 		port->tx_conf[res->qid].tx_deferred_start = ison;
2785 		needreconfig = 1;
2786 	}
2787 
2788 	if (needreconfig)
2789 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2790 }
2791 
2792 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2793 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2794 						port, "port");
2795 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2796 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 						port_id, RTE_UINT16);
2798 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2799 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2800 						rxtxq, "rxq#txq");
2801 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2802 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2803 						qid, RTE_UINT16);
2804 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2805 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2806 						opname, "deferred_start");
2807 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2808 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2809 						state, "on#off");
2810 
2811 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2812 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2813 	.data = NULL,
2814 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2815 	.tokens = {
2816 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2817 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2818 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2819 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2820 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2821 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2822 		NULL,
2823 	},
2824 };
2825 
2826 /* *** configure port rxq/txq setup *** */
2827 struct cmd_setup_rxtx_queue {
2828 	cmdline_fixed_string_t port;
2829 	portid_t portid;
2830 	cmdline_fixed_string_t rxtxq;
2831 	uint16_t qid;
2832 	cmdline_fixed_string_t setup;
2833 };
2834 
2835 /* Common CLI fields for queue setup */
2836 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2837 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2838 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2839 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2840 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2841 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2842 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2843 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2844 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2845 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2846 
2847 static void
2848 cmd_setup_rxtx_queue_parsed(
2849 	void *parsed_result,
2850 	__rte_unused struct cmdline *cl,
2851 	__rte_unused void *data)
2852 {
2853 	struct cmd_setup_rxtx_queue *res = parsed_result;
2854 	struct rte_port *port;
2855 	struct rte_mempool *mp;
2856 	unsigned int socket_id;
2857 	uint8_t isrx = 0;
2858 	int ret;
2859 
2860 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2861 		return;
2862 
2863 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2864 		fprintf(stderr, "Invalid port id\n");
2865 		return;
2866 	}
2867 
2868 	if (!strcmp(res->rxtxq, "rxq"))
2869 		isrx = 1;
2870 	else if (!strcmp(res->rxtxq, "txq"))
2871 		isrx = 0;
2872 	else {
2873 		fprintf(stderr, "Unknown parameter\n");
2874 		return;
2875 	}
2876 
2877 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2878 		fprintf(stderr, "Invalid rx queue\n");
2879 		return;
2880 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2881 		fprintf(stderr, "Invalid tx queue\n");
2882 		return;
2883 	}
2884 
2885 	port = &ports[res->portid];
2886 	if (isrx) {
2887 		socket_id = rxring_numa[res->portid];
2888 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2889 			socket_id = port->socket_id;
2890 
2891 		mp = mbuf_pool_find(socket_id, 0);
2892 		if (mp == NULL) {
2893 			fprintf(stderr,
2894 				"Failed to setup RX queue: No mempool allocation on the socket %d\n",
2895 				rxring_numa[res->portid]);
2896 			return;
2897 		}
2898 		ret = rx_queue_setup(res->portid,
2899 				     res->qid,
2900 				     port->nb_rx_desc[res->qid],
2901 				     socket_id,
2902 				     &port->rx_conf[res->qid],
2903 				     mp);
2904 		if (ret)
2905 			fprintf(stderr, "Failed to setup RX queue\n");
2906 	} else {
2907 		socket_id = txring_numa[res->portid];
2908 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2909 			socket_id = port->socket_id;
2910 
2911 		if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2912 			fprintf(stderr,
2913 				"Failed to setup TX queue: not enough descriptors\n");
2914 			return;
2915 		}
2916 		ret = rte_eth_tx_queue_setup(res->portid,
2917 					     res->qid,
2918 					     port->nb_tx_desc[res->qid],
2919 					     socket_id,
2920 					     &port->tx_conf[res->qid]);
2921 		if (ret)
2922 			fprintf(stderr, "Failed to setup TX queue\n");
2923 	}
2924 }
2925 
2926 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2927 	.f = cmd_setup_rxtx_queue_parsed,
2928 	.data = NULL,
2929 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2930 	.tokens = {
2931 		(void *)&cmd_setup_rxtx_queue_port,
2932 		(void *)&cmd_setup_rxtx_queue_portid,
2933 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2934 		(void *)&cmd_setup_rxtx_queue_qid,
2935 		(void *)&cmd_setup_rxtx_queue_setup,
2936 		NULL,
2937 	},
2938 };
2939 
2940 
2941 /* *** Configure RSS RETA *** */
2942 struct cmd_config_rss_reta {
2943 	cmdline_fixed_string_t port;
2944 	cmdline_fixed_string_t keyword;
2945 	portid_t port_id;
2946 	cmdline_fixed_string_t name;
2947 	cmdline_fixed_string_t list_name;
2948 	cmdline_fixed_string_t list_of_items;
2949 };
2950 
2951 static int
2952 parse_reta_config(const char *str,
2953 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2954 		  uint16_t nb_entries)
2955 {
2956 	int i;
2957 	unsigned size;
2958 	uint16_t hash_index, idx, shift;
2959 	uint16_t nb_queue;
2960 	char s[256];
2961 	const char *p, *p0 = str;
2962 	char *end;
2963 	enum fieldnames {
2964 		FLD_HASH_INDEX = 0,
2965 		FLD_QUEUE,
2966 		_NUM_FLD
2967 	};
2968 	unsigned long int_fld[_NUM_FLD];
2969 	char *str_fld[_NUM_FLD];
2970 
2971 	while ((p = strchr(p0,'(')) != NULL) {
2972 		++p;
2973 		if((p0 = strchr(p,')')) == NULL)
2974 			return -1;
2975 
2976 		size = p0 - p;
2977 		if(size >= sizeof(s))
2978 			return -1;
2979 
2980 		snprintf(s, sizeof(s), "%.*s", size, p);
2981 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2982 			return -1;
2983 		for (i = 0; i < _NUM_FLD; i++) {
2984 			errno = 0;
2985 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2986 			if (errno != 0 || end == str_fld[i] ||
2987 					int_fld[i] > 65535)
2988 				return -1;
2989 		}
2990 
2991 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2992 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2993 
2994 		if (hash_index >= nb_entries) {
2995 			fprintf(stderr, "Invalid RETA hash index=%d\n",
2996 				hash_index);
2997 			return -1;
2998 		}
2999 
3000 		idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3001 		shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3002 		reta_conf[idx].mask |= (1ULL << shift);
3003 		reta_conf[idx].reta[shift] = nb_queue;
3004 	}
3005 
3006 	return 0;
3007 }
3008 
3009 static void
3010 cmd_set_rss_reta_parsed(void *parsed_result,
3011 			__rte_unused struct cmdline *cl,
3012 			__rte_unused void *data)
3013 {
3014 	int ret;
3015 	struct rte_eth_dev_info dev_info;
3016 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3017 	struct cmd_config_rss_reta *res = parsed_result;
3018 
3019 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3020 	if (ret != 0)
3021 		return;
3022 
3023 	if (dev_info.reta_size == 0) {
3024 		fprintf(stderr,
3025 			"Redirection table size is 0 which is invalid for RSS\n");
3026 		return;
3027 	} else
3028 		printf("The reta size of port %d is %u\n",
3029 			res->port_id, dev_info.reta_size);
3030 	if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3031 		fprintf(stderr,
3032 			"Currently do not support more than %u entries of redirection table\n",
3033 			RTE_ETH_RSS_RETA_SIZE_512);
3034 		return;
3035 	}
3036 
3037 	memset(reta_conf, 0, sizeof(reta_conf));
3038 	if (!strcmp(res->list_name, "reta")) {
3039 		if (parse_reta_config(res->list_of_items, reta_conf,
3040 						dev_info.reta_size)) {
3041 			fprintf(stderr,
3042 				"Invalid RSS Redirection Table config entered\n");
3043 			return;
3044 		}
3045 		ret = rte_eth_dev_rss_reta_update(res->port_id,
3046 				reta_conf, dev_info.reta_size);
3047 		if (ret != 0)
3048 			fprintf(stderr,
3049 				"Bad redirection table parameter, return code = %d\n",
3050 				ret);
3051 	}
3052 }
3053 
3054 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3055 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3056 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3057 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3058 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3059 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3060 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3061 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3063 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3064 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3065         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3066                                  NULL);
3067 cmdline_parse_inst_t cmd_config_rss_reta = {
3068 	.f = cmd_set_rss_reta_parsed,
3069 	.data = NULL,
3070 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3071 	.tokens = {
3072 		(void *)&cmd_config_rss_reta_port,
3073 		(void *)&cmd_config_rss_reta_keyword,
3074 		(void *)&cmd_config_rss_reta_port_id,
3075 		(void *)&cmd_config_rss_reta_name,
3076 		(void *)&cmd_config_rss_reta_list_name,
3077 		(void *)&cmd_config_rss_reta_list_of_items,
3078 		NULL,
3079 	},
3080 };
3081 
3082 /* *** SHOW PORT RETA INFO *** */
3083 struct cmd_showport_reta {
3084 	cmdline_fixed_string_t show;
3085 	cmdline_fixed_string_t port;
3086 	portid_t port_id;
3087 	cmdline_fixed_string_t rss;
3088 	cmdline_fixed_string_t reta;
3089 	uint16_t size;
3090 	cmdline_fixed_string_t list_of_items;
3091 };
3092 
3093 static int
3094 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3095 			   uint16_t nb_entries,
3096 			   char *str)
3097 {
3098 	uint32_t size;
3099 	const char *p, *p0 = str;
3100 	char s[256];
3101 	char *end;
3102 	char *str_fld[8];
3103 	uint16_t i;
3104 	uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3105 			RTE_ETH_RETA_GROUP_SIZE;
3106 	int ret;
3107 
3108 	p = strchr(p0, '(');
3109 	if (p == NULL)
3110 		return -1;
3111 	p++;
3112 	p0 = strchr(p, ')');
3113 	if (p0 == NULL)
3114 		return -1;
3115 	size = p0 - p;
3116 	if (size >= sizeof(s)) {
3117 		fprintf(stderr,
3118 			"The string size exceeds the internal buffer size\n");
3119 		return -1;
3120 	}
3121 	snprintf(s, sizeof(s), "%.*s", size, p);
3122 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3123 	if (ret <= 0 || ret != num) {
3124 		fprintf(stderr,
3125 			"The bits of masks do not match the number of reta entries: %u\n",
3126 			num);
3127 		return -1;
3128 	}
3129 	for (i = 0; i < ret; i++)
3130 		conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3131 
3132 	return 0;
3133 }
3134 
3135 static void
3136 cmd_showport_reta_parsed(void *parsed_result,
3137 			 __rte_unused struct cmdline *cl,
3138 			 __rte_unused void *data)
3139 {
3140 	struct cmd_showport_reta *res = parsed_result;
3141 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3142 	struct rte_eth_dev_info dev_info;
3143 	uint16_t max_reta_size;
3144 	int ret;
3145 
3146 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3147 	if (ret != 0)
3148 		return;
3149 
3150 	max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3151 	if (res->size == 0 || res->size > max_reta_size) {
3152 		fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3153 			res->size, max_reta_size);
3154 		return;
3155 	}
3156 
3157 	memset(reta_conf, 0, sizeof(reta_conf));
3158 	if (showport_parse_reta_config(reta_conf, res->size,
3159 				res->list_of_items) < 0) {
3160 		fprintf(stderr, "Invalid string: %s for reta masks\n",
3161 			res->list_of_items);
3162 		return;
3163 	}
3164 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3165 }
3166 
3167 cmdline_parse_token_string_t cmd_showport_reta_show =
3168 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3169 cmdline_parse_token_string_t cmd_showport_reta_port =
3170 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3171 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3172 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3173 cmdline_parse_token_string_t cmd_showport_reta_rss =
3174 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3175 cmdline_parse_token_string_t cmd_showport_reta_reta =
3176 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3177 cmdline_parse_token_num_t cmd_showport_reta_size =
3178 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3179 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3180 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3181 					list_of_items, NULL);
3182 
3183 cmdline_parse_inst_t cmd_showport_reta = {
3184 	.f = cmd_showport_reta_parsed,
3185 	.data = NULL,
3186 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3187 	.tokens = {
3188 		(void *)&cmd_showport_reta_show,
3189 		(void *)&cmd_showport_reta_port,
3190 		(void *)&cmd_showport_reta_port_id,
3191 		(void *)&cmd_showport_reta_rss,
3192 		(void *)&cmd_showport_reta_reta,
3193 		(void *)&cmd_showport_reta_size,
3194 		(void *)&cmd_showport_reta_list_of_items,
3195 		NULL,
3196 	},
3197 };
3198 
3199 /* *** Show RSS hash configuration *** */
3200 struct cmd_showport_rss_hash {
3201 	cmdline_fixed_string_t show;
3202 	cmdline_fixed_string_t port;
3203 	portid_t port_id;
3204 	cmdline_fixed_string_t rss_hash;
3205 	cmdline_fixed_string_t rss_type;
3206 	cmdline_fixed_string_t key; /* optional argument */
3207 };
3208 
3209 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3210 				__rte_unused struct cmdline *cl,
3211 				void *show_rss_key)
3212 {
3213 	struct cmd_showport_rss_hash *res = parsed_result;
3214 
3215 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3216 }
3217 
3218 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3219 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3220 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3221 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3222 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3223 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3224 				 RTE_UINT16);
3225 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3226 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3227 				 "rss-hash");
3228 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3229 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3230 
3231 cmdline_parse_inst_t cmd_showport_rss_hash = {
3232 	.f = cmd_showport_rss_hash_parsed,
3233 	.data = NULL,
3234 	.help_str = "show port <port_id> rss-hash",
3235 	.tokens = {
3236 		(void *)&cmd_showport_rss_hash_show,
3237 		(void *)&cmd_showport_rss_hash_port,
3238 		(void *)&cmd_showport_rss_hash_port_id,
3239 		(void *)&cmd_showport_rss_hash_rss_hash,
3240 		NULL,
3241 	},
3242 };
3243 
3244 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3245 	.f = cmd_showport_rss_hash_parsed,
3246 	.data = (void *)1,
3247 	.help_str = "show port <port_id> rss-hash key",
3248 	.tokens = {
3249 		(void *)&cmd_showport_rss_hash_show,
3250 		(void *)&cmd_showport_rss_hash_port,
3251 		(void *)&cmd_showport_rss_hash_port_id,
3252 		(void *)&cmd_showport_rss_hash_rss_hash,
3253 		(void *)&cmd_showport_rss_hash_rss_key,
3254 		NULL,
3255 	},
3256 };
3257 
3258 /* *** Configure DCB *** */
3259 struct cmd_config_dcb {
3260 	cmdline_fixed_string_t port;
3261 	cmdline_fixed_string_t config;
3262 	portid_t port_id;
3263 	cmdline_fixed_string_t dcb;
3264 	cmdline_fixed_string_t vt;
3265 	cmdline_fixed_string_t vt_en;
3266 	uint8_t num_tcs;
3267 	cmdline_fixed_string_t pfc;
3268 	cmdline_fixed_string_t pfc_en;
3269 };
3270 
3271 static void
3272 cmd_config_dcb_parsed(void *parsed_result,
3273                         __rte_unused struct cmdline *cl,
3274                         __rte_unused void *data)
3275 {
3276 	struct cmd_config_dcb *res = parsed_result;
3277 	struct rte_eth_dcb_info dcb_info;
3278 	portid_t port_id = res->port_id;
3279 	struct rte_port *port;
3280 	uint8_t pfc_en;
3281 	int ret;
3282 
3283 	port = &ports[port_id];
3284 	/** Check if the port is not started **/
3285 	if (port->port_status != RTE_PORT_STOPPED) {
3286 		fprintf(stderr, "Please stop port %d first\n", port_id);
3287 		return;
3288 	}
3289 
3290 	if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3291 		fprintf(stderr,
3292 			"The invalid number of traffic class, only 4 or 8 allowed.\n");
3293 		return;
3294 	}
3295 
3296 	if (nb_fwd_lcores < res->num_tcs) {
3297 		fprintf(stderr,
3298 			"nb_cores shouldn't be less than number of TCs.\n");
3299 		return;
3300 	}
3301 
3302 	/* Check whether the port supports the report of DCB info. */
3303 	ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3304 	if (ret == -ENOTSUP) {
3305 		fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3306 		return;
3307 	}
3308 
3309 	if (!strncmp(res->pfc_en, "on", 2))
3310 		pfc_en = 1;
3311 	else
3312 		pfc_en = 0;
3313 
3314 	/* DCB in VT mode */
3315 	if (!strncmp(res->vt_en, "on", 2))
3316 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3317 				(enum rte_eth_nb_tcs)res->num_tcs,
3318 				pfc_en);
3319 	else
3320 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3321 				(enum rte_eth_nb_tcs)res->num_tcs,
3322 				pfc_en);
3323 	if (ret != 0) {
3324 		fprintf(stderr, "Cannot initialize network ports.\n");
3325 		return;
3326 	}
3327 
3328 	fwd_config_setup();
3329 
3330 	cmd_reconfig_device_queue(port_id, 1, 1);
3331 }
3332 
3333 cmdline_parse_token_string_t cmd_config_dcb_port =
3334         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3335 cmdline_parse_token_string_t cmd_config_dcb_config =
3336         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3337 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3338 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3339 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3340         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3341 cmdline_parse_token_string_t cmd_config_dcb_vt =
3342         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3343 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3344         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3345 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3346 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3347 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3348         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3349 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3350         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3351 
3352 cmdline_parse_inst_t cmd_config_dcb = {
3353 	.f = cmd_config_dcb_parsed,
3354 	.data = NULL,
3355 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3356 	.tokens = {
3357 		(void *)&cmd_config_dcb_port,
3358 		(void *)&cmd_config_dcb_config,
3359 		(void *)&cmd_config_dcb_port_id,
3360 		(void *)&cmd_config_dcb_dcb,
3361 		(void *)&cmd_config_dcb_vt,
3362 		(void *)&cmd_config_dcb_vt_en,
3363 		(void *)&cmd_config_dcb_num_tcs,
3364 		(void *)&cmd_config_dcb_pfc,
3365 		(void *)&cmd_config_dcb_pfc_en,
3366                 NULL,
3367         },
3368 };
3369 
3370 /* *** configure number of packets per burst *** */
3371 struct cmd_config_burst {
3372 	cmdline_fixed_string_t port;
3373 	cmdline_fixed_string_t keyword;
3374 	cmdline_fixed_string_t all;
3375 	cmdline_fixed_string_t name;
3376 	uint16_t value;
3377 };
3378 
3379 static void
3380 cmd_config_burst_parsed(void *parsed_result,
3381 			__rte_unused struct cmdline *cl,
3382 			__rte_unused void *data)
3383 {
3384 	struct cmd_config_burst *res = parsed_result;
3385 	struct rte_eth_dev_info dev_info;
3386 	uint16_t rec_nb_pkts;
3387 	int ret;
3388 
3389 	if (!all_ports_stopped()) {
3390 		fprintf(stderr, "Please stop all ports first\n");
3391 		return;
3392 	}
3393 
3394 	if (!strcmp(res->name, "burst")) {
3395 		if (res->value == 0) {
3396 			/* If user gives a value of zero, query the PMD for
3397 			 * its recommended Rx burst size. Testpmd uses a single
3398 			 * size for all ports, so assume all ports are the same
3399 			 * NIC model and use the values from Port 0.
3400 			 */
3401 			ret = eth_dev_info_get_print_err(0, &dev_info);
3402 			if (ret != 0)
3403 				return;
3404 
3405 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3406 
3407 			if (rec_nb_pkts == 0) {
3408 				printf("PMD does not recommend a burst size.\n"
3409 					"User provided value must be between"
3410 					" 1 and %d\n", MAX_PKT_BURST);
3411 				return;
3412 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3413 				printf("PMD recommended burst size of %d"
3414 					" exceeds maximum value of %d\n",
3415 					rec_nb_pkts, MAX_PKT_BURST);
3416 				return;
3417 			}
3418 			printf("Using PMD-provided burst value of %d\n",
3419 				rec_nb_pkts);
3420 			nb_pkt_per_burst = rec_nb_pkts;
3421 		} else if (res->value > MAX_PKT_BURST) {
3422 			fprintf(stderr, "burst must be >= 1 && <= %d\n",
3423 				MAX_PKT_BURST);
3424 			return;
3425 		} else
3426 			nb_pkt_per_burst = res->value;
3427 	} else {
3428 		fprintf(stderr, "Unknown parameter\n");
3429 		return;
3430 	}
3431 
3432 	init_port_config();
3433 
3434 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3435 }
3436 
3437 cmdline_parse_token_string_t cmd_config_burst_port =
3438 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3439 cmdline_parse_token_string_t cmd_config_burst_keyword =
3440 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3441 cmdline_parse_token_string_t cmd_config_burst_all =
3442 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3443 cmdline_parse_token_string_t cmd_config_burst_name =
3444 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3445 cmdline_parse_token_num_t cmd_config_burst_value =
3446 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3447 
3448 cmdline_parse_inst_t cmd_config_burst = {
3449 	.f = cmd_config_burst_parsed,
3450 	.data = NULL,
3451 	.help_str = "port config all burst <value>",
3452 	.tokens = {
3453 		(void *)&cmd_config_burst_port,
3454 		(void *)&cmd_config_burst_keyword,
3455 		(void *)&cmd_config_burst_all,
3456 		(void *)&cmd_config_burst_name,
3457 		(void *)&cmd_config_burst_value,
3458 		NULL,
3459 	},
3460 };
3461 
3462 /* *** configure rx/tx queues *** */
3463 struct cmd_config_thresh {
3464 	cmdline_fixed_string_t port;
3465 	cmdline_fixed_string_t keyword;
3466 	cmdline_fixed_string_t all;
3467 	cmdline_fixed_string_t name;
3468 	uint8_t value;
3469 };
3470 
3471 static void
3472 cmd_config_thresh_parsed(void *parsed_result,
3473 			__rte_unused struct cmdline *cl,
3474 			__rte_unused void *data)
3475 {
3476 	struct cmd_config_thresh *res = parsed_result;
3477 
3478 	if (!all_ports_stopped()) {
3479 		fprintf(stderr, "Please stop all ports first\n");
3480 		return;
3481 	}
3482 
3483 	if (!strcmp(res->name, "txpt"))
3484 		tx_pthresh = res->value;
3485 	else if(!strcmp(res->name, "txht"))
3486 		tx_hthresh = res->value;
3487 	else if(!strcmp(res->name, "txwt"))
3488 		tx_wthresh = res->value;
3489 	else if(!strcmp(res->name, "rxpt"))
3490 		rx_pthresh = res->value;
3491 	else if(!strcmp(res->name, "rxht"))
3492 		rx_hthresh = res->value;
3493 	else if(!strcmp(res->name, "rxwt"))
3494 		rx_wthresh = res->value;
3495 	else {
3496 		fprintf(stderr, "Unknown parameter\n");
3497 		return;
3498 	}
3499 
3500 	init_port_config();
3501 
3502 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3503 }
3504 
3505 cmdline_parse_token_string_t cmd_config_thresh_port =
3506 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3507 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3508 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3509 cmdline_parse_token_string_t cmd_config_thresh_all =
3510 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3511 cmdline_parse_token_string_t cmd_config_thresh_name =
3512 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3513 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3514 cmdline_parse_token_num_t cmd_config_thresh_value =
3515 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3516 
3517 cmdline_parse_inst_t cmd_config_thresh = {
3518 	.f = cmd_config_thresh_parsed,
3519 	.data = NULL,
3520 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3521 	.tokens = {
3522 		(void *)&cmd_config_thresh_port,
3523 		(void *)&cmd_config_thresh_keyword,
3524 		(void *)&cmd_config_thresh_all,
3525 		(void *)&cmd_config_thresh_name,
3526 		(void *)&cmd_config_thresh_value,
3527 		NULL,
3528 	},
3529 };
3530 
3531 /* *** configure free/rs threshold *** */
3532 struct cmd_config_threshold {
3533 	cmdline_fixed_string_t port;
3534 	cmdline_fixed_string_t keyword;
3535 	cmdline_fixed_string_t all;
3536 	cmdline_fixed_string_t name;
3537 	uint16_t value;
3538 };
3539 
3540 static void
3541 cmd_config_threshold_parsed(void *parsed_result,
3542 			__rte_unused struct cmdline *cl,
3543 			__rte_unused void *data)
3544 {
3545 	struct cmd_config_threshold *res = parsed_result;
3546 
3547 	if (!all_ports_stopped()) {
3548 		fprintf(stderr, "Please stop all ports first\n");
3549 		return;
3550 	}
3551 
3552 	if (!strcmp(res->name, "txfreet"))
3553 		tx_free_thresh = res->value;
3554 	else if (!strcmp(res->name, "txrst"))
3555 		tx_rs_thresh = res->value;
3556 	else if (!strcmp(res->name, "rxfreet"))
3557 		rx_free_thresh = res->value;
3558 	else {
3559 		fprintf(stderr, "Unknown parameter\n");
3560 		return;
3561 	}
3562 
3563 	init_port_config();
3564 
3565 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3566 }
3567 
3568 cmdline_parse_token_string_t cmd_config_threshold_port =
3569 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3570 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3571 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3572 								"config");
3573 cmdline_parse_token_string_t cmd_config_threshold_all =
3574 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3575 cmdline_parse_token_string_t cmd_config_threshold_name =
3576 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3577 						"txfreet#txrst#rxfreet");
3578 cmdline_parse_token_num_t cmd_config_threshold_value =
3579 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3580 
3581 cmdline_parse_inst_t cmd_config_threshold = {
3582 	.f = cmd_config_threshold_parsed,
3583 	.data = NULL,
3584 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3585 	.tokens = {
3586 		(void *)&cmd_config_threshold_port,
3587 		(void *)&cmd_config_threshold_keyword,
3588 		(void *)&cmd_config_threshold_all,
3589 		(void *)&cmd_config_threshold_name,
3590 		(void *)&cmd_config_threshold_value,
3591 		NULL,
3592 	},
3593 };
3594 
3595 /* *** stop *** */
3596 struct cmd_stop_result {
3597 	cmdline_fixed_string_t stop;
3598 };
3599 
3600 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3601 			    __rte_unused struct cmdline *cl,
3602 			    __rte_unused void *data)
3603 {
3604 	stop_packet_forwarding();
3605 }
3606 
3607 cmdline_parse_token_string_t cmd_stop_stop =
3608 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3609 
3610 cmdline_parse_inst_t cmd_stop = {
3611 	.f = cmd_stop_parsed,
3612 	.data = NULL,
3613 	.help_str = "stop: Stop packet forwarding",
3614 	.tokens = {
3615 		(void *)&cmd_stop_stop,
3616 		NULL,
3617 	},
3618 };
3619 
3620 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3621 
3622 unsigned int
3623 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3624 		unsigned int *parsed_items, int check_unique_values)
3625 {
3626 	unsigned int nb_item;
3627 	unsigned int value;
3628 	unsigned int i;
3629 	unsigned int j;
3630 	int value_ok;
3631 	char c;
3632 
3633 	/*
3634 	 * First parse all items in the list and store their value.
3635 	 */
3636 	value = 0;
3637 	nb_item = 0;
3638 	value_ok = 0;
3639 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3640 		c = str[i];
3641 		if ((c >= '0') && (c <= '9')) {
3642 			value = (unsigned int) (value * 10 + (c - '0'));
3643 			value_ok = 1;
3644 			continue;
3645 		}
3646 		if (c != ',') {
3647 			fprintf(stderr, "character %c is not a decimal digit\n", c);
3648 			return 0;
3649 		}
3650 		if (! value_ok) {
3651 			fprintf(stderr, "No valid value before comma\n");
3652 			return 0;
3653 		}
3654 		if (nb_item < max_items) {
3655 			parsed_items[nb_item] = value;
3656 			value_ok = 0;
3657 			value = 0;
3658 		}
3659 		nb_item++;
3660 	}
3661 	if (nb_item >= max_items) {
3662 		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3663 			item_name, nb_item + 1, max_items);
3664 		return 0;
3665 	}
3666 	parsed_items[nb_item++] = value;
3667 	if (! check_unique_values)
3668 		return nb_item;
3669 
3670 	/*
3671 	 * Then, check that all values in the list are different.
3672 	 * No optimization here...
3673 	 */
3674 	for (i = 0; i < nb_item; i++) {
3675 		for (j = i + 1; j < nb_item; j++) {
3676 			if (parsed_items[j] == parsed_items[i]) {
3677 				fprintf(stderr,
3678 					"duplicated %s %u at index %u and %u\n",
3679 					item_name, parsed_items[i], i, j);
3680 				return 0;
3681 			}
3682 		}
3683 	}
3684 	return nb_item;
3685 }
3686 
3687 struct cmd_set_list_result {
3688 	cmdline_fixed_string_t cmd_keyword;
3689 	cmdline_fixed_string_t list_name;
3690 	cmdline_fixed_string_t list_of_items;
3691 };
3692 
3693 static void cmd_set_list_parsed(void *parsed_result,
3694 				__rte_unused struct cmdline *cl,
3695 				__rte_unused void *data)
3696 {
3697 	struct cmd_set_list_result *res;
3698 	union {
3699 		unsigned int lcorelist[RTE_MAX_LCORE];
3700 		unsigned int portlist[RTE_MAX_ETHPORTS];
3701 	} parsed_items;
3702 	unsigned int nb_item;
3703 
3704 	if (test_done == 0) {
3705 		fprintf(stderr, "Please stop forwarding first\n");
3706 		return;
3707 	}
3708 
3709 	res = parsed_result;
3710 	if (!strcmp(res->list_name, "corelist")) {
3711 		nb_item = parse_item_list(res->list_of_items, "core",
3712 					  RTE_MAX_LCORE,
3713 					  parsed_items.lcorelist, 1);
3714 		if (nb_item > 0) {
3715 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3716 			fwd_config_setup();
3717 		}
3718 		return;
3719 	}
3720 	if (!strcmp(res->list_name, "portlist")) {
3721 		nb_item = parse_item_list(res->list_of_items, "port",
3722 					  RTE_MAX_ETHPORTS,
3723 					  parsed_items.portlist, 1);
3724 		if (nb_item > 0) {
3725 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3726 			fwd_config_setup();
3727 		}
3728 	}
3729 }
3730 
3731 cmdline_parse_token_string_t cmd_set_list_keyword =
3732 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3733 				 "set");
3734 cmdline_parse_token_string_t cmd_set_list_name =
3735 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3736 				 "corelist#portlist");
3737 cmdline_parse_token_string_t cmd_set_list_of_items =
3738 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3739 				 NULL);
3740 
3741 cmdline_parse_inst_t cmd_set_fwd_list = {
3742 	.f = cmd_set_list_parsed,
3743 	.data = NULL,
3744 	.help_str = "set corelist|portlist <list0[,list1]*>",
3745 	.tokens = {
3746 		(void *)&cmd_set_list_keyword,
3747 		(void *)&cmd_set_list_name,
3748 		(void *)&cmd_set_list_of_items,
3749 		NULL,
3750 	},
3751 };
3752 
3753 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3754 
3755 struct cmd_setmask_result {
3756 	cmdline_fixed_string_t set;
3757 	cmdline_fixed_string_t mask;
3758 	uint64_t hexavalue;
3759 };
3760 
3761 static void cmd_set_mask_parsed(void *parsed_result,
3762 				__rte_unused struct cmdline *cl,
3763 				__rte_unused void *data)
3764 {
3765 	struct cmd_setmask_result *res = parsed_result;
3766 
3767 	if (test_done == 0) {
3768 		fprintf(stderr, "Please stop forwarding first\n");
3769 		return;
3770 	}
3771 	if (!strcmp(res->mask, "coremask")) {
3772 		set_fwd_lcores_mask(res->hexavalue);
3773 		fwd_config_setup();
3774 	} else if (!strcmp(res->mask, "portmask")) {
3775 		set_fwd_ports_mask(res->hexavalue);
3776 		fwd_config_setup();
3777 	}
3778 }
3779 
3780 cmdline_parse_token_string_t cmd_setmask_set =
3781 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3782 cmdline_parse_token_string_t cmd_setmask_mask =
3783 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3784 				 "coremask#portmask");
3785 cmdline_parse_token_num_t cmd_setmask_value =
3786 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3787 
3788 cmdline_parse_inst_t cmd_set_fwd_mask = {
3789 	.f = cmd_set_mask_parsed,
3790 	.data = NULL,
3791 	.help_str = "set coremask|portmask <hexadecimal value>",
3792 	.tokens = {
3793 		(void *)&cmd_setmask_set,
3794 		(void *)&cmd_setmask_mask,
3795 		(void *)&cmd_setmask_value,
3796 		NULL,
3797 	},
3798 };
3799 
3800 /*
3801  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3802  */
3803 struct cmd_set_result {
3804 	cmdline_fixed_string_t set;
3805 	cmdline_fixed_string_t what;
3806 	uint16_t value;
3807 };
3808 
3809 static void cmd_set_parsed(void *parsed_result,
3810 			   __rte_unused struct cmdline *cl,
3811 			   __rte_unused void *data)
3812 {
3813 	struct cmd_set_result *res = parsed_result;
3814 	if (!strcmp(res->what, "nbport")) {
3815 		set_fwd_ports_number(res->value);
3816 		fwd_config_setup();
3817 	} else if (!strcmp(res->what, "nbcore")) {
3818 		set_fwd_lcores_number(res->value);
3819 		fwd_config_setup();
3820 	} else if (!strcmp(res->what, "burst"))
3821 		set_nb_pkt_per_burst(res->value);
3822 	else if (!strcmp(res->what, "verbose"))
3823 		set_verbose_level(res->value);
3824 }
3825 
3826 cmdline_parse_token_string_t cmd_set_set =
3827 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3828 cmdline_parse_token_string_t cmd_set_what =
3829 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3830 				 "nbport#nbcore#burst#verbose");
3831 cmdline_parse_token_num_t cmd_set_value =
3832 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3833 
3834 cmdline_parse_inst_t cmd_set_numbers = {
3835 	.f = cmd_set_parsed,
3836 	.data = NULL,
3837 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3838 	.tokens = {
3839 		(void *)&cmd_set_set,
3840 		(void *)&cmd_set_what,
3841 		(void *)&cmd_set_value,
3842 		NULL,
3843 	},
3844 };
3845 
3846 /* *** SET LOG LEVEL CONFIGURATION *** */
3847 
3848 struct cmd_set_log_result {
3849 	cmdline_fixed_string_t set;
3850 	cmdline_fixed_string_t log;
3851 	cmdline_fixed_string_t type;
3852 	uint32_t level;
3853 };
3854 
3855 static void
3856 cmd_set_log_parsed(void *parsed_result,
3857 		   __rte_unused struct cmdline *cl,
3858 		   __rte_unused void *data)
3859 {
3860 	struct cmd_set_log_result *res;
3861 	int ret;
3862 
3863 	res = parsed_result;
3864 	if (!strcmp(res->type, "global"))
3865 		rte_log_set_global_level(res->level);
3866 	else {
3867 		ret = rte_log_set_level_regexp(res->type, res->level);
3868 		if (ret < 0)
3869 			fprintf(stderr, "Unable to set log level\n");
3870 	}
3871 }
3872 
3873 cmdline_parse_token_string_t cmd_set_log_set =
3874 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3875 cmdline_parse_token_string_t cmd_set_log_log =
3876 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3877 cmdline_parse_token_string_t cmd_set_log_type =
3878 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3879 cmdline_parse_token_num_t cmd_set_log_level =
3880 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3881 
3882 cmdline_parse_inst_t cmd_set_log = {
3883 	.f = cmd_set_log_parsed,
3884 	.data = NULL,
3885 	.help_str = "set log global|<type> <level>",
3886 	.tokens = {
3887 		(void *)&cmd_set_log_set,
3888 		(void *)&cmd_set_log_log,
3889 		(void *)&cmd_set_log_type,
3890 		(void *)&cmd_set_log_level,
3891 		NULL,
3892 	},
3893 };
3894 
3895 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3896 
3897 struct cmd_set_rxoffs_result {
3898 	cmdline_fixed_string_t cmd_keyword;
3899 	cmdline_fixed_string_t rxoffs;
3900 	cmdline_fixed_string_t seg_offsets;
3901 };
3902 
3903 static void
3904 cmd_set_rxoffs_parsed(void *parsed_result,
3905 		      __rte_unused struct cmdline *cl,
3906 		      __rte_unused void *data)
3907 {
3908 	struct cmd_set_rxoffs_result *res;
3909 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3910 	unsigned int nb_segs;
3911 
3912 	res = parsed_result;
3913 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3914 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3915 	if (nb_segs > 0)
3916 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3917 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3918 }
3919 
3920 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3921 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3922 				 cmd_keyword, "set");
3923 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3924 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3925 				 rxoffs, "rxoffs");
3926 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3927 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3928 				 seg_offsets, NULL);
3929 
3930 cmdline_parse_inst_t cmd_set_rxoffs = {
3931 	.f = cmd_set_rxoffs_parsed,
3932 	.data = NULL,
3933 	.help_str = "set rxoffs <len0[,len1]*>",
3934 	.tokens = {
3935 		(void *)&cmd_set_rxoffs_keyword,
3936 		(void *)&cmd_set_rxoffs_name,
3937 		(void *)&cmd_set_rxoffs_offsets,
3938 		NULL,
3939 	},
3940 };
3941 
3942 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3943 
3944 struct cmd_set_rxpkts_result {
3945 	cmdline_fixed_string_t cmd_keyword;
3946 	cmdline_fixed_string_t rxpkts;
3947 	cmdline_fixed_string_t seg_lengths;
3948 };
3949 
3950 static void
3951 cmd_set_rxpkts_parsed(void *parsed_result,
3952 		      __rte_unused struct cmdline *cl,
3953 		      __rte_unused void *data)
3954 {
3955 	struct cmd_set_rxpkts_result *res;
3956 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3957 	unsigned int nb_segs;
3958 
3959 	res = parsed_result;
3960 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3961 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3962 	if (nb_segs > 0)
3963 		set_rx_pkt_segments(seg_lengths, nb_segs);
3964 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3965 }
3966 
3967 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3968 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3969 				 cmd_keyword, "set");
3970 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3971 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3972 				 rxpkts, "rxpkts");
3973 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3974 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3975 				 seg_lengths, NULL);
3976 
3977 cmdline_parse_inst_t cmd_set_rxpkts = {
3978 	.f = cmd_set_rxpkts_parsed,
3979 	.data = NULL,
3980 	.help_str = "set rxpkts <len0[,len1]*>",
3981 	.tokens = {
3982 		(void *)&cmd_set_rxpkts_keyword,
3983 		(void *)&cmd_set_rxpkts_name,
3984 		(void *)&cmd_set_rxpkts_lengths,
3985 		NULL,
3986 	},
3987 };
3988 
3989 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3990 
3991 struct cmd_set_txpkts_result {
3992 	cmdline_fixed_string_t cmd_keyword;
3993 	cmdline_fixed_string_t txpkts;
3994 	cmdline_fixed_string_t seg_lengths;
3995 };
3996 
3997 static void
3998 cmd_set_txpkts_parsed(void *parsed_result,
3999 		      __rte_unused struct cmdline *cl,
4000 		      __rte_unused void *data)
4001 {
4002 	struct cmd_set_txpkts_result *res;
4003 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4004 	unsigned int nb_segs;
4005 
4006 	res = parsed_result;
4007 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4008 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4009 	if (nb_segs > 0)
4010 		set_tx_pkt_segments(seg_lengths, nb_segs);
4011 }
4012 
4013 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4014 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4015 				 cmd_keyword, "set");
4016 cmdline_parse_token_string_t cmd_set_txpkts_name =
4017 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4018 				 txpkts, "txpkts");
4019 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4020 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4021 				 seg_lengths, NULL);
4022 
4023 cmdline_parse_inst_t cmd_set_txpkts = {
4024 	.f = cmd_set_txpkts_parsed,
4025 	.data = NULL,
4026 	.help_str = "set txpkts <len0[,len1]*>",
4027 	.tokens = {
4028 		(void *)&cmd_set_txpkts_keyword,
4029 		(void *)&cmd_set_txpkts_name,
4030 		(void *)&cmd_set_txpkts_lengths,
4031 		NULL,
4032 	},
4033 };
4034 
4035 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4036 
4037 struct cmd_set_txsplit_result {
4038 	cmdline_fixed_string_t cmd_keyword;
4039 	cmdline_fixed_string_t txsplit;
4040 	cmdline_fixed_string_t mode;
4041 };
4042 
4043 static void
4044 cmd_set_txsplit_parsed(void *parsed_result,
4045 		      __rte_unused struct cmdline *cl,
4046 		      __rte_unused void *data)
4047 {
4048 	struct cmd_set_txsplit_result *res;
4049 
4050 	res = parsed_result;
4051 	set_tx_pkt_split(res->mode);
4052 }
4053 
4054 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4055 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4056 				 cmd_keyword, "set");
4057 cmdline_parse_token_string_t cmd_set_txsplit_name =
4058 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4059 				 txsplit, "txsplit");
4060 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4061 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4062 				 mode, NULL);
4063 
4064 cmdline_parse_inst_t cmd_set_txsplit = {
4065 	.f = cmd_set_txsplit_parsed,
4066 	.data = NULL,
4067 	.help_str = "set txsplit on|off|rand",
4068 	.tokens = {
4069 		(void *)&cmd_set_txsplit_keyword,
4070 		(void *)&cmd_set_txsplit_name,
4071 		(void *)&cmd_set_txsplit_mode,
4072 		NULL,
4073 	},
4074 };
4075 
4076 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4077 
4078 struct cmd_set_txtimes_result {
4079 	cmdline_fixed_string_t cmd_keyword;
4080 	cmdline_fixed_string_t txtimes;
4081 	cmdline_fixed_string_t tx_times;
4082 };
4083 
4084 static void
4085 cmd_set_txtimes_parsed(void *parsed_result,
4086 		       __rte_unused struct cmdline *cl,
4087 		       __rte_unused void *data)
4088 {
4089 	struct cmd_set_txtimes_result *res;
4090 	unsigned int tx_times[2] = {0, 0};
4091 	unsigned int n_times;
4092 
4093 	res = parsed_result;
4094 	n_times = parse_item_list(res->tx_times, "tx times",
4095 				  2, tx_times, 0);
4096 	if (n_times == 2)
4097 		set_tx_pkt_times(tx_times);
4098 }
4099 
4100 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4101 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4102 				 cmd_keyword, "set");
4103 cmdline_parse_token_string_t cmd_set_txtimes_name =
4104 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4105 				 txtimes, "txtimes");
4106 cmdline_parse_token_string_t cmd_set_txtimes_value =
4107 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4108 				 tx_times, NULL);
4109 
4110 cmdline_parse_inst_t cmd_set_txtimes = {
4111 	.f = cmd_set_txtimes_parsed,
4112 	.data = NULL,
4113 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
4114 	.tokens = {
4115 		(void *)&cmd_set_txtimes_keyword,
4116 		(void *)&cmd_set_txtimes_name,
4117 		(void *)&cmd_set_txtimes_value,
4118 		NULL,
4119 	},
4120 };
4121 
4122 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4123 struct cmd_rx_vlan_filter_all_result {
4124 	cmdline_fixed_string_t rx_vlan;
4125 	cmdline_fixed_string_t what;
4126 	cmdline_fixed_string_t all;
4127 	portid_t port_id;
4128 };
4129 
4130 static void
4131 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4132 			      __rte_unused struct cmdline *cl,
4133 			      __rte_unused void *data)
4134 {
4135 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4136 
4137 	if (!strcmp(res->what, "add"))
4138 		rx_vlan_all_filter_set(res->port_id, 1);
4139 	else
4140 		rx_vlan_all_filter_set(res->port_id, 0);
4141 }
4142 
4143 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4144 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4145 				 rx_vlan, "rx_vlan");
4146 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4147 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4148 				 what, "add#rm");
4149 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4150 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4151 				 all, "all");
4152 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4153 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4154 			      port_id, RTE_UINT16);
4155 
4156 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4157 	.f = cmd_rx_vlan_filter_all_parsed,
4158 	.data = NULL,
4159 	.help_str = "rx_vlan add|rm all <port_id>: "
4160 		"Add/Remove all identifiers to/from the set of VLAN "
4161 		"identifiers filtered by a port",
4162 	.tokens = {
4163 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4164 		(void *)&cmd_rx_vlan_filter_all_what,
4165 		(void *)&cmd_rx_vlan_filter_all_all,
4166 		(void *)&cmd_rx_vlan_filter_all_portid,
4167 		NULL,
4168 	},
4169 };
4170 
4171 /* *** VLAN OFFLOAD SET ON A PORT *** */
4172 struct cmd_vlan_offload_result {
4173 	cmdline_fixed_string_t vlan;
4174 	cmdline_fixed_string_t set;
4175 	cmdline_fixed_string_t vlan_type;
4176 	cmdline_fixed_string_t what;
4177 	cmdline_fixed_string_t on;
4178 	cmdline_fixed_string_t port_id;
4179 };
4180 
4181 static void
4182 cmd_vlan_offload_parsed(void *parsed_result,
4183 			  __rte_unused struct cmdline *cl,
4184 			  __rte_unused void *data)
4185 {
4186 	int on;
4187 	struct cmd_vlan_offload_result *res = parsed_result;
4188 	char *str;
4189 	int i, len = 0;
4190 	portid_t port_id = 0;
4191 	unsigned int tmp;
4192 
4193 	str = res->port_id;
4194 	len = strnlen(str, STR_TOKEN_SIZE);
4195 	i = 0;
4196 	/* Get port_id first */
4197 	while(i < len){
4198 		if(str[i] == ',')
4199 			break;
4200 
4201 		i++;
4202 	}
4203 	str[i]='\0';
4204 	tmp = strtoul(str, NULL, 0);
4205 	/* If port_id greater that what portid_t can represent, return */
4206 	if(tmp >= RTE_MAX_ETHPORTS)
4207 		return;
4208 	port_id = (portid_t)tmp;
4209 
4210 	if (!strcmp(res->on, "on"))
4211 		on = 1;
4212 	else
4213 		on = 0;
4214 
4215 	if (!strcmp(res->what, "strip"))
4216 		rx_vlan_strip_set(port_id,  on);
4217 	else if(!strcmp(res->what, "stripq")){
4218 		uint16_t queue_id = 0;
4219 
4220 		/* No queue_id, return */
4221 		if(i + 1 >= len) {
4222 			fprintf(stderr, "must specify (port,queue_id)\n");
4223 			return;
4224 		}
4225 		tmp = strtoul(str + i + 1, NULL, 0);
4226 		/* If queue_id greater that what 16-bits can represent, return */
4227 		if(tmp > 0xffff)
4228 			return;
4229 
4230 		queue_id = (uint16_t)tmp;
4231 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4232 	}
4233 	else if (!strcmp(res->what, "filter"))
4234 		rx_vlan_filter_set(port_id, on);
4235 	else if (!strcmp(res->what, "qinq_strip"))
4236 		rx_vlan_qinq_strip_set(port_id, on);
4237 	else
4238 		vlan_extend_set(port_id, on);
4239 
4240 	return;
4241 }
4242 
4243 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4244 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4245 				 vlan, "vlan");
4246 cmdline_parse_token_string_t cmd_vlan_offload_set =
4247 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4248 				 set, "set");
4249 cmdline_parse_token_string_t cmd_vlan_offload_what =
4250 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4251 				what, "strip#filter#qinq_strip#extend#stripq");
4252 cmdline_parse_token_string_t cmd_vlan_offload_on =
4253 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4254 			      on, "on#off");
4255 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4256 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4257 			      port_id, NULL);
4258 
4259 cmdline_parse_inst_t cmd_vlan_offload = {
4260 	.f = cmd_vlan_offload_parsed,
4261 	.data = NULL,
4262 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4263 		"<port_id[,queue_id]>: "
4264 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4265 	.tokens = {
4266 		(void *)&cmd_vlan_offload_vlan,
4267 		(void *)&cmd_vlan_offload_set,
4268 		(void *)&cmd_vlan_offload_what,
4269 		(void *)&cmd_vlan_offload_on,
4270 		(void *)&cmd_vlan_offload_portid,
4271 		NULL,
4272 	},
4273 };
4274 
4275 /* *** VLAN TPID SET ON A PORT *** */
4276 struct cmd_vlan_tpid_result {
4277 	cmdline_fixed_string_t vlan;
4278 	cmdline_fixed_string_t set;
4279 	cmdline_fixed_string_t vlan_type;
4280 	cmdline_fixed_string_t what;
4281 	uint16_t tp_id;
4282 	portid_t port_id;
4283 };
4284 
4285 static void
4286 cmd_vlan_tpid_parsed(void *parsed_result,
4287 			  __rte_unused struct cmdline *cl,
4288 			  __rte_unused void *data)
4289 {
4290 	struct cmd_vlan_tpid_result *res = parsed_result;
4291 	enum rte_vlan_type vlan_type;
4292 
4293 	if (!strcmp(res->vlan_type, "inner"))
4294 		vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4295 	else if (!strcmp(res->vlan_type, "outer"))
4296 		vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4297 	else {
4298 		fprintf(stderr, "Unknown vlan type\n");
4299 		return;
4300 	}
4301 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4302 }
4303 
4304 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4305 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4306 				 vlan, "vlan");
4307 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4308 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4309 				 set, "set");
4310 cmdline_parse_token_string_t cmd_vlan_type =
4311 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4312 				 vlan_type, "inner#outer");
4313 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4314 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4315 				 what, "tpid");
4316 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4317 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4318 			      tp_id, RTE_UINT16);
4319 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4320 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4321 			      port_id, RTE_UINT16);
4322 
4323 cmdline_parse_inst_t cmd_vlan_tpid = {
4324 	.f = cmd_vlan_tpid_parsed,
4325 	.data = NULL,
4326 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4327 		"Set the VLAN Ether type",
4328 	.tokens = {
4329 		(void *)&cmd_vlan_tpid_vlan,
4330 		(void *)&cmd_vlan_tpid_set,
4331 		(void *)&cmd_vlan_type,
4332 		(void *)&cmd_vlan_tpid_what,
4333 		(void *)&cmd_vlan_tpid_tpid,
4334 		(void *)&cmd_vlan_tpid_portid,
4335 		NULL,
4336 	},
4337 };
4338 
4339 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4340 struct cmd_rx_vlan_filter_result {
4341 	cmdline_fixed_string_t rx_vlan;
4342 	cmdline_fixed_string_t what;
4343 	uint16_t vlan_id;
4344 	portid_t port_id;
4345 };
4346 
4347 static void
4348 cmd_rx_vlan_filter_parsed(void *parsed_result,
4349 			  __rte_unused struct cmdline *cl,
4350 			  __rte_unused void *data)
4351 {
4352 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4353 
4354 	if (!strcmp(res->what, "add"))
4355 		rx_vft_set(res->port_id, res->vlan_id, 1);
4356 	else
4357 		rx_vft_set(res->port_id, res->vlan_id, 0);
4358 }
4359 
4360 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4361 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4362 				 rx_vlan, "rx_vlan");
4363 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4364 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4365 				 what, "add#rm");
4366 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4367 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4368 			      vlan_id, RTE_UINT16);
4369 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4370 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4371 			      port_id, RTE_UINT16);
4372 
4373 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4374 	.f = cmd_rx_vlan_filter_parsed,
4375 	.data = NULL,
4376 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4377 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4378 		"identifiers filtered by a port",
4379 	.tokens = {
4380 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4381 		(void *)&cmd_rx_vlan_filter_what,
4382 		(void *)&cmd_rx_vlan_filter_vlanid,
4383 		(void *)&cmd_rx_vlan_filter_portid,
4384 		NULL,
4385 	},
4386 };
4387 
4388 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4389 struct cmd_tx_vlan_set_result {
4390 	cmdline_fixed_string_t tx_vlan;
4391 	cmdline_fixed_string_t set;
4392 	portid_t port_id;
4393 	uint16_t vlan_id;
4394 };
4395 
4396 static void
4397 cmd_tx_vlan_set_parsed(void *parsed_result,
4398 		       __rte_unused struct cmdline *cl,
4399 		       __rte_unused void *data)
4400 {
4401 	struct cmd_tx_vlan_set_result *res = parsed_result;
4402 
4403 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4404 		return;
4405 
4406 	if (!port_is_stopped(res->port_id)) {
4407 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4408 		return;
4409 	}
4410 
4411 	tx_vlan_set(res->port_id, res->vlan_id);
4412 
4413 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4414 }
4415 
4416 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4417 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4418 				 tx_vlan, "tx_vlan");
4419 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4420 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4421 				 set, "set");
4422 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4423 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4424 			      port_id, RTE_UINT16);
4425 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4426 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4427 			      vlan_id, RTE_UINT16);
4428 
4429 cmdline_parse_inst_t cmd_tx_vlan_set = {
4430 	.f = cmd_tx_vlan_set_parsed,
4431 	.data = NULL,
4432 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4433 		"Enable hardware insertion of a single VLAN header "
4434 		"with a given TAG Identifier in packets sent on a port",
4435 	.tokens = {
4436 		(void *)&cmd_tx_vlan_set_tx_vlan,
4437 		(void *)&cmd_tx_vlan_set_set,
4438 		(void *)&cmd_tx_vlan_set_portid,
4439 		(void *)&cmd_tx_vlan_set_vlanid,
4440 		NULL,
4441 	},
4442 };
4443 
4444 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4445 struct cmd_tx_vlan_set_qinq_result {
4446 	cmdline_fixed_string_t tx_vlan;
4447 	cmdline_fixed_string_t set;
4448 	portid_t port_id;
4449 	uint16_t vlan_id;
4450 	uint16_t vlan_id_outer;
4451 };
4452 
4453 static void
4454 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4455 			    __rte_unused struct cmdline *cl,
4456 			    __rte_unused void *data)
4457 {
4458 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4459 
4460 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4461 		return;
4462 
4463 	if (!port_is_stopped(res->port_id)) {
4464 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4465 		return;
4466 	}
4467 
4468 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4469 
4470 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4471 }
4472 
4473 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4474 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4475 		tx_vlan, "tx_vlan");
4476 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4477 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4478 		set, "set");
4479 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4480 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4481 		port_id, RTE_UINT16);
4482 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4483 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4484 		vlan_id, RTE_UINT16);
4485 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4486 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4487 		vlan_id_outer, RTE_UINT16);
4488 
4489 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4490 	.f = cmd_tx_vlan_set_qinq_parsed,
4491 	.data = NULL,
4492 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4493 		"Enable hardware insertion of double VLAN header "
4494 		"with given TAG Identifiers in packets sent on a port",
4495 	.tokens = {
4496 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4497 		(void *)&cmd_tx_vlan_set_qinq_set,
4498 		(void *)&cmd_tx_vlan_set_qinq_portid,
4499 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4500 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4501 		NULL,
4502 	},
4503 };
4504 
4505 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4506 struct cmd_tx_vlan_set_pvid_result {
4507 	cmdline_fixed_string_t tx_vlan;
4508 	cmdline_fixed_string_t set;
4509 	cmdline_fixed_string_t pvid;
4510 	portid_t port_id;
4511 	uint16_t vlan_id;
4512 	cmdline_fixed_string_t mode;
4513 };
4514 
4515 static void
4516 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4517 			    __rte_unused struct cmdline *cl,
4518 			    __rte_unused void *data)
4519 {
4520 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4521 
4522 	if (strcmp(res->mode, "on") == 0)
4523 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4524 	else
4525 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4526 }
4527 
4528 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4529 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4530 				 tx_vlan, "tx_vlan");
4531 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4532 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4533 				 set, "set");
4534 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4535 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4536 				 pvid, "pvid");
4537 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4538 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4539 			     port_id, RTE_UINT16);
4540 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4541 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4542 			      vlan_id, RTE_UINT16);
4543 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4544 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4545 				 mode, "on#off");
4546 
4547 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4548 	.f = cmd_tx_vlan_set_pvid_parsed,
4549 	.data = NULL,
4550 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4551 	.tokens = {
4552 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4553 		(void *)&cmd_tx_vlan_set_pvid_set,
4554 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4555 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4556 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4557 		(void *)&cmd_tx_vlan_set_pvid_mode,
4558 		NULL,
4559 	},
4560 };
4561 
4562 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4563 struct cmd_tx_vlan_reset_result {
4564 	cmdline_fixed_string_t tx_vlan;
4565 	cmdline_fixed_string_t reset;
4566 	portid_t port_id;
4567 };
4568 
4569 static void
4570 cmd_tx_vlan_reset_parsed(void *parsed_result,
4571 			 __rte_unused struct cmdline *cl,
4572 			 __rte_unused void *data)
4573 {
4574 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4575 
4576 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4577 		return;
4578 
4579 	if (!port_is_stopped(res->port_id)) {
4580 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4581 		return;
4582 	}
4583 
4584 	tx_vlan_reset(res->port_id);
4585 
4586 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4587 }
4588 
4589 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4590 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4591 				 tx_vlan, "tx_vlan");
4592 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4593 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4594 				 reset, "reset");
4595 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4596 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4597 			      port_id, RTE_UINT16);
4598 
4599 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4600 	.f = cmd_tx_vlan_reset_parsed,
4601 	.data = NULL,
4602 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4603 		"VLAN header in packets sent on a port",
4604 	.tokens = {
4605 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4606 		(void *)&cmd_tx_vlan_reset_reset,
4607 		(void *)&cmd_tx_vlan_reset_portid,
4608 		NULL,
4609 	},
4610 };
4611 
4612 
4613 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4614 struct cmd_csum_result {
4615 	cmdline_fixed_string_t csum;
4616 	cmdline_fixed_string_t mode;
4617 	cmdline_fixed_string_t proto;
4618 	cmdline_fixed_string_t hwsw;
4619 	portid_t port_id;
4620 };
4621 
4622 static void
4623 csum_show(int port_id)
4624 {
4625 	struct rte_eth_dev_info dev_info;
4626 	uint64_t tx_offloads;
4627 	int ret;
4628 
4629 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4630 	printf("Parse tunnel is %s\n",
4631 		(ports[port_id].parse_tunnel) ? "on" : "off");
4632 	printf("IP checksum offload is %s\n",
4633 		(tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4634 	printf("UDP checksum offload is %s\n",
4635 		(tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4636 	printf("TCP checksum offload is %s\n",
4637 		(tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4638 	printf("SCTP checksum offload is %s\n",
4639 		(tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4640 	printf("Outer-Ip checksum offload is %s\n",
4641 		(tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4642 	printf("Outer-Udp checksum offload is %s\n",
4643 		(tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4644 
4645 	/* display warnings if configuration is not supported by the NIC */
4646 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4647 	if (ret != 0)
4648 		return;
4649 
4650 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4651 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4652 		fprintf(stderr,
4653 			"Warning: hardware IP checksum enabled but not supported by port %d\n",
4654 			port_id);
4655 	}
4656 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4657 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4658 		fprintf(stderr,
4659 			"Warning: hardware UDP checksum enabled but not supported by port %d\n",
4660 			port_id);
4661 	}
4662 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4663 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4664 		fprintf(stderr,
4665 			"Warning: hardware TCP checksum enabled but not supported by port %d\n",
4666 			port_id);
4667 	}
4668 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4669 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4670 		fprintf(stderr,
4671 			"Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4672 			port_id);
4673 	}
4674 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4675 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4676 		fprintf(stderr,
4677 			"Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4678 			port_id);
4679 	}
4680 	if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4681 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4682 			== 0) {
4683 		fprintf(stderr,
4684 			"Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4685 			port_id);
4686 	}
4687 }
4688 
4689 static void
4690 cmd_config_queue_tx_offloads(struct rte_port *port)
4691 {
4692 	int k;
4693 
4694 	/* Apply queue tx offloads configuration */
4695 	for (k = 0; k < port->dev_info.max_tx_queues; k++)
4696 		port->tx_conf[k].offloads =
4697 			port->dev_conf.txmode.offloads;
4698 }
4699 
4700 static void
4701 cmd_csum_parsed(void *parsed_result,
4702 		       __rte_unused struct cmdline *cl,
4703 		       __rte_unused void *data)
4704 {
4705 	struct cmd_csum_result *res = parsed_result;
4706 	int hw = 0;
4707 	uint64_t csum_offloads = 0;
4708 	struct rte_eth_dev_info dev_info;
4709 	int ret;
4710 
4711 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4712 		fprintf(stderr, "invalid port %d\n", res->port_id);
4713 		return;
4714 	}
4715 	if (!port_is_stopped(res->port_id)) {
4716 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4717 		return;
4718 	}
4719 
4720 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4721 	if (ret != 0)
4722 		return;
4723 
4724 	if (!strcmp(res->mode, "set")) {
4725 
4726 		if (!strcmp(res->hwsw, "hw"))
4727 			hw = 1;
4728 
4729 		if (!strcmp(res->proto, "ip")) {
4730 			if (hw == 0 || (dev_info.tx_offload_capa &
4731 						RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4732 				csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4733 			} else {
4734 				fprintf(stderr,
4735 					"IP checksum offload is not supported by port %u\n",
4736 					res->port_id);
4737 			}
4738 		} else if (!strcmp(res->proto, "udp")) {
4739 			if (hw == 0 || (dev_info.tx_offload_capa &
4740 						RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4741 				csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4742 			} else {
4743 				fprintf(stderr,
4744 					"UDP checksum offload is not supported by port %u\n",
4745 					res->port_id);
4746 			}
4747 		} else if (!strcmp(res->proto, "tcp")) {
4748 			if (hw == 0 || (dev_info.tx_offload_capa &
4749 						RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4750 				csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4751 			} else {
4752 				fprintf(stderr,
4753 					"TCP checksum offload is not supported by port %u\n",
4754 					res->port_id);
4755 			}
4756 		} else if (!strcmp(res->proto, "sctp")) {
4757 			if (hw == 0 || (dev_info.tx_offload_capa &
4758 						RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4759 				csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4760 			} else {
4761 				fprintf(stderr,
4762 					"SCTP checksum offload is not supported by port %u\n",
4763 					res->port_id);
4764 			}
4765 		} else if (!strcmp(res->proto, "outer-ip")) {
4766 			if (hw == 0 || (dev_info.tx_offload_capa &
4767 					RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4768 				csum_offloads |=
4769 						RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4770 			} else {
4771 				fprintf(stderr,
4772 					"Outer IP checksum offload is not supported by port %u\n",
4773 					res->port_id);
4774 			}
4775 		} else if (!strcmp(res->proto, "outer-udp")) {
4776 			if (hw == 0 || (dev_info.tx_offload_capa &
4777 					RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4778 				csum_offloads |=
4779 						RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4780 			} else {
4781 				fprintf(stderr,
4782 					"Outer UDP checksum offload is not supported by port %u\n",
4783 					res->port_id);
4784 			}
4785 		}
4786 
4787 		if (hw) {
4788 			ports[res->port_id].dev_conf.txmode.offloads |=
4789 							csum_offloads;
4790 		} else {
4791 			ports[res->port_id].dev_conf.txmode.offloads &=
4792 							(~csum_offloads);
4793 		}
4794 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4795 	}
4796 	csum_show(res->port_id);
4797 
4798 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4799 }
4800 
4801 cmdline_parse_token_string_t cmd_csum_csum =
4802 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4803 				csum, "csum");
4804 cmdline_parse_token_string_t cmd_csum_mode =
4805 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4806 				mode, "set");
4807 cmdline_parse_token_string_t cmd_csum_proto =
4808 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4809 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4810 cmdline_parse_token_string_t cmd_csum_hwsw =
4811 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4812 				hwsw, "hw#sw");
4813 cmdline_parse_token_num_t cmd_csum_portid =
4814 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4815 				port_id, RTE_UINT16);
4816 
4817 cmdline_parse_inst_t cmd_csum_set = {
4818 	.f = cmd_csum_parsed,
4819 	.data = NULL,
4820 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4821 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4822 		"using csum forward engine",
4823 	.tokens = {
4824 		(void *)&cmd_csum_csum,
4825 		(void *)&cmd_csum_mode,
4826 		(void *)&cmd_csum_proto,
4827 		(void *)&cmd_csum_hwsw,
4828 		(void *)&cmd_csum_portid,
4829 		NULL,
4830 	},
4831 };
4832 
4833 cmdline_parse_token_string_t cmd_csum_mode_show =
4834 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4835 				mode, "show");
4836 
4837 cmdline_parse_inst_t cmd_csum_show = {
4838 	.f = cmd_csum_parsed,
4839 	.data = NULL,
4840 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4841 	.tokens = {
4842 		(void *)&cmd_csum_csum,
4843 		(void *)&cmd_csum_mode_show,
4844 		(void *)&cmd_csum_portid,
4845 		NULL,
4846 	},
4847 };
4848 
4849 /* Enable/disable tunnel parsing */
4850 struct cmd_csum_tunnel_result {
4851 	cmdline_fixed_string_t csum;
4852 	cmdline_fixed_string_t parse;
4853 	cmdline_fixed_string_t onoff;
4854 	portid_t port_id;
4855 };
4856 
4857 static void
4858 cmd_csum_tunnel_parsed(void *parsed_result,
4859 		       __rte_unused struct cmdline *cl,
4860 		       __rte_unused void *data)
4861 {
4862 	struct cmd_csum_tunnel_result *res = parsed_result;
4863 
4864 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4865 		return;
4866 
4867 	if (!strcmp(res->onoff, "on"))
4868 		ports[res->port_id].parse_tunnel = 1;
4869 	else
4870 		ports[res->port_id].parse_tunnel = 0;
4871 
4872 	csum_show(res->port_id);
4873 }
4874 
4875 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4876 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4877 				csum, "csum");
4878 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4879 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4880 				parse, "parse-tunnel");
4881 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4882 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4883 				onoff, "on#off");
4884 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4885 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4886 				port_id, RTE_UINT16);
4887 
4888 cmdline_parse_inst_t cmd_csum_tunnel = {
4889 	.f = cmd_csum_tunnel_parsed,
4890 	.data = NULL,
4891 	.help_str = "csum parse-tunnel on|off <port_id>: "
4892 		"Enable/Disable parsing of tunnels for csum engine",
4893 	.tokens = {
4894 		(void *)&cmd_csum_tunnel_csum,
4895 		(void *)&cmd_csum_tunnel_parse,
4896 		(void *)&cmd_csum_tunnel_onoff,
4897 		(void *)&cmd_csum_tunnel_portid,
4898 		NULL,
4899 	},
4900 };
4901 
4902 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4903 struct cmd_tso_set_result {
4904 	cmdline_fixed_string_t tso;
4905 	cmdline_fixed_string_t mode;
4906 	uint16_t tso_segsz;
4907 	portid_t port_id;
4908 };
4909 
4910 static void
4911 cmd_tso_set_parsed(void *parsed_result,
4912 		       __rte_unused struct cmdline *cl,
4913 		       __rte_unused void *data)
4914 {
4915 	struct cmd_tso_set_result *res = parsed_result;
4916 	struct rte_eth_dev_info dev_info;
4917 	int ret;
4918 
4919 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4920 		return;
4921 	if (!port_is_stopped(res->port_id)) {
4922 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
4923 		return;
4924 	}
4925 
4926 	if (!strcmp(res->mode, "set"))
4927 		ports[res->port_id].tso_segsz = res->tso_segsz;
4928 
4929 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4930 	if (ret != 0)
4931 		return;
4932 
4933 	if ((ports[res->port_id].tso_segsz != 0) &&
4934 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4935 		fprintf(stderr, "Error: TSO is not supported by port %d\n",
4936 			res->port_id);
4937 		return;
4938 	}
4939 
4940 	if (ports[res->port_id].tso_segsz == 0) {
4941 		ports[res->port_id].dev_conf.txmode.offloads &=
4942 						~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4943 		printf("TSO for non-tunneled packets is disabled\n");
4944 	} else {
4945 		ports[res->port_id].dev_conf.txmode.offloads |=
4946 						RTE_ETH_TX_OFFLOAD_TCP_TSO;
4947 		printf("TSO segment size for non-tunneled packets is %d\n",
4948 			ports[res->port_id].tso_segsz);
4949 	}
4950 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4951 
4952 	/* display warnings if configuration is not supported by the NIC */
4953 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4954 	if (ret != 0)
4955 		return;
4956 
4957 	if ((ports[res->port_id].tso_segsz != 0) &&
4958 		(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4959 		fprintf(stderr,
4960 			"Warning: TSO enabled but not supported by port %d\n",
4961 			res->port_id);
4962 	}
4963 
4964 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4965 }
4966 
4967 cmdline_parse_token_string_t cmd_tso_set_tso =
4968 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4969 				tso, "tso");
4970 cmdline_parse_token_string_t cmd_tso_set_mode =
4971 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4972 				mode, "set");
4973 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4974 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4975 				tso_segsz, RTE_UINT16);
4976 cmdline_parse_token_num_t cmd_tso_set_portid =
4977 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4978 				port_id, RTE_UINT16);
4979 
4980 cmdline_parse_inst_t cmd_tso_set = {
4981 	.f = cmd_tso_set_parsed,
4982 	.data = NULL,
4983 	.help_str = "tso set <tso_segsz> <port_id>: "
4984 		"Set TSO segment size of non-tunneled packets for csum engine "
4985 		"(0 to disable)",
4986 	.tokens = {
4987 		(void *)&cmd_tso_set_tso,
4988 		(void *)&cmd_tso_set_mode,
4989 		(void *)&cmd_tso_set_tso_segsz,
4990 		(void *)&cmd_tso_set_portid,
4991 		NULL,
4992 	},
4993 };
4994 
4995 cmdline_parse_token_string_t cmd_tso_show_mode =
4996 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4997 				mode, "show");
4998 
4999 
5000 cmdline_parse_inst_t cmd_tso_show = {
5001 	.f = cmd_tso_set_parsed,
5002 	.data = NULL,
5003 	.help_str = "tso show <port_id>: "
5004 		"Show TSO segment size of non-tunneled packets for csum engine",
5005 	.tokens = {
5006 		(void *)&cmd_tso_set_tso,
5007 		(void *)&cmd_tso_show_mode,
5008 		(void *)&cmd_tso_set_portid,
5009 		NULL,
5010 	},
5011 };
5012 
5013 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5014 struct cmd_tunnel_tso_set_result {
5015 	cmdline_fixed_string_t tso;
5016 	cmdline_fixed_string_t mode;
5017 	uint16_t tso_segsz;
5018 	portid_t port_id;
5019 };
5020 
5021 static struct rte_eth_dev_info
5022 check_tunnel_tso_nic_support(portid_t port_id)
5023 {
5024 	struct rte_eth_dev_info dev_info;
5025 
5026 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5027 		return dev_info;
5028 
5029 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5030 		fprintf(stderr,
5031 			"Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5032 			port_id);
5033 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5034 		fprintf(stderr,
5035 			"Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5036 			port_id);
5037 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5038 		fprintf(stderr,
5039 			"Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5040 			port_id);
5041 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5042 		fprintf(stderr,
5043 			"Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5044 			port_id);
5045 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5046 		fprintf(stderr,
5047 			"Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5048 			port_id);
5049 	if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5050 		fprintf(stderr,
5051 			"Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5052 			port_id);
5053 	return dev_info;
5054 }
5055 
5056 static void
5057 cmd_tunnel_tso_set_parsed(void *parsed_result,
5058 			  __rte_unused struct cmdline *cl,
5059 			  __rte_unused void *data)
5060 {
5061 	struct cmd_tunnel_tso_set_result *res = parsed_result;
5062 	struct rte_eth_dev_info dev_info;
5063 
5064 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5065 		return;
5066 	if (!port_is_stopped(res->port_id)) {
5067 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
5068 		return;
5069 	}
5070 
5071 	if (!strcmp(res->mode, "set"))
5072 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5073 
5074 	dev_info = check_tunnel_tso_nic_support(res->port_id);
5075 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
5076 		ports[res->port_id].dev_conf.txmode.offloads &=
5077 			~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5078 			  RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5079 			  RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5080 			  RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5081 			  RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5082 			  RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5083 		printf("TSO for tunneled packets is disabled\n");
5084 	} else {
5085 		uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5086 					 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5087 					 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5088 					 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5089 					 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5090 					 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5091 
5092 		ports[res->port_id].dev_conf.txmode.offloads |=
5093 			(tso_offloads & dev_info.tx_offload_capa);
5094 		printf("TSO segment size for tunneled packets is %d\n",
5095 			ports[res->port_id].tunnel_tso_segsz);
5096 
5097 		/* Below conditions are needed to make it work:
5098 		 * (1) tunnel TSO is supported by the NIC;
5099 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5100 		 * are recognized;
5101 		 * (3) for tunneled pkts with outer L3 of IPv4,
5102 		 * "csum set outer-ip" must be set to hw, because after tso,
5103 		 * total_len of outer IP header is changed, and the checksum
5104 		 * of outer IP header calculated by sw should be wrong; that
5105 		 * is not necessary for IPv6 tunneled pkts because there's no
5106 		 * checksum in IP header anymore.
5107 		 */
5108 
5109 		if (!ports[res->port_id].parse_tunnel)
5110 			fprintf(stderr,
5111 				"Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5112 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
5113 		      RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5114 			fprintf(stderr,
5115 				"Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5116 	}
5117 
5118 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
5119 	cmd_reconfig_device_queue(res->port_id, 1, 1);
5120 }
5121 
5122 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5123 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5124 				tso, "tunnel_tso");
5125 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5126 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5127 				mode, "set");
5128 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5129 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5130 				tso_segsz, RTE_UINT16);
5131 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5132 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5133 				port_id, RTE_UINT16);
5134 
5135 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5136 	.f = cmd_tunnel_tso_set_parsed,
5137 	.data = NULL,
5138 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5139 		"Set TSO segment size of tunneled packets for csum engine "
5140 		"(0 to disable)",
5141 	.tokens = {
5142 		(void *)&cmd_tunnel_tso_set_tso,
5143 		(void *)&cmd_tunnel_tso_set_mode,
5144 		(void *)&cmd_tunnel_tso_set_tso_segsz,
5145 		(void *)&cmd_tunnel_tso_set_portid,
5146 		NULL,
5147 	},
5148 };
5149 
5150 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5151 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5152 				mode, "show");
5153 
5154 
5155 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5156 	.f = cmd_tunnel_tso_set_parsed,
5157 	.data = NULL,
5158 	.help_str = "tunnel_tso show <port_id> "
5159 		"Show TSO segment size of tunneled packets for csum engine",
5160 	.tokens = {
5161 		(void *)&cmd_tunnel_tso_set_tso,
5162 		(void *)&cmd_tunnel_tso_show_mode,
5163 		(void *)&cmd_tunnel_tso_set_portid,
5164 		NULL,
5165 	},
5166 };
5167 
5168 #ifdef RTE_LIB_GRO
5169 /* *** SET GRO FOR A PORT *** */
5170 struct cmd_gro_enable_result {
5171 	cmdline_fixed_string_t cmd_set;
5172 	cmdline_fixed_string_t cmd_port;
5173 	cmdline_fixed_string_t cmd_keyword;
5174 	cmdline_fixed_string_t cmd_onoff;
5175 	portid_t cmd_pid;
5176 };
5177 
5178 static void
5179 cmd_gro_enable_parsed(void *parsed_result,
5180 		__rte_unused struct cmdline *cl,
5181 		__rte_unused void *data)
5182 {
5183 	struct cmd_gro_enable_result *res;
5184 
5185 	res = parsed_result;
5186 	if (!strcmp(res->cmd_keyword, "gro"))
5187 		setup_gro(res->cmd_onoff, res->cmd_pid);
5188 }
5189 
5190 cmdline_parse_token_string_t cmd_gro_enable_set =
5191 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5192 			cmd_set, "set");
5193 cmdline_parse_token_string_t cmd_gro_enable_port =
5194 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5195 			cmd_keyword, "port");
5196 cmdline_parse_token_num_t cmd_gro_enable_pid =
5197 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5198 			cmd_pid, RTE_UINT16);
5199 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5200 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5201 			cmd_keyword, "gro");
5202 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5203 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5204 			cmd_onoff, "on#off");
5205 
5206 cmdline_parse_inst_t cmd_gro_enable = {
5207 	.f = cmd_gro_enable_parsed,
5208 	.data = NULL,
5209 	.help_str = "set port <port_id> gro on|off",
5210 	.tokens = {
5211 		(void *)&cmd_gro_enable_set,
5212 		(void *)&cmd_gro_enable_port,
5213 		(void *)&cmd_gro_enable_pid,
5214 		(void *)&cmd_gro_enable_keyword,
5215 		(void *)&cmd_gro_enable_onoff,
5216 		NULL,
5217 	},
5218 };
5219 
5220 /* *** DISPLAY GRO CONFIGURATION *** */
5221 struct cmd_gro_show_result {
5222 	cmdline_fixed_string_t cmd_show;
5223 	cmdline_fixed_string_t cmd_port;
5224 	cmdline_fixed_string_t cmd_keyword;
5225 	portid_t cmd_pid;
5226 };
5227 
5228 static void
5229 cmd_gro_show_parsed(void *parsed_result,
5230 		__rte_unused struct cmdline *cl,
5231 		__rte_unused void *data)
5232 {
5233 	struct cmd_gro_show_result *res;
5234 
5235 	res = parsed_result;
5236 	if (!strcmp(res->cmd_keyword, "gro"))
5237 		show_gro(res->cmd_pid);
5238 }
5239 
5240 cmdline_parse_token_string_t cmd_gro_show_show =
5241 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5242 			cmd_show, "show");
5243 cmdline_parse_token_string_t cmd_gro_show_port =
5244 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5245 			cmd_port, "port");
5246 cmdline_parse_token_num_t cmd_gro_show_pid =
5247 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5248 			cmd_pid, RTE_UINT16);
5249 cmdline_parse_token_string_t cmd_gro_show_keyword =
5250 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5251 			cmd_keyword, "gro");
5252 
5253 cmdline_parse_inst_t cmd_gro_show = {
5254 	.f = cmd_gro_show_parsed,
5255 	.data = NULL,
5256 	.help_str = "show port <port_id> gro",
5257 	.tokens = {
5258 		(void *)&cmd_gro_show_show,
5259 		(void *)&cmd_gro_show_port,
5260 		(void *)&cmd_gro_show_pid,
5261 		(void *)&cmd_gro_show_keyword,
5262 		NULL,
5263 	},
5264 };
5265 
5266 /* *** SET FLUSH CYCLES FOR GRO *** */
5267 struct cmd_gro_flush_result {
5268 	cmdline_fixed_string_t cmd_set;
5269 	cmdline_fixed_string_t cmd_keyword;
5270 	cmdline_fixed_string_t cmd_flush;
5271 	uint8_t cmd_cycles;
5272 };
5273 
5274 static void
5275 cmd_gro_flush_parsed(void *parsed_result,
5276 		__rte_unused struct cmdline *cl,
5277 		__rte_unused void *data)
5278 {
5279 	struct cmd_gro_flush_result *res;
5280 
5281 	res = parsed_result;
5282 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5283 			(!strcmp(res->cmd_flush, "flush")))
5284 		setup_gro_flush_cycles(res->cmd_cycles);
5285 }
5286 
5287 cmdline_parse_token_string_t cmd_gro_flush_set =
5288 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5289 			cmd_set, "set");
5290 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5291 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5292 			cmd_keyword, "gro");
5293 cmdline_parse_token_string_t cmd_gro_flush_flush =
5294 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5295 			cmd_flush, "flush");
5296 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5297 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5298 			cmd_cycles, RTE_UINT8);
5299 
5300 cmdline_parse_inst_t cmd_gro_flush = {
5301 	.f = cmd_gro_flush_parsed,
5302 	.data = NULL,
5303 	.help_str = "set gro flush <cycles>",
5304 	.tokens = {
5305 		(void *)&cmd_gro_flush_set,
5306 		(void *)&cmd_gro_flush_keyword,
5307 		(void *)&cmd_gro_flush_flush,
5308 		(void *)&cmd_gro_flush_cycles,
5309 		NULL,
5310 	},
5311 };
5312 #endif /* RTE_LIB_GRO */
5313 
5314 #ifdef RTE_LIB_GSO
5315 /* *** ENABLE/DISABLE GSO *** */
5316 struct cmd_gso_enable_result {
5317 	cmdline_fixed_string_t cmd_set;
5318 	cmdline_fixed_string_t cmd_port;
5319 	cmdline_fixed_string_t cmd_keyword;
5320 	cmdline_fixed_string_t cmd_mode;
5321 	portid_t cmd_pid;
5322 };
5323 
5324 static void
5325 cmd_gso_enable_parsed(void *parsed_result,
5326 		__rte_unused struct cmdline *cl,
5327 		__rte_unused void *data)
5328 {
5329 	struct cmd_gso_enable_result *res;
5330 
5331 	res = parsed_result;
5332 	if (!strcmp(res->cmd_keyword, "gso"))
5333 		setup_gso(res->cmd_mode, res->cmd_pid);
5334 }
5335 
5336 cmdline_parse_token_string_t cmd_gso_enable_set =
5337 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5338 			cmd_set, "set");
5339 cmdline_parse_token_string_t cmd_gso_enable_port =
5340 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5341 			cmd_port, "port");
5342 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5343 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5344 			cmd_keyword, "gso");
5345 cmdline_parse_token_string_t cmd_gso_enable_mode =
5346 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5347 			cmd_mode, "on#off");
5348 cmdline_parse_token_num_t cmd_gso_enable_pid =
5349 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5350 			cmd_pid, RTE_UINT16);
5351 
5352 cmdline_parse_inst_t cmd_gso_enable = {
5353 	.f = cmd_gso_enable_parsed,
5354 	.data = NULL,
5355 	.help_str = "set port <port_id> gso on|off",
5356 	.tokens = {
5357 		(void *)&cmd_gso_enable_set,
5358 		(void *)&cmd_gso_enable_port,
5359 		(void *)&cmd_gso_enable_pid,
5360 		(void *)&cmd_gso_enable_keyword,
5361 		(void *)&cmd_gso_enable_mode,
5362 		NULL,
5363 	},
5364 };
5365 
5366 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5367 struct cmd_gso_size_result {
5368 	cmdline_fixed_string_t cmd_set;
5369 	cmdline_fixed_string_t cmd_keyword;
5370 	cmdline_fixed_string_t cmd_segsz;
5371 	uint16_t cmd_size;
5372 };
5373 
5374 static void
5375 cmd_gso_size_parsed(void *parsed_result,
5376 		       __rte_unused struct cmdline *cl,
5377 		       __rte_unused void *data)
5378 {
5379 	struct cmd_gso_size_result *res = parsed_result;
5380 
5381 	if (test_done == 0) {
5382 		fprintf(stderr,
5383 			"Before setting GSO segsz, please first stop forwarding\n");
5384 		return;
5385 	}
5386 
5387 	if (!strcmp(res->cmd_keyword, "gso") &&
5388 			!strcmp(res->cmd_segsz, "segsz")) {
5389 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5390 			fprintf(stderr,
5391 				"gso_size should be larger than %zu. Please input a legal value\n",
5392 				RTE_GSO_SEG_SIZE_MIN);
5393 		else
5394 			gso_max_segment_size = res->cmd_size;
5395 	}
5396 }
5397 
5398 cmdline_parse_token_string_t cmd_gso_size_set =
5399 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5400 				cmd_set, "set");
5401 cmdline_parse_token_string_t cmd_gso_size_keyword =
5402 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5403 				cmd_keyword, "gso");
5404 cmdline_parse_token_string_t cmd_gso_size_segsz =
5405 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5406 				cmd_segsz, "segsz");
5407 cmdline_parse_token_num_t cmd_gso_size_size =
5408 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5409 				cmd_size, RTE_UINT16);
5410 
5411 cmdline_parse_inst_t cmd_gso_size = {
5412 	.f = cmd_gso_size_parsed,
5413 	.data = NULL,
5414 	.help_str = "set gso segsz <length>",
5415 	.tokens = {
5416 		(void *)&cmd_gso_size_set,
5417 		(void *)&cmd_gso_size_keyword,
5418 		(void *)&cmd_gso_size_segsz,
5419 		(void *)&cmd_gso_size_size,
5420 		NULL,
5421 	},
5422 };
5423 
5424 /* *** SHOW GSO CONFIGURATION *** */
5425 struct cmd_gso_show_result {
5426 	cmdline_fixed_string_t cmd_show;
5427 	cmdline_fixed_string_t cmd_port;
5428 	cmdline_fixed_string_t cmd_keyword;
5429 	portid_t cmd_pid;
5430 };
5431 
5432 static void
5433 cmd_gso_show_parsed(void *parsed_result,
5434 		       __rte_unused struct cmdline *cl,
5435 		       __rte_unused void *data)
5436 {
5437 	struct cmd_gso_show_result *res = parsed_result;
5438 
5439 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5440 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5441 		return;
5442 	}
5443 	if (!strcmp(res->cmd_keyword, "gso")) {
5444 		if (gso_ports[res->cmd_pid].enable) {
5445 			printf("Max GSO'd packet size: %uB\n"
5446 					"Supported GSO types: TCP/IPv4, "
5447 					"UDP/IPv4, VxLAN with inner "
5448 					"TCP/IPv4 packet, GRE with inner "
5449 					"TCP/IPv4 packet\n",
5450 					gso_max_segment_size);
5451 		} else
5452 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5453 	}
5454 }
5455 
5456 cmdline_parse_token_string_t cmd_gso_show_show =
5457 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5458 		cmd_show, "show");
5459 cmdline_parse_token_string_t cmd_gso_show_port =
5460 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5461 		cmd_port, "port");
5462 cmdline_parse_token_string_t cmd_gso_show_keyword =
5463 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5464 				cmd_keyword, "gso");
5465 cmdline_parse_token_num_t cmd_gso_show_pid =
5466 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5467 				cmd_pid, RTE_UINT16);
5468 
5469 cmdline_parse_inst_t cmd_gso_show = {
5470 	.f = cmd_gso_show_parsed,
5471 	.data = NULL,
5472 	.help_str = "show port <port_id> gso",
5473 	.tokens = {
5474 		(void *)&cmd_gso_show_show,
5475 		(void *)&cmd_gso_show_port,
5476 		(void *)&cmd_gso_show_pid,
5477 		(void *)&cmd_gso_show_keyword,
5478 		NULL,
5479 	},
5480 };
5481 #endif /* RTE_LIB_GSO */
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 	struct rte_port *port = &ports[port_id];
5926 
5927 	/*
5928 	 * Bonding mode changed means resources of device changed, like whether
5929 	 * started rte timer or not. Device should be restarted when resources
5930 	 * of device changed.
5931 	 */
5932 	if (port->port_status != RTE_PORT_STOPPED) {
5933 		fprintf(stderr,
5934 			"\t Error: Can't set bonding mode when port %d is not stopped\n",
5935 			port_id);
5936 		return;
5937 	}
5938 
5939 	/* Set the bonding mode for the relevant port. */
5940 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5941 		fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5942 			port_id);
5943 }
5944 
5945 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5946 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5947 		set, "set");
5948 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5949 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5950 		bonding, "bonding");
5951 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5952 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5953 		mode, "mode");
5954 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5955 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5956 		value, RTE_UINT8);
5957 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5958 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5959 		port_id, RTE_UINT16);
5960 
5961 cmdline_parse_inst_t cmd_set_bonding_mode = {
5962 		.f = cmd_set_bonding_mode_parsed,
5963 		.help_str = "set bonding mode <mode_value> <port_id>: "
5964 			"Set the bonding mode for port_id",
5965 		.data = NULL,
5966 		.tokens = {
5967 				(void *) &cmd_setbonding_mode_set,
5968 				(void *) &cmd_setbonding_mode_bonding,
5969 				(void *) &cmd_setbonding_mode_mode,
5970 				(void *) &cmd_setbonding_mode_value,
5971 				(void *) &cmd_setbonding_mode_port,
5972 				NULL
5973 		}
5974 };
5975 
5976 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5977 struct cmd_set_bonding_lacp_dedicated_queues_result {
5978 	cmdline_fixed_string_t set;
5979 	cmdline_fixed_string_t bonding;
5980 	cmdline_fixed_string_t lacp;
5981 	cmdline_fixed_string_t dedicated_queues;
5982 	portid_t port_id;
5983 	cmdline_fixed_string_t mode;
5984 };
5985 
5986 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5987 		__rte_unused  struct cmdline *cl,
5988 		__rte_unused void *data)
5989 {
5990 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5991 	portid_t port_id = res->port_id;
5992 	struct rte_port *port;
5993 
5994 	port = &ports[port_id];
5995 
5996 	/** Check if the port is not started **/
5997 	if (port->port_status != RTE_PORT_STOPPED) {
5998 		fprintf(stderr, "Please stop port %d first\n", port_id);
5999 		return;
6000 	}
6001 
6002 	if (!strcmp(res->mode, "enable")) {
6003 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
6004 			printf("Dedicate queues for LACP control packets"
6005 					" enabled\n");
6006 		else
6007 			printf("Enabling dedicate queues for LACP control "
6008 					"packets on port %d failed\n", port_id);
6009 	} else if (!strcmp(res->mode, "disable")) {
6010 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6011 			printf("Dedicated queues for LACP control packets "
6012 					"disabled\n");
6013 		else
6014 			printf("Disabling dedicated queues for LACP control "
6015 					"traffic on port %d failed\n", port_id);
6016 	}
6017 }
6018 
6019 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6021 		set, "set");
6022 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6023 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6024 		bonding, "bonding");
6025 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6026 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6027 		lacp, "lacp");
6028 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6029 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6030 		dedicated_queues, "dedicated_queues");
6031 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6032 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6033 		port_id, RTE_UINT16);
6034 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6035 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6036 		mode, "enable#disable");
6037 
6038 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6039 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6040 		.help_str = "set bonding lacp dedicated_queues <port_id> "
6041 			"enable|disable: "
6042 			"Enable/disable dedicated queues for LACP control traffic for port_id",
6043 		.data = NULL,
6044 		.tokens = {
6045 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
6046 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6047 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6048 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6049 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6050 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6051 			NULL
6052 		}
6053 };
6054 
6055 /* *** SET BALANCE XMIT POLICY *** */
6056 struct cmd_set_bonding_balance_xmit_policy_result {
6057 	cmdline_fixed_string_t set;
6058 	cmdline_fixed_string_t bonding;
6059 	cmdline_fixed_string_t balance_xmit_policy;
6060 	portid_t port_id;
6061 	cmdline_fixed_string_t policy;
6062 };
6063 
6064 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6065 		__rte_unused  struct cmdline *cl,
6066 		__rte_unused void *data)
6067 {
6068 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6069 	portid_t port_id = res->port_id;
6070 	uint8_t policy;
6071 
6072 	if (!strcmp(res->policy, "l2")) {
6073 		policy = BALANCE_XMIT_POLICY_LAYER2;
6074 	} else if (!strcmp(res->policy, "l23")) {
6075 		policy = BALANCE_XMIT_POLICY_LAYER23;
6076 	} else if (!strcmp(res->policy, "l34")) {
6077 		policy = BALANCE_XMIT_POLICY_LAYER34;
6078 	} else {
6079 		fprintf(stderr, "\t Invalid xmit policy selection");
6080 		return;
6081 	}
6082 
6083 	/* Set the bonding mode for the relevant port. */
6084 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6085 		fprintf(stderr,
6086 			"\t Failed to set bonding balance xmit policy for port = %d.\n",
6087 			port_id);
6088 	}
6089 }
6090 
6091 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6092 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6093 		set, "set");
6094 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6096 		bonding, "bonding");
6097 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6098 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6099 		balance_xmit_policy, "balance_xmit_policy");
6100 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6101 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6102 		port_id, RTE_UINT16);
6103 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6104 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6105 		policy, "l2#l23#l34");
6106 
6107 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6108 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
6109 		.help_str = "set bonding balance_xmit_policy <port_id> "
6110 			"l2|l23|l34: "
6111 			"Set the bonding balance_xmit_policy for port_id",
6112 		.data = NULL,
6113 		.tokens = {
6114 				(void *)&cmd_setbonding_balance_xmit_policy_set,
6115 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
6116 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6117 				(void *)&cmd_setbonding_balance_xmit_policy_port,
6118 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
6119 				NULL
6120 		}
6121 };
6122 
6123 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6124 struct cmd_show_bonding_lacp_info_result {
6125 	cmdline_fixed_string_t show;
6126 	cmdline_fixed_string_t bonding;
6127 	cmdline_fixed_string_t lacp;
6128 	cmdline_fixed_string_t info;
6129 	portid_t port_id;
6130 };
6131 
6132 static void port_param_show(struct port_params *params)
6133 {
6134 	char buf[RTE_ETHER_ADDR_FMT_SIZE];
6135 
6136 	printf("\t\tsystem priority: %u\n", params->system_priority);
6137 	rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, &params->system);
6138 	printf("\t\tsystem mac address: %s\n", buf);
6139 	printf("\t\tport key: %u\n", params->key);
6140 	printf("\t\tport priority: %u\n", params->port_priority);
6141 	printf("\t\tport number: %u\n", params->port_number);
6142 }
6143 
6144 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6145 {
6146 	char a_state[256] = { 0 };
6147 	char p_state[256] = { 0 };
6148 	int a_len = 0;
6149 	int p_len = 0;
6150 	uint32_t i;
6151 
6152 	static const char * const state[] = {
6153 		"ACTIVE",
6154 		"TIMEOUT",
6155 		"AGGREGATION",
6156 		"SYNCHRONIZATION",
6157 		"COLLECTING",
6158 		"DISTRIBUTING",
6159 		"DEFAULTED",
6160 		"EXPIRED"
6161 	};
6162 	static const char * const selection[] = {
6163 		"UNSELECTED",
6164 		"STANDBY",
6165 		"SELECTED"
6166 	};
6167 
6168 	for (i = 0; i < RTE_DIM(state); i++) {
6169 		if ((info->actor_state >> i) & 1)
6170 			a_len += snprintf(&a_state[a_len],
6171 						RTE_DIM(a_state) - a_len, "%s ",
6172 						state[i]);
6173 
6174 		if ((info->partner_state >> i) & 1)
6175 			p_len += snprintf(&p_state[p_len],
6176 						RTE_DIM(p_state) - p_len, "%s ",
6177 						state[i]);
6178 	}
6179 	printf("\tAggregator port id: %u\n", info->agg_port_id);
6180 	printf("\tselection: %s\n", selection[info->selected]);
6181 	printf("\tActor detail info:\n");
6182 	port_param_show(&info->actor);
6183 	printf("\t\tport state: %s\n", a_state);
6184 	printf("\tPartner detail info:\n");
6185 	port_param_show(&info->partner);
6186 	printf("\t\tport state: %s\n", p_state);
6187 	printf("\n");
6188 }
6189 
6190 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6191 {
6192 	printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6193 	printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6194 	printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6195 	printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6196 	printf("\taggregate wait timeout: %u ms\n",
6197 			conf->aggregate_wait_timeout_ms);
6198 	printf("\ttx period: %u ms\n", conf->tx_period_ms);
6199 	printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6200 	printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6201 	switch (conf->agg_selection) {
6202 	case AGG_BANDWIDTH:
6203 		printf("\taggregation mode: bandwidth\n");
6204 		break;
6205 	case AGG_STABLE:
6206 		printf("\taggregation mode: stable\n");
6207 		break;
6208 	case AGG_COUNT:
6209 		printf("\taggregation mode: count\n");
6210 		break;
6211 	default:
6212 		printf("\taggregation mode: invalid\n");
6213 		break;
6214 	}
6215 
6216 	printf("\n");
6217 }
6218 
6219 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6220 		__rte_unused  struct cmdline *cl,
6221 		__rte_unused void *data)
6222 {
6223 	struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6224 	struct rte_eth_bond_8023ad_slave_info slave_info;
6225 	struct rte_eth_bond_8023ad_conf port_conf;
6226 	portid_t slaves[RTE_MAX_ETHPORTS];
6227 	portid_t port_id = res->port_id;
6228 	int num_active_slaves;
6229 	int bonding_mode;
6230 	int i;
6231 	int ret;
6232 
6233 	bonding_mode = rte_eth_bond_mode_get(port_id);
6234 	if (bonding_mode != BONDING_MODE_8023AD) {
6235 		fprintf(stderr, "\tBonding mode is not mode 4\n");
6236 		return;
6237 	}
6238 
6239 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6240 			RTE_MAX_ETHPORTS);
6241 	if (num_active_slaves < 0) {
6242 		fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6243 				port_id);
6244 		return;
6245 	}
6246 	if (num_active_slaves == 0)
6247 		fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6248 			port_id);
6249 
6250 	printf("\tIEEE802.3 port: %u\n", port_id);
6251 	ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6252 	if (ret) {
6253 		fprintf(stderr, "\tGet bonded device %u info failed\n",
6254 			port_id);
6255 		return;
6256 	}
6257 	lacp_conf_show(&port_conf);
6258 
6259 	for (i = 0; i < num_active_slaves; i++) {
6260 		ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6261 				&slave_info);
6262 		if (ret) {
6263 			fprintf(stderr, "\tGet slave device %u info failed\n",
6264 				slaves[i]);
6265 			return;
6266 		}
6267 		printf("\tSlave Port: %u\n", slaves[i]);
6268 		lacp_slave_info_show(&slave_info);
6269 	}
6270 }
6271 
6272 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6273 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6274 		show, "show");
6275 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6276 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6277 		bonding, "bonding");
6278 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6279 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6280 		bonding, "lacp");
6281 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6282 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6283 		info, "info");
6284 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6285 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6286 		port_id, RTE_UINT16);
6287 
6288 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6289 		.f = cmd_show_bonding_lacp_info_parsed,
6290 		.help_str = "show bonding lacp info <port_id> : "
6291 			"Show bonding IEEE802.3 information for port_id",
6292 		.data = NULL,
6293 		.tokens = {
6294 			(void *)&cmd_show_bonding_lacp_info_show,
6295 			(void *)&cmd_show_bonding_lacp_info_bonding,
6296 			(void *)&cmd_show_bonding_lacp_info_lacp,
6297 			(void *)&cmd_show_bonding_lacp_info_info,
6298 			(void *)&cmd_show_bonding_lacp_info_port_id,
6299 			NULL
6300 		}
6301 };
6302 
6303 /* *** SHOW NIC BONDING CONFIGURATION *** */
6304 struct cmd_show_bonding_config_result {
6305 	cmdline_fixed_string_t show;
6306 	cmdline_fixed_string_t bonding;
6307 	cmdline_fixed_string_t config;
6308 	portid_t port_id;
6309 };
6310 
6311 static void cmd_show_bonding_config_parsed(void *parsed_result,
6312 		__rte_unused  struct cmdline *cl,
6313 		__rte_unused void *data)
6314 {
6315 	struct cmd_show_bonding_config_result *res = parsed_result;
6316 	int bonding_mode, agg_mode;
6317 	portid_t slaves[RTE_MAX_ETHPORTS];
6318 	int num_slaves, num_active_slaves;
6319 	int primary_id;
6320 	int i;
6321 	portid_t port_id = res->port_id;
6322 
6323 	/* Display the bonding mode.*/
6324 	bonding_mode = rte_eth_bond_mode_get(port_id);
6325 	if (bonding_mode < 0) {
6326 		fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6327 			port_id);
6328 		return;
6329 	} else
6330 		printf("\tBonding mode: %d\n", bonding_mode);
6331 
6332 	if (bonding_mode == BONDING_MODE_BALANCE ||
6333 		bonding_mode == BONDING_MODE_8023AD) {
6334 		int balance_xmit_policy;
6335 
6336 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6337 		if (balance_xmit_policy < 0) {
6338 			fprintf(stderr,
6339 				"\tFailed to get balance xmit policy for port = %d\n",
6340 				port_id);
6341 			return;
6342 		} else {
6343 			printf("\tBalance Xmit Policy: ");
6344 
6345 			switch (balance_xmit_policy) {
6346 			case BALANCE_XMIT_POLICY_LAYER2:
6347 				printf("BALANCE_XMIT_POLICY_LAYER2");
6348 				break;
6349 			case BALANCE_XMIT_POLICY_LAYER23:
6350 				printf("BALANCE_XMIT_POLICY_LAYER23");
6351 				break;
6352 			case BALANCE_XMIT_POLICY_LAYER34:
6353 				printf("BALANCE_XMIT_POLICY_LAYER34");
6354 				break;
6355 			}
6356 			printf("\n");
6357 		}
6358 	}
6359 
6360 	if (bonding_mode == BONDING_MODE_8023AD) {
6361 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6362 		printf("\tIEEE802.3AD Aggregator Mode: ");
6363 		switch (agg_mode) {
6364 		case AGG_BANDWIDTH:
6365 			printf("bandwidth");
6366 			break;
6367 		case AGG_STABLE:
6368 			printf("stable");
6369 			break;
6370 		case AGG_COUNT:
6371 			printf("count");
6372 			break;
6373 		}
6374 		printf("\n");
6375 	}
6376 
6377 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6378 
6379 	if (num_slaves < 0) {
6380 		fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6381 			port_id);
6382 		return;
6383 	}
6384 	if (num_slaves > 0) {
6385 		printf("\tSlaves (%d): [", num_slaves);
6386 		for (i = 0; i < num_slaves - 1; i++)
6387 			printf("%d ", slaves[i]);
6388 
6389 		printf("%d]\n", slaves[num_slaves - 1]);
6390 	} else {
6391 		printf("\tSlaves: []\n");
6392 
6393 	}
6394 
6395 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6396 			RTE_MAX_ETHPORTS);
6397 
6398 	if (num_active_slaves < 0) {
6399 		fprintf(stderr,
6400 			"\tFailed to get active slave list for port = %d\n",
6401 			port_id);
6402 		return;
6403 	}
6404 	if (num_active_slaves > 0) {
6405 		printf("\tActive Slaves (%d): [", num_active_slaves);
6406 		for (i = 0; i < num_active_slaves - 1; i++)
6407 			printf("%d ", slaves[i]);
6408 
6409 		printf("%d]\n", slaves[num_active_slaves - 1]);
6410 
6411 	} else {
6412 		printf("\tActive Slaves: []\n");
6413 
6414 	}
6415 
6416 	primary_id = rte_eth_bond_primary_get(port_id);
6417 	if (primary_id < 0) {
6418 		fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6419 			port_id);
6420 		return;
6421 	} else
6422 		printf("\tPrimary: [%d]\n", primary_id);
6423 
6424 }
6425 
6426 cmdline_parse_token_string_t cmd_showbonding_config_show =
6427 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6428 		show, "show");
6429 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6430 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6431 		bonding, "bonding");
6432 cmdline_parse_token_string_t cmd_showbonding_config_config =
6433 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6434 		config, "config");
6435 cmdline_parse_token_num_t cmd_showbonding_config_port =
6436 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6437 		port_id, RTE_UINT16);
6438 
6439 cmdline_parse_inst_t cmd_show_bonding_config = {
6440 		.f = cmd_show_bonding_config_parsed,
6441 		.help_str = "show bonding config <port_id>: "
6442 			"Show the bonding config for port_id",
6443 		.data = NULL,
6444 		.tokens = {
6445 				(void *)&cmd_showbonding_config_show,
6446 				(void *)&cmd_showbonding_config_bonding,
6447 				(void *)&cmd_showbonding_config_config,
6448 				(void *)&cmd_showbonding_config_port,
6449 				NULL
6450 		}
6451 };
6452 
6453 /* *** SET BONDING PRIMARY *** */
6454 struct cmd_set_bonding_primary_result {
6455 	cmdline_fixed_string_t set;
6456 	cmdline_fixed_string_t bonding;
6457 	cmdline_fixed_string_t primary;
6458 	portid_t slave_id;
6459 	portid_t port_id;
6460 };
6461 
6462 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6463 		__rte_unused  struct cmdline *cl,
6464 		__rte_unused void *data)
6465 {
6466 	struct cmd_set_bonding_primary_result *res = parsed_result;
6467 	portid_t master_port_id = res->port_id;
6468 	portid_t slave_port_id = res->slave_id;
6469 
6470 	/* Set the primary slave for a bonded device. */
6471 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6472 		fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6473 			master_port_id);
6474 		return;
6475 	}
6476 	init_port_config();
6477 }
6478 
6479 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6481 		set, "set");
6482 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6484 		bonding, "bonding");
6485 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6487 		primary, "primary");
6488 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6489 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6490 		slave_id, RTE_UINT16);
6491 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6492 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6493 		port_id, RTE_UINT16);
6494 
6495 cmdline_parse_inst_t cmd_set_bonding_primary = {
6496 		.f = cmd_set_bonding_primary_parsed,
6497 		.help_str = "set bonding primary <slave_id> <port_id>: "
6498 			"Set the primary slave for port_id",
6499 		.data = NULL,
6500 		.tokens = {
6501 				(void *)&cmd_setbonding_primary_set,
6502 				(void *)&cmd_setbonding_primary_bonding,
6503 				(void *)&cmd_setbonding_primary_primary,
6504 				(void *)&cmd_setbonding_primary_slave,
6505 				(void *)&cmd_setbonding_primary_port,
6506 				NULL
6507 		}
6508 };
6509 
6510 /* *** ADD SLAVE *** */
6511 struct cmd_add_bonding_slave_result {
6512 	cmdline_fixed_string_t add;
6513 	cmdline_fixed_string_t bonding;
6514 	cmdline_fixed_string_t slave;
6515 	portid_t slave_id;
6516 	portid_t port_id;
6517 };
6518 
6519 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6520 		__rte_unused  struct cmdline *cl,
6521 		__rte_unused void *data)
6522 {
6523 	struct cmd_add_bonding_slave_result *res = parsed_result;
6524 	portid_t master_port_id = res->port_id;
6525 	portid_t slave_port_id = res->slave_id;
6526 
6527 	/* add the slave for a bonded device. */
6528 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6529 		fprintf(stderr,
6530 			"\t Failed to add slave %d to master port = %d.\n",
6531 			slave_port_id, master_port_id);
6532 		return;
6533 	}
6534 	init_port_config();
6535 	set_port_slave_flag(slave_port_id);
6536 }
6537 
6538 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6539 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6540 		add, "add");
6541 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6542 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6543 		bonding, "bonding");
6544 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6545 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6546 		slave, "slave");
6547 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6548 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6549 		slave_id, RTE_UINT16);
6550 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6551 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6552 		port_id, RTE_UINT16);
6553 
6554 cmdline_parse_inst_t cmd_add_bonding_slave = {
6555 		.f = cmd_add_bonding_slave_parsed,
6556 		.help_str = "add bonding slave <slave_id> <port_id>: "
6557 			"Add a slave device to a bonded device",
6558 		.data = NULL,
6559 		.tokens = {
6560 				(void *)&cmd_addbonding_slave_add,
6561 				(void *)&cmd_addbonding_slave_bonding,
6562 				(void *)&cmd_addbonding_slave_slave,
6563 				(void *)&cmd_addbonding_slave_slaveid,
6564 				(void *)&cmd_addbonding_slave_port,
6565 				NULL
6566 		}
6567 };
6568 
6569 /* *** REMOVE SLAVE *** */
6570 struct cmd_remove_bonding_slave_result {
6571 	cmdline_fixed_string_t remove;
6572 	cmdline_fixed_string_t bonding;
6573 	cmdline_fixed_string_t slave;
6574 	portid_t slave_id;
6575 	portid_t port_id;
6576 };
6577 
6578 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6579 		__rte_unused  struct cmdline *cl,
6580 		__rte_unused void *data)
6581 {
6582 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6583 	portid_t master_port_id = res->port_id;
6584 	portid_t slave_port_id = res->slave_id;
6585 
6586 	/* remove the slave from a bonded device. */
6587 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6588 		fprintf(stderr,
6589 			"\t Failed to remove slave %d from master port = %d.\n",
6590 			slave_port_id, master_port_id);
6591 		return;
6592 	}
6593 	init_port_config();
6594 	clear_port_slave_flag(slave_port_id);
6595 }
6596 
6597 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6598 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6599 				remove, "remove");
6600 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6601 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6602 				bonding, "bonding");
6603 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6604 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6605 				slave, "slave");
6606 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6607 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6608 				slave_id, RTE_UINT16);
6609 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6610 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6611 				port_id, RTE_UINT16);
6612 
6613 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6614 		.f = cmd_remove_bonding_slave_parsed,
6615 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6616 			"Remove a slave device from a bonded device",
6617 		.data = NULL,
6618 		.tokens = {
6619 				(void *)&cmd_removebonding_slave_remove,
6620 				(void *)&cmd_removebonding_slave_bonding,
6621 				(void *)&cmd_removebonding_slave_slave,
6622 				(void *)&cmd_removebonding_slave_slaveid,
6623 				(void *)&cmd_removebonding_slave_port,
6624 				NULL
6625 		}
6626 };
6627 
6628 /* *** CREATE BONDED DEVICE *** */
6629 struct cmd_create_bonded_device_result {
6630 	cmdline_fixed_string_t create;
6631 	cmdline_fixed_string_t bonded;
6632 	cmdline_fixed_string_t device;
6633 	uint8_t mode;
6634 	uint8_t socket;
6635 };
6636 
6637 static int bond_dev_num = 0;
6638 
6639 static void cmd_create_bonded_device_parsed(void *parsed_result,
6640 		__rte_unused  struct cmdline *cl,
6641 		__rte_unused void *data)
6642 {
6643 	struct cmd_create_bonded_device_result *res = parsed_result;
6644 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6645 	int port_id;
6646 	int ret;
6647 
6648 	if (test_done == 0) {
6649 		fprintf(stderr, "Please stop forwarding first\n");
6650 		return;
6651 	}
6652 
6653 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6654 			bond_dev_num++);
6655 
6656 	/* Create a new bonded device. */
6657 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6658 	if (port_id < 0) {
6659 		fprintf(stderr, "\t Failed to create bonded device.\n");
6660 		return;
6661 	} else {
6662 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6663 				port_id);
6664 
6665 		/* Update number of ports */
6666 		nb_ports = rte_eth_dev_count_avail();
6667 		reconfig(port_id, res->socket);
6668 		ret = rte_eth_promiscuous_enable(port_id);
6669 		if (ret != 0)
6670 			fprintf(stderr,
6671 				"Failed to enable promiscuous mode for port %u: %s - ignore\n",
6672 				port_id, rte_strerror(-ret));
6673 
6674 		ports[port_id].need_setup = 0;
6675 		ports[port_id].port_status = RTE_PORT_STOPPED;
6676 	}
6677 
6678 }
6679 
6680 cmdline_parse_token_string_t cmd_createbonded_device_create =
6681 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6682 				create, "create");
6683 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6684 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6685 				bonded, "bonded");
6686 cmdline_parse_token_string_t cmd_createbonded_device_device =
6687 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6688 				device, "device");
6689 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6690 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6691 				mode, RTE_UINT8);
6692 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6693 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6694 				socket, RTE_UINT8);
6695 
6696 cmdline_parse_inst_t cmd_create_bonded_device = {
6697 		.f = cmd_create_bonded_device_parsed,
6698 		.help_str = "create bonded device <mode> <socket>: "
6699 			"Create a new bonded device with specific bonding mode and socket",
6700 		.data = NULL,
6701 		.tokens = {
6702 				(void *)&cmd_createbonded_device_create,
6703 				(void *)&cmd_createbonded_device_bonded,
6704 				(void *)&cmd_createbonded_device_device,
6705 				(void *)&cmd_createbonded_device_mode,
6706 				(void *)&cmd_createbonded_device_socket,
6707 				NULL
6708 		}
6709 };
6710 
6711 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6712 struct cmd_set_bond_mac_addr_result {
6713 	cmdline_fixed_string_t set;
6714 	cmdline_fixed_string_t bonding;
6715 	cmdline_fixed_string_t mac_addr;
6716 	uint16_t port_num;
6717 	struct rte_ether_addr address;
6718 };
6719 
6720 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6721 		__rte_unused  struct cmdline *cl,
6722 		__rte_unused void *data)
6723 {
6724 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6725 	int ret;
6726 
6727 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6728 		return;
6729 
6730 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6731 
6732 	/* check the return value and print it if is < 0 */
6733 	if (ret < 0)
6734 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6735 			strerror(-ret));
6736 }
6737 
6738 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6739 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6740 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6741 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6742 				"bonding");
6743 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6744 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6745 				"mac_addr");
6746 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6747 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6748 				port_num, RTE_UINT16);
6749 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6750 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6751 
6752 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6753 		.f = cmd_set_bond_mac_addr_parsed,
6754 		.data = (void *) 0,
6755 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6756 		.tokens = {
6757 				(void *)&cmd_set_bond_mac_addr_set,
6758 				(void *)&cmd_set_bond_mac_addr_bonding,
6759 				(void *)&cmd_set_bond_mac_addr_mac,
6760 				(void *)&cmd_set_bond_mac_addr_portnum,
6761 				(void *)&cmd_set_bond_mac_addr_addr,
6762 				NULL
6763 		}
6764 };
6765 
6766 
6767 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6768 struct cmd_set_bond_mon_period_result {
6769 	cmdline_fixed_string_t set;
6770 	cmdline_fixed_string_t bonding;
6771 	cmdline_fixed_string_t mon_period;
6772 	uint16_t port_num;
6773 	uint32_t period_ms;
6774 };
6775 
6776 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6777 		__rte_unused  struct cmdline *cl,
6778 		__rte_unused void *data)
6779 {
6780 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6781 	int ret;
6782 
6783 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6784 
6785 	/* check the return value and print it if is < 0 */
6786 	if (ret < 0)
6787 		fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6788 			strerror(-ret));
6789 }
6790 
6791 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6792 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6793 				set, "set");
6794 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6795 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6796 				bonding, "bonding");
6797 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6798 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6799 				mon_period,	"mon_period");
6800 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6801 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6802 				port_num, RTE_UINT16);
6803 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6804 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6805 				period_ms, RTE_UINT32);
6806 
6807 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6808 		.f = cmd_set_bond_mon_period_parsed,
6809 		.data = (void *) 0,
6810 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6811 		.tokens = {
6812 				(void *)&cmd_set_bond_mon_period_set,
6813 				(void *)&cmd_set_bond_mon_period_bonding,
6814 				(void *)&cmd_set_bond_mon_period_mon_period,
6815 				(void *)&cmd_set_bond_mon_period_portnum,
6816 				(void *)&cmd_set_bond_mon_period_period_ms,
6817 				NULL
6818 		}
6819 };
6820 
6821 
6822 
6823 struct cmd_set_bonding_agg_mode_policy_result {
6824 	cmdline_fixed_string_t set;
6825 	cmdline_fixed_string_t bonding;
6826 	cmdline_fixed_string_t agg_mode;
6827 	uint16_t port_num;
6828 	cmdline_fixed_string_t policy;
6829 };
6830 
6831 
6832 static void
6833 cmd_set_bonding_agg_mode(void *parsed_result,
6834 		__rte_unused struct cmdline *cl,
6835 		__rte_unused void *data)
6836 {
6837 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6838 	uint8_t policy = AGG_BANDWIDTH;
6839 
6840 	if (!strcmp(res->policy, "bandwidth"))
6841 		policy = AGG_BANDWIDTH;
6842 	else if (!strcmp(res->policy, "stable"))
6843 		policy = AGG_STABLE;
6844 	else if (!strcmp(res->policy, "count"))
6845 		policy = AGG_COUNT;
6846 
6847 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6848 }
6849 
6850 
6851 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6852 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6853 				set, "set");
6854 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6855 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6856 				bonding, "bonding");
6857 
6858 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6859 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6860 				agg_mode, "agg_mode");
6861 
6862 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6863 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6864 				port_num, RTE_UINT16);
6865 
6866 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6867 	TOKEN_STRING_INITIALIZER(
6868 			struct cmd_set_bonding_balance_xmit_policy_result,
6869 		policy, "stable#bandwidth#count");
6870 
6871 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6872 	.f = cmd_set_bonding_agg_mode,
6873 	.data = (void *) 0,
6874 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6875 	.tokens = {
6876 			(void *)&cmd_set_bonding_agg_mode_set,
6877 			(void *)&cmd_set_bonding_agg_mode_bonding,
6878 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6879 			(void *)&cmd_set_bonding_agg_mode_portnum,
6880 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6881 			NULL
6882 		}
6883 };
6884 
6885 
6886 #endif /* RTE_NET_BOND */
6887 
6888 /* *** SET FORWARDING MODE *** */
6889 struct cmd_set_fwd_mode_result {
6890 	cmdline_fixed_string_t set;
6891 	cmdline_fixed_string_t fwd;
6892 	cmdline_fixed_string_t mode;
6893 };
6894 
6895 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6896 				    __rte_unused struct cmdline *cl,
6897 				    __rte_unused void *data)
6898 {
6899 	struct cmd_set_fwd_mode_result *res = parsed_result;
6900 
6901 	retry_enabled = 0;
6902 	set_pkt_forwarding_mode(res->mode);
6903 }
6904 
6905 cmdline_parse_token_string_t cmd_setfwd_set =
6906 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6907 cmdline_parse_token_string_t cmd_setfwd_fwd =
6908 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6909 cmdline_parse_token_string_t cmd_setfwd_mode =
6910 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6911 		"" /* defined at init */);
6912 
6913 cmdline_parse_inst_t cmd_set_fwd_mode = {
6914 	.f = cmd_set_fwd_mode_parsed,
6915 	.data = NULL,
6916 	.help_str = NULL, /* defined at init */
6917 	.tokens = {
6918 		(void *)&cmd_setfwd_set,
6919 		(void *)&cmd_setfwd_fwd,
6920 		(void *)&cmd_setfwd_mode,
6921 		NULL,
6922 	},
6923 };
6924 
6925 static void cmd_set_fwd_mode_init(void)
6926 {
6927 	char *modes, *c;
6928 	static char token[128];
6929 	static char help[256];
6930 	cmdline_parse_token_string_t *token_struct;
6931 
6932 	modes = list_pkt_forwarding_modes();
6933 	snprintf(help, sizeof(help), "set fwd %s: "
6934 		"Set packet forwarding mode", modes);
6935 	cmd_set_fwd_mode.help_str = help;
6936 
6937 	/* string token separator is # */
6938 	for (c = token; *modes != '\0'; modes++)
6939 		if (*modes == '|')
6940 			*c++ = '#';
6941 		else
6942 			*c++ = *modes;
6943 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6944 	token_struct->string_data.str = token;
6945 }
6946 
6947 /* *** SET RETRY FORWARDING MODE *** */
6948 struct cmd_set_fwd_retry_mode_result {
6949 	cmdline_fixed_string_t set;
6950 	cmdline_fixed_string_t fwd;
6951 	cmdline_fixed_string_t mode;
6952 	cmdline_fixed_string_t retry;
6953 };
6954 
6955 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6956 			    __rte_unused struct cmdline *cl,
6957 			    __rte_unused void *data)
6958 {
6959 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6960 
6961 	retry_enabled = 1;
6962 	set_pkt_forwarding_mode(res->mode);
6963 }
6964 
6965 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6966 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6967 			set, "set");
6968 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6969 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6970 			fwd, "fwd");
6971 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6972 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6973 			mode,
6974 		"" /* defined at init */);
6975 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6976 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6977 			retry, "retry");
6978 
6979 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6980 	.f = cmd_set_fwd_retry_mode_parsed,
6981 	.data = NULL,
6982 	.help_str = NULL, /* defined at init */
6983 	.tokens = {
6984 		(void *)&cmd_setfwd_retry_set,
6985 		(void *)&cmd_setfwd_retry_fwd,
6986 		(void *)&cmd_setfwd_retry_mode,
6987 		(void *)&cmd_setfwd_retry_retry,
6988 		NULL,
6989 	},
6990 };
6991 
6992 static void cmd_set_fwd_retry_mode_init(void)
6993 {
6994 	char *modes, *c;
6995 	static char token[128];
6996 	static char help[256];
6997 	cmdline_parse_token_string_t *token_struct;
6998 
6999 	modes = list_pkt_forwarding_retry_modes();
7000 	snprintf(help, sizeof(help), "set fwd %s retry: "
7001 		"Set packet forwarding mode with retry", modes);
7002 	cmd_set_fwd_retry_mode.help_str = help;
7003 
7004 	/* string token separator is # */
7005 	for (c = token; *modes != '\0'; modes++)
7006 		if (*modes == '|')
7007 			*c++ = '#';
7008 		else
7009 			*c++ = *modes;
7010 	token_struct = (cmdline_parse_token_string_t *)
7011 		cmd_set_fwd_retry_mode.tokens[2];
7012 	token_struct->string_data.str = token;
7013 }
7014 
7015 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7016 struct cmd_set_burst_tx_retry_result {
7017 	cmdline_fixed_string_t set;
7018 	cmdline_fixed_string_t burst;
7019 	cmdline_fixed_string_t tx;
7020 	cmdline_fixed_string_t delay;
7021 	uint32_t time;
7022 	cmdline_fixed_string_t retry;
7023 	uint32_t retry_num;
7024 };
7025 
7026 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7027 					__rte_unused struct cmdline *cl,
7028 					__rte_unused void *data)
7029 {
7030 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
7031 
7032 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7033 		&& !strcmp(res->tx, "tx")) {
7034 		if (!strcmp(res->delay, "delay"))
7035 			burst_tx_delay_time = res->time;
7036 		if (!strcmp(res->retry, "retry"))
7037 			burst_tx_retry_num = res->retry_num;
7038 	}
7039 
7040 }
7041 
7042 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7043 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7044 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7045 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7046 				 "burst");
7047 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7048 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7049 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7050 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7051 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7052 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7053 				 RTE_UINT32);
7054 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7055 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7056 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7057 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7058 				 RTE_UINT32);
7059 
7060 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7061 	.f = cmd_set_burst_tx_retry_parsed,
7062 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7063 	.tokens = {
7064 		(void *)&cmd_set_burst_tx_retry_set,
7065 		(void *)&cmd_set_burst_tx_retry_burst,
7066 		(void *)&cmd_set_burst_tx_retry_tx,
7067 		(void *)&cmd_set_burst_tx_retry_delay,
7068 		(void *)&cmd_set_burst_tx_retry_time,
7069 		(void *)&cmd_set_burst_tx_retry_retry,
7070 		(void *)&cmd_set_burst_tx_retry_retry_num,
7071 		NULL,
7072 	},
7073 };
7074 
7075 /* *** SET PROMISC MODE *** */
7076 struct cmd_set_promisc_mode_result {
7077 	cmdline_fixed_string_t set;
7078 	cmdline_fixed_string_t promisc;
7079 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7080 	uint16_t port_num;               /* valid if "allports" argument == 0 */
7081 	cmdline_fixed_string_t mode;
7082 };
7083 
7084 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7085 					__rte_unused struct cmdline *cl,
7086 					void *allports)
7087 {
7088 	struct cmd_set_promisc_mode_result *res = parsed_result;
7089 	int enable;
7090 	portid_t i;
7091 
7092 	if (!strcmp(res->mode, "on"))
7093 		enable = 1;
7094 	else
7095 		enable = 0;
7096 
7097 	/* all ports */
7098 	if (allports) {
7099 		RTE_ETH_FOREACH_DEV(i)
7100 			eth_set_promisc_mode(i, enable);
7101 	} else {
7102 		eth_set_promisc_mode(res->port_num, enable);
7103 	}
7104 }
7105 
7106 cmdline_parse_token_string_t cmd_setpromisc_set =
7107 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7108 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7109 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7110 				 "promisc");
7111 cmdline_parse_token_string_t cmd_setpromisc_portall =
7112 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7113 				 "all");
7114 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7115 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7116 			      RTE_UINT16);
7117 cmdline_parse_token_string_t cmd_setpromisc_mode =
7118 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7119 				 "on#off");
7120 
7121 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7122 	.f = cmd_set_promisc_mode_parsed,
7123 	.data = (void *)1,
7124 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
7125 	.tokens = {
7126 		(void *)&cmd_setpromisc_set,
7127 		(void *)&cmd_setpromisc_promisc,
7128 		(void *)&cmd_setpromisc_portall,
7129 		(void *)&cmd_setpromisc_mode,
7130 		NULL,
7131 	},
7132 };
7133 
7134 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7135 	.f = cmd_set_promisc_mode_parsed,
7136 	.data = (void *)0,
7137 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7138 	.tokens = {
7139 		(void *)&cmd_setpromisc_set,
7140 		(void *)&cmd_setpromisc_promisc,
7141 		(void *)&cmd_setpromisc_portnum,
7142 		(void *)&cmd_setpromisc_mode,
7143 		NULL,
7144 	},
7145 };
7146 
7147 /* *** SET ALLMULTI MODE *** */
7148 struct cmd_set_allmulti_mode_result {
7149 	cmdline_fixed_string_t set;
7150 	cmdline_fixed_string_t allmulti;
7151 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7152 	uint16_t port_num;               /* valid if "allports" argument == 0 */
7153 	cmdline_fixed_string_t mode;
7154 };
7155 
7156 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7157 					__rte_unused struct cmdline *cl,
7158 					void *allports)
7159 {
7160 	struct cmd_set_allmulti_mode_result *res = parsed_result;
7161 	int enable;
7162 	portid_t i;
7163 
7164 	if (!strcmp(res->mode, "on"))
7165 		enable = 1;
7166 	else
7167 		enable = 0;
7168 
7169 	/* all ports */
7170 	if (allports) {
7171 		RTE_ETH_FOREACH_DEV(i) {
7172 			eth_set_allmulticast_mode(i, enable);
7173 		}
7174 	}
7175 	else {
7176 		eth_set_allmulticast_mode(res->port_num, enable);
7177 	}
7178 }
7179 
7180 cmdline_parse_token_string_t cmd_setallmulti_set =
7181 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7182 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7183 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7184 				 "allmulti");
7185 cmdline_parse_token_string_t cmd_setallmulti_portall =
7186 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7187 				 "all");
7188 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7189 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7190 			      RTE_UINT16);
7191 cmdline_parse_token_string_t cmd_setallmulti_mode =
7192 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7193 				 "on#off");
7194 
7195 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7196 	.f = cmd_set_allmulti_mode_parsed,
7197 	.data = (void *)1,
7198 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7199 	.tokens = {
7200 		(void *)&cmd_setallmulti_set,
7201 		(void *)&cmd_setallmulti_allmulti,
7202 		(void *)&cmd_setallmulti_portall,
7203 		(void *)&cmd_setallmulti_mode,
7204 		NULL,
7205 	},
7206 };
7207 
7208 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7209 	.f = cmd_set_allmulti_mode_parsed,
7210 	.data = (void *)0,
7211 	.help_str = "set allmulti <port_id> on|off: "
7212 		"Set allmulti mode on port_id",
7213 	.tokens = {
7214 		(void *)&cmd_setallmulti_set,
7215 		(void *)&cmd_setallmulti_allmulti,
7216 		(void *)&cmd_setallmulti_portnum,
7217 		(void *)&cmd_setallmulti_mode,
7218 		NULL,
7219 	},
7220 };
7221 
7222 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7223 struct cmd_link_flow_ctrl_show {
7224 	cmdline_fixed_string_t show;
7225 	cmdline_fixed_string_t port;
7226 	portid_t port_id;
7227 	cmdline_fixed_string_t flow_ctrl;
7228 };
7229 
7230 cmdline_parse_token_string_t cmd_lfc_show_show =
7231 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7232 				show, "show");
7233 cmdline_parse_token_string_t cmd_lfc_show_port =
7234 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7235 				port, "port");
7236 cmdline_parse_token_num_t cmd_lfc_show_portid =
7237 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7238 				port_id, RTE_UINT16);
7239 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7240 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7241 				flow_ctrl, "flow_ctrl");
7242 
7243 static void
7244 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7245 			      __rte_unused struct cmdline *cl,
7246 			      __rte_unused void *data)
7247 {
7248 	struct cmd_link_flow_ctrl_show *res = parsed_result;
7249 	static const char *info_border = "*********************";
7250 	struct rte_eth_fc_conf fc_conf;
7251 	bool rx_fc_en = false;
7252 	bool tx_fc_en = false;
7253 	int ret;
7254 
7255 	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7256 	if (ret != 0) {
7257 		fprintf(stderr,
7258 			"Failed to get current flow ctrl information: err = %d\n",
7259 			ret);
7260 		return;
7261 	}
7262 
7263 	if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7264 		rx_fc_en = true;
7265 	if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7266 		tx_fc_en = true;
7267 
7268 	printf("\n%s Flow control infos for port %-2d %s\n",
7269 		info_border, res->port_id, info_border);
7270 	printf("FC mode:\n");
7271 	printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
7272 	printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
7273 	printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7274 	printf("Pause time: 0x%x\n", fc_conf.pause_time);
7275 	printf("High waterline: 0x%x\n", fc_conf.high_water);
7276 	printf("Low waterline: 0x%x\n", fc_conf.low_water);
7277 	printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7278 	printf("Forward MAC control frames: %s\n",
7279 		fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7280 	printf("\n%s**************   End  ***********%s\n",
7281 		info_border, info_border);
7282 }
7283 
7284 cmdline_parse_inst_t cmd_link_flow_control_show = {
7285 	.f = cmd_link_flow_ctrl_show_parsed,
7286 	.data = NULL,
7287 	.help_str = "show port <port_id> flow_ctrl",
7288 	.tokens = {
7289 		(void *)&cmd_lfc_show_show,
7290 		(void *)&cmd_lfc_show_port,
7291 		(void *)&cmd_lfc_show_portid,
7292 		(void *)&cmd_lfc_show_flow_ctrl,
7293 		NULL,
7294 	},
7295 };
7296 
7297 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7298 struct cmd_link_flow_ctrl_set_result {
7299 	cmdline_fixed_string_t set;
7300 	cmdline_fixed_string_t flow_ctrl;
7301 	cmdline_fixed_string_t rx;
7302 	cmdline_fixed_string_t rx_lfc_mode;
7303 	cmdline_fixed_string_t tx;
7304 	cmdline_fixed_string_t tx_lfc_mode;
7305 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
7306 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7307 	cmdline_fixed_string_t autoneg_str;
7308 	cmdline_fixed_string_t autoneg;
7309 	cmdline_fixed_string_t hw_str;
7310 	uint32_t high_water;
7311 	cmdline_fixed_string_t lw_str;
7312 	uint32_t low_water;
7313 	cmdline_fixed_string_t pt_str;
7314 	uint16_t pause_time;
7315 	cmdline_fixed_string_t xon_str;
7316 	uint16_t send_xon;
7317 	portid_t port_id;
7318 };
7319 
7320 cmdline_parse_token_string_t cmd_lfc_set_set =
7321 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7322 				set, "set");
7323 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7324 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7325 				flow_ctrl, "flow_ctrl");
7326 cmdline_parse_token_string_t cmd_lfc_set_rx =
7327 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7328 				rx, "rx");
7329 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7330 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7331 				rx_lfc_mode, "on#off");
7332 cmdline_parse_token_string_t cmd_lfc_set_tx =
7333 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7334 				tx, "tx");
7335 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7336 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7337 				tx_lfc_mode, "on#off");
7338 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7339 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7340 				hw_str, "high_water");
7341 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7342 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7343 				high_water, RTE_UINT32);
7344 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7345 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7346 				lw_str, "low_water");
7347 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7348 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7349 				low_water, RTE_UINT32);
7350 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7351 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7352 				pt_str, "pause_time");
7353 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7354 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7355 				pause_time, RTE_UINT16);
7356 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7357 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7358 				xon_str, "send_xon");
7359 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7360 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7361 				send_xon, RTE_UINT16);
7362 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7363 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7364 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7365 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7366 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7367 				mac_ctrl_frame_fwd_mode, "on#off");
7368 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7369 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7370 				autoneg_str, "autoneg");
7371 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7372 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7373 				autoneg, "on#off");
7374 cmdline_parse_token_num_t cmd_lfc_set_portid =
7375 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7376 				port_id, RTE_UINT16);
7377 
7378 /* forward declaration */
7379 static void
7380 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7381 			      void *data);
7382 
7383 cmdline_parse_inst_t cmd_link_flow_control_set = {
7384 	.f = cmd_link_flow_ctrl_set_parsed,
7385 	.data = NULL,
7386 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7387 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7388 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
7389 	.tokens = {
7390 		(void *)&cmd_lfc_set_set,
7391 		(void *)&cmd_lfc_set_flow_ctrl,
7392 		(void *)&cmd_lfc_set_rx,
7393 		(void *)&cmd_lfc_set_rx_mode,
7394 		(void *)&cmd_lfc_set_tx,
7395 		(void *)&cmd_lfc_set_tx_mode,
7396 		(void *)&cmd_lfc_set_high_water,
7397 		(void *)&cmd_lfc_set_low_water,
7398 		(void *)&cmd_lfc_set_pause_time,
7399 		(void *)&cmd_lfc_set_send_xon,
7400 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7401 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7402 		(void *)&cmd_lfc_set_autoneg_str,
7403 		(void *)&cmd_lfc_set_autoneg,
7404 		(void *)&cmd_lfc_set_portid,
7405 		NULL,
7406 	},
7407 };
7408 
7409 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7410 	.f = cmd_link_flow_ctrl_set_parsed,
7411 	.data = (void *)&cmd_link_flow_control_set_rx,
7412 	.help_str = "set flow_ctrl rx on|off <port_id>: "
7413 		"Change rx flow control parameter",
7414 	.tokens = {
7415 		(void *)&cmd_lfc_set_set,
7416 		(void *)&cmd_lfc_set_flow_ctrl,
7417 		(void *)&cmd_lfc_set_rx,
7418 		(void *)&cmd_lfc_set_rx_mode,
7419 		(void *)&cmd_lfc_set_portid,
7420 		NULL,
7421 	},
7422 };
7423 
7424 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7425 	.f = cmd_link_flow_ctrl_set_parsed,
7426 	.data = (void *)&cmd_link_flow_control_set_tx,
7427 	.help_str = "set flow_ctrl tx on|off <port_id>: "
7428 		"Change tx flow control parameter",
7429 	.tokens = {
7430 		(void *)&cmd_lfc_set_set,
7431 		(void *)&cmd_lfc_set_flow_ctrl,
7432 		(void *)&cmd_lfc_set_tx,
7433 		(void *)&cmd_lfc_set_tx_mode,
7434 		(void *)&cmd_lfc_set_portid,
7435 		NULL,
7436 	},
7437 };
7438 
7439 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7440 	.f = cmd_link_flow_ctrl_set_parsed,
7441 	.data = (void *)&cmd_link_flow_control_set_hw,
7442 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
7443 		"Change high water flow control parameter",
7444 	.tokens = {
7445 		(void *)&cmd_lfc_set_set,
7446 		(void *)&cmd_lfc_set_flow_ctrl,
7447 		(void *)&cmd_lfc_set_high_water_str,
7448 		(void *)&cmd_lfc_set_high_water,
7449 		(void *)&cmd_lfc_set_portid,
7450 		NULL,
7451 	},
7452 };
7453 
7454 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7455 	.f = cmd_link_flow_ctrl_set_parsed,
7456 	.data = (void *)&cmd_link_flow_control_set_lw,
7457 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7458 		"Change low water flow control parameter",
7459 	.tokens = {
7460 		(void *)&cmd_lfc_set_set,
7461 		(void *)&cmd_lfc_set_flow_ctrl,
7462 		(void *)&cmd_lfc_set_low_water_str,
7463 		(void *)&cmd_lfc_set_low_water,
7464 		(void *)&cmd_lfc_set_portid,
7465 		NULL,
7466 	},
7467 };
7468 
7469 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7470 	.f = cmd_link_flow_ctrl_set_parsed,
7471 	.data = (void *)&cmd_link_flow_control_set_pt,
7472 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7473 		"Change pause time flow control parameter",
7474 	.tokens = {
7475 		(void *)&cmd_lfc_set_set,
7476 		(void *)&cmd_lfc_set_flow_ctrl,
7477 		(void *)&cmd_lfc_set_pause_time_str,
7478 		(void *)&cmd_lfc_set_pause_time,
7479 		(void *)&cmd_lfc_set_portid,
7480 		NULL,
7481 	},
7482 };
7483 
7484 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7485 	.f = cmd_link_flow_ctrl_set_parsed,
7486 	.data = (void *)&cmd_link_flow_control_set_xon,
7487 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7488 		"Change send_xon flow control parameter",
7489 	.tokens = {
7490 		(void *)&cmd_lfc_set_set,
7491 		(void *)&cmd_lfc_set_flow_ctrl,
7492 		(void *)&cmd_lfc_set_send_xon_str,
7493 		(void *)&cmd_lfc_set_send_xon,
7494 		(void *)&cmd_lfc_set_portid,
7495 		NULL,
7496 	},
7497 };
7498 
7499 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7500 	.f = cmd_link_flow_ctrl_set_parsed,
7501 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7502 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7503 		"Change mac ctrl fwd flow control parameter",
7504 	.tokens = {
7505 		(void *)&cmd_lfc_set_set,
7506 		(void *)&cmd_lfc_set_flow_ctrl,
7507 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7508 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7509 		(void *)&cmd_lfc_set_portid,
7510 		NULL,
7511 	},
7512 };
7513 
7514 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7515 	.f = cmd_link_flow_ctrl_set_parsed,
7516 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7517 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7518 		"Change autoneg flow control parameter",
7519 	.tokens = {
7520 		(void *)&cmd_lfc_set_set,
7521 		(void *)&cmd_lfc_set_flow_ctrl,
7522 		(void *)&cmd_lfc_set_autoneg_str,
7523 		(void *)&cmd_lfc_set_autoneg,
7524 		(void *)&cmd_lfc_set_portid,
7525 		NULL,
7526 	},
7527 };
7528 
7529 static void
7530 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7531 			      __rte_unused struct cmdline *cl,
7532 			      void *data)
7533 {
7534 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7535 	cmdline_parse_inst_t *cmd = data;
7536 	struct rte_eth_fc_conf fc_conf;
7537 	int rx_fc_en = 0;
7538 	int tx_fc_en = 0;
7539 	int ret;
7540 
7541 	/*
7542 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7543 	 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7544 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7545 	 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7546 	 */
7547 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7548 			{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7549 	};
7550 
7551 	/* Partial command line, retrieve current configuration */
7552 	if (cmd) {
7553 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7554 		if (ret != 0) {
7555 			fprintf(stderr,
7556 				"cannot get current flow ctrl parameters, return code = %d\n",
7557 				ret);
7558 			return;
7559 		}
7560 
7561 		if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7562 		    (fc_conf.mode == RTE_ETH_FC_FULL))
7563 			rx_fc_en = 1;
7564 		if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7565 		    (fc_conf.mode == RTE_ETH_FC_FULL))
7566 			tx_fc_en = 1;
7567 	}
7568 
7569 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7570 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7571 
7572 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7573 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7574 
7575 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7576 
7577 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7578 		fc_conf.high_water = res->high_water;
7579 
7580 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7581 		fc_conf.low_water = res->low_water;
7582 
7583 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7584 		fc_conf.pause_time = res->pause_time;
7585 
7586 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7587 		fc_conf.send_xon = res->send_xon;
7588 
7589 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7590 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7591 			fc_conf.mac_ctrl_frame_fwd = 1;
7592 		else
7593 			fc_conf.mac_ctrl_frame_fwd = 0;
7594 	}
7595 
7596 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7597 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7598 
7599 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7600 	if (ret != 0)
7601 		fprintf(stderr,
7602 			"bad flow control parameter, return code = %d\n",
7603 			ret);
7604 }
7605 
7606 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7607 struct cmd_priority_flow_ctrl_set_result {
7608 	cmdline_fixed_string_t set;
7609 	cmdline_fixed_string_t pfc_ctrl;
7610 	cmdline_fixed_string_t rx;
7611 	cmdline_fixed_string_t rx_pfc_mode;
7612 	cmdline_fixed_string_t tx;
7613 	cmdline_fixed_string_t tx_pfc_mode;
7614 	uint32_t high_water;
7615 	uint32_t low_water;
7616 	uint16_t pause_time;
7617 	uint8_t  priority;
7618 	portid_t port_id;
7619 };
7620 
7621 static void
7622 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7623 		       __rte_unused struct cmdline *cl,
7624 		       __rte_unused void *data)
7625 {
7626 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7627 	struct rte_eth_pfc_conf pfc_conf;
7628 	int rx_fc_enable, tx_fc_enable;
7629 	int ret;
7630 
7631 	/*
7632 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7633 	 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7634 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7635 	 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7636 	 */
7637 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7638 		{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7639 	};
7640 
7641 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7642 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7643 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7644 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7645 	pfc_conf.fc.high_water = res->high_water;
7646 	pfc_conf.fc.low_water  = res->low_water;
7647 	pfc_conf.fc.pause_time = res->pause_time;
7648 	pfc_conf.priority      = res->priority;
7649 
7650 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7651 	if (ret != 0)
7652 		fprintf(stderr,
7653 			"bad priority flow control parameter, return code = %d\n",
7654 			ret);
7655 }
7656 
7657 cmdline_parse_token_string_t cmd_pfc_set_set =
7658 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7659 				set, "set");
7660 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7661 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7662 				pfc_ctrl, "pfc_ctrl");
7663 cmdline_parse_token_string_t cmd_pfc_set_rx =
7664 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7665 				rx, "rx");
7666 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7667 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7668 				rx_pfc_mode, "on#off");
7669 cmdline_parse_token_string_t cmd_pfc_set_tx =
7670 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7671 				tx, "tx");
7672 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7673 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7674 				tx_pfc_mode, "on#off");
7675 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7676 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7677 				high_water, RTE_UINT32);
7678 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7679 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7680 				low_water, RTE_UINT32);
7681 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7682 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7683 				pause_time, RTE_UINT16);
7684 cmdline_parse_token_num_t cmd_pfc_set_priority =
7685 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7686 				priority, RTE_UINT8);
7687 cmdline_parse_token_num_t cmd_pfc_set_portid =
7688 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7689 				port_id, RTE_UINT16);
7690 
7691 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7692 	.f = cmd_priority_flow_ctrl_set_parsed,
7693 	.data = NULL,
7694 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7695 		"<pause_time> <priority> <port_id>: "
7696 		"Configure the Ethernet priority flow control",
7697 	.tokens = {
7698 		(void *)&cmd_pfc_set_set,
7699 		(void *)&cmd_pfc_set_flow_ctrl,
7700 		(void *)&cmd_pfc_set_rx,
7701 		(void *)&cmd_pfc_set_rx_mode,
7702 		(void *)&cmd_pfc_set_tx,
7703 		(void *)&cmd_pfc_set_tx_mode,
7704 		(void *)&cmd_pfc_set_high_water,
7705 		(void *)&cmd_pfc_set_low_water,
7706 		(void *)&cmd_pfc_set_pause_time,
7707 		(void *)&cmd_pfc_set_priority,
7708 		(void *)&cmd_pfc_set_portid,
7709 		NULL,
7710 	},
7711 };
7712 
7713 struct cmd_queue_priority_flow_ctrl_set_result {
7714 	cmdline_fixed_string_t set;
7715 	cmdline_fixed_string_t pfc_queue_ctrl;
7716 	portid_t port_id;
7717 	cmdline_fixed_string_t rx;
7718 	cmdline_fixed_string_t rx_pfc_mode;
7719 	uint16_t tx_qid;
7720 	uint8_t  tx_tc;
7721 	cmdline_fixed_string_t tx;
7722 	cmdline_fixed_string_t tx_pfc_mode;
7723 	uint16_t rx_qid;
7724 	uint8_t  rx_tc;
7725 	uint16_t pause_time;
7726 };
7727 
7728 static void
7729 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7730 					__rte_unused struct cmdline *cl,
7731 					__rte_unused void *data)
7732 {
7733 	struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7734 	struct rte_eth_pfc_queue_conf pfc_queue_conf;
7735 	int rx_fc_enable, tx_fc_enable;
7736 	int ret;
7737 
7738 	/*
7739 	 * Rx on/off, flow control is enabled/disabled on RX side. This can
7740 	 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7741 	 * side. Tx on/off, flow control is enabled/disabled on TX side. This
7742 	 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7743 	 * the Tx side.
7744 	 */
7745 	static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7746 		{RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7747 		{RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7748 	};
7749 
7750 	memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7751 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7752 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7753 	pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7754 	pfc_queue_conf.rx_pause.tc  = res->tx_tc;
7755 	pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7756 	pfc_queue_conf.tx_pause.tc  = res->rx_tc;
7757 	pfc_queue_conf.tx_pause.rx_qid  = res->rx_qid;
7758 	pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7759 
7760 	ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7761 							     &pfc_queue_conf);
7762 	if (ret != 0) {
7763 		fprintf(stderr,
7764 			"bad queue priority flow control parameter, rc = %d\n",
7765 			ret);
7766 	}
7767 }
7768 
7769 cmdline_parse_token_string_t cmd_q_pfc_set_set =
7770 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7771 				set, "set");
7772 cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7773 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7774 				pfc_queue_ctrl, "pfc_queue_ctrl");
7775 cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7776 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7777 				port_id, RTE_UINT16);
7778 cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7779 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7780 				rx, "rx");
7781 cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7782 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7783 				rx_pfc_mode, "on#off");
7784 cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7785 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7786 				tx_qid, RTE_UINT16);
7787 cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7788 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7789 				tx_tc, RTE_UINT8);
7790 cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7791 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7792 				tx, "tx");
7793 cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7794 	TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7795 				tx_pfc_mode, "on#off");
7796 cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7797 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7798 				rx_qid, RTE_UINT16);
7799 cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7800 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7801 				rx_tc, RTE_UINT8);
7802 cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7803 	TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7804 				pause_time, RTE_UINT16);
7805 
7806 cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7807 	.f = cmd_queue_priority_flow_ctrl_set_parsed,
7808 	.data = NULL,
7809 	.help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7810 		"tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7811 		"Configure the Ethernet queue priority flow control",
7812 	.tokens = {
7813 		(void *)&cmd_q_pfc_set_set,
7814 		(void *)&cmd_q_pfc_set_flow_ctrl,
7815 		(void *)&cmd_q_pfc_set_portid,
7816 		(void *)&cmd_q_pfc_set_rx,
7817 		(void *)&cmd_q_pfc_set_rx_mode,
7818 		(void *)&cmd_q_pfc_set_tx_qid,
7819 		(void *)&cmd_q_pfc_set_tx_tc,
7820 		(void *)&cmd_q_pfc_set_tx,
7821 		(void *)&cmd_q_pfc_set_tx_mode,
7822 		(void *)&cmd_q_pfc_set_rx_qid,
7823 		(void *)&cmd_q_pfc_set_rx_tc,
7824 		(void *)&cmd_q_pfc_set_pause_time,
7825 		NULL,
7826 	},
7827 };
7828 
7829 /* *** RESET CONFIGURATION *** */
7830 struct cmd_reset_result {
7831 	cmdline_fixed_string_t reset;
7832 	cmdline_fixed_string_t def;
7833 };
7834 
7835 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7836 			     struct cmdline *cl,
7837 			     __rte_unused void *data)
7838 {
7839 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7840 	set_def_fwd_config();
7841 }
7842 
7843 cmdline_parse_token_string_t cmd_reset_set =
7844 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7845 cmdline_parse_token_string_t cmd_reset_def =
7846 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7847 				 "default");
7848 
7849 cmdline_parse_inst_t cmd_reset = {
7850 	.f = cmd_reset_parsed,
7851 	.data = NULL,
7852 	.help_str = "set default: Reset default forwarding configuration",
7853 	.tokens = {
7854 		(void *)&cmd_reset_set,
7855 		(void *)&cmd_reset_def,
7856 		NULL,
7857 	},
7858 };
7859 
7860 /* *** START FORWARDING *** */
7861 struct cmd_start_result {
7862 	cmdline_fixed_string_t start;
7863 };
7864 
7865 cmdline_parse_token_string_t cmd_start_start =
7866 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7867 
7868 static void cmd_start_parsed(__rte_unused void *parsed_result,
7869 			     __rte_unused struct cmdline *cl,
7870 			     __rte_unused void *data)
7871 {
7872 	start_packet_forwarding(0);
7873 }
7874 
7875 cmdline_parse_inst_t cmd_start = {
7876 	.f = cmd_start_parsed,
7877 	.data = NULL,
7878 	.help_str = "start: Start packet forwarding",
7879 	.tokens = {
7880 		(void *)&cmd_start_start,
7881 		NULL,
7882 	},
7883 };
7884 
7885 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7886 struct cmd_start_tx_first_result {
7887 	cmdline_fixed_string_t start;
7888 	cmdline_fixed_string_t tx_first;
7889 };
7890 
7891 static void
7892 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7893 			  __rte_unused struct cmdline *cl,
7894 			  __rte_unused void *data)
7895 {
7896 	start_packet_forwarding(1);
7897 }
7898 
7899 cmdline_parse_token_string_t cmd_start_tx_first_start =
7900 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7901 				 "start");
7902 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7903 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7904 				 tx_first, "tx_first");
7905 
7906 cmdline_parse_inst_t cmd_start_tx_first = {
7907 	.f = cmd_start_tx_first_parsed,
7908 	.data = NULL,
7909 	.help_str = "start tx_first: Start packet forwarding, "
7910 		"after sending 1 burst of packets",
7911 	.tokens = {
7912 		(void *)&cmd_start_tx_first_start,
7913 		(void *)&cmd_start_tx_first_tx_first,
7914 		NULL,
7915 	},
7916 };
7917 
7918 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7919 struct cmd_start_tx_first_n_result {
7920 	cmdline_fixed_string_t start;
7921 	cmdline_fixed_string_t tx_first;
7922 	uint32_t tx_num;
7923 };
7924 
7925 static void
7926 cmd_start_tx_first_n_parsed(void *parsed_result,
7927 			  __rte_unused struct cmdline *cl,
7928 			  __rte_unused void *data)
7929 {
7930 	struct cmd_start_tx_first_n_result *res = parsed_result;
7931 
7932 	start_packet_forwarding(res->tx_num);
7933 }
7934 
7935 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7936 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7937 			start, "start");
7938 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7939 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7940 			tx_first, "tx_first");
7941 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7942 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7943 			tx_num, RTE_UINT32);
7944 
7945 cmdline_parse_inst_t cmd_start_tx_first_n = {
7946 	.f = cmd_start_tx_first_n_parsed,
7947 	.data = NULL,
7948 	.help_str = "start tx_first <num>: "
7949 		"packet forwarding, after sending <num> bursts of packets",
7950 	.tokens = {
7951 		(void *)&cmd_start_tx_first_n_start,
7952 		(void *)&cmd_start_tx_first_n_tx_first,
7953 		(void *)&cmd_start_tx_first_n_tx_num,
7954 		NULL,
7955 	},
7956 };
7957 
7958 /* *** SET LINK UP *** */
7959 struct cmd_set_link_up_result {
7960 	cmdline_fixed_string_t set;
7961 	cmdline_fixed_string_t link_up;
7962 	cmdline_fixed_string_t port;
7963 	portid_t port_id;
7964 };
7965 
7966 cmdline_parse_token_string_t cmd_set_link_up_set =
7967 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7968 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7969 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7970 				"link-up");
7971 cmdline_parse_token_string_t cmd_set_link_up_port =
7972 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7973 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7974 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7975 				RTE_UINT16);
7976 
7977 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7978 			     __rte_unused struct cmdline *cl,
7979 			     __rte_unused void *data)
7980 {
7981 	struct cmd_set_link_up_result *res = parsed_result;
7982 	dev_set_link_up(res->port_id);
7983 }
7984 
7985 cmdline_parse_inst_t cmd_set_link_up = {
7986 	.f = cmd_set_link_up_parsed,
7987 	.data = NULL,
7988 	.help_str = "set link-up port <port id>",
7989 	.tokens = {
7990 		(void *)&cmd_set_link_up_set,
7991 		(void *)&cmd_set_link_up_link_up,
7992 		(void *)&cmd_set_link_up_port,
7993 		(void *)&cmd_set_link_up_port_id,
7994 		NULL,
7995 	},
7996 };
7997 
7998 /* *** SET LINK DOWN *** */
7999 struct cmd_set_link_down_result {
8000 	cmdline_fixed_string_t set;
8001 	cmdline_fixed_string_t link_down;
8002 	cmdline_fixed_string_t port;
8003 	portid_t port_id;
8004 };
8005 
8006 cmdline_parse_token_string_t cmd_set_link_down_set =
8007 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
8008 cmdline_parse_token_string_t cmd_set_link_down_link_down =
8009 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
8010 				"link-down");
8011 cmdline_parse_token_string_t cmd_set_link_down_port =
8012 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
8013 cmdline_parse_token_num_t cmd_set_link_down_port_id =
8014 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
8015 				RTE_UINT16);
8016 
8017 static void cmd_set_link_down_parsed(
8018 				__rte_unused void *parsed_result,
8019 				__rte_unused struct cmdline *cl,
8020 				__rte_unused void *data)
8021 {
8022 	struct cmd_set_link_down_result *res = parsed_result;
8023 	dev_set_link_down(res->port_id);
8024 }
8025 
8026 cmdline_parse_inst_t cmd_set_link_down = {
8027 	.f = cmd_set_link_down_parsed,
8028 	.data = NULL,
8029 	.help_str = "set link-down port <port id>",
8030 	.tokens = {
8031 		(void *)&cmd_set_link_down_set,
8032 		(void *)&cmd_set_link_down_link_down,
8033 		(void *)&cmd_set_link_down_port,
8034 		(void *)&cmd_set_link_down_port_id,
8035 		NULL,
8036 	},
8037 };
8038 
8039 /* *** SHOW CFG *** */
8040 struct cmd_showcfg_result {
8041 	cmdline_fixed_string_t show;
8042 	cmdline_fixed_string_t cfg;
8043 	cmdline_fixed_string_t what;
8044 };
8045 
8046 static void cmd_showcfg_parsed(void *parsed_result,
8047 			       __rte_unused struct cmdline *cl,
8048 			       __rte_unused void *data)
8049 {
8050 	struct cmd_showcfg_result *res = parsed_result;
8051 	if (!strcmp(res->what, "rxtx"))
8052 		rxtx_config_display();
8053 	else if (!strcmp(res->what, "cores"))
8054 		fwd_lcores_config_display();
8055 	else if (!strcmp(res->what, "fwd"))
8056 		pkt_fwd_config_display(&cur_fwd_config);
8057 	else if (!strcmp(res->what, "rxoffs"))
8058 		show_rx_pkt_offsets();
8059 	else if (!strcmp(res->what, "rxpkts"))
8060 		show_rx_pkt_segments();
8061 	else if (!strcmp(res->what, "txpkts"))
8062 		show_tx_pkt_segments();
8063 	else if (!strcmp(res->what, "txtimes"))
8064 		show_tx_pkt_times();
8065 }
8066 
8067 cmdline_parse_token_string_t cmd_showcfg_show =
8068 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
8069 cmdline_parse_token_string_t cmd_showcfg_port =
8070 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
8071 cmdline_parse_token_string_t cmd_showcfg_what =
8072 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
8073 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
8074 
8075 cmdline_parse_inst_t cmd_showcfg = {
8076 	.f = cmd_showcfg_parsed,
8077 	.data = NULL,
8078 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
8079 	.tokens = {
8080 		(void *)&cmd_showcfg_show,
8081 		(void *)&cmd_showcfg_port,
8082 		(void *)&cmd_showcfg_what,
8083 		NULL,
8084 	},
8085 };
8086 
8087 /* *** SHOW ALL PORT INFO *** */
8088 struct cmd_showportall_result {
8089 	cmdline_fixed_string_t show;
8090 	cmdline_fixed_string_t port;
8091 	cmdline_fixed_string_t what;
8092 	cmdline_fixed_string_t all;
8093 };
8094 
8095 static void cmd_showportall_parsed(void *parsed_result,
8096 				__rte_unused struct cmdline *cl,
8097 				__rte_unused void *data)
8098 {
8099 	portid_t i;
8100 
8101 	struct cmd_showportall_result *res = parsed_result;
8102 	if (!strcmp(res->show, "clear")) {
8103 		if (!strcmp(res->what, "stats"))
8104 			RTE_ETH_FOREACH_DEV(i)
8105 				nic_stats_clear(i);
8106 		else if (!strcmp(res->what, "xstats"))
8107 			RTE_ETH_FOREACH_DEV(i)
8108 				nic_xstats_clear(i);
8109 	} else if (!strcmp(res->what, "info"))
8110 		RTE_ETH_FOREACH_DEV(i)
8111 			port_infos_display(i);
8112 	else if (!strcmp(res->what, "summary")) {
8113 		port_summary_header_display();
8114 		RTE_ETH_FOREACH_DEV(i)
8115 			port_summary_display(i);
8116 	}
8117 	else if (!strcmp(res->what, "stats"))
8118 		RTE_ETH_FOREACH_DEV(i)
8119 			nic_stats_display(i);
8120 	else if (!strcmp(res->what, "xstats"))
8121 		RTE_ETH_FOREACH_DEV(i)
8122 			nic_xstats_display(i);
8123 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8124 	else if (!strcmp(res->what, "fdir"))
8125 		RTE_ETH_FOREACH_DEV(i)
8126 			fdir_get_infos(i);
8127 #endif
8128 	else if (!strcmp(res->what, "dcb_tc"))
8129 		RTE_ETH_FOREACH_DEV(i)
8130 			port_dcb_info_display(i);
8131 }
8132 
8133 cmdline_parse_token_string_t cmd_showportall_show =
8134 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8135 				 "show#clear");
8136 cmdline_parse_token_string_t cmd_showportall_port =
8137 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8138 cmdline_parse_token_string_t cmd_showportall_what =
8139 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8140 				 "info#summary#stats#xstats#fdir#dcb_tc");
8141 cmdline_parse_token_string_t cmd_showportall_all =
8142 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8143 cmdline_parse_inst_t cmd_showportall = {
8144 	.f = cmd_showportall_parsed,
8145 	.data = NULL,
8146 	.help_str = "show|clear port "
8147 		"info|summary|stats|xstats|fdir|dcb_tc all",
8148 	.tokens = {
8149 		(void *)&cmd_showportall_show,
8150 		(void *)&cmd_showportall_port,
8151 		(void *)&cmd_showportall_what,
8152 		(void *)&cmd_showportall_all,
8153 		NULL,
8154 	},
8155 };
8156 
8157 /* *** SHOW PORT INFO *** */
8158 struct cmd_showport_result {
8159 	cmdline_fixed_string_t show;
8160 	cmdline_fixed_string_t port;
8161 	cmdline_fixed_string_t what;
8162 	uint16_t portnum;
8163 };
8164 
8165 static void cmd_showport_parsed(void *parsed_result,
8166 				__rte_unused struct cmdline *cl,
8167 				__rte_unused void *data)
8168 {
8169 	struct cmd_showport_result *res = parsed_result;
8170 	if (!strcmp(res->show, "clear")) {
8171 		if (!strcmp(res->what, "stats"))
8172 			nic_stats_clear(res->portnum);
8173 		else if (!strcmp(res->what, "xstats"))
8174 			nic_xstats_clear(res->portnum);
8175 	} else if (!strcmp(res->what, "info"))
8176 		port_infos_display(res->portnum);
8177 	else if (!strcmp(res->what, "summary")) {
8178 		port_summary_header_display();
8179 		port_summary_display(res->portnum);
8180 	}
8181 	else if (!strcmp(res->what, "stats"))
8182 		nic_stats_display(res->portnum);
8183 	else if (!strcmp(res->what, "xstats"))
8184 		nic_xstats_display(res->portnum);
8185 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8186 	else if (!strcmp(res->what, "fdir"))
8187 		 fdir_get_infos(res->portnum);
8188 #endif
8189 	else if (!strcmp(res->what, "dcb_tc"))
8190 		port_dcb_info_display(res->portnum);
8191 }
8192 
8193 cmdline_parse_token_string_t cmd_showport_show =
8194 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8195 				 "show#clear");
8196 cmdline_parse_token_string_t cmd_showport_port =
8197 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8198 cmdline_parse_token_string_t cmd_showport_what =
8199 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8200 				 "info#summary#stats#xstats#fdir#dcb_tc");
8201 cmdline_parse_token_num_t cmd_showport_portnum =
8202 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8203 
8204 cmdline_parse_inst_t cmd_showport = {
8205 	.f = cmd_showport_parsed,
8206 	.data = NULL,
8207 	.help_str = "show|clear port "
8208 		"info|summary|stats|xstats|fdir|dcb_tc "
8209 		"<port_id>",
8210 	.tokens = {
8211 		(void *)&cmd_showport_show,
8212 		(void *)&cmd_showport_port,
8213 		(void *)&cmd_showport_what,
8214 		(void *)&cmd_showport_portnum,
8215 		NULL,
8216 	},
8217 };
8218 
8219 /* *** show port representors information *** */
8220 struct cmd_representor_info_result {
8221 	cmdline_fixed_string_t cmd_show;
8222 	cmdline_fixed_string_t cmd_port;
8223 	cmdline_fixed_string_t cmd_info;
8224 	cmdline_fixed_string_t cmd_keyword;
8225 	portid_t cmd_pid;
8226 };
8227 
8228 static void
8229 cmd_representor_info_parsed(void *parsed_result,
8230 		__rte_unused struct cmdline *cl,
8231 		__rte_unused void *data)
8232 {
8233 	struct cmd_representor_info_result *res = parsed_result;
8234 	struct rte_eth_representor_info *info;
8235 	struct rte_eth_representor_range *range;
8236 	uint32_t range_diff;
8237 	uint32_t i;
8238 	int ret;
8239 	int num;
8240 
8241 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8242 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8243 		return;
8244 	}
8245 
8246 	ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8247 	if (ret < 0) {
8248 		fprintf(stderr,
8249 			"Failed to get the number of representor info ranges for port %hu: %s\n",
8250 			res->cmd_pid, rte_strerror(-ret));
8251 		return;
8252 	}
8253 	num = ret;
8254 
8255 	info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8256 	if (info == NULL) {
8257 		fprintf(stderr,
8258 			"Failed to allocate memory for representor info for port %hu\n",
8259 			res->cmd_pid);
8260 		return;
8261 	}
8262 	info->nb_ranges_alloc = num;
8263 
8264 	ret = rte_eth_representor_info_get(res->cmd_pid, info);
8265 	if (ret < 0) {
8266 		fprintf(stderr,
8267 			"Failed to get the representor info for port %hu: %s\n",
8268 			res->cmd_pid, rte_strerror(-ret));
8269 		free(info);
8270 		return;
8271 	}
8272 
8273 	printf("Port controller: %hu\n", info->controller);
8274 	printf("Port PF: %hu\n", info->pf);
8275 
8276 	printf("Ranges: %u\n", info->nb_ranges);
8277 	for (i = 0; i < info->nb_ranges; i++) {
8278 		range = &info->ranges[i];
8279 		range_diff = range->id_end - range->id_base;
8280 
8281 		printf("%u. ", i + 1);
8282 		printf("'%s' ", range->name);
8283 		if (range_diff > 0)
8284 			printf("[%u-%u]: ", range->id_base, range->id_end);
8285 		else
8286 			printf("[%u]: ", range->id_base);
8287 
8288 		printf("Controller %d, PF %d", range->controller, range->pf);
8289 
8290 		switch (range->type) {
8291 		case RTE_ETH_REPRESENTOR_NONE:
8292 			printf(", NONE\n");
8293 			break;
8294 		case RTE_ETH_REPRESENTOR_VF:
8295 			if (range_diff > 0)
8296 				printf(", VF %d..%d\n", range->vf,
8297 				       range->vf + range_diff);
8298 			else
8299 				printf(", VF %d\n", range->vf);
8300 			break;
8301 		case RTE_ETH_REPRESENTOR_SF:
8302 			printf(", SF %d\n", range->sf);
8303 			break;
8304 		case RTE_ETH_REPRESENTOR_PF:
8305 			if (range_diff > 0)
8306 				printf("..%d\n", range->pf + range_diff);
8307 			else
8308 				printf("\n");
8309 			break;
8310 		default:
8311 			printf(", UNKNOWN TYPE %d\n", range->type);
8312 			break;
8313 		}
8314 	}
8315 
8316 	free(info);
8317 }
8318 
8319 cmdline_parse_token_string_t cmd_representor_info_show =
8320 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8321 			cmd_show, "show");
8322 cmdline_parse_token_string_t cmd_representor_info_port =
8323 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8324 			cmd_port, "port");
8325 cmdline_parse_token_string_t cmd_representor_info_info =
8326 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8327 			cmd_info, "info");
8328 cmdline_parse_token_num_t cmd_representor_info_pid =
8329 	TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8330 			cmd_pid, RTE_UINT16);
8331 cmdline_parse_token_string_t cmd_representor_info_keyword =
8332 	TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8333 			cmd_keyword, "representor");
8334 
8335 cmdline_parse_inst_t cmd_representor_info = {
8336 	.f = cmd_representor_info_parsed,
8337 	.data = NULL,
8338 	.help_str = "show port info <port_id> representor",
8339 	.tokens = {
8340 		(void *)&cmd_representor_info_show,
8341 		(void *)&cmd_representor_info_port,
8342 		(void *)&cmd_representor_info_info,
8343 		(void *)&cmd_representor_info_pid,
8344 		(void *)&cmd_representor_info_keyword,
8345 		NULL,
8346 	},
8347 };
8348 
8349 
8350 /* *** SHOW DEVICE INFO *** */
8351 struct cmd_showdevice_result {
8352 	cmdline_fixed_string_t show;
8353 	cmdline_fixed_string_t device;
8354 	cmdline_fixed_string_t what;
8355 	cmdline_fixed_string_t identifier;
8356 };
8357 
8358 static void cmd_showdevice_parsed(void *parsed_result,
8359 				__rte_unused struct cmdline *cl,
8360 				__rte_unused void *data)
8361 {
8362 	struct cmd_showdevice_result *res = parsed_result;
8363 	if (!strcmp(res->what, "info")) {
8364 		if (!strcmp(res->identifier, "all"))
8365 			device_infos_display(NULL);
8366 		else
8367 			device_infos_display(res->identifier);
8368 	}
8369 }
8370 
8371 cmdline_parse_token_string_t cmd_showdevice_show =
8372 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8373 				 "show");
8374 cmdline_parse_token_string_t cmd_showdevice_device =
8375 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8376 cmdline_parse_token_string_t cmd_showdevice_what =
8377 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8378 				 "info");
8379 cmdline_parse_token_string_t cmd_showdevice_identifier =
8380 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8381 			identifier, NULL);
8382 
8383 cmdline_parse_inst_t cmd_showdevice = {
8384 	.f = cmd_showdevice_parsed,
8385 	.data = NULL,
8386 	.help_str = "show device info <identifier>|all",
8387 	.tokens = {
8388 		(void *)&cmd_showdevice_show,
8389 		(void *)&cmd_showdevice_device,
8390 		(void *)&cmd_showdevice_what,
8391 		(void *)&cmd_showdevice_identifier,
8392 		NULL,
8393 	},
8394 };
8395 
8396 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8397 struct cmd_showeeprom_result {
8398 	cmdline_fixed_string_t show;
8399 	cmdline_fixed_string_t port;
8400 	uint16_t portnum;
8401 	cmdline_fixed_string_t type;
8402 };
8403 
8404 static void cmd_showeeprom_parsed(void *parsed_result,
8405 		__rte_unused struct cmdline *cl,
8406 		__rte_unused void *data)
8407 {
8408 	struct cmd_showeeprom_result *res = parsed_result;
8409 
8410 	if (!strcmp(res->type, "eeprom"))
8411 		port_eeprom_display(res->portnum);
8412 	else if (!strcmp(res->type, "module_eeprom"))
8413 		port_module_eeprom_display(res->portnum);
8414 	else
8415 		fprintf(stderr, "Unknown argument\n");
8416 }
8417 
8418 cmdline_parse_token_string_t cmd_showeeprom_show =
8419 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8420 cmdline_parse_token_string_t cmd_showeeprom_port =
8421 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8422 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8423 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8424 			RTE_UINT16);
8425 cmdline_parse_token_string_t cmd_showeeprom_type =
8426 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8427 
8428 cmdline_parse_inst_t cmd_showeeprom = {
8429 	.f = cmd_showeeprom_parsed,
8430 	.data = NULL,
8431 	.help_str = "show port <port_id> module_eeprom|eeprom",
8432 	.tokens = {
8433 		(void *)&cmd_showeeprom_show,
8434 		(void *)&cmd_showeeprom_port,
8435 		(void *)&cmd_showeeprom_portnum,
8436 		(void *)&cmd_showeeprom_type,
8437 		NULL,
8438 	},
8439 };
8440 
8441 /* *** SHOW QUEUE INFO *** */
8442 struct cmd_showqueue_result {
8443 	cmdline_fixed_string_t show;
8444 	cmdline_fixed_string_t type;
8445 	cmdline_fixed_string_t what;
8446 	uint16_t portnum;
8447 	uint16_t queuenum;
8448 };
8449 
8450 static void
8451 cmd_showqueue_parsed(void *parsed_result,
8452 	__rte_unused struct cmdline *cl,
8453 	__rte_unused void *data)
8454 {
8455 	struct cmd_showqueue_result *res = parsed_result;
8456 
8457 	if (!strcmp(res->type, "rxq"))
8458 		rx_queue_infos_display(res->portnum, res->queuenum);
8459 	else if (!strcmp(res->type, "txq"))
8460 		tx_queue_infos_display(res->portnum, res->queuenum);
8461 }
8462 
8463 cmdline_parse_token_string_t cmd_showqueue_show =
8464 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8465 cmdline_parse_token_string_t cmd_showqueue_type =
8466 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8467 cmdline_parse_token_string_t cmd_showqueue_what =
8468 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8469 cmdline_parse_token_num_t cmd_showqueue_portnum =
8470 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8471 		RTE_UINT16);
8472 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8473 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8474 		RTE_UINT16);
8475 
8476 cmdline_parse_inst_t cmd_showqueue = {
8477 	.f = cmd_showqueue_parsed,
8478 	.data = NULL,
8479 	.help_str = "show rxq|txq info <port_id> <queue_id>",
8480 	.tokens = {
8481 		(void *)&cmd_showqueue_show,
8482 		(void *)&cmd_showqueue_type,
8483 		(void *)&cmd_showqueue_what,
8484 		(void *)&cmd_showqueue_portnum,
8485 		(void *)&cmd_showqueue_queuenum,
8486 		NULL,
8487 	},
8488 };
8489 
8490 /* show/clear fwd engine statistics */
8491 struct fwd_result {
8492 	cmdline_fixed_string_t action;
8493 	cmdline_fixed_string_t fwd;
8494 	cmdline_fixed_string_t stats;
8495 	cmdline_fixed_string_t all;
8496 };
8497 
8498 cmdline_parse_token_string_t cmd_fwd_action =
8499 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8500 cmdline_parse_token_string_t cmd_fwd_fwd =
8501 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8502 cmdline_parse_token_string_t cmd_fwd_stats =
8503 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8504 cmdline_parse_token_string_t cmd_fwd_all =
8505 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8506 
8507 static void
8508 cmd_showfwdall_parsed(void *parsed_result,
8509 		      __rte_unused struct cmdline *cl,
8510 		      __rte_unused void *data)
8511 {
8512 	struct fwd_result *res = parsed_result;
8513 
8514 	if (!strcmp(res->action, "show"))
8515 		fwd_stats_display();
8516 	else
8517 		fwd_stats_reset();
8518 }
8519 
8520 static cmdline_parse_inst_t cmd_showfwdall = {
8521 	.f = cmd_showfwdall_parsed,
8522 	.data = NULL,
8523 	.help_str = "show|clear fwd stats all",
8524 	.tokens = {
8525 		(void *)&cmd_fwd_action,
8526 		(void *)&cmd_fwd_fwd,
8527 		(void *)&cmd_fwd_stats,
8528 		(void *)&cmd_fwd_all,
8529 		NULL,
8530 	},
8531 };
8532 
8533 /* *** READ PORT REGISTER *** */
8534 struct cmd_read_reg_result {
8535 	cmdline_fixed_string_t read;
8536 	cmdline_fixed_string_t reg;
8537 	portid_t port_id;
8538 	uint32_t reg_off;
8539 };
8540 
8541 static void
8542 cmd_read_reg_parsed(void *parsed_result,
8543 		    __rte_unused struct cmdline *cl,
8544 		    __rte_unused void *data)
8545 {
8546 	struct cmd_read_reg_result *res = parsed_result;
8547 	port_reg_display(res->port_id, res->reg_off);
8548 }
8549 
8550 cmdline_parse_token_string_t cmd_read_reg_read =
8551 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8552 cmdline_parse_token_string_t cmd_read_reg_reg =
8553 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8554 cmdline_parse_token_num_t cmd_read_reg_port_id =
8555 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8556 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8557 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8558 
8559 cmdline_parse_inst_t cmd_read_reg = {
8560 	.f = cmd_read_reg_parsed,
8561 	.data = NULL,
8562 	.help_str = "read reg <port_id> <reg_off>",
8563 	.tokens = {
8564 		(void *)&cmd_read_reg_read,
8565 		(void *)&cmd_read_reg_reg,
8566 		(void *)&cmd_read_reg_port_id,
8567 		(void *)&cmd_read_reg_reg_off,
8568 		NULL,
8569 	},
8570 };
8571 
8572 /* *** READ PORT REGISTER BIT FIELD *** */
8573 struct cmd_read_reg_bit_field_result {
8574 	cmdline_fixed_string_t read;
8575 	cmdline_fixed_string_t regfield;
8576 	portid_t port_id;
8577 	uint32_t reg_off;
8578 	uint8_t bit1_pos;
8579 	uint8_t bit2_pos;
8580 };
8581 
8582 static void
8583 cmd_read_reg_bit_field_parsed(void *parsed_result,
8584 			      __rte_unused struct cmdline *cl,
8585 			      __rte_unused void *data)
8586 {
8587 	struct cmd_read_reg_bit_field_result *res = parsed_result;
8588 	port_reg_bit_field_display(res->port_id, res->reg_off,
8589 				   res->bit1_pos, res->bit2_pos);
8590 }
8591 
8592 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8593 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8594 				 "read");
8595 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8596 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8597 				 regfield, "regfield");
8598 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8599 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8600 			      RTE_UINT16);
8601 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8602 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8603 			      RTE_UINT32);
8604 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8605 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8606 			      RTE_UINT8);
8607 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8608 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8609 			      RTE_UINT8);
8610 
8611 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8612 	.f = cmd_read_reg_bit_field_parsed,
8613 	.data = NULL,
8614 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8615 	"Read register bit field between bit_x and bit_y included",
8616 	.tokens = {
8617 		(void *)&cmd_read_reg_bit_field_read,
8618 		(void *)&cmd_read_reg_bit_field_regfield,
8619 		(void *)&cmd_read_reg_bit_field_port_id,
8620 		(void *)&cmd_read_reg_bit_field_reg_off,
8621 		(void *)&cmd_read_reg_bit_field_bit1_pos,
8622 		(void *)&cmd_read_reg_bit_field_bit2_pos,
8623 		NULL,
8624 	},
8625 };
8626 
8627 /* *** READ PORT REGISTER BIT *** */
8628 struct cmd_read_reg_bit_result {
8629 	cmdline_fixed_string_t read;
8630 	cmdline_fixed_string_t regbit;
8631 	portid_t port_id;
8632 	uint32_t reg_off;
8633 	uint8_t bit_pos;
8634 };
8635 
8636 static void
8637 cmd_read_reg_bit_parsed(void *parsed_result,
8638 			__rte_unused struct cmdline *cl,
8639 			__rte_unused void *data)
8640 {
8641 	struct cmd_read_reg_bit_result *res = parsed_result;
8642 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8643 }
8644 
8645 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8646 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8647 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8648 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8649 				 regbit, "regbit");
8650 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8651 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8652 				 RTE_UINT16);
8653 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8654 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8655 				 RTE_UINT32);
8656 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8657 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8658 				 RTE_UINT8);
8659 
8660 cmdline_parse_inst_t cmd_read_reg_bit = {
8661 	.f = cmd_read_reg_bit_parsed,
8662 	.data = NULL,
8663 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8664 	.tokens = {
8665 		(void *)&cmd_read_reg_bit_read,
8666 		(void *)&cmd_read_reg_bit_regbit,
8667 		(void *)&cmd_read_reg_bit_port_id,
8668 		(void *)&cmd_read_reg_bit_reg_off,
8669 		(void *)&cmd_read_reg_bit_bit_pos,
8670 		NULL,
8671 	},
8672 };
8673 
8674 /* *** WRITE PORT REGISTER *** */
8675 struct cmd_write_reg_result {
8676 	cmdline_fixed_string_t write;
8677 	cmdline_fixed_string_t reg;
8678 	portid_t port_id;
8679 	uint32_t reg_off;
8680 	uint32_t value;
8681 };
8682 
8683 static void
8684 cmd_write_reg_parsed(void *parsed_result,
8685 		     __rte_unused struct cmdline *cl,
8686 		     __rte_unused void *data)
8687 {
8688 	struct cmd_write_reg_result *res = parsed_result;
8689 	port_reg_set(res->port_id, res->reg_off, res->value);
8690 }
8691 
8692 cmdline_parse_token_string_t cmd_write_reg_write =
8693 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8694 cmdline_parse_token_string_t cmd_write_reg_reg =
8695 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8696 cmdline_parse_token_num_t cmd_write_reg_port_id =
8697 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8698 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8699 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8700 cmdline_parse_token_num_t cmd_write_reg_value =
8701 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8702 
8703 cmdline_parse_inst_t cmd_write_reg = {
8704 	.f = cmd_write_reg_parsed,
8705 	.data = NULL,
8706 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8707 	.tokens = {
8708 		(void *)&cmd_write_reg_write,
8709 		(void *)&cmd_write_reg_reg,
8710 		(void *)&cmd_write_reg_port_id,
8711 		(void *)&cmd_write_reg_reg_off,
8712 		(void *)&cmd_write_reg_value,
8713 		NULL,
8714 	},
8715 };
8716 
8717 /* *** WRITE PORT REGISTER BIT FIELD *** */
8718 struct cmd_write_reg_bit_field_result {
8719 	cmdline_fixed_string_t write;
8720 	cmdline_fixed_string_t regfield;
8721 	portid_t port_id;
8722 	uint32_t reg_off;
8723 	uint8_t bit1_pos;
8724 	uint8_t bit2_pos;
8725 	uint32_t value;
8726 };
8727 
8728 static void
8729 cmd_write_reg_bit_field_parsed(void *parsed_result,
8730 			       __rte_unused struct cmdline *cl,
8731 			       __rte_unused void *data)
8732 {
8733 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8734 	port_reg_bit_field_set(res->port_id, res->reg_off,
8735 			  res->bit1_pos, res->bit2_pos, res->value);
8736 }
8737 
8738 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8739 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8740 				 "write");
8741 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8742 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8743 				 regfield, "regfield");
8744 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8745 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8746 			      RTE_UINT16);
8747 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8748 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8749 			      RTE_UINT32);
8750 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8751 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8752 			      RTE_UINT8);
8753 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8754 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8755 			      RTE_UINT8);
8756 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8757 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8758 			      RTE_UINT32);
8759 
8760 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8761 	.f = cmd_write_reg_bit_field_parsed,
8762 	.data = NULL,
8763 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8764 		"<reg_value>: "
8765 		"Set register bit field between bit_x and bit_y included",
8766 	.tokens = {
8767 		(void *)&cmd_write_reg_bit_field_write,
8768 		(void *)&cmd_write_reg_bit_field_regfield,
8769 		(void *)&cmd_write_reg_bit_field_port_id,
8770 		(void *)&cmd_write_reg_bit_field_reg_off,
8771 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8772 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8773 		(void *)&cmd_write_reg_bit_field_value,
8774 		NULL,
8775 	},
8776 };
8777 
8778 /* *** WRITE PORT REGISTER BIT *** */
8779 struct cmd_write_reg_bit_result {
8780 	cmdline_fixed_string_t write;
8781 	cmdline_fixed_string_t regbit;
8782 	portid_t port_id;
8783 	uint32_t reg_off;
8784 	uint8_t bit_pos;
8785 	uint8_t value;
8786 };
8787 
8788 static void
8789 cmd_write_reg_bit_parsed(void *parsed_result,
8790 			 __rte_unused struct cmdline *cl,
8791 			 __rte_unused void *data)
8792 {
8793 	struct cmd_write_reg_bit_result *res = parsed_result;
8794 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8795 }
8796 
8797 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8798 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8799 				 "write");
8800 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8801 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8802 				 regbit, "regbit");
8803 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8804 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8805 				 RTE_UINT16);
8806 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8807 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8808 				 RTE_UINT32);
8809 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8810 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8811 				 RTE_UINT8);
8812 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8813 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8814 				 RTE_UINT8);
8815 
8816 cmdline_parse_inst_t cmd_write_reg_bit = {
8817 	.f = cmd_write_reg_bit_parsed,
8818 	.data = NULL,
8819 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8820 		"0 <= bit_x <= 31",
8821 	.tokens = {
8822 		(void *)&cmd_write_reg_bit_write,
8823 		(void *)&cmd_write_reg_bit_regbit,
8824 		(void *)&cmd_write_reg_bit_port_id,
8825 		(void *)&cmd_write_reg_bit_reg_off,
8826 		(void *)&cmd_write_reg_bit_bit_pos,
8827 		(void *)&cmd_write_reg_bit_value,
8828 		NULL,
8829 	},
8830 };
8831 
8832 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8833 struct cmd_read_rxd_txd_result {
8834 	cmdline_fixed_string_t read;
8835 	cmdline_fixed_string_t rxd_txd;
8836 	portid_t port_id;
8837 	uint16_t queue_id;
8838 	uint16_t desc_id;
8839 };
8840 
8841 static void
8842 cmd_read_rxd_txd_parsed(void *parsed_result,
8843 			__rte_unused struct cmdline *cl,
8844 			__rte_unused void *data)
8845 {
8846 	struct cmd_read_rxd_txd_result *res = parsed_result;
8847 
8848 	if (!strcmp(res->rxd_txd, "rxd"))
8849 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8850 	else if (!strcmp(res->rxd_txd, "txd"))
8851 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8852 }
8853 
8854 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8855 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8856 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8857 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8858 				 "rxd#txd");
8859 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8860 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8861 				 RTE_UINT16);
8862 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8863 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8864 				 RTE_UINT16);
8865 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8866 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8867 				 RTE_UINT16);
8868 
8869 cmdline_parse_inst_t cmd_read_rxd_txd = {
8870 	.f = cmd_read_rxd_txd_parsed,
8871 	.data = NULL,
8872 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8873 	.tokens = {
8874 		(void *)&cmd_read_rxd_txd_read,
8875 		(void *)&cmd_read_rxd_txd_rxd_txd,
8876 		(void *)&cmd_read_rxd_txd_port_id,
8877 		(void *)&cmd_read_rxd_txd_queue_id,
8878 		(void *)&cmd_read_rxd_txd_desc_id,
8879 		NULL,
8880 	},
8881 };
8882 
8883 /* *** QUIT *** */
8884 struct cmd_quit_result {
8885 	cmdline_fixed_string_t quit;
8886 };
8887 
8888 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8889 			    struct cmdline *cl,
8890 			    __rte_unused void *data)
8891 {
8892 	cmdline_quit(cl);
8893 }
8894 
8895 cmdline_parse_token_string_t cmd_quit_quit =
8896 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8897 
8898 cmdline_parse_inst_t cmd_quit = {
8899 	.f = cmd_quit_parsed,
8900 	.data = NULL,
8901 	.help_str = "quit: Exit application",
8902 	.tokens = {
8903 		(void *)&cmd_quit_quit,
8904 		NULL,
8905 	},
8906 };
8907 
8908 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8909 struct cmd_mac_addr_result {
8910 	cmdline_fixed_string_t mac_addr_cmd;
8911 	cmdline_fixed_string_t what;
8912 	uint16_t port_num;
8913 	struct rte_ether_addr address;
8914 };
8915 
8916 static void cmd_mac_addr_parsed(void *parsed_result,
8917 		__rte_unused struct cmdline *cl,
8918 		__rte_unused void *data)
8919 {
8920 	struct cmd_mac_addr_result *res = parsed_result;
8921 	int ret;
8922 
8923 	if (strcmp(res->what, "add") == 0)
8924 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8925 	else if (strcmp(res->what, "set") == 0)
8926 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8927 						       &res->address);
8928 	else
8929 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8930 
8931 	/* check the return value and print it if is < 0 */
8932 	if(ret < 0)
8933 		fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8934 
8935 }
8936 
8937 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8938 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8939 				"mac_addr");
8940 cmdline_parse_token_string_t cmd_mac_addr_what =
8941 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8942 				"add#remove#set");
8943 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8944 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8945 					RTE_UINT16);
8946 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8947 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8948 
8949 cmdline_parse_inst_t cmd_mac_addr = {
8950 	.f = cmd_mac_addr_parsed,
8951 	.data = (void *)0,
8952 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8953 			"Add/Remove/Set MAC address on port_id",
8954 	.tokens = {
8955 		(void *)&cmd_mac_addr_cmd,
8956 		(void *)&cmd_mac_addr_what,
8957 		(void *)&cmd_mac_addr_portnum,
8958 		(void *)&cmd_mac_addr_addr,
8959 		NULL,
8960 	},
8961 };
8962 
8963 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8964 struct cmd_eth_peer_result {
8965 	cmdline_fixed_string_t set;
8966 	cmdline_fixed_string_t eth_peer;
8967 	portid_t port_id;
8968 	cmdline_fixed_string_t peer_addr;
8969 };
8970 
8971 static void cmd_set_eth_peer_parsed(void *parsed_result,
8972 			__rte_unused struct cmdline *cl,
8973 			__rte_unused void *data)
8974 {
8975 		struct cmd_eth_peer_result *res = parsed_result;
8976 
8977 		if (test_done == 0) {
8978 			fprintf(stderr, "Please stop forwarding first\n");
8979 			return;
8980 		}
8981 		if (!strcmp(res->eth_peer, "eth-peer")) {
8982 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8983 			fwd_config_setup();
8984 		}
8985 }
8986 cmdline_parse_token_string_t cmd_eth_peer_set =
8987 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8988 cmdline_parse_token_string_t cmd_eth_peer =
8989 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8990 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8991 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8992 		RTE_UINT16);
8993 cmdline_parse_token_string_t cmd_eth_peer_addr =
8994 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8995 
8996 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8997 	.f = cmd_set_eth_peer_parsed,
8998 	.data = NULL,
8999 	.help_str = "set eth-peer <port_id> <peer_mac>",
9000 	.tokens = {
9001 		(void *)&cmd_eth_peer_set,
9002 		(void *)&cmd_eth_peer,
9003 		(void *)&cmd_eth_peer_port_id,
9004 		(void *)&cmd_eth_peer_addr,
9005 		NULL,
9006 	},
9007 };
9008 
9009 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9010 struct cmd_set_qmap_result {
9011 	cmdline_fixed_string_t set;
9012 	cmdline_fixed_string_t qmap;
9013 	cmdline_fixed_string_t what;
9014 	portid_t port_id;
9015 	uint16_t queue_id;
9016 	uint8_t map_value;
9017 };
9018 
9019 static void
9020 cmd_set_qmap_parsed(void *parsed_result,
9021 		       __rte_unused struct cmdline *cl,
9022 		       __rte_unused void *data)
9023 {
9024 	struct cmd_set_qmap_result *res = parsed_result;
9025 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9026 
9027 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9028 }
9029 
9030 cmdline_parse_token_string_t cmd_setqmap_set =
9031 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9032 				 set, "set");
9033 cmdline_parse_token_string_t cmd_setqmap_qmap =
9034 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9035 				 qmap, "stat_qmap");
9036 cmdline_parse_token_string_t cmd_setqmap_what =
9037 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9038 				 what, "tx#rx");
9039 cmdline_parse_token_num_t cmd_setqmap_portid =
9040 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9041 			      port_id, RTE_UINT16);
9042 cmdline_parse_token_num_t cmd_setqmap_queueid =
9043 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9044 			      queue_id, RTE_UINT16);
9045 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9046 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9047 			      map_value, RTE_UINT8);
9048 
9049 cmdline_parse_inst_t cmd_set_qmap = {
9050 	.f = cmd_set_qmap_parsed,
9051 	.data = NULL,
9052 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9053 		"Set statistics mapping value on tx|rx queue_id of port_id",
9054 	.tokens = {
9055 		(void *)&cmd_setqmap_set,
9056 		(void *)&cmd_setqmap_qmap,
9057 		(void *)&cmd_setqmap_what,
9058 		(void *)&cmd_setqmap_portid,
9059 		(void *)&cmd_setqmap_queueid,
9060 		(void *)&cmd_setqmap_mapvalue,
9061 		NULL,
9062 	},
9063 };
9064 
9065 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
9066 struct cmd_set_xstats_hide_zero_result {
9067 	cmdline_fixed_string_t keyword;
9068 	cmdline_fixed_string_t name;
9069 	cmdline_fixed_string_t on_off;
9070 };
9071 
9072 static void
9073 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9074 			__rte_unused struct cmdline *cl,
9075 			__rte_unused void *data)
9076 {
9077 	struct cmd_set_xstats_hide_zero_result *res;
9078 	uint16_t on_off = 0;
9079 
9080 	res = parsed_result;
9081 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9082 	set_xstats_hide_zero(on_off);
9083 }
9084 
9085 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9086 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9087 				 keyword, "set");
9088 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9089 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9090 				 name, "xstats-hide-zero");
9091 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9092 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9093 				 on_off, "on#off");
9094 
9095 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9096 	.f = cmd_set_xstats_hide_zero_parsed,
9097 	.data = NULL,
9098 	.help_str = "set xstats-hide-zero on|off",
9099 	.tokens = {
9100 		(void *)&cmd_set_xstats_hide_zero_keyword,
9101 		(void *)&cmd_set_xstats_hide_zero_name,
9102 		(void *)&cmd_set_xstats_hide_zero_on_off,
9103 		NULL,
9104 	},
9105 };
9106 
9107 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9108 struct cmd_set_record_core_cycles_result {
9109 	cmdline_fixed_string_t keyword;
9110 	cmdline_fixed_string_t name;
9111 	cmdline_fixed_string_t on_off;
9112 };
9113 
9114 static void
9115 cmd_set_record_core_cycles_parsed(void *parsed_result,
9116 			__rte_unused struct cmdline *cl,
9117 			__rte_unused void *data)
9118 {
9119 	struct cmd_set_record_core_cycles_result *res;
9120 	uint16_t on_off = 0;
9121 
9122 	res = parsed_result;
9123 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9124 	set_record_core_cycles(on_off);
9125 }
9126 
9127 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9128 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9129 				 keyword, "set");
9130 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9131 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9132 				 name, "record-core-cycles");
9133 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9134 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9135 				 on_off, "on#off");
9136 
9137 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9138 	.f = cmd_set_record_core_cycles_parsed,
9139 	.data = NULL,
9140 	.help_str = "set record-core-cycles on|off",
9141 	.tokens = {
9142 		(void *)&cmd_set_record_core_cycles_keyword,
9143 		(void *)&cmd_set_record_core_cycles_name,
9144 		(void *)&cmd_set_record_core_cycles_on_off,
9145 		NULL,
9146 	},
9147 };
9148 
9149 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9150 struct cmd_set_record_burst_stats_result {
9151 	cmdline_fixed_string_t keyword;
9152 	cmdline_fixed_string_t name;
9153 	cmdline_fixed_string_t on_off;
9154 };
9155 
9156 static void
9157 cmd_set_record_burst_stats_parsed(void *parsed_result,
9158 			__rte_unused struct cmdline *cl,
9159 			__rte_unused void *data)
9160 {
9161 	struct cmd_set_record_burst_stats_result *res;
9162 	uint16_t on_off = 0;
9163 
9164 	res = parsed_result;
9165 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9166 	set_record_burst_stats(on_off);
9167 }
9168 
9169 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9170 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9171 				 keyword, "set");
9172 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9173 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9174 				 name, "record-burst-stats");
9175 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9176 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9177 				 on_off, "on#off");
9178 
9179 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9180 	.f = cmd_set_record_burst_stats_parsed,
9181 	.data = NULL,
9182 	.help_str = "set record-burst-stats on|off",
9183 	.tokens = {
9184 		(void *)&cmd_set_record_burst_stats_keyword,
9185 		(void *)&cmd_set_record_burst_stats_name,
9186 		(void *)&cmd_set_record_burst_stats_on_off,
9187 		NULL,
9188 	},
9189 };
9190 
9191 /* *** CONFIGURE UNICAST HASH TABLE *** */
9192 struct cmd_set_uc_hash_table {
9193 	cmdline_fixed_string_t set;
9194 	cmdline_fixed_string_t port;
9195 	portid_t port_id;
9196 	cmdline_fixed_string_t what;
9197 	struct rte_ether_addr address;
9198 	cmdline_fixed_string_t mode;
9199 };
9200 
9201 static void
9202 cmd_set_uc_hash_parsed(void *parsed_result,
9203 		       __rte_unused struct cmdline *cl,
9204 		       __rte_unused void *data)
9205 {
9206 	int ret=0;
9207 	struct cmd_set_uc_hash_table *res = parsed_result;
9208 
9209 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9210 
9211 	if (strcmp(res->what, "uta") == 0)
9212 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9213 						&res->address,(uint8_t)is_on);
9214 	if (ret < 0)
9215 		fprintf(stderr,
9216 			"bad unicast hash table parameter, return code = %d\n",
9217 			ret);
9218 
9219 }
9220 
9221 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9222 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9223 				 set, "set");
9224 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9225 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9226 				 port, "port");
9227 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9228 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9229 			      port_id, RTE_UINT16);
9230 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9231 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9232 				 what, "uta");
9233 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9234 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9235 				address);
9236 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9237 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9238 				 mode, "on#off");
9239 
9240 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9241 	.f = cmd_set_uc_hash_parsed,
9242 	.data = NULL,
9243 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
9244 	.tokens = {
9245 		(void *)&cmd_set_uc_hash_set,
9246 		(void *)&cmd_set_uc_hash_port,
9247 		(void *)&cmd_set_uc_hash_portid,
9248 		(void *)&cmd_set_uc_hash_what,
9249 		(void *)&cmd_set_uc_hash_mac,
9250 		(void *)&cmd_set_uc_hash_mode,
9251 		NULL,
9252 	},
9253 };
9254 
9255 struct cmd_set_uc_all_hash_table {
9256 	cmdline_fixed_string_t set;
9257 	cmdline_fixed_string_t port;
9258 	portid_t port_id;
9259 	cmdline_fixed_string_t what;
9260 	cmdline_fixed_string_t value;
9261 	cmdline_fixed_string_t mode;
9262 };
9263 
9264 static void
9265 cmd_set_uc_all_hash_parsed(void *parsed_result,
9266 		       __rte_unused struct cmdline *cl,
9267 		       __rte_unused void *data)
9268 {
9269 	int ret=0;
9270 	struct cmd_set_uc_all_hash_table *res = parsed_result;
9271 
9272 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9273 
9274 	if ((strcmp(res->what, "uta") == 0) &&
9275 		(strcmp(res->value, "all") == 0))
9276 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9277 	if (ret < 0)
9278 		fprintf(stderr,
9279 			"bad unicast hash table parameter, return code = %d\n",
9280 			ret);
9281 }
9282 
9283 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9284 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9285 				 set, "set");
9286 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9287 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9288 				 port, "port");
9289 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9290 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9291 			      port_id, RTE_UINT16);
9292 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9293 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9294 				 what, "uta");
9295 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9296 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9297 				value,"all");
9298 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9299 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9300 				 mode, "on#off");
9301 
9302 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9303 	.f = cmd_set_uc_all_hash_parsed,
9304 	.data = NULL,
9305 	.help_str = "set port <port_id> uta all on|off",
9306 	.tokens = {
9307 		(void *)&cmd_set_uc_all_hash_set,
9308 		(void *)&cmd_set_uc_all_hash_port,
9309 		(void *)&cmd_set_uc_all_hash_portid,
9310 		(void *)&cmd_set_uc_all_hash_what,
9311 		(void *)&cmd_set_uc_all_hash_value,
9312 		(void *)&cmd_set_uc_all_hash_mode,
9313 		NULL,
9314 	},
9315 };
9316 
9317 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9318 struct cmd_set_vf_traffic {
9319 	cmdline_fixed_string_t set;
9320 	cmdline_fixed_string_t port;
9321 	portid_t port_id;
9322 	cmdline_fixed_string_t vf;
9323 	uint8_t vf_id;
9324 	cmdline_fixed_string_t what;
9325 	cmdline_fixed_string_t mode;
9326 };
9327 
9328 static void
9329 cmd_set_vf_traffic_parsed(void *parsed_result,
9330 		       __rte_unused struct cmdline *cl,
9331 		       __rte_unused void *data)
9332 {
9333 	struct cmd_set_vf_traffic *res = parsed_result;
9334 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9335 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9336 
9337 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9338 }
9339 
9340 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9341 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9342 				 set, "set");
9343 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9344 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9345 				 port, "port");
9346 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9347 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9348 			      port_id, RTE_UINT16);
9349 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9350 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9351 				 vf, "vf");
9352 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9353 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9354 			      vf_id, RTE_UINT8);
9355 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9356 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9357 				 what, "tx#rx");
9358 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9359 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9360 				 mode, "on#off");
9361 
9362 cmdline_parse_inst_t cmd_set_vf_traffic = {
9363 	.f = cmd_set_vf_traffic_parsed,
9364 	.data = NULL,
9365 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9366 	.tokens = {
9367 		(void *)&cmd_setvf_traffic_set,
9368 		(void *)&cmd_setvf_traffic_port,
9369 		(void *)&cmd_setvf_traffic_portid,
9370 		(void *)&cmd_setvf_traffic_vf,
9371 		(void *)&cmd_setvf_traffic_vfid,
9372 		(void *)&cmd_setvf_traffic_what,
9373 		(void *)&cmd_setvf_traffic_mode,
9374 		NULL,
9375 	},
9376 };
9377 
9378 /* *** CONFIGURE VF RECEIVE MODE *** */
9379 struct cmd_set_vf_rxmode {
9380 	cmdline_fixed_string_t set;
9381 	cmdline_fixed_string_t port;
9382 	portid_t port_id;
9383 	cmdline_fixed_string_t vf;
9384 	uint8_t vf_id;
9385 	cmdline_fixed_string_t what;
9386 	cmdline_fixed_string_t mode;
9387 	cmdline_fixed_string_t on;
9388 };
9389 
9390 static void
9391 cmd_set_vf_rxmode_parsed(void *parsed_result,
9392 		       __rte_unused struct cmdline *cl,
9393 		       __rte_unused void *data)
9394 {
9395 	int ret = -ENOTSUP;
9396 	uint16_t vf_rxmode = 0;
9397 	struct cmd_set_vf_rxmode *res = parsed_result;
9398 
9399 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9400 	if (!strcmp(res->what,"rxmode")) {
9401 		if (!strcmp(res->mode, "AUPE"))
9402 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9403 		else if (!strcmp(res->mode, "ROPE"))
9404 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9405 		else if (!strcmp(res->mode, "BAM"))
9406 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9407 		else if (!strncmp(res->mode, "MPE",3))
9408 			vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9409 	}
9410 
9411 	RTE_SET_USED(is_on);
9412 	RTE_SET_USED(vf_rxmode);
9413 
9414 #ifdef RTE_NET_IXGBE
9415 	if (ret == -ENOTSUP)
9416 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9417 						  vf_rxmode, (uint8_t)is_on);
9418 #endif
9419 #ifdef RTE_NET_BNXT
9420 	if (ret == -ENOTSUP)
9421 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9422 						 vf_rxmode, (uint8_t)is_on);
9423 #endif
9424 	if (ret < 0)
9425 		fprintf(stderr,
9426 			"bad VF receive mode parameter, return code = %d\n",
9427 			ret);
9428 }
9429 
9430 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9431 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9432 				 set, "set");
9433 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9434 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9435 				 port, "port");
9436 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9437 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9438 			      port_id, RTE_UINT16);
9439 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9440 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9441 				 vf, "vf");
9442 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9443 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9444 			      vf_id, RTE_UINT8);
9445 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9446 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9447 				 what, "rxmode");
9448 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9449 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9450 				 mode, "AUPE#ROPE#BAM#MPE");
9451 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9452 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9453 				 on, "on#off");
9454 
9455 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9456 	.f = cmd_set_vf_rxmode_parsed,
9457 	.data = NULL,
9458 	.help_str = "set port <port_id> vf <vf_id> rxmode "
9459 		"AUPE|ROPE|BAM|MPE on|off",
9460 	.tokens = {
9461 		(void *)&cmd_set_vf_rxmode_set,
9462 		(void *)&cmd_set_vf_rxmode_port,
9463 		(void *)&cmd_set_vf_rxmode_portid,
9464 		(void *)&cmd_set_vf_rxmode_vf,
9465 		(void *)&cmd_set_vf_rxmode_vfid,
9466 		(void *)&cmd_set_vf_rxmode_what,
9467 		(void *)&cmd_set_vf_rxmode_mode,
9468 		(void *)&cmd_set_vf_rxmode_on,
9469 		NULL,
9470 	},
9471 };
9472 
9473 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9474 struct cmd_vf_mac_addr_result {
9475 	cmdline_fixed_string_t mac_addr_cmd;
9476 	cmdline_fixed_string_t what;
9477 	cmdline_fixed_string_t port;
9478 	uint16_t port_num;
9479 	cmdline_fixed_string_t vf;
9480 	uint8_t vf_num;
9481 	struct rte_ether_addr address;
9482 };
9483 
9484 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9485 		__rte_unused struct cmdline *cl,
9486 		__rte_unused void *data)
9487 {
9488 	struct cmd_vf_mac_addr_result *res = parsed_result;
9489 	int ret = -ENOTSUP;
9490 
9491 	if (strcmp(res->what, "add") != 0)
9492 		return;
9493 
9494 #ifdef RTE_NET_I40E
9495 	if (ret == -ENOTSUP)
9496 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9497 						   &res->address);
9498 #endif
9499 #ifdef RTE_NET_BNXT
9500 	if (ret == -ENOTSUP)
9501 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9502 						res->vf_num);
9503 #endif
9504 
9505 	if(ret < 0)
9506 		fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9507 
9508 }
9509 
9510 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9511 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9512 				mac_addr_cmd,"mac_addr");
9513 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9514 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9515 				what,"add");
9516 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9517 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9518 				port,"port");
9519 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9520 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9521 				port_num, RTE_UINT16);
9522 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9523 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9524 				vf,"vf");
9525 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9526 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9527 				vf_num, RTE_UINT8);
9528 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9529 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9530 				address);
9531 
9532 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9533 	.f = cmd_vf_mac_addr_parsed,
9534 	.data = (void *)0,
9535 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9536 		"Add MAC address filtering for a VF on port_id",
9537 	.tokens = {
9538 		(void *)&cmd_vf_mac_addr_cmd,
9539 		(void *)&cmd_vf_mac_addr_what,
9540 		(void *)&cmd_vf_mac_addr_port,
9541 		(void *)&cmd_vf_mac_addr_portnum,
9542 		(void *)&cmd_vf_mac_addr_vf,
9543 		(void *)&cmd_vf_mac_addr_vfnum,
9544 		(void *)&cmd_vf_mac_addr_addr,
9545 		NULL,
9546 	},
9547 };
9548 
9549 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9550 struct cmd_vf_rx_vlan_filter {
9551 	cmdline_fixed_string_t rx_vlan;
9552 	cmdline_fixed_string_t what;
9553 	uint16_t vlan_id;
9554 	cmdline_fixed_string_t port;
9555 	portid_t port_id;
9556 	cmdline_fixed_string_t vf;
9557 	uint64_t vf_mask;
9558 };
9559 
9560 static void
9561 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9562 			  __rte_unused struct cmdline *cl,
9563 			  __rte_unused void *data)
9564 {
9565 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
9566 	int ret = -ENOTSUP;
9567 
9568 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9569 
9570 #ifdef RTE_NET_IXGBE
9571 	if (ret == -ENOTSUP)
9572 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9573 				res->vlan_id, res->vf_mask, is_add);
9574 #endif
9575 #ifdef RTE_NET_I40E
9576 	if (ret == -ENOTSUP)
9577 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9578 				res->vlan_id, res->vf_mask, is_add);
9579 #endif
9580 #ifdef RTE_NET_BNXT
9581 	if (ret == -ENOTSUP)
9582 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9583 				res->vlan_id, res->vf_mask, is_add);
9584 #endif
9585 
9586 	switch (ret) {
9587 	case 0:
9588 		break;
9589 	case -EINVAL:
9590 		fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9591 			res->vlan_id, res->vf_mask);
9592 		break;
9593 	case -ENODEV:
9594 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
9595 		break;
9596 	case -ENOTSUP:
9597 		fprintf(stderr, "function not implemented or supported\n");
9598 		break;
9599 	default:
9600 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9601 	}
9602 }
9603 
9604 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9605 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9606 				 rx_vlan, "rx_vlan");
9607 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9608 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9609 				 what, "add#rm");
9610 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9611 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9612 			      vlan_id, RTE_UINT16);
9613 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9614 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9615 				 port, "port");
9616 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9617 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9618 			      port_id, RTE_UINT16);
9619 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9620 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9621 				 vf, "vf");
9622 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9623 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9624 			      vf_mask, RTE_UINT64);
9625 
9626 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9627 	.f = cmd_vf_rx_vlan_filter_parsed,
9628 	.data = NULL,
9629 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9630 		"(vf_mask = hexadecimal VF mask)",
9631 	.tokens = {
9632 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9633 		(void *)&cmd_vf_rx_vlan_filter_what,
9634 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
9635 		(void *)&cmd_vf_rx_vlan_filter_port,
9636 		(void *)&cmd_vf_rx_vlan_filter_portid,
9637 		(void *)&cmd_vf_rx_vlan_filter_vf,
9638 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
9639 		NULL,
9640 	},
9641 };
9642 
9643 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9644 struct cmd_queue_rate_limit_result {
9645 	cmdline_fixed_string_t set;
9646 	cmdline_fixed_string_t port;
9647 	uint16_t port_num;
9648 	cmdline_fixed_string_t queue;
9649 	uint8_t queue_num;
9650 	cmdline_fixed_string_t rate;
9651 	uint16_t rate_num;
9652 };
9653 
9654 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9655 		__rte_unused struct cmdline *cl,
9656 		__rte_unused void *data)
9657 {
9658 	struct cmd_queue_rate_limit_result *res = parsed_result;
9659 	int ret = 0;
9660 
9661 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9662 		&& (strcmp(res->queue, "queue") == 0)
9663 		&& (strcmp(res->rate, "rate") == 0))
9664 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
9665 					res->rate_num);
9666 	if (ret < 0)
9667 		fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9668 			strerror(-ret));
9669 
9670 }
9671 
9672 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9673 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9674 				set, "set");
9675 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9676 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9677 				port, "port");
9678 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9679 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9680 				port_num, RTE_UINT16);
9681 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9682 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9683 				queue, "queue");
9684 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9685 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9686 				queue_num, RTE_UINT8);
9687 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9688 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9689 				rate, "rate");
9690 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9691 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9692 				rate_num, RTE_UINT16);
9693 
9694 cmdline_parse_inst_t cmd_queue_rate_limit = {
9695 	.f = cmd_queue_rate_limit_parsed,
9696 	.data = (void *)0,
9697 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9698 		"Set rate limit for a queue on port_id",
9699 	.tokens = {
9700 		(void *)&cmd_queue_rate_limit_set,
9701 		(void *)&cmd_queue_rate_limit_port,
9702 		(void *)&cmd_queue_rate_limit_portnum,
9703 		(void *)&cmd_queue_rate_limit_queue,
9704 		(void *)&cmd_queue_rate_limit_queuenum,
9705 		(void *)&cmd_queue_rate_limit_rate,
9706 		(void *)&cmd_queue_rate_limit_ratenum,
9707 		NULL,
9708 	},
9709 };
9710 
9711 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9712 struct cmd_vf_rate_limit_result {
9713 	cmdline_fixed_string_t set;
9714 	cmdline_fixed_string_t port;
9715 	uint16_t port_num;
9716 	cmdline_fixed_string_t vf;
9717 	uint8_t vf_num;
9718 	cmdline_fixed_string_t rate;
9719 	uint16_t rate_num;
9720 	cmdline_fixed_string_t q_msk;
9721 	uint64_t q_msk_val;
9722 };
9723 
9724 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9725 		__rte_unused struct cmdline *cl,
9726 		__rte_unused void *data)
9727 {
9728 	struct cmd_vf_rate_limit_result *res = parsed_result;
9729 	int ret = 0;
9730 
9731 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9732 		&& (strcmp(res->vf, "vf") == 0)
9733 		&& (strcmp(res->rate, "rate") == 0)
9734 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9735 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9736 					res->rate_num, res->q_msk_val);
9737 	if (ret < 0)
9738 		fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9739 			strerror(-ret));
9740 
9741 }
9742 
9743 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9744 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9745 				set, "set");
9746 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9747 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9748 				port, "port");
9749 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9750 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9751 				port_num, RTE_UINT16);
9752 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9753 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9754 				vf, "vf");
9755 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9756 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9757 				vf_num, RTE_UINT8);
9758 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9759 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9760 				rate, "rate");
9761 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9762 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9763 				rate_num, RTE_UINT16);
9764 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9765 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9766 				q_msk, "queue_mask");
9767 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9768 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9769 				q_msk_val, RTE_UINT64);
9770 
9771 cmdline_parse_inst_t cmd_vf_rate_limit = {
9772 	.f = cmd_vf_rate_limit_parsed,
9773 	.data = (void *)0,
9774 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9775 		"queue_mask <queue_mask_value>: "
9776 		"Set rate limit for queues of VF on port_id",
9777 	.tokens = {
9778 		(void *)&cmd_vf_rate_limit_set,
9779 		(void *)&cmd_vf_rate_limit_port,
9780 		(void *)&cmd_vf_rate_limit_portnum,
9781 		(void *)&cmd_vf_rate_limit_vf,
9782 		(void *)&cmd_vf_rate_limit_vfnum,
9783 		(void *)&cmd_vf_rate_limit_rate,
9784 		(void *)&cmd_vf_rate_limit_ratenum,
9785 		(void *)&cmd_vf_rate_limit_q_msk,
9786 		(void *)&cmd_vf_rate_limit_q_msk_val,
9787 		NULL,
9788 	},
9789 };
9790 
9791 /* *** CONFIGURE TUNNEL UDP PORT *** */
9792 struct cmd_tunnel_udp_config {
9793 	cmdline_fixed_string_t rx_vxlan_port;
9794 	cmdline_fixed_string_t what;
9795 	uint16_t udp_port;
9796 	portid_t port_id;
9797 };
9798 
9799 static void
9800 cmd_tunnel_udp_config_parsed(void *parsed_result,
9801 			  __rte_unused struct cmdline *cl,
9802 			  __rte_unused void *data)
9803 {
9804 	struct cmd_tunnel_udp_config *res = parsed_result;
9805 	struct rte_eth_udp_tunnel tunnel_udp;
9806 	int ret;
9807 
9808 	tunnel_udp.udp_port = res->udp_port;
9809 	tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9810 
9811 	if (!strcmp(res->what, "add"))
9812 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9813 						      &tunnel_udp);
9814 	else
9815 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9816 							 &tunnel_udp);
9817 
9818 	if (ret < 0)
9819 		fprintf(stderr, "udp tunneling add error: (%s)\n",
9820 			strerror(-ret));
9821 }
9822 
9823 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9824 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9825 				rx_vxlan_port, "rx_vxlan_port");
9826 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9827 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9828 				what, "add#rm");
9829 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9830 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9831 				udp_port, RTE_UINT16);
9832 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9833 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9834 				port_id, RTE_UINT16);
9835 
9836 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9837 	.f = cmd_tunnel_udp_config_parsed,
9838 	.data = (void *)0,
9839 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9840 		"Add/Remove a tunneling UDP port filter",
9841 	.tokens = {
9842 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9843 		(void *)&cmd_tunnel_udp_config_what,
9844 		(void *)&cmd_tunnel_udp_config_udp_port,
9845 		(void *)&cmd_tunnel_udp_config_port_id,
9846 		NULL,
9847 	},
9848 };
9849 
9850 struct cmd_config_tunnel_udp_port {
9851 	cmdline_fixed_string_t port;
9852 	cmdline_fixed_string_t config;
9853 	portid_t port_id;
9854 	cmdline_fixed_string_t udp_tunnel_port;
9855 	cmdline_fixed_string_t action;
9856 	cmdline_fixed_string_t tunnel_type;
9857 	uint16_t udp_port;
9858 };
9859 
9860 static void
9861 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9862 			       __rte_unused struct cmdline *cl,
9863 			       __rte_unused void *data)
9864 {
9865 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9866 	struct rte_eth_udp_tunnel tunnel_udp;
9867 	int ret = 0;
9868 
9869 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9870 		return;
9871 
9872 	tunnel_udp.udp_port = res->udp_port;
9873 
9874 	if (!strcmp(res->tunnel_type, "vxlan")) {
9875 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9876 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9877 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9878 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9879 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9880 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9881 		tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9882 	} else {
9883 		fprintf(stderr, "Invalid tunnel type\n");
9884 		return;
9885 	}
9886 
9887 	if (!strcmp(res->action, "add"))
9888 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9889 						      &tunnel_udp);
9890 	else
9891 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9892 							 &tunnel_udp);
9893 
9894 	if (ret < 0)
9895 		fprintf(stderr, "udp tunneling port add error: (%s)\n",
9896 			strerror(-ret));
9897 }
9898 
9899 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9900 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9901 				 "port");
9902 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9903 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9904 				 "config");
9905 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9906 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9907 			      RTE_UINT16);
9908 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9909 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9910 				 udp_tunnel_port,
9911 				 "udp_tunnel_port");
9912 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9913 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9914 				 "add#rm");
9915 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9916 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9917 				 "vxlan#geneve#vxlan-gpe#ecpri");
9918 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9919 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9920 			      RTE_UINT16);
9921 
9922 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9923 	.f = cmd_cfg_tunnel_udp_port_parsed,
9924 	.data = NULL,
9925 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9926 		"geneve|vxlan-gpe|ecpri <udp_port>",
9927 	.tokens = {
9928 		(void *)&cmd_config_tunnel_udp_port_port,
9929 		(void *)&cmd_config_tunnel_udp_port_config,
9930 		(void *)&cmd_config_tunnel_udp_port_port_id,
9931 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9932 		(void *)&cmd_config_tunnel_udp_port_action,
9933 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9934 		(void *)&cmd_config_tunnel_udp_port_value,
9935 		NULL,
9936 	},
9937 };
9938 
9939 /* ******************************************************************************** */
9940 
9941 struct cmd_dump_result {
9942 	cmdline_fixed_string_t dump;
9943 };
9944 
9945 static void
9946 dump_struct_sizes(void)
9947 {
9948 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9949 	DUMP_SIZE(struct rte_mbuf);
9950 	DUMP_SIZE(struct rte_mempool);
9951 	DUMP_SIZE(struct rte_ring);
9952 #undef DUMP_SIZE
9953 }
9954 
9955 
9956 /* Dump the socket memory statistics on console */
9957 static void
9958 dump_socket_mem(FILE *f)
9959 {
9960 	struct rte_malloc_socket_stats socket_stats;
9961 	unsigned int i;
9962 	size_t total = 0;
9963 	size_t alloc = 0;
9964 	size_t free = 0;
9965 	unsigned int n_alloc = 0;
9966 	unsigned int n_free = 0;
9967 	static size_t last_allocs;
9968 	static size_t last_total;
9969 
9970 
9971 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9972 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9973 		    !socket_stats.heap_totalsz_bytes)
9974 			continue;
9975 		total += socket_stats.heap_totalsz_bytes;
9976 		alloc += socket_stats.heap_allocsz_bytes;
9977 		free += socket_stats.heap_freesz_bytes;
9978 		n_alloc += socket_stats.alloc_count;
9979 		n_free += socket_stats.free_count;
9980 		fprintf(f,
9981 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9982 			i,
9983 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9984 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9985 			(double)socket_stats.heap_allocsz_bytes * 100 /
9986 			(double)socket_stats.heap_totalsz_bytes,
9987 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9988 			socket_stats.alloc_count,
9989 			socket_stats.free_count);
9990 	}
9991 	fprintf(f,
9992 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9993 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9994 		total ? ((double)alloc * 100 / (double)total) : 0,
9995 		(double)free / (1024 * 1024),
9996 		n_alloc, n_free);
9997 	if (last_allocs)
9998 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9999 			((double)total - (double)last_total) / (1024 * 1024),
10000 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
10001 	last_allocs = alloc;
10002 	last_total = total;
10003 }
10004 
10005 static void cmd_dump_parsed(void *parsed_result,
10006 			    __rte_unused struct cmdline *cl,
10007 			    __rte_unused void *data)
10008 {
10009 	struct cmd_dump_result *res = parsed_result;
10010 
10011 	if (!strcmp(res->dump, "dump_physmem"))
10012 		rte_dump_physmem_layout(stdout);
10013 	else if (!strcmp(res->dump, "dump_socket_mem"))
10014 		dump_socket_mem(stdout);
10015 	else if (!strcmp(res->dump, "dump_memzone"))
10016 		rte_memzone_dump(stdout);
10017 	else if (!strcmp(res->dump, "dump_struct_sizes"))
10018 		dump_struct_sizes();
10019 	else if (!strcmp(res->dump, "dump_ring"))
10020 		rte_ring_list_dump(stdout);
10021 	else if (!strcmp(res->dump, "dump_mempool"))
10022 		rte_mempool_list_dump(stdout);
10023 	else if (!strcmp(res->dump, "dump_devargs"))
10024 		rte_devargs_dump(stdout);
10025 	else if (!strcmp(res->dump, "dump_log_types"))
10026 		rte_log_dump(stdout);
10027 }
10028 
10029 cmdline_parse_token_string_t cmd_dump_dump =
10030 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10031 		"dump_physmem#"
10032 		"dump_memzone#"
10033 		"dump_socket_mem#"
10034 		"dump_struct_sizes#"
10035 		"dump_ring#"
10036 		"dump_mempool#"
10037 		"dump_devargs#"
10038 		"dump_log_types");
10039 
10040 cmdline_parse_inst_t cmd_dump = {
10041 	.f = cmd_dump_parsed,  /* function to call */
10042 	.data = NULL,      /* 2nd arg of func */
10043 	.help_str = "Dump status",
10044 	.tokens = {        /* token list, NULL terminated */
10045 		(void *)&cmd_dump_dump,
10046 		NULL,
10047 	},
10048 };
10049 
10050 /* ******************************************************************************** */
10051 
10052 struct cmd_dump_one_result {
10053 	cmdline_fixed_string_t dump;
10054 	cmdline_fixed_string_t name;
10055 };
10056 
10057 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10058 				__rte_unused void *data)
10059 {
10060 	struct cmd_dump_one_result *res = parsed_result;
10061 
10062 	if (!strcmp(res->dump, "dump_ring")) {
10063 		struct rte_ring *r;
10064 		r = rte_ring_lookup(res->name);
10065 		if (r == NULL) {
10066 			cmdline_printf(cl, "Cannot find ring\n");
10067 			return;
10068 		}
10069 		rte_ring_dump(stdout, r);
10070 	} else if (!strcmp(res->dump, "dump_mempool")) {
10071 		struct rte_mempool *mp;
10072 		mp = rte_mempool_lookup(res->name);
10073 		if (mp == NULL) {
10074 			cmdline_printf(cl, "Cannot find mempool\n");
10075 			return;
10076 		}
10077 		rte_mempool_dump(stdout, mp);
10078 	}
10079 }
10080 
10081 cmdline_parse_token_string_t cmd_dump_one_dump =
10082 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10083 				 "dump_ring#dump_mempool");
10084 
10085 cmdline_parse_token_string_t cmd_dump_one_name =
10086 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10087 
10088 cmdline_parse_inst_t cmd_dump_one = {
10089 	.f = cmd_dump_one_parsed,  /* function to call */
10090 	.data = NULL,      /* 2nd arg of func */
10091 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10092 	.tokens = {        /* token list, NULL terminated */
10093 		(void *)&cmd_dump_one_dump,
10094 		(void *)&cmd_dump_one_name,
10095 		NULL,
10096 	},
10097 };
10098 
10099 /* *** queue region set *** */
10100 struct cmd_queue_region_result {
10101 	cmdline_fixed_string_t set;
10102 	cmdline_fixed_string_t port;
10103 	portid_t port_id;
10104 	cmdline_fixed_string_t cmd;
10105 	cmdline_fixed_string_t region;
10106 	uint8_t  region_id;
10107 	cmdline_fixed_string_t queue_start_index;
10108 	uint8_t  queue_id;
10109 	cmdline_fixed_string_t queue_num;
10110 	uint8_t  queue_num_value;
10111 };
10112 
10113 static void
10114 cmd_queue_region_parsed(void *parsed_result,
10115 			__rte_unused struct cmdline *cl,
10116 			__rte_unused void *data)
10117 {
10118 	struct cmd_queue_region_result *res = parsed_result;
10119 	int ret = -ENOTSUP;
10120 #ifdef RTE_NET_I40E
10121 	struct rte_pmd_i40e_queue_region_conf region_conf;
10122 	enum rte_pmd_i40e_queue_region_op op_type;
10123 #endif
10124 
10125 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10126 		return;
10127 
10128 #ifdef RTE_NET_I40E
10129 	memset(&region_conf, 0, sizeof(region_conf));
10130 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10131 	region_conf.region_id = res->region_id;
10132 	region_conf.queue_num = res->queue_num_value;
10133 	region_conf.queue_start_index = res->queue_id;
10134 
10135 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10136 				op_type, &region_conf);
10137 #endif
10138 
10139 	switch (ret) {
10140 	case 0:
10141 		break;
10142 	case -ENOTSUP:
10143 		fprintf(stderr, "function not implemented or supported\n");
10144 		break;
10145 	default:
10146 		fprintf(stderr, "queue region config error: (%s)\n",
10147 			strerror(-ret));
10148 	}
10149 }
10150 
10151 cmdline_parse_token_string_t cmd_queue_region_set =
10152 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10153 		set, "set");
10154 cmdline_parse_token_string_t cmd_queue_region_port =
10155 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10156 cmdline_parse_token_num_t cmd_queue_region_port_id =
10157 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10158 				port_id, RTE_UINT16);
10159 cmdline_parse_token_string_t cmd_queue_region_cmd =
10160 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10161 				 cmd, "queue-region");
10162 cmdline_parse_token_string_t cmd_queue_region_id =
10163 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10164 				region, "region_id");
10165 cmdline_parse_token_num_t cmd_queue_region_index =
10166 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10167 				region_id, RTE_UINT8);
10168 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10169 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10170 				queue_start_index, "queue_start_index");
10171 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10172 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10173 				queue_id, RTE_UINT8);
10174 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10175 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10176 				queue_num, "queue_num");
10177 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10178 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10179 				queue_num_value, RTE_UINT8);
10180 
10181 cmdline_parse_inst_t cmd_queue_region = {
10182 	.f = cmd_queue_region_parsed,
10183 	.data = NULL,
10184 	.help_str = "set port <port_id> queue-region region_id <value> "
10185 		"queue_start_index <value> queue_num <value>: Set a queue region",
10186 	.tokens = {
10187 		(void *)&cmd_queue_region_set,
10188 		(void *)&cmd_queue_region_port,
10189 		(void *)&cmd_queue_region_port_id,
10190 		(void *)&cmd_queue_region_cmd,
10191 		(void *)&cmd_queue_region_id,
10192 		(void *)&cmd_queue_region_index,
10193 		(void *)&cmd_queue_region_queue_start_index,
10194 		(void *)&cmd_queue_region_queue_id,
10195 		(void *)&cmd_queue_region_queue_num,
10196 		(void *)&cmd_queue_region_queue_num_value,
10197 		NULL,
10198 	},
10199 };
10200 
10201 /* *** queue region and flowtype set *** */
10202 struct cmd_region_flowtype_result {
10203 	cmdline_fixed_string_t set;
10204 	cmdline_fixed_string_t port;
10205 	portid_t port_id;
10206 	cmdline_fixed_string_t cmd;
10207 	cmdline_fixed_string_t region;
10208 	uint8_t  region_id;
10209 	cmdline_fixed_string_t flowtype;
10210 	uint8_t  flowtype_id;
10211 };
10212 
10213 static void
10214 cmd_region_flowtype_parsed(void *parsed_result,
10215 			__rte_unused struct cmdline *cl,
10216 			__rte_unused void *data)
10217 {
10218 	struct cmd_region_flowtype_result *res = parsed_result;
10219 	int ret = -ENOTSUP;
10220 #ifdef RTE_NET_I40E
10221 	struct rte_pmd_i40e_queue_region_conf region_conf;
10222 	enum rte_pmd_i40e_queue_region_op op_type;
10223 #endif
10224 
10225 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10226 		return;
10227 
10228 #ifdef RTE_NET_I40E
10229 	memset(&region_conf, 0, sizeof(region_conf));
10230 
10231 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10232 	region_conf.region_id = res->region_id;
10233 	region_conf.hw_flowtype = res->flowtype_id;
10234 
10235 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10236 			op_type, &region_conf);
10237 #endif
10238 
10239 	switch (ret) {
10240 	case 0:
10241 		break;
10242 	case -ENOTSUP:
10243 		fprintf(stderr, "function not implemented or supported\n");
10244 		break;
10245 	default:
10246 		fprintf(stderr, "region flowtype config error: (%s)\n",
10247 			strerror(-ret));
10248 	}
10249 }
10250 
10251 cmdline_parse_token_string_t cmd_region_flowtype_set =
10252 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10253 				set, "set");
10254 cmdline_parse_token_string_t cmd_region_flowtype_port =
10255 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10256 				port, "port");
10257 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10258 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10259 				port_id, RTE_UINT16);
10260 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10261 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10262 				cmd, "queue-region");
10263 cmdline_parse_token_string_t cmd_region_flowtype_index =
10264 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10265 				region, "region_id");
10266 cmdline_parse_token_num_t cmd_region_flowtype_id =
10267 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10268 				region_id, RTE_UINT8);
10269 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10270 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10271 				flowtype, "flowtype");
10272 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10273 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10274 				flowtype_id, RTE_UINT8);
10275 cmdline_parse_inst_t cmd_region_flowtype = {
10276 	.f = cmd_region_flowtype_parsed,
10277 	.data = NULL,
10278 	.help_str = "set port <port_id> queue-region region_id <value> "
10279 		"flowtype <value>: Set a flowtype region index",
10280 	.tokens = {
10281 		(void *)&cmd_region_flowtype_set,
10282 		(void *)&cmd_region_flowtype_port,
10283 		(void *)&cmd_region_flowtype_port_index,
10284 		(void *)&cmd_region_flowtype_cmd,
10285 		(void *)&cmd_region_flowtype_index,
10286 		(void *)&cmd_region_flowtype_id,
10287 		(void *)&cmd_region_flowtype_flow_index,
10288 		(void *)&cmd_region_flowtype_flow_id,
10289 		NULL,
10290 	},
10291 };
10292 
10293 /* *** User Priority (UP) to queue region (region_id) set *** */
10294 struct cmd_user_priority_region_result {
10295 	cmdline_fixed_string_t set;
10296 	cmdline_fixed_string_t port;
10297 	portid_t port_id;
10298 	cmdline_fixed_string_t cmd;
10299 	cmdline_fixed_string_t user_priority;
10300 	uint8_t  user_priority_id;
10301 	cmdline_fixed_string_t region;
10302 	uint8_t  region_id;
10303 };
10304 
10305 static void
10306 cmd_user_priority_region_parsed(void *parsed_result,
10307 			__rte_unused struct cmdline *cl,
10308 			__rte_unused void *data)
10309 {
10310 	struct cmd_user_priority_region_result *res = parsed_result;
10311 	int ret = -ENOTSUP;
10312 #ifdef RTE_NET_I40E
10313 	struct rte_pmd_i40e_queue_region_conf region_conf;
10314 	enum rte_pmd_i40e_queue_region_op op_type;
10315 #endif
10316 
10317 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10318 		return;
10319 
10320 #ifdef RTE_NET_I40E
10321 	memset(&region_conf, 0, sizeof(region_conf));
10322 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10323 	region_conf.user_priority = res->user_priority_id;
10324 	region_conf.region_id = res->region_id;
10325 
10326 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10327 				op_type, &region_conf);
10328 #endif
10329 
10330 	switch (ret) {
10331 	case 0:
10332 		break;
10333 	case -ENOTSUP:
10334 		fprintf(stderr, "function not implemented or supported\n");
10335 		break;
10336 	default:
10337 		fprintf(stderr, "user_priority region config error: (%s)\n",
10338 			strerror(-ret));
10339 	}
10340 }
10341 
10342 cmdline_parse_token_string_t cmd_user_priority_region_set =
10343 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10344 				set, "set");
10345 cmdline_parse_token_string_t cmd_user_priority_region_port =
10346 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10347 				port, "port");
10348 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10349 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10350 				port_id, RTE_UINT16);
10351 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10352 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10353 				cmd, "queue-region");
10354 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10355 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10356 				user_priority, "UP");
10357 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10358 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10359 				user_priority_id, RTE_UINT8);
10360 cmdline_parse_token_string_t cmd_user_priority_region_region =
10361 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10362 				region, "region_id");
10363 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10364 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10365 				region_id, RTE_UINT8);
10366 
10367 cmdline_parse_inst_t cmd_user_priority_region = {
10368 	.f = cmd_user_priority_region_parsed,
10369 	.data = NULL,
10370 	.help_str = "set port <port_id> queue-region UP <value> "
10371 		"region_id <value>: Set the mapping of User Priority (UP) "
10372 		"to queue region (region_id) ",
10373 	.tokens = {
10374 		(void *)&cmd_user_priority_region_set,
10375 		(void *)&cmd_user_priority_region_port,
10376 		(void *)&cmd_user_priority_region_port_index,
10377 		(void *)&cmd_user_priority_region_cmd,
10378 		(void *)&cmd_user_priority_region_UP,
10379 		(void *)&cmd_user_priority_region_UP_id,
10380 		(void *)&cmd_user_priority_region_region,
10381 		(void *)&cmd_user_priority_region_region_id,
10382 		NULL,
10383 	},
10384 };
10385 
10386 /* *** flush all queue region related configuration *** */
10387 struct cmd_flush_queue_region_result {
10388 	cmdline_fixed_string_t set;
10389 	cmdline_fixed_string_t port;
10390 	portid_t port_id;
10391 	cmdline_fixed_string_t cmd;
10392 	cmdline_fixed_string_t flush;
10393 	cmdline_fixed_string_t what;
10394 };
10395 
10396 static void
10397 cmd_flush_queue_region_parsed(void *parsed_result,
10398 			__rte_unused struct cmdline *cl,
10399 			__rte_unused void *data)
10400 {
10401 	struct cmd_flush_queue_region_result *res = parsed_result;
10402 	int ret = -ENOTSUP;
10403 #ifdef RTE_NET_I40E
10404 	struct rte_pmd_i40e_queue_region_conf region_conf;
10405 	enum rte_pmd_i40e_queue_region_op op_type;
10406 #endif
10407 
10408 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10409 		return;
10410 
10411 #ifdef RTE_NET_I40E
10412 	memset(&region_conf, 0, sizeof(region_conf));
10413 
10414 	if (strcmp(res->what, "on") == 0)
10415 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10416 	else
10417 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10418 
10419 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10420 				op_type, &region_conf);
10421 #endif
10422 
10423 	switch (ret) {
10424 	case 0:
10425 		break;
10426 	case -ENOTSUP:
10427 		fprintf(stderr, "function not implemented or supported\n");
10428 		break;
10429 	default:
10430 		fprintf(stderr, "queue region config flush error: (%s)\n",
10431 			strerror(-ret));
10432 	}
10433 }
10434 
10435 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10436 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10437 				set, "set");
10438 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10439 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10440 				port, "port");
10441 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10442 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10443 				port_id, RTE_UINT16);
10444 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10445 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10446 				cmd, "queue-region");
10447 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10448 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10449 				flush, "flush");
10450 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10451 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10452 				what, "on#off");
10453 
10454 cmdline_parse_inst_t cmd_flush_queue_region = {
10455 	.f = cmd_flush_queue_region_parsed,
10456 	.data = NULL,
10457 	.help_str = "set port <port_id> queue-region flush on|off"
10458 		": flush all queue region related configuration",
10459 	.tokens = {
10460 		(void *)&cmd_flush_queue_region_set,
10461 		(void *)&cmd_flush_queue_region_port,
10462 		(void *)&cmd_flush_queue_region_port_index,
10463 		(void *)&cmd_flush_queue_region_cmd,
10464 		(void *)&cmd_flush_queue_region_flush,
10465 		(void *)&cmd_flush_queue_region_what,
10466 		NULL,
10467 	},
10468 };
10469 
10470 /* *** get all queue region related configuration info *** */
10471 struct cmd_show_queue_region_info {
10472 	cmdline_fixed_string_t show;
10473 	cmdline_fixed_string_t port;
10474 	portid_t port_id;
10475 	cmdline_fixed_string_t cmd;
10476 };
10477 
10478 static void
10479 cmd_show_queue_region_info_parsed(void *parsed_result,
10480 			__rte_unused struct cmdline *cl,
10481 			__rte_unused void *data)
10482 {
10483 	struct cmd_show_queue_region_info *res = parsed_result;
10484 	int ret = -ENOTSUP;
10485 #ifdef RTE_NET_I40E
10486 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10487 	enum rte_pmd_i40e_queue_region_op op_type;
10488 #endif
10489 
10490 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10491 		return;
10492 
10493 #ifdef RTE_NET_I40E
10494 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10495 
10496 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10497 
10498 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10499 					op_type, &rte_pmd_regions);
10500 
10501 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10502 #endif
10503 
10504 	switch (ret) {
10505 	case 0:
10506 		break;
10507 	case -ENOTSUP:
10508 		fprintf(stderr, "function not implemented or supported\n");
10509 		break;
10510 	default:
10511 		fprintf(stderr, "queue region config info show error: (%s)\n",
10512 			strerror(-ret));
10513 	}
10514 }
10515 
10516 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10517 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10518 				show, "show");
10519 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10520 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10521 				port, "port");
10522 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10523 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10524 				port_id, RTE_UINT16);
10525 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10526 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10527 				cmd, "queue-region");
10528 
10529 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10530 	.f = cmd_show_queue_region_info_parsed,
10531 	.data = NULL,
10532 	.help_str = "show port <port_id> queue-region"
10533 		": show all queue region related configuration info",
10534 	.tokens = {
10535 		(void *)&cmd_show_queue_region_info_get,
10536 		(void *)&cmd_show_queue_region_info_port,
10537 		(void *)&cmd_show_queue_region_info_port_index,
10538 		(void *)&cmd_show_queue_region_info_cmd,
10539 		NULL,
10540 	},
10541 };
10542 
10543 /* *** Filters Control *** */
10544 
10545 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10546 do { \
10547 	if ((ip_addr).family == AF_INET) \
10548 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10549 	else { \
10550 		fprintf(stderr, "invalid parameter.\n"); \
10551 		return; \
10552 	} \
10553 } while (0)
10554 
10555 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10556 do { \
10557 	if ((ip_addr).family == AF_INET6) \
10558 		rte_memcpy(&(ip), \
10559 				 &((ip_addr).addr.ipv6), \
10560 				 sizeof(struct in6_addr)); \
10561 	else { \
10562 		fprintf(stderr, "invalid parameter.\n"); \
10563 		return; \
10564 	} \
10565 } while (0)
10566 
10567 #ifdef RTE_NET_I40E
10568 
10569 static uint16_t
10570 str2flowtype(char *string)
10571 {
10572 	uint8_t i = 0;
10573 	static const struct {
10574 		char str[32];
10575 		uint16_t type;
10576 	} flowtype_str[] = {
10577 		{"raw", RTE_ETH_FLOW_RAW},
10578 		{"ipv4", RTE_ETH_FLOW_IPV4},
10579 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10580 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10581 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10582 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10583 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10584 		{"ipv6", RTE_ETH_FLOW_IPV6},
10585 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10586 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10587 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10588 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10589 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10590 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10591 		{"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10592 		{"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10593 		{"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10594 		{"gtpu", RTE_ETH_FLOW_GTPU},
10595 	};
10596 
10597 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10598 		if (!strcmp(flowtype_str[i].str, string))
10599 			return flowtype_str[i].type;
10600 	}
10601 
10602 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10603 		return (uint16_t)atoi(string);
10604 
10605 	return RTE_ETH_FLOW_UNKNOWN;
10606 }
10607 
10608 /* *** deal with flow director filter *** */
10609 struct cmd_flow_director_result {
10610 	cmdline_fixed_string_t flow_director_filter;
10611 	portid_t port_id;
10612 	cmdline_fixed_string_t mode;
10613 	cmdline_fixed_string_t mode_value;
10614 	cmdline_fixed_string_t ops;
10615 	cmdline_fixed_string_t flow;
10616 	cmdline_fixed_string_t flow_type;
10617 	cmdline_fixed_string_t drop;
10618 	cmdline_fixed_string_t queue;
10619 	uint16_t  queue_id;
10620 	cmdline_fixed_string_t fd_id;
10621 	uint32_t  fd_id_value;
10622 	cmdline_fixed_string_t packet;
10623 	char filepath[];
10624 };
10625 
10626 static void
10627 cmd_flow_director_filter_parsed(void *parsed_result,
10628 			  __rte_unused struct cmdline *cl,
10629 			  __rte_unused void *data)
10630 {
10631 	struct cmd_flow_director_result *res = parsed_result;
10632 	int ret = 0;
10633 	struct rte_pmd_i40e_flow_type_mapping
10634 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10635 	struct rte_pmd_i40e_pkt_template_conf conf;
10636 	uint16_t flow_type = str2flowtype(res->flow_type);
10637 	uint16_t i, port = res->port_id;
10638 	uint8_t add;
10639 
10640 	memset(&conf, 0, sizeof(conf));
10641 
10642 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10643 		fprintf(stderr, "Invalid flow type specified.\n");
10644 		return;
10645 	}
10646 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10647 						 mapping);
10648 	if (ret)
10649 		return;
10650 	if (mapping[flow_type].pctype == 0ULL) {
10651 		fprintf(stderr, "Invalid flow type specified.\n");
10652 		return;
10653 	}
10654 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10655 		if (mapping[flow_type].pctype & (1ULL << i)) {
10656 			conf.input.pctype = i;
10657 			break;
10658 		}
10659 	}
10660 
10661 	conf.input.packet = open_file(res->filepath,
10662 				&conf.input.length);
10663 	if (!conf.input.packet)
10664 		return;
10665 	if (!strcmp(res->drop, "drop"))
10666 		conf.action.behavior =
10667 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10668 	else
10669 		conf.action.behavior =
10670 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10671 	conf.action.report_status =
10672 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10673 	conf.action.rx_queue = res->queue_id;
10674 	conf.soft_id = res->fd_id_value;
10675 	add  = strcmp(res->ops, "del") ? 1 : 0;
10676 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10677 							&conf,
10678 							add);
10679 	if (ret < 0)
10680 		fprintf(stderr, "flow director config error: (%s)\n",
10681 			strerror(-ret));
10682 	close_file(conf.input.packet);
10683 }
10684 
10685 cmdline_parse_token_string_t cmd_flow_director_filter =
10686 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10687 				 flow_director_filter, "flow_director_filter");
10688 cmdline_parse_token_num_t cmd_flow_director_port_id =
10689 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10690 			      port_id, RTE_UINT16);
10691 cmdline_parse_token_string_t cmd_flow_director_ops =
10692 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10693 				 ops, "add#del#update");
10694 cmdline_parse_token_string_t cmd_flow_director_flow =
10695 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10696 				 flow, "flow");
10697 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10698 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10699 		flow_type, NULL);
10700 cmdline_parse_token_string_t cmd_flow_director_drop =
10701 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10702 				 drop, "drop#fwd");
10703 cmdline_parse_token_string_t cmd_flow_director_queue =
10704 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10705 				 queue, "queue");
10706 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10707 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10708 			      queue_id, RTE_UINT16);
10709 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10710 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10711 				 fd_id, "fd_id");
10712 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10713 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10714 			      fd_id_value, RTE_UINT32);
10715 
10716 cmdline_parse_token_string_t cmd_flow_director_mode =
10717 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10718 				 mode, "mode");
10719 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10720 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10721 				 mode_value, "raw");
10722 cmdline_parse_token_string_t cmd_flow_director_packet =
10723 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10724 				 packet, "packet");
10725 cmdline_parse_token_string_t cmd_flow_director_filepath =
10726 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10727 				 filepath, NULL);
10728 
10729 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10730 	.f = cmd_flow_director_filter_parsed,
10731 	.data = NULL,
10732 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10733 		"director entry on NIC",
10734 	.tokens = {
10735 		(void *)&cmd_flow_director_filter,
10736 		(void *)&cmd_flow_director_port_id,
10737 		(void *)&cmd_flow_director_mode,
10738 		(void *)&cmd_flow_director_mode_raw,
10739 		(void *)&cmd_flow_director_ops,
10740 		(void *)&cmd_flow_director_flow,
10741 		(void *)&cmd_flow_director_flow_type,
10742 		(void *)&cmd_flow_director_drop,
10743 		(void *)&cmd_flow_director_queue,
10744 		(void *)&cmd_flow_director_queue_id,
10745 		(void *)&cmd_flow_director_fd_id,
10746 		(void *)&cmd_flow_director_fd_id_value,
10747 		(void *)&cmd_flow_director_packet,
10748 		(void *)&cmd_flow_director_filepath,
10749 		NULL,
10750 	},
10751 };
10752 
10753 #endif /* RTE_NET_I40E */
10754 
10755 /* *** deal with flow director mask *** */
10756 struct cmd_flow_director_mask_result {
10757 	cmdline_fixed_string_t flow_director_mask;
10758 	portid_t port_id;
10759 	cmdline_fixed_string_t mode;
10760 	cmdline_fixed_string_t mode_value;
10761 	cmdline_fixed_string_t vlan;
10762 	uint16_t vlan_mask;
10763 	cmdline_fixed_string_t src_mask;
10764 	cmdline_ipaddr_t ipv4_src;
10765 	cmdline_ipaddr_t ipv6_src;
10766 	uint16_t port_src;
10767 	cmdline_fixed_string_t dst_mask;
10768 	cmdline_ipaddr_t ipv4_dst;
10769 	cmdline_ipaddr_t ipv6_dst;
10770 	uint16_t port_dst;
10771 	cmdline_fixed_string_t mac;
10772 	uint8_t mac_addr_byte_mask;
10773 	cmdline_fixed_string_t tunnel_id;
10774 	uint32_t tunnel_id_mask;
10775 	cmdline_fixed_string_t tunnel_type;
10776 	uint8_t tunnel_type_mask;
10777 };
10778 
10779 static void
10780 cmd_flow_director_mask_parsed(void *parsed_result,
10781 			  __rte_unused struct cmdline *cl,
10782 			  __rte_unused void *data)
10783 {
10784 	struct cmd_flow_director_mask_result *res = parsed_result;
10785 	struct rte_eth_fdir_masks *mask;
10786 	struct rte_port *port;
10787 
10788 	port = &ports[res->port_id];
10789 	/** Check if the port is not started **/
10790 	if (port->port_status != RTE_PORT_STOPPED) {
10791 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
10792 		return;
10793 	}
10794 
10795 	mask = &port->dev_conf.fdir_conf.mask;
10796 
10797 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10798 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10799 			fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10800 			return;
10801 		}
10802 
10803 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10804 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10805 		if (strcmp(res->mode_value, "Tunnel")) {
10806 			fprintf(stderr, "Please set mode to Tunnel.\n");
10807 			return;
10808 		}
10809 
10810 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10811 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10812 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10813 		mask->tunnel_type_mask = res->tunnel_type_mask;
10814 	} else {
10815 		if (strcmp(res->mode_value, "IP")) {
10816 			fprintf(stderr, "Please set mode to IP.\n");
10817 			return;
10818 		}
10819 
10820 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10821 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10822 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10823 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10824 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10825 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10826 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10827 	}
10828 
10829 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10830 }
10831 
10832 cmdline_parse_token_string_t cmd_flow_director_mask =
10833 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10834 				 flow_director_mask, "flow_director_mask");
10835 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10836 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10837 			      port_id, RTE_UINT16);
10838 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10839 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10840 				 vlan, "vlan");
10841 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10842 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10843 			      vlan_mask, RTE_UINT16);
10844 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10845 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10846 				 src_mask, "src_mask");
10847 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10848 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10849 				 ipv4_src);
10850 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10851 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10852 				 ipv6_src);
10853 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10854 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10855 			      port_src, RTE_UINT16);
10856 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10857 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10858 				 dst_mask, "dst_mask");
10859 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10860 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10861 				 ipv4_dst);
10862 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10863 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10864 				 ipv6_dst);
10865 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10866 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10867 			      port_dst, RTE_UINT16);
10868 
10869 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10870 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10871 				 mode, "mode");
10872 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10873 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10874 				 mode_value, "IP");
10875 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10876 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10877 				 mode_value, "MAC-VLAN");
10878 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10879 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10880 				 mode_value, "Tunnel");
10881 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10882 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10883 				 mac, "mac");
10884 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10885 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10886 			      mac_addr_byte_mask, RTE_UINT8);
10887 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10888 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10889 				 tunnel_type, "tunnel-type");
10890 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10891 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10892 			      tunnel_type_mask, RTE_UINT8);
10893 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10894 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10895 				 tunnel_id, "tunnel-id");
10896 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10897 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10898 			      tunnel_id_mask, RTE_UINT32);
10899 
10900 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10901 	.f = cmd_flow_director_mask_parsed,
10902 	.data = NULL,
10903 	.help_str = "flow_director_mask ... : "
10904 		"Set IP mode flow director's mask on NIC",
10905 	.tokens = {
10906 		(void *)&cmd_flow_director_mask,
10907 		(void *)&cmd_flow_director_mask_port_id,
10908 		(void *)&cmd_flow_director_mask_mode,
10909 		(void *)&cmd_flow_director_mask_mode_ip,
10910 		(void *)&cmd_flow_director_mask_vlan,
10911 		(void *)&cmd_flow_director_mask_vlan_value,
10912 		(void *)&cmd_flow_director_mask_src,
10913 		(void *)&cmd_flow_director_mask_ipv4_src,
10914 		(void *)&cmd_flow_director_mask_ipv6_src,
10915 		(void *)&cmd_flow_director_mask_port_src,
10916 		(void *)&cmd_flow_director_mask_dst,
10917 		(void *)&cmd_flow_director_mask_ipv4_dst,
10918 		(void *)&cmd_flow_director_mask_ipv6_dst,
10919 		(void *)&cmd_flow_director_mask_port_dst,
10920 		NULL,
10921 	},
10922 };
10923 
10924 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10925 	.f = cmd_flow_director_mask_parsed,
10926 	.data = NULL,
10927 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10928 		"flow director's mask on NIC",
10929 	.tokens = {
10930 		(void *)&cmd_flow_director_mask,
10931 		(void *)&cmd_flow_director_mask_port_id,
10932 		(void *)&cmd_flow_director_mask_mode,
10933 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10934 		(void *)&cmd_flow_director_mask_vlan,
10935 		(void *)&cmd_flow_director_mask_vlan_value,
10936 		NULL,
10937 	},
10938 };
10939 
10940 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10941 	.f = cmd_flow_director_mask_parsed,
10942 	.data = NULL,
10943 	.help_str = "flow_director_mask ... : Set tunnel mode "
10944 		"flow director's mask on NIC",
10945 	.tokens = {
10946 		(void *)&cmd_flow_director_mask,
10947 		(void *)&cmd_flow_director_mask_port_id,
10948 		(void *)&cmd_flow_director_mask_mode,
10949 		(void *)&cmd_flow_director_mask_mode_tunnel,
10950 		(void *)&cmd_flow_director_mask_vlan,
10951 		(void *)&cmd_flow_director_mask_vlan_value,
10952 		(void *)&cmd_flow_director_mask_mac,
10953 		(void *)&cmd_flow_director_mask_mac_value,
10954 		(void *)&cmd_flow_director_mask_tunnel_type,
10955 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10956 		(void *)&cmd_flow_director_mask_tunnel_id,
10957 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10958 		NULL,
10959 	},
10960 };
10961 
10962 /* *** deal with flow director flexible payload configuration *** */
10963 struct cmd_flow_director_flexpayload_result {
10964 	cmdline_fixed_string_t flow_director_flexpayload;
10965 	portid_t port_id;
10966 	cmdline_fixed_string_t payload_layer;
10967 	cmdline_fixed_string_t payload_cfg;
10968 };
10969 
10970 static inline int
10971 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10972 {
10973 	char s[256];
10974 	const char *p, *p0 = q_arg;
10975 	char *end;
10976 	unsigned long int_fld;
10977 	char *str_fld[max_num];
10978 	int i;
10979 	unsigned size;
10980 	int ret = -1;
10981 
10982 	p = strchr(p0, '(');
10983 	if (p == NULL)
10984 		return -1;
10985 	++p;
10986 	p0 = strchr(p, ')');
10987 	if (p0 == NULL)
10988 		return -1;
10989 
10990 	size = p0 - p;
10991 	if (size >= sizeof(s))
10992 		return -1;
10993 
10994 	snprintf(s, sizeof(s), "%.*s", size, p);
10995 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10996 	if (ret < 0 || ret > max_num)
10997 		return -1;
10998 	for (i = 0; i < ret; i++) {
10999 		errno = 0;
11000 		int_fld = strtoul(str_fld[i], &end, 0);
11001 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11002 			return -1;
11003 		offsets[i] = (uint16_t)int_fld;
11004 	}
11005 	return ret;
11006 }
11007 
11008 static void
11009 cmd_flow_director_flxpld_parsed(void *parsed_result,
11010 			  __rte_unused struct cmdline *cl,
11011 			  __rte_unused void *data)
11012 {
11013 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
11014 	struct rte_eth_flex_payload_cfg flex_cfg;
11015 	struct rte_port *port;
11016 	int ret = 0;
11017 
11018 	port = &ports[res->port_id];
11019 	/** Check if the port is not started **/
11020 	if (port->port_status != RTE_PORT_STOPPED) {
11021 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
11022 		return;
11023 	}
11024 
11025 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11026 
11027 	if (!strcmp(res->payload_layer, "raw"))
11028 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11029 	else if (!strcmp(res->payload_layer, "l2"))
11030 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11031 	else if (!strcmp(res->payload_layer, "l3"))
11032 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11033 	else if (!strcmp(res->payload_layer, "l4"))
11034 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11035 
11036 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11037 			    RTE_ETH_FDIR_MAX_FLEXLEN);
11038 	if (ret < 0) {
11039 		fprintf(stderr, "error: Cannot parse flex payload input.\n");
11040 		return;
11041 	}
11042 
11043 	fdir_set_flex_payload(res->port_id, &flex_cfg);
11044 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11045 }
11046 
11047 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11048 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11049 				 flow_director_flexpayload,
11050 				 "flow_director_flex_payload");
11051 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11052 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11053 			      port_id, RTE_UINT16);
11054 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11055 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11056 				 payload_layer, "raw#l2#l3#l4");
11057 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11058 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11059 				 payload_cfg, NULL);
11060 
11061 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11062 	.f = cmd_flow_director_flxpld_parsed,
11063 	.data = NULL,
11064 	.help_str = "flow_director_flexpayload ... : "
11065 		"Set flow director's flex payload on NIC",
11066 	.tokens = {
11067 		(void *)&cmd_flow_director_flexpayload,
11068 		(void *)&cmd_flow_director_flexpayload_port_id,
11069 		(void *)&cmd_flow_director_flexpayload_payload_layer,
11070 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
11071 		NULL,
11072 	},
11073 };
11074 
11075 /* Generic flow interface command. */
11076 extern cmdline_parse_inst_t cmd_flow;
11077 
11078 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11079 struct cmd_mcast_addr_result {
11080 	cmdline_fixed_string_t mcast_addr_cmd;
11081 	cmdline_fixed_string_t what;
11082 	uint16_t port_num;
11083 	struct rte_ether_addr mc_addr;
11084 };
11085 
11086 static void cmd_mcast_addr_parsed(void *parsed_result,
11087 		__rte_unused struct cmdline *cl,
11088 		__rte_unused void *data)
11089 {
11090 	struct cmd_mcast_addr_result *res = parsed_result;
11091 
11092 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11093 		fprintf(stderr,
11094 			"Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11095 			RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11096 		return;
11097 	}
11098 	if (strcmp(res->what, "add") == 0)
11099 		mcast_addr_add(res->port_num, &res->mc_addr);
11100 	else
11101 		mcast_addr_remove(res->port_num, &res->mc_addr);
11102 }
11103 
11104 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11105 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11106 				 mcast_addr_cmd, "mcast_addr");
11107 cmdline_parse_token_string_t cmd_mcast_addr_what =
11108 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11109 				 "add#remove");
11110 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11111 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11112 				 RTE_UINT16);
11113 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11114 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11115 
11116 cmdline_parse_inst_t cmd_mcast_addr = {
11117 	.f = cmd_mcast_addr_parsed,
11118 	.data = (void *)0,
11119 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11120 		"Add/Remove multicast MAC address on port_id",
11121 	.tokens = {
11122 		(void *)&cmd_mcast_addr_cmd,
11123 		(void *)&cmd_mcast_addr_what,
11124 		(void *)&cmd_mcast_addr_portnum,
11125 		(void *)&cmd_mcast_addr_addr,
11126 		NULL,
11127 	},
11128 };
11129 
11130 /* vf vlan anti spoof configuration */
11131 
11132 /* Common result structure for vf vlan anti spoof */
11133 struct cmd_vf_vlan_anti_spoof_result {
11134 	cmdline_fixed_string_t set;
11135 	cmdline_fixed_string_t vf;
11136 	cmdline_fixed_string_t vlan;
11137 	cmdline_fixed_string_t antispoof;
11138 	portid_t port_id;
11139 	uint32_t vf_id;
11140 	cmdline_fixed_string_t on_off;
11141 };
11142 
11143 /* Common CLI fields for vf vlan anti spoof enable disable */
11144 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11145 	TOKEN_STRING_INITIALIZER
11146 		(struct cmd_vf_vlan_anti_spoof_result,
11147 		 set, "set");
11148 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11149 	TOKEN_STRING_INITIALIZER
11150 		(struct cmd_vf_vlan_anti_spoof_result,
11151 		 vf, "vf");
11152 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11153 	TOKEN_STRING_INITIALIZER
11154 		(struct cmd_vf_vlan_anti_spoof_result,
11155 		 vlan, "vlan");
11156 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11157 	TOKEN_STRING_INITIALIZER
11158 		(struct cmd_vf_vlan_anti_spoof_result,
11159 		 antispoof, "antispoof");
11160 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11161 	TOKEN_NUM_INITIALIZER
11162 		(struct cmd_vf_vlan_anti_spoof_result,
11163 		 port_id, RTE_UINT16);
11164 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11165 	TOKEN_NUM_INITIALIZER
11166 		(struct cmd_vf_vlan_anti_spoof_result,
11167 		 vf_id, RTE_UINT32);
11168 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11169 	TOKEN_STRING_INITIALIZER
11170 		(struct cmd_vf_vlan_anti_spoof_result,
11171 		 on_off, "on#off");
11172 
11173 static void
11174 cmd_set_vf_vlan_anti_spoof_parsed(
11175 	void *parsed_result,
11176 	__rte_unused struct cmdline *cl,
11177 	__rte_unused void *data)
11178 {
11179 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11180 	int ret = -ENOTSUP;
11181 
11182 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11183 
11184 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11185 		return;
11186 
11187 #ifdef RTE_NET_IXGBE
11188 	if (ret == -ENOTSUP)
11189 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11190 				res->vf_id, is_on);
11191 #endif
11192 #ifdef RTE_NET_I40E
11193 	if (ret == -ENOTSUP)
11194 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11195 				res->vf_id, is_on);
11196 #endif
11197 #ifdef RTE_NET_BNXT
11198 	if (ret == -ENOTSUP)
11199 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11200 				res->vf_id, is_on);
11201 #endif
11202 
11203 	switch (ret) {
11204 	case 0:
11205 		break;
11206 	case -EINVAL:
11207 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11208 		break;
11209 	case -ENODEV:
11210 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11211 		break;
11212 	case -ENOTSUP:
11213 		fprintf(stderr, "function not implemented\n");
11214 		break;
11215 	default:
11216 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11217 	}
11218 }
11219 
11220 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11221 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
11222 	.data = NULL,
11223 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11224 	.tokens = {
11225 		(void *)&cmd_vf_vlan_anti_spoof_set,
11226 		(void *)&cmd_vf_vlan_anti_spoof_vf,
11227 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
11228 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
11229 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
11230 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
11231 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
11232 		NULL,
11233 	},
11234 };
11235 
11236 /* vf mac anti spoof configuration */
11237 
11238 /* Common result structure for vf mac anti spoof */
11239 struct cmd_vf_mac_anti_spoof_result {
11240 	cmdline_fixed_string_t set;
11241 	cmdline_fixed_string_t vf;
11242 	cmdline_fixed_string_t mac;
11243 	cmdline_fixed_string_t antispoof;
11244 	portid_t port_id;
11245 	uint32_t vf_id;
11246 	cmdline_fixed_string_t on_off;
11247 };
11248 
11249 /* Common CLI fields for vf mac anti spoof enable disable */
11250 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11251 	TOKEN_STRING_INITIALIZER
11252 		(struct cmd_vf_mac_anti_spoof_result,
11253 		 set, "set");
11254 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11255 	TOKEN_STRING_INITIALIZER
11256 		(struct cmd_vf_mac_anti_spoof_result,
11257 		 vf, "vf");
11258 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11259 	TOKEN_STRING_INITIALIZER
11260 		(struct cmd_vf_mac_anti_spoof_result,
11261 		 mac, "mac");
11262 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11263 	TOKEN_STRING_INITIALIZER
11264 		(struct cmd_vf_mac_anti_spoof_result,
11265 		 antispoof, "antispoof");
11266 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11267 	TOKEN_NUM_INITIALIZER
11268 		(struct cmd_vf_mac_anti_spoof_result,
11269 		 port_id, RTE_UINT16);
11270 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11271 	TOKEN_NUM_INITIALIZER
11272 		(struct cmd_vf_mac_anti_spoof_result,
11273 		 vf_id, RTE_UINT32);
11274 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11275 	TOKEN_STRING_INITIALIZER
11276 		(struct cmd_vf_mac_anti_spoof_result,
11277 		 on_off, "on#off");
11278 
11279 static void
11280 cmd_set_vf_mac_anti_spoof_parsed(
11281 	void *parsed_result,
11282 	__rte_unused struct cmdline *cl,
11283 	__rte_unused void *data)
11284 {
11285 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11286 	int ret = -ENOTSUP;
11287 
11288 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11289 
11290 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11291 		return;
11292 
11293 #ifdef RTE_NET_IXGBE
11294 	if (ret == -ENOTSUP)
11295 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11296 			res->vf_id, is_on);
11297 #endif
11298 #ifdef RTE_NET_I40E
11299 	if (ret == -ENOTSUP)
11300 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11301 			res->vf_id, is_on);
11302 #endif
11303 #ifdef RTE_NET_BNXT
11304 	if (ret == -ENOTSUP)
11305 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11306 			res->vf_id, is_on);
11307 #endif
11308 
11309 	switch (ret) {
11310 	case 0:
11311 		break;
11312 	case -EINVAL:
11313 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11314 			res->vf_id, is_on);
11315 		break;
11316 	case -ENODEV:
11317 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11318 		break;
11319 	case -ENOTSUP:
11320 		fprintf(stderr, "function not implemented\n");
11321 		break;
11322 	default:
11323 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11324 	}
11325 }
11326 
11327 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11328 	.f = cmd_set_vf_mac_anti_spoof_parsed,
11329 	.data = NULL,
11330 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11331 	.tokens = {
11332 		(void *)&cmd_vf_mac_anti_spoof_set,
11333 		(void *)&cmd_vf_mac_anti_spoof_vf,
11334 		(void *)&cmd_vf_mac_anti_spoof_mac,
11335 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
11336 		(void *)&cmd_vf_mac_anti_spoof_port_id,
11337 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
11338 		(void *)&cmd_vf_mac_anti_spoof_on_off,
11339 		NULL,
11340 	},
11341 };
11342 
11343 /* vf vlan strip queue configuration */
11344 
11345 /* Common result structure for vf mac anti spoof */
11346 struct cmd_vf_vlan_stripq_result {
11347 	cmdline_fixed_string_t set;
11348 	cmdline_fixed_string_t vf;
11349 	cmdline_fixed_string_t vlan;
11350 	cmdline_fixed_string_t stripq;
11351 	portid_t port_id;
11352 	uint16_t vf_id;
11353 	cmdline_fixed_string_t on_off;
11354 };
11355 
11356 /* Common CLI fields for vf vlan strip enable disable */
11357 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11358 	TOKEN_STRING_INITIALIZER
11359 		(struct cmd_vf_vlan_stripq_result,
11360 		 set, "set");
11361 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11362 	TOKEN_STRING_INITIALIZER
11363 		(struct cmd_vf_vlan_stripq_result,
11364 		 vf, "vf");
11365 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11366 	TOKEN_STRING_INITIALIZER
11367 		(struct cmd_vf_vlan_stripq_result,
11368 		 vlan, "vlan");
11369 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11370 	TOKEN_STRING_INITIALIZER
11371 		(struct cmd_vf_vlan_stripq_result,
11372 		 stripq, "stripq");
11373 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11374 	TOKEN_NUM_INITIALIZER
11375 		(struct cmd_vf_vlan_stripq_result,
11376 		 port_id, RTE_UINT16);
11377 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11378 	TOKEN_NUM_INITIALIZER
11379 		(struct cmd_vf_vlan_stripq_result,
11380 		 vf_id, RTE_UINT16);
11381 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11382 	TOKEN_STRING_INITIALIZER
11383 		(struct cmd_vf_vlan_stripq_result,
11384 		 on_off, "on#off");
11385 
11386 static void
11387 cmd_set_vf_vlan_stripq_parsed(
11388 	void *parsed_result,
11389 	__rte_unused struct cmdline *cl,
11390 	__rte_unused void *data)
11391 {
11392 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
11393 	int ret = -ENOTSUP;
11394 
11395 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11396 
11397 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11398 		return;
11399 
11400 #ifdef RTE_NET_IXGBE
11401 	if (ret == -ENOTSUP)
11402 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11403 			res->vf_id, is_on);
11404 #endif
11405 #ifdef RTE_NET_I40E
11406 	if (ret == -ENOTSUP)
11407 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11408 			res->vf_id, is_on);
11409 #endif
11410 #ifdef RTE_NET_BNXT
11411 	if (ret == -ENOTSUP)
11412 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11413 			res->vf_id, is_on);
11414 #endif
11415 
11416 	switch (ret) {
11417 	case 0:
11418 		break;
11419 	case -EINVAL:
11420 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11421 			res->vf_id, is_on);
11422 		break;
11423 	case -ENODEV:
11424 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11425 		break;
11426 	case -ENOTSUP:
11427 		fprintf(stderr, "function not implemented\n");
11428 		break;
11429 	default:
11430 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11431 	}
11432 }
11433 
11434 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11435 	.f = cmd_set_vf_vlan_stripq_parsed,
11436 	.data = NULL,
11437 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11438 	.tokens = {
11439 		(void *)&cmd_vf_vlan_stripq_set,
11440 		(void *)&cmd_vf_vlan_stripq_vf,
11441 		(void *)&cmd_vf_vlan_stripq_vlan,
11442 		(void *)&cmd_vf_vlan_stripq_stripq,
11443 		(void *)&cmd_vf_vlan_stripq_port_id,
11444 		(void *)&cmd_vf_vlan_stripq_vf_id,
11445 		(void *)&cmd_vf_vlan_stripq_on_off,
11446 		NULL,
11447 	},
11448 };
11449 
11450 /* vf vlan insert configuration */
11451 
11452 /* Common result structure for vf vlan insert */
11453 struct cmd_vf_vlan_insert_result {
11454 	cmdline_fixed_string_t set;
11455 	cmdline_fixed_string_t vf;
11456 	cmdline_fixed_string_t vlan;
11457 	cmdline_fixed_string_t insert;
11458 	portid_t port_id;
11459 	uint16_t vf_id;
11460 	uint16_t vlan_id;
11461 };
11462 
11463 /* Common CLI fields for vf vlan insert enable disable */
11464 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11465 	TOKEN_STRING_INITIALIZER
11466 		(struct cmd_vf_vlan_insert_result,
11467 		 set, "set");
11468 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11469 	TOKEN_STRING_INITIALIZER
11470 		(struct cmd_vf_vlan_insert_result,
11471 		 vf, "vf");
11472 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11473 	TOKEN_STRING_INITIALIZER
11474 		(struct cmd_vf_vlan_insert_result,
11475 		 vlan, "vlan");
11476 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11477 	TOKEN_STRING_INITIALIZER
11478 		(struct cmd_vf_vlan_insert_result,
11479 		 insert, "insert");
11480 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11481 	TOKEN_NUM_INITIALIZER
11482 		(struct cmd_vf_vlan_insert_result,
11483 		 port_id, RTE_UINT16);
11484 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11485 	TOKEN_NUM_INITIALIZER
11486 		(struct cmd_vf_vlan_insert_result,
11487 		 vf_id, RTE_UINT16);
11488 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11489 	TOKEN_NUM_INITIALIZER
11490 		(struct cmd_vf_vlan_insert_result,
11491 		 vlan_id, RTE_UINT16);
11492 
11493 static void
11494 cmd_set_vf_vlan_insert_parsed(
11495 	void *parsed_result,
11496 	__rte_unused struct cmdline *cl,
11497 	__rte_unused void *data)
11498 {
11499 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11500 	int ret = -ENOTSUP;
11501 
11502 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11503 		return;
11504 
11505 #ifdef RTE_NET_IXGBE
11506 	if (ret == -ENOTSUP)
11507 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11508 			res->vlan_id);
11509 #endif
11510 #ifdef RTE_NET_I40E
11511 	if (ret == -ENOTSUP)
11512 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11513 			res->vlan_id);
11514 #endif
11515 #ifdef RTE_NET_BNXT
11516 	if (ret == -ENOTSUP)
11517 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11518 			res->vlan_id);
11519 #endif
11520 
11521 	switch (ret) {
11522 	case 0:
11523 		break;
11524 	case -EINVAL:
11525 		fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11526 			res->vf_id, res->vlan_id);
11527 		break;
11528 	case -ENODEV:
11529 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11530 		break;
11531 	case -ENOTSUP:
11532 		fprintf(stderr, "function not implemented\n");
11533 		break;
11534 	default:
11535 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11536 	}
11537 }
11538 
11539 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11540 	.f = cmd_set_vf_vlan_insert_parsed,
11541 	.data = NULL,
11542 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11543 	.tokens = {
11544 		(void *)&cmd_vf_vlan_insert_set,
11545 		(void *)&cmd_vf_vlan_insert_vf,
11546 		(void *)&cmd_vf_vlan_insert_vlan,
11547 		(void *)&cmd_vf_vlan_insert_insert,
11548 		(void *)&cmd_vf_vlan_insert_port_id,
11549 		(void *)&cmd_vf_vlan_insert_vf_id,
11550 		(void *)&cmd_vf_vlan_insert_vlan_id,
11551 		NULL,
11552 	},
11553 };
11554 
11555 /* tx loopback configuration */
11556 
11557 /* Common result structure for tx loopback */
11558 struct cmd_tx_loopback_result {
11559 	cmdline_fixed_string_t set;
11560 	cmdline_fixed_string_t tx;
11561 	cmdline_fixed_string_t loopback;
11562 	portid_t port_id;
11563 	cmdline_fixed_string_t on_off;
11564 };
11565 
11566 /* Common CLI fields for tx loopback enable disable */
11567 cmdline_parse_token_string_t cmd_tx_loopback_set =
11568 	TOKEN_STRING_INITIALIZER
11569 		(struct cmd_tx_loopback_result,
11570 		 set, "set");
11571 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11572 	TOKEN_STRING_INITIALIZER
11573 		(struct cmd_tx_loopback_result,
11574 		 tx, "tx");
11575 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11576 	TOKEN_STRING_INITIALIZER
11577 		(struct cmd_tx_loopback_result,
11578 		 loopback, "loopback");
11579 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11580 	TOKEN_NUM_INITIALIZER
11581 		(struct cmd_tx_loopback_result,
11582 		 port_id, RTE_UINT16);
11583 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11584 	TOKEN_STRING_INITIALIZER
11585 		(struct cmd_tx_loopback_result,
11586 		 on_off, "on#off");
11587 
11588 static void
11589 cmd_set_tx_loopback_parsed(
11590 	void *parsed_result,
11591 	__rte_unused struct cmdline *cl,
11592 	__rte_unused void *data)
11593 {
11594 	struct cmd_tx_loopback_result *res = parsed_result;
11595 	int ret = -ENOTSUP;
11596 
11597 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11598 
11599 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11600 		return;
11601 
11602 #ifdef RTE_NET_IXGBE
11603 	if (ret == -ENOTSUP)
11604 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11605 #endif
11606 #ifdef RTE_NET_I40E
11607 	if (ret == -ENOTSUP)
11608 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11609 #endif
11610 #ifdef RTE_NET_BNXT
11611 	if (ret == -ENOTSUP)
11612 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11613 #endif
11614 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11615 	if (ret == -ENOTSUP)
11616 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11617 #endif
11618 
11619 	switch (ret) {
11620 	case 0:
11621 		break;
11622 	case -EINVAL:
11623 		fprintf(stderr, "invalid is_on %d\n", is_on);
11624 		break;
11625 	case -ENODEV:
11626 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11627 		break;
11628 	case -ENOTSUP:
11629 		fprintf(stderr, "function not implemented\n");
11630 		break;
11631 	default:
11632 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11633 	}
11634 }
11635 
11636 cmdline_parse_inst_t cmd_set_tx_loopback = {
11637 	.f = cmd_set_tx_loopback_parsed,
11638 	.data = NULL,
11639 	.help_str = "set tx loopback <port_id> on|off",
11640 	.tokens = {
11641 		(void *)&cmd_tx_loopback_set,
11642 		(void *)&cmd_tx_loopback_tx,
11643 		(void *)&cmd_tx_loopback_loopback,
11644 		(void *)&cmd_tx_loopback_port_id,
11645 		(void *)&cmd_tx_loopback_on_off,
11646 		NULL,
11647 	},
11648 };
11649 
11650 /* all queues drop enable configuration */
11651 
11652 /* Common result structure for all queues drop enable */
11653 struct cmd_all_queues_drop_en_result {
11654 	cmdline_fixed_string_t set;
11655 	cmdline_fixed_string_t all;
11656 	cmdline_fixed_string_t queues;
11657 	cmdline_fixed_string_t drop;
11658 	portid_t port_id;
11659 	cmdline_fixed_string_t on_off;
11660 };
11661 
11662 /* Common CLI fields for tx loopback enable disable */
11663 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11664 	TOKEN_STRING_INITIALIZER
11665 		(struct cmd_all_queues_drop_en_result,
11666 		 set, "set");
11667 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11668 	TOKEN_STRING_INITIALIZER
11669 		(struct cmd_all_queues_drop_en_result,
11670 		 all, "all");
11671 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11672 	TOKEN_STRING_INITIALIZER
11673 		(struct cmd_all_queues_drop_en_result,
11674 		 queues, "queues");
11675 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11676 	TOKEN_STRING_INITIALIZER
11677 		(struct cmd_all_queues_drop_en_result,
11678 		 drop, "drop");
11679 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11680 	TOKEN_NUM_INITIALIZER
11681 		(struct cmd_all_queues_drop_en_result,
11682 		 port_id, RTE_UINT16);
11683 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11684 	TOKEN_STRING_INITIALIZER
11685 		(struct cmd_all_queues_drop_en_result,
11686 		 on_off, "on#off");
11687 
11688 static void
11689 cmd_set_all_queues_drop_en_parsed(
11690 	void *parsed_result,
11691 	__rte_unused struct cmdline *cl,
11692 	__rte_unused void *data)
11693 {
11694 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11695 	int ret = -ENOTSUP;
11696 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11697 
11698 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11699 		return;
11700 
11701 #ifdef RTE_NET_IXGBE
11702 	if (ret == -ENOTSUP)
11703 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11704 #endif
11705 #ifdef RTE_NET_BNXT
11706 	if (ret == -ENOTSUP)
11707 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11708 #endif
11709 	switch (ret) {
11710 	case 0:
11711 		break;
11712 	case -EINVAL:
11713 		fprintf(stderr, "invalid is_on %d\n", is_on);
11714 		break;
11715 	case -ENODEV:
11716 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11717 		break;
11718 	case -ENOTSUP:
11719 		fprintf(stderr, "function not implemented\n");
11720 		break;
11721 	default:
11722 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11723 	}
11724 }
11725 
11726 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11727 	.f = cmd_set_all_queues_drop_en_parsed,
11728 	.data = NULL,
11729 	.help_str = "set all queues drop <port_id> on|off",
11730 	.tokens = {
11731 		(void *)&cmd_all_queues_drop_en_set,
11732 		(void *)&cmd_all_queues_drop_en_all,
11733 		(void *)&cmd_all_queues_drop_en_queues,
11734 		(void *)&cmd_all_queues_drop_en_drop,
11735 		(void *)&cmd_all_queues_drop_en_port_id,
11736 		(void *)&cmd_all_queues_drop_en_on_off,
11737 		NULL,
11738 	},
11739 };
11740 
11741 /* vf split drop enable configuration */
11742 
11743 /* Common result structure for vf split drop enable */
11744 struct cmd_vf_split_drop_en_result {
11745 	cmdline_fixed_string_t set;
11746 	cmdline_fixed_string_t vf;
11747 	cmdline_fixed_string_t split;
11748 	cmdline_fixed_string_t drop;
11749 	portid_t port_id;
11750 	uint16_t vf_id;
11751 	cmdline_fixed_string_t on_off;
11752 };
11753 
11754 /* Common CLI fields for vf split drop enable disable */
11755 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11756 	TOKEN_STRING_INITIALIZER
11757 		(struct cmd_vf_split_drop_en_result,
11758 		 set, "set");
11759 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11760 	TOKEN_STRING_INITIALIZER
11761 		(struct cmd_vf_split_drop_en_result,
11762 		 vf, "vf");
11763 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11764 	TOKEN_STRING_INITIALIZER
11765 		(struct cmd_vf_split_drop_en_result,
11766 		 split, "split");
11767 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11768 	TOKEN_STRING_INITIALIZER
11769 		(struct cmd_vf_split_drop_en_result,
11770 		 drop, "drop");
11771 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11772 	TOKEN_NUM_INITIALIZER
11773 		(struct cmd_vf_split_drop_en_result,
11774 		 port_id, RTE_UINT16);
11775 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11776 	TOKEN_NUM_INITIALIZER
11777 		(struct cmd_vf_split_drop_en_result,
11778 		 vf_id, RTE_UINT16);
11779 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11780 	TOKEN_STRING_INITIALIZER
11781 		(struct cmd_vf_split_drop_en_result,
11782 		 on_off, "on#off");
11783 
11784 static void
11785 cmd_set_vf_split_drop_en_parsed(
11786 	void *parsed_result,
11787 	__rte_unused struct cmdline *cl,
11788 	__rte_unused void *data)
11789 {
11790 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11791 	int ret = -ENOTSUP;
11792 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11793 
11794 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11795 		return;
11796 
11797 #ifdef RTE_NET_IXGBE
11798 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11799 			is_on);
11800 #endif
11801 	switch (ret) {
11802 	case 0:
11803 		break;
11804 	case -EINVAL:
11805 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11806 			res->vf_id, is_on);
11807 		break;
11808 	case -ENODEV:
11809 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11810 		break;
11811 	case -ENOTSUP:
11812 		fprintf(stderr, "not supported on port %d\n", res->port_id);
11813 		break;
11814 	default:
11815 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11816 	}
11817 }
11818 
11819 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11820 	.f = cmd_set_vf_split_drop_en_parsed,
11821 	.data = NULL,
11822 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11823 	.tokens = {
11824 		(void *)&cmd_vf_split_drop_en_set,
11825 		(void *)&cmd_vf_split_drop_en_vf,
11826 		(void *)&cmd_vf_split_drop_en_split,
11827 		(void *)&cmd_vf_split_drop_en_drop,
11828 		(void *)&cmd_vf_split_drop_en_port_id,
11829 		(void *)&cmd_vf_split_drop_en_vf_id,
11830 		(void *)&cmd_vf_split_drop_en_on_off,
11831 		NULL,
11832 	},
11833 };
11834 
11835 /* vf mac address configuration */
11836 
11837 /* Common result structure for vf mac address */
11838 struct cmd_set_vf_mac_addr_result {
11839 	cmdline_fixed_string_t set;
11840 	cmdline_fixed_string_t vf;
11841 	cmdline_fixed_string_t mac;
11842 	cmdline_fixed_string_t addr;
11843 	portid_t port_id;
11844 	uint16_t vf_id;
11845 	struct rte_ether_addr mac_addr;
11846 
11847 };
11848 
11849 /* Common CLI fields for vf split drop enable disable */
11850 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11851 	TOKEN_STRING_INITIALIZER
11852 		(struct cmd_set_vf_mac_addr_result,
11853 		 set, "set");
11854 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11855 	TOKEN_STRING_INITIALIZER
11856 		(struct cmd_set_vf_mac_addr_result,
11857 		 vf, "vf");
11858 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11859 	TOKEN_STRING_INITIALIZER
11860 		(struct cmd_set_vf_mac_addr_result,
11861 		 mac, "mac");
11862 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11863 	TOKEN_STRING_INITIALIZER
11864 		(struct cmd_set_vf_mac_addr_result,
11865 		 addr, "addr");
11866 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11867 	TOKEN_NUM_INITIALIZER
11868 		(struct cmd_set_vf_mac_addr_result,
11869 		 port_id, RTE_UINT16);
11870 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11871 	TOKEN_NUM_INITIALIZER
11872 		(struct cmd_set_vf_mac_addr_result,
11873 		 vf_id, RTE_UINT16);
11874 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11875 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11876 		 mac_addr);
11877 
11878 static void
11879 cmd_set_vf_mac_addr_parsed(
11880 	void *parsed_result,
11881 	__rte_unused struct cmdline *cl,
11882 	__rte_unused void *data)
11883 {
11884 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11885 	int ret = -ENOTSUP;
11886 
11887 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11888 		return;
11889 
11890 #ifdef RTE_NET_IXGBE
11891 	if (ret == -ENOTSUP)
11892 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11893 				&res->mac_addr);
11894 #endif
11895 #ifdef RTE_NET_I40E
11896 	if (ret == -ENOTSUP)
11897 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11898 				&res->mac_addr);
11899 #endif
11900 #ifdef RTE_NET_BNXT
11901 	if (ret == -ENOTSUP)
11902 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11903 				&res->mac_addr);
11904 #endif
11905 
11906 	switch (ret) {
11907 	case 0:
11908 		break;
11909 	case -EINVAL:
11910 		fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11911 		break;
11912 	case -ENODEV:
11913 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
11914 		break;
11915 	case -ENOTSUP:
11916 		fprintf(stderr, "function not implemented\n");
11917 		break;
11918 	default:
11919 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11920 	}
11921 }
11922 
11923 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11924 	.f = cmd_set_vf_mac_addr_parsed,
11925 	.data = NULL,
11926 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11927 	.tokens = {
11928 		(void *)&cmd_set_vf_mac_addr_set,
11929 		(void *)&cmd_set_vf_mac_addr_vf,
11930 		(void *)&cmd_set_vf_mac_addr_mac,
11931 		(void *)&cmd_set_vf_mac_addr_addr,
11932 		(void *)&cmd_set_vf_mac_addr_port_id,
11933 		(void *)&cmd_set_vf_mac_addr_vf_id,
11934 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11935 		NULL,
11936 	},
11937 };
11938 
11939 /* MACsec configuration */
11940 
11941 /* Common result structure for MACsec offload enable */
11942 struct cmd_macsec_offload_on_result {
11943 	cmdline_fixed_string_t set;
11944 	cmdline_fixed_string_t macsec;
11945 	cmdline_fixed_string_t offload;
11946 	portid_t port_id;
11947 	cmdline_fixed_string_t on;
11948 	cmdline_fixed_string_t encrypt;
11949 	cmdline_fixed_string_t en_on_off;
11950 	cmdline_fixed_string_t replay_protect;
11951 	cmdline_fixed_string_t rp_on_off;
11952 };
11953 
11954 /* Common CLI fields for MACsec offload disable */
11955 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11956 	TOKEN_STRING_INITIALIZER
11957 		(struct cmd_macsec_offload_on_result,
11958 		 set, "set");
11959 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11960 	TOKEN_STRING_INITIALIZER
11961 		(struct cmd_macsec_offload_on_result,
11962 		 macsec, "macsec");
11963 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11964 	TOKEN_STRING_INITIALIZER
11965 		(struct cmd_macsec_offload_on_result,
11966 		 offload, "offload");
11967 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11968 	TOKEN_NUM_INITIALIZER
11969 		(struct cmd_macsec_offload_on_result,
11970 		 port_id, RTE_UINT16);
11971 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11972 	TOKEN_STRING_INITIALIZER
11973 		(struct cmd_macsec_offload_on_result,
11974 		 on, "on");
11975 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11976 	TOKEN_STRING_INITIALIZER
11977 		(struct cmd_macsec_offload_on_result,
11978 		 encrypt, "encrypt");
11979 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11980 	TOKEN_STRING_INITIALIZER
11981 		(struct cmd_macsec_offload_on_result,
11982 		 en_on_off, "on#off");
11983 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11984 	TOKEN_STRING_INITIALIZER
11985 		(struct cmd_macsec_offload_on_result,
11986 		 replay_protect, "replay-protect");
11987 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11988 	TOKEN_STRING_INITIALIZER
11989 		(struct cmd_macsec_offload_on_result,
11990 		 rp_on_off, "on#off");
11991 
11992 static void
11993 cmd_set_macsec_offload_on_parsed(
11994 	void *parsed_result,
11995 	__rte_unused struct cmdline *cl,
11996 	__rte_unused void *data)
11997 {
11998 	struct cmd_macsec_offload_on_result *res = parsed_result;
11999 	int ret = -ENOTSUP;
12000 	portid_t port_id = res->port_id;
12001 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12002 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12003 	struct rte_eth_dev_info dev_info;
12004 
12005 	if (port_id_is_invalid(port_id, ENABLED_WARN))
12006 		return;
12007 	if (!port_is_stopped(port_id)) {
12008 		fprintf(stderr, "Please stop port %d first\n", port_id);
12009 		return;
12010 	}
12011 
12012 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
12013 	if (ret != 0)
12014 		return;
12015 
12016 	if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12017 #ifdef RTE_NET_IXGBE
12018 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12019 #endif
12020 	}
12021 	RTE_SET_USED(en);
12022 	RTE_SET_USED(rp);
12023 
12024 	switch (ret) {
12025 	case 0:
12026 		ports[port_id].dev_conf.txmode.offloads |=
12027 						RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12028 		cmd_reconfig_device_queue(port_id, 1, 1);
12029 		break;
12030 	case -ENODEV:
12031 		fprintf(stderr, "invalid port_id %d\n", port_id);
12032 		break;
12033 	case -ENOTSUP:
12034 		fprintf(stderr, "not supported on port %d\n", port_id);
12035 		break;
12036 	default:
12037 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12038 	}
12039 }
12040 
12041 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12042 	.f = cmd_set_macsec_offload_on_parsed,
12043 	.data = NULL,
12044 	.help_str = "set macsec offload <port_id> on "
12045 		"encrypt on|off replay-protect on|off",
12046 	.tokens = {
12047 		(void *)&cmd_macsec_offload_on_set,
12048 		(void *)&cmd_macsec_offload_on_macsec,
12049 		(void *)&cmd_macsec_offload_on_offload,
12050 		(void *)&cmd_macsec_offload_on_port_id,
12051 		(void *)&cmd_macsec_offload_on_on,
12052 		(void *)&cmd_macsec_offload_on_encrypt,
12053 		(void *)&cmd_macsec_offload_on_en_on_off,
12054 		(void *)&cmd_macsec_offload_on_replay_protect,
12055 		(void *)&cmd_macsec_offload_on_rp_on_off,
12056 		NULL,
12057 	},
12058 };
12059 
12060 /* Common result structure for MACsec offload disable */
12061 struct cmd_macsec_offload_off_result {
12062 	cmdline_fixed_string_t set;
12063 	cmdline_fixed_string_t macsec;
12064 	cmdline_fixed_string_t offload;
12065 	portid_t port_id;
12066 	cmdline_fixed_string_t off;
12067 };
12068 
12069 /* Common CLI fields for MACsec offload disable */
12070 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12071 	TOKEN_STRING_INITIALIZER
12072 		(struct cmd_macsec_offload_off_result,
12073 		 set, "set");
12074 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12075 	TOKEN_STRING_INITIALIZER
12076 		(struct cmd_macsec_offload_off_result,
12077 		 macsec, "macsec");
12078 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12079 	TOKEN_STRING_INITIALIZER
12080 		(struct cmd_macsec_offload_off_result,
12081 		 offload, "offload");
12082 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12083 	TOKEN_NUM_INITIALIZER
12084 		(struct cmd_macsec_offload_off_result,
12085 		 port_id, RTE_UINT16);
12086 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12087 	TOKEN_STRING_INITIALIZER
12088 		(struct cmd_macsec_offload_off_result,
12089 		 off, "off");
12090 
12091 static void
12092 cmd_set_macsec_offload_off_parsed(
12093 	void *parsed_result,
12094 	__rte_unused struct cmdline *cl,
12095 	__rte_unused void *data)
12096 {
12097 	struct cmd_macsec_offload_off_result *res = parsed_result;
12098 	int ret = -ENOTSUP;
12099 	struct rte_eth_dev_info dev_info;
12100 	portid_t port_id = res->port_id;
12101 
12102 	if (port_id_is_invalid(port_id, ENABLED_WARN))
12103 		return;
12104 	if (!port_is_stopped(port_id)) {
12105 		fprintf(stderr, "Please stop port %d first\n", port_id);
12106 		return;
12107 	}
12108 
12109 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
12110 	if (ret != 0)
12111 		return;
12112 
12113 	if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12114 #ifdef RTE_NET_IXGBE
12115 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
12116 #endif
12117 	}
12118 	switch (ret) {
12119 	case 0:
12120 		ports[port_id].dev_conf.txmode.offloads &=
12121 						~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12122 		cmd_reconfig_device_queue(port_id, 1, 1);
12123 		break;
12124 	case -ENODEV:
12125 		fprintf(stderr, "invalid port_id %d\n", port_id);
12126 		break;
12127 	case -ENOTSUP:
12128 		fprintf(stderr, "not supported on port %d\n", port_id);
12129 		break;
12130 	default:
12131 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12132 	}
12133 }
12134 
12135 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12136 	.f = cmd_set_macsec_offload_off_parsed,
12137 	.data = NULL,
12138 	.help_str = "set macsec offload <port_id> off",
12139 	.tokens = {
12140 		(void *)&cmd_macsec_offload_off_set,
12141 		(void *)&cmd_macsec_offload_off_macsec,
12142 		(void *)&cmd_macsec_offload_off_offload,
12143 		(void *)&cmd_macsec_offload_off_port_id,
12144 		(void *)&cmd_macsec_offload_off_off,
12145 		NULL,
12146 	},
12147 };
12148 
12149 /* Common result structure for MACsec secure connection configure */
12150 struct cmd_macsec_sc_result {
12151 	cmdline_fixed_string_t set;
12152 	cmdline_fixed_string_t macsec;
12153 	cmdline_fixed_string_t sc;
12154 	cmdline_fixed_string_t tx_rx;
12155 	portid_t port_id;
12156 	struct rte_ether_addr mac;
12157 	uint16_t pi;
12158 };
12159 
12160 /* Common CLI fields for MACsec secure connection configure */
12161 cmdline_parse_token_string_t cmd_macsec_sc_set =
12162 	TOKEN_STRING_INITIALIZER
12163 		(struct cmd_macsec_sc_result,
12164 		 set, "set");
12165 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12166 	TOKEN_STRING_INITIALIZER
12167 		(struct cmd_macsec_sc_result,
12168 		 macsec, "macsec");
12169 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12170 	TOKEN_STRING_INITIALIZER
12171 		(struct cmd_macsec_sc_result,
12172 		 sc, "sc");
12173 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12174 	TOKEN_STRING_INITIALIZER
12175 		(struct cmd_macsec_sc_result,
12176 		 tx_rx, "tx#rx");
12177 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12178 	TOKEN_NUM_INITIALIZER
12179 		(struct cmd_macsec_sc_result,
12180 		 port_id, RTE_UINT16);
12181 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12182 	TOKEN_ETHERADDR_INITIALIZER
12183 		(struct cmd_macsec_sc_result,
12184 		 mac);
12185 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12186 	TOKEN_NUM_INITIALIZER
12187 		(struct cmd_macsec_sc_result,
12188 		 pi, RTE_UINT16);
12189 
12190 static void
12191 cmd_set_macsec_sc_parsed(
12192 	void *parsed_result,
12193 	__rte_unused struct cmdline *cl,
12194 	__rte_unused void *data)
12195 {
12196 	struct cmd_macsec_sc_result *res = parsed_result;
12197 	int ret = -ENOTSUP;
12198 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12199 
12200 #ifdef RTE_NET_IXGBE
12201 	ret = is_tx ?
12202 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12203 				res->mac.addr_bytes) :
12204 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12205 				res->mac.addr_bytes, res->pi);
12206 #endif
12207 	RTE_SET_USED(is_tx);
12208 
12209 	switch (ret) {
12210 	case 0:
12211 		break;
12212 	case -ENODEV:
12213 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12214 		break;
12215 	case -ENOTSUP:
12216 		fprintf(stderr, "not supported on port %d\n", res->port_id);
12217 		break;
12218 	default:
12219 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12220 	}
12221 }
12222 
12223 cmdline_parse_inst_t cmd_set_macsec_sc = {
12224 	.f = cmd_set_macsec_sc_parsed,
12225 	.data = NULL,
12226 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12227 	.tokens = {
12228 		(void *)&cmd_macsec_sc_set,
12229 		(void *)&cmd_macsec_sc_macsec,
12230 		(void *)&cmd_macsec_sc_sc,
12231 		(void *)&cmd_macsec_sc_tx_rx,
12232 		(void *)&cmd_macsec_sc_port_id,
12233 		(void *)&cmd_macsec_sc_mac,
12234 		(void *)&cmd_macsec_sc_pi,
12235 		NULL,
12236 	},
12237 };
12238 
12239 /* Common result structure for MACsec secure connection configure */
12240 struct cmd_macsec_sa_result {
12241 	cmdline_fixed_string_t set;
12242 	cmdline_fixed_string_t macsec;
12243 	cmdline_fixed_string_t sa;
12244 	cmdline_fixed_string_t tx_rx;
12245 	portid_t port_id;
12246 	uint8_t idx;
12247 	uint8_t an;
12248 	uint32_t pn;
12249 	cmdline_fixed_string_t key;
12250 };
12251 
12252 /* Common CLI fields for MACsec secure connection configure */
12253 cmdline_parse_token_string_t cmd_macsec_sa_set =
12254 	TOKEN_STRING_INITIALIZER
12255 		(struct cmd_macsec_sa_result,
12256 		 set, "set");
12257 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12258 	TOKEN_STRING_INITIALIZER
12259 		(struct cmd_macsec_sa_result,
12260 		 macsec, "macsec");
12261 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12262 	TOKEN_STRING_INITIALIZER
12263 		(struct cmd_macsec_sa_result,
12264 		 sa, "sa");
12265 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12266 	TOKEN_STRING_INITIALIZER
12267 		(struct cmd_macsec_sa_result,
12268 		 tx_rx, "tx#rx");
12269 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12270 	TOKEN_NUM_INITIALIZER
12271 		(struct cmd_macsec_sa_result,
12272 		 port_id, RTE_UINT16);
12273 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12274 	TOKEN_NUM_INITIALIZER
12275 		(struct cmd_macsec_sa_result,
12276 		 idx, RTE_UINT8);
12277 cmdline_parse_token_num_t cmd_macsec_sa_an =
12278 	TOKEN_NUM_INITIALIZER
12279 		(struct cmd_macsec_sa_result,
12280 		 an, RTE_UINT8);
12281 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12282 	TOKEN_NUM_INITIALIZER
12283 		(struct cmd_macsec_sa_result,
12284 		 pn, RTE_UINT32);
12285 cmdline_parse_token_string_t cmd_macsec_sa_key =
12286 	TOKEN_STRING_INITIALIZER
12287 		(struct cmd_macsec_sa_result,
12288 		 key, NULL);
12289 
12290 static void
12291 cmd_set_macsec_sa_parsed(
12292 	void *parsed_result,
12293 	__rte_unused struct cmdline *cl,
12294 	__rte_unused void *data)
12295 {
12296 	struct cmd_macsec_sa_result *res = parsed_result;
12297 	int ret = -ENOTSUP;
12298 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12299 	uint8_t key[16] = { 0 };
12300 	uint8_t xdgt0;
12301 	uint8_t xdgt1;
12302 	int key_len;
12303 	int i;
12304 
12305 	key_len = strlen(res->key) / 2;
12306 	if (key_len > 16)
12307 		key_len = 16;
12308 
12309 	for (i = 0; i < key_len; i++) {
12310 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12311 		if (xdgt0 == 0xFF)
12312 			return;
12313 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12314 		if (xdgt1 == 0xFF)
12315 			return;
12316 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12317 	}
12318 
12319 #ifdef RTE_NET_IXGBE
12320 	ret = is_tx ?
12321 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12322 			res->idx, res->an, res->pn, key) :
12323 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12324 			res->idx, res->an, res->pn, key);
12325 #endif
12326 	RTE_SET_USED(is_tx);
12327 	RTE_SET_USED(key);
12328 
12329 	switch (ret) {
12330 	case 0:
12331 		break;
12332 	case -EINVAL:
12333 		fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12334 		break;
12335 	case -ENODEV:
12336 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12337 		break;
12338 	case -ENOTSUP:
12339 		fprintf(stderr, "not supported on port %d\n", res->port_id);
12340 		break;
12341 	default:
12342 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12343 	}
12344 }
12345 
12346 cmdline_parse_inst_t cmd_set_macsec_sa = {
12347 	.f = cmd_set_macsec_sa_parsed,
12348 	.data = NULL,
12349 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12350 	.tokens = {
12351 		(void *)&cmd_macsec_sa_set,
12352 		(void *)&cmd_macsec_sa_macsec,
12353 		(void *)&cmd_macsec_sa_sa,
12354 		(void *)&cmd_macsec_sa_tx_rx,
12355 		(void *)&cmd_macsec_sa_port_id,
12356 		(void *)&cmd_macsec_sa_idx,
12357 		(void *)&cmd_macsec_sa_an,
12358 		(void *)&cmd_macsec_sa_pn,
12359 		(void *)&cmd_macsec_sa_key,
12360 		NULL,
12361 	},
12362 };
12363 
12364 /* VF unicast promiscuous mode configuration */
12365 
12366 /* Common result structure for VF unicast promiscuous mode */
12367 struct cmd_vf_promisc_result {
12368 	cmdline_fixed_string_t set;
12369 	cmdline_fixed_string_t vf;
12370 	cmdline_fixed_string_t promisc;
12371 	portid_t port_id;
12372 	uint32_t vf_id;
12373 	cmdline_fixed_string_t on_off;
12374 };
12375 
12376 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12377 cmdline_parse_token_string_t cmd_vf_promisc_set =
12378 	TOKEN_STRING_INITIALIZER
12379 		(struct cmd_vf_promisc_result,
12380 		 set, "set");
12381 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12382 	TOKEN_STRING_INITIALIZER
12383 		(struct cmd_vf_promisc_result,
12384 		 vf, "vf");
12385 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12386 	TOKEN_STRING_INITIALIZER
12387 		(struct cmd_vf_promisc_result,
12388 		 promisc, "promisc");
12389 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12390 	TOKEN_NUM_INITIALIZER
12391 		(struct cmd_vf_promisc_result,
12392 		 port_id, RTE_UINT16);
12393 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12394 	TOKEN_NUM_INITIALIZER
12395 		(struct cmd_vf_promisc_result,
12396 		 vf_id, RTE_UINT32);
12397 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12398 	TOKEN_STRING_INITIALIZER
12399 		(struct cmd_vf_promisc_result,
12400 		 on_off, "on#off");
12401 
12402 static void
12403 cmd_set_vf_promisc_parsed(
12404 	void *parsed_result,
12405 	__rte_unused struct cmdline *cl,
12406 	__rte_unused void *data)
12407 {
12408 	struct cmd_vf_promisc_result *res = parsed_result;
12409 	int ret = -ENOTSUP;
12410 
12411 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12412 
12413 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12414 		return;
12415 
12416 #ifdef RTE_NET_I40E
12417 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12418 						  res->vf_id, is_on);
12419 #endif
12420 
12421 	switch (ret) {
12422 	case 0:
12423 		break;
12424 	case -EINVAL:
12425 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12426 		break;
12427 	case -ENODEV:
12428 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12429 		break;
12430 	case -ENOTSUP:
12431 		fprintf(stderr, "function not implemented\n");
12432 		break;
12433 	default:
12434 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12435 	}
12436 }
12437 
12438 cmdline_parse_inst_t cmd_set_vf_promisc = {
12439 	.f = cmd_set_vf_promisc_parsed,
12440 	.data = NULL,
12441 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
12442 		"Set unicast promiscuous mode for a VF from the PF",
12443 	.tokens = {
12444 		(void *)&cmd_vf_promisc_set,
12445 		(void *)&cmd_vf_promisc_vf,
12446 		(void *)&cmd_vf_promisc_promisc,
12447 		(void *)&cmd_vf_promisc_port_id,
12448 		(void *)&cmd_vf_promisc_vf_id,
12449 		(void *)&cmd_vf_promisc_on_off,
12450 		NULL,
12451 	},
12452 };
12453 
12454 /* VF multicast promiscuous mode configuration */
12455 
12456 /* Common result structure for VF multicast promiscuous mode */
12457 struct cmd_vf_allmulti_result {
12458 	cmdline_fixed_string_t set;
12459 	cmdline_fixed_string_t vf;
12460 	cmdline_fixed_string_t allmulti;
12461 	portid_t port_id;
12462 	uint32_t vf_id;
12463 	cmdline_fixed_string_t on_off;
12464 };
12465 
12466 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12467 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12468 	TOKEN_STRING_INITIALIZER
12469 		(struct cmd_vf_allmulti_result,
12470 		 set, "set");
12471 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12472 	TOKEN_STRING_INITIALIZER
12473 		(struct cmd_vf_allmulti_result,
12474 		 vf, "vf");
12475 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12476 	TOKEN_STRING_INITIALIZER
12477 		(struct cmd_vf_allmulti_result,
12478 		 allmulti, "allmulti");
12479 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12480 	TOKEN_NUM_INITIALIZER
12481 		(struct cmd_vf_allmulti_result,
12482 		 port_id, RTE_UINT16);
12483 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12484 	TOKEN_NUM_INITIALIZER
12485 		(struct cmd_vf_allmulti_result,
12486 		 vf_id, RTE_UINT32);
12487 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12488 	TOKEN_STRING_INITIALIZER
12489 		(struct cmd_vf_allmulti_result,
12490 		 on_off, "on#off");
12491 
12492 static void
12493 cmd_set_vf_allmulti_parsed(
12494 	void *parsed_result,
12495 	__rte_unused struct cmdline *cl,
12496 	__rte_unused void *data)
12497 {
12498 	struct cmd_vf_allmulti_result *res = parsed_result;
12499 	int ret = -ENOTSUP;
12500 
12501 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12502 
12503 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12504 		return;
12505 
12506 #ifdef RTE_NET_I40E
12507 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12508 						    res->vf_id, is_on);
12509 #endif
12510 
12511 	switch (ret) {
12512 	case 0:
12513 		break;
12514 	case -EINVAL:
12515 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12516 		break;
12517 	case -ENODEV:
12518 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12519 		break;
12520 	case -ENOTSUP:
12521 		fprintf(stderr, "function not implemented\n");
12522 		break;
12523 	default:
12524 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12525 	}
12526 }
12527 
12528 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12529 	.f = cmd_set_vf_allmulti_parsed,
12530 	.data = NULL,
12531 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12532 		"Set multicast promiscuous mode for a VF from the PF",
12533 	.tokens = {
12534 		(void *)&cmd_vf_allmulti_set,
12535 		(void *)&cmd_vf_allmulti_vf,
12536 		(void *)&cmd_vf_allmulti_allmulti,
12537 		(void *)&cmd_vf_allmulti_port_id,
12538 		(void *)&cmd_vf_allmulti_vf_id,
12539 		(void *)&cmd_vf_allmulti_on_off,
12540 		NULL,
12541 	},
12542 };
12543 
12544 /* vf broadcast mode configuration */
12545 
12546 /* Common result structure for vf broadcast */
12547 struct cmd_set_vf_broadcast_result {
12548 	cmdline_fixed_string_t set;
12549 	cmdline_fixed_string_t vf;
12550 	cmdline_fixed_string_t broadcast;
12551 	portid_t port_id;
12552 	uint16_t vf_id;
12553 	cmdline_fixed_string_t on_off;
12554 };
12555 
12556 /* Common CLI fields for vf broadcast enable disable */
12557 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12558 	TOKEN_STRING_INITIALIZER
12559 		(struct cmd_set_vf_broadcast_result,
12560 		 set, "set");
12561 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12562 	TOKEN_STRING_INITIALIZER
12563 		(struct cmd_set_vf_broadcast_result,
12564 		 vf, "vf");
12565 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12566 	TOKEN_STRING_INITIALIZER
12567 		(struct cmd_set_vf_broadcast_result,
12568 		 broadcast, "broadcast");
12569 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12570 	TOKEN_NUM_INITIALIZER
12571 		(struct cmd_set_vf_broadcast_result,
12572 		 port_id, RTE_UINT16);
12573 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12574 	TOKEN_NUM_INITIALIZER
12575 		(struct cmd_set_vf_broadcast_result,
12576 		 vf_id, RTE_UINT16);
12577 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12578 	TOKEN_STRING_INITIALIZER
12579 		(struct cmd_set_vf_broadcast_result,
12580 		 on_off, "on#off");
12581 
12582 static void
12583 cmd_set_vf_broadcast_parsed(
12584 	void *parsed_result,
12585 	__rte_unused struct cmdline *cl,
12586 	__rte_unused void *data)
12587 {
12588 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12589 	int ret = -ENOTSUP;
12590 
12591 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12592 
12593 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12594 		return;
12595 
12596 #ifdef RTE_NET_I40E
12597 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12598 					    res->vf_id, is_on);
12599 #endif
12600 
12601 	switch (ret) {
12602 	case 0:
12603 		break;
12604 	case -EINVAL:
12605 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12606 			res->vf_id, is_on);
12607 		break;
12608 	case -ENODEV:
12609 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12610 		break;
12611 	case -ENOTSUP:
12612 		fprintf(stderr, "function not implemented\n");
12613 		break;
12614 	default:
12615 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12616 	}
12617 }
12618 
12619 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12620 	.f = cmd_set_vf_broadcast_parsed,
12621 	.data = NULL,
12622 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12623 	.tokens = {
12624 		(void *)&cmd_set_vf_broadcast_set,
12625 		(void *)&cmd_set_vf_broadcast_vf,
12626 		(void *)&cmd_set_vf_broadcast_broadcast,
12627 		(void *)&cmd_set_vf_broadcast_port_id,
12628 		(void *)&cmd_set_vf_broadcast_vf_id,
12629 		(void *)&cmd_set_vf_broadcast_on_off,
12630 		NULL,
12631 	},
12632 };
12633 
12634 /* vf vlan tag configuration */
12635 
12636 /* Common result structure for vf vlan tag */
12637 struct cmd_set_vf_vlan_tag_result {
12638 	cmdline_fixed_string_t set;
12639 	cmdline_fixed_string_t vf;
12640 	cmdline_fixed_string_t vlan;
12641 	cmdline_fixed_string_t tag;
12642 	portid_t port_id;
12643 	uint16_t vf_id;
12644 	cmdline_fixed_string_t on_off;
12645 };
12646 
12647 /* Common CLI fields for vf vlan tag enable disable */
12648 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12649 	TOKEN_STRING_INITIALIZER
12650 		(struct cmd_set_vf_vlan_tag_result,
12651 		 set, "set");
12652 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12653 	TOKEN_STRING_INITIALIZER
12654 		(struct cmd_set_vf_vlan_tag_result,
12655 		 vf, "vf");
12656 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12657 	TOKEN_STRING_INITIALIZER
12658 		(struct cmd_set_vf_vlan_tag_result,
12659 		 vlan, "vlan");
12660 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12661 	TOKEN_STRING_INITIALIZER
12662 		(struct cmd_set_vf_vlan_tag_result,
12663 		 tag, "tag");
12664 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12665 	TOKEN_NUM_INITIALIZER
12666 		(struct cmd_set_vf_vlan_tag_result,
12667 		 port_id, RTE_UINT16);
12668 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12669 	TOKEN_NUM_INITIALIZER
12670 		(struct cmd_set_vf_vlan_tag_result,
12671 		 vf_id, RTE_UINT16);
12672 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12673 	TOKEN_STRING_INITIALIZER
12674 		(struct cmd_set_vf_vlan_tag_result,
12675 		 on_off, "on#off");
12676 
12677 static void
12678 cmd_set_vf_vlan_tag_parsed(
12679 	void *parsed_result,
12680 	__rte_unused struct cmdline *cl,
12681 	__rte_unused void *data)
12682 {
12683 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12684 	int ret = -ENOTSUP;
12685 
12686 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12687 
12688 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12689 		return;
12690 
12691 #ifdef RTE_NET_I40E
12692 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12693 					   res->vf_id, is_on);
12694 #endif
12695 
12696 	switch (ret) {
12697 	case 0:
12698 		break;
12699 	case -EINVAL:
12700 		fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12701 			res->vf_id, is_on);
12702 		break;
12703 	case -ENODEV:
12704 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12705 		break;
12706 	case -ENOTSUP:
12707 		fprintf(stderr, "function not implemented\n");
12708 		break;
12709 	default:
12710 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12711 	}
12712 }
12713 
12714 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12715 	.f = cmd_set_vf_vlan_tag_parsed,
12716 	.data = NULL,
12717 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12718 	.tokens = {
12719 		(void *)&cmd_set_vf_vlan_tag_set,
12720 		(void *)&cmd_set_vf_vlan_tag_vf,
12721 		(void *)&cmd_set_vf_vlan_tag_vlan,
12722 		(void *)&cmd_set_vf_vlan_tag_tag,
12723 		(void *)&cmd_set_vf_vlan_tag_port_id,
12724 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12725 		(void *)&cmd_set_vf_vlan_tag_on_off,
12726 		NULL,
12727 	},
12728 };
12729 
12730 /* Common definition of VF and TC TX bandwidth configuration */
12731 struct cmd_vf_tc_bw_result {
12732 	cmdline_fixed_string_t set;
12733 	cmdline_fixed_string_t vf;
12734 	cmdline_fixed_string_t tc;
12735 	cmdline_fixed_string_t tx;
12736 	cmdline_fixed_string_t min_bw;
12737 	cmdline_fixed_string_t max_bw;
12738 	cmdline_fixed_string_t strict_link_prio;
12739 	portid_t port_id;
12740 	uint16_t vf_id;
12741 	uint8_t tc_no;
12742 	uint32_t bw;
12743 	cmdline_fixed_string_t bw_list;
12744 	uint8_t tc_map;
12745 };
12746 
12747 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12748 	TOKEN_STRING_INITIALIZER
12749 		(struct cmd_vf_tc_bw_result,
12750 		 set, "set");
12751 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12752 	TOKEN_STRING_INITIALIZER
12753 		(struct cmd_vf_tc_bw_result,
12754 		 vf, "vf");
12755 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12756 	TOKEN_STRING_INITIALIZER
12757 		(struct cmd_vf_tc_bw_result,
12758 		 tc, "tc");
12759 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12760 	TOKEN_STRING_INITIALIZER
12761 		(struct cmd_vf_tc_bw_result,
12762 		 tx, "tx");
12763 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12764 	TOKEN_STRING_INITIALIZER
12765 		(struct cmd_vf_tc_bw_result,
12766 		 strict_link_prio, "strict-link-priority");
12767 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12768 	TOKEN_STRING_INITIALIZER
12769 		(struct cmd_vf_tc_bw_result,
12770 		 min_bw, "min-bandwidth");
12771 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12772 	TOKEN_STRING_INITIALIZER
12773 		(struct cmd_vf_tc_bw_result,
12774 		 max_bw, "max-bandwidth");
12775 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12776 	TOKEN_NUM_INITIALIZER
12777 		(struct cmd_vf_tc_bw_result,
12778 		 port_id, RTE_UINT16);
12779 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12780 	TOKEN_NUM_INITIALIZER
12781 		(struct cmd_vf_tc_bw_result,
12782 		 vf_id, RTE_UINT16);
12783 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12784 	TOKEN_NUM_INITIALIZER
12785 		(struct cmd_vf_tc_bw_result,
12786 		 tc_no, RTE_UINT8);
12787 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12788 	TOKEN_NUM_INITIALIZER
12789 		(struct cmd_vf_tc_bw_result,
12790 		 bw, RTE_UINT32);
12791 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12792 	TOKEN_STRING_INITIALIZER
12793 		(struct cmd_vf_tc_bw_result,
12794 		 bw_list, NULL);
12795 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12796 	TOKEN_NUM_INITIALIZER
12797 		(struct cmd_vf_tc_bw_result,
12798 		 tc_map, RTE_UINT8);
12799 
12800 /* VF max bandwidth setting */
12801 static void
12802 cmd_vf_max_bw_parsed(
12803 	void *parsed_result,
12804 	__rte_unused struct cmdline *cl,
12805 	__rte_unused void *data)
12806 {
12807 	struct cmd_vf_tc_bw_result *res = parsed_result;
12808 	int ret = -ENOTSUP;
12809 
12810 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12811 		return;
12812 
12813 #ifdef RTE_NET_I40E
12814 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12815 					 res->vf_id, res->bw);
12816 #endif
12817 
12818 	switch (ret) {
12819 	case 0:
12820 		break;
12821 	case -EINVAL:
12822 		fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12823 			res->vf_id, res->bw);
12824 		break;
12825 	case -ENODEV:
12826 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12827 		break;
12828 	case -ENOTSUP:
12829 		fprintf(stderr, "function not implemented\n");
12830 		break;
12831 	default:
12832 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12833 	}
12834 }
12835 
12836 cmdline_parse_inst_t cmd_vf_max_bw = {
12837 	.f = cmd_vf_max_bw_parsed,
12838 	.data = NULL,
12839 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12840 	.tokens = {
12841 		(void *)&cmd_vf_tc_bw_set,
12842 		(void *)&cmd_vf_tc_bw_vf,
12843 		(void *)&cmd_vf_tc_bw_tx,
12844 		(void *)&cmd_vf_tc_bw_max_bw,
12845 		(void *)&cmd_vf_tc_bw_port_id,
12846 		(void *)&cmd_vf_tc_bw_vf_id,
12847 		(void *)&cmd_vf_tc_bw_bw,
12848 		NULL,
12849 	},
12850 };
12851 
12852 static int
12853 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12854 			   uint8_t *tc_num,
12855 			   char *str)
12856 {
12857 	uint32_t size;
12858 	const char *p, *p0 = str;
12859 	char s[256];
12860 	char *end;
12861 	char *str_fld[16];
12862 	uint16_t i;
12863 	int ret;
12864 
12865 	p = strchr(p0, '(');
12866 	if (p == NULL) {
12867 		fprintf(stderr,
12868 			"The bandwidth-list should be '(bw1, bw2, ...)'\n");
12869 		return -1;
12870 	}
12871 	p++;
12872 	p0 = strchr(p, ')');
12873 	if (p0 == NULL) {
12874 		fprintf(stderr,
12875 			"The bandwidth-list should be '(bw1, bw2, ...)'\n");
12876 		return -1;
12877 	}
12878 	size = p0 - p;
12879 	if (size >= sizeof(s)) {
12880 		fprintf(stderr,
12881 			"The string size exceeds the internal buffer size\n");
12882 		return -1;
12883 	}
12884 	snprintf(s, sizeof(s), "%.*s", size, p);
12885 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12886 	if (ret <= 0) {
12887 		fprintf(stderr, "Failed to get the bandwidth list.\n");
12888 		return -1;
12889 	}
12890 	*tc_num = ret;
12891 	for (i = 0; i < ret; i++)
12892 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12893 
12894 	return 0;
12895 }
12896 
12897 /* TC min bandwidth setting */
12898 static void
12899 cmd_vf_tc_min_bw_parsed(
12900 	void *parsed_result,
12901 	__rte_unused struct cmdline *cl,
12902 	__rte_unused void *data)
12903 {
12904 	struct cmd_vf_tc_bw_result *res = parsed_result;
12905 	uint8_t tc_num;
12906 	uint8_t bw[16];
12907 	int ret = -ENOTSUP;
12908 
12909 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12910 		return;
12911 
12912 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12913 	if (ret)
12914 		return;
12915 
12916 #ifdef RTE_NET_I40E
12917 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12918 					      tc_num, bw);
12919 #endif
12920 
12921 	switch (ret) {
12922 	case 0:
12923 		break;
12924 	case -EINVAL:
12925 		fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12926 		break;
12927 	case -ENODEV:
12928 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12929 		break;
12930 	case -ENOTSUP:
12931 		fprintf(stderr, "function not implemented\n");
12932 		break;
12933 	default:
12934 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12935 	}
12936 }
12937 
12938 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12939 	.f = cmd_vf_tc_min_bw_parsed,
12940 	.data = NULL,
12941 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12942 		    " <bw1, bw2, ...>",
12943 	.tokens = {
12944 		(void *)&cmd_vf_tc_bw_set,
12945 		(void *)&cmd_vf_tc_bw_vf,
12946 		(void *)&cmd_vf_tc_bw_tc,
12947 		(void *)&cmd_vf_tc_bw_tx,
12948 		(void *)&cmd_vf_tc_bw_min_bw,
12949 		(void *)&cmd_vf_tc_bw_port_id,
12950 		(void *)&cmd_vf_tc_bw_vf_id,
12951 		(void *)&cmd_vf_tc_bw_bw_list,
12952 		NULL,
12953 	},
12954 };
12955 
12956 static void
12957 cmd_tc_min_bw_parsed(
12958 	void *parsed_result,
12959 	__rte_unused struct cmdline *cl,
12960 	__rte_unused void *data)
12961 {
12962 	struct cmd_vf_tc_bw_result *res = parsed_result;
12963 	struct rte_port *port;
12964 	uint8_t tc_num;
12965 	uint8_t bw[16];
12966 	int ret = -ENOTSUP;
12967 
12968 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12969 		return;
12970 
12971 	port = &ports[res->port_id];
12972 	/** Check if the port is not started **/
12973 	if (port->port_status != RTE_PORT_STOPPED) {
12974 		fprintf(stderr, "Please stop port %d first\n", res->port_id);
12975 		return;
12976 	}
12977 
12978 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12979 	if (ret)
12980 		return;
12981 
12982 #ifdef RTE_NET_IXGBE
12983 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12984 #endif
12985 
12986 	switch (ret) {
12987 	case 0:
12988 		break;
12989 	case -EINVAL:
12990 		fprintf(stderr, "invalid bandwidth\n");
12991 		break;
12992 	case -ENODEV:
12993 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
12994 		break;
12995 	case -ENOTSUP:
12996 		fprintf(stderr, "function not implemented\n");
12997 		break;
12998 	default:
12999 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13000 	}
13001 }
13002 
13003 cmdline_parse_inst_t cmd_tc_min_bw = {
13004 	.f = cmd_tc_min_bw_parsed,
13005 	.data = NULL,
13006 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13007 	.tokens = {
13008 		(void *)&cmd_vf_tc_bw_set,
13009 		(void *)&cmd_vf_tc_bw_tc,
13010 		(void *)&cmd_vf_tc_bw_tx,
13011 		(void *)&cmd_vf_tc_bw_min_bw,
13012 		(void *)&cmd_vf_tc_bw_port_id,
13013 		(void *)&cmd_vf_tc_bw_bw_list,
13014 		NULL,
13015 	},
13016 };
13017 
13018 /* TC max bandwidth setting */
13019 static void
13020 cmd_vf_tc_max_bw_parsed(
13021 	void *parsed_result,
13022 	__rte_unused struct cmdline *cl,
13023 	__rte_unused void *data)
13024 {
13025 	struct cmd_vf_tc_bw_result *res = parsed_result;
13026 	int ret = -ENOTSUP;
13027 
13028 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13029 		return;
13030 
13031 #ifdef RTE_NET_I40E
13032 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13033 					    res->tc_no, res->bw);
13034 #endif
13035 
13036 	switch (ret) {
13037 	case 0:
13038 		break;
13039 	case -EINVAL:
13040 		fprintf(stderr,
13041 			"invalid vf_id %d, tc_no %d or bandwidth %d\n",
13042 			res->vf_id, res->tc_no, res->bw);
13043 		break;
13044 	case -ENODEV:
13045 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
13046 		break;
13047 	case -ENOTSUP:
13048 		fprintf(stderr, "function not implemented\n");
13049 		break;
13050 	default:
13051 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13052 	}
13053 }
13054 
13055 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13056 	.f = cmd_vf_tc_max_bw_parsed,
13057 	.data = NULL,
13058 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13059 		    " <bandwidth>",
13060 	.tokens = {
13061 		(void *)&cmd_vf_tc_bw_set,
13062 		(void *)&cmd_vf_tc_bw_vf,
13063 		(void *)&cmd_vf_tc_bw_tc,
13064 		(void *)&cmd_vf_tc_bw_tx,
13065 		(void *)&cmd_vf_tc_bw_max_bw,
13066 		(void *)&cmd_vf_tc_bw_port_id,
13067 		(void *)&cmd_vf_tc_bw_vf_id,
13068 		(void *)&cmd_vf_tc_bw_tc_no,
13069 		(void *)&cmd_vf_tc_bw_bw,
13070 		NULL,
13071 	},
13072 };
13073 
13074 /** Set VXLAN encapsulation details */
13075 struct cmd_set_vxlan_result {
13076 	cmdline_fixed_string_t set;
13077 	cmdline_fixed_string_t vxlan;
13078 	cmdline_fixed_string_t pos_token;
13079 	cmdline_fixed_string_t ip_version;
13080 	uint32_t vlan_present:1;
13081 	uint32_t vni;
13082 	uint16_t udp_src;
13083 	uint16_t udp_dst;
13084 	cmdline_ipaddr_t ip_src;
13085 	cmdline_ipaddr_t ip_dst;
13086 	uint16_t tci;
13087 	uint8_t tos;
13088 	uint8_t ttl;
13089 	struct rte_ether_addr eth_src;
13090 	struct rte_ether_addr eth_dst;
13091 };
13092 
13093 cmdline_parse_token_string_t cmd_set_vxlan_set =
13094 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13095 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13096 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13097 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13098 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13099 				 "vxlan-tos-ttl");
13100 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13101 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13102 				 "vxlan-with-vlan");
13103 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13104 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13105 				 "ip-version");
13106 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13107 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13108 				 "ipv4#ipv6");
13109 cmdline_parse_token_string_t cmd_set_vxlan_vni =
13110 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13111 				 "vni");
13112 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13113 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13114 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13115 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13116 				 "udp-src");
13117 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13118 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13119 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13120 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13121 				 "udp-dst");
13122 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13123 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13124 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13125 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13126 				 "ip-tos");
13127 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13128 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13129 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13130 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13131 				 "ip-ttl");
13132 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13133 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13134 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13135 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13136 				 "ip-src");
13137 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13138 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13139 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13140 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13141 				 "ip-dst");
13142 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13143 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13144 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13145 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13146 				 "vlan-tci");
13147 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13148 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13149 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13150 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13151 				 "eth-src");
13152 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13153 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13154 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13155 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13156 				 "eth-dst");
13157 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13158 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13159 
13160 static void cmd_set_vxlan_parsed(void *parsed_result,
13161 	__rte_unused struct cmdline *cl,
13162 	__rte_unused void *data)
13163 {
13164 	struct cmd_set_vxlan_result *res = parsed_result;
13165 	union {
13166 		uint32_t vxlan_id;
13167 		uint8_t vni[4];
13168 	} id = {
13169 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13170 	};
13171 
13172 	vxlan_encap_conf.select_tos_ttl = 0;
13173 	if (strcmp(res->vxlan, "vxlan") == 0)
13174 		vxlan_encap_conf.select_vlan = 0;
13175 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13176 		vxlan_encap_conf.select_vlan = 1;
13177 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13178 		vxlan_encap_conf.select_vlan = 0;
13179 		vxlan_encap_conf.select_tos_ttl = 1;
13180 	}
13181 	if (strcmp(res->ip_version, "ipv4") == 0)
13182 		vxlan_encap_conf.select_ipv4 = 1;
13183 	else if (strcmp(res->ip_version, "ipv6") == 0)
13184 		vxlan_encap_conf.select_ipv4 = 0;
13185 	else
13186 		return;
13187 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13188 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13189 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13190 	vxlan_encap_conf.ip_tos = res->tos;
13191 	vxlan_encap_conf.ip_ttl = res->ttl;
13192 	if (vxlan_encap_conf.select_ipv4) {
13193 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13194 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13195 	} else {
13196 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13197 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13198 	}
13199 	if (vxlan_encap_conf.select_vlan)
13200 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13201 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13202 		   RTE_ETHER_ADDR_LEN);
13203 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13204 		   RTE_ETHER_ADDR_LEN);
13205 }
13206 
13207 cmdline_parse_inst_t cmd_set_vxlan = {
13208 	.f = cmd_set_vxlan_parsed,
13209 	.data = NULL,
13210 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13211 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13212 		" eth-src <eth-src> eth-dst <eth-dst>",
13213 	.tokens = {
13214 		(void *)&cmd_set_vxlan_set,
13215 		(void *)&cmd_set_vxlan_vxlan,
13216 		(void *)&cmd_set_vxlan_ip_version,
13217 		(void *)&cmd_set_vxlan_ip_version_value,
13218 		(void *)&cmd_set_vxlan_vni,
13219 		(void *)&cmd_set_vxlan_vni_value,
13220 		(void *)&cmd_set_vxlan_udp_src,
13221 		(void *)&cmd_set_vxlan_udp_src_value,
13222 		(void *)&cmd_set_vxlan_udp_dst,
13223 		(void *)&cmd_set_vxlan_udp_dst_value,
13224 		(void *)&cmd_set_vxlan_ip_src,
13225 		(void *)&cmd_set_vxlan_ip_src_value,
13226 		(void *)&cmd_set_vxlan_ip_dst,
13227 		(void *)&cmd_set_vxlan_ip_dst_value,
13228 		(void *)&cmd_set_vxlan_eth_src,
13229 		(void *)&cmd_set_vxlan_eth_src_value,
13230 		(void *)&cmd_set_vxlan_eth_dst,
13231 		(void *)&cmd_set_vxlan_eth_dst_value,
13232 		NULL,
13233 	},
13234 };
13235 
13236 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13237 	.f = cmd_set_vxlan_parsed,
13238 	.data = NULL,
13239 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13240 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13241 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13242 		" eth-dst <eth-dst>",
13243 	.tokens = {
13244 		(void *)&cmd_set_vxlan_set,
13245 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
13246 		(void *)&cmd_set_vxlan_ip_version,
13247 		(void *)&cmd_set_vxlan_ip_version_value,
13248 		(void *)&cmd_set_vxlan_vni,
13249 		(void *)&cmd_set_vxlan_vni_value,
13250 		(void *)&cmd_set_vxlan_udp_src,
13251 		(void *)&cmd_set_vxlan_udp_src_value,
13252 		(void *)&cmd_set_vxlan_udp_dst,
13253 		(void *)&cmd_set_vxlan_udp_dst_value,
13254 		(void *)&cmd_set_vxlan_ip_tos,
13255 		(void *)&cmd_set_vxlan_ip_tos_value,
13256 		(void *)&cmd_set_vxlan_ip_ttl,
13257 		(void *)&cmd_set_vxlan_ip_ttl_value,
13258 		(void *)&cmd_set_vxlan_ip_src,
13259 		(void *)&cmd_set_vxlan_ip_src_value,
13260 		(void *)&cmd_set_vxlan_ip_dst,
13261 		(void *)&cmd_set_vxlan_ip_dst_value,
13262 		(void *)&cmd_set_vxlan_eth_src,
13263 		(void *)&cmd_set_vxlan_eth_src_value,
13264 		(void *)&cmd_set_vxlan_eth_dst,
13265 		(void *)&cmd_set_vxlan_eth_dst_value,
13266 		NULL,
13267 	},
13268 };
13269 
13270 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13271 	.f = cmd_set_vxlan_parsed,
13272 	.data = NULL,
13273 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13274 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13275 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13276 		" <eth-dst>",
13277 	.tokens = {
13278 		(void *)&cmd_set_vxlan_set,
13279 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
13280 		(void *)&cmd_set_vxlan_ip_version,
13281 		(void *)&cmd_set_vxlan_ip_version_value,
13282 		(void *)&cmd_set_vxlan_vni,
13283 		(void *)&cmd_set_vxlan_vni_value,
13284 		(void *)&cmd_set_vxlan_udp_src,
13285 		(void *)&cmd_set_vxlan_udp_src_value,
13286 		(void *)&cmd_set_vxlan_udp_dst,
13287 		(void *)&cmd_set_vxlan_udp_dst_value,
13288 		(void *)&cmd_set_vxlan_ip_src,
13289 		(void *)&cmd_set_vxlan_ip_src_value,
13290 		(void *)&cmd_set_vxlan_ip_dst,
13291 		(void *)&cmd_set_vxlan_ip_dst_value,
13292 		(void *)&cmd_set_vxlan_vlan,
13293 		(void *)&cmd_set_vxlan_vlan_value,
13294 		(void *)&cmd_set_vxlan_eth_src,
13295 		(void *)&cmd_set_vxlan_eth_src_value,
13296 		(void *)&cmd_set_vxlan_eth_dst,
13297 		(void *)&cmd_set_vxlan_eth_dst_value,
13298 		NULL,
13299 	},
13300 };
13301 
13302 /** Set NVGRE encapsulation details */
13303 struct cmd_set_nvgre_result {
13304 	cmdline_fixed_string_t set;
13305 	cmdline_fixed_string_t nvgre;
13306 	cmdline_fixed_string_t pos_token;
13307 	cmdline_fixed_string_t ip_version;
13308 	uint32_t tni;
13309 	cmdline_ipaddr_t ip_src;
13310 	cmdline_ipaddr_t ip_dst;
13311 	uint16_t tci;
13312 	struct rte_ether_addr eth_src;
13313 	struct rte_ether_addr eth_dst;
13314 };
13315 
13316 cmdline_parse_token_string_t cmd_set_nvgre_set =
13317 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13318 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13319 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13320 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13321 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13322 				 "nvgre-with-vlan");
13323 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13324 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13325 				 "ip-version");
13326 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13327 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13328 				 "ipv4#ipv6");
13329 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13330 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13331 				 "tni");
13332 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13333 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13334 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13335 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13336 				 "ip-src");
13337 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13338 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13339 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13340 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13341 				 "ip-dst");
13342 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13343 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13344 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13345 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13346 				 "vlan-tci");
13347 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13348 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13349 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13350 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13351 				 "eth-src");
13352 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13353 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13354 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13355 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13356 				 "eth-dst");
13357 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13358 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13359 
13360 static void cmd_set_nvgre_parsed(void *parsed_result,
13361 	__rte_unused struct cmdline *cl,
13362 	__rte_unused void *data)
13363 {
13364 	struct cmd_set_nvgre_result *res = parsed_result;
13365 	union {
13366 		uint32_t nvgre_tni;
13367 		uint8_t tni[4];
13368 	} id = {
13369 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13370 	};
13371 
13372 	if (strcmp(res->nvgre, "nvgre") == 0)
13373 		nvgre_encap_conf.select_vlan = 0;
13374 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13375 		nvgre_encap_conf.select_vlan = 1;
13376 	if (strcmp(res->ip_version, "ipv4") == 0)
13377 		nvgre_encap_conf.select_ipv4 = 1;
13378 	else if (strcmp(res->ip_version, "ipv6") == 0)
13379 		nvgre_encap_conf.select_ipv4 = 0;
13380 	else
13381 		return;
13382 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13383 	if (nvgre_encap_conf.select_ipv4) {
13384 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13385 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13386 	} else {
13387 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13388 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13389 	}
13390 	if (nvgre_encap_conf.select_vlan)
13391 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13392 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13393 		   RTE_ETHER_ADDR_LEN);
13394 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13395 		   RTE_ETHER_ADDR_LEN);
13396 }
13397 
13398 cmdline_parse_inst_t cmd_set_nvgre = {
13399 	.f = cmd_set_nvgre_parsed,
13400 	.data = NULL,
13401 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13402 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13403 		" eth-dst <eth-dst>",
13404 	.tokens = {
13405 		(void *)&cmd_set_nvgre_set,
13406 		(void *)&cmd_set_nvgre_nvgre,
13407 		(void *)&cmd_set_nvgre_ip_version,
13408 		(void *)&cmd_set_nvgre_ip_version_value,
13409 		(void *)&cmd_set_nvgre_tni,
13410 		(void *)&cmd_set_nvgre_tni_value,
13411 		(void *)&cmd_set_nvgre_ip_src,
13412 		(void *)&cmd_set_nvgre_ip_src_value,
13413 		(void *)&cmd_set_nvgre_ip_dst,
13414 		(void *)&cmd_set_nvgre_ip_dst_value,
13415 		(void *)&cmd_set_nvgre_eth_src,
13416 		(void *)&cmd_set_nvgre_eth_src_value,
13417 		(void *)&cmd_set_nvgre_eth_dst,
13418 		(void *)&cmd_set_nvgre_eth_dst_value,
13419 		NULL,
13420 	},
13421 };
13422 
13423 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13424 	.f = cmd_set_nvgre_parsed,
13425 	.data = NULL,
13426 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13427 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13428 		" eth-src <eth-src> eth-dst <eth-dst>",
13429 	.tokens = {
13430 		(void *)&cmd_set_nvgre_set,
13431 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
13432 		(void *)&cmd_set_nvgre_ip_version,
13433 		(void *)&cmd_set_nvgre_ip_version_value,
13434 		(void *)&cmd_set_nvgre_tni,
13435 		(void *)&cmd_set_nvgre_tni_value,
13436 		(void *)&cmd_set_nvgre_ip_src,
13437 		(void *)&cmd_set_nvgre_ip_src_value,
13438 		(void *)&cmd_set_nvgre_ip_dst,
13439 		(void *)&cmd_set_nvgre_ip_dst_value,
13440 		(void *)&cmd_set_nvgre_vlan,
13441 		(void *)&cmd_set_nvgre_vlan_value,
13442 		(void *)&cmd_set_nvgre_eth_src,
13443 		(void *)&cmd_set_nvgre_eth_src_value,
13444 		(void *)&cmd_set_nvgre_eth_dst,
13445 		(void *)&cmd_set_nvgre_eth_dst_value,
13446 		NULL,
13447 	},
13448 };
13449 
13450 /** Set L2 encapsulation details */
13451 struct cmd_set_l2_encap_result {
13452 	cmdline_fixed_string_t set;
13453 	cmdline_fixed_string_t l2_encap;
13454 	cmdline_fixed_string_t pos_token;
13455 	cmdline_fixed_string_t ip_version;
13456 	uint32_t vlan_present:1;
13457 	uint16_t tci;
13458 	struct rte_ether_addr eth_src;
13459 	struct rte_ether_addr eth_dst;
13460 };
13461 
13462 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13463 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13464 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13465 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13466 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13467 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13468 				 "l2_encap-with-vlan");
13469 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13470 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13471 				 "ip-version");
13472 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13473 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13474 				 "ipv4#ipv6");
13475 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13476 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13477 				 "vlan-tci");
13478 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13479 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13480 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13481 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13482 				 "eth-src");
13483 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13484 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13485 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13486 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13487 				 "eth-dst");
13488 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13489 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13490 
13491 static void cmd_set_l2_encap_parsed(void *parsed_result,
13492 	__rte_unused struct cmdline *cl,
13493 	__rte_unused void *data)
13494 {
13495 	struct cmd_set_l2_encap_result *res = parsed_result;
13496 
13497 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13498 		l2_encap_conf.select_vlan = 0;
13499 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13500 		l2_encap_conf.select_vlan = 1;
13501 	if (strcmp(res->ip_version, "ipv4") == 0)
13502 		l2_encap_conf.select_ipv4 = 1;
13503 	else if (strcmp(res->ip_version, "ipv6") == 0)
13504 		l2_encap_conf.select_ipv4 = 0;
13505 	else
13506 		return;
13507 	if (l2_encap_conf.select_vlan)
13508 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13509 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13510 		   RTE_ETHER_ADDR_LEN);
13511 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13512 		   RTE_ETHER_ADDR_LEN);
13513 }
13514 
13515 cmdline_parse_inst_t cmd_set_l2_encap = {
13516 	.f = cmd_set_l2_encap_parsed,
13517 	.data = NULL,
13518 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13519 		" eth-src <eth-src> eth-dst <eth-dst>",
13520 	.tokens = {
13521 		(void *)&cmd_set_l2_encap_set,
13522 		(void *)&cmd_set_l2_encap_l2_encap,
13523 		(void *)&cmd_set_l2_encap_ip_version,
13524 		(void *)&cmd_set_l2_encap_ip_version_value,
13525 		(void *)&cmd_set_l2_encap_eth_src,
13526 		(void *)&cmd_set_l2_encap_eth_src_value,
13527 		(void *)&cmd_set_l2_encap_eth_dst,
13528 		(void *)&cmd_set_l2_encap_eth_dst_value,
13529 		NULL,
13530 	},
13531 };
13532 
13533 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13534 	.f = cmd_set_l2_encap_parsed,
13535 	.data = NULL,
13536 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13537 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13538 	.tokens = {
13539 		(void *)&cmd_set_l2_encap_set,
13540 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13541 		(void *)&cmd_set_l2_encap_ip_version,
13542 		(void *)&cmd_set_l2_encap_ip_version_value,
13543 		(void *)&cmd_set_l2_encap_vlan,
13544 		(void *)&cmd_set_l2_encap_vlan_value,
13545 		(void *)&cmd_set_l2_encap_eth_src,
13546 		(void *)&cmd_set_l2_encap_eth_src_value,
13547 		(void *)&cmd_set_l2_encap_eth_dst,
13548 		(void *)&cmd_set_l2_encap_eth_dst_value,
13549 		NULL,
13550 	},
13551 };
13552 
13553 /** Set L2 decapsulation details */
13554 struct cmd_set_l2_decap_result {
13555 	cmdline_fixed_string_t set;
13556 	cmdline_fixed_string_t l2_decap;
13557 	cmdline_fixed_string_t pos_token;
13558 	uint32_t vlan_present:1;
13559 };
13560 
13561 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13562 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13563 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13564 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13565 				 "l2_decap");
13566 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13567 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13568 				 "l2_decap-with-vlan");
13569 
13570 static void cmd_set_l2_decap_parsed(void *parsed_result,
13571 	__rte_unused struct cmdline *cl,
13572 	__rte_unused void *data)
13573 {
13574 	struct cmd_set_l2_decap_result *res = parsed_result;
13575 
13576 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13577 		l2_decap_conf.select_vlan = 0;
13578 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13579 		l2_decap_conf.select_vlan = 1;
13580 }
13581 
13582 cmdline_parse_inst_t cmd_set_l2_decap = {
13583 	.f = cmd_set_l2_decap_parsed,
13584 	.data = NULL,
13585 	.help_str = "set l2_decap",
13586 	.tokens = {
13587 		(void *)&cmd_set_l2_decap_set,
13588 		(void *)&cmd_set_l2_decap_l2_decap,
13589 		NULL,
13590 	},
13591 };
13592 
13593 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13594 	.f = cmd_set_l2_decap_parsed,
13595 	.data = NULL,
13596 	.help_str = "set l2_decap-with-vlan",
13597 	.tokens = {
13598 		(void *)&cmd_set_l2_decap_set,
13599 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13600 		NULL,
13601 	},
13602 };
13603 
13604 /** Set MPLSoGRE encapsulation details */
13605 struct cmd_set_mplsogre_encap_result {
13606 	cmdline_fixed_string_t set;
13607 	cmdline_fixed_string_t mplsogre;
13608 	cmdline_fixed_string_t pos_token;
13609 	cmdline_fixed_string_t ip_version;
13610 	uint32_t vlan_present:1;
13611 	uint32_t label;
13612 	cmdline_ipaddr_t ip_src;
13613 	cmdline_ipaddr_t ip_dst;
13614 	uint16_t tci;
13615 	struct rte_ether_addr eth_src;
13616 	struct rte_ether_addr eth_dst;
13617 };
13618 
13619 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13620 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13621 				 "set");
13622 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13623 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13624 				 "mplsogre_encap");
13625 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13626 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13627 				 mplsogre, "mplsogre_encap-with-vlan");
13628 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13629 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13630 				 pos_token, "ip-version");
13631 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13632 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13633 				 ip_version, "ipv4#ipv6");
13634 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13635 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13636 				 pos_token, "label");
13637 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13638 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13639 			      RTE_UINT32);
13640 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13641 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13642 				 pos_token, "ip-src");
13643 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13644 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13645 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13646 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13647 				 pos_token, "ip-dst");
13648 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13649 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13650 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13651 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13652 				 pos_token, "vlan-tci");
13653 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13654 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13655 			      RTE_UINT16);
13656 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13657 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13658 				 pos_token, "eth-src");
13659 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13660 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13661 				    eth_src);
13662 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13663 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13664 				 pos_token, "eth-dst");
13665 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13666 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13667 				    eth_dst);
13668 
13669 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13670 	__rte_unused struct cmdline *cl,
13671 	__rte_unused void *data)
13672 {
13673 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13674 	union {
13675 		uint32_t mplsogre_label;
13676 		uint8_t label[4];
13677 	} id = {
13678 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13679 	};
13680 
13681 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13682 		mplsogre_encap_conf.select_vlan = 0;
13683 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13684 		mplsogre_encap_conf.select_vlan = 1;
13685 	if (strcmp(res->ip_version, "ipv4") == 0)
13686 		mplsogre_encap_conf.select_ipv4 = 1;
13687 	else if (strcmp(res->ip_version, "ipv6") == 0)
13688 		mplsogre_encap_conf.select_ipv4 = 0;
13689 	else
13690 		return;
13691 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13692 	if (mplsogre_encap_conf.select_ipv4) {
13693 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13694 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13695 	} else {
13696 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13697 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13698 	}
13699 	if (mplsogre_encap_conf.select_vlan)
13700 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13701 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13702 		   RTE_ETHER_ADDR_LEN);
13703 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13704 		   RTE_ETHER_ADDR_LEN);
13705 }
13706 
13707 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13708 	.f = cmd_set_mplsogre_encap_parsed,
13709 	.data = NULL,
13710 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13711 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13712 		" eth-dst <eth-dst>",
13713 	.tokens = {
13714 		(void *)&cmd_set_mplsogre_encap_set,
13715 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13716 		(void *)&cmd_set_mplsogre_encap_ip_version,
13717 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13718 		(void *)&cmd_set_mplsogre_encap_label,
13719 		(void *)&cmd_set_mplsogre_encap_label_value,
13720 		(void *)&cmd_set_mplsogre_encap_ip_src,
13721 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13722 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13723 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13724 		(void *)&cmd_set_mplsogre_encap_eth_src,
13725 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13726 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13727 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13728 		NULL,
13729 	},
13730 };
13731 
13732 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13733 	.f = cmd_set_mplsogre_encap_parsed,
13734 	.data = NULL,
13735 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13736 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13737 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13738 	.tokens = {
13739 		(void *)&cmd_set_mplsogre_encap_set,
13740 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13741 		(void *)&cmd_set_mplsogre_encap_ip_version,
13742 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13743 		(void *)&cmd_set_mplsogre_encap_label,
13744 		(void *)&cmd_set_mplsogre_encap_label_value,
13745 		(void *)&cmd_set_mplsogre_encap_ip_src,
13746 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13747 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13748 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13749 		(void *)&cmd_set_mplsogre_encap_vlan,
13750 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13751 		(void *)&cmd_set_mplsogre_encap_eth_src,
13752 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13753 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13754 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13755 		NULL,
13756 	},
13757 };
13758 
13759 /** Set MPLSoGRE decapsulation details */
13760 struct cmd_set_mplsogre_decap_result {
13761 	cmdline_fixed_string_t set;
13762 	cmdline_fixed_string_t mplsogre;
13763 	cmdline_fixed_string_t pos_token;
13764 	cmdline_fixed_string_t ip_version;
13765 	uint32_t vlan_present:1;
13766 };
13767 
13768 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13769 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13770 				 "set");
13771 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13772 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13773 				 "mplsogre_decap");
13774 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13775 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13776 				 mplsogre, "mplsogre_decap-with-vlan");
13777 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13778 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13779 				 pos_token, "ip-version");
13780 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13781 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13782 				 ip_version, "ipv4#ipv6");
13783 
13784 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13785 	__rte_unused struct cmdline *cl,
13786 	__rte_unused void *data)
13787 {
13788 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13789 
13790 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13791 		mplsogre_decap_conf.select_vlan = 0;
13792 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13793 		mplsogre_decap_conf.select_vlan = 1;
13794 	if (strcmp(res->ip_version, "ipv4") == 0)
13795 		mplsogre_decap_conf.select_ipv4 = 1;
13796 	else if (strcmp(res->ip_version, "ipv6") == 0)
13797 		mplsogre_decap_conf.select_ipv4 = 0;
13798 }
13799 
13800 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13801 	.f = cmd_set_mplsogre_decap_parsed,
13802 	.data = NULL,
13803 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13804 	.tokens = {
13805 		(void *)&cmd_set_mplsogre_decap_set,
13806 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13807 		(void *)&cmd_set_mplsogre_decap_ip_version,
13808 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13809 		NULL,
13810 	},
13811 };
13812 
13813 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13814 	.f = cmd_set_mplsogre_decap_parsed,
13815 	.data = NULL,
13816 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13817 	.tokens = {
13818 		(void *)&cmd_set_mplsogre_decap_set,
13819 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13820 		(void *)&cmd_set_mplsogre_decap_ip_version,
13821 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13822 		NULL,
13823 	},
13824 };
13825 
13826 /** Set MPLSoUDP encapsulation details */
13827 struct cmd_set_mplsoudp_encap_result {
13828 	cmdline_fixed_string_t set;
13829 	cmdline_fixed_string_t mplsoudp;
13830 	cmdline_fixed_string_t pos_token;
13831 	cmdline_fixed_string_t ip_version;
13832 	uint32_t vlan_present:1;
13833 	uint32_t label;
13834 	uint16_t udp_src;
13835 	uint16_t udp_dst;
13836 	cmdline_ipaddr_t ip_src;
13837 	cmdline_ipaddr_t ip_dst;
13838 	uint16_t tci;
13839 	struct rte_ether_addr eth_src;
13840 	struct rte_ether_addr eth_dst;
13841 };
13842 
13843 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13844 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13845 				 "set");
13846 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13847 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13848 				 "mplsoudp_encap");
13849 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13850 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13851 				 mplsoudp, "mplsoudp_encap-with-vlan");
13852 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13853 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13854 				 pos_token, "ip-version");
13855 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13856 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13857 				 ip_version, "ipv4#ipv6");
13858 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13859 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13860 				 pos_token, "label");
13861 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13862 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13863 			      RTE_UINT32);
13864 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13865 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13866 				 pos_token, "udp-src");
13867 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13868 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13869 			      RTE_UINT16);
13870 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13871 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13872 				 pos_token, "udp-dst");
13873 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13874 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13875 			      RTE_UINT16);
13876 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13877 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13878 				 pos_token, "ip-src");
13879 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13880 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13881 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13882 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13883 				 pos_token, "ip-dst");
13884 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13885 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13886 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13887 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13888 				 pos_token, "vlan-tci");
13889 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13890 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13891 			      RTE_UINT16);
13892 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13893 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13894 				 pos_token, "eth-src");
13895 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13896 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13897 				    eth_src);
13898 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13899 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13900 				 pos_token, "eth-dst");
13901 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13902 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13903 				    eth_dst);
13904 
13905 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13906 	__rte_unused struct cmdline *cl,
13907 	__rte_unused void *data)
13908 {
13909 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13910 	union {
13911 		uint32_t mplsoudp_label;
13912 		uint8_t label[4];
13913 	} id = {
13914 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13915 	};
13916 
13917 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13918 		mplsoudp_encap_conf.select_vlan = 0;
13919 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13920 		mplsoudp_encap_conf.select_vlan = 1;
13921 	if (strcmp(res->ip_version, "ipv4") == 0)
13922 		mplsoudp_encap_conf.select_ipv4 = 1;
13923 	else if (strcmp(res->ip_version, "ipv6") == 0)
13924 		mplsoudp_encap_conf.select_ipv4 = 0;
13925 	else
13926 		return;
13927 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13928 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13929 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13930 	if (mplsoudp_encap_conf.select_ipv4) {
13931 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13932 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13933 	} else {
13934 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13935 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13936 	}
13937 	if (mplsoudp_encap_conf.select_vlan)
13938 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13939 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13940 		   RTE_ETHER_ADDR_LEN);
13941 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13942 		   RTE_ETHER_ADDR_LEN);
13943 }
13944 
13945 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13946 	.f = cmd_set_mplsoudp_encap_parsed,
13947 	.data = NULL,
13948 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13949 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13950 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13951 	.tokens = {
13952 		(void *)&cmd_set_mplsoudp_encap_set,
13953 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13954 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13955 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13956 		(void *)&cmd_set_mplsoudp_encap_label,
13957 		(void *)&cmd_set_mplsoudp_encap_label_value,
13958 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13959 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13960 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13961 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13962 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13963 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13964 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13965 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13966 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13967 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13968 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13969 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13970 		NULL,
13971 	},
13972 };
13973 
13974 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13975 	.f = cmd_set_mplsoudp_encap_parsed,
13976 	.data = NULL,
13977 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13978 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13979 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13980 		" eth-src <eth-src> eth-dst <eth-dst>",
13981 	.tokens = {
13982 		(void *)&cmd_set_mplsoudp_encap_set,
13983 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13984 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13985 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13986 		(void *)&cmd_set_mplsoudp_encap_label,
13987 		(void *)&cmd_set_mplsoudp_encap_label_value,
13988 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13989 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13990 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13991 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13992 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13993 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13994 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13995 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13996 		(void *)&cmd_set_mplsoudp_encap_vlan,
13997 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13998 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13999 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
14000 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
14001 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14002 		NULL,
14003 	},
14004 };
14005 
14006 /** Set MPLSoUDP decapsulation details */
14007 struct cmd_set_mplsoudp_decap_result {
14008 	cmdline_fixed_string_t set;
14009 	cmdline_fixed_string_t mplsoudp;
14010 	cmdline_fixed_string_t pos_token;
14011 	cmdline_fixed_string_t ip_version;
14012 	uint32_t vlan_present:1;
14013 };
14014 
14015 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14016 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14017 				 "set");
14018 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14019 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14020 				 "mplsoudp_decap");
14021 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14022 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14023 				 mplsoudp, "mplsoudp_decap-with-vlan");
14024 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14025 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14026 				 pos_token, "ip-version");
14027 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14028 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14029 				 ip_version, "ipv4#ipv6");
14030 
14031 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14032 	__rte_unused struct cmdline *cl,
14033 	__rte_unused void *data)
14034 {
14035 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14036 
14037 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14038 		mplsoudp_decap_conf.select_vlan = 0;
14039 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14040 		mplsoudp_decap_conf.select_vlan = 1;
14041 	if (strcmp(res->ip_version, "ipv4") == 0)
14042 		mplsoudp_decap_conf.select_ipv4 = 1;
14043 	else if (strcmp(res->ip_version, "ipv6") == 0)
14044 		mplsoudp_decap_conf.select_ipv4 = 0;
14045 }
14046 
14047 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14048 	.f = cmd_set_mplsoudp_decap_parsed,
14049 	.data = NULL,
14050 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14051 	.tokens = {
14052 		(void *)&cmd_set_mplsoudp_decap_set,
14053 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14054 		(void *)&cmd_set_mplsoudp_decap_ip_version,
14055 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
14056 		NULL,
14057 	},
14058 };
14059 
14060 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14061 	.f = cmd_set_mplsoudp_decap_parsed,
14062 	.data = NULL,
14063 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14064 	.tokens = {
14065 		(void *)&cmd_set_mplsoudp_decap_set,
14066 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14067 		(void *)&cmd_set_mplsoudp_decap_ip_version,
14068 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
14069 		NULL,
14070 	},
14071 };
14072 
14073 /** Set connection tracking object common details */
14074 struct cmd_set_conntrack_common_result {
14075 	cmdline_fixed_string_t set;
14076 	cmdline_fixed_string_t conntrack;
14077 	cmdline_fixed_string_t common;
14078 	cmdline_fixed_string_t peer;
14079 	cmdline_fixed_string_t is_orig;
14080 	cmdline_fixed_string_t enable;
14081 	cmdline_fixed_string_t live;
14082 	cmdline_fixed_string_t sack;
14083 	cmdline_fixed_string_t cack;
14084 	cmdline_fixed_string_t last_dir;
14085 	cmdline_fixed_string_t liberal;
14086 	cmdline_fixed_string_t state;
14087 	cmdline_fixed_string_t max_ack_win;
14088 	cmdline_fixed_string_t retrans;
14089 	cmdline_fixed_string_t last_win;
14090 	cmdline_fixed_string_t last_seq;
14091 	cmdline_fixed_string_t last_ack;
14092 	cmdline_fixed_string_t last_end;
14093 	cmdline_fixed_string_t last_index;
14094 	uint8_t stat;
14095 	uint8_t factor;
14096 	uint16_t peer_port;
14097 	uint32_t is_original;
14098 	uint32_t en;
14099 	uint32_t is_live;
14100 	uint32_t s_ack;
14101 	uint32_t c_ack;
14102 	uint32_t ld;
14103 	uint32_t lb;
14104 	uint8_t re_num;
14105 	uint8_t li;
14106 	uint16_t lw;
14107 	uint32_t ls;
14108 	uint32_t la;
14109 	uint32_t le;
14110 };
14111 
14112 cmdline_parse_token_string_t cmd_set_conntrack_set =
14113 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14114 				 set, "set");
14115 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14116 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14117 				 conntrack, "conntrack");
14118 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14119 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14120 				 common, "com");
14121 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14122 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14123 				 peer, "peer");
14124 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14125 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14126 			      peer_port, RTE_UINT16);
14127 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14128 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14129 				 is_orig, "is_orig");
14130 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14131 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14132 			      is_original, RTE_UINT32);
14133 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14134 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14135 				 enable, "enable");
14136 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14137 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14138 			      en, RTE_UINT32);
14139 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14140 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14141 				 live, "live");
14142 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14143 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14144 			      is_live, RTE_UINT32);
14145 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14146 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14147 				 sack, "sack");
14148 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14149 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14150 			      s_ack, RTE_UINT32);
14151 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14152 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14153 				 cack, "cack");
14154 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14155 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14156 			      c_ack, RTE_UINT32);
14157 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14158 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14159 				 last_dir, "last_dir");
14160 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14161 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14162 			      ld, RTE_UINT32);
14163 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14164 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14165 				 liberal, "liberal");
14166 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14167 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14168 			      lb, RTE_UINT32);
14169 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14170 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14171 				 state, "state");
14172 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14173 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14174 			      stat, RTE_UINT8);
14175 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14176 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14177 				 max_ack_win, "max_ack_win");
14178 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14179 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14180 			      factor, RTE_UINT8);
14181 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14182 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14183 				 retrans, "r_lim");
14184 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14185 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14186 			      re_num, RTE_UINT8);
14187 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14188 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14189 				 last_win, "last_win");
14190 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14191 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14192 			      lw, RTE_UINT16);
14193 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14194 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14195 				 last_seq, "last_seq");
14196 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14197 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14198 			      ls, RTE_UINT32);
14199 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14200 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14201 				 last_ack, "last_ack");
14202 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14203 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14204 			      la, RTE_UINT32);
14205 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14206 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14207 				 last_end, "last_end");
14208 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14209 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14210 			      le, RTE_UINT32);
14211 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14212 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14213 				 last_index, "last_index");
14214 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14215 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14216 			      li, RTE_UINT8);
14217 
14218 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14219 	__rte_unused struct cmdline *cl,
14220 	__rte_unused void *data)
14221 {
14222 	struct cmd_set_conntrack_common_result *res = parsed_result;
14223 
14224 	/* No need to swap to big endian. */
14225 	conntrack_context.peer_port = res->peer_port;
14226 	conntrack_context.is_original_dir = res->is_original;
14227 	conntrack_context.enable = res->en;
14228 	conntrack_context.live_connection = res->is_live;
14229 	conntrack_context.selective_ack = res->s_ack;
14230 	conntrack_context.challenge_ack_passed = res->c_ack;
14231 	conntrack_context.last_direction = res->ld;
14232 	conntrack_context.liberal_mode = res->lb;
14233 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14234 	conntrack_context.max_ack_window = res->factor;
14235 	conntrack_context.retransmission_limit = res->re_num;
14236 	conntrack_context.last_window = res->lw;
14237 	conntrack_context.last_index =
14238 		(enum rte_flow_conntrack_tcp_last_index)res->li;
14239 	conntrack_context.last_seq = res->ls;
14240 	conntrack_context.last_ack = res->la;
14241 	conntrack_context.last_end = res->le;
14242 }
14243 
14244 cmdline_parse_inst_t cmd_set_conntrack_common = {
14245 	.f = cmd_set_conntrack_common_parsed,
14246 	.data = NULL,
14247 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14248 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14249 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14250 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14251 		" last_index <flag>",
14252 	.tokens = {
14253 		(void *)&cmd_set_conntrack_set,
14254 		(void *)&cmd_set_conntrack_conntrack,
14255 		(void *)&cmd_set_conntrack_common_com,
14256 		(void *)&cmd_set_conntrack_common_peer,
14257 		(void *)&cmd_set_conntrack_common_peer_value,
14258 		(void *)&cmd_set_conntrack_common_is_orig,
14259 		(void *)&cmd_set_conntrack_common_is_orig_value,
14260 		(void *)&cmd_set_conntrack_common_enable,
14261 		(void *)&cmd_set_conntrack_common_enable_value,
14262 		(void *)&cmd_set_conntrack_common_live,
14263 		(void *)&cmd_set_conntrack_common_live_value,
14264 		(void *)&cmd_set_conntrack_common_sack,
14265 		(void *)&cmd_set_conntrack_common_sack_value,
14266 		(void *)&cmd_set_conntrack_common_cack,
14267 		(void *)&cmd_set_conntrack_common_cack_value,
14268 		(void *)&cmd_set_conntrack_common_last_dir,
14269 		(void *)&cmd_set_conntrack_common_last_dir_value,
14270 		(void *)&cmd_set_conntrack_common_liberal,
14271 		(void *)&cmd_set_conntrack_common_liberal_value,
14272 		(void *)&cmd_set_conntrack_common_state,
14273 		(void *)&cmd_set_conntrack_common_state_value,
14274 		(void *)&cmd_set_conntrack_common_max_ackwin,
14275 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
14276 		(void *)&cmd_set_conntrack_common_retrans,
14277 		(void *)&cmd_set_conntrack_common_retrans_value,
14278 		(void *)&cmd_set_conntrack_common_last_win,
14279 		(void *)&cmd_set_conntrack_common_last_win_value,
14280 		(void *)&cmd_set_conntrack_common_last_seq,
14281 		(void *)&cmd_set_conntrack_common_last_seq_value,
14282 		(void *)&cmd_set_conntrack_common_last_ack,
14283 		(void *)&cmd_set_conntrack_common_last_ack_value,
14284 		(void *)&cmd_set_conntrack_common_last_end,
14285 		(void *)&cmd_set_conntrack_common_last_end_value,
14286 		(void *)&cmd_set_conntrack_common_last_index,
14287 		(void *)&cmd_set_conntrack_common_last_index_value,
14288 		NULL,
14289 	},
14290 };
14291 
14292 /** Set connection tracking object both directions' details */
14293 struct cmd_set_conntrack_dir_result {
14294 	cmdline_fixed_string_t set;
14295 	cmdline_fixed_string_t conntrack;
14296 	cmdline_fixed_string_t dir;
14297 	cmdline_fixed_string_t scale;
14298 	cmdline_fixed_string_t fin;
14299 	cmdline_fixed_string_t ack_seen;
14300 	cmdline_fixed_string_t unack;
14301 	cmdline_fixed_string_t sent_end;
14302 	cmdline_fixed_string_t reply_end;
14303 	cmdline_fixed_string_t max_win;
14304 	cmdline_fixed_string_t max_ack;
14305 	uint32_t factor;
14306 	uint32_t f;
14307 	uint32_t as;
14308 	uint32_t un;
14309 	uint32_t se;
14310 	uint32_t re;
14311 	uint32_t mw;
14312 	uint32_t ma;
14313 };
14314 
14315 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14316 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14317 				 set, "set");
14318 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14319 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14320 				 conntrack, "conntrack");
14321 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14322 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14323 				 dir, "orig#rply");
14324 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14325 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14326 				 scale, "scale");
14327 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14328 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14329 			      factor, RTE_UINT32);
14330 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14331 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14332 				 fin, "fin");
14333 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14334 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14335 			      f, RTE_UINT32);
14336 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14337 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14338 				 ack_seen, "acked");
14339 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14340 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14341 			      as, RTE_UINT32);
14342 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14343 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14344 				 unack, "unack_data");
14345 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14346 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14347 			      un, RTE_UINT32);
14348 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14349 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14350 				 sent_end, "sent_end");
14351 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14352 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14353 			      se, RTE_UINT32);
14354 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14355 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14356 				 reply_end, "reply_end");
14357 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14358 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14359 			      re, RTE_UINT32);
14360 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14361 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14362 				 max_win, "max_win");
14363 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14364 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14365 			      mw, RTE_UINT32);
14366 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14367 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14368 				 max_ack, "max_ack");
14369 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14370 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14371 			      ma, RTE_UINT32);
14372 
14373 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14374 	__rte_unused struct cmdline *cl,
14375 	__rte_unused void *data)
14376 {
14377 	struct cmd_set_conntrack_dir_result *res = parsed_result;
14378 	struct rte_flow_tcp_dir_param *dir = NULL;
14379 
14380 	if (strcmp(res->dir, "orig") == 0)
14381 		dir = &conntrack_context.original_dir;
14382 	else if (strcmp(res->dir, "rply") == 0)
14383 		dir = &conntrack_context.reply_dir;
14384 	else
14385 		return;
14386 	dir->scale = res->factor;
14387 	dir->close_initiated = res->f;
14388 	dir->last_ack_seen = res->as;
14389 	dir->data_unacked = res->un;
14390 	dir->sent_end = res->se;
14391 	dir->reply_end = res->re;
14392 	dir->max_ack = res->ma;
14393 	dir->max_win = res->mw;
14394 }
14395 
14396 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14397 	.f = cmd_set_conntrack_dir_parsed,
14398 	.data = NULL,
14399 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14400 		    " acked <seen> unack_data <unack> sent_end <sent>"
14401 		    " reply_end <reply> max_win <win> max_ack <ack>",
14402 	.tokens = {
14403 		(void *)&cmd_set_conntrack_set,
14404 		(void *)&cmd_set_conntrack_conntrack,
14405 		(void *)&cmd_set_conntrack_dir_dir,
14406 		(void *)&cmd_set_conntrack_dir_scale,
14407 		(void *)&cmd_set_conntrack_dir_scale_value,
14408 		(void *)&cmd_set_conntrack_dir_fin,
14409 		(void *)&cmd_set_conntrack_dir_fin_value,
14410 		(void *)&cmd_set_conntrack_dir_ack,
14411 		(void *)&cmd_set_conntrack_dir_ack_value,
14412 		(void *)&cmd_set_conntrack_dir_unack_data,
14413 		(void *)&cmd_set_conntrack_dir_unack_data_value,
14414 		(void *)&cmd_set_conntrack_dir_sent_end,
14415 		(void *)&cmd_set_conntrack_dir_sent_end_value,
14416 		(void *)&cmd_set_conntrack_dir_reply_end,
14417 		(void *)&cmd_set_conntrack_dir_reply_end_value,
14418 		(void *)&cmd_set_conntrack_dir_max_win,
14419 		(void *)&cmd_set_conntrack_dir_max_win_value,
14420 		(void *)&cmd_set_conntrack_dir_max_ack,
14421 		(void *)&cmd_set_conntrack_dir_max_ack_value,
14422 		NULL,
14423 	},
14424 };
14425 
14426 /* Strict link priority scheduling mode setting */
14427 static void
14428 cmd_strict_link_prio_parsed(
14429 	void *parsed_result,
14430 	__rte_unused struct cmdline *cl,
14431 	__rte_unused void *data)
14432 {
14433 	struct cmd_vf_tc_bw_result *res = parsed_result;
14434 	int ret = -ENOTSUP;
14435 
14436 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14437 		return;
14438 
14439 #ifdef RTE_NET_I40E
14440 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14441 #endif
14442 
14443 	switch (ret) {
14444 	case 0:
14445 		break;
14446 	case -EINVAL:
14447 		fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14448 		break;
14449 	case -ENODEV:
14450 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
14451 		break;
14452 	case -ENOTSUP:
14453 		fprintf(stderr, "function not implemented\n");
14454 		break;
14455 	default:
14456 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14457 	}
14458 }
14459 
14460 cmdline_parse_inst_t cmd_strict_link_prio = {
14461 	.f = cmd_strict_link_prio_parsed,
14462 	.data = NULL,
14463 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14464 	.tokens = {
14465 		(void *)&cmd_vf_tc_bw_set,
14466 		(void *)&cmd_vf_tc_bw_tx,
14467 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14468 		(void *)&cmd_vf_tc_bw_port_id,
14469 		(void *)&cmd_vf_tc_bw_tc_map,
14470 		NULL,
14471 	},
14472 };
14473 
14474 /* Load dynamic device personalization*/
14475 struct cmd_ddp_add_result {
14476 	cmdline_fixed_string_t ddp;
14477 	cmdline_fixed_string_t add;
14478 	portid_t port_id;
14479 	char filepath[];
14480 };
14481 
14482 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14483 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14484 cmdline_parse_token_string_t cmd_ddp_add_add =
14485 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14486 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14487 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14488 		RTE_UINT16);
14489 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14490 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14491 
14492 static void
14493 cmd_ddp_add_parsed(
14494 	void *parsed_result,
14495 	__rte_unused struct cmdline *cl,
14496 	__rte_unused void *data)
14497 {
14498 	struct cmd_ddp_add_result *res = parsed_result;
14499 	uint8_t *buff;
14500 	uint32_t size;
14501 	char *filepath;
14502 	char *file_fld[2];
14503 	int file_num;
14504 	int ret = -ENOTSUP;
14505 
14506 	if (!all_ports_stopped()) {
14507 		fprintf(stderr, "Please stop all ports first\n");
14508 		return;
14509 	}
14510 
14511 	filepath = strdup(res->filepath);
14512 	if (filepath == NULL) {
14513 		fprintf(stderr, "Failed to allocate memory\n");
14514 		return;
14515 	}
14516 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14517 
14518 	buff = open_file(file_fld[0], &size);
14519 	if (!buff) {
14520 		free((void *)filepath);
14521 		return;
14522 	}
14523 
14524 #ifdef RTE_NET_I40E
14525 	if (ret == -ENOTSUP)
14526 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14527 					       buff, size,
14528 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14529 #endif
14530 
14531 	if (ret == -EEXIST)
14532 		fprintf(stderr, "Profile has already existed.\n");
14533 	else if (ret < 0)
14534 		fprintf(stderr, "Failed to load profile.\n");
14535 	else if (file_num == 2)
14536 		save_file(file_fld[1], buff, size);
14537 
14538 	close_file(buff);
14539 	free((void *)filepath);
14540 }
14541 
14542 cmdline_parse_inst_t cmd_ddp_add = {
14543 	.f = cmd_ddp_add_parsed,
14544 	.data = NULL,
14545 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14546 	.tokens = {
14547 		(void *)&cmd_ddp_add_ddp,
14548 		(void *)&cmd_ddp_add_add,
14549 		(void *)&cmd_ddp_add_port_id,
14550 		(void *)&cmd_ddp_add_filepath,
14551 		NULL,
14552 	},
14553 };
14554 
14555 /* Delete dynamic device personalization*/
14556 struct cmd_ddp_del_result {
14557 	cmdline_fixed_string_t ddp;
14558 	cmdline_fixed_string_t del;
14559 	portid_t port_id;
14560 	char filepath[];
14561 };
14562 
14563 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14564 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14565 cmdline_parse_token_string_t cmd_ddp_del_del =
14566 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14567 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14568 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14569 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14570 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14571 
14572 static void
14573 cmd_ddp_del_parsed(
14574 	void *parsed_result,
14575 	__rte_unused struct cmdline *cl,
14576 	__rte_unused void *data)
14577 {
14578 	struct cmd_ddp_del_result *res = parsed_result;
14579 	uint8_t *buff;
14580 	uint32_t size;
14581 	int ret = -ENOTSUP;
14582 
14583 	if (!all_ports_stopped()) {
14584 		fprintf(stderr, "Please stop all ports first\n");
14585 		return;
14586 	}
14587 
14588 	buff = open_file(res->filepath, &size);
14589 	if (!buff)
14590 		return;
14591 
14592 #ifdef RTE_NET_I40E
14593 	if (ret == -ENOTSUP)
14594 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14595 					       buff, size,
14596 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14597 #endif
14598 
14599 	if (ret == -EACCES)
14600 		fprintf(stderr, "Profile does not exist.\n");
14601 	else if (ret < 0)
14602 		fprintf(stderr, "Failed to delete profile.\n");
14603 
14604 	close_file(buff);
14605 }
14606 
14607 cmdline_parse_inst_t cmd_ddp_del = {
14608 	.f = cmd_ddp_del_parsed,
14609 	.data = NULL,
14610 	.help_str = "ddp del <port_id> <backup_profile_path>",
14611 	.tokens = {
14612 		(void *)&cmd_ddp_del_ddp,
14613 		(void *)&cmd_ddp_del_del,
14614 		(void *)&cmd_ddp_del_port_id,
14615 		(void *)&cmd_ddp_del_filepath,
14616 		NULL,
14617 	},
14618 };
14619 
14620 /* Get dynamic device personalization profile info */
14621 struct cmd_ddp_info_result {
14622 	cmdline_fixed_string_t ddp;
14623 	cmdline_fixed_string_t get;
14624 	cmdline_fixed_string_t info;
14625 	char filepath[];
14626 };
14627 
14628 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14629 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14630 cmdline_parse_token_string_t cmd_ddp_info_get =
14631 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14632 cmdline_parse_token_string_t cmd_ddp_info_info =
14633 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14634 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14635 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14636 
14637 static void
14638 cmd_ddp_info_parsed(
14639 	void *parsed_result,
14640 	__rte_unused struct cmdline *cl,
14641 	__rte_unused void *data)
14642 {
14643 	struct cmd_ddp_info_result *res = parsed_result;
14644 	uint8_t *pkg;
14645 	uint32_t pkg_size;
14646 	int ret = -ENOTSUP;
14647 #ifdef RTE_NET_I40E
14648 	uint32_t i, j, n;
14649 	uint8_t *buff;
14650 	uint32_t buff_size = 0;
14651 	struct rte_pmd_i40e_profile_info info;
14652 	uint32_t dev_num = 0;
14653 	struct rte_pmd_i40e_ddp_device_id *devs;
14654 	uint32_t proto_num = 0;
14655 	struct rte_pmd_i40e_proto_info *proto = NULL;
14656 	uint32_t pctype_num = 0;
14657 	struct rte_pmd_i40e_ptype_info *pctype;
14658 	uint32_t ptype_num = 0;
14659 	struct rte_pmd_i40e_ptype_info *ptype;
14660 	uint8_t proto_id;
14661 
14662 #endif
14663 
14664 	pkg = open_file(res->filepath, &pkg_size);
14665 	if (!pkg)
14666 		return;
14667 
14668 #ifdef RTE_NET_I40E
14669 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14670 				(uint8_t *)&info, sizeof(info),
14671 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14672 	if (!ret) {
14673 		printf("Global Track id:       0x%x\n", info.track_id);
14674 		printf("Global Version:        %d.%d.%d.%d\n",
14675 			info.version.major,
14676 			info.version.minor,
14677 			info.version.update,
14678 			info.version.draft);
14679 		printf("Global Package name:   %s\n\n", info.name);
14680 	}
14681 
14682 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14683 				(uint8_t *)&info, sizeof(info),
14684 				RTE_PMD_I40E_PKG_INFO_HEADER);
14685 	if (!ret) {
14686 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14687 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14688 			info.version.major,
14689 			info.version.minor,
14690 			info.version.update,
14691 			info.version.draft);
14692 		printf("i40e Profile name:     %s\n\n", info.name);
14693 	}
14694 
14695 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14696 				(uint8_t *)&buff_size, sizeof(buff_size),
14697 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14698 	if (!ret && buff_size) {
14699 		buff = (uint8_t *)malloc(buff_size);
14700 		if (buff) {
14701 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14702 						buff, buff_size,
14703 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14704 			if (!ret)
14705 				printf("Package Notes:\n%s\n\n", buff);
14706 			free(buff);
14707 		}
14708 	}
14709 
14710 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14711 				(uint8_t *)&dev_num, sizeof(dev_num),
14712 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14713 	if (!ret && dev_num) {
14714 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14715 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14716 		if (devs) {
14717 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14718 						(uint8_t *)devs, buff_size,
14719 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14720 			if (!ret) {
14721 				printf("List of supported devices:\n");
14722 				for (i = 0; i < dev_num; i++) {
14723 					printf("  %04X:%04X %04X:%04X\n",
14724 						devs[i].vendor_dev_id >> 16,
14725 						devs[i].vendor_dev_id & 0xFFFF,
14726 						devs[i].sub_vendor_dev_id >> 16,
14727 						devs[i].sub_vendor_dev_id & 0xFFFF);
14728 				}
14729 				printf("\n");
14730 			}
14731 			free(devs);
14732 		}
14733 	}
14734 
14735 	/* get information about protocols and packet types */
14736 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14737 		(uint8_t *)&proto_num, sizeof(proto_num),
14738 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14739 	if (ret || !proto_num)
14740 		goto no_print_return;
14741 
14742 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14743 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14744 	if (!proto)
14745 		goto no_print_return;
14746 
14747 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14748 					buff_size,
14749 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14750 	if (!ret) {
14751 		printf("List of used protocols:\n");
14752 		for (i = 0; i < proto_num; i++)
14753 			printf("  %2u: %s\n", proto[i].proto_id,
14754 			       proto[i].name);
14755 		printf("\n");
14756 	}
14757 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14758 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14759 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14760 	if (ret || !pctype_num)
14761 		goto no_print_pctypes;
14762 
14763 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14764 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14765 	if (!pctype)
14766 		goto no_print_pctypes;
14767 
14768 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14769 					buff_size,
14770 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14771 	if (ret) {
14772 		free(pctype);
14773 		goto no_print_pctypes;
14774 	}
14775 
14776 	printf("List of defined packet classification types:\n");
14777 	for (i = 0; i < pctype_num; i++) {
14778 		printf("  %2u:", pctype[i].ptype_id);
14779 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14780 			proto_id = pctype[i].protocols[j];
14781 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14782 				for (n = 0; n < proto_num; n++) {
14783 					if (proto[n].proto_id == proto_id) {
14784 						printf(" %s", proto[n].name);
14785 						break;
14786 					}
14787 				}
14788 			}
14789 		}
14790 		printf("\n");
14791 	}
14792 	printf("\n");
14793 	free(pctype);
14794 
14795 no_print_pctypes:
14796 
14797 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14798 					sizeof(ptype_num),
14799 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14800 	if (ret || !ptype_num)
14801 		goto no_print_return;
14802 
14803 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14804 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14805 	if (!ptype)
14806 		goto no_print_return;
14807 
14808 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14809 					buff_size,
14810 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14811 	if (ret) {
14812 		free(ptype);
14813 		goto no_print_return;
14814 	}
14815 	printf("List of defined packet types:\n");
14816 	for (i = 0; i < ptype_num; i++) {
14817 		printf("  %2u:", ptype[i].ptype_id);
14818 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14819 			proto_id = ptype[i].protocols[j];
14820 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14821 				for (n = 0; n < proto_num; n++) {
14822 					if (proto[n].proto_id == proto_id) {
14823 						printf(" %s", proto[n].name);
14824 						break;
14825 					}
14826 				}
14827 			}
14828 		}
14829 		printf("\n");
14830 	}
14831 	free(ptype);
14832 	printf("\n");
14833 
14834 	ret = 0;
14835 no_print_return:
14836 	free(proto);
14837 #endif
14838 	if (ret == -ENOTSUP)
14839 		fprintf(stderr, "Function not supported in PMD\n");
14840 	close_file(pkg);
14841 }
14842 
14843 cmdline_parse_inst_t cmd_ddp_get_info = {
14844 	.f = cmd_ddp_info_parsed,
14845 	.data = NULL,
14846 	.help_str = "ddp get info <profile_path>",
14847 	.tokens = {
14848 		(void *)&cmd_ddp_info_ddp,
14849 		(void *)&cmd_ddp_info_get,
14850 		(void *)&cmd_ddp_info_info,
14851 		(void *)&cmd_ddp_info_filepath,
14852 		NULL,
14853 	},
14854 };
14855 
14856 /* Get dynamic device personalization profile info list*/
14857 #define PROFILE_INFO_SIZE 48
14858 #define MAX_PROFILE_NUM 16
14859 
14860 struct cmd_ddp_get_list_result {
14861 	cmdline_fixed_string_t ddp;
14862 	cmdline_fixed_string_t get;
14863 	cmdline_fixed_string_t list;
14864 	portid_t port_id;
14865 };
14866 
14867 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14868 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14869 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14870 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14871 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14872 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14873 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14874 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14875 		RTE_UINT16);
14876 
14877 static void
14878 cmd_ddp_get_list_parsed(
14879 	__rte_unused void *parsed_result,
14880 	__rte_unused struct cmdline *cl,
14881 	__rte_unused void *data)
14882 {
14883 #ifdef RTE_NET_I40E
14884 	struct cmd_ddp_get_list_result *res = parsed_result;
14885 	struct rte_pmd_i40e_profile_list *p_list;
14886 	struct rte_pmd_i40e_profile_info *p_info;
14887 	uint32_t p_num;
14888 	uint32_t size;
14889 	uint32_t i;
14890 #endif
14891 	int ret = -ENOTSUP;
14892 
14893 #ifdef RTE_NET_I40E
14894 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14895 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14896 	if (!p_list) {
14897 		fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14898 		return;
14899 	}
14900 
14901 	if (ret == -ENOTSUP)
14902 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14903 						(uint8_t *)p_list, size);
14904 
14905 	if (!ret) {
14906 		p_num = p_list->p_count;
14907 		printf("Profile number is: %d\n\n", p_num);
14908 
14909 		for (i = 0; i < p_num; i++) {
14910 			p_info = &p_list->p_info[i];
14911 			printf("Profile %d:\n", i);
14912 			printf("Track id:     0x%x\n", p_info->track_id);
14913 			printf("Version:      %d.%d.%d.%d\n",
14914 			       p_info->version.major,
14915 			       p_info->version.minor,
14916 			       p_info->version.update,
14917 			       p_info->version.draft);
14918 			printf("Profile name: %s\n\n", p_info->name);
14919 		}
14920 	}
14921 
14922 	free(p_list);
14923 #endif
14924 
14925 	if (ret < 0)
14926 		fprintf(stderr, "Failed to get ddp list\n");
14927 }
14928 
14929 cmdline_parse_inst_t cmd_ddp_get_list = {
14930 	.f = cmd_ddp_get_list_parsed,
14931 	.data = NULL,
14932 	.help_str = "ddp get list <port_id>",
14933 	.tokens = {
14934 		(void *)&cmd_ddp_get_list_ddp,
14935 		(void *)&cmd_ddp_get_list_get,
14936 		(void *)&cmd_ddp_get_list_list,
14937 		(void *)&cmd_ddp_get_list_port_id,
14938 		NULL,
14939 	},
14940 };
14941 
14942 /* Configure input set */
14943 struct cmd_cfg_input_set_result {
14944 	cmdline_fixed_string_t port;
14945 	cmdline_fixed_string_t cfg;
14946 	portid_t port_id;
14947 	cmdline_fixed_string_t pctype;
14948 	uint8_t pctype_id;
14949 	cmdline_fixed_string_t inset_type;
14950 	cmdline_fixed_string_t opt;
14951 	cmdline_fixed_string_t field;
14952 	uint8_t field_idx;
14953 };
14954 
14955 static void
14956 cmd_cfg_input_set_parsed(
14957 	__rte_unused void *parsed_result,
14958 	__rte_unused struct cmdline *cl,
14959 	__rte_unused void *data)
14960 {
14961 #ifdef RTE_NET_I40E
14962 	struct cmd_cfg_input_set_result *res = parsed_result;
14963 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14964 	struct rte_pmd_i40e_inset inset;
14965 #endif
14966 	int ret = -ENOTSUP;
14967 
14968 	if (!all_ports_stopped()) {
14969 		fprintf(stderr, "Please stop all ports first\n");
14970 		return;
14971 	}
14972 
14973 #ifdef RTE_NET_I40E
14974 	if (!strcmp(res->inset_type, "hash_inset"))
14975 		inset_type = INSET_HASH;
14976 	else if (!strcmp(res->inset_type, "fdir_inset"))
14977 		inset_type = INSET_FDIR;
14978 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14979 		inset_type = INSET_FDIR_FLX;
14980 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14981 				     &inset, inset_type);
14982 	if (ret) {
14983 		fprintf(stderr, "Failed to get input set.\n");
14984 		return;
14985 	}
14986 
14987 	if (!strcmp(res->opt, "get")) {
14988 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14989 						   res->field_idx);
14990 		if (ret)
14991 			printf("Field index %d is enabled.\n", res->field_idx);
14992 		else
14993 			printf("Field index %d is disabled.\n", res->field_idx);
14994 		return;
14995 	} else if (!strcmp(res->opt, "set"))
14996 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14997 						   res->field_idx);
14998 	else if (!strcmp(res->opt, "clear"))
14999 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15000 						     res->field_idx);
15001 	if (ret) {
15002 		fprintf(stderr, "Failed to configure input set field.\n");
15003 		return;
15004 	}
15005 
15006 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15007 				     &inset, inset_type);
15008 	if (ret) {
15009 		fprintf(stderr, "Failed to set input set.\n");
15010 		return;
15011 	}
15012 #endif
15013 
15014 	if (ret == -ENOTSUP)
15015 		fprintf(stderr, "Function not supported\n");
15016 }
15017 
15018 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15019 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15020 				 port, "port");
15021 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15022 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15023 				 cfg, "config");
15024 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15025 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15026 			      port_id, RTE_UINT16);
15027 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15028 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15029 				 pctype, "pctype");
15030 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15031 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15032 			      pctype_id, RTE_UINT8);
15033 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15034 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15035 				 inset_type,
15036 				 "hash_inset#fdir_inset#fdir_flx_inset");
15037 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15038 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15039 				 opt, "get#set#clear");
15040 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15041 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15042 				 field, "field");
15043 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15044 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15045 			      field_idx, RTE_UINT8);
15046 
15047 cmdline_parse_inst_t cmd_cfg_input_set = {
15048 	.f = cmd_cfg_input_set_parsed,
15049 	.data = NULL,
15050 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15051 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15052 	.tokens = {
15053 		(void *)&cmd_cfg_input_set_port,
15054 		(void *)&cmd_cfg_input_set_cfg,
15055 		(void *)&cmd_cfg_input_set_port_id,
15056 		(void *)&cmd_cfg_input_set_pctype,
15057 		(void *)&cmd_cfg_input_set_pctype_id,
15058 		(void *)&cmd_cfg_input_set_inset_type,
15059 		(void *)&cmd_cfg_input_set_opt,
15060 		(void *)&cmd_cfg_input_set_field,
15061 		(void *)&cmd_cfg_input_set_field_idx,
15062 		NULL,
15063 	},
15064 };
15065 
15066 /* Clear input set */
15067 struct cmd_clear_input_set_result {
15068 	cmdline_fixed_string_t port;
15069 	cmdline_fixed_string_t cfg;
15070 	portid_t port_id;
15071 	cmdline_fixed_string_t pctype;
15072 	uint8_t pctype_id;
15073 	cmdline_fixed_string_t inset_type;
15074 	cmdline_fixed_string_t clear;
15075 	cmdline_fixed_string_t all;
15076 };
15077 
15078 static void
15079 cmd_clear_input_set_parsed(
15080 	__rte_unused void *parsed_result,
15081 	__rte_unused struct cmdline *cl,
15082 	__rte_unused void *data)
15083 {
15084 #ifdef RTE_NET_I40E
15085 	struct cmd_clear_input_set_result *res = parsed_result;
15086 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15087 	struct rte_pmd_i40e_inset inset;
15088 #endif
15089 	int ret = -ENOTSUP;
15090 
15091 	if (!all_ports_stopped()) {
15092 		fprintf(stderr, "Please stop all ports first\n");
15093 		return;
15094 	}
15095 
15096 #ifdef RTE_NET_I40E
15097 	if (!strcmp(res->inset_type, "hash_inset"))
15098 		inset_type = INSET_HASH;
15099 	else if (!strcmp(res->inset_type, "fdir_inset"))
15100 		inset_type = INSET_FDIR;
15101 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15102 		inset_type = INSET_FDIR_FLX;
15103 
15104 	memset(&inset, 0, sizeof(inset));
15105 
15106 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15107 				     &inset, inset_type);
15108 	if (ret) {
15109 		fprintf(stderr, "Failed to clear input set.\n");
15110 		return;
15111 	}
15112 
15113 #endif
15114 
15115 	if (ret == -ENOTSUP)
15116 		fprintf(stderr, "Function not supported\n");
15117 }
15118 
15119 cmdline_parse_token_string_t cmd_clear_input_set_port =
15120 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15121 				 port, "port");
15122 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15123 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15124 				 cfg, "config");
15125 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15126 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15127 			      port_id, RTE_UINT16);
15128 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15129 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15130 				 pctype, "pctype");
15131 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15132 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15133 			      pctype_id, RTE_UINT8);
15134 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15135 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15136 				 inset_type,
15137 				 "hash_inset#fdir_inset#fdir_flx_inset");
15138 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15139 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15140 				 clear, "clear");
15141 cmdline_parse_token_string_t cmd_clear_input_set_all =
15142 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15143 				 all, "all");
15144 
15145 cmdline_parse_inst_t cmd_clear_input_set = {
15146 	.f = cmd_clear_input_set_parsed,
15147 	.data = NULL,
15148 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15149 		    "fdir_inset|fdir_flx_inset clear all",
15150 	.tokens = {
15151 		(void *)&cmd_clear_input_set_port,
15152 		(void *)&cmd_clear_input_set_cfg,
15153 		(void *)&cmd_clear_input_set_port_id,
15154 		(void *)&cmd_clear_input_set_pctype,
15155 		(void *)&cmd_clear_input_set_pctype_id,
15156 		(void *)&cmd_clear_input_set_inset_type,
15157 		(void *)&cmd_clear_input_set_clear,
15158 		(void *)&cmd_clear_input_set_all,
15159 		NULL,
15160 	},
15161 };
15162 
15163 /* show vf stats */
15164 
15165 /* Common result structure for show vf stats */
15166 struct cmd_show_vf_stats_result {
15167 	cmdline_fixed_string_t show;
15168 	cmdline_fixed_string_t vf;
15169 	cmdline_fixed_string_t stats;
15170 	portid_t port_id;
15171 	uint16_t vf_id;
15172 };
15173 
15174 /* Common CLI fields show vf stats*/
15175 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15176 	TOKEN_STRING_INITIALIZER
15177 		(struct cmd_show_vf_stats_result,
15178 		 show, "show");
15179 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15180 	TOKEN_STRING_INITIALIZER
15181 		(struct cmd_show_vf_stats_result,
15182 		 vf, "vf");
15183 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15184 	TOKEN_STRING_INITIALIZER
15185 		(struct cmd_show_vf_stats_result,
15186 		 stats, "stats");
15187 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15188 	TOKEN_NUM_INITIALIZER
15189 		(struct cmd_show_vf_stats_result,
15190 		 port_id, RTE_UINT16);
15191 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15192 	TOKEN_NUM_INITIALIZER
15193 		(struct cmd_show_vf_stats_result,
15194 		 vf_id, RTE_UINT16);
15195 
15196 static void
15197 cmd_show_vf_stats_parsed(
15198 	void *parsed_result,
15199 	__rte_unused struct cmdline *cl,
15200 	__rte_unused void *data)
15201 {
15202 	struct cmd_show_vf_stats_result *res = parsed_result;
15203 	struct rte_eth_stats stats;
15204 	int ret = -ENOTSUP;
15205 	static const char *nic_stats_border = "########################";
15206 
15207 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15208 		return;
15209 
15210 	memset(&stats, 0, sizeof(stats));
15211 
15212 #ifdef RTE_NET_I40E
15213 	if (ret == -ENOTSUP)
15214 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15215 						res->vf_id,
15216 						&stats);
15217 #endif
15218 #ifdef RTE_NET_BNXT
15219 	if (ret == -ENOTSUP)
15220 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15221 						res->vf_id,
15222 						&stats);
15223 #endif
15224 
15225 	switch (ret) {
15226 	case 0:
15227 		break;
15228 	case -EINVAL:
15229 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15230 		break;
15231 	case -ENODEV:
15232 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15233 		break;
15234 	case -ENOTSUP:
15235 		fprintf(stderr, "function not implemented\n");
15236 		break;
15237 	default:
15238 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15239 	}
15240 
15241 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
15242 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15243 
15244 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
15245 	       "%-"PRIu64"\n",
15246 	       stats.ipackets, stats.imissed, stats.ibytes);
15247 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
15248 	printf("  RX-nombuf:  %-10"PRIu64"\n",
15249 	       stats.rx_nombuf);
15250 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
15251 	       "%-"PRIu64"\n",
15252 	       stats.opackets, stats.oerrors, stats.obytes);
15253 
15254 	printf("  %s############################%s\n",
15255 			       nic_stats_border, nic_stats_border);
15256 }
15257 
15258 cmdline_parse_inst_t cmd_show_vf_stats = {
15259 	.f = cmd_show_vf_stats_parsed,
15260 	.data = NULL,
15261 	.help_str = "show vf stats <port_id> <vf_id>",
15262 	.tokens = {
15263 		(void *)&cmd_show_vf_stats_show,
15264 		(void *)&cmd_show_vf_stats_vf,
15265 		(void *)&cmd_show_vf_stats_stats,
15266 		(void *)&cmd_show_vf_stats_port_id,
15267 		(void *)&cmd_show_vf_stats_vf_id,
15268 		NULL,
15269 	},
15270 };
15271 
15272 /* clear vf stats */
15273 
15274 /* Common result structure for clear vf stats */
15275 struct cmd_clear_vf_stats_result {
15276 	cmdline_fixed_string_t clear;
15277 	cmdline_fixed_string_t vf;
15278 	cmdline_fixed_string_t stats;
15279 	portid_t port_id;
15280 	uint16_t vf_id;
15281 };
15282 
15283 /* Common CLI fields clear vf stats*/
15284 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15285 	TOKEN_STRING_INITIALIZER
15286 		(struct cmd_clear_vf_stats_result,
15287 		 clear, "clear");
15288 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15289 	TOKEN_STRING_INITIALIZER
15290 		(struct cmd_clear_vf_stats_result,
15291 		 vf, "vf");
15292 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15293 	TOKEN_STRING_INITIALIZER
15294 		(struct cmd_clear_vf_stats_result,
15295 		 stats, "stats");
15296 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15297 	TOKEN_NUM_INITIALIZER
15298 		(struct cmd_clear_vf_stats_result,
15299 		 port_id, RTE_UINT16);
15300 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15301 	TOKEN_NUM_INITIALIZER
15302 		(struct cmd_clear_vf_stats_result,
15303 		 vf_id, RTE_UINT16);
15304 
15305 static void
15306 cmd_clear_vf_stats_parsed(
15307 	void *parsed_result,
15308 	__rte_unused struct cmdline *cl,
15309 	__rte_unused void *data)
15310 {
15311 	struct cmd_clear_vf_stats_result *res = parsed_result;
15312 	int ret = -ENOTSUP;
15313 
15314 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15315 		return;
15316 
15317 #ifdef RTE_NET_I40E
15318 	if (ret == -ENOTSUP)
15319 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15320 						  res->vf_id);
15321 #endif
15322 #ifdef RTE_NET_BNXT
15323 	if (ret == -ENOTSUP)
15324 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15325 						  res->vf_id);
15326 #endif
15327 
15328 	switch (ret) {
15329 	case 0:
15330 		break;
15331 	case -EINVAL:
15332 		fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15333 		break;
15334 	case -ENODEV:
15335 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15336 		break;
15337 	case -ENOTSUP:
15338 		fprintf(stderr, "function not implemented\n");
15339 		break;
15340 	default:
15341 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15342 	}
15343 }
15344 
15345 cmdline_parse_inst_t cmd_clear_vf_stats = {
15346 	.f = cmd_clear_vf_stats_parsed,
15347 	.data = NULL,
15348 	.help_str = "clear vf stats <port_id> <vf_id>",
15349 	.tokens = {
15350 		(void *)&cmd_clear_vf_stats_clear,
15351 		(void *)&cmd_clear_vf_stats_vf,
15352 		(void *)&cmd_clear_vf_stats_stats,
15353 		(void *)&cmd_clear_vf_stats_port_id,
15354 		(void *)&cmd_clear_vf_stats_vf_id,
15355 		NULL,
15356 	},
15357 };
15358 
15359 /* port config pctype mapping reset */
15360 
15361 /* Common result structure for port config pctype mapping reset */
15362 struct cmd_pctype_mapping_reset_result {
15363 	cmdline_fixed_string_t port;
15364 	cmdline_fixed_string_t config;
15365 	portid_t port_id;
15366 	cmdline_fixed_string_t pctype;
15367 	cmdline_fixed_string_t mapping;
15368 	cmdline_fixed_string_t reset;
15369 };
15370 
15371 /* Common CLI fields for port config pctype mapping reset*/
15372 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15373 	TOKEN_STRING_INITIALIZER
15374 		(struct cmd_pctype_mapping_reset_result,
15375 		 port, "port");
15376 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15377 	TOKEN_STRING_INITIALIZER
15378 		(struct cmd_pctype_mapping_reset_result,
15379 		 config, "config");
15380 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15381 	TOKEN_NUM_INITIALIZER
15382 		(struct cmd_pctype_mapping_reset_result,
15383 		 port_id, RTE_UINT16);
15384 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15385 	TOKEN_STRING_INITIALIZER
15386 		(struct cmd_pctype_mapping_reset_result,
15387 		 pctype, "pctype");
15388 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15389 	TOKEN_STRING_INITIALIZER
15390 		(struct cmd_pctype_mapping_reset_result,
15391 		 mapping, "mapping");
15392 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15393 	TOKEN_STRING_INITIALIZER
15394 		(struct cmd_pctype_mapping_reset_result,
15395 		 reset, "reset");
15396 
15397 static void
15398 cmd_pctype_mapping_reset_parsed(
15399 	void *parsed_result,
15400 	__rte_unused struct cmdline *cl,
15401 	__rte_unused void *data)
15402 {
15403 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15404 	int ret = -ENOTSUP;
15405 
15406 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15407 		return;
15408 
15409 #ifdef RTE_NET_I40E
15410 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15411 #endif
15412 
15413 	switch (ret) {
15414 	case 0:
15415 		break;
15416 	case -ENODEV:
15417 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15418 		break;
15419 	case -ENOTSUP:
15420 		fprintf(stderr, "function not implemented\n");
15421 		break;
15422 	default:
15423 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15424 	}
15425 }
15426 
15427 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15428 	.f = cmd_pctype_mapping_reset_parsed,
15429 	.data = NULL,
15430 	.help_str = "port config <port_id> pctype mapping reset",
15431 	.tokens = {
15432 		(void *)&cmd_pctype_mapping_reset_port,
15433 		(void *)&cmd_pctype_mapping_reset_config,
15434 		(void *)&cmd_pctype_mapping_reset_port_id,
15435 		(void *)&cmd_pctype_mapping_reset_pctype,
15436 		(void *)&cmd_pctype_mapping_reset_mapping,
15437 		(void *)&cmd_pctype_mapping_reset_reset,
15438 		NULL,
15439 	},
15440 };
15441 
15442 /* show port pctype mapping */
15443 
15444 /* Common result structure for show port pctype mapping */
15445 struct cmd_pctype_mapping_get_result {
15446 	cmdline_fixed_string_t show;
15447 	cmdline_fixed_string_t port;
15448 	portid_t port_id;
15449 	cmdline_fixed_string_t pctype;
15450 	cmdline_fixed_string_t mapping;
15451 };
15452 
15453 /* Common CLI fields for pctype mapping get */
15454 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15455 	TOKEN_STRING_INITIALIZER
15456 		(struct cmd_pctype_mapping_get_result,
15457 		 show, "show");
15458 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15459 	TOKEN_STRING_INITIALIZER
15460 		(struct cmd_pctype_mapping_get_result,
15461 		 port, "port");
15462 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15463 	TOKEN_NUM_INITIALIZER
15464 		(struct cmd_pctype_mapping_get_result,
15465 		 port_id, RTE_UINT16);
15466 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15467 	TOKEN_STRING_INITIALIZER
15468 		(struct cmd_pctype_mapping_get_result,
15469 		 pctype, "pctype");
15470 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15471 	TOKEN_STRING_INITIALIZER
15472 		(struct cmd_pctype_mapping_get_result,
15473 		 mapping, "mapping");
15474 
15475 static void
15476 cmd_pctype_mapping_get_parsed(
15477 	void *parsed_result,
15478 	__rte_unused struct cmdline *cl,
15479 	__rte_unused void *data)
15480 {
15481 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15482 	int ret = -ENOTSUP;
15483 #ifdef RTE_NET_I40E
15484 	struct rte_pmd_i40e_flow_type_mapping
15485 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15486 	int i, j, first_pctype;
15487 #endif
15488 
15489 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15490 		return;
15491 
15492 #ifdef RTE_NET_I40E
15493 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15494 #endif
15495 
15496 	switch (ret) {
15497 	case 0:
15498 		break;
15499 	case -ENODEV:
15500 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15501 		return;
15502 	case -ENOTSUP:
15503 		fprintf(stderr, "function not implemented\n");
15504 		return;
15505 	default:
15506 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15507 		return;
15508 	}
15509 
15510 #ifdef RTE_NET_I40E
15511 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15512 		if (mapping[i].pctype != 0ULL) {
15513 			first_pctype = 1;
15514 
15515 			printf("pctype: ");
15516 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15517 				if (mapping[i].pctype & (1ULL << j)) {
15518 					printf(first_pctype ?
15519 					       "%02d" : ",%02d", j);
15520 					first_pctype = 0;
15521 				}
15522 			}
15523 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15524 		}
15525 	}
15526 #endif
15527 }
15528 
15529 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15530 	.f = cmd_pctype_mapping_get_parsed,
15531 	.data = NULL,
15532 	.help_str = "show port <port_id> pctype mapping",
15533 	.tokens = {
15534 		(void *)&cmd_pctype_mapping_get_show,
15535 		(void *)&cmd_pctype_mapping_get_port,
15536 		(void *)&cmd_pctype_mapping_get_port_id,
15537 		(void *)&cmd_pctype_mapping_get_pctype,
15538 		(void *)&cmd_pctype_mapping_get_mapping,
15539 		NULL,
15540 	},
15541 };
15542 
15543 /* port config pctype mapping update */
15544 
15545 /* Common result structure for port config pctype mapping update */
15546 struct cmd_pctype_mapping_update_result {
15547 	cmdline_fixed_string_t port;
15548 	cmdline_fixed_string_t config;
15549 	portid_t port_id;
15550 	cmdline_fixed_string_t pctype;
15551 	cmdline_fixed_string_t mapping;
15552 	cmdline_fixed_string_t update;
15553 	cmdline_fixed_string_t pctype_list;
15554 	uint16_t flow_type;
15555 };
15556 
15557 /* Common CLI fields for pctype mapping update*/
15558 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15559 	TOKEN_STRING_INITIALIZER
15560 		(struct cmd_pctype_mapping_update_result,
15561 		 port, "port");
15562 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15563 	TOKEN_STRING_INITIALIZER
15564 		(struct cmd_pctype_mapping_update_result,
15565 		 config, "config");
15566 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15567 	TOKEN_NUM_INITIALIZER
15568 		(struct cmd_pctype_mapping_update_result,
15569 		 port_id, RTE_UINT16);
15570 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15571 	TOKEN_STRING_INITIALIZER
15572 		(struct cmd_pctype_mapping_update_result,
15573 		 pctype, "pctype");
15574 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15575 	TOKEN_STRING_INITIALIZER
15576 		(struct cmd_pctype_mapping_update_result,
15577 		 mapping, "mapping");
15578 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15579 	TOKEN_STRING_INITIALIZER
15580 		(struct cmd_pctype_mapping_update_result,
15581 		 update, "update");
15582 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15583 	TOKEN_STRING_INITIALIZER
15584 		(struct cmd_pctype_mapping_update_result,
15585 		 pctype_list, NULL);
15586 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15587 	TOKEN_NUM_INITIALIZER
15588 		(struct cmd_pctype_mapping_update_result,
15589 		 flow_type, RTE_UINT16);
15590 
15591 static void
15592 cmd_pctype_mapping_update_parsed(
15593 	void *parsed_result,
15594 	__rte_unused struct cmdline *cl,
15595 	__rte_unused void *data)
15596 {
15597 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15598 	int ret = -ENOTSUP;
15599 #ifdef RTE_NET_I40E
15600 	struct rte_pmd_i40e_flow_type_mapping mapping;
15601 	unsigned int i;
15602 	unsigned int nb_item;
15603 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15604 #endif
15605 
15606 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15607 		return;
15608 
15609 #ifdef RTE_NET_I40E
15610 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15611 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15612 	mapping.flow_type = res->flow_type;
15613 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15614 		mapping.pctype |= (1ULL << pctype_list[i]);
15615 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15616 						&mapping,
15617 						1,
15618 						0);
15619 #endif
15620 
15621 	switch (ret) {
15622 	case 0:
15623 		break;
15624 	case -EINVAL:
15625 		fprintf(stderr, "invalid pctype or flow type\n");
15626 		break;
15627 	case -ENODEV:
15628 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15629 		break;
15630 	case -ENOTSUP:
15631 		fprintf(stderr, "function not implemented\n");
15632 		break;
15633 	default:
15634 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15635 	}
15636 }
15637 
15638 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15639 	.f = cmd_pctype_mapping_update_parsed,
15640 	.data = NULL,
15641 	.help_str = "port config <port_id> pctype mapping update"
15642 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15643 	.tokens = {
15644 		(void *)&cmd_pctype_mapping_update_port,
15645 		(void *)&cmd_pctype_mapping_update_config,
15646 		(void *)&cmd_pctype_mapping_update_port_id,
15647 		(void *)&cmd_pctype_mapping_update_pctype,
15648 		(void *)&cmd_pctype_mapping_update_mapping,
15649 		(void *)&cmd_pctype_mapping_update_update,
15650 		(void *)&cmd_pctype_mapping_update_pc_type,
15651 		(void *)&cmd_pctype_mapping_update_flow_type,
15652 		NULL,
15653 	},
15654 };
15655 
15656 /* ptype mapping get */
15657 
15658 /* Common result structure for ptype mapping get */
15659 struct cmd_ptype_mapping_get_result {
15660 	cmdline_fixed_string_t ptype;
15661 	cmdline_fixed_string_t mapping;
15662 	cmdline_fixed_string_t get;
15663 	portid_t port_id;
15664 	uint8_t valid_only;
15665 };
15666 
15667 /* Common CLI fields for ptype mapping get */
15668 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15669 	TOKEN_STRING_INITIALIZER
15670 		(struct cmd_ptype_mapping_get_result,
15671 		 ptype, "ptype");
15672 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15673 	TOKEN_STRING_INITIALIZER
15674 		(struct cmd_ptype_mapping_get_result,
15675 		 mapping, "mapping");
15676 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15677 	TOKEN_STRING_INITIALIZER
15678 		(struct cmd_ptype_mapping_get_result,
15679 		 get, "get");
15680 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15681 	TOKEN_NUM_INITIALIZER
15682 		(struct cmd_ptype_mapping_get_result,
15683 		 port_id, RTE_UINT16);
15684 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15685 	TOKEN_NUM_INITIALIZER
15686 		(struct cmd_ptype_mapping_get_result,
15687 		 valid_only, RTE_UINT8);
15688 
15689 static void
15690 cmd_ptype_mapping_get_parsed(
15691 	void *parsed_result,
15692 	__rte_unused struct cmdline *cl,
15693 	__rte_unused void *data)
15694 {
15695 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15696 	int ret = -ENOTSUP;
15697 #ifdef RTE_NET_I40E
15698 	int max_ptype_num = 256;
15699 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15700 	uint16_t count;
15701 	int i;
15702 #endif
15703 
15704 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15705 		return;
15706 
15707 #ifdef RTE_NET_I40E
15708 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15709 					mapping,
15710 					max_ptype_num,
15711 					&count,
15712 					res->valid_only);
15713 #endif
15714 
15715 	switch (ret) {
15716 	case 0:
15717 		break;
15718 	case -ENODEV:
15719 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15720 		break;
15721 	case -ENOTSUP:
15722 		fprintf(stderr, "function not implemented\n");
15723 		break;
15724 	default:
15725 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15726 	}
15727 
15728 #ifdef RTE_NET_I40E
15729 	if (!ret) {
15730 		for (i = 0; i < count; i++)
15731 			printf("%3d\t0x%08x\n",
15732 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15733 	}
15734 #endif
15735 }
15736 
15737 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15738 	.f = cmd_ptype_mapping_get_parsed,
15739 	.data = NULL,
15740 	.help_str = "ptype mapping get <port_id> <valid_only>",
15741 	.tokens = {
15742 		(void *)&cmd_ptype_mapping_get_ptype,
15743 		(void *)&cmd_ptype_mapping_get_mapping,
15744 		(void *)&cmd_ptype_mapping_get_get,
15745 		(void *)&cmd_ptype_mapping_get_port_id,
15746 		(void *)&cmd_ptype_mapping_get_valid_only,
15747 		NULL,
15748 	},
15749 };
15750 
15751 /* ptype mapping replace */
15752 
15753 /* Common result structure for ptype mapping replace */
15754 struct cmd_ptype_mapping_replace_result {
15755 	cmdline_fixed_string_t ptype;
15756 	cmdline_fixed_string_t mapping;
15757 	cmdline_fixed_string_t replace;
15758 	portid_t port_id;
15759 	uint32_t target;
15760 	uint8_t mask;
15761 	uint32_t pkt_type;
15762 };
15763 
15764 /* Common CLI fields for ptype mapping replace */
15765 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15766 	TOKEN_STRING_INITIALIZER
15767 		(struct cmd_ptype_mapping_replace_result,
15768 		 ptype, "ptype");
15769 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15770 	TOKEN_STRING_INITIALIZER
15771 		(struct cmd_ptype_mapping_replace_result,
15772 		 mapping, "mapping");
15773 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15774 	TOKEN_STRING_INITIALIZER
15775 		(struct cmd_ptype_mapping_replace_result,
15776 		 replace, "replace");
15777 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15778 	TOKEN_NUM_INITIALIZER
15779 		(struct cmd_ptype_mapping_replace_result,
15780 		 port_id, RTE_UINT16);
15781 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15782 	TOKEN_NUM_INITIALIZER
15783 		(struct cmd_ptype_mapping_replace_result,
15784 		 target, RTE_UINT32);
15785 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15786 	TOKEN_NUM_INITIALIZER
15787 		(struct cmd_ptype_mapping_replace_result,
15788 		 mask, RTE_UINT8);
15789 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15790 	TOKEN_NUM_INITIALIZER
15791 		(struct cmd_ptype_mapping_replace_result,
15792 		 pkt_type, RTE_UINT32);
15793 
15794 static void
15795 cmd_ptype_mapping_replace_parsed(
15796 	void *parsed_result,
15797 	__rte_unused struct cmdline *cl,
15798 	__rte_unused void *data)
15799 {
15800 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15801 	int ret = -ENOTSUP;
15802 
15803 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15804 		return;
15805 
15806 #ifdef RTE_NET_I40E
15807 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15808 					res->target,
15809 					res->mask,
15810 					res->pkt_type);
15811 #endif
15812 
15813 	switch (ret) {
15814 	case 0:
15815 		break;
15816 	case -EINVAL:
15817 		fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15818 			res->target, res->pkt_type);
15819 		break;
15820 	case -ENODEV:
15821 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15822 		break;
15823 	case -ENOTSUP:
15824 		fprintf(stderr, "function not implemented\n");
15825 		break;
15826 	default:
15827 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15828 	}
15829 }
15830 
15831 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15832 	.f = cmd_ptype_mapping_replace_parsed,
15833 	.data = NULL,
15834 	.help_str =
15835 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15836 	.tokens = {
15837 		(void *)&cmd_ptype_mapping_replace_ptype,
15838 		(void *)&cmd_ptype_mapping_replace_mapping,
15839 		(void *)&cmd_ptype_mapping_replace_replace,
15840 		(void *)&cmd_ptype_mapping_replace_port_id,
15841 		(void *)&cmd_ptype_mapping_replace_target,
15842 		(void *)&cmd_ptype_mapping_replace_mask,
15843 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15844 		NULL,
15845 	},
15846 };
15847 
15848 /* ptype mapping reset */
15849 
15850 /* Common result structure for ptype mapping reset */
15851 struct cmd_ptype_mapping_reset_result {
15852 	cmdline_fixed_string_t ptype;
15853 	cmdline_fixed_string_t mapping;
15854 	cmdline_fixed_string_t reset;
15855 	portid_t port_id;
15856 };
15857 
15858 /* Common CLI fields for ptype mapping reset*/
15859 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15860 	TOKEN_STRING_INITIALIZER
15861 		(struct cmd_ptype_mapping_reset_result,
15862 		 ptype, "ptype");
15863 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15864 	TOKEN_STRING_INITIALIZER
15865 		(struct cmd_ptype_mapping_reset_result,
15866 		 mapping, "mapping");
15867 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15868 	TOKEN_STRING_INITIALIZER
15869 		(struct cmd_ptype_mapping_reset_result,
15870 		 reset, "reset");
15871 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15872 	TOKEN_NUM_INITIALIZER
15873 		(struct cmd_ptype_mapping_reset_result,
15874 		 port_id, RTE_UINT16);
15875 
15876 static void
15877 cmd_ptype_mapping_reset_parsed(
15878 	void *parsed_result,
15879 	__rte_unused struct cmdline *cl,
15880 	__rte_unused void *data)
15881 {
15882 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15883 	int ret = -ENOTSUP;
15884 
15885 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15886 		return;
15887 
15888 #ifdef RTE_NET_I40E
15889 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15890 #endif
15891 
15892 	switch (ret) {
15893 	case 0:
15894 		break;
15895 	case -ENODEV:
15896 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15897 		break;
15898 	case -ENOTSUP:
15899 		fprintf(stderr, "function not implemented\n");
15900 		break;
15901 	default:
15902 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15903 	}
15904 }
15905 
15906 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15907 	.f = cmd_ptype_mapping_reset_parsed,
15908 	.data = NULL,
15909 	.help_str = "ptype mapping reset <port_id>",
15910 	.tokens = {
15911 		(void *)&cmd_ptype_mapping_reset_ptype,
15912 		(void *)&cmd_ptype_mapping_reset_mapping,
15913 		(void *)&cmd_ptype_mapping_reset_reset,
15914 		(void *)&cmd_ptype_mapping_reset_port_id,
15915 		NULL,
15916 	},
15917 };
15918 
15919 /* ptype mapping update */
15920 
15921 /* Common result structure for ptype mapping update */
15922 struct cmd_ptype_mapping_update_result {
15923 	cmdline_fixed_string_t ptype;
15924 	cmdline_fixed_string_t mapping;
15925 	cmdline_fixed_string_t reset;
15926 	portid_t port_id;
15927 	uint8_t hw_ptype;
15928 	uint32_t sw_ptype;
15929 };
15930 
15931 /* Common CLI fields for ptype mapping update*/
15932 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15933 	TOKEN_STRING_INITIALIZER
15934 		(struct cmd_ptype_mapping_update_result,
15935 		 ptype, "ptype");
15936 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15937 	TOKEN_STRING_INITIALIZER
15938 		(struct cmd_ptype_mapping_update_result,
15939 		 mapping, "mapping");
15940 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15941 	TOKEN_STRING_INITIALIZER
15942 		(struct cmd_ptype_mapping_update_result,
15943 		 reset, "update");
15944 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15945 	TOKEN_NUM_INITIALIZER
15946 		(struct cmd_ptype_mapping_update_result,
15947 		 port_id, RTE_UINT16);
15948 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15949 	TOKEN_NUM_INITIALIZER
15950 		(struct cmd_ptype_mapping_update_result,
15951 		 hw_ptype, RTE_UINT8);
15952 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15953 	TOKEN_NUM_INITIALIZER
15954 		(struct cmd_ptype_mapping_update_result,
15955 		 sw_ptype, RTE_UINT32);
15956 
15957 static void
15958 cmd_ptype_mapping_update_parsed(
15959 	void *parsed_result,
15960 	__rte_unused struct cmdline *cl,
15961 	__rte_unused void *data)
15962 {
15963 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15964 	int ret = -ENOTSUP;
15965 #ifdef RTE_NET_I40E
15966 	struct rte_pmd_i40e_ptype_mapping mapping;
15967 #endif
15968 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15969 		return;
15970 
15971 #ifdef RTE_NET_I40E
15972 	mapping.hw_ptype = res->hw_ptype;
15973 	mapping.sw_ptype = res->sw_ptype;
15974 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15975 						&mapping,
15976 						1,
15977 						0);
15978 #endif
15979 
15980 	switch (ret) {
15981 	case 0:
15982 		break;
15983 	case -EINVAL:
15984 		fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15985 		break;
15986 	case -ENODEV:
15987 		fprintf(stderr, "invalid port_id %d\n", res->port_id);
15988 		break;
15989 	case -ENOTSUP:
15990 		fprintf(stderr, "function not implemented\n");
15991 		break;
15992 	default:
15993 		fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15994 	}
15995 }
15996 
15997 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15998 	.f = cmd_ptype_mapping_update_parsed,
15999 	.data = NULL,
16000 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16001 	.tokens = {
16002 		(void *)&cmd_ptype_mapping_update_ptype,
16003 		(void *)&cmd_ptype_mapping_update_mapping,
16004 		(void *)&cmd_ptype_mapping_update_update,
16005 		(void *)&cmd_ptype_mapping_update_port_id,
16006 		(void *)&cmd_ptype_mapping_update_hw_ptype,
16007 		(void *)&cmd_ptype_mapping_update_sw_ptype,
16008 		NULL,
16009 	},
16010 };
16011 
16012 /* Common result structure for file commands */
16013 struct cmd_cmdfile_result {
16014 	cmdline_fixed_string_t load;
16015 	cmdline_fixed_string_t filename;
16016 };
16017 
16018 /* Common CLI fields for file commands */
16019 cmdline_parse_token_string_t cmd_load_cmdfile =
16020 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16021 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16022 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16023 
16024 static void
16025 cmd_load_from_file_parsed(
16026 	void *parsed_result,
16027 	__rte_unused struct cmdline *cl,
16028 	__rte_unused void *data)
16029 {
16030 	struct cmd_cmdfile_result *res = parsed_result;
16031 
16032 	cmdline_read_from_file(res->filename);
16033 }
16034 
16035 cmdline_parse_inst_t cmd_load_from_file = {
16036 	.f = cmd_load_from_file_parsed,
16037 	.data = NULL,
16038 	.help_str = "load <filename>",
16039 	.tokens = {
16040 		(void *)&cmd_load_cmdfile,
16041 		(void *)&cmd_load_cmdfile_filename,
16042 		NULL,
16043 	},
16044 };
16045 
16046 /* Get Rx offloads capabilities */
16047 struct cmd_rx_offload_get_capa_result {
16048 	cmdline_fixed_string_t show;
16049 	cmdline_fixed_string_t port;
16050 	portid_t port_id;
16051 	cmdline_fixed_string_t rx_offload;
16052 	cmdline_fixed_string_t capabilities;
16053 };
16054 
16055 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16056 	TOKEN_STRING_INITIALIZER
16057 		(struct cmd_rx_offload_get_capa_result,
16058 		 show, "show");
16059 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16060 	TOKEN_STRING_INITIALIZER
16061 		(struct cmd_rx_offload_get_capa_result,
16062 		 port, "port");
16063 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16064 	TOKEN_NUM_INITIALIZER
16065 		(struct cmd_rx_offload_get_capa_result,
16066 		 port_id, RTE_UINT16);
16067 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16068 	TOKEN_STRING_INITIALIZER
16069 		(struct cmd_rx_offload_get_capa_result,
16070 		 rx_offload, "rx_offload");
16071 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16072 	TOKEN_STRING_INITIALIZER
16073 		(struct cmd_rx_offload_get_capa_result,
16074 		 capabilities, "capabilities");
16075 
16076 static void
16077 print_rx_offloads(uint64_t offloads)
16078 {
16079 	uint64_t single_offload;
16080 	int begin;
16081 	int end;
16082 	int bit;
16083 
16084 	if (offloads == 0)
16085 		return;
16086 
16087 	begin = __builtin_ctzll(offloads);
16088 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16089 
16090 	single_offload = 1ULL << begin;
16091 	for (bit = begin; bit < end; bit++) {
16092 		if (offloads & single_offload)
16093 			printf(" %s",
16094 			       rte_eth_dev_rx_offload_name(single_offload));
16095 		single_offload <<= 1;
16096 	}
16097 }
16098 
16099 static void
16100 cmd_rx_offload_get_capa_parsed(
16101 	void *parsed_result,
16102 	__rte_unused struct cmdline *cl,
16103 	__rte_unused void *data)
16104 {
16105 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
16106 	struct rte_eth_dev_info dev_info;
16107 	portid_t port_id = res->port_id;
16108 	uint64_t queue_offloads;
16109 	uint64_t port_offloads;
16110 	int ret;
16111 
16112 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16113 	if (ret != 0)
16114 		return;
16115 
16116 	queue_offloads = dev_info.rx_queue_offload_capa;
16117 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16118 
16119 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
16120 	printf("  Per Queue :");
16121 	print_rx_offloads(queue_offloads);
16122 
16123 	printf("\n");
16124 	printf("  Per Port  :");
16125 	print_rx_offloads(port_offloads);
16126 	printf("\n\n");
16127 }
16128 
16129 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16130 	.f = cmd_rx_offload_get_capa_parsed,
16131 	.data = NULL,
16132 	.help_str = "show port <port_id> rx_offload capabilities",
16133 	.tokens = {
16134 		(void *)&cmd_rx_offload_get_capa_show,
16135 		(void *)&cmd_rx_offload_get_capa_port,
16136 		(void *)&cmd_rx_offload_get_capa_port_id,
16137 		(void *)&cmd_rx_offload_get_capa_rx_offload,
16138 		(void *)&cmd_rx_offload_get_capa_capabilities,
16139 		NULL,
16140 	}
16141 };
16142 
16143 /* Get Rx offloads configuration */
16144 struct cmd_rx_offload_get_configuration_result {
16145 	cmdline_fixed_string_t show;
16146 	cmdline_fixed_string_t port;
16147 	portid_t port_id;
16148 	cmdline_fixed_string_t rx_offload;
16149 	cmdline_fixed_string_t configuration;
16150 };
16151 
16152 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16153 	TOKEN_STRING_INITIALIZER
16154 		(struct cmd_rx_offload_get_configuration_result,
16155 		 show, "show");
16156 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16157 	TOKEN_STRING_INITIALIZER
16158 		(struct cmd_rx_offload_get_configuration_result,
16159 		 port, "port");
16160 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16161 	TOKEN_NUM_INITIALIZER
16162 		(struct cmd_rx_offload_get_configuration_result,
16163 		 port_id, RTE_UINT16);
16164 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16165 	TOKEN_STRING_INITIALIZER
16166 		(struct cmd_rx_offload_get_configuration_result,
16167 		 rx_offload, "rx_offload");
16168 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16169 	TOKEN_STRING_INITIALIZER
16170 		(struct cmd_rx_offload_get_configuration_result,
16171 		 configuration, "configuration");
16172 
16173 static void
16174 cmd_rx_offload_get_configuration_parsed(
16175 	void *parsed_result,
16176 	__rte_unused struct cmdline *cl,
16177 	__rte_unused void *data)
16178 {
16179 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16180 	struct rte_eth_dev_info dev_info;
16181 	portid_t port_id = res->port_id;
16182 	struct rte_port *port = &ports[port_id];
16183 	struct rte_eth_conf dev_conf;
16184 	uint64_t port_offloads;
16185 	uint64_t queue_offloads;
16186 	uint16_t nb_rx_queues;
16187 	int q;
16188 	int ret;
16189 
16190 	printf("Rx Offloading Configuration of port %d :\n", port_id);
16191 
16192 	ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16193 	if (ret != 0)
16194 		return;
16195 
16196 	port_offloads = dev_conf.rxmode.offloads;
16197 	printf("  Port :");
16198 	print_rx_offloads(port_offloads);
16199 	printf("\n");
16200 
16201 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16202 	if (ret != 0)
16203 		return;
16204 
16205 	nb_rx_queues = dev_info.nb_rx_queues;
16206 	for (q = 0; q < nb_rx_queues; q++) {
16207 		queue_offloads = port->rx_conf[q].offloads;
16208 		printf("  Queue[%2d] :", q);
16209 		print_rx_offloads(queue_offloads);
16210 		printf("\n");
16211 	}
16212 	printf("\n");
16213 }
16214 
16215 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16216 	.f = cmd_rx_offload_get_configuration_parsed,
16217 	.data = NULL,
16218 	.help_str = "show port <port_id> rx_offload configuration",
16219 	.tokens = {
16220 		(void *)&cmd_rx_offload_get_configuration_show,
16221 		(void *)&cmd_rx_offload_get_configuration_port,
16222 		(void *)&cmd_rx_offload_get_configuration_port_id,
16223 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
16224 		(void *)&cmd_rx_offload_get_configuration_configuration,
16225 		NULL,
16226 	}
16227 };
16228 
16229 /* Enable/Disable a per port offloading */
16230 struct cmd_config_per_port_rx_offload_result {
16231 	cmdline_fixed_string_t port;
16232 	cmdline_fixed_string_t config;
16233 	portid_t port_id;
16234 	cmdline_fixed_string_t rx_offload;
16235 	cmdline_fixed_string_t offload;
16236 	cmdline_fixed_string_t on_off;
16237 };
16238 
16239 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16240 	TOKEN_STRING_INITIALIZER
16241 		(struct cmd_config_per_port_rx_offload_result,
16242 		 port, "port");
16243 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16244 	TOKEN_STRING_INITIALIZER
16245 		(struct cmd_config_per_port_rx_offload_result,
16246 		 config, "config");
16247 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16248 	TOKEN_NUM_INITIALIZER
16249 		(struct cmd_config_per_port_rx_offload_result,
16250 		 port_id, RTE_UINT16);
16251 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16252 	TOKEN_STRING_INITIALIZER
16253 		(struct cmd_config_per_port_rx_offload_result,
16254 		 rx_offload, "rx_offload");
16255 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16256 	TOKEN_STRING_INITIALIZER
16257 		(struct cmd_config_per_port_rx_offload_result,
16258 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16259 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16260 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16261 			   "scatter#buffer_split#timestamp#security#"
16262 			   "keep_crc#rss_hash");
16263 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16264 	TOKEN_STRING_INITIALIZER
16265 		(struct cmd_config_per_port_rx_offload_result,
16266 		 on_off, "on#off");
16267 
16268 static uint64_t
16269 search_rx_offload(const char *name)
16270 {
16271 	uint64_t single_offload;
16272 	const char *single_name;
16273 	int found = 0;
16274 	unsigned int bit;
16275 
16276 	single_offload = 1;
16277 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16278 		single_name = rte_eth_dev_rx_offload_name(single_offload);
16279 		if (!strcasecmp(single_name, name)) {
16280 			found = 1;
16281 			break;
16282 		}
16283 		single_offload <<= 1;
16284 	}
16285 
16286 	if (found)
16287 		return single_offload;
16288 
16289 	return 0;
16290 }
16291 
16292 static void
16293 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16294 				__rte_unused struct cmdline *cl,
16295 				__rte_unused void *data)
16296 {
16297 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16298 	portid_t port_id = res->port_id;
16299 	struct rte_eth_dev_info dev_info;
16300 	struct rte_port *port = &ports[port_id];
16301 	uint64_t single_offload;
16302 	uint16_t nb_rx_queues;
16303 	int q;
16304 	int ret;
16305 
16306 	if (port->port_status != RTE_PORT_STOPPED) {
16307 		fprintf(stderr,
16308 			"Error: Can't config offload when Port %d is not stopped\n",
16309 			port_id);
16310 		return;
16311 	}
16312 
16313 	single_offload = search_rx_offload(res->offload);
16314 	if (single_offload == 0) {
16315 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16316 		return;
16317 	}
16318 
16319 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16320 	if (ret != 0)
16321 		return;
16322 
16323 	nb_rx_queues = dev_info.nb_rx_queues;
16324 	if (!strcmp(res->on_off, "on")) {
16325 		port->dev_conf.rxmode.offloads |= single_offload;
16326 		for (q = 0; q < nb_rx_queues; q++)
16327 			port->rx_conf[q].offloads |= single_offload;
16328 	} else {
16329 		port->dev_conf.rxmode.offloads &= ~single_offload;
16330 		for (q = 0; q < nb_rx_queues; q++)
16331 			port->rx_conf[q].offloads &= ~single_offload;
16332 	}
16333 
16334 	cmd_reconfig_device_queue(port_id, 1, 1);
16335 }
16336 
16337 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16338 	.f = cmd_config_per_port_rx_offload_parsed,
16339 	.data = NULL,
16340 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16341 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16342 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16343 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16344 		    "keep_crc|rss_hash on|off",
16345 	.tokens = {
16346 		(void *)&cmd_config_per_port_rx_offload_result_port,
16347 		(void *)&cmd_config_per_port_rx_offload_result_config,
16348 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
16349 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16350 		(void *)&cmd_config_per_port_rx_offload_result_offload,
16351 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
16352 		NULL,
16353 	}
16354 };
16355 
16356 /* Enable/Disable a per queue offloading */
16357 struct cmd_config_per_queue_rx_offload_result {
16358 	cmdline_fixed_string_t port;
16359 	portid_t port_id;
16360 	cmdline_fixed_string_t rxq;
16361 	uint16_t queue_id;
16362 	cmdline_fixed_string_t rx_offload;
16363 	cmdline_fixed_string_t offload;
16364 	cmdline_fixed_string_t on_off;
16365 };
16366 
16367 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16368 	TOKEN_STRING_INITIALIZER
16369 		(struct cmd_config_per_queue_rx_offload_result,
16370 		 port, "port");
16371 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16372 	TOKEN_NUM_INITIALIZER
16373 		(struct cmd_config_per_queue_rx_offload_result,
16374 		 port_id, RTE_UINT16);
16375 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16376 	TOKEN_STRING_INITIALIZER
16377 		(struct cmd_config_per_queue_rx_offload_result,
16378 		 rxq, "rxq");
16379 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16380 	TOKEN_NUM_INITIALIZER
16381 		(struct cmd_config_per_queue_rx_offload_result,
16382 		 queue_id, RTE_UINT16);
16383 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16384 	TOKEN_STRING_INITIALIZER
16385 		(struct cmd_config_per_queue_rx_offload_result,
16386 		 rx_offload, "rx_offload");
16387 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16388 	TOKEN_STRING_INITIALIZER
16389 		(struct cmd_config_per_queue_rx_offload_result,
16390 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16391 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16392 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16393 			   "scatter#buffer_split#timestamp#security#keep_crc");
16394 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16395 	TOKEN_STRING_INITIALIZER
16396 		(struct cmd_config_per_queue_rx_offload_result,
16397 		 on_off, "on#off");
16398 
16399 static void
16400 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16401 				__rte_unused struct cmdline *cl,
16402 				__rte_unused void *data)
16403 {
16404 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16405 	struct rte_eth_dev_info dev_info;
16406 	portid_t port_id = res->port_id;
16407 	uint16_t queue_id = res->queue_id;
16408 	struct rte_port *port = &ports[port_id];
16409 	uint64_t single_offload;
16410 	int ret;
16411 
16412 	if (port->port_status != RTE_PORT_STOPPED) {
16413 		fprintf(stderr,
16414 			"Error: Can't config offload when Port %d is not stopped\n",
16415 			port_id);
16416 		return;
16417 	}
16418 
16419 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16420 	if (ret != 0)
16421 		return;
16422 
16423 	if (queue_id >= dev_info.nb_rx_queues) {
16424 		fprintf(stderr,
16425 			"Error: input queue_id should be 0 ... %d\n",
16426 			dev_info.nb_rx_queues - 1);
16427 		return;
16428 	}
16429 
16430 	single_offload = search_rx_offload(res->offload);
16431 	if (single_offload == 0) {
16432 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16433 		return;
16434 	}
16435 
16436 	if (!strcmp(res->on_off, "on"))
16437 		port->rx_conf[queue_id].offloads |= single_offload;
16438 	else
16439 		port->rx_conf[queue_id].offloads &= ~single_offload;
16440 
16441 	cmd_reconfig_device_queue(port_id, 1, 1);
16442 }
16443 
16444 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16445 	.f = cmd_config_per_queue_rx_offload_parsed,
16446 	.data = NULL,
16447 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
16448 		    "vlan_strip|ipv4_cksum|"
16449 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16450 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16451 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16452 		    "keep_crc on|off",
16453 	.tokens = {
16454 		(void *)&cmd_config_per_queue_rx_offload_result_port,
16455 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
16456 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
16457 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16458 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16459 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
16460 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
16461 		NULL,
16462 	}
16463 };
16464 
16465 /* Get Tx offloads capabilities */
16466 struct cmd_tx_offload_get_capa_result {
16467 	cmdline_fixed_string_t show;
16468 	cmdline_fixed_string_t port;
16469 	portid_t port_id;
16470 	cmdline_fixed_string_t tx_offload;
16471 	cmdline_fixed_string_t capabilities;
16472 };
16473 
16474 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16475 	TOKEN_STRING_INITIALIZER
16476 		(struct cmd_tx_offload_get_capa_result,
16477 		 show, "show");
16478 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16479 	TOKEN_STRING_INITIALIZER
16480 		(struct cmd_tx_offload_get_capa_result,
16481 		 port, "port");
16482 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16483 	TOKEN_NUM_INITIALIZER
16484 		(struct cmd_tx_offload_get_capa_result,
16485 		 port_id, RTE_UINT16);
16486 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16487 	TOKEN_STRING_INITIALIZER
16488 		(struct cmd_tx_offload_get_capa_result,
16489 		 tx_offload, "tx_offload");
16490 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16491 	TOKEN_STRING_INITIALIZER
16492 		(struct cmd_tx_offload_get_capa_result,
16493 		 capabilities, "capabilities");
16494 
16495 static void
16496 print_tx_offloads(uint64_t offloads)
16497 {
16498 	uint64_t single_offload;
16499 	int begin;
16500 	int end;
16501 	int bit;
16502 
16503 	if (offloads == 0)
16504 		return;
16505 
16506 	begin = __builtin_ctzll(offloads);
16507 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16508 
16509 	single_offload = 1ULL << begin;
16510 	for (bit = begin; bit < end; bit++) {
16511 		if (offloads & single_offload)
16512 			printf(" %s",
16513 			       rte_eth_dev_tx_offload_name(single_offload));
16514 		single_offload <<= 1;
16515 	}
16516 }
16517 
16518 static void
16519 cmd_tx_offload_get_capa_parsed(
16520 	void *parsed_result,
16521 	__rte_unused struct cmdline *cl,
16522 	__rte_unused void *data)
16523 {
16524 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
16525 	struct rte_eth_dev_info dev_info;
16526 	portid_t port_id = res->port_id;
16527 	uint64_t queue_offloads;
16528 	uint64_t port_offloads;
16529 	int ret;
16530 
16531 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16532 	if (ret != 0)
16533 		return;
16534 
16535 	queue_offloads = dev_info.tx_queue_offload_capa;
16536 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16537 
16538 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
16539 	printf("  Per Queue :");
16540 	print_tx_offloads(queue_offloads);
16541 
16542 	printf("\n");
16543 	printf("  Per Port  :");
16544 	print_tx_offloads(port_offloads);
16545 	printf("\n\n");
16546 }
16547 
16548 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16549 	.f = cmd_tx_offload_get_capa_parsed,
16550 	.data = NULL,
16551 	.help_str = "show port <port_id> tx_offload capabilities",
16552 	.tokens = {
16553 		(void *)&cmd_tx_offload_get_capa_show,
16554 		(void *)&cmd_tx_offload_get_capa_port,
16555 		(void *)&cmd_tx_offload_get_capa_port_id,
16556 		(void *)&cmd_tx_offload_get_capa_tx_offload,
16557 		(void *)&cmd_tx_offload_get_capa_capabilities,
16558 		NULL,
16559 	}
16560 };
16561 
16562 /* Get Tx offloads configuration */
16563 struct cmd_tx_offload_get_configuration_result {
16564 	cmdline_fixed_string_t show;
16565 	cmdline_fixed_string_t port;
16566 	portid_t port_id;
16567 	cmdline_fixed_string_t tx_offload;
16568 	cmdline_fixed_string_t configuration;
16569 };
16570 
16571 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16572 	TOKEN_STRING_INITIALIZER
16573 		(struct cmd_tx_offload_get_configuration_result,
16574 		 show, "show");
16575 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16576 	TOKEN_STRING_INITIALIZER
16577 		(struct cmd_tx_offload_get_configuration_result,
16578 		 port, "port");
16579 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16580 	TOKEN_NUM_INITIALIZER
16581 		(struct cmd_tx_offload_get_configuration_result,
16582 		 port_id, RTE_UINT16);
16583 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16584 	TOKEN_STRING_INITIALIZER
16585 		(struct cmd_tx_offload_get_configuration_result,
16586 		 tx_offload, "tx_offload");
16587 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16588 	TOKEN_STRING_INITIALIZER
16589 		(struct cmd_tx_offload_get_configuration_result,
16590 		 configuration, "configuration");
16591 
16592 static void
16593 cmd_tx_offload_get_configuration_parsed(
16594 	void *parsed_result,
16595 	__rte_unused struct cmdline *cl,
16596 	__rte_unused void *data)
16597 {
16598 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16599 	struct rte_eth_dev_info dev_info;
16600 	portid_t port_id = res->port_id;
16601 	struct rte_port *port = &ports[port_id];
16602 	struct rte_eth_conf dev_conf;
16603 	uint64_t port_offloads;
16604 	uint64_t queue_offloads;
16605 	uint16_t nb_tx_queues;
16606 	int q;
16607 	int ret;
16608 
16609 	printf("Tx Offloading Configuration of port %d :\n", port_id);
16610 
16611 	ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16612 	if (ret != 0)
16613 		return;
16614 
16615 	port_offloads = dev_conf.txmode.offloads;
16616 	printf("  Port :");
16617 	print_tx_offloads(port_offloads);
16618 	printf("\n");
16619 
16620 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16621 	if (ret != 0)
16622 		return;
16623 
16624 	nb_tx_queues = dev_info.nb_tx_queues;
16625 	for (q = 0; q < nb_tx_queues; q++) {
16626 		queue_offloads = port->tx_conf[q].offloads;
16627 		printf("  Queue[%2d] :", q);
16628 		print_tx_offloads(queue_offloads);
16629 		printf("\n");
16630 	}
16631 	printf("\n");
16632 }
16633 
16634 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16635 	.f = cmd_tx_offload_get_configuration_parsed,
16636 	.data = NULL,
16637 	.help_str = "show port <port_id> tx_offload configuration",
16638 	.tokens = {
16639 		(void *)&cmd_tx_offload_get_configuration_show,
16640 		(void *)&cmd_tx_offload_get_configuration_port,
16641 		(void *)&cmd_tx_offload_get_configuration_port_id,
16642 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
16643 		(void *)&cmd_tx_offload_get_configuration_configuration,
16644 		NULL,
16645 	}
16646 };
16647 
16648 /* Enable/Disable a per port offloading */
16649 struct cmd_config_per_port_tx_offload_result {
16650 	cmdline_fixed_string_t port;
16651 	cmdline_fixed_string_t config;
16652 	portid_t port_id;
16653 	cmdline_fixed_string_t tx_offload;
16654 	cmdline_fixed_string_t offload;
16655 	cmdline_fixed_string_t on_off;
16656 };
16657 
16658 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16659 	TOKEN_STRING_INITIALIZER
16660 		(struct cmd_config_per_port_tx_offload_result,
16661 		 port, "port");
16662 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16663 	TOKEN_STRING_INITIALIZER
16664 		(struct cmd_config_per_port_tx_offload_result,
16665 		 config, "config");
16666 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16667 	TOKEN_NUM_INITIALIZER
16668 		(struct cmd_config_per_port_tx_offload_result,
16669 		 port_id, RTE_UINT16);
16670 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16671 	TOKEN_STRING_INITIALIZER
16672 		(struct cmd_config_per_port_tx_offload_result,
16673 		 tx_offload, "tx_offload");
16674 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16675 	TOKEN_STRING_INITIALIZER
16676 		(struct cmd_config_per_port_tx_offload_result,
16677 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16678 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16679 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16680 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16681 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16682 			  "send_on_timestamp");
16683 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16684 	TOKEN_STRING_INITIALIZER
16685 		(struct cmd_config_per_port_tx_offload_result,
16686 		 on_off, "on#off");
16687 
16688 static uint64_t
16689 search_tx_offload(const char *name)
16690 {
16691 	uint64_t single_offload;
16692 	const char *single_name;
16693 	int found = 0;
16694 	unsigned int bit;
16695 
16696 	single_offload = 1;
16697 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16698 		single_name = rte_eth_dev_tx_offload_name(single_offload);
16699 		if (single_name == NULL)
16700 			break;
16701 		if (!strcasecmp(single_name, name)) {
16702 			found = 1;
16703 			break;
16704 		} else if (!strcasecmp(single_name, "UNKNOWN"))
16705 			break;
16706 		single_offload <<= 1;
16707 	}
16708 
16709 	if (found)
16710 		return single_offload;
16711 
16712 	return 0;
16713 }
16714 
16715 static void
16716 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16717 				__rte_unused struct cmdline *cl,
16718 				__rte_unused void *data)
16719 {
16720 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16721 	portid_t port_id = res->port_id;
16722 	struct rte_eth_dev_info dev_info;
16723 	struct rte_port *port = &ports[port_id];
16724 	uint64_t single_offload;
16725 	uint16_t nb_tx_queues;
16726 	int q;
16727 	int ret;
16728 
16729 	if (port->port_status != RTE_PORT_STOPPED) {
16730 		fprintf(stderr,
16731 			"Error: Can't config offload when Port %d is not stopped\n",
16732 			port_id);
16733 		return;
16734 	}
16735 
16736 	single_offload = search_tx_offload(res->offload);
16737 	if (single_offload == 0) {
16738 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16739 		return;
16740 	}
16741 
16742 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16743 	if (ret != 0)
16744 		return;
16745 
16746 	nb_tx_queues = dev_info.nb_tx_queues;
16747 	if (!strcmp(res->on_off, "on")) {
16748 		port->dev_conf.txmode.offloads |= single_offload;
16749 		for (q = 0; q < nb_tx_queues; q++)
16750 			port->tx_conf[q].offloads |= single_offload;
16751 	} else {
16752 		port->dev_conf.txmode.offloads &= ~single_offload;
16753 		for (q = 0; q < nb_tx_queues; q++)
16754 			port->tx_conf[q].offloads &= ~single_offload;
16755 	}
16756 
16757 	cmd_reconfig_device_queue(port_id, 1, 1);
16758 }
16759 
16760 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16761 	.f = cmd_config_per_port_tx_offload_parsed,
16762 	.data = NULL,
16763 	.help_str = "port config <port_id> tx_offload "
16764 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16765 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16766 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16767 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16768 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16769 		    "send_on_timestamp on|off",
16770 	.tokens = {
16771 		(void *)&cmd_config_per_port_tx_offload_result_port,
16772 		(void *)&cmd_config_per_port_tx_offload_result_config,
16773 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
16774 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16775 		(void *)&cmd_config_per_port_tx_offload_result_offload,
16776 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
16777 		NULL,
16778 	}
16779 };
16780 
16781 /* Enable/Disable a per queue offloading */
16782 struct cmd_config_per_queue_tx_offload_result {
16783 	cmdline_fixed_string_t port;
16784 	portid_t port_id;
16785 	cmdline_fixed_string_t txq;
16786 	uint16_t queue_id;
16787 	cmdline_fixed_string_t tx_offload;
16788 	cmdline_fixed_string_t offload;
16789 	cmdline_fixed_string_t on_off;
16790 };
16791 
16792 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16793 	TOKEN_STRING_INITIALIZER
16794 		(struct cmd_config_per_queue_tx_offload_result,
16795 		 port, "port");
16796 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16797 	TOKEN_NUM_INITIALIZER
16798 		(struct cmd_config_per_queue_tx_offload_result,
16799 		 port_id, RTE_UINT16);
16800 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16801 	TOKEN_STRING_INITIALIZER
16802 		(struct cmd_config_per_queue_tx_offload_result,
16803 		 txq, "txq");
16804 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16805 	TOKEN_NUM_INITIALIZER
16806 		(struct cmd_config_per_queue_tx_offload_result,
16807 		 queue_id, RTE_UINT16);
16808 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16809 	TOKEN_STRING_INITIALIZER
16810 		(struct cmd_config_per_queue_tx_offload_result,
16811 		 tx_offload, "tx_offload");
16812 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16813 	TOKEN_STRING_INITIALIZER
16814 		(struct cmd_config_per_queue_tx_offload_result,
16815 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16816 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16817 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16818 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16819 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
16820 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16821 	TOKEN_STRING_INITIALIZER
16822 		(struct cmd_config_per_queue_tx_offload_result,
16823 		 on_off, "on#off");
16824 
16825 static void
16826 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16827 				__rte_unused struct cmdline *cl,
16828 				__rte_unused void *data)
16829 {
16830 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16831 	struct rte_eth_dev_info dev_info;
16832 	portid_t port_id = res->port_id;
16833 	uint16_t queue_id = res->queue_id;
16834 	struct rte_port *port = &ports[port_id];
16835 	uint64_t single_offload;
16836 	int ret;
16837 
16838 	if (port->port_status != RTE_PORT_STOPPED) {
16839 		fprintf(stderr,
16840 			"Error: Can't config offload when Port %d is not stopped\n",
16841 			port_id);
16842 		return;
16843 	}
16844 
16845 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16846 	if (ret != 0)
16847 		return;
16848 
16849 	if (queue_id >= dev_info.nb_tx_queues) {
16850 		fprintf(stderr,
16851 			"Error: input queue_id should be 0 ... %d\n",
16852 			dev_info.nb_tx_queues - 1);
16853 		return;
16854 	}
16855 
16856 	single_offload = search_tx_offload(res->offload);
16857 	if (single_offload == 0) {
16858 		fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16859 		return;
16860 	}
16861 
16862 	if (!strcmp(res->on_off, "on"))
16863 		port->tx_conf[queue_id].offloads |= single_offload;
16864 	else
16865 		port->tx_conf[queue_id].offloads &= ~single_offload;
16866 
16867 	cmd_reconfig_device_queue(port_id, 1, 1);
16868 }
16869 
16870 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16871 	.f = cmd_config_per_queue_tx_offload_parsed,
16872 	.data = NULL,
16873 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16874 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16875 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16876 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16877 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16878 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16879 		    "on|off",
16880 	.tokens = {
16881 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16882 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16883 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16884 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16885 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16886 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16887 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16888 		NULL,
16889 	}
16890 };
16891 
16892 /* *** configure tx_metadata for specific port *** */
16893 struct cmd_config_tx_metadata_specific_result {
16894 	cmdline_fixed_string_t port;
16895 	cmdline_fixed_string_t keyword;
16896 	uint16_t port_id;
16897 	cmdline_fixed_string_t item;
16898 	uint32_t value;
16899 };
16900 
16901 static void
16902 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16903 				__rte_unused struct cmdline *cl,
16904 				__rte_unused void *data)
16905 {
16906 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16907 
16908 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16909 		return;
16910 	ports[res->port_id].tx_metadata = res->value;
16911 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16912 	if (ports[res->port_id].tx_metadata)
16913 		add_tx_md_callback(res->port_id);
16914 	else
16915 		remove_tx_md_callback(res->port_id);
16916 	rte_flow_dynf_metadata_register();
16917 }
16918 
16919 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16920 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16921 			port, "port");
16922 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16923 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16924 			keyword, "config");
16925 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16926 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16927 			port_id, RTE_UINT16);
16928 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16929 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16930 			item, "tx_metadata");
16931 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16932 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16933 			value, RTE_UINT32);
16934 
16935 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16936 	.f = cmd_config_tx_metadata_specific_parsed,
16937 	.data = NULL,
16938 	.help_str = "port config <port_id> tx_metadata <value>",
16939 	.tokens = {
16940 		(void *)&cmd_config_tx_metadata_specific_port,
16941 		(void *)&cmd_config_tx_metadata_specific_keyword,
16942 		(void *)&cmd_config_tx_metadata_specific_id,
16943 		(void *)&cmd_config_tx_metadata_specific_item,
16944 		(void *)&cmd_config_tx_metadata_specific_value,
16945 		NULL,
16946 	},
16947 };
16948 
16949 /* *** set dynf *** */
16950 struct cmd_config_tx_dynf_specific_result {
16951 	cmdline_fixed_string_t port;
16952 	cmdline_fixed_string_t keyword;
16953 	uint16_t port_id;
16954 	cmdline_fixed_string_t item;
16955 	cmdline_fixed_string_t name;
16956 	cmdline_fixed_string_t value;
16957 };
16958 
16959 static void
16960 cmd_config_dynf_specific_parsed(void *parsed_result,
16961 				__rte_unused struct cmdline *cl,
16962 				__rte_unused void *data)
16963 {
16964 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16965 	struct rte_mbuf_dynflag desc_flag;
16966 	int flag;
16967 	uint64_t old_port_flags;
16968 
16969 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16970 		return;
16971 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16972 	if (flag <= 0) {
16973 		if (strlcpy(desc_flag.name, res->name,
16974 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16975 			fprintf(stderr, "Flag name too long\n");
16976 			return;
16977 		}
16978 		desc_flag.flags = 0;
16979 		flag = rte_mbuf_dynflag_register(&desc_flag);
16980 		if (flag < 0) {
16981 			fprintf(stderr, "Can't register flag\n");
16982 			return;
16983 		}
16984 		strcpy(dynf_names[flag], desc_flag.name);
16985 	}
16986 	old_port_flags = ports[res->port_id].mbuf_dynf;
16987 	if (!strcmp(res->value, "set")) {
16988 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16989 		if (old_port_flags == 0)
16990 			add_tx_dynf_callback(res->port_id);
16991 	} else {
16992 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16993 		if (ports[res->port_id].mbuf_dynf == 0)
16994 			remove_tx_dynf_callback(res->port_id);
16995 	}
16996 }
16997 
16998 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16999 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17000 			keyword, "port");
17001 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17002 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17003 			keyword, "config");
17004 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17005 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17006 			port_id, RTE_UINT16);
17007 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17008 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17009 			item, "dynf");
17010 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17011 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17012 			name, NULL);
17013 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17014 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17015 			value, "set#clear");
17016 
17017 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17018 	.f = cmd_config_dynf_specific_parsed,
17019 	.data = NULL,
17020 	.help_str = "port config <port id> dynf <name> set|clear",
17021 	.tokens = {
17022 		(void *)&cmd_config_tx_dynf_specific_port,
17023 		(void *)&cmd_config_tx_dynf_specific_keyword,
17024 		(void *)&cmd_config_tx_dynf_specific_port_id,
17025 		(void *)&cmd_config_tx_dynf_specific_item,
17026 		(void *)&cmd_config_tx_dynf_specific_name,
17027 		(void *)&cmd_config_tx_dynf_specific_value,
17028 		NULL,
17029 	},
17030 };
17031 
17032 /* *** display tx_metadata per port configuration *** */
17033 struct cmd_show_tx_metadata_result {
17034 	cmdline_fixed_string_t cmd_show;
17035 	cmdline_fixed_string_t cmd_port;
17036 	cmdline_fixed_string_t cmd_keyword;
17037 	portid_t cmd_pid;
17038 };
17039 
17040 static void
17041 cmd_show_tx_metadata_parsed(void *parsed_result,
17042 		__rte_unused struct cmdline *cl,
17043 		__rte_unused void *data)
17044 {
17045 	struct cmd_show_tx_metadata_result *res = parsed_result;
17046 
17047 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17048 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17049 		return;
17050 	}
17051 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17052 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17053 		       ports[res->cmd_pid].tx_metadata);
17054 	}
17055 }
17056 
17057 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17058 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17059 			cmd_show, "show");
17060 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17061 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17062 			cmd_port, "port");
17063 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17064 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17065 			cmd_pid, RTE_UINT16);
17066 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17067 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17068 			cmd_keyword, "tx_metadata");
17069 
17070 cmdline_parse_inst_t cmd_show_tx_metadata = {
17071 	.f = cmd_show_tx_metadata_parsed,
17072 	.data = NULL,
17073 	.help_str = "show port <port_id> tx_metadata",
17074 	.tokens = {
17075 		(void *)&cmd_show_tx_metadata_show,
17076 		(void *)&cmd_show_tx_metadata_port,
17077 		(void *)&cmd_show_tx_metadata_pid,
17078 		(void *)&cmd_show_tx_metadata_keyword,
17079 		NULL,
17080 	},
17081 };
17082 
17083 /* *** show fec capability per port configuration *** */
17084 struct cmd_show_fec_capability_result {
17085 	cmdline_fixed_string_t cmd_show;
17086 	cmdline_fixed_string_t cmd_port;
17087 	cmdline_fixed_string_t cmd_fec;
17088 	cmdline_fixed_string_t cmd_keyword;
17089 	portid_t cmd_pid;
17090 };
17091 
17092 static void
17093 cmd_show_fec_capability_parsed(void *parsed_result,
17094 		__rte_unused struct cmdline *cl,
17095 		__rte_unused void *data)
17096 {
17097 	struct cmd_show_fec_capability_result *res = parsed_result;
17098 	struct rte_eth_fec_capa *speed_fec_capa;
17099 	unsigned int num;
17100 	int ret;
17101 
17102 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17103 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17104 		return;
17105 	}
17106 
17107 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17108 	if (ret == -ENOTSUP) {
17109 		fprintf(stderr, "Function not implemented\n");
17110 		return;
17111 	} else if (ret < 0) {
17112 		fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17113 		return;
17114 	}
17115 
17116 	num = (unsigned int)ret;
17117 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17118 	if (speed_fec_capa == NULL) {
17119 		fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17120 		return;
17121 	}
17122 
17123 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17124 	if (ret < 0) {
17125 		fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17126 		goto out;
17127 	}
17128 
17129 	show_fec_capability(num, speed_fec_capa);
17130 out:
17131 	free(speed_fec_capa);
17132 }
17133 
17134 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17135 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17136 			cmd_show, "show");
17137 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17138 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17139 			cmd_port, "port");
17140 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17141 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17142 			cmd_pid, RTE_UINT16);
17143 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17144 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17145 			cmd_fec, "fec");
17146 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17147 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17148 			cmd_keyword, "capabilities");
17149 
17150 cmdline_parse_inst_t cmd_show_capability = {
17151 	.f = cmd_show_fec_capability_parsed,
17152 	.data = NULL,
17153 	.help_str = "show port <port_id> fec capabilities",
17154 	.tokens = {
17155 		(void *)&cmd_show_fec_capability_show,
17156 		(void *)&cmd_show_fec_capability_port,
17157 		(void *)&cmd_show_fec_capability_pid,
17158 		(void *)&cmd_show_fec_capability_fec,
17159 		(void *)&cmd_show_fec_capability_keyword,
17160 		NULL,
17161 	},
17162 };
17163 
17164 /* *** show fec mode per port configuration *** */
17165 struct cmd_show_fec_metadata_result {
17166 	cmdline_fixed_string_t cmd_show;
17167 	cmdline_fixed_string_t cmd_port;
17168 	cmdline_fixed_string_t cmd_keyword;
17169 	portid_t cmd_pid;
17170 };
17171 
17172 static void
17173 cmd_show_fec_mode_parsed(void *parsed_result,
17174 		__rte_unused struct cmdline *cl,
17175 		__rte_unused void *data)
17176 {
17177 #define FEC_NAME_SIZE 16
17178 	struct cmd_show_fec_metadata_result *res = parsed_result;
17179 	uint32_t mode;
17180 	char buf[FEC_NAME_SIZE];
17181 	int ret;
17182 
17183 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17184 		fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17185 		return;
17186 	}
17187 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
17188 	if (ret == -ENOTSUP) {
17189 		fprintf(stderr, "Function not implemented\n");
17190 		return;
17191 	} else if (ret < 0) {
17192 		fprintf(stderr, "Get FEC mode failed\n");
17193 		return;
17194 	}
17195 
17196 	switch (mode) {
17197 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17198 		strlcpy(buf, "off", sizeof(buf));
17199 		break;
17200 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17201 		strlcpy(buf, "auto", sizeof(buf));
17202 		break;
17203 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17204 		strlcpy(buf, "baser", sizeof(buf));
17205 		break;
17206 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17207 		strlcpy(buf, "rs", sizeof(buf));
17208 		break;
17209 	default:
17210 		return;
17211 	}
17212 
17213 	printf("%s\n", buf);
17214 }
17215 
17216 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17217 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17218 			cmd_show, "show");
17219 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17220 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17221 			cmd_port, "port");
17222 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17223 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17224 			cmd_pid, RTE_UINT16);
17225 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17226 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17227 			cmd_keyword, "fec_mode");
17228 
17229 cmdline_parse_inst_t cmd_show_fec_mode = {
17230 	.f = cmd_show_fec_mode_parsed,
17231 	.data = NULL,
17232 	.help_str = "show port <port_id> fec_mode",
17233 	.tokens = {
17234 		(void *)&cmd_show_fec_mode_show,
17235 		(void *)&cmd_show_fec_mode_port,
17236 		(void *)&cmd_show_fec_mode_pid,
17237 		(void *)&cmd_show_fec_mode_keyword,
17238 		NULL,
17239 	},
17240 };
17241 
17242 /* *** set fec mode per port configuration *** */
17243 struct cmd_set_port_fec_mode {
17244 	cmdline_fixed_string_t set;
17245 	cmdline_fixed_string_t port;
17246 	portid_t port_id;
17247 	cmdline_fixed_string_t fec_mode;
17248 	cmdline_fixed_string_t fec_value;
17249 };
17250 
17251 /* Common CLI fields for set fec mode */
17252 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17253 	TOKEN_STRING_INITIALIZER
17254 		(struct cmd_set_port_fec_mode,
17255 		 set, "set");
17256 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17257 	TOKEN_STRING_INITIALIZER
17258 		(struct cmd_set_port_fec_mode,
17259 		 port, "port");
17260 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17261 	TOKEN_NUM_INITIALIZER
17262 		(struct cmd_set_port_fec_mode,
17263 		 port_id, RTE_UINT16);
17264 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17265 	TOKEN_STRING_INITIALIZER
17266 		(struct cmd_set_port_fec_mode,
17267 		 fec_mode, "fec_mode");
17268 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17269 	TOKEN_STRING_INITIALIZER
17270 		(struct cmd_set_port_fec_mode,
17271 		 fec_value, NULL);
17272 
17273 static void
17274 cmd_set_port_fec_mode_parsed(
17275 	void *parsed_result,
17276 	__rte_unused struct cmdline *cl,
17277 	__rte_unused void *data)
17278 {
17279 	struct cmd_set_port_fec_mode *res = parsed_result;
17280 	uint16_t port_id = res->port_id;
17281 	uint32_t fec_capa;
17282 	int ret;
17283 
17284 	ret = parse_fec_mode(res->fec_value, &fec_capa);
17285 	if (ret < 0) {
17286 		fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17287 				res->fec_value,	port_id);
17288 		return;
17289 	}
17290 
17291 	ret = rte_eth_fec_set(port_id, fec_capa);
17292 	if (ret == -ENOTSUP) {
17293 		fprintf(stderr, "Function not implemented\n");
17294 		return;
17295 	} else if (ret < 0) {
17296 		fprintf(stderr, "Set FEC mode failed\n");
17297 		return;
17298 	}
17299 }
17300 
17301 cmdline_parse_inst_t cmd_set_fec_mode = {
17302 	.f = cmd_set_port_fec_mode_parsed,
17303 	.data = NULL,
17304 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17305 	.tokens = {
17306 		(void *)&cmd_set_port_fec_mode_set,
17307 		(void *)&cmd_set_port_fec_mode_port,
17308 		(void *)&cmd_set_port_fec_mode_port_id,
17309 		(void *)&cmd_set_port_fec_mode_str,
17310 		(void *)&cmd_set_port_fec_mode_value,
17311 		NULL,
17312 	},
17313 };
17314 
17315 /* show port supported ptypes */
17316 
17317 /* Common result structure for show port ptypes */
17318 struct cmd_show_port_supported_ptypes_result {
17319 	cmdline_fixed_string_t show;
17320 	cmdline_fixed_string_t port;
17321 	portid_t port_id;
17322 	cmdline_fixed_string_t ptypes;
17323 };
17324 
17325 /* Common CLI fields for show port ptypes */
17326 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17327 	TOKEN_STRING_INITIALIZER
17328 		(struct cmd_show_port_supported_ptypes_result,
17329 		 show, "show");
17330 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17331 	TOKEN_STRING_INITIALIZER
17332 		(struct cmd_show_port_supported_ptypes_result,
17333 		 port, "port");
17334 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17335 	TOKEN_NUM_INITIALIZER
17336 		(struct cmd_show_port_supported_ptypes_result,
17337 		 port_id, RTE_UINT16);
17338 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17339 	TOKEN_STRING_INITIALIZER
17340 		(struct cmd_show_port_supported_ptypes_result,
17341 		 ptypes, "ptypes");
17342 
17343 static void
17344 cmd_show_port_supported_ptypes_parsed(
17345 	void *parsed_result,
17346 	__rte_unused struct cmdline *cl,
17347 	__rte_unused void *data)
17348 {
17349 #define RSVD_PTYPE_MASK       0xf0000000
17350 #define MAX_PTYPES_PER_LAYER  16
17351 #define LTYPE_NAMESIZE        32
17352 #define PTYPE_NAMESIZE        256
17353 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17354 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17355 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17356 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17357 	uint16_t port_id = res->port_id;
17358 	int ret, i;
17359 
17360 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17361 	if (ret < 0)
17362 		return;
17363 
17364 	while (ptype_mask != RSVD_PTYPE_MASK) {
17365 
17366 		switch (ptype_mask) {
17367 		case RTE_PTYPE_L2_MASK:
17368 			strlcpy(ltype, "L2", sizeof(ltype));
17369 			break;
17370 		case RTE_PTYPE_L3_MASK:
17371 			strlcpy(ltype, "L3", sizeof(ltype));
17372 			break;
17373 		case RTE_PTYPE_L4_MASK:
17374 			strlcpy(ltype, "L4", sizeof(ltype));
17375 			break;
17376 		case RTE_PTYPE_TUNNEL_MASK:
17377 			strlcpy(ltype, "Tunnel", sizeof(ltype));
17378 			break;
17379 		case RTE_PTYPE_INNER_L2_MASK:
17380 			strlcpy(ltype, "Inner L2", sizeof(ltype));
17381 			break;
17382 		case RTE_PTYPE_INNER_L3_MASK:
17383 			strlcpy(ltype, "Inner L3", sizeof(ltype));
17384 			break;
17385 		case RTE_PTYPE_INNER_L4_MASK:
17386 			strlcpy(ltype, "Inner L4", sizeof(ltype));
17387 			break;
17388 		default:
17389 			return;
17390 		}
17391 
17392 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17393 						       ptype_mask, ptypes,
17394 						       MAX_PTYPES_PER_LAYER);
17395 
17396 		if (ret > 0)
17397 			printf("Supported %s ptypes:\n", ltype);
17398 		else
17399 			printf("%s ptypes unsupported\n", ltype);
17400 
17401 		for (i = 0; i < ret; ++i) {
17402 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17403 			printf("%s\n", buf);
17404 		}
17405 
17406 		ptype_mask <<= 4;
17407 	}
17408 }
17409 
17410 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17411 	.f = cmd_show_port_supported_ptypes_parsed,
17412 	.data = NULL,
17413 	.help_str = "show port <port_id> ptypes",
17414 	.tokens = {
17415 		(void *)&cmd_show_port_supported_ptypes_show,
17416 		(void *)&cmd_show_port_supported_ptypes_port,
17417 		(void *)&cmd_show_port_supported_ptypes_port_id,
17418 		(void *)&cmd_show_port_supported_ptypes_ptypes,
17419 		NULL,
17420 	},
17421 };
17422 
17423 /* *** display rx/tx descriptor status *** */
17424 struct cmd_show_rx_tx_desc_status_result {
17425 	cmdline_fixed_string_t cmd_show;
17426 	cmdline_fixed_string_t cmd_port;
17427 	cmdline_fixed_string_t cmd_keyword;
17428 	cmdline_fixed_string_t cmd_desc;
17429 	cmdline_fixed_string_t cmd_status;
17430 	portid_t cmd_pid;
17431 	portid_t cmd_qid;
17432 	portid_t cmd_did;
17433 };
17434 
17435 static void
17436 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17437 		__rte_unused struct cmdline *cl,
17438 		__rte_unused void *data)
17439 {
17440 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17441 	int rc;
17442 
17443 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17444 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17445 		return;
17446 	}
17447 
17448 	if (!strcmp(res->cmd_keyword, "rxq")) {
17449 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17450 					     res->cmd_did);
17451 		if (rc < 0) {
17452 			fprintf(stderr,
17453 				"Invalid input: queue id = %d, desc id = %d\n",
17454 				res->cmd_qid, res->cmd_did);
17455 			return;
17456 		}
17457 		if (rc == RTE_ETH_RX_DESC_AVAIL)
17458 			printf("Desc status = AVAILABLE\n");
17459 		else if (rc == RTE_ETH_RX_DESC_DONE)
17460 			printf("Desc status = DONE\n");
17461 		else
17462 			printf("Desc status = UNAVAILABLE\n");
17463 	} else if (!strcmp(res->cmd_keyword, "txq")) {
17464 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17465 					     res->cmd_did);
17466 		if (rc < 0) {
17467 			fprintf(stderr,
17468 				"Invalid input: queue id = %d, desc id = %d\n",
17469 				res->cmd_qid, res->cmd_did);
17470 			return;
17471 		}
17472 		if (rc == RTE_ETH_TX_DESC_FULL)
17473 			printf("Desc status = FULL\n");
17474 		else if (rc == RTE_ETH_TX_DESC_DONE)
17475 			printf("Desc status = DONE\n");
17476 		else
17477 			printf("Desc status = UNAVAILABLE\n");
17478 	}
17479 }
17480 
17481 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17482 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17483 			cmd_show, "show");
17484 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17485 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17486 			cmd_port, "port");
17487 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17488 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17489 			cmd_pid, RTE_UINT16);
17490 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17491 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17492 			cmd_keyword, "rxq#txq");
17493 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17494 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17495 			cmd_qid, RTE_UINT16);
17496 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17497 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17498 			cmd_desc, "desc");
17499 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17500 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17501 			cmd_did, RTE_UINT16);
17502 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17503 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17504 			cmd_status, "status");
17505 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17506 	.f = cmd_show_rx_tx_desc_status_parsed,
17507 	.data = NULL,
17508 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17509 		"status",
17510 	.tokens = {
17511 		(void *)&cmd_show_rx_tx_desc_status_show,
17512 		(void *)&cmd_show_rx_tx_desc_status_port,
17513 		(void *)&cmd_show_rx_tx_desc_status_pid,
17514 		(void *)&cmd_show_rx_tx_desc_status_keyword,
17515 		(void *)&cmd_show_rx_tx_desc_status_qid,
17516 		(void *)&cmd_show_rx_tx_desc_status_desc,
17517 		(void *)&cmd_show_rx_tx_desc_status_did,
17518 		(void *)&cmd_show_rx_tx_desc_status_status,
17519 		NULL,
17520 	},
17521 };
17522 
17523 /* *** display rx queue desc used count *** */
17524 struct cmd_show_rx_queue_desc_used_count_result {
17525 	cmdline_fixed_string_t cmd_show;
17526 	cmdline_fixed_string_t cmd_port;
17527 	cmdline_fixed_string_t cmd_rxq;
17528 	cmdline_fixed_string_t cmd_desc;
17529 	cmdline_fixed_string_t cmd_used;
17530 	cmdline_fixed_string_t cmd_count;
17531 	portid_t cmd_pid;
17532 	portid_t cmd_qid;
17533 };
17534 
17535 static void
17536 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17537 		__rte_unused struct cmdline *cl,
17538 		__rte_unused void *data)
17539 {
17540 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17541 	int rc;
17542 
17543 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17544 		fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17545 		return;
17546 	}
17547 
17548 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17549 	if (rc < 0) {
17550 		fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17551 		return;
17552 	}
17553 	printf("Used desc count = %d\n", rc);
17554 }
17555 
17556 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17557 	TOKEN_STRING_INITIALIZER
17558 		(struct cmd_show_rx_queue_desc_used_count_result,
17559 		 cmd_show, "show");
17560 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17561 	TOKEN_STRING_INITIALIZER
17562 		(struct cmd_show_rx_queue_desc_used_count_result,
17563 		 cmd_port, "port");
17564 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17565 	TOKEN_NUM_INITIALIZER
17566 		(struct cmd_show_rx_queue_desc_used_count_result,
17567 		 cmd_pid, RTE_UINT16);
17568 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17569 	TOKEN_STRING_INITIALIZER
17570 		(struct cmd_show_rx_queue_desc_used_count_result,
17571 		 cmd_rxq, "rxq");
17572 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17573 	TOKEN_NUM_INITIALIZER
17574 		(struct cmd_show_rx_queue_desc_used_count_result,
17575 		 cmd_qid, RTE_UINT16);
17576 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17577 	TOKEN_STRING_INITIALIZER
17578 		(struct cmd_show_rx_queue_desc_used_count_result,
17579 		 cmd_count, "desc");
17580 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17581 	TOKEN_STRING_INITIALIZER
17582 		(struct cmd_show_rx_queue_desc_used_count_result,
17583 		 cmd_count, "used");
17584 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17585 	TOKEN_STRING_INITIALIZER
17586 		(struct cmd_show_rx_queue_desc_used_count_result,
17587 		 cmd_count, "count");
17588 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17589 	.f = cmd_show_rx_queue_desc_used_count_parsed,
17590 	.data = NULL,
17591 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
17592 	.tokens = {
17593 		(void *)&cmd_show_rx_queue_desc_used_count_show,
17594 		(void *)&cmd_show_rx_queue_desc_used_count_port,
17595 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
17596 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
17597 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
17598 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
17599 		(void *)&cmd_show_rx_queue_desc_used_count_used,
17600 		(void *)&cmd_show_rx_queue_desc_used_count_count,
17601 		NULL,
17602 	},
17603 };
17604 
17605 /* Common result structure for set port ptypes */
17606 struct cmd_set_port_ptypes_result {
17607 	cmdline_fixed_string_t set;
17608 	cmdline_fixed_string_t port;
17609 	portid_t port_id;
17610 	cmdline_fixed_string_t ptype_mask;
17611 	uint32_t mask;
17612 };
17613 
17614 /* Common CLI fields for set port ptypes */
17615 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17616 	TOKEN_STRING_INITIALIZER
17617 		(struct cmd_set_port_ptypes_result,
17618 		 set, "set");
17619 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17620 	TOKEN_STRING_INITIALIZER
17621 		(struct cmd_set_port_ptypes_result,
17622 		 port, "port");
17623 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17624 	TOKEN_NUM_INITIALIZER
17625 		(struct cmd_set_port_ptypes_result,
17626 		 port_id, RTE_UINT16);
17627 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17628 	TOKEN_STRING_INITIALIZER
17629 		(struct cmd_set_port_ptypes_result,
17630 		 ptype_mask, "ptype_mask");
17631 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17632 	TOKEN_NUM_INITIALIZER
17633 		(struct cmd_set_port_ptypes_result,
17634 		 mask, RTE_UINT32);
17635 
17636 static void
17637 cmd_set_port_ptypes_parsed(
17638 	void *parsed_result,
17639 	__rte_unused struct cmdline *cl,
17640 	__rte_unused void *data)
17641 {
17642 	struct cmd_set_port_ptypes_result *res = parsed_result;
17643 #define PTYPE_NAMESIZE        256
17644 	char ptype_name[PTYPE_NAMESIZE];
17645 	uint16_t port_id = res->port_id;
17646 	uint32_t ptype_mask = res->mask;
17647 	int ret, i;
17648 
17649 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17650 					       NULL, 0);
17651 	if (ret <= 0) {
17652 		fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17653 			port_id);
17654 		return;
17655 	}
17656 
17657 	uint32_t ptypes[ret];
17658 
17659 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17660 	if (ret < 0) {
17661 		fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17662 			port_id);
17663 		return;
17664 	}
17665 
17666 	printf("Successfully set following ptypes for Port %d\n", port_id);
17667 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17668 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17669 		printf("%s\n", ptype_name);
17670 	}
17671 
17672 	clear_ptypes = false;
17673 }
17674 
17675 cmdline_parse_inst_t cmd_set_port_ptypes = {
17676 	.f = cmd_set_port_ptypes_parsed,
17677 	.data = NULL,
17678 	.help_str = "set port <port_id> ptype_mask <mask>",
17679 	.tokens = {
17680 		(void *)&cmd_set_port_ptypes_set,
17681 		(void *)&cmd_set_port_ptypes_port,
17682 		(void *)&cmd_set_port_ptypes_port_id,
17683 		(void *)&cmd_set_port_ptypes_mask_str,
17684 		(void *)&cmd_set_port_ptypes_mask_u32,
17685 		NULL,
17686 	},
17687 };
17688 
17689 /* *** display mac addresses added to a port *** */
17690 struct cmd_showport_macs_result {
17691 	cmdline_fixed_string_t cmd_show;
17692 	cmdline_fixed_string_t cmd_port;
17693 	cmdline_fixed_string_t cmd_keyword;
17694 	portid_t cmd_pid;
17695 };
17696 
17697 static void
17698 cmd_showport_macs_parsed(void *parsed_result,
17699 		__rte_unused struct cmdline *cl,
17700 		__rte_unused void *data)
17701 {
17702 	struct cmd_showport_macs_result *res = parsed_result;
17703 
17704 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17705 		return;
17706 
17707 	if (!strcmp(res->cmd_keyword, "macs"))
17708 		show_macs(res->cmd_pid);
17709 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17710 		show_mcast_macs(res->cmd_pid);
17711 }
17712 
17713 cmdline_parse_token_string_t cmd_showport_macs_show =
17714 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17715 			cmd_show, "show");
17716 cmdline_parse_token_string_t cmd_showport_macs_port =
17717 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17718 			cmd_port, "port");
17719 cmdline_parse_token_num_t cmd_showport_macs_pid =
17720 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17721 			cmd_pid, RTE_UINT16);
17722 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17723 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17724 			cmd_keyword, "macs#mcast_macs");
17725 
17726 cmdline_parse_inst_t cmd_showport_macs = {
17727 	.f = cmd_showport_macs_parsed,
17728 	.data = NULL,
17729 	.help_str = "show port <port_id> macs|mcast_macs",
17730 	.tokens = {
17731 		(void *)&cmd_showport_macs_show,
17732 		(void *)&cmd_showport_macs_port,
17733 		(void *)&cmd_showport_macs_pid,
17734 		(void *)&cmd_showport_macs_keyword,
17735 		NULL,
17736 	},
17737 };
17738 
17739 /* *** show flow transfer proxy port ID for the given port *** */
17740 struct cmd_show_port_flow_transfer_proxy_result {
17741 	cmdline_fixed_string_t show;
17742 	cmdline_fixed_string_t port;
17743 	portid_t port_id;
17744 	cmdline_fixed_string_t flow;
17745 	cmdline_fixed_string_t transfer;
17746 	cmdline_fixed_string_t proxy;
17747 };
17748 
17749 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17750 	TOKEN_STRING_INITIALIZER
17751 		(struct cmd_show_port_flow_transfer_proxy_result,
17752 		 show, "show");
17753 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17754 	TOKEN_STRING_INITIALIZER
17755 		(struct cmd_show_port_flow_transfer_proxy_result,
17756 		 port, "port");
17757 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17758 	TOKEN_NUM_INITIALIZER
17759 		(struct cmd_show_port_flow_transfer_proxy_result,
17760 		 port_id, RTE_UINT16);
17761 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17762 	TOKEN_STRING_INITIALIZER
17763 		(struct cmd_show_port_flow_transfer_proxy_result,
17764 		 flow, "flow");
17765 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17766 	TOKEN_STRING_INITIALIZER
17767 		(struct cmd_show_port_flow_transfer_proxy_result,
17768 		 transfer, "transfer");
17769 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17770 	TOKEN_STRING_INITIALIZER
17771 		(struct cmd_show_port_flow_transfer_proxy_result,
17772 		 proxy, "proxy");
17773 
17774 static void
17775 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17776 					 __rte_unused struct cmdline *cl,
17777 					 __rte_unused void *data)
17778 {
17779 	struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17780 	portid_t proxy_port_id;
17781 	int ret;
17782 
17783 	printf("\n");
17784 
17785 	ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17786 	if (ret != 0) {
17787 		fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17788 			rte_strerror(-ret));
17789 		return;
17790 	}
17791 
17792 	printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17793 }
17794 
17795 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17796 	.f = cmd_show_port_flow_transfer_proxy_parsed,
17797 	.data = NULL,
17798 	.help_str = "show port <port_id> flow transfer proxy",
17799 	.tokens = {
17800 		(void *)&cmd_show_port_flow_transfer_proxy_show,
17801 		(void *)&cmd_show_port_flow_transfer_proxy_port,
17802 		(void *)&cmd_show_port_flow_transfer_proxy_port_id,
17803 		(void *)&cmd_show_port_flow_transfer_proxy_flow,
17804 		(void *)&cmd_show_port_flow_transfer_proxy_transfer,
17805 		(void *)&cmd_show_port_flow_transfer_proxy_proxy,
17806 		NULL,
17807 	}
17808 };
17809 
17810 /* ******************************************************************************** */
17811 
17812 /* list of instructions */
17813 cmdline_parse_ctx_t main_ctx[] = {
17814 	(cmdline_parse_inst_t *)&cmd_help_brief,
17815 	(cmdline_parse_inst_t *)&cmd_help_long,
17816 	(cmdline_parse_inst_t *)&cmd_quit,
17817 	(cmdline_parse_inst_t *)&cmd_load_from_file,
17818 	(cmdline_parse_inst_t *)&cmd_showport,
17819 	(cmdline_parse_inst_t *)&cmd_showqueue,
17820 	(cmdline_parse_inst_t *)&cmd_showeeprom,
17821 	(cmdline_parse_inst_t *)&cmd_showportall,
17822 	(cmdline_parse_inst_t *)&cmd_representor_info,
17823 	(cmdline_parse_inst_t *)&cmd_showdevice,
17824 	(cmdline_parse_inst_t *)&cmd_showcfg,
17825 	(cmdline_parse_inst_t *)&cmd_showfwdall,
17826 	(cmdline_parse_inst_t *)&cmd_start,
17827 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
17828 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17829 	(cmdline_parse_inst_t *)&cmd_set_link_up,
17830 	(cmdline_parse_inst_t *)&cmd_set_link_down,
17831 	(cmdline_parse_inst_t *)&cmd_reset,
17832 	(cmdline_parse_inst_t *)&cmd_set_numbers,
17833 	(cmdline_parse_inst_t *)&cmd_set_log,
17834 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
17835 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
17836 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
17837 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
17838 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
17839 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
17840 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17841 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17842 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17843 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17844 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17845 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17846 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17847 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17848 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
17849 	(cmdline_parse_inst_t *)&cmd_set_link_check,
17850 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17851 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
17852 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17853 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
17854 #ifdef RTE_NET_BOND
17855 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17856 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
17857 	(cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17858 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17859 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17860 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17861 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
17862 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17863 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17864 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17865 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17866 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17867 #endif
17868 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
17869 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
17870 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17871 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17872 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17873 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17874 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17875 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17876 	(cmdline_parse_inst_t *)&cmd_csum_set,
17877 	(cmdline_parse_inst_t *)&cmd_csum_show,
17878 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
17879 	(cmdline_parse_inst_t *)&cmd_tso_set,
17880 	(cmdline_parse_inst_t *)&cmd_tso_show,
17881 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17882 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17883 #ifdef RTE_LIB_GRO
17884 	(cmdline_parse_inst_t *)&cmd_gro_enable,
17885 	(cmdline_parse_inst_t *)&cmd_gro_flush,
17886 	(cmdline_parse_inst_t *)&cmd_gro_show,
17887 #endif
17888 #ifdef RTE_LIB_GSO
17889 	(cmdline_parse_inst_t *)&cmd_gso_enable,
17890 	(cmdline_parse_inst_t *)&cmd_gso_size,
17891 	(cmdline_parse_inst_t *)&cmd_gso_show,
17892 #endif
17893 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17894 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17895 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17896 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17897 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17898 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17899 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17900 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17901 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17902 	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17903 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17904 	(cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17905 	(cmdline_parse_inst_t *)&cmd_config_dcb,
17906 	(cmdline_parse_inst_t *)&cmd_read_reg,
17907 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17908 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
17909 	(cmdline_parse_inst_t *)&cmd_write_reg,
17910 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17911 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
17912 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17913 	(cmdline_parse_inst_t *)&cmd_stop,
17914 	(cmdline_parse_inst_t *)&cmd_mac_addr,
17915 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17916 	(cmdline_parse_inst_t *)&cmd_set_qmap,
17917 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17918 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17919 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17920 	(cmdline_parse_inst_t *)&cmd_operate_port,
17921 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
17922 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
17923 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
17924 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
17925 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17926 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
17927 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
17928 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
17929 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17930 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
17931 	(cmdline_parse_inst_t *)&cmd_config_mtu,
17932 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17933 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17934 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17935 	(cmdline_parse_inst_t *)&cmd_config_rss,
17936 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17937 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17938 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17939 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17940 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
17941 	(cmdline_parse_inst_t *)&cmd_showport_reta,
17942 	(cmdline_parse_inst_t *)&cmd_showport_macs,
17943 	(cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17944 	(cmdline_parse_inst_t *)&cmd_config_burst,
17945 	(cmdline_parse_inst_t *)&cmd_config_thresh,
17946 	(cmdline_parse_inst_t *)&cmd_config_threshold,
17947 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17948 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17949 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17950 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17951 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17952 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17953 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17954 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17955 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17956 	(cmdline_parse_inst_t *)&cmd_dump,
17957 	(cmdline_parse_inst_t *)&cmd_dump_one,
17958 #ifdef RTE_NET_I40E
17959 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17960 #endif
17961 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17962 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17963 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17964 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17965 	(cmdline_parse_inst_t *)&cmd_flow,
17966 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17967 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17968 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17969 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17970 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
17971 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
17972 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
17973 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
17974 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17975 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17976 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17977 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17978 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17979 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
17980 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17981 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17982 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17983 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17984 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17985 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17986 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17987 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17988 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17989 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17990 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17991 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17992 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17993 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17994 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17995 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17996 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17997 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17998 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17999 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18000 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
18001 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18002 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18003 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
18004 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
18005 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
18006 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18007 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18008 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
18009 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18010 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
18011 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18012 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
18013 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18014 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18015 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18016 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18017 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18018 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18019 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18020 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18021 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18022 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18023 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18024 	(cmdline_parse_inst_t *)&cmd_ddp_add,
18025 	(cmdline_parse_inst_t *)&cmd_ddp_del,
18026 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
18027 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
18028 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
18029 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
18030 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
18031 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18032 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18033 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18034 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18035 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18036 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18037 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18038 
18039 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18040 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18041 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18042 	(cmdline_parse_inst_t *)&cmd_queue_region,
18043 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
18044 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
18045 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
18046 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18047 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18048 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18049 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18050 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18051 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18052 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18053 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18054 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18055 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18056 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18057 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18058 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18059 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18060 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18061 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18062 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18063 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18064 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18065 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18066 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18067 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18068 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18069 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18070 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18071 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18072 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18073 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18074 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18075 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18076 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18077 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18078 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18079 #ifdef RTE_LIB_BPF
18080 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18081 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18082 #endif
18083 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18084 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18085 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18086 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18087 	(cmdline_parse_inst_t *)&cmd_set_raw,
18088 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
18089 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18090 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18091 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
18092 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
18093 	(cmdline_parse_inst_t *)&cmd_show_capability,
18094 	(cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18095 	(cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18096 	NULL,
18097 };
18098 
18099 /* read cmdline commands from file */
18100 void
18101 cmdline_read_from_file(const char *filename)
18102 {
18103 	struct cmdline *cl;
18104 
18105 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18106 	if (cl == NULL) {
18107 		fprintf(stderr,
18108 			"Failed to create file based cmdline context: %s\n",
18109 			filename);
18110 		return;
18111 	}
18112 
18113 	cmdline_interact(cl);
18114 	cmdline_quit(cl);
18115 
18116 	cmdline_free(cl);
18117 
18118 	printf("Read CLI commands from %s\n", filename);
18119 }
18120 
18121 /* prompt function, called from main on MAIN lcore */
18122 void
18123 prompt(void)
18124 {
18125 	int ret;
18126 	/* initialize non-constant commands */
18127 	cmd_set_fwd_mode_init();
18128 	cmd_set_fwd_retry_mode_init();
18129 
18130 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18131 	if (testpmd_cl == NULL)
18132 		return;
18133 
18134 	ret = atexit(prompt_exit);
18135 	if (ret != 0)
18136 		fprintf(stderr, "Cannot set exit function for cmdline\n");
18137 
18138 	cmdline_interact(testpmd_cl);
18139 	if (ret != 0)
18140 		cmdline_stdin_exit(testpmd_cl);
18141 }
18142 
18143 void
18144 prompt_exit(void)
18145 {
18146 	if (testpmd_cl != NULL) {
18147 		cmdline_quit(testpmd_cl);
18148 		cmdline_stdin_exit(testpmd_cl);
18149 	}
18150 }
18151 
18152 static void
18153 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18154 {
18155 	if (id == (portid_t)RTE_PORT_ALL) {
18156 		portid_t pid;
18157 
18158 		RTE_ETH_FOREACH_DEV(pid) {
18159 			/* check if need_reconfig has been set to 1 */
18160 			if (ports[pid].need_reconfig == 0)
18161 				ports[pid].need_reconfig = dev;
18162 			/* check if need_reconfig_queues has been set to 1 */
18163 			if (ports[pid].need_reconfig_queues == 0)
18164 				ports[pid].need_reconfig_queues = queue;
18165 		}
18166 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18167 		/* check if need_reconfig has been set to 1 */
18168 		if (ports[id].need_reconfig == 0)
18169 			ports[id].need_reconfig = dev;
18170 		/* check if need_reconfig_queues has been set to 1 */
18171 		if (ports[id].need_reconfig_queues == 0)
18172 			ports[id].need_reconfig_queues = queue;
18173 	}
18174 }
18175