xref: /dpdk/app/test-pmd/cmdline.c (revision cffb3d66a8e389f6e73ac25219e56664a993572a)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5 
6 #include <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <termios.h>
12 #include <unistd.h>
13 #include <inttypes.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 
17 #include <sys/queue.h>
18 
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
21 #include <rte_log.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
28 #include <rte_eal.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
33 #include <rte_ring.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
36 #include <rte_pci.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
41 #include <rte_flow.h>
42 #include <rte_gro.h>
43 #include <rte_mbuf_dyn.h>
44 
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
52 #include <cmdline.h>
53 #ifdef RTE_NET_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
56 #endif
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
59 #endif
60 #ifdef RTE_NET_IXGBE
61 #include <rte_pmd_ixgbe.h>
62 #endif
63 #ifdef RTE_NET_I40E
64 #include <rte_pmd_i40e.h>
65 #endif
66 #ifdef RTE_NET_BNXT
67 #include <rte_pmd_bnxt.h>
68 #endif
69 #include "testpmd.h"
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
72 #include "bpf_cmd.h"
73 
74 static struct cmdline *testpmd_cl;
75 
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
77 
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 	cmdline_fixed_string_t help;
81 };
82 
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
84                                   struct cmdline *cl,
85                                   __rte_unused void *data)
86 {
87 	cmdline_printf(
88 		cl,
89 		"\n"
90 		"Help is available for the following sections:\n\n"
91 		"    help control                    : Start and stop forwarding.\n"
92 		"    help display                    : Displaying port, stats and config "
93 		"information.\n"
94 		"    help config                     : Configuration information.\n"
95 		"    help ports                      : Configuring ports.\n"
96 		"    help registers                  : Reading and setting port registers.\n"
97 		"    help filters                    : Filters configuration help.\n"
98 		"    help traffic_management         : Traffic Management commands.\n"
99 		"    help devices                    : Device related cmds.\n"
100 		"    help all                        : All of the above sections.\n\n"
101 	);
102 
103 }
104 
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 
108 cmdline_parse_inst_t cmd_help_brief = {
109 	.f = cmd_help_brief_parsed,
110 	.data = NULL,
111 	.help_str = "help: Show help",
112 	.tokens = {
113 		(void *)&cmd_help_brief_help,
114 		NULL,
115 	},
116 };
117 
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 	cmdline_fixed_string_t help;
121 	cmdline_fixed_string_t section;
122 };
123 
124 static void cmd_help_long_parsed(void *parsed_result,
125                                  struct cmdline *cl,
126                                  __rte_unused void *data)
127 {
128 	int show_all = 0;
129 	struct cmd_help_long_result *res = parsed_result;
130 
131 	if (!strcmp(res->section, "all"))
132 		show_all = 1;
133 
134 	if (show_all || !strcmp(res->section, "control")) {
135 
136 		cmdline_printf(
137 			cl,
138 			"\n"
139 			"Control forwarding:\n"
140 			"-------------------\n\n"
141 
142 			"start\n"
143 			"    Start packet forwarding with current configuration.\n\n"
144 
145 			"start tx_first\n"
146 			"    Start packet forwarding with current config"
147 			" after sending one burst of packets.\n\n"
148 
149 			"stop\n"
150 			"    Stop packet forwarding, and display accumulated"
151 			" statistics.\n\n"
152 
153 			"quit\n"
154 			"    Quit to prompt.\n\n"
155 		);
156 	}
157 
158 	if (show_all || !strcmp(res->section, "display")) {
159 
160 		cmdline_printf(
161 			cl,
162 			"\n"
163 			"Display:\n"
164 			"--------\n\n"
165 
166 			"show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 			"    Display information for port_id, or all.\n\n"
168 
169 			"show port port_id (module_eeprom|eeprom)\n"
170 			"    Display the module EEPROM or EEPROM information for port_id.\n\n"
171 
172 			"show port X rss reta (size) (mask0,mask1,...)\n"
173 			"    Display the rss redirection table entry indicated"
174 			" by masks on port X. size is used to indicate the"
175 			" hardware supported reta size\n\n"
176 
177 			"show port (port_id) rss-hash [key]\n"
178 			"    Display the RSS hash functions and RSS hash key of port\n\n"
179 
180 			"clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 			"    Clear information for port_id, or all.\n\n"
182 
183 			"show (rxq|txq) info (port_id) (queue_id)\n"
184 			"    Display information for configured RX/TX queue.\n\n"
185 
186 			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 			"    Display the given configuration.\n\n"
188 
189 			"read rxd (port_id) (queue_id) (rxd_id)\n"
190 			"    Display an RX descriptor of a port RX queue.\n\n"
191 
192 			"read txd (port_id) (queue_id) (txd_id)\n"
193 			"    Display a TX descriptor of a port TX queue.\n\n"
194 
195 			"ddp get list (port_id)\n"
196 			"    Get ddp profile info list\n\n"
197 
198 			"ddp get info (profile_path)\n"
199 			"    Get ddp profile information.\n\n"
200 
201 			"show vf stats (port_id) (vf_id)\n"
202 			"    Display a VF's statistics.\n\n"
203 
204 			"clear vf stats (port_id) (vf_id)\n"
205 			"    Reset a VF's statistics.\n\n"
206 
207 			"show port (port_id) pctype mapping\n"
208 			"    Get flow ptype to pctype mapping on a port\n\n"
209 
210 			"show port meter stats (port_id) (meter_id) (clear)\n"
211 			"    Get meter stats on a port\n\n"
212 
213 			"show fwd stats all\n"
214 			"    Display statistics for all fwd engines.\n\n"
215 
216 			"clear fwd stats all\n"
217 			"    Clear statistics for all fwd engines.\n\n"
218 
219 			"show port (port_id) rx_offload capabilities\n"
220 			"    List all per queue and per port Rx offloading"
221 			" capabilities of a port\n\n"
222 
223 			"show port (port_id) rx_offload configuration\n"
224 			"    List port level and all queue level"
225 			" Rx offloading configuration\n\n"
226 
227 			"show port (port_id) tx_offload capabilities\n"
228 			"    List all per queue and per port"
229 			" Tx offloading capabilities of a port\n\n"
230 
231 			"show port (port_id) tx_offload configuration\n"
232 			"    List port level and all queue level"
233 			" Tx offloading configuration\n\n"
234 
235 			"show port (port_id) tx_metadata\n"
236 			"    Show Tx metadata value set"
237 			" for a specific port\n\n"
238 
239 			"show port (port_id) ptypes\n"
240 			"    Show port supported ptypes"
241 			" for a specific port\n\n"
242 
243 			"show device info (<identifier>|all)"
244 			"       Show general information about devices probed.\n\n"
245 
246 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 			"       Show status of rx|tx descriptor.\n\n"
248 
249 			"show port (port_id) rxq (queue_id) desc used count\n"
250 			"    Show current number of filled receive"
251 			" packet descriptors.\n\n"
252 
253 			"show port (port_id) macs|mcast_macs"
254 			"       Display list of mac addresses added to port.\n\n"
255 
256 			"show port (port_id) fec capabilities"
257 			"	Show fec capabilities of a port.\n\n"
258 
259 			"show port (port_id) fec_mode"
260 			"	Show fec mode of a port.\n\n"
261 
262 			"show port (port_id) flow_ctrl"
263 			"	Show flow control info of a port.\n\n"
264 		);
265 	}
266 
267 	if (show_all || !strcmp(res->section, "config")) {
268 		cmdline_printf(
269 			cl,
270 			"\n"
271 			"Configuration:\n"
272 			"--------------\n"
273 			"Configuration changes only become active when"
274 			" forwarding is started/restarted.\n\n"
275 
276 			"set default\n"
277 			"    Reset forwarding to the default configuration.\n\n"
278 
279 			"set verbose (level)\n"
280 			"    Set the debug verbosity level X.\n\n"
281 
282 			"set log global|(type) (level)\n"
283 			"    Set the log level.\n\n"
284 
285 			"set nbport (num)\n"
286 			"    Set number of ports.\n\n"
287 
288 			"set nbcore (num)\n"
289 			"    Set number of cores.\n\n"
290 
291 			"set coremask (mask)\n"
292 			"    Set the forwarding cores hexadecimal mask.\n\n"
293 
294 			"set portmask (mask)\n"
295 			"    Set the forwarding ports hexadecimal mask.\n\n"
296 
297 			"set burst (num)\n"
298 			"    Set number of packets per burst.\n\n"
299 
300 			"set burst tx delay (microseconds) retry (num)\n"
301 			"    Set the transmit delay time and number of retries,"
302 			" effective when retry is enabled.\n\n"
303 
304 			"set rxoffs (x[,y]*)\n"
305 			"    Set the offset of each packet segment on"
306 			" receiving if split feature is engaged."
307 			" Affects only the queues configured with split"
308 			" offloads.\n\n"
309 
310 			"set rxpkts (x[,y]*)\n"
311 			"    Set the length of each segment to scatter"
312 			" packets on receiving if split feature is engaged."
313 			" Affects only the queues configured with split"
314 			" offloads.\n\n"
315 
316 			"set txpkts (x[,y]*)\n"
317 			"    Set the length of each segment of TXONLY"
318 			" and optionally CSUM packets.\n\n"
319 
320 			"set txsplit (off|on|rand)\n"
321 			"    Set the split policy for the TX packets."
322 			" Right now only applicable for CSUM and TXONLY"
323 			" modes\n\n"
324 
325 			"set txtimes (x, y)\n"
326 			"    Set the scheduling on timestamps"
327 			" timings for the TXONLY mode\n\n"
328 
329 			"set corelist (x[,y]*)\n"
330 			"    Set the list of forwarding cores.\n\n"
331 
332 			"set portlist (x[,y]*)\n"
333 			"    Set the list of forwarding ports.\n\n"
334 
335 			"set port setup on (iterator|event)\n"
336 			"    Select how attached port is retrieved for setup.\n\n"
337 
338 			"set tx loopback (port_id) (on|off)\n"
339 			"    Enable or disable tx loopback.\n\n"
340 
341 			"set all queues drop (port_id) (on|off)\n"
342 			"    Set drop enable bit for all queues.\n\n"
343 
344 			"set vf split drop (port_id) (vf_id) (on|off)\n"
345 			"    Set split drop enable bit for a VF from the PF.\n\n"
346 
347 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
348 			"    Set MAC antispoof for a VF from the PF.\n\n"
349 
350 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
351 			"    Enable MACsec offload.\n\n"
352 
353 			"set macsec offload (port_id) off\n"
354 			"    Disable MACsec offload.\n\n"
355 
356 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
357 			"    Configure MACsec secure connection (SC).\n\n"
358 
359 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
360 			"    Configure MACsec secure association (SA).\n\n"
361 
362 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
363 			"    Set VF broadcast for a VF from the PF.\n\n"
364 
365 			"vlan set stripq (on|off) (port_id,queue_id)\n"
366 			"    Set the VLAN strip for a queue on a port.\n\n"
367 
368 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
369 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
370 
371 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
372 			"    Set VLAN insert for a VF from the PF.\n\n"
373 
374 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
375 			"    Set VLAN antispoof for a VF from the PF.\n\n"
376 
377 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
378 			"    Set VLAN tag for a VF from the PF.\n\n"
379 
380 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
381 			"    Set a VF's max bandwidth(Mbps).\n\n"
382 
383 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
384 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
385 
386 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
387 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
388 
389 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
390 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
391 
392 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
393 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
394 
395 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
396 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
397 
398 			"vlan set (inner|outer) tpid (value) (port_id)\n"
399 			"    Set the VLAN TPID for Packet Filtering on"
400 			" a port\n\n"
401 
402 			"rx_vlan add (vlan_id|all) (port_id)\n"
403 			"    Add a vlan_id, or all identifiers, to the set"
404 			" of VLAN identifiers filtered by port_id.\n\n"
405 
406 			"rx_vlan rm (vlan_id|all) (port_id)\n"
407 			"    Remove a vlan_id, or all identifiers, from the set"
408 			" of VLAN identifiers filtered by port_id.\n\n"
409 
410 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
411 			"    Add a vlan_id, to the set of VLAN identifiers"
412 			"filtered for VF(s) from port_id.\n\n"
413 
414 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
415 			"    Remove a vlan_id, to the set of VLAN identifiers"
416 			"filtered for VF(s) from port_id.\n\n"
417 
418 			"rx_vxlan_port add (udp_port) (port_id)\n"
419 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
420 
421 			"rx_vxlan_port rm (udp_port) (port_id)\n"
422 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
423 
424 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
425 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
426 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
427 
428 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
429 			"    Set port based TX VLAN insertion.\n\n"
430 
431 			"tx_vlan reset (port_id)\n"
432 			"    Disable hardware insertion of a VLAN header in"
433 			" packets sent on a port.\n\n"
434 
435 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
436 			"    Select hardware or software calculation of the"
437 			" checksum when transmitting a packet using the"
438 			" csum forward engine.\n"
439 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
440 			"    outer-ip concerns the outer IP layer in"
441 			"    outer-udp concerns the outer UDP layer in"
442 			" case the packet is recognized as a tunnel packet by"
443 			" the forward engine (vxlan, gre and ipip are supported)\n"
444 			"    Please check the NIC datasheet for HW limits.\n\n"
445 
446 			"csum parse-tunnel (on|off) (tx_port_id)\n"
447 			"    If disabled, treat tunnel packets as non-tunneled"
448 			" packets (treat inner headers as payload). The port\n"
449 			"    argument is the port used for TX in csum forward"
450 			" engine.\n\n"
451 
452 			"csum show (port_id)\n"
453 			"    Display tx checksum offload configuration\n\n"
454 
455 			"tso set (segsize) (portid)\n"
456 			"    Enable TCP Segmentation Offload in csum forward"
457 			" engine.\n"
458 			"    Please check the NIC datasheet for HW limits.\n\n"
459 
460 			"tso show (portid)"
461 			"    Display the status of TCP Segmentation Offload.\n\n"
462 
463 			"set port (port_id) gro on|off\n"
464 			"    Enable or disable Generic Receive Offload in"
465 			" csum forwarding engine.\n\n"
466 
467 			"show port (port_id) gro\n"
468 			"    Display GRO configuration.\n\n"
469 
470 			"set gro flush (cycles)\n"
471 			"    Set the cycle to flush GROed packets from"
472 			" reassembly tables.\n\n"
473 
474 			"set port (port_id) gso (on|off)"
475 			"    Enable or disable Generic Segmentation Offload in"
476 			" csum forwarding engine.\n\n"
477 
478 			"set gso segsz (length)\n"
479 			"    Set max packet length for output GSO segments,"
480 			" including packet header and payload.\n\n"
481 
482 			"show port (port_id) gso\n"
483 			"    Show GSO configuration.\n\n"
484 
485 			"set fwd (%s)\n"
486 			"    Set packet forwarding mode.\n\n"
487 
488 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
489 			"    Add a MAC address on port_id.\n\n"
490 
491 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 			"    Remove a MAC address from port_id.\n\n"
493 
494 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
495 			"    Set the default MAC address for port_id.\n\n"
496 
497 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
498 			"    Add a MAC address for a VF on the port.\n\n"
499 
500 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
501 			"    Set the MAC address for a VF from the PF.\n\n"
502 
503 			"set eth-peer (port_id) (peer_addr)\n"
504 			"    set the peer address for certain port.\n\n"
505 
506 			"set port (port_id) uta (mac_address|all) (on|off)\n"
507 			"    Add/Remove a or all unicast hash filter(s)"
508 			"from port X.\n\n"
509 
510 			"set promisc (port_id|all) (on|off)\n"
511 			"    Set the promiscuous mode on port_id, or all.\n\n"
512 
513 			"set allmulti (port_id|all) (on|off)\n"
514 			"    Set the allmulti mode on port_id, or all.\n\n"
515 
516 			"set vf promisc (port_id) (vf_id) (on|off)\n"
517 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
518 
519 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
520 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
521 
522 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
523 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
524 			" (on|off) autoneg (on|off) (port_id)\n"
525 			"set flow_ctrl rx (on|off) (portid)\n"
526 			"set flow_ctrl tx (on|off) (portid)\n"
527 			"set flow_ctrl high_water (high_water) (portid)\n"
528 			"set flow_ctrl low_water (low_water) (portid)\n"
529 			"set flow_ctrl pause_time (pause_time) (portid)\n"
530 			"set flow_ctrl send_xon (send_xon) (portid)\n"
531 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
532 			"set flow_ctrl autoneg (on|off) (port_id)\n"
533 			"    Set the link flow control parameter on a port.\n\n"
534 
535 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
536 			" (low_water) (pause_time) (priority) (port_id)\n"
537 			"    Set the priority flow control parameter on a"
538 			" port.\n\n"
539 
540 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
541 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
542 			" queue on port.\n"
543 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
544 			" on port 0 to mapping 5.\n\n"
545 
546 			"set xstats-hide-zero on|off\n"
547 			"    Set the option to hide the zero values"
548 			" for xstats display.\n"
549 
550 			"set record-core-cycles on|off\n"
551 			"    Set the option to enable measurement of CPU cycles.\n"
552 
553 			"set record-burst-stats on|off\n"
554 			"    Set the option to enable display of RX and TX bursts.\n"
555 
556 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
557 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
558 
559 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
560 			"|MPE) (on|off)\n"
561 			"    AUPE:accepts untagged VLAN;"
562 			"ROPE:accept unicast hash\n\n"
563 			"    BAM:accepts broadcast packets;"
564 			"MPE:accepts all multicast packets\n\n"
565 			"    Enable/Disable a VF receive mode of a port\n\n"
566 
567 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
568 			"    Set rate limit for a queue of a port\n\n"
569 
570 			"set port (port_id) vf (vf_id) rate (rate_num) "
571 			"queue_mask (queue_mask_value)\n"
572 			"    Set rate limit for queues in VF of a port\n\n"
573 
574 			"set port (port_id) mirror-rule (rule_id)"
575 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
576 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
577 			"   Set pool or vlan type mirror rule on a port.\n"
578 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
579 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
580 			" to pool 0.\n\n"
581 
582 			"set port (port_id) mirror-rule (rule_id)"
583 			" (uplink-mirror|downlink-mirror) dst-pool"
584 			" (pool_id) (on|off)\n"
585 			"   Set uplink or downlink type mirror rule on a port.\n"
586 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
587 			" 0 on' enable mirror income traffic to pool 0.\n\n"
588 
589 			"reset port (port_id) mirror-rule (rule_id)\n"
590 			"   Reset a mirror rule.\n\n"
591 
592 			"set flush_rx (on|off)\n"
593 			"   Flush (default) or don't flush RX streams before"
594 			" forwarding. Mainly used with PCAP drivers.\n\n"
595 
596 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
597 			"   Set the bypass mode for the lowest port on bypass enabled"
598 			" NIC.\n\n"
599 
600 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
601 			"mode (normal|bypass|isolate) (port_id)\n"
602 			"   Set the event required to initiate specified bypass mode for"
603 			" the lowest port on a bypass enabled NIC where:\n"
604 			"       timeout   = enable bypass after watchdog timeout.\n"
605 			"       os_on     = enable bypass when OS/board is powered on.\n"
606 			"       os_off    = enable bypass when OS/board is powered off.\n"
607 			"       power_on  = enable bypass when power supply is turned on.\n"
608 			"       power_off = enable bypass when power supply is turned off."
609 			"\n\n"
610 
611 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
612 			"   Set the bypass watchdog timeout to 'n' seconds"
613 			" where 0 = instant.\n\n"
614 
615 			"show bypass config (port_id)\n"
616 			"   Show the bypass configuration for a bypass enabled NIC"
617 			" using the lowest port on the NIC.\n\n"
618 
619 #ifdef RTE_NET_BOND
620 			"create bonded device (mode) (socket)\n"
621 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
622 
623 			"add bonding slave (slave_id) (port_id)\n"
624 			"	Add a slave device to a bonded device.\n\n"
625 
626 			"remove bonding slave (slave_id) (port_id)\n"
627 			"	Remove a slave device from a bonded device.\n\n"
628 
629 			"set bonding mode (value) (port_id)\n"
630 			"	Set the bonding mode on a bonded device.\n\n"
631 
632 			"set bonding primary (slave_id) (port_id)\n"
633 			"	Set the primary slave for a bonded device.\n\n"
634 
635 			"show bonding config (port_id)\n"
636 			"	Show the bonding config for port_id.\n\n"
637 
638 			"set bonding mac_addr (port_id) (address)\n"
639 			"	Set the MAC address of a bonded device.\n\n"
640 
641 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
642 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
643 
644 			"set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
645 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
646 
647 			"set bonding mon_period (port_id) (value)\n"
648 			"	Set the bonding link status monitoring polling period in ms.\n\n"
649 
650 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
651 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
652 
653 #endif
654 			"set link-up port (port_id)\n"
655 			"	Set link up for a port.\n\n"
656 
657 			"set link-down port (port_id)\n"
658 			"	Set link down for a port.\n\n"
659 
660 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
661 			"    Load a profile package on a port\n\n"
662 
663 			"ddp del (port_id) (backup_profile_path)\n"
664 			"    Delete a profile package from a port\n\n"
665 
666 			"ptype mapping get (port_id) (valid_only)\n"
667 			"    Get ptype mapping on a port\n\n"
668 
669 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
670 			"    Replace target with the pkt_type in ptype mapping\n\n"
671 
672 			"ptype mapping reset (port_id)\n"
673 			"    Reset ptype mapping on a port\n\n"
674 
675 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
676 			"    Update a ptype mapping item on a port\n\n"
677 
678 			"set port (port_id) ptype_mask (ptype_mask)\n"
679 			"    set packet types classification for a specific port\n\n"
680 
681 			"set port (port_id) queue-region region_id (value) "
682 			"queue_start_index (value) queue_num (value)\n"
683 			"    Set a queue region on a port\n\n"
684 
685 			"set port (port_id) queue-region region_id (value) "
686 			"flowtype (value)\n"
687 			"    Set a flowtype region index on a port\n\n"
688 
689 			"set port (port_id) queue-region UP (value) region_id (value)\n"
690 			"    Set the mapping of User Priority to "
691 			"queue region on a port\n\n"
692 
693 			"set port (port_id) queue-region flush (on|off)\n"
694 			"    flush all queue region related configuration\n\n"
695 
696 			"show port meter cap (port_id)\n"
697 			"    Show port meter capability information\n\n"
698 
699 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
700 			"    meter profile add - srtcm rfc 2697\n\n"
701 
702 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
703 			"    meter profile add - trtcm rfc 2698\n\n"
704 
705 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
706 			"    meter profile add - trtcm rfc 4115\n\n"
707 
708 			"del port meter profile (port_id) (profile_id)\n"
709 			"    meter profile delete\n\n"
710 
711 			"create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
712 			"(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
713 			"(dscp_tbl_entry63)]\n"
714 			"    meter create\n\n"
715 
716 			"enable port meter (port_id) (mtr_id)\n"
717 			"    meter enable\n\n"
718 
719 			"disable port meter (port_id) (mtr_id)\n"
720 			"    meter disable\n\n"
721 
722 			"del port meter (port_id) (mtr_id)\n"
723 			"    meter delete\n\n"
724 
725 			"add port meter policy (port_id) (policy_id) g_actions (actions)\n"
726 			"y_actions (actions) r_actions (actions)\n"
727 			"    meter policy add\n\n"
728 
729 			"del port meter policy (port_id) (policy_id)\n"
730 			"    meter policy delete\n\n"
731 
732 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
733 			"    meter update meter profile\n\n"
734 
735 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
736 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
737 			"    update meter dscp table entries\n\n"
738 
739 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
740 			"(action0) [(action1) (action2)]\n"
741 			"    meter update policer action\n\n"
742 
743 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
744 			"    meter update stats\n\n"
745 
746 			"show port (port_id) queue-region\n"
747 			"    show all queue region related configuration info\n\n"
748 
749 			"set port (port_id) fec_mode auto|off|rs|baser\n"
750 			"    set fec mode for a specific port\n\n"
751 
752 			, list_pkt_forwarding_modes()
753 		);
754 	}
755 
756 	if (show_all || !strcmp(res->section, "ports")) {
757 
758 		cmdline_printf(
759 			cl,
760 			"\n"
761 			"Port Operations:\n"
762 			"----------------\n\n"
763 
764 			"port start (port_id|all)\n"
765 			"    Start all ports or port_id.\n\n"
766 
767 			"port stop (port_id|all)\n"
768 			"    Stop all ports or port_id.\n\n"
769 
770 			"port close (port_id|all)\n"
771 			"    Close all ports or port_id.\n\n"
772 
773 			"port reset (port_id|all)\n"
774 			"    Reset all ports or port_id.\n\n"
775 
776 			"port attach (ident)\n"
777 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
778 
779 			"port detach (port_id)\n"
780 			"    Detach physical or virtual dev by port_id\n\n"
781 
782 			"port config (port_id|all)"
783 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
784 			" duplex (half|full|auto)\n"
785 			"    Set speed and duplex for all ports or port_id\n\n"
786 
787 			"port config (port_id|all) loopback (mode)\n"
788 			"    Set loopback mode for all ports or port_id\n\n"
789 
790 			"port config all (rxq|txq|rxd|txd) (value)\n"
791 			"    Set number for rxq/txq/rxd/txd.\n\n"
792 
793 			"port config all max-pkt-len (value)\n"
794 			"    Set the max packet length.\n\n"
795 
796 			"port config all max-lro-pkt-size (value)\n"
797 			"    Set the max LRO aggregated packet size.\n\n"
798 
799 			"port config all drop-en (on|off)\n"
800 			"    Enable or disable packet drop on all RX queues of all ports when no "
801 			"receive buffers available.\n\n"
802 
803 			"port config all rss (all|default|ip|tcp|udp|sctp|"
804 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
805 			"level-outer|level-inner|<flowtype_id>)\n"
806 			"    Set the RSS mode.\n\n"
807 
808 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
809 			"    Set the RSS redirection table.\n\n"
810 
811 			"port config (port_id) dcb vt (on|off) (traffic_class)"
812 			" pfc (on|off)\n"
813 			"    Set the DCB mode.\n\n"
814 
815 			"port config all burst (value)\n"
816 			"    Set the number of packets per burst.\n\n"
817 
818 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
819 			" (value)\n"
820 			"    Set the ring prefetch/host/writeback threshold"
821 			" for tx/rx queue.\n\n"
822 
823 			"port config all (txfreet|txrst|rxfreet) (value)\n"
824 			"    Set free threshold for rx/tx, or set"
825 			" tx rs bit threshold.\n\n"
826 			"port config mtu X value\n"
827 			"    Set the MTU of port X to a given value\n\n"
828 
829 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
830 			"    Set a rx/tx queue's ring size configuration, the new"
831 			" value will take effect after command that (re-)start the port"
832 			" or command that setup the specific queue\n\n"
833 
834 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
835 			"    Start/stop a rx/tx queue of port X. Only take effect"
836 			" when port X is started\n\n"
837 
838 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
839 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
840 			" take effect when port X is stopped.\n\n"
841 
842 			"port (port_id) (rxq|txq) (queue_id) setup\n"
843 			"    Setup a rx/tx queue of port X.\n\n"
844 
845 			"port config (port_id) pctype mapping reset\n"
846 			"    Reset flow type to pctype mapping on a port\n\n"
847 
848 			"port config (port_id) pctype mapping update"
849 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
850 			"    Update a flow type to pctype mapping item on a port\n\n"
851 
852 			"port config (port_id) pctype (pctype_id) hash_inset|"
853 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
854 			" (field_idx)\n"
855 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
856 
857 			"port config (port_id) pctype (pctype_id) hash_inset|"
858 			"fdir_inset|fdir_flx_inset clear all"
859 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
860 
861 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
862 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
863 
864 			"port config <port_id> rx_offload vlan_strip|"
865 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
866 			"outer_ipv4_cksum|macsec_strip|header_split|"
867 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
868 			"buffer_split|timestamp|security|keep_crc on|off\n"
869 			"     Enable or disable a per port Rx offloading"
870 			" on all Rx queues of a port\n\n"
871 
872 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
873 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
874 			"outer_ipv4_cksum|macsec_strip|header_split|"
875 			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
876 			"buffer_split|timestamp|security|keep_crc on|off\n"
877 			"    Enable or disable a per queue Rx offloading"
878 			" only on a specific Rx queue\n\n"
879 
880 			"port config (port_id) tx_offload vlan_insert|"
881 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
882 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
883 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
884 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
885 			"security on|off\n"
886 			"    Enable or disable a per port Tx offloading"
887 			" on all Tx queues of a port\n\n"
888 
889 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
890 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
891 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
892 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
893 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
894 			" on|off\n"
895 			"    Enable or disable a per queue Tx offloading"
896 			" only on a specific Tx queue\n\n"
897 
898 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
899 			"    Load an eBPF program as a callback"
900 			" for particular RX/TX queue\n\n"
901 
902 			"bpf-unload rx|tx (port) (queue)\n"
903 			"    Unload previously loaded eBPF program"
904 			" for particular RX/TX queue\n\n"
905 
906 			"port config (port_id) tx_metadata (value)\n"
907 			"    Set Tx metadata value per port. Testpmd will add this value"
908 			" to any Tx packet sent from this port\n\n"
909 
910 			"port config (port_id) dynf (name) set|clear\n"
911 			"    Register a dynf and Set/clear this flag on Tx. "
912 			"Testpmd will set this value to any Tx packet "
913 			"sent from this port\n\n"
914 
915 			"port cleanup (port_id) txq (queue_id) (free_cnt)\n"
916 			"    Cleanup txq mbufs for a specific Tx queue\n\n"
917 		);
918 	}
919 
920 	if (show_all || !strcmp(res->section, "registers")) {
921 
922 		cmdline_printf(
923 			cl,
924 			"\n"
925 			"Registers:\n"
926 			"----------\n\n"
927 
928 			"read reg (port_id) (address)\n"
929 			"    Display value of a port register.\n\n"
930 
931 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
932 			"    Display a port register bit field.\n\n"
933 
934 			"read regbit (port_id) (address) (bit_x)\n"
935 			"    Display a single port register bit.\n\n"
936 
937 			"write reg (port_id) (address) (value)\n"
938 			"    Set value of a port register.\n\n"
939 
940 			"write regfield (port_id) (address) (bit_x) (bit_y)"
941 			" (value)\n"
942 			"    Set bit field of a port register.\n\n"
943 
944 			"write regbit (port_id) (address) (bit_x) (value)\n"
945 			"    Set single bit value of a port register.\n\n"
946 		);
947 	}
948 	if (show_all || !strcmp(res->section, "filters")) {
949 
950 		cmdline_printf(
951 			cl,
952 			"\n"
953 			"filters:\n"
954 			"--------\n\n"
955 
956 #ifdef RTE_NET_I40E
957 			"flow_director_filter (port_id) mode raw (add|del|update)"
958 			" flow (flow_id) (drop|fwd) queue (queue_id)"
959 			" fd_id (fd_id_value) packet (packet file name)\n"
960 			"    Add/Del a raw type flow director filter.\n\n"
961 #endif
962 
963 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
964 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
965 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
966 			"    Set flow director IP mask.\n\n"
967 
968 			"flow_director_mask (port_id) mode MAC-VLAN"
969 			" vlan (vlan_value)\n"
970 			"    Set flow director MAC-VLAN mask.\n\n"
971 
972 			"flow_director_mask (port_id) mode Tunnel"
973 			" vlan (vlan_value) mac (mac_value)"
974 			" tunnel-type (tunnel_type_value)"
975 			" tunnel-id (tunnel_id_value)\n"
976 			"    Set flow director Tunnel mask.\n\n"
977 
978 			"flow_director_flex_payload (port_id)"
979 			" (raw|l2|l3|l4) (config)\n"
980 			"    Configure flex payload selection.\n\n"
981 
982 			"flow validate {port_id}"
983 			" [group {group_id}] [priority {level}]"
984 			" [ingress] [egress]"
985 			" pattern {item} [/ {item} [...]] / end"
986 			" actions {action} [/ {action} [...]] / end\n"
987 			"    Check whether a flow rule can be created.\n\n"
988 
989 			"flow create {port_id}"
990 			" [group {group_id}] [priority {level}]"
991 			" [ingress] [egress]"
992 			" pattern {item} [/ {item} [...]] / end"
993 			" actions {action} [/ {action} [...]] / end\n"
994 			"    Create a flow rule.\n\n"
995 
996 			"flow destroy {port_id} rule {rule_id} [...]\n"
997 			"    Destroy specific flow rules.\n\n"
998 
999 			"flow flush {port_id}\n"
1000 			"    Destroy all flow rules.\n\n"
1001 
1002 			"flow query {port_id} {rule_id} {action}\n"
1003 			"    Query an existing flow rule.\n\n"
1004 
1005 			"flow list {port_id} [group {group_id}] [...]\n"
1006 			"    List existing flow rules sorted by priority,"
1007 			" filtered by group identifiers.\n\n"
1008 
1009 			"flow isolate {port_id} {boolean}\n"
1010 			"    Restrict ingress traffic to the defined"
1011 			" flow rules\n\n"
1012 
1013 			"flow aged {port_id} [destroy]\n"
1014 			"    List and destroy aged flows"
1015 			" flow rules\n\n"
1016 
1017 			"flow indirect_action {port_id} create"
1018 			" [action_id {indirect_action_id}]"
1019 			" [ingress] [egress]"
1020 			" action {action} / end\n"
1021 			"    Create indirect action.\n\n"
1022 
1023 			"flow indirect_action {port_id} update"
1024 			" {indirect_action_id} action {action} / end\n"
1025 			"    Update indirect action.\n\n"
1026 
1027 			"flow indirect_action {port_id} destroy"
1028 			" action_id {indirect_action_id} [...]\n"
1029 			"    Destroy specific indirect actions.\n\n"
1030 
1031 			"flow indirect_action {port_id} query"
1032 			" {indirect_action_id}\n"
1033 			"    Query an existing indirect action.\n\n"
1034 
1035 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1036 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1037 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1038 			"       Configure the VXLAN encapsulation for flows.\n\n"
1039 
1040 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1041 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1042 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1043 			" eth-dst (eth-dst)\n"
1044 			"       Configure the VXLAN encapsulation for flows.\n\n"
1045 
1046 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1047 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1048 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1049 			" eth-dst (eth-dst)\n"
1050 			"       Configure the VXLAN encapsulation for flows.\n\n"
1051 
1052 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1053 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1054 			" (eth-dst)\n"
1055 			"       Configure the NVGRE encapsulation for flows.\n\n"
1056 
1057 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1058 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1059 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1060 			"       Configure the NVGRE encapsulation for flows.\n\n"
1061 
1062 			"set raw_encap {flow items}\n"
1063 			"	Configure the encapsulation with raw data.\n\n"
1064 
1065 			"set raw_decap {flow items}\n"
1066 			"	Configure the decapsulation with raw data.\n\n"
1067 
1068 		);
1069 	}
1070 
1071 	if (show_all || !strcmp(res->section, "traffic_management")) {
1072 		cmdline_printf(
1073 			cl,
1074 			"\n"
1075 			"Traffic Management:\n"
1076 			"--------------\n"
1077 			"show port tm cap (port_id)\n"
1078 			"       Display the port TM capability.\n\n"
1079 
1080 			"show port tm level cap (port_id) (level_id)\n"
1081 			"       Display the port TM hierarchical level capability.\n\n"
1082 
1083 			"show port tm node cap (port_id) (node_id)\n"
1084 			"       Display the port TM node capability.\n\n"
1085 
1086 			"show port tm node type (port_id) (node_id)\n"
1087 			"       Display the port TM node type.\n\n"
1088 
1089 			"show port tm node stats (port_id) (node_id) (clear)\n"
1090 			"       Display the port TM node stats.\n\n"
1091 
1092 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1093 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1094 			" (packet_length_adjust) (packet_mode)\n"
1095 			"       Add port tm node private shaper profile.\n\n"
1096 
1097 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1098 			"       Delete port tm node private shaper profile.\n\n"
1099 
1100 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1101 			" (shaper_profile_id)\n"
1102 			"       Add/update port tm node shared shaper.\n\n"
1103 
1104 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1105 			"       Delete port tm node shared shaper.\n\n"
1106 
1107 			"set port tm node shaper profile (port_id) (node_id)"
1108 			" (shaper_profile_id)\n"
1109 			"       Set port tm node shaper profile.\n\n"
1110 
1111 			"add port tm node wred profile (port_id) (wred_profile_id)"
1112 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1113 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1114 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1115 			"       Add port tm node wred profile.\n\n"
1116 
1117 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1118 			"       Delete port tm node wred profile.\n\n"
1119 
1120 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1121 			" (priority) (weight) (level_id) (shaper_profile_id)"
1122 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1123 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1124 			"       Add port tm nonleaf node.\n\n"
1125 
1126 			"add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1127 			" (priority) (weight) (level_id) (shaper_profile_id)"
1128 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1129 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1130 			"       Add port tm nonleaf node with pkt mode enabled.\n\n"
1131 
1132 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1133 			" (priority) (weight) (level_id) (shaper_profile_id)"
1134 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1135 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1136 			"       Add port tm leaf node.\n\n"
1137 
1138 			"del port tm node (port_id) (node_id)\n"
1139 			"       Delete port tm node.\n\n"
1140 
1141 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1142 			" (priority) (weight)\n"
1143 			"       Set port tm node parent.\n\n"
1144 
1145 			"suspend port tm node (port_id) (node_id)"
1146 			"       Suspend tm node.\n\n"
1147 
1148 			"resume port tm node (port_id) (node_id)"
1149 			"       Resume tm node.\n\n"
1150 
1151 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1152 			"       Commit tm hierarchy.\n\n"
1153 
1154 			"set port tm mark ip_ecn (port) (green) (yellow)"
1155 			" (red)\n"
1156 			"    Enables/Disables the traffic management marking"
1157 			" for IP ECN (Explicit Congestion Notification)"
1158 			" packets on a given port\n\n"
1159 
1160 			"set port tm mark ip_dscp (port) (green) (yellow)"
1161 			" (red)\n"
1162 			"    Enables/Disables the traffic management marking"
1163 			" on the port for IP dscp packets\n\n"
1164 
1165 			"set port tm mark vlan_dei (port) (green) (yellow)"
1166 			" (red)\n"
1167 			"    Enables/Disables the traffic management marking"
1168 			" on the port for VLAN packets with DEI enabled\n\n"
1169 		);
1170 	}
1171 
1172 	if (show_all || !strcmp(res->section, "devices")) {
1173 		cmdline_printf(
1174 			cl,
1175 			"\n"
1176 			"Device Operations:\n"
1177 			"--------------\n"
1178 			"device detach (identifier)\n"
1179 			"       Detach device by identifier.\n\n"
1180 		);
1181 	}
1182 
1183 }
1184 
1185 cmdline_parse_token_string_t cmd_help_long_help =
1186 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1187 
1188 cmdline_parse_token_string_t cmd_help_long_section =
1189 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1190 			"all#control#display#config#"
1191 			"ports#registers#filters#traffic_management#devices");
1192 
1193 cmdline_parse_inst_t cmd_help_long = {
1194 	.f = cmd_help_long_parsed,
1195 	.data = NULL,
1196 	.help_str = "help all|control|display|config|ports|register|"
1197 		"filters|traffic_management|devices: "
1198 		"Show help",
1199 	.tokens = {
1200 		(void *)&cmd_help_long_help,
1201 		(void *)&cmd_help_long_section,
1202 		NULL,
1203 	},
1204 };
1205 
1206 
1207 /* *** start/stop/close all ports *** */
1208 struct cmd_operate_port_result {
1209 	cmdline_fixed_string_t keyword;
1210 	cmdline_fixed_string_t name;
1211 	cmdline_fixed_string_t value;
1212 };
1213 
1214 static void cmd_operate_port_parsed(void *parsed_result,
1215 				__rte_unused struct cmdline *cl,
1216 				__rte_unused void *data)
1217 {
1218 	struct cmd_operate_port_result *res = parsed_result;
1219 
1220 	if (!strcmp(res->name, "start"))
1221 		start_port(RTE_PORT_ALL);
1222 	else if (!strcmp(res->name, "stop"))
1223 		stop_port(RTE_PORT_ALL);
1224 	else if (!strcmp(res->name, "close"))
1225 		close_port(RTE_PORT_ALL);
1226 	else if (!strcmp(res->name, "reset"))
1227 		reset_port(RTE_PORT_ALL);
1228 	else
1229 		printf("Unknown parameter\n");
1230 }
1231 
1232 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1233 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1234 								"port");
1235 cmdline_parse_token_string_t cmd_operate_port_all_port =
1236 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1237 						"start#stop#close#reset");
1238 cmdline_parse_token_string_t cmd_operate_port_all_all =
1239 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1240 
1241 cmdline_parse_inst_t cmd_operate_port = {
1242 	.f = cmd_operate_port_parsed,
1243 	.data = NULL,
1244 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1245 	.tokens = {
1246 		(void *)&cmd_operate_port_all_cmd,
1247 		(void *)&cmd_operate_port_all_port,
1248 		(void *)&cmd_operate_port_all_all,
1249 		NULL,
1250 	},
1251 };
1252 
1253 /* *** start/stop/close specific port *** */
1254 struct cmd_operate_specific_port_result {
1255 	cmdline_fixed_string_t keyword;
1256 	cmdline_fixed_string_t name;
1257 	uint8_t value;
1258 };
1259 
1260 static void cmd_operate_specific_port_parsed(void *parsed_result,
1261 			__rte_unused struct cmdline *cl,
1262 				__rte_unused void *data)
1263 {
1264 	struct cmd_operate_specific_port_result *res = parsed_result;
1265 
1266 	if (!strcmp(res->name, "start"))
1267 		start_port(res->value);
1268 	else if (!strcmp(res->name, "stop"))
1269 		stop_port(res->value);
1270 	else if (!strcmp(res->name, "close"))
1271 		close_port(res->value);
1272 	else if (!strcmp(res->name, "reset"))
1273 		reset_port(res->value);
1274 	else
1275 		printf("Unknown parameter\n");
1276 }
1277 
1278 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1279 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1280 							keyword, "port");
1281 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1282 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1283 						name, "start#stop#close#reset");
1284 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1285 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1286 							value, RTE_UINT8);
1287 
1288 cmdline_parse_inst_t cmd_operate_specific_port = {
1289 	.f = cmd_operate_specific_port_parsed,
1290 	.data = NULL,
1291 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1292 	.tokens = {
1293 		(void *)&cmd_operate_specific_port_cmd,
1294 		(void *)&cmd_operate_specific_port_port,
1295 		(void *)&cmd_operate_specific_port_id,
1296 		NULL,
1297 	},
1298 };
1299 
1300 /* *** enable port setup (after attach) via iterator or event *** */
1301 struct cmd_set_port_setup_on_result {
1302 	cmdline_fixed_string_t set;
1303 	cmdline_fixed_string_t port;
1304 	cmdline_fixed_string_t setup;
1305 	cmdline_fixed_string_t on;
1306 	cmdline_fixed_string_t mode;
1307 };
1308 
1309 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1310 				__rte_unused struct cmdline *cl,
1311 				__rte_unused void *data)
1312 {
1313 	struct cmd_set_port_setup_on_result *res = parsed_result;
1314 
1315 	if (strcmp(res->mode, "event") == 0)
1316 		setup_on_probe_event = true;
1317 	else if (strcmp(res->mode, "iterator") == 0)
1318 		setup_on_probe_event = false;
1319 	else
1320 		printf("Unknown mode\n");
1321 }
1322 
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1324 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1325 			set, "set");
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1327 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1328 			port, "port");
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1330 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1331 			setup, "setup");
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1333 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 			on, "on");
1335 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1336 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1337 			mode, "iterator#event");
1338 
1339 cmdline_parse_inst_t cmd_set_port_setup_on = {
1340 	.f = cmd_set_port_setup_on_parsed,
1341 	.data = NULL,
1342 	.help_str = "set port setup on iterator|event",
1343 	.tokens = {
1344 		(void *)&cmd_set_port_setup_on_set,
1345 		(void *)&cmd_set_port_setup_on_port,
1346 		(void *)&cmd_set_port_setup_on_setup,
1347 		(void *)&cmd_set_port_setup_on_on,
1348 		(void *)&cmd_set_port_setup_on_mode,
1349 		NULL,
1350 	},
1351 };
1352 
1353 /* *** attach a specified port *** */
1354 struct cmd_operate_attach_port_result {
1355 	cmdline_fixed_string_t port;
1356 	cmdline_fixed_string_t keyword;
1357 	cmdline_multi_string_t identifier;
1358 };
1359 
1360 static void cmd_operate_attach_port_parsed(void *parsed_result,
1361 				__rte_unused struct cmdline *cl,
1362 				__rte_unused void *data)
1363 {
1364 	struct cmd_operate_attach_port_result *res = parsed_result;
1365 
1366 	if (!strcmp(res->keyword, "attach"))
1367 		attach_port(res->identifier);
1368 	else
1369 		printf("Unknown parameter\n");
1370 }
1371 
1372 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1373 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1374 			port, "port");
1375 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1376 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 			keyword, "attach");
1378 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1379 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1380 			identifier, TOKEN_STRING_MULTI);
1381 
1382 cmdline_parse_inst_t cmd_operate_attach_port = {
1383 	.f = cmd_operate_attach_port_parsed,
1384 	.data = NULL,
1385 	.help_str = "port attach <identifier>: "
1386 		"(identifier: pci address or virtual dev name)",
1387 	.tokens = {
1388 		(void *)&cmd_operate_attach_port_port,
1389 		(void *)&cmd_operate_attach_port_keyword,
1390 		(void *)&cmd_operate_attach_port_identifier,
1391 		NULL,
1392 	},
1393 };
1394 
1395 /* *** detach a specified port *** */
1396 struct cmd_operate_detach_port_result {
1397 	cmdline_fixed_string_t port;
1398 	cmdline_fixed_string_t keyword;
1399 	portid_t port_id;
1400 };
1401 
1402 static void cmd_operate_detach_port_parsed(void *parsed_result,
1403 				__rte_unused struct cmdline *cl,
1404 				__rte_unused void *data)
1405 {
1406 	struct cmd_operate_detach_port_result *res = parsed_result;
1407 
1408 	if (!strcmp(res->keyword, "detach")) {
1409 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1410 		detach_port_device(res->port_id);
1411 	} else {
1412 		printf("Unknown parameter\n");
1413 	}
1414 }
1415 
1416 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1417 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1418 			port, "port");
1419 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1420 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1421 			keyword, "detach");
1422 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1423 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1424 			port_id, RTE_UINT16);
1425 
1426 cmdline_parse_inst_t cmd_operate_detach_port = {
1427 	.f = cmd_operate_detach_port_parsed,
1428 	.data = NULL,
1429 	.help_str = "port detach <port_id>",
1430 	.tokens = {
1431 		(void *)&cmd_operate_detach_port_port,
1432 		(void *)&cmd_operate_detach_port_keyword,
1433 		(void *)&cmd_operate_detach_port_port_id,
1434 		NULL,
1435 	},
1436 };
1437 
1438 /* *** detach device by identifier *** */
1439 struct cmd_operate_detach_device_result {
1440 	cmdline_fixed_string_t device;
1441 	cmdline_fixed_string_t keyword;
1442 	cmdline_fixed_string_t identifier;
1443 };
1444 
1445 static void cmd_operate_detach_device_parsed(void *parsed_result,
1446 				__rte_unused struct cmdline *cl,
1447 				__rte_unused void *data)
1448 {
1449 	struct cmd_operate_detach_device_result *res = parsed_result;
1450 
1451 	if (!strcmp(res->keyword, "detach"))
1452 		detach_devargs(res->identifier);
1453 	else
1454 		printf("Unknown parameter\n");
1455 }
1456 
1457 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1458 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1459 			device, "device");
1460 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1461 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1462 			keyword, "detach");
1463 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1464 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1465 			identifier, NULL);
1466 
1467 cmdline_parse_inst_t cmd_operate_detach_device = {
1468 	.f = cmd_operate_detach_device_parsed,
1469 	.data = NULL,
1470 	.help_str = "device detach <identifier>:"
1471 		"(identifier: pci address or virtual dev name)",
1472 	.tokens = {
1473 		(void *)&cmd_operate_detach_device_device,
1474 		(void *)&cmd_operate_detach_device_keyword,
1475 		(void *)&cmd_operate_detach_device_identifier,
1476 		NULL,
1477 	},
1478 };
1479 /* *** configure speed for all ports *** */
1480 struct cmd_config_speed_all {
1481 	cmdline_fixed_string_t port;
1482 	cmdline_fixed_string_t keyword;
1483 	cmdline_fixed_string_t all;
1484 	cmdline_fixed_string_t item1;
1485 	cmdline_fixed_string_t item2;
1486 	cmdline_fixed_string_t value1;
1487 	cmdline_fixed_string_t value2;
1488 };
1489 
1490 static int
1491 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1492 {
1493 
1494 	int duplex;
1495 
1496 	if (!strcmp(duplexstr, "half")) {
1497 		duplex = ETH_LINK_HALF_DUPLEX;
1498 	} else if (!strcmp(duplexstr, "full")) {
1499 		duplex = ETH_LINK_FULL_DUPLEX;
1500 	} else if (!strcmp(duplexstr, "auto")) {
1501 		duplex = ETH_LINK_FULL_DUPLEX;
1502 	} else {
1503 		printf("Unknown duplex parameter\n");
1504 		return -1;
1505 	}
1506 
1507 	if (!strcmp(speedstr, "10")) {
1508 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1509 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1510 	} else if (!strcmp(speedstr, "100")) {
1511 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1512 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1513 	} else {
1514 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1515 			printf("Invalid speed/duplex parameters\n");
1516 			return -1;
1517 		}
1518 		if (!strcmp(speedstr, "1000")) {
1519 			*speed = ETH_LINK_SPEED_1G;
1520 		} else if (!strcmp(speedstr, "10000")) {
1521 			*speed = ETH_LINK_SPEED_10G;
1522 		} else if (!strcmp(speedstr, "25000")) {
1523 			*speed = ETH_LINK_SPEED_25G;
1524 		} else if (!strcmp(speedstr, "40000")) {
1525 			*speed = ETH_LINK_SPEED_40G;
1526 		} else if (!strcmp(speedstr, "50000")) {
1527 			*speed = ETH_LINK_SPEED_50G;
1528 		} else if (!strcmp(speedstr, "100000")) {
1529 			*speed = ETH_LINK_SPEED_100G;
1530 		} else if (!strcmp(speedstr, "200000")) {
1531 			*speed = ETH_LINK_SPEED_200G;
1532 		} else if (!strcmp(speedstr, "auto")) {
1533 			*speed = ETH_LINK_SPEED_AUTONEG;
1534 		} else {
1535 			printf("Unknown speed parameter\n");
1536 			return -1;
1537 		}
1538 	}
1539 
1540 	if (*speed != ETH_LINK_SPEED_AUTONEG)
1541 		*speed |= ETH_LINK_SPEED_FIXED;
1542 
1543 	return 0;
1544 }
1545 
1546 static void
1547 cmd_config_speed_all_parsed(void *parsed_result,
1548 			__rte_unused struct cmdline *cl,
1549 			__rte_unused void *data)
1550 {
1551 	struct cmd_config_speed_all *res = parsed_result;
1552 	uint32_t link_speed;
1553 	portid_t pid;
1554 
1555 	if (!all_ports_stopped()) {
1556 		printf("Please stop all ports first\n");
1557 		return;
1558 	}
1559 
1560 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1561 			&link_speed) < 0)
1562 		return;
1563 
1564 	RTE_ETH_FOREACH_DEV(pid) {
1565 		ports[pid].dev_conf.link_speeds = link_speed;
1566 	}
1567 
1568 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1569 }
1570 
1571 cmdline_parse_token_string_t cmd_config_speed_all_port =
1572 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1573 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1574 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1575 							"config");
1576 cmdline_parse_token_string_t cmd_config_speed_all_all =
1577 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1578 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1579 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1580 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1581 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1582 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1583 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1584 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1585 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1586 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1587 						"half#full#auto");
1588 
1589 cmdline_parse_inst_t cmd_config_speed_all = {
1590 	.f = cmd_config_speed_all_parsed,
1591 	.data = NULL,
1592 	.help_str = "port config all speed "
1593 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1594 							"half|full|auto",
1595 	.tokens = {
1596 		(void *)&cmd_config_speed_all_port,
1597 		(void *)&cmd_config_speed_all_keyword,
1598 		(void *)&cmd_config_speed_all_all,
1599 		(void *)&cmd_config_speed_all_item1,
1600 		(void *)&cmd_config_speed_all_value1,
1601 		(void *)&cmd_config_speed_all_item2,
1602 		(void *)&cmd_config_speed_all_value2,
1603 		NULL,
1604 	},
1605 };
1606 
1607 /* *** configure speed for specific port *** */
1608 struct cmd_config_speed_specific {
1609 	cmdline_fixed_string_t port;
1610 	cmdline_fixed_string_t keyword;
1611 	portid_t id;
1612 	cmdline_fixed_string_t item1;
1613 	cmdline_fixed_string_t item2;
1614 	cmdline_fixed_string_t value1;
1615 	cmdline_fixed_string_t value2;
1616 };
1617 
1618 static void
1619 cmd_config_speed_specific_parsed(void *parsed_result,
1620 				__rte_unused struct cmdline *cl,
1621 				__rte_unused void *data)
1622 {
1623 	struct cmd_config_speed_specific *res = parsed_result;
1624 	uint32_t link_speed;
1625 
1626 	if (!all_ports_stopped()) {
1627 		printf("Please stop all ports first\n");
1628 		return;
1629 	}
1630 
1631 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1632 		return;
1633 
1634 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1635 			&link_speed) < 0)
1636 		return;
1637 
1638 	ports[res->id].dev_conf.link_speeds = link_speed;
1639 
1640 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1641 }
1642 
1643 
1644 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1645 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1646 								"port");
1647 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1648 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1649 								"config");
1650 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1651 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1652 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1653 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1654 								"speed");
1655 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1656 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1657 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1658 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1659 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1660 								"duplex");
1661 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1662 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1663 							"half#full#auto");
1664 
1665 cmdline_parse_inst_t cmd_config_speed_specific = {
1666 	.f = cmd_config_speed_specific_parsed,
1667 	.data = NULL,
1668 	.help_str = "port config <port_id> speed "
1669 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1670 							"half|full|auto",
1671 	.tokens = {
1672 		(void *)&cmd_config_speed_specific_port,
1673 		(void *)&cmd_config_speed_specific_keyword,
1674 		(void *)&cmd_config_speed_specific_id,
1675 		(void *)&cmd_config_speed_specific_item1,
1676 		(void *)&cmd_config_speed_specific_value1,
1677 		(void *)&cmd_config_speed_specific_item2,
1678 		(void *)&cmd_config_speed_specific_value2,
1679 		NULL,
1680 	},
1681 };
1682 
1683 /* *** configure loopback for all ports *** */
1684 struct cmd_config_loopback_all {
1685 	cmdline_fixed_string_t port;
1686 	cmdline_fixed_string_t keyword;
1687 	cmdline_fixed_string_t all;
1688 	cmdline_fixed_string_t item;
1689 	uint32_t mode;
1690 };
1691 
1692 static void
1693 cmd_config_loopback_all_parsed(void *parsed_result,
1694 			__rte_unused struct cmdline *cl,
1695 			__rte_unused void *data)
1696 {
1697 	struct cmd_config_loopback_all *res = parsed_result;
1698 	portid_t pid;
1699 
1700 	if (!all_ports_stopped()) {
1701 		printf("Please stop all ports first\n");
1702 		return;
1703 	}
1704 
1705 	RTE_ETH_FOREACH_DEV(pid) {
1706 		ports[pid].dev_conf.lpbk_mode = res->mode;
1707 	}
1708 
1709 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1710 }
1711 
1712 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1713 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1714 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1715 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1716 							"config");
1717 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1718 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1719 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1720 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1721 							"loopback");
1722 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1723 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1724 
1725 cmdline_parse_inst_t cmd_config_loopback_all = {
1726 	.f = cmd_config_loopback_all_parsed,
1727 	.data = NULL,
1728 	.help_str = "port config all loopback <mode>",
1729 	.tokens = {
1730 		(void *)&cmd_config_loopback_all_port,
1731 		(void *)&cmd_config_loopback_all_keyword,
1732 		(void *)&cmd_config_loopback_all_all,
1733 		(void *)&cmd_config_loopback_all_item,
1734 		(void *)&cmd_config_loopback_all_mode,
1735 		NULL,
1736 	},
1737 };
1738 
1739 /* *** configure loopback for specific port *** */
1740 struct cmd_config_loopback_specific {
1741 	cmdline_fixed_string_t port;
1742 	cmdline_fixed_string_t keyword;
1743 	uint16_t port_id;
1744 	cmdline_fixed_string_t item;
1745 	uint32_t mode;
1746 };
1747 
1748 static void
1749 cmd_config_loopback_specific_parsed(void *parsed_result,
1750 				__rte_unused struct cmdline *cl,
1751 				__rte_unused void *data)
1752 {
1753 	struct cmd_config_loopback_specific *res = parsed_result;
1754 
1755 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1756 		return;
1757 
1758 	if (!port_is_stopped(res->port_id)) {
1759 		printf("Please stop port %u first\n", res->port_id);
1760 		return;
1761 	}
1762 
1763 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1764 
1765 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1766 }
1767 
1768 
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1770 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1771 								"port");
1772 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1773 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1774 								"config");
1775 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1776 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1777 								RTE_UINT16);
1778 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1779 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1780 								"loopback");
1781 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1782 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1783 			      RTE_UINT32);
1784 
1785 cmdline_parse_inst_t cmd_config_loopback_specific = {
1786 	.f = cmd_config_loopback_specific_parsed,
1787 	.data = NULL,
1788 	.help_str = "port config <port_id> loopback <mode>",
1789 	.tokens = {
1790 		(void *)&cmd_config_loopback_specific_port,
1791 		(void *)&cmd_config_loopback_specific_keyword,
1792 		(void *)&cmd_config_loopback_specific_id,
1793 		(void *)&cmd_config_loopback_specific_item,
1794 		(void *)&cmd_config_loopback_specific_mode,
1795 		NULL,
1796 	},
1797 };
1798 
1799 /* *** configure txq/rxq, txd/rxd *** */
1800 struct cmd_config_rx_tx {
1801 	cmdline_fixed_string_t port;
1802 	cmdline_fixed_string_t keyword;
1803 	cmdline_fixed_string_t all;
1804 	cmdline_fixed_string_t name;
1805 	uint16_t value;
1806 };
1807 
1808 static void
1809 cmd_config_rx_tx_parsed(void *parsed_result,
1810 			__rte_unused struct cmdline *cl,
1811 			__rte_unused void *data)
1812 {
1813 	struct cmd_config_rx_tx *res = parsed_result;
1814 
1815 	if (!all_ports_stopped()) {
1816 		printf("Please stop all ports first\n");
1817 		return;
1818 	}
1819 	if (!strcmp(res->name, "rxq")) {
1820 		if (!res->value && !nb_txq) {
1821 			printf("Warning: Either rx or tx queues should be non zero\n");
1822 			return;
1823 		}
1824 		if (check_nb_rxq(res->value) != 0)
1825 			return;
1826 		nb_rxq = res->value;
1827 	}
1828 	else if (!strcmp(res->name, "txq")) {
1829 		if (!res->value && !nb_rxq) {
1830 			printf("Warning: Either rx or tx queues should be non zero\n");
1831 			return;
1832 		}
1833 		if (check_nb_txq(res->value) != 0)
1834 			return;
1835 		nb_txq = res->value;
1836 	}
1837 	else if (!strcmp(res->name, "rxd")) {
1838 		if (check_nb_rxd(res->value) != 0)
1839 			return;
1840 		nb_rxd = res->value;
1841 	} else if (!strcmp(res->name, "txd")) {
1842 		if (check_nb_txd(res->value) != 0)
1843 			return;
1844 
1845 		nb_txd = res->value;
1846 	} else {
1847 		printf("Unknown parameter\n");
1848 		return;
1849 	}
1850 
1851 	fwd_config_setup();
1852 
1853 	init_port_config();
1854 
1855 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1856 }
1857 
1858 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1859 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1860 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1861 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1862 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1863 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1864 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1865 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1866 						"rxq#txq#rxd#txd");
1867 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1868 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1869 
1870 cmdline_parse_inst_t cmd_config_rx_tx = {
1871 	.f = cmd_config_rx_tx_parsed,
1872 	.data = NULL,
1873 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1874 	.tokens = {
1875 		(void *)&cmd_config_rx_tx_port,
1876 		(void *)&cmd_config_rx_tx_keyword,
1877 		(void *)&cmd_config_rx_tx_all,
1878 		(void *)&cmd_config_rx_tx_name,
1879 		(void *)&cmd_config_rx_tx_value,
1880 		NULL,
1881 	},
1882 };
1883 
1884 /* *** config max packet length *** */
1885 struct cmd_config_max_pkt_len_result {
1886 	cmdline_fixed_string_t port;
1887 	cmdline_fixed_string_t keyword;
1888 	cmdline_fixed_string_t all;
1889 	cmdline_fixed_string_t name;
1890 	uint32_t value;
1891 };
1892 
1893 static void
1894 cmd_config_max_pkt_len_parsed(void *parsed_result,
1895 				__rte_unused struct cmdline *cl,
1896 				__rte_unused void *data)
1897 {
1898 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1899 	uint32_t max_rx_pkt_len_backup = 0;
1900 	portid_t pid;
1901 	int ret;
1902 
1903 	if (!all_ports_stopped()) {
1904 		printf("Please stop all ports first\n");
1905 		return;
1906 	}
1907 
1908 	RTE_ETH_FOREACH_DEV(pid) {
1909 		struct rte_port *port = &ports[pid];
1910 
1911 		if (!strcmp(res->name, "max-pkt-len")) {
1912 			if (res->value < RTE_ETHER_MIN_LEN) {
1913 				printf("max-pkt-len can not be less than %d\n",
1914 						RTE_ETHER_MIN_LEN);
1915 				return;
1916 			}
1917 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1918 				return;
1919 
1920 			ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1921 			if (ret != 0) {
1922 				printf("rte_eth_dev_info_get() failed for port %u\n",
1923 					pid);
1924 				return;
1925 			}
1926 
1927 			max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1928 
1929 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1930 			if (update_jumbo_frame_offload(pid) != 0)
1931 				port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1932 		} else {
1933 			printf("Unknown parameter\n");
1934 			return;
1935 		}
1936 	}
1937 
1938 	init_port_config();
1939 
1940 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1941 }
1942 
1943 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1944 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1945 								"port");
1946 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1947 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1948 								"config");
1949 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1950 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1951 								"all");
1952 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1953 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1954 								"max-pkt-len");
1955 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1956 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1957 								RTE_UINT32);
1958 
1959 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1960 	.f = cmd_config_max_pkt_len_parsed,
1961 	.data = NULL,
1962 	.help_str = "port config all max-pkt-len <value>",
1963 	.tokens = {
1964 		(void *)&cmd_config_max_pkt_len_port,
1965 		(void *)&cmd_config_max_pkt_len_keyword,
1966 		(void *)&cmd_config_max_pkt_len_all,
1967 		(void *)&cmd_config_max_pkt_len_name,
1968 		(void *)&cmd_config_max_pkt_len_value,
1969 		NULL,
1970 	},
1971 };
1972 
1973 /* *** config max LRO aggregated packet size *** */
1974 struct cmd_config_max_lro_pkt_size_result {
1975 	cmdline_fixed_string_t port;
1976 	cmdline_fixed_string_t keyword;
1977 	cmdline_fixed_string_t all;
1978 	cmdline_fixed_string_t name;
1979 	uint32_t value;
1980 };
1981 
1982 static void
1983 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1984 				__rte_unused struct cmdline *cl,
1985 				__rte_unused void *data)
1986 {
1987 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1988 	portid_t pid;
1989 
1990 	if (!all_ports_stopped()) {
1991 		printf("Please stop all ports first\n");
1992 		return;
1993 	}
1994 
1995 	RTE_ETH_FOREACH_DEV(pid) {
1996 		struct rte_port *port = &ports[pid];
1997 
1998 		if (!strcmp(res->name, "max-lro-pkt-size")) {
1999 			if (res->value ==
2000 					port->dev_conf.rxmode.max_lro_pkt_size)
2001 				return;
2002 
2003 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2004 		} else {
2005 			printf("Unknown parameter\n");
2006 			return;
2007 		}
2008 	}
2009 
2010 	init_port_config();
2011 
2012 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2013 }
2014 
2015 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2016 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2017 				 port, "port");
2018 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2019 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2020 				 keyword, "config");
2021 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2022 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2023 				 all, "all");
2024 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2025 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2026 				 name, "max-lro-pkt-size");
2027 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2028 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2029 			      value, RTE_UINT32);
2030 
2031 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2032 	.f = cmd_config_max_lro_pkt_size_parsed,
2033 	.data = NULL,
2034 	.help_str = "port config all max-lro-pkt-size <value>",
2035 	.tokens = {
2036 		(void *)&cmd_config_max_lro_pkt_size_port,
2037 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2038 		(void *)&cmd_config_max_lro_pkt_size_all,
2039 		(void *)&cmd_config_max_lro_pkt_size_name,
2040 		(void *)&cmd_config_max_lro_pkt_size_value,
2041 		NULL,
2042 	},
2043 };
2044 
2045 /* *** configure port MTU *** */
2046 struct cmd_config_mtu_result {
2047 	cmdline_fixed_string_t port;
2048 	cmdline_fixed_string_t keyword;
2049 	cmdline_fixed_string_t mtu;
2050 	portid_t port_id;
2051 	uint16_t value;
2052 };
2053 
2054 static void
2055 cmd_config_mtu_parsed(void *parsed_result,
2056 		      __rte_unused struct cmdline *cl,
2057 		      __rte_unused void *data)
2058 {
2059 	struct cmd_config_mtu_result *res = parsed_result;
2060 
2061 	if (res->value < RTE_ETHER_MIN_LEN) {
2062 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2063 		return;
2064 	}
2065 	port_mtu_set(res->port_id, res->value);
2066 }
2067 
2068 cmdline_parse_token_string_t cmd_config_mtu_port =
2069 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2070 				 "port");
2071 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2072 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2073 				 "config");
2074 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2075 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2076 				 "mtu");
2077 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2078 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2079 				 RTE_UINT16);
2080 cmdline_parse_token_num_t cmd_config_mtu_value =
2081 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2082 				 RTE_UINT16);
2083 
2084 cmdline_parse_inst_t cmd_config_mtu = {
2085 	.f = cmd_config_mtu_parsed,
2086 	.data = NULL,
2087 	.help_str = "port config mtu <port_id> <value>",
2088 	.tokens = {
2089 		(void *)&cmd_config_mtu_port,
2090 		(void *)&cmd_config_mtu_keyword,
2091 		(void *)&cmd_config_mtu_mtu,
2092 		(void *)&cmd_config_mtu_port_id,
2093 		(void *)&cmd_config_mtu_value,
2094 		NULL,
2095 	},
2096 };
2097 
2098 /* *** configure rx mode *** */
2099 struct cmd_config_rx_mode_flag {
2100 	cmdline_fixed_string_t port;
2101 	cmdline_fixed_string_t keyword;
2102 	cmdline_fixed_string_t all;
2103 	cmdline_fixed_string_t name;
2104 	cmdline_fixed_string_t value;
2105 };
2106 
2107 static void
2108 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2109 				__rte_unused struct cmdline *cl,
2110 				__rte_unused void *data)
2111 {
2112 	struct cmd_config_rx_mode_flag *res = parsed_result;
2113 
2114 	if (!all_ports_stopped()) {
2115 		printf("Please stop all ports first\n");
2116 		return;
2117 	}
2118 
2119 	if (!strcmp(res->name, "drop-en")) {
2120 		if (!strcmp(res->value, "on"))
2121 			rx_drop_en = 1;
2122 		else if (!strcmp(res->value, "off"))
2123 			rx_drop_en = 0;
2124 		else {
2125 			printf("Unknown parameter\n");
2126 			return;
2127 		}
2128 	} else {
2129 		printf("Unknown parameter\n");
2130 		return;
2131 	}
2132 
2133 	init_port_config();
2134 
2135 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2136 }
2137 
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2139 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2141 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2142 								"config");
2143 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2144 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2145 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2146 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2147 					"drop-en");
2148 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2149 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2150 							"on#off");
2151 
2152 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2153 	.f = cmd_config_rx_mode_flag_parsed,
2154 	.data = NULL,
2155 	.help_str = "port config all drop-en on|off",
2156 	.tokens = {
2157 		(void *)&cmd_config_rx_mode_flag_port,
2158 		(void *)&cmd_config_rx_mode_flag_keyword,
2159 		(void *)&cmd_config_rx_mode_flag_all,
2160 		(void *)&cmd_config_rx_mode_flag_name,
2161 		(void *)&cmd_config_rx_mode_flag_value,
2162 		NULL,
2163 	},
2164 };
2165 
2166 /* *** configure rss *** */
2167 struct cmd_config_rss {
2168 	cmdline_fixed_string_t port;
2169 	cmdline_fixed_string_t keyword;
2170 	cmdline_fixed_string_t all;
2171 	cmdline_fixed_string_t name;
2172 	cmdline_fixed_string_t value;
2173 };
2174 
2175 static void
2176 cmd_config_rss_parsed(void *parsed_result,
2177 			__rte_unused struct cmdline *cl,
2178 			__rte_unused void *data)
2179 {
2180 	struct cmd_config_rss *res = parsed_result;
2181 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2182 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2183 	int use_default = 0;
2184 	int all_updated = 1;
2185 	int diag;
2186 	uint16_t i;
2187 	int ret;
2188 
2189 	if (!strcmp(res->value, "all"))
2190 		rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2191 			ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2192 			ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2193 			ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2194 			ETH_RSS_ECPRI;
2195 	else if (!strcmp(res->value, "eth"))
2196 		rss_conf.rss_hf = ETH_RSS_ETH;
2197 	else if (!strcmp(res->value, "vlan"))
2198 		rss_conf.rss_hf = ETH_RSS_VLAN;
2199 	else if (!strcmp(res->value, "ip"))
2200 		rss_conf.rss_hf = ETH_RSS_IP;
2201 	else if (!strcmp(res->value, "udp"))
2202 		rss_conf.rss_hf = ETH_RSS_UDP;
2203 	else if (!strcmp(res->value, "tcp"))
2204 		rss_conf.rss_hf = ETH_RSS_TCP;
2205 	else if (!strcmp(res->value, "sctp"))
2206 		rss_conf.rss_hf = ETH_RSS_SCTP;
2207 	else if (!strcmp(res->value, "ether"))
2208 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2209 	else if (!strcmp(res->value, "port"))
2210 		rss_conf.rss_hf = ETH_RSS_PORT;
2211 	else if (!strcmp(res->value, "vxlan"))
2212 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2213 	else if (!strcmp(res->value, "geneve"))
2214 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2215 	else if (!strcmp(res->value, "nvgre"))
2216 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2217 	else if (!strcmp(res->value, "l3-pre32"))
2218 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2219 	else if (!strcmp(res->value, "l3-pre40"))
2220 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2221 	else if (!strcmp(res->value, "l3-pre48"))
2222 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2223 	else if (!strcmp(res->value, "l3-pre56"))
2224 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2225 	else if (!strcmp(res->value, "l3-pre64"))
2226 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2227 	else if (!strcmp(res->value, "l3-pre96"))
2228 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2229 	else if (!strcmp(res->value, "l3-src-only"))
2230 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2231 	else if (!strcmp(res->value, "l3-dst-only"))
2232 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2233 	else if (!strcmp(res->value, "l4-src-only"))
2234 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2235 	else if (!strcmp(res->value, "l4-dst-only"))
2236 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2237 	else if (!strcmp(res->value, "l2-src-only"))
2238 		rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2239 	else if (!strcmp(res->value, "l2-dst-only"))
2240 		rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2241 	else if (!strcmp(res->value, "l2tpv3"))
2242 		rss_conf.rss_hf = ETH_RSS_L2TPV3;
2243 	else if (!strcmp(res->value, "esp"))
2244 		rss_conf.rss_hf = ETH_RSS_ESP;
2245 	else if (!strcmp(res->value, "ah"))
2246 		rss_conf.rss_hf = ETH_RSS_AH;
2247 	else if (!strcmp(res->value, "pfcp"))
2248 		rss_conf.rss_hf = ETH_RSS_PFCP;
2249 	else if (!strcmp(res->value, "pppoe"))
2250 		rss_conf.rss_hf = ETH_RSS_PPPOE;
2251 	else if (!strcmp(res->value, "gtpu"))
2252 		rss_conf.rss_hf = ETH_RSS_GTPU;
2253 	else if (!strcmp(res->value, "ecpri"))
2254 		rss_conf.rss_hf = ETH_RSS_ECPRI;
2255 	else if (!strcmp(res->value, "mpls"))
2256 		rss_conf.rss_hf = ETH_RSS_MPLS;
2257 	else if (!strcmp(res->value, "none"))
2258 		rss_conf.rss_hf = 0;
2259 	else if (!strcmp(res->value, "level-default")) {
2260 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2261 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2262 	} else if (!strcmp(res->value, "level-outer")) {
2263 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2264 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2265 	} else if (!strcmp(res->value, "level-inner")) {
2266 		rss_hf &= (~ETH_RSS_LEVEL_MASK);
2267 		rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2268 	} else if (!strcmp(res->value, "default"))
2269 		use_default = 1;
2270 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2271 						atoi(res->value) < 64)
2272 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2273 	else {
2274 		printf("Unknown parameter\n");
2275 		return;
2276 	}
2277 	rss_conf.rss_key = NULL;
2278 	/* Update global configuration for RSS types. */
2279 	RTE_ETH_FOREACH_DEV(i) {
2280 		struct rte_eth_rss_conf local_rss_conf;
2281 
2282 		ret = eth_dev_info_get_print_err(i, &dev_info);
2283 		if (ret != 0)
2284 			return;
2285 
2286 		if (use_default)
2287 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2288 
2289 		local_rss_conf = rss_conf;
2290 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2291 			dev_info.flow_type_rss_offloads;
2292 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2293 			printf("Port %u modified RSS hash function based on hardware support,"
2294 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2295 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2296 		}
2297 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2298 		if (diag < 0) {
2299 			all_updated = 0;
2300 			printf("Configuration of RSS hash at ethernet port %d "
2301 				"failed with error (%d): %s.\n",
2302 				i, -diag, strerror(-diag));
2303 		}
2304 	}
2305 	if (all_updated && !use_default) {
2306 		rss_hf = rss_conf.rss_hf;
2307 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2308 	}
2309 }
2310 
2311 cmdline_parse_token_string_t cmd_config_rss_port =
2312 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2313 cmdline_parse_token_string_t cmd_config_rss_keyword =
2314 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2315 cmdline_parse_token_string_t cmd_config_rss_all =
2316 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2317 cmdline_parse_token_string_t cmd_config_rss_name =
2318 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2319 cmdline_parse_token_string_t cmd_config_rss_value =
2320 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2321 
2322 cmdline_parse_inst_t cmd_config_rss = {
2323 	.f = cmd_config_rss_parsed,
2324 	.data = NULL,
2325 	.help_str = "port config all rss "
2326 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2327 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2328 		"level-outer|level-inner|<flowtype_id>",
2329 	.tokens = {
2330 		(void *)&cmd_config_rss_port,
2331 		(void *)&cmd_config_rss_keyword,
2332 		(void *)&cmd_config_rss_all,
2333 		(void *)&cmd_config_rss_name,
2334 		(void *)&cmd_config_rss_value,
2335 		NULL,
2336 	},
2337 };
2338 
2339 /* *** configure rss hash key *** */
2340 struct cmd_config_rss_hash_key {
2341 	cmdline_fixed_string_t port;
2342 	cmdline_fixed_string_t config;
2343 	portid_t port_id;
2344 	cmdline_fixed_string_t rss_hash_key;
2345 	cmdline_fixed_string_t rss_type;
2346 	cmdline_fixed_string_t key;
2347 };
2348 
2349 static uint8_t
2350 hexa_digit_to_value(char hexa_digit)
2351 {
2352 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2353 		return (uint8_t) (hexa_digit - '0');
2354 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2355 		return (uint8_t) ((hexa_digit - 'a') + 10);
2356 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2357 		return (uint8_t) ((hexa_digit - 'A') + 10);
2358 	/* Invalid hexa digit */
2359 	return 0xFF;
2360 }
2361 
2362 static uint8_t
2363 parse_and_check_key_hexa_digit(char *key, int idx)
2364 {
2365 	uint8_t hexa_v;
2366 
2367 	hexa_v = hexa_digit_to_value(key[idx]);
2368 	if (hexa_v == 0xFF)
2369 		printf("invalid key: character %c at position %d is not a "
2370 		       "valid hexa digit\n", key[idx], idx);
2371 	return hexa_v;
2372 }
2373 
2374 static void
2375 cmd_config_rss_hash_key_parsed(void *parsed_result,
2376 			       __rte_unused struct cmdline *cl,
2377 			       __rte_unused void *data)
2378 {
2379 	struct cmd_config_rss_hash_key *res = parsed_result;
2380 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2381 	uint8_t xdgt0;
2382 	uint8_t xdgt1;
2383 	int i;
2384 	struct rte_eth_dev_info dev_info;
2385 	uint8_t hash_key_size;
2386 	uint32_t key_len;
2387 	int ret;
2388 
2389 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2390 	if (ret != 0)
2391 		return;
2392 
2393 	if (dev_info.hash_key_size > 0 &&
2394 			dev_info.hash_key_size <= sizeof(hash_key))
2395 		hash_key_size = dev_info.hash_key_size;
2396 	else {
2397 		printf("dev_info did not provide a valid hash key size\n");
2398 		return;
2399 	}
2400 	/* Check the length of the RSS hash key */
2401 	key_len = strlen(res->key);
2402 	if (key_len != (hash_key_size * 2)) {
2403 		printf("key length: %d invalid - key must be a string of %d"
2404 			   " hexa-decimal numbers\n",
2405 			   (int) key_len, hash_key_size * 2);
2406 		return;
2407 	}
2408 	/* Translate RSS hash key into binary representation */
2409 	for (i = 0; i < hash_key_size; i++) {
2410 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2411 		if (xdgt0 == 0xFF)
2412 			return;
2413 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2414 		if (xdgt1 == 0xFF)
2415 			return;
2416 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2417 	}
2418 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2419 			hash_key_size);
2420 }
2421 
2422 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2423 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2425 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2426 				 "config");
2427 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2428 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2429 				 RTE_UINT16);
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2431 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2432 				 rss_hash_key, "rss-hash-key");
2433 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2434 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2435 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2436 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2437 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2438 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2439 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2440 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2441 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2442 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2443 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2444 
2445 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2446 	.f = cmd_config_rss_hash_key_parsed,
2447 	.data = NULL,
2448 	.help_str = "port config <port_id> rss-hash-key "
2449 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2450 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2451 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2452 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2453 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2454 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2455 		"<string of hex digits (variable length, NIC dependent)>",
2456 	.tokens = {
2457 		(void *)&cmd_config_rss_hash_key_port,
2458 		(void *)&cmd_config_rss_hash_key_config,
2459 		(void *)&cmd_config_rss_hash_key_port_id,
2460 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2461 		(void *)&cmd_config_rss_hash_key_rss_type,
2462 		(void *)&cmd_config_rss_hash_key_value,
2463 		NULL,
2464 	},
2465 };
2466 
2467 /* *** cleanup txq mbufs *** */
2468 struct cmd_cleanup_txq_mbufs_result {
2469 	cmdline_fixed_string_t port;
2470 	cmdline_fixed_string_t keyword;
2471 	cmdline_fixed_string_t name;
2472 	uint16_t port_id;
2473 	uint16_t queue_id;
2474 	uint32_t free_cnt;
2475 };
2476 
2477 static void
2478 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2479 			     __rte_unused struct cmdline *cl,
2480 			     __rte_unused void *data)
2481 {
2482 	struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2483 	uint16_t port_id = res->port_id;
2484 	uint16_t queue_id = res->queue_id;
2485 	uint32_t free_cnt = res->free_cnt;
2486 	struct rte_eth_txq_info qinfo;
2487 	int ret;
2488 
2489 	if (test_done == 0) {
2490 		printf("Please stop forwarding first\n");
2491 		return;
2492 	}
2493 
2494 	if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2495 		printf("Failed to get port %u Tx queue %u info\n",
2496 		       port_id, queue_id);
2497 		return;
2498 	}
2499 
2500 	if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2501 		printf("Tx queue %u not started\n", queue_id);
2502 		return;
2503 	}
2504 
2505 	ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2506 	if (ret < 0) {
2507 		printf("Failed to cleanup mbuf for port %u Tx queue %u "
2508 		       "error desc: %s(%d)\n",
2509 		       port_id, queue_id, strerror(-ret), ret);
2510 		return;
2511 	}
2512 
2513 	printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2514 	       port_id, queue_id, ret);
2515 }
2516 
2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2518 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2519 				 "port");
2520 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2521 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2522 				 "cleanup");
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2524 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2525 			      RTE_UINT16);
2526 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2527 	TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2528 				 "txq");
2529 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2530 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2531 			      RTE_UINT16);
2532 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2533 	TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2534 			      RTE_UINT32);
2535 
2536 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2537 	.f = cmd_cleanup_txq_mbufs_parsed,
2538 	.data = NULL,
2539 	.help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2540 	.tokens = {
2541 		(void *)&cmd_cleanup_txq_mbufs_port,
2542 		(void *)&cmd_cleanup_txq_mbufs_cleanup,
2543 		(void *)&cmd_cleanup_txq_mbufs_port_id,
2544 		(void *)&cmd_cleanup_txq_mbufs_txq,
2545 		(void *)&cmd_cleanup_txq_mbufs_queue_id,
2546 		(void *)&cmd_cleanup_txq_mbufs_free_cnt,
2547 		NULL,
2548 	},
2549 };
2550 
2551 /* *** configure port rxq/txq ring size *** */
2552 struct cmd_config_rxtx_ring_size {
2553 	cmdline_fixed_string_t port;
2554 	cmdline_fixed_string_t config;
2555 	portid_t portid;
2556 	cmdline_fixed_string_t rxtxq;
2557 	uint16_t qid;
2558 	cmdline_fixed_string_t rsize;
2559 	uint16_t size;
2560 };
2561 
2562 static void
2563 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2564 				 __rte_unused struct cmdline *cl,
2565 				 __rte_unused void *data)
2566 {
2567 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2568 	struct rte_port *port;
2569 	uint8_t isrx;
2570 
2571 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2572 		return;
2573 
2574 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2575 		printf("Invalid port id\n");
2576 		return;
2577 	}
2578 
2579 	port = &ports[res->portid];
2580 
2581 	if (!strcmp(res->rxtxq, "rxq"))
2582 		isrx = 1;
2583 	else if (!strcmp(res->rxtxq, "txq"))
2584 		isrx = 0;
2585 	else {
2586 		printf("Unknown parameter\n");
2587 		return;
2588 	}
2589 
2590 	if (isrx && rx_queue_id_is_invalid(res->qid))
2591 		return;
2592 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2593 		return;
2594 
2595 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2596 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2597 		       rx_free_thresh);
2598 		return;
2599 	}
2600 
2601 	if (isrx)
2602 		port->nb_rx_desc[res->qid] = res->size;
2603 	else
2604 		port->nb_tx_desc[res->qid] = res->size;
2605 
2606 	cmd_reconfig_device_queue(res->portid, 0, 1);
2607 }
2608 
2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2610 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2611 				 port, "port");
2612 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2613 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 				 config, "config");
2615 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2616 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2617 				 portid, RTE_UINT16);
2618 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2619 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 				 rxtxq, "rxq#txq");
2621 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2622 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2623 			      qid, RTE_UINT16);
2624 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2625 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 				 rsize, "ring_size");
2627 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2628 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2629 			      size, RTE_UINT16);
2630 
2631 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2632 	.f = cmd_config_rxtx_ring_size_parsed,
2633 	.data = NULL,
2634 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2635 	.tokens = {
2636 		(void *)&cmd_config_rxtx_ring_size_port,
2637 		(void *)&cmd_config_rxtx_ring_size_config,
2638 		(void *)&cmd_config_rxtx_ring_size_portid,
2639 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2640 		(void *)&cmd_config_rxtx_ring_size_qid,
2641 		(void *)&cmd_config_rxtx_ring_size_rsize,
2642 		(void *)&cmd_config_rxtx_ring_size_size,
2643 		NULL,
2644 	},
2645 };
2646 
2647 /* *** configure port rxq/txq start/stop *** */
2648 struct cmd_config_rxtx_queue {
2649 	cmdline_fixed_string_t port;
2650 	portid_t portid;
2651 	cmdline_fixed_string_t rxtxq;
2652 	uint16_t qid;
2653 	cmdline_fixed_string_t opname;
2654 };
2655 
2656 static void
2657 cmd_config_rxtx_queue_parsed(void *parsed_result,
2658 			__rte_unused struct cmdline *cl,
2659 			__rte_unused void *data)
2660 {
2661 	struct cmd_config_rxtx_queue *res = parsed_result;
2662 	uint8_t isrx;
2663 	uint8_t isstart;
2664 	int ret = 0;
2665 
2666 	if (test_done == 0) {
2667 		printf("Please stop forwarding first\n");
2668 		return;
2669 	}
2670 
2671 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2672 		return;
2673 
2674 	if (port_is_started(res->portid) != 1) {
2675 		printf("Please start port %u first\n", res->portid);
2676 		return;
2677 	}
2678 
2679 	if (!strcmp(res->rxtxq, "rxq"))
2680 		isrx = 1;
2681 	else if (!strcmp(res->rxtxq, "txq"))
2682 		isrx = 0;
2683 	else {
2684 		printf("Unknown parameter\n");
2685 		return;
2686 	}
2687 
2688 	if (isrx && rx_queue_id_is_invalid(res->qid))
2689 		return;
2690 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2691 		return;
2692 
2693 	if (!strcmp(res->opname, "start"))
2694 		isstart = 1;
2695 	else if (!strcmp(res->opname, "stop"))
2696 		isstart = 0;
2697 	else {
2698 		printf("Unknown parameter\n");
2699 		return;
2700 	}
2701 
2702 	if (isstart && isrx)
2703 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2704 	else if (!isstart && isrx)
2705 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2706 	else if (isstart && !isrx)
2707 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2708 	else
2709 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2710 
2711 	if (ret == -ENOTSUP)
2712 		printf("Function not supported in PMD driver\n");
2713 }
2714 
2715 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2716 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2717 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2718 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2719 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2720 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2721 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2722 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2723 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2724 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2725 						"start#stop");
2726 
2727 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2728 	.f = cmd_config_rxtx_queue_parsed,
2729 	.data = NULL,
2730 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2731 	.tokens = {
2732 		(void *)&cmd_config_rxtx_queue_port,
2733 		(void *)&cmd_config_rxtx_queue_portid,
2734 		(void *)&cmd_config_rxtx_queue_rxtxq,
2735 		(void *)&cmd_config_rxtx_queue_qid,
2736 		(void *)&cmd_config_rxtx_queue_opname,
2737 		NULL,
2738 	},
2739 };
2740 
2741 /* *** configure port rxq/txq deferred start on/off *** */
2742 struct cmd_config_deferred_start_rxtx_queue {
2743 	cmdline_fixed_string_t port;
2744 	portid_t port_id;
2745 	cmdline_fixed_string_t rxtxq;
2746 	uint16_t qid;
2747 	cmdline_fixed_string_t opname;
2748 	cmdline_fixed_string_t state;
2749 };
2750 
2751 static void
2752 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2753 			__rte_unused struct cmdline *cl,
2754 			__rte_unused void *data)
2755 {
2756 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2757 	struct rte_port *port;
2758 	uint8_t isrx;
2759 	uint8_t ison;
2760 	uint8_t needreconfig = 0;
2761 
2762 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2763 		return;
2764 
2765 	if (port_is_started(res->port_id) != 0) {
2766 		printf("Please stop port %u first\n", res->port_id);
2767 		return;
2768 	}
2769 
2770 	port = &ports[res->port_id];
2771 
2772 	isrx = !strcmp(res->rxtxq, "rxq");
2773 
2774 	if (isrx && rx_queue_id_is_invalid(res->qid))
2775 		return;
2776 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2777 		return;
2778 
2779 	ison = !strcmp(res->state, "on");
2780 
2781 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2782 		port->rx_conf[res->qid].rx_deferred_start = ison;
2783 		needreconfig = 1;
2784 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2785 		port->tx_conf[res->qid].tx_deferred_start = ison;
2786 		needreconfig = 1;
2787 	}
2788 
2789 	if (needreconfig)
2790 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2791 }
2792 
2793 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2794 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2795 						port, "port");
2796 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2797 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2798 						port_id, RTE_UINT16);
2799 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2800 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 						rxtxq, "rxq#txq");
2802 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2803 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2804 						qid, RTE_UINT16);
2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2806 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2807 						opname, "deferred_start");
2808 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2809 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2810 						state, "on#off");
2811 
2812 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2813 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2814 	.data = NULL,
2815 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2816 	.tokens = {
2817 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2818 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2819 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2820 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2821 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2822 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2823 		NULL,
2824 	},
2825 };
2826 
2827 /* *** configure port rxq/txq setup *** */
2828 struct cmd_setup_rxtx_queue {
2829 	cmdline_fixed_string_t port;
2830 	portid_t portid;
2831 	cmdline_fixed_string_t rxtxq;
2832 	uint16_t qid;
2833 	cmdline_fixed_string_t setup;
2834 };
2835 
2836 /* Common CLI fields for queue setup */
2837 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2838 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2839 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2840 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2841 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2842 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2843 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2844 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2845 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2846 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2847 
2848 static void
2849 cmd_setup_rxtx_queue_parsed(
2850 	void *parsed_result,
2851 	__rte_unused struct cmdline *cl,
2852 	__rte_unused void *data)
2853 {
2854 	struct cmd_setup_rxtx_queue *res = parsed_result;
2855 	struct rte_port *port;
2856 	struct rte_mempool *mp;
2857 	unsigned int socket_id;
2858 	uint8_t isrx = 0;
2859 	int ret;
2860 
2861 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2862 		return;
2863 
2864 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2865 		printf("Invalid port id\n");
2866 		return;
2867 	}
2868 
2869 	if (!strcmp(res->rxtxq, "rxq"))
2870 		isrx = 1;
2871 	else if (!strcmp(res->rxtxq, "txq"))
2872 		isrx = 0;
2873 	else {
2874 		printf("Unknown parameter\n");
2875 		return;
2876 	}
2877 
2878 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2879 		printf("Invalid rx queue\n");
2880 		return;
2881 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2882 		printf("Invalid tx queue\n");
2883 		return;
2884 	}
2885 
2886 	port = &ports[res->portid];
2887 	if (isrx) {
2888 		socket_id = rxring_numa[res->portid];
2889 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2890 			socket_id = port->socket_id;
2891 
2892 		mp = mbuf_pool_find(socket_id, 0);
2893 		if (mp == NULL) {
2894 			printf("Failed to setup RX queue: "
2895 				"No mempool allocation"
2896 				" on the socket %d\n",
2897 				rxring_numa[res->portid]);
2898 			return;
2899 		}
2900 		ret = rx_queue_setup(res->portid,
2901 				     res->qid,
2902 				     port->nb_rx_desc[res->qid],
2903 				     socket_id,
2904 				     &port->rx_conf[res->qid],
2905 				     mp);
2906 		if (ret)
2907 			printf("Failed to setup RX queue\n");
2908 	} else {
2909 		socket_id = txring_numa[res->portid];
2910 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2911 			socket_id = port->socket_id;
2912 
2913 		if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2914 			printf("Failed to setup TX queue: not enough descriptors\n");
2915 			return;
2916 		}
2917 		ret = rte_eth_tx_queue_setup(res->portid,
2918 					     res->qid,
2919 					     port->nb_tx_desc[res->qid],
2920 					     socket_id,
2921 					     &port->tx_conf[res->qid]);
2922 		if (ret)
2923 			printf("Failed to setup TX queue\n");
2924 	}
2925 }
2926 
2927 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2928 	.f = cmd_setup_rxtx_queue_parsed,
2929 	.data = NULL,
2930 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2931 	.tokens = {
2932 		(void *)&cmd_setup_rxtx_queue_port,
2933 		(void *)&cmd_setup_rxtx_queue_portid,
2934 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2935 		(void *)&cmd_setup_rxtx_queue_qid,
2936 		(void *)&cmd_setup_rxtx_queue_setup,
2937 		NULL,
2938 	},
2939 };
2940 
2941 
2942 /* *** Configure RSS RETA *** */
2943 struct cmd_config_rss_reta {
2944 	cmdline_fixed_string_t port;
2945 	cmdline_fixed_string_t keyword;
2946 	portid_t port_id;
2947 	cmdline_fixed_string_t name;
2948 	cmdline_fixed_string_t list_name;
2949 	cmdline_fixed_string_t list_of_items;
2950 };
2951 
2952 static int
2953 parse_reta_config(const char *str,
2954 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2955 		  uint16_t nb_entries)
2956 {
2957 	int i;
2958 	unsigned size;
2959 	uint16_t hash_index, idx, shift;
2960 	uint16_t nb_queue;
2961 	char s[256];
2962 	const char *p, *p0 = str;
2963 	char *end;
2964 	enum fieldnames {
2965 		FLD_HASH_INDEX = 0,
2966 		FLD_QUEUE,
2967 		_NUM_FLD
2968 	};
2969 	unsigned long int_fld[_NUM_FLD];
2970 	char *str_fld[_NUM_FLD];
2971 
2972 	while ((p = strchr(p0,'(')) != NULL) {
2973 		++p;
2974 		if((p0 = strchr(p,')')) == NULL)
2975 			return -1;
2976 
2977 		size = p0 - p;
2978 		if(size >= sizeof(s))
2979 			return -1;
2980 
2981 		snprintf(s, sizeof(s), "%.*s", size, p);
2982 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2983 			return -1;
2984 		for (i = 0; i < _NUM_FLD; i++) {
2985 			errno = 0;
2986 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2987 			if (errno != 0 || end == str_fld[i] ||
2988 					int_fld[i] > 65535)
2989 				return -1;
2990 		}
2991 
2992 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2993 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2994 
2995 		if (hash_index >= nb_entries) {
2996 			printf("Invalid RETA hash index=%d\n", hash_index);
2997 			return -1;
2998 		}
2999 
3000 		idx = hash_index / RTE_RETA_GROUP_SIZE;
3001 		shift = hash_index % RTE_RETA_GROUP_SIZE;
3002 		reta_conf[idx].mask |= (1ULL << shift);
3003 		reta_conf[idx].reta[shift] = nb_queue;
3004 	}
3005 
3006 	return 0;
3007 }
3008 
3009 static void
3010 cmd_set_rss_reta_parsed(void *parsed_result,
3011 			__rte_unused struct cmdline *cl,
3012 			__rte_unused void *data)
3013 {
3014 	int ret;
3015 	struct rte_eth_dev_info dev_info;
3016 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3017 	struct cmd_config_rss_reta *res = parsed_result;
3018 
3019 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3020 	if (ret != 0)
3021 		return;
3022 
3023 	if (dev_info.reta_size == 0) {
3024 		printf("Redirection table size is 0 which is "
3025 					"invalid for RSS\n");
3026 		return;
3027 	} else
3028 		printf("The reta size of port %d is %u\n",
3029 			res->port_id, dev_info.reta_size);
3030 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3031 		printf("Currently do not support more than %u entries of "
3032 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
3033 		return;
3034 	}
3035 
3036 	memset(reta_conf, 0, sizeof(reta_conf));
3037 	if (!strcmp(res->list_name, "reta")) {
3038 		if (parse_reta_config(res->list_of_items, reta_conf,
3039 						dev_info.reta_size)) {
3040 			printf("Invalid RSS Redirection Table "
3041 					"config entered\n");
3042 			return;
3043 		}
3044 		ret = rte_eth_dev_rss_reta_update(res->port_id,
3045 				reta_conf, dev_info.reta_size);
3046 		if (ret != 0)
3047 			printf("Bad redirection table parameter, "
3048 					"return code = %d \n", ret);
3049 	}
3050 }
3051 
3052 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3053 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3054 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3055 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3056 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3057 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3058 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3059 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3060 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3061 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3063         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3064                                  NULL);
3065 cmdline_parse_inst_t cmd_config_rss_reta = {
3066 	.f = cmd_set_rss_reta_parsed,
3067 	.data = NULL,
3068 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3069 	.tokens = {
3070 		(void *)&cmd_config_rss_reta_port,
3071 		(void *)&cmd_config_rss_reta_keyword,
3072 		(void *)&cmd_config_rss_reta_port_id,
3073 		(void *)&cmd_config_rss_reta_name,
3074 		(void *)&cmd_config_rss_reta_list_name,
3075 		(void *)&cmd_config_rss_reta_list_of_items,
3076 		NULL,
3077 	},
3078 };
3079 
3080 /* *** SHOW PORT RETA INFO *** */
3081 struct cmd_showport_reta {
3082 	cmdline_fixed_string_t show;
3083 	cmdline_fixed_string_t port;
3084 	portid_t port_id;
3085 	cmdline_fixed_string_t rss;
3086 	cmdline_fixed_string_t reta;
3087 	uint16_t size;
3088 	cmdline_fixed_string_t list_of_items;
3089 };
3090 
3091 static int
3092 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3093 			   uint16_t nb_entries,
3094 			   char *str)
3095 {
3096 	uint32_t size;
3097 	const char *p, *p0 = str;
3098 	char s[256];
3099 	char *end;
3100 	char *str_fld[8];
3101 	uint16_t i;
3102 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3103 			RTE_RETA_GROUP_SIZE;
3104 	int ret;
3105 
3106 	p = strchr(p0, '(');
3107 	if (p == NULL)
3108 		return -1;
3109 	p++;
3110 	p0 = strchr(p, ')');
3111 	if (p0 == NULL)
3112 		return -1;
3113 	size = p0 - p;
3114 	if (size >= sizeof(s)) {
3115 		printf("The string size exceeds the internal buffer size\n");
3116 		return -1;
3117 	}
3118 	snprintf(s, sizeof(s), "%.*s", size, p);
3119 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3120 	if (ret <= 0 || ret != num) {
3121 		printf("The bits of masks do not match the number of "
3122 					"reta entries: %u\n", num);
3123 		return -1;
3124 	}
3125 	for (i = 0; i < ret; i++)
3126 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3127 
3128 	return 0;
3129 }
3130 
3131 static void
3132 cmd_showport_reta_parsed(void *parsed_result,
3133 			 __rte_unused struct cmdline *cl,
3134 			 __rte_unused void *data)
3135 {
3136 	struct cmd_showport_reta *res = parsed_result;
3137 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3138 	struct rte_eth_dev_info dev_info;
3139 	uint16_t max_reta_size;
3140 	int ret;
3141 
3142 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3143 	if (ret != 0)
3144 		return;
3145 
3146 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3147 	if (res->size == 0 || res->size > max_reta_size) {
3148 		printf("Invalid redirection table size: %u (1-%u)\n",
3149 			res->size, max_reta_size);
3150 		return;
3151 	}
3152 
3153 	memset(reta_conf, 0, sizeof(reta_conf));
3154 	if (showport_parse_reta_config(reta_conf, res->size,
3155 				res->list_of_items) < 0) {
3156 		printf("Invalid string: %s for reta masks\n",
3157 					res->list_of_items);
3158 		return;
3159 	}
3160 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3161 }
3162 
3163 cmdline_parse_token_string_t cmd_showport_reta_show =
3164 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3165 cmdline_parse_token_string_t cmd_showport_reta_port =
3166 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3167 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3168 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3169 cmdline_parse_token_string_t cmd_showport_reta_rss =
3170 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3171 cmdline_parse_token_string_t cmd_showport_reta_reta =
3172 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3173 cmdline_parse_token_num_t cmd_showport_reta_size =
3174 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3175 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3176 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3177 					list_of_items, NULL);
3178 
3179 cmdline_parse_inst_t cmd_showport_reta = {
3180 	.f = cmd_showport_reta_parsed,
3181 	.data = NULL,
3182 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3183 	.tokens = {
3184 		(void *)&cmd_showport_reta_show,
3185 		(void *)&cmd_showport_reta_port,
3186 		(void *)&cmd_showport_reta_port_id,
3187 		(void *)&cmd_showport_reta_rss,
3188 		(void *)&cmd_showport_reta_reta,
3189 		(void *)&cmd_showport_reta_size,
3190 		(void *)&cmd_showport_reta_list_of_items,
3191 		NULL,
3192 	},
3193 };
3194 
3195 /* *** Show RSS hash configuration *** */
3196 struct cmd_showport_rss_hash {
3197 	cmdline_fixed_string_t show;
3198 	cmdline_fixed_string_t port;
3199 	portid_t port_id;
3200 	cmdline_fixed_string_t rss_hash;
3201 	cmdline_fixed_string_t rss_type;
3202 	cmdline_fixed_string_t key; /* optional argument */
3203 };
3204 
3205 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3206 				__rte_unused struct cmdline *cl,
3207 				void *show_rss_key)
3208 {
3209 	struct cmd_showport_rss_hash *res = parsed_result;
3210 
3211 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3212 }
3213 
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3215 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3216 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3217 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3218 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3219 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3220 				 RTE_UINT16);
3221 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3222 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3223 				 "rss-hash");
3224 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3225 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3226 
3227 cmdline_parse_inst_t cmd_showport_rss_hash = {
3228 	.f = cmd_showport_rss_hash_parsed,
3229 	.data = NULL,
3230 	.help_str = "show port <port_id> rss-hash",
3231 	.tokens = {
3232 		(void *)&cmd_showport_rss_hash_show,
3233 		(void *)&cmd_showport_rss_hash_port,
3234 		(void *)&cmd_showport_rss_hash_port_id,
3235 		(void *)&cmd_showport_rss_hash_rss_hash,
3236 		NULL,
3237 	},
3238 };
3239 
3240 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3241 	.f = cmd_showport_rss_hash_parsed,
3242 	.data = (void *)1,
3243 	.help_str = "show port <port_id> rss-hash key",
3244 	.tokens = {
3245 		(void *)&cmd_showport_rss_hash_show,
3246 		(void *)&cmd_showport_rss_hash_port,
3247 		(void *)&cmd_showport_rss_hash_port_id,
3248 		(void *)&cmd_showport_rss_hash_rss_hash,
3249 		(void *)&cmd_showport_rss_hash_rss_key,
3250 		NULL,
3251 	},
3252 };
3253 
3254 /* *** Configure DCB *** */
3255 struct cmd_config_dcb {
3256 	cmdline_fixed_string_t port;
3257 	cmdline_fixed_string_t config;
3258 	portid_t port_id;
3259 	cmdline_fixed_string_t dcb;
3260 	cmdline_fixed_string_t vt;
3261 	cmdline_fixed_string_t vt_en;
3262 	uint8_t num_tcs;
3263 	cmdline_fixed_string_t pfc;
3264 	cmdline_fixed_string_t pfc_en;
3265 };
3266 
3267 static void
3268 cmd_config_dcb_parsed(void *parsed_result,
3269                         __rte_unused struct cmdline *cl,
3270                         __rte_unused void *data)
3271 {
3272 	struct cmd_config_dcb *res = parsed_result;
3273 	struct rte_eth_dcb_info dcb_info;
3274 	portid_t port_id = res->port_id;
3275 	struct rte_port *port;
3276 	uint8_t pfc_en;
3277 	int ret;
3278 
3279 	port = &ports[port_id];
3280 	/** Check if the port is not started **/
3281 	if (port->port_status != RTE_PORT_STOPPED) {
3282 		printf("Please stop port %d first\n", port_id);
3283 		return;
3284 	}
3285 
3286 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3287 		printf("The invalid number of traffic class,"
3288 			" only 4 or 8 allowed.\n");
3289 		return;
3290 	}
3291 
3292 	if (nb_fwd_lcores < res->num_tcs) {
3293 		printf("nb_cores shouldn't be less than number of TCs.\n");
3294 		return;
3295 	}
3296 
3297 	/* Check whether the port supports the report of DCB info. */
3298 	ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3299 	if (ret == -ENOTSUP) {
3300 		printf("rte_eth_dev_get_dcb_info not supported.\n");
3301 		return;
3302 	}
3303 
3304 	if (!strncmp(res->pfc_en, "on", 2))
3305 		pfc_en = 1;
3306 	else
3307 		pfc_en = 0;
3308 
3309 	/* DCB in VT mode */
3310 	if (!strncmp(res->vt_en, "on", 2))
3311 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3312 				(enum rte_eth_nb_tcs)res->num_tcs,
3313 				pfc_en);
3314 	else
3315 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3316 				(enum rte_eth_nb_tcs)res->num_tcs,
3317 				pfc_en);
3318 
3319 
3320 	if (ret != 0) {
3321 		printf("Cannot initialize network ports.\n");
3322 		return;
3323 	}
3324 
3325 	cmd_reconfig_device_queue(port_id, 1, 1);
3326 }
3327 
3328 cmdline_parse_token_string_t cmd_config_dcb_port =
3329         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3330 cmdline_parse_token_string_t cmd_config_dcb_config =
3331         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3332 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3333 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3334 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3335         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3336 cmdline_parse_token_string_t cmd_config_dcb_vt =
3337         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3338 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3339         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3340 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3341 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3342 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3343         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3344 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3345         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3346 
3347 cmdline_parse_inst_t cmd_config_dcb = {
3348 	.f = cmd_config_dcb_parsed,
3349 	.data = NULL,
3350 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3351 	.tokens = {
3352 		(void *)&cmd_config_dcb_port,
3353 		(void *)&cmd_config_dcb_config,
3354 		(void *)&cmd_config_dcb_port_id,
3355 		(void *)&cmd_config_dcb_dcb,
3356 		(void *)&cmd_config_dcb_vt,
3357 		(void *)&cmd_config_dcb_vt_en,
3358 		(void *)&cmd_config_dcb_num_tcs,
3359 		(void *)&cmd_config_dcb_pfc,
3360 		(void *)&cmd_config_dcb_pfc_en,
3361                 NULL,
3362         },
3363 };
3364 
3365 /* *** configure number of packets per burst *** */
3366 struct cmd_config_burst {
3367 	cmdline_fixed_string_t port;
3368 	cmdline_fixed_string_t keyword;
3369 	cmdline_fixed_string_t all;
3370 	cmdline_fixed_string_t name;
3371 	uint16_t value;
3372 };
3373 
3374 static void
3375 cmd_config_burst_parsed(void *parsed_result,
3376 			__rte_unused struct cmdline *cl,
3377 			__rte_unused void *data)
3378 {
3379 	struct cmd_config_burst *res = parsed_result;
3380 	struct rte_eth_dev_info dev_info;
3381 	uint16_t rec_nb_pkts;
3382 	int ret;
3383 
3384 	if (!all_ports_stopped()) {
3385 		printf("Please stop all ports first\n");
3386 		return;
3387 	}
3388 
3389 	if (!strcmp(res->name, "burst")) {
3390 		if (res->value == 0) {
3391 			/* If user gives a value of zero, query the PMD for
3392 			 * its recommended Rx burst size. Testpmd uses a single
3393 			 * size for all ports, so assume all ports are the same
3394 			 * NIC model and use the values from Port 0.
3395 			 */
3396 			ret = eth_dev_info_get_print_err(0, &dev_info);
3397 			if (ret != 0)
3398 				return;
3399 
3400 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3401 
3402 			if (rec_nb_pkts == 0) {
3403 				printf("PMD does not recommend a burst size.\n"
3404 					"User provided value must be between"
3405 					" 1 and %d\n", MAX_PKT_BURST);
3406 				return;
3407 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3408 				printf("PMD recommended burst size of %d"
3409 					" exceeds maximum value of %d\n",
3410 					rec_nb_pkts, MAX_PKT_BURST);
3411 				return;
3412 			}
3413 			printf("Using PMD-provided burst value of %d\n",
3414 				rec_nb_pkts);
3415 			nb_pkt_per_burst = rec_nb_pkts;
3416 		} else if (res->value > MAX_PKT_BURST) {
3417 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3418 			return;
3419 		} else
3420 			nb_pkt_per_burst = res->value;
3421 	} else {
3422 		printf("Unknown parameter\n");
3423 		return;
3424 	}
3425 
3426 	init_port_config();
3427 
3428 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3429 }
3430 
3431 cmdline_parse_token_string_t cmd_config_burst_port =
3432 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3433 cmdline_parse_token_string_t cmd_config_burst_keyword =
3434 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3435 cmdline_parse_token_string_t cmd_config_burst_all =
3436 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3437 cmdline_parse_token_string_t cmd_config_burst_name =
3438 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3439 cmdline_parse_token_num_t cmd_config_burst_value =
3440 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3441 
3442 cmdline_parse_inst_t cmd_config_burst = {
3443 	.f = cmd_config_burst_parsed,
3444 	.data = NULL,
3445 	.help_str = "port config all burst <value>",
3446 	.tokens = {
3447 		(void *)&cmd_config_burst_port,
3448 		(void *)&cmd_config_burst_keyword,
3449 		(void *)&cmd_config_burst_all,
3450 		(void *)&cmd_config_burst_name,
3451 		(void *)&cmd_config_burst_value,
3452 		NULL,
3453 	},
3454 };
3455 
3456 /* *** configure rx/tx queues *** */
3457 struct cmd_config_thresh {
3458 	cmdline_fixed_string_t port;
3459 	cmdline_fixed_string_t keyword;
3460 	cmdline_fixed_string_t all;
3461 	cmdline_fixed_string_t name;
3462 	uint8_t value;
3463 };
3464 
3465 static void
3466 cmd_config_thresh_parsed(void *parsed_result,
3467 			__rte_unused struct cmdline *cl,
3468 			__rte_unused void *data)
3469 {
3470 	struct cmd_config_thresh *res = parsed_result;
3471 
3472 	if (!all_ports_stopped()) {
3473 		printf("Please stop all ports first\n");
3474 		return;
3475 	}
3476 
3477 	if (!strcmp(res->name, "txpt"))
3478 		tx_pthresh = res->value;
3479 	else if(!strcmp(res->name, "txht"))
3480 		tx_hthresh = res->value;
3481 	else if(!strcmp(res->name, "txwt"))
3482 		tx_wthresh = res->value;
3483 	else if(!strcmp(res->name, "rxpt"))
3484 		rx_pthresh = res->value;
3485 	else if(!strcmp(res->name, "rxht"))
3486 		rx_hthresh = res->value;
3487 	else if(!strcmp(res->name, "rxwt"))
3488 		rx_wthresh = res->value;
3489 	else {
3490 		printf("Unknown parameter\n");
3491 		return;
3492 	}
3493 
3494 	init_port_config();
3495 
3496 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3497 }
3498 
3499 cmdline_parse_token_string_t cmd_config_thresh_port =
3500 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3501 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3502 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3503 cmdline_parse_token_string_t cmd_config_thresh_all =
3504 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3505 cmdline_parse_token_string_t cmd_config_thresh_name =
3506 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3507 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3508 cmdline_parse_token_num_t cmd_config_thresh_value =
3509 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3510 
3511 cmdline_parse_inst_t cmd_config_thresh = {
3512 	.f = cmd_config_thresh_parsed,
3513 	.data = NULL,
3514 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3515 	.tokens = {
3516 		(void *)&cmd_config_thresh_port,
3517 		(void *)&cmd_config_thresh_keyword,
3518 		(void *)&cmd_config_thresh_all,
3519 		(void *)&cmd_config_thresh_name,
3520 		(void *)&cmd_config_thresh_value,
3521 		NULL,
3522 	},
3523 };
3524 
3525 /* *** configure free/rs threshold *** */
3526 struct cmd_config_threshold {
3527 	cmdline_fixed_string_t port;
3528 	cmdline_fixed_string_t keyword;
3529 	cmdline_fixed_string_t all;
3530 	cmdline_fixed_string_t name;
3531 	uint16_t value;
3532 };
3533 
3534 static void
3535 cmd_config_threshold_parsed(void *parsed_result,
3536 			__rte_unused struct cmdline *cl,
3537 			__rte_unused void *data)
3538 {
3539 	struct cmd_config_threshold *res = parsed_result;
3540 
3541 	if (!all_ports_stopped()) {
3542 		printf("Please stop all ports first\n");
3543 		return;
3544 	}
3545 
3546 	if (!strcmp(res->name, "txfreet"))
3547 		tx_free_thresh = res->value;
3548 	else if (!strcmp(res->name, "txrst"))
3549 		tx_rs_thresh = res->value;
3550 	else if (!strcmp(res->name, "rxfreet"))
3551 		rx_free_thresh = res->value;
3552 	else {
3553 		printf("Unknown parameter\n");
3554 		return;
3555 	}
3556 
3557 	init_port_config();
3558 
3559 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3560 }
3561 
3562 cmdline_parse_token_string_t cmd_config_threshold_port =
3563 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3564 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3565 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3566 								"config");
3567 cmdline_parse_token_string_t cmd_config_threshold_all =
3568 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3569 cmdline_parse_token_string_t cmd_config_threshold_name =
3570 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3571 						"txfreet#txrst#rxfreet");
3572 cmdline_parse_token_num_t cmd_config_threshold_value =
3573 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3574 
3575 cmdline_parse_inst_t cmd_config_threshold = {
3576 	.f = cmd_config_threshold_parsed,
3577 	.data = NULL,
3578 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3579 	.tokens = {
3580 		(void *)&cmd_config_threshold_port,
3581 		(void *)&cmd_config_threshold_keyword,
3582 		(void *)&cmd_config_threshold_all,
3583 		(void *)&cmd_config_threshold_name,
3584 		(void *)&cmd_config_threshold_value,
3585 		NULL,
3586 	},
3587 };
3588 
3589 /* *** stop *** */
3590 struct cmd_stop_result {
3591 	cmdline_fixed_string_t stop;
3592 };
3593 
3594 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3595 			    __rte_unused struct cmdline *cl,
3596 			    __rte_unused void *data)
3597 {
3598 	stop_packet_forwarding();
3599 }
3600 
3601 cmdline_parse_token_string_t cmd_stop_stop =
3602 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3603 
3604 cmdline_parse_inst_t cmd_stop = {
3605 	.f = cmd_stop_parsed,
3606 	.data = NULL,
3607 	.help_str = "stop: Stop packet forwarding",
3608 	.tokens = {
3609 		(void *)&cmd_stop_stop,
3610 		NULL,
3611 	},
3612 };
3613 
3614 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3615 
3616 unsigned int
3617 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3618 		unsigned int *parsed_items, int check_unique_values)
3619 {
3620 	unsigned int nb_item;
3621 	unsigned int value;
3622 	unsigned int i;
3623 	unsigned int j;
3624 	int value_ok;
3625 	char c;
3626 
3627 	/*
3628 	 * First parse all items in the list and store their value.
3629 	 */
3630 	value = 0;
3631 	nb_item = 0;
3632 	value_ok = 0;
3633 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3634 		c = str[i];
3635 		if ((c >= '0') && (c <= '9')) {
3636 			value = (unsigned int) (value * 10 + (c - '0'));
3637 			value_ok = 1;
3638 			continue;
3639 		}
3640 		if (c != ',') {
3641 			printf("character %c is not a decimal digit\n", c);
3642 			return 0;
3643 		}
3644 		if (! value_ok) {
3645 			printf("No valid value before comma\n");
3646 			return 0;
3647 		}
3648 		if (nb_item < max_items) {
3649 			parsed_items[nb_item] = value;
3650 			value_ok = 0;
3651 			value = 0;
3652 		}
3653 		nb_item++;
3654 	}
3655 	if (nb_item >= max_items) {
3656 		printf("Number of %s = %u > %u (maximum items)\n",
3657 		       item_name, nb_item + 1, max_items);
3658 		return 0;
3659 	}
3660 	parsed_items[nb_item++] = value;
3661 	if (! check_unique_values)
3662 		return nb_item;
3663 
3664 	/*
3665 	 * Then, check that all values in the list are differents.
3666 	 * No optimization here...
3667 	 */
3668 	for (i = 0; i < nb_item; i++) {
3669 		for (j = i + 1; j < nb_item; j++) {
3670 			if (parsed_items[j] == parsed_items[i]) {
3671 				printf("duplicated %s %u at index %u and %u\n",
3672 				       item_name, parsed_items[i], i, j);
3673 				return 0;
3674 			}
3675 		}
3676 	}
3677 	return nb_item;
3678 }
3679 
3680 struct cmd_set_list_result {
3681 	cmdline_fixed_string_t cmd_keyword;
3682 	cmdline_fixed_string_t list_name;
3683 	cmdline_fixed_string_t list_of_items;
3684 };
3685 
3686 static void cmd_set_list_parsed(void *parsed_result,
3687 				__rte_unused struct cmdline *cl,
3688 				__rte_unused void *data)
3689 {
3690 	struct cmd_set_list_result *res;
3691 	union {
3692 		unsigned int lcorelist[RTE_MAX_LCORE];
3693 		unsigned int portlist[RTE_MAX_ETHPORTS];
3694 	} parsed_items;
3695 	unsigned int nb_item;
3696 
3697 	if (test_done == 0) {
3698 		printf("Please stop forwarding first\n");
3699 		return;
3700 	}
3701 
3702 	res = parsed_result;
3703 	if (!strcmp(res->list_name, "corelist")) {
3704 		nb_item = parse_item_list(res->list_of_items, "core",
3705 					  RTE_MAX_LCORE,
3706 					  parsed_items.lcorelist, 1);
3707 		if (nb_item > 0) {
3708 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3709 			fwd_config_setup();
3710 		}
3711 		return;
3712 	}
3713 	if (!strcmp(res->list_name, "portlist")) {
3714 		nb_item = parse_item_list(res->list_of_items, "port",
3715 					  RTE_MAX_ETHPORTS,
3716 					  parsed_items.portlist, 1);
3717 		if (nb_item > 0) {
3718 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3719 			fwd_config_setup();
3720 		}
3721 	}
3722 }
3723 
3724 cmdline_parse_token_string_t cmd_set_list_keyword =
3725 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3726 				 "set");
3727 cmdline_parse_token_string_t cmd_set_list_name =
3728 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3729 				 "corelist#portlist");
3730 cmdline_parse_token_string_t cmd_set_list_of_items =
3731 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3732 				 NULL);
3733 
3734 cmdline_parse_inst_t cmd_set_fwd_list = {
3735 	.f = cmd_set_list_parsed,
3736 	.data = NULL,
3737 	.help_str = "set corelist|portlist <list0[,list1]*>",
3738 	.tokens = {
3739 		(void *)&cmd_set_list_keyword,
3740 		(void *)&cmd_set_list_name,
3741 		(void *)&cmd_set_list_of_items,
3742 		NULL,
3743 	},
3744 };
3745 
3746 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3747 
3748 struct cmd_setmask_result {
3749 	cmdline_fixed_string_t set;
3750 	cmdline_fixed_string_t mask;
3751 	uint64_t hexavalue;
3752 };
3753 
3754 static void cmd_set_mask_parsed(void *parsed_result,
3755 				__rte_unused struct cmdline *cl,
3756 				__rte_unused void *data)
3757 {
3758 	struct cmd_setmask_result *res = parsed_result;
3759 
3760 	if (test_done == 0) {
3761 		printf("Please stop forwarding first\n");
3762 		return;
3763 	}
3764 	if (!strcmp(res->mask, "coremask")) {
3765 		set_fwd_lcores_mask(res->hexavalue);
3766 		fwd_config_setup();
3767 	} else if (!strcmp(res->mask, "portmask")) {
3768 		set_fwd_ports_mask(res->hexavalue);
3769 		fwd_config_setup();
3770 	}
3771 }
3772 
3773 cmdline_parse_token_string_t cmd_setmask_set =
3774 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3775 cmdline_parse_token_string_t cmd_setmask_mask =
3776 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3777 				 "coremask#portmask");
3778 cmdline_parse_token_num_t cmd_setmask_value =
3779 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3780 
3781 cmdline_parse_inst_t cmd_set_fwd_mask = {
3782 	.f = cmd_set_mask_parsed,
3783 	.data = NULL,
3784 	.help_str = "set coremask|portmask <hexadecimal value>",
3785 	.tokens = {
3786 		(void *)&cmd_setmask_set,
3787 		(void *)&cmd_setmask_mask,
3788 		(void *)&cmd_setmask_value,
3789 		NULL,
3790 	},
3791 };
3792 
3793 /*
3794  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3795  */
3796 struct cmd_set_result {
3797 	cmdline_fixed_string_t set;
3798 	cmdline_fixed_string_t what;
3799 	uint16_t value;
3800 };
3801 
3802 static void cmd_set_parsed(void *parsed_result,
3803 			   __rte_unused struct cmdline *cl,
3804 			   __rte_unused void *data)
3805 {
3806 	struct cmd_set_result *res = parsed_result;
3807 	if (!strcmp(res->what, "nbport")) {
3808 		set_fwd_ports_number(res->value);
3809 		fwd_config_setup();
3810 	} else if (!strcmp(res->what, "nbcore")) {
3811 		set_fwd_lcores_number(res->value);
3812 		fwd_config_setup();
3813 	} else if (!strcmp(res->what, "burst"))
3814 		set_nb_pkt_per_burst(res->value);
3815 	else if (!strcmp(res->what, "verbose"))
3816 		set_verbose_level(res->value);
3817 }
3818 
3819 cmdline_parse_token_string_t cmd_set_set =
3820 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3821 cmdline_parse_token_string_t cmd_set_what =
3822 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3823 				 "nbport#nbcore#burst#verbose");
3824 cmdline_parse_token_num_t cmd_set_value =
3825 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3826 
3827 cmdline_parse_inst_t cmd_set_numbers = {
3828 	.f = cmd_set_parsed,
3829 	.data = NULL,
3830 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3831 	.tokens = {
3832 		(void *)&cmd_set_set,
3833 		(void *)&cmd_set_what,
3834 		(void *)&cmd_set_value,
3835 		NULL,
3836 	},
3837 };
3838 
3839 /* *** SET LOG LEVEL CONFIGURATION *** */
3840 
3841 struct cmd_set_log_result {
3842 	cmdline_fixed_string_t set;
3843 	cmdline_fixed_string_t log;
3844 	cmdline_fixed_string_t type;
3845 	uint32_t level;
3846 };
3847 
3848 static void
3849 cmd_set_log_parsed(void *parsed_result,
3850 		   __rte_unused struct cmdline *cl,
3851 		   __rte_unused void *data)
3852 {
3853 	struct cmd_set_log_result *res;
3854 	int ret;
3855 
3856 	res = parsed_result;
3857 	if (!strcmp(res->type, "global"))
3858 		rte_log_set_global_level(res->level);
3859 	else {
3860 		ret = rte_log_set_level_regexp(res->type, res->level);
3861 		if (ret < 0)
3862 			printf("Unable to set log level\n");
3863 	}
3864 }
3865 
3866 cmdline_parse_token_string_t cmd_set_log_set =
3867 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3868 cmdline_parse_token_string_t cmd_set_log_log =
3869 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3870 cmdline_parse_token_string_t cmd_set_log_type =
3871 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3872 cmdline_parse_token_num_t cmd_set_log_level =
3873 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3874 
3875 cmdline_parse_inst_t cmd_set_log = {
3876 	.f = cmd_set_log_parsed,
3877 	.data = NULL,
3878 	.help_str = "set log global|<type> <level>",
3879 	.tokens = {
3880 		(void *)&cmd_set_log_set,
3881 		(void *)&cmd_set_log_log,
3882 		(void *)&cmd_set_log_type,
3883 		(void *)&cmd_set_log_level,
3884 		NULL,
3885 	},
3886 };
3887 
3888 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3889 
3890 struct cmd_set_rxoffs_result {
3891 	cmdline_fixed_string_t cmd_keyword;
3892 	cmdline_fixed_string_t rxoffs;
3893 	cmdline_fixed_string_t seg_offsets;
3894 };
3895 
3896 static void
3897 cmd_set_rxoffs_parsed(void *parsed_result,
3898 		      __rte_unused struct cmdline *cl,
3899 		      __rte_unused void *data)
3900 {
3901 	struct cmd_set_rxoffs_result *res;
3902 	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3903 	unsigned int nb_segs;
3904 
3905 	res = parsed_result;
3906 	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3907 				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3908 	if (nb_segs > 0)
3909 		set_rx_pkt_offsets(seg_offsets, nb_segs);
3910 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3911 }
3912 
3913 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3914 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3915 				 cmd_keyword, "set");
3916 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3917 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3918 				 rxoffs, "rxoffs");
3919 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3920 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3921 				 seg_offsets, NULL);
3922 
3923 cmdline_parse_inst_t cmd_set_rxoffs = {
3924 	.f = cmd_set_rxoffs_parsed,
3925 	.data = NULL,
3926 	.help_str = "set rxoffs <len0[,len1]*>",
3927 	.tokens = {
3928 		(void *)&cmd_set_rxoffs_keyword,
3929 		(void *)&cmd_set_rxoffs_name,
3930 		(void *)&cmd_set_rxoffs_offsets,
3931 		NULL,
3932 	},
3933 };
3934 
3935 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3936 
3937 struct cmd_set_rxpkts_result {
3938 	cmdline_fixed_string_t cmd_keyword;
3939 	cmdline_fixed_string_t rxpkts;
3940 	cmdline_fixed_string_t seg_lengths;
3941 };
3942 
3943 static void
3944 cmd_set_rxpkts_parsed(void *parsed_result,
3945 		      __rte_unused struct cmdline *cl,
3946 		      __rte_unused void *data)
3947 {
3948 	struct cmd_set_rxpkts_result *res;
3949 	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3950 	unsigned int nb_segs;
3951 
3952 	res = parsed_result;
3953 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3954 				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3955 	if (nb_segs > 0)
3956 		set_rx_pkt_segments(seg_lengths, nb_segs);
3957 	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3958 }
3959 
3960 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3961 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3962 				 cmd_keyword, "set");
3963 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3964 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3965 				 rxpkts, "rxpkts");
3966 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3967 	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3968 				 seg_lengths, NULL);
3969 
3970 cmdline_parse_inst_t cmd_set_rxpkts = {
3971 	.f = cmd_set_rxpkts_parsed,
3972 	.data = NULL,
3973 	.help_str = "set rxpkts <len0[,len1]*>",
3974 	.tokens = {
3975 		(void *)&cmd_set_rxpkts_keyword,
3976 		(void *)&cmd_set_rxpkts_name,
3977 		(void *)&cmd_set_rxpkts_lengths,
3978 		NULL,
3979 	},
3980 };
3981 
3982 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3983 
3984 struct cmd_set_txpkts_result {
3985 	cmdline_fixed_string_t cmd_keyword;
3986 	cmdline_fixed_string_t txpkts;
3987 	cmdline_fixed_string_t seg_lengths;
3988 };
3989 
3990 static void
3991 cmd_set_txpkts_parsed(void *parsed_result,
3992 		      __rte_unused struct cmdline *cl,
3993 		      __rte_unused void *data)
3994 {
3995 	struct cmd_set_txpkts_result *res;
3996 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3997 	unsigned int nb_segs;
3998 
3999 	res = parsed_result;
4000 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4001 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4002 	if (nb_segs > 0)
4003 		set_tx_pkt_segments(seg_lengths, nb_segs);
4004 }
4005 
4006 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4007 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4008 				 cmd_keyword, "set");
4009 cmdline_parse_token_string_t cmd_set_txpkts_name =
4010 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4011 				 txpkts, "txpkts");
4012 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4013 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4014 				 seg_lengths, NULL);
4015 
4016 cmdline_parse_inst_t cmd_set_txpkts = {
4017 	.f = cmd_set_txpkts_parsed,
4018 	.data = NULL,
4019 	.help_str = "set txpkts <len0[,len1]*>",
4020 	.tokens = {
4021 		(void *)&cmd_set_txpkts_keyword,
4022 		(void *)&cmd_set_txpkts_name,
4023 		(void *)&cmd_set_txpkts_lengths,
4024 		NULL,
4025 	},
4026 };
4027 
4028 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4029 
4030 struct cmd_set_txsplit_result {
4031 	cmdline_fixed_string_t cmd_keyword;
4032 	cmdline_fixed_string_t txsplit;
4033 	cmdline_fixed_string_t mode;
4034 };
4035 
4036 static void
4037 cmd_set_txsplit_parsed(void *parsed_result,
4038 		      __rte_unused struct cmdline *cl,
4039 		      __rte_unused void *data)
4040 {
4041 	struct cmd_set_txsplit_result *res;
4042 
4043 	res = parsed_result;
4044 	set_tx_pkt_split(res->mode);
4045 }
4046 
4047 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4048 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4049 				 cmd_keyword, "set");
4050 cmdline_parse_token_string_t cmd_set_txsplit_name =
4051 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4052 				 txsplit, "txsplit");
4053 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4054 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4055 				 mode, NULL);
4056 
4057 cmdline_parse_inst_t cmd_set_txsplit = {
4058 	.f = cmd_set_txsplit_parsed,
4059 	.data = NULL,
4060 	.help_str = "set txsplit on|off|rand",
4061 	.tokens = {
4062 		(void *)&cmd_set_txsplit_keyword,
4063 		(void *)&cmd_set_txsplit_name,
4064 		(void *)&cmd_set_txsplit_mode,
4065 		NULL,
4066 	},
4067 };
4068 
4069 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4070 
4071 struct cmd_set_txtimes_result {
4072 	cmdline_fixed_string_t cmd_keyword;
4073 	cmdline_fixed_string_t txtimes;
4074 	cmdline_fixed_string_t tx_times;
4075 };
4076 
4077 static void
4078 cmd_set_txtimes_parsed(void *parsed_result,
4079 		       __rte_unused struct cmdline *cl,
4080 		       __rte_unused void *data)
4081 {
4082 	struct cmd_set_txtimes_result *res;
4083 	unsigned int tx_times[2] = {0, 0};
4084 	unsigned int n_times;
4085 
4086 	res = parsed_result;
4087 	n_times = parse_item_list(res->tx_times, "tx times",
4088 				  2, tx_times, 0);
4089 	if (n_times == 2)
4090 		set_tx_pkt_times(tx_times);
4091 }
4092 
4093 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4094 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4095 				 cmd_keyword, "set");
4096 cmdline_parse_token_string_t cmd_set_txtimes_name =
4097 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4098 				 txtimes, "txtimes");
4099 cmdline_parse_token_string_t cmd_set_txtimes_value =
4100 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4101 				 tx_times, NULL);
4102 
4103 cmdline_parse_inst_t cmd_set_txtimes = {
4104 	.f = cmd_set_txtimes_parsed,
4105 	.data = NULL,
4106 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
4107 	.tokens = {
4108 		(void *)&cmd_set_txtimes_keyword,
4109 		(void *)&cmd_set_txtimes_name,
4110 		(void *)&cmd_set_txtimes_value,
4111 		NULL,
4112 	},
4113 };
4114 
4115 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4116 struct cmd_rx_vlan_filter_all_result {
4117 	cmdline_fixed_string_t rx_vlan;
4118 	cmdline_fixed_string_t what;
4119 	cmdline_fixed_string_t all;
4120 	portid_t port_id;
4121 };
4122 
4123 static void
4124 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4125 			      __rte_unused struct cmdline *cl,
4126 			      __rte_unused void *data)
4127 {
4128 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4129 
4130 	if (!strcmp(res->what, "add"))
4131 		rx_vlan_all_filter_set(res->port_id, 1);
4132 	else
4133 		rx_vlan_all_filter_set(res->port_id, 0);
4134 }
4135 
4136 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4137 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 				 rx_vlan, "rx_vlan");
4139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4140 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4141 				 what, "add#rm");
4142 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4143 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4144 				 all, "all");
4145 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4146 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4147 			      port_id, RTE_UINT16);
4148 
4149 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4150 	.f = cmd_rx_vlan_filter_all_parsed,
4151 	.data = NULL,
4152 	.help_str = "rx_vlan add|rm all <port_id>: "
4153 		"Add/Remove all identifiers to/from the set of VLAN "
4154 		"identifiers filtered by a port",
4155 	.tokens = {
4156 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4157 		(void *)&cmd_rx_vlan_filter_all_what,
4158 		(void *)&cmd_rx_vlan_filter_all_all,
4159 		(void *)&cmd_rx_vlan_filter_all_portid,
4160 		NULL,
4161 	},
4162 };
4163 
4164 /* *** VLAN OFFLOAD SET ON A PORT *** */
4165 struct cmd_vlan_offload_result {
4166 	cmdline_fixed_string_t vlan;
4167 	cmdline_fixed_string_t set;
4168 	cmdline_fixed_string_t vlan_type;
4169 	cmdline_fixed_string_t what;
4170 	cmdline_fixed_string_t on;
4171 	cmdline_fixed_string_t port_id;
4172 };
4173 
4174 static void
4175 cmd_vlan_offload_parsed(void *parsed_result,
4176 			  __rte_unused struct cmdline *cl,
4177 			  __rte_unused void *data)
4178 {
4179 	int on;
4180 	struct cmd_vlan_offload_result *res = parsed_result;
4181 	char *str;
4182 	int i, len = 0;
4183 	portid_t port_id = 0;
4184 	unsigned int tmp;
4185 
4186 	str = res->port_id;
4187 	len = strnlen(str, STR_TOKEN_SIZE);
4188 	i = 0;
4189 	/* Get port_id first */
4190 	while(i < len){
4191 		if(str[i] == ',')
4192 			break;
4193 
4194 		i++;
4195 	}
4196 	str[i]='\0';
4197 	tmp = strtoul(str, NULL, 0);
4198 	/* If port_id greater that what portid_t can represent, return */
4199 	if(tmp >= RTE_MAX_ETHPORTS)
4200 		return;
4201 	port_id = (portid_t)tmp;
4202 
4203 	if (!strcmp(res->on, "on"))
4204 		on = 1;
4205 	else
4206 		on = 0;
4207 
4208 	if (!strcmp(res->what, "strip"))
4209 		rx_vlan_strip_set(port_id,  on);
4210 	else if(!strcmp(res->what, "stripq")){
4211 		uint16_t queue_id = 0;
4212 
4213 		/* No queue_id, return */
4214 		if(i + 1 >= len) {
4215 			printf("must specify (port,queue_id)\n");
4216 			return;
4217 		}
4218 		tmp = strtoul(str + i + 1, NULL, 0);
4219 		/* If queue_id greater that what 16-bits can represent, return */
4220 		if(tmp > 0xffff)
4221 			return;
4222 
4223 		queue_id = (uint16_t)tmp;
4224 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4225 	}
4226 	else if (!strcmp(res->what, "filter"))
4227 		rx_vlan_filter_set(port_id, on);
4228 	else if (!strcmp(res->what, "qinq_strip"))
4229 		rx_vlan_qinq_strip_set(port_id, on);
4230 	else
4231 		vlan_extend_set(port_id, on);
4232 
4233 	return;
4234 }
4235 
4236 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4237 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4238 				 vlan, "vlan");
4239 cmdline_parse_token_string_t cmd_vlan_offload_set =
4240 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4241 				 set, "set");
4242 cmdline_parse_token_string_t cmd_vlan_offload_what =
4243 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4244 				what, "strip#filter#qinq_strip#extend#stripq");
4245 cmdline_parse_token_string_t cmd_vlan_offload_on =
4246 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4247 			      on, "on#off");
4248 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4249 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4250 			      port_id, NULL);
4251 
4252 cmdline_parse_inst_t cmd_vlan_offload = {
4253 	.f = cmd_vlan_offload_parsed,
4254 	.data = NULL,
4255 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4256 		"<port_id[,queue_id]>: "
4257 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4258 	.tokens = {
4259 		(void *)&cmd_vlan_offload_vlan,
4260 		(void *)&cmd_vlan_offload_set,
4261 		(void *)&cmd_vlan_offload_what,
4262 		(void *)&cmd_vlan_offload_on,
4263 		(void *)&cmd_vlan_offload_portid,
4264 		NULL,
4265 	},
4266 };
4267 
4268 /* *** VLAN TPID SET ON A PORT *** */
4269 struct cmd_vlan_tpid_result {
4270 	cmdline_fixed_string_t vlan;
4271 	cmdline_fixed_string_t set;
4272 	cmdline_fixed_string_t vlan_type;
4273 	cmdline_fixed_string_t what;
4274 	uint16_t tp_id;
4275 	portid_t port_id;
4276 };
4277 
4278 static void
4279 cmd_vlan_tpid_parsed(void *parsed_result,
4280 			  __rte_unused struct cmdline *cl,
4281 			  __rte_unused void *data)
4282 {
4283 	struct cmd_vlan_tpid_result *res = parsed_result;
4284 	enum rte_vlan_type vlan_type;
4285 
4286 	if (!strcmp(res->vlan_type, "inner"))
4287 		vlan_type = ETH_VLAN_TYPE_INNER;
4288 	else if (!strcmp(res->vlan_type, "outer"))
4289 		vlan_type = ETH_VLAN_TYPE_OUTER;
4290 	else {
4291 		printf("Unknown vlan type\n");
4292 		return;
4293 	}
4294 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4295 }
4296 
4297 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4298 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4299 				 vlan, "vlan");
4300 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4301 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4302 				 set, "set");
4303 cmdline_parse_token_string_t cmd_vlan_type =
4304 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4305 				 vlan_type, "inner#outer");
4306 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4307 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4308 				 what, "tpid");
4309 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4310 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4311 			      tp_id, RTE_UINT16);
4312 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4313 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4314 			      port_id, RTE_UINT16);
4315 
4316 cmdline_parse_inst_t cmd_vlan_tpid = {
4317 	.f = cmd_vlan_tpid_parsed,
4318 	.data = NULL,
4319 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4320 		"Set the VLAN Ether type",
4321 	.tokens = {
4322 		(void *)&cmd_vlan_tpid_vlan,
4323 		(void *)&cmd_vlan_tpid_set,
4324 		(void *)&cmd_vlan_type,
4325 		(void *)&cmd_vlan_tpid_what,
4326 		(void *)&cmd_vlan_tpid_tpid,
4327 		(void *)&cmd_vlan_tpid_portid,
4328 		NULL,
4329 	},
4330 };
4331 
4332 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4333 struct cmd_rx_vlan_filter_result {
4334 	cmdline_fixed_string_t rx_vlan;
4335 	cmdline_fixed_string_t what;
4336 	uint16_t vlan_id;
4337 	portid_t port_id;
4338 };
4339 
4340 static void
4341 cmd_rx_vlan_filter_parsed(void *parsed_result,
4342 			  __rte_unused struct cmdline *cl,
4343 			  __rte_unused void *data)
4344 {
4345 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4346 
4347 	if (!strcmp(res->what, "add"))
4348 		rx_vft_set(res->port_id, res->vlan_id, 1);
4349 	else
4350 		rx_vft_set(res->port_id, res->vlan_id, 0);
4351 }
4352 
4353 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4354 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4355 				 rx_vlan, "rx_vlan");
4356 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4357 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4358 				 what, "add#rm");
4359 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4360 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4361 			      vlan_id, RTE_UINT16);
4362 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4363 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4364 			      port_id, RTE_UINT16);
4365 
4366 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4367 	.f = cmd_rx_vlan_filter_parsed,
4368 	.data = NULL,
4369 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4370 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4371 		"identifiers filtered by a port",
4372 	.tokens = {
4373 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4374 		(void *)&cmd_rx_vlan_filter_what,
4375 		(void *)&cmd_rx_vlan_filter_vlanid,
4376 		(void *)&cmd_rx_vlan_filter_portid,
4377 		NULL,
4378 	},
4379 };
4380 
4381 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4382 struct cmd_tx_vlan_set_result {
4383 	cmdline_fixed_string_t tx_vlan;
4384 	cmdline_fixed_string_t set;
4385 	portid_t port_id;
4386 	uint16_t vlan_id;
4387 };
4388 
4389 static void
4390 cmd_tx_vlan_set_parsed(void *parsed_result,
4391 		       __rte_unused struct cmdline *cl,
4392 		       __rte_unused void *data)
4393 {
4394 	struct cmd_tx_vlan_set_result *res = parsed_result;
4395 
4396 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4397 		return;
4398 
4399 	if (!port_is_stopped(res->port_id)) {
4400 		printf("Please stop port %d first\n", res->port_id);
4401 		return;
4402 	}
4403 
4404 	tx_vlan_set(res->port_id, res->vlan_id);
4405 
4406 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4407 }
4408 
4409 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4410 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4411 				 tx_vlan, "tx_vlan");
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4413 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4414 				 set, "set");
4415 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4416 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4417 			      port_id, RTE_UINT16);
4418 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4419 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4420 			      vlan_id, RTE_UINT16);
4421 
4422 cmdline_parse_inst_t cmd_tx_vlan_set = {
4423 	.f = cmd_tx_vlan_set_parsed,
4424 	.data = NULL,
4425 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4426 		"Enable hardware insertion of a single VLAN header "
4427 		"with a given TAG Identifier in packets sent on a port",
4428 	.tokens = {
4429 		(void *)&cmd_tx_vlan_set_tx_vlan,
4430 		(void *)&cmd_tx_vlan_set_set,
4431 		(void *)&cmd_tx_vlan_set_portid,
4432 		(void *)&cmd_tx_vlan_set_vlanid,
4433 		NULL,
4434 	},
4435 };
4436 
4437 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4438 struct cmd_tx_vlan_set_qinq_result {
4439 	cmdline_fixed_string_t tx_vlan;
4440 	cmdline_fixed_string_t set;
4441 	portid_t port_id;
4442 	uint16_t vlan_id;
4443 	uint16_t vlan_id_outer;
4444 };
4445 
4446 static void
4447 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4448 			    __rte_unused struct cmdline *cl,
4449 			    __rte_unused void *data)
4450 {
4451 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4452 
4453 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4454 		return;
4455 
4456 	if (!port_is_stopped(res->port_id)) {
4457 		printf("Please stop port %d first\n", res->port_id);
4458 		return;
4459 	}
4460 
4461 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4462 
4463 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4464 }
4465 
4466 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4467 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 		tx_vlan, "tx_vlan");
4469 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4470 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4471 		set, "set");
4472 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4473 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4474 		port_id, RTE_UINT16);
4475 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4476 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 		vlan_id, RTE_UINT16);
4478 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4479 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4480 		vlan_id_outer, RTE_UINT16);
4481 
4482 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4483 	.f = cmd_tx_vlan_set_qinq_parsed,
4484 	.data = NULL,
4485 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4486 		"Enable hardware insertion of double VLAN header "
4487 		"with given TAG Identifiers in packets sent on a port",
4488 	.tokens = {
4489 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4490 		(void *)&cmd_tx_vlan_set_qinq_set,
4491 		(void *)&cmd_tx_vlan_set_qinq_portid,
4492 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4493 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4494 		NULL,
4495 	},
4496 };
4497 
4498 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4499 struct cmd_tx_vlan_set_pvid_result {
4500 	cmdline_fixed_string_t tx_vlan;
4501 	cmdline_fixed_string_t set;
4502 	cmdline_fixed_string_t pvid;
4503 	portid_t port_id;
4504 	uint16_t vlan_id;
4505 	cmdline_fixed_string_t mode;
4506 };
4507 
4508 static void
4509 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4510 			    __rte_unused struct cmdline *cl,
4511 			    __rte_unused void *data)
4512 {
4513 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4514 
4515 	if (strcmp(res->mode, "on") == 0)
4516 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4517 	else
4518 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4519 }
4520 
4521 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4522 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 				 tx_vlan, "tx_vlan");
4524 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4525 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 				 set, "set");
4527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4528 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4529 				 pvid, "pvid");
4530 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4531 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4532 			     port_id, RTE_UINT16);
4533 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4534 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4535 			      vlan_id, RTE_UINT16);
4536 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4537 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4538 				 mode, "on#off");
4539 
4540 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4541 	.f = cmd_tx_vlan_set_pvid_parsed,
4542 	.data = NULL,
4543 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4544 	.tokens = {
4545 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4546 		(void *)&cmd_tx_vlan_set_pvid_set,
4547 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4548 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4549 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4550 		(void *)&cmd_tx_vlan_set_pvid_mode,
4551 		NULL,
4552 	},
4553 };
4554 
4555 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4556 struct cmd_tx_vlan_reset_result {
4557 	cmdline_fixed_string_t tx_vlan;
4558 	cmdline_fixed_string_t reset;
4559 	portid_t port_id;
4560 };
4561 
4562 static void
4563 cmd_tx_vlan_reset_parsed(void *parsed_result,
4564 			 __rte_unused struct cmdline *cl,
4565 			 __rte_unused void *data)
4566 {
4567 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4568 
4569 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4570 		return;
4571 
4572 	if (!port_is_stopped(res->port_id)) {
4573 		printf("Please stop port %d first\n", res->port_id);
4574 		return;
4575 	}
4576 
4577 	tx_vlan_reset(res->port_id);
4578 
4579 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4580 }
4581 
4582 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4583 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4584 				 tx_vlan, "tx_vlan");
4585 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4586 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4587 				 reset, "reset");
4588 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4589 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4590 			      port_id, RTE_UINT16);
4591 
4592 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4593 	.f = cmd_tx_vlan_reset_parsed,
4594 	.data = NULL,
4595 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4596 		"VLAN header in packets sent on a port",
4597 	.tokens = {
4598 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4599 		(void *)&cmd_tx_vlan_reset_reset,
4600 		(void *)&cmd_tx_vlan_reset_portid,
4601 		NULL,
4602 	},
4603 };
4604 
4605 
4606 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4607 struct cmd_csum_result {
4608 	cmdline_fixed_string_t csum;
4609 	cmdline_fixed_string_t mode;
4610 	cmdline_fixed_string_t proto;
4611 	cmdline_fixed_string_t hwsw;
4612 	portid_t port_id;
4613 };
4614 
4615 static void
4616 csum_show(int port_id)
4617 {
4618 	struct rte_eth_dev_info dev_info;
4619 	uint64_t tx_offloads;
4620 	int ret;
4621 
4622 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4623 	printf("Parse tunnel is %s\n",
4624 		(ports[port_id].parse_tunnel) ? "on" : "off");
4625 	printf("IP checksum offload is %s\n",
4626 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4627 	printf("UDP checksum offload is %s\n",
4628 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4629 	printf("TCP checksum offload is %s\n",
4630 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4631 	printf("SCTP checksum offload is %s\n",
4632 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4633 	printf("Outer-Ip checksum offload is %s\n",
4634 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4635 	printf("Outer-Udp checksum offload is %s\n",
4636 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4637 
4638 	/* display warnings if configuration is not supported by the NIC */
4639 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4640 	if (ret != 0)
4641 		return;
4642 
4643 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4644 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4645 		printf("Warning: hardware IP checksum enabled but not "
4646 			"supported by port %d\n", port_id);
4647 	}
4648 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4649 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4650 		printf("Warning: hardware UDP checksum enabled but not "
4651 			"supported by port %d\n", port_id);
4652 	}
4653 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4654 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4655 		printf("Warning: hardware TCP checksum enabled but not "
4656 			"supported by port %d\n", port_id);
4657 	}
4658 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4659 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4660 		printf("Warning: hardware SCTP checksum enabled but not "
4661 			"supported by port %d\n", port_id);
4662 	}
4663 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4664 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4665 		printf("Warning: hardware outer IP checksum enabled but not "
4666 			"supported by port %d\n", port_id);
4667 	}
4668 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4669 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4670 			== 0) {
4671 		printf("Warning: hardware outer UDP checksum enabled but not "
4672 			"supported by port %d\n", port_id);
4673 	}
4674 }
4675 
4676 static void
4677 cmd_config_queue_tx_offloads(struct rte_port *port)
4678 {
4679 	int k;
4680 
4681 	/* Apply queue tx offloads configuration */
4682 	for (k = 0; k < port->dev_info.max_tx_queues; k++)
4683 		port->tx_conf[k].offloads =
4684 			port->dev_conf.txmode.offloads;
4685 }
4686 
4687 static void
4688 cmd_csum_parsed(void *parsed_result,
4689 		       __rte_unused struct cmdline *cl,
4690 		       __rte_unused void *data)
4691 {
4692 	struct cmd_csum_result *res = parsed_result;
4693 	int hw = 0;
4694 	uint64_t csum_offloads = 0;
4695 	struct rte_eth_dev_info dev_info;
4696 	int ret;
4697 
4698 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4699 		printf("invalid port %d\n", res->port_id);
4700 		return;
4701 	}
4702 	if (!port_is_stopped(res->port_id)) {
4703 		printf("Please stop port %d first\n", res->port_id);
4704 		return;
4705 	}
4706 
4707 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4708 	if (ret != 0)
4709 		return;
4710 
4711 	if (!strcmp(res->mode, "set")) {
4712 
4713 		if (!strcmp(res->hwsw, "hw"))
4714 			hw = 1;
4715 
4716 		if (!strcmp(res->proto, "ip")) {
4717 			if (hw == 0 || (dev_info.tx_offload_capa &
4718 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4719 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4720 			} else {
4721 				printf("IP checksum offload is not supported "
4722 				       "by port %u\n", res->port_id);
4723 			}
4724 		} else if (!strcmp(res->proto, "udp")) {
4725 			if (hw == 0 || (dev_info.tx_offload_capa &
4726 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4727 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4728 			} else {
4729 				printf("UDP checksum offload is not supported "
4730 				       "by port %u\n", res->port_id);
4731 			}
4732 		} else if (!strcmp(res->proto, "tcp")) {
4733 			if (hw == 0 || (dev_info.tx_offload_capa &
4734 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4735 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4736 			} else {
4737 				printf("TCP checksum offload is not supported "
4738 				       "by port %u\n", res->port_id);
4739 			}
4740 		} else if (!strcmp(res->proto, "sctp")) {
4741 			if (hw == 0 || (dev_info.tx_offload_capa &
4742 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4743 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4744 			} else {
4745 				printf("SCTP checksum offload is not supported "
4746 				       "by port %u\n", res->port_id);
4747 			}
4748 		} else if (!strcmp(res->proto, "outer-ip")) {
4749 			if (hw == 0 || (dev_info.tx_offload_capa &
4750 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4751 				csum_offloads |=
4752 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4753 			} else {
4754 				printf("Outer IP checksum offload is not "
4755 				       "supported by port %u\n", res->port_id);
4756 			}
4757 		} else if (!strcmp(res->proto, "outer-udp")) {
4758 			if (hw == 0 || (dev_info.tx_offload_capa &
4759 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4760 				csum_offloads |=
4761 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4762 			} else {
4763 				printf("Outer UDP checksum offload is not "
4764 				       "supported by port %u\n", res->port_id);
4765 			}
4766 		}
4767 
4768 		if (hw) {
4769 			ports[res->port_id].dev_conf.txmode.offloads |=
4770 							csum_offloads;
4771 		} else {
4772 			ports[res->port_id].dev_conf.txmode.offloads &=
4773 							(~csum_offloads);
4774 		}
4775 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4776 	}
4777 	csum_show(res->port_id);
4778 
4779 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4780 }
4781 
4782 cmdline_parse_token_string_t cmd_csum_csum =
4783 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4784 				csum, "csum");
4785 cmdline_parse_token_string_t cmd_csum_mode =
4786 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4787 				mode, "set");
4788 cmdline_parse_token_string_t cmd_csum_proto =
4789 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4790 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4791 cmdline_parse_token_string_t cmd_csum_hwsw =
4792 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4793 				hwsw, "hw#sw");
4794 cmdline_parse_token_num_t cmd_csum_portid =
4795 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4796 				port_id, RTE_UINT16);
4797 
4798 cmdline_parse_inst_t cmd_csum_set = {
4799 	.f = cmd_csum_parsed,
4800 	.data = NULL,
4801 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4802 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4803 		"using csum forward engine",
4804 	.tokens = {
4805 		(void *)&cmd_csum_csum,
4806 		(void *)&cmd_csum_mode,
4807 		(void *)&cmd_csum_proto,
4808 		(void *)&cmd_csum_hwsw,
4809 		(void *)&cmd_csum_portid,
4810 		NULL,
4811 	},
4812 };
4813 
4814 cmdline_parse_token_string_t cmd_csum_mode_show =
4815 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4816 				mode, "show");
4817 
4818 cmdline_parse_inst_t cmd_csum_show = {
4819 	.f = cmd_csum_parsed,
4820 	.data = NULL,
4821 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4822 	.tokens = {
4823 		(void *)&cmd_csum_csum,
4824 		(void *)&cmd_csum_mode_show,
4825 		(void *)&cmd_csum_portid,
4826 		NULL,
4827 	},
4828 };
4829 
4830 /* Enable/disable tunnel parsing */
4831 struct cmd_csum_tunnel_result {
4832 	cmdline_fixed_string_t csum;
4833 	cmdline_fixed_string_t parse;
4834 	cmdline_fixed_string_t onoff;
4835 	portid_t port_id;
4836 };
4837 
4838 static void
4839 cmd_csum_tunnel_parsed(void *parsed_result,
4840 		       __rte_unused struct cmdline *cl,
4841 		       __rte_unused void *data)
4842 {
4843 	struct cmd_csum_tunnel_result *res = parsed_result;
4844 
4845 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4846 		return;
4847 
4848 	if (!strcmp(res->onoff, "on"))
4849 		ports[res->port_id].parse_tunnel = 1;
4850 	else
4851 		ports[res->port_id].parse_tunnel = 0;
4852 
4853 	csum_show(res->port_id);
4854 }
4855 
4856 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4857 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4858 				csum, "csum");
4859 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4860 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4861 				parse, "parse-tunnel");
4862 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4863 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4864 				onoff, "on#off");
4865 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4866 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4867 				port_id, RTE_UINT16);
4868 
4869 cmdline_parse_inst_t cmd_csum_tunnel = {
4870 	.f = cmd_csum_tunnel_parsed,
4871 	.data = NULL,
4872 	.help_str = "csum parse-tunnel on|off <port_id>: "
4873 		"Enable/Disable parsing of tunnels for csum engine",
4874 	.tokens = {
4875 		(void *)&cmd_csum_tunnel_csum,
4876 		(void *)&cmd_csum_tunnel_parse,
4877 		(void *)&cmd_csum_tunnel_onoff,
4878 		(void *)&cmd_csum_tunnel_portid,
4879 		NULL,
4880 	},
4881 };
4882 
4883 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4884 struct cmd_tso_set_result {
4885 	cmdline_fixed_string_t tso;
4886 	cmdline_fixed_string_t mode;
4887 	uint16_t tso_segsz;
4888 	portid_t port_id;
4889 };
4890 
4891 static void
4892 cmd_tso_set_parsed(void *parsed_result,
4893 		       __rte_unused struct cmdline *cl,
4894 		       __rte_unused void *data)
4895 {
4896 	struct cmd_tso_set_result *res = parsed_result;
4897 	struct rte_eth_dev_info dev_info;
4898 	int ret;
4899 
4900 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4901 		return;
4902 	if (!port_is_stopped(res->port_id)) {
4903 		printf("Please stop port %d first\n", res->port_id);
4904 		return;
4905 	}
4906 
4907 	if (!strcmp(res->mode, "set"))
4908 		ports[res->port_id].tso_segsz = res->tso_segsz;
4909 
4910 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4911 	if (ret != 0)
4912 		return;
4913 
4914 	if ((ports[res->port_id].tso_segsz != 0) &&
4915 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4916 		printf("Error: TSO is not supported by port %d\n",
4917 		       res->port_id);
4918 		return;
4919 	}
4920 
4921 	if (ports[res->port_id].tso_segsz == 0) {
4922 		ports[res->port_id].dev_conf.txmode.offloads &=
4923 						~DEV_TX_OFFLOAD_TCP_TSO;
4924 		printf("TSO for non-tunneled packets is disabled\n");
4925 	} else {
4926 		ports[res->port_id].dev_conf.txmode.offloads |=
4927 						DEV_TX_OFFLOAD_TCP_TSO;
4928 		printf("TSO segment size for non-tunneled packets is %d\n",
4929 			ports[res->port_id].tso_segsz);
4930 	}
4931 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4932 
4933 	/* display warnings if configuration is not supported by the NIC */
4934 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4935 	if (ret != 0)
4936 		return;
4937 
4938 	if ((ports[res->port_id].tso_segsz != 0) &&
4939 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4940 		printf("Warning: TSO enabled but not "
4941 			"supported by port %d\n", res->port_id);
4942 	}
4943 
4944 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4945 }
4946 
4947 cmdline_parse_token_string_t cmd_tso_set_tso =
4948 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4949 				tso, "tso");
4950 cmdline_parse_token_string_t cmd_tso_set_mode =
4951 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4952 				mode, "set");
4953 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4954 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4955 				tso_segsz, RTE_UINT16);
4956 cmdline_parse_token_num_t cmd_tso_set_portid =
4957 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4958 				port_id, RTE_UINT16);
4959 
4960 cmdline_parse_inst_t cmd_tso_set = {
4961 	.f = cmd_tso_set_parsed,
4962 	.data = NULL,
4963 	.help_str = "tso set <tso_segsz> <port_id>: "
4964 		"Set TSO segment size of non-tunneled packets for csum engine "
4965 		"(0 to disable)",
4966 	.tokens = {
4967 		(void *)&cmd_tso_set_tso,
4968 		(void *)&cmd_tso_set_mode,
4969 		(void *)&cmd_tso_set_tso_segsz,
4970 		(void *)&cmd_tso_set_portid,
4971 		NULL,
4972 	},
4973 };
4974 
4975 cmdline_parse_token_string_t cmd_tso_show_mode =
4976 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4977 				mode, "show");
4978 
4979 
4980 cmdline_parse_inst_t cmd_tso_show = {
4981 	.f = cmd_tso_set_parsed,
4982 	.data = NULL,
4983 	.help_str = "tso show <port_id>: "
4984 		"Show TSO segment size of non-tunneled packets for csum engine",
4985 	.tokens = {
4986 		(void *)&cmd_tso_set_tso,
4987 		(void *)&cmd_tso_show_mode,
4988 		(void *)&cmd_tso_set_portid,
4989 		NULL,
4990 	},
4991 };
4992 
4993 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4994 struct cmd_tunnel_tso_set_result {
4995 	cmdline_fixed_string_t tso;
4996 	cmdline_fixed_string_t mode;
4997 	uint16_t tso_segsz;
4998 	portid_t port_id;
4999 };
5000 
5001 static struct rte_eth_dev_info
5002 check_tunnel_tso_nic_support(portid_t port_id)
5003 {
5004 	struct rte_eth_dev_info dev_info;
5005 
5006 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5007 		return dev_info;
5008 
5009 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5010 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5011 		       "not enabled for port %d\n", port_id);
5012 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5013 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
5014 		       "not enabled for port %d\n", port_id);
5015 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5016 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
5017 		       "not enabled for port %d\n", port_id);
5018 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5019 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5020 		       "not enabled for port %d\n", port_id);
5021 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5022 		printf("Warning: IP TUNNEL TSO not supported therefore "
5023 		       "not enabled for port %d\n", port_id);
5024 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5025 		printf("Warning: UDP TUNNEL TSO not supported therefore "
5026 		       "not enabled for port %d\n", port_id);
5027 	return dev_info;
5028 }
5029 
5030 static void
5031 cmd_tunnel_tso_set_parsed(void *parsed_result,
5032 			  __rte_unused struct cmdline *cl,
5033 			  __rte_unused void *data)
5034 {
5035 	struct cmd_tunnel_tso_set_result *res = parsed_result;
5036 	struct rte_eth_dev_info dev_info;
5037 
5038 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5039 		return;
5040 	if (!port_is_stopped(res->port_id)) {
5041 		printf("Please stop port %d first\n", res->port_id);
5042 		return;
5043 	}
5044 
5045 	if (!strcmp(res->mode, "set"))
5046 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5047 
5048 	dev_info = check_tunnel_tso_nic_support(res->port_id);
5049 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
5050 		ports[res->port_id].dev_conf.txmode.offloads &=
5051 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5052 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
5053 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5054 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5055 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
5056 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
5057 		printf("TSO for tunneled packets is disabled\n");
5058 	} else {
5059 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5060 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5061 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5062 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5063 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
5064 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5065 
5066 		ports[res->port_id].dev_conf.txmode.offloads |=
5067 			(tso_offloads & dev_info.tx_offload_capa);
5068 		printf("TSO segment size for tunneled packets is %d\n",
5069 			ports[res->port_id].tunnel_tso_segsz);
5070 
5071 		/* Below conditions are needed to make it work:
5072 		 * (1) tunnel TSO is supported by the NIC;
5073 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5074 		 * are recognized;
5075 		 * (3) for tunneled pkts with outer L3 of IPv4,
5076 		 * "csum set outer-ip" must be set to hw, because after tso,
5077 		 * total_len of outer IP header is changed, and the checksum
5078 		 * of outer IP header calculated by sw should be wrong; that
5079 		 * is not necessary for IPv6 tunneled pkts because there's no
5080 		 * checksum in IP header anymore.
5081 		 */
5082 
5083 		if (!ports[res->port_id].parse_tunnel)
5084 			printf("Warning: csum parse_tunnel must be set "
5085 				"so that tunneled packets are recognized\n");
5086 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
5087 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5088 			printf("Warning: csum set outer-ip must be set to hw "
5089 				"if outer L3 is IPv4; not necessary for IPv6\n");
5090 	}
5091 
5092 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
5093 	cmd_reconfig_device_queue(res->port_id, 1, 1);
5094 }
5095 
5096 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5097 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5098 				tso, "tunnel_tso");
5099 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5100 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5101 				mode, "set");
5102 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5103 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5104 				tso_segsz, RTE_UINT16);
5105 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5106 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5107 				port_id, RTE_UINT16);
5108 
5109 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5110 	.f = cmd_tunnel_tso_set_parsed,
5111 	.data = NULL,
5112 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5113 		"Set TSO segment size of tunneled packets for csum engine "
5114 		"(0 to disable)",
5115 	.tokens = {
5116 		(void *)&cmd_tunnel_tso_set_tso,
5117 		(void *)&cmd_tunnel_tso_set_mode,
5118 		(void *)&cmd_tunnel_tso_set_tso_segsz,
5119 		(void *)&cmd_tunnel_tso_set_portid,
5120 		NULL,
5121 	},
5122 };
5123 
5124 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5125 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5126 				mode, "show");
5127 
5128 
5129 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5130 	.f = cmd_tunnel_tso_set_parsed,
5131 	.data = NULL,
5132 	.help_str = "tunnel_tso show <port_id> "
5133 		"Show TSO segment size of tunneled packets for csum engine",
5134 	.tokens = {
5135 		(void *)&cmd_tunnel_tso_set_tso,
5136 		(void *)&cmd_tunnel_tso_show_mode,
5137 		(void *)&cmd_tunnel_tso_set_portid,
5138 		NULL,
5139 	},
5140 };
5141 
5142 /* *** SET GRO FOR A PORT *** */
5143 struct cmd_gro_enable_result {
5144 	cmdline_fixed_string_t cmd_set;
5145 	cmdline_fixed_string_t cmd_port;
5146 	cmdline_fixed_string_t cmd_keyword;
5147 	cmdline_fixed_string_t cmd_onoff;
5148 	portid_t cmd_pid;
5149 };
5150 
5151 static void
5152 cmd_gro_enable_parsed(void *parsed_result,
5153 		__rte_unused struct cmdline *cl,
5154 		__rte_unused void *data)
5155 {
5156 	struct cmd_gro_enable_result *res;
5157 
5158 	res = parsed_result;
5159 	if (!strcmp(res->cmd_keyword, "gro"))
5160 		setup_gro(res->cmd_onoff, res->cmd_pid);
5161 }
5162 
5163 cmdline_parse_token_string_t cmd_gro_enable_set =
5164 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5165 			cmd_set, "set");
5166 cmdline_parse_token_string_t cmd_gro_enable_port =
5167 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5168 			cmd_keyword, "port");
5169 cmdline_parse_token_num_t cmd_gro_enable_pid =
5170 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5171 			cmd_pid, RTE_UINT16);
5172 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5173 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5174 			cmd_keyword, "gro");
5175 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5176 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5177 			cmd_onoff, "on#off");
5178 
5179 cmdline_parse_inst_t cmd_gro_enable = {
5180 	.f = cmd_gro_enable_parsed,
5181 	.data = NULL,
5182 	.help_str = "set port <port_id> gro on|off",
5183 	.tokens = {
5184 		(void *)&cmd_gro_enable_set,
5185 		(void *)&cmd_gro_enable_port,
5186 		(void *)&cmd_gro_enable_pid,
5187 		(void *)&cmd_gro_enable_keyword,
5188 		(void *)&cmd_gro_enable_onoff,
5189 		NULL,
5190 	},
5191 };
5192 
5193 /* *** DISPLAY GRO CONFIGURATION *** */
5194 struct cmd_gro_show_result {
5195 	cmdline_fixed_string_t cmd_show;
5196 	cmdline_fixed_string_t cmd_port;
5197 	cmdline_fixed_string_t cmd_keyword;
5198 	portid_t cmd_pid;
5199 };
5200 
5201 static void
5202 cmd_gro_show_parsed(void *parsed_result,
5203 		__rte_unused struct cmdline *cl,
5204 		__rte_unused void *data)
5205 {
5206 	struct cmd_gro_show_result *res;
5207 
5208 	res = parsed_result;
5209 	if (!strcmp(res->cmd_keyword, "gro"))
5210 		show_gro(res->cmd_pid);
5211 }
5212 
5213 cmdline_parse_token_string_t cmd_gro_show_show =
5214 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5215 			cmd_show, "show");
5216 cmdline_parse_token_string_t cmd_gro_show_port =
5217 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5218 			cmd_port, "port");
5219 cmdline_parse_token_num_t cmd_gro_show_pid =
5220 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5221 			cmd_pid, RTE_UINT16);
5222 cmdline_parse_token_string_t cmd_gro_show_keyword =
5223 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5224 			cmd_keyword, "gro");
5225 
5226 cmdline_parse_inst_t cmd_gro_show = {
5227 	.f = cmd_gro_show_parsed,
5228 	.data = NULL,
5229 	.help_str = "show port <port_id> gro",
5230 	.tokens = {
5231 		(void *)&cmd_gro_show_show,
5232 		(void *)&cmd_gro_show_port,
5233 		(void *)&cmd_gro_show_pid,
5234 		(void *)&cmd_gro_show_keyword,
5235 		NULL,
5236 	},
5237 };
5238 
5239 /* *** SET FLUSH CYCLES FOR GRO *** */
5240 struct cmd_gro_flush_result {
5241 	cmdline_fixed_string_t cmd_set;
5242 	cmdline_fixed_string_t cmd_keyword;
5243 	cmdline_fixed_string_t cmd_flush;
5244 	uint8_t cmd_cycles;
5245 };
5246 
5247 static void
5248 cmd_gro_flush_parsed(void *parsed_result,
5249 		__rte_unused struct cmdline *cl,
5250 		__rte_unused void *data)
5251 {
5252 	struct cmd_gro_flush_result *res;
5253 
5254 	res = parsed_result;
5255 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5256 			(!strcmp(res->cmd_flush, "flush")))
5257 		setup_gro_flush_cycles(res->cmd_cycles);
5258 }
5259 
5260 cmdline_parse_token_string_t cmd_gro_flush_set =
5261 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5262 			cmd_set, "set");
5263 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5264 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5265 			cmd_keyword, "gro");
5266 cmdline_parse_token_string_t cmd_gro_flush_flush =
5267 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5268 			cmd_flush, "flush");
5269 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5270 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5271 			cmd_cycles, RTE_UINT8);
5272 
5273 cmdline_parse_inst_t cmd_gro_flush = {
5274 	.f = cmd_gro_flush_parsed,
5275 	.data = NULL,
5276 	.help_str = "set gro flush <cycles>",
5277 	.tokens = {
5278 		(void *)&cmd_gro_flush_set,
5279 		(void *)&cmd_gro_flush_keyword,
5280 		(void *)&cmd_gro_flush_flush,
5281 		(void *)&cmd_gro_flush_cycles,
5282 		NULL,
5283 	},
5284 };
5285 
5286 /* *** ENABLE/DISABLE GSO *** */
5287 struct cmd_gso_enable_result {
5288 	cmdline_fixed_string_t cmd_set;
5289 	cmdline_fixed_string_t cmd_port;
5290 	cmdline_fixed_string_t cmd_keyword;
5291 	cmdline_fixed_string_t cmd_mode;
5292 	portid_t cmd_pid;
5293 };
5294 
5295 static void
5296 cmd_gso_enable_parsed(void *parsed_result,
5297 		__rte_unused struct cmdline *cl,
5298 		__rte_unused void *data)
5299 {
5300 	struct cmd_gso_enable_result *res;
5301 
5302 	res = parsed_result;
5303 	if (!strcmp(res->cmd_keyword, "gso"))
5304 		setup_gso(res->cmd_mode, res->cmd_pid);
5305 }
5306 
5307 cmdline_parse_token_string_t cmd_gso_enable_set =
5308 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5309 			cmd_set, "set");
5310 cmdline_parse_token_string_t cmd_gso_enable_port =
5311 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5312 			cmd_port, "port");
5313 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5314 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5315 			cmd_keyword, "gso");
5316 cmdline_parse_token_string_t cmd_gso_enable_mode =
5317 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5318 			cmd_mode, "on#off");
5319 cmdline_parse_token_num_t cmd_gso_enable_pid =
5320 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5321 			cmd_pid, RTE_UINT16);
5322 
5323 cmdline_parse_inst_t cmd_gso_enable = {
5324 	.f = cmd_gso_enable_parsed,
5325 	.data = NULL,
5326 	.help_str = "set port <port_id> gso on|off",
5327 	.tokens = {
5328 		(void *)&cmd_gso_enable_set,
5329 		(void *)&cmd_gso_enable_port,
5330 		(void *)&cmd_gso_enable_pid,
5331 		(void *)&cmd_gso_enable_keyword,
5332 		(void *)&cmd_gso_enable_mode,
5333 		NULL,
5334 	},
5335 };
5336 
5337 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5338 struct cmd_gso_size_result {
5339 	cmdline_fixed_string_t cmd_set;
5340 	cmdline_fixed_string_t cmd_keyword;
5341 	cmdline_fixed_string_t cmd_segsz;
5342 	uint16_t cmd_size;
5343 };
5344 
5345 static void
5346 cmd_gso_size_parsed(void *parsed_result,
5347 		       __rte_unused struct cmdline *cl,
5348 		       __rte_unused void *data)
5349 {
5350 	struct cmd_gso_size_result *res = parsed_result;
5351 
5352 	if (test_done == 0) {
5353 		printf("Before setting GSO segsz, please first"
5354 				" stop forwarding\n");
5355 		return;
5356 	}
5357 
5358 	if (!strcmp(res->cmd_keyword, "gso") &&
5359 			!strcmp(res->cmd_segsz, "segsz")) {
5360 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5361 			printf("gso_size should be larger than %zu."
5362 					" Please input a legal value\n",
5363 					RTE_GSO_SEG_SIZE_MIN);
5364 		else
5365 			gso_max_segment_size = res->cmd_size;
5366 	}
5367 }
5368 
5369 cmdline_parse_token_string_t cmd_gso_size_set =
5370 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5371 				cmd_set, "set");
5372 cmdline_parse_token_string_t cmd_gso_size_keyword =
5373 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5374 				cmd_keyword, "gso");
5375 cmdline_parse_token_string_t cmd_gso_size_segsz =
5376 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5377 				cmd_segsz, "segsz");
5378 cmdline_parse_token_num_t cmd_gso_size_size =
5379 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5380 				cmd_size, RTE_UINT16);
5381 
5382 cmdline_parse_inst_t cmd_gso_size = {
5383 	.f = cmd_gso_size_parsed,
5384 	.data = NULL,
5385 	.help_str = "set gso segsz <length>",
5386 	.tokens = {
5387 		(void *)&cmd_gso_size_set,
5388 		(void *)&cmd_gso_size_keyword,
5389 		(void *)&cmd_gso_size_segsz,
5390 		(void *)&cmd_gso_size_size,
5391 		NULL,
5392 	},
5393 };
5394 
5395 /* *** SHOW GSO CONFIGURATION *** */
5396 struct cmd_gso_show_result {
5397 	cmdline_fixed_string_t cmd_show;
5398 	cmdline_fixed_string_t cmd_port;
5399 	cmdline_fixed_string_t cmd_keyword;
5400 	portid_t cmd_pid;
5401 };
5402 
5403 static void
5404 cmd_gso_show_parsed(void *parsed_result,
5405 		       __rte_unused struct cmdline *cl,
5406 		       __rte_unused void *data)
5407 {
5408 	struct cmd_gso_show_result *res = parsed_result;
5409 
5410 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5411 		printf("invalid port id %u\n", res->cmd_pid);
5412 		return;
5413 	}
5414 	if (!strcmp(res->cmd_keyword, "gso")) {
5415 		if (gso_ports[res->cmd_pid].enable) {
5416 			printf("Max GSO'd packet size: %uB\n"
5417 					"Supported GSO types: TCP/IPv4, "
5418 					"UDP/IPv4, VxLAN with inner "
5419 					"TCP/IPv4 packet, GRE with inner "
5420 					"TCP/IPv4 packet\n",
5421 					gso_max_segment_size);
5422 		} else
5423 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5424 	}
5425 }
5426 
5427 cmdline_parse_token_string_t cmd_gso_show_show =
5428 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5429 		cmd_show, "show");
5430 cmdline_parse_token_string_t cmd_gso_show_port =
5431 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5432 		cmd_port, "port");
5433 cmdline_parse_token_string_t cmd_gso_show_keyword =
5434 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5435 				cmd_keyword, "gso");
5436 cmdline_parse_token_num_t cmd_gso_show_pid =
5437 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5438 				cmd_pid, RTE_UINT16);
5439 
5440 cmdline_parse_inst_t cmd_gso_show = {
5441 	.f = cmd_gso_show_parsed,
5442 	.data = NULL,
5443 	.help_str = "show port <port_id> gso",
5444 	.tokens = {
5445 		(void *)&cmd_gso_show_show,
5446 		(void *)&cmd_gso_show_port,
5447 		(void *)&cmd_gso_show_pid,
5448 		(void *)&cmd_gso_show_keyword,
5449 		NULL,
5450 	},
5451 };
5452 
5453 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5454 struct cmd_set_flush_rx {
5455 	cmdline_fixed_string_t set;
5456 	cmdline_fixed_string_t flush_rx;
5457 	cmdline_fixed_string_t mode;
5458 };
5459 
5460 static void
5461 cmd_set_flush_rx_parsed(void *parsed_result,
5462 		__rte_unused struct cmdline *cl,
5463 		__rte_unused void *data)
5464 {
5465 	struct cmd_set_flush_rx *res = parsed_result;
5466 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5467 }
5468 
5469 cmdline_parse_token_string_t cmd_setflushrx_set =
5470 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5471 			set, "set");
5472 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5473 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5474 			flush_rx, "flush_rx");
5475 cmdline_parse_token_string_t cmd_setflushrx_mode =
5476 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5477 			mode, "on#off");
5478 
5479 
5480 cmdline_parse_inst_t cmd_set_flush_rx = {
5481 	.f = cmd_set_flush_rx_parsed,
5482 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5483 	.data = NULL,
5484 	.tokens = {
5485 		(void *)&cmd_setflushrx_set,
5486 		(void *)&cmd_setflushrx_flush_rx,
5487 		(void *)&cmd_setflushrx_mode,
5488 		NULL,
5489 	},
5490 };
5491 
5492 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5493 struct cmd_set_link_check {
5494 	cmdline_fixed_string_t set;
5495 	cmdline_fixed_string_t link_check;
5496 	cmdline_fixed_string_t mode;
5497 };
5498 
5499 static void
5500 cmd_set_link_check_parsed(void *parsed_result,
5501 		__rte_unused struct cmdline *cl,
5502 		__rte_unused void *data)
5503 {
5504 	struct cmd_set_link_check *res = parsed_result;
5505 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5506 }
5507 
5508 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5509 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5510 			set, "set");
5511 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5512 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5513 			link_check, "link_check");
5514 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5515 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5516 			mode, "on#off");
5517 
5518 
5519 cmdline_parse_inst_t cmd_set_link_check = {
5520 	.f = cmd_set_link_check_parsed,
5521 	.help_str = "set link_check on|off: Enable/Disable link status check "
5522 	            "when starting/stopping a port",
5523 	.data = NULL,
5524 	.tokens = {
5525 		(void *)&cmd_setlinkcheck_set,
5526 		(void *)&cmd_setlinkcheck_link_check,
5527 		(void *)&cmd_setlinkcheck_mode,
5528 		NULL,
5529 	},
5530 };
5531 
5532 /* *** SET NIC BYPASS MODE *** */
5533 struct cmd_set_bypass_mode_result {
5534 	cmdline_fixed_string_t set;
5535 	cmdline_fixed_string_t bypass;
5536 	cmdline_fixed_string_t mode;
5537 	cmdline_fixed_string_t value;
5538 	portid_t port_id;
5539 };
5540 
5541 static void
5542 cmd_set_bypass_mode_parsed(void *parsed_result,
5543 		__rte_unused struct cmdline *cl,
5544 		__rte_unused void *data)
5545 {
5546 	struct cmd_set_bypass_mode_result *res = parsed_result;
5547 	portid_t port_id = res->port_id;
5548 	int32_t rc = -EINVAL;
5549 
5550 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5551 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5552 
5553 	if (!strcmp(res->value, "bypass"))
5554 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5555 	else if (!strcmp(res->value, "isolate"))
5556 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5557 	else
5558 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5559 
5560 	/* Set the bypass mode for the relevant port. */
5561 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5562 #endif
5563 	if (rc != 0)
5564 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5565 }
5566 
5567 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5568 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5569 			set, "set");
5570 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5571 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5572 			bypass, "bypass");
5573 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5574 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5575 			mode, "mode");
5576 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5577 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5578 			value, "normal#bypass#isolate");
5579 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5580 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5581 				port_id, RTE_UINT16);
5582 
5583 cmdline_parse_inst_t cmd_set_bypass_mode = {
5584 	.f = cmd_set_bypass_mode_parsed,
5585 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5586 	            "Set the NIC bypass mode for port_id",
5587 	.data = NULL,
5588 	.tokens = {
5589 		(void *)&cmd_setbypass_mode_set,
5590 		(void *)&cmd_setbypass_mode_bypass,
5591 		(void *)&cmd_setbypass_mode_mode,
5592 		(void *)&cmd_setbypass_mode_value,
5593 		(void *)&cmd_setbypass_mode_port,
5594 		NULL,
5595 	},
5596 };
5597 
5598 /* *** SET NIC BYPASS EVENT *** */
5599 struct cmd_set_bypass_event_result {
5600 	cmdline_fixed_string_t set;
5601 	cmdline_fixed_string_t bypass;
5602 	cmdline_fixed_string_t event;
5603 	cmdline_fixed_string_t event_value;
5604 	cmdline_fixed_string_t mode;
5605 	cmdline_fixed_string_t mode_value;
5606 	portid_t port_id;
5607 };
5608 
5609 static void
5610 cmd_set_bypass_event_parsed(void *parsed_result,
5611 		__rte_unused struct cmdline *cl,
5612 		__rte_unused void *data)
5613 {
5614 	int32_t rc = -EINVAL;
5615 	struct cmd_set_bypass_event_result *res = parsed_result;
5616 	portid_t port_id = res->port_id;
5617 
5618 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5619 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5620 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5621 
5622 	if (!strcmp(res->event_value, "timeout"))
5623 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5624 	else if (!strcmp(res->event_value, "os_on"))
5625 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5626 	else if (!strcmp(res->event_value, "os_off"))
5627 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5628 	else if (!strcmp(res->event_value, "power_on"))
5629 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5630 	else if (!strcmp(res->event_value, "power_off"))
5631 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5632 	else
5633 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5634 
5635 	if (!strcmp(res->mode_value, "bypass"))
5636 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5637 	else if (!strcmp(res->mode_value, "isolate"))
5638 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5639 	else
5640 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5641 
5642 	/* Set the watchdog timeout. */
5643 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5644 
5645 		rc = -EINVAL;
5646 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5647 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5648 							   bypass_timeout);
5649 		}
5650 		if (rc != 0) {
5651 			printf("Failed to set timeout value %u "
5652 			"for port %d, errto code: %d.\n",
5653 			bypass_timeout, port_id, rc);
5654 		}
5655 	}
5656 
5657 	/* Set the bypass event to transition to bypass mode. */
5658 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5659 					      bypass_mode);
5660 #endif
5661 
5662 	if (rc != 0)
5663 		printf("\t Failed to set bypass event for port = %d.\n",
5664 		       port_id);
5665 }
5666 
5667 cmdline_parse_token_string_t cmd_setbypass_event_set =
5668 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5669 			set, "set");
5670 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5671 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5672 			bypass, "bypass");
5673 cmdline_parse_token_string_t cmd_setbypass_event_event =
5674 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5675 			event, "event");
5676 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5677 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5678 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5679 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5680 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5681 			mode, "mode");
5682 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5683 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5684 			mode_value, "normal#bypass#isolate");
5685 cmdline_parse_token_num_t cmd_setbypass_event_port =
5686 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5687 				port_id, RTE_UINT16);
5688 
5689 cmdline_parse_inst_t cmd_set_bypass_event = {
5690 	.f = cmd_set_bypass_event_parsed,
5691 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5692 		"power_off mode normal|bypass|isolate <port_id>: "
5693 		"Set the NIC bypass event mode for port_id",
5694 	.data = NULL,
5695 	.tokens = {
5696 		(void *)&cmd_setbypass_event_set,
5697 		(void *)&cmd_setbypass_event_bypass,
5698 		(void *)&cmd_setbypass_event_event,
5699 		(void *)&cmd_setbypass_event_event_value,
5700 		(void *)&cmd_setbypass_event_mode,
5701 		(void *)&cmd_setbypass_event_mode_value,
5702 		(void *)&cmd_setbypass_event_port,
5703 		NULL,
5704 	},
5705 };
5706 
5707 
5708 /* *** SET NIC BYPASS TIMEOUT *** */
5709 struct cmd_set_bypass_timeout_result {
5710 	cmdline_fixed_string_t set;
5711 	cmdline_fixed_string_t bypass;
5712 	cmdline_fixed_string_t timeout;
5713 	cmdline_fixed_string_t value;
5714 };
5715 
5716 static void
5717 cmd_set_bypass_timeout_parsed(void *parsed_result,
5718 		__rte_unused struct cmdline *cl,
5719 		__rte_unused void *data)
5720 {
5721 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5722 
5723 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5724 	if (!strcmp(res->value, "1.5"))
5725 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5726 	else if (!strcmp(res->value, "2"))
5727 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5728 	else if (!strcmp(res->value, "3"))
5729 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5730 	else if (!strcmp(res->value, "4"))
5731 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5732 	else if (!strcmp(res->value, "8"))
5733 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5734 	else if (!strcmp(res->value, "16"))
5735 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5736 	else if (!strcmp(res->value, "32"))
5737 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5738 	else
5739 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5740 #endif
5741 }
5742 
5743 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5744 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5745 			set, "set");
5746 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5747 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5748 			bypass, "bypass");
5749 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5750 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5751 			timeout, "timeout");
5752 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5753 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5754 			value, "0#1.5#2#3#4#8#16#32");
5755 
5756 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5757 	.f = cmd_set_bypass_timeout_parsed,
5758 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5759 		"Set the NIC bypass watchdog timeout in seconds",
5760 	.data = NULL,
5761 	.tokens = {
5762 		(void *)&cmd_setbypass_timeout_set,
5763 		(void *)&cmd_setbypass_timeout_bypass,
5764 		(void *)&cmd_setbypass_timeout_timeout,
5765 		(void *)&cmd_setbypass_timeout_value,
5766 		NULL,
5767 	},
5768 };
5769 
5770 /* *** SHOW NIC BYPASS MODE *** */
5771 struct cmd_show_bypass_config_result {
5772 	cmdline_fixed_string_t show;
5773 	cmdline_fixed_string_t bypass;
5774 	cmdline_fixed_string_t config;
5775 	portid_t port_id;
5776 };
5777 
5778 static void
5779 cmd_show_bypass_config_parsed(void *parsed_result,
5780 		__rte_unused struct cmdline *cl,
5781 		__rte_unused void *data)
5782 {
5783 	struct cmd_show_bypass_config_result *res = parsed_result;
5784 	portid_t port_id = res->port_id;
5785 	int rc = -EINVAL;
5786 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5787 	uint32_t event_mode;
5788 	uint32_t bypass_mode;
5789 	uint32_t timeout = bypass_timeout;
5790 	unsigned int i;
5791 
5792 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5793 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5794 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5795 		{"UNKNOWN", "normal", "bypass", "isolate"};
5796 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5797 		"NONE",
5798 		"OS/board on",
5799 		"power supply on",
5800 		"OS/board off",
5801 		"power supply off",
5802 		"timeout"};
5803 
5804 	/* Display the bypass mode.*/
5805 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5806 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5807 		return;
5808 	}
5809 	else {
5810 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5811 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5812 
5813 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5814 	}
5815 
5816 	/* Display the bypass timeout.*/
5817 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5818 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5819 
5820 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5821 
5822 	/* Display the bypass events and associated modes. */
5823 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5824 
5825 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5826 			printf("\tFailed to get bypass mode for event = %s\n",
5827 				events[i]);
5828 		} else {
5829 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5830 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5831 
5832 			printf("\tbypass event: %-16s = %s\n", events[i],
5833 				modes[event_mode]);
5834 		}
5835 	}
5836 #endif
5837 	if (rc != 0)
5838 		printf("\tFailed to get bypass configuration for port = %d\n",
5839 		       port_id);
5840 }
5841 
5842 cmdline_parse_token_string_t cmd_showbypass_config_show =
5843 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5844 			show, "show");
5845 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5846 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5847 			bypass, "bypass");
5848 cmdline_parse_token_string_t cmd_showbypass_config_config =
5849 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5850 			config, "config");
5851 cmdline_parse_token_num_t cmd_showbypass_config_port =
5852 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5853 				port_id, RTE_UINT16);
5854 
5855 cmdline_parse_inst_t cmd_show_bypass_config = {
5856 	.f = cmd_show_bypass_config_parsed,
5857 	.help_str = "show bypass config <port_id>: "
5858 	            "Show the NIC bypass config for port_id",
5859 	.data = NULL,
5860 	.tokens = {
5861 		(void *)&cmd_showbypass_config_show,
5862 		(void *)&cmd_showbypass_config_bypass,
5863 		(void *)&cmd_showbypass_config_config,
5864 		(void *)&cmd_showbypass_config_port,
5865 		NULL,
5866 	},
5867 };
5868 
5869 #ifdef RTE_NET_BOND
5870 /* *** SET BONDING MODE *** */
5871 struct cmd_set_bonding_mode_result {
5872 	cmdline_fixed_string_t set;
5873 	cmdline_fixed_string_t bonding;
5874 	cmdline_fixed_string_t mode;
5875 	uint8_t value;
5876 	portid_t port_id;
5877 };
5878 
5879 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5880 		__rte_unused  struct cmdline *cl,
5881 		__rte_unused void *data)
5882 {
5883 	struct cmd_set_bonding_mode_result *res = parsed_result;
5884 	portid_t port_id = res->port_id;
5885 
5886 	/* Set the bonding mode for the relevant port. */
5887 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5888 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5889 }
5890 
5891 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5892 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5893 		set, "set");
5894 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5895 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5896 		bonding, "bonding");
5897 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5898 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5899 		mode, "mode");
5900 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5901 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5902 		value, RTE_UINT8);
5903 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5904 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5905 		port_id, RTE_UINT16);
5906 
5907 cmdline_parse_inst_t cmd_set_bonding_mode = {
5908 		.f = cmd_set_bonding_mode_parsed,
5909 		.help_str = "set bonding mode <mode_value> <port_id>: "
5910 			"Set the bonding mode for port_id",
5911 		.data = NULL,
5912 		.tokens = {
5913 				(void *) &cmd_setbonding_mode_set,
5914 				(void *) &cmd_setbonding_mode_bonding,
5915 				(void *) &cmd_setbonding_mode_mode,
5916 				(void *) &cmd_setbonding_mode_value,
5917 				(void *) &cmd_setbonding_mode_port,
5918 				NULL
5919 		}
5920 };
5921 
5922 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5923 struct cmd_set_bonding_lacp_dedicated_queues_result {
5924 	cmdline_fixed_string_t set;
5925 	cmdline_fixed_string_t bonding;
5926 	cmdline_fixed_string_t lacp;
5927 	cmdline_fixed_string_t dedicated_queues;
5928 	portid_t port_id;
5929 	cmdline_fixed_string_t mode;
5930 };
5931 
5932 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5933 		__rte_unused  struct cmdline *cl,
5934 		__rte_unused void *data)
5935 {
5936 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5937 	portid_t port_id = res->port_id;
5938 	struct rte_port *port;
5939 
5940 	port = &ports[port_id];
5941 
5942 	/** Check if the port is not started **/
5943 	if (port->port_status != RTE_PORT_STOPPED) {
5944 		printf("Please stop port %d first\n", port_id);
5945 		return;
5946 	}
5947 
5948 	if (!strcmp(res->mode, "enable")) {
5949 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5950 			printf("Dedicate queues for LACP control packets"
5951 					" enabled\n");
5952 		else
5953 			printf("Enabling dedicate queues for LACP control "
5954 					"packets on port %d failed\n", port_id);
5955 	} else if (!strcmp(res->mode, "disable")) {
5956 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5957 			printf("Dedicated queues for LACP control packets "
5958 					"disabled\n");
5959 		else
5960 			printf("Disabling dedicated queues for LACP control "
5961 					"traffic on port %d failed\n", port_id);
5962 	}
5963 }
5964 
5965 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5966 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5967 		set, "set");
5968 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5969 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5970 		bonding, "bonding");
5971 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5972 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5973 		lacp, "lacp");
5974 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5976 		dedicated_queues, "dedicated_queues");
5977 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5978 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5979 		port_id, RTE_UINT16);
5980 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5981 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5982 		mode, "enable#disable");
5983 
5984 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5985 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5986 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5987 			"enable|disable: "
5988 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5989 		.data = NULL,
5990 		.tokens = {
5991 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5992 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5993 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5994 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5995 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5996 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5997 			NULL
5998 		}
5999 };
6000 
6001 /* *** SET BALANCE XMIT POLICY *** */
6002 struct cmd_set_bonding_balance_xmit_policy_result {
6003 	cmdline_fixed_string_t set;
6004 	cmdline_fixed_string_t bonding;
6005 	cmdline_fixed_string_t balance_xmit_policy;
6006 	portid_t port_id;
6007 	cmdline_fixed_string_t policy;
6008 };
6009 
6010 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6011 		__rte_unused  struct cmdline *cl,
6012 		__rte_unused void *data)
6013 {
6014 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6015 	portid_t port_id = res->port_id;
6016 	uint8_t policy;
6017 
6018 	if (!strcmp(res->policy, "l2")) {
6019 		policy = BALANCE_XMIT_POLICY_LAYER2;
6020 	} else if (!strcmp(res->policy, "l23")) {
6021 		policy = BALANCE_XMIT_POLICY_LAYER23;
6022 	} else if (!strcmp(res->policy, "l34")) {
6023 		policy = BALANCE_XMIT_POLICY_LAYER34;
6024 	} else {
6025 		printf("\t Invalid xmit policy selection");
6026 		return;
6027 	}
6028 
6029 	/* Set the bonding mode for the relevant port. */
6030 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6031 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6032 				port_id);
6033 	}
6034 }
6035 
6036 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6037 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6038 		set, "set");
6039 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6040 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6041 		bonding, "bonding");
6042 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6043 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6044 		balance_xmit_policy, "balance_xmit_policy");
6045 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6046 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6047 		port_id, RTE_UINT16);
6048 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6049 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6050 		policy, "l2#l23#l34");
6051 
6052 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6053 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
6054 		.help_str = "set bonding balance_xmit_policy <port_id> "
6055 			"l2|l23|l34: "
6056 			"Set the bonding balance_xmit_policy for port_id",
6057 		.data = NULL,
6058 		.tokens = {
6059 				(void *)&cmd_setbonding_balance_xmit_policy_set,
6060 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
6061 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6062 				(void *)&cmd_setbonding_balance_xmit_policy_port,
6063 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
6064 				NULL
6065 		}
6066 };
6067 
6068 /* *** SHOW NIC BONDING CONFIGURATION *** */
6069 struct cmd_show_bonding_config_result {
6070 	cmdline_fixed_string_t show;
6071 	cmdline_fixed_string_t bonding;
6072 	cmdline_fixed_string_t config;
6073 	portid_t port_id;
6074 };
6075 
6076 static void cmd_show_bonding_config_parsed(void *parsed_result,
6077 		__rte_unused  struct cmdline *cl,
6078 		__rte_unused void *data)
6079 {
6080 	struct cmd_show_bonding_config_result *res = parsed_result;
6081 	int bonding_mode, agg_mode;
6082 	portid_t slaves[RTE_MAX_ETHPORTS];
6083 	int num_slaves, num_active_slaves;
6084 	int primary_id;
6085 	int i;
6086 	portid_t port_id = res->port_id;
6087 
6088 	/* Display the bonding mode.*/
6089 	bonding_mode = rte_eth_bond_mode_get(port_id);
6090 	if (bonding_mode < 0) {
6091 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
6092 		return;
6093 	} else
6094 		printf("\tBonding mode: %d\n", bonding_mode);
6095 
6096 	if (bonding_mode == BONDING_MODE_BALANCE) {
6097 		int balance_xmit_policy;
6098 
6099 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6100 		if (balance_xmit_policy < 0) {
6101 			printf("\tFailed to get balance xmit policy for port = %d\n",
6102 					port_id);
6103 			return;
6104 		} else {
6105 			printf("\tBalance Xmit Policy: ");
6106 
6107 			switch (balance_xmit_policy) {
6108 			case BALANCE_XMIT_POLICY_LAYER2:
6109 				printf("BALANCE_XMIT_POLICY_LAYER2");
6110 				break;
6111 			case BALANCE_XMIT_POLICY_LAYER23:
6112 				printf("BALANCE_XMIT_POLICY_LAYER23");
6113 				break;
6114 			case BALANCE_XMIT_POLICY_LAYER34:
6115 				printf("BALANCE_XMIT_POLICY_LAYER34");
6116 				break;
6117 			}
6118 			printf("\n");
6119 		}
6120 	}
6121 
6122 	if (bonding_mode == BONDING_MODE_8023AD) {
6123 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6124 		printf("\tIEEE802.3AD Aggregator Mode: ");
6125 		switch (agg_mode) {
6126 		case AGG_BANDWIDTH:
6127 			printf("bandwidth");
6128 			break;
6129 		case AGG_STABLE:
6130 			printf("stable");
6131 			break;
6132 		case AGG_COUNT:
6133 			printf("count");
6134 			break;
6135 		}
6136 		printf("\n");
6137 	}
6138 
6139 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6140 
6141 	if (num_slaves < 0) {
6142 		printf("\tFailed to get slave list for port = %d\n", port_id);
6143 		return;
6144 	}
6145 	if (num_slaves > 0) {
6146 		printf("\tSlaves (%d): [", num_slaves);
6147 		for (i = 0; i < num_slaves - 1; i++)
6148 			printf("%d ", slaves[i]);
6149 
6150 		printf("%d]\n", slaves[num_slaves - 1]);
6151 	} else {
6152 		printf("\tSlaves: []\n");
6153 
6154 	}
6155 
6156 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6157 			RTE_MAX_ETHPORTS);
6158 
6159 	if (num_active_slaves < 0) {
6160 		printf("\tFailed to get active slave list for port = %d\n", port_id);
6161 		return;
6162 	}
6163 	if (num_active_slaves > 0) {
6164 		printf("\tActive Slaves (%d): [", num_active_slaves);
6165 		for (i = 0; i < num_active_slaves - 1; i++)
6166 			printf("%d ", slaves[i]);
6167 
6168 		printf("%d]\n", slaves[num_active_slaves - 1]);
6169 
6170 	} else {
6171 		printf("\tActive Slaves: []\n");
6172 
6173 	}
6174 
6175 	primary_id = rte_eth_bond_primary_get(port_id);
6176 	if (primary_id < 0) {
6177 		printf("\tFailed to get primary slave for port = %d\n", port_id);
6178 		return;
6179 	} else
6180 		printf("\tPrimary: [%d]\n", primary_id);
6181 
6182 }
6183 
6184 cmdline_parse_token_string_t cmd_showbonding_config_show =
6185 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6186 		show, "show");
6187 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6188 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6189 		bonding, "bonding");
6190 cmdline_parse_token_string_t cmd_showbonding_config_config =
6191 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6192 		config, "config");
6193 cmdline_parse_token_num_t cmd_showbonding_config_port =
6194 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6195 		port_id, RTE_UINT16);
6196 
6197 cmdline_parse_inst_t cmd_show_bonding_config = {
6198 		.f = cmd_show_bonding_config_parsed,
6199 		.help_str = "show bonding config <port_id>: "
6200 			"Show the bonding config for port_id",
6201 		.data = NULL,
6202 		.tokens = {
6203 				(void *)&cmd_showbonding_config_show,
6204 				(void *)&cmd_showbonding_config_bonding,
6205 				(void *)&cmd_showbonding_config_config,
6206 				(void *)&cmd_showbonding_config_port,
6207 				NULL
6208 		}
6209 };
6210 
6211 /* *** SET BONDING PRIMARY *** */
6212 struct cmd_set_bonding_primary_result {
6213 	cmdline_fixed_string_t set;
6214 	cmdline_fixed_string_t bonding;
6215 	cmdline_fixed_string_t primary;
6216 	portid_t slave_id;
6217 	portid_t port_id;
6218 };
6219 
6220 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6221 		__rte_unused  struct cmdline *cl,
6222 		__rte_unused void *data)
6223 {
6224 	struct cmd_set_bonding_primary_result *res = parsed_result;
6225 	portid_t master_port_id = res->port_id;
6226 	portid_t slave_port_id = res->slave_id;
6227 
6228 	/* Set the primary slave for a bonded device. */
6229 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6230 		printf("\t Failed to set primary slave for port = %d.\n",
6231 				master_port_id);
6232 		return;
6233 	}
6234 	init_port_config();
6235 }
6236 
6237 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6238 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6239 		set, "set");
6240 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6241 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6242 		bonding, "bonding");
6243 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6244 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6245 		primary, "primary");
6246 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6247 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6248 		slave_id, RTE_UINT16);
6249 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6250 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6251 		port_id, RTE_UINT16);
6252 
6253 cmdline_parse_inst_t cmd_set_bonding_primary = {
6254 		.f = cmd_set_bonding_primary_parsed,
6255 		.help_str = "set bonding primary <slave_id> <port_id>: "
6256 			"Set the primary slave for port_id",
6257 		.data = NULL,
6258 		.tokens = {
6259 				(void *)&cmd_setbonding_primary_set,
6260 				(void *)&cmd_setbonding_primary_bonding,
6261 				(void *)&cmd_setbonding_primary_primary,
6262 				(void *)&cmd_setbonding_primary_slave,
6263 				(void *)&cmd_setbonding_primary_port,
6264 				NULL
6265 		}
6266 };
6267 
6268 /* *** ADD SLAVE *** */
6269 struct cmd_add_bonding_slave_result {
6270 	cmdline_fixed_string_t add;
6271 	cmdline_fixed_string_t bonding;
6272 	cmdline_fixed_string_t slave;
6273 	portid_t slave_id;
6274 	portid_t port_id;
6275 };
6276 
6277 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6278 		__rte_unused  struct cmdline *cl,
6279 		__rte_unused void *data)
6280 {
6281 	struct cmd_add_bonding_slave_result *res = parsed_result;
6282 	portid_t master_port_id = res->port_id;
6283 	portid_t slave_port_id = res->slave_id;
6284 
6285 	/* add the slave for a bonded device. */
6286 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6287 		printf("\t Failed to add slave %d to master port = %d.\n",
6288 				slave_port_id, master_port_id);
6289 		return;
6290 	}
6291 	init_port_config();
6292 	set_port_slave_flag(slave_port_id);
6293 }
6294 
6295 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6296 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6297 		add, "add");
6298 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6299 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6300 		bonding, "bonding");
6301 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6302 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6303 		slave, "slave");
6304 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6305 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6306 		slave_id, RTE_UINT16);
6307 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6308 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6309 		port_id, RTE_UINT16);
6310 
6311 cmdline_parse_inst_t cmd_add_bonding_slave = {
6312 		.f = cmd_add_bonding_slave_parsed,
6313 		.help_str = "add bonding slave <slave_id> <port_id>: "
6314 			"Add a slave device to a bonded device",
6315 		.data = NULL,
6316 		.tokens = {
6317 				(void *)&cmd_addbonding_slave_add,
6318 				(void *)&cmd_addbonding_slave_bonding,
6319 				(void *)&cmd_addbonding_slave_slave,
6320 				(void *)&cmd_addbonding_slave_slaveid,
6321 				(void *)&cmd_addbonding_slave_port,
6322 				NULL
6323 		}
6324 };
6325 
6326 /* *** REMOVE SLAVE *** */
6327 struct cmd_remove_bonding_slave_result {
6328 	cmdline_fixed_string_t remove;
6329 	cmdline_fixed_string_t bonding;
6330 	cmdline_fixed_string_t slave;
6331 	portid_t slave_id;
6332 	portid_t port_id;
6333 };
6334 
6335 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6336 		__rte_unused  struct cmdline *cl,
6337 		__rte_unused void *data)
6338 {
6339 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6340 	portid_t master_port_id = res->port_id;
6341 	portid_t slave_port_id = res->slave_id;
6342 
6343 	/* remove the slave from a bonded device. */
6344 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6345 		printf("\t Failed to remove slave %d from master port = %d.\n",
6346 				slave_port_id, master_port_id);
6347 		return;
6348 	}
6349 	init_port_config();
6350 	clear_port_slave_flag(slave_port_id);
6351 }
6352 
6353 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6354 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6355 				remove, "remove");
6356 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6357 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6358 				bonding, "bonding");
6359 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6360 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6361 				slave, "slave");
6362 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6363 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6364 				slave_id, RTE_UINT16);
6365 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6366 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6367 				port_id, RTE_UINT16);
6368 
6369 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6370 		.f = cmd_remove_bonding_slave_parsed,
6371 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6372 			"Remove a slave device from a bonded device",
6373 		.data = NULL,
6374 		.tokens = {
6375 				(void *)&cmd_removebonding_slave_remove,
6376 				(void *)&cmd_removebonding_slave_bonding,
6377 				(void *)&cmd_removebonding_slave_slave,
6378 				(void *)&cmd_removebonding_slave_slaveid,
6379 				(void *)&cmd_removebonding_slave_port,
6380 				NULL
6381 		}
6382 };
6383 
6384 /* *** CREATE BONDED DEVICE *** */
6385 struct cmd_create_bonded_device_result {
6386 	cmdline_fixed_string_t create;
6387 	cmdline_fixed_string_t bonded;
6388 	cmdline_fixed_string_t device;
6389 	uint8_t mode;
6390 	uint8_t socket;
6391 };
6392 
6393 static int bond_dev_num = 0;
6394 
6395 static void cmd_create_bonded_device_parsed(void *parsed_result,
6396 		__rte_unused  struct cmdline *cl,
6397 		__rte_unused void *data)
6398 {
6399 	struct cmd_create_bonded_device_result *res = parsed_result;
6400 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6401 	int port_id;
6402 	int ret;
6403 
6404 	if (test_done == 0) {
6405 		printf("Please stop forwarding first\n");
6406 		return;
6407 	}
6408 
6409 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6410 			bond_dev_num++);
6411 
6412 	/* Create a new bonded device. */
6413 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6414 	if (port_id < 0) {
6415 		printf("\t Failed to create bonded device.\n");
6416 		return;
6417 	} else {
6418 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6419 				port_id);
6420 
6421 		/* Update number of ports */
6422 		nb_ports = rte_eth_dev_count_avail();
6423 		reconfig(port_id, res->socket);
6424 		ret = rte_eth_promiscuous_enable(port_id);
6425 		if (ret != 0)
6426 			printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6427 				port_id, rte_strerror(-ret));
6428 
6429 		ports[port_id].need_setup = 0;
6430 		ports[port_id].port_status = RTE_PORT_STOPPED;
6431 	}
6432 
6433 }
6434 
6435 cmdline_parse_token_string_t cmd_createbonded_device_create =
6436 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6437 				create, "create");
6438 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6439 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6440 				bonded, "bonded");
6441 cmdline_parse_token_string_t cmd_createbonded_device_device =
6442 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6443 				device, "device");
6444 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6445 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6446 				mode, RTE_UINT8);
6447 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6448 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6449 				socket, RTE_UINT8);
6450 
6451 cmdline_parse_inst_t cmd_create_bonded_device = {
6452 		.f = cmd_create_bonded_device_parsed,
6453 		.help_str = "create bonded device <mode> <socket>: "
6454 			"Create a new bonded device with specific bonding mode and socket",
6455 		.data = NULL,
6456 		.tokens = {
6457 				(void *)&cmd_createbonded_device_create,
6458 				(void *)&cmd_createbonded_device_bonded,
6459 				(void *)&cmd_createbonded_device_device,
6460 				(void *)&cmd_createbonded_device_mode,
6461 				(void *)&cmd_createbonded_device_socket,
6462 				NULL
6463 		}
6464 };
6465 
6466 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6467 struct cmd_set_bond_mac_addr_result {
6468 	cmdline_fixed_string_t set;
6469 	cmdline_fixed_string_t bonding;
6470 	cmdline_fixed_string_t mac_addr;
6471 	uint16_t port_num;
6472 	struct rte_ether_addr address;
6473 };
6474 
6475 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6476 		__rte_unused  struct cmdline *cl,
6477 		__rte_unused void *data)
6478 {
6479 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6480 	int ret;
6481 
6482 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6483 		return;
6484 
6485 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6486 
6487 	/* check the return value and print it if is < 0 */
6488 	if (ret < 0)
6489 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6490 }
6491 
6492 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6493 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6494 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6495 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6496 				"bonding");
6497 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6498 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6499 				"mac_addr");
6500 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6501 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6502 				port_num, RTE_UINT16);
6503 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6504 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6505 
6506 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6507 		.f = cmd_set_bond_mac_addr_parsed,
6508 		.data = (void *) 0,
6509 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6510 		.tokens = {
6511 				(void *)&cmd_set_bond_mac_addr_set,
6512 				(void *)&cmd_set_bond_mac_addr_bonding,
6513 				(void *)&cmd_set_bond_mac_addr_mac,
6514 				(void *)&cmd_set_bond_mac_addr_portnum,
6515 				(void *)&cmd_set_bond_mac_addr_addr,
6516 				NULL
6517 		}
6518 };
6519 
6520 
6521 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6522 struct cmd_set_bond_mon_period_result {
6523 	cmdline_fixed_string_t set;
6524 	cmdline_fixed_string_t bonding;
6525 	cmdline_fixed_string_t mon_period;
6526 	uint16_t port_num;
6527 	uint32_t period_ms;
6528 };
6529 
6530 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6531 		__rte_unused  struct cmdline *cl,
6532 		__rte_unused void *data)
6533 {
6534 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6535 	int ret;
6536 
6537 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6538 
6539 	/* check the return value and print it if is < 0 */
6540 	if (ret < 0)
6541 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6542 }
6543 
6544 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6545 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6546 				set, "set");
6547 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6548 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6549 				bonding, "bonding");
6550 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6551 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6552 				mon_period,	"mon_period");
6553 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6554 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6555 				port_num, RTE_UINT16);
6556 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6557 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6558 				period_ms, RTE_UINT32);
6559 
6560 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6561 		.f = cmd_set_bond_mon_period_parsed,
6562 		.data = (void *) 0,
6563 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6564 		.tokens = {
6565 				(void *)&cmd_set_bond_mon_period_set,
6566 				(void *)&cmd_set_bond_mon_period_bonding,
6567 				(void *)&cmd_set_bond_mon_period_mon_period,
6568 				(void *)&cmd_set_bond_mon_period_portnum,
6569 				(void *)&cmd_set_bond_mon_period_period_ms,
6570 				NULL
6571 		}
6572 };
6573 
6574 
6575 
6576 struct cmd_set_bonding_agg_mode_policy_result {
6577 	cmdline_fixed_string_t set;
6578 	cmdline_fixed_string_t bonding;
6579 	cmdline_fixed_string_t agg_mode;
6580 	uint16_t port_num;
6581 	cmdline_fixed_string_t policy;
6582 };
6583 
6584 
6585 static void
6586 cmd_set_bonding_agg_mode(void *parsed_result,
6587 		__rte_unused struct cmdline *cl,
6588 		__rte_unused void *data)
6589 {
6590 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6591 	uint8_t policy = AGG_BANDWIDTH;
6592 
6593 	if (!strcmp(res->policy, "bandwidth"))
6594 		policy = AGG_BANDWIDTH;
6595 	else if (!strcmp(res->policy, "stable"))
6596 		policy = AGG_STABLE;
6597 	else if (!strcmp(res->policy, "count"))
6598 		policy = AGG_COUNT;
6599 
6600 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6601 }
6602 
6603 
6604 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6605 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6606 				set, "set");
6607 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6608 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6609 				bonding, "bonding");
6610 
6611 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6612 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6613 				agg_mode, "agg_mode");
6614 
6615 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6616 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6617 				port_num, RTE_UINT16);
6618 
6619 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6620 	TOKEN_STRING_INITIALIZER(
6621 			struct cmd_set_bonding_balance_xmit_policy_result,
6622 		policy, "stable#bandwidth#count");
6623 
6624 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6625 	.f = cmd_set_bonding_agg_mode,
6626 	.data = (void *) 0,
6627 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6628 	.tokens = {
6629 			(void *)&cmd_set_bonding_agg_mode_set,
6630 			(void *)&cmd_set_bonding_agg_mode_bonding,
6631 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6632 			(void *)&cmd_set_bonding_agg_mode_portnum,
6633 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6634 			NULL
6635 		}
6636 };
6637 
6638 
6639 #endif /* RTE_NET_BOND */
6640 
6641 /* *** SET FORWARDING MODE *** */
6642 struct cmd_set_fwd_mode_result {
6643 	cmdline_fixed_string_t set;
6644 	cmdline_fixed_string_t fwd;
6645 	cmdline_fixed_string_t mode;
6646 };
6647 
6648 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6649 				    __rte_unused struct cmdline *cl,
6650 				    __rte_unused void *data)
6651 {
6652 	struct cmd_set_fwd_mode_result *res = parsed_result;
6653 
6654 	retry_enabled = 0;
6655 	set_pkt_forwarding_mode(res->mode);
6656 }
6657 
6658 cmdline_parse_token_string_t cmd_setfwd_set =
6659 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6660 cmdline_parse_token_string_t cmd_setfwd_fwd =
6661 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6662 cmdline_parse_token_string_t cmd_setfwd_mode =
6663 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6664 		"" /* defined at init */);
6665 
6666 cmdline_parse_inst_t cmd_set_fwd_mode = {
6667 	.f = cmd_set_fwd_mode_parsed,
6668 	.data = NULL,
6669 	.help_str = NULL, /* defined at init */
6670 	.tokens = {
6671 		(void *)&cmd_setfwd_set,
6672 		(void *)&cmd_setfwd_fwd,
6673 		(void *)&cmd_setfwd_mode,
6674 		NULL,
6675 	},
6676 };
6677 
6678 static void cmd_set_fwd_mode_init(void)
6679 {
6680 	char *modes, *c;
6681 	static char token[128];
6682 	static char help[256];
6683 	cmdline_parse_token_string_t *token_struct;
6684 
6685 	modes = list_pkt_forwarding_modes();
6686 	snprintf(help, sizeof(help), "set fwd %s: "
6687 		"Set packet forwarding mode", modes);
6688 	cmd_set_fwd_mode.help_str = help;
6689 
6690 	/* string token separator is # */
6691 	for (c = token; *modes != '\0'; modes++)
6692 		if (*modes == '|')
6693 			*c++ = '#';
6694 		else
6695 			*c++ = *modes;
6696 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6697 	token_struct->string_data.str = token;
6698 }
6699 
6700 /* *** SET RETRY FORWARDING MODE *** */
6701 struct cmd_set_fwd_retry_mode_result {
6702 	cmdline_fixed_string_t set;
6703 	cmdline_fixed_string_t fwd;
6704 	cmdline_fixed_string_t mode;
6705 	cmdline_fixed_string_t retry;
6706 };
6707 
6708 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6709 			    __rte_unused struct cmdline *cl,
6710 			    __rte_unused void *data)
6711 {
6712 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6713 
6714 	retry_enabled = 1;
6715 	set_pkt_forwarding_mode(res->mode);
6716 }
6717 
6718 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6719 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6720 			set, "set");
6721 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6722 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6723 			fwd, "fwd");
6724 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6725 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6726 			mode,
6727 		"" /* defined at init */);
6728 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6729 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6730 			retry, "retry");
6731 
6732 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6733 	.f = cmd_set_fwd_retry_mode_parsed,
6734 	.data = NULL,
6735 	.help_str = NULL, /* defined at init */
6736 	.tokens = {
6737 		(void *)&cmd_setfwd_retry_set,
6738 		(void *)&cmd_setfwd_retry_fwd,
6739 		(void *)&cmd_setfwd_retry_mode,
6740 		(void *)&cmd_setfwd_retry_retry,
6741 		NULL,
6742 	},
6743 };
6744 
6745 static void cmd_set_fwd_retry_mode_init(void)
6746 {
6747 	char *modes, *c;
6748 	static char token[128];
6749 	static char help[256];
6750 	cmdline_parse_token_string_t *token_struct;
6751 
6752 	modes = list_pkt_forwarding_retry_modes();
6753 	snprintf(help, sizeof(help), "set fwd %s retry: "
6754 		"Set packet forwarding mode with retry", modes);
6755 	cmd_set_fwd_retry_mode.help_str = help;
6756 
6757 	/* string token separator is # */
6758 	for (c = token; *modes != '\0'; modes++)
6759 		if (*modes == '|')
6760 			*c++ = '#';
6761 		else
6762 			*c++ = *modes;
6763 	token_struct = (cmdline_parse_token_string_t *)
6764 		cmd_set_fwd_retry_mode.tokens[2];
6765 	token_struct->string_data.str = token;
6766 }
6767 
6768 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6769 struct cmd_set_burst_tx_retry_result {
6770 	cmdline_fixed_string_t set;
6771 	cmdline_fixed_string_t burst;
6772 	cmdline_fixed_string_t tx;
6773 	cmdline_fixed_string_t delay;
6774 	uint32_t time;
6775 	cmdline_fixed_string_t retry;
6776 	uint32_t retry_num;
6777 };
6778 
6779 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6780 					__rte_unused struct cmdline *cl,
6781 					__rte_unused void *data)
6782 {
6783 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6784 
6785 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6786 		&& !strcmp(res->tx, "tx")) {
6787 		if (!strcmp(res->delay, "delay"))
6788 			burst_tx_delay_time = res->time;
6789 		if (!strcmp(res->retry, "retry"))
6790 			burst_tx_retry_num = res->retry_num;
6791 	}
6792 
6793 }
6794 
6795 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6796 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6797 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6798 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6799 				 "burst");
6800 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6801 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6802 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6803 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6804 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6805 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6806 				 RTE_UINT32);
6807 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6808 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6809 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6810 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6811 				 RTE_UINT32);
6812 
6813 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6814 	.f = cmd_set_burst_tx_retry_parsed,
6815 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6816 	.tokens = {
6817 		(void *)&cmd_set_burst_tx_retry_set,
6818 		(void *)&cmd_set_burst_tx_retry_burst,
6819 		(void *)&cmd_set_burst_tx_retry_tx,
6820 		(void *)&cmd_set_burst_tx_retry_delay,
6821 		(void *)&cmd_set_burst_tx_retry_time,
6822 		(void *)&cmd_set_burst_tx_retry_retry,
6823 		(void *)&cmd_set_burst_tx_retry_retry_num,
6824 		NULL,
6825 	},
6826 };
6827 
6828 /* *** SET PROMISC MODE *** */
6829 struct cmd_set_promisc_mode_result {
6830 	cmdline_fixed_string_t set;
6831 	cmdline_fixed_string_t promisc;
6832 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6833 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6834 	cmdline_fixed_string_t mode;
6835 };
6836 
6837 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6838 					__rte_unused struct cmdline *cl,
6839 					void *allports)
6840 {
6841 	struct cmd_set_promisc_mode_result *res = parsed_result;
6842 	int enable;
6843 	portid_t i;
6844 
6845 	if (!strcmp(res->mode, "on"))
6846 		enable = 1;
6847 	else
6848 		enable = 0;
6849 
6850 	/* all ports */
6851 	if (allports) {
6852 		RTE_ETH_FOREACH_DEV(i)
6853 			eth_set_promisc_mode(i, enable);
6854 	} else {
6855 		eth_set_promisc_mode(res->port_num, enable);
6856 	}
6857 }
6858 
6859 cmdline_parse_token_string_t cmd_setpromisc_set =
6860 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6861 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6862 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6863 				 "promisc");
6864 cmdline_parse_token_string_t cmd_setpromisc_portall =
6865 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6866 				 "all");
6867 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6868 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6869 			      RTE_UINT16);
6870 cmdline_parse_token_string_t cmd_setpromisc_mode =
6871 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6872 				 "on#off");
6873 
6874 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6875 	.f = cmd_set_promisc_mode_parsed,
6876 	.data = (void *)1,
6877 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6878 	.tokens = {
6879 		(void *)&cmd_setpromisc_set,
6880 		(void *)&cmd_setpromisc_promisc,
6881 		(void *)&cmd_setpromisc_portall,
6882 		(void *)&cmd_setpromisc_mode,
6883 		NULL,
6884 	},
6885 };
6886 
6887 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6888 	.f = cmd_set_promisc_mode_parsed,
6889 	.data = (void *)0,
6890 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6891 	.tokens = {
6892 		(void *)&cmd_setpromisc_set,
6893 		(void *)&cmd_setpromisc_promisc,
6894 		(void *)&cmd_setpromisc_portnum,
6895 		(void *)&cmd_setpromisc_mode,
6896 		NULL,
6897 	},
6898 };
6899 
6900 /* *** SET ALLMULTI MODE *** */
6901 struct cmd_set_allmulti_mode_result {
6902 	cmdline_fixed_string_t set;
6903 	cmdline_fixed_string_t allmulti;
6904 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6905 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6906 	cmdline_fixed_string_t mode;
6907 };
6908 
6909 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6910 					__rte_unused struct cmdline *cl,
6911 					void *allports)
6912 {
6913 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6914 	int enable;
6915 	portid_t i;
6916 
6917 	if (!strcmp(res->mode, "on"))
6918 		enable = 1;
6919 	else
6920 		enable = 0;
6921 
6922 	/* all ports */
6923 	if (allports) {
6924 		RTE_ETH_FOREACH_DEV(i) {
6925 			eth_set_allmulticast_mode(i, enable);
6926 		}
6927 	}
6928 	else {
6929 		eth_set_allmulticast_mode(res->port_num, enable);
6930 	}
6931 }
6932 
6933 cmdline_parse_token_string_t cmd_setallmulti_set =
6934 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6935 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6936 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6937 				 "allmulti");
6938 cmdline_parse_token_string_t cmd_setallmulti_portall =
6939 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6940 				 "all");
6941 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6942 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6943 			      RTE_UINT16);
6944 cmdline_parse_token_string_t cmd_setallmulti_mode =
6945 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6946 				 "on#off");
6947 
6948 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6949 	.f = cmd_set_allmulti_mode_parsed,
6950 	.data = (void *)1,
6951 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6952 	.tokens = {
6953 		(void *)&cmd_setallmulti_set,
6954 		(void *)&cmd_setallmulti_allmulti,
6955 		(void *)&cmd_setallmulti_portall,
6956 		(void *)&cmd_setallmulti_mode,
6957 		NULL,
6958 	},
6959 };
6960 
6961 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6962 	.f = cmd_set_allmulti_mode_parsed,
6963 	.data = (void *)0,
6964 	.help_str = "set allmulti <port_id> on|off: "
6965 		"Set allmulti mode on port_id",
6966 	.tokens = {
6967 		(void *)&cmd_setallmulti_set,
6968 		(void *)&cmd_setallmulti_allmulti,
6969 		(void *)&cmd_setallmulti_portnum,
6970 		(void *)&cmd_setallmulti_mode,
6971 		NULL,
6972 	},
6973 };
6974 
6975 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6976 struct cmd_link_flow_ctrl_show {
6977 	cmdline_fixed_string_t show;
6978 	cmdline_fixed_string_t port;
6979 	portid_t port_id;
6980 	cmdline_fixed_string_t flow_ctrl;
6981 };
6982 
6983 cmdline_parse_token_string_t cmd_lfc_show_show =
6984 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6985 				show, "show");
6986 cmdline_parse_token_string_t cmd_lfc_show_port =
6987 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6988 				port, "port");
6989 cmdline_parse_token_num_t cmd_lfc_show_portid =
6990 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6991 				port_id, RTE_UINT16);
6992 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6993 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6994 				flow_ctrl, "flow_ctrl");
6995 
6996 static void
6997 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6998 			      __rte_unused struct cmdline *cl,
6999 			      __rte_unused void *data)
7000 {
7001 	struct cmd_link_flow_ctrl_show *res = parsed_result;
7002 	static const char *info_border = "*********************";
7003 	struct rte_eth_fc_conf fc_conf;
7004 	bool rx_fc_en = false;
7005 	bool tx_fc_en = false;
7006 	int ret;
7007 
7008 	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7009 	if (ret != 0) {
7010 		printf("Failed to get current flow ctrl information: err = %d\n",
7011 		       ret);
7012 		return;
7013 	}
7014 
7015 	if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7016 		rx_fc_en = true;
7017 	if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7018 		tx_fc_en = true;
7019 
7020 	printf("\n%s Flow control infos for port %-2d %s\n",
7021 		info_border, res->port_id, info_border);
7022 	printf("FC mode:\n");
7023 	printf("   Rx pause: %s\n", rx_fc_en ? "on" : "off");
7024 	printf("   Tx pause: %s\n", tx_fc_en ? "on" : "off");
7025 	printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7026 	printf("Pause time: 0x%x\n", fc_conf.pause_time);
7027 	printf("High waterline: 0x%x\n", fc_conf.high_water);
7028 	printf("Low waterline: 0x%x\n", fc_conf.low_water);
7029 	printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7030 	printf("Forward MAC control frames: %s\n",
7031 		fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7032 	printf("\n%s**************   End  ***********%s\n",
7033 		info_border, info_border);
7034 }
7035 
7036 cmdline_parse_inst_t cmd_link_flow_control_show = {
7037 	.f = cmd_link_flow_ctrl_show_parsed,
7038 	.data = NULL,
7039 	.help_str = "show port <port_id> flow_ctrl",
7040 	.tokens = {
7041 		(void *)&cmd_lfc_show_show,
7042 		(void *)&cmd_lfc_show_port,
7043 		(void *)&cmd_lfc_show_portid,
7044 		(void *)&cmd_lfc_show_flow_ctrl,
7045 		NULL,
7046 	},
7047 };
7048 
7049 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7050 struct cmd_link_flow_ctrl_set_result {
7051 	cmdline_fixed_string_t set;
7052 	cmdline_fixed_string_t flow_ctrl;
7053 	cmdline_fixed_string_t rx;
7054 	cmdline_fixed_string_t rx_lfc_mode;
7055 	cmdline_fixed_string_t tx;
7056 	cmdline_fixed_string_t tx_lfc_mode;
7057 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
7058 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7059 	cmdline_fixed_string_t autoneg_str;
7060 	cmdline_fixed_string_t autoneg;
7061 	cmdline_fixed_string_t hw_str;
7062 	uint32_t high_water;
7063 	cmdline_fixed_string_t lw_str;
7064 	uint32_t low_water;
7065 	cmdline_fixed_string_t pt_str;
7066 	uint16_t pause_time;
7067 	cmdline_fixed_string_t xon_str;
7068 	uint16_t send_xon;
7069 	portid_t port_id;
7070 };
7071 
7072 cmdline_parse_token_string_t cmd_lfc_set_set =
7073 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7074 				set, "set");
7075 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7076 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7077 				flow_ctrl, "flow_ctrl");
7078 cmdline_parse_token_string_t cmd_lfc_set_rx =
7079 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7080 				rx, "rx");
7081 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7082 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7083 				rx_lfc_mode, "on#off");
7084 cmdline_parse_token_string_t cmd_lfc_set_tx =
7085 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7086 				tx, "tx");
7087 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7088 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7089 				tx_lfc_mode, "on#off");
7090 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7091 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7092 				hw_str, "high_water");
7093 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7094 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7095 				high_water, RTE_UINT32);
7096 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7097 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7098 				lw_str, "low_water");
7099 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7100 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7101 				low_water, RTE_UINT32);
7102 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7103 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7104 				pt_str, "pause_time");
7105 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7106 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7107 				pause_time, RTE_UINT16);
7108 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7109 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7110 				xon_str, "send_xon");
7111 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7112 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7113 				send_xon, RTE_UINT16);
7114 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7115 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7116 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7117 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7118 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7119 				mac_ctrl_frame_fwd_mode, "on#off");
7120 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7121 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7122 				autoneg_str, "autoneg");
7123 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7124 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7125 				autoneg, "on#off");
7126 cmdline_parse_token_num_t cmd_lfc_set_portid =
7127 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7128 				port_id, RTE_UINT16);
7129 
7130 /* forward declaration */
7131 static void
7132 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7133 			      void *data);
7134 
7135 cmdline_parse_inst_t cmd_link_flow_control_set = {
7136 	.f = cmd_link_flow_ctrl_set_parsed,
7137 	.data = NULL,
7138 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7139 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7140 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
7141 	.tokens = {
7142 		(void *)&cmd_lfc_set_set,
7143 		(void *)&cmd_lfc_set_flow_ctrl,
7144 		(void *)&cmd_lfc_set_rx,
7145 		(void *)&cmd_lfc_set_rx_mode,
7146 		(void *)&cmd_lfc_set_tx,
7147 		(void *)&cmd_lfc_set_tx_mode,
7148 		(void *)&cmd_lfc_set_high_water,
7149 		(void *)&cmd_lfc_set_low_water,
7150 		(void *)&cmd_lfc_set_pause_time,
7151 		(void *)&cmd_lfc_set_send_xon,
7152 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7153 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7154 		(void *)&cmd_lfc_set_autoneg_str,
7155 		(void *)&cmd_lfc_set_autoneg,
7156 		(void *)&cmd_lfc_set_portid,
7157 		NULL,
7158 	},
7159 };
7160 
7161 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7162 	.f = cmd_link_flow_ctrl_set_parsed,
7163 	.data = (void *)&cmd_link_flow_control_set_rx,
7164 	.help_str = "set flow_ctrl rx on|off <port_id>: "
7165 		"Change rx flow control parameter",
7166 	.tokens = {
7167 		(void *)&cmd_lfc_set_set,
7168 		(void *)&cmd_lfc_set_flow_ctrl,
7169 		(void *)&cmd_lfc_set_rx,
7170 		(void *)&cmd_lfc_set_rx_mode,
7171 		(void *)&cmd_lfc_set_portid,
7172 		NULL,
7173 	},
7174 };
7175 
7176 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7177 	.f = cmd_link_flow_ctrl_set_parsed,
7178 	.data = (void *)&cmd_link_flow_control_set_tx,
7179 	.help_str = "set flow_ctrl tx on|off <port_id>: "
7180 		"Change tx flow control parameter",
7181 	.tokens = {
7182 		(void *)&cmd_lfc_set_set,
7183 		(void *)&cmd_lfc_set_flow_ctrl,
7184 		(void *)&cmd_lfc_set_tx,
7185 		(void *)&cmd_lfc_set_tx_mode,
7186 		(void *)&cmd_lfc_set_portid,
7187 		NULL,
7188 	},
7189 };
7190 
7191 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7192 	.f = cmd_link_flow_ctrl_set_parsed,
7193 	.data = (void *)&cmd_link_flow_control_set_hw,
7194 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
7195 		"Change high water flow control parameter",
7196 	.tokens = {
7197 		(void *)&cmd_lfc_set_set,
7198 		(void *)&cmd_lfc_set_flow_ctrl,
7199 		(void *)&cmd_lfc_set_high_water_str,
7200 		(void *)&cmd_lfc_set_high_water,
7201 		(void *)&cmd_lfc_set_portid,
7202 		NULL,
7203 	},
7204 };
7205 
7206 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7207 	.f = cmd_link_flow_ctrl_set_parsed,
7208 	.data = (void *)&cmd_link_flow_control_set_lw,
7209 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7210 		"Change low water flow control parameter",
7211 	.tokens = {
7212 		(void *)&cmd_lfc_set_set,
7213 		(void *)&cmd_lfc_set_flow_ctrl,
7214 		(void *)&cmd_lfc_set_low_water_str,
7215 		(void *)&cmd_lfc_set_low_water,
7216 		(void *)&cmd_lfc_set_portid,
7217 		NULL,
7218 	},
7219 };
7220 
7221 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7222 	.f = cmd_link_flow_ctrl_set_parsed,
7223 	.data = (void *)&cmd_link_flow_control_set_pt,
7224 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7225 		"Change pause time flow control parameter",
7226 	.tokens = {
7227 		(void *)&cmd_lfc_set_set,
7228 		(void *)&cmd_lfc_set_flow_ctrl,
7229 		(void *)&cmd_lfc_set_pause_time_str,
7230 		(void *)&cmd_lfc_set_pause_time,
7231 		(void *)&cmd_lfc_set_portid,
7232 		NULL,
7233 	},
7234 };
7235 
7236 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7237 	.f = cmd_link_flow_ctrl_set_parsed,
7238 	.data = (void *)&cmd_link_flow_control_set_xon,
7239 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7240 		"Change send_xon flow control parameter",
7241 	.tokens = {
7242 		(void *)&cmd_lfc_set_set,
7243 		(void *)&cmd_lfc_set_flow_ctrl,
7244 		(void *)&cmd_lfc_set_send_xon_str,
7245 		(void *)&cmd_lfc_set_send_xon,
7246 		(void *)&cmd_lfc_set_portid,
7247 		NULL,
7248 	},
7249 };
7250 
7251 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7252 	.f = cmd_link_flow_ctrl_set_parsed,
7253 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7254 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7255 		"Change mac ctrl fwd flow control parameter",
7256 	.tokens = {
7257 		(void *)&cmd_lfc_set_set,
7258 		(void *)&cmd_lfc_set_flow_ctrl,
7259 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7260 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7261 		(void *)&cmd_lfc_set_portid,
7262 		NULL,
7263 	},
7264 };
7265 
7266 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7267 	.f = cmd_link_flow_ctrl_set_parsed,
7268 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7269 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7270 		"Change autoneg flow control parameter",
7271 	.tokens = {
7272 		(void *)&cmd_lfc_set_set,
7273 		(void *)&cmd_lfc_set_flow_ctrl,
7274 		(void *)&cmd_lfc_set_autoneg_str,
7275 		(void *)&cmd_lfc_set_autoneg,
7276 		(void *)&cmd_lfc_set_portid,
7277 		NULL,
7278 	},
7279 };
7280 
7281 static void
7282 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7283 			      __rte_unused struct cmdline *cl,
7284 			      void *data)
7285 {
7286 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7287 	cmdline_parse_inst_t *cmd = data;
7288 	struct rte_eth_fc_conf fc_conf;
7289 	int rx_fc_en = 0;
7290 	int tx_fc_en = 0;
7291 	int ret;
7292 
7293 	/*
7294 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7295 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7296 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7297 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7298 	 */
7299 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7300 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7301 	};
7302 
7303 	/* Partial command line, retrieve current configuration */
7304 	if (cmd) {
7305 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7306 		if (ret != 0) {
7307 			printf("cannot get current flow ctrl parameters, return"
7308 			       "code = %d\n", ret);
7309 			return;
7310 		}
7311 
7312 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7313 		    (fc_conf.mode == RTE_FC_FULL))
7314 			rx_fc_en = 1;
7315 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7316 		    (fc_conf.mode == RTE_FC_FULL))
7317 			tx_fc_en = 1;
7318 	}
7319 
7320 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7321 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7322 
7323 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7324 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7325 
7326 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7327 
7328 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7329 		fc_conf.high_water = res->high_water;
7330 
7331 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7332 		fc_conf.low_water = res->low_water;
7333 
7334 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7335 		fc_conf.pause_time = res->pause_time;
7336 
7337 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7338 		fc_conf.send_xon = res->send_xon;
7339 
7340 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7341 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7342 			fc_conf.mac_ctrl_frame_fwd = 1;
7343 		else
7344 			fc_conf.mac_ctrl_frame_fwd = 0;
7345 	}
7346 
7347 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7348 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7349 
7350 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7351 	if (ret != 0)
7352 		printf("bad flow contrl parameter, return code = %d \n", ret);
7353 }
7354 
7355 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7356 struct cmd_priority_flow_ctrl_set_result {
7357 	cmdline_fixed_string_t set;
7358 	cmdline_fixed_string_t pfc_ctrl;
7359 	cmdline_fixed_string_t rx;
7360 	cmdline_fixed_string_t rx_pfc_mode;
7361 	cmdline_fixed_string_t tx;
7362 	cmdline_fixed_string_t tx_pfc_mode;
7363 	uint32_t high_water;
7364 	uint32_t low_water;
7365 	uint16_t pause_time;
7366 	uint8_t  priority;
7367 	portid_t port_id;
7368 };
7369 
7370 static void
7371 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7372 		       __rte_unused struct cmdline *cl,
7373 		       __rte_unused void *data)
7374 {
7375 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7376 	struct rte_eth_pfc_conf pfc_conf;
7377 	int rx_fc_enable, tx_fc_enable;
7378 	int ret;
7379 
7380 	/*
7381 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7382 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7383 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7384 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7385 	 */
7386 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7387 		{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7388 	};
7389 
7390 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7391 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7392 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7393 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7394 	pfc_conf.fc.high_water = res->high_water;
7395 	pfc_conf.fc.low_water  = res->low_water;
7396 	pfc_conf.fc.pause_time = res->pause_time;
7397 	pfc_conf.priority      = res->priority;
7398 
7399 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7400 	if (ret != 0)
7401 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7402 }
7403 
7404 cmdline_parse_token_string_t cmd_pfc_set_set =
7405 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7406 				set, "set");
7407 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7408 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7409 				pfc_ctrl, "pfc_ctrl");
7410 cmdline_parse_token_string_t cmd_pfc_set_rx =
7411 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7412 				rx, "rx");
7413 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7414 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7415 				rx_pfc_mode, "on#off");
7416 cmdline_parse_token_string_t cmd_pfc_set_tx =
7417 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7418 				tx, "tx");
7419 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7420 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7421 				tx_pfc_mode, "on#off");
7422 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7423 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7424 				high_water, RTE_UINT32);
7425 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7426 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7427 				low_water, RTE_UINT32);
7428 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7429 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7430 				pause_time, RTE_UINT16);
7431 cmdline_parse_token_num_t cmd_pfc_set_priority =
7432 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7433 				priority, RTE_UINT8);
7434 cmdline_parse_token_num_t cmd_pfc_set_portid =
7435 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7436 				port_id, RTE_UINT16);
7437 
7438 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7439 	.f = cmd_priority_flow_ctrl_set_parsed,
7440 	.data = NULL,
7441 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7442 		"<pause_time> <priority> <port_id>: "
7443 		"Configure the Ethernet priority flow control",
7444 	.tokens = {
7445 		(void *)&cmd_pfc_set_set,
7446 		(void *)&cmd_pfc_set_flow_ctrl,
7447 		(void *)&cmd_pfc_set_rx,
7448 		(void *)&cmd_pfc_set_rx_mode,
7449 		(void *)&cmd_pfc_set_tx,
7450 		(void *)&cmd_pfc_set_tx_mode,
7451 		(void *)&cmd_pfc_set_high_water,
7452 		(void *)&cmd_pfc_set_low_water,
7453 		(void *)&cmd_pfc_set_pause_time,
7454 		(void *)&cmd_pfc_set_priority,
7455 		(void *)&cmd_pfc_set_portid,
7456 		NULL,
7457 	},
7458 };
7459 
7460 /* *** RESET CONFIGURATION *** */
7461 struct cmd_reset_result {
7462 	cmdline_fixed_string_t reset;
7463 	cmdline_fixed_string_t def;
7464 };
7465 
7466 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7467 			     struct cmdline *cl,
7468 			     __rte_unused void *data)
7469 {
7470 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7471 	set_def_fwd_config();
7472 }
7473 
7474 cmdline_parse_token_string_t cmd_reset_set =
7475 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7476 cmdline_parse_token_string_t cmd_reset_def =
7477 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7478 				 "default");
7479 
7480 cmdline_parse_inst_t cmd_reset = {
7481 	.f = cmd_reset_parsed,
7482 	.data = NULL,
7483 	.help_str = "set default: Reset default forwarding configuration",
7484 	.tokens = {
7485 		(void *)&cmd_reset_set,
7486 		(void *)&cmd_reset_def,
7487 		NULL,
7488 	},
7489 };
7490 
7491 /* *** START FORWARDING *** */
7492 struct cmd_start_result {
7493 	cmdline_fixed_string_t start;
7494 };
7495 
7496 cmdline_parse_token_string_t cmd_start_start =
7497 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7498 
7499 static void cmd_start_parsed(__rte_unused void *parsed_result,
7500 			     __rte_unused struct cmdline *cl,
7501 			     __rte_unused void *data)
7502 {
7503 	start_packet_forwarding(0);
7504 }
7505 
7506 cmdline_parse_inst_t cmd_start = {
7507 	.f = cmd_start_parsed,
7508 	.data = NULL,
7509 	.help_str = "start: Start packet forwarding",
7510 	.tokens = {
7511 		(void *)&cmd_start_start,
7512 		NULL,
7513 	},
7514 };
7515 
7516 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7517 struct cmd_start_tx_first_result {
7518 	cmdline_fixed_string_t start;
7519 	cmdline_fixed_string_t tx_first;
7520 };
7521 
7522 static void
7523 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7524 			  __rte_unused struct cmdline *cl,
7525 			  __rte_unused void *data)
7526 {
7527 	start_packet_forwarding(1);
7528 }
7529 
7530 cmdline_parse_token_string_t cmd_start_tx_first_start =
7531 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7532 				 "start");
7533 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7534 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7535 				 tx_first, "tx_first");
7536 
7537 cmdline_parse_inst_t cmd_start_tx_first = {
7538 	.f = cmd_start_tx_first_parsed,
7539 	.data = NULL,
7540 	.help_str = "start tx_first: Start packet forwarding, "
7541 		"after sending 1 burst of packets",
7542 	.tokens = {
7543 		(void *)&cmd_start_tx_first_start,
7544 		(void *)&cmd_start_tx_first_tx_first,
7545 		NULL,
7546 	},
7547 };
7548 
7549 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7550 struct cmd_start_tx_first_n_result {
7551 	cmdline_fixed_string_t start;
7552 	cmdline_fixed_string_t tx_first;
7553 	uint32_t tx_num;
7554 };
7555 
7556 static void
7557 cmd_start_tx_first_n_parsed(void *parsed_result,
7558 			  __rte_unused struct cmdline *cl,
7559 			  __rte_unused void *data)
7560 {
7561 	struct cmd_start_tx_first_n_result *res = parsed_result;
7562 
7563 	start_packet_forwarding(res->tx_num);
7564 }
7565 
7566 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7567 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7568 			start, "start");
7569 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7570 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7571 			tx_first, "tx_first");
7572 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7573 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7574 			tx_num, RTE_UINT32);
7575 
7576 cmdline_parse_inst_t cmd_start_tx_first_n = {
7577 	.f = cmd_start_tx_first_n_parsed,
7578 	.data = NULL,
7579 	.help_str = "start tx_first <num>: "
7580 		"packet forwarding, after sending <num> bursts of packets",
7581 	.tokens = {
7582 		(void *)&cmd_start_tx_first_n_start,
7583 		(void *)&cmd_start_tx_first_n_tx_first,
7584 		(void *)&cmd_start_tx_first_n_tx_num,
7585 		NULL,
7586 	},
7587 };
7588 
7589 /* *** SET LINK UP *** */
7590 struct cmd_set_link_up_result {
7591 	cmdline_fixed_string_t set;
7592 	cmdline_fixed_string_t link_up;
7593 	cmdline_fixed_string_t port;
7594 	portid_t port_id;
7595 };
7596 
7597 cmdline_parse_token_string_t cmd_set_link_up_set =
7598 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7599 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7600 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7601 				"link-up");
7602 cmdline_parse_token_string_t cmd_set_link_up_port =
7603 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7604 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7605 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7606 				RTE_UINT16);
7607 
7608 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7609 			     __rte_unused struct cmdline *cl,
7610 			     __rte_unused void *data)
7611 {
7612 	struct cmd_set_link_up_result *res = parsed_result;
7613 	dev_set_link_up(res->port_id);
7614 }
7615 
7616 cmdline_parse_inst_t cmd_set_link_up = {
7617 	.f = cmd_set_link_up_parsed,
7618 	.data = NULL,
7619 	.help_str = "set link-up port <port id>",
7620 	.tokens = {
7621 		(void *)&cmd_set_link_up_set,
7622 		(void *)&cmd_set_link_up_link_up,
7623 		(void *)&cmd_set_link_up_port,
7624 		(void *)&cmd_set_link_up_port_id,
7625 		NULL,
7626 	},
7627 };
7628 
7629 /* *** SET LINK DOWN *** */
7630 struct cmd_set_link_down_result {
7631 	cmdline_fixed_string_t set;
7632 	cmdline_fixed_string_t link_down;
7633 	cmdline_fixed_string_t port;
7634 	portid_t port_id;
7635 };
7636 
7637 cmdline_parse_token_string_t cmd_set_link_down_set =
7638 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7639 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7640 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7641 				"link-down");
7642 cmdline_parse_token_string_t cmd_set_link_down_port =
7643 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7644 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7645 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7646 				RTE_UINT16);
7647 
7648 static void cmd_set_link_down_parsed(
7649 				__rte_unused void *parsed_result,
7650 				__rte_unused struct cmdline *cl,
7651 				__rte_unused void *data)
7652 {
7653 	struct cmd_set_link_down_result *res = parsed_result;
7654 	dev_set_link_down(res->port_id);
7655 }
7656 
7657 cmdline_parse_inst_t cmd_set_link_down = {
7658 	.f = cmd_set_link_down_parsed,
7659 	.data = NULL,
7660 	.help_str = "set link-down port <port id>",
7661 	.tokens = {
7662 		(void *)&cmd_set_link_down_set,
7663 		(void *)&cmd_set_link_down_link_down,
7664 		(void *)&cmd_set_link_down_port,
7665 		(void *)&cmd_set_link_down_port_id,
7666 		NULL,
7667 	},
7668 };
7669 
7670 /* *** SHOW CFG *** */
7671 struct cmd_showcfg_result {
7672 	cmdline_fixed_string_t show;
7673 	cmdline_fixed_string_t cfg;
7674 	cmdline_fixed_string_t what;
7675 };
7676 
7677 static void cmd_showcfg_parsed(void *parsed_result,
7678 			       __rte_unused struct cmdline *cl,
7679 			       __rte_unused void *data)
7680 {
7681 	struct cmd_showcfg_result *res = parsed_result;
7682 	if (!strcmp(res->what, "rxtx"))
7683 		rxtx_config_display();
7684 	else if (!strcmp(res->what, "cores"))
7685 		fwd_lcores_config_display();
7686 	else if (!strcmp(res->what, "fwd"))
7687 		pkt_fwd_config_display(&cur_fwd_config);
7688 	else if (!strcmp(res->what, "rxoffs"))
7689 		show_rx_pkt_offsets();
7690 	else if (!strcmp(res->what, "rxpkts"))
7691 		show_rx_pkt_segments();
7692 	else if (!strcmp(res->what, "txpkts"))
7693 		show_tx_pkt_segments();
7694 	else if (!strcmp(res->what, "txtimes"))
7695 		show_tx_pkt_times();
7696 }
7697 
7698 cmdline_parse_token_string_t cmd_showcfg_show =
7699 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7700 cmdline_parse_token_string_t cmd_showcfg_port =
7701 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7702 cmdline_parse_token_string_t cmd_showcfg_what =
7703 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7704 				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7705 
7706 cmdline_parse_inst_t cmd_showcfg = {
7707 	.f = cmd_showcfg_parsed,
7708 	.data = NULL,
7709 	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7710 	.tokens = {
7711 		(void *)&cmd_showcfg_show,
7712 		(void *)&cmd_showcfg_port,
7713 		(void *)&cmd_showcfg_what,
7714 		NULL,
7715 	},
7716 };
7717 
7718 /* *** SHOW ALL PORT INFO *** */
7719 struct cmd_showportall_result {
7720 	cmdline_fixed_string_t show;
7721 	cmdline_fixed_string_t port;
7722 	cmdline_fixed_string_t what;
7723 	cmdline_fixed_string_t all;
7724 };
7725 
7726 static void cmd_showportall_parsed(void *parsed_result,
7727 				__rte_unused struct cmdline *cl,
7728 				__rte_unused void *data)
7729 {
7730 	portid_t i;
7731 
7732 	struct cmd_showportall_result *res = parsed_result;
7733 	if (!strcmp(res->show, "clear")) {
7734 		if (!strcmp(res->what, "stats"))
7735 			RTE_ETH_FOREACH_DEV(i)
7736 				nic_stats_clear(i);
7737 		else if (!strcmp(res->what, "xstats"))
7738 			RTE_ETH_FOREACH_DEV(i)
7739 				nic_xstats_clear(i);
7740 	} else if (!strcmp(res->what, "info"))
7741 		RTE_ETH_FOREACH_DEV(i)
7742 			port_infos_display(i);
7743 	else if (!strcmp(res->what, "summary")) {
7744 		port_summary_header_display();
7745 		RTE_ETH_FOREACH_DEV(i)
7746 			port_summary_display(i);
7747 	}
7748 	else if (!strcmp(res->what, "stats"))
7749 		RTE_ETH_FOREACH_DEV(i)
7750 			nic_stats_display(i);
7751 	else if (!strcmp(res->what, "xstats"))
7752 		RTE_ETH_FOREACH_DEV(i)
7753 			nic_xstats_display(i);
7754 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7755 	else if (!strcmp(res->what, "fdir"))
7756 		RTE_ETH_FOREACH_DEV(i)
7757 			fdir_get_infos(i);
7758 #endif
7759 	else if (!strcmp(res->what, "dcb_tc"))
7760 		RTE_ETH_FOREACH_DEV(i)
7761 			port_dcb_info_display(i);
7762 }
7763 
7764 cmdline_parse_token_string_t cmd_showportall_show =
7765 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7766 				 "show#clear");
7767 cmdline_parse_token_string_t cmd_showportall_port =
7768 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7769 cmdline_parse_token_string_t cmd_showportall_what =
7770 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7771 				 "info#summary#stats#xstats#fdir#dcb_tc");
7772 cmdline_parse_token_string_t cmd_showportall_all =
7773 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7774 cmdline_parse_inst_t cmd_showportall = {
7775 	.f = cmd_showportall_parsed,
7776 	.data = NULL,
7777 	.help_str = "show|clear port "
7778 		"info|summary|stats|xstats|fdir|dcb_tc all",
7779 	.tokens = {
7780 		(void *)&cmd_showportall_show,
7781 		(void *)&cmd_showportall_port,
7782 		(void *)&cmd_showportall_what,
7783 		(void *)&cmd_showportall_all,
7784 		NULL,
7785 	},
7786 };
7787 
7788 /* *** SHOW PORT INFO *** */
7789 struct cmd_showport_result {
7790 	cmdline_fixed_string_t show;
7791 	cmdline_fixed_string_t port;
7792 	cmdline_fixed_string_t what;
7793 	uint16_t portnum;
7794 };
7795 
7796 static void cmd_showport_parsed(void *parsed_result,
7797 				__rte_unused struct cmdline *cl,
7798 				__rte_unused void *data)
7799 {
7800 	struct cmd_showport_result *res = parsed_result;
7801 	if (!strcmp(res->show, "clear")) {
7802 		if (!strcmp(res->what, "stats"))
7803 			nic_stats_clear(res->portnum);
7804 		else if (!strcmp(res->what, "xstats"))
7805 			nic_xstats_clear(res->portnum);
7806 	} else if (!strcmp(res->what, "info"))
7807 		port_infos_display(res->portnum);
7808 	else if (!strcmp(res->what, "summary")) {
7809 		port_summary_header_display();
7810 		port_summary_display(res->portnum);
7811 	}
7812 	else if (!strcmp(res->what, "stats"))
7813 		nic_stats_display(res->portnum);
7814 	else if (!strcmp(res->what, "xstats"))
7815 		nic_xstats_display(res->portnum);
7816 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7817 	else if (!strcmp(res->what, "fdir"))
7818 		 fdir_get_infos(res->portnum);
7819 #endif
7820 	else if (!strcmp(res->what, "dcb_tc"))
7821 		port_dcb_info_display(res->portnum);
7822 }
7823 
7824 cmdline_parse_token_string_t cmd_showport_show =
7825 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7826 				 "show#clear");
7827 cmdline_parse_token_string_t cmd_showport_port =
7828 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7829 cmdline_parse_token_string_t cmd_showport_what =
7830 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7831 				 "info#summary#stats#xstats#fdir#dcb_tc");
7832 cmdline_parse_token_num_t cmd_showport_portnum =
7833 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7834 
7835 cmdline_parse_inst_t cmd_showport = {
7836 	.f = cmd_showport_parsed,
7837 	.data = NULL,
7838 	.help_str = "show|clear port "
7839 		"info|summary|stats|xstats|fdir|dcb_tc "
7840 		"<port_id>",
7841 	.tokens = {
7842 		(void *)&cmd_showport_show,
7843 		(void *)&cmd_showport_port,
7844 		(void *)&cmd_showport_what,
7845 		(void *)&cmd_showport_portnum,
7846 		NULL,
7847 	},
7848 };
7849 
7850 /* *** SHOW DEVICE INFO *** */
7851 struct cmd_showdevice_result {
7852 	cmdline_fixed_string_t show;
7853 	cmdline_fixed_string_t device;
7854 	cmdline_fixed_string_t what;
7855 	cmdline_fixed_string_t identifier;
7856 };
7857 
7858 static void cmd_showdevice_parsed(void *parsed_result,
7859 				__rte_unused struct cmdline *cl,
7860 				__rte_unused void *data)
7861 {
7862 	struct cmd_showdevice_result *res = parsed_result;
7863 	if (!strcmp(res->what, "info")) {
7864 		if (!strcmp(res->identifier, "all"))
7865 			device_infos_display(NULL);
7866 		else
7867 			device_infos_display(res->identifier);
7868 	}
7869 }
7870 
7871 cmdline_parse_token_string_t cmd_showdevice_show =
7872 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7873 				 "show");
7874 cmdline_parse_token_string_t cmd_showdevice_device =
7875 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7876 cmdline_parse_token_string_t cmd_showdevice_what =
7877 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7878 				 "info");
7879 cmdline_parse_token_string_t cmd_showdevice_identifier =
7880 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7881 			identifier, NULL);
7882 
7883 cmdline_parse_inst_t cmd_showdevice = {
7884 	.f = cmd_showdevice_parsed,
7885 	.data = NULL,
7886 	.help_str = "show device info <identifier>|all",
7887 	.tokens = {
7888 		(void *)&cmd_showdevice_show,
7889 		(void *)&cmd_showdevice_device,
7890 		(void *)&cmd_showdevice_what,
7891 		(void *)&cmd_showdevice_identifier,
7892 		NULL,
7893 	},
7894 };
7895 
7896 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7897 struct cmd_showeeprom_result {
7898 	cmdline_fixed_string_t show;
7899 	cmdline_fixed_string_t port;
7900 	uint16_t portnum;
7901 	cmdline_fixed_string_t type;
7902 };
7903 
7904 static void cmd_showeeprom_parsed(void *parsed_result,
7905 		__rte_unused struct cmdline *cl,
7906 		__rte_unused void *data)
7907 {
7908 	struct cmd_showeeprom_result *res = parsed_result;
7909 
7910 	if (!strcmp(res->type, "eeprom"))
7911 		port_eeprom_display(res->portnum);
7912 	else if (!strcmp(res->type, "module_eeprom"))
7913 		port_module_eeprom_display(res->portnum);
7914 	else
7915 		printf("Unknown argument\n");
7916 }
7917 
7918 cmdline_parse_token_string_t cmd_showeeprom_show =
7919 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7920 cmdline_parse_token_string_t cmd_showeeprom_port =
7921 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7922 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7923 	TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7924 			RTE_UINT16);
7925 cmdline_parse_token_string_t cmd_showeeprom_type =
7926 	TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7927 
7928 cmdline_parse_inst_t cmd_showeeprom = {
7929 	.f = cmd_showeeprom_parsed,
7930 	.data = NULL,
7931 	.help_str = "show port <port_id> module_eeprom|eeprom",
7932 	.tokens = {
7933 		(void *)&cmd_showeeprom_show,
7934 		(void *)&cmd_showeeprom_port,
7935 		(void *)&cmd_showeeprom_portnum,
7936 		(void *)&cmd_showeeprom_type,
7937 		NULL,
7938 	},
7939 };
7940 
7941 /* *** SHOW QUEUE INFO *** */
7942 struct cmd_showqueue_result {
7943 	cmdline_fixed_string_t show;
7944 	cmdline_fixed_string_t type;
7945 	cmdline_fixed_string_t what;
7946 	uint16_t portnum;
7947 	uint16_t queuenum;
7948 };
7949 
7950 static void
7951 cmd_showqueue_parsed(void *parsed_result,
7952 	__rte_unused struct cmdline *cl,
7953 	__rte_unused void *data)
7954 {
7955 	struct cmd_showqueue_result *res = parsed_result;
7956 
7957 	if (!strcmp(res->type, "rxq"))
7958 		rx_queue_infos_display(res->portnum, res->queuenum);
7959 	else if (!strcmp(res->type, "txq"))
7960 		tx_queue_infos_display(res->portnum, res->queuenum);
7961 }
7962 
7963 cmdline_parse_token_string_t cmd_showqueue_show =
7964 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7965 cmdline_parse_token_string_t cmd_showqueue_type =
7966 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7967 cmdline_parse_token_string_t cmd_showqueue_what =
7968 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7969 cmdline_parse_token_num_t cmd_showqueue_portnum =
7970 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7971 		RTE_UINT16);
7972 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7973 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7974 		RTE_UINT16);
7975 
7976 cmdline_parse_inst_t cmd_showqueue = {
7977 	.f = cmd_showqueue_parsed,
7978 	.data = NULL,
7979 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7980 	.tokens = {
7981 		(void *)&cmd_showqueue_show,
7982 		(void *)&cmd_showqueue_type,
7983 		(void *)&cmd_showqueue_what,
7984 		(void *)&cmd_showqueue_portnum,
7985 		(void *)&cmd_showqueue_queuenum,
7986 		NULL,
7987 	},
7988 };
7989 
7990 /* show/clear fwd engine statistics */
7991 struct fwd_result {
7992 	cmdline_fixed_string_t action;
7993 	cmdline_fixed_string_t fwd;
7994 	cmdline_fixed_string_t stats;
7995 	cmdline_fixed_string_t all;
7996 };
7997 
7998 cmdline_parse_token_string_t cmd_fwd_action =
7999 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8000 cmdline_parse_token_string_t cmd_fwd_fwd =
8001 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8002 cmdline_parse_token_string_t cmd_fwd_stats =
8003 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8004 cmdline_parse_token_string_t cmd_fwd_all =
8005 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8006 
8007 static void
8008 cmd_showfwdall_parsed(void *parsed_result,
8009 		      __rte_unused struct cmdline *cl,
8010 		      __rte_unused void *data)
8011 {
8012 	struct fwd_result *res = parsed_result;
8013 
8014 	if (!strcmp(res->action, "show"))
8015 		fwd_stats_display();
8016 	else
8017 		fwd_stats_reset();
8018 }
8019 
8020 static cmdline_parse_inst_t cmd_showfwdall = {
8021 	.f = cmd_showfwdall_parsed,
8022 	.data = NULL,
8023 	.help_str = "show|clear fwd stats all",
8024 	.tokens = {
8025 		(void *)&cmd_fwd_action,
8026 		(void *)&cmd_fwd_fwd,
8027 		(void *)&cmd_fwd_stats,
8028 		(void *)&cmd_fwd_all,
8029 		NULL,
8030 	},
8031 };
8032 
8033 /* *** READ PORT REGISTER *** */
8034 struct cmd_read_reg_result {
8035 	cmdline_fixed_string_t read;
8036 	cmdline_fixed_string_t reg;
8037 	portid_t port_id;
8038 	uint32_t reg_off;
8039 };
8040 
8041 static void
8042 cmd_read_reg_parsed(void *parsed_result,
8043 		    __rte_unused struct cmdline *cl,
8044 		    __rte_unused void *data)
8045 {
8046 	struct cmd_read_reg_result *res = parsed_result;
8047 	port_reg_display(res->port_id, res->reg_off);
8048 }
8049 
8050 cmdline_parse_token_string_t cmd_read_reg_read =
8051 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8052 cmdline_parse_token_string_t cmd_read_reg_reg =
8053 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8054 cmdline_parse_token_num_t cmd_read_reg_port_id =
8055 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8056 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8057 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8058 
8059 cmdline_parse_inst_t cmd_read_reg = {
8060 	.f = cmd_read_reg_parsed,
8061 	.data = NULL,
8062 	.help_str = "read reg <port_id> <reg_off>",
8063 	.tokens = {
8064 		(void *)&cmd_read_reg_read,
8065 		(void *)&cmd_read_reg_reg,
8066 		(void *)&cmd_read_reg_port_id,
8067 		(void *)&cmd_read_reg_reg_off,
8068 		NULL,
8069 	},
8070 };
8071 
8072 /* *** READ PORT REGISTER BIT FIELD *** */
8073 struct cmd_read_reg_bit_field_result {
8074 	cmdline_fixed_string_t read;
8075 	cmdline_fixed_string_t regfield;
8076 	portid_t port_id;
8077 	uint32_t reg_off;
8078 	uint8_t bit1_pos;
8079 	uint8_t bit2_pos;
8080 };
8081 
8082 static void
8083 cmd_read_reg_bit_field_parsed(void *parsed_result,
8084 			      __rte_unused struct cmdline *cl,
8085 			      __rte_unused void *data)
8086 {
8087 	struct cmd_read_reg_bit_field_result *res = parsed_result;
8088 	port_reg_bit_field_display(res->port_id, res->reg_off,
8089 				   res->bit1_pos, res->bit2_pos);
8090 }
8091 
8092 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8093 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8094 				 "read");
8095 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8096 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8097 				 regfield, "regfield");
8098 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8099 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8100 			      RTE_UINT16);
8101 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8102 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8103 			      RTE_UINT32);
8104 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8105 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8106 			      RTE_UINT8);
8107 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8108 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8109 			      RTE_UINT8);
8110 
8111 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8112 	.f = cmd_read_reg_bit_field_parsed,
8113 	.data = NULL,
8114 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8115 	"Read register bit field between bit_x and bit_y included",
8116 	.tokens = {
8117 		(void *)&cmd_read_reg_bit_field_read,
8118 		(void *)&cmd_read_reg_bit_field_regfield,
8119 		(void *)&cmd_read_reg_bit_field_port_id,
8120 		(void *)&cmd_read_reg_bit_field_reg_off,
8121 		(void *)&cmd_read_reg_bit_field_bit1_pos,
8122 		(void *)&cmd_read_reg_bit_field_bit2_pos,
8123 		NULL,
8124 	},
8125 };
8126 
8127 /* *** READ PORT REGISTER BIT *** */
8128 struct cmd_read_reg_bit_result {
8129 	cmdline_fixed_string_t read;
8130 	cmdline_fixed_string_t regbit;
8131 	portid_t port_id;
8132 	uint32_t reg_off;
8133 	uint8_t bit_pos;
8134 };
8135 
8136 static void
8137 cmd_read_reg_bit_parsed(void *parsed_result,
8138 			__rte_unused struct cmdline *cl,
8139 			__rte_unused void *data)
8140 {
8141 	struct cmd_read_reg_bit_result *res = parsed_result;
8142 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8143 }
8144 
8145 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8146 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8147 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8148 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8149 				 regbit, "regbit");
8150 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8151 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8152 				 RTE_UINT16);
8153 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8154 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8155 				 RTE_UINT32);
8156 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8157 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8158 				 RTE_UINT8);
8159 
8160 cmdline_parse_inst_t cmd_read_reg_bit = {
8161 	.f = cmd_read_reg_bit_parsed,
8162 	.data = NULL,
8163 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8164 	.tokens = {
8165 		(void *)&cmd_read_reg_bit_read,
8166 		(void *)&cmd_read_reg_bit_regbit,
8167 		(void *)&cmd_read_reg_bit_port_id,
8168 		(void *)&cmd_read_reg_bit_reg_off,
8169 		(void *)&cmd_read_reg_bit_bit_pos,
8170 		NULL,
8171 	},
8172 };
8173 
8174 /* *** WRITE PORT REGISTER *** */
8175 struct cmd_write_reg_result {
8176 	cmdline_fixed_string_t write;
8177 	cmdline_fixed_string_t reg;
8178 	portid_t port_id;
8179 	uint32_t reg_off;
8180 	uint32_t value;
8181 };
8182 
8183 static void
8184 cmd_write_reg_parsed(void *parsed_result,
8185 		     __rte_unused struct cmdline *cl,
8186 		     __rte_unused void *data)
8187 {
8188 	struct cmd_write_reg_result *res = parsed_result;
8189 	port_reg_set(res->port_id, res->reg_off, res->value);
8190 }
8191 
8192 cmdline_parse_token_string_t cmd_write_reg_write =
8193 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8194 cmdline_parse_token_string_t cmd_write_reg_reg =
8195 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8196 cmdline_parse_token_num_t cmd_write_reg_port_id =
8197 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8198 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8199 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8200 cmdline_parse_token_num_t cmd_write_reg_value =
8201 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8202 
8203 cmdline_parse_inst_t cmd_write_reg = {
8204 	.f = cmd_write_reg_parsed,
8205 	.data = NULL,
8206 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
8207 	.tokens = {
8208 		(void *)&cmd_write_reg_write,
8209 		(void *)&cmd_write_reg_reg,
8210 		(void *)&cmd_write_reg_port_id,
8211 		(void *)&cmd_write_reg_reg_off,
8212 		(void *)&cmd_write_reg_value,
8213 		NULL,
8214 	},
8215 };
8216 
8217 /* *** WRITE PORT REGISTER BIT FIELD *** */
8218 struct cmd_write_reg_bit_field_result {
8219 	cmdline_fixed_string_t write;
8220 	cmdline_fixed_string_t regfield;
8221 	portid_t port_id;
8222 	uint32_t reg_off;
8223 	uint8_t bit1_pos;
8224 	uint8_t bit2_pos;
8225 	uint32_t value;
8226 };
8227 
8228 static void
8229 cmd_write_reg_bit_field_parsed(void *parsed_result,
8230 			       __rte_unused struct cmdline *cl,
8231 			       __rte_unused void *data)
8232 {
8233 	struct cmd_write_reg_bit_field_result *res = parsed_result;
8234 	port_reg_bit_field_set(res->port_id, res->reg_off,
8235 			  res->bit1_pos, res->bit2_pos, res->value);
8236 }
8237 
8238 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8239 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8240 				 "write");
8241 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8242 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8243 				 regfield, "regfield");
8244 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8245 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8246 			      RTE_UINT16);
8247 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8248 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8249 			      RTE_UINT32);
8250 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8251 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8252 			      RTE_UINT8);
8253 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8254 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8255 			      RTE_UINT8);
8256 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8257 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8258 			      RTE_UINT32);
8259 
8260 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8261 	.f = cmd_write_reg_bit_field_parsed,
8262 	.data = NULL,
8263 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8264 		"<reg_value>: "
8265 		"Set register bit field between bit_x and bit_y included",
8266 	.tokens = {
8267 		(void *)&cmd_write_reg_bit_field_write,
8268 		(void *)&cmd_write_reg_bit_field_regfield,
8269 		(void *)&cmd_write_reg_bit_field_port_id,
8270 		(void *)&cmd_write_reg_bit_field_reg_off,
8271 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8272 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8273 		(void *)&cmd_write_reg_bit_field_value,
8274 		NULL,
8275 	},
8276 };
8277 
8278 /* *** WRITE PORT REGISTER BIT *** */
8279 struct cmd_write_reg_bit_result {
8280 	cmdline_fixed_string_t write;
8281 	cmdline_fixed_string_t regbit;
8282 	portid_t port_id;
8283 	uint32_t reg_off;
8284 	uint8_t bit_pos;
8285 	uint8_t value;
8286 };
8287 
8288 static void
8289 cmd_write_reg_bit_parsed(void *parsed_result,
8290 			 __rte_unused struct cmdline *cl,
8291 			 __rte_unused void *data)
8292 {
8293 	struct cmd_write_reg_bit_result *res = parsed_result;
8294 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8295 }
8296 
8297 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8298 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8299 				 "write");
8300 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8301 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8302 				 regbit, "regbit");
8303 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8304 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8305 				 RTE_UINT16);
8306 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8307 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8308 				 RTE_UINT32);
8309 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8310 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8311 				 RTE_UINT8);
8312 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8313 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8314 				 RTE_UINT8);
8315 
8316 cmdline_parse_inst_t cmd_write_reg_bit = {
8317 	.f = cmd_write_reg_bit_parsed,
8318 	.data = NULL,
8319 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8320 		"0 <= bit_x <= 31",
8321 	.tokens = {
8322 		(void *)&cmd_write_reg_bit_write,
8323 		(void *)&cmd_write_reg_bit_regbit,
8324 		(void *)&cmd_write_reg_bit_port_id,
8325 		(void *)&cmd_write_reg_bit_reg_off,
8326 		(void *)&cmd_write_reg_bit_bit_pos,
8327 		(void *)&cmd_write_reg_bit_value,
8328 		NULL,
8329 	},
8330 };
8331 
8332 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8333 struct cmd_read_rxd_txd_result {
8334 	cmdline_fixed_string_t read;
8335 	cmdline_fixed_string_t rxd_txd;
8336 	portid_t port_id;
8337 	uint16_t queue_id;
8338 	uint16_t desc_id;
8339 };
8340 
8341 static void
8342 cmd_read_rxd_txd_parsed(void *parsed_result,
8343 			__rte_unused struct cmdline *cl,
8344 			__rte_unused void *data)
8345 {
8346 	struct cmd_read_rxd_txd_result *res = parsed_result;
8347 
8348 	if (!strcmp(res->rxd_txd, "rxd"))
8349 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8350 	else if (!strcmp(res->rxd_txd, "txd"))
8351 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8352 }
8353 
8354 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8355 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8356 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8357 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8358 				 "rxd#txd");
8359 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8360 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8361 				 RTE_UINT16);
8362 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8363 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8364 				 RTE_UINT16);
8365 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8366 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8367 				 RTE_UINT16);
8368 
8369 cmdline_parse_inst_t cmd_read_rxd_txd = {
8370 	.f = cmd_read_rxd_txd_parsed,
8371 	.data = NULL,
8372 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8373 	.tokens = {
8374 		(void *)&cmd_read_rxd_txd_read,
8375 		(void *)&cmd_read_rxd_txd_rxd_txd,
8376 		(void *)&cmd_read_rxd_txd_port_id,
8377 		(void *)&cmd_read_rxd_txd_queue_id,
8378 		(void *)&cmd_read_rxd_txd_desc_id,
8379 		NULL,
8380 	},
8381 };
8382 
8383 /* *** QUIT *** */
8384 struct cmd_quit_result {
8385 	cmdline_fixed_string_t quit;
8386 };
8387 
8388 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8389 			    struct cmdline *cl,
8390 			    __rte_unused void *data)
8391 {
8392 	cmdline_quit(cl);
8393 }
8394 
8395 cmdline_parse_token_string_t cmd_quit_quit =
8396 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8397 
8398 cmdline_parse_inst_t cmd_quit = {
8399 	.f = cmd_quit_parsed,
8400 	.data = NULL,
8401 	.help_str = "quit: Exit application",
8402 	.tokens = {
8403 		(void *)&cmd_quit_quit,
8404 		NULL,
8405 	},
8406 };
8407 
8408 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8409 struct cmd_mac_addr_result {
8410 	cmdline_fixed_string_t mac_addr_cmd;
8411 	cmdline_fixed_string_t what;
8412 	uint16_t port_num;
8413 	struct rte_ether_addr address;
8414 };
8415 
8416 static void cmd_mac_addr_parsed(void *parsed_result,
8417 		__rte_unused struct cmdline *cl,
8418 		__rte_unused void *data)
8419 {
8420 	struct cmd_mac_addr_result *res = parsed_result;
8421 	int ret;
8422 
8423 	if (strcmp(res->what, "add") == 0)
8424 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8425 	else if (strcmp(res->what, "set") == 0)
8426 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8427 						       &res->address);
8428 	else
8429 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8430 
8431 	/* check the return value and print it if is < 0 */
8432 	if(ret < 0)
8433 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8434 
8435 }
8436 
8437 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8438 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8439 				"mac_addr");
8440 cmdline_parse_token_string_t cmd_mac_addr_what =
8441 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8442 				"add#remove#set");
8443 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8444 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8445 					RTE_UINT16);
8446 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8447 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8448 
8449 cmdline_parse_inst_t cmd_mac_addr = {
8450 	.f = cmd_mac_addr_parsed,
8451 	.data = (void *)0,
8452 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8453 			"Add/Remove/Set MAC address on port_id",
8454 	.tokens = {
8455 		(void *)&cmd_mac_addr_cmd,
8456 		(void *)&cmd_mac_addr_what,
8457 		(void *)&cmd_mac_addr_portnum,
8458 		(void *)&cmd_mac_addr_addr,
8459 		NULL,
8460 	},
8461 };
8462 
8463 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8464 struct cmd_eth_peer_result {
8465 	cmdline_fixed_string_t set;
8466 	cmdline_fixed_string_t eth_peer;
8467 	portid_t port_id;
8468 	cmdline_fixed_string_t peer_addr;
8469 };
8470 
8471 static void cmd_set_eth_peer_parsed(void *parsed_result,
8472 			__rte_unused struct cmdline *cl,
8473 			__rte_unused void *data)
8474 {
8475 		struct cmd_eth_peer_result *res = parsed_result;
8476 
8477 		if (test_done == 0) {
8478 			printf("Please stop forwarding first\n");
8479 			return;
8480 		}
8481 		if (!strcmp(res->eth_peer, "eth-peer")) {
8482 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8483 			fwd_config_setup();
8484 		}
8485 }
8486 cmdline_parse_token_string_t cmd_eth_peer_set =
8487 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8488 cmdline_parse_token_string_t cmd_eth_peer =
8489 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8490 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8491 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8492 		RTE_UINT16);
8493 cmdline_parse_token_string_t cmd_eth_peer_addr =
8494 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8495 
8496 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8497 	.f = cmd_set_eth_peer_parsed,
8498 	.data = NULL,
8499 	.help_str = "set eth-peer <port_id> <peer_mac>",
8500 	.tokens = {
8501 		(void *)&cmd_eth_peer_set,
8502 		(void *)&cmd_eth_peer,
8503 		(void *)&cmd_eth_peer_port_id,
8504 		(void *)&cmd_eth_peer_addr,
8505 		NULL,
8506 	},
8507 };
8508 
8509 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8510 struct cmd_set_qmap_result {
8511 	cmdline_fixed_string_t set;
8512 	cmdline_fixed_string_t qmap;
8513 	cmdline_fixed_string_t what;
8514 	portid_t port_id;
8515 	uint16_t queue_id;
8516 	uint8_t map_value;
8517 };
8518 
8519 static void
8520 cmd_set_qmap_parsed(void *parsed_result,
8521 		       __rte_unused struct cmdline *cl,
8522 		       __rte_unused void *data)
8523 {
8524 	struct cmd_set_qmap_result *res = parsed_result;
8525 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8526 
8527 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8528 }
8529 
8530 cmdline_parse_token_string_t cmd_setqmap_set =
8531 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8532 				 set, "set");
8533 cmdline_parse_token_string_t cmd_setqmap_qmap =
8534 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8535 				 qmap, "stat_qmap");
8536 cmdline_parse_token_string_t cmd_setqmap_what =
8537 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8538 				 what, "tx#rx");
8539 cmdline_parse_token_num_t cmd_setqmap_portid =
8540 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8541 			      port_id, RTE_UINT16);
8542 cmdline_parse_token_num_t cmd_setqmap_queueid =
8543 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8544 			      queue_id, RTE_UINT16);
8545 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8546 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8547 			      map_value, RTE_UINT8);
8548 
8549 cmdline_parse_inst_t cmd_set_qmap = {
8550 	.f = cmd_set_qmap_parsed,
8551 	.data = NULL,
8552 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8553 		"Set statistics mapping value on tx|rx queue_id of port_id",
8554 	.tokens = {
8555 		(void *)&cmd_setqmap_set,
8556 		(void *)&cmd_setqmap_qmap,
8557 		(void *)&cmd_setqmap_what,
8558 		(void *)&cmd_setqmap_portid,
8559 		(void *)&cmd_setqmap_queueid,
8560 		(void *)&cmd_setqmap_mapvalue,
8561 		NULL,
8562 	},
8563 };
8564 
8565 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8566 struct cmd_set_xstats_hide_zero_result {
8567 	cmdline_fixed_string_t keyword;
8568 	cmdline_fixed_string_t name;
8569 	cmdline_fixed_string_t on_off;
8570 };
8571 
8572 static void
8573 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8574 			__rte_unused struct cmdline *cl,
8575 			__rte_unused void *data)
8576 {
8577 	struct cmd_set_xstats_hide_zero_result *res;
8578 	uint16_t on_off = 0;
8579 
8580 	res = parsed_result;
8581 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8582 	set_xstats_hide_zero(on_off);
8583 }
8584 
8585 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8586 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8587 				 keyword, "set");
8588 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8589 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8590 				 name, "xstats-hide-zero");
8591 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8592 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8593 				 on_off, "on#off");
8594 
8595 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8596 	.f = cmd_set_xstats_hide_zero_parsed,
8597 	.data = NULL,
8598 	.help_str = "set xstats-hide-zero on|off",
8599 	.tokens = {
8600 		(void *)&cmd_set_xstats_hide_zero_keyword,
8601 		(void *)&cmd_set_xstats_hide_zero_name,
8602 		(void *)&cmd_set_xstats_hide_zero_on_off,
8603 		NULL,
8604 	},
8605 };
8606 
8607 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8608 struct cmd_set_record_core_cycles_result {
8609 	cmdline_fixed_string_t keyword;
8610 	cmdline_fixed_string_t name;
8611 	cmdline_fixed_string_t on_off;
8612 };
8613 
8614 static void
8615 cmd_set_record_core_cycles_parsed(void *parsed_result,
8616 			__rte_unused struct cmdline *cl,
8617 			__rte_unused void *data)
8618 {
8619 	struct cmd_set_record_core_cycles_result *res;
8620 	uint16_t on_off = 0;
8621 
8622 	res = parsed_result;
8623 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8624 	set_record_core_cycles(on_off);
8625 }
8626 
8627 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8628 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8629 				 keyword, "set");
8630 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8631 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8632 				 name, "record-core-cycles");
8633 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8634 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8635 				 on_off, "on#off");
8636 
8637 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8638 	.f = cmd_set_record_core_cycles_parsed,
8639 	.data = NULL,
8640 	.help_str = "set record-core-cycles on|off",
8641 	.tokens = {
8642 		(void *)&cmd_set_record_core_cycles_keyword,
8643 		(void *)&cmd_set_record_core_cycles_name,
8644 		(void *)&cmd_set_record_core_cycles_on_off,
8645 		NULL,
8646 	},
8647 };
8648 
8649 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8650 struct cmd_set_record_burst_stats_result {
8651 	cmdline_fixed_string_t keyword;
8652 	cmdline_fixed_string_t name;
8653 	cmdline_fixed_string_t on_off;
8654 };
8655 
8656 static void
8657 cmd_set_record_burst_stats_parsed(void *parsed_result,
8658 			__rte_unused struct cmdline *cl,
8659 			__rte_unused void *data)
8660 {
8661 	struct cmd_set_record_burst_stats_result *res;
8662 	uint16_t on_off = 0;
8663 
8664 	res = parsed_result;
8665 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8666 	set_record_burst_stats(on_off);
8667 }
8668 
8669 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8670 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8671 				 keyword, "set");
8672 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8673 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8674 				 name, "record-burst-stats");
8675 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8676 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8677 				 on_off, "on#off");
8678 
8679 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8680 	.f = cmd_set_record_burst_stats_parsed,
8681 	.data = NULL,
8682 	.help_str = "set record-burst-stats on|off",
8683 	.tokens = {
8684 		(void *)&cmd_set_record_burst_stats_keyword,
8685 		(void *)&cmd_set_record_burst_stats_name,
8686 		(void *)&cmd_set_record_burst_stats_on_off,
8687 		NULL,
8688 	},
8689 };
8690 
8691 /* *** CONFIGURE UNICAST HASH TABLE *** */
8692 struct cmd_set_uc_hash_table {
8693 	cmdline_fixed_string_t set;
8694 	cmdline_fixed_string_t port;
8695 	portid_t port_id;
8696 	cmdline_fixed_string_t what;
8697 	struct rte_ether_addr address;
8698 	cmdline_fixed_string_t mode;
8699 };
8700 
8701 static void
8702 cmd_set_uc_hash_parsed(void *parsed_result,
8703 		       __rte_unused struct cmdline *cl,
8704 		       __rte_unused void *data)
8705 {
8706 	int ret=0;
8707 	struct cmd_set_uc_hash_table *res = parsed_result;
8708 
8709 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8710 
8711 	if (strcmp(res->what, "uta") == 0)
8712 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8713 						&res->address,(uint8_t)is_on);
8714 	if (ret < 0)
8715 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8716 
8717 }
8718 
8719 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8720 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8721 				 set, "set");
8722 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8723 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8724 				 port, "port");
8725 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8726 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8727 			      port_id, RTE_UINT16);
8728 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8729 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8730 				 what, "uta");
8731 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8732 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8733 				address);
8734 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8735 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8736 				 mode, "on#off");
8737 
8738 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8739 	.f = cmd_set_uc_hash_parsed,
8740 	.data = NULL,
8741 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8742 	.tokens = {
8743 		(void *)&cmd_set_uc_hash_set,
8744 		(void *)&cmd_set_uc_hash_port,
8745 		(void *)&cmd_set_uc_hash_portid,
8746 		(void *)&cmd_set_uc_hash_what,
8747 		(void *)&cmd_set_uc_hash_mac,
8748 		(void *)&cmd_set_uc_hash_mode,
8749 		NULL,
8750 	},
8751 };
8752 
8753 struct cmd_set_uc_all_hash_table {
8754 	cmdline_fixed_string_t set;
8755 	cmdline_fixed_string_t port;
8756 	portid_t port_id;
8757 	cmdline_fixed_string_t what;
8758 	cmdline_fixed_string_t value;
8759 	cmdline_fixed_string_t mode;
8760 };
8761 
8762 static void
8763 cmd_set_uc_all_hash_parsed(void *parsed_result,
8764 		       __rte_unused struct cmdline *cl,
8765 		       __rte_unused void *data)
8766 {
8767 	int ret=0;
8768 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8769 
8770 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8771 
8772 	if ((strcmp(res->what, "uta") == 0) &&
8773 		(strcmp(res->value, "all") == 0))
8774 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8775 	if (ret < 0)
8776 		printf("bad unicast hash table parameter,"
8777 			"return code = %d \n", ret);
8778 }
8779 
8780 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8781 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8782 				 set, "set");
8783 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8784 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8785 				 port, "port");
8786 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8787 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8788 			      port_id, RTE_UINT16);
8789 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8790 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8791 				 what, "uta");
8792 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8793 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8794 				value,"all");
8795 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8796 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8797 				 mode, "on#off");
8798 
8799 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8800 	.f = cmd_set_uc_all_hash_parsed,
8801 	.data = NULL,
8802 	.help_str = "set port <port_id> uta all on|off",
8803 	.tokens = {
8804 		(void *)&cmd_set_uc_all_hash_set,
8805 		(void *)&cmd_set_uc_all_hash_port,
8806 		(void *)&cmd_set_uc_all_hash_portid,
8807 		(void *)&cmd_set_uc_all_hash_what,
8808 		(void *)&cmd_set_uc_all_hash_value,
8809 		(void *)&cmd_set_uc_all_hash_mode,
8810 		NULL,
8811 	},
8812 };
8813 
8814 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8815 struct cmd_set_vf_traffic {
8816 	cmdline_fixed_string_t set;
8817 	cmdline_fixed_string_t port;
8818 	portid_t port_id;
8819 	cmdline_fixed_string_t vf;
8820 	uint8_t vf_id;
8821 	cmdline_fixed_string_t what;
8822 	cmdline_fixed_string_t mode;
8823 };
8824 
8825 static void
8826 cmd_set_vf_traffic_parsed(void *parsed_result,
8827 		       __rte_unused struct cmdline *cl,
8828 		       __rte_unused void *data)
8829 {
8830 	struct cmd_set_vf_traffic *res = parsed_result;
8831 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8832 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8833 
8834 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8835 }
8836 
8837 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8838 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8839 				 set, "set");
8840 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8841 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8842 				 port, "port");
8843 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8844 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8845 			      port_id, RTE_UINT16);
8846 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8847 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8848 				 vf, "vf");
8849 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8850 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8851 			      vf_id, RTE_UINT8);
8852 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8853 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8854 				 what, "tx#rx");
8855 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8856 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8857 				 mode, "on#off");
8858 
8859 cmdline_parse_inst_t cmd_set_vf_traffic = {
8860 	.f = cmd_set_vf_traffic_parsed,
8861 	.data = NULL,
8862 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8863 	.tokens = {
8864 		(void *)&cmd_setvf_traffic_set,
8865 		(void *)&cmd_setvf_traffic_port,
8866 		(void *)&cmd_setvf_traffic_portid,
8867 		(void *)&cmd_setvf_traffic_vf,
8868 		(void *)&cmd_setvf_traffic_vfid,
8869 		(void *)&cmd_setvf_traffic_what,
8870 		(void *)&cmd_setvf_traffic_mode,
8871 		NULL,
8872 	},
8873 };
8874 
8875 /* *** CONFIGURE VF RECEIVE MODE *** */
8876 struct cmd_set_vf_rxmode {
8877 	cmdline_fixed_string_t set;
8878 	cmdline_fixed_string_t port;
8879 	portid_t port_id;
8880 	cmdline_fixed_string_t vf;
8881 	uint8_t vf_id;
8882 	cmdline_fixed_string_t what;
8883 	cmdline_fixed_string_t mode;
8884 	cmdline_fixed_string_t on;
8885 };
8886 
8887 static void
8888 cmd_set_vf_rxmode_parsed(void *parsed_result,
8889 		       __rte_unused struct cmdline *cl,
8890 		       __rte_unused void *data)
8891 {
8892 	int ret = -ENOTSUP;
8893 	uint16_t vf_rxmode = 0;
8894 	struct cmd_set_vf_rxmode *res = parsed_result;
8895 
8896 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8897 	if (!strcmp(res->what,"rxmode")) {
8898 		if (!strcmp(res->mode, "AUPE"))
8899 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8900 		else if (!strcmp(res->mode, "ROPE"))
8901 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8902 		else if (!strcmp(res->mode, "BAM"))
8903 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8904 		else if (!strncmp(res->mode, "MPE",3))
8905 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8906 	}
8907 
8908 	RTE_SET_USED(is_on);
8909 
8910 #ifdef RTE_NET_IXGBE
8911 	if (ret == -ENOTSUP)
8912 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8913 						  vf_rxmode, (uint8_t)is_on);
8914 #endif
8915 #ifdef RTE_NET_BNXT
8916 	if (ret == -ENOTSUP)
8917 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8918 						 vf_rxmode, (uint8_t)is_on);
8919 #endif
8920 	if (ret < 0)
8921 		printf("bad VF receive mode parameter, return code = %d \n",
8922 		ret);
8923 }
8924 
8925 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8926 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8927 				 set, "set");
8928 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8929 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8930 				 port, "port");
8931 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8932 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8933 			      port_id, RTE_UINT16);
8934 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8935 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8936 				 vf, "vf");
8937 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8938 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8939 			      vf_id, RTE_UINT8);
8940 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8941 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8942 				 what, "rxmode");
8943 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8944 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8945 				 mode, "AUPE#ROPE#BAM#MPE");
8946 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8947 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8948 				 on, "on#off");
8949 
8950 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8951 	.f = cmd_set_vf_rxmode_parsed,
8952 	.data = NULL,
8953 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8954 		"AUPE|ROPE|BAM|MPE on|off",
8955 	.tokens = {
8956 		(void *)&cmd_set_vf_rxmode_set,
8957 		(void *)&cmd_set_vf_rxmode_port,
8958 		(void *)&cmd_set_vf_rxmode_portid,
8959 		(void *)&cmd_set_vf_rxmode_vf,
8960 		(void *)&cmd_set_vf_rxmode_vfid,
8961 		(void *)&cmd_set_vf_rxmode_what,
8962 		(void *)&cmd_set_vf_rxmode_mode,
8963 		(void *)&cmd_set_vf_rxmode_on,
8964 		NULL,
8965 	},
8966 };
8967 
8968 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8969 struct cmd_vf_mac_addr_result {
8970 	cmdline_fixed_string_t mac_addr_cmd;
8971 	cmdline_fixed_string_t what;
8972 	cmdline_fixed_string_t port;
8973 	uint16_t port_num;
8974 	cmdline_fixed_string_t vf;
8975 	uint8_t vf_num;
8976 	struct rte_ether_addr address;
8977 };
8978 
8979 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8980 		__rte_unused struct cmdline *cl,
8981 		__rte_unused void *data)
8982 {
8983 	struct cmd_vf_mac_addr_result *res = parsed_result;
8984 	int ret = -ENOTSUP;
8985 
8986 	if (strcmp(res->what, "add") != 0)
8987 		return;
8988 
8989 #ifdef RTE_NET_I40E
8990 	if (ret == -ENOTSUP)
8991 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8992 						   &res->address);
8993 #endif
8994 #ifdef RTE_NET_BNXT
8995 	if (ret == -ENOTSUP)
8996 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8997 						res->vf_num);
8998 #endif
8999 
9000 	if(ret < 0)
9001 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9002 
9003 }
9004 
9005 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9006 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9007 				mac_addr_cmd,"mac_addr");
9008 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9009 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9010 				what,"add");
9011 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9012 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9013 				port,"port");
9014 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9015 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9016 				port_num, RTE_UINT16);
9017 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9018 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9019 				vf,"vf");
9020 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9021 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9022 				vf_num, RTE_UINT8);
9023 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9024 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9025 				address);
9026 
9027 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9028 	.f = cmd_vf_mac_addr_parsed,
9029 	.data = (void *)0,
9030 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9031 		"Add MAC address filtering for a VF on port_id",
9032 	.tokens = {
9033 		(void *)&cmd_vf_mac_addr_cmd,
9034 		(void *)&cmd_vf_mac_addr_what,
9035 		(void *)&cmd_vf_mac_addr_port,
9036 		(void *)&cmd_vf_mac_addr_portnum,
9037 		(void *)&cmd_vf_mac_addr_vf,
9038 		(void *)&cmd_vf_mac_addr_vfnum,
9039 		(void *)&cmd_vf_mac_addr_addr,
9040 		NULL,
9041 	},
9042 };
9043 
9044 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9045 struct cmd_vf_rx_vlan_filter {
9046 	cmdline_fixed_string_t rx_vlan;
9047 	cmdline_fixed_string_t what;
9048 	uint16_t vlan_id;
9049 	cmdline_fixed_string_t port;
9050 	portid_t port_id;
9051 	cmdline_fixed_string_t vf;
9052 	uint64_t vf_mask;
9053 };
9054 
9055 static void
9056 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9057 			  __rte_unused struct cmdline *cl,
9058 			  __rte_unused void *data)
9059 {
9060 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
9061 	int ret = -ENOTSUP;
9062 
9063 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9064 
9065 #ifdef RTE_NET_IXGBE
9066 	if (ret == -ENOTSUP)
9067 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9068 				res->vlan_id, res->vf_mask, is_add);
9069 #endif
9070 #ifdef RTE_NET_I40E
9071 	if (ret == -ENOTSUP)
9072 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9073 				res->vlan_id, res->vf_mask, is_add);
9074 #endif
9075 #ifdef RTE_NET_BNXT
9076 	if (ret == -ENOTSUP)
9077 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9078 				res->vlan_id, res->vf_mask, is_add);
9079 #endif
9080 
9081 	switch (ret) {
9082 	case 0:
9083 		break;
9084 	case -EINVAL:
9085 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9086 				res->vlan_id, res->vf_mask);
9087 		break;
9088 	case -ENODEV:
9089 		printf("invalid port_id %d\n", res->port_id);
9090 		break;
9091 	case -ENOTSUP:
9092 		printf("function not implemented or supported\n");
9093 		break;
9094 	default:
9095 		printf("programming error: (%s)\n", strerror(-ret));
9096 	}
9097 }
9098 
9099 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9100 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9101 				 rx_vlan, "rx_vlan");
9102 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9103 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9104 				 what, "add#rm");
9105 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9106 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9107 			      vlan_id, RTE_UINT16);
9108 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9109 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9110 				 port, "port");
9111 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9112 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9113 			      port_id, RTE_UINT16);
9114 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9115 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9116 				 vf, "vf");
9117 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9118 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9119 			      vf_mask, RTE_UINT64);
9120 
9121 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9122 	.f = cmd_vf_rx_vlan_filter_parsed,
9123 	.data = NULL,
9124 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9125 		"(vf_mask = hexadecimal VF mask)",
9126 	.tokens = {
9127 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9128 		(void *)&cmd_vf_rx_vlan_filter_what,
9129 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
9130 		(void *)&cmd_vf_rx_vlan_filter_port,
9131 		(void *)&cmd_vf_rx_vlan_filter_portid,
9132 		(void *)&cmd_vf_rx_vlan_filter_vf,
9133 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
9134 		NULL,
9135 	},
9136 };
9137 
9138 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9139 struct cmd_queue_rate_limit_result {
9140 	cmdline_fixed_string_t set;
9141 	cmdline_fixed_string_t port;
9142 	uint16_t port_num;
9143 	cmdline_fixed_string_t queue;
9144 	uint8_t queue_num;
9145 	cmdline_fixed_string_t rate;
9146 	uint16_t rate_num;
9147 };
9148 
9149 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9150 		__rte_unused struct cmdline *cl,
9151 		__rte_unused void *data)
9152 {
9153 	struct cmd_queue_rate_limit_result *res = parsed_result;
9154 	int ret = 0;
9155 
9156 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9157 		&& (strcmp(res->queue, "queue") == 0)
9158 		&& (strcmp(res->rate, "rate") == 0))
9159 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
9160 					res->rate_num);
9161 	if (ret < 0)
9162 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9163 
9164 }
9165 
9166 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9167 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9168 				set, "set");
9169 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9170 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9171 				port, "port");
9172 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9173 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9174 				port_num, RTE_UINT16);
9175 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9176 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9177 				queue, "queue");
9178 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9179 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9180 				queue_num, RTE_UINT8);
9181 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9182 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9183 				rate, "rate");
9184 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9185 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9186 				rate_num, RTE_UINT16);
9187 
9188 cmdline_parse_inst_t cmd_queue_rate_limit = {
9189 	.f = cmd_queue_rate_limit_parsed,
9190 	.data = (void *)0,
9191 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9192 		"Set rate limit for a queue on port_id",
9193 	.tokens = {
9194 		(void *)&cmd_queue_rate_limit_set,
9195 		(void *)&cmd_queue_rate_limit_port,
9196 		(void *)&cmd_queue_rate_limit_portnum,
9197 		(void *)&cmd_queue_rate_limit_queue,
9198 		(void *)&cmd_queue_rate_limit_queuenum,
9199 		(void *)&cmd_queue_rate_limit_rate,
9200 		(void *)&cmd_queue_rate_limit_ratenum,
9201 		NULL,
9202 	},
9203 };
9204 
9205 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9206 struct cmd_vf_rate_limit_result {
9207 	cmdline_fixed_string_t set;
9208 	cmdline_fixed_string_t port;
9209 	uint16_t port_num;
9210 	cmdline_fixed_string_t vf;
9211 	uint8_t vf_num;
9212 	cmdline_fixed_string_t rate;
9213 	uint16_t rate_num;
9214 	cmdline_fixed_string_t q_msk;
9215 	uint64_t q_msk_val;
9216 };
9217 
9218 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9219 		__rte_unused struct cmdline *cl,
9220 		__rte_unused void *data)
9221 {
9222 	struct cmd_vf_rate_limit_result *res = parsed_result;
9223 	int ret = 0;
9224 
9225 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9226 		&& (strcmp(res->vf, "vf") == 0)
9227 		&& (strcmp(res->rate, "rate") == 0)
9228 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9229 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9230 					res->rate_num, res->q_msk_val);
9231 	if (ret < 0)
9232 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9233 
9234 }
9235 
9236 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9237 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9238 				set, "set");
9239 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9240 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9241 				port, "port");
9242 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9243 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9244 				port_num, RTE_UINT16);
9245 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9246 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9247 				vf, "vf");
9248 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9249 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9250 				vf_num, RTE_UINT8);
9251 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9252 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9253 				rate, "rate");
9254 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9255 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9256 				rate_num, RTE_UINT16);
9257 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9258 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9259 				q_msk, "queue_mask");
9260 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9261 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9262 				q_msk_val, RTE_UINT64);
9263 
9264 cmdline_parse_inst_t cmd_vf_rate_limit = {
9265 	.f = cmd_vf_rate_limit_parsed,
9266 	.data = (void *)0,
9267 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9268 		"queue_mask <queue_mask_value>: "
9269 		"Set rate limit for queues of VF on port_id",
9270 	.tokens = {
9271 		(void *)&cmd_vf_rate_limit_set,
9272 		(void *)&cmd_vf_rate_limit_port,
9273 		(void *)&cmd_vf_rate_limit_portnum,
9274 		(void *)&cmd_vf_rate_limit_vf,
9275 		(void *)&cmd_vf_rate_limit_vfnum,
9276 		(void *)&cmd_vf_rate_limit_rate,
9277 		(void *)&cmd_vf_rate_limit_ratenum,
9278 		(void *)&cmd_vf_rate_limit_q_msk,
9279 		(void *)&cmd_vf_rate_limit_q_msk_val,
9280 		NULL,
9281 	},
9282 };
9283 
9284 /* *** CONFIGURE TUNNEL UDP PORT *** */
9285 struct cmd_tunnel_udp_config {
9286 	cmdline_fixed_string_t rx_vxlan_port;
9287 	cmdline_fixed_string_t what;
9288 	uint16_t udp_port;
9289 	portid_t port_id;
9290 };
9291 
9292 static void
9293 cmd_tunnel_udp_config_parsed(void *parsed_result,
9294 			  __rte_unused struct cmdline *cl,
9295 			  __rte_unused void *data)
9296 {
9297 	struct cmd_tunnel_udp_config *res = parsed_result;
9298 	struct rte_eth_udp_tunnel tunnel_udp;
9299 	int ret;
9300 
9301 	tunnel_udp.udp_port = res->udp_port;
9302 	tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9303 
9304 	if (!strcmp(res->what, "add"))
9305 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9306 						      &tunnel_udp);
9307 	else
9308 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9309 							 &tunnel_udp);
9310 
9311 	if (ret < 0)
9312 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9313 }
9314 
9315 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9316 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9317 				rx_vxlan_port, "rx_vxlan_port");
9318 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9319 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9320 				what, "add#rm");
9321 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9322 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9323 				udp_port, RTE_UINT16);
9324 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9325 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9326 				port_id, RTE_UINT16);
9327 
9328 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9329 	.f = cmd_tunnel_udp_config_parsed,
9330 	.data = (void *)0,
9331 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9332 		"Add/Remove a tunneling UDP port filter",
9333 	.tokens = {
9334 		(void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9335 		(void *)&cmd_tunnel_udp_config_what,
9336 		(void *)&cmd_tunnel_udp_config_udp_port,
9337 		(void *)&cmd_tunnel_udp_config_port_id,
9338 		NULL,
9339 	},
9340 };
9341 
9342 struct cmd_config_tunnel_udp_port {
9343 	cmdline_fixed_string_t port;
9344 	cmdline_fixed_string_t config;
9345 	portid_t port_id;
9346 	cmdline_fixed_string_t udp_tunnel_port;
9347 	cmdline_fixed_string_t action;
9348 	cmdline_fixed_string_t tunnel_type;
9349 	uint16_t udp_port;
9350 };
9351 
9352 static void
9353 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9354 			       __rte_unused struct cmdline *cl,
9355 			       __rte_unused void *data)
9356 {
9357 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9358 	struct rte_eth_udp_tunnel tunnel_udp;
9359 	int ret = 0;
9360 
9361 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9362 		return;
9363 
9364 	tunnel_udp.udp_port = res->udp_port;
9365 
9366 	if (!strcmp(res->tunnel_type, "vxlan")) {
9367 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9368 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9369 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9370 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9371 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9372 	} else if (!strcmp(res->tunnel_type, "ecpri")) {
9373 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9374 	} else {
9375 		printf("Invalid tunnel type\n");
9376 		return;
9377 	}
9378 
9379 	if (!strcmp(res->action, "add"))
9380 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9381 						      &tunnel_udp);
9382 	else
9383 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9384 							 &tunnel_udp);
9385 
9386 	if (ret < 0)
9387 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9388 }
9389 
9390 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9391 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9392 				 "port");
9393 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9394 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9395 				 "config");
9396 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9397 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9398 			      RTE_UINT16);
9399 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9400 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9401 				 udp_tunnel_port,
9402 				 "udp_tunnel_port");
9403 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9404 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9405 				 "add#rm");
9406 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9407 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9408 				 "vxlan#geneve#vxlan-gpe#ecpri");
9409 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9410 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9411 			      RTE_UINT16);
9412 
9413 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9414 	.f = cmd_cfg_tunnel_udp_port_parsed,
9415 	.data = NULL,
9416 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9417 		"geneve|vxlan-gpe|ecpri <udp_port>",
9418 	.tokens = {
9419 		(void *)&cmd_config_tunnel_udp_port_port,
9420 		(void *)&cmd_config_tunnel_udp_port_config,
9421 		(void *)&cmd_config_tunnel_udp_port_port_id,
9422 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9423 		(void *)&cmd_config_tunnel_udp_port_action,
9424 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9425 		(void *)&cmd_config_tunnel_udp_port_value,
9426 		NULL,
9427 	},
9428 };
9429 
9430 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9431 struct cmd_set_mirror_mask_result {
9432 	cmdline_fixed_string_t set;
9433 	cmdline_fixed_string_t port;
9434 	portid_t port_id;
9435 	cmdline_fixed_string_t mirror;
9436 	uint8_t rule_id;
9437 	cmdline_fixed_string_t what;
9438 	cmdline_fixed_string_t value;
9439 	cmdline_fixed_string_t dstpool;
9440 	uint8_t dstpool_id;
9441 	cmdline_fixed_string_t on;
9442 };
9443 
9444 cmdline_parse_token_string_t cmd_mirror_mask_set =
9445 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9446 				set, "set");
9447 cmdline_parse_token_string_t cmd_mirror_mask_port =
9448 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9449 				port, "port");
9450 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9451 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9452 				port_id, RTE_UINT16);
9453 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9454 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9455 				mirror, "mirror-rule");
9456 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9457 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9458 				rule_id, RTE_UINT8);
9459 cmdline_parse_token_string_t cmd_mirror_mask_what =
9460 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9461 				what, "pool-mirror-up#pool-mirror-down"
9462 				      "#vlan-mirror");
9463 cmdline_parse_token_string_t cmd_mirror_mask_value =
9464 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9465 				value, NULL);
9466 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9467 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9468 				dstpool, "dst-pool");
9469 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9470 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9471 				dstpool_id, RTE_UINT8);
9472 cmdline_parse_token_string_t cmd_mirror_mask_on =
9473 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9474 				on, "on#off");
9475 
9476 static void
9477 cmd_set_mirror_mask_parsed(void *parsed_result,
9478 		       __rte_unused struct cmdline *cl,
9479 		       __rte_unused void *data)
9480 {
9481 	int ret,nb_item,i;
9482 	struct cmd_set_mirror_mask_result *res = parsed_result;
9483 	struct rte_eth_mirror_conf mr_conf;
9484 
9485 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9486 
9487 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9488 
9489 	mr_conf.dst_pool = res->dstpool_id;
9490 
9491 	if (!strcmp(res->what, "pool-mirror-up")) {
9492 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9493 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9494 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9495 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9496 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9497 	} else if (!strcmp(res->what, "vlan-mirror")) {
9498 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9499 		nb_item = parse_item_list(res->value, "vlan",
9500 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9501 		if (nb_item <= 0)
9502 			return;
9503 
9504 		for (i = 0; i < nb_item; i++) {
9505 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9506 				printf("Invalid vlan_id: must be < 4096\n");
9507 				return;
9508 			}
9509 
9510 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9511 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9512 		}
9513 	}
9514 
9515 	if (!strcmp(res->on, "on"))
9516 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9517 						res->rule_id, 1);
9518 	else
9519 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9520 						res->rule_id, 0);
9521 	if (ret < 0)
9522 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9523 }
9524 
9525 cmdline_parse_inst_t cmd_set_mirror_mask = {
9526 		.f = cmd_set_mirror_mask_parsed,
9527 		.data = NULL,
9528 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9529 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9530 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9531 		.tokens = {
9532 			(void *)&cmd_mirror_mask_set,
9533 			(void *)&cmd_mirror_mask_port,
9534 			(void *)&cmd_mirror_mask_portid,
9535 			(void *)&cmd_mirror_mask_mirror,
9536 			(void *)&cmd_mirror_mask_ruleid,
9537 			(void *)&cmd_mirror_mask_what,
9538 			(void *)&cmd_mirror_mask_value,
9539 			(void *)&cmd_mirror_mask_dstpool,
9540 			(void *)&cmd_mirror_mask_poolid,
9541 			(void *)&cmd_mirror_mask_on,
9542 			NULL,
9543 		},
9544 };
9545 
9546 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9547 struct cmd_set_mirror_link_result {
9548 	cmdline_fixed_string_t set;
9549 	cmdline_fixed_string_t port;
9550 	portid_t port_id;
9551 	cmdline_fixed_string_t mirror;
9552 	uint8_t rule_id;
9553 	cmdline_fixed_string_t what;
9554 	cmdline_fixed_string_t dstpool;
9555 	uint8_t dstpool_id;
9556 	cmdline_fixed_string_t on;
9557 };
9558 
9559 cmdline_parse_token_string_t cmd_mirror_link_set =
9560 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9561 				 set, "set");
9562 cmdline_parse_token_string_t cmd_mirror_link_port =
9563 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9564 				port, "port");
9565 cmdline_parse_token_num_t cmd_mirror_link_portid =
9566 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9567 				port_id, RTE_UINT16);
9568 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9569 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9570 				mirror, "mirror-rule");
9571 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9572 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9573 			    rule_id, RTE_UINT8);
9574 cmdline_parse_token_string_t cmd_mirror_link_what =
9575 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9576 				what, "uplink-mirror#downlink-mirror");
9577 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9578 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9579 				dstpool, "dst-pool");
9580 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9581 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9582 				dstpool_id, RTE_UINT8);
9583 cmdline_parse_token_string_t cmd_mirror_link_on =
9584 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9585 				on, "on#off");
9586 
9587 static void
9588 cmd_set_mirror_link_parsed(void *parsed_result,
9589 		       __rte_unused struct cmdline *cl,
9590 		       __rte_unused void *data)
9591 {
9592 	int ret;
9593 	struct cmd_set_mirror_link_result *res = parsed_result;
9594 	struct rte_eth_mirror_conf mr_conf;
9595 
9596 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9597 	if (!strcmp(res->what, "uplink-mirror"))
9598 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9599 	else
9600 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9601 
9602 	mr_conf.dst_pool = res->dstpool_id;
9603 
9604 	if (!strcmp(res->on, "on"))
9605 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9606 						res->rule_id, 1);
9607 	else
9608 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9609 						res->rule_id, 0);
9610 
9611 	/* check the return value and print it if is < 0 */
9612 	if (ret < 0)
9613 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9614 
9615 }
9616 
9617 cmdline_parse_inst_t cmd_set_mirror_link = {
9618 		.f = cmd_set_mirror_link_parsed,
9619 		.data = NULL,
9620 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9621 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9622 		.tokens = {
9623 			(void *)&cmd_mirror_link_set,
9624 			(void *)&cmd_mirror_link_port,
9625 			(void *)&cmd_mirror_link_portid,
9626 			(void *)&cmd_mirror_link_mirror,
9627 			(void *)&cmd_mirror_link_ruleid,
9628 			(void *)&cmd_mirror_link_what,
9629 			(void *)&cmd_mirror_link_dstpool,
9630 			(void *)&cmd_mirror_link_poolid,
9631 			(void *)&cmd_mirror_link_on,
9632 			NULL,
9633 		},
9634 };
9635 
9636 /* *** RESET VM MIRROR RULE *** */
9637 struct cmd_rm_mirror_rule_result {
9638 	cmdline_fixed_string_t reset;
9639 	cmdline_fixed_string_t port;
9640 	portid_t port_id;
9641 	cmdline_fixed_string_t mirror;
9642 	uint8_t rule_id;
9643 };
9644 
9645 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9646 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9647 				 reset, "reset");
9648 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9649 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9650 				port, "port");
9651 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9652 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9653 				port_id, RTE_UINT16);
9654 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9655 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9656 				mirror, "mirror-rule");
9657 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9658 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9659 				rule_id, RTE_UINT8);
9660 
9661 static void
9662 cmd_reset_mirror_rule_parsed(void *parsed_result,
9663 		       __rte_unused struct cmdline *cl,
9664 		       __rte_unused void *data)
9665 {
9666 	int ret;
9667 	struct cmd_set_mirror_link_result *res = parsed_result;
9668         /* check rule_id */
9669 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9670 	if(ret < 0)
9671 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9672 }
9673 
9674 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9675 		.f = cmd_reset_mirror_rule_parsed,
9676 		.data = NULL,
9677 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9678 		.tokens = {
9679 			(void *)&cmd_rm_mirror_rule_reset,
9680 			(void *)&cmd_rm_mirror_rule_port,
9681 			(void *)&cmd_rm_mirror_rule_portid,
9682 			(void *)&cmd_rm_mirror_rule_mirror,
9683 			(void *)&cmd_rm_mirror_rule_ruleid,
9684 			NULL,
9685 		},
9686 };
9687 
9688 /* ******************************************************************************** */
9689 
9690 struct cmd_dump_result {
9691 	cmdline_fixed_string_t dump;
9692 };
9693 
9694 static void
9695 dump_struct_sizes(void)
9696 {
9697 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9698 	DUMP_SIZE(struct rte_mbuf);
9699 	DUMP_SIZE(struct rte_mempool);
9700 	DUMP_SIZE(struct rte_ring);
9701 #undef DUMP_SIZE
9702 }
9703 
9704 
9705 /* Dump the socket memory statistics on console */
9706 static void
9707 dump_socket_mem(FILE *f)
9708 {
9709 	struct rte_malloc_socket_stats socket_stats;
9710 	unsigned int i;
9711 	size_t total = 0;
9712 	size_t alloc = 0;
9713 	size_t free = 0;
9714 	unsigned int n_alloc = 0;
9715 	unsigned int n_free = 0;
9716 	static size_t last_allocs;
9717 	static size_t last_total;
9718 
9719 
9720 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9721 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9722 		    !socket_stats.heap_totalsz_bytes)
9723 			continue;
9724 		total += socket_stats.heap_totalsz_bytes;
9725 		alloc += socket_stats.heap_allocsz_bytes;
9726 		free += socket_stats.heap_freesz_bytes;
9727 		n_alloc += socket_stats.alloc_count;
9728 		n_free += socket_stats.free_count;
9729 		fprintf(f,
9730 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9731 			i,
9732 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9733 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9734 			(double)socket_stats.heap_allocsz_bytes * 100 /
9735 			(double)socket_stats.heap_totalsz_bytes,
9736 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9737 			socket_stats.alloc_count,
9738 			socket_stats.free_count);
9739 	}
9740 	fprintf(f,
9741 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9742 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9743 		total ? ((double)alloc * 100 / (double)total) : 0,
9744 		(double)free / (1024 * 1024),
9745 		n_alloc, n_free);
9746 	if (last_allocs)
9747 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9748 			((double)total - (double)last_total) / (1024 * 1024),
9749 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9750 	last_allocs = alloc;
9751 	last_total = total;
9752 }
9753 
9754 static void cmd_dump_parsed(void *parsed_result,
9755 			    __rte_unused struct cmdline *cl,
9756 			    __rte_unused void *data)
9757 {
9758 	struct cmd_dump_result *res = parsed_result;
9759 
9760 	if (!strcmp(res->dump, "dump_physmem"))
9761 		rte_dump_physmem_layout(stdout);
9762 	else if (!strcmp(res->dump, "dump_socket_mem"))
9763 		dump_socket_mem(stdout);
9764 	else if (!strcmp(res->dump, "dump_memzone"))
9765 		rte_memzone_dump(stdout);
9766 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9767 		dump_struct_sizes();
9768 	else if (!strcmp(res->dump, "dump_ring"))
9769 		rte_ring_list_dump(stdout);
9770 	else if (!strcmp(res->dump, "dump_mempool"))
9771 		rte_mempool_list_dump(stdout);
9772 	else if (!strcmp(res->dump, "dump_devargs"))
9773 		rte_devargs_dump(stdout);
9774 	else if (!strcmp(res->dump, "dump_log_types"))
9775 		rte_log_dump(stdout);
9776 }
9777 
9778 cmdline_parse_token_string_t cmd_dump_dump =
9779 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9780 		"dump_physmem#"
9781 		"dump_memzone#"
9782 		"dump_socket_mem#"
9783 		"dump_struct_sizes#"
9784 		"dump_ring#"
9785 		"dump_mempool#"
9786 		"dump_devargs#"
9787 		"dump_log_types");
9788 
9789 cmdline_parse_inst_t cmd_dump = {
9790 	.f = cmd_dump_parsed,  /* function to call */
9791 	.data = NULL,      /* 2nd arg of func */
9792 	.help_str = "Dump status",
9793 	.tokens = {        /* token list, NULL terminated */
9794 		(void *)&cmd_dump_dump,
9795 		NULL,
9796 	},
9797 };
9798 
9799 /* ******************************************************************************** */
9800 
9801 struct cmd_dump_one_result {
9802 	cmdline_fixed_string_t dump;
9803 	cmdline_fixed_string_t name;
9804 };
9805 
9806 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9807 				__rte_unused void *data)
9808 {
9809 	struct cmd_dump_one_result *res = parsed_result;
9810 
9811 	if (!strcmp(res->dump, "dump_ring")) {
9812 		struct rte_ring *r;
9813 		r = rte_ring_lookup(res->name);
9814 		if (r == NULL) {
9815 			cmdline_printf(cl, "Cannot find ring\n");
9816 			return;
9817 		}
9818 		rte_ring_dump(stdout, r);
9819 	} else if (!strcmp(res->dump, "dump_mempool")) {
9820 		struct rte_mempool *mp;
9821 		mp = rte_mempool_lookup(res->name);
9822 		if (mp == NULL) {
9823 			cmdline_printf(cl, "Cannot find mempool\n");
9824 			return;
9825 		}
9826 		rte_mempool_dump(stdout, mp);
9827 	}
9828 }
9829 
9830 cmdline_parse_token_string_t cmd_dump_one_dump =
9831 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9832 				 "dump_ring#dump_mempool");
9833 
9834 cmdline_parse_token_string_t cmd_dump_one_name =
9835 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9836 
9837 cmdline_parse_inst_t cmd_dump_one = {
9838 	.f = cmd_dump_one_parsed,  /* function to call */
9839 	.data = NULL,      /* 2nd arg of func */
9840 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9841 	.tokens = {        /* token list, NULL terminated */
9842 		(void *)&cmd_dump_one_dump,
9843 		(void *)&cmd_dump_one_name,
9844 		NULL,
9845 	},
9846 };
9847 
9848 /* *** queue region set *** */
9849 struct cmd_queue_region_result {
9850 	cmdline_fixed_string_t set;
9851 	cmdline_fixed_string_t port;
9852 	portid_t port_id;
9853 	cmdline_fixed_string_t cmd;
9854 	cmdline_fixed_string_t region;
9855 	uint8_t  region_id;
9856 	cmdline_fixed_string_t queue_start_index;
9857 	uint8_t  queue_id;
9858 	cmdline_fixed_string_t queue_num;
9859 	uint8_t  queue_num_value;
9860 };
9861 
9862 static void
9863 cmd_queue_region_parsed(void *parsed_result,
9864 			__rte_unused struct cmdline *cl,
9865 			__rte_unused void *data)
9866 {
9867 	struct cmd_queue_region_result *res = parsed_result;
9868 	int ret = -ENOTSUP;
9869 #ifdef RTE_NET_I40E
9870 	struct rte_pmd_i40e_queue_region_conf region_conf;
9871 	enum rte_pmd_i40e_queue_region_op op_type;
9872 #endif
9873 
9874 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9875 		return;
9876 
9877 #ifdef RTE_NET_I40E
9878 	memset(&region_conf, 0, sizeof(region_conf));
9879 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9880 	region_conf.region_id = res->region_id;
9881 	region_conf.queue_num = res->queue_num_value;
9882 	region_conf.queue_start_index = res->queue_id;
9883 
9884 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9885 				op_type, &region_conf);
9886 #endif
9887 
9888 	switch (ret) {
9889 	case 0:
9890 		break;
9891 	case -ENOTSUP:
9892 		printf("function not implemented or supported\n");
9893 		break;
9894 	default:
9895 		printf("queue region config error: (%s)\n", strerror(-ret));
9896 	}
9897 }
9898 
9899 cmdline_parse_token_string_t cmd_queue_region_set =
9900 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9901 		set, "set");
9902 cmdline_parse_token_string_t cmd_queue_region_port =
9903 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9904 cmdline_parse_token_num_t cmd_queue_region_port_id =
9905 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9906 				port_id, RTE_UINT16);
9907 cmdline_parse_token_string_t cmd_queue_region_cmd =
9908 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9909 				 cmd, "queue-region");
9910 cmdline_parse_token_string_t cmd_queue_region_id =
9911 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9912 				region, "region_id");
9913 cmdline_parse_token_num_t cmd_queue_region_index =
9914 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9915 				region_id, RTE_UINT8);
9916 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9917 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9918 				queue_start_index, "queue_start_index");
9919 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9920 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9921 				queue_id, RTE_UINT8);
9922 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9923 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9924 				queue_num, "queue_num");
9925 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9926 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9927 				queue_num_value, RTE_UINT8);
9928 
9929 cmdline_parse_inst_t cmd_queue_region = {
9930 	.f = cmd_queue_region_parsed,
9931 	.data = NULL,
9932 	.help_str = "set port <port_id> queue-region region_id <value> "
9933 		"queue_start_index <value> queue_num <value>: Set a queue region",
9934 	.tokens = {
9935 		(void *)&cmd_queue_region_set,
9936 		(void *)&cmd_queue_region_port,
9937 		(void *)&cmd_queue_region_port_id,
9938 		(void *)&cmd_queue_region_cmd,
9939 		(void *)&cmd_queue_region_id,
9940 		(void *)&cmd_queue_region_index,
9941 		(void *)&cmd_queue_region_queue_start_index,
9942 		(void *)&cmd_queue_region_queue_id,
9943 		(void *)&cmd_queue_region_queue_num,
9944 		(void *)&cmd_queue_region_queue_num_value,
9945 		NULL,
9946 	},
9947 };
9948 
9949 /* *** queue region and flowtype set *** */
9950 struct cmd_region_flowtype_result {
9951 	cmdline_fixed_string_t set;
9952 	cmdline_fixed_string_t port;
9953 	portid_t port_id;
9954 	cmdline_fixed_string_t cmd;
9955 	cmdline_fixed_string_t region;
9956 	uint8_t  region_id;
9957 	cmdline_fixed_string_t flowtype;
9958 	uint8_t  flowtype_id;
9959 };
9960 
9961 static void
9962 cmd_region_flowtype_parsed(void *parsed_result,
9963 			__rte_unused struct cmdline *cl,
9964 			__rte_unused void *data)
9965 {
9966 	struct cmd_region_flowtype_result *res = parsed_result;
9967 	int ret = -ENOTSUP;
9968 #ifdef RTE_NET_I40E
9969 	struct rte_pmd_i40e_queue_region_conf region_conf;
9970 	enum rte_pmd_i40e_queue_region_op op_type;
9971 #endif
9972 
9973 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9974 		return;
9975 
9976 #ifdef RTE_NET_I40E
9977 	memset(&region_conf, 0, sizeof(region_conf));
9978 
9979 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9980 	region_conf.region_id = res->region_id;
9981 	region_conf.hw_flowtype = res->flowtype_id;
9982 
9983 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9984 			op_type, &region_conf);
9985 #endif
9986 
9987 	switch (ret) {
9988 	case 0:
9989 		break;
9990 	case -ENOTSUP:
9991 		printf("function not implemented or supported\n");
9992 		break;
9993 	default:
9994 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9995 	}
9996 }
9997 
9998 cmdline_parse_token_string_t cmd_region_flowtype_set =
9999 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10000 				set, "set");
10001 cmdline_parse_token_string_t cmd_region_flowtype_port =
10002 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10003 				port, "port");
10004 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10005 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10006 				port_id, RTE_UINT16);
10007 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10008 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10009 				cmd, "queue-region");
10010 cmdline_parse_token_string_t cmd_region_flowtype_index =
10011 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10012 				region, "region_id");
10013 cmdline_parse_token_num_t cmd_region_flowtype_id =
10014 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10015 				region_id, RTE_UINT8);
10016 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10017 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10018 				flowtype, "flowtype");
10019 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10020 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10021 				flowtype_id, RTE_UINT8);
10022 cmdline_parse_inst_t cmd_region_flowtype = {
10023 	.f = cmd_region_flowtype_parsed,
10024 	.data = NULL,
10025 	.help_str = "set port <port_id> queue-region region_id <value> "
10026 		"flowtype <value>: Set a flowtype region index",
10027 	.tokens = {
10028 		(void *)&cmd_region_flowtype_set,
10029 		(void *)&cmd_region_flowtype_port,
10030 		(void *)&cmd_region_flowtype_port_index,
10031 		(void *)&cmd_region_flowtype_cmd,
10032 		(void *)&cmd_region_flowtype_index,
10033 		(void *)&cmd_region_flowtype_id,
10034 		(void *)&cmd_region_flowtype_flow_index,
10035 		(void *)&cmd_region_flowtype_flow_id,
10036 		NULL,
10037 	},
10038 };
10039 
10040 /* *** User Priority (UP) to queue region (region_id) set *** */
10041 struct cmd_user_priority_region_result {
10042 	cmdline_fixed_string_t set;
10043 	cmdline_fixed_string_t port;
10044 	portid_t port_id;
10045 	cmdline_fixed_string_t cmd;
10046 	cmdline_fixed_string_t user_priority;
10047 	uint8_t  user_priority_id;
10048 	cmdline_fixed_string_t region;
10049 	uint8_t  region_id;
10050 };
10051 
10052 static void
10053 cmd_user_priority_region_parsed(void *parsed_result,
10054 			__rte_unused struct cmdline *cl,
10055 			__rte_unused void *data)
10056 {
10057 	struct cmd_user_priority_region_result *res = parsed_result;
10058 	int ret = -ENOTSUP;
10059 #ifdef RTE_NET_I40E
10060 	struct rte_pmd_i40e_queue_region_conf region_conf;
10061 	enum rte_pmd_i40e_queue_region_op op_type;
10062 #endif
10063 
10064 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10065 		return;
10066 
10067 #ifdef RTE_NET_I40E
10068 	memset(&region_conf, 0, sizeof(region_conf));
10069 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10070 	region_conf.user_priority = res->user_priority_id;
10071 	region_conf.region_id = res->region_id;
10072 
10073 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10074 				op_type, &region_conf);
10075 #endif
10076 
10077 	switch (ret) {
10078 	case 0:
10079 		break;
10080 	case -ENOTSUP:
10081 		printf("function not implemented or supported\n");
10082 		break;
10083 	default:
10084 		printf("user_priority region config error: (%s)\n",
10085 				strerror(-ret));
10086 	}
10087 }
10088 
10089 cmdline_parse_token_string_t cmd_user_priority_region_set =
10090 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10091 				set, "set");
10092 cmdline_parse_token_string_t cmd_user_priority_region_port =
10093 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10094 				port, "port");
10095 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10096 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10097 				port_id, RTE_UINT16);
10098 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10099 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10100 				cmd, "queue-region");
10101 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10102 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10103 				user_priority, "UP");
10104 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10105 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10106 				user_priority_id, RTE_UINT8);
10107 cmdline_parse_token_string_t cmd_user_priority_region_region =
10108 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10109 				region, "region_id");
10110 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10111 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10112 				region_id, RTE_UINT8);
10113 
10114 cmdline_parse_inst_t cmd_user_priority_region = {
10115 	.f = cmd_user_priority_region_parsed,
10116 	.data = NULL,
10117 	.help_str = "set port <port_id> queue-region UP <value> "
10118 		"region_id <value>: Set the mapping of User Priority (UP) "
10119 		"to queue region (region_id) ",
10120 	.tokens = {
10121 		(void *)&cmd_user_priority_region_set,
10122 		(void *)&cmd_user_priority_region_port,
10123 		(void *)&cmd_user_priority_region_port_index,
10124 		(void *)&cmd_user_priority_region_cmd,
10125 		(void *)&cmd_user_priority_region_UP,
10126 		(void *)&cmd_user_priority_region_UP_id,
10127 		(void *)&cmd_user_priority_region_region,
10128 		(void *)&cmd_user_priority_region_region_id,
10129 		NULL,
10130 	},
10131 };
10132 
10133 /* *** flush all queue region related configuration *** */
10134 struct cmd_flush_queue_region_result {
10135 	cmdline_fixed_string_t set;
10136 	cmdline_fixed_string_t port;
10137 	portid_t port_id;
10138 	cmdline_fixed_string_t cmd;
10139 	cmdline_fixed_string_t flush;
10140 	cmdline_fixed_string_t what;
10141 };
10142 
10143 static void
10144 cmd_flush_queue_region_parsed(void *parsed_result,
10145 			__rte_unused struct cmdline *cl,
10146 			__rte_unused void *data)
10147 {
10148 	struct cmd_flush_queue_region_result *res = parsed_result;
10149 	int ret = -ENOTSUP;
10150 #ifdef RTE_NET_I40E
10151 	struct rte_pmd_i40e_queue_region_conf region_conf;
10152 	enum rte_pmd_i40e_queue_region_op op_type;
10153 #endif
10154 
10155 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10156 		return;
10157 
10158 #ifdef RTE_NET_I40E
10159 	memset(&region_conf, 0, sizeof(region_conf));
10160 
10161 	if (strcmp(res->what, "on") == 0)
10162 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10163 	else
10164 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10165 
10166 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10167 				op_type, &region_conf);
10168 #endif
10169 
10170 	switch (ret) {
10171 	case 0:
10172 		break;
10173 	case -ENOTSUP:
10174 		printf("function not implemented or supported\n");
10175 		break;
10176 	default:
10177 		printf("queue region config flush error: (%s)\n",
10178 				strerror(-ret));
10179 	}
10180 }
10181 
10182 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10183 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10184 				set, "set");
10185 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10186 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10187 				port, "port");
10188 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10189 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10190 				port_id, RTE_UINT16);
10191 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10192 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10193 				cmd, "queue-region");
10194 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10195 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10196 				flush, "flush");
10197 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10198 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10199 				what, "on#off");
10200 
10201 cmdline_parse_inst_t cmd_flush_queue_region = {
10202 	.f = cmd_flush_queue_region_parsed,
10203 	.data = NULL,
10204 	.help_str = "set port <port_id> queue-region flush on|off"
10205 		": flush all queue region related configuration",
10206 	.tokens = {
10207 		(void *)&cmd_flush_queue_region_set,
10208 		(void *)&cmd_flush_queue_region_port,
10209 		(void *)&cmd_flush_queue_region_port_index,
10210 		(void *)&cmd_flush_queue_region_cmd,
10211 		(void *)&cmd_flush_queue_region_flush,
10212 		(void *)&cmd_flush_queue_region_what,
10213 		NULL,
10214 	},
10215 };
10216 
10217 /* *** get all queue region related configuration info *** */
10218 struct cmd_show_queue_region_info {
10219 	cmdline_fixed_string_t show;
10220 	cmdline_fixed_string_t port;
10221 	portid_t port_id;
10222 	cmdline_fixed_string_t cmd;
10223 };
10224 
10225 static void
10226 cmd_show_queue_region_info_parsed(void *parsed_result,
10227 			__rte_unused struct cmdline *cl,
10228 			__rte_unused void *data)
10229 {
10230 	struct cmd_show_queue_region_info *res = parsed_result;
10231 	int ret = -ENOTSUP;
10232 #ifdef RTE_NET_I40E
10233 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10234 	enum rte_pmd_i40e_queue_region_op op_type;
10235 #endif
10236 
10237 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10238 		return;
10239 
10240 #ifdef RTE_NET_I40E
10241 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10242 
10243 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10244 
10245 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10246 					op_type, &rte_pmd_regions);
10247 
10248 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10249 #endif
10250 
10251 	switch (ret) {
10252 	case 0:
10253 		break;
10254 	case -ENOTSUP:
10255 		printf("function not implemented or supported\n");
10256 		break;
10257 	default:
10258 		printf("queue region config info show error: (%s)\n",
10259 				strerror(-ret));
10260 	}
10261 }
10262 
10263 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10264 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10265 				show, "show");
10266 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10267 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10268 				port, "port");
10269 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10270 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10271 				port_id, RTE_UINT16);
10272 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10273 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10274 				cmd, "queue-region");
10275 
10276 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10277 	.f = cmd_show_queue_region_info_parsed,
10278 	.data = NULL,
10279 	.help_str = "show port <port_id> queue-region"
10280 		": show all queue region related configuration info",
10281 	.tokens = {
10282 		(void *)&cmd_show_queue_region_info_get,
10283 		(void *)&cmd_show_queue_region_info_port,
10284 		(void *)&cmd_show_queue_region_info_port_index,
10285 		(void *)&cmd_show_queue_region_info_cmd,
10286 		NULL,
10287 	},
10288 };
10289 
10290 /* *** Filters Control *** */
10291 
10292 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10293 do { \
10294 	if ((ip_addr).family == AF_INET) \
10295 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10296 	else { \
10297 		printf("invalid parameter.\n"); \
10298 		return; \
10299 	} \
10300 } while (0)
10301 
10302 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10303 do { \
10304 	if ((ip_addr).family == AF_INET6) \
10305 		rte_memcpy(&(ip), \
10306 				 &((ip_addr).addr.ipv6), \
10307 				 sizeof(struct in6_addr)); \
10308 	else { \
10309 		printf("invalid parameter.\n"); \
10310 		return; \
10311 	} \
10312 } while (0)
10313 
10314 #ifdef RTE_NET_I40E
10315 
10316 static uint16_t
10317 str2flowtype(char *string)
10318 {
10319 	uint8_t i = 0;
10320 	static const struct {
10321 		char str[32];
10322 		uint16_t type;
10323 	} flowtype_str[] = {
10324 		{"raw", RTE_ETH_FLOW_RAW},
10325 		{"ipv4", RTE_ETH_FLOW_IPV4},
10326 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10327 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10328 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10329 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10330 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10331 		{"ipv6", RTE_ETH_FLOW_IPV6},
10332 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10333 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10334 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10335 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10336 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10337 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10338 	};
10339 
10340 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10341 		if (!strcmp(flowtype_str[i].str, string))
10342 			return flowtype_str[i].type;
10343 	}
10344 
10345 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10346 		return (uint16_t)atoi(string);
10347 
10348 	return RTE_ETH_FLOW_UNKNOWN;
10349 }
10350 
10351 /* *** deal with flow director filter *** */
10352 struct cmd_flow_director_result {
10353 	cmdline_fixed_string_t flow_director_filter;
10354 	portid_t port_id;
10355 	cmdline_fixed_string_t mode;
10356 	cmdline_fixed_string_t mode_value;
10357 	cmdline_fixed_string_t ops;
10358 	cmdline_fixed_string_t flow;
10359 	cmdline_fixed_string_t flow_type;
10360 	cmdline_fixed_string_t drop;
10361 	cmdline_fixed_string_t queue;
10362 	uint16_t  queue_id;
10363 	cmdline_fixed_string_t fd_id;
10364 	uint32_t  fd_id_value;
10365 	cmdline_fixed_string_t packet;
10366 	char filepath[];
10367 };
10368 
10369 static void
10370 cmd_flow_director_filter_parsed(void *parsed_result,
10371 			  __rte_unused struct cmdline *cl,
10372 			  __rte_unused void *data)
10373 {
10374 	struct cmd_flow_director_result *res = parsed_result;
10375 	int ret = 0;
10376 	struct rte_pmd_i40e_flow_type_mapping
10377 			mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10378 	struct rte_pmd_i40e_pkt_template_conf conf;
10379 	uint16_t flow_type = str2flowtype(res->flow_type);
10380 	uint16_t i, port = res->port_id;
10381 	uint8_t add;
10382 
10383 	memset(&conf, 0, sizeof(conf));
10384 
10385 	if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10386 		printf("Invalid flow type specified.\n");
10387 		return;
10388 	}
10389 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10390 						 mapping);
10391 	if (ret)
10392 		return;
10393 	if (mapping[flow_type].pctype == 0ULL) {
10394 		printf("Invalid flow type specified.\n");
10395 		return;
10396 	}
10397 	for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10398 		if (mapping[flow_type].pctype & (1ULL << i)) {
10399 			conf.input.pctype = i;
10400 			break;
10401 		}
10402 	}
10403 
10404 	conf.input.packet = open_file(res->filepath,
10405 				&conf.input.length);
10406 	if (!conf.input.packet)
10407 		return;
10408 	if (!strcmp(res->drop, "drop"))
10409 		conf.action.behavior =
10410 			RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10411 	else
10412 		conf.action.behavior =
10413 			RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10414 	conf.action.report_status =
10415 			RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10416 	conf.action.rx_queue = res->queue_id;
10417 	conf.soft_id = res->fd_id_value;
10418 	add  = strcmp(res->ops, "del") ? 1 : 0;
10419 	ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10420 							&conf,
10421 							add);
10422 	if (ret < 0)
10423 		printf("flow director config error: (%s)\n",
10424 		       strerror(-ret));
10425 	close_file(conf.input.packet);
10426 }
10427 
10428 cmdline_parse_token_string_t cmd_flow_director_filter =
10429 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10430 				 flow_director_filter, "flow_director_filter");
10431 cmdline_parse_token_num_t cmd_flow_director_port_id =
10432 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10433 			      port_id, RTE_UINT16);
10434 cmdline_parse_token_string_t cmd_flow_director_ops =
10435 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10436 				 ops, "add#del#update");
10437 cmdline_parse_token_string_t cmd_flow_director_flow =
10438 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10439 				 flow, "flow");
10440 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10441 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10442 		flow_type, NULL);
10443 cmdline_parse_token_string_t cmd_flow_director_drop =
10444 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10445 				 drop, "drop#fwd");
10446 cmdline_parse_token_string_t cmd_flow_director_queue =
10447 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10448 				 queue, "queue");
10449 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10450 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10451 			      queue_id, RTE_UINT16);
10452 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10453 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10454 				 fd_id, "fd_id");
10455 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10456 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10457 			      fd_id_value, RTE_UINT32);
10458 
10459 cmdline_parse_token_string_t cmd_flow_director_mode =
10460 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10461 				 mode, "mode");
10462 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10463 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10464 				 mode_value, "raw");
10465 cmdline_parse_token_string_t cmd_flow_director_packet =
10466 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10467 				 packet, "packet");
10468 cmdline_parse_token_string_t cmd_flow_director_filepath =
10469 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10470 				 filepath, NULL);
10471 
10472 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10473 	.f = cmd_flow_director_filter_parsed,
10474 	.data = NULL,
10475 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10476 		"director entry on NIC",
10477 	.tokens = {
10478 		(void *)&cmd_flow_director_filter,
10479 		(void *)&cmd_flow_director_port_id,
10480 		(void *)&cmd_flow_director_mode,
10481 		(void *)&cmd_flow_director_mode_raw,
10482 		(void *)&cmd_flow_director_ops,
10483 		(void *)&cmd_flow_director_flow,
10484 		(void *)&cmd_flow_director_flow_type,
10485 		(void *)&cmd_flow_director_drop,
10486 		(void *)&cmd_flow_director_queue,
10487 		(void *)&cmd_flow_director_queue_id,
10488 		(void *)&cmd_flow_director_fd_id,
10489 		(void *)&cmd_flow_director_fd_id_value,
10490 		(void *)&cmd_flow_director_packet,
10491 		(void *)&cmd_flow_director_filepath,
10492 		NULL,
10493 	},
10494 };
10495 
10496 #endif /* RTE_NET_I40E */
10497 
10498 /* *** deal with flow director mask *** */
10499 struct cmd_flow_director_mask_result {
10500 	cmdline_fixed_string_t flow_director_mask;
10501 	portid_t port_id;
10502 	cmdline_fixed_string_t mode;
10503 	cmdline_fixed_string_t mode_value;
10504 	cmdline_fixed_string_t vlan;
10505 	uint16_t vlan_mask;
10506 	cmdline_fixed_string_t src_mask;
10507 	cmdline_ipaddr_t ipv4_src;
10508 	cmdline_ipaddr_t ipv6_src;
10509 	uint16_t port_src;
10510 	cmdline_fixed_string_t dst_mask;
10511 	cmdline_ipaddr_t ipv4_dst;
10512 	cmdline_ipaddr_t ipv6_dst;
10513 	uint16_t port_dst;
10514 	cmdline_fixed_string_t mac;
10515 	uint8_t mac_addr_byte_mask;
10516 	cmdline_fixed_string_t tunnel_id;
10517 	uint32_t tunnel_id_mask;
10518 	cmdline_fixed_string_t tunnel_type;
10519 	uint8_t tunnel_type_mask;
10520 };
10521 
10522 static void
10523 cmd_flow_director_mask_parsed(void *parsed_result,
10524 			  __rte_unused struct cmdline *cl,
10525 			  __rte_unused void *data)
10526 {
10527 	struct cmd_flow_director_mask_result *res = parsed_result;
10528 	struct rte_eth_fdir_masks *mask;
10529 	struct rte_port *port;
10530 
10531 	port = &ports[res->port_id];
10532 	/** Check if the port is not started **/
10533 	if (port->port_status != RTE_PORT_STOPPED) {
10534 		printf("Please stop port %d first\n", res->port_id);
10535 		return;
10536 	}
10537 
10538 	mask = &port->dev_conf.fdir_conf.mask;
10539 
10540 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10541 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10542 			printf("Please set mode to MAC-VLAN.\n");
10543 			return;
10544 		}
10545 
10546 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10547 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10548 		if (strcmp(res->mode_value, "Tunnel")) {
10549 			printf("Please set mode to Tunnel.\n");
10550 			return;
10551 		}
10552 
10553 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10554 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10555 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10556 		mask->tunnel_type_mask = res->tunnel_type_mask;
10557 	} else {
10558 		if (strcmp(res->mode_value, "IP")) {
10559 			printf("Please set mode to IP.\n");
10560 			return;
10561 		}
10562 
10563 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10564 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10565 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10566 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10567 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10568 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10569 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10570 	}
10571 
10572 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10573 }
10574 
10575 cmdline_parse_token_string_t cmd_flow_director_mask =
10576 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10577 				 flow_director_mask, "flow_director_mask");
10578 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10579 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10580 			      port_id, RTE_UINT16);
10581 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10582 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10583 				 vlan, "vlan");
10584 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10585 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10586 			      vlan_mask, RTE_UINT16);
10587 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10588 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10589 				 src_mask, "src_mask");
10590 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10591 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10592 				 ipv4_src);
10593 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10594 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10595 				 ipv6_src);
10596 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10597 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10598 			      port_src, RTE_UINT16);
10599 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10600 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10601 				 dst_mask, "dst_mask");
10602 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10603 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10604 				 ipv4_dst);
10605 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10606 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10607 				 ipv6_dst);
10608 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10609 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10610 			      port_dst, RTE_UINT16);
10611 
10612 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10613 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10614 				 mode, "mode");
10615 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10616 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10617 				 mode_value, "IP");
10618 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10619 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10620 				 mode_value, "MAC-VLAN");
10621 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10622 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10623 				 mode_value, "Tunnel");
10624 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10625 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10626 				 mac, "mac");
10627 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10628 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10629 			      mac_addr_byte_mask, RTE_UINT8);
10630 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10631 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10632 				 tunnel_type, "tunnel-type");
10633 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10634 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10635 			      tunnel_type_mask, RTE_UINT8);
10636 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10637 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10638 				 tunnel_id, "tunnel-id");
10639 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10640 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10641 			      tunnel_id_mask, RTE_UINT32);
10642 
10643 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10644 	.f = cmd_flow_director_mask_parsed,
10645 	.data = NULL,
10646 	.help_str = "flow_director_mask ... : "
10647 		"Set IP mode flow director's mask on NIC",
10648 	.tokens = {
10649 		(void *)&cmd_flow_director_mask,
10650 		(void *)&cmd_flow_director_mask_port_id,
10651 		(void *)&cmd_flow_director_mask_mode,
10652 		(void *)&cmd_flow_director_mask_mode_ip,
10653 		(void *)&cmd_flow_director_mask_vlan,
10654 		(void *)&cmd_flow_director_mask_vlan_value,
10655 		(void *)&cmd_flow_director_mask_src,
10656 		(void *)&cmd_flow_director_mask_ipv4_src,
10657 		(void *)&cmd_flow_director_mask_ipv6_src,
10658 		(void *)&cmd_flow_director_mask_port_src,
10659 		(void *)&cmd_flow_director_mask_dst,
10660 		(void *)&cmd_flow_director_mask_ipv4_dst,
10661 		(void *)&cmd_flow_director_mask_ipv6_dst,
10662 		(void *)&cmd_flow_director_mask_port_dst,
10663 		NULL,
10664 	},
10665 };
10666 
10667 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10668 	.f = cmd_flow_director_mask_parsed,
10669 	.data = NULL,
10670 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10671 		"flow director's mask on NIC",
10672 	.tokens = {
10673 		(void *)&cmd_flow_director_mask,
10674 		(void *)&cmd_flow_director_mask_port_id,
10675 		(void *)&cmd_flow_director_mask_mode,
10676 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10677 		(void *)&cmd_flow_director_mask_vlan,
10678 		(void *)&cmd_flow_director_mask_vlan_value,
10679 		NULL,
10680 	},
10681 };
10682 
10683 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10684 	.f = cmd_flow_director_mask_parsed,
10685 	.data = NULL,
10686 	.help_str = "flow_director_mask ... : Set tunnel mode "
10687 		"flow director's mask on NIC",
10688 	.tokens = {
10689 		(void *)&cmd_flow_director_mask,
10690 		(void *)&cmd_flow_director_mask_port_id,
10691 		(void *)&cmd_flow_director_mask_mode,
10692 		(void *)&cmd_flow_director_mask_mode_tunnel,
10693 		(void *)&cmd_flow_director_mask_vlan,
10694 		(void *)&cmd_flow_director_mask_vlan_value,
10695 		(void *)&cmd_flow_director_mask_mac,
10696 		(void *)&cmd_flow_director_mask_mac_value,
10697 		(void *)&cmd_flow_director_mask_tunnel_type,
10698 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10699 		(void *)&cmd_flow_director_mask_tunnel_id,
10700 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10701 		NULL,
10702 	},
10703 };
10704 
10705 /* *** deal with flow director flexible payload configuration *** */
10706 struct cmd_flow_director_flexpayload_result {
10707 	cmdline_fixed_string_t flow_director_flexpayload;
10708 	portid_t port_id;
10709 	cmdline_fixed_string_t payload_layer;
10710 	cmdline_fixed_string_t payload_cfg;
10711 };
10712 
10713 static inline int
10714 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10715 {
10716 	char s[256];
10717 	const char *p, *p0 = q_arg;
10718 	char *end;
10719 	unsigned long int_fld;
10720 	char *str_fld[max_num];
10721 	int i;
10722 	unsigned size;
10723 	int ret = -1;
10724 
10725 	p = strchr(p0, '(');
10726 	if (p == NULL)
10727 		return -1;
10728 	++p;
10729 	p0 = strchr(p, ')');
10730 	if (p0 == NULL)
10731 		return -1;
10732 
10733 	size = p0 - p;
10734 	if (size >= sizeof(s))
10735 		return -1;
10736 
10737 	snprintf(s, sizeof(s), "%.*s", size, p);
10738 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10739 	if (ret < 0 || ret > max_num)
10740 		return -1;
10741 	for (i = 0; i < ret; i++) {
10742 		errno = 0;
10743 		int_fld = strtoul(str_fld[i], &end, 0);
10744 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10745 			return -1;
10746 		offsets[i] = (uint16_t)int_fld;
10747 	}
10748 	return ret;
10749 }
10750 
10751 static void
10752 cmd_flow_director_flxpld_parsed(void *parsed_result,
10753 			  __rte_unused struct cmdline *cl,
10754 			  __rte_unused void *data)
10755 {
10756 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
10757 	struct rte_eth_flex_payload_cfg flex_cfg;
10758 	struct rte_port *port;
10759 	int ret = 0;
10760 
10761 	port = &ports[res->port_id];
10762 	/** Check if the port is not started **/
10763 	if (port->port_status != RTE_PORT_STOPPED) {
10764 		printf("Please stop port %d first\n", res->port_id);
10765 		return;
10766 	}
10767 
10768 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10769 
10770 	if (!strcmp(res->payload_layer, "raw"))
10771 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10772 	else if (!strcmp(res->payload_layer, "l2"))
10773 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10774 	else if (!strcmp(res->payload_layer, "l3"))
10775 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10776 	else if (!strcmp(res->payload_layer, "l4"))
10777 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10778 
10779 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10780 			    RTE_ETH_FDIR_MAX_FLEXLEN);
10781 	if (ret < 0) {
10782 		printf("error: Cannot parse flex payload input.\n");
10783 		return;
10784 	}
10785 
10786 	fdir_set_flex_payload(res->port_id, &flex_cfg);
10787 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10788 }
10789 
10790 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10791 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10792 				 flow_director_flexpayload,
10793 				 "flow_director_flex_payload");
10794 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10795 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10796 			      port_id, RTE_UINT16);
10797 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10798 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10799 				 payload_layer, "raw#l2#l3#l4");
10800 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10801 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10802 				 payload_cfg, NULL);
10803 
10804 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10805 	.f = cmd_flow_director_flxpld_parsed,
10806 	.data = NULL,
10807 	.help_str = "flow_director_flexpayload ... : "
10808 		"Set flow director's flex payload on NIC",
10809 	.tokens = {
10810 		(void *)&cmd_flow_director_flexpayload,
10811 		(void *)&cmd_flow_director_flexpayload_port_id,
10812 		(void *)&cmd_flow_director_flexpayload_payload_layer,
10813 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
10814 		NULL,
10815 	},
10816 };
10817 
10818 /* Generic flow interface command. */
10819 extern cmdline_parse_inst_t cmd_flow;
10820 
10821 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10822 struct cmd_mcast_addr_result {
10823 	cmdline_fixed_string_t mcast_addr_cmd;
10824 	cmdline_fixed_string_t what;
10825 	uint16_t port_num;
10826 	struct rte_ether_addr mc_addr;
10827 };
10828 
10829 static void cmd_mcast_addr_parsed(void *parsed_result,
10830 		__rte_unused struct cmdline *cl,
10831 		__rte_unused void *data)
10832 {
10833 	struct cmd_mcast_addr_result *res = parsed_result;
10834 
10835 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10836 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10837 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10838 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10839 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10840 		return;
10841 	}
10842 	if (strcmp(res->what, "add") == 0)
10843 		mcast_addr_add(res->port_num, &res->mc_addr);
10844 	else
10845 		mcast_addr_remove(res->port_num, &res->mc_addr);
10846 }
10847 
10848 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10849 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10850 				 mcast_addr_cmd, "mcast_addr");
10851 cmdline_parse_token_string_t cmd_mcast_addr_what =
10852 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10853 				 "add#remove");
10854 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10855 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10856 				 RTE_UINT16);
10857 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10858 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10859 
10860 cmdline_parse_inst_t cmd_mcast_addr = {
10861 	.f = cmd_mcast_addr_parsed,
10862 	.data = (void *)0,
10863 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10864 		"Add/Remove multicast MAC address on port_id",
10865 	.tokens = {
10866 		(void *)&cmd_mcast_addr_cmd,
10867 		(void *)&cmd_mcast_addr_what,
10868 		(void *)&cmd_mcast_addr_portnum,
10869 		(void *)&cmd_mcast_addr_addr,
10870 		NULL,
10871 	},
10872 };
10873 
10874 /* vf vlan anti spoof configuration */
10875 
10876 /* Common result structure for vf vlan anti spoof */
10877 struct cmd_vf_vlan_anti_spoof_result {
10878 	cmdline_fixed_string_t set;
10879 	cmdline_fixed_string_t vf;
10880 	cmdline_fixed_string_t vlan;
10881 	cmdline_fixed_string_t antispoof;
10882 	portid_t port_id;
10883 	uint32_t vf_id;
10884 	cmdline_fixed_string_t on_off;
10885 };
10886 
10887 /* Common CLI fields for vf vlan anti spoof enable disable */
10888 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10889 	TOKEN_STRING_INITIALIZER
10890 		(struct cmd_vf_vlan_anti_spoof_result,
10891 		 set, "set");
10892 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10893 	TOKEN_STRING_INITIALIZER
10894 		(struct cmd_vf_vlan_anti_spoof_result,
10895 		 vf, "vf");
10896 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10897 	TOKEN_STRING_INITIALIZER
10898 		(struct cmd_vf_vlan_anti_spoof_result,
10899 		 vlan, "vlan");
10900 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10901 	TOKEN_STRING_INITIALIZER
10902 		(struct cmd_vf_vlan_anti_spoof_result,
10903 		 antispoof, "antispoof");
10904 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10905 	TOKEN_NUM_INITIALIZER
10906 		(struct cmd_vf_vlan_anti_spoof_result,
10907 		 port_id, RTE_UINT16);
10908 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10909 	TOKEN_NUM_INITIALIZER
10910 		(struct cmd_vf_vlan_anti_spoof_result,
10911 		 vf_id, RTE_UINT32);
10912 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10913 	TOKEN_STRING_INITIALIZER
10914 		(struct cmd_vf_vlan_anti_spoof_result,
10915 		 on_off, "on#off");
10916 
10917 static void
10918 cmd_set_vf_vlan_anti_spoof_parsed(
10919 	void *parsed_result,
10920 	__rte_unused struct cmdline *cl,
10921 	__rte_unused void *data)
10922 {
10923 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10924 	int ret = -ENOTSUP;
10925 
10926 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10927 
10928 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10929 		return;
10930 
10931 #ifdef RTE_NET_IXGBE
10932 	if (ret == -ENOTSUP)
10933 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10934 				res->vf_id, is_on);
10935 #endif
10936 #ifdef RTE_NET_I40E
10937 	if (ret == -ENOTSUP)
10938 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10939 				res->vf_id, is_on);
10940 #endif
10941 #ifdef RTE_NET_BNXT
10942 	if (ret == -ENOTSUP)
10943 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10944 				res->vf_id, is_on);
10945 #endif
10946 
10947 	switch (ret) {
10948 	case 0:
10949 		break;
10950 	case -EINVAL:
10951 		printf("invalid vf_id %d\n", res->vf_id);
10952 		break;
10953 	case -ENODEV:
10954 		printf("invalid port_id %d\n", res->port_id);
10955 		break;
10956 	case -ENOTSUP:
10957 		printf("function not implemented\n");
10958 		break;
10959 	default:
10960 		printf("programming error: (%s)\n", strerror(-ret));
10961 	}
10962 }
10963 
10964 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10965 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
10966 	.data = NULL,
10967 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10968 	.tokens = {
10969 		(void *)&cmd_vf_vlan_anti_spoof_set,
10970 		(void *)&cmd_vf_vlan_anti_spoof_vf,
10971 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
10972 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
10973 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
10974 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
10975 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
10976 		NULL,
10977 	},
10978 };
10979 
10980 /* vf mac anti spoof configuration */
10981 
10982 /* Common result structure for vf mac anti spoof */
10983 struct cmd_vf_mac_anti_spoof_result {
10984 	cmdline_fixed_string_t set;
10985 	cmdline_fixed_string_t vf;
10986 	cmdline_fixed_string_t mac;
10987 	cmdline_fixed_string_t antispoof;
10988 	portid_t port_id;
10989 	uint32_t vf_id;
10990 	cmdline_fixed_string_t on_off;
10991 };
10992 
10993 /* Common CLI fields for vf mac anti spoof enable disable */
10994 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10995 	TOKEN_STRING_INITIALIZER
10996 		(struct cmd_vf_mac_anti_spoof_result,
10997 		 set, "set");
10998 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10999 	TOKEN_STRING_INITIALIZER
11000 		(struct cmd_vf_mac_anti_spoof_result,
11001 		 vf, "vf");
11002 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11003 	TOKEN_STRING_INITIALIZER
11004 		(struct cmd_vf_mac_anti_spoof_result,
11005 		 mac, "mac");
11006 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11007 	TOKEN_STRING_INITIALIZER
11008 		(struct cmd_vf_mac_anti_spoof_result,
11009 		 antispoof, "antispoof");
11010 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11011 	TOKEN_NUM_INITIALIZER
11012 		(struct cmd_vf_mac_anti_spoof_result,
11013 		 port_id, RTE_UINT16);
11014 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11015 	TOKEN_NUM_INITIALIZER
11016 		(struct cmd_vf_mac_anti_spoof_result,
11017 		 vf_id, RTE_UINT32);
11018 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11019 	TOKEN_STRING_INITIALIZER
11020 		(struct cmd_vf_mac_anti_spoof_result,
11021 		 on_off, "on#off");
11022 
11023 static void
11024 cmd_set_vf_mac_anti_spoof_parsed(
11025 	void *parsed_result,
11026 	__rte_unused struct cmdline *cl,
11027 	__rte_unused void *data)
11028 {
11029 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11030 	int ret = -ENOTSUP;
11031 
11032 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11033 
11034 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11035 		return;
11036 
11037 #ifdef RTE_NET_IXGBE
11038 	if (ret == -ENOTSUP)
11039 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11040 			res->vf_id, is_on);
11041 #endif
11042 #ifdef RTE_NET_I40E
11043 	if (ret == -ENOTSUP)
11044 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11045 			res->vf_id, is_on);
11046 #endif
11047 #ifdef RTE_NET_BNXT
11048 	if (ret == -ENOTSUP)
11049 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11050 			res->vf_id, is_on);
11051 #endif
11052 
11053 	switch (ret) {
11054 	case 0:
11055 		break;
11056 	case -EINVAL:
11057 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11058 		break;
11059 	case -ENODEV:
11060 		printf("invalid port_id %d\n", res->port_id);
11061 		break;
11062 	case -ENOTSUP:
11063 		printf("function not implemented\n");
11064 		break;
11065 	default:
11066 		printf("programming error: (%s)\n", strerror(-ret));
11067 	}
11068 }
11069 
11070 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11071 	.f = cmd_set_vf_mac_anti_spoof_parsed,
11072 	.data = NULL,
11073 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11074 	.tokens = {
11075 		(void *)&cmd_vf_mac_anti_spoof_set,
11076 		(void *)&cmd_vf_mac_anti_spoof_vf,
11077 		(void *)&cmd_vf_mac_anti_spoof_mac,
11078 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
11079 		(void *)&cmd_vf_mac_anti_spoof_port_id,
11080 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
11081 		(void *)&cmd_vf_mac_anti_spoof_on_off,
11082 		NULL,
11083 	},
11084 };
11085 
11086 /* vf vlan strip queue configuration */
11087 
11088 /* Common result structure for vf mac anti spoof */
11089 struct cmd_vf_vlan_stripq_result {
11090 	cmdline_fixed_string_t set;
11091 	cmdline_fixed_string_t vf;
11092 	cmdline_fixed_string_t vlan;
11093 	cmdline_fixed_string_t stripq;
11094 	portid_t port_id;
11095 	uint16_t vf_id;
11096 	cmdline_fixed_string_t on_off;
11097 };
11098 
11099 /* Common CLI fields for vf vlan strip enable disable */
11100 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11101 	TOKEN_STRING_INITIALIZER
11102 		(struct cmd_vf_vlan_stripq_result,
11103 		 set, "set");
11104 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11105 	TOKEN_STRING_INITIALIZER
11106 		(struct cmd_vf_vlan_stripq_result,
11107 		 vf, "vf");
11108 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11109 	TOKEN_STRING_INITIALIZER
11110 		(struct cmd_vf_vlan_stripq_result,
11111 		 vlan, "vlan");
11112 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11113 	TOKEN_STRING_INITIALIZER
11114 		(struct cmd_vf_vlan_stripq_result,
11115 		 stripq, "stripq");
11116 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11117 	TOKEN_NUM_INITIALIZER
11118 		(struct cmd_vf_vlan_stripq_result,
11119 		 port_id, RTE_UINT16);
11120 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11121 	TOKEN_NUM_INITIALIZER
11122 		(struct cmd_vf_vlan_stripq_result,
11123 		 vf_id, RTE_UINT16);
11124 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11125 	TOKEN_STRING_INITIALIZER
11126 		(struct cmd_vf_vlan_stripq_result,
11127 		 on_off, "on#off");
11128 
11129 static void
11130 cmd_set_vf_vlan_stripq_parsed(
11131 	void *parsed_result,
11132 	__rte_unused struct cmdline *cl,
11133 	__rte_unused void *data)
11134 {
11135 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
11136 	int ret = -ENOTSUP;
11137 
11138 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11139 
11140 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11141 		return;
11142 
11143 #ifdef RTE_NET_IXGBE
11144 	if (ret == -ENOTSUP)
11145 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11146 			res->vf_id, is_on);
11147 #endif
11148 #ifdef RTE_NET_I40E
11149 	if (ret == -ENOTSUP)
11150 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11151 			res->vf_id, is_on);
11152 #endif
11153 #ifdef RTE_NET_BNXT
11154 	if (ret == -ENOTSUP)
11155 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11156 			res->vf_id, is_on);
11157 #endif
11158 
11159 	switch (ret) {
11160 	case 0:
11161 		break;
11162 	case -EINVAL:
11163 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11164 		break;
11165 	case -ENODEV:
11166 		printf("invalid port_id %d\n", res->port_id);
11167 		break;
11168 	case -ENOTSUP:
11169 		printf("function not implemented\n");
11170 		break;
11171 	default:
11172 		printf("programming error: (%s)\n", strerror(-ret));
11173 	}
11174 }
11175 
11176 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11177 	.f = cmd_set_vf_vlan_stripq_parsed,
11178 	.data = NULL,
11179 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11180 	.tokens = {
11181 		(void *)&cmd_vf_vlan_stripq_set,
11182 		(void *)&cmd_vf_vlan_stripq_vf,
11183 		(void *)&cmd_vf_vlan_stripq_vlan,
11184 		(void *)&cmd_vf_vlan_stripq_stripq,
11185 		(void *)&cmd_vf_vlan_stripq_port_id,
11186 		(void *)&cmd_vf_vlan_stripq_vf_id,
11187 		(void *)&cmd_vf_vlan_stripq_on_off,
11188 		NULL,
11189 	},
11190 };
11191 
11192 /* vf vlan insert configuration */
11193 
11194 /* Common result structure for vf vlan insert */
11195 struct cmd_vf_vlan_insert_result {
11196 	cmdline_fixed_string_t set;
11197 	cmdline_fixed_string_t vf;
11198 	cmdline_fixed_string_t vlan;
11199 	cmdline_fixed_string_t insert;
11200 	portid_t port_id;
11201 	uint16_t vf_id;
11202 	uint16_t vlan_id;
11203 };
11204 
11205 /* Common CLI fields for vf vlan insert enable disable */
11206 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11207 	TOKEN_STRING_INITIALIZER
11208 		(struct cmd_vf_vlan_insert_result,
11209 		 set, "set");
11210 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11211 	TOKEN_STRING_INITIALIZER
11212 		(struct cmd_vf_vlan_insert_result,
11213 		 vf, "vf");
11214 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11215 	TOKEN_STRING_INITIALIZER
11216 		(struct cmd_vf_vlan_insert_result,
11217 		 vlan, "vlan");
11218 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11219 	TOKEN_STRING_INITIALIZER
11220 		(struct cmd_vf_vlan_insert_result,
11221 		 insert, "insert");
11222 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11223 	TOKEN_NUM_INITIALIZER
11224 		(struct cmd_vf_vlan_insert_result,
11225 		 port_id, RTE_UINT16);
11226 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11227 	TOKEN_NUM_INITIALIZER
11228 		(struct cmd_vf_vlan_insert_result,
11229 		 vf_id, RTE_UINT16);
11230 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11231 	TOKEN_NUM_INITIALIZER
11232 		(struct cmd_vf_vlan_insert_result,
11233 		 vlan_id, RTE_UINT16);
11234 
11235 static void
11236 cmd_set_vf_vlan_insert_parsed(
11237 	void *parsed_result,
11238 	__rte_unused struct cmdline *cl,
11239 	__rte_unused void *data)
11240 {
11241 	struct cmd_vf_vlan_insert_result *res = parsed_result;
11242 	int ret = -ENOTSUP;
11243 
11244 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11245 		return;
11246 
11247 #ifdef RTE_NET_IXGBE
11248 	if (ret == -ENOTSUP)
11249 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11250 			res->vlan_id);
11251 #endif
11252 #ifdef RTE_NET_I40E
11253 	if (ret == -ENOTSUP)
11254 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11255 			res->vlan_id);
11256 #endif
11257 #ifdef RTE_NET_BNXT
11258 	if (ret == -ENOTSUP)
11259 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11260 			res->vlan_id);
11261 #endif
11262 
11263 	switch (ret) {
11264 	case 0:
11265 		break;
11266 	case -EINVAL:
11267 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11268 		break;
11269 	case -ENODEV:
11270 		printf("invalid port_id %d\n", res->port_id);
11271 		break;
11272 	case -ENOTSUP:
11273 		printf("function not implemented\n");
11274 		break;
11275 	default:
11276 		printf("programming error: (%s)\n", strerror(-ret));
11277 	}
11278 }
11279 
11280 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11281 	.f = cmd_set_vf_vlan_insert_parsed,
11282 	.data = NULL,
11283 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11284 	.tokens = {
11285 		(void *)&cmd_vf_vlan_insert_set,
11286 		(void *)&cmd_vf_vlan_insert_vf,
11287 		(void *)&cmd_vf_vlan_insert_vlan,
11288 		(void *)&cmd_vf_vlan_insert_insert,
11289 		(void *)&cmd_vf_vlan_insert_port_id,
11290 		(void *)&cmd_vf_vlan_insert_vf_id,
11291 		(void *)&cmd_vf_vlan_insert_vlan_id,
11292 		NULL,
11293 	},
11294 };
11295 
11296 /* tx loopback configuration */
11297 
11298 /* Common result structure for tx loopback */
11299 struct cmd_tx_loopback_result {
11300 	cmdline_fixed_string_t set;
11301 	cmdline_fixed_string_t tx;
11302 	cmdline_fixed_string_t loopback;
11303 	portid_t port_id;
11304 	cmdline_fixed_string_t on_off;
11305 };
11306 
11307 /* Common CLI fields for tx loopback enable disable */
11308 cmdline_parse_token_string_t cmd_tx_loopback_set =
11309 	TOKEN_STRING_INITIALIZER
11310 		(struct cmd_tx_loopback_result,
11311 		 set, "set");
11312 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11313 	TOKEN_STRING_INITIALIZER
11314 		(struct cmd_tx_loopback_result,
11315 		 tx, "tx");
11316 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11317 	TOKEN_STRING_INITIALIZER
11318 		(struct cmd_tx_loopback_result,
11319 		 loopback, "loopback");
11320 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11321 	TOKEN_NUM_INITIALIZER
11322 		(struct cmd_tx_loopback_result,
11323 		 port_id, RTE_UINT16);
11324 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11325 	TOKEN_STRING_INITIALIZER
11326 		(struct cmd_tx_loopback_result,
11327 		 on_off, "on#off");
11328 
11329 static void
11330 cmd_set_tx_loopback_parsed(
11331 	void *parsed_result,
11332 	__rte_unused struct cmdline *cl,
11333 	__rte_unused void *data)
11334 {
11335 	struct cmd_tx_loopback_result *res = parsed_result;
11336 	int ret = -ENOTSUP;
11337 
11338 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11339 
11340 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11341 		return;
11342 
11343 #ifdef RTE_NET_IXGBE
11344 	if (ret == -ENOTSUP)
11345 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11346 #endif
11347 #ifdef RTE_NET_I40E
11348 	if (ret == -ENOTSUP)
11349 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11350 #endif
11351 #ifdef RTE_NET_BNXT
11352 	if (ret == -ENOTSUP)
11353 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11354 #endif
11355 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11356 	if (ret == -ENOTSUP)
11357 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11358 #endif
11359 
11360 	switch (ret) {
11361 	case 0:
11362 		break;
11363 	case -EINVAL:
11364 		printf("invalid is_on %d\n", is_on);
11365 		break;
11366 	case -ENODEV:
11367 		printf("invalid port_id %d\n", res->port_id);
11368 		break;
11369 	case -ENOTSUP:
11370 		printf("function not implemented\n");
11371 		break;
11372 	default:
11373 		printf("programming error: (%s)\n", strerror(-ret));
11374 	}
11375 }
11376 
11377 cmdline_parse_inst_t cmd_set_tx_loopback = {
11378 	.f = cmd_set_tx_loopback_parsed,
11379 	.data = NULL,
11380 	.help_str = "set tx loopback <port_id> on|off",
11381 	.tokens = {
11382 		(void *)&cmd_tx_loopback_set,
11383 		(void *)&cmd_tx_loopback_tx,
11384 		(void *)&cmd_tx_loopback_loopback,
11385 		(void *)&cmd_tx_loopback_port_id,
11386 		(void *)&cmd_tx_loopback_on_off,
11387 		NULL,
11388 	},
11389 };
11390 
11391 /* all queues drop enable configuration */
11392 
11393 /* Common result structure for all queues drop enable */
11394 struct cmd_all_queues_drop_en_result {
11395 	cmdline_fixed_string_t set;
11396 	cmdline_fixed_string_t all;
11397 	cmdline_fixed_string_t queues;
11398 	cmdline_fixed_string_t drop;
11399 	portid_t port_id;
11400 	cmdline_fixed_string_t on_off;
11401 };
11402 
11403 /* Common CLI fields for tx loopback enable disable */
11404 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11405 	TOKEN_STRING_INITIALIZER
11406 		(struct cmd_all_queues_drop_en_result,
11407 		 set, "set");
11408 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11409 	TOKEN_STRING_INITIALIZER
11410 		(struct cmd_all_queues_drop_en_result,
11411 		 all, "all");
11412 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11413 	TOKEN_STRING_INITIALIZER
11414 		(struct cmd_all_queues_drop_en_result,
11415 		 queues, "queues");
11416 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11417 	TOKEN_STRING_INITIALIZER
11418 		(struct cmd_all_queues_drop_en_result,
11419 		 drop, "drop");
11420 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11421 	TOKEN_NUM_INITIALIZER
11422 		(struct cmd_all_queues_drop_en_result,
11423 		 port_id, RTE_UINT16);
11424 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11425 	TOKEN_STRING_INITIALIZER
11426 		(struct cmd_all_queues_drop_en_result,
11427 		 on_off, "on#off");
11428 
11429 static void
11430 cmd_set_all_queues_drop_en_parsed(
11431 	void *parsed_result,
11432 	__rte_unused struct cmdline *cl,
11433 	__rte_unused void *data)
11434 {
11435 	struct cmd_all_queues_drop_en_result *res = parsed_result;
11436 	int ret = -ENOTSUP;
11437 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11438 
11439 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11440 		return;
11441 
11442 #ifdef RTE_NET_IXGBE
11443 	if (ret == -ENOTSUP)
11444 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11445 #endif
11446 #ifdef RTE_NET_BNXT
11447 	if (ret == -ENOTSUP)
11448 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11449 #endif
11450 	switch (ret) {
11451 	case 0:
11452 		break;
11453 	case -EINVAL:
11454 		printf("invalid is_on %d\n", is_on);
11455 		break;
11456 	case -ENODEV:
11457 		printf("invalid port_id %d\n", res->port_id);
11458 		break;
11459 	case -ENOTSUP:
11460 		printf("function not implemented\n");
11461 		break;
11462 	default:
11463 		printf("programming error: (%s)\n", strerror(-ret));
11464 	}
11465 }
11466 
11467 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11468 	.f = cmd_set_all_queues_drop_en_parsed,
11469 	.data = NULL,
11470 	.help_str = "set all queues drop <port_id> on|off",
11471 	.tokens = {
11472 		(void *)&cmd_all_queues_drop_en_set,
11473 		(void *)&cmd_all_queues_drop_en_all,
11474 		(void *)&cmd_all_queues_drop_en_queues,
11475 		(void *)&cmd_all_queues_drop_en_drop,
11476 		(void *)&cmd_all_queues_drop_en_port_id,
11477 		(void *)&cmd_all_queues_drop_en_on_off,
11478 		NULL,
11479 	},
11480 };
11481 
11482 /* vf split drop enable configuration */
11483 
11484 /* Common result structure for vf split drop enable */
11485 struct cmd_vf_split_drop_en_result {
11486 	cmdline_fixed_string_t set;
11487 	cmdline_fixed_string_t vf;
11488 	cmdline_fixed_string_t split;
11489 	cmdline_fixed_string_t drop;
11490 	portid_t port_id;
11491 	uint16_t vf_id;
11492 	cmdline_fixed_string_t on_off;
11493 };
11494 
11495 /* Common CLI fields for vf split drop enable disable */
11496 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11497 	TOKEN_STRING_INITIALIZER
11498 		(struct cmd_vf_split_drop_en_result,
11499 		 set, "set");
11500 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11501 	TOKEN_STRING_INITIALIZER
11502 		(struct cmd_vf_split_drop_en_result,
11503 		 vf, "vf");
11504 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11505 	TOKEN_STRING_INITIALIZER
11506 		(struct cmd_vf_split_drop_en_result,
11507 		 split, "split");
11508 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11509 	TOKEN_STRING_INITIALIZER
11510 		(struct cmd_vf_split_drop_en_result,
11511 		 drop, "drop");
11512 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11513 	TOKEN_NUM_INITIALIZER
11514 		(struct cmd_vf_split_drop_en_result,
11515 		 port_id, RTE_UINT16);
11516 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11517 	TOKEN_NUM_INITIALIZER
11518 		(struct cmd_vf_split_drop_en_result,
11519 		 vf_id, RTE_UINT16);
11520 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11521 	TOKEN_STRING_INITIALIZER
11522 		(struct cmd_vf_split_drop_en_result,
11523 		 on_off, "on#off");
11524 
11525 static void
11526 cmd_set_vf_split_drop_en_parsed(
11527 	void *parsed_result,
11528 	__rte_unused struct cmdline *cl,
11529 	__rte_unused void *data)
11530 {
11531 	struct cmd_vf_split_drop_en_result *res = parsed_result;
11532 	int ret = -ENOTSUP;
11533 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11534 
11535 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11536 		return;
11537 
11538 #ifdef RTE_NET_IXGBE
11539 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11540 			is_on);
11541 #endif
11542 	switch (ret) {
11543 	case 0:
11544 		break;
11545 	case -EINVAL:
11546 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11547 		break;
11548 	case -ENODEV:
11549 		printf("invalid port_id %d\n", res->port_id);
11550 		break;
11551 	case -ENOTSUP:
11552 		printf("not supported on port %d\n", res->port_id);
11553 		break;
11554 	default:
11555 		printf("programming error: (%s)\n", strerror(-ret));
11556 	}
11557 }
11558 
11559 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11560 	.f = cmd_set_vf_split_drop_en_parsed,
11561 	.data = NULL,
11562 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
11563 	.tokens = {
11564 		(void *)&cmd_vf_split_drop_en_set,
11565 		(void *)&cmd_vf_split_drop_en_vf,
11566 		(void *)&cmd_vf_split_drop_en_split,
11567 		(void *)&cmd_vf_split_drop_en_drop,
11568 		(void *)&cmd_vf_split_drop_en_port_id,
11569 		(void *)&cmd_vf_split_drop_en_vf_id,
11570 		(void *)&cmd_vf_split_drop_en_on_off,
11571 		NULL,
11572 	},
11573 };
11574 
11575 /* vf mac address configuration */
11576 
11577 /* Common result structure for vf mac address */
11578 struct cmd_set_vf_mac_addr_result {
11579 	cmdline_fixed_string_t set;
11580 	cmdline_fixed_string_t vf;
11581 	cmdline_fixed_string_t mac;
11582 	cmdline_fixed_string_t addr;
11583 	portid_t port_id;
11584 	uint16_t vf_id;
11585 	struct rte_ether_addr mac_addr;
11586 
11587 };
11588 
11589 /* Common CLI fields for vf split drop enable disable */
11590 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11591 	TOKEN_STRING_INITIALIZER
11592 		(struct cmd_set_vf_mac_addr_result,
11593 		 set, "set");
11594 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11595 	TOKEN_STRING_INITIALIZER
11596 		(struct cmd_set_vf_mac_addr_result,
11597 		 vf, "vf");
11598 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11599 	TOKEN_STRING_INITIALIZER
11600 		(struct cmd_set_vf_mac_addr_result,
11601 		 mac, "mac");
11602 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11603 	TOKEN_STRING_INITIALIZER
11604 		(struct cmd_set_vf_mac_addr_result,
11605 		 addr, "addr");
11606 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11607 	TOKEN_NUM_INITIALIZER
11608 		(struct cmd_set_vf_mac_addr_result,
11609 		 port_id, RTE_UINT16);
11610 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11611 	TOKEN_NUM_INITIALIZER
11612 		(struct cmd_set_vf_mac_addr_result,
11613 		 vf_id, RTE_UINT16);
11614 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11615 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11616 		 mac_addr);
11617 
11618 static void
11619 cmd_set_vf_mac_addr_parsed(
11620 	void *parsed_result,
11621 	__rte_unused struct cmdline *cl,
11622 	__rte_unused void *data)
11623 {
11624 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
11625 	int ret = -ENOTSUP;
11626 
11627 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11628 		return;
11629 
11630 #ifdef RTE_NET_IXGBE
11631 	if (ret == -ENOTSUP)
11632 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11633 				&res->mac_addr);
11634 #endif
11635 #ifdef RTE_NET_I40E
11636 	if (ret == -ENOTSUP)
11637 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11638 				&res->mac_addr);
11639 #endif
11640 #ifdef RTE_NET_BNXT
11641 	if (ret == -ENOTSUP)
11642 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11643 				&res->mac_addr);
11644 #endif
11645 
11646 	switch (ret) {
11647 	case 0:
11648 		break;
11649 	case -EINVAL:
11650 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11651 		break;
11652 	case -ENODEV:
11653 		printf("invalid port_id %d\n", res->port_id);
11654 		break;
11655 	case -ENOTSUP:
11656 		printf("function not implemented\n");
11657 		break;
11658 	default:
11659 		printf("programming error: (%s)\n", strerror(-ret));
11660 	}
11661 }
11662 
11663 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11664 	.f = cmd_set_vf_mac_addr_parsed,
11665 	.data = NULL,
11666 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11667 	.tokens = {
11668 		(void *)&cmd_set_vf_mac_addr_set,
11669 		(void *)&cmd_set_vf_mac_addr_vf,
11670 		(void *)&cmd_set_vf_mac_addr_mac,
11671 		(void *)&cmd_set_vf_mac_addr_addr,
11672 		(void *)&cmd_set_vf_mac_addr_port_id,
11673 		(void *)&cmd_set_vf_mac_addr_vf_id,
11674 		(void *)&cmd_set_vf_mac_addr_mac_addr,
11675 		NULL,
11676 	},
11677 };
11678 
11679 /* MACsec configuration */
11680 
11681 /* Common result structure for MACsec offload enable */
11682 struct cmd_macsec_offload_on_result {
11683 	cmdline_fixed_string_t set;
11684 	cmdline_fixed_string_t macsec;
11685 	cmdline_fixed_string_t offload;
11686 	portid_t port_id;
11687 	cmdline_fixed_string_t on;
11688 	cmdline_fixed_string_t encrypt;
11689 	cmdline_fixed_string_t en_on_off;
11690 	cmdline_fixed_string_t replay_protect;
11691 	cmdline_fixed_string_t rp_on_off;
11692 };
11693 
11694 /* Common CLI fields for MACsec offload disable */
11695 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11696 	TOKEN_STRING_INITIALIZER
11697 		(struct cmd_macsec_offload_on_result,
11698 		 set, "set");
11699 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11700 	TOKEN_STRING_INITIALIZER
11701 		(struct cmd_macsec_offload_on_result,
11702 		 macsec, "macsec");
11703 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11704 	TOKEN_STRING_INITIALIZER
11705 		(struct cmd_macsec_offload_on_result,
11706 		 offload, "offload");
11707 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11708 	TOKEN_NUM_INITIALIZER
11709 		(struct cmd_macsec_offload_on_result,
11710 		 port_id, RTE_UINT16);
11711 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11712 	TOKEN_STRING_INITIALIZER
11713 		(struct cmd_macsec_offload_on_result,
11714 		 on, "on");
11715 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11716 	TOKEN_STRING_INITIALIZER
11717 		(struct cmd_macsec_offload_on_result,
11718 		 encrypt, "encrypt");
11719 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11720 	TOKEN_STRING_INITIALIZER
11721 		(struct cmd_macsec_offload_on_result,
11722 		 en_on_off, "on#off");
11723 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11724 	TOKEN_STRING_INITIALIZER
11725 		(struct cmd_macsec_offload_on_result,
11726 		 replay_protect, "replay-protect");
11727 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11728 	TOKEN_STRING_INITIALIZER
11729 		(struct cmd_macsec_offload_on_result,
11730 		 rp_on_off, "on#off");
11731 
11732 static void
11733 cmd_set_macsec_offload_on_parsed(
11734 	void *parsed_result,
11735 	__rte_unused struct cmdline *cl,
11736 	__rte_unused void *data)
11737 {
11738 	struct cmd_macsec_offload_on_result *res = parsed_result;
11739 	int ret = -ENOTSUP;
11740 	portid_t port_id = res->port_id;
11741 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11742 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11743 	struct rte_eth_dev_info dev_info;
11744 
11745 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11746 		return;
11747 	if (!port_is_stopped(port_id)) {
11748 		printf("Please stop port %d first\n", port_id);
11749 		return;
11750 	}
11751 
11752 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11753 	if (ret != 0)
11754 		return;
11755 
11756 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11757 #ifdef RTE_NET_IXGBE
11758 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11759 #endif
11760 	}
11761 	RTE_SET_USED(en);
11762 	RTE_SET_USED(rp);
11763 
11764 	switch (ret) {
11765 	case 0:
11766 		ports[port_id].dev_conf.txmode.offloads |=
11767 						DEV_TX_OFFLOAD_MACSEC_INSERT;
11768 		cmd_reconfig_device_queue(port_id, 1, 1);
11769 		break;
11770 	case -ENODEV:
11771 		printf("invalid port_id %d\n", port_id);
11772 		break;
11773 	case -ENOTSUP:
11774 		printf("not supported on port %d\n", port_id);
11775 		break;
11776 	default:
11777 		printf("programming error: (%s)\n", strerror(-ret));
11778 	}
11779 }
11780 
11781 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11782 	.f = cmd_set_macsec_offload_on_parsed,
11783 	.data = NULL,
11784 	.help_str = "set macsec offload <port_id> on "
11785 		"encrypt on|off replay-protect on|off",
11786 	.tokens = {
11787 		(void *)&cmd_macsec_offload_on_set,
11788 		(void *)&cmd_macsec_offload_on_macsec,
11789 		(void *)&cmd_macsec_offload_on_offload,
11790 		(void *)&cmd_macsec_offload_on_port_id,
11791 		(void *)&cmd_macsec_offload_on_on,
11792 		(void *)&cmd_macsec_offload_on_encrypt,
11793 		(void *)&cmd_macsec_offload_on_en_on_off,
11794 		(void *)&cmd_macsec_offload_on_replay_protect,
11795 		(void *)&cmd_macsec_offload_on_rp_on_off,
11796 		NULL,
11797 	},
11798 };
11799 
11800 /* Common result structure for MACsec offload disable */
11801 struct cmd_macsec_offload_off_result {
11802 	cmdline_fixed_string_t set;
11803 	cmdline_fixed_string_t macsec;
11804 	cmdline_fixed_string_t offload;
11805 	portid_t port_id;
11806 	cmdline_fixed_string_t off;
11807 };
11808 
11809 /* Common CLI fields for MACsec offload disable */
11810 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11811 	TOKEN_STRING_INITIALIZER
11812 		(struct cmd_macsec_offload_off_result,
11813 		 set, "set");
11814 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11815 	TOKEN_STRING_INITIALIZER
11816 		(struct cmd_macsec_offload_off_result,
11817 		 macsec, "macsec");
11818 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11819 	TOKEN_STRING_INITIALIZER
11820 		(struct cmd_macsec_offload_off_result,
11821 		 offload, "offload");
11822 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11823 	TOKEN_NUM_INITIALIZER
11824 		(struct cmd_macsec_offload_off_result,
11825 		 port_id, RTE_UINT16);
11826 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11827 	TOKEN_STRING_INITIALIZER
11828 		(struct cmd_macsec_offload_off_result,
11829 		 off, "off");
11830 
11831 static void
11832 cmd_set_macsec_offload_off_parsed(
11833 	void *parsed_result,
11834 	__rte_unused struct cmdline *cl,
11835 	__rte_unused void *data)
11836 {
11837 	struct cmd_macsec_offload_off_result *res = parsed_result;
11838 	int ret = -ENOTSUP;
11839 	struct rte_eth_dev_info dev_info;
11840 	portid_t port_id = res->port_id;
11841 
11842 	if (port_id_is_invalid(port_id, ENABLED_WARN))
11843 		return;
11844 	if (!port_is_stopped(port_id)) {
11845 		printf("Please stop port %d first\n", port_id);
11846 		return;
11847 	}
11848 
11849 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
11850 	if (ret != 0)
11851 		return;
11852 
11853 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11854 #ifdef RTE_NET_IXGBE
11855 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
11856 #endif
11857 	}
11858 	switch (ret) {
11859 	case 0:
11860 		ports[port_id].dev_conf.txmode.offloads &=
11861 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
11862 		cmd_reconfig_device_queue(port_id, 1, 1);
11863 		break;
11864 	case -ENODEV:
11865 		printf("invalid port_id %d\n", port_id);
11866 		break;
11867 	case -ENOTSUP:
11868 		printf("not supported on port %d\n", port_id);
11869 		break;
11870 	default:
11871 		printf("programming error: (%s)\n", strerror(-ret));
11872 	}
11873 }
11874 
11875 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11876 	.f = cmd_set_macsec_offload_off_parsed,
11877 	.data = NULL,
11878 	.help_str = "set macsec offload <port_id> off",
11879 	.tokens = {
11880 		(void *)&cmd_macsec_offload_off_set,
11881 		(void *)&cmd_macsec_offload_off_macsec,
11882 		(void *)&cmd_macsec_offload_off_offload,
11883 		(void *)&cmd_macsec_offload_off_port_id,
11884 		(void *)&cmd_macsec_offload_off_off,
11885 		NULL,
11886 	},
11887 };
11888 
11889 /* Common result structure for MACsec secure connection configure */
11890 struct cmd_macsec_sc_result {
11891 	cmdline_fixed_string_t set;
11892 	cmdline_fixed_string_t macsec;
11893 	cmdline_fixed_string_t sc;
11894 	cmdline_fixed_string_t tx_rx;
11895 	portid_t port_id;
11896 	struct rte_ether_addr mac;
11897 	uint16_t pi;
11898 };
11899 
11900 /* Common CLI fields for MACsec secure connection configure */
11901 cmdline_parse_token_string_t cmd_macsec_sc_set =
11902 	TOKEN_STRING_INITIALIZER
11903 		(struct cmd_macsec_sc_result,
11904 		 set, "set");
11905 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11906 	TOKEN_STRING_INITIALIZER
11907 		(struct cmd_macsec_sc_result,
11908 		 macsec, "macsec");
11909 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11910 	TOKEN_STRING_INITIALIZER
11911 		(struct cmd_macsec_sc_result,
11912 		 sc, "sc");
11913 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11914 	TOKEN_STRING_INITIALIZER
11915 		(struct cmd_macsec_sc_result,
11916 		 tx_rx, "tx#rx");
11917 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11918 	TOKEN_NUM_INITIALIZER
11919 		(struct cmd_macsec_sc_result,
11920 		 port_id, RTE_UINT16);
11921 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11922 	TOKEN_ETHERADDR_INITIALIZER
11923 		(struct cmd_macsec_sc_result,
11924 		 mac);
11925 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11926 	TOKEN_NUM_INITIALIZER
11927 		(struct cmd_macsec_sc_result,
11928 		 pi, RTE_UINT16);
11929 
11930 static void
11931 cmd_set_macsec_sc_parsed(
11932 	void *parsed_result,
11933 	__rte_unused struct cmdline *cl,
11934 	__rte_unused void *data)
11935 {
11936 	struct cmd_macsec_sc_result *res = parsed_result;
11937 	int ret = -ENOTSUP;
11938 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11939 
11940 #ifdef RTE_NET_IXGBE
11941 	ret = is_tx ?
11942 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11943 				res->mac.addr_bytes) :
11944 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11945 				res->mac.addr_bytes, res->pi);
11946 #endif
11947 	RTE_SET_USED(is_tx);
11948 
11949 	switch (ret) {
11950 	case 0:
11951 		break;
11952 	case -ENODEV:
11953 		printf("invalid port_id %d\n", res->port_id);
11954 		break;
11955 	case -ENOTSUP:
11956 		printf("not supported on port %d\n", res->port_id);
11957 		break;
11958 	default:
11959 		printf("programming error: (%s)\n", strerror(-ret));
11960 	}
11961 }
11962 
11963 cmdline_parse_inst_t cmd_set_macsec_sc = {
11964 	.f = cmd_set_macsec_sc_parsed,
11965 	.data = NULL,
11966 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11967 	.tokens = {
11968 		(void *)&cmd_macsec_sc_set,
11969 		(void *)&cmd_macsec_sc_macsec,
11970 		(void *)&cmd_macsec_sc_sc,
11971 		(void *)&cmd_macsec_sc_tx_rx,
11972 		(void *)&cmd_macsec_sc_port_id,
11973 		(void *)&cmd_macsec_sc_mac,
11974 		(void *)&cmd_macsec_sc_pi,
11975 		NULL,
11976 	},
11977 };
11978 
11979 /* Common result structure for MACsec secure connection configure */
11980 struct cmd_macsec_sa_result {
11981 	cmdline_fixed_string_t set;
11982 	cmdline_fixed_string_t macsec;
11983 	cmdline_fixed_string_t sa;
11984 	cmdline_fixed_string_t tx_rx;
11985 	portid_t port_id;
11986 	uint8_t idx;
11987 	uint8_t an;
11988 	uint32_t pn;
11989 	cmdline_fixed_string_t key;
11990 };
11991 
11992 /* Common CLI fields for MACsec secure connection configure */
11993 cmdline_parse_token_string_t cmd_macsec_sa_set =
11994 	TOKEN_STRING_INITIALIZER
11995 		(struct cmd_macsec_sa_result,
11996 		 set, "set");
11997 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11998 	TOKEN_STRING_INITIALIZER
11999 		(struct cmd_macsec_sa_result,
12000 		 macsec, "macsec");
12001 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12002 	TOKEN_STRING_INITIALIZER
12003 		(struct cmd_macsec_sa_result,
12004 		 sa, "sa");
12005 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12006 	TOKEN_STRING_INITIALIZER
12007 		(struct cmd_macsec_sa_result,
12008 		 tx_rx, "tx#rx");
12009 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12010 	TOKEN_NUM_INITIALIZER
12011 		(struct cmd_macsec_sa_result,
12012 		 port_id, RTE_UINT16);
12013 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12014 	TOKEN_NUM_INITIALIZER
12015 		(struct cmd_macsec_sa_result,
12016 		 idx, RTE_UINT8);
12017 cmdline_parse_token_num_t cmd_macsec_sa_an =
12018 	TOKEN_NUM_INITIALIZER
12019 		(struct cmd_macsec_sa_result,
12020 		 an, RTE_UINT8);
12021 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12022 	TOKEN_NUM_INITIALIZER
12023 		(struct cmd_macsec_sa_result,
12024 		 pn, RTE_UINT32);
12025 cmdline_parse_token_string_t cmd_macsec_sa_key =
12026 	TOKEN_STRING_INITIALIZER
12027 		(struct cmd_macsec_sa_result,
12028 		 key, NULL);
12029 
12030 static void
12031 cmd_set_macsec_sa_parsed(
12032 	void *parsed_result,
12033 	__rte_unused struct cmdline *cl,
12034 	__rte_unused void *data)
12035 {
12036 	struct cmd_macsec_sa_result *res = parsed_result;
12037 	int ret = -ENOTSUP;
12038 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12039 	uint8_t key[16] = { 0 };
12040 	uint8_t xdgt0;
12041 	uint8_t xdgt1;
12042 	int key_len;
12043 	int i;
12044 
12045 	key_len = strlen(res->key) / 2;
12046 	if (key_len > 16)
12047 		key_len = 16;
12048 
12049 	for (i = 0; i < key_len; i++) {
12050 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12051 		if (xdgt0 == 0xFF)
12052 			return;
12053 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12054 		if (xdgt1 == 0xFF)
12055 			return;
12056 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12057 	}
12058 
12059 #ifdef RTE_NET_IXGBE
12060 	ret = is_tx ?
12061 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12062 			res->idx, res->an, res->pn, key) :
12063 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12064 			res->idx, res->an, res->pn, key);
12065 #endif
12066 	RTE_SET_USED(is_tx);
12067 	RTE_SET_USED(key);
12068 
12069 	switch (ret) {
12070 	case 0:
12071 		break;
12072 	case -EINVAL:
12073 		printf("invalid idx %d or an %d\n", res->idx, res->an);
12074 		break;
12075 	case -ENODEV:
12076 		printf("invalid port_id %d\n", res->port_id);
12077 		break;
12078 	case -ENOTSUP:
12079 		printf("not supported on port %d\n", res->port_id);
12080 		break;
12081 	default:
12082 		printf("programming error: (%s)\n", strerror(-ret));
12083 	}
12084 }
12085 
12086 cmdline_parse_inst_t cmd_set_macsec_sa = {
12087 	.f = cmd_set_macsec_sa_parsed,
12088 	.data = NULL,
12089 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12090 	.tokens = {
12091 		(void *)&cmd_macsec_sa_set,
12092 		(void *)&cmd_macsec_sa_macsec,
12093 		(void *)&cmd_macsec_sa_sa,
12094 		(void *)&cmd_macsec_sa_tx_rx,
12095 		(void *)&cmd_macsec_sa_port_id,
12096 		(void *)&cmd_macsec_sa_idx,
12097 		(void *)&cmd_macsec_sa_an,
12098 		(void *)&cmd_macsec_sa_pn,
12099 		(void *)&cmd_macsec_sa_key,
12100 		NULL,
12101 	},
12102 };
12103 
12104 /* VF unicast promiscuous mode configuration */
12105 
12106 /* Common result structure for VF unicast promiscuous mode */
12107 struct cmd_vf_promisc_result {
12108 	cmdline_fixed_string_t set;
12109 	cmdline_fixed_string_t vf;
12110 	cmdline_fixed_string_t promisc;
12111 	portid_t port_id;
12112 	uint32_t vf_id;
12113 	cmdline_fixed_string_t on_off;
12114 };
12115 
12116 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12117 cmdline_parse_token_string_t cmd_vf_promisc_set =
12118 	TOKEN_STRING_INITIALIZER
12119 		(struct cmd_vf_promisc_result,
12120 		 set, "set");
12121 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12122 	TOKEN_STRING_INITIALIZER
12123 		(struct cmd_vf_promisc_result,
12124 		 vf, "vf");
12125 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12126 	TOKEN_STRING_INITIALIZER
12127 		(struct cmd_vf_promisc_result,
12128 		 promisc, "promisc");
12129 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12130 	TOKEN_NUM_INITIALIZER
12131 		(struct cmd_vf_promisc_result,
12132 		 port_id, RTE_UINT16);
12133 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12134 	TOKEN_NUM_INITIALIZER
12135 		(struct cmd_vf_promisc_result,
12136 		 vf_id, RTE_UINT32);
12137 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12138 	TOKEN_STRING_INITIALIZER
12139 		(struct cmd_vf_promisc_result,
12140 		 on_off, "on#off");
12141 
12142 static void
12143 cmd_set_vf_promisc_parsed(
12144 	void *parsed_result,
12145 	__rte_unused struct cmdline *cl,
12146 	__rte_unused void *data)
12147 {
12148 	struct cmd_vf_promisc_result *res = parsed_result;
12149 	int ret = -ENOTSUP;
12150 
12151 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12152 
12153 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12154 		return;
12155 
12156 #ifdef RTE_NET_I40E
12157 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12158 						  res->vf_id, is_on);
12159 #endif
12160 
12161 	switch (ret) {
12162 	case 0:
12163 		break;
12164 	case -EINVAL:
12165 		printf("invalid vf_id %d\n", res->vf_id);
12166 		break;
12167 	case -ENODEV:
12168 		printf("invalid port_id %d\n", res->port_id);
12169 		break;
12170 	case -ENOTSUP:
12171 		printf("function not implemented\n");
12172 		break;
12173 	default:
12174 		printf("programming error: (%s)\n", strerror(-ret));
12175 	}
12176 }
12177 
12178 cmdline_parse_inst_t cmd_set_vf_promisc = {
12179 	.f = cmd_set_vf_promisc_parsed,
12180 	.data = NULL,
12181 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
12182 		"Set unicast promiscuous mode for a VF from the PF",
12183 	.tokens = {
12184 		(void *)&cmd_vf_promisc_set,
12185 		(void *)&cmd_vf_promisc_vf,
12186 		(void *)&cmd_vf_promisc_promisc,
12187 		(void *)&cmd_vf_promisc_port_id,
12188 		(void *)&cmd_vf_promisc_vf_id,
12189 		(void *)&cmd_vf_promisc_on_off,
12190 		NULL,
12191 	},
12192 };
12193 
12194 /* VF multicast promiscuous mode configuration */
12195 
12196 /* Common result structure for VF multicast promiscuous mode */
12197 struct cmd_vf_allmulti_result {
12198 	cmdline_fixed_string_t set;
12199 	cmdline_fixed_string_t vf;
12200 	cmdline_fixed_string_t allmulti;
12201 	portid_t port_id;
12202 	uint32_t vf_id;
12203 	cmdline_fixed_string_t on_off;
12204 };
12205 
12206 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12207 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12208 	TOKEN_STRING_INITIALIZER
12209 		(struct cmd_vf_allmulti_result,
12210 		 set, "set");
12211 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12212 	TOKEN_STRING_INITIALIZER
12213 		(struct cmd_vf_allmulti_result,
12214 		 vf, "vf");
12215 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12216 	TOKEN_STRING_INITIALIZER
12217 		(struct cmd_vf_allmulti_result,
12218 		 allmulti, "allmulti");
12219 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12220 	TOKEN_NUM_INITIALIZER
12221 		(struct cmd_vf_allmulti_result,
12222 		 port_id, RTE_UINT16);
12223 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12224 	TOKEN_NUM_INITIALIZER
12225 		(struct cmd_vf_allmulti_result,
12226 		 vf_id, RTE_UINT32);
12227 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12228 	TOKEN_STRING_INITIALIZER
12229 		(struct cmd_vf_allmulti_result,
12230 		 on_off, "on#off");
12231 
12232 static void
12233 cmd_set_vf_allmulti_parsed(
12234 	void *parsed_result,
12235 	__rte_unused struct cmdline *cl,
12236 	__rte_unused void *data)
12237 {
12238 	struct cmd_vf_allmulti_result *res = parsed_result;
12239 	int ret = -ENOTSUP;
12240 
12241 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12242 
12243 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12244 		return;
12245 
12246 #ifdef RTE_NET_I40E
12247 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12248 						    res->vf_id, is_on);
12249 #endif
12250 
12251 	switch (ret) {
12252 	case 0:
12253 		break;
12254 	case -EINVAL:
12255 		printf("invalid vf_id %d\n", res->vf_id);
12256 		break;
12257 	case -ENODEV:
12258 		printf("invalid port_id %d\n", res->port_id);
12259 		break;
12260 	case -ENOTSUP:
12261 		printf("function not implemented\n");
12262 		break;
12263 	default:
12264 		printf("programming error: (%s)\n", strerror(-ret));
12265 	}
12266 }
12267 
12268 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12269 	.f = cmd_set_vf_allmulti_parsed,
12270 	.data = NULL,
12271 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12272 		"Set multicast promiscuous mode for a VF from the PF",
12273 	.tokens = {
12274 		(void *)&cmd_vf_allmulti_set,
12275 		(void *)&cmd_vf_allmulti_vf,
12276 		(void *)&cmd_vf_allmulti_allmulti,
12277 		(void *)&cmd_vf_allmulti_port_id,
12278 		(void *)&cmd_vf_allmulti_vf_id,
12279 		(void *)&cmd_vf_allmulti_on_off,
12280 		NULL,
12281 	},
12282 };
12283 
12284 /* vf broadcast mode configuration */
12285 
12286 /* Common result structure for vf broadcast */
12287 struct cmd_set_vf_broadcast_result {
12288 	cmdline_fixed_string_t set;
12289 	cmdline_fixed_string_t vf;
12290 	cmdline_fixed_string_t broadcast;
12291 	portid_t port_id;
12292 	uint16_t vf_id;
12293 	cmdline_fixed_string_t on_off;
12294 };
12295 
12296 /* Common CLI fields for vf broadcast enable disable */
12297 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12298 	TOKEN_STRING_INITIALIZER
12299 		(struct cmd_set_vf_broadcast_result,
12300 		 set, "set");
12301 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12302 	TOKEN_STRING_INITIALIZER
12303 		(struct cmd_set_vf_broadcast_result,
12304 		 vf, "vf");
12305 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12306 	TOKEN_STRING_INITIALIZER
12307 		(struct cmd_set_vf_broadcast_result,
12308 		 broadcast, "broadcast");
12309 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12310 	TOKEN_NUM_INITIALIZER
12311 		(struct cmd_set_vf_broadcast_result,
12312 		 port_id, RTE_UINT16);
12313 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12314 	TOKEN_NUM_INITIALIZER
12315 		(struct cmd_set_vf_broadcast_result,
12316 		 vf_id, RTE_UINT16);
12317 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12318 	TOKEN_STRING_INITIALIZER
12319 		(struct cmd_set_vf_broadcast_result,
12320 		 on_off, "on#off");
12321 
12322 static void
12323 cmd_set_vf_broadcast_parsed(
12324 	void *parsed_result,
12325 	__rte_unused struct cmdline *cl,
12326 	__rte_unused void *data)
12327 {
12328 	struct cmd_set_vf_broadcast_result *res = parsed_result;
12329 	int ret = -ENOTSUP;
12330 
12331 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12332 
12333 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12334 		return;
12335 
12336 #ifdef RTE_NET_I40E
12337 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12338 					    res->vf_id, is_on);
12339 #endif
12340 
12341 	switch (ret) {
12342 	case 0:
12343 		break;
12344 	case -EINVAL:
12345 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12346 		break;
12347 	case -ENODEV:
12348 		printf("invalid port_id %d\n", res->port_id);
12349 		break;
12350 	case -ENOTSUP:
12351 		printf("function not implemented\n");
12352 		break;
12353 	default:
12354 		printf("programming error: (%s)\n", strerror(-ret));
12355 	}
12356 }
12357 
12358 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12359 	.f = cmd_set_vf_broadcast_parsed,
12360 	.data = NULL,
12361 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
12362 	.tokens = {
12363 		(void *)&cmd_set_vf_broadcast_set,
12364 		(void *)&cmd_set_vf_broadcast_vf,
12365 		(void *)&cmd_set_vf_broadcast_broadcast,
12366 		(void *)&cmd_set_vf_broadcast_port_id,
12367 		(void *)&cmd_set_vf_broadcast_vf_id,
12368 		(void *)&cmd_set_vf_broadcast_on_off,
12369 		NULL,
12370 	},
12371 };
12372 
12373 /* vf vlan tag configuration */
12374 
12375 /* Common result structure for vf vlan tag */
12376 struct cmd_set_vf_vlan_tag_result {
12377 	cmdline_fixed_string_t set;
12378 	cmdline_fixed_string_t vf;
12379 	cmdline_fixed_string_t vlan;
12380 	cmdline_fixed_string_t tag;
12381 	portid_t port_id;
12382 	uint16_t vf_id;
12383 	cmdline_fixed_string_t on_off;
12384 };
12385 
12386 /* Common CLI fields for vf vlan tag enable disable */
12387 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12388 	TOKEN_STRING_INITIALIZER
12389 		(struct cmd_set_vf_vlan_tag_result,
12390 		 set, "set");
12391 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12392 	TOKEN_STRING_INITIALIZER
12393 		(struct cmd_set_vf_vlan_tag_result,
12394 		 vf, "vf");
12395 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12396 	TOKEN_STRING_INITIALIZER
12397 		(struct cmd_set_vf_vlan_tag_result,
12398 		 vlan, "vlan");
12399 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12400 	TOKEN_STRING_INITIALIZER
12401 		(struct cmd_set_vf_vlan_tag_result,
12402 		 tag, "tag");
12403 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12404 	TOKEN_NUM_INITIALIZER
12405 		(struct cmd_set_vf_vlan_tag_result,
12406 		 port_id, RTE_UINT16);
12407 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12408 	TOKEN_NUM_INITIALIZER
12409 		(struct cmd_set_vf_vlan_tag_result,
12410 		 vf_id, RTE_UINT16);
12411 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12412 	TOKEN_STRING_INITIALIZER
12413 		(struct cmd_set_vf_vlan_tag_result,
12414 		 on_off, "on#off");
12415 
12416 static void
12417 cmd_set_vf_vlan_tag_parsed(
12418 	void *parsed_result,
12419 	__rte_unused struct cmdline *cl,
12420 	__rte_unused void *data)
12421 {
12422 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12423 	int ret = -ENOTSUP;
12424 
12425 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12426 
12427 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12428 		return;
12429 
12430 #ifdef RTE_NET_I40E
12431 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12432 					   res->vf_id, is_on);
12433 #endif
12434 
12435 	switch (ret) {
12436 	case 0:
12437 		break;
12438 	case -EINVAL:
12439 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12440 		break;
12441 	case -ENODEV:
12442 		printf("invalid port_id %d\n", res->port_id);
12443 		break;
12444 	case -ENOTSUP:
12445 		printf("function not implemented\n");
12446 		break;
12447 	default:
12448 		printf("programming error: (%s)\n", strerror(-ret));
12449 	}
12450 }
12451 
12452 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12453 	.f = cmd_set_vf_vlan_tag_parsed,
12454 	.data = NULL,
12455 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12456 	.tokens = {
12457 		(void *)&cmd_set_vf_vlan_tag_set,
12458 		(void *)&cmd_set_vf_vlan_tag_vf,
12459 		(void *)&cmd_set_vf_vlan_tag_vlan,
12460 		(void *)&cmd_set_vf_vlan_tag_tag,
12461 		(void *)&cmd_set_vf_vlan_tag_port_id,
12462 		(void *)&cmd_set_vf_vlan_tag_vf_id,
12463 		(void *)&cmd_set_vf_vlan_tag_on_off,
12464 		NULL,
12465 	},
12466 };
12467 
12468 /* Common definition of VF and TC TX bandwidth configuration */
12469 struct cmd_vf_tc_bw_result {
12470 	cmdline_fixed_string_t set;
12471 	cmdline_fixed_string_t vf;
12472 	cmdline_fixed_string_t tc;
12473 	cmdline_fixed_string_t tx;
12474 	cmdline_fixed_string_t min_bw;
12475 	cmdline_fixed_string_t max_bw;
12476 	cmdline_fixed_string_t strict_link_prio;
12477 	portid_t port_id;
12478 	uint16_t vf_id;
12479 	uint8_t tc_no;
12480 	uint32_t bw;
12481 	cmdline_fixed_string_t bw_list;
12482 	uint8_t tc_map;
12483 };
12484 
12485 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12486 	TOKEN_STRING_INITIALIZER
12487 		(struct cmd_vf_tc_bw_result,
12488 		 set, "set");
12489 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12490 	TOKEN_STRING_INITIALIZER
12491 		(struct cmd_vf_tc_bw_result,
12492 		 vf, "vf");
12493 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12494 	TOKEN_STRING_INITIALIZER
12495 		(struct cmd_vf_tc_bw_result,
12496 		 tc, "tc");
12497 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12498 	TOKEN_STRING_INITIALIZER
12499 		(struct cmd_vf_tc_bw_result,
12500 		 tx, "tx");
12501 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12502 	TOKEN_STRING_INITIALIZER
12503 		(struct cmd_vf_tc_bw_result,
12504 		 strict_link_prio, "strict-link-priority");
12505 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12506 	TOKEN_STRING_INITIALIZER
12507 		(struct cmd_vf_tc_bw_result,
12508 		 min_bw, "min-bandwidth");
12509 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12510 	TOKEN_STRING_INITIALIZER
12511 		(struct cmd_vf_tc_bw_result,
12512 		 max_bw, "max-bandwidth");
12513 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12514 	TOKEN_NUM_INITIALIZER
12515 		(struct cmd_vf_tc_bw_result,
12516 		 port_id, RTE_UINT16);
12517 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12518 	TOKEN_NUM_INITIALIZER
12519 		(struct cmd_vf_tc_bw_result,
12520 		 vf_id, RTE_UINT16);
12521 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12522 	TOKEN_NUM_INITIALIZER
12523 		(struct cmd_vf_tc_bw_result,
12524 		 tc_no, RTE_UINT8);
12525 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12526 	TOKEN_NUM_INITIALIZER
12527 		(struct cmd_vf_tc_bw_result,
12528 		 bw, RTE_UINT32);
12529 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12530 	TOKEN_STRING_INITIALIZER
12531 		(struct cmd_vf_tc_bw_result,
12532 		 bw_list, NULL);
12533 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12534 	TOKEN_NUM_INITIALIZER
12535 		(struct cmd_vf_tc_bw_result,
12536 		 tc_map, RTE_UINT8);
12537 
12538 /* VF max bandwidth setting */
12539 static void
12540 cmd_vf_max_bw_parsed(
12541 	void *parsed_result,
12542 	__rte_unused struct cmdline *cl,
12543 	__rte_unused void *data)
12544 {
12545 	struct cmd_vf_tc_bw_result *res = parsed_result;
12546 	int ret = -ENOTSUP;
12547 
12548 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12549 		return;
12550 
12551 #ifdef RTE_NET_I40E
12552 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12553 					 res->vf_id, res->bw);
12554 #endif
12555 
12556 	switch (ret) {
12557 	case 0:
12558 		break;
12559 	case -EINVAL:
12560 		printf("invalid vf_id %d or bandwidth %d\n",
12561 		       res->vf_id, res->bw);
12562 		break;
12563 	case -ENODEV:
12564 		printf("invalid port_id %d\n", res->port_id);
12565 		break;
12566 	case -ENOTSUP:
12567 		printf("function not implemented\n");
12568 		break;
12569 	default:
12570 		printf("programming error: (%s)\n", strerror(-ret));
12571 	}
12572 }
12573 
12574 cmdline_parse_inst_t cmd_vf_max_bw = {
12575 	.f = cmd_vf_max_bw_parsed,
12576 	.data = NULL,
12577 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12578 	.tokens = {
12579 		(void *)&cmd_vf_tc_bw_set,
12580 		(void *)&cmd_vf_tc_bw_vf,
12581 		(void *)&cmd_vf_tc_bw_tx,
12582 		(void *)&cmd_vf_tc_bw_max_bw,
12583 		(void *)&cmd_vf_tc_bw_port_id,
12584 		(void *)&cmd_vf_tc_bw_vf_id,
12585 		(void *)&cmd_vf_tc_bw_bw,
12586 		NULL,
12587 	},
12588 };
12589 
12590 static int
12591 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12592 			   uint8_t *tc_num,
12593 			   char *str)
12594 {
12595 	uint32_t size;
12596 	const char *p, *p0 = str;
12597 	char s[256];
12598 	char *end;
12599 	char *str_fld[16];
12600 	uint16_t i;
12601 	int ret;
12602 
12603 	p = strchr(p0, '(');
12604 	if (p == NULL) {
12605 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12606 		return -1;
12607 	}
12608 	p++;
12609 	p0 = strchr(p, ')');
12610 	if (p0 == NULL) {
12611 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12612 		return -1;
12613 	}
12614 	size = p0 - p;
12615 	if (size >= sizeof(s)) {
12616 		printf("The string size exceeds the internal buffer size\n");
12617 		return -1;
12618 	}
12619 	snprintf(s, sizeof(s), "%.*s", size, p);
12620 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12621 	if (ret <= 0) {
12622 		printf("Failed to get the bandwidth list. ");
12623 		return -1;
12624 	}
12625 	*tc_num = ret;
12626 	for (i = 0; i < ret; i++)
12627 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12628 
12629 	return 0;
12630 }
12631 
12632 /* TC min bandwidth setting */
12633 static void
12634 cmd_vf_tc_min_bw_parsed(
12635 	void *parsed_result,
12636 	__rte_unused struct cmdline *cl,
12637 	__rte_unused void *data)
12638 {
12639 	struct cmd_vf_tc_bw_result *res = parsed_result;
12640 	uint8_t tc_num;
12641 	uint8_t bw[16];
12642 	int ret = -ENOTSUP;
12643 
12644 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12645 		return;
12646 
12647 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12648 	if (ret)
12649 		return;
12650 
12651 #ifdef RTE_NET_I40E
12652 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12653 					      tc_num, bw);
12654 #endif
12655 
12656 	switch (ret) {
12657 	case 0:
12658 		break;
12659 	case -EINVAL:
12660 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12661 		break;
12662 	case -ENODEV:
12663 		printf("invalid port_id %d\n", res->port_id);
12664 		break;
12665 	case -ENOTSUP:
12666 		printf("function not implemented\n");
12667 		break;
12668 	default:
12669 		printf("programming error: (%s)\n", strerror(-ret));
12670 	}
12671 }
12672 
12673 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12674 	.f = cmd_vf_tc_min_bw_parsed,
12675 	.data = NULL,
12676 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12677 		    " <bw1, bw2, ...>",
12678 	.tokens = {
12679 		(void *)&cmd_vf_tc_bw_set,
12680 		(void *)&cmd_vf_tc_bw_vf,
12681 		(void *)&cmd_vf_tc_bw_tc,
12682 		(void *)&cmd_vf_tc_bw_tx,
12683 		(void *)&cmd_vf_tc_bw_min_bw,
12684 		(void *)&cmd_vf_tc_bw_port_id,
12685 		(void *)&cmd_vf_tc_bw_vf_id,
12686 		(void *)&cmd_vf_tc_bw_bw_list,
12687 		NULL,
12688 	},
12689 };
12690 
12691 static void
12692 cmd_tc_min_bw_parsed(
12693 	void *parsed_result,
12694 	__rte_unused struct cmdline *cl,
12695 	__rte_unused void *data)
12696 {
12697 	struct cmd_vf_tc_bw_result *res = parsed_result;
12698 	struct rte_port *port;
12699 	uint8_t tc_num;
12700 	uint8_t bw[16];
12701 	int ret = -ENOTSUP;
12702 
12703 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12704 		return;
12705 
12706 	port = &ports[res->port_id];
12707 	/** Check if the port is not started **/
12708 	if (port->port_status != RTE_PORT_STOPPED) {
12709 		printf("Please stop port %d first\n", res->port_id);
12710 		return;
12711 	}
12712 
12713 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12714 	if (ret)
12715 		return;
12716 
12717 #ifdef RTE_NET_IXGBE
12718 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12719 #endif
12720 
12721 	switch (ret) {
12722 	case 0:
12723 		break;
12724 	case -EINVAL:
12725 		printf("invalid bandwidth\n");
12726 		break;
12727 	case -ENODEV:
12728 		printf("invalid port_id %d\n", res->port_id);
12729 		break;
12730 	case -ENOTSUP:
12731 		printf("function not implemented\n");
12732 		break;
12733 	default:
12734 		printf("programming error: (%s)\n", strerror(-ret));
12735 	}
12736 }
12737 
12738 cmdline_parse_inst_t cmd_tc_min_bw = {
12739 	.f = cmd_tc_min_bw_parsed,
12740 	.data = NULL,
12741 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12742 	.tokens = {
12743 		(void *)&cmd_vf_tc_bw_set,
12744 		(void *)&cmd_vf_tc_bw_tc,
12745 		(void *)&cmd_vf_tc_bw_tx,
12746 		(void *)&cmd_vf_tc_bw_min_bw,
12747 		(void *)&cmd_vf_tc_bw_port_id,
12748 		(void *)&cmd_vf_tc_bw_bw_list,
12749 		NULL,
12750 	},
12751 };
12752 
12753 /* TC max bandwidth setting */
12754 static void
12755 cmd_vf_tc_max_bw_parsed(
12756 	void *parsed_result,
12757 	__rte_unused struct cmdline *cl,
12758 	__rte_unused void *data)
12759 {
12760 	struct cmd_vf_tc_bw_result *res = parsed_result;
12761 	int ret = -ENOTSUP;
12762 
12763 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12764 		return;
12765 
12766 #ifdef RTE_NET_I40E
12767 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12768 					    res->tc_no, res->bw);
12769 #endif
12770 
12771 	switch (ret) {
12772 	case 0:
12773 		break;
12774 	case -EINVAL:
12775 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12776 		       res->vf_id, res->tc_no, res->bw);
12777 		break;
12778 	case -ENODEV:
12779 		printf("invalid port_id %d\n", res->port_id);
12780 		break;
12781 	case -ENOTSUP:
12782 		printf("function not implemented\n");
12783 		break;
12784 	default:
12785 		printf("programming error: (%s)\n", strerror(-ret));
12786 	}
12787 }
12788 
12789 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12790 	.f = cmd_vf_tc_max_bw_parsed,
12791 	.data = NULL,
12792 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12793 		    " <bandwidth>",
12794 	.tokens = {
12795 		(void *)&cmd_vf_tc_bw_set,
12796 		(void *)&cmd_vf_tc_bw_vf,
12797 		(void *)&cmd_vf_tc_bw_tc,
12798 		(void *)&cmd_vf_tc_bw_tx,
12799 		(void *)&cmd_vf_tc_bw_max_bw,
12800 		(void *)&cmd_vf_tc_bw_port_id,
12801 		(void *)&cmd_vf_tc_bw_vf_id,
12802 		(void *)&cmd_vf_tc_bw_tc_no,
12803 		(void *)&cmd_vf_tc_bw_bw,
12804 		NULL,
12805 	},
12806 };
12807 
12808 /** Set VXLAN encapsulation details */
12809 struct cmd_set_vxlan_result {
12810 	cmdline_fixed_string_t set;
12811 	cmdline_fixed_string_t vxlan;
12812 	cmdline_fixed_string_t pos_token;
12813 	cmdline_fixed_string_t ip_version;
12814 	uint32_t vlan_present:1;
12815 	uint32_t vni;
12816 	uint16_t udp_src;
12817 	uint16_t udp_dst;
12818 	cmdline_ipaddr_t ip_src;
12819 	cmdline_ipaddr_t ip_dst;
12820 	uint16_t tci;
12821 	uint8_t tos;
12822 	uint8_t ttl;
12823 	struct rte_ether_addr eth_src;
12824 	struct rte_ether_addr eth_dst;
12825 };
12826 
12827 cmdline_parse_token_string_t cmd_set_vxlan_set =
12828 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12829 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12830 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12831 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12832 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12833 				 "vxlan-tos-ttl");
12834 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12835 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12836 				 "vxlan-with-vlan");
12837 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12838 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12839 				 "ip-version");
12840 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12841 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12842 				 "ipv4#ipv6");
12843 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12844 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12845 				 "vni");
12846 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12847 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12848 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12849 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12850 				 "udp-src");
12851 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12852 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12853 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12854 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12855 				 "udp-dst");
12856 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12857 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12858 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12859 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12860 				 "ip-tos");
12861 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12862 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12863 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12864 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12865 				 "ip-ttl");
12866 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12867 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12868 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12869 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12870 				 "ip-src");
12871 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12872 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12873 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12874 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12875 				 "ip-dst");
12876 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12877 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12878 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12879 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12880 				 "vlan-tci");
12881 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12882 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12883 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12884 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12885 				 "eth-src");
12886 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12887 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12888 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12889 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12890 				 "eth-dst");
12891 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12892 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12893 
12894 static void cmd_set_vxlan_parsed(void *parsed_result,
12895 	__rte_unused struct cmdline *cl,
12896 	__rte_unused void *data)
12897 {
12898 	struct cmd_set_vxlan_result *res = parsed_result;
12899 	union {
12900 		uint32_t vxlan_id;
12901 		uint8_t vni[4];
12902 	} id = {
12903 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12904 	};
12905 
12906 	vxlan_encap_conf.select_tos_ttl = 0;
12907 	if (strcmp(res->vxlan, "vxlan") == 0)
12908 		vxlan_encap_conf.select_vlan = 0;
12909 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12910 		vxlan_encap_conf.select_vlan = 1;
12911 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12912 		vxlan_encap_conf.select_vlan = 0;
12913 		vxlan_encap_conf.select_tos_ttl = 1;
12914 	}
12915 	if (strcmp(res->ip_version, "ipv4") == 0)
12916 		vxlan_encap_conf.select_ipv4 = 1;
12917 	else if (strcmp(res->ip_version, "ipv6") == 0)
12918 		vxlan_encap_conf.select_ipv4 = 0;
12919 	else
12920 		return;
12921 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12922 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12923 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12924 	vxlan_encap_conf.ip_tos = res->tos;
12925 	vxlan_encap_conf.ip_ttl = res->ttl;
12926 	if (vxlan_encap_conf.select_ipv4) {
12927 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12928 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12929 	} else {
12930 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12931 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12932 	}
12933 	if (vxlan_encap_conf.select_vlan)
12934 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12935 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12936 		   RTE_ETHER_ADDR_LEN);
12937 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12938 		   RTE_ETHER_ADDR_LEN);
12939 }
12940 
12941 cmdline_parse_inst_t cmd_set_vxlan = {
12942 	.f = cmd_set_vxlan_parsed,
12943 	.data = NULL,
12944 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12945 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12946 		" eth-src <eth-src> eth-dst <eth-dst>",
12947 	.tokens = {
12948 		(void *)&cmd_set_vxlan_set,
12949 		(void *)&cmd_set_vxlan_vxlan,
12950 		(void *)&cmd_set_vxlan_ip_version,
12951 		(void *)&cmd_set_vxlan_ip_version_value,
12952 		(void *)&cmd_set_vxlan_vni,
12953 		(void *)&cmd_set_vxlan_vni_value,
12954 		(void *)&cmd_set_vxlan_udp_src,
12955 		(void *)&cmd_set_vxlan_udp_src_value,
12956 		(void *)&cmd_set_vxlan_udp_dst,
12957 		(void *)&cmd_set_vxlan_udp_dst_value,
12958 		(void *)&cmd_set_vxlan_ip_src,
12959 		(void *)&cmd_set_vxlan_ip_src_value,
12960 		(void *)&cmd_set_vxlan_ip_dst,
12961 		(void *)&cmd_set_vxlan_ip_dst_value,
12962 		(void *)&cmd_set_vxlan_eth_src,
12963 		(void *)&cmd_set_vxlan_eth_src_value,
12964 		(void *)&cmd_set_vxlan_eth_dst,
12965 		(void *)&cmd_set_vxlan_eth_dst_value,
12966 		NULL,
12967 	},
12968 };
12969 
12970 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12971 	.f = cmd_set_vxlan_parsed,
12972 	.data = NULL,
12973 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12974 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12975 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12976 		" eth-dst <eth-dst>",
12977 	.tokens = {
12978 		(void *)&cmd_set_vxlan_set,
12979 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
12980 		(void *)&cmd_set_vxlan_ip_version,
12981 		(void *)&cmd_set_vxlan_ip_version_value,
12982 		(void *)&cmd_set_vxlan_vni,
12983 		(void *)&cmd_set_vxlan_vni_value,
12984 		(void *)&cmd_set_vxlan_udp_src,
12985 		(void *)&cmd_set_vxlan_udp_src_value,
12986 		(void *)&cmd_set_vxlan_udp_dst,
12987 		(void *)&cmd_set_vxlan_udp_dst_value,
12988 		(void *)&cmd_set_vxlan_ip_tos,
12989 		(void *)&cmd_set_vxlan_ip_tos_value,
12990 		(void *)&cmd_set_vxlan_ip_ttl,
12991 		(void *)&cmd_set_vxlan_ip_ttl_value,
12992 		(void *)&cmd_set_vxlan_ip_src,
12993 		(void *)&cmd_set_vxlan_ip_src_value,
12994 		(void *)&cmd_set_vxlan_ip_dst,
12995 		(void *)&cmd_set_vxlan_ip_dst_value,
12996 		(void *)&cmd_set_vxlan_eth_src,
12997 		(void *)&cmd_set_vxlan_eth_src_value,
12998 		(void *)&cmd_set_vxlan_eth_dst,
12999 		(void *)&cmd_set_vxlan_eth_dst_value,
13000 		NULL,
13001 	},
13002 };
13003 
13004 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13005 	.f = cmd_set_vxlan_parsed,
13006 	.data = NULL,
13007 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13008 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13009 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13010 		" <eth-dst>",
13011 	.tokens = {
13012 		(void *)&cmd_set_vxlan_set,
13013 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
13014 		(void *)&cmd_set_vxlan_ip_version,
13015 		(void *)&cmd_set_vxlan_ip_version_value,
13016 		(void *)&cmd_set_vxlan_vni,
13017 		(void *)&cmd_set_vxlan_vni_value,
13018 		(void *)&cmd_set_vxlan_udp_src,
13019 		(void *)&cmd_set_vxlan_udp_src_value,
13020 		(void *)&cmd_set_vxlan_udp_dst,
13021 		(void *)&cmd_set_vxlan_udp_dst_value,
13022 		(void *)&cmd_set_vxlan_ip_src,
13023 		(void *)&cmd_set_vxlan_ip_src_value,
13024 		(void *)&cmd_set_vxlan_ip_dst,
13025 		(void *)&cmd_set_vxlan_ip_dst_value,
13026 		(void *)&cmd_set_vxlan_vlan,
13027 		(void *)&cmd_set_vxlan_vlan_value,
13028 		(void *)&cmd_set_vxlan_eth_src,
13029 		(void *)&cmd_set_vxlan_eth_src_value,
13030 		(void *)&cmd_set_vxlan_eth_dst,
13031 		(void *)&cmd_set_vxlan_eth_dst_value,
13032 		NULL,
13033 	},
13034 };
13035 
13036 /** Set NVGRE encapsulation details */
13037 struct cmd_set_nvgre_result {
13038 	cmdline_fixed_string_t set;
13039 	cmdline_fixed_string_t nvgre;
13040 	cmdline_fixed_string_t pos_token;
13041 	cmdline_fixed_string_t ip_version;
13042 	uint32_t tni;
13043 	cmdline_ipaddr_t ip_src;
13044 	cmdline_ipaddr_t ip_dst;
13045 	uint16_t tci;
13046 	struct rte_ether_addr eth_src;
13047 	struct rte_ether_addr eth_dst;
13048 };
13049 
13050 cmdline_parse_token_string_t cmd_set_nvgre_set =
13051 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13052 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13053 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13054 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13055 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13056 				 "nvgre-with-vlan");
13057 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13058 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13059 				 "ip-version");
13060 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13061 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13062 				 "ipv4#ipv6");
13063 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13064 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13065 				 "tni");
13066 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13067 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13068 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13069 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13070 				 "ip-src");
13071 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13072 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13073 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13074 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13075 				 "ip-dst");
13076 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13077 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13078 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13079 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13080 				 "vlan-tci");
13081 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13082 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13083 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13084 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13085 				 "eth-src");
13086 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13087 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13088 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13089 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13090 				 "eth-dst");
13091 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13092 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13093 
13094 static void cmd_set_nvgre_parsed(void *parsed_result,
13095 	__rte_unused struct cmdline *cl,
13096 	__rte_unused void *data)
13097 {
13098 	struct cmd_set_nvgre_result *res = parsed_result;
13099 	union {
13100 		uint32_t nvgre_tni;
13101 		uint8_t tni[4];
13102 	} id = {
13103 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13104 	};
13105 
13106 	if (strcmp(res->nvgre, "nvgre") == 0)
13107 		nvgre_encap_conf.select_vlan = 0;
13108 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13109 		nvgre_encap_conf.select_vlan = 1;
13110 	if (strcmp(res->ip_version, "ipv4") == 0)
13111 		nvgre_encap_conf.select_ipv4 = 1;
13112 	else if (strcmp(res->ip_version, "ipv6") == 0)
13113 		nvgre_encap_conf.select_ipv4 = 0;
13114 	else
13115 		return;
13116 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13117 	if (nvgre_encap_conf.select_ipv4) {
13118 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13119 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13120 	} else {
13121 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13122 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13123 	}
13124 	if (nvgre_encap_conf.select_vlan)
13125 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13126 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13127 		   RTE_ETHER_ADDR_LEN);
13128 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13129 		   RTE_ETHER_ADDR_LEN);
13130 }
13131 
13132 cmdline_parse_inst_t cmd_set_nvgre = {
13133 	.f = cmd_set_nvgre_parsed,
13134 	.data = NULL,
13135 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13136 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13137 		" eth-dst <eth-dst>",
13138 	.tokens = {
13139 		(void *)&cmd_set_nvgre_set,
13140 		(void *)&cmd_set_nvgre_nvgre,
13141 		(void *)&cmd_set_nvgre_ip_version,
13142 		(void *)&cmd_set_nvgre_ip_version_value,
13143 		(void *)&cmd_set_nvgre_tni,
13144 		(void *)&cmd_set_nvgre_tni_value,
13145 		(void *)&cmd_set_nvgre_ip_src,
13146 		(void *)&cmd_set_nvgre_ip_src_value,
13147 		(void *)&cmd_set_nvgre_ip_dst,
13148 		(void *)&cmd_set_nvgre_ip_dst_value,
13149 		(void *)&cmd_set_nvgre_eth_src,
13150 		(void *)&cmd_set_nvgre_eth_src_value,
13151 		(void *)&cmd_set_nvgre_eth_dst,
13152 		(void *)&cmd_set_nvgre_eth_dst_value,
13153 		NULL,
13154 	},
13155 };
13156 
13157 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13158 	.f = cmd_set_nvgre_parsed,
13159 	.data = NULL,
13160 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13161 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13162 		" eth-src <eth-src> eth-dst <eth-dst>",
13163 	.tokens = {
13164 		(void *)&cmd_set_nvgre_set,
13165 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
13166 		(void *)&cmd_set_nvgre_ip_version,
13167 		(void *)&cmd_set_nvgre_ip_version_value,
13168 		(void *)&cmd_set_nvgre_tni,
13169 		(void *)&cmd_set_nvgre_tni_value,
13170 		(void *)&cmd_set_nvgre_ip_src,
13171 		(void *)&cmd_set_nvgre_ip_src_value,
13172 		(void *)&cmd_set_nvgre_ip_dst,
13173 		(void *)&cmd_set_nvgre_ip_dst_value,
13174 		(void *)&cmd_set_nvgre_vlan,
13175 		(void *)&cmd_set_nvgre_vlan_value,
13176 		(void *)&cmd_set_nvgre_eth_src,
13177 		(void *)&cmd_set_nvgre_eth_src_value,
13178 		(void *)&cmd_set_nvgre_eth_dst,
13179 		(void *)&cmd_set_nvgre_eth_dst_value,
13180 		NULL,
13181 	},
13182 };
13183 
13184 /** Set L2 encapsulation details */
13185 struct cmd_set_l2_encap_result {
13186 	cmdline_fixed_string_t set;
13187 	cmdline_fixed_string_t l2_encap;
13188 	cmdline_fixed_string_t pos_token;
13189 	cmdline_fixed_string_t ip_version;
13190 	uint32_t vlan_present:1;
13191 	uint16_t tci;
13192 	struct rte_ether_addr eth_src;
13193 	struct rte_ether_addr eth_dst;
13194 };
13195 
13196 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13197 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13198 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13199 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13200 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13201 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13202 				 "l2_encap-with-vlan");
13203 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13204 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13205 				 "ip-version");
13206 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13207 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13208 				 "ipv4#ipv6");
13209 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13210 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13211 				 "vlan-tci");
13212 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13213 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13214 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13215 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13216 				 "eth-src");
13217 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13218 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13219 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13220 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13221 				 "eth-dst");
13222 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13223 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13224 
13225 static void cmd_set_l2_encap_parsed(void *parsed_result,
13226 	__rte_unused struct cmdline *cl,
13227 	__rte_unused void *data)
13228 {
13229 	struct cmd_set_l2_encap_result *res = parsed_result;
13230 
13231 	if (strcmp(res->l2_encap, "l2_encap") == 0)
13232 		l2_encap_conf.select_vlan = 0;
13233 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13234 		l2_encap_conf.select_vlan = 1;
13235 	if (strcmp(res->ip_version, "ipv4") == 0)
13236 		l2_encap_conf.select_ipv4 = 1;
13237 	else if (strcmp(res->ip_version, "ipv6") == 0)
13238 		l2_encap_conf.select_ipv4 = 0;
13239 	else
13240 		return;
13241 	if (l2_encap_conf.select_vlan)
13242 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13243 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13244 		   RTE_ETHER_ADDR_LEN);
13245 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13246 		   RTE_ETHER_ADDR_LEN);
13247 }
13248 
13249 cmdline_parse_inst_t cmd_set_l2_encap = {
13250 	.f = cmd_set_l2_encap_parsed,
13251 	.data = NULL,
13252 	.help_str = "set l2_encap ip-version ipv4|ipv6"
13253 		" eth-src <eth-src> eth-dst <eth-dst>",
13254 	.tokens = {
13255 		(void *)&cmd_set_l2_encap_set,
13256 		(void *)&cmd_set_l2_encap_l2_encap,
13257 		(void *)&cmd_set_l2_encap_ip_version,
13258 		(void *)&cmd_set_l2_encap_ip_version_value,
13259 		(void *)&cmd_set_l2_encap_eth_src,
13260 		(void *)&cmd_set_l2_encap_eth_src_value,
13261 		(void *)&cmd_set_l2_encap_eth_dst,
13262 		(void *)&cmd_set_l2_encap_eth_dst_value,
13263 		NULL,
13264 	},
13265 };
13266 
13267 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13268 	.f = cmd_set_l2_encap_parsed,
13269 	.data = NULL,
13270 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13271 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13272 	.tokens = {
13273 		(void *)&cmd_set_l2_encap_set,
13274 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13275 		(void *)&cmd_set_l2_encap_ip_version,
13276 		(void *)&cmd_set_l2_encap_ip_version_value,
13277 		(void *)&cmd_set_l2_encap_vlan,
13278 		(void *)&cmd_set_l2_encap_vlan_value,
13279 		(void *)&cmd_set_l2_encap_eth_src,
13280 		(void *)&cmd_set_l2_encap_eth_src_value,
13281 		(void *)&cmd_set_l2_encap_eth_dst,
13282 		(void *)&cmd_set_l2_encap_eth_dst_value,
13283 		NULL,
13284 	},
13285 };
13286 
13287 /** Set L2 decapsulation details */
13288 struct cmd_set_l2_decap_result {
13289 	cmdline_fixed_string_t set;
13290 	cmdline_fixed_string_t l2_decap;
13291 	cmdline_fixed_string_t pos_token;
13292 	uint32_t vlan_present:1;
13293 };
13294 
13295 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13296 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13297 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13298 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13299 				 "l2_decap");
13300 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13301 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13302 				 "l2_decap-with-vlan");
13303 
13304 static void cmd_set_l2_decap_parsed(void *parsed_result,
13305 	__rte_unused struct cmdline *cl,
13306 	__rte_unused void *data)
13307 {
13308 	struct cmd_set_l2_decap_result *res = parsed_result;
13309 
13310 	if (strcmp(res->l2_decap, "l2_decap") == 0)
13311 		l2_decap_conf.select_vlan = 0;
13312 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13313 		l2_decap_conf.select_vlan = 1;
13314 }
13315 
13316 cmdline_parse_inst_t cmd_set_l2_decap = {
13317 	.f = cmd_set_l2_decap_parsed,
13318 	.data = NULL,
13319 	.help_str = "set l2_decap",
13320 	.tokens = {
13321 		(void *)&cmd_set_l2_decap_set,
13322 		(void *)&cmd_set_l2_decap_l2_decap,
13323 		NULL,
13324 	},
13325 };
13326 
13327 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13328 	.f = cmd_set_l2_decap_parsed,
13329 	.data = NULL,
13330 	.help_str = "set l2_decap-with-vlan",
13331 	.tokens = {
13332 		(void *)&cmd_set_l2_decap_set,
13333 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13334 		NULL,
13335 	},
13336 };
13337 
13338 /** Set MPLSoGRE encapsulation details */
13339 struct cmd_set_mplsogre_encap_result {
13340 	cmdline_fixed_string_t set;
13341 	cmdline_fixed_string_t mplsogre;
13342 	cmdline_fixed_string_t pos_token;
13343 	cmdline_fixed_string_t ip_version;
13344 	uint32_t vlan_present:1;
13345 	uint32_t label;
13346 	cmdline_ipaddr_t ip_src;
13347 	cmdline_ipaddr_t ip_dst;
13348 	uint16_t tci;
13349 	struct rte_ether_addr eth_src;
13350 	struct rte_ether_addr eth_dst;
13351 };
13352 
13353 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13354 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13355 				 "set");
13356 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13357 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13358 				 "mplsogre_encap");
13359 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13360 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13361 				 mplsogre, "mplsogre_encap-with-vlan");
13362 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13363 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13364 				 pos_token, "ip-version");
13365 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13366 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13367 				 ip_version, "ipv4#ipv6");
13368 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13369 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13370 				 pos_token, "label");
13371 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13372 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13373 			      RTE_UINT32);
13374 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13375 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13376 				 pos_token, "ip-src");
13377 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13378 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13379 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13380 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13381 				 pos_token, "ip-dst");
13382 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13383 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13384 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13385 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13386 				 pos_token, "vlan-tci");
13387 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13388 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13389 			      RTE_UINT16);
13390 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13391 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13392 				 pos_token, "eth-src");
13393 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13394 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13395 				    eth_src);
13396 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13397 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13398 				 pos_token, "eth-dst");
13399 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13400 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13401 				    eth_dst);
13402 
13403 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13404 	__rte_unused struct cmdline *cl,
13405 	__rte_unused void *data)
13406 {
13407 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
13408 	union {
13409 		uint32_t mplsogre_label;
13410 		uint8_t label[4];
13411 	} id = {
13412 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13413 	};
13414 
13415 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13416 		mplsogre_encap_conf.select_vlan = 0;
13417 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13418 		mplsogre_encap_conf.select_vlan = 1;
13419 	if (strcmp(res->ip_version, "ipv4") == 0)
13420 		mplsogre_encap_conf.select_ipv4 = 1;
13421 	else if (strcmp(res->ip_version, "ipv6") == 0)
13422 		mplsogre_encap_conf.select_ipv4 = 0;
13423 	else
13424 		return;
13425 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13426 	if (mplsogre_encap_conf.select_ipv4) {
13427 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13428 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13429 	} else {
13430 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13431 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13432 	}
13433 	if (mplsogre_encap_conf.select_vlan)
13434 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13435 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13436 		   RTE_ETHER_ADDR_LEN);
13437 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13438 		   RTE_ETHER_ADDR_LEN);
13439 }
13440 
13441 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13442 	.f = cmd_set_mplsogre_encap_parsed,
13443 	.data = NULL,
13444 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13445 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13446 		" eth-dst <eth-dst>",
13447 	.tokens = {
13448 		(void *)&cmd_set_mplsogre_encap_set,
13449 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13450 		(void *)&cmd_set_mplsogre_encap_ip_version,
13451 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13452 		(void *)&cmd_set_mplsogre_encap_label,
13453 		(void *)&cmd_set_mplsogre_encap_label_value,
13454 		(void *)&cmd_set_mplsogre_encap_ip_src,
13455 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13456 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13457 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13458 		(void *)&cmd_set_mplsogre_encap_eth_src,
13459 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13460 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13461 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13462 		NULL,
13463 	},
13464 };
13465 
13466 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13467 	.f = cmd_set_mplsogre_encap_parsed,
13468 	.data = NULL,
13469 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13470 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
13471 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13472 	.tokens = {
13473 		(void *)&cmd_set_mplsogre_encap_set,
13474 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13475 		(void *)&cmd_set_mplsogre_encap_ip_version,
13476 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
13477 		(void *)&cmd_set_mplsogre_encap_label,
13478 		(void *)&cmd_set_mplsogre_encap_label_value,
13479 		(void *)&cmd_set_mplsogre_encap_ip_src,
13480 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
13481 		(void *)&cmd_set_mplsogre_encap_ip_dst,
13482 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
13483 		(void *)&cmd_set_mplsogre_encap_vlan,
13484 		(void *)&cmd_set_mplsogre_encap_vlan_value,
13485 		(void *)&cmd_set_mplsogre_encap_eth_src,
13486 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
13487 		(void *)&cmd_set_mplsogre_encap_eth_dst,
13488 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
13489 		NULL,
13490 	},
13491 };
13492 
13493 /** Set MPLSoGRE decapsulation details */
13494 struct cmd_set_mplsogre_decap_result {
13495 	cmdline_fixed_string_t set;
13496 	cmdline_fixed_string_t mplsogre;
13497 	cmdline_fixed_string_t pos_token;
13498 	cmdline_fixed_string_t ip_version;
13499 	uint32_t vlan_present:1;
13500 };
13501 
13502 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13503 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13504 				 "set");
13505 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13506 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13507 				 "mplsogre_decap");
13508 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13509 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13510 				 mplsogre, "mplsogre_decap-with-vlan");
13511 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13512 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13513 				 pos_token, "ip-version");
13514 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13515 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13516 				 ip_version, "ipv4#ipv6");
13517 
13518 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13519 	__rte_unused struct cmdline *cl,
13520 	__rte_unused void *data)
13521 {
13522 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
13523 
13524 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13525 		mplsogre_decap_conf.select_vlan = 0;
13526 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13527 		mplsogre_decap_conf.select_vlan = 1;
13528 	if (strcmp(res->ip_version, "ipv4") == 0)
13529 		mplsogre_decap_conf.select_ipv4 = 1;
13530 	else if (strcmp(res->ip_version, "ipv6") == 0)
13531 		mplsogre_decap_conf.select_ipv4 = 0;
13532 }
13533 
13534 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13535 	.f = cmd_set_mplsogre_decap_parsed,
13536 	.data = NULL,
13537 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13538 	.tokens = {
13539 		(void *)&cmd_set_mplsogre_decap_set,
13540 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13541 		(void *)&cmd_set_mplsogre_decap_ip_version,
13542 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13543 		NULL,
13544 	},
13545 };
13546 
13547 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13548 	.f = cmd_set_mplsogre_decap_parsed,
13549 	.data = NULL,
13550 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13551 	.tokens = {
13552 		(void *)&cmd_set_mplsogre_decap_set,
13553 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13554 		(void *)&cmd_set_mplsogre_decap_ip_version,
13555 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
13556 		NULL,
13557 	},
13558 };
13559 
13560 /** Set MPLSoUDP encapsulation details */
13561 struct cmd_set_mplsoudp_encap_result {
13562 	cmdline_fixed_string_t set;
13563 	cmdline_fixed_string_t mplsoudp;
13564 	cmdline_fixed_string_t pos_token;
13565 	cmdline_fixed_string_t ip_version;
13566 	uint32_t vlan_present:1;
13567 	uint32_t label;
13568 	uint16_t udp_src;
13569 	uint16_t udp_dst;
13570 	cmdline_ipaddr_t ip_src;
13571 	cmdline_ipaddr_t ip_dst;
13572 	uint16_t tci;
13573 	struct rte_ether_addr eth_src;
13574 	struct rte_ether_addr eth_dst;
13575 };
13576 
13577 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13578 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13579 				 "set");
13580 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13581 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13582 				 "mplsoudp_encap");
13583 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13584 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13585 				 mplsoudp, "mplsoudp_encap-with-vlan");
13586 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13587 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13588 				 pos_token, "ip-version");
13589 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13590 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13591 				 ip_version, "ipv4#ipv6");
13592 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13593 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13594 				 pos_token, "label");
13595 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13596 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13597 			      RTE_UINT32);
13598 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13599 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13600 				 pos_token, "udp-src");
13601 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13602 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13603 			      RTE_UINT16);
13604 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13605 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13606 				 pos_token, "udp-dst");
13607 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13608 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13609 			      RTE_UINT16);
13610 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13611 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13612 				 pos_token, "ip-src");
13613 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13614 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13615 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13616 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13617 				 pos_token, "ip-dst");
13618 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13619 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13620 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13621 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13622 				 pos_token, "vlan-tci");
13623 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13624 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13625 			      RTE_UINT16);
13626 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13627 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13628 				 pos_token, "eth-src");
13629 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13630 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13631 				    eth_src);
13632 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13633 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13634 				 pos_token, "eth-dst");
13635 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13636 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13637 				    eth_dst);
13638 
13639 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13640 	__rte_unused struct cmdline *cl,
13641 	__rte_unused void *data)
13642 {
13643 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13644 	union {
13645 		uint32_t mplsoudp_label;
13646 		uint8_t label[4];
13647 	} id = {
13648 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13649 	};
13650 
13651 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13652 		mplsoudp_encap_conf.select_vlan = 0;
13653 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13654 		mplsoudp_encap_conf.select_vlan = 1;
13655 	if (strcmp(res->ip_version, "ipv4") == 0)
13656 		mplsoudp_encap_conf.select_ipv4 = 1;
13657 	else if (strcmp(res->ip_version, "ipv6") == 0)
13658 		mplsoudp_encap_conf.select_ipv4 = 0;
13659 	else
13660 		return;
13661 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13662 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13663 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13664 	if (mplsoudp_encap_conf.select_ipv4) {
13665 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13666 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13667 	} else {
13668 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13669 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13670 	}
13671 	if (mplsoudp_encap_conf.select_vlan)
13672 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13673 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13674 		   RTE_ETHER_ADDR_LEN);
13675 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13676 		   RTE_ETHER_ADDR_LEN);
13677 }
13678 
13679 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13680 	.f = cmd_set_mplsoudp_encap_parsed,
13681 	.data = NULL,
13682 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13683 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13684 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13685 	.tokens = {
13686 		(void *)&cmd_set_mplsoudp_encap_set,
13687 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13688 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13689 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13690 		(void *)&cmd_set_mplsoudp_encap_label,
13691 		(void *)&cmd_set_mplsoudp_encap_label_value,
13692 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13693 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13694 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13695 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13696 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13697 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13698 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13699 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13700 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13701 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13702 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13703 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13704 		NULL,
13705 	},
13706 };
13707 
13708 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13709 	.f = cmd_set_mplsoudp_encap_parsed,
13710 	.data = NULL,
13711 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13712 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
13713 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13714 		" eth-src <eth-src> eth-dst <eth-dst>",
13715 	.tokens = {
13716 		(void *)&cmd_set_mplsoudp_encap_set,
13717 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13718 		(void *)&cmd_set_mplsoudp_encap_ip_version,
13719 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
13720 		(void *)&cmd_set_mplsoudp_encap_label,
13721 		(void *)&cmd_set_mplsoudp_encap_label_value,
13722 		(void *)&cmd_set_mplsoudp_encap_udp_src,
13723 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
13724 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
13725 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13726 		(void *)&cmd_set_mplsoudp_encap_ip_src,
13727 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
13728 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
13729 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13730 		(void *)&cmd_set_mplsoudp_encap_vlan,
13731 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
13732 		(void *)&cmd_set_mplsoudp_encap_eth_src,
13733 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
13734 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
13735 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13736 		NULL,
13737 	},
13738 };
13739 
13740 /** Set MPLSoUDP decapsulation details */
13741 struct cmd_set_mplsoudp_decap_result {
13742 	cmdline_fixed_string_t set;
13743 	cmdline_fixed_string_t mplsoudp;
13744 	cmdline_fixed_string_t pos_token;
13745 	cmdline_fixed_string_t ip_version;
13746 	uint32_t vlan_present:1;
13747 };
13748 
13749 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13750 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13751 				 "set");
13752 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13753 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13754 				 "mplsoudp_decap");
13755 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13756 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13757 				 mplsoudp, "mplsoudp_decap-with-vlan");
13758 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13759 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13760 				 pos_token, "ip-version");
13761 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13762 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13763 				 ip_version, "ipv4#ipv6");
13764 
13765 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13766 	__rte_unused struct cmdline *cl,
13767 	__rte_unused void *data)
13768 {
13769 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13770 
13771 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13772 		mplsoudp_decap_conf.select_vlan = 0;
13773 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13774 		mplsoudp_decap_conf.select_vlan = 1;
13775 	if (strcmp(res->ip_version, "ipv4") == 0)
13776 		mplsoudp_decap_conf.select_ipv4 = 1;
13777 	else if (strcmp(res->ip_version, "ipv6") == 0)
13778 		mplsoudp_decap_conf.select_ipv4 = 0;
13779 }
13780 
13781 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13782 	.f = cmd_set_mplsoudp_decap_parsed,
13783 	.data = NULL,
13784 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13785 	.tokens = {
13786 		(void *)&cmd_set_mplsoudp_decap_set,
13787 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13788 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13789 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13790 		NULL,
13791 	},
13792 };
13793 
13794 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13795 	.f = cmd_set_mplsoudp_decap_parsed,
13796 	.data = NULL,
13797 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13798 	.tokens = {
13799 		(void *)&cmd_set_mplsoudp_decap_set,
13800 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13801 		(void *)&cmd_set_mplsoudp_decap_ip_version,
13802 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
13803 		NULL,
13804 	},
13805 };
13806 
13807 /** Set connection tracking object common details */
13808 struct cmd_set_conntrack_common_result {
13809 	cmdline_fixed_string_t set;
13810 	cmdline_fixed_string_t conntrack;
13811 	cmdline_fixed_string_t common;
13812 	cmdline_fixed_string_t peer;
13813 	cmdline_fixed_string_t is_orig;
13814 	cmdline_fixed_string_t enable;
13815 	cmdline_fixed_string_t live;
13816 	cmdline_fixed_string_t sack;
13817 	cmdline_fixed_string_t cack;
13818 	cmdline_fixed_string_t last_dir;
13819 	cmdline_fixed_string_t liberal;
13820 	cmdline_fixed_string_t state;
13821 	cmdline_fixed_string_t max_ack_win;
13822 	cmdline_fixed_string_t retrans;
13823 	cmdline_fixed_string_t last_win;
13824 	cmdline_fixed_string_t last_seq;
13825 	cmdline_fixed_string_t last_ack;
13826 	cmdline_fixed_string_t last_end;
13827 	cmdline_fixed_string_t last_index;
13828 	uint8_t stat;
13829 	uint8_t factor;
13830 	uint16_t peer_port;
13831 	uint32_t is_original;
13832 	uint32_t en;
13833 	uint32_t is_live;
13834 	uint32_t s_ack;
13835 	uint32_t c_ack;
13836 	uint32_t ld;
13837 	uint32_t lb;
13838 	uint8_t re_num;
13839 	uint8_t li;
13840 	uint16_t lw;
13841 	uint32_t ls;
13842 	uint32_t la;
13843 	uint32_t le;
13844 };
13845 
13846 cmdline_parse_token_string_t cmd_set_conntrack_set =
13847 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13848 				 set, "set");
13849 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13850 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13851 				 conntrack, "conntrack");
13852 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13853 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13854 				 common, "com");
13855 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13856 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13857 				 peer, "peer");
13858 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13859 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13860 			      peer_port, RTE_UINT16);
13861 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13862 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13863 				 is_orig, "is_orig");
13864 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13865 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13866 			      is_original, RTE_UINT32);
13867 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13868 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13869 				 enable, "enable");
13870 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13871 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13872 			      en, RTE_UINT32);
13873 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13874 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13875 				 live, "live");
13876 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13877 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13878 			      is_live, RTE_UINT32);
13879 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13880 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13881 				 sack, "sack");
13882 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13883 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13884 			      s_ack, RTE_UINT32);
13885 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13886 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13887 				 cack, "cack");
13888 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13889 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13890 			      c_ack, RTE_UINT32);
13891 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13892 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13893 				 last_dir, "last_dir");
13894 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13895 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13896 			      ld, RTE_UINT32);
13897 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13898 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13899 				 liberal, "liberal");
13900 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13901 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13902 			      lb, RTE_UINT32);
13903 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13904 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13905 				 state, "state");
13906 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13907 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13908 			      stat, RTE_UINT8);
13909 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13910 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13911 				 max_ack_win, "max_ack_win");
13912 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13913 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13914 			      factor, RTE_UINT8);
13915 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13916 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13917 				 retrans, "r_lim");
13918 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13919 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13920 			      re_num, RTE_UINT8);
13921 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13922 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13923 				 last_win, "last_win");
13924 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13925 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13926 			      lw, RTE_UINT16);
13927 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13928 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13929 				 last_seq, "last_seq");
13930 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13931 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13932 			      ls, RTE_UINT32);
13933 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13934 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13935 				 last_ack, "last_ack");
13936 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13937 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13938 			      la, RTE_UINT32);
13939 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13940 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13941 				 last_end, "last_end");
13942 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13943 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13944 			      le, RTE_UINT32);
13945 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13946 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13947 				 last_index, "last_index");
13948 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13949 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13950 			      li, RTE_UINT8);
13951 
13952 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13953 	__rte_unused struct cmdline *cl,
13954 	__rte_unused void *data)
13955 {
13956 	struct cmd_set_conntrack_common_result *res = parsed_result;
13957 
13958 	/* No need to swap to big endian. */
13959 	conntrack_context.peer_port = res->peer_port;
13960 	conntrack_context.is_original_dir = res->is_original;
13961 	conntrack_context.enable = res->en;
13962 	conntrack_context.live_connection = res->is_live;
13963 	conntrack_context.selective_ack = res->s_ack;
13964 	conntrack_context.challenge_ack_passed = res->c_ack;
13965 	conntrack_context.last_direction = res->ld;
13966 	conntrack_context.liberal_mode = res->lb;
13967 	conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13968 	conntrack_context.max_ack_window = res->factor;
13969 	conntrack_context.retransmission_limit = res->re_num;
13970 	conntrack_context.last_window = res->lw;
13971 	conntrack_context.last_index =
13972 		(enum rte_flow_conntrack_tcp_last_index)res->li;
13973 	conntrack_context.last_seq = res->ls;
13974 	conntrack_context.last_ack = res->la;
13975 	conntrack_context.last_end = res->le;
13976 }
13977 
13978 cmdline_parse_inst_t cmd_set_conntrack_common = {
13979 	.f = cmd_set_conntrack_common_parsed,
13980 	.data = NULL,
13981 	.help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13982 		" live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13983 		" liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13984 		" last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13985 		" last_index <flag>",
13986 	.tokens = {
13987 		(void *)&cmd_set_conntrack_set,
13988 		(void *)&cmd_set_conntrack_conntrack,
13989 		(void *)&cmd_set_conntrack_common_com,
13990 		(void *)&cmd_set_conntrack_common_peer,
13991 		(void *)&cmd_set_conntrack_common_peer_value,
13992 		(void *)&cmd_set_conntrack_common_is_orig,
13993 		(void *)&cmd_set_conntrack_common_is_orig_value,
13994 		(void *)&cmd_set_conntrack_common_enable,
13995 		(void *)&cmd_set_conntrack_common_enable_value,
13996 		(void *)&cmd_set_conntrack_common_live,
13997 		(void *)&cmd_set_conntrack_common_live_value,
13998 		(void *)&cmd_set_conntrack_common_sack,
13999 		(void *)&cmd_set_conntrack_common_sack_value,
14000 		(void *)&cmd_set_conntrack_common_cack,
14001 		(void *)&cmd_set_conntrack_common_cack_value,
14002 		(void *)&cmd_set_conntrack_common_last_dir,
14003 		(void *)&cmd_set_conntrack_common_last_dir_value,
14004 		(void *)&cmd_set_conntrack_common_liberal,
14005 		(void *)&cmd_set_conntrack_common_liberal_value,
14006 		(void *)&cmd_set_conntrack_common_state,
14007 		(void *)&cmd_set_conntrack_common_state_value,
14008 		(void *)&cmd_set_conntrack_common_max_ackwin,
14009 		(void *)&cmd_set_conntrack_common_max_ackwin_value,
14010 		(void *)&cmd_set_conntrack_common_retrans,
14011 		(void *)&cmd_set_conntrack_common_retrans_value,
14012 		(void *)&cmd_set_conntrack_common_last_win,
14013 		(void *)&cmd_set_conntrack_common_last_win_value,
14014 		(void *)&cmd_set_conntrack_common_last_seq,
14015 		(void *)&cmd_set_conntrack_common_last_seq_value,
14016 		(void *)&cmd_set_conntrack_common_last_ack,
14017 		(void *)&cmd_set_conntrack_common_last_ack_value,
14018 		(void *)&cmd_set_conntrack_common_last_end,
14019 		(void *)&cmd_set_conntrack_common_last_end_value,
14020 		(void *)&cmd_set_conntrack_common_last_index,
14021 		(void *)&cmd_set_conntrack_common_last_index_value,
14022 		NULL,
14023 	},
14024 };
14025 
14026 /** Set connection tracking object both directions' details */
14027 struct cmd_set_conntrack_dir_result {
14028 	cmdline_fixed_string_t set;
14029 	cmdline_fixed_string_t conntrack;
14030 	cmdline_fixed_string_t dir;
14031 	cmdline_fixed_string_t scale;
14032 	cmdline_fixed_string_t fin;
14033 	cmdline_fixed_string_t ack_seen;
14034 	cmdline_fixed_string_t unack;
14035 	cmdline_fixed_string_t sent_end;
14036 	cmdline_fixed_string_t reply_end;
14037 	cmdline_fixed_string_t max_win;
14038 	cmdline_fixed_string_t max_ack;
14039 	uint32_t factor;
14040 	uint32_t f;
14041 	uint32_t as;
14042 	uint32_t un;
14043 	uint32_t se;
14044 	uint32_t re;
14045 	uint32_t mw;
14046 	uint32_t ma;
14047 };
14048 
14049 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14050 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14051 				 set, "set");
14052 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14053 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14054 				 conntrack, "conntrack");
14055 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14056 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14057 				 dir, "orig#rply");
14058 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14059 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14060 				 scale, "scale");
14061 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14062 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14063 			      factor, RTE_UINT32);
14064 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14065 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14066 				 fin, "fin");
14067 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14068 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14069 			      f, RTE_UINT32);
14070 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14071 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14072 				 ack_seen, "acked");
14073 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14074 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14075 			      as, RTE_UINT32);
14076 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14077 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14078 				 unack, "unack_data");
14079 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14080 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14081 			      un, RTE_UINT32);
14082 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14083 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14084 				 sent_end, "sent_end");
14085 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14086 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14087 			      se, RTE_UINT32);
14088 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14089 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14090 				 reply_end, "reply_end");
14091 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14092 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14093 			      re, RTE_UINT32);
14094 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14095 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14096 				 max_win, "max_win");
14097 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14098 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14099 			      mw, RTE_UINT32);
14100 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14101 	TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14102 				 max_ack, "max_ack");
14103 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14104 	TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14105 			      ma, RTE_UINT32);
14106 
14107 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14108 	__rte_unused struct cmdline *cl,
14109 	__rte_unused void *data)
14110 {
14111 	struct cmd_set_conntrack_dir_result *res = parsed_result;
14112 	struct rte_flow_tcp_dir_param *dir = NULL;
14113 
14114 	if (strcmp(res->dir, "orig") == 0)
14115 		dir = &conntrack_context.original_dir;
14116 	else if (strcmp(res->dir, "rply") == 0)
14117 		dir = &conntrack_context.reply_dir;
14118 	else
14119 		return;
14120 	dir->scale = res->factor;
14121 	dir->close_initiated = res->f;
14122 	dir->last_ack_seen = res->as;
14123 	dir->data_unacked = res->un;
14124 	dir->sent_end = res->se;
14125 	dir->reply_end = res->re;
14126 	dir->max_ack = res->ma;
14127 	dir->max_win = res->mw;
14128 }
14129 
14130 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14131 	.f = cmd_set_conntrack_dir_parsed,
14132 	.data = NULL,
14133 	.help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14134 		    " acked <seen> unack_data <unack> sent_end <sent>"
14135 		    " reply_end <reply> max_win <win> max_ack <ack>",
14136 	.tokens = {
14137 		(void *)&cmd_set_conntrack_set,
14138 		(void *)&cmd_set_conntrack_conntrack,
14139 		(void *)&cmd_set_conntrack_dir_dir,
14140 		(void *)&cmd_set_conntrack_dir_scale,
14141 		(void *)&cmd_set_conntrack_dir_scale_value,
14142 		(void *)&cmd_set_conntrack_dir_fin,
14143 		(void *)&cmd_set_conntrack_dir_fin_value,
14144 		(void *)&cmd_set_conntrack_dir_ack,
14145 		(void *)&cmd_set_conntrack_dir_ack_value,
14146 		(void *)&cmd_set_conntrack_dir_unack_data,
14147 		(void *)&cmd_set_conntrack_dir_unack_data_value,
14148 		(void *)&cmd_set_conntrack_dir_sent_end,
14149 		(void *)&cmd_set_conntrack_dir_sent_end_value,
14150 		(void *)&cmd_set_conntrack_dir_reply_end,
14151 		(void *)&cmd_set_conntrack_dir_reply_end_value,
14152 		(void *)&cmd_set_conntrack_dir_max_win,
14153 		(void *)&cmd_set_conntrack_dir_max_win_value,
14154 		(void *)&cmd_set_conntrack_dir_max_ack,
14155 		(void *)&cmd_set_conntrack_dir_max_ack_value,
14156 		NULL,
14157 	},
14158 };
14159 
14160 /* Strict link priority scheduling mode setting */
14161 static void
14162 cmd_strict_link_prio_parsed(
14163 	void *parsed_result,
14164 	__rte_unused struct cmdline *cl,
14165 	__rte_unused void *data)
14166 {
14167 	struct cmd_vf_tc_bw_result *res = parsed_result;
14168 	int ret = -ENOTSUP;
14169 
14170 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14171 		return;
14172 
14173 #ifdef RTE_NET_I40E
14174 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14175 #endif
14176 
14177 	switch (ret) {
14178 	case 0:
14179 		break;
14180 	case -EINVAL:
14181 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14182 		break;
14183 	case -ENODEV:
14184 		printf("invalid port_id %d\n", res->port_id);
14185 		break;
14186 	case -ENOTSUP:
14187 		printf("function not implemented\n");
14188 		break;
14189 	default:
14190 		printf("programming error: (%s)\n", strerror(-ret));
14191 	}
14192 }
14193 
14194 cmdline_parse_inst_t cmd_strict_link_prio = {
14195 	.f = cmd_strict_link_prio_parsed,
14196 	.data = NULL,
14197 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14198 	.tokens = {
14199 		(void *)&cmd_vf_tc_bw_set,
14200 		(void *)&cmd_vf_tc_bw_tx,
14201 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14202 		(void *)&cmd_vf_tc_bw_port_id,
14203 		(void *)&cmd_vf_tc_bw_tc_map,
14204 		NULL,
14205 	},
14206 };
14207 
14208 /* Load dynamic device personalization*/
14209 struct cmd_ddp_add_result {
14210 	cmdline_fixed_string_t ddp;
14211 	cmdline_fixed_string_t add;
14212 	portid_t port_id;
14213 	char filepath[];
14214 };
14215 
14216 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14217 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14218 cmdline_parse_token_string_t cmd_ddp_add_add =
14219 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14220 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14221 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14222 		RTE_UINT16);
14223 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14224 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14225 
14226 static void
14227 cmd_ddp_add_parsed(
14228 	void *parsed_result,
14229 	__rte_unused struct cmdline *cl,
14230 	__rte_unused void *data)
14231 {
14232 	struct cmd_ddp_add_result *res = parsed_result;
14233 	uint8_t *buff;
14234 	uint32_t size;
14235 	char *filepath;
14236 	char *file_fld[2];
14237 	int file_num;
14238 	int ret = -ENOTSUP;
14239 
14240 	if (!all_ports_stopped()) {
14241 		printf("Please stop all ports first\n");
14242 		return;
14243 	}
14244 
14245 	filepath = strdup(res->filepath);
14246 	if (filepath == NULL) {
14247 		printf("Failed to allocate memory\n");
14248 		return;
14249 	}
14250 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14251 
14252 	buff = open_file(file_fld[0], &size);
14253 	if (!buff) {
14254 		free((void *)filepath);
14255 		return;
14256 	}
14257 
14258 #ifdef RTE_NET_I40E
14259 	if (ret == -ENOTSUP)
14260 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14261 					       buff, size,
14262 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14263 #endif
14264 
14265 	if (ret == -EEXIST)
14266 		printf("Profile has already existed.\n");
14267 	else if (ret < 0)
14268 		printf("Failed to load profile.\n");
14269 	else if (file_num == 2)
14270 		save_file(file_fld[1], buff, size);
14271 
14272 	close_file(buff);
14273 	free((void *)filepath);
14274 }
14275 
14276 cmdline_parse_inst_t cmd_ddp_add = {
14277 	.f = cmd_ddp_add_parsed,
14278 	.data = NULL,
14279 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14280 	.tokens = {
14281 		(void *)&cmd_ddp_add_ddp,
14282 		(void *)&cmd_ddp_add_add,
14283 		(void *)&cmd_ddp_add_port_id,
14284 		(void *)&cmd_ddp_add_filepath,
14285 		NULL,
14286 	},
14287 };
14288 
14289 /* Delete dynamic device personalization*/
14290 struct cmd_ddp_del_result {
14291 	cmdline_fixed_string_t ddp;
14292 	cmdline_fixed_string_t del;
14293 	portid_t port_id;
14294 	char filepath[];
14295 };
14296 
14297 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14298 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14299 cmdline_parse_token_string_t cmd_ddp_del_del =
14300 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14301 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14302 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14303 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14304 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14305 
14306 static void
14307 cmd_ddp_del_parsed(
14308 	void *parsed_result,
14309 	__rte_unused struct cmdline *cl,
14310 	__rte_unused void *data)
14311 {
14312 	struct cmd_ddp_del_result *res = parsed_result;
14313 	uint8_t *buff;
14314 	uint32_t size;
14315 	int ret = -ENOTSUP;
14316 
14317 	if (!all_ports_stopped()) {
14318 		printf("Please stop all ports first\n");
14319 		return;
14320 	}
14321 
14322 	buff = open_file(res->filepath, &size);
14323 	if (!buff)
14324 		return;
14325 
14326 #ifdef RTE_NET_I40E
14327 	if (ret == -ENOTSUP)
14328 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14329 					       buff, size,
14330 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14331 #endif
14332 
14333 	if (ret == -EACCES)
14334 		printf("Profile does not exist.\n");
14335 	else if (ret < 0)
14336 		printf("Failed to delete profile.\n");
14337 
14338 	close_file(buff);
14339 }
14340 
14341 cmdline_parse_inst_t cmd_ddp_del = {
14342 	.f = cmd_ddp_del_parsed,
14343 	.data = NULL,
14344 	.help_str = "ddp del <port_id> <backup_profile_path>",
14345 	.tokens = {
14346 		(void *)&cmd_ddp_del_ddp,
14347 		(void *)&cmd_ddp_del_del,
14348 		(void *)&cmd_ddp_del_port_id,
14349 		(void *)&cmd_ddp_del_filepath,
14350 		NULL,
14351 	},
14352 };
14353 
14354 /* Get dynamic device personalization profile info */
14355 struct cmd_ddp_info_result {
14356 	cmdline_fixed_string_t ddp;
14357 	cmdline_fixed_string_t get;
14358 	cmdline_fixed_string_t info;
14359 	char filepath[];
14360 };
14361 
14362 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14363 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14364 cmdline_parse_token_string_t cmd_ddp_info_get =
14365 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14366 cmdline_parse_token_string_t cmd_ddp_info_info =
14367 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14368 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14369 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14370 
14371 static void
14372 cmd_ddp_info_parsed(
14373 	void *parsed_result,
14374 	__rte_unused struct cmdline *cl,
14375 	__rte_unused void *data)
14376 {
14377 	struct cmd_ddp_info_result *res = parsed_result;
14378 	uint8_t *pkg;
14379 	uint32_t pkg_size;
14380 	int ret = -ENOTSUP;
14381 #ifdef RTE_NET_I40E
14382 	uint32_t i, j, n;
14383 	uint8_t *buff;
14384 	uint32_t buff_size = 0;
14385 	struct rte_pmd_i40e_profile_info info;
14386 	uint32_t dev_num = 0;
14387 	struct rte_pmd_i40e_ddp_device_id *devs;
14388 	uint32_t proto_num = 0;
14389 	struct rte_pmd_i40e_proto_info *proto = NULL;
14390 	uint32_t pctype_num = 0;
14391 	struct rte_pmd_i40e_ptype_info *pctype;
14392 	uint32_t ptype_num = 0;
14393 	struct rte_pmd_i40e_ptype_info *ptype;
14394 	uint8_t proto_id;
14395 
14396 #endif
14397 
14398 	pkg = open_file(res->filepath, &pkg_size);
14399 	if (!pkg)
14400 		return;
14401 
14402 #ifdef RTE_NET_I40E
14403 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14404 				(uint8_t *)&info, sizeof(info),
14405 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14406 	if (!ret) {
14407 		printf("Global Track id:       0x%x\n", info.track_id);
14408 		printf("Global Version:        %d.%d.%d.%d\n",
14409 			info.version.major,
14410 			info.version.minor,
14411 			info.version.update,
14412 			info.version.draft);
14413 		printf("Global Package name:   %s\n\n", info.name);
14414 	}
14415 
14416 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14417 				(uint8_t *)&info, sizeof(info),
14418 				RTE_PMD_I40E_PKG_INFO_HEADER);
14419 	if (!ret) {
14420 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14421 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14422 			info.version.major,
14423 			info.version.minor,
14424 			info.version.update,
14425 			info.version.draft);
14426 		printf("i40e Profile name:     %s\n\n", info.name);
14427 	}
14428 
14429 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14430 				(uint8_t *)&buff_size, sizeof(buff_size),
14431 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14432 	if (!ret && buff_size) {
14433 		buff = (uint8_t *)malloc(buff_size);
14434 		if (buff) {
14435 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14436 						buff, buff_size,
14437 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14438 			if (!ret)
14439 				printf("Package Notes:\n%s\n\n", buff);
14440 			free(buff);
14441 		}
14442 	}
14443 
14444 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14445 				(uint8_t *)&dev_num, sizeof(dev_num),
14446 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14447 	if (!ret && dev_num) {
14448 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14449 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14450 		if (devs) {
14451 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14452 						(uint8_t *)devs, buff_size,
14453 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14454 			if (!ret) {
14455 				printf("List of supported devices:\n");
14456 				for (i = 0; i < dev_num; i++) {
14457 					printf("  %04X:%04X %04X:%04X\n",
14458 						devs[i].vendor_dev_id >> 16,
14459 						devs[i].vendor_dev_id & 0xFFFF,
14460 						devs[i].sub_vendor_dev_id >> 16,
14461 						devs[i].sub_vendor_dev_id & 0xFFFF);
14462 				}
14463 				printf("\n");
14464 			}
14465 			free(devs);
14466 		}
14467 	}
14468 
14469 	/* get information about protocols and packet types */
14470 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14471 		(uint8_t *)&proto_num, sizeof(proto_num),
14472 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14473 	if (ret || !proto_num)
14474 		goto no_print_return;
14475 
14476 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14477 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14478 	if (!proto)
14479 		goto no_print_return;
14480 
14481 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14482 					buff_size,
14483 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14484 	if (!ret) {
14485 		printf("List of used protocols:\n");
14486 		for (i = 0; i < proto_num; i++)
14487 			printf("  %2u: %s\n", proto[i].proto_id,
14488 			       proto[i].name);
14489 		printf("\n");
14490 	}
14491 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14492 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14493 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14494 	if (ret || !pctype_num)
14495 		goto no_print_pctypes;
14496 
14497 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14498 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14499 	if (!pctype)
14500 		goto no_print_pctypes;
14501 
14502 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14503 					buff_size,
14504 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14505 	if (ret) {
14506 		free(pctype);
14507 		goto no_print_pctypes;
14508 	}
14509 
14510 	printf("List of defined packet classification types:\n");
14511 	for (i = 0; i < pctype_num; i++) {
14512 		printf("  %2u:", pctype[i].ptype_id);
14513 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14514 			proto_id = pctype[i].protocols[j];
14515 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14516 				for (n = 0; n < proto_num; n++) {
14517 					if (proto[n].proto_id == proto_id) {
14518 						printf(" %s", proto[n].name);
14519 						break;
14520 					}
14521 				}
14522 			}
14523 		}
14524 		printf("\n");
14525 	}
14526 	printf("\n");
14527 	free(pctype);
14528 
14529 no_print_pctypes:
14530 
14531 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14532 					sizeof(ptype_num),
14533 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14534 	if (ret || !ptype_num)
14535 		goto no_print_return;
14536 
14537 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14538 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14539 	if (!ptype)
14540 		goto no_print_return;
14541 
14542 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14543 					buff_size,
14544 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14545 	if (ret) {
14546 		free(ptype);
14547 		goto no_print_return;
14548 	}
14549 	printf("List of defined packet types:\n");
14550 	for (i = 0; i < ptype_num; i++) {
14551 		printf("  %2u:", ptype[i].ptype_id);
14552 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14553 			proto_id = ptype[i].protocols[j];
14554 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14555 				for (n = 0; n < proto_num; n++) {
14556 					if (proto[n].proto_id == proto_id) {
14557 						printf(" %s", proto[n].name);
14558 						break;
14559 					}
14560 				}
14561 			}
14562 		}
14563 		printf("\n");
14564 	}
14565 	free(ptype);
14566 	printf("\n");
14567 
14568 	ret = 0;
14569 no_print_return:
14570 	if (proto)
14571 		free(proto);
14572 #endif
14573 	if (ret == -ENOTSUP)
14574 		printf("Function not supported in PMD driver\n");
14575 	close_file(pkg);
14576 }
14577 
14578 cmdline_parse_inst_t cmd_ddp_get_info = {
14579 	.f = cmd_ddp_info_parsed,
14580 	.data = NULL,
14581 	.help_str = "ddp get info <profile_path>",
14582 	.tokens = {
14583 		(void *)&cmd_ddp_info_ddp,
14584 		(void *)&cmd_ddp_info_get,
14585 		(void *)&cmd_ddp_info_info,
14586 		(void *)&cmd_ddp_info_filepath,
14587 		NULL,
14588 	},
14589 };
14590 
14591 /* Get dynamic device personalization profile info list*/
14592 #define PROFILE_INFO_SIZE 48
14593 #define MAX_PROFILE_NUM 16
14594 
14595 struct cmd_ddp_get_list_result {
14596 	cmdline_fixed_string_t ddp;
14597 	cmdline_fixed_string_t get;
14598 	cmdline_fixed_string_t list;
14599 	portid_t port_id;
14600 };
14601 
14602 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14603 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14604 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14605 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14606 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14607 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14608 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14609 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14610 		RTE_UINT16);
14611 
14612 static void
14613 cmd_ddp_get_list_parsed(
14614 	__rte_unused void *parsed_result,
14615 	__rte_unused struct cmdline *cl,
14616 	__rte_unused void *data)
14617 {
14618 #ifdef RTE_NET_I40E
14619 	struct cmd_ddp_get_list_result *res = parsed_result;
14620 	struct rte_pmd_i40e_profile_list *p_list;
14621 	struct rte_pmd_i40e_profile_info *p_info;
14622 	uint32_t p_num;
14623 	uint32_t size;
14624 	uint32_t i;
14625 #endif
14626 	int ret = -ENOTSUP;
14627 
14628 #ifdef RTE_NET_I40E
14629 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14630 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14631 	if (!p_list) {
14632 		printf("%s: Failed to malloc buffer\n", __func__);
14633 		return;
14634 	}
14635 
14636 	if (ret == -ENOTSUP)
14637 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14638 						(uint8_t *)p_list, size);
14639 
14640 	if (!ret) {
14641 		p_num = p_list->p_count;
14642 		printf("Profile number is: %d\n\n", p_num);
14643 
14644 		for (i = 0; i < p_num; i++) {
14645 			p_info = &p_list->p_info[i];
14646 			printf("Profile %d:\n", i);
14647 			printf("Track id:     0x%x\n", p_info->track_id);
14648 			printf("Version:      %d.%d.%d.%d\n",
14649 			       p_info->version.major,
14650 			       p_info->version.minor,
14651 			       p_info->version.update,
14652 			       p_info->version.draft);
14653 			printf("Profile name: %s\n\n", p_info->name);
14654 		}
14655 	}
14656 
14657 	free(p_list);
14658 #endif
14659 
14660 	if (ret < 0)
14661 		printf("Failed to get ddp list\n");
14662 }
14663 
14664 cmdline_parse_inst_t cmd_ddp_get_list = {
14665 	.f = cmd_ddp_get_list_parsed,
14666 	.data = NULL,
14667 	.help_str = "ddp get list <port_id>",
14668 	.tokens = {
14669 		(void *)&cmd_ddp_get_list_ddp,
14670 		(void *)&cmd_ddp_get_list_get,
14671 		(void *)&cmd_ddp_get_list_list,
14672 		(void *)&cmd_ddp_get_list_port_id,
14673 		NULL,
14674 	},
14675 };
14676 
14677 /* Configure input set */
14678 struct cmd_cfg_input_set_result {
14679 	cmdline_fixed_string_t port;
14680 	cmdline_fixed_string_t cfg;
14681 	portid_t port_id;
14682 	cmdline_fixed_string_t pctype;
14683 	uint8_t pctype_id;
14684 	cmdline_fixed_string_t inset_type;
14685 	cmdline_fixed_string_t opt;
14686 	cmdline_fixed_string_t field;
14687 	uint8_t field_idx;
14688 };
14689 
14690 static void
14691 cmd_cfg_input_set_parsed(
14692 	__rte_unused void *parsed_result,
14693 	__rte_unused struct cmdline *cl,
14694 	__rte_unused void *data)
14695 {
14696 #ifdef RTE_NET_I40E
14697 	struct cmd_cfg_input_set_result *res = parsed_result;
14698 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14699 	struct rte_pmd_i40e_inset inset;
14700 #endif
14701 	int ret = -ENOTSUP;
14702 
14703 	if (!all_ports_stopped()) {
14704 		printf("Please stop all ports first\n");
14705 		return;
14706 	}
14707 
14708 #ifdef RTE_NET_I40E
14709 	if (!strcmp(res->inset_type, "hash_inset"))
14710 		inset_type = INSET_HASH;
14711 	else if (!strcmp(res->inset_type, "fdir_inset"))
14712 		inset_type = INSET_FDIR;
14713 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14714 		inset_type = INSET_FDIR_FLX;
14715 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14716 				     &inset, inset_type);
14717 	if (ret) {
14718 		printf("Failed to get input set.\n");
14719 		return;
14720 	}
14721 
14722 	if (!strcmp(res->opt, "get")) {
14723 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
14724 						   res->field_idx);
14725 		if (ret)
14726 			printf("Field index %d is enabled.\n", res->field_idx);
14727 		else
14728 			printf("Field index %d is disabled.\n", res->field_idx);
14729 		return;
14730 	} else if (!strcmp(res->opt, "set"))
14731 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14732 						   res->field_idx);
14733 	else if (!strcmp(res->opt, "clear"))
14734 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14735 						     res->field_idx);
14736 	if (ret) {
14737 		printf("Failed to configure input set field.\n");
14738 		return;
14739 	}
14740 
14741 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14742 				     &inset, inset_type);
14743 	if (ret) {
14744 		printf("Failed to set input set.\n");
14745 		return;
14746 	}
14747 #endif
14748 
14749 	if (ret == -ENOTSUP)
14750 		printf("Function not supported\n");
14751 }
14752 
14753 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14754 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14755 				 port, "port");
14756 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14757 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14758 				 cfg, "config");
14759 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14760 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14761 			      port_id, RTE_UINT16);
14762 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14763 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14764 				 pctype, "pctype");
14765 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14766 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14767 			      pctype_id, RTE_UINT8);
14768 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14769 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14770 				 inset_type,
14771 				 "hash_inset#fdir_inset#fdir_flx_inset");
14772 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14773 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14774 				 opt, "get#set#clear");
14775 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14776 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14777 				 field, "field");
14778 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14779 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14780 			      field_idx, RTE_UINT8);
14781 
14782 cmdline_parse_inst_t cmd_cfg_input_set = {
14783 	.f = cmd_cfg_input_set_parsed,
14784 	.data = NULL,
14785 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14786 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14787 	.tokens = {
14788 		(void *)&cmd_cfg_input_set_port,
14789 		(void *)&cmd_cfg_input_set_cfg,
14790 		(void *)&cmd_cfg_input_set_port_id,
14791 		(void *)&cmd_cfg_input_set_pctype,
14792 		(void *)&cmd_cfg_input_set_pctype_id,
14793 		(void *)&cmd_cfg_input_set_inset_type,
14794 		(void *)&cmd_cfg_input_set_opt,
14795 		(void *)&cmd_cfg_input_set_field,
14796 		(void *)&cmd_cfg_input_set_field_idx,
14797 		NULL,
14798 	},
14799 };
14800 
14801 /* Clear input set */
14802 struct cmd_clear_input_set_result {
14803 	cmdline_fixed_string_t port;
14804 	cmdline_fixed_string_t cfg;
14805 	portid_t port_id;
14806 	cmdline_fixed_string_t pctype;
14807 	uint8_t pctype_id;
14808 	cmdline_fixed_string_t inset_type;
14809 	cmdline_fixed_string_t clear;
14810 	cmdline_fixed_string_t all;
14811 };
14812 
14813 static void
14814 cmd_clear_input_set_parsed(
14815 	__rte_unused void *parsed_result,
14816 	__rte_unused struct cmdline *cl,
14817 	__rte_unused void *data)
14818 {
14819 #ifdef RTE_NET_I40E
14820 	struct cmd_clear_input_set_result *res = parsed_result;
14821 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14822 	struct rte_pmd_i40e_inset inset;
14823 #endif
14824 	int ret = -ENOTSUP;
14825 
14826 	if (!all_ports_stopped()) {
14827 		printf("Please stop all ports first\n");
14828 		return;
14829 	}
14830 
14831 #ifdef RTE_NET_I40E
14832 	if (!strcmp(res->inset_type, "hash_inset"))
14833 		inset_type = INSET_HASH;
14834 	else if (!strcmp(res->inset_type, "fdir_inset"))
14835 		inset_type = INSET_FDIR;
14836 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14837 		inset_type = INSET_FDIR_FLX;
14838 
14839 	memset(&inset, 0, sizeof(inset));
14840 
14841 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14842 				     &inset, inset_type);
14843 	if (ret) {
14844 		printf("Failed to clear input set.\n");
14845 		return;
14846 	}
14847 
14848 #endif
14849 
14850 	if (ret == -ENOTSUP)
14851 		printf("Function not supported\n");
14852 }
14853 
14854 cmdline_parse_token_string_t cmd_clear_input_set_port =
14855 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14856 				 port, "port");
14857 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14858 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14859 				 cfg, "config");
14860 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14861 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14862 			      port_id, RTE_UINT16);
14863 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14864 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14865 				 pctype, "pctype");
14866 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14867 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14868 			      pctype_id, RTE_UINT8);
14869 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14870 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14871 				 inset_type,
14872 				 "hash_inset#fdir_inset#fdir_flx_inset");
14873 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14874 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14875 				 clear, "clear");
14876 cmdline_parse_token_string_t cmd_clear_input_set_all =
14877 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14878 				 all, "all");
14879 
14880 cmdline_parse_inst_t cmd_clear_input_set = {
14881 	.f = cmd_clear_input_set_parsed,
14882 	.data = NULL,
14883 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14884 		    "fdir_inset|fdir_flx_inset clear all",
14885 	.tokens = {
14886 		(void *)&cmd_clear_input_set_port,
14887 		(void *)&cmd_clear_input_set_cfg,
14888 		(void *)&cmd_clear_input_set_port_id,
14889 		(void *)&cmd_clear_input_set_pctype,
14890 		(void *)&cmd_clear_input_set_pctype_id,
14891 		(void *)&cmd_clear_input_set_inset_type,
14892 		(void *)&cmd_clear_input_set_clear,
14893 		(void *)&cmd_clear_input_set_all,
14894 		NULL,
14895 	},
14896 };
14897 
14898 /* show vf stats */
14899 
14900 /* Common result structure for show vf stats */
14901 struct cmd_show_vf_stats_result {
14902 	cmdline_fixed_string_t show;
14903 	cmdline_fixed_string_t vf;
14904 	cmdline_fixed_string_t stats;
14905 	portid_t port_id;
14906 	uint16_t vf_id;
14907 };
14908 
14909 /* Common CLI fields show vf stats*/
14910 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14911 	TOKEN_STRING_INITIALIZER
14912 		(struct cmd_show_vf_stats_result,
14913 		 show, "show");
14914 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14915 	TOKEN_STRING_INITIALIZER
14916 		(struct cmd_show_vf_stats_result,
14917 		 vf, "vf");
14918 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14919 	TOKEN_STRING_INITIALIZER
14920 		(struct cmd_show_vf_stats_result,
14921 		 stats, "stats");
14922 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14923 	TOKEN_NUM_INITIALIZER
14924 		(struct cmd_show_vf_stats_result,
14925 		 port_id, RTE_UINT16);
14926 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14927 	TOKEN_NUM_INITIALIZER
14928 		(struct cmd_show_vf_stats_result,
14929 		 vf_id, RTE_UINT16);
14930 
14931 static void
14932 cmd_show_vf_stats_parsed(
14933 	void *parsed_result,
14934 	__rte_unused struct cmdline *cl,
14935 	__rte_unused void *data)
14936 {
14937 	struct cmd_show_vf_stats_result *res = parsed_result;
14938 	struct rte_eth_stats stats;
14939 	int ret = -ENOTSUP;
14940 	static const char *nic_stats_border = "########################";
14941 
14942 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14943 		return;
14944 
14945 	memset(&stats, 0, sizeof(stats));
14946 
14947 #ifdef RTE_NET_I40E
14948 	if (ret == -ENOTSUP)
14949 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14950 						res->vf_id,
14951 						&stats);
14952 #endif
14953 #ifdef RTE_NET_BNXT
14954 	if (ret == -ENOTSUP)
14955 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14956 						res->vf_id,
14957 						&stats);
14958 #endif
14959 
14960 	switch (ret) {
14961 	case 0:
14962 		break;
14963 	case -EINVAL:
14964 		printf("invalid vf_id %d\n", res->vf_id);
14965 		break;
14966 	case -ENODEV:
14967 		printf("invalid port_id %d\n", res->port_id);
14968 		break;
14969 	case -ENOTSUP:
14970 		printf("function not implemented\n");
14971 		break;
14972 	default:
14973 		printf("programming error: (%s)\n", strerror(-ret));
14974 	}
14975 
14976 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
14977 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14978 
14979 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
14980 	       "%-"PRIu64"\n",
14981 	       stats.ipackets, stats.imissed, stats.ibytes);
14982 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
14983 	printf("  RX-nombuf:  %-10"PRIu64"\n",
14984 	       stats.rx_nombuf);
14985 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
14986 	       "%-"PRIu64"\n",
14987 	       stats.opackets, stats.oerrors, stats.obytes);
14988 
14989 	printf("  %s############################%s\n",
14990 			       nic_stats_border, nic_stats_border);
14991 }
14992 
14993 cmdline_parse_inst_t cmd_show_vf_stats = {
14994 	.f = cmd_show_vf_stats_parsed,
14995 	.data = NULL,
14996 	.help_str = "show vf stats <port_id> <vf_id>",
14997 	.tokens = {
14998 		(void *)&cmd_show_vf_stats_show,
14999 		(void *)&cmd_show_vf_stats_vf,
15000 		(void *)&cmd_show_vf_stats_stats,
15001 		(void *)&cmd_show_vf_stats_port_id,
15002 		(void *)&cmd_show_vf_stats_vf_id,
15003 		NULL,
15004 	},
15005 };
15006 
15007 /* clear vf stats */
15008 
15009 /* Common result structure for clear vf stats */
15010 struct cmd_clear_vf_stats_result {
15011 	cmdline_fixed_string_t clear;
15012 	cmdline_fixed_string_t vf;
15013 	cmdline_fixed_string_t stats;
15014 	portid_t port_id;
15015 	uint16_t vf_id;
15016 };
15017 
15018 /* Common CLI fields clear vf stats*/
15019 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15020 	TOKEN_STRING_INITIALIZER
15021 		(struct cmd_clear_vf_stats_result,
15022 		 clear, "clear");
15023 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15024 	TOKEN_STRING_INITIALIZER
15025 		(struct cmd_clear_vf_stats_result,
15026 		 vf, "vf");
15027 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15028 	TOKEN_STRING_INITIALIZER
15029 		(struct cmd_clear_vf_stats_result,
15030 		 stats, "stats");
15031 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15032 	TOKEN_NUM_INITIALIZER
15033 		(struct cmd_clear_vf_stats_result,
15034 		 port_id, RTE_UINT16);
15035 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15036 	TOKEN_NUM_INITIALIZER
15037 		(struct cmd_clear_vf_stats_result,
15038 		 vf_id, RTE_UINT16);
15039 
15040 static void
15041 cmd_clear_vf_stats_parsed(
15042 	void *parsed_result,
15043 	__rte_unused struct cmdline *cl,
15044 	__rte_unused void *data)
15045 {
15046 	struct cmd_clear_vf_stats_result *res = parsed_result;
15047 	int ret = -ENOTSUP;
15048 
15049 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15050 		return;
15051 
15052 #ifdef RTE_NET_I40E
15053 	if (ret == -ENOTSUP)
15054 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15055 						  res->vf_id);
15056 #endif
15057 #ifdef RTE_NET_BNXT
15058 	if (ret == -ENOTSUP)
15059 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15060 						  res->vf_id);
15061 #endif
15062 
15063 	switch (ret) {
15064 	case 0:
15065 		break;
15066 	case -EINVAL:
15067 		printf("invalid vf_id %d\n", res->vf_id);
15068 		break;
15069 	case -ENODEV:
15070 		printf("invalid port_id %d\n", res->port_id);
15071 		break;
15072 	case -ENOTSUP:
15073 		printf("function not implemented\n");
15074 		break;
15075 	default:
15076 		printf("programming error: (%s)\n", strerror(-ret));
15077 	}
15078 }
15079 
15080 cmdline_parse_inst_t cmd_clear_vf_stats = {
15081 	.f = cmd_clear_vf_stats_parsed,
15082 	.data = NULL,
15083 	.help_str = "clear vf stats <port_id> <vf_id>",
15084 	.tokens = {
15085 		(void *)&cmd_clear_vf_stats_clear,
15086 		(void *)&cmd_clear_vf_stats_vf,
15087 		(void *)&cmd_clear_vf_stats_stats,
15088 		(void *)&cmd_clear_vf_stats_port_id,
15089 		(void *)&cmd_clear_vf_stats_vf_id,
15090 		NULL,
15091 	},
15092 };
15093 
15094 /* port config pctype mapping reset */
15095 
15096 /* Common result structure for port config pctype mapping reset */
15097 struct cmd_pctype_mapping_reset_result {
15098 	cmdline_fixed_string_t port;
15099 	cmdline_fixed_string_t config;
15100 	portid_t port_id;
15101 	cmdline_fixed_string_t pctype;
15102 	cmdline_fixed_string_t mapping;
15103 	cmdline_fixed_string_t reset;
15104 };
15105 
15106 /* Common CLI fields for port config pctype mapping reset*/
15107 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15108 	TOKEN_STRING_INITIALIZER
15109 		(struct cmd_pctype_mapping_reset_result,
15110 		 port, "port");
15111 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15112 	TOKEN_STRING_INITIALIZER
15113 		(struct cmd_pctype_mapping_reset_result,
15114 		 config, "config");
15115 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15116 	TOKEN_NUM_INITIALIZER
15117 		(struct cmd_pctype_mapping_reset_result,
15118 		 port_id, RTE_UINT16);
15119 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15120 	TOKEN_STRING_INITIALIZER
15121 		(struct cmd_pctype_mapping_reset_result,
15122 		 pctype, "pctype");
15123 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15124 	TOKEN_STRING_INITIALIZER
15125 		(struct cmd_pctype_mapping_reset_result,
15126 		 mapping, "mapping");
15127 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15128 	TOKEN_STRING_INITIALIZER
15129 		(struct cmd_pctype_mapping_reset_result,
15130 		 reset, "reset");
15131 
15132 static void
15133 cmd_pctype_mapping_reset_parsed(
15134 	void *parsed_result,
15135 	__rte_unused struct cmdline *cl,
15136 	__rte_unused void *data)
15137 {
15138 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15139 	int ret = -ENOTSUP;
15140 
15141 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15142 		return;
15143 
15144 #ifdef RTE_NET_I40E
15145 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15146 #endif
15147 
15148 	switch (ret) {
15149 	case 0:
15150 		break;
15151 	case -ENODEV:
15152 		printf("invalid port_id %d\n", res->port_id);
15153 		break;
15154 	case -ENOTSUP:
15155 		printf("function not implemented\n");
15156 		break;
15157 	default:
15158 		printf("programming error: (%s)\n", strerror(-ret));
15159 	}
15160 }
15161 
15162 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15163 	.f = cmd_pctype_mapping_reset_parsed,
15164 	.data = NULL,
15165 	.help_str = "port config <port_id> pctype mapping reset",
15166 	.tokens = {
15167 		(void *)&cmd_pctype_mapping_reset_port,
15168 		(void *)&cmd_pctype_mapping_reset_config,
15169 		(void *)&cmd_pctype_mapping_reset_port_id,
15170 		(void *)&cmd_pctype_mapping_reset_pctype,
15171 		(void *)&cmd_pctype_mapping_reset_mapping,
15172 		(void *)&cmd_pctype_mapping_reset_reset,
15173 		NULL,
15174 	},
15175 };
15176 
15177 /* show port pctype mapping */
15178 
15179 /* Common result structure for show port pctype mapping */
15180 struct cmd_pctype_mapping_get_result {
15181 	cmdline_fixed_string_t show;
15182 	cmdline_fixed_string_t port;
15183 	portid_t port_id;
15184 	cmdline_fixed_string_t pctype;
15185 	cmdline_fixed_string_t mapping;
15186 };
15187 
15188 /* Common CLI fields for pctype mapping get */
15189 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15190 	TOKEN_STRING_INITIALIZER
15191 		(struct cmd_pctype_mapping_get_result,
15192 		 show, "show");
15193 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15194 	TOKEN_STRING_INITIALIZER
15195 		(struct cmd_pctype_mapping_get_result,
15196 		 port, "port");
15197 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15198 	TOKEN_NUM_INITIALIZER
15199 		(struct cmd_pctype_mapping_get_result,
15200 		 port_id, RTE_UINT16);
15201 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15202 	TOKEN_STRING_INITIALIZER
15203 		(struct cmd_pctype_mapping_get_result,
15204 		 pctype, "pctype");
15205 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15206 	TOKEN_STRING_INITIALIZER
15207 		(struct cmd_pctype_mapping_get_result,
15208 		 mapping, "mapping");
15209 
15210 static void
15211 cmd_pctype_mapping_get_parsed(
15212 	void *parsed_result,
15213 	__rte_unused struct cmdline *cl,
15214 	__rte_unused void *data)
15215 {
15216 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15217 	int ret = -ENOTSUP;
15218 #ifdef RTE_NET_I40E
15219 	struct rte_pmd_i40e_flow_type_mapping
15220 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15221 	int i, j, first_pctype;
15222 #endif
15223 
15224 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15225 		return;
15226 
15227 #ifdef RTE_NET_I40E
15228 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15229 #endif
15230 
15231 	switch (ret) {
15232 	case 0:
15233 		break;
15234 	case -ENODEV:
15235 		printf("invalid port_id %d\n", res->port_id);
15236 		return;
15237 	case -ENOTSUP:
15238 		printf("function not implemented\n");
15239 		return;
15240 	default:
15241 		printf("programming error: (%s)\n", strerror(-ret));
15242 		return;
15243 	}
15244 
15245 #ifdef RTE_NET_I40E
15246 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15247 		if (mapping[i].pctype != 0ULL) {
15248 			first_pctype = 1;
15249 
15250 			printf("pctype: ");
15251 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15252 				if (mapping[i].pctype & (1ULL << j)) {
15253 					printf(first_pctype ?
15254 					       "%02d" : ",%02d", j);
15255 					first_pctype = 0;
15256 				}
15257 			}
15258 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15259 		}
15260 	}
15261 #endif
15262 }
15263 
15264 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15265 	.f = cmd_pctype_mapping_get_parsed,
15266 	.data = NULL,
15267 	.help_str = "show port <port_id> pctype mapping",
15268 	.tokens = {
15269 		(void *)&cmd_pctype_mapping_get_show,
15270 		(void *)&cmd_pctype_mapping_get_port,
15271 		(void *)&cmd_pctype_mapping_get_port_id,
15272 		(void *)&cmd_pctype_mapping_get_pctype,
15273 		(void *)&cmd_pctype_mapping_get_mapping,
15274 		NULL,
15275 	},
15276 };
15277 
15278 /* port config pctype mapping update */
15279 
15280 /* Common result structure for port config pctype mapping update */
15281 struct cmd_pctype_mapping_update_result {
15282 	cmdline_fixed_string_t port;
15283 	cmdline_fixed_string_t config;
15284 	portid_t port_id;
15285 	cmdline_fixed_string_t pctype;
15286 	cmdline_fixed_string_t mapping;
15287 	cmdline_fixed_string_t update;
15288 	cmdline_fixed_string_t pctype_list;
15289 	uint16_t flow_type;
15290 };
15291 
15292 /* Common CLI fields for pctype mapping update*/
15293 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15294 	TOKEN_STRING_INITIALIZER
15295 		(struct cmd_pctype_mapping_update_result,
15296 		 port, "port");
15297 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15298 	TOKEN_STRING_INITIALIZER
15299 		(struct cmd_pctype_mapping_update_result,
15300 		 config, "config");
15301 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15302 	TOKEN_NUM_INITIALIZER
15303 		(struct cmd_pctype_mapping_update_result,
15304 		 port_id, RTE_UINT16);
15305 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15306 	TOKEN_STRING_INITIALIZER
15307 		(struct cmd_pctype_mapping_update_result,
15308 		 pctype, "pctype");
15309 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15310 	TOKEN_STRING_INITIALIZER
15311 		(struct cmd_pctype_mapping_update_result,
15312 		 mapping, "mapping");
15313 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15314 	TOKEN_STRING_INITIALIZER
15315 		(struct cmd_pctype_mapping_update_result,
15316 		 update, "update");
15317 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15318 	TOKEN_STRING_INITIALIZER
15319 		(struct cmd_pctype_mapping_update_result,
15320 		 pctype_list, NULL);
15321 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15322 	TOKEN_NUM_INITIALIZER
15323 		(struct cmd_pctype_mapping_update_result,
15324 		 flow_type, RTE_UINT16);
15325 
15326 static void
15327 cmd_pctype_mapping_update_parsed(
15328 	void *parsed_result,
15329 	__rte_unused struct cmdline *cl,
15330 	__rte_unused void *data)
15331 {
15332 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15333 	int ret = -ENOTSUP;
15334 #ifdef RTE_NET_I40E
15335 	struct rte_pmd_i40e_flow_type_mapping mapping;
15336 	unsigned int i;
15337 	unsigned int nb_item;
15338 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15339 #endif
15340 
15341 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15342 		return;
15343 
15344 #ifdef RTE_NET_I40E
15345 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15346 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15347 	mapping.flow_type = res->flow_type;
15348 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15349 		mapping.pctype |= (1ULL << pctype_list[i]);
15350 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15351 						&mapping,
15352 						1,
15353 						0);
15354 #endif
15355 
15356 	switch (ret) {
15357 	case 0:
15358 		break;
15359 	case -EINVAL:
15360 		printf("invalid pctype or flow type\n");
15361 		break;
15362 	case -ENODEV:
15363 		printf("invalid port_id %d\n", res->port_id);
15364 		break;
15365 	case -ENOTSUP:
15366 		printf("function not implemented\n");
15367 		break;
15368 	default:
15369 		printf("programming error: (%s)\n", strerror(-ret));
15370 	}
15371 }
15372 
15373 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15374 	.f = cmd_pctype_mapping_update_parsed,
15375 	.data = NULL,
15376 	.help_str = "port config <port_id> pctype mapping update"
15377 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15378 	.tokens = {
15379 		(void *)&cmd_pctype_mapping_update_port,
15380 		(void *)&cmd_pctype_mapping_update_config,
15381 		(void *)&cmd_pctype_mapping_update_port_id,
15382 		(void *)&cmd_pctype_mapping_update_pctype,
15383 		(void *)&cmd_pctype_mapping_update_mapping,
15384 		(void *)&cmd_pctype_mapping_update_update,
15385 		(void *)&cmd_pctype_mapping_update_pc_type,
15386 		(void *)&cmd_pctype_mapping_update_flow_type,
15387 		NULL,
15388 	},
15389 };
15390 
15391 /* ptype mapping get */
15392 
15393 /* Common result structure for ptype mapping get */
15394 struct cmd_ptype_mapping_get_result {
15395 	cmdline_fixed_string_t ptype;
15396 	cmdline_fixed_string_t mapping;
15397 	cmdline_fixed_string_t get;
15398 	portid_t port_id;
15399 	uint8_t valid_only;
15400 };
15401 
15402 /* Common CLI fields for ptype mapping get */
15403 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15404 	TOKEN_STRING_INITIALIZER
15405 		(struct cmd_ptype_mapping_get_result,
15406 		 ptype, "ptype");
15407 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15408 	TOKEN_STRING_INITIALIZER
15409 		(struct cmd_ptype_mapping_get_result,
15410 		 mapping, "mapping");
15411 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15412 	TOKEN_STRING_INITIALIZER
15413 		(struct cmd_ptype_mapping_get_result,
15414 		 get, "get");
15415 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15416 	TOKEN_NUM_INITIALIZER
15417 		(struct cmd_ptype_mapping_get_result,
15418 		 port_id, RTE_UINT16);
15419 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15420 	TOKEN_NUM_INITIALIZER
15421 		(struct cmd_ptype_mapping_get_result,
15422 		 valid_only, RTE_UINT8);
15423 
15424 static void
15425 cmd_ptype_mapping_get_parsed(
15426 	void *parsed_result,
15427 	__rte_unused struct cmdline *cl,
15428 	__rte_unused void *data)
15429 {
15430 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15431 	int ret = -ENOTSUP;
15432 #ifdef RTE_NET_I40E
15433 	int max_ptype_num = 256;
15434 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15435 	uint16_t count;
15436 	int i;
15437 #endif
15438 
15439 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15440 		return;
15441 
15442 #ifdef RTE_NET_I40E
15443 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15444 					mapping,
15445 					max_ptype_num,
15446 					&count,
15447 					res->valid_only);
15448 #endif
15449 
15450 	switch (ret) {
15451 	case 0:
15452 		break;
15453 	case -ENODEV:
15454 		printf("invalid port_id %d\n", res->port_id);
15455 		break;
15456 	case -ENOTSUP:
15457 		printf("function not implemented\n");
15458 		break;
15459 	default:
15460 		printf("programming error: (%s)\n", strerror(-ret));
15461 	}
15462 
15463 #ifdef RTE_NET_I40E
15464 	if (!ret) {
15465 		for (i = 0; i < count; i++)
15466 			printf("%3d\t0x%08x\n",
15467 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15468 	}
15469 #endif
15470 }
15471 
15472 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15473 	.f = cmd_ptype_mapping_get_parsed,
15474 	.data = NULL,
15475 	.help_str = "ptype mapping get <port_id> <valid_only>",
15476 	.tokens = {
15477 		(void *)&cmd_ptype_mapping_get_ptype,
15478 		(void *)&cmd_ptype_mapping_get_mapping,
15479 		(void *)&cmd_ptype_mapping_get_get,
15480 		(void *)&cmd_ptype_mapping_get_port_id,
15481 		(void *)&cmd_ptype_mapping_get_valid_only,
15482 		NULL,
15483 	},
15484 };
15485 
15486 /* ptype mapping replace */
15487 
15488 /* Common result structure for ptype mapping replace */
15489 struct cmd_ptype_mapping_replace_result {
15490 	cmdline_fixed_string_t ptype;
15491 	cmdline_fixed_string_t mapping;
15492 	cmdline_fixed_string_t replace;
15493 	portid_t port_id;
15494 	uint32_t target;
15495 	uint8_t mask;
15496 	uint32_t pkt_type;
15497 };
15498 
15499 /* Common CLI fields for ptype mapping replace */
15500 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15501 	TOKEN_STRING_INITIALIZER
15502 		(struct cmd_ptype_mapping_replace_result,
15503 		 ptype, "ptype");
15504 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15505 	TOKEN_STRING_INITIALIZER
15506 		(struct cmd_ptype_mapping_replace_result,
15507 		 mapping, "mapping");
15508 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15509 	TOKEN_STRING_INITIALIZER
15510 		(struct cmd_ptype_mapping_replace_result,
15511 		 replace, "replace");
15512 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15513 	TOKEN_NUM_INITIALIZER
15514 		(struct cmd_ptype_mapping_replace_result,
15515 		 port_id, RTE_UINT16);
15516 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15517 	TOKEN_NUM_INITIALIZER
15518 		(struct cmd_ptype_mapping_replace_result,
15519 		 target, RTE_UINT32);
15520 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15521 	TOKEN_NUM_INITIALIZER
15522 		(struct cmd_ptype_mapping_replace_result,
15523 		 mask, RTE_UINT8);
15524 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15525 	TOKEN_NUM_INITIALIZER
15526 		(struct cmd_ptype_mapping_replace_result,
15527 		 pkt_type, RTE_UINT32);
15528 
15529 static void
15530 cmd_ptype_mapping_replace_parsed(
15531 	void *parsed_result,
15532 	__rte_unused struct cmdline *cl,
15533 	__rte_unused void *data)
15534 {
15535 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15536 	int ret = -ENOTSUP;
15537 
15538 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15539 		return;
15540 
15541 #ifdef RTE_NET_I40E
15542 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15543 					res->target,
15544 					res->mask,
15545 					res->pkt_type);
15546 #endif
15547 
15548 	switch (ret) {
15549 	case 0:
15550 		break;
15551 	case -EINVAL:
15552 		printf("invalid ptype 0x%8x or 0x%8x\n",
15553 				res->target, res->pkt_type);
15554 		break;
15555 	case -ENODEV:
15556 		printf("invalid port_id %d\n", res->port_id);
15557 		break;
15558 	case -ENOTSUP:
15559 		printf("function not implemented\n");
15560 		break;
15561 	default:
15562 		printf("programming error: (%s)\n", strerror(-ret));
15563 	}
15564 }
15565 
15566 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15567 	.f = cmd_ptype_mapping_replace_parsed,
15568 	.data = NULL,
15569 	.help_str =
15570 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15571 	.tokens = {
15572 		(void *)&cmd_ptype_mapping_replace_ptype,
15573 		(void *)&cmd_ptype_mapping_replace_mapping,
15574 		(void *)&cmd_ptype_mapping_replace_replace,
15575 		(void *)&cmd_ptype_mapping_replace_port_id,
15576 		(void *)&cmd_ptype_mapping_replace_target,
15577 		(void *)&cmd_ptype_mapping_replace_mask,
15578 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15579 		NULL,
15580 	},
15581 };
15582 
15583 /* ptype mapping reset */
15584 
15585 /* Common result structure for ptype mapping reset */
15586 struct cmd_ptype_mapping_reset_result {
15587 	cmdline_fixed_string_t ptype;
15588 	cmdline_fixed_string_t mapping;
15589 	cmdline_fixed_string_t reset;
15590 	portid_t port_id;
15591 };
15592 
15593 /* Common CLI fields for ptype mapping reset*/
15594 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15595 	TOKEN_STRING_INITIALIZER
15596 		(struct cmd_ptype_mapping_reset_result,
15597 		 ptype, "ptype");
15598 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15599 	TOKEN_STRING_INITIALIZER
15600 		(struct cmd_ptype_mapping_reset_result,
15601 		 mapping, "mapping");
15602 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15603 	TOKEN_STRING_INITIALIZER
15604 		(struct cmd_ptype_mapping_reset_result,
15605 		 reset, "reset");
15606 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15607 	TOKEN_NUM_INITIALIZER
15608 		(struct cmd_ptype_mapping_reset_result,
15609 		 port_id, RTE_UINT16);
15610 
15611 static void
15612 cmd_ptype_mapping_reset_parsed(
15613 	void *parsed_result,
15614 	__rte_unused struct cmdline *cl,
15615 	__rte_unused void *data)
15616 {
15617 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15618 	int ret = -ENOTSUP;
15619 
15620 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15621 		return;
15622 
15623 #ifdef RTE_NET_I40E
15624 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15625 #endif
15626 
15627 	switch (ret) {
15628 	case 0:
15629 		break;
15630 	case -ENODEV:
15631 		printf("invalid port_id %d\n", res->port_id);
15632 		break;
15633 	case -ENOTSUP:
15634 		printf("function not implemented\n");
15635 		break;
15636 	default:
15637 		printf("programming error: (%s)\n", strerror(-ret));
15638 	}
15639 }
15640 
15641 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15642 	.f = cmd_ptype_mapping_reset_parsed,
15643 	.data = NULL,
15644 	.help_str = "ptype mapping reset <port_id>",
15645 	.tokens = {
15646 		(void *)&cmd_ptype_mapping_reset_ptype,
15647 		(void *)&cmd_ptype_mapping_reset_mapping,
15648 		(void *)&cmd_ptype_mapping_reset_reset,
15649 		(void *)&cmd_ptype_mapping_reset_port_id,
15650 		NULL,
15651 	},
15652 };
15653 
15654 /* ptype mapping update */
15655 
15656 /* Common result structure for ptype mapping update */
15657 struct cmd_ptype_mapping_update_result {
15658 	cmdline_fixed_string_t ptype;
15659 	cmdline_fixed_string_t mapping;
15660 	cmdline_fixed_string_t reset;
15661 	portid_t port_id;
15662 	uint8_t hw_ptype;
15663 	uint32_t sw_ptype;
15664 };
15665 
15666 /* Common CLI fields for ptype mapping update*/
15667 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15668 	TOKEN_STRING_INITIALIZER
15669 		(struct cmd_ptype_mapping_update_result,
15670 		 ptype, "ptype");
15671 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15672 	TOKEN_STRING_INITIALIZER
15673 		(struct cmd_ptype_mapping_update_result,
15674 		 mapping, "mapping");
15675 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15676 	TOKEN_STRING_INITIALIZER
15677 		(struct cmd_ptype_mapping_update_result,
15678 		 reset, "update");
15679 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15680 	TOKEN_NUM_INITIALIZER
15681 		(struct cmd_ptype_mapping_update_result,
15682 		 port_id, RTE_UINT16);
15683 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15684 	TOKEN_NUM_INITIALIZER
15685 		(struct cmd_ptype_mapping_update_result,
15686 		 hw_ptype, RTE_UINT8);
15687 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15688 	TOKEN_NUM_INITIALIZER
15689 		(struct cmd_ptype_mapping_update_result,
15690 		 sw_ptype, RTE_UINT32);
15691 
15692 static void
15693 cmd_ptype_mapping_update_parsed(
15694 	void *parsed_result,
15695 	__rte_unused struct cmdline *cl,
15696 	__rte_unused void *data)
15697 {
15698 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15699 	int ret = -ENOTSUP;
15700 #ifdef RTE_NET_I40E
15701 	struct rte_pmd_i40e_ptype_mapping mapping;
15702 #endif
15703 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15704 		return;
15705 
15706 #ifdef RTE_NET_I40E
15707 	mapping.hw_ptype = res->hw_ptype;
15708 	mapping.sw_ptype = res->sw_ptype;
15709 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15710 						&mapping,
15711 						1,
15712 						0);
15713 #endif
15714 
15715 	switch (ret) {
15716 	case 0:
15717 		break;
15718 	case -EINVAL:
15719 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
15720 		break;
15721 	case -ENODEV:
15722 		printf("invalid port_id %d\n", res->port_id);
15723 		break;
15724 	case -ENOTSUP:
15725 		printf("function not implemented\n");
15726 		break;
15727 	default:
15728 		printf("programming error: (%s)\n", strerror(-ret));
15729 	}
15730 }
15731 
15732 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15733 	.f = cmd_ptype_mapping_update_parsed,
15734 	.data = NULL,
15735 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15736 	.tokens = {
15737 		(void *)&cmd_ptype_mapping_update_ptype,
15738 		(void *)&cmd_ptype_mapping_update_mapping,
15739 		(void *)&cmd_ptype_mapping_update_update,
15740 		(void *)&cmd_ptype_mapping_update_port_id,
15741 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15742 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15743 		NULL,
15744 	},
15745 };
15746 
15747 /* Common result structure for file commands */
15748 struct cmd_cmdfile_result {
15749 	cmdline_fixed_string_t load;
15750 	cmdline_fixed_string_t filename;
15751 };
15752 
15753 /* Common CLI fields for file commands */
15754 cmdline_parse_token_string_t cmd_load_cmdfile =
15755 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15756 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15757 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15758 
15759 static void
15760 cmd_load_from_file_parsed(
15761 	void *parsed_result,
15762 	__rte_unused struct cmdline *cl,
15763 	__rte_unused void *data)
15764 {
15765 	struct cmd_cmdfile_result *res = parsed_result;
15766 
15767 	cmdline_read_from_file(res->filename);
15768 }
15769 
15770 cmdline_parse_inst_t cmd_load_from_file = {
15771 	.f = cmd_load_from_file_parsed,
15772 	.data = NULL,
15773 	.help_str = "load <filename>",
15774 	.tokens = {
15775 		(void *)&cmd_load_cmdfile,
15776 		(void *)&cmd_load_cmdfile_filename,
15777 		NULL,
15778 	},
15779 };
15780 
15781 /* Get Rx offloads capabilities */
15782 struct cmd_rx_offload_get_capa_result {
15783 	cmdline_fixed_string_t show;
15784 	cmdline_fixed_string_t port;
15785 	portid_t port_id;
15786 	cmdline_fixed_string_t rx_offload;
15787 	cmdline_fixed_string_t capabilities;
15788 };
15789 
15790 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15791 	TOKEN_STRING_INITIALIZER
15792 		(struct cmd_rx_offload_get_capa_result,
15793 		 show, "show");
15794 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15795 	TOKEN_STRING_INITIALIZER
15796 		(struct cmd_rx_offload_get_capa_result,
15797 		 port, "port");
15798 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15799 	TOKEN_NUM_INITIALIZER
15800 		(struct cmd_rx_offload_get_capa_result,
15801 		 port_id, RTE_UINT16);
15802 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15803 	TOKEN_STRING_INITIALIZER
15804 		(struct cmd_rx_offload_get_capa_result,
15805 		 rx_offload, "rx_offload");
15806 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15807 	TOKEN_STRING_INITIALIZER
15808 		(struct cmd_rx_offload_get_capa_result,
15809 		 capabilities, "capabilities");
15810 
15811 static void
15812 print_rx_offloads(uint64_t offloads)
15813 {
15814 	uint64_t single_offload;
15815 	int begin;
15816 	int end;
15817 	int bit;
15818 
15819 	if (offloads == 0)
15820 		return;
15821 
15822 	begin = __builtin_ctzll(offloads);
15823 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15824 
15825 	single_offload = 1ULL << begin;
15826 	for (bit = begin; bit < end; bit++) {
15827 		if (offloads & single_offload)
15828 			printf(" %s",
15829 			       rte_eth_dev_rx_offload_name(single_offload));
15830 		single_offload <<= 1;
15831 	}
15832 }
15833 
15834 static void
15835 cmd_rx_offload_get_capa_parsed(
15836 	void *parsed_result,
15837 	__rte_unused struct cmdline *cl,
15838 	__rte_unused void *data)
15839 {
15840 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
15841 	struct rte_eth_dev_info dev_info;
15842 	portid_t port_id = res->port_id;
15843 	uint64_t queue_offloads;
15844 	uint64_t port_offloads;
15845 	int ret;
15846 
15847 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15848 	if (ret != 0)
15849 		return;
15850 
15851 	queue_offloads = dev_info.rx_queue_offload_capa;
15852 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15853 
15854 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
15855 	printf("  Per Queue :");
15856 	print_rx_offloads(queue_offloads);
15857 
15858 	printf("\n");
15859 	printf("  Per Port  :");
15860 	print_rx_offloads(port_offloads);
15861 	printf("\n\n");
15862 }
15863 
15864 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15865 	.f = cmd_rx_offload_get_capa_parsed,
15866 	.data = NULL,
15867 	.help_str = "show port <port_id> rx_offload capabilities",
15868 	.tokens = {
15869 		(void *)&cmd_rx_offload_get_capa_show,
15870 		(void *)&cmd_rx_offload_get_capa_port,
15871 		(void *)&cmd_rx_offload_get_capa_port_id,
15872 		(void *)&cmd_rx_offload_get_capa_rx_offload,
15873 		(void *)&cmd_rx_offload_get_capa_capabilities,
15874 		NULL,
15875 	}
15876 };
15877 
15878 /* Get Rx offloads configuration */
15879 struct cmd_rx_offload_get_configuration_result {
15880 	cmdline_fixed_string_t show;
15881 	cmdline_fixed_string_t port;
15882 	portid_t port_id;
15883 	cmdline_fixed_string_t rx_offload;
15884 	cmdline_fixed_string_t configuration;
15885 };
15886 
15887 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15888 	TOKEN_STRING_INITIALIZER
15889 		(struct cmd_rx_offload_get_configuration_result,
15890 		 show, "show");
15891 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15892 	TOKEN_STRING_INITIALIZER
15893 		(struct cmd_rx_offload_get_configuration_result,
15894 		 port, "port");
15895 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15896 	TOKEN_NUM_INITIALIZER
15897 		(struct cmd_rx_offload_get_configuration_result,
15898 		 port_id, RTE_UINT16);
15899 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15900 	TOKEN_STRING_INITIALIZER
15901 		(struct cmd_rx_offload_get_configuration_result,
15902 		 rx_offload, "rx_offload");
15903 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15904 	TOKEN_STRING_INITIALIZER
15905 		(struct cmd_rx_offload_get_configuration_result,
15906 		 configuration, "configuration");
15907 
15908 static void
15909 cmd_rx_offload_get_configuration_parsed(
15910 	void *parsed_result,
15911 	__rte_unused struct cmdline *cl,
15912 	__rte_unused void *data)
15913 {
15914 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15915 	struct rte_eth_dev_info dev_info;
15916 	portid_t port_id = res->port_id;
15917 	struct rte_port *port = &ports[port_id];
15918 	uint64_t port_offloads;
15919 	uint64_t queue_offloads;
15920 	uint16_t nb_rx_queues;
15921 	int q;
15922 	int ret;
15923 
15924 	printf("Rx Offloading Configuration of port %d :\n", port_id);
15925 
15926 	port_offloads = port->dev_conf.rxmode.offloads;
15927 	printf("  Port :");
15928 	print_rx_offloads(port_offloads);
15929 	printf("\n");
15930 
15931 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
15932 	if (ret != 0)
15933 		return;
15934 
15935 	nb_rx_queues = dev_info.nb_rx_queues;
15936 	for (q = 0; q < nb_rx_queues; q++) {
15937 		queue_offloads = port->rx_conf[q].offloads;
15938 		printf("  Queue[%2d] :", q);
15939 		print_rx_offloads(queue_offloads);
15940 		printf("\n");
15941 	}
15942 	printf("\n");
15943 }
15944 
15945 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15946 	.f = cmd_rx_offload_get_configuration_parsed,
15947 	.data = NULL,
15948 	.help_str = "show port <port_id> rx_offload configuration",
15949 	.tokens = {
15950 		(void *)&cmd_rx_offload_get_configuration_show,
15951 		(void *)&cmd_rx_offload_get_configuration_port,
15952 		(void *)&cmd_rx_offload_get_configuration_port_id,
15953 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
15954 		(void *)&cmd_rx_offload_get_configuration_configuration,
15955 		NULL,
15956 	}
15957 };
15958 
15959 /* Enable/Disable a per port offloading */
15960 struct cmd_config_per_port_rx_offload_result {
15961 	cmdline_fixed_string_t port;
15962 	cmdline_fixed_string_t config;
15963 	portid_t port_id;
15964 	cmdline_fixed_string_t rx_offload;
15965 	cmdline_fixed_string_t offload;
15966 	cmdline_fixed_string_t on_off;
15967 };
15968 
15969 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15970 	TOKEN_STRING_INITIALIZER
15971 		(struct cmd_config_per_port_rx_offload_result,
15972 		 port, "port");
15973 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15974 	TOKEN_STRING_INITIALIZER
15975 		(struct cmd_config_per_port_rx_offload_result,
15976 		 config, "config");
15977 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15978 	TOKEN_NUM_INITIALIZER
15979 		(struct cmd_config_per_port_rx_offload_result,
15980 		 port_id, RTE_UINT16);
15981 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15982 	TOKEN_STRING_INITIALIZER
15983 		(struct cmd_config_per_port_rx_offload_result,
15984 		 rx_offload, "rx_offload");
15985 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15986 	TOKEN_STRING_INITIALIZER
15987 		(struct cmd_config_per_port_rx_offload_result,
15988 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15989 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15990 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15991 			   "scatter#buffer_split#timestamp#security#"
15992 			   "keep_crc#rss_hash");
15993 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15994 	TOKEN_STRING_INITIALIZER
15995 		(struct cmd_config_per_port_rx_offload_result,
15996 		 on_off, "on#off");
15997 
15998 static uint64_t
15999 search_rx_offload(const char *name)
16000 {
16001 	uint64_t single_offload;
16002 	const char *single_name;
16003 	int found = 0;
16004 	unsigned int bit;
16005 
16006 	single_offload = 1;
16007 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16008 		single_name = rte_eth_dev_rx_offload_name(single_offload);
16009 		if (!strcasecmp(single_name, name)) {
16010 			found = 1;
16011 			break;
16012 		}
16013 		single_offload <<= 1;
16014 	}
16015 
16016 	if (found)
16017 		return single_offload;
16018 
16019 	return 0;
16020 }
16021 
16022 static void
16023 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16024 				__rte_unused struct cmdline *cl,
16025 				__rte_unused void *data)
16026 {
16027 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16028 	portid_t port_id = res->port_id;
16029 	struct rte_eth_dev_info dev_info;
16030 	struct rte_port *port = &ports[port_id];
16031 	uint64_t single_offload;
16032 	uint16_t nb_rx_queues;
16033 	int q;
16034 	int ret;
16035 
16036 	if (port->port_status != RTE_PORT_STOPPED) {
16037 		printf("Error: Can't config offload when Port %d "
16038 		       "is not stopped\n", port_id);
16039 		return;
16040 	}
16041 
16042 	single_offload = search_rx_offload(res->offload);
16043 	if (single_offload == 0) {
16044 		printf("Unknown offload name: %s\n", res->offload);
16045 		return;
16046 	}
16047 
16048 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16049 	if (ret != 0)
16050 		return;
16051 
16052 	nb_rx_queues = dev_info.nb_rx_queues;
16053 	if (!strcmp(res->on_off, "on")) {
16054 		port->dev_conf.rxmode.offloads |= single_offload;
16055 		for (q = 0; q < nb_rx_queues; q++)
16056 			port->rx_conf[q].offloads |= single_offload;
16057 	} else {
16058 		port->dev_conf.rxmode.offloads &= ~single_offload;
16059 		for (q = 0; q < nb_rx_queues; q++)
16060 			port->rx_conf[q].offloads &= ~single_offload;
16061 	}
16062 
16063 	cmd_reconfig_device_queue(port_id, 1, 1);
16064 }
16065 
16066 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16067 	.f = cmd_config_per_port_rx_offload_parsed,
16068 	.data = NULL,
16069 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16070 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16071 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16072 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16073 		    "keep_crc|rss_hash on|off",
16074 	.tokens = {
16075 		(void *)&cmd_config_per_port_rx_offload_result_port,
16076 		(void *)&cmd_config_per_port_rx_offload_result_config,
16077 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
16078 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16079 		(void *)&cmd_config_per_port_rx_offload_result_offload,
16080 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
16081 		NULL,
16082 	}
16083 };
16084 
16085 /* Enable/Disable a per queue offloading */
16086 struct cmd_config_per_queue_rx_offload_result {
16087 	cmdline_fixed_string_t port;
16088 	portid_t port_id;
16089 	cmdline_fixed_string_t rxq;
16090 	uint16_t queue_id;
16091 	cmdline_fixed_string_t rx_offload;
16092 	cmdline_fixed_string_t offload;
16093 	cmdline_fixed_string_t on_off;
16094 };
16095 
16096 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16097 	TOKEN_STRING_INITIALIZER
16098 		(struct cmd_config_per_queue_rx_offload_result,
16099 		 port, "port");
16100 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16101 	TOKEN_NUM_INITIALIZER
16102 		(struct cmd_config_per_queue_rx_offload_result,
16103 		 port_id, RTE_UINT16);
16104 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16105 	TOKEN_STRING_INITIALIZER
16106 		(struct cmd_config_per_queue_rx_offload_result,
16107 		 rxq, "rxq");
16108 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16109 	TOKEN_NUM_INITIALIZER
16110 		(struct cmd_config_per_queue_rx_offload_result,
16111 		 queue_id, RTE_UINT16);
16112 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16113 	TOKEN_STRING_INITIALIZER
16114 		(struct cmd_config_per_queue_rx_offload_result,
16115 		 rx_offload, "rx_offload");
16116 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16117 	TOKEN_STRING_INITIALIZER
16118 		(struct cmd_config_per_queue_rx_offload_result,
16119 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16120 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16121 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16122 			   "scatter#buffer_split#timestamp#security#keep_crc");
16123 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16124 	TOKEN_STRING_INITIALIZER
16125 		(struct cmd_config_per_queue_rx_offload_result,
16126 		 on_off, "on#off");
16127 
16128 static void
16129 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16130 				__rte_unused struct cmdline *cl,
16131 				__rte_unused void *data)
16132 {
16133 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16134 	struct rte_eth_dev_info dev_info;
16135 	portid_t port_id = res->port_id;
16136 	uint16_t queue_id = res->queue_id;
16137 	struct rte_port *port = &ports[port_id];
16138 	uint64_t single_offload;
16139 	int ret;
16140 
16141 	if (port->port_status != RTE_PORT_STOPPED) {
16142 		printf("Error: Can't config offload when Port %d "
16143 		       "is not stopped\n", port_id);
16144 		return;
16145 	}
16146 
16147 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16148 	if (ret != 0)
16149 		return;
16150 
16151 	if (queue_id >= dev_info.nb_rx_queues) {
16152 		printf("Error: input queue_id should be 0 ... "
16153 		       "%d\n", dev_info.nb_rx_queues - 1);
16154 		return;
16155 	}
16156 
16157 	single_offload = search_rx_offload(res->offload);
16158 	if (single_offload == 0) {
16159 		printf("Unknown offload name: %s\n", res->offload);
16160 		return;
16161 	}
16162 
16163 	if (!strcmp(res->on_off, "on"))
16164 		port->rx_conf[queue_id].offloads |= single_offload;
16165 	else
16166 		port->rx_conf[queue_id].offloads &= ~single_offload;
16167 
16168 	cmd_reconfig_device_queue(port_id, 1, 1);
16169 }
16170 
16171 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16172 	.f = cmd_config_per_queue_rx_offload_parsed,
16173 	.data = NULL,
16174 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
16175 		    "vlan_strip|ipv4_cksum|"
16176 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16177 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
16178 		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
16179 		    "keep_crc on|off",
16180 	.tokens = {
16181 		(void *)&cmd_config_per_queue_rx_offload_result_port,
16182 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
16183 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
16184 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16185 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16186 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
16187 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
16188 		NULL,
16189 	}
16190 };
16191 
16192 /* Get Tx offloads capabilities */
16193 struct cmd_tx_offload_get_capa_result {
16194 	cmdline_fixed_string_t show;
16195 	cmdline_fixed_string_t port;
16196 	portid_t port_id;
16197 	cmdline_fixed_string_t tx_offload;
16198 	cmdline_fixed_string_t capabilities;
16199 };
16200 
16201 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16202 	TOKEN_STRING_INITIALIZER
16203 		(struct cmd_tx_offload_get_capa_result,
16204 		 show, "show");
16205 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16206 	TOKEN_STRING_INITIALIZER
16207 		(struct cmd_tx_offload_get_capa_result,
16208 		 port, "port");
16209 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16210 	TOKEN_NUM_INITIALIZER
16211 		(struct cmd_tx_offload_get_capa_result,
16212 		 port_id, RTE_UINT16);
16213 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16214 	TOKEN_STRING_INITIALIZER
16215 		(struct cmd_tx_offload_get_capa_result,
16216 		 tx_offload, "tx_offload");
16217 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16218 	TOKEN_STRING_INITIALIZER
16219 		(struct cmd_tx_offload_get_capa_result,
16220 		 capabilities, "capabilities");
16221 
16222 static void
16223 print_tx_offloads(uint64_t offloads)
16224 {
16225 	uint64_t single_offload;
16226 	int begin;
16227 	int end;
16228 	int bit;
16229 
16230 	if (offloads == 0)
16231 		return;
16232 
16233 	begin = __builtin_ctzll(offloads);
16234 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16235 
16236 	single_offload = 1ULL << begin;
16237 	for (bit = begin; bit < end; bit++) {
16238 		if (offloads & single_offload)
16239 			printf(" %s",
16240 			       rte_eth_dev_tx_offload_name(single_offload));
16241 		single_offload <<= 1;
16242 	}
16243 }
16244 
16245 static void
16246 cmd_tx_offload_get_capa_parsed(
16247 	void *parsed_result,
16248 	__rte_unused struct cmdline *cl,
16249 	__rte_unused void *data)
16250 {
16251 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
16252 	struct rte_eth_dev_info dev_info;
16253 	portid_t port_id = res->port_id;
16254 	uint64_t queue_offloads;
16255 	uint64_t port_offloads;
16256 	int ret;
16257 
16258 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16259 	if (ret != 0)
16260 		return;
16261 
16262 	queue_offloads = dev_info.tx_queue_offload_capa;
16263 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16264 
16265 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
16266 	printf("  Per Queue :");
16267 	print_tx_offloads(queue_offloads);
16268 
16269 	printf("\n");
16270 	printf("  Per Port  :");
16271 	print_tx_offloads(port_offloads);
16272 	printf("\n\n");
16273 }
16274 
16275 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16276 	.f = cmd_tx_offload_get_capa_parsed,
16277 	.data = NULL,
16278 	.help_str = "show port <port_id> tx_offload capabilities",
16279 	.tokens = {
16280 		(void *)&cmd_tx_offload_get_capa_show,
16281 		(void *)&cmd_tx_offload_get_capa_port,
16282 		(void *)&cmd_tx_offload_get_capa_port_id,
16283 		(void *)&cmd_tx_offload_get_capa_tx_offload,
16284 		(void *)&cmd_tx_offload_get_capa_capabilities,
16285 		NULL,
16286 	}
16287 };
16288 
16289 /* Get Tx offloads configuration */
16290 struct cmd_tx_offload_get_configuration_result {
16291 	cmdline_fixed_string_t show;
16292 	cmdline_fixed_string_t port;
16293 	portid_t port_id;
16294 	cmdline_fixed_string_t tx_offload;
16295 	cmdline_fixed_string_t configuration;
16296 };
16297 
16298 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16299 	TOKEN_STRING_INITIALIZER
16300 		(struct cmd_tx_offload_get_configuration_result,
16301 		 show, "show");
16302 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16303 	TOKEN_STRING_INITIALIZER
16304 		(struct cmd_tx_offload_get_configuration_result,
16305 		 port, "port");
16306 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16307 	TOKEN_NUM_INITIALIZER
16308 		(struct cmd_tx_offload_get_configuration_result,
16309 		 port_id, RTE_UINT16);
16310 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16311 	TOKEN_STRING_INITIALIZER
16312 		(struct cmd_tx_offload_get_configuration_result,
16313 		 tx_offload, "tx_offload");
16314 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16315 	TOKEN_STRING_INITIALIZER
16316 		(struct cmd_tx_offload_get_configuration_result,
16317 		 configuration, "configuration");
16318 
16319 static void
16320 cmd_tx_offload_get_configuration_parsed(
16321 	void *parsed_result,
16322 	__rte_unused struct cmdline *cl,
16323 	__rte_unused void *data)
16324 {
16325 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16326 	struct rte_eth_dev_info dev_info;
16327 	portid_t port_id = res->port_id;
16328 	struct rte_port *port = &ports[port_id];
16329 	uint64_t port_offloads;
16330 	uint64_t queue_offloads;
16331 	uint16_t nb_tx_queues;
16332 	int q;
16333 	int ret;
16334 
16335 	printf("Tx Offloading Configuration of port %d :\n", port_id);
16336 
16337 	port_offloads = port->dev_conf.txmode.offloads;
16338 	printf("  Port :");
16339 	print_tx_offloads(port_offloads);
16340 	printf("\n");
16341 
16342 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16343 	if (ret != 0)
16344 		return;
16345 
16346 	nb_tx_queues = dev_info.nb_tx_queues;
16347 	for (q = 0; q < nb_tx_queues; q++) {
16348 		queue_offloads = port->tx_conf[q].offloads;
16349 		printf("  Queue[%2d] :", q);
16350 		print_tx_offloads(queue_offloads);
16351 		printf("\n");
16352 	}
16353 	printf("\n");
16354 }
16355 
16356 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16357 	.f = cmd_tx_offload_get_configuration_parsed,
16358 	.data = NULL,
16359 	.help_str = "show port <port_id> tx_offload configuration",
16360 	.tokens = {
16361 		(void *)&cmd_tx_offload_get_configuration_show,
16362 		(void *)&cmd_tx_offload_get_configuration_port,
16363 		(void *)&cmd_tx_offload_get_configuration_port_id,
16364 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
16365 		(void *)&cmd_tx_offload_get_configuration_configuration,
16366 		NULL,
16367 	}
16368 };
16369 
16370 /* Enable/Disable a per port offloading */
16371 struct cmd_config_per_port_tx_offload_result {
16372 	cmdline_fixed_string_t port;
16373 	cmdline_fixed_string_t config;
16374 	portid_t port_id;
16375 	cmdline_fixed_string_t tx_offload;
16376 	cmdline_fixed_string_t offload;
16377 	cmdline_fixed_string_t on_off;
16378 };
16379 
16380 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16381 	TOKEN_STRING_INITIALIZER
16382 		(struct cmd_config_per_port_tx_offload_result,
16383 		 port, "port");
16384 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16385 	TOKEN_STRING_INITIALIZER
16386 		(struct cmd_config_per_port_tx_offload_result,
16387 		 config, "config");
16388 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16389 	TOKEN_NUM_INITIALIZER
16390 		(struct cmd_config_per_port_tx_offload_result,
16391 		 port_id, RTE_UINT16);
16392 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16393 	TOKEN_STRING_INITIALIZER
16394 		(struct cmd_config_per_port_tx_offload_result,
16395 		 tx_offload, "tx_offload");
16396 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16397 	TOKEN_STRING_INITIALIZER
16398 		(struct cmd_config_per_port_tx_offload_result,
16399 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16400 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16401 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16402 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16403 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16404 			  "send_on_timestamp");
16405 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16406 	TOKEN_STRING_INITIALIZER
16407 		(struct cmd_config_per_port_tx_offload_result,
16408 		 on_off, "on#off");
16409 
16410 static uint64_t
16411 search_tx_offload(const char *name)
16412 {
16413 	uint64_t single_offload;
16414 	const char *single_name;
16415 	int found = 0;
16416 	unsigned int bit;
16417 
16418 	single_offload = 1;
16419 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16420 		single_name = rte_eth_dev_tx_offload_name(single_offload);
16421 		if (single_name == NULL)
16422 			break;
16423 		if (!strcasecmp(single_name, name)) {
16424 			found = 1;
16425 			break;
16426 		} else if (!strcasecmp(single_name, "UNKNOWN"))
16427 			break;
16428 		single_offload <<= 1;
16429 	}
16430 
16431 	if (found)
16432 		return single_offload;
16433 
16434 	return 0;
16435 }
16436 
16437 static void
16438 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16439 				__rte_unused struct cmdline *cl,
16440 				__rte_unused void *data)
16441 {
16442 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16443 	portid_t port_id = res->port_id;
16444 	struct rte_eth_dev_info dev_info;
16445 	struct rte_port *port = &ports[port_id];
16446 	uint64_t single_offload;
16447 	uint16_t nb_tx_queues;
16448 	int q;
16449 	int ret;
16450 
16451 	if (port->port_status != RTE_PORT_STOPPED) {
16452 		printf("Error: Can't config offload when Port %d "
16453 		       "is not stopped\n", port_id);
16454 		return;
16455 	}
16456 
16457 	single_offload = search_tx_offload(res->offload);
16458 	if (single_offload == 0) {
16459 		printf("Unknown offload name: %s\n", res->offload);
16460 		return;
16461 	}
16462 
16463 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16464 	if (ret != 0)
16465 		return;
16466 
16467 	nb_tx_queues = dev_info.nb_tx_queues;
16468 	if (!strcmp(res->on_off, "on")) {
16469 		port->dev_conf.txmode.offloads |= single_offload;
16470 		for (q = 0; q < nb_tx_queues; q++)
16471 			port->tx_conf[q].offloads |= single_offload;
16472 	} else {
16473 		port->dev_conf.txmode.offloads &= ~single_offload;
16474 		for (q = 0; q < nb_tx_queues; q++)
16475 			port->tx_conf[q].offloads &= ~single_offload;
16476 	}
16477 
16478 	cmd_reconfig_device_queue(port_id, 1, 1);
16479 }
16480 
16481 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16482 	.f = cmd_config_per_port_tx_offload_parsed,
16483 	.data = NULL,
16484 	.help_str = "port config <port_id> tx_offload "
16485 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16486 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16487 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16488 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16489 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16490 		    "send_on_timestamp on|off",
16491 	.tokens = {
16492 		(void *)&cmd_config_per_port_tx_offload_result_port,
16493 		(void *)&cmd_config_per_port_tx_offload_result_config,
16494 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
16495 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16496 		(void *)&cmd_config_per_port_tx_offload_result_offload,
16497 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
16498 		NULL,
16499 	}
16500 };
16501 
16502 /* Enable/Disable a per queue offloading */
16503 struct cmd_config_per_queue_tx_offload_result {
16504 	cmdline_fixed_string_t port;
16505 	portid_t port_id;
16506 	cmdline_fixed_string_t txq;
16507 	uint16_t queue_id;
16508 	cmdline_fixed_string_t tx_offload;
16509 	cmdline_fixed_string_t offload;
16510 	cmdline_fixed_string_t on_off;
16511 };
16512 
16513 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16514 	TOKEN_STRING_INITIALIZER
16515 		(struct cmd_config_per_queue_tx_offload_result,
16516 		 port, "port");
16517 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16518 	TOKEN_NUM_INITIALIZER
16519 		(struct cmd_config_per_queue_tx_offload_result,
16520 		 port_id, RTE_UINT16);
16521 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16522 	TOKEN_STRING_INITIALIZER
16523 		(struct cmd_config_per_queue_tx_offload_result,
16524 		 txq, "txq");
16525 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16526 	TOKEN_NUM_INITIALIZER
16527 		(struct cmd_config_per_queue_tx_offload_result,
16528 		 queue_id, RTE_UINT16);
16529 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16530 	TOKEN_STRING_INITIALIZER
16531 		(struct cmd_config_per_queue_tx_offload_result,
16532 		 tx_offload, "tx_offload");
16533 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16534 	TOKEN_STRING_INITIALIZER
16535 		(struct cmd_config_per_queue_tx_offload_result,
16536 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16537 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16538 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16539 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16540 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
16541 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16542 	TOKEN_STRING_INITIALIZER
16543 		(struct cmd_config_per_queue_tx_offload_result,
16544 		 on_off, "on#off");
16545 
16546 static void
16547 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16548 				__rte_unused struct cmdline *cl,
16549 				__rte_unused void *data)
16550 {
16551 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16552 	struct rte_eth_dev_info dev_info;
16553 	portid_t port_id = res->port_id;
16554 	uint16_t queue_id = res->queue_id;
16555 	struct rte_port *port = &ports[port_id];
16556 	uint64_t single_offload;
16557 	int ret;
16558 
16559 	if (port->port_status != RTE_PORT_STOPPED) {
16560 		printf("Error: Can't config offload when Port %d "
16561 		       "is not stopped\n", port_id);
16562 		return;
16563 	}
16564 
16565 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
16566 	if (ret != 0)
16567 		return;
16568 
16569 	if (queue_id >= dev_info.nb_tx_queues) {
16570 		printf("Error: input queue_id should be 0 ... "
16571 		       "%d\n", dev_info.nb_tx_queues - 1);
16572 		return;
16573 	}
16574 
16575 	single_offload = search_tx_offload(res->offload);
16576 	if (single_offload == 0) {
16577 		printf("Unknown offload name: %s\n", res->offload);
16578 		return;
16579 	}
16580 
16581 	if (!strcmp(res->on_off, "on"))
16582 		port->tx_conf[queue_id].offloads |= single_offload;
16583 	else
16584 		port->tx_conf[queue_id].offloads &= ~single_offload;
16585 
16586 	cmd_reconfig_device_queue(port_id, 1, 1);
16587 }
16588 
16589 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16590 	.f = cmd_config_per_queue_tx_offload_parsed,
16591 	.data = NULL,
16592 	.help_str = "port <port_id> txq <queue_id> tx_offload "
16593 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16594 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16595 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16596 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16597 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
16598 		    "on|off",
16599 	.tokens = {
16600 		(void *)&cmd_config_per_queue_tx_offload_result_port,
16601 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
16602 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
16603 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16604 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16605 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
16606 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
16607 		NULL,
16608 	}
16609 };
16610 
16611 /* *** configure tx_metadata for specific port *** */
16612 struct cmd_config_tx_metadata_specific_result {
16613 	cmdline_fixed_string_t port;
16614 	cmdline_fixed_string_t keyword;
16615 	uint16_t port_id;
16616 	cmdline_fixed_string_t item;
16617 	uint32_t value;
16618 };
16619 
16620 static void
16621 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16622 				__rte_unused struct cmdline *cl,
16623 				__rte_unused void *data)
16624 {
16625 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16626 
16627 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16628 		return;
16629 	ports[res->port_id].tx_metadata = res->value;
16630 	/* Add/remove callback to insert valid metadata in every Tx packet. */
16631 	if (ports[res->port_id].tx_metadata)
16632 		add_tx_md_callback(res->port_id);
16633 	else
16634 		remove_tx_md_callback(res->port_id);
16635 	rte_flow_dynf_metadata_register();
16636 }
16637 
16638 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16639 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16640 			port, "port");
16641 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16642 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16643 			keyword, "config");
16644 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16645 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16646 			port_id, RTE_UINT16);
16647 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16648 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16649 			item, "tx_metadata");
16650 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16651 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16652 			value, RTE_UINT32);
16653 
16654 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16655 	.f = cmd_config_tx_metadata_specific_parsed,
16656 	.data = NULL,
16657 	.help_str = "port config <port_id> tx_metadata <value>",
16658 	.tokens = {
16659 		(void *)&cmd_config_tx_metadata_specific_port,
16660 		(void *)&cmd_config_tx_metadata_specific_keyword,
16661 		(void *)&cmd_config_tx_metadata_specific_id,
16662 		(void *)&cmd_config_tx_metadata_specific_item,
16663 		(void *)&cmd_config_tx_metadata_specific_value,
16664 		NULL,
16665 	},
16666 };
16667 
16668 /* *** set dynf *** */
16669 struct cmd_config_tx_dynf_specific_result {
16670 	cmdline_fixed_string_t port;
16671 	cmdline_fixed_string_t keyword;
16672 	uint16_t port_id;
16673 	cmdline_fixed_string_t item;
16674 	cmdline_fixed_string_t name;
16675 	cmdline_fixed_string_t value;
16676 };
16677 
16678 static void
16679 cmd_config_dynf_specific_parsed(void *parsed_result,
16680 				__rte_unused struct cmdline *cl,
16681 				__rte_unused void *data)
16682 {
16683 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16684 	struct rte_mbuf_dynflag desc_flag;
16685 	int flag;
16686 	uint64_t old_port_flags;
16687 
16688 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16689 		return;
16690 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16691 	if (flag <= 0) {
16692 		if (strlcpy(desc_flag.name, res->name,
16693 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16694 			printf("Flag name too long\n");
16695 			return;
16696 		}
16697 		desc_flag.flags = 0;
16698 		flag = rte_mbuf_dynflag_register(&desc_flag);
16699 		if (flag < 0) {
16700 			printf("Can't register flag\n");
16701 			return;
16702 		}
16703 		strcpy(dynf_names[flag], desc_flag.name);
16704 	}
16705 	old_port_flags = ports[res->port_id].mbuf_dynf;
16706 	if (!strcmp(res->value, "set")) {
16707 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
16708 		if (old_port_flags == 0)
16709 			add_tx_dynf_callback(res->port_id);
16710 	} else {
16711 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16712 		if (ports[res->port_id].mbuf_dynf == 0)
16713 			remove_tx_dynf_callback(res->port_id);
16714 	}
16715 }
16716 
16717 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16718 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16719 			keyword, "port");
16720 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16721 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16722 			keyword, "config");
16723 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16724 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16725 			port_id, RTE_UINT16);
16726 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16727 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16728 			item, "dynf");
16729 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16730 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16731 			name, NULL);
16732 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16733 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16734 			value, "set#clear");
16735 
16736 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16737 	.f = cmd_config_dynf_specific_parsed,
16738 	.data = NULL,
16739 	.help_str = "port config <port id> dynf <name> set|clear",
16740 	.tokens = {
16741 		(void *)&cmd_config_tx_dynf_specific_port,
16742 		(void *)&cmd_config_tx_dynf_specific_keyword,
16743 		(void *)&cmd_config_tx_dynf_specific_port_id,
16744 		(void *)&cmd_config_tx_dynf_specific_item,
16745 		(void *)&cmd_config_tx_dynf_specific_name,
16746 		(void *)&cmd_config_tx_dynf_specific_value,
16747 		NULL,
16748 	},
16749 };
16750 
16751 /* *** display tx_metadata per port configuration *** */
16752 struct cmd_show_tx_metadata_result {
16753 	cmdline_fixed_string_t cmd_show;
16754 	cmdline_fixed_string_t cmd_port;
16755 	cmdline_fixed_string_t cmd_keyword;
16756 	portid_t cmd_pid;
16757 };
16758 
16759 static void
16760 cmd_show_tx_metadata_parsed(void *parsed_result,
16761 		__rte_unused struct cmdline *cl,
16762 		__rte_unused void *data)
16763 {
16764 	struct cmd_show_tx_metadata_result *res = parsed_result;
16765 
16766 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16767 		printf("invalid port id %u\n", res->cmd_pid);
16768 		return;
16769 	}
16770 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16771 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16772 		       ports[res->cmd_pid].tx_metadata);
16773 	}
16774 }
16775 
16776 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16777 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16778 			cmd_show, "show");
16779 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16780 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16781 			cmd_port, "port");
16782 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16783 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16784 			cmd_pid, RTE_UINT16);
16785 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16786 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16787 			cmd_keyword, "tx_metadata");
16788 
16789 cmdline_parse_inst_t cmd_show_tx_metadata = {
16790 	.f = cmd_show_tx_metadata_parsed,
16791 	.data = NULL,
16792 	.help_str = "show port <port_id> tx_metadata",
16793 	.tokens = {
16794 		(void *)&cmd_show_tx_metadata_show,
16795 		(void *)&cmd_show_tx_metadata_port,
16796 		(void *)&cmd_show_tx_metadata_pid,
16797 		(void *)&cmd_show_tx_metadata_keyword,
16798 		NULL,
16799 	},
16800 };
16801 
16802 /* *** show fec capability per port configuration *** */
16803 struct cmd_show_fec_capability_result {
16804 	cmdline_fixed_string_t cmd_show;
16805 	cmdline_fixed_string_t cmd_port;
16806 	cmdline_fixed_string_t cmd_fec;
16807 	cmdline_fixed_string_t cmd_keyword;
16808 	portid_t cmd_pid;
16809 };
16810 
16811 static void
16812 cmd_show_fec_capability_parsed(void *parsed_result,
16813 		__rte_unused struct cmdline *cl,
16814 		__rte_unused void *data)
16815 {
16816 	struct cmd_show_fec_capability_result *res = parsed_result;
16817 	struct rte_eth_fec_capa *speed_fec_capa;
16818 	unsigned int num;
16819 	int ret;
16820 
16821 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16822 		printf("Invalid port id %u\n", res->cmd_pid);
16823 		return;
16824 	}
16825 
16826 	ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16827 	if (ret == -ENOTSUP) {
16828 		printf("Function not implemented\n");
16829 		return;
16830 	} else if (ret < 0) {
16831 		printf("Get FEC capability failed: %d\n", ret);
16832 		return;
16833 	}
16834 
16835 	num = (unsigned int)ret;
16836 	speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16837 	if (speed_fec_capa == NULL) {
16838 		printf("Failed to alloc FEC capability buffer\n");
16839 		return;
16840 	}
16841 
16842 	ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16843 	if (ret < 0) {
16844 		printf("Error getting FEC capability: %d\n", ret);
16845 		goto out;
16846 	}
16847 
16848 	show_fec_capability(num, speed_fec_capa);
16849 out:
16850 	free(speed_fec_capa);
16851 }
16852 
16853 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16854 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16855 			cmd_show, "show");
16856 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16857 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16858 			cmd_port, "port");
16859 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16860 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16861 			cmd_pid, RTE_UINT16);
16862 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16863 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16864 			cmd_fec, "fec");
16865 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16866 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16867 			cmd_keyword, "capabilities");
16868 
16869 cmdline_parse_inst_t cmd_show_capability = {
16870 	.f = cmd_show_fec_capability_parsed,
16871 	.data = NULL,
16872 	.help_str = "show port <port_id> fec capabilities",
16873 	.tokens = {
16874 		(void *)&cmd_show_fec_capability_show,
16875 		(void *)&cmd_show_fec_capability_port,
16876 		(void *)&cmd_show_fec_capability_pid,
16877 		(void *)&cmd_show_fec_capability_fec,
16878 		(void *)&cmd_show_fec_capability_keyword,
16879 		NULL,
16880 	},
16881 };
16882 
16883 /* *** show fec mode per port configuration *** */
16884 struct cmd_show_fec_metadata_result {
16885 	cmdline_fixed_string_t cmd_show;
16886 	cmdline_fixed_string_t cmd_port;
16887 	cmdline_fixed_string_t cmd_keyword;
16888 	portid_t cmd_pid;
16889 };
16890 
16891 static void
16892 cmd_show_fec_mode_parsed(void *parsed_result,
16893 		__rte_unused struct cmdline *cl,
16894 		__rte_unused void *data)
16895 {
16896 #define FEC_NAME_SIZE 16
16897 	struct cmd_show_fec_metadata_result *res = parsed_result;
16898 	uint32_t mode;
16899 	char buf[FEC_NAME_SIZE];
16900 	int ret;
16901 
16902 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16903 		printf("Invalid port id %u\n", res->cmd_pid);
16904 		return;
16905 	}
16906 	ret = rte_eth_fec_get(res->cmd_pid, &mode);
16907 	if (ret == -ENOTSUP) {
16908 		printf("Function not implemented\n");
16909 		return;
16910 	} else if (ret < 0) {
16911 		printf("Get FEC mode failed\n");
16912 		return;
16913 	}
16914 
16915 	switch (mode) {
16916 	case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16917 		strlcpy(buf, "off", sizeof(buf));
16918 		break;
16919 	case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16920 		strlcpy(buf, "auto", sizeof(buf));
16921 		break;
16922 	case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16923 		strlcpy(buf, "baser", sizeof(buf));
16924 		break;
16925 	case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16926 		strlcpy(buf, "rs", sizeof(buf));
16927 		break;
16928 	default:
16929 		return;
16930 	}
16931 
16932 	printf("%s\n", buf);
16933 }
16934 
16935 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16936 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16937 			cmd_show, "show");
16938 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16939 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16940 			cmd_port, "port");
16941 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16942 	TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16943 			cmd_pid, RTE_UINT16);
16944 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16945 	TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16946 			cmd_keyword, "fec_mode");
16947 
16948 cmdline_parse_inst_t cmd_show_fec_mode = {
16949 	.f = cmd_show_fec_mode_parsed,
16950 	.data = NULL,
16951 	.help_str = "show port <port_id> fec_mode",
16952 	.tokens = {
16953 		(void *)&cmd_show_fec_mode_show,
16954 		(void *)&cmd_show_fec_mode_port,
16955 		(void *)&cmd_show_fec_mode_pid,
16956 		(void *)&cmd_show_fec_mode_keyword,
16957 		NULL,
16958 	},
16959 };
16960 
16961 /* *** set fec mode per port configuration *** */
16962 struct cmd_set_port_fec_mode {
16963 	cmdline_fixed_string_t set;
16964 	cmdline_fixed_string_t port;
16965 	portid_t port_id;
16966 	cmdline_fixed_string_t fec_mode;
16967 	cmdline_fixed_string_t fec_value;
16968 };
16969 
16970 /* Common CLI fields for set fec mode */
16971 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16972 	TOKEN_STRING_INITIALIZER
16973 		(struct cmd_set_port_fec_mode,
16974 		 set, "set");
16975 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16976 	TOKEN_STRING_INITIALIZER
16977 		(struct cmd_set_port_fec_mode,
16978 		 port, "port");
16979 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16980 	TOKEN_NUM_INITIALIZER
16981 		(struct cmd_set_port_fec_mode,
16982 		 port_id, RTE_UINT16);
16983 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16984 	TOKEN_STRING_INITIALIZER
16985 		(struct cmd_set_port_fec_mode,
16986 		 fec_mode, "fec_mode");
16987 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16988 	TOKEN_STRING_INITIALIZER
16989 		(struct cmd_set_port_fec_mode,
16990 		 fec_value, NULL);
16991 
16992 static void
16993 cmd_set_port_fec_mode_parsed(
16994 	void *parsed_result,
16995 	__rte_unused struct cmdline *cl,
16996 	__rte_unused void *data)
16997 {
16998 	struct cmd_set_port_fec_mode *res = parsed_result;
16999 	uint16_t port_id = res->port_id;
17000 	uint32_t mode;
17001 	int ret;
17002 
17003 	ret = parse_fec_mode(res->fec_value, &mode);
17004 	if (ret < 0) {
17005 		printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
17006 			port_id);
17007 		return;
17008 	}
17009 
17010 	ret = rte_eth_fec_set(port_id, mode);
17011 	if (ret == -ENOTSUP) {
17012 		printf("Function not implemented\n");
17013 		return;
17014 	} else if (ret < 0) {
17015 		printf("Set FEC mode failed\n");
17016 		return;
17017 	}
17018 }
17019 
17020 cmdline_parse_inst_t cmd_set_fec_mode = {
17021 	.f = cmd_set_port_fec_mode_parsed,
17022 	.data = NULL,
17023 	.help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17024 	.tokens = {
17025 		(void *)&cmd_set_port_fec_mode_set,
17026 		(void *)&cmd_set_port_fec_mode_port,
17027 		(void *)&cmd_set_port_fec_mode_port_id,
17028 		(void *)&cmd_set_port_fec_mode_str,
17029 		(void *)&cmd_set_port_fec_mode_value,
17030 		NULL,
17031 	},
17032 };
17033 
17034 /* show port supported ptypes */
17035 
17036 /* Common result structure for show port ptypes */
17037 struct cmd_show_port_supported_ptypes_result {
17038 	cmdline_fixed_string_t show;
17039 	cmdline_fixed_string_t port;
17040 	portid_t port_id;
17041 	cmdline_fixed_string_t ptypes;
17042 };
17043 
17044 /* Common CLI fields for show port ptypes */
17045 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17046 	TOKEN_STRING_INITIALIZER
17047 		(struct cmd_show_port_supported_ptypes_result,
17048 		 show, "show");
17049 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17050 	TOKEN_STRING_INITIALIZER
17051 		(struct cmd_show_port_supported_ptypes_result,
17052 		 port, "port");
17053 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17054 	TOKEN_NUM_INITIALIZER
17055 		(struct cmd_show_port_supported_ptypes_result,
17056 		 port_id, RTE_UINT16);
17057 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17058 	TOKEN_STRING_INITIALIZER
17059 		(struct cmd_show_port_supported_ptypes_result,
17060 		 ptypes, "ptypes");
17061 
17062 static void
17063 cmd_show_port_supported_ptypes_parsed(
17064 	void *parsed_result,
17065 	__rte_unused struct cmdline *cl,
17066 	__rte_unused void *data)
17067 {
17068 #define RSVD_PTYPE_MASK       0xf0000000
17069 #define MAX_PTYPES_PER_LAYER  16
17070 #define LTYPE_NAMESIZE        32
17071 #define PTYPE_NAMESIZE        256
17072 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17073 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17074 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17075 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17076 	uint16_t port_id = res->port_id;
17077 	int ret, i;
17078 
17079 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17080 	if (ret < 0)
17081 		return;
17082 
17083 	while (ptype_mask != RSVD_PTYPE_MASK) {
17084 
17085 		switch (ptype_mask) {
17086 		case RTE_PTYPE_L2_MASK:
17087 			strlcpy(ltype, "L2", sizeof(ltype));
17088 			break;
17089 		case RTE_PTYPE_L3_MASK:
17090 			strlcpy(ltype, "L3", sizeof(ltype));
17091 			break;
17092 		case RTE_PTYPE_L4_MASK:
17093 			strlcpy(ltype, "L4", sizeof(ltype));
17094 			break;
17095 		case RTE_PTYPE_TUNNEL_MASK:
17096 			strlcpy(ltype, "Tunnel", sizeof(ltype));
17097 			break;
17098 		case RTE_PTYPE_INNER_L2_MASK:
17099 			strlcpy(ltype, "Inner L2", sizeof(ltype));
17100 			break;
17101 		case RTE_PTYPE_INNER_L3_MASK:
17102 			strlcpy(ltype, "Inner L3", sizeof(ltype));
17103 			break;
17104 		case RTE_PTYPE_INNER_L4_MASK:
17105 			strlcpy(ltype, "Inner L4", sizeof(ltype));
17106 			break;
17107 		default:
17108 			return;
17109 		}
17110 
17111 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17112 						       ptype_mask, ptypes,
17113 						       MAX_PTYPES_PER_LAYER);
17114 
17115 		if (ret > 0)
17116 			printf("Supported %s ptypes:\n", ltype);
17117 		else
17118 			printf("%s ptypes unsupported\n", ltype);
17119 
17120 		for (i = 0; i < ret; ++i) {
17121 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17122 			printf("%s\n", buf);
17123 		}
17124 
17125 		ptype_mask <<= 4;
17126 	}
17127 }
17128 
17129 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17130 	.f = cmd_show_port_supported_ptypes_parsed,
17131 	.data = NULL,
17132 	.help_str = "show port <port_id> ptypes",
17133 	.tokens = {
17134 		(void *)&cmd_show_port_supported_ptypes_show,
17135 		(void *)&cmd_show_port_supported_ptypes_port,
17136 		(void *)&cmd_show_port_supported_ptypes_port_id,
17137 		(void *)&cmd_show_port_supported_ptypes_ptypes,
17138 		NULL,
17139 	},
17140 };
17141 
17142 /* *** display rx/tx descriptor status *** */
17143 struct cmd_show_rx_tx_desc_status_result {
17144 	cmdline_fixed_string_t cmd_show;
17145 	cmdline_fixed_string_t cmd_port;
17146 	cmdline_fixed_string_t cmd_keyword;
17147 	cmdline_fixed_string_t cmd_desc;
17148 	cmdline_fixed_string_t cmd_status;
17149 	portid_t cmd_pid;
17150 	portid_t cmd_qid;
17151 	portid_t cmd_did;
17152 };
17153 
17154 static void
17155 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17156 		__rte_unused struct cmdline *cl,
17157 		__rte_unused void *data)
17158 {
17159 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17160 	int rc;
17161 
17162 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17163 		printf("invalid port id %u\n", res->cmd_pid);
17164 		return;
17165 	}
17166 
17167 	if (!strcmp(res->cmd_keyword, "rxq")) {
17168 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17169 					     res->cmd_did);
17170 		if (rc < 0) {
17171 			printf("Invalid input: queue id = %d, desc id = %d\n",
17172 			       res->cmd_qid, res->cmd_did);
17173 			return;
17174 		}
17175 		if (rc == RTE_ETH_RX_DESC_AVAIL)
17176 			printf("Desc status = AVAILABLE\n");
17177 		else if (rc == RTE_ETH_RX_DESC_DONE)
17178 			printf("Desc status = DONE\n");
17179 		else
17180 			printf("Desc status = UNAVAILABLE\n");
17181 	} else if (!strcmp(res->cmd_keyword, "txq")) {
17182 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17183 					     res->cmd_did);
17184 		if (rc < 0) {
17185 			printf("Invalid input: queue id = %d, desc id = %d\n",
17186 			       res->cmd_qid, res->cmd_did);
17187 			return;
17188 		}
17189 		if (rc == RTE_ETH_TX_DESC_FULL)
17190 			printf("Desc status = FULL\n");
17191 		else if (rc == RTE_ETH_TX_DESC_DONE)
17192 			printf("Desc status = DONE\n");
17193 		else
17194 			printf("Desc status = UNAVAILABLE\n");
17195 	}
17196 }
17197 
17198 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17199 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17200 			cmd_show, "show");
17201 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17202 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17203 			cmd_port, "port");
17204 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17205 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17206 			cmd_pid, RTE_UINT16);
17207 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17208 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17209 			cmd_keyword, "rxq#txq");
17210 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17211 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17212 			cmd_qid, RTE_UINT16);
17213 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17214 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17215 			cmd_desc, "desc");
17216 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17217 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17218 			cmd_did, RTE_UINT16);
17219 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17220 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17221 			cmd_status, "status");
17222 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17223 	.f = cmd_show_rx_tx_desc_status_parsed,
17224 	.data = NULL,
17225 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17226 		"status",
17227 	.tokens = {
17228 		(void *)&cmd_show_rx_tx_desc_status_show,
17229 		(void *)&cmd_show_rx_tx_desc_status_port,
17230 		(void *)&cmd_show_rx_tx_desc_status_pid,
17231 		(void *)&cmd_show_rx_tx_desc_status_keyword,
17232 		(void *)&cmd_show_rx_tx_desc_status_qid,
17233 		(void *)&cmd_show_rx_tx_desc_status_desc,
17234 		(void *)&cmd_show_rx_tx_desc_status_did,
17235 		(void *)&cmd_show_rx_tx_desc_status_status,
17236 		NULL,
17237 	},
17238 };
17239 
17240 /* *** display rx queue desc used count *** */
17241 struct cmd_show_rx_queue_desc_used_count_result {
17242 	cmdline_fixed_string_t cmd_show;
17243 	cmdline_fixed_string_t cmd_port;
17244 	cmdline_fixed_string_t cmd_rxq;
17245 	cmdline_fixed_string_t cmd_desc;
17246 	cmdline_fixed_string_t cmd_used;
17247 	cmdline_fixed_string_t cmd_count;
17248 	portid_t cmd_pid;
17249 	portid_t cmd_qid;
17250 };
17251 
17252 static void
17253 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17254 		__rte_unused struct cmdline *cl,
17255 		__rte_unused void *data)
17256 {
17257 	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17258 	int rc;
17259 
17260 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17261 		printf("invalid port id %u\n", res->cmd_pid);
17262 		return;
17263 	}
17264 
17265 	rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17266 	if (rc < 0) {
17267 		printf("Invalid queueid = %d\n", res->cmd_qid);
17268 		return;
17269 	}
17270 	printf("Used desc count = %d\n", rc);
17271 }
17272 
17273 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17274 	TOKEN_STRING_INITIALIZER
17275 		(struct cmd_show_rx_queue_desc_used_count_result,
17276 		 cmd_show, "show");
17277 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17278 	TOKEN_STRING_INITIALIZER
17279 		(struct cmd_show_rx_queue_desc_used_count_result,
17280 		 cmd_port, "port");
17281 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17282 	TOKEN_NUM_INITIALIZER
17283 		(struct cmd_show_rx_queue_desc_used_count_result,
17284 		 cmd_pid, RTE_UINT16);
17285 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17286 	TOKEN_STRING_INITIALIZER
17287 		(struct cmd_show_rx_queue_desc_used_count_result,
17288 		 cmd_rxq, "rxq");
17289 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17290 	TOKEN_NUM_INITIALIZER
17291 		(struct cmd_show_rx_queue_desc_used_count_result,
17292 		 cmd_qid, RTE_UINT16);
17293 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17294 	TOKEN_STRING_INITIALIZER
17295 		(struct cmd_show_rx_queue_desc_used_count_result,
17296 		 cmd_count, "desc");
17297 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17298 	TOKEN_STRING_INITIALIZER
17299 		(struct cmd_show_rx_queue_desc_used_count_result,
17300 		 cmd_count, "used");
17301 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17302 	TOKEN_STRING_INITIALIZER
17303 		(struct cmd_show_rx_queue_desc_used_count_result,
17304 		 cmd_count, "count");
17305 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17306 	.f = cmd_show_rx_queue_desc_used_count_parsed,
17307 	.data = NULL,
17308 	.help_str = "show port <port_id> rxq <queue_id> desc used count",
17309 	.tokens = {
17310 		(void *)&cmd_show_rx_queue_desc_used_count_show,
17311 		(void *)&cmd_show_rx_queue_desc_used_count_port,
17312 		(void *)&cmd_show_rx_queue_desc_used_count_pid,
17313 		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
17314 		(void *)&cmd_show_rx_queue_desc_used_count_qid,
17315 		(void *)&cmd_show_rx_queue_desc_used_count_desc,
17316 		(void *)&cmd_show_rx_queue_desc_used_count_used,
17317 		(void *)&cmd_show_rx_queue_desc_used_count_count,
17318 		NULL,
17319 	},
17320 };
17321 
17322 /* Common result structure for set port ptypes */
17323 struct cmd_set_port_ptypes_result {
17324 	cmdline_fixed_string_t set;
17325 	cmdline_fixed_string_t port;
17326 	portid_t port_id;
17327 	cmdline_fixed_string_t ptype_mask;
17328 	uint32_t mask;
17329 };
17330 
17331 /* Common CLI fields for set port ptypes */
17332 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17333 	TOKEN_STRING_INITIALIZER
17334 		(struct cmd_set_port_ptypes_result,
17335 		 set, "set");
17336 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17337 	TOKEN_STRING_INITIALIZER
17338 		(struct cmd_set_port_ptypes_result,
17339 		 port, "port");
17340 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17341 	TOKEN_NUM_INITIALIZER
17342 		(struct cmd_set_port_ptypes_result,
17343 		 port_id, RTE_UINT16);
17344 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17345 	TOKEN_STRING_INITIALIZER
17346 		(struct cmd_set_port_ptypes_result,
17347 		 ptype_mask, "ptype_mask");
17348 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17349 	TOKEN_NUM_INITIALIZER
17350 		(struct cmd_set_port_ptypes_result,
17351 		 mask, RTE_UINT32);
17352 
17353 static void
17354 cmd_set_port_ptypes_parsed(
17355 	void *parsed_result,
17356 	__rte_unused struct cmdline *cl,
17357 	__rte_unused void *data)
17358 {
17359 	struct cmd_set_port_ptypes_result *res = parsed_result;
17360 #define PTYPE_NAMESIZE        256
17361 	char ptype_name[PTYPE_NAMESIZE];
17362 	uint16_t port_id = res->port_id;
17363 	uint32_t ptype_mask = res->mask;
17364 	int ret, i;
17365 
17366 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17367 					       NULL, 0);
17368 	if (ret <= 0) {
17369 		printf("Port %d doesn't support any ptypes.\n", port_id);
17370 		return;
17371 	}
17372 
17373 	uint32_t ptypes[ret];
17374 
17375 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17376 	if (ret < 0) {
17377 		printf("Unable to set requested ptypes for Port %d\n", port_id);
17378 		return;
17379 	}
17380 
17381 	printf("Successfully set following ptypes for Port %d\n", port_id);
17382 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17383 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17384 		printf("%s\n", ptype_name);
17385 	}
17386 
17387 	clear_ptypes = false;
17388 }
17389 
17390 cmdline_parse_inst_t cmd_set_port_ptypes = {
17391 	.f = cmd_set_port_ptypes_parsed,
17392 	.data = NULL,
17393 	.help_str = "set port <port_id> ptype_mask <mask>",
17394 	.tokens = {
17395 		(void *)&cmd_set_port_ptypes_set,
17396 		(void *)&cmd_set_port_ptypes_port,
17397 		(void *)&cmd_set_port_ptypes_port_id,
17398 		(void *)&cmd_set_port_ptypes_mask_str,
17399 		(void *)&cmd_set_port_ptypes_mask_u32,
17400 		NULL,
17401 	},
17402 };
17403 
17404 /* *** display mac addresses added to a port *** */
17405 struct cmd_showport_macs_result {
17406 	cmdline_fixed_string_t cmd_show;
17407 	cmdline_fixed_string_t cmd_port;
17408 	cmdline_fixed_string_t cmd_keyword;
17409 	portid_t cmd_pid;
17410 };
17411 
17412 static void
17413 cmd_showport_macs_parsed(void *parsed_result,
17414 		__rte_unused struct cmdline *cl,
17415 		__rte_unused void *data)
17416 {
17417 	struct cmd_showport_macs_result *res = parsed_result;
17418 
17419 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17420 		return;
17421 
17422 	if (!strcmp(res->cmd_keyword, "macs"))
17423 		show_macs(res->cmd_pid);
17424 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17425 		show_mcast_macs(res->cmd_pid);
17426 }
17427 
17428 cmdline_parse_token_string_t cmd_showport_macs_show =
17429 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17430 			cmd_show, "show");
17431 cmdline_parse_token_string_t cmd_showport_macs_port =
17432 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17433 			cmd_port, "port");
17434 cmdline_parse_token_num_t cmd_showport_macs_pid =
17435 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17436 			cmd_pid, RTE_UINT16);
17437 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17438 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17439 			cmd_keyword, "macs#mcast_macs");
17440 
17441 cmdline_parse_inst_t cmd_showport_macs = {
17442 	.f = cmd_showport_macs_parsed,
17443 	.data = NULL,
17444 	.help_str = "show port <port_id> macs|mcast_macs",
17445 	.tokens = {
17446 		(void *)&cmd_showport_macs_show,
17447 		(void *)&cmd_showport_macs_port,
17448 		(void *)&cmd_showport_macs_pid,
17449 		(void *)&cmd_showport_macs_keyword,
17450 		NULL,
17451 	},
17452 };
17453 
17454 /* ******************************************************************************** */
17455 
17456 /* list of instructions */
17457 cmdline_parse_ctx_t main_ctx[] = {
17458 	(cmdline_parse_inst_t *)&cmd_help_brief,
17459 	(cmdline_parse_inst_t *)&cmd_help_long,
17460 	(cmdline_parse_inst_t *)&cmd_quit,
17461 	(cmdline_parse_inst_t *)&cmd_load_from_file,
17462 	(cmdline_parse_inst_t *)&cmd_showport,
17463 	(cmdline_parse_inst_t *)&cmd_showqueue,
17464 	(cmdline_parse_inst_t *)&cmd_showeeprom,
17465 	(cmdline_parse_inst_t *)&cmd_showportall,
17466 	(cmdline_parse_inst_t *)&cmd_showdevice,
17467 	(cmdline_parse_inst_t *)&cmd_showcfg,
17468 	(cmdline_parse_inst_t *)&cmd_showfwdall,
17469 	(cmdline_parse_inst_t *)&cmd_start,
17470 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
17471 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17472 	(cmdline_parse_inst_t *)&cmd_set_link_up,
17473 	(cmdline_parse_inst_t *)&cmd_set_link_down,
17474 	(cmdline_parse_inst_t *)&cmd_reset,
17475 	(cmdline_parse_inst_t *)&cmd_set_numbers,
17476 	(cmdline_parse_inst_t *)&cmd_set_log,
17477 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
17478 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
17479 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
17480 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
17481 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
17482 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
17483 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17484 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17485 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17486 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17487 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17488 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17489 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17490 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17491 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
17492 	(cmdline_parse_inst_t *)&cmd_set_link_check,
17493 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17494 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
17495 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17496 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
17497 #ifdef RTE_NET_BOND
17498 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17499 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
17500 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17501 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17502 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17503 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
17504 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17505 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17506 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17507 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17508 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17509 #endif
17510 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
17511 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
17512 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17513 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17514 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17515 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17516 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17517 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17518 	(cmdline_parse_inst_t *)&cmd_csum_set,
17519 	(cmdline_parse_inst_t *)&cmd_csum_show,
17520 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
17521 	(cmdline_parse_inst_t *)&cmd_tso_set,
17522 	(cmdline_parse_inst_t *)&cmd_tso_show,
17523 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17524 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17525 	(cmdline_parse_inst_t *)&cmd_gro_enable,
17526 	(cmdline_parse_inst_t *)&cmd_gro_flush,
17527 	(cmdline_parse_inst_t *)&cmd_gro_show,
17528 	(cmdline_parse_inst_t *)&cmd_gso_enable,
17529 	(cmdline_parse_inst_t *)&cmd_gso_size,
17530 	(cmdline_parse_inst_t *)&cmd_gso_show,
17531 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17532 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17533 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17534 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17535 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17536 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17537 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17538 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17539 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17540 	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17541 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17542 	(cmdline_parse_inst_t *)&cmd_config_dcb,
17543 	(cmdline_parse_inst_t *)&cmd_read_reg,
17544 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17545 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
17546 	(cmdline_parse_inst_t *)&cmd_write_reg,
17547 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17548 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
17549 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17550 	(cmdline_parse_inst_t *)&cmd_stop,
17551 	(cmdline_parse_inst_t *)&cmd_mac_addr,
17552 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17553 	(cmdline_parse_inst_t *)&cmd_set_qmap,
17554 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17555 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17556 	(cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17557 	(cmdline_parse_inst_t *)&cmd_operate_port,
17558 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
17559 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
17560 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
17561 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
17562 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17563 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
17564 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
17565 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
17566 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17567 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
17568 	(cmdline_parse_inst_t *)&cmd_config_mtu,
17569 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17570 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17571 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17572 	(cmdline_parse_inst_t *)&cmd_config_rss,
17573 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17574 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17575 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17576 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17577 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
17578 	(cmdline_parse_inst_t *)&cmd_showport_reta,
17579 	(cmdline_parse_inst_t *)&cmd_showport_macs,
17580 	(cmdline_parse_inst_t *)&cmd_config_burst,
17581 	(cmdline_parse_inst_t *)&cmd_config_thresh,
17582 	(cmdline_parse_inst_t *)&cmd_config_threshold,
17583 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17584 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17585 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17586 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17587 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17588 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17589 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
17590 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17591 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17592 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17593 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17594 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17595 	(cmdline_parse_inst_t *)&cmd_dump,
17596 	(cmdline_parse_inst_t *)&cmd_dump_one,
17597 #ifdef RTE_NET_I40E
17598 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17599 #endif
17600 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17601 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17602 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17603 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17604 	(cmdline_parse_inst_t *)&cmd_flow,
17605 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17606 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17607 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17608 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17609 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
17610 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
17611 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
17612 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
17613 	(cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17614 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17615 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17616 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17617 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17618 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
17619 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17620 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17621 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17622 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17623 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17624 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17625 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17626 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17627 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17628 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17629 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17630 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17631 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17632 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17633 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17634 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17635 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17636 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17637 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17638 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17639 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
17640 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17641 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17642 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
17643 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
17644 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
17645 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17646 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17647 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
17648 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17649 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
17650 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17651 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
17652 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17653 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17654 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17655 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17656 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17657 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17658 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17659 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17660 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17661 	(cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17662 	(cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17663 	(cmdline_parse_inst_t *)&cmd_ddp_add,
17664 	(cmdline_parse_inst_t *)&cmd_ddp_del,
17665 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
17666 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
17667 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
17668 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
17669 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
17670 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17671 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17672 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17673 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17674 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17675 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17676 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17677 
17678 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17679 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17680 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17681 	(cmdline_parse_inst_t *)&cmd_queue_region,
17682 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
17683 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
17684 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
17685 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17686 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17687 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17688 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17689 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17690 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17691 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17692 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17693 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17694 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17695 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17696 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17697 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17698 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17699 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17700 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17701 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17702 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17703 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17704 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17705 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17706 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17707 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17708 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17709 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17710 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17711 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17712 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17713 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17714 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17715 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17716 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17717 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17718 #ifdef RTE_LIB_BPF
17719 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17720 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17721 #endif
17722 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17723 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17724 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17725 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17726 	(cmdline_parse_inst_t *)&cmd_set_raw,
17727 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
17728 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17729 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17730 	(cmdline_parse_inst_t *)&cmd_show_fec_mode,
17731 	(cmdline_parse_inst_t *)&cmd_set_fec_mode,
17732 	(cmdline_parse_inst_t *)&cmd_show_capability,
17733 	NULL,
17734 };
17735 
17736 /* read cmdline commands from file */
17737 void
17738 cmdline_read_from_file(const char *filename)
17739 {
17740 	struct cmdline *cl;
17741 
17742 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17743 	if (cl == NULL) {
17744 		printf("Failed to create file based cmdline context: %s\n",
17745 		       filename);
17746 		return;
17747 	}
17748 
17749 	cmdline_interact(cl);
17750 	cmdline_quit(cl);
17751 
17752 	cmdline_free(cl);
17753 
17754 	printf("Read CLI commands from %s\n", filename);
17755 }
17756 
17757 /* prompt function, called from main on MAIN lcore */
17758 void
17759 prompt(void)
17760 {
17761 	int ret;
17762 	/* initialize non-constant commands */
17763 	cmd_set_fwd_mode_init();
17764 	cmd_set_fwd_retry_mode_init();
17765 
17766 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17767 	if (testpmd_cl == NULL)
17768 		return;
17769 
17770 	ret = atexit(prompt_exit);
17771 	if (ret != 0)
17772 		printf("Cannot set exit function for cmdline\n");
17773 
17774 	cmdline_interact(testpmd_cl);
17775 	if (ret != 0)
17776 		cmdline_stdin_exit(testpmd_cl);
17777 }
17778 
17779 void
17780 prompt_exit(void)
17781 {
17782 	if (testpmd_cl != NULL) {
17783 		cmdline_quit(testpmd_cl);
17784 		cmdline_stdin_exit(testpmd_cl);
17785 	}
17786 }
17787 
17788 static void
17789 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17790 {
17791 	if (id == (portid_t)RTE_PORT_ALL) {
17792 		portid_t pid;
17793 
17794 		RTE_ETH_FOREACH_DEV(pid) {
17795 			/* check if need_reconfig has been set to 1 */
17796 			if (ports[pid].need_reconfig == 0)
17797 				ports[pid].need_reconfig = dev;
17798 			/* check if need_reconfig_queues has been set to 1 */
17799 			if (ports[pid].need_reconfig_queues == 0)
17800 				ports[pid].need_reconfig_queues = queue;
17801 		}
17802 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17803 		/* check if need_reconfig has been set to 1 */
17804 		if (ports[id].need_reconfig == 0)
17805 			ports[id].need_reconfig = dev;
17806 		/* check if need_reconfig_queues has been set to 1 */
17807 		if (ports[id].need_reconfig_queues == 0)
17808 			ports[id].need_reconfig_queues = queue;
17809 	}
17810 }
17811