xref: /dpdk/app/test-pmd/cmdline.c (revision bc700b6767278e49c4ea9c08bb43c0fd9ca3e70d)
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_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
56 #endif
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
59 #endif
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
62 #endif
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
65 #endif
66 #ifdef RTE_LIBRTE_BNXT_PMD
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|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 			"    Display information for port_id, or all.\n\n"
168 
169 			"show port X rss reta (size) (mask0,mask1,...)\n"
170 			"    Display the rss redirection table entry indicated"
171 			" by masks on port X. size is used to indicate the"
172 			" hardware supported reta size\n\n"
173 
174 			"show port (port_id) rss-hash [key]\n"
175 			"    Display the RSS hash functions and RSS hash key of port\n\n"
176 
177 			"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 			"    Clear information for port_id, or all.\n\n"
179 
180 			"show (rxq|txq) info (port_id) (queue_id)\n"
181 			"    Display information for configured RX/TX queue.\n\n"
182 
183 			"show config (rxtx|cores|fwd|txpkts)\n"
184 			"    Display the given configuration.\n\n"
185 
186 			"read rxd (port_id) (queue_id) (rxd_id)\n"
187 			"    Display an RX descriptor of a port RX queue.\n\n"
188 
189 			"read txd (port_id) (queue_id) (txd_id)\n"
190 			"    Display a TX descriptor of a port TX queue.\n\n"
191 
192 			"ddp get list (port_id)\n"
193 			"    Get ddp profile info list\n\n"
194 
195 			"ddp get info (profile_path)\n"
196 			"    Get ddp profile information.\n\n"
197 
198 			"show vf stats (port_id) (vf_id)\n"
199 			"    Display a VF's statistics.\n\n"
200 
201 			"clear vf stats (port_id) (vf_id)\n"
202 			"    Reset a VF's statistics.\n\n"
203 
204 			"show port (port_id) pctype mapping\n"
205 			"    Get flow ptype to pctype mapping on a port\n\n"
206 
207 			"show port meter stats (port_id) (meter_id) (clear)\n"
208 			"    Get meter stats on a port\n\n"
209 
210 			"show fwd stats all\n"
211 			"    Display statistics for all fwd engines.\n\n"
212 
213 			"clear fwd stats all\n"
214 			"    Clear statistics for all fwd engines.\n\n"
215 
216 			"show port (port_id) rx_offload capabilities\n"
217 			"    List all per queue and per port Rx offloading"
218 			" capabilities of a port\n\n"
219 
220 			"show port (port_id) rx_offload configuration\n"
221 			"    List port level and all queue level"
222 			" Rx offloading configuration\n\n"
223 
224 			"show port (port_id) tx_offload capabilities\n"
225 			"    List all per queue and per port"
226 			" Tx offloading capabilities of a port\n\n"
227 
228 			"show port (port_id) tx_offload configuration\n"
229 			"    List port level and all queue level"
230 			" Tx offloading configuration\n\n"
231 
232 			"show port (port_id) tx_metadata\n"
233 			"    Show Tx metadata value set"
234 			" for a specific port\n\n"
235 
236 			"show port (port_id) ptypes\n"
237 			"    Show port supported ptypes"
238 			" for a specific port\n\n"
239 
240 			"show device info (<identifier>|all)"
241 			"       Show general information about devices probed.\n\n"
242 
243 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 			"       Show status of rx|tx descriptor.\n\n"
245 
246 			"show port (port_id) macs|mcast_macs"
247 			"       Display list of mac addresses added to port.\n\n"
248 		);
249 	}
250 
251 	if (show_all || !strcmp(res->section, "config")) {
252 		cmdline_printf(
253 			cl,
254 			"\n"
255 			"Configuration:\n"
256 			"--------------\n"
257 			"Configuration changes only become active when"
258 			" forwarding is started/restarted.\n\n"
259 
260 			"set default\n"
261 			"    Reset forwarding to the default configuration.\n\n"
262 
263 			"set verbose (level)\n"
264 			"    Set the debug verbosity level X.\n\n"
265 
266 			"set log global|(type) (level)\n"
267 			"    Set the log level.\n\n"
268 
269 			"set nbport (num)\n"
270 			"    Set number of ports.\n\n"
271 
272 			"set nbcore (num)\n"
273 			"    Set number of cores.\n\n"
274 
275 			"set coremask (mask)\n"
276 			"    Set the forwarding cores hexadecimal mask.\n\n"
277 
278 			"set portmask (mask)\n"
279 			"    Set the forwarding ports hexadecimal mask.\n\n"
280 
281 			"set burst (num)\n"
282 			"    Set number of packets per burst.\n\n"
283 
284 			"set burst tx delay (microseconds) retry (num)\n"
285 			"    Set the transmit delay time and number of retries,"
286 			" effective when retry is enabled.\n\n"
287 
288 			"set txpkts (x[,y]*)\n"
289 			"    Set the length of each segment of TXONLY"
290 			" and optionally CSUM packets.\n\n"
291 
292 			"set txsplit (off|on|rand)\n"
293 			"    Set the split policy for the TX packets."
294 			" Right now only applicable for CSUM and TXONLY"
295 			" modes\n\n"
296 
297 			"set txtimes (x, y)\n"
298 			"    Set the scheduling on timestamps"
299 			" timings for the TXONLY mode\n\n"
300 
301 			"set corelist (x[,y]*)\n"
302 			"    Set the list of forwarding cores.\n\n"
303 
304 			"set portlist (x[,y]*)\n"
305 			"    Set the list of forwarding ports.\n\n"
306 
307 			"set port setup on (iterator|event)\n"
308 			"    Select how attached port is retrieved for setup.\n\n"
309 
310 			"set tx loopback (port_id) (on|off)\n"
311 			"    Enable or disable tx loopback.\n\n"
312 
313 			"set all queues drop (port_id) (on|off)\n"
314 			"    Set drop enable bit for all queues.\n\n"
315 
316 			"set vf split drop (port_id) (vf_id) (on|off)\n"
317 			"    Set split drop enable bit for a VF from the PF.\n\n"
318 
319 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
320 			"    Set MAC antispoof for a VF from the PF.\n\n"
321 
322 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
323 			"    Enable MACsec offload.\n\n"
324 
325 			"set macsec offload (port_id) off\n"
326 			"    Disable MACsec offload.\n\n"
327 
328 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
329 			"    Configure MACsec secure connection (SC).\n\n"
330 
331 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
332 			"    Configure MACsec secure association (SA).\n\n"
333 
334 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
335 			"    Set VF broadcast for a VF from the PF.\n\n"
336 
337 			"vlan set stripq (on|off) (port_id,queue_id)\n"
338 			"    Set the VLAN strip for a queue on a port.\n\n"
339 
340 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
341 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
342 
343 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
344 			"    Set VLAN insert for a VF from the PF.\n\n"
345 
346 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
347 			"    Set VLAN antispoof for a VF from the PF.\n\n"
348 
349 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
350 			"    Set VLAN tag for a VF from the PF.\n\n"
351 
352 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
353 			"    Set a VF's max bandwidth(Mbps).\n\n"
354 
355 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
356 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
357 
358 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
359 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
360 
361 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
362 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
363 
364 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
365 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
366 
367 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
368 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
369 
370 			"vlan set (inner|outer) tpid (value) (port_id)\n"
371 			"    Set the VLAN TPID for Packet Filtering on"
372 			" a port\n\n"
373 
374 			"rx_vlan add (vlan_id|all) (port_id)\n"
375 			"    Add a vlan_id, or all identifiers, to the set"
376 			" of VLAN identifiers filtered by port_id.\n\n"
377 
378 			"rx_vlan rm (vlan_id|all) (port_id)\n"
379 			"    Remove a vlan_id, or all identifiers, from the set"
380 			" of VLAN identifiers filtered by port_id.\n\n"
381 
382 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
383 			"    Add a vlan_id, to the set of VLAN identifiers"
384 			"filtered for VF(s) from port_id.\n\n"
385 
386 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
387 			"    Remove a vlan_id, to the set of VLAN identifiers"
388 			"filtered for VF(s) from port_id.\n\n"
389 
390 			"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
391 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
392 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
393 			"   add a tunnel filter of a port.\n\n"
394 
395 			"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
397 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 			"   remove a tunnel filter of a port.\n\n"
399 
400 			"rx_vxlan_port add (udp_port) (port_id)\n"
401 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
402 
403 			"rx_vxlan_port rm (udp_port) (port_id)\n"
404 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
405 
406 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
407 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
408 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
409 
410 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
411 			"    Set port based TX VLAN insertion.\n\n"
412 
413 			"tx_vlan reset (port_id)\n"
414 			"    Disable hardware insertion of a VLAN header in"
415 			" packets sent on a port.\n\n"
416 
417 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
418 			"    Select hardware or software calculation of the"
419 			" checksum when transmitting a packet using the"
420 			" csum forward engine.\n"
421 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
422 			"    outer-ip concerns the outer IP layer in"
423 			"    outer-udp concerns the outer UDP layer in"
424 			" case the packet is recognized as a tunnel packet by"
425 			" the forward engine (vxlan, gre and ipip are supported)\n"
426 			"    Please check the NIC datasheet for HW limits.\n\n"
427 
428 			"csum parse-tunnel (on|off) (tx_port_id)\n"
429 			"    If disabled, treat tunnel packets as non-tunneled"
430 			" packets (treat inner headers as payload). The port\n"
431 			"    argument is the port used for TX in csum forward"
432 			" engine.\n\n"
433 
434 			"csum show (port_id)\n"
435 			"    Display tx checksum offload configuration\n\n"
436 
437 			"tso set (segsize) (portid)\n"
438 			"    Enable TCP Segmentation Offload in csum forward"
439 			" engine.\n"
440 			"    Please check the NIC datasheet for HW limits.\n\n"
441 
442 			"tso show (portid)"
443 			"    Display the status of TCP Segmentation Offload.\n\n"
444 
445 			"set port (port_id) gro on|off\n"
446 			"    Enable or disable Generic Receive Offload in"
447 			" csum forwarding engine.\n\n"
448 
449 			"show port (port_id) gro\n"
450 			"    Display GRO configuration.\n\n"
451 
452 			"set gro flush (cycles)\n"
453 			"    Set the cycle to flush GROed packets from"
454 			" reassembly tables.\n\n"
455 
456 			"set port (port_id) gso (on|off)"
457 			"    Enable or disable Generic Segmentation Offload in"
458 			" csum forwarding engine.\n\n"
459 
460 			"set gso segsz (length)\n"
461 			"    Set max packet length for output GSO segments,"
462 			" including packet header and payload.\n\n"
463 
464 			"show port (port_id) gso\n"
465 			"    Show GSO configuration.\n\n"
466 
467 			"set fwd (%s)\n"
468 			"    Set packet forwarding mode.\n\n"
469 
470 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
471 			"    Add a MAC address on port_id.\n\n"
472 
473 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
474 			"    Remove a MAC address from port_id.\n\n"
475 
476 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
477 			"    Set the default MAC address for port_id.\n\n"
478 
479 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
480 			"    Add a MAC address for a VF on the port.\n\n"
481 
482 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
483 			"    Set the MAC address for a VF from the PF.\n\n"
484 
485 			"set eth-peer (port_id) (peer_addr)\n"
486 			"    set the peer address for certain port.\n\n"
487 
488 			"set port (port_id) uta (mac_address|all) (on|off)\n"
489 			"    Add/Remove a or all unicast hash filter(s)"
490 			"from port X.\n\n"
491 
492 			"set promisc (port_id|all) (on|off)\n"
493 			"    Set the promiscuous mode on port_id, or all.\n\n"
494 
495 			"set allmulti (port_id|all) (on|off)\n"
496 			"    Set the allmulti mode on port_id, or all.\n\n"
497 
498 			"set vf promisc (port_id) (vf_id) (on|off)\n"
499 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
500 
501 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
502 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
503 
504 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
505 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
506 			" (on|off) autoneg (on|off) (port_id)\n"
507 			"set flow_ctrl rx (on|off) (portid)\n"
508 			"set flow_ctrl tx (on|off) (portid)\n"
509 			"set flow_ctrl high_water (high_water) (portid)\n"
510 			"set flow_ctrl low_water (low_water) (portid)\n"
511 			"set flow_ctrl pause_time (pause_time) (portid)\n"
512 			"set flow_ctrl send_xon (send_xon) (portid)\n"
513 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
514 			"set flow_ctrl autoneg (on|off) (port_id)\n"
515 			"    Set the link flow control parameter on a port.\n\n"
516 
517 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
518 			" (low_water) (pause_time) (priority) (port_id)\n"
519 			"    Set the priority flow control parameter on a"
520 			" port.\n\n"
521 
522 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
523 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
524 			" queue on port.\n"
525 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
526 			" on port 0 to mapping 5.\n\n"
527 
528 			"set xstats-hide-zero on|off\n"
529 			"    Set the option to hide the zero values"
530 			" for xstats display.\n"
531 
532 			"set record-core-cycles on|off\n"
533 			"    Set the option to enable measurement of CPU cycles.\n"
534 
535 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
536 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
537 
538 			"set port (port_id) vf (vf_id) (mac_addr)"
539 			" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
540 			"   Add/Remove unicast or multicast MAC addr filter"
541 			" for a VF.\n\n"
542 
543 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
544 			"|MPE) (on|off)\n"
545 			"    AUPE:accepts untagged VLAN;"
546 			"ROPE:accept unicast hash\n\n"
547 			"    BAM:accepts broadcast packets;"
548 			"MPE:accepts all multicast packets\n\n"
549 			"    Enable/Disable a VF receive mode of a port\n\n"
550 
551 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
552 			"    Set rate limit for a queue of a port\n\n"
553 
554 			"set port (port_id) vf (vf_id) rate (rate_num) "
555 			"queue_mask (queue_mask_value)\n"
556 			"    Set rate limit for queues in VF of a port\n\n"
557 
558 			"set port (port_id) mirror-rule (rule_id)"
559 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
560 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
561 			"   Set pool or vlan type mirror rule on a port.\n"
562 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
563 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
564 			" to pool 0.\n\n"
565 
566 			"set port (port_id) mirror-rule (rule_id)"
567 			" (uplink-mirror|downlink-mirror) dst-pool"
568 			" (pool_id) (on|off)\n"
569 			"   Set uplink or downlink type mirror rule on a port.\n"
570 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
571 			" 0 on' enable mirror income traffic to pool 0.\n\n"
572 
573 			"reset port (port_id) mirror-rule (rule_id)\n"
574 			"   Reset a mirror rule.\n\n"
575 
576 			"set flush_rx (on|off)\n"
577 			"   Flush (default) or don't flush RX streams before"
578 			" forwarding. Mainly used with PCAP drivers.\n\n"
579 
580 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
581 			"   Set the bypass mode for the lowest port on bypass enabled"
582 			" NIC.\n\n"
583 
584 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
585 			"mode (normal|bypass|isolate) (port_id)\n"
586 			"   Set the event required to initiate specified bypass mode for"
587 			" the lowest port on a bypass enabled NIC where:\n"
588 			"       timeout   = enable bypass after watchdog timeout.\n"
589 			"       os_on     = enable bypass when OS/board is powered on.\n"
590 			"       os_off    = enable bypass when OS/board is powered off.\n"
591 			"       power_on  = enable bypass when power supply is turned on.\n"
592 			"       power_off = enable bypass when power supply is turned off."
593 			"\n\n"
594 
595 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
596 			"   Set the bypass watchdog timeout to 'n' seconds"
597 			" where 0 = instant.\n\n"
598 
599 			"show bypass config (port_id)\n"
600 			"   Show the bypass configuration for a bypass enabled NIC"
601 			" using the lowest port on the NIC.\n\n"
602 
603 #ifdef RTE_LIBRTE_PMD_BOND
604 			"create bonded device (mode) (socket)\n"
605 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
606 
607 			"add bonding slave (slave_id) (port_id)\n"
608 			"	Add a slave device to a bonded device.\n\n"
609 
610 			"remove bonding slave (slave_id) (port_id)\n"
611 			"	Remove a slave device from a bonded device.\n\n"
612 
613 			"set bonding mode (value) (port_id)\n"
614 			"	Set the bonding mode on a bonded device.\n\n"
615 
616 			"set bonding primary (slave_id) (port_id)\n"
617 			"	Set the primary slave for a bonded device.\n\n"
618 
619 			"show bonding config (port_id)\n"
620 			"	Show the bonding config for port_id.\n\n"
621 
622 			"set bonding mac_addr (port_id) (address)\n"
623 			"	Set the MAC address of a bonded device.\n\n"
624 
625 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
626 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
627 
628 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
629 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
630 
631 			"set bonding mon_period (port_id) (value)\n"
632 			"	Set the bonding link status monitoring polling period in ms.\n\n"
633 
634 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
635 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
636 
637 #endif
638 			"set link-up port (port_id)\n"
639 			"	Set link up for a port.\n\n"
640 
641 			"set link-down port (port_id)\n"
642 			"	Set link down for a port.\n\n"
643 
644 			"E-tag set insertion on port-tag-id (value)"
645 			" port (port_id) vf (vf_id)\n"
646 			"    Enable E-tag insertion for a VF on a port\n\n"
647 
648 			"E-tag set insertion off port (port_id) vf (vf_id)\n"
649 			"    Disable E-tag insertion for a VF on a port\n\n"
650 
651 			"E-tag set stripping (on|off) port (port_id)\n"
652 			"    Enable/disable E-tag stripping on a port\n\n"
653 
654 			"E-tag set forwarding (on|off) port (port_id)\n"
655 			"    Enable/disable E-tag based forwarding"
656 			" on a port\n\n"
657 
658 			"E-tag set filter add e-tag-id (value) dst-pool"
659 			" (pool_id) port (port_id)\n"
660 			"    Add an E-tag forwarding filter on a port\n\n"
661 
662 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
663 			"    Delete an E-tag forwarding filter on a port\n\n"
664 
665 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
666 			"    Load a profile package on a port\n\n"
667 
668 			"ddp del (port_id) (backup_profile_path)\n"
669 			"    Delete a profile package from a port\n\n"
670 
671 			"ptype mapping get (port_id) (valid_only)\n"
672 			"    Get ptype mapping on a port\n\n"
673 
674 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
675 			"    Replace target with the pkt_type in ptype mapping\n\n"
676 
677 			"ptype mapping reset (port_id)\n"
678 			"    Reset ptype mapping on a port\n\n"
679 
680 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
681 			"    Update a ptype mapping item on a port\n\n"
682 
683 			"set port (port_id) ptype_mask (ptype_mask)\n"
684 			"    set packet types classification for a specific port\n\n"
685 
686 			"set port (port_id) queue-region region_id (value) "
687 			"queue_start_index (value) queue_num (value)\n"
688 			"    Set a queue region on a port\n\n"
689 
690 			"set port (port_id) queue-region region_id (value) "
691 			"flowtype (value)\n"
692 			"    Set a flowtype region index on a port\n\n"
693 
694 			"set port (port_id) queue-region UP (value) region_id (value)\n"
695 			"    Set the mapping of User Priority to "
696 			"queue region on a port\n\n"
697 
698 			"set port (port_id) queue-region flush (on|off)\n"
699 			"    flush all queue region related configuration\n\n"
700 
701 			"show port meter cap (port_id)\n"
702 			"    Show port meter capability information\n\n"
703 
704 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
705 			"    meter profile add - srtcm rfc 2697\n\n"
706 
707 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
708 			"    meter profile add - trtcm rfc 2698\n\n"
709 
710 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
711 			"    meter profile add - trtcm rfc 4115\n\n"
712 
713 			"del port meter profile (port_id) (profile_id)\n"
714 			"    meter profile delete\n\n"
715 
716 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
717 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
718 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
719 			"(dscp_tbl_entry63)]\n"
720 			"    meter create\n\n"
721 
722 			"enable port meter (port_id) (mtr_id)\n"
723 			"    meter enable\n\n"
724 
725 			"disable port meter (port_id) (mtr_id)\n"
726 			"    meter disable\n\n"
727 
728 			"del port meter (port_id) (mtr_id)\n"
729 			"    meter delete\n\n"
730 
731 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
732 			"    meter update meter profile\n\n"
733 
734 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
735 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
736 			"    update meter dscp table entries\n\n"
737 
738 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
739 			"(action0) [(action1) (action2)]\n"
740 			"    meter update policer action\n\n"
741 
742 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
743 			"    meter update stats\n\n"
744 
745 			"show port (port_id) queue-region\n"
746 			"    show all queue region related configuration info\n\n"
747 
748 			, list_pkt_forwarding_modes()
749 		);
750 	}
751 
752 	if (show_all || !strcmp(res->section, "ports")) {
753 
754 		cmdline_printf(
755 			cl,
756 			"\n"
757 			"Port Operations:\n"
758 			"----------------\n\n"
759 
760 			"port start (port_id|all)\n"
761 			"    Start all ports or port_id.\n\n"
762 
763 			"port stop (port_id|all)\n"
764 			"    Stop all ports or port_id.\n\n"
765 
766 			"port close (port_id|all)\n"
767 			"    Close all ports or port_id.\n\n"
768 
769 			"port reset (port_id|all)\n"
770 			"    Reset all ports or port_id.\n\n"
771 
772 			"port attach (ident)\n"
773 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
774 
775 			"port detach (port_id)\n"
776 			"    Detach physical or virtual dev by port_id\n\n"
777 
778 			"port config (port_id|all)"
779 			" speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
780 			" duplex (half|full|auto)\n"
781 			"    Set speed and duplex for all ports or port_id\n\n"
782 
783 			"port config (port_id|all) loopback (mode)\n"
784 			"    Set loopback mode for all ports or port_id\n\n"
785 
786 			"port config all (rxq|txq|rxd|txd) (value)\n"
787 			"    Set number for rxq/txq/rxd/txd.\n\n"
788 
789 			"port config all max-pkt-len (value)\n"
790 			"    Set the max packet length.\n\n"
791 
792 			"port config all max-lro-pkt-size (value)\n"
793 			"    Set the max LRO aggregated packet size.\n\n"
794 
795 			"port config all drop-en (on|off)\n"
796 			"    Enable or disable packet drop on all RX queues of all ports when no "
797 			"receive buffers available.\n\n"
798 
799 			"port config all rss (all|default|ip|tcp|udp|sctp|"
800 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
801 			"    Set the RSS mode.\n\n"
802 
803 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
804 			"    Set the RSS redirection table.\n\n"
805 
806 			"port config (port_id) dcb vt (on|off) (traffic_class)"
807 			" pfc (on|off)\n"
808 			"    Set the DCB mode.\n\n"
809 
810 			"port config all burst (value)\n"
811 			"    Set the number of packets per burst.\n\n"
812 
813 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
814 			" (value)\n"
815 			"    Set the ring prefetch/host/writeback threshold"
816 			" for tx/rx queue.\n\n"
817 
818 			"port config all (txfreet|txrst|rxfreet) (value)\n"
819 			"    Set free threshold for rx/tx, or set"
820 			" tx rs bit threshold.\n\n"
821 			"port config mtu X value\n"
822 			"    Set the MTU of port X to a given value\n\n"
823 
824 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
825 			"    Set a rx/tx queue's ring size configuration, the new"
826 			" value will take effect after command that (re-)start the port"
827 			" or command that setup the specific queue\n\n"
828 
829 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
830 			"    Start/stop a rx/tx queue of port X. Only take effect"
831 			" when port X is started\n\n"
832 
833 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
834 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
835 			" take effect when port X is stopped.\n\n"
836 
837 			"port (port_id) (rxq|txq) (queue_id) setup\n"
838 			"    Setup a rx/tx queue of port X.\n\n"
839 
840 			"port config (port_id|all) l2-tunnel E-tag ether-type"
841 			" (value)\n"
842 			"    Set the value of E-tag ether-type.\n\n"
843 
844 			"port config (port_id|all) l2-tunnel E-tag"
845 			" (enable|disable)\n"
846 			"    Enable/disable the E-tag support.\n\n"
847 
848 			"port config (port_id) pctype mapping reset\n"
849 			"    Reset flow type to pctype mapping on a port\n\n"
850 
851 			"port config (port_id) pctype mapping update"
852 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
853 			"    Update a flow type to pctype mapping item on a port\n\n"
854 
855 			"port config (port_id) pctype (pctype_id) hash_inset|"
856 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
857 			" (field_idx)\n"
858 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
859 
860 			"port config (port_id) pctype (pctype_id) hash_inset|"
861 			"fdir_inset|fdir_flx_inset clear all"
862 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
863 
864 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
865 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
866 
867 			"port config <port_id> rx_offload vlan_strip|"
868 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
869 			"outer_ipv4_cksum|macsec_strip|header_split|"
870 			"vlan_filter|vlan_extend|jumbo_frame|"
871 			"scatter|timestamp|security|keep_crc on|off\n"
872 			"     Enable or disable a per port Rx offloading"
873 			" on all Rx queues of a port\n\n"
874 
875 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
876 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
877 			"outer_ipv4_cksum|macsec_strip|header_split|"
878 			"vlan_filter|vlan_extend|jumbo_frame|"
879 			"scatter|timestamp|security|keep_crc on|off\n"
880 			"    Enable or disable a per queue Rx offloading"
881 			" only on a specific Rx queue\n\n"
882 
883 			"port config (port_id) tx_offload vlan_insert|"
884 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
885 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
886 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
887 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
888 			"security on|off\n"
889 			"    Enable or disable a per port Tx offloading"
890 			" on all Tx queues of a port\n\n"
891 
892 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
893 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
894 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
895 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
896 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
897 			" on|off\n"
898 			"    Enable or disable a per queue Tx offloading"
899 			" only on a specific Tx queue\n\n"
900 
901 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
902 			"    Load an eBPF program as a callback"
903 			" for particular RX/TX queue\n\n"
904 
905 			"bpf-unload rx|tx (port) (queue)\n"
906 			"    Unload previously loaded eBPF program"
907 			" for particular RX/TX queue\n\n"
908 
909 			"port config (port_id) tx_metadata (value)\n"
910 			"    Set Tx metadata value per port. Testpmd will add this value"
911 			" to any Tx packet sent from this port\n\n"
912 
913 			"port config (port_id) dynf (name) set|clear\n"
914 			"    Register a dynf and Set/clear this flag on Tx. "
915 			"Testpmd will set this value to any Tx packet "
916 			"sent from this port\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 			"ethertype_filter (port_id) (add|del)"
957 			" (mac_addr|mac_ignr) (mac_address) ethertype"
958 			" (ether_type) (drop|fwd) queue (queue_id)\n"
959 			"    Add/Del an ethertype filter.\n\n"
960 
961 			"2tuple_filter (port_id) (add|del)"
962 			" dst_port (dst_port_value) protocol (protocol_value)"
963 			" mask (mask_value) tcp_flags (tcp_flags_value)"
964 			" priority (prio_value) queue (queue_id)\n"
965 			"    Add/Del a 2tuple filter.\n\n"
966 
967 			"5tuple_filter (port_id) (add|del)"
968 			" dst_ip (dst_address) src_ip (src_address)"
969 			" dst_port (dst_port_value) src_port (src_port_value)"
970 			" protocol (protocol_value)"
971 			" mask (mask_value) tcp_flags (tcp_flags_value)"
972 			" priority (prio_value) queue (queue_id)\n"
973 			"    Add/Del a 5tuple filter.\n\n"
974 
975 			"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
976 			"    Add/Del syn filter.\n\n"
977 
978 			"flex_filter (port_id) (add|del) len (len_value)"
979 			" bytes (bytes_value) mask (mask_value)"
980 			" priority (prio_value) queue (queue_id)\n"
981 			"    Add/Del a flex filter.\n\n"
982 
983 			"flow_director_filter (port_id) mode IP (add|del|update)"
984 			" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
985 			" src (src_ip_address) dst (dst_ip_address)"
986 			" tos (tos_value) proto (proto_value) ttl (ttl_value)"
987 			" vlan (vlan_value) flexbytes (flexbytes_value)"
988 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
989 			" fd_id (fd_id_value)\n"
990 			"    Add/Del an IP type flow director filter.\n\n"
991 
992 			"flow_director_filter (port_id) mode IP (add|del|update)"
993 			" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
994 			" src (src_ip_address) (src_port)"
995 			" dst (dst_ip_address) (dst_port)"
996 			" tos (tos_value) ttl (ttl_value)"
997 			" vlan (vlan_value) flexbytes (flexbytes_value)"
998 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
999 			" fd_id (fd_id_value)\n"
1000 			"    Add/Del an UDP/TCP type flow director filter.\n\n"
1001 
1002 			"flow_director_filter (port_id) mode IP (add|del|update)"
1003 			" flow (ipv4-sctp|ipv6-sctp)"
1004 			" src (src_ip_address) (src_port)"
1005 			" dst (dst_ip_address) (dst_port)"
1006 			" tag (verification_tag) "
1007 			" tos (tos_value) ttl (ttl_value)"
1008 			" vlan (vlan_value)"
1009 			" flexbytes (flexbytes_value) (drop|fwd)"
1010 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1011 			"    Add/Del a SCTP type flow director filter.\n\n"
1012 
1013 			"flow_director_filter (port_id) mode IP (add|del|update)"
1014 			" flow l2_payload ether (ethertype)"
1015 			" flexbytes (flexbytes_value) (drop|fwd)"
1016 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1017 			"    Add/Del a l2 payload type flow director filter.\n\n"
1018 
1019 			"flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1020 			" mac (mac_address) vlan (vlan_value)"
1021 			" flexbytes (flexbytes_value) (drop|fwd)"
1022 			" queue (queue_id) fd_id (fd_id_value)\n"
1023 			"    Add/Del a MAC-VLAN flow director filter.\n\n"
1024 
1025 			"flow_director_filter (port_id) mode Tunnel (add|del|update)"
1026 			" mac (mac_address) vlan (vlan_value)"
1027 			" tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1028 			" flexbytes (flexbytes_value) (drop|fwd)"
1029 			" queue (queue_id) fd_id (fd_id_value)\n"
1030 			"    Add/Del a Tunnel flow director filter.\n\n"
1031 
1032 			"flow_director_filter (port_id) mode raw (add|del|update)"
1033 			" flow (flow_id) (drop|fwd) queue (queue_id)"
1034 			" fd_id (fd_id_value) packet (packet file name)\n"
1035 			"    Add/Del a raw type flow director filter.\n\n"
1036 
1037 			"flush_flow_director (port_id)\n"
1038 			"    Flush all flow director entries of a device.\n\n"
1039 
1040 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
1041 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
1042 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1043 			"    Set flow director IP mask.\n\n"
1044 
1045 			"flow_director_mask (port_id) mode MAC-VLAN"
1046 			" vlan (vlan_value)\n"
1047 			"    Set flow director MAC-VLAN mask.\n\n"
1048 
1049 			"flow_director_mask (port_id) mode Tunnel"
1050 			" vlan (vlan_value) mac (mac_value)"
1051 			" tunnel-type (tunnel_type_value)"
1052 			" tunnel-id (tunnel_id_value)\n"
1053 			"    Set flow director Tunnel mask.\n\n"
1054 
1055 			"flow_director_flex_mask (port_id)"
1056 			" flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1057 			"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1058 			" (mask)\n"
1059 			"    Configure mask of flex payload.\n\n"
1060 
1061 			"flow_director_flex_payload (port_id)"
1062 			" (raw|l2|l3|l4) (config)\n"
1063 			"    Configure flex payload selection.\n\n"
1064 
1065 			"get_sym_hash_ena_per_port (port_id)\n"
1066 			"    get symmetric hash enable configuration per port.\n\n"
1067 
1068 			"set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1069 			"    set symmetric hash enable configuration per port"
1070 			" to enable or disable.\n\n"
1071 
1072 			"get_hash_global_config (port_id)\n"
1073 			"    Get the global configurations of hash filters.\n\n"
1074 
1075 			"set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1076 			" (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1077 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1078 			" (enable|disable)\n"
1079 			"    Set the global configurations of hash filters.\n\n"
1080 
1081 			"set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1082 			"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1083 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1084 			"l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1085 			"src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1086 			"ipv6-next-header|udp-src-port|udp-dst-port|"
1087 			"tcp-src-port|tcp-dst-port|sctp-src-port|"
1088 			"sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1089 			"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1090 			"fld-8th|none) (select|add)\n"
1091 			"    Set the input set for hash.\n\n"
1092 
1093 			"set_fdir_input_set (port_id) "
1094 			"(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1095 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1096 			"l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1097 			"dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1098 			"ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1099 			"udp-dst-port|tcp-src-port|tcp-dst-port|"
1100 			"sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1101 			" (select|add)\n"
1102 			"    Set the input set for FDir.\n\n"
1103 
1104 			"flow validate {port_id}"
1105 			" [group {group_id}] [priority {level}]"
1106 			" [ingress] [egress]"
1107 			" pattern {item} [/ {item} [...]] / end"
1108 			" actions {action} [/ {action} [...]] / end\n"
1109 			"    Check whether a flow rule can be created.\n\n"
1110 
1111 			"flow create {port_id}"
1112 			" [group {group_id}] [priority {level}]"
1113 			" [ingress] [egress]"
1114 			" pattern {item} [/ {item} [...]] / end"
1115 			" actions {action} [/ {action} [...]] / end\n"
1116 			"    Create a flow rule.\n\n"
1117 
1118 			"flow destroy {port_id} rule {rule_id} [...]\n"
1119 			"    Destroy specific flow rules.\n\n"
1120 
1121 			"flow flush {port_id}\n"
1122 			"    Destroy all flow rules.\n\n"
1123 
1124 			"flow query {port_id} {rule_id} {action}\n"
1125 			"    Query an existing flow rule.\n\n"
1126 
1127 			"flow list {port_id} [group {group_id}] [...]\n"
1128 			"    List existing flow rules sorted by priority,"
1129 			" filtered by group identifiers.\n\n"
1130 
1131 			"flow isolate {port_id} {boolean}\n"
1132 			"    Restrict ingress traffic to the defined"
1133 			" flow rules\n\n"
1134 
1135 			"flow aged {port_id} [destroy]\n"
1136 			"    List and destroy aged flows"
1137 			" flow rules\n\n"
1138 
1139 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1140 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1141 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1142 			"       Configure the VXLAN encapsulation for flows.\n\n"
1143 
1144 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1145 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1146 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1147 			" eth-dst (eth-dst)\n"
1148 			"       Configure the VXLAN encapsulation for flows.\n\n"
1149 
1150 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1151 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1152 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1153 			" eth-dst (eth-dst)\n"
1154 			"       Configure the VXLAN encapsulation for flows.\n\n"
1155 
1156 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1157 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1158 			" (eth-dst)\n"
1159 			"       Configure the NVGRE encapsulation for flows.\n\n"
1160 
1161 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1162 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1163 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1164 			"       Configure the NVGRE encapsulation for flows.\n\n"
1165 
1166 			"set raw_encap {flow items}\n"
1167 			"	Configure the encapsulation with raw data.\n\n"
1168 
1169 			"set raw_decap {flow items}\n"
1170 			"	Configure the decapsulation with raw data.\n\n"
1171 
1172 		);
1173 	}
1174 
1175 	if (show_all || !strcmp(res->section, "traffic_management")) {
1176 		cmdline_printf(
1177 			cl,
1178 			"\n"
1179 			"Traffic Management:\n"
1180 			"--------------\n"
1181 			"show port tm cap (port_id)\n"
1182 			"       Display the port TM capability.\n\n"
1183 
1184 			"show port tm level cap (port_id) (level_id)\n"
1185 			"       Display the port TM hierarchical level capability.\n\n"
1186 
1187 			"show port tm node cap (port_id) (node_id)\n"
1188 			"       Display the port TM node capability.\n\n"
1189 
1190 			"show port tm node type (port_id) (node_id)\n"
1191 			"       Display the port TM node type.\n\n"
1192 
1193 			"show port tm node stats (port_id) (node_id) (clear)\n"
1194 			"       Display the port TM node stats.\n\n"
1195 
1196 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1197 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1198 			" (packet_length_adjust)\n"
1199 			"       Add port tm node private shaper profile.\n\n"
1200 
1201 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1202 			"       Delete port tm node private shaper profile.\n\n"
1203 
1204 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1205 			" (shaper_profile_id)\n"
1206 			"       Add/update port tm node shared shaper.\n\n"
1207 
1208 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1209 			"       Delete port tm node shared shaper.\n\n"
1210 
1211 			"set port tm node shaper profile (port_id) (node_id)"
1212 			" (shaper_profile_id)\n"
1213 			"       Set port tm node shaper profile.\n\n"
1214 
1215 			"add port tm node wred profile (port_id) (wred_profile_id)"
1216 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1217 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1218 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1219 			"       Add port tm node wred profile.\n\n"
1220 
1221 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1222 			"       Delete port tm node wred profile.\n\n"
1223 
1224 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1225 			" (priority) (weight) (level_id) (shaper_profile_id)"
1226 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1227 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1228 			"       Add port tm nonleaf node.\n\n"
1229 
1230 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1231 			" (priority) (weight) (level_id) (shaper_profile_id)"
1232 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1233 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1234 			"       Add port tm leaf node.\n\n"
1235 
1236 			"del port tm node (port_id) (node_id)\n"
1237 			"       Delete port tm node.\n\n"
1238 
1239 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1240 			" (priority) (weight)\n"
1241 			"       Set port tm node parent.\n\n"
1242 
1243 			"suspend port tm node (port_id) (node_id)"
1244 			"       Suspend tm node.\n\n"
1245 
1246 			"resume port tm node (port_id) (node_id)"
1247 			"       Resume tm node.\n\n"
1248 
1249 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1250 			"       Commit tm hierarchy.\n\n"
1251 
1252 			"set port tm mark ip_ecn (port) (green) (yellow)"
1253 			" (red)\n"
1254 			"    Enables/Disables the traffic management marking"
1255 			" for IP ECN (Explicit Congestion Notification)"
1256 			" packets on a given port\n\n"
1257 
1258 			"set port tm mark ip_dscp (port) (green) (yellow)"
1259 			" (red)\n"
1260 			"    Enables/Disables the traffic management marking"
1261 			" on the port for IP dscp packets\n\n"
1262 
1263 			"set port tm mark vlan_dei (port) (green) (yellow)"
1264 			" (red)\n"
1265 			"    Enables/Disables the traffic management marking"
1266 			" on the port for VLAN packets with DEI enabled\n\n"
1267 		);
1268 	}
1269 
1270 	if (show_all || !strcmp(res->section, "devices")) {
1271 		cmdline_printf(
1272 			cl,
1273 			"\n"
1274 			"Device Operations:\n"
1275 			"--------------\n"
1276 			"device detach (identifier)\n"
1277 			"       Detach device by identifier.\n\n"
1278 		);
1279 	}
1280 
1281 }
1282 
1283 cmdline_parse_token_string_t cmd_help_long_help =
1284 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1285 
1286 cmdline_parse_token_string_t cmd_help_long_section =
1287 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1288 			"all#control#display#config#"
1289 			"ports#registers#filters#traffic_management#devices");
1290 
1291 cmdline_parse_inst_t cmd_help_long = {
1292 	.f = cmd_help_long_parsed,
1293 	.data = NULL,
1294 	.help_str = "help all|control|display|config|ports|register|"
1295 		"filters|traffic_management|devices: "
1296 		"Show help",
1297 	.tokens = {
1298 		(void *)&cmd_help_long_help,
1299 		(void *)&cmd_help_long_section,
1300 		NULL,
1301 	},
1302 };
1303 
1304 
1305 /* *** start/stop/close all ports *** */
1306 struct cmd_operate_port_result {
1307 	cmdline_fixed_string_t keyword;
1308 	cmdline_fixed_string_t name;
1309 	cmdline_fixed_string_t value;
1310 };
1311 
1312 static void cmd_operate_port_parsed(void *parsed_result,
1313 				__rte_unused struct cmdline *cl,
1314 				__rte_unused void *data)
1315 {
1316 	struct cmd_operate_port_result *res = parsed_result;
1317 
1318 	if (!strcmp(res->name, "start"))
1319 		start_port(RTE_PORT_ALL);
1320 	else if (!strcmp(res->name, "stop"))
1321 		stop_port(RTE_PORT_ALL);
1322 	else if (!strcmp(res->name, "close"))
1323 		close_port(RTE_PORT_ALL);
1324 	else if (!strcmp(res->name, "reset"))
1325 		reset_port(RTE_PORT_ALL);
1326 	else
1327 		printf("Unknown parameter\n");
1328 }
1329 
1330 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1331 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1332 								"port");
1333 cmdline_parse_token_string_t cmd_operate_port_all_port =
1334 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1335 						"start#stop#close#reset");
1336 cmdline_parse_token_string_t cmd_operate_port_all_all =
1337 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1338 
1339 cmdline_parse_inst_t cmd_operate_port = {
1340 	.f = cmd_operate_port_parsed,
1341 	.data = NULL,
1342 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1343 	.tokens = {
1344 		(void *)&cmd_operate_port_all_cmd,
1345 		(void *)&cmd_operate_port_all_port,
1346 		(void *)&cmd_operate_port_all_all,
1347 		NULL,
1348 	},
1349 };
1350 
1351 /* *** start/stop/close specific port *** */
1352 struct cmd_operate_specific_port_result {
1353 	cmdline_fixed_string_t keyword;
1354 	cmdline_fixed_string_t name;
1355 	uint8_t value;
1356 };
1357 
1358 static void cmd_operate_specific_port_parsed(void *parsed_result,
1359 			__rte_unused struct cmdline *cl,
1360 				__rte_unused void *data)
1361 {
1362 	struct cmd_operate_specific_port_result *res = parsed_result;
1363 
1364 	if (!strcmp(res->name, "start"))
1365 		start_port(res->value);
1366 	else if (!strcmp(res->name, "stop"))
1367 		stop_port(res->value);
1368 	else if (!strcmp(res->name, "close"))
1369 		close_port(res->value);
1370 	else if (!strcmp(res->name, "reset"))
1371 		reset_port(res->value);
1372 	else
1373 		printf("Unknown parameter\n");
1374 }
1375 
1376 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1377 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1378 							keyword, "port");
1379 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1380 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1381 						name, "start#stop#close#reset");
1382 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1383 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1384 							value, UINT8);
1385 
1386 cmdline_parse_inst_t cmd_operate_specific_port = {
1387 	.f = cmd_operate_specific_port_parsed,
1388 	.data = NULL,
1389 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1390 	.tokens = {
1391 		(void *)&cmd_operate_specific_port_cmd,
1392 		(void *)&cmd_operate_specific_port_port,
1393 		(void *)&cmd_operate_specific_port_id,
1394 		NULL,
1395 	},
1396 };
1397 
1398 /* *** enable port setup (after attach) via iterator or event *** */
1399 struct cmd_set_port_setup_on_result {
1400 	cmdline_fixed_string_t set;
1401 	cmdline_fixed_string_t port;
1402 	cmdline_fixed_string_t setup;
1403 	cmdline_fixed_string_t on;
1404 	cmdline_fixed_string_t mode;
1405 };
1406 
1407 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1408 				__rte_unused struct cmdline *cl,
1409 				__rte_unused void *data)
1410 {
1411 	struct cmd_set_port_setup_on_result *res = parsed_result;
1412 
1413 	if (strcmp(res->mode, "event") == 0)
1414 		setup_on_probe_event = true;
1415 	else if (strcmp(res->mode, "iterator") == 0)
1416 		setup_on_probe_event = false;
1417 	else
1418 		printf("Unknown mode\n");
1419 }
1420 
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1422 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1423 			set, "set");
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1425 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1426 			port, "port");
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1428 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1429 			setup, "setup");
1430 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1431 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1432 			on, "on");
1433 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1434 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1435 			mode, "iterator#event");
1436 
1437 cmdline_parse_inst_t cmd_set_port_setup_on = {
1438 	.f = cmd_set_port_setup_on_parsed,
1439 	.data = NULL,
1440 	.help_str = "set port setup on iterator|event",
1441 	.tokens = {
1442 		(void *)&cmd_set_port_setup_on_set,
1443 		(void *)&cmd_set_port_setup_on_port,
1444 		(void *)&cmd_set_port_setup_on_setup,
1445 		(void *)&cmd_set_port_setup_on_on,
1446 		(void *)&cmd_set_port_setup_on_mode,
1447 		NULL,
1448 	},
1449 };
1450 
1451 /* *** attach a specified port *** */
1452 struct cmd_operate_attach_port_result {
1453 	cmdline_fixed_string_t port;
1454 	cmdline_fixed_string_t keyword;
1455 	cmdline_multi_string_t identifier;
1456 };
1457 
1458 static void cmd_operate_attach_port_parsed(void *parsed_result,
1459 				__rte_unused struct cmdline *cl,
1460 				__rte_unused void *data)
1461 {
1462 	struct cmd_operate_attach_port_result *res = parsed_result;
1463 
1464 	if (!strcmp(res->keyword, "attach"))
1465 		attach_port(res->identifier);
1466 	else
1467 		printf("Unknown parameter\n");
1468 }
1469 
1470 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1471 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1472 			port, "port");
1473 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1474 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1475 			keyword, "attach");
1476 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1477 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1478 			identifier, TOKEN_STRING_MULTI);
1479 
1480 cmdline_parse_inst_t cmd_operate_attach_port = {
1481 	.f = cmd_operate_attach_port_parsed,
1482 	.data = NULL,
1483 	.help_str = "port attach <identifier>: "
1484 		"(identifier: pci address or virtual dev name)",
1485 	.tokens = {
1486 		(void *)&cmd_operate_attach_port_port,
1487 		(void *)&cmd_operate_attach_port_keyword,
1488 		(void *)&cmd_operate_attach_port_identifier,
1489 		NULL,
1490 	},
1491 };
1492 
1493 /* *** detach a specified port *** */
1494 struct cmd_operate_detach_port_result {
1495 	cmdline_fixed_string_t port;
1496 	cmdline_fixed_string_t keyword;
1497 	portid_t port_id;
1498 };
1499 
1500 static void cmd_operate_detach_port_parsed(void *parsed_result,
1501 				__rte_unused struct cmdline *cl,
1502 				__rte_unused void *data)
1503 {
1504 	struct cmd_operate_detach_port_result *res = parsed_result;
1505 
1506 	if (!strcmp(res->keyword, "detach")) {
1507 		RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1508 		detach_port_device(res->port_id);
1509 	} else {
1510 		printf("Unknown parameter\n");
1511 	}
1512 }
1513 
1514 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1515 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1516 			port, "port");
1517 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1518 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1519 			keyword, "detach");
1520 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1521 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1522 			port_id, UINT16);
1523 
1524 cmdline_parse_inst_t cmd_operate_detach_port = {
1525 	.f = cmd_operate_detach_port_parsed,
1526 	.data = NULL,
1527 	.help_str = "port detach <port_id>",
1528 	.tokens = {
1529 		(void *)&cmd_operate_detach_port_port,
1530 		(void *)&cmd_operate_detach_port_keyword,
1531 		(void *)&cmd_operate_detach_port_port_id,
1532 		NULL,
1533 	},
1534 };
1535 
1536 /* *** detach device by identifier *** */
1537 struct cmd_operate_detach_device_result {
1538 	cmdline_fixed_string_t device;
1539 	cmdline_fixed_string_t keyword;
1540 	cmdline_fixed_string_t identifier;
1541 };
1542 
1543 static void cmd_operate_detach_device_parsed(void *parsed_result,
1544 				__rte_unused struct cmdline *cl,
1545 				__rte_unused void *data)
1546 {
1547 	struct cmd_operate_detach_device_result *res = parsed_result;
1548 
1549 	if (!strcmp(res->keyword, "detach"))
1550 		detach_devargs(res->identifier);
1551 	else
1552 		printf("Unknown parameter\n");
1553 }
1554 
1555 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1556 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1557 			device, "device");
1558 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1559 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1560 			keyword, "detach");
1561 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1562 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1563 			identifier, NULL);
1564 
1565 cmdline_parse_inst_t cmd_operate_detach_device = {
1566 	.f = cmd_operate_detach_device_parsed,
1567 	.data = NULL,
1568 	.help_str = "device detach <identifier>:"
1569 		"(identifier: pci address or virtual dev name)",
1570 	.tokens = {
1571 		(void *)&cmd_operate_detach_device_device,
1572 		(void *)&cmd_operate_detach_device_keyword,
1573 		(void *)&cmd_operate_detach_device_identifier,
1574 		NULL,
1575 	},
1576 };
1577 /* *** configure speed for all ports *** */
1578 struct cmd_config_speed_all {
1579 	cmdline_fixed_string_t port;
1580 	cmdline_fixed_string_t keyword;
1581 	cmdline_fixed_string_t all;
1582 	cmdline_fixed_string_t item1;
1583 	cmdline_fixed_string_t item2;
1584 	cmdline_fixed_string_t value1;
1585 	cmdline_fixed_string_t value2;
1586 };
1587 
1588 static int
1589 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1590 {
1591 
1592 	int duplex;
1593 
1594 	if (!strcmp(duplexstr, "half")) {
1595 		duplex = ETH_LINK_HALF_DUPLEX;
1596 	} else if (!strcmp(duplexstr, "full")) {
1597 		duplex = ETH_LINK_FULL_DUPLEX;
1598 	} else if (!strcmp(duplexstr, "auto")) {
1599 		duplex = ETH_LINK_FULL_DUPLEX;
1600 	} else {
1601 		printf("Unknown duplex parameter\n");
1602 		return -1;
1603 	}
1604 
1605 	if (!strcmp(speedstr, "10")) {
1606 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1607 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1608 	} else if (!strcmp(speedstr, "100")) {
1609 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1610 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1611 	} else {
1612 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1613 			printf("Invalid speed/duplex parameters\n");
1614 			return -1;
1615 		}
1616 		if (!strcmp(speedstr, "1000")) {
1617 			*speed = ETH_LINK_SPEED_1G;
1618 		} else if (!strcmp(speedstr, "10000")) {
1619 			*speed = ETH_LINK_SPEED_10G;
1620 		} else if (!strcmp(speedstr, "25000")) {
1621 			*speed = ETH_LINK_SPEED_25G;
1622 		} else if (!strcmp(speedstr, "40000")) {
1623 			*speed = ETH_LINK_SPEED_40G;
1624 		} else if (!strcmp(speedstr, "50000")) {
1625 			*speed = ETH_LINK_SPEED_50G;
1626 		} else if (!strcmp(speedstr, "100000")) {
1627 			*speed = ETH_LINK_SPEED_100G;
1628 		} else if (!strcmp(speedstr, "200000")) {
1629 			*speed = ETH_LINK_SPEED_200G;
1630 		} else if (!strcmp(speedstr, "auto")) {
1631 			*speed = ETH_LINK_SPEED_AUTONEG;
1632 		} else {
1633 			printf("Unknown speed parameter\n");
1634 			return -1;
1635 		}
1636 	}
1637 
1638 	return 0;
1639 }
1640 
1641 static void
1642 cmd_config_speed_all_parsed(void *parsed_result,
1643 			__rte_unused struct cmdline *cl,
1644 			__rte_unused void *data)
1645 {
1646 	struct cmd_config_speed_all *res = parsed_result;
1647 	uint32_t link_speed;
1648 	portid_t pid;
1649 
1650 	if (!all_ports_stopped()) {
1651 		printf("Please stop all ports first\n");
1652 		return;
1653 	}
1654 
1655 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1656 			&link_speed) < 0)
1657 		return;
1658 
1659 	RTE_ETH_FOREACH_DEV(pid) {
1660 		ports[pid].dev_conf.link_speeds = link_speed;
1661 	}
1662 
1663 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1664 }
1665 
1666 cmdline_parse_token_string_t cmd_config_speed_all_port =
1667 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1668 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1669 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1670 							"config");
1671 cmdline_parse_token_string_t cmd_config_speed_all_all =
1672 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1673 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1674 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1675 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1676 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1677 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1678 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1679 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1680 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1681 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1682 						"half#full#auto");
1683 
1684 cmdline_parse_inst_t cmd_config_speed_all = {
1685 	.f = cmd_config_speed_all_parsed,
1686 	.data = NULL,
1687 	.help_str = "port config all speed "
1688 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1689 							"half|full|auto",
1690 	.tokens = {
1691 		(void *)&cmd_config_speed_all_port,
1692 		(void *)&cmd_config_speed_all_keyword,
1693 		(void *)&cmd_config_speed_all_all,
1694 		(void *)&cmd_config_speed_all_item1,
1695 		(void *)&cmd_config_speed_all_value1,
1696 		(void *)&cmd_config_speed_all_item2,
1697 		(void *)&cmd_config_speed_all_value2,
1698 		NULL,
1699 	},
1700 };
1701 
1702 /* *** configure speed for specific port *** */
1703 struct cmd_config_speed_specific {
1704 	cmdline_fixed_string_t port;
1705 	cmdline_fixed_string_t keyword;
1706 	portid_t id;
1707 	cmdline_fixed_string_t item1;
1708 	cmdline_fixed_string_t item2;
1709 	cmdline_fixed_string_t value1;
1710 	cmdline_fixed_string_t value2;
1711 };
1712 
1713 static void
1714 cmd_config_speed_specific_parsed(void *parsed_result,
1715 				__rte_unused struct cmdline *cl,
1716 				__rte_unused void *data)
1717 {
1718 	struct cmd_config_speed_specific *res = parsed_result;
1719 	uint32_t link_speed;
1720 
1721 	if (!all_ports_stopped()) {
1722 		printf("Please stop all ports first\n");
1723 		return;
1724 	}
1725 
1726 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1727 		return;
1728 
1729 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1730 			&link_speed) < 0)
1731 		return;
1732 
1733 	ports[res->id].dev_conf.link_speeds = link_speed;
1734 
1735 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1736 }
1737 
1738 
1739 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1740 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1741 								"port");
1742 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1743 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1744 								"config");
1745 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1746 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1747 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1748 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1749 								"speed");
1750 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1751 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1752 				"10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1753 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1754 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1755 								"duplex");
1756 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1757 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1758 							"half#full#auto");
1759 
1760 cmdline_parse_inst_t cmd_config_speed_specific = {
1761 	.f = cmd_config_speed_specific_parsed,
1762 	.data = NULL,
1763 	.help_str = "port config <port_id> speed "
1764 		"10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1765 							"half|full|auto",
1766 	.tokens = {
1767 		(void *)&cmd_config_speed_specific_port,
1768 		(void *)&cmd_config_speed_specific_keyword,
1769 		(void *)&cmd_config_speed_specific_id,
1770 		(void *)&cmd_config_speed_specific_item1,
1771 		(void *)&cmd_config_speed_specific_value1,
1772 		(void *)&cmd_config_speed_specific_item2,
1773 		(void *)&cmd_config_speed_specific_value2,
1774 		NULL,
1775 	},
1776 };
1777 
1778 /* *** configure loopback for all ports *** */
1779 struct cmd_config_loopback_all {
1780 	cmdline_fixed_string_t port;
1781 	cmdline_fixed_string_t keyword;
1782 	cmdline_fixed_string_t all;
1783 	cmdline_fixed_string_t item;
1784 	uint32_t mode;
1785 };
1786 
1787 static void
1788 cmd_config_loopback_all_parsed(void *parsed_result,
1789 			__rte_unused struct cmdline *cl,
1790 			__rte_unused void *data)
1791 {
1792 	struct cmd_config_loopback_all *res = parsed_result;
1793 	portid_t pid;
1794 
1795 	if (!all_ports_stopped()) {
1796 		printf("Please stop all ports first\n");
1797 		return;
1798 	}
1799 
1800 	RTE_ETH_FOREACH_DEV(pid) {
1801 		ports[pid].dev_conf.lpbk_mode = res->mode;
1802 	}
1803 
1804 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1805 }
1806 
1807 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1808 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1809 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1810 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1811 							"config");
1812 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1813 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1814 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1815 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1816 							"loopback");
1817 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1818 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1819 
1820 cmdline_parse_inst_t cmd_config_loopback_all = {
1821 	.f = cmd_config_loopback_all_parsed,
1822 	.data = NULL,
1823 	.help_str = "port config all loopback <mode>",
1824 	.tokens = {
1825 		(void *)&cmd_config_loopback_all_port,
1826 		(void *)&cmd_config_loopback_all_keyword,
1827 		(void *)&cmd_config_loopback_all_all,
1828 		(void *)&cmd_config_loopback_all_item,
1829 		(void *)&cmd_config_loopback_all_mode,
1830 		NULL,
1831 	},
1832 };
1833 
1834 /* *** configure loopback for specific port *** */
1835 struct cmd_config_loopback_specific {
1836 	cmdline_fixed_string_t port;
1837 	cmdline_fixed_string_t keyword;
1838 	uint16_t port_id;
1839 	cmdline_fixed_string_t item;
1840 	uint32_t mode;
1841 };
1842 
1843 static void
1844 cmd_config_loopback_specific_parsed(void *parsed_result,
1845 				__rte_unused struct cmdline *cl,
1846 				__rte_unused void *data)
1847 {
1848 	struct cmd_config_loopback_specific *res = parsed_result;
1849 
1850 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1851 		return;
1852 
1853 	if (!port_is_stopped(res->port_id)) {
1854 		printf("Please stop port %u first\n", res->port_id);
1855 		return;
1856 	}
1857 
1858 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1859 
1860 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1861 }
1862 
1863 
1864 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1865 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1866 								"port");
1867 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1868 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1869 								"config");
1870 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1871 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1872 								UINT16);
1873 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1874 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1875 								"loopback");
1876 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1877 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1878 			      UINT32);
1879 
1880 cmdline_parse_inst_t cmd_config_loopback_specific = {
1881 	.f = cmd_config_loopback_specific_parsed,
1882 	.data = NULL,
1883 	.help_str = "port config <port_id> loopback <mode>",
1884 	.tokens = {
1885 		(void *)&cmd_config_loopback_specific_port,
1886 		(void *)&cmd_config_loopback_specific_keyword,
1887 		(void *)&cmd_config_loopback_specific_id,
1888 		(void *)&cmd_config_loopback_specific_item,
1889 		(void *)&cmd_config_loopback_specific_mode,
1890 		NULL,
1891 	},
1892 };
1893 
1894 /* *** configure txq/rxq, txd/rxd *** */
1895 struct cmd_config_rx_tx {
1896 	cmdline_fixed_string_t port;
1897 	cmdline_fixed_string_t keyword;
1898 	cmdline_fixed_string_t all;
1899 	cmdline_fixed_string_t name;
1900 	uint16_t value;
1901 };
1902 
1903 static void
1904 cmd_config_rx_tx_parsed(void *parsed_result,
1905 			__rte_unused struct cmdline *cl,
1906 			__rte_unused void *data)
1907 {
1908 	struct cmd_config_rx_tx *res = parsed_result;
1909 
1910 	if (!all_ports_stopped()) {
1911 		printf("Please stop all ports first\n");
1912 		return;
1913 	}
1914 	if (!strcmp(res->name, "rxq")) {
1915 		if (!res->value && !nb_txq) {
1916 			printf("Warning: Either rx or tx queues should be non zero\n");
1917 			return;
1918 		}
1919 		if (check_nb_rxq(res->value) != 0)
1920 			return;
1921 		nb_rxq = res->value;
1922 	}
1923 	else if (!strcmp(res->name, "txq")) {
1924 		if (!res->value && !nb_rxq) {
1925 			printf("Warning: Either rx or tx queues should be non zero\n");
1926 			return;
1927 		}
1928 		if (check_nb_txq(res->value) != 0)
1929 			return;
1930 		nb_txq = res->value;
1931 	}
1932 	else if (!strcmp(res->name, "rxd")) {
1933 		if (check_nb_rxd(res->value) != 0)
1934 			return;
1935 		nb_rxd = res->value;
1936 	} else if (!strcmp(res->name, "txd")) {
1937 		if (check_nb_txd(res->value) != 0)
1938 			return;
1939 
1940 		nb_txd = res->value;
1941 	} else {
1942 		printf("Unknown parameter\n");
1943 		return;
1944 	}
1945 
1946 	fwd_config_setup();
1947 
1948 	init_port_config();
1949 
1950 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1951 }
1952 
1953 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1954 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1955 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1956 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1957 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1958 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1959 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1960 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1961 						"rxq#txq#rxd#txd");
1962 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1963 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1964 
1965 cmdline_parse_inst_t cmd_config_rx_tx = {
1966 	.f = cmd_config_rx_tx_parsed,
1967 	.data = NULL,
1968 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1969 	.tokens = {
1970 		(void *)&cmd_config_rx_tx_port,
1971 		(void *)&cmd_config_rx_tx_keyword,
1972 		(void *)&cmd_config_rx_tx_all,
1973 		(void *)&cmd_config_rx_tx_name,
1974 		(void *)&cmd_config_rx_tx_value,
1975 		NULL,
1976 	},
1977 };
1978 
1979 /* *** config max packet length *** */
1980 struct cmd_config_max_pkt_len_result {
1981 	cmdline_fixed_string_t port;
1982 	cmdline_fixed_string_t keyword;
1983 	cmdline_fixed_string_t all;
1984 	cmdline_fixed_string_t name;
1985 	uint32_t value;
1986 };
1987 
1988 static void
1989 cmd_config_max_pkt_len_parsed(void *parsed_result,
1990 				__rte_unused struct cmdline *cl,
1991 				__rte_unused void *data)
1992 {
1993 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1994 	portid_t pid;
1995 
1996 	if (!all_ports_stopped()) {
1997 		printf("Please stop all ports first\n");
1998 		return;
1999 	}
2000 
2001 	RTE_ETH_FOREACH_DEV(pid) {
2002 		struct rte_port *port = &ports[pid];
2003 		uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2004 
2005 		if (!strcmp(res->name, "max-pkt-len")) {
2006 			if (res->value < RTE_ETHER_MIN_LEN) {
2007 				printf("max-pkt-len can not be less than %d\n",
2008 						RTE_ETHER_MIN_LEN);
2009 				return;
2010 			}
2011 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2012 				return;
2013 
2014 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2015 			if (res->value > RTE_ETHER_MAX_LEN)
2016 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2017 			else
2018 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2019 			port->dev_conf.rxmode.offloads = rx_offloads;
2020 		} else {
2021 			printf("Unknown parameter\n");
2022 			return;
2023 		}
2024 	}
2025 
2026 	init_port_config();
2027 
2028 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2029 }
2030 
2031 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2032 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2033 								"port");
2034 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2035 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2036 								"config");
2037 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2038 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2039 								"all");
2040 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2041 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2042 								"max-pkt-len");
2043 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2044 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2045 								UINT32);
2046 
2047 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2048 	.f = cmd_config_max_pkt_len_parsed,
2049 	.data = NULL,
2050 	.help_str = "port config all max-pkt-len <value>",
2051 	.tokens = {
2052 		(void *)&cmd_config_max_pkt_len_port,
2053 		(void *)&cmd_config_max_pkt_len_keyword,
2054 		(void *)&cmd_config_max_pkt_len_all,
2055 		(void *)&cmd_config_max_pkt_len_name,
2056 		(void *)&cmd_config_max_pkt_len_value,
2057 		NULL,
2058 	},
2059 };
2060 
2061 /* *** config max LRO aggregated packet size *** */
2062 struct cmd_config_max_lro_pkt_size_result {
2063 	cmdline_fixed_string_t port;
2064 	cmdline_fixed_string_t keyword;
2065 	cmdline_fixed_string_t all;
2066 	cmdline_fixed_string_t name;
2067 	uint32_t value;
2068 };
2069 
2070 static void
2071 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2072 				__rte_unused struct cmdline *cl,
2073 				__rte_unused void *data)
2074 {
2075 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2076 	portid_t pid;
2077 
2078 	if (!all_ports_stopped()) {
2079 		printf("Please stop all ports first\n");
2080 		return;
2081 	}
2082 
2083 	RTE_ETH_FOREACH_DEV(pid) {
2084 		struct rte_port *port = &ports[pid];
2085 
2086 		if (!strcmp(res->name, "max-lro-pkt-size")) {
2087 			if (res->value ==
2088 					port->dev_conf.rxmode.max_lro_pkt_size)
2089 				return;
2090 
2091 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2092 		} else {
2093 			printf("Unknown parameter\n");
2094 			return;
2095 		}
2096 	}
2097 
2098 	init_port_config();
2099 
2100 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2101 }
2102 
2103 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2104 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2105 				 port, "port");
2106 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2107 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2108 				 keyword, "config");
2109 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2110 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2111 				 all, "all");
2112 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2113 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2114 				 name, "max-lro-pkt-size");
2115 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2116 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2117 			      value, UINT32);
2118 
2119 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2120 	.f = cmd_config_max_lro_pkt_size_parsed,
2121 	.data = NULL,
2122 	.help_str = "port config all max-lro-pkt-size <value>",
2123 	.tokens = {
2124 		(void *)&cmd_config_max_lro_pkt_size_port,
2125 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2126 		(void *)&cmd_config_max_lro_pkt_size_all,
2127 		(void *)&cmd_config_max_lro_pkt_size_name,
2128 		(void *)&cmd_config_max_lro_pkt_size_value,
2129 		NULL,
2130 	},
2131 };
2132 
2133 /* *** configure port MTU *** */
2134 struct cmd_config_mtu_result {
2135 	cmdline_fixed_string_t port;
2136 	cmdline_fixed_string_t keyword;
2137 	cmdline_fixed_string_t mtu;
2138 	portid_t port_id;
2139 	uint16_t value;
2140 };
2141 
2142 static void
2143 cmd_config_mtu_parsed(void *parsed_result,
2144 		      __rte_unused struct cmdline *cl,
2145 		      __rte_unused void *data)
2146 {
2147 	struct cmd_config_mtu_result *res = parsed_result;
2148 
2149 	if (res->value < RTE_ETHER_MIN_LEN) {
2150 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2151 		return;
2152 	}
2153 	port_mtu_set(res->port_id, res->value);
2154 }
2155 
2156 cmdline_parse_token_string_t cmd_config_mtu_port =
2157 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2158 				 "port");
2159 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2160 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2161 				 "config");
2162 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2163 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2164 				 "mtu");
2165 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2166 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2167 cmdline_parse_token_num_t cmd_config_mtu_value =
2168 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2169 
2170 cmdline_parse_inst_t cmd_config_mtu = {
2171 	.f = cmd_config_mtu_parsed,
2172 	.data = NULL,
2173 	.help_str = "port config mtu <port_id> <value>",
2174 	.tokens = {
2175 		(void *)&cmd_config_mtu_port,
2176 		(void *)&cmd_config_mtu_keyword,
2177 		(void *)&cmd_config_mtu_mtu,
2178 		(void *)&cmd_config_mtu_port_id,
2179 		(void *)&cmd_config_mtu_value,
2180 		NULL,
2181 	},
2182 };
2183 
2184 /* *** configure rx mode *** */
2185 struct cmd_config_rx_mode_flag {
2186 	cmdline_fixed_string_t port;
2187 	cmdline_fixed_string_t keyword;
2188 	cmdline_fixed_string_t all;
2189 	cmdline_fixed_string_t name;
2190 	cmdline_fixed_string_t value;
2191 };
2192 
2193 static void
2194 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2195 				__rte_unused struct cmdline *cl,
2196 				__rte_unused void *data)
2197 {
2198 	struct cmd_config_rx_mode_flag *res = parsed_result;
2199 
2200 	if (!all_ports_stopped()) {
2201 		printf("Please stop all ports first\n");
2202 		return;
2203 	}
2204 
2205 	if (!strcmp(res->name, "drop-en")) {
2206 		if (!strcmp(res->value, "on"))
2207 			rx_drop_en = 1;
2208 		else if (!strcmp(res->value, "off"))
2209 			rx_drop_en = 0;
2210 		else {
2211 			printf("Unknown parameter\n");
2212 			return;
2213 		}
2214 	} else {
2215 		printf("Unknown parameter\n");
2216 		return;
2217 	}
2218 
2219 	init_port_config();
2220 
2221 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2222 }
2223 
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2225 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2227 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2228 								"config");
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2230 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2231 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2232 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2233 					"drop-en");
2234 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2235 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2236 							"on#off");
2237 
2238 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2239 	.f = cmd_config_rx_mode_flag_parsed,
2240 	.data = NULL,
2241 	.help_str = "port config all drop-en on|off",
2242 	.tokens = {
2243 		(void *)&cmd_config_rx_mode_flag_port,
2244 		(void *)&cmd_config_rx_mode_flag_keyword,
2245 		(void *)&cmd_config_rx_mode_flag_all,
2246 		(void *)&cmd_config_rx_mode_flag_name,
2247 		(void *)&cmd_config_rx_mode_flag_value,
2248 		NULL,
2249 	},
2250 };
2251 
2252 /* *** configure rss *** */
2253 struct cmd_config_rss {
2254 	cmdline_fixed_string_t port;
2255 	cmdline_fixed_string_t keyword;
2256 	cmdline_fixed_string_t all;
2257 	cmdline_fixed_string_t name;
2258 	cmdline_fixed_string_t value;
2259 };
2260 
2261 static void
2262 cmd_config_rss_parsed(void *parsed_result,
2263 			__rte_unused struct cmdline *cl,
2264 			__rte_unused void *data)
2265 {
2266 	struct cmd_config_rss *res = parsed_result;
2267 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2268 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2269 	int use_default = 0;
2270 	int all_updated = 1;
2271 	int diag;
2272 	uint16_t i;
2273 	int ret;
2274 
2275 	if (!strcmp(res->value, "all"))
2276 		rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2277 			ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2278 			ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2279 			ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2280 	else if (!strcmp(res->value, "eth"))
2281 		rss_conf.rss_hf = ETH_RSS_ETH;
2282 	else if (!strcmp(res->value, "vlan"))
2283 		rss_conf.rss_hf = ETH_RSS_VLAN;
2284 	else if (!strcmp(res->value, "ip"))
2285 		rss_conf.rss_hf = ETH_RSS_IP;
2286 	else if (!strcmp(res->value, "udp"))
2287 		rss_conf.rss_hf = ETH_RSS_UDP;
2288 	else if (!strcmp(res->value, "tcp"))
2289 		rss_conf.rss_hf = ETH_RSS_TCP;
2290 	else if (!strcmp(res->value, "sctp"))
2291 		rss_conf.rss_hf = ETH_RSS_SCTP;
2292 	else if (!strcmp(res->value, "ether"))
2293 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2294 	else if (!strcmp(res->value, "port"))
2295 		rss_conf.rss_hf = ETH_RSS_PORT;
2296 	else if (!strcmp(res->value, "vxlan"))
2297 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2298 	else if (!strcmp(res->value, "geneve"))
2299 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2300 	else if (!strcmp(res->value, "nvgre"))
2301 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2302 	else if (!strcmp(res->value, "l3-pre32"))
2303 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2304 	else if (!strcmp(res->value, "l3-pre40"))
2305 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2306 	else if (!strcmp(res->value, "l3-pre48"))
2307 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2308 	else if (!strcmp(res->value, "l3-pre56"))
2309 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2310 	else if (!strcmp(res->value, "l3-pre64"))
2311 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2312 	else if (!strcmp(res->value, "l3-pre96"))
2313 		rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2314 	else if (!strcmp(res->value, "l3-src-only"))
2315 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2316 	else if (!strcmp(res->value, "l3-dst-only"))
2317 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2318 	else if (!strcmp(res->value, "l4-src-only"))
2319 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2320 	else if (!strcmp(res->value, "l4-dst-only"))
2321 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2322 	else if (!strcmp(res->value, "l2-src-only"))
2323 		rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2324 	else if (!strcmp(res->value, "l2-dst-only"))
2325 		rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2326 	else if (!strcmp(res->value, "l2tpv3"))
2327 		rss_conf.rss_hf = ETH_RSS_L2TPV3;
2328 	else if (!strcmp(res->value, "esp"))
2329 		rss_conf.rss_hf = ETH_RSS_ESP;
2330 	else if (!strcmp(res->value, "ah"))
2331 		rss_conf.rss_hf = ETH_RSS_AH;
2332 	else if (!strcmp(res->value, "pfcp"))
2333 		rss_conf.rss_hf = ETH_RSS_PFCP;
2334 	else if (!strcmp(res->value, "pppoe"))
2335 		rss_conf.rss_hf = ETH_RSS_PPPOE;
2336 	else if (!strcmp(res->value, "gtpu"))
2337 		rss_conf.rss_hf = ETH_RSS_GTPU;
2338 	else if (!strcmp(res->value, "none"))
2339 		rss_conf.rss_hf = 0;
2340 	else if (!strcmp(res->value, "default"))
2341 		use_default = 1;
2342 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2343 						atoi(res->value) < 64)
2344 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2345 	else {
2346 		printf("Unknown parameter\n");
2347 		return;
2348 	}
2349 	rss_conf.rss_key = NULL;
2350 	/* Update global configuration for RSS types. */
2351 	RTE_ETH_FOREACH_DEV(i) {
2352 		struct rte_eth_rss_conf local_rss_conf;
2353 
2354 		ret = eth_dev_info_get_print_err(i, &dev_info);
2355 		if (ret != 0)
2356 			return;
2357 
2358 		if (use_default)
2359 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2360 
2361 		local_rss_conf = rss_conf;
2362 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2363 			dev_info.flow_type_rss_offloads;
2364 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2365 			printf("Port %u modified RSS hash function based on hardware support,"
2366 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2367 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2368 		}
2369 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2370 		if (diag < 0) {
2371 			all_updated = 0;
2372 			printf("Configuration of RSS hash at ethernet port %d "
2373 				"failed with error (%d): %s.\n",
2374 				i, -diag, strerror(-diag));
2375 		}
2376 	}
2377 	if (all_updated && !use_default) {
2378 		rss_hf = rss_conf.rss_hf;
2379 		printf("rss_hf %#"PRIx64"\n", rss_hf);
2380 	}
2381 }
2382 
2383 cmdline_parse_token_string_t cmd_config_rss_port =
2384 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2385 cmdline_parse_token_string_t cmd_config_rss_keyword =
2386 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2387 cmdline_parse_token_string_t cmd_config_rss_all =
2388 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2389 cmdline_parse_token_string_t cmd_config_rss_name =
2390 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2391 cmdline_parse_token_string_t cmd_config_rss_value =
2392 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2393 
2394 cmdline_parse_inst_t cmd_config_rss = {
2395 	.f = cmd_config_rss_parsed,
2396 	.data = NULL,
2397 	.help_str = "port config all rss "
2398 		"all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2399 		"nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|<flowtype_id>",
2400 	.tokens = {
2401 		(void *)&cmd_config_rss_port,
2402 		(void *)&cmd_config_rss_keyword,
2403 		(void *)&cmd_config_rss_all,
2404 		(void *)&cmd_config_rss_name,
2405 		(void *)&cmd_config_rss_value,
2406 		NULL,
2407 	},
2408 };
2409 
2410 /* *** configure rss hash key *** */
2411 struct cmd_config_rss_hash_key {
2412 	cmdline_fixed_string_t port;
2413 	cmdline_fixed_string_t config;
2414 	portid_t port_id;
2415 	cmdline_fixed_string_t rss_hash_key;
2416 	cmdline_fixed_string_t rss_type;
2417 	cmdline_fixed_string_t key;
2418 };
2419 
2420 static uint8_t
2421 hexa_digit_to_value(char hexa_digit)
2422 {
2423 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2424 		return (uint8_t) (hexa_digit - '0');
2425 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2426 		return (uint8_t) ((hexa_digit - 'a') + 10);
2427 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2428 		return (uint8_t) ((hexa_digit - 'A') + 10);
2429 	/* Invalid hexa digit */
2430 	return 0xFF;
2431 }
2432 
2433 static uint8_t
2434 parse_and_check_key_hexa_digit(char *key, int idx)
2435 {
2436 	uint8_t hexa_v;
2437 
2438 	hexa_v = hexa_digit_to_value(key[idx]);
2439 	if (hexa_v == 0xFF)
2440 		printf("invalid key: character %c at position %d is not a "
2441 		       "valid hexa digit\n", key[idx], idx);
2442 	return hexa_v;
2443 }
2444 
2445 static void
2446 cmd_config_rss_hash_key_parsed(void *parsed_result,
2447 			       __rte_unused struct cmdline *cl,
2448 			       __rte_unused void *data)
2449 {
2450 	struct cmd_config_rss_hash_key *res = parsed_result;
2451 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2452 	uint8_t xdgt0;
2453 	uint8_t xdgt1;
2454 	int i;
2455 	struct rte_eth_dev_info dev_info;
2456 	uint8_t hash_key_size;
2457 	uint32_t key_len;
2458 	int ret;
2459 
2460 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2461 	if (ret != 0)
2462 		return;
2463 
2464 	if (dev_info.hash_key_size > 0 &&
2465 			dev_info.hash_key_size <= sizeof(hash_key))
2466 		hash_key_size = dev_info.hash_key_size;
2467 	else {
2468 		printf("dev_info did not provide a valid hash key size\n");
2469 		return;
2470 	}
2471 	/* Check the length of the RSS hash key */
2472 	key_len = strlen(res->key);
2473 	if (key_len != (hash_key_size * 2)) {
2474 		printf("key length: %d invalid - key must be a string of %d"
2475 			   " hexa-decimal numbers\n",
2476 			   (int) key_len, hash_key_size * 2);
2477 		return;
2478 	}
2479 	/* Translate RSS hash key into binary representation */
2480 	for (i = 0; i < hash_key_size; i++) {
2481 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2482 		if (xdgt0 == 0xFF)
2483 			return;
2484 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2485 		if (xdgt1 == 0xFF)
2486 			return;
2487 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2488 	}
2489 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2490 			hash_key_size);
2491 }
2492 
2493 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2494 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2495 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2496 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2497 				 "config");
2498 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2499 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2500 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2501 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2502 				 rss_hash_key, "rss-hash-key");
2503 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2504 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2505 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2506 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2507 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2508 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2509 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2510 				 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2511 				 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2512 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2513 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2514 
2515 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2516 	.f = cmd_config_rss_hash_key_parsed,
2517 	.data = NULL,
2518 	.help_str = "port config <port_id> rss-hash-key "
2519 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2520 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2521 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2522 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2523 		"l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2524 		"l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2525 		"<string of hex digits (variable length, NIC dependent)>",
2526 	.tokens = {
2527 		(void *)&cmd_config_rss_hash_key_port,
2528 		(void *)&cmd_config_rss_hash_key_config,
2529 		(void *)&cmd_config_rss_hash_key_port_id,
2530 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2531 		(void *)&cmd_config_rss_hash_key_rss_type,
2532 		(void *)&cmd_config_rss_hash_key_value,
2533 		NULL,
2534 	},
2535 };
2536 
2537 /* *** configure port rxq/txq ring size *** */
2538 struct cmd_config_rxtx_ring_size {
2539 	cmdline_fixed_string_t port;
2540 	cmdline_fixed_string_t config;
2541 	portid_t portid;
2542 	cmdline_fixed_string_t rxtxq;
2543 	uint16_t qid;
2544 	cmdline_fixed_string_t rsize;
2545 	uint16_t size;
2546 };
2547 
2548 static void
2549 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2550 				 __rte_unused struct cmdline *cl,
2551 				 __rte_unused void *data)
2552 {
2553 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2554 	struct rte_port *port;
2555 	uint8_t isrx;
2556 
2557 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2558 		return;
2559 
2560 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2561 		printf("Invalid port id\n");
2562 		return;
2563 	}
2564 
2565 	port = &ports[res->portid];
2566 
2567 	if (!strcmp(res->rxtxq, "rxq"))
2568 		isrx = 1;
2569 	else if (!strcmp(res->rxtxq, "txq"))
2570 		isrx = 0;
2571 	else {
2572 		printf("Unknown parameter\n");
2573 		return;
2574 	}
2575 
2576 	if (isrx && rx_queue_id_is_invalid(res->qid))
2577 		return;
2578 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2579 		return;
2580 
2581 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2582 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2583 		       rx_free_thresh);
2584 		return;
2585 	}
2586 
2587 	if (isrx)
2588 		port->nb_rx_desc[res->qid] = res->size;
2589 	else
2590 		port->nb_tx_desc[res->qid] = res->size;
2591 
2592 	cmd_reconfig_device_queue(res->portid, 0, 1);
2593 }
2594 
2595 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2596 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2597 				 port, "port");
2598 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2599 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2600 				 config, "config");
2601 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2602 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2603 				 portid, UINT16);
2604 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2605 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2606 				 rxtxq, "rxq#txq");
2607 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2608 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 			      qid, UINT16);
2610 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2611 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 				 rsize, "ring_size");
2613 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2614 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 			      size, UINT16);
2616 
2617 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2618 	.f = cmd_config_rxtx_ring_size_parsed,
2619 	.data = NULL,
2620 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2621 	.tokens = {
2622 		(void *)&cmd_config_rxtx_ring_size_port,
2623 		(void *)&cmd_config_rxtx_ring_size_config,
2624 		(void *)&cmd_config_rxtx_ring_size_portid,
2625 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2626 		(void *)&cmd_config_rxtx_ring_size_qid,
2627 		(void *)&cmd_config_rxtx_ring_size_rsize,
2628 		(void *)&cmd_config_rxtx_ring_size_size,
2629 		NULL,
2630 	},
2631 };
2632 
2633 /* *** configure port rxq/txq start/stop *** */
2634 struct cmd_config_rxtx_queue {
2635 	cmdline_fixed_string_t port;
2636 	portid_t portid;
2637 	cmdline_fixed_string_t rxtxq;
2638 	uint16_t qid;
2639 	cmdline_fixed_string_t opname;
2640 };
2641 
2642 static void
2643 cmd_config_rxtx_queue_parsed(void *parsed_result,
2644 			__rte_unused struct cmdline *cl,
2645 			__rte_unused void *data)
2646 {
2647 	struct cmd_config_rxtx_queue *res = parsed_result;
2648 	uint8_t isrx;
2649 	uint8_t isstart;
2650 	int ret = 0;
2651 
2652 	if (test_done == 0) {
2653 		printf("Please stop forwarding first\n");
2654 		return;
2655 	}
2656 
2657 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2658 		return;
2659 
2660 	if (port_is_started(res->portid) != 1) {
2661 		printf("Please start port %u first\n", res->portid);
2662 		return;
2663 	}
2664 
2665 	if (!strcmp(res->rxtxq, "rxq"))
2666 		isrx = 1;
2667 	else if (!strcmp(res->rxtxq, "txq"))
2668 		isrx = 0;
2669 	else {
2670 		printf("Unknown parameter\n");
2671 		return;
2672 	}
2673 
2674 	if (isrx && rx_queue_id_is_invalid(res->qid))
2675 		return;
2676 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2677 		return;
2678 
2679 	if (!strcmp(res->opname, "start"))
2680 		isstart = 1;
2681 	else if (!strcmp(res->opname, "stop"))
2682 		isstart = 0;
2683 	else {
2684 		printf("Unknown parameter\n");
2685 		return;
2686 	}
2687 
2688 	if (isstart && isrx)
2689 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2690 	else if (!isstart && isrx)
2691 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2692 	else if (isstart && !isrx)
2693 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2694 	else
2695 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2696 
2697 	if (ret == -ENOTSUP)
2698 		printf("Function not supported in PMD driver\n");
2699 }
2700 
2701 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2702 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2703 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2704 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2705 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2706 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2707 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2708 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2709 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2710 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2711 						"start#stop");
2712 
2713 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2714 	.f = cmd_config_rxtx_queue_parsed,
2715 	.data = NULL,
2716 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2717 	.tokens = {
2718 		(void *)&cmd_config_rxtx_queue_port,
2719 		(void *)&cmd_config_rxtx_queue_portid,
2720 		(void *)&cmd_config_rxtx_queue_rxtxq,
2721 		(void *)&cmd_config_rxtx_queue_qid,
2722 		(void *)&cmd_config_rxtx_queue_opname,
2723 		NULL,
2724 	},
2725 };
2726 
2727 /* *** configure port rxq/txq deferred start on/off *** */
2728 struct cmd_config_deferred_start_rxtx_queue {
2729 	cmdline_fixed_string_t port;
2730 	portid_t port_id;
2731 	cmdline_fixed_string_t rxtxq;
2732 	uint16_t qid;
2733 	cmdline_fixed_string_t opname;
2734 	cmdline_fixed_string_t state;
2735 };
2736 
2737 static void
2738 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2739 			__rte_unused struct cmdline *cl,
2740 			__rte_unused void *data)
2741 {
2742 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2743 	struct rte_port *port;
2744 	uint8_t isrx;
2745 	uint8_t ison;
2746 	uint8_t needreconfig = 0;
2747 
2748 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2749 		return;
2750 
2751 	if (port_is_started(res->port_id) != 0) {
2752 		printf("Please stop port %u first\n", res->port_id);
2753 		return;
2754 	}
2755 
2756 	port = &ports[res->port_id];
2757 
2758 	isrx = !strcmp(res->rxtxq, "rxq");
2759 
2760 	if (isrx && rx_queue_id_is_invalid(res->qid))
2761 		return;
2762 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2763 		return;
2764 
2765 	ison = !strcmp(res->state, "on");
2766 
2767 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2768 		port->rx_conf[res->qid].rx_deferred_start = ison;
2769 		needreconfig = 1;
2770 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2771 		port->tx_conf[res->qid].tx_deferred_start = ison;
2772 		needreconfig = 1;
2773 	}
2774 
2775 	if (needreconfig)
2776 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2777 }
2778 
2779 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2780 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2781 						port, "port");
2782 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2783 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2784 						port_id, UINT16);
2785 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2786 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2787 						rxtxq, "rxq#txq");
2788 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2789 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2790 						qid, UINT16);
2791 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2792 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 						opname, "deferred_start");
2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2795 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2796 						state, "on#off");
2797 
2798 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2799 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2800 	.data = NULL,
2801 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2802 	.tokens = {
2803 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2804 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2805 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2806 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2807 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2808 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2809 		NULL,
2810 	},
2811 };
2812 
2813 /* *** configure port rxq/txq setup *** */
2814 struct cmd_setup_rxtx_queue {
2815 	cmdline_fixed_string_t port;
2816 	portid_t portid;
2817 	cmdline_fixed_string_t rxtxq;
2818 	uint16_t qid;
2819 	cmdline_fixed_string_t setup;
2820 };
2821 
2822 /* Common CLI fields for queue setup */
2823 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2824 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2825 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2826 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2827 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2828 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2829 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2830 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2831 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2832 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2833 
2834 static void
2835 cmd_setup_rxtx_queue_parsed(
2836 	void *parsed_result,
2837 	__rte_unused struct cmdline *cl,
2838 	__rte_unused void *data)
2839 {
2840 	struct cmd_setup_rxtx_queue *res = parsed_result;
2841 	struct rte_port *port;
2842 	struct rte_mempool *mp;
2843 	unsigned int socket_id;
2844 	uint8_t isrx = 0;
2845 	int ret;
2846 
2847 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2848 		return;
2849 
2850 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2851 		printf("Invalid port id\n");
2852 		return;
2853 	}
2854 
2855 	if (!strcmp(res->rxtxq, "rxq"))
2856 		isrx = 1;
2857 	else if (!strcmp(res->rxtxq, "txq"))
2858 		isrx = 0;
2859 	else {
2860 		printf("Unknown parameter\n");
2861 		return;
2862 	}
2863 
2864 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2865 		printf("Invalid rx queue\n");
2866 		return;
2867 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2868 		printf("Invalid tx queue\n");
2869 		return;
2870 	}
2871 
2872 	port = &ports[res->portid];
2873 	if (isrx) {
2874 		socket_id = rxring_numa[res->portid];
2875 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2876 			socket_id = port->socket_id;
2877 
2878 		mp = mbuf_pool_find(socket_id);
2879 		if (mp == NULL) {
2880 			printf("Failed to setup RX queue: "
2881 				"No mempool allocation"
2882 				" on the socket %d\n",
2883 				rxring_numa[res->portid]);
2884 			return;
2885 		}
2886 		ret = rte_eth_rx_queue_setup(res->portid,
2887 					     res->qid,
2888 					     port->nb_rx_desc[res->qid],
2889 					     socket_id,
2890 					     &port->rx_conf[res->qid],
2891 					     mp);
2892 		if (ret)
2893 			printf("Failed to setup RX queue\n");
2894 	} else {
2895 		socket_id = txring_numa[res->portid];
2896 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2897 			socket_id = port->socket_id;
2898 
2899 		ret = rte_eth_tx_queue_setup(res->portid,
2900 					     res->qid,
2901 					     port->nb_tx_desc[res->qid],
2902 					     socket_id,
2903 					     &port->tx_conf[res->qid]);
2904 		if (ret)
2905 			printf("Failed to setup TX queue\n");
2906 	}
2907 }
2908 
2909 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2910 	.f = cmd_setup_rxtx_queue_parsed,
2911 	.data = NULL,
2912 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2913 	.tokens = {
2914 		(void *)&cmd_setup_rxtx_queue_port,
2915 		(void *)&cmd_setup_rxtx_queue_portid,
2916 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2917 		(void *)&cmd_setup_rxtx_queue_qid,
2918 		(void *)&cmd_setup_rxtx_queue_setup,
2919 		NULL,
2920 	},
2921 };
2922 
2923 
2924 /* *** Configure RSS RETA *** */
2925 struct cmd_config_rss_reta {
2926 	cmdline_fixed_string_t port;
2927 	cmdline_fixed_string_t keyword;
2928 	portid_t port_id;
2929 	cmdline_fixed_string_t name;
2930 	cmdline_fixed_string_t list_name;
2931 	cmdline_fixed_string_t list_of_items;
2932 };
2933 
2934 static int
2935 parse_reta_config(const char *str,
2936 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2937 		  uint16_t nb_entries)
2938 {
2939 	int i;
2940 	unsigned size;
2941 	uint16_t hash_index, idx, shift;
2942 	uint16_t nb_queue;
2943 	char s[256];
2944 	const char *p, *p0 = str;
2945 	char *end;
2946 	enum fieldnames {
2947 		FLD_HASH_INDEX = 0,
2948 		FLD_QUEUE,
2949 		_NUM_FLD
2950 	};
2951 	unsigned long int_fld[_NUM_FLD];
2952 	char *str_fld[_NUM_FLD];
2953 
2954 	while ((p = strchr(p0,'(')) != NULL) {
2955 		++p;
2956 		if((p0 = strchr(p,')')) == NULL)
2957 			return -1;
2958 
2959 		size = p0 - p;
2960 		if(size >= sizeof(s))
2961 			return -1;
2962 
2963 		snprintf(s, sizeof(s), "%.*s", size, p);
2964 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2965 			return -1;
2966 		for (i = 0; i < _NUM_FLD; i++) {
2967 			errno = 0;
2968 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2969 			if (errno != 0 || end == str_fld[i] ||
2970 					int_fld[i] > 65535)
2971 				return -1;
2972 		}
2973 
2974 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2975 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2976 
2977 		if (hash_index >= nb_entries) {
2978 			printf("Invalid RETA hash index=%d\n", hash_index);
2979 			return -1;
2980 		}
2981 
2982 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2983 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2984 		reta_conf[idx].mask |= (1ULL << shift);
2985 		reta_conf[idx].reta[shift] = nb_queue;
2986 	}
2987 
2988 	return 0;
2989 }
2990 
2991 static void
2992 cmd_set_rss_reta_parsed(void *parsed_result,
2993 			__rte_unused struct cmdline *cl,
2994 			__rte_unused void *data)
2995 {
2996 	int ret;
2997 	struct rte_eth_dev_info dev_info;
2998 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2999 	struct cmd_config_rss_reta *res = parsed_result;
3000 
3001 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3002 	if (ret != 0)
3003 		return;
3004 
3005 	if (dev_info.reta_size == 0) {
3006 		printf("Redirection table size is 0 which is "
3007 					"invalid for RSS\n");
3008 		return;
3009 	} else
3010 		printf("The reta size of port %d is %u\n",
3011 			res->port_id, dev_info.reta_size);
3012 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3013 		printf("Currently do not support more than %u entries of "
3014 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
3015 		return;
3016 	}
3017 
3018 	memset(reta_conf, 0, sizeof(reta_conf));
3019 	if (!strcmp(res->list_name, "reta")) {
3020 		if (parse_reta_config(res->list_of_items, reta_conf,
3021 						dev_info.reta_size)) {
3022 			printf("Invalid RSS Redirection Table "
3023 					"config entered\n");
3024 			return;
3025 		}
3026 		ret = rte_eth_dev_rss_reta_update(res->port_id,
3027 				reta_conf, dev_info.reta_size);
3028 		if (ret != 0)
3029 			printf("Bad redirection table parameter, "
3030 					"return code = %d \n", ret);
3031 	}
3032 }
3033 
3034 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3035 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3036 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3037 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3038 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3039 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3040 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3041 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3042 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3043 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3044 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3045         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3046                                  NULL);
3047 cmdline_parse_inst_t cmd_config_rss_reta = {
3048 	.f = cmd_set_rss_reta_parsed,
3049 	.data = NULL,
3050 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3051 	.tokens = {
3052 		(void *)&cmd_config_rss_reta_port,
3053 		(void *)&cmd_config_rss_reta_keyword,
3054 		(void *)&cmd_config_rss_reta_port_id,
3055 		(void *)&cmd_config_rss_reta_name,
3056 		(void *)&cmd_config_rss_reta_list_name,
3057 		(void *)&cmd_config_rss_reta_list_of_items,
3058 		NULL,
3059 	},
3060 };
3061 
3062 /* *** SHOW PORT RETA INFO *** */
3063 struct cmd_showport_reta {
3064 	cmdline_fixed_string_t show;
3065 	cmdline_fixed_string_t port;
3066 	portid_t port_id;
3067 	cmdline_fixed_string_t rss;
3068 	cmdline_fixed_string_t reta;
3069 	uint16_t size;
3070 	cmdline_fixed_string_t list_of_items;
3071 };
3072 
3073 static int
3074 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3075 			   uint16_t nb_entries,
3076 			   char *str)
3077 {
3078 	uint32_t size;
3079 	const char *p, *p0 = str;
3080 	char s[256];
3081 	char *end;
3082 	char *str_fld[8];
3083 	uint16_t i;
3084 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3085 			RTE_RETA_GROUP_SIZE;
3086 	int ret;
3087 
3088 	p = strchr(p0, '(');
3089 	if (p == NULL)
3090 		return -1;
3091 	p++;
3092 	p0 = strchr(p, ')');
3093 	if (p0 == NULL)
3094 		return -1;
3095 	size = p0 - p;
3096 	if (size >= sizeof(s)) {
3097 		printf("The string size exceeds the internal buffer size\n");
3098 		return -1;
3099 	}
3100 	snprintf(s, sizeof(s), "%.*s", size, p);
3101 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3102 	if (ret <= 0 || ret != num) {
3103 		printf("The bits of masks do not match the number of "
3104 					"reta entries: %u\n", num);
3105 		return -1;
3106 	}
3107 	for (i = 0; i < ret; i++)
3108 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3109 
3110 	return 0;
3111 }
3112 
3113 static void
3114 cmd_showport_reta_parsed(void *parsed_result,
3115 			 __rte_unused struct cmdline *cl,
3116 			 __rte_unused void *data)
3117 {
3118 	struct cmd_showport_reta *res = parsed_result;
3119 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3120 	struct rte_eth_dev_info dev_info;
3121 	uint16_t max_reta_size;
3122 	int ret;
3123 
3124 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3125 	if (ret != 0)
3126 		return;
3127 
3128 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3129 	if (res->size == 0 || res->size > max_reta_size) {
3130 		printf("Invalid redirection table size: %u (1-%u)\n",
3131 			res->size, max_reta_size);
3132 		return;
3133 	}
3134 
3135 	memset(reta_conf, 0, sizeof(reta_conf));
3136 	if (showport_parse_reta_config(reta_conf, res->size,
3137 				res->list_of_items) < 0) {
3138 		printf("Invalid string: %s for reta masks\n",
3139 					res->list_of_items);
3140 		return;
3141 	}
3142 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3143 }
3144 
3145 cmdline_parse_token_string_t cmd_showport_reta_show =
3146 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3147 cmdline_parse_token_string_t cmd_showport_reta_port =
3148 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3149 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3150 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3151 cmdline_parse_token_string_t cmd_showport_reta_rss =
3152 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3153 cmdline_parse_token_string_t cmd_showport_reta_reta =
3154 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3155 cmdline_parse_token_num_t cmd_showport_reta_size =
3156 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3157 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3158 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3159 					list_of_items, NULL);
3160 
3161 cmdline_parse_inst_t cmd_showport_reta = {
3162 	.f = cmd_showport_reta_parsed,
3163 	.data = NULL,
3164 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3165 	.tokens = {
3166 		(void *)&cmd_showport_reta_show,
3167 		(void *)&cmd_showport_reta_port,
3168 		(void *)&cmd_showport_reta_port_id,
3169 		(void *)&cmd_showport_reta_rss,
3170 		(void *)&cmd_showport_reta_reta,
3171 		(void *)&cmd_showport_reta_size,
3172 		(void *)&cmd_showport_reta_list_of_items,
3173 		NULL,
3174 	},
3175 };
3176 
3177 /* *** Show RSS hash configuration *** */
3178 struct cmd_showport_rss_hash {
3179 	cmdline_fixed_string_t show;
3180 	cmdline_fixed_string_t port;
3181 	portid_t port_id;
3182 	cmdline_fixed_string_t rss_hash;
3183 	cmdline_fixed_string_t rss_type;
3184 	cmdline_fixed_string_t key; /* optional argument */
3185 };
3186 
3187 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3188 				__rte_unused struct cmdline *cl,
3189 				void *show_rss_key)
3190 {
3191 	struct cmd_showport_rss_hash *res = parsed_result;
3192 
3193 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3194 }
3195 
3196 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3197 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3198 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3199 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3200 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3201 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3202 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3203 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3204 				 "rss-hash");
3205 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3206 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3207 
3208 cmdline_parse_inst_t cmd_showport_rss_hash = {
3209 	.f = cmd_showport_rss_hash_parsed,
3210 	.data = NULL,
3211 	.help_str = "show port <port_id> rss-hash",
3212 	.tokens = {
3213 		(void *)&cmd_showport_rss_hash_show,
3214 		(void *)&cmd_showport_rss_hash_port,
3215 		(void *)&cmd_showport_rss_hash_port_id,
3216 		(void *)&cmd_showport_rss_hash_rss_hash,
3217 		NULL,
3218 	},
3219 };
3220 
3221 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3222 	.f = cmd_showport_rss_hash_parsed,
3223 	.data = (void *)1,
3224 	.help_str = "show port <port_id> rss-hash key",
3225 	.tokens = {
3226 		(void *)&cmd_showport_rss_hash_show,
3227 		(void *)&cmd_showport_rss_hash_port,
3228 		(void *)&cmd_showport_rss_hash_port_id,
3229 		(void *)&cmd_showport_rss_hash_rss_hash,
3230 		(void *)&cmd_showport_rss_hash_rss_key,
3231 		NULL,
3232 	},
3233 };
3234 
3235 /* *** Configure DCB *** */
3236 struct cmd_config_dcb {
3237 	cmdline_fixed_string_t port;
3238 	cmdline_fixed_string_t config;
3239 	portid_t port_id;
3240 	cmdline_fixed_string_t dcb;
3241 	cmdline_fixed_string_t vt;
3242 	cmdline_fixed_string_t vt_en;
3243 	uint8_t num_tcs;
3244 	cmdline_fixed_string_t pfc;
3245 	cmdline_fixed_string_t pfc_en;
3246 };
3247 
3248 static void
3249 cmd_config_dcb_parsed(void *parsed_result,
3250                         __rte_unused struct cmdline *cl,
3251                         __rte_unused void *data)
3252 {
3253 	struct cmd_config_dcb *res = parsed_result;
3254 	portid_t port_id = res->port_id;
3255 	struct rte_port *port;
3256 	uint8_t pfc_en;
3257 	int ret;
3258 
3259 	port = &ports[port_id];
3260 	/** Check if the port is not started **/
3261 	if (port->port_status != RTE_PORT_STOPPED) {
3262 		printf("Please stop port %d first\n", port_id);
3263 		return;
3264 	}
3265 
3266 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3267 		printf("The invalid number of traffic class,"
3268 			" only 4 or 8 allowed.\n");
3269 		return;
3270 	}
3271 
3272 	if (nb_fwd_lcores < res->num_tcs) {
3273 		printf("nb_cores shouldn't be less than number of TCs.\n");
3274 		return;
3275 	}
3276 	if (!strncmp(res->pfc_en, "on", 2))
3277 		pfc_en = 1;
3278 	else
3279 		pfc_en = 0;
3280 
3281 	/* DCB in VT mode */
3282 	if (!strncmp(res->vt_en, "on", 2))
3283 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3284 				(enum rte_eth_nb_tcs)res->num_tcs,
3285 				pfc_en);
3286 	else
3287 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3288 				(enum rte_eth_nb_tcs)res->num_tcs,
3289 				pfc_en);
3290 
3291 
3292 	if (ret != 0) {
3293 		printf("Cannot initialize network ports.\n");
3294 		return;
3295 	}
3296 
3297 	cmd_reconfig_device_queue(port_id, 1, 1);
3298 }
3299 
3300 cmdline_parse_token_string_t cmd_config_dcb_port =
3301         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3302 cmdline_parse_token_string_t cmd_config_dcb_config =
3303         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3304 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3305 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3306 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3307         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3308 cmdline_parse_token_string_t cmd_config_dcb_vt =
3309         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3310 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3311         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3312 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3313         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3314 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3315         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3316 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3317         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3318 
3319 cmdline_parse_inst_t cmd_config_dcb = {
3320 	.f = cmd_config_dcb_parsed,
3321 	.data = NULL,
3322 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3323 	.tokens = {
3324 		(void *)&cmd_config_dcb_port,
3325 		(void *)&cmd_config_dcb_config,
3326 		(void *)&cmd_config_dcb_port_id,
3327 		(void *)&cmd_config_dcb_dcb,
3328 		(void *)&cmd_config_dcb_vt,
3329 		(void *)&cmd_config_dcb_vt_en,
3330 		(void *)&cmd_config_dcb_num_tcs,
3331 		(void *)&cmd_config_dcb_pfc,
3332 		(void *)&cmd_config_dcb_pfc_en,
3333                 NULL,
3334         },
3335 };
3336 
3337 /* *** configure number of packets per burst *** */
3338 struct cmd_config_burst {
3339 	cmdline_fixed_string_t port;
3340 	cmdline_fixed_string_t keyword;
3341 	cmdline_fixed_string_t all;
3342 	cmdline_fixed_string_t name;
3343 	uint16_t value;
3344 };
3345 
3346 static void
3347 cmd_config_burst_parsed(void *parsed_result,
3348 			__rte_unused struct cmdline *cl,
3349 			__rte_unused void *data)
3350 {
3351 	struct cmd_config_burst *res = parsed_result;
3352 	struct rte_eth_dev_info dev_info;
3353 	uint16_t rec_nb_pkts;
3354 	int ret;
3355 
3356 	if (!all_ports_stopped()) {
3357 		printf("Please stop all ports first\n");
3358 		return;
3359 	}
3360 
3361 	if (!strcmp(res->name, "burst")) {
3362 		if (res->value == 0) {
3363 			/* If user gives a value of zero, query the PMD for
3364 			 * its recommended Rx burst size. Testpmd uses a single
3365 			 * size for all ports, so assume all ports are the same
3366 			 * NIC model and use the values from Port 0.
3367 			 */
3368 			ret = eth_dev_info_get_print_err(0, &dev_info);
3369 			if (ret != 0)
3370 				return;
3371 
3372 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3373 
3374 			if (rec_nb_pkts == 0) {
3375 				printf("PMD does not recommend a burst size.\n"
3376 					"User provided value must be between"
3377 					" 1 and %d\n", MAX_PKT_BURST);
3378 				return;
3379 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3380 				printf("PMD recommended burst size of %d"
3381 					" exceeds maximum value of %d\n",
3382 					rec_nb_pkts, MAX_PKT_BURST);
3383 				return;
3384 			}
3385 			printf("Using PMD-provided burst value of %d\n",
3386 				rec_nb_pkts);
3387 			nb_pkt_per_burst = rec_nb_pkts;
3388 		} else if (res->value > MAX_PKT_BURST) {
3389 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3390 			return;
3391 		} else
3392 			nb_pkt_per_burst = res->value;
3393 	} else {
3394 		printf("Unknown parameter\n");
3395 		return;
3396 	}
3397 
3398 	init_port_config();
3399 
3400 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3401 }
3402 
3403 cmdline_parse_token_string_t cmd_config_burst_port =
3404 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3405 cmdline_parse_token_string_t cmd_config_burst_keyword =
3406 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3407 cmdline_parse_token_string_t cmd_config_burst_all =
3408 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3409 cmdline_parse_token_string_t cmd_config_burst_name =
3410 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3411 cmdline_parse_token_num_t cmd_config_burst_value =
3412 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3413 
3414 cmdline_parse_inst_t cmd_config_burst = {
3415 	.f = cmd_config_burst_parsed,
3416 	.data = NULL,
3417 	.help_str = "port config all burst <value>",
3418 	.tokens = {
3419 		(void *)&cmd_config_burst_port,
3420 		(void *)&cmd_config_burst_keyword,
3421 		(void *)&cmd_config_burst_all,
3422 		(void *)&cmd_config_burst_name,
3423 		(void *)&cmd_config_burst_value,
3424 		NULL,
3425 	},
3426 };
3427 
3428 /* *** configure rx/tx queues *** */
3429 struct cmd_config_thresh {
3430 	cmdline_fixed_string_t port;
3431 	cmdline_fixed_string_t keyword;
3432 	cmdline_fixed_string_t all;
3433 	cmdline_fixed_string_t name;
3434 	uint8_t value;
3435 };
3436 
3437 static void
3438 cmd_config_thresh_parsed(void *parsed_result,
3439 			__rte_unused struct cmdline *cl,
3440 			__rte_unused void *data)
3441 {
3442 	struct cmd_config_thresh *res = parsed_result;
3443 
3444 	if (!all_ports_stopped()) {
3445 		printf("Please stop all ports first\n");
3446 		return;
3447 	}
3448 
3449 	if (!strcmp(res->name, "txpt"))
3450 		tx_pthresh = res->value;
3451 	else if(!strcmp(res->name, "txht"))
3452 		tx_hthresh = res->value;
3453 	else if(!strcmp(res->name, "txwt"))
3454 		tx_wthresh = res->value;
3455 	else if(!strcmp(res->name, "rxpt"))
3456 		rx_pthresh = res->value;
3457 	else if(!strcmp(res->name, "rxht"))
3458 		rx_hthresh = res->value;
3459 	else if(!strcmp(res->name, "rxwt"))
3460 		rx_wthresh = res->value;
3461 	else {
3462 		printf("Unknown parameter\n");
3463 		return;
3464 	}
3465 
3466 	init_port_config();
3467 
3468 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3469 }
3470 
3471 cmdline_parse_token_string_t cmd_config_thresh_port =
3472 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3473 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3474 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3475 cmdline_parse_token_string_t cmd_config_thresh_all =
3476 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3477 cmdline_parse_token_string_t cmd_config_thresh_name =
3478 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3479 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3480 cmdline_parse_token_num_t cmd_config_thresh_value =
3481 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3482 
3483 cmdline_parse_inst_t cmd_config_thresh = {
3484 	.f = cmd_config_thresh_parsed,
3485 	.data = NULL,
3486 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3487 	.tokens = {
3488 		(void *)&cmd_config_thresh_port,
3489 		(void *)&cmd_config_thresh_keyword,
3490 		(void *)&cmd_config_thresh_all,
3491 		(void *)&cmd_config_thresh_name,
3492 		(void *)&cmd_config_thresh_value,
3493 		NULL,
3494 	},
3495 };
3496 
3497 /* *** configure free/rs threshold *** */
3498 struct cmd_config_threshold {
3499 	cmdline_fixed_string_t port;
3500 	cmdline_fixed_string_t keyword;
3501 	cmdline_fixed_string_t all;
3502 	cmdline_fixed_string_t name;
3503 	uint16_t value;
3504 };
3505 
3506 static void
3507 cmd_config_threshold_parsed(void *parsed_result,
3508 			__rte_unused struct cmdline *cl,
3509 			__rte_unused void *data)
3510 {
3511 	struct cmd_config_threshold *res = parsed_result;
3512 
3513 	if (!all_ports_stopped()) {
3514 		printf("Please stop all ports first\n");
3515 		return;
3516 	}
3517 
3518 	if (!strcmp(res->name, "txfreet"))
3519 		tx_free_thresh = res->value;
3520 	else if (!strcmp(res->name, "txrst"))
3521 		tx_rs_thresh = res->value;
3522 	else if (!strcmp(res->name, "rxfreet"))
3523 		rx_free_thresh = res->value;
3524 	else {
3525 		printf("Unknown parameter\n");
3526 		return;
3527 	}
3528 
3529 	init_port_config();
3530 
3531 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3532 }
3533 
3534 cmdline_parse_token_string_t cmd_config_threshold_port =
3535 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3536 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3537 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3538 								"config");
3539 cmdline_parse_token_string_t cmd_config_threshold_all =
3540 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3541 cmdline_parse_token_string_t cmd_config_threshold_name =
3542 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3543 						"txfreet#txrst#rxfreet");
3544 cmdline_parse_token_num_t cmd_config_threshold_value =
3545 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3546 
3547 cmdline_parse_inst_t cmd_config_threshold = {
3548 	.f = cmd_config_threshold_parsed,
3549 	.data = NULL,
3550 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3551 	.tokens = {
3552 		(void *)&cmd_config_threshold_port,
3553 		(void *)&cmd_config_threshold_keyword,
3554 		(void *)&cmd_config_threshold_all,
3555 		(void *)&cmd_config_threshold_name,
3556 		(void *)&cmd_config_threshold_value,
3557 		NULL,
3558 	},
3559 };
3560 
3561 /* *** stop *** */
3562 struct cmd_stop_result {
3563 	cmdline_fixed_string_t stop;
3564 };
3565 
3566 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3567 			    __rte_unused struct cmdline *cl,
3568 			    __rte_unused void *data)
3569 {
3570 	stop_packet_forwarding();
3571 }
3572 
3573 cmdline_parse_token_string_t cmd_stop_stop =
3574 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3575 
3576 cmdline_parse_inst_t cmd_stop = {
3577 	.f = cmd_stop_parsed,
3578 	.data = NULL,
3579 	.help_str = "stop: Stop packet forwarding",
3580 	.tokens = {
3581 		(void *)&cmd_stop_stop,
3582 		NULL,
3583 	},
3584 };
3585 
3586 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3587 
3588 unsigned int
3589 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3590 		unsigned int *parsed_items, int check_unique_values)
3591 {
3592 	unsigned int nb_item;
3593 	unsigned int value;
3594 	unsigned int i;
3595 	unsigned int j;
3596 	int value_ok;
3597 	char c;
3598 
3599 	/*
3600 	 * First parse all items in the list and store their value.
3601 	 */
3602 	value = 0;
3603 	nb_item = 0;
3604 	value_ok = 0;
3605 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3606 		c = str[i];
3607 		if ((c >= '0') && (c <= '9')) {
3608 			value = (unsigned int) (value * 10 + (c - '0'));
3609 			value_ok = 1;
3610 			continue;
3611 		}
3612 		if (c != ',') {
3613 			printf("character %c is not a decimal digit\n", c);
3614 			return 0;
3615 		}
3616 		if (! value_ok) {
3617 			printf("No valid value before comma\n");
3618 			return 0;
3619 		}
3620 		if (nb_item < max_items) {
3621 			parsed_items[nb_item] = value;
3622 			value_ok = 0;
3623 			value = 0;
3624 		}
3625 		nb_item++;
3626 	}
3627 	if (nb_item >= max_items) {
3628 		printf("Number of %s = %u > %u (maximum items)\n",
3629 		       item_name, nb_item + 1, max_items);
3630 		return 0;
3631 	}
3632 	parsed_items[nb_item++] = value;
3633 	if (! check_unique_values)
3634 		return nb_item;
3635 
3636 	/*
3637 	 * Then, check that all values in the list are differents.
3638 	 * No optimization here...
3639 	 */
3640 	for (i = 0; i < nb_item; i++) {
3641 		for (j = i + 1; j < nb_item; j++) {
3642 			if (parsed_items[j] == parsed_items[i]) {
3643 				printf("duplicated %s %u at index %u and %u\n",
3644 				       item_name, parsed_items[i], i, j);
3645 				return 0;
3646 			}
3647 		}
3648 	}
3649 	return nb_item;
3650 }
3651 
3652 struct cmd_set_list_result {
3653 	cmdline_fixed_string_t cmd_keyword;
3654 	cmdline_fixed_string_t list_name;
3655 	cmdline_fixed_string_t list_of_items;
3656 };
3657 
3658 static void cmd_set_list_parsed(void *parsed_result,
3659 				__rte_unused struct cmdline *cl,
3660 				__rte_unused void *data)
3661 {
3662 	struct cmd_set_list_result *res;
3663 	union {
3664 		unsigned int lcorelist[RTE_MAX_LCORE];
3665 		unsigned int portlist[RTE_MAX_ETHPORTS];
3666 	} parsed_items;
3667 	unsigned int nb_item;
3668 
3669 	if (test_done == 0) {
3670 		printf("Please stop forwarding first\n");
3671 		return;
3672 	}
3673 
3674 	res = parsed_result;
3675 	if (!strcmp(res->list_name, "corelist")) {
3676 		nb_item = parse_item_list(res->list_of_items, "core",
3677 					  RTE_MAX_LCORE,
3678 					  parsed_items.lcorelist, 1);
3679 		if (nb_item > 0) {
3680 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3681 			fwd_config_setup();
3682 		}
3683 		return;
3684 	}
3685 	if (!strcmp(res->list_name, "portlist")) {
3686 		nb_item = parse_item_list(res->list_of_items, "port",
3687 					  RTE_MAX_ETHPORTS,
3688 					  parsed_items.portlist, 1);
3689 		if (nb_item > 0) {
3690 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3691 			fwd_config_setup();
3692 		}
3693 	}
3694 }
3695 
3696 cmdline_parse_token_string_t cmd_set_list_keyword =
3697 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3698 				 "set");
3699 cmdline_parse_token_string_t cmd_set_list_name =
3700 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3701 				 "corelist#portlist");
3702 cmdline_parse_token_string_t cmd_set_list_of_items =
3703 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3704 				 NULL);
3705 
3706 cmdline_parse_inst_t cmd_set_fwd_list = {
3707 	.f = cmd_set_list_parsed,
3708 	.data = NULL,
3709 	.help_str = "set corelist|portlist <list0[,list1]*>",
3710 	.tokens = {
3711 		(void *)&cmd_set_list_keyword,
3712 		(void *)&cmd_set_list_name,
3713 		(void *)&cmd_set_list_of_items,
3714 		NULL,
3715 	},
3716 };
3717 
3718 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3719 
3720 struct cmd_setmask_result {
3721 	cmdline_fixed_string_t set;
3722 	cmdline_fixed_string_t mask;
3723 	uint64_t hexavalue;
3724 };
3725 
3726 static void cmd_set_mask_parsed(void *parsed_result,
3727 				__rte_unused struct cmdline *cl,
3728 				__rte_unused void *data)
3729 {
3730 	struct cmd_setmask_result *res = parsed_result;
3731 
3732 	if (test_done == 0) {
3733 		printf("Please stop forwarding first\n");
3734 		return;
3735 	}
3736 	if (!strcmp(res->mask, "coremask")) {
3737 		set_fwd_lcores_mask(res->hexavalue);
3738 		fwd_config_setup();
3739 	} else if (!strcmp(res->mask, "portmask")) {
3740 		set_fwd_ports_mask(res->hexavalue);
3741 		fwd_config_setup();
3742 	}
3743 }
3744 
3745 cmdline_parse_token_string_t cmd_setmask_set =
3746 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3747 cmdline_parse_token_string_t cmd_setmask_mask =
3748 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3749 				 "coremask#portmask");
3750 cmdline_parse_token_num_t cmd_setmask_value =
3751 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3752 
3753 cmdline_parse_inst_t cmd_set_fwd_mask = {
3754 	.f = cmd_set_mask_parsed,
3755 	.data = NULL,
3756 	.help_str = "set coremask|portmask <hexadecimal value>",
3757 	.tokens = {
3758 		(void *)&cmd_setmask_set,
3759 		(void *)&cmd_setmask_mask,
3760 		(void *)&cmd_setmask_value,
3761 		NULL,
3762 	},
3763 };
3764 
3765 /*
3766  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3767  */
3768 struct cmd_set_result {
3769 	cmdline_fixed_string_t set;
3770 	cmdline_fixed_string_t what;
3771 	uint16_t value;
3772 };
3773 
3774 static void cmd_set_parsed(void *parsed_result,
3775 			   __rte_unused struct cmdline *cl,
3776 			   __rte_unused void *data)
3777 {
3778 	struct cmd_set_result *res = parsed_result;
3779 	if (!strcmp(res->what, "nbport")) {
3780 		set_fwd_ports_number(res->value);
3781 		fwd_config_setup();
3782 	} else if (!strcmp(res->what, "nbcore")) {
3783 		set_fwd_lcores_number(res->value);
3784 		fwd_config_setup();
3785 	} else if (!strcmp(res->what, "burst"))
3786 		set_nb_pkt_per_burst(res->value);
3787 	else if (!strcmp(res->what, "verbose"))
3788 		set_verbose_level(res->value);
3789 }
3790 
3791 cmdline_parse_token_string_t cmd_set_set =
3792 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3793 cmdline_parse_token_string_t cmd_set_what =
3794 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3795 				 "nbport#nbcore#burst#verbose");
3796 cmdline_parse_token_num_t cmd_set_value =
3797 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3798 
3799 cmdline_parse_inst_t cmd_set_numbers = {
3800 	.f = cmd_set_parsed,
3801 	.data = NULL,
3802 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3803 	.tokens = {
3804 		(void *)&cmd_set_set,
3805 		(void *)&cmd_set_what,
3806 		(void *)&cmd_set_value,
3807 		NULL,
3808 	},
3809 };
3810 
3811 /* *** SET LOG LEVEL CONFIGURATION *** */
3812 
3813 struct cmd_set_log_result {
3814 	cmdline_fixed_string_t set;
3815 	cmdline_fixed_string_t log;
3816 	cmdline_fixed_string_t type;
3817 	uint32_t level;
3818 };
3819 
3820 static void
3821 cmd_set_log_parsed(void *parsed_result,
3822 		   __rte_unused struct cmdline *cl,
3823 		   __rte_unused void *data)
3824 {
3825 	struct cmd_set_log_result *res;
3826 	int ret;
3827 
3828 	res = parsed_result;
3829 	if (!strcmp(res->type, "global"))
3830 		rte_log_set_global_level(res->level);
3831 	else {
3832 		ret = rte_log_set_level_regexp(res->type, res->level);
3833 		if (ret < 0)
3834 			printf("Unable to set log level\n");
3835 	}
3836 }
3837 
3838 cmdline_parse_token_string_t cmd_set_log_set =
3839 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3840 cmdline_parse_token_string_t cmd_set_log_log =
3841 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3842 cmdline_parse_token_string_t cmd_set_log_type =
3843 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3844 cmdline_parse_token_num_t cmd_set_log_level =
3845 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3846 
3847 cmdline_parse_inst_t cmd_set_log = {
3848 	.f = cmd_set_log_parsed,
3849 	.data = NULL,
3850 	.help_str = "set log global|<type> <level>",
3851 	.tokens = {
3852 		(void *)&cmd_set_log_set,
3853 		(void *)&cmd_set_log_log,
3854 		(void *)&cmd_set_log_type,
3855 		(void *)&cmd_set_log_level,
3856 		NULL,
3857 	},
3858 };
3859 
3860 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3861 
3862 struct cmd_set_txpkts_result {
3863 	cmdline_fixed_string_t cmd_keyword;
3864 	cmdline_fixed_string_t txpkts;
3865 	cmdline_fixed_string_t seg_lengths;
3866 };
3867 
3868 static void
3869 cmd_set_txpkts_parsed(void *parsed_result,
3870 		      __rte_unused struct cmdline *cl,
3871 		      __rte_unused void *data)
3872 {
3873 	struct cmd_set_txpkts_result *res;
3874 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3875 	unsigned int nb_segs;
3876 
3877 	res = parsed_result;
3878 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3879 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3880 	if (nb_segs > 0)
3881 		set_tx_pkt_segments(seg_lengths, nb_segs);
3882 }
3883 
3884 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3885 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3886 				 cmd_keyword, "set");
3887 cmdline_parse_token_string_t cmd_set_txpkts_name =
3888 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3889 				 txpkts, "txpkts");
3890 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3891 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3892 				 seg_lengths, NULL);
3893 
3894 cmdline_parse_inst_t cmd_set_txpkts = {
3895 	.f = cmd_set_txpkts_parsed,
3896 	.data = NULL,
3897 	.help_str = "set txpkts <len0[,len1]*>",
3898 	.tokens = {
3899 		(void *)&cmd_set_txpkts_keyword,
3900 		(void *)&cmd_set_txpkts_name,
3901 		(void *)&cmd_set_txpkts_lengths,
3902 		NULL,
3903 	},
3904 };
3905 
3906 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3907 
3908 struct cmd_set_txsplit_result {
3909 	cmdline_fixed_string_t cmd_keyword;
3910 	cmdline_fixed_string_t txsplit;
3911 	cmdline_fixed_string_t mode;
3912 };
3913 
3914 static void
3915 cmd_set_txsplit_parsed(void *parsed_result,
3916 		      __rte_unused struct cmdline *cl,
3917 		      __rte_unused void *data)
3918 {
3919 	struct cmd_set_txsplit_result *res;
3920 
3921 	res = parsed_result;
3922 	set_tx_pkt_split(res->mode);
3923 }
3924 
3925 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3926 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3927 				 cmd_keyword, "set");
3928 cmdline_parse_token_string_t cmd_set_txsplit_name =
3929 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3930 				 txsplit, "txsplit");
3931 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3932 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3933 				 mode, NULL);
3934 
3935 cmdline_parse_inst_t cmd_set_txsplit = {
3936 	.f = cmd_set_txsplit_parsed,
3937 	.data = NULL,
3938 	.help_str = "set txsplit on|off|rand",
3939 	.tokens = {
3940 		(void *)&cmd_set_txsplit_keyword,
3941 		(void *)&cmd_set_txsplit_name,
3942 		(void *)&cmd_set_txsplit_mode,
3943 		NULL,
3944 	},
3945 };
3946 
3947 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3948 
3949 struct cmd_set_txtimes_result {
3950 	cmdline_fixed_string_t cmd_keyword;
3951 	cmdline_fixed_string_t txtimes;
3952 	cmdline_fixed_string_t tx_times;
3953 };
3954 
3955 static void
3956 cmd_set_txtimes_parsed(void *parsed_result,
3957 		       __rte_unused struct cmdline *cl,
3958 		       __rte_unused void *data)
3959 {
3960 	struct cmd_set_txtimes_result *res;
3961 	unsigned int tx_times[2] = {0, 0};
3962 	unsigned int n_times;
3963 
3964 	res = parsed_result;
3965 	n_times = parse_item_list(res->tx_times, "tx times",
3966 				  2, tx_times, 0);
3967 	if (n_times == 2)
3968 		set_tx_pkt_times(tx_times);
3969 }
3970 
3971 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3972 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3973 				 cmd_keyword, "set");
3974 cmdline_parse_token_string_t cmd_set_txtimes_name =
3975 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3976 				 txtimes, "txtimes");
3977 cmdline_parse_token_string_t cmd_set_txtimes_value =
3978 	TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3979 				 tx_times, NULL);
3980 
3981 cmdline_parse_inst_t cmd_set_txtimes = {
3982 	.f = cmd_set_txtimes_parsed,
3983 	.data = NULL,
3984 	.help_str = "set txtimes <inter_burst>,<intra_burst>",
3985 	.tokens = {
3986 		(void *)&cmd_set_txtimes_keyword,
3987 		(void *)&cmd_set_txtimes_name,
3988 		(void *)&cmd_set_txtimes_value,
3989 		NULL,
3990 	},
3991 };
3992 
3993 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3994 struct cmd_rx_vlan_filter_all_result {
3995 	cmdline_fixed_string_t rx_vlan;
3996 	cmdline_fixed_string_t what;
3997 	cmdline_fixed_string_t all;
3998 	portid_t port_id;
3999 };
4000 
4001 static void
4002 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4003 			      __rte_unused struct cmdline *cl,
4004 			      __rte_unused void *data)
4005 {
4006 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4007 
4008 	if (!strcmp(res->what, "add"))
4009 		rx_vlan_all_filter_set(res->port_id, 1);
4010 	else
4011 		rx_vlan_all_filter_set(res->port_id, 0);
4012 }
4013 
4014 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4015 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4016 				 rx_vlan, "rx_vlan");
4017 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4018 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4019 				 what, "add#rm");
4020 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4021 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4022 				 all, "all");
4023 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4024 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4025 			      port_id, UINT16);
4026 
4027 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4028 	.f = cmd_rx_vlan_filter_all_parsed,
4029 	.data = NULL,
4030 	.help_str = "rx_vlan add|rm all <port_id>: "
4031 		"Add/Remove all identifiers to/from the set of VLAN "
4032 		"identifiers filtered by a port",
4033 	.tokens = {
4034 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
4035 		(void *)&cmd_rx_vlan_filter_all_what,
4036 		(void *)&cmd_rx_vlan_filter_all_all,
4037 		(void *)&cmd_rx_vlan_filter_all_portid,
4038 		NULL,
4039 	},
4040 };
4041 
4042 /* *** VLAN OFFLOAD SET ON A PORT *** */
4043 struct cmd_vlan_offload_result {
4044 	cmdline_fixed_string_t vlan;
4045 	cmdline_fixed_string_t set;
4046 	cmdline_fixed_string_t vlan_type;
4047 	cmdline_fixed_string_t what;
4048 	cmdline_fixed_string_t on;
4049 	cmdline_fixed_string_t port_id;
4050 };
4051 
4052 static void
4053 cmd_vlan_offload_parsed(void *parsed_result,
4054 			  __rte_unused struct cmdline *cl,
4055 			  __rte_unused void *data)
4056 {
4057 	int on;
4058 	struct cmd_vlan_offload_result *res = parsed_result;
4059 	char *str;
4060 	int i, len = 0;
4061 	portid_t port_id = 0;
4062 	unsigned int tmp;
4063 
4064 	str = res->port_id;
4065 	len = strnlen(str, STR_TOKEN_SIZE);
4066 	i = 0;
4067 	/* Get port_id first */
4068 	while(i < len){
4069 		if(str[i] == ',')
4070 			break;
4071 
4072 		i++;
4073 	}
4074 	str[i]='\0';
4075 	tmp = strtoul(str, NULL, 0);
4076 	/* If port_id greater that what portid_t can represent, return */
4077 	if(tmp >= RTE_MAX_ETHPORTS)
4078 		return;
4079 	port_id = (portid_t)tmp;
4080 
4081 	if (!strcmp(res->on, "on"))
4082 		on = 1;
4083 	else
4084 		on = 0;
4085 
4086 	if (!strcmp(res->what, "strip"))
4087 		rx_vlan_strip_set(port_id,  on);
4088 	else if(!strcmp(res->what, "stripq")){
4089 		uint16_t queue_id = 0;
4090 
4091 		/* No queue_id, return */
4092 		if(i + 1 >= len) {
4093 			printf("must specify (port,queue_id)\n");
4094 			return;
4095 		}
4096 		tmp = strtoul(str + i + 1, NULL, 0);
4097 		/* If queue_id greater that what 16-bits can represent, return */
4098 		if(tmp > 0xffff)
4099 			return;
4100 
4101 		queue_id = (uint16_t)tmp;
4102 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4103 	}
4104 	else if (!strcmp(res->what, "filter"))
4105 		rx_vlan_filter_set(port_id, on);
4106 	else if (!strcmp(res->what, "qinq_strip"))
4107 		rx_vlan_qinq_strip_set(port_id, on);
4108 	else
4109 		vlan_extend_set(port_id, on);
4110 
4111 	return;
4112 }
4113 
4114 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4115 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4116 				 vlan, "vlan");
4117 cmdline_parse_token_string_t cmd_vlan_offload_set =
4118 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4119 				 set, "set");
4120 cmdline_parse_token_string_t cmd_vlan_offload_what =
4121 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4122 				what, "strip#filter#qinq_strip#extend#stripq");
4123 cmdline_parse_token_string_t cmd_vlan_offload_on =
4124 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4125 			      on, "on#off");
4126 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4127 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4128 			      port_id, NULL);
4129 
4130 cmdline_parse_inst_t cmd_vlan_offload = {
4131 	.f = cmd_vlan_offload_parsed,
4132 	.data = NULL,
4133 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4134 		"<port_id[,queue_id]>: "
4135 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4136 	.tokens = {
4137 		(void *)&cmd_vlan_offload_vlan,
4138 		(void *)&cmd_vlan_offload_set,
4139 		(void *)&cmd_vlan_offload_what,
4140 		(void *)&cmd_vlan_offload_on,
4141 		(void *)&cmd_vlan_offload_portid,
4142 		NULL,
4143 	},
4144 };
4145 
4146 /* *** VLAN TPID SET ON A PORT *** */
4147 struct cmd_vlan_tpid_result {
4148 	cmdline_fixed_string_t vlan;
4149 	cmdline_fixed_string_t set;
4150 	cmdline_fixed_string_t vlan_type;
4151 	cmdline_fixed_string_t what;
4152 	uint16_t tp_id;
4153 	portid_t port_id;
4154 };
4155 
4156 static void
4157 cmd_vlan_tpid_parsed(void *parsed_result,
4158 			  __rte_unused struct cmdline *cl,
4159 			  __rte_unused void *data)
4160 {
4161 	struct cmd_vlan_tpid_result *res = parsed_result;
4162 	enum rte_vlan_type vlan_type;
4163 
4164 	if (!strcmp(res->vlan_type, "inner"))
4165 		vlan_type = ETH_VLAN_TYPE_INNER;
4166 	else if (!strcmp(res->vlan_type, "outer"))
4167 		vlan_type = ETH_VLAN_TYPE_OUTER;
4168 	else {
4169 		printf("Unknown vlan type\n");
4170 		return;
4171 	}
4172 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4173 }
4174 
4175 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4176 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4177 				 vlan, "vlan");
4178 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4179 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4180 				 set, "set");
4181 cmdline_parse_token_string_t cmd_vlan_type =
4182 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4183 				 vlan_type, "inner#outer");
4184 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4185 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4186 				 what, "tpid");
4187 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4188 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4189 			      tp_id, UINT16);
4190 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4191 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4192 			      port_id, UINT16);
4193 
4194 cmdline_parse_inst_t cmd_vlan_tpid = {
4195 	.f = cmd_vlan_tpid_parsed,
4196 	.data = NULL,
4197 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4198 		"Set the VLAN Ether type",
4199 	.tokens = {
4200 		(void *)&cmd_vlan_tpid_vlan,
4201 		(void *)&cmd_vlan_tpid_set,
4202 		(void *)&cmd_vlan_type,
4203 		(void *)&cmd_vlan_tpid_what,
4204 		(void *)&cmd_vlan_tpid_tpid,
4205 		(void *)&cmd_vlan_tpid_portid,
4206 		NULL,
4207 	},
4208 };
4209 
4210 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4211 struct cmd_rx_vlan_filter_result {
4212 	cmdline_fixed_string_t rx_vlan;
4213 	cmdline_fixed_string_t what;
4214 	uint16_t vlan_id;
4215 	portid_t port_id;
4216 };
4217 
4218 static void
4219 cmd_rx_vlan_filter_parsed(void *parsed_result,
4220 			  __rte_unused struct cmdline *cl,
4221 			  __rte_unused void *data)
4222 {
4223 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4224 
4225 	if (!strcmp(res->what, "add"))
4226 		rx_vft_set(res->port_id, res->vlan_id, 1);
4227 	else
4228 		rx_vft_set(res->port_id, res->vlan_id, 0);
4229 }
4230 
4231 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4232 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4233 				 rx_vlan, "rx_vlan");
4234 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4235 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4236 				 what, "add#rm");
4237 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4238 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4239 			      vlan_id, UINT16);
4240 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4241 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4242 			      port_id, UINT16);
4243 
4244 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4245 	.f = cmd_rx_vlan_filter_parsed,
4246 	.data = NULL,
4247 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4248 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4249 		"identifiers filtered by a port",
4250 	.tokens = {
4251 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4252 		(void *)&cmd_rx_vlan_filter_what,
4253 		(void *)&cmd_rx_vlan_filter_vlanid,
4254 		(void *)&cmd_rx_vlan_filter_portid,
4255 		NULL,
4256 	},
4257 };
4258 
4259 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4260 struct cmd_tx_vlan_set_result {
4261 	cmdline_fixed_string_t tx_vlan;
4262 	cmdline_fixed_string_t set;
4263 	portid_t port_id;
4264 	uint16_t vlan_id;
4265 };
4266 
4267 static void
4268 cmd_tx_vlan_set_parsed(void *parsed_result,
4269 		       __rte_unused struct cmdline *cl,
4270 		       __rte_unused void *data)
4271 {
4272 	struct cmd_tx_vlan_set_result *res = parsed_result;
4273 
4274 	if (!port_is_stopped(res->port_id)) {
4275 		printf("Please stop port %d first\n", res->port_id);
4276 		return;
4277 	}
4278 
4279 	tx_vlan_set(res->port_id, res->vlan_id);
4280 
4281 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4282 }
4283 
4284 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4285 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4286 				 tx_vlan, "tx_vlan");
4287 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4288 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4289 				 set, "set");
4290 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4291 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4292 			      port_id, UINT16);
4293 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4294 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4295 			      vlan_id, UINT16);
4296 
4297 cmdline_parse_inst_t cmd_tx_vlan_set = {
4298 	.f = cmd_tx_vlan_set_parsed,
4299 	.data = NULL,
4300 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4301 		"Enable hardware insertion of a single VLAN header "
4302 		"with a given TAG Identifier in packets sent on a port",
4303 	.tokens = {
4304 		(void *)&cmd_tx_vlan_set_tx_vlan,
4305 		(void *)&cmd_tx_vlan_set_set,
4306 		(void *)&cmd_tx_vlan_set_portid,
4307 		(void *)&cmd_tx_vlan_set_vlanid,
4308 		NULL,
4309 	},
4310 };
4311 
4312 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4313 struct cmd_tx_vlan_set_qinq_result {
4314 	cmdline_fixed_string_t tx_vlan;
4315 	cmdline_fixed_string_t set;
4316 	portid_t port_id;
4317 	uint16_t vlan_id;
4318 	uint16_t vlan_id_outer;
4319 };
4320 
4321 static void
4322 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4323 			    __rte_unused struct cmdline *cl,
4324 			    __rte_unused void *data)
4325 {
4326 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4327 
4328 	if (!port_is_stopped(res->port_id)) {
4329 		printf("Please stop port %d first\n", res->port_id);
4330 		return;
4331 	}
4332 
4333 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4334 
4335 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4336 }
4337 
4338 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4339 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4340 		tx_vlan, "tx_vlan");
4341 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4342 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4343 		set, "set");
4344 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4345 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4346 		port_id, UINT16);
4347 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4348 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4349 		vlan_id, UINT16);
4350 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4351 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4352 		vlan_id_outer, UINT16);
4353 
4354 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4355 	.f = cmd_tx_vlan_set_qinq_parsed,
4356 	.data = NULL,
4357 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4358 		"Enable hardware insertion of double VLAN header "
4359 		"with given TAG Identifiers in packets sent on a port",
4360 	.tokens = {
4361 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4362 		(void *)&cmd_tx_vlan_set_qinq_set,
4363 		(void *)&cmd_tx_vlan_set_qinq_portid,
4364 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4365 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4366 		NULL,
4367 	},
4368 };
4369 
4370 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4371 struct cmd_tx_vlan_set_pvid_result {
4372 	cmdline_fixed_string_t tx_vlan;
4373 	cmdline_fixed_string_t set;
4374 	cmdline_fixed_string_t pvid;
4375 	portid_t port_id;
4376 	uint16_t vlan_id;
4377 	cmdline_fixed_string_t mode;
4378 };
4379 
4380 static void
4381 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4382 			    __rte_unused struct cmdline *cl,
4383 			    __rte_unused void *data)
4384 {
4385 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4386 
4387 	if (strcmp(res->mode, "on") == 0)
4388 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4389 	else
4390 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4391 }
4392 
4393 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4394 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4395 				 tx_vlan, "tx_vlan");
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4397 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4398 				 set, "set");
4399 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4400 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4401 				 pvid, "pvid");
4402 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4403 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4404 			     port_id, UINT16);
4405 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4406 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4407 			      vlan_id, UINT16);
4408 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4409 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4410 				 mode, "on#off");
4411 
4412 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4413 	.f = cmd_tx_vlan_set_pvid_parsed,
4414 	.data = NULL,
4415 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4416 	.tokens = {
4417 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4418 		(void *)&cmd_tx_vlan_set_pvid_set,
4419 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4420 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4421 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4422 		(void *)&cmd_tx_vlan_set_pvid_mode,
4423 		NULL,
4424 	},
4425 };
4426 
4427 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4428 struct cmd_tx_vlan_reset_result {
4429 	cmdline_fixed_string_t tx_vlan;
4430 	cmdline_fixed_string_t reset;
4431 	portid_t port_id;
4432 };
4433 
4434 static void
4435 cmd_tx_vlan_reset_parsed(void *parsed_result,
4436 			 __rte_unused struct cmdline *cl,
4437 			 __rte_unused void *data)
4438 {
4439 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4440 
4441 	if (!port_is_stopped(res->port_id)) {
4442 		printf("Please stop port %d first\n", res->port_id);
4443 		return;
4444 	}
4445 
4446 	tx_vlan_reset(res->port_id);
4447 
4448 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4449 }
4450 
4451 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4452 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4453 				 tx_vlan, "tx_vlan");
4454 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4455 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4456 				 reset, "reset");
4457 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4458 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4459 			      port_id, UINT16);
4460 
4461 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4462 	.f = cmd_tx_vlan_reset_parsed,
4463 	.data = NULL,
4464 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4465 		"VLAN header in packets sent on a port",
4466 	.tokens = {
4467 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4468 		(void *)&cmd_tx_vlan_reset_reset,
4469 		(void *)&cmd_tx_vlan_reset_portid,
4470 		NULL,
4471 	},
4472 };
4473 
4474 
4475 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4476 struct cmd_csum_result {
4477 	cmdline_fixed_string_t csum;
4478 	cmdline_fixed_string_t mode;
4479 	cmdline_fixed_string_t proto;
4480 	cmdline_fixed_string_t hwsw;
4481 	portid_t port_id;
4482 };
4483 
4484 static void
4485 csum_show(int port_id)
4486 {
4487 	struct rte_eth_dev_info dev_info;
4488 	uint64_t tx_offloads;
4489 	int ret;
4490 
4491 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4492 	printf("Parse tunnel is %s\n",
4493 		(ports[port_id].parse_tunnel) ? "on" : "off");
4494 	printf("IP checksum offload is %s\n",
4495 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4496 	printf("UDP checksum offload is %s\n",
4497 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4498 	printf("TCP checksum offload is %s\n",
4499 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4500 	printf("SCTP checksum offload is %s\n",
4501 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4502 	printf("Outer-Ip checksum offload is %s\n",
4503 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4504 	printf("Outer-Udp checksum offload is %s\n",
4505 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4506 
4507 	/* display warnings if configuration is not supported by the NIC */
4508 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4509 	if (ret != 0)
4510 		return;
4511 
4512 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4513 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4514 		printf("Warning: hardware IP checksum enabled but not "
4515 			"supported by port %d\n", port_id);
4516 	}
4517 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4518 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4519 		printf("Warning: hardware UDP checksum enabled but not "
4520 			"supported by port %d\n", port_id);
4521 	}
4522 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4523 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4524 		printf("Warning: hardware TCP checksum enabled but not "
4525 			"supported by port %d\n", port_id);
4526 	}
4527 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4528 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4529 		printf("Warning: hardware SCTP checksum enabled but not "
4530 			"supported by port %d\n", port_id);
4531 	}
4532 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4533 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4534 		printf("Warning: hardware outer IP checksum enabled but not "
4535 			"supported by port %d\n", port_id);
4536 	}
4537 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4538 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4539 			== 0) {
4540 		printf("Warning: hardware outer UDP checksum enabled but not "
4541 			"supported by port %d\n", port_id);
4542 	}
4543 }
4544 
4545 static void
4546 cmd_config_queue_tx_offloads(struct rte_port *port)
4547 {
4548 	int k;
4549 
4550 	/* Apply queue tx offloads configuration */
4551 	for (k = 0; k < port->dev_info.max_rx_queues; k++)
4552 		port->tx_conf[k].offloads =
4553 			port->dev_conf.txmode.offloads;
4554 }
4555 
4556 static void
4557 cmd_csum_parsed(void *parsed_result,
4558 		       __rte_unused struct cmdline *cl,
4559 		       __rte_unused void *data)
4560 {
4561 	struct cmd_csum_result *res = parsed_result;
4562 	int hw = 0;
4563 	uint64_t csum_offloads = 0;
4564 	struct rte_eth_dev_info dev_info;
4565 	int ret;
4566 
4567 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4568 		printf("invalid port %d\n", res->port_id);
4569 		return;
4570 	}
4571 	if (!port_is_stopped(res->port_id)) {
4572 		printf("Please stop port %d first\n", res->port_id);
4573 		return;
4574 	}
4575 
4576 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4577 	if (ret != 0)
4578 		return;
4579 
4580 	if (!strcmp(res->mode, "set")) {
4581 
4582 		if (!strcmp(res->hwsw, "hw"))
4583 			hw = 1;
4584 
4585 		if (!strcmp(res->proto, "ip")) {
4586 			if (hw == 0 || (dev_info.tx_offload_capa &
4587 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4588 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4589 			} else {
4590 				printf("IP checksum offload is not supported "
4591 				       "by port %u\n", res->port_id);
4592 			}
4593 		} else if (!strcmp(res->proto, "udp")) {
4594 			if (hw == 0 || (dev_info.tx_offload_capa &
4595 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4596 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4597 			} else {
4598 				printf("UDP checksum offload is not supported "
4599 				       "by port %u\n", res->port_id);
4600 			}
4601 		} else if (!strcmp(res->proto, "tcp")) {
4602 			if (hw == 0 || (dev_info.tx_offload_capa &
4603 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4604 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4605 			} else {
4606 				printf("TCP checksum offload is not supported "
4607 				       "by port %u\n", res->port_id);
4608 			}
4609 		} else if (!strcmp(res->proto, "sctp")) {
4610 			if (hw == 0 || (dev_info.tx_offload_capa &
4611 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4612 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4613 			} else {
4614 				printf("SCTP checksum offload is not supported "
4615 				       "by port %u\n", res->port_id);
4616 			}
4617 		} else if (!strcmp(res->proto, "outer-ip")) {
4618 			if (hw == 0 || (dev_info.tx_offload_capa &
4619 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4620 				csum_offloads |=
4621 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4622 			} else {
4623 				printf("Outer IP checksum offload is not "
4624 				       "supported by port %u\n", res->port_id);
4625 			}
4626 		} else if (!strcmp(res->proto, "outer-udp")) {
4627 			if (hw == 0 || (dev_info.tx_offload_capa &
4628 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4629 				csum_offloads |=
4630 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4631 			} else {
4632 				printf("Outer UDP checksum offload is not "
4633 				       "supported by port %u\n", res->port_id);
4634 			}
4635 		}
4636 
4637 		if (hw) {
4638 			ports[res->port_id].dev_conf.txmode.offloads |=
4639 							csum_offloads;
4640 		} else {
4641 			ports[res->port_id].dev_conf.txmode.offloads &=
4642 							(~csum_offloads);
4643 		}
4644 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4645 	}
4646 	csum_show(res->port_id);
4647 
4648 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4649 }
4650 
4651 cmdline_parse_token_string_t cmd_csum_csum =
4652 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4653 				csum, "csum");
4654 cmdline_parse_token_string_t cmd_csum_mode =
4655 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4656 				mode, "set");
4657 cmdline_parse_token_string_t cmd_csum_proto =
4658 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4659 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4660 cmdline_parse_token_string_t cmd_csum_hwsw =
4661 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4662 				hwsw, "hw#sw");
4663 cmdline_parse_token_num_t cmd_csum_portid =
4664 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4665 				port_id, UINT16);
4666 
4667 cmdline_parse_inst_t cmd_csum_set = {
4668 	.f = cmd_csum_parsed,
4669 	.data = NULL,
4670 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4671 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4672 		"using csum forward engine",
4673 	.tokens = {
4674 		(void *)&cmd_csum_csum,
4675 		(void *)&cmd_csum_mode,
4676 		(void *)&cmd_csum_proto,
4677 		(void *)&cmd_csum_hwsw,
4678 		(void *)&cmd_csum_portid,
4679 		NULL,
4680 	},
4681 };
4682 
4683 cmdline_parse_token_string_t cmd_csum_mode_show =
4684 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4685 				mode, "show");
4686 
4687 cmdline_parse_inst_t cmd_csum_show = {
4688 	.f = cmd_csum_parsed,
4689 	.data = NULL,
4690 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4691 	.tokens = {
4692 		(void *)&cmd_csum_csum,
4693 		(void *)&cmd_csum_mode_show,
4694 		(void *)&cmd_csum_portid,
4695 		NULL,
4696 	},
4697 };
4698 
4699 /* Enable/disable tunnel parsing */
4700 struct cmd_csum_tunnel_result {
4701 	cmdline_fixed_string_t csum;
4702 	cmdline_fixed_string_t parse;
4703 	cmdline_fixed_string_t onoff;
4704 	portid_t port_id;
4705 };
4706 
4707 static void
4708 cmd_csum_tunnel_parsed(void *parsed_result,
4709 		       __rte_unused struct cmdline *cl,
4710 		       __rte_unused void *data)
4711 {
4712 	struct cmd_csum_tunnel_result *res = parsed_result;
4713 
4714 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4715 		return;
4716 
4717 	if (!strcmp(res->onoff, "on"))
4718 		ports[res->port_id].parse_tunnel = 1;
4719 	else
4720 		ports[res->port_id].parse_tunnel = 0;
4721 
4722 	csum_show(res->port_id);
4723 }
4724 
4725 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4726 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4727 				csum, "csum");
4728 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4729 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4730 				parse, "parse-tunnel");
4731 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4732 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4733 				onoff, "on#off");
4734 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4735 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4736 				port_id, UINT16);
4737 
4738 cmdline_parse_inst_t cmd_csum_tunnel = {
4739 	.f = cmd_csum_tunnel_parsed,
4740 	.data = NULL,
4741 	.help_str = "csum parse-tunnel on|off <port_id>: "
4742 		"Enable/Disable parsing of tunnels for csum engine",
4743 	.tokens = {
4744 		(void *)&cmd_csum_tunnel_csum,
4745 		(void *)&cmd_csum_tunnel_parse,
4746 		(void *)&cmd_csum_tunnel_onoff,
4747 		(void *)&cmd_csum_tunnel_portid,
4748 		NULL,
4749 	},
4750 };
4751 
4752 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4753 struct cmd_tso_set_result {
4754 	cmdline_fixed_string_t tso;
4755 	cmdline_fixed_string_t mode;
4756 	uint16_t tso_segsz;
4757 	portid_t port_id;
4758 };
4759 
4760 static void
4761 cmd_tso_set_parsed(void *parsed_result,
4762 		       __rte_unused struct cmdline *cl,
4763 		       __rte_unused void *data)
4764 {
4765 	struct cmd_tso_set_result *res = parsed_result;
4766 	struct rte_eth_dev_info dev_info;
4767 	int ret;
4768 
4769 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4770 		return;
4771 	if (!port_is_stopped(res->port_id)) {
4772 		printf("Please stop port %d first\n", res->port_id);
4773 		return;
4774 	}
4775 
4776 	if (!strcmp(res->mode, "set"))
4777 		ports[res->port_id].tso_segsz = res->tso_segsz;
4778 
4779 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4780 	if (ret != 0)
4781 		return;
4782 
4783 	if ((ports[res->port_id].tso_segsz != 0) &&
4784 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4785 		printf("Error: TSO is not supported by port %d\n",
4786 		       res->port_id);
4787 		return;
4788 	}
4789 
4790 	if (ports[res->port_id].tso_segsz == 0) {
4791 		ports[res->port_id].dev_conf.txmode.offloads &=
4792 						~DEV_TX_OFFLOAD_TCP_TSO;
4793 		printf("TSO for non-tunneled packets is disabled\n");
4794 	} else {
4795 		ports[res->port_id].dev_conf.txmode.offloads |=
4796 						DEV_TX_OFFLOAD_TCP_TSO;
4797 		printf("TSO segment size for non-tunneled packets is %d\n",
4798 			ports[res->port_id].tso_segsz);
4799 	}
4800 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4801 
4802 	/* display warnings if configuration is not supported by the NIC */
4803 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4804 	if (ret != 0)
4805 		return;
4806 
4807 	if ((ports[res->port_id].tso_segsz != 0) &&
4808 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4809 		printf("Warning: TSO enabled but not "
4810 			"supported by port %d\n", res->port_id);
4811 	}
4812 
4813 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4814 }
4815 
4816 cmdline_parse_token_string_t cmd_tso_set_tso =
4817 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4818 				tso, "tso");
4819 cmdline_parse_token_string_t cmd_tso_set_mode =
4820 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4821 				mode, "set");
4822 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4823 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4824 				tso_segsz, UINT16);
4825 cmdline_parse_token_num_t cmd_tso_set_portid =
4826 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4827 				port_id, UINT16);
4828 
4829 cmdline_parse_inst_t cmd_tso_set = {
4830 	.f = cmd_tso_set_parsed,
4831 	.data = NULL,
4832 	.help_str = "tso set <tso_segsz> <port_id>: "
4833 		"Set TSO segment size of non-tunneled packets for csum engine "
4834 		"(0 to disable)",
4835 	.tokens = {
4836 		(void *)&cmd_tso_set_tso,
4837 		(void *)&cmd_tso_set_mode,
4838 		(void *)&cmd_tso_set_tso_segsz,
4839 		(void *)&cmd_tso_set_portid,
4840 		NULL,
4841 	},
4842 };
4843 
4844 cmdline_parse_token_string_t cmd_tso_show_mode =
4845 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4846 				mode, "show");
4847 
4848 
4849 cmdline_parse_inst_t cmd_tso_show = {
4850 	.f = cmd_tso_set_parsed,
4851 	.data = NULL,
4852 	.help_str = "tso show <port_id>: "
4853 		"Show TSO segment size of non-tunneled packets for csum engine",
4854 	.tokens = {
4855 		(void *)&cmd_tso_set_tso,
4856 		(void *)&cmd_tso_show_mode,
4857 		(void *)&cmd_tso_set_portid,
4858 		NULL,
4859 	},
4860 };
4861 
4862 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4863 struct cmd_tunnel_tso_set_result {
4864 	cmdline_fixed_string_t tso;
4865 	cmdline_fixed_string_t mode;
4866 	uint16_t tso_segsz;
4867 	portid_t port_id;
4868 };
4869 
4870 static struct rte_eth_dev_info
4871 check_tunnel_tso_nic_support(portid_t port_id)
4872 {
4873 	struct rte_eth_dev_info dev_info;
4874 
4875 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4876 		return dev_info;
4877 
4878 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4879 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4880 		       "not enabled for port %d\n", port_id);
4881 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4882 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4883 		       "not enabled for port %d\n", port_id);
4884 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4885 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
4886 		       "not enabled for port %d\n", port_id);
4887 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4888 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4889 		       "not enabled for port %d\n", port_id);
4890 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4891 		printf("Warning: IP TUNNEL TSO not supported therefore "
4892 		       "not enabled for port %d\n", port_id);
4893 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4894 		printf("Warning: UDP TUNNEL TSO not supported therefore "
4895 		       "not enabled for port %d\n", port_id);
4896 	return dev_info;
4897 }
4898 
4899 static void
4900 cmd_tunnel_tso_set_parsed(void *parsed_result,
4901 			  __rte_unused struct cmdline *cl,
4902 			  __rte_unused void *data)
4903 {
4904 	struct cmd_tunnel_tso_set_result *res = parsed_result;
4905 	struct rte_eth_dev_info dev_info;
4906 
4907 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4908 		return;
4909 	if (!port_is_stopped(res->port_id)) {
4910 		printf("Please stop port %d first\n", res->port_id);
4911 		return;
4912 	}
4913 
4914 	if (!strcmp(res->mode, "set"))
4915 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4916 
4917 	dev_info = check_tunnel_tso_nic_support(res->port_id);
4918 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4919 		ports[res->port_id].dev_conf.txmode.offloads &=
4920 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4921 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4922 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4923 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4924 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
4925 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
4926 		printf("TSO for tunneled packets is disabled\n");
4927 	} else {
4928 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4929 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4930 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4931 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4932 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
4933 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4934 
4935 		ports[res->port_id].dev_conf.txmode.offloads |=
4936 			(tso_offloads & dev_info.tx_offload_capa);
4937 		printf("TSO segment size for tunneled packets is %d\n",
4938 			ports[res->port_id].tunnel_tso_segsz);
4939 
4940 		/* Below conditions are needed to make it work:
4941 		 * (1) tunnel TSO is supported by the NIC;
4942 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4943 		 * are recognized;
4944 		 * (3) for tunneled pkts with outer L3 of IPv4,
4945 		 * "csum set outer-ip" must be set to hw, because after tso,
4946 		 * total_len of outer IP header is changed, and the checksum
4947 		 * of outer IP header calculated by sw should be wrong; that
4948 		 * is not necessary for IPv6 tunneled pkts because there's no
4949 		 * checksum in IP header anymore.
4950 		 */
4951 
4952 		if (!ports[res->port_id].parse_tunnel)
4953 			printf("Warning: csum parse_tunnel must be set "
4954 				"so that tunneled packets are recognized\n");
4955 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4956 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4957 			printf("Warning: csum set outer-ip must be set to hw "
4958 				"if outer L3 is IPv4; not necessary for IPv6\n");
4959 	}
4960 
4961 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4962 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4963 }
4964 
4965 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4966 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4967 				tso, "tunnel_tso");
4968 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4969 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4970 				mode, "set");
4971 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4972 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4973 				tso_segsz, UINT16);
4974 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4975 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4976 				port_id, UINT16);
4977 
4978 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4979 	.f = cmd_tunnel_tso_set_parsed,
4980 	.data = NULL,
4981 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4982 		"Set TSO segment size of tunneled packets for csum engine "
4983 		"(0 to disable)",
4984 	.tokens = {
4985 		(void *)&cmd_tunnel_tso_set_tso,
4986 		(void *)&cmd_tunnel_tso_set_mode,
4987 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4988 		(void *)&cmd_tunnel_tso_set_portid,
4989 		NULL,
4990 	},
4991 };
4992 
4993 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4994 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4995 				mode, "show");
4996 
4997 
4998 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4999 	.f = cmd_tunnel_tso_set_parsed,
5000 	.data = NULL,
5001 	.help_str = "tunnel_tso show <port_id> "
5002 		"Show TSO segment size of tunneled packets for csum engine",
5003 	.tokens = {
5004 		(void *)&cmd_tunnel_tso_set_tso,
5005 		(void *)&cmd_tunnel_tso_show_mode,
5006 		(void *)&cmd_tunnel_tso_set_portid,
5007 		NULL,
5008 	},
5009 };
5010 
5011 /* *** SET GRO FOR A PORT *** */
5012 struct cmd_gro_enable_result {
5013 	cmdline_fixed_string_t cmd_set;
5014 	cmdline_fixed_string_t cmd_port;
5015 	cmdline_fixed_string_t cmd_keyword;
5016 	cmdline_fixed_string_t cmd_onoff;
5017 	portid_t cmd_pid;
5018 };
5019 
5020 static void
5021 cmd_gro_enable_parsed(void *parsed_result,
5022 		__rte_unused struct cmdline *cl,
5023 		__rte_unused void *data)
5024 {
5025 	struct cmd_gro_enable_result *res;
5026 
5027 	res = parsed_result;
5028 	if (!strcmp(res->cmd_keyword, "gro"))
5029 		setup_gro(res->cmd_onoff, res->cmd_pid);
5030 }
5031 
5032 cmdline_parse_token_string_t cmd_gro_enable_set =
5033 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5034 			cmd_set, "set");
5035 cmdline_parse_token_string_t cmd_gro_enable_port =
5036 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5037 			cmd_keyword, "port");
5038 cmdline_parse_token_num_t cmd_gro_enable_pid =
5039 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5040 			cmd_pid, UINT16);
5041 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5042 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5043 			cmd_keyword, "gro");
5044 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5045 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5046 			cmd_onoff, "on#off");
5047 
5048 cmdline_parse_inst_t cmd_gro_enable = {
5049 	.f = cmd_gro_enable_parsed,
5050 	.data = NULL,
5051 	.help_str = "set port <port_id> gro on|off",
5052 	.tokens = {
5053 		(void *)&cmd_gro_enable_set,
5054 		(void *)&cmd_gro_enable_port,
5055 		(void *)&cmd_gro_enable_pid,
5056 		(void *)&cmd_gro_enable_keyword,
5057 		(void *)&cmd_gro_enable_onoff,
5058 		NULL,
5059 	},
5060 };
5061 
5062 /* *** DISPLAY GRO CONFIGURATION *** */
5063 struct cmd_gro_show_result {
5064 	cmdline_fixed_string_t cmd_show;
5065 	cmdline_fixed_string_t cmd_port;
5066 	cmdline_fixed_string_t cmd_keyword;
5067 	portid_t cmd_pid;
5068 };
5069 
5070 static void
5071 cmd_gro_show_parsed(void *parsed_result,
5072 		__rte_unused struct cmdline *cl,
5073 		__rte_unused void *data)
5074 {
5075 	struct cmd_gro_show_result *res;
5076 
5077 	res = parsed_result;
5078 	if (!strcmp(res->cmd_keyword, "gro"))
5079 		show_gro(res->cmd_pid);
5080 }
5081 
5082 cmdline_parse_token_string_t cmd_gro_show_show =
5083 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5084 			cmd_show, "show");
5085 cmdline_parse_token_string_t cmd_gro_show_port =
5086 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5087 			cmd_port, "port");
5088 cmdline_parse_token_num_t cmd_gro_show_pid =
5089 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5090 			cmd_pid, UINT16);
5091 cmdline_parse_token_string_t cmd_gro_show_keyword =
5092 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5093 			cmd_keyword, "gro");
5094 
5095 cmdline_parse_inst_t cmd_gro_show = {
5096 	.f = cmd_gro_show_parsed,
5097 	.data = NULL,
5098 	.help_str = "show port <port_id> gro",
5099 	.tokens = {
5100 		(void *)&cmd_gro_show_show,
5101 		(void *)&cmd_gro_show_port,
5102 		(void *)&cmd_gro_show_pid,
5103 		(void *)&cmd_gro_show_keyword,
5104 		NULL,
5105 	},
5106 };
5107 
5108 /* *** SET FLUSH CYCLES FOR GRO *** */
5109 struct cmd_gro_flush_result {
5110 	cmdline_fixed_string_t cmd_set;
5111 	cmdline_fixed_string_t cmd_keyword;
5112 	cmdline_fixed_string_t cmd_flush;
5113 	uint8_t cmd_cycles;
5114 };
5115 
5116 static void
5117 cmd_gro_flush_parsed(void *parsed_result,
5118 		__rte_unused struct cmdline *cl,
5119 		__rte_unused void *data)
5120 {
5121 	struct cmd_gro_flush_result *res;
5122 
5123 	res = parsed_result;
5124 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5125 			(!strcmp(res->cmd_flush, "flush")))
5126 		setup_gro_flush_cycles(res->cmd_cycles);
5127 }
5128 
5129 cmdline_parse_token_string_t cmd_gro_flush_set =
5130 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5131 			cmd_set, "set");
5132 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5133 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5134 			cmd_keyword, "gro");
5135 cmdline_parse_token_string_t cmd_gro_flush_flush =
5136 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5137 			cmd_flush, "flush");
5138 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5139 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5140 			cmd_cycles, UINT8);
5141 
5142 cmdline_parse_inst_t cmd_gro_flush = {
5143 	.f = cmd_gro_flush_parsed,
5144 	.data = NULL,
5145 	.help_str = "set gro flush <cycles>",
5146 	.tokens = {
5147 		(void *)&cmd_gro_flush_set,
5148 		(void *)&cmd_gro_flush_keyword,
5149 		(void *)&cmd_gro_flush_flush,
5150 		(void *)&cmd_gro_flush_cycles,
5151 		NULL,
5152 	},
5153 };
5154 
5155 /* *** ENABLE/DISABLE GSO *** */
5156 struct cmd_gso_enable_result {
5157 	cmdline_fixed_string_t cmd_set;
5158 	cmdline_fixed_string_t cmd_port;
5159 	cmdline_fixed_string_t cmd_keyword;
5160 	cmdline_fixed_string_t cmd_mode;
5161 	portid_t cmd_pid;
5162 };
5163 
5164 static void
5165 cmd_gso_enable_parsed(void *parsed_result,
5166 		__rte_unused struct cmdline *cl,
5167 		__rte_unused void *data)
5168 {
5169 	struct cmd_gso_enable_result *res;
5170 
5171 	res = parsed_result;
5172 	if (!strcmp(res->cmd_keyword, "gso"))
5173 		setup_gso(res->cmd_mode, res->cmd_pid);
5174 }
5175 
5176 cmdline_parse_token_string_t cmd_gso_enable_set =
5177 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5178 			cmd_set, "set");
5179 cmdline_parse_token_string_t cmd_gso_enable_port =
5180 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5181 			cmd_port, "port");
5182 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5183 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5184 			cmd_keyword, "gso");
5185 cmdline_parse_token_string_t cmd_gso_enable_mode =
5186 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5187 			cmd_mode, "on#off");
5188 cmdline_parse_token_num_t cmd_gso_enable_pid =
5189 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5190 			cmd_pid, UINT16);
5191 
5192 cmdline_parse_inst_t cmd_gso_enable = {
5193 	.f = cmd_gso_enable_parsed,
5194 	.data = NULL,
5195 	.help_str = "set port <port_id> gso on|off",
5196 	.tokens = {
5197 		(void *)&cmd_gso_enable_set,
5198 		(void *)&cmd_gso_enable_port,
5199 		(void *)&cmd_gso_enable_pid,
5200 		(void *)&cmd_gso_enable_keyword,
5201 		(void *)&cmd_gso_enable_mode,
5202 		NULL,
5203 	},
5204 };
5205 
5206 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5207 struct cmd_gso_size_result {
5208 	cmdline_fixed_string_t cmd_set;
5209 	cmdline_fixed_string_t cmd_keyword;
5210 	cmdline_fixed_string_t cmd_segsz;
5211 	uint16_t cmd_size;
5212 };
5213 
5214 static void
5215 cmd_gso_size_parsed(void *parsed_result,
5216 		       __rte_unused struct cmdline *cl,
5217 		       __rte_unused void *data)
5218 {
5219 	struct cmd_gso_size_result *res = parsed_result;
5220 
5221 	if (test_done == 0) {
5222 		printf("Before setting GSO segsz, please first"
5223 				" stop forwarding\n");
5224 		return;
5225 	}
5226 
5227 	if (!strcmp(res->cmd_keyword, "gso") &&
5228 			!strcmp(res->cmd_segsz, "segsz")) {
5229 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5230 			printf("gso_size should be larger than %zu."
5231 					" Please input a legal value\n",
5232 					RTE_GSO_SEG_SIZE_MIN);
5233 		else
5234 			gso_max_segment_size = res->cmd_size;
5235 	}
5236 }
5237 
5238 cmdline_parse_token_string_t cmd_gso_size_set =
5239 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5240 				cmd_set, "set");
5241 cmdline_parse_token_string_t cmd_gso_size_keyword =
5242 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5243 				cmd_keyword, "gso");
5244 cmdline_parse_token_string_t cmd_gso_size_segsz =
5245 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5246 				cmd_segsz, "segsz");
5247 cmdline_parse_token_num_t cmd_gso_size_size =
5248 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5249 				cmd_size, UINT16);
5250 
5251 cmdline_parse_inst_t cmd_gso_size = {
5252 	.f = cmd_gso_size_parsed,
5253 	.data = NULL,
5254 	.help_str = "set gso segsz <length>",
5255 	.tokens = {
5256 		(void *)&cmd_gso_size_set,
5257 		(void *)&cmd_gso_size_keyword,
5258 		(void *)&cmd_gso_size_segsz,
5259 		(void *)&cmd_gso_size_size,
5260 		NULL,
5261 	},
5262 };
5263 
5264 /* *** SHOW GSO CONFIGURATION *** */
5265 struct cmd_gso_show_result {
5266 	cmdline_fixed_string_t cmd_show;
5267 	cmdline_fixed_string_t cmd_port;
5268 	cmdline_fixed_string_t cmd_keyword;
5269 	portid_t cmd_pid;
5270 };
5271 
5272 static void
5273 cmd_gso_show_parsed(void *parsed_result,
5274 		       __rte_unused struct cmdline *cl,
5275 		       __rte_unused void *data)
5276 {
5277 	struct cmd_gso_show_result *res = parsed_result;
5278 
5279 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5280 		printf("invalid port id %u\n", res->cmd_pid);
5281 		return;
5282 	}
5283 	if (!strcmp(res->cmd_keyword, "gso")) {
5284 		if (gso_ports[res->cmd_pid].enable) {
5285 			printf("Max GSO'd packet size: %uB\n"
5286 					"Supported GSO types: TCP/IPv4, "
5287 					"UDP/IPv4, VxLAN with inner "
5288 					"TCP/IPv4 packet, GRE with inner "
5289 					"TCP/IPv4 packet\n",
5290 					gso_max_segment_size);
5291 		} else
5292 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5293 	}
5294 }
5295 
5296 cmdline_parse_token_string_t cmd_gso_show_show =
5297 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5298 		cmd_show, "show");
5299 cmdline_parse_token_string_t cmd_gso_show_port =
5300 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5301 		cmd_port, "port");
5302 cmdline_parse_token_string_t cmd_gso_show_keyword =
5303 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5304 				cmd_keyword, "gso");
5305 cmdline_parse_token_num_t cmd_gso_show_pid =
5306 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5307 				cmd_pid, UINT16);
5308 
5309 cmdline_parse_inst_t cmd_gso_show = {
5310 	.f = cmd_gso_show_parsed,
5311 	.data = NULL,
5312 	.help_str = "show port <port_id> gso",
5313 	.tokens = {
5314 		(void *)&cmd_gso_show_show,
5315 		(void *)&cmd_gso_show_port,
5316 		(void *)&cmd_gso_show_pid,
5317 		(void *)&cmd_gso_show_keyword,
5318 		NULL,
5319 	},
5320 };
5321 
5322 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5323 struct cmd_set_flush_rx {
5324 	cmdline_fixed_string_t set;
5325 	cmdline_fixed_string_t flush_rx;
5326 	cmdline_fixed_string_t mode;
5327 };
5328 
5329 static void
5330 cmd_set_flush_rx_parsed(void *parsed_result,
5331 		__rte_unused struct cmdline *cl,
5332 		__rte_unused void *data)
5333 {
5334 	struct cmd_set_flush_rx *res = parsed_result;
5335 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5336 }
5337 
5338 cmdline_parse_token_string_t cmd_setflushrx_set =
5339 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5340 			set, "set");
5341 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5342 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5343 			flush_rx, "flush_rx");
5344 cmdline_parse_token_string_t cmd_setflushrx_mode =
5345 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5346 			mode, "on#off");
5347 
5348 
5349 cmdline_parse_inst_t cmd_set_flush_rx = {
5350 	.f = cmd_set_flush_rx_parsed,
5351 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5352 	.data = NULL,
5353 	.tokens = {
5354 		(void *)&cmd_setflushrx_set,
5355 		(void *)&cmd_setflushrx_flush_rx,
5356 		(void *)&cmd_setflushrx_mode,
5357 		NULL,
5358 	},
5359 };
5360 
5361 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5362 struct cmd_set_link_check {
5363 	cmdline_fixed_string_t set;
5364 	cmdline_fixed_string_t link_check;
5365 	cmdline_fixed_string_t mode;
5366 };
5367 
5368 static void
5369 cmd_set_link_check_parsed(void *parsed_result,
5370 		__rte_unused struct cmdline *cl,
5371 		__rte_unused void *data)
5372 {
5373 	struct cmd_set_link_check *res = parsed_result;
5374 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5375 }
5376 
5377 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5378 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5379 			set, "set");
5380 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5381 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5382 			link_check, "link_check");
5383 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5384 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5385 			mode, "on#off");
5386 
5387 
5388 cmdline_parse_inst_t cmd_set_link_check = {
5389 	.f = cmd_set_link_check_parsed,
5390 	.help_str = "set link_check on|off: Enable/Disable link status check "
5391 	            "when starting/stopping a port",
5392 	.data = NULL,
5393 	.tokens = {
5394 		(void *)&cmd_setlinkcheck_set,
5395 		(void *)&cmd_setlinkcheck_link_check,
5396 		(void *)&cmd_setlinkcheck_mode,
5397 		NULL,
5398 	},
5399 };
5400 
5401 /* *** SET NIC BYPASS MODE *** */
5402 struct cmd_set_bypass_mode_result {
5403 	cmdline_fixed_string_t set;
5404 	cmdline_fixed_string_t bypass;
5405 	cmdline_fixed_string_t mode;
5406 	cmdline_fixed_string_t value;
5407 	portid_t port_id;
5408 };
5409 
5410 static void
5411 cmd_set_bypass_mode_parsed(void *parsed_result,
5412 		__rte_unused struct cmdline *cl,
5413 		__rte_unused void *data)
5414 {
5415 	struct cmd_set_bypass_mode_result *res = parsed_result;
5416 	portid_t port_id = res->port_id;
5417 	int32_t rc = -EINVAL;
5418 
5419 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5420 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5421 
5422 	if (!strcmp(res->value, "bypass"))
5423 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5424 	else if (!strcmp(res->value, "isolate"))
5425 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5426 	else
5427 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5428 
5429 	/* Set the bypass mode for the relevant port. */
5430 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5431 #endif
5432 	if (rc != 0)
5433 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5434 }
5435 
5436 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5437 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5438 			set, "set");
5439 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5440 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5441 			bypass, "bypass");
5442 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5443 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5444 			mode, "mode");
5445 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5446 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5447 			value, "normal#bypass#isolate");
5448 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5449 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5450 				port_id, UINT16);
5451 
5452 cmdline_parse_inst_t cmd_set_bypass_mode = {
5453 	.f = cmd_set_bypass_mode_parsed,
5454 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5455 	            "Set the NIC bypass mode for port_id",
5456 	.data = NULL,
5457 	.tokens = {
5458 		(void *)&cmd_setbypass_mode_set,
5459 		(void *)&cmd_setbypass_mode_bypass,
5460 		(void *)&cmd_setbypass_mode_mode,
5461 		(void *)&cmd_setbypass_mode_value,
5462 		(void *)&cmd_setbypass_mode_port,
5463 		NULL,
5464 	},
5465 };
5466 
5467 /* *** SET NIC BYPASS EVENT *** */
5468 struct cmd_set_bypass_event_result {
5469 	cmdline_fixed_string_t set;
5470 	cmdline_fixed_string_t bypass;
5471 	cmdline_fixed_string_t event;
5472 	cmdline_fixed_string_t event_value;
5473 	cmdline_fixed_string_t mode;
5474 	cmdline_fixed_string_t mode_value;
5475 	portid_t port_id;
5476 };
5477 
5478 static void
5479 cmd_set_bypass_event_parsed(void *parsed_result,
5480 		__rte_unused struct cmdline *cl,
5481 		__rte_unused void *data)
5482 {
5483 	int32_t rc = -EINVAL;
5484 	struct cmd_set_bypass_event_result *res = parsed_result;
5485 	portid_t port_id = res->port_id;
5486 
5487 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5488 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5489 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5490 
5491 	if (!strcmp(res->event_value, "timeout"))
5492 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5493 	else if (!strcmp(res->event_value, "os_on"))
5494 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5495 	else if (!strcmp(res->event_value, "os_off"))
5496 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5497 	else if (!strcmp(res->event_value, "power_on"))
5498 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5499 	else if (!strcmp(res->event_value, "power_off"))
5500 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5501 	else
5502 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5503 
5504 	if (!strcmp(res->mode_value, "bypass"))
5505 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5506 	else if (!strcmp(res->mode_value, "isolate"))
5507 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5508 	else
5509 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5510 
5511 	/* Set the watchdog timeout. */
5512 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5513 
5514 		rc = -EINVAL;
5515 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5516 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5517 							   bypass_timeout);
5518 		}
5519 		if (rc != 0) {
5520 			printf("Failed to set timeout value %u "
5521 			"for port %d, errto code: %d.\n",
5522 			bypass_timeout, port_id, rc);
5523 		}
5524 	}
5525 
5526 	/* Set the bypass event to transition to bypass mode. */
5527 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5528 					      bypass_mode);
5529 #endif
5530 
5531 	if (rc != 0)
5532 		printf("\t Failed to set bypass event for port = %d.\n",
5533 		       port_id);
5534 }
5535 
5536 cmdline_parse_token_string_t cmd_setbypass_event_set =
5537 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5538 			set, "set");
5539 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5540 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5541 			bypass, "bypass");
5542 cmdline_parse_token_string_t cmd_setbypass_event_event =
5543 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5544 			event, "event");
5545 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5546 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5547 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5548 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5549 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5550 			mode, "mode");
5551 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5552 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5553 			mode_value, "normal#bypass#isolate");
5554 cmdline_parse_token_num_t cmd_setbypass_event_port =
5555 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5556 				port_id, UINT16);
5557 
5558 cmdline_parse_inst_t cmd_set_bypass_event = {
5559 	.f = cmd_set_bypass_event_parsed,
5560 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5561 		"power_off mode normal|bypass|isolate <port_id>: "
5562 		"Set the NIC bypass event mode for port_id",
5563 	.data = NULL,
5564 	.tokens = {
5565 		(void *)&cmd_setbypass_event_set,
5566 		(void *)&cmd_setbypass_event_bypass,
5567 		(void *)&cmd_setbypass_event_event,
5568 		(void *)&cmd_setbypass_event_event_value,
5569 		(void *)&cmd_setbypass_event_mode,
5570 		(void *)&cmd_setbypass_event_mode_value,
5571 		(void *)&cmd_setbypass_event_port,
5572 		NULL,
5573 	},
5574 };
5575 
5576 
5577 /* *** SET NIC BYPASS TIMEOUT *** */
5578 struct cmd_set_bypass_timeout_result {
5579 	cmdline_fixed_string_t set;
5580 	cmdline_fixed_string_t bypass;
5581 	cmdline_fixed_string_t timeout;
5582 	cmdline_fixed_string_t value;
5583 };
5584 
5585 static void
5586 cmd_set_bypass_timeout_parsed(void *parsed_result,
5587 		__rte_unused struct cmdline *cl,
5588 		__rte_unused void *data)
5589 {
5590 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5591 
5592 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5593 	if (!strcmp(res->value, "1.5"))
5594 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5595 	else if (!strcmp(res->value, "2"))
5596 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5597 	else if (!strcmp(res->value, "3"))
5598 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5599 	else if (!strcmp(res->value, "4"))
5600 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5601 	else if (!strcmp(res->value, "8"))
5602 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5603 	else if (!strcmp(res->value, "16"))
5604 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5605 	else if (!strcmp(res->value, "32"))
5606 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5607 	else
5608 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5609 #endif
5610 }
5611 
5612 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5613 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5614 			set, "set");
5615 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5616 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5617 			bypass, "bypass");
5618 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5619 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5620 			timeout, "timeout");
5621 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5622 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5623 			value, "0#1.5#2#3#4#8#16#32");
5624 
5625 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5626 	.f = cmd_set_bypass_timeout_parsed,
5627 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5628 		"Set the NIC bypass watchdog timeout in seconds",
5629 	.data = NULL,
5630 	.tokens = {
5631 		(void *)&cmd_setbypass_timeout_set,
5632 		(void *)&cmd_setbypass_timeout_bypass,
5633 		(void *)&cmd_setbypass_timeout_timeout,
5634 		(void *)&cmd_setbypass_timeout_value,
5635 		NULL,
5636 	},
5637 };
5638 
5639 /* *** SHOW NIC BYPASS MODE *** */
5640 struct cmd_show_bypass_config_result {
5641 	cmdline_fixed_string_t show;
5642 	cmdline_fixed_string_t bypass;
5643 	cmdline_fixed_string_t config;
5644 	portid_t port_id;
5645 };
5646 
5647 static void
5648 cmd_show_bypass_config_parsed(void *parsed_result,
5649 		__rte_unused struct cmdline *cl,
5650 		__rte_unused void *data)
5651 {
5652 	struct cmd_show_bypass_config_result *res = parsed_result;
5653 	portid_t port_id = res->port_id;
5654 	int rc = -EINVAL;
5655 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5656 	uint32_t event_mode;
5657 	uint32_t bypass_mode;
5658 	uint32_t timeout = bypass_timeout;
5659 	unsigned int i;
5660 
5661 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5662 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5663 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5664 		{"UNKNOWN", "normal", "bypass", "isolate"};
5665 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5666 		"NONE",
5667 		"OS/board on",
5668 		"power supply on",
5669 		"OS/board off",
5670 		"power supply off",
5671 		"timeout"};
5672 
5673 	/* Display the bypass mode.*/
5674 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5675 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5676 		return;
5677 	}
5678 	else {
5679 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5680 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5681 
5682 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5683 	}
5684 
5685 	/* Display the bypass timeout.*/
5686 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5687 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5688 
5689 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5690 
5691 	/* Display the bypass events and associated modes. */
5692 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5693 
5694 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5695 			printf("\tFailed to get bypass mode for event = %s\n",
5696 				events[i]);
5697 		} else {
5698 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5699 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5700 
5701 			printf("\tbypass event: %-16s = %s\n", events[i],
5702 				modes[event_mode]);
5703 		}
5704 	}
5705 #endif
5706 	if (rc != 0)
5707 		printf("\tFailed to get bypass configuration for port = %d\n",
5708 		       port_id);
5709 }
5710 
5711 cmdline_parse_token_string_t cmd_showbypass_config_show =
5712 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5713 			show, "show");
5714 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5715 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5716 			bypass, "bypass");
5717 cmdline_parse_token_string_t cmd_showbypass_config_config =
5718 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5719 			config, "config");
5720 cmdline_parse_token_num_t cmd_showbypass_config_port =
5721 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5722 				port_id, UINT16);
5723 
5724 cmdline_parse_inst_t cmd_show_bypass_config = {
5725 	.f = cmd_show_bypass_config_parsed,
5726 	.help_str = "show bypass config <port_id>: "
5727 	            "Show the NIC bypass config for port_id",
5728 	.data = NULL,
5729 	.tokens = {
5730 		(void *)&cmd_showbypass_config_show,
5731 		(void *)&cmd_showbypass_config_bypass,
5732 		(void *)&cmd_showbypass_config_config,
5733 		(void *)&cmd_showbypass_config_port,
5734 		NULL,
5735 	},
5736 };
5737 
5738 #ifdef RTE_LIBRTE_PMD_BOND
5739 /* *** SET BONDING MODE *** */
5740 struct cmd_set_bonding_mode_result {
5741 	cmdline_fixed_string_t set;
5742 	cmdline_fixed_string_t bonding;
5743 	cmdline_fixed_string_t mode;
5744 	uint8_t value;
5745 	portid_t port_id;
5746 };
5747 
5748 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5749 		__rte_unused  struct cmdline *cl,
5750 		__rte_unused void *data)
5751 {
5752 	struct cmd_set_bonding_mode_result *res = parsed_result;
5753 	portid_t port_id = res->port_id;
5754 
5755 	/* Set the bonding mode for the relevant port. */
5756 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5757 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5758 }
5759 
5760 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5762 		set, "set");
5763 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5765 		bonding, "bonding");
5766 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5768 		mode, "mode");
5769 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5771 		value, UINT8);
5772 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5773 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5774 		port_id, UINT16);
5775 
5776 cmdline_parse_inst_t cmd_set_bonding_mode = {
5777 		.f = cmd_set_bonding_mode_parsed,
5778 		.help_str = "set bonding mode <mode_value> <port_id>: "
5779 			"Set the bonding mode for port_id",
5780 		.data = NULL,
5781 		.tokens = {
5782 				(void *) &cmd_setbonding_mode_set,
5783 				(void *) &cmd_setbonding_mode_bonding,
5784 				(void *) &cmd_setbonding_mode_mode,
5785 				(void *) &cmd_setbonding_mode_value,
5786 				(void *) &cmd_setbonding_mode_port,
5787 				NULL
5788 		}
5789 };
5790 
5791 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5792 struct cmd_set_bonding_lacp_dedicated_queues_result {
5793 	cmdline_fixed_string_t set;
5794 	cmdline_fixed_string_t bonding;
5795 	cmdline_fixed_string_t lacp;
5796 	cmdline_fixed_string_t dedicated_queues;
5797 	portid_t port_id;
5798 	cmdline_fixed_string_t mode;
5799 };
5800 
5801 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5802 		__rte_unused  struct cmdline *cl,
5803 		__rte_unused void *data)
5804 {
5805 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5806 	portid_t port_id = res->port_id;
5807 	struct rte_port *port;
5808 
5809 	port = &ports[port_id];
5810 
5811 	/** Check if the port is not started **/
5812 	if (port->port_status != RTE_PORT_STOPPED) {
5813 		printf("Please stop port %d first\n", port_id);
5814 		return;
5815 	}
5816 
5817 	if (!strcmp(res->mode, "enable")) {
5818 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5819 			printf("Dedicate queues for LACP control packets"
5820 					" enabled\n");
5821 		else
5822 			printf("Enabling dedicate queues for LACP control "
5823 					"packets on port %d failed\n", port_id);
5824 	} else if (!strcmp(res->mode, "disable")) {
5825 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5826 			printf("Dedicated queues for LACP control packets "
5827 					"disabled\n");
5828 		else
5829 			printf("Disabling dedicated queues for LACP control "
5830 					"traffic on port %d failed\n", port_id);
5831 	}
5832 }
5833 
5834 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5836 		set, "set");
5837 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5839 		bonding, "bonding");
5840 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5842 		lacp, "lacp");
5843 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5845 		dedicated_queues, "dedicated_queues");
5846 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5847 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5848 		port_id, UINT16);
5849 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5851 		mode, "enable#disable");
5852 
5853 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5854 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5855 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5856 			"enable|disable: "
5857 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5858 		.data = NULL,
5859 		.tokens = {
5860 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5861 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5862 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5863 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5864 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5865 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5866 			NULL
5867 		}
5868 };
5869 
5870 /* *** SET BALANCE XMIT POLICY *** */
5871 struct cmd_set_bonding_balance_xmit_policy_result {
5872 	cmdline_fixed_string_t set;
5873 	cmdline_fixed_string_t bonding;
5874 	cmdline_fixed_string_t balance_xmit_policy;
5875 	portid_t port_id;
5876 	cmdline_fixed_string_t policy;
5877 };
5878 
5879 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5880 		__rte_unused  struct cmdline *cl,
5881 		__rte_unused void *data)
5882 {
5883 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5884 	portid_t port_id = res->port_id;
5885 	uint8_t policy;
5886 
5887 	if (!strcmp(res->policy, "l2")) {
5888 		policy = BALANCE_XMIT_POLICY_LAYER2;
5889 	} else if (!strcmp(res->policy, "l23")) {
5890 		policy = BALANCE_XMIT_POLICY_LAYER23;
5891 	} else if (!strcmp(res->policy, "l34")) {
5892 		policy = BALANCE_XMIT_POLICY_LAYER34;
5893 	} else {
5894 		printf("\t Invalid xmit policy selection");
5895 		return;
5896 	}
5897 
5898 	/* Set the bonding mode for the relevant port. */
5899 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5900 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5901 				port_id);
5902 	}
5903 }
5904 
5905 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5907 		set, "set");
5908 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5910 		bonding, "bonding");
5911 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5913 		balance_xmit_policy, "balance_xmit_policy");
5914 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5915 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5916 		port_id, UINT16);
5917 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5919 		policy, "l2#l23#l34");
5920 
5921 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5922 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
5923 		.help_str = "set bonding balance_xmit_policy <port_id> "
5924 			"l2|l23|l34: "
5925 			"Set the bonding balance_xmit_policy for port_id",
5926 		.data = NULL,
5927 		.tokens = {
5928 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5929 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5930 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5931 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5932 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5933 				NULL
5934 		}
5935 };
5936 
5937 /* *** SHOW NIC BONDING CONFIGURATION *** */
5938 struct cmd_show_bonding_config_result {
5939 	cmdline_fixed_string_t show;
5940 	cmdline_fixed_string_t bonding;
5941 	cmdline_fixed_string_t config;
5942 	portid_t port_id;
5943 };
5944 
5945 static void cmd_show_bonding_config_parsed(void *parsed_result,
5946 		__rte_unused  struct cmdline *cl,
5947 		__rte_unused void *data)
5948 {
5949 	struct cmd_show_bonding_config_result *res = parsed_result;
5950 	int bonding_mode, agg_mode;
5951 	portid_t slaves[RTE_MAX_ETHPORTS];
5952 	int num_slaves, num_active_slaves;
5953 	int primary_id;
5954 	int i;
5955 	portid_t port_id = res->port_id;
5956 
5957 	/* Display the bonding mode.*/
5958 	bonding_mode = rte_eth_bond_mode_get(port_id);
5959 	if (bonding_mode < 0) {
5960 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5961 		return;
5962 	} else
5963 		printf("\tBonding mode: %d\n", bonding_mode);
5964 
5965 	if (bonding_mode == BONDING_MODE_BALANCE) {
5966 		int balance_xmit_policy;
5967 
5968 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5969 		if (balance_xmit_policy < 0) {
5970 			printf("\tFailed to get balance xmit policy for port = %d\n",
5971 					port_id);
5972 			return;
5973 		} else {
5974 			printf("\tBalance Xmit Policy: ");
5975 
5976 			switch (balance_xmit_policy) {
5977 			case BALANCE_XMIT_POLICY_LAYER2:
5978 				printf("BALANCE_XMIT_POLICY_LAYER2");
5979 				break;
5980 			case BALANCE_XMIT_POLICY_LAYER23:
5981 				printf("BALANCE_XMIT_POLICY_LAYER23");
5982 				break;
5983 			case BALANCE_XMIT_POLICY_LAYER34:
5984 				printf("BALANCE_XMIT_POLICY_LAYER34");
5985 				break;
5986 			}
5987 			printf("\n");
5988 		}
5989 	}
5990 
5991 	if (bonding_mode == BONDING_MODE_8023AD) {
5992 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5993 		printf("\tIEEE802.3AD Aggregator Mode: ");
5994 		switch (agg_mode) {
5995 		case AGG_BANDWIDTH:
5996 			printf("bandwidth");
5997 			break;
5998 		case AGG_STABLE:
5999 			printf("stable");
6000 			break;
6001 		case AGG_COUNT:
6002 			printf("count");
6003 			break;
6004 		}
6005 		printf("\n");
6006 	}
6007 
6008 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6009 
6010 	if (num_slaves < 0) {
6011 		printf("\tFailed to get slave list for port = %d\n", port_id);
6012 		return;
6013 	}
6014 	if (num_slaves > 0) {
6015 		printf("\tSlaves (%d): [", num_slaves);
6016 		for (i = 0; i < num_slaves - 1; i++)
6017 			printf("%d ", slaves[i]);
6018 
6019 		printf("%d]\n", slaves[num_slaves - 1]);
6020 	} else {
6021 		printf("\tSlaves: []\n");
6022 
6023 	}
6024 
6025 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6026 			RTE_MAX_ETHPORTS);
6027 
6028 	if (num_active_slaves < 0) {
6029 		printf("\tFailed to get active slave list for port = %d\n", port_id);
6030 		return;
6031 	}
6032 	if (num_active_slaves > 0) {
6033 		printf("\tActive Slaves (%d): [", num_active_slaves);
6034 		for (i = 0; i < num_active_slaves - 1; i++)
6035 			printf("%d ", slaves[i]);
6036 
6037 		printf("%d]\n", slaves[num_active_slaves - 1]);
6038 
6039 	} else {
6040 		printf("\tActive Slaves: []\n");
6041 
6042 	}
6043 
6044 	primary_id = rte_eth_bond_primary_get(port_id);
6045 	if (primary_id < 0) {
6046 		printf("\tFailed to get primary slave for port = %d\n", port_id);
6047 		return;
6048 	} else
6049 		printf("\tPrimary: [%d]\n", primary_id);
6050 
6051 }
6052 
6053 cmdline_parse_token_string_t cmd_showbonding_config_show =
6054 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6055 		show, "show");
6056 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6057 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6058 		bonding, "bonding");
6059 cmdline_parse_token_string_t cmd_showbonding_config_config =
6060 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6061 		config, "config");
6062 cmdline_parse_token_num_t cmd_showbonding_config_port =
6063 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6064 		port_id, UINT16);
6065 
6066 cmdline_parse_inst_t cmd_show_bonding_config = {
6067 		.f = cmd_show_bonding_config_parsed,
6068 		.help_str = "show bonding config <port_id>: "
6069 			"Show the bonding config for port_id",
6070 		.data = NULL,
6071 		.tokens = {
6072 				(void *)&cmd_showbonding_config_show,
6073 				(void *)&cmd_showbonding_config_bonding,
6074 				(void *)&cmd_showbonding_config_config,
6075 				(void *)&cmd_showbonding_config_port,
6076 				NULL
6077 		}
6078 };
6079 
6080 /* *** SET BONDING PRIMARY *** */
6081 struct cmd_set_bonding_primary_result {
6082 	cmdline_fixed_string_t set;
6083 	cmdline_fixed_string_t bonding;
6084 	cmdline_fixed_string_t primary;
6085 	portid_t slave_id;
6086 	portid_t port_id;
6087 };
6088 
6089 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6090 		__rte_unused  struct cmdline *cl,
6091 		__rte_unused void *data)
6092 {
6093 	struct cmd_set_bonding_primary_result *res = parsed_result;
6094 	portid_t master_port_id = res->port_id;
6095 	portid_t slave_port_id = res->slave_id;
6096 
6097 	/* Set the primary slave for a bonded device. */
6098 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6099 		printf("\t Failed to set primary slave for port = %d.\n",
6100 				master_port_id);
6101 		return;
6102 	}
6103 	init_port_config();
6104 }
6105 
6106 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6108 		set, "set");
6109 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6111 		bonding, "bonding");
6112 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6114 		primary, "primary");
6115 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6117 		slave_id, UINT16);
6118 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6119 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6120 		port_id, UINT16);
6121 
6122 cmdline_parse_inst_t cmd_set_bonding_primary = {
6123 		.f = cmd_set_bonding_primary_parsed,
6124 		.help_str = "set bonding primary <slave_id> <port_id>: "
6125 			"Set the primary slave for port_id",
6126 		.data = NULL,
6127 		.tokens = {
6128 				(void *)&cmd_setbonding_primary_set,
6129 				(void *)&cmd_setbonding_primary_bonding,
6130 				(void *)&cmd_setbonding_primary_primary,
6131 				(void *)&cmd_setbonding_primary_slave,
6132 				(void *)&cmd_setbonding_primary_port,
6133 				NULL
6134 		}
6135 };
6136 
6137 /* *** ADD SLAVE *** */
6138 struct cmd_add_bonding_slave_result {
6139 	cmdline_fixed_string_t add;
6140 	cmdline_fixed_string_t bonding;
6141 	cmdline_fixed_string_t slave;
6142 	portid_t slave_id;
6143 	portid_t port_id;
6144 };
6145 
6146 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6147 		__rte_unused  struct cmdline *cl,
6148 		__rte_unused void *data)
6149 {
6150 	struct cmd_add_bonding_slave_result *res = parsed_result;
6151 	portid_t master_port_id = res->port_id;
6152 	portid_t slave_port_id = res->slave_id;
6153 
6154 	/* add the slave for a bonded device. */
6155 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6156 		printf("\t Failed to add slave %d to master port = %d.\n",
6157 				slave_port_id, master_port_id);
6158 		return;
6159 	}
6160 	init_port_config();
6161 	set_port_slave_flag(slave_port_id);
6162 }
6163 
6164 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6165 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6166 		add, "add");
6167 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6168 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6169 		bonding, "bonding");
6170 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6171 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6172 		slave, "slave");
6173 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6174 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6175 		slave_id, UINT16);
6176 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6177 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6178 		port_id, UINT16);
6179 
6180 cmdline_parse_inst_t cmd_add_bonding_slave = {
6181 		.f = cmd_add_bonding_slave_parsed,
6182 		.help_str = "add bonding slave <slave_id> <port_id>: "
6183 			"Add a slave device to a bonded device",
6184 		.data = NULL,
6185 		.tokens = {
6186 				(void *)&cmd_addbonding_slave_add,
6187 				(void *)&cmd_addbonding_slave_bonding,
6188 				(void *)&cmd_addbonding_slave_slave,
6189 				(void *)&cmd_addbonding_slave_slaveid,
6190 				(void *)&cmd_addbonding_slave_port,
6191 				NULL
6192 		}
6193 };
6194 
6195 /* *** REMOVE SLAVE *** */
6196 struct cmd_remove_bonding_slave_result {
6197 	cmdline_fixed_string_t remove;
6198 	cmdline_fixed_string_t bonding;
6199 	cmdline_fixed_string_t slave;
6200 	portid_t slave_id;
6201 	portid_t port_id;
6202 };
6203 
6204 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6205 		__rte_unused  struct cmdline *cl,
6206 		__rte_unused void *data)
6207 {
6208 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6209 	portid_t master_port_id = res->port_id;
6210 	portid_t slave_port_id = res->slave_id;
6211 
6212 	/* remove the slave from a bonded device. */
6213 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6214 		printf("\t Failed to remove slave %d from master port = %d.\n",
6215 				slave_port_id, master_port_id);
6216 		return;
6217 	}
6218 	init_port_config();
6219 	clear_port_slave_flag(slave_port_id);
6220 }
6221 
6222 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6223 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6224 				remove, "remove");
6225 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6226 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6227 				bonding, "bonding");
6228 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6229 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6230 				slave, "slave");
6231 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6232 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6233 				slave_id, UINT16);
6234 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6235 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6236 				port_id, UINT16);
6237 
6238 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6239 		.f = cmd_remove_bonding_slave_parsed,
6240 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6241 			"Remove a slave device from a bonded device",
6242 		.data = NULL,
6243 		.tokens = {
6244 				(void *)&cmd_removebonding_slave_remove,
6245 				(void *)&cmd_removebonding_slave_bonding,
6246 				(void *)&cmd_removebonding_slave_slave,
6247 				(void *)&cmd_removebonding_slave_slaveid,
6248 				(void *)&cmd_removebonding_slave_port,
6249 				NULL
6250 		}
6251 };
6252 
6253 /* *** CREATE BONDED DEVICE *** */
6254 struct cmd_create_bonded_device_result {
6255 	cmdline_fixed_string_t create;
6256 	cmdline_fixed_string_t bonded;
6257 	cmdline_fixed_string_t device;
6258 	uint8_t mode;
6259 	uint8_t socket;
6260 };
6261 
6262 static int bond_dev_num = 0;
6263 
6264 static void cmd_create_bonded_device_parsed(void *parsed_result,
6265 		__rte_unused  struct cmdline *cl,
6266 		__rte_unused void *data)
6267 {
6268 	struct cmd_create_bonded_device_result *res = parsed_result;
6269 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6270 	int port_id;
6271 	int ret;
6272 
6273 	if (test_done == 0) {
6274 		printf("Please stop forwarding first\n");
6275 		return;
6276 	}
6277 
6278 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6279 			bond_dev_num++);
6280 
6281 	/* Create a new bonded device. */
6282 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6283 	if (port_id < 0) {
6284 		printf("\t Failed to create bonded device.\n");
6285 		return;
6286 	} else {
6287 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6288 				port_id);
6289 
6290 		/* Update number of ports */
6291 		nb_ports = rte_eth_dev_count_avail();
6292 		reconfig(port_id, res->socket);
6293 		ret = rte_eth_promiscuous_enable(port_id);
6294 		if (ret != 0)
6295 			printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6296 				port_id, rte_strerror(-ret));
6297 
6298 		ports[port_id].need_setup = 0;
6299 		ports[port_id].port_status = RTE_PORT_STOPPED;
6300 	}
6301 
6302 }
6303 
6304 cmdline_parse_token_string_t cmd_createbonded_device_create =
6305 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6306 				create, "create");
6307 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6308 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6309 				bonded, "bonded");
6310 cmdline_parse_token_string_t cmd_createbonded_device_device =
6311 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6312 				device, "device");
6313 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6314 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6315 				mode, UINT8);
6316 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6317 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6318 				socket, UINT8);
6319 
6320 cmdline_parse_inst_t cmd_create_bonded_device = {
6321 		.f = cmd_create_bonded_device_parsed,
6322 		.help_str = "create bonded device <mode> <socket>: "
6323 			"Create a new bonded device with specific bonding mode and socket",
6324 		.data = NULL,
6325 		.tokens = {
6326 				(void *)&cmd_createbonded_device_create,
6327 				(void *)&cmd_createbonded_device_bonded,
6328 				(void *)&cmd_createbonded_device_device,
6329 				(void *)&cmd_createbonded_device_mode,
6330 				(void *)&cmd_createbonded_device_socket,
6331 				NULL
6332 		}
6333 };
6334 
6335 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6336 struct cmd_set_bond_mac_addr_result {
6337 	cmdline_fixed_string_t set;
6338 	cmdline_fixed_string_t bonding;
6339 	cmdline_fixed_string_t mac_addr;
6340 	uint16_t port_num;
6341 	struct rte_ether_addr address;
6342 };
6343 
6344 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6345 		__rte_unused  struct cmdline *cl,
6346 		__rte_unused void *data)
6347 {
6348 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6349 	int ret;
6350 
6351 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6352 		return;
6353 
6354 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6355 
6356 	/* check the return value and print it if is < 0 */
6357 	if (ret < 0)
6358 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6359 }
6360 
6361 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6362 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6363 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6364 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6365 				"bonding");
6366 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6367 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6368 				"mac_addr");
6369 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6370 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6371 				port_num, UINT16);
6372 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6373 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6374 
6375 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6376 		.f = cmd_set_bond_mac_addr_parsed,
6377 		.data = (void *) 0,
6378 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6379 		.tokens = {
6380 				(void *)&cmd_set_bond_mac_addr_set,
6381 				(void *)&cmd_set_bond_mac_addr_bonding,
6382 				(void *)&cmd_set_bond_mac_addr_mac,
6383 				(void *)&cmd_set_bond_mac_addr_portnum,
6384 				(void *)&cmd_set_bond_mac_addr_addr,
6385 				NULL
6386 		}
6387 };
6388 
6389 
6390 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6391 struct cmd_set_bond_mon_period_result {
6392 	cmdline_fixed_string_t set;
6393 	cmdline_fixed_string_t bonding;
6394 	cmdline_fixed_string_t mon_period;
6395 	uint16_t port_num;
6396 	uint32_t period_ms;
6397 };
6398 
6399 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6400 		__rte_unused  struct cmdline *cl,
6401 		__rte_unused void *data)
6402 {
6403 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6404 	int ret;
6405 
6406 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6407 
6408 	/* check the return value and print it if is < 0 */
6409 	if (ret < 0)
6410 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6411 }
6412 
6413 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6414 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6415 				set, "set");
6416 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6417 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6418 				bonding, "bonding");
6419 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6420 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6421 				mon_period,	"mon_period");
6422 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6423 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6424 				port_num, UINT16);
6425 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6426 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6427 				period_ms, UINT32);
6428 
6429 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6430 		.f = cmd_set_bond_mon_period_parsed,
6431 		.data = (void *) 0,
6432 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6433 		.tokens = {
6434 				(void *)&cmd_set_bond_mon_period_set,
6435 				(void *)&cmd_set_bond_mon_period_bonding,
6436 				(void *)&cmd_set_bond_mon_period_mon_period,
6437 				(void *)&cmd_set_bond_mon_period_portnum,
6438 				(void *)&cmd_set_bond_mon_period_period_ms,
6439 				NULL
6440 		}
6441 };
6442 
6443 
6444 
6445 struct cmd_set_bonding_agg_mode_policy_result {
6446 	cmdline_fixed_string_t set;
6447 	cmdline_fixed_string_t bonding;
6448 	cmdline_fixed_string_t agg_mode;
6449 	uint16_t port_num;
6450 	cmdline_fixed_string_t policy;
6451 };
6452 
6453 
6454 static void
6455 cmd_set_bonding_agg_mode(void *parsed_result,
6456 		__rte_unused struct cmdline *cl,
6457 		__rte_unused void *data)
6458 {
6459 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6460 	uint8_t policy = AGG_BANDWIDTH;
6461 
6462 	if (!strcmp(res->policy, "bandwidth"))
6463 		policy = AGG_BANDWIDTH;
6464 	else if (!strcmp(res->policy, "stable"))
6465 		policy = AGG_STABLE;
6466 	else if (!strcmp(res->policy, "count"))
6467 		policy = AGG_COUNT;
6468 
6469 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6470 }
6471 
6472 
6473 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6474 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6475 				set, "set");
6476 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6477 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6478 				bonding, "bonding");
6479 
6480 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6481 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6482 				agg_mode, "agg_mode");
6483 
6484 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6485 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6486 				port_num, UINT16);
6487 
6488 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6489 	TOKEN_STRING_INITIALIZER(
6490 			struct cmd_set_bonding_balance_xmit_policy_result,
6491 		policy, "stable#bandwidth#count");
6492 
6493 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6494 	.f = cmd_set_bonding_agg_mode,
6495 	.data = (void *) 0,
6496 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6497 	.tokens = {
6498 			(void *)&cmd_set_bonding_agg_mode_set,
6499 			(void *)&cmd_set_bonding_agg_mode_bonding,
6500 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6501 			(void *)&cmd_set_bonding_agg_mode_portnum,
6502 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6503 			NULL
6504 		}
6505 };
6506 
6507 
6508 #endif /* RTE_LIBRTE_PMD_BOND */
6509 
6510 /* *** SET FORWARDING MODE *** */
6511 struct cmd_set_fwd_mode_result {
6512 	cmdline_fixed_string_t set;
6513 	cmdline_fixed_string_t fwd;
6514 	cmdline_fixed_string_t mode;
6515 };
6516 
6517 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6518 				    __rte_unused struct cmdline *cl,
6519 				    __rte_unused void *data)
6520 {
6521 	struct cmd_set_fwd_mode_result *res = parsed_result;
6522 
6523 	retry_enabled = 0;
6524 	set_pkt_forwarding_mode(res->mode);
6525 }
6526 
6527 cmdline_parse_token_string_t cmd_setfwd_set =
6528 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6529 cmdline_parse_token_string_t cmd_setfwd_fwd =
6530 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6531 cmdline_parse_token_string_t cmd_setfwd_mode =
6532 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6533 		"" /* defined at init */);
6534 
6535 cmdline_parse_inst_t cmd_set_fwd_mode = {
6536 	.f = cmd_set_fwd_mode_parsed,
6537 	.data = NULL,
6538 	.help_str = NULL, /* defined at init */
6539 	.tokens = {
6540 		(void *)&cmd_setfwd_set,
6541 		(void *)&cmd_setfwd_fwd,
6542 		(void *)&cmd_setfwd_mode,
6543 		NULL,
6544 	},
6545 };
6546 
6547 static void cmd_set_fwd_mode_init(void)
6548 {
6549 	char *modes, *c;
6550 	static char token[128];
6551 	static char help[256];
6552 	cmdline_parse_token_string_t *token_struct;
6553 
6554 	modes = list_pkt_forwarding_modes();
6555 	snprintf(help, sizeof(help), "set fwd %s: "
6556 		"Set packet forwarding mode", modes);
6557 	cmd_set_fwd_mode.help_str = help;
6558 
6559 	/* string token separator is # */
6560 	for (c = token; *modes != '\0'; modes++)
6561 		if (*modes == '|')
6562 			*c++ = '#';
6563 		else
6564 			*c++ = *modes;
6565 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6566 	token_struct->string_data.str = token;
6567 }
6568 
6569 /* *** SET RETRY FORWARDING MODE *** */
6570 struct cmd_set_fwd_retry_mode_result {
6571 	cmdline_fixed_string_t set;
6572 	cmdline_fixed_string_t fwd;
6573 	cmdline_fixed_string_t mode;
6574 	cmdline_fixed_string_t retry;
6575 };
6576 
6577 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6578 			    __rte_unused struct cmdline *cl,
6579 			    __rte_unused void *data)
6580 {
6581 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6582 
6583 	retry_enabled = 1;
6584 	set_pkt_forwarding_mode(res->mode);
6585 }
6586 
6587 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6588 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6589 			set, "set");
6590 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6591 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6592 			fwd, "fwd");
6593 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6594 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6595 			mode,
6596 		"" /* defined at init */);
6597 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6598 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6599 			retry, "retry");
6600 
6601 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6602 	.f = cmd_set_fwd_retry_mode_parsed,
6603 	.data = NULL,
6604 	.help_str = NULL, /* defined at init */
6605 	.tokens = {
6606 		(void *)&cmd_setfwd_retry_set,
6607 		(void *)&cmd_setfwd_retry_fwd,
6608 		(void *)&cmd_setfwd_retry_mode,
6609 		(void *)&cmd_setfwd_retry_retry,
6610 		NULL,
6611 	},
6612 };
6613 
6614 static void cmd_set_fwd_retry_mode_init(void)
6615 {
6616 	char *modes, *c;
6617 	static char token[128];
6618 	static char help[256];
6619 	cmdline_parse_token_string_t *token_struct;
6620 
6621 	modes = list_pkt_forwarding_retry_modes();
6622 	snprintf(help, sizeof(help), "set fwd %s retry: "
6623 		"Set packet forwarding mode with retry", modes);
6624 	cmd_set_fwd_retry_mode.help_str = help;
6625 
6626 	/* string token separator is # */
6627 	for (c = token; *modes != '\0'; modes++)
6628 		if (*modes == '|')
6629 			*c++ = '#';
6630 		else
6631 			*c++ = *modes;
6632 	token_struct = (cmdline_parse_token_string_t *)
6633 		cmd_set_fwd_retry_mode.tokens[2];
6634 	token_struct->string_data.str = token;
6635 }
6636 
6637 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6638 struct cmd_set_burst_tx_retry_result {
6639 	cmdline_fixed_string_t set;
6640 	cmdline_fixed_string_t burst;
6641 	cmdline_fixed_string_t tx;
6642 	cmdline_fixed_string_t delay;
6643 	uint32_t time;
6644 	cmdline_fixed_string_t retry;
6645 	uint32_t retry_num;
6646 };
6647 
6648 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6649 					__rte_unused struct cmdline *cl,
6650 					__rte_unused void *data)
6651 {
6652 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6653 
6654 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6655 		&& !strcmp(res->tx, "tx")) {
6656 		if (!strcmp(res->delay, "delay"))
6657 			burst_tx_delay_time = res->time;
6658 		if (!strcmp(res->retry, "retry"))
6659 			burst_tx_retry_num = res->retry_num;
6660 	}
6661 
6662 }
6663 
6664 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6665 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6666 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6667 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6668 				 "burst");
6669 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6670 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6671 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6672 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6673 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6674 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6675 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6676 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6677 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6678 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6679 
6680 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6681 	.f = cmd_set_burst_tx_retry_parsed,
6682 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6683 	.tokens = {
6684 		(void *)&cmd_set_burst_tx_retry_set,
6685 		(void *)&cmd_set_burst_tx_retry_burst,
6686 		(void *)&cmd_set_burst_tx_retry_tx,
6687 		(void *)&cmd_set_burst_tx_retry_delay,
6688 		(void *)&cmd_set_burst_tx_retry_time,
6689 		(void *)&cmd_set_burst_tx_retry_retry,
6690 		(void *)&cmd_set_burst_tx_retry_retry_num,
6691 		NULL,
6692 	},
6693 };
6694 
6695 /* *** SET PROMISC MODE *** */
6696 struct cmd_set_promisc_mode_result {
6697 	cmdline_fixed_string_t set;
6698 	cmdline_fixed_string_t promisc;
6699 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6700 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6701 	cmdline_fixed_string_t mode;
6702 };
6703 
6704 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6705 					__rte_unused struct cmdline *cl,
6706 					void *allports)
6707 {
6708 	struct cmd_set_promisc_mode_result *res = parsed_result;
6709 	int enable;
6710 	portid_t i;
6711 
6712 	if (!strcmp(res->mode, "on"))
6713 		enable = 1;
6714 	else
6715 		enable = 0;
6716 
6717 	/* all ports */
6718 	if (allports) {
6719 		RTE_ETH_FOREACH_DEV(i)
6720 			eth_set_promisc_mode(i, enable);
6721 	} else {
6722 		eth_set_promisc_mode(res->port_num, enable);
6723 	}
6724 }
6725 
6726 cmdline_parse_token_string_t cmd_setpromisc_set =
6727 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6728 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6729 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6730 				 "promisc");
6731 cmdline_parse_token_string_t cmd_setpromisc_portall =
6732 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6733 				 "all");
6734 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6735 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6736 			      UINT16);
6737 cmdline_parse_token_string_t cmd_setpromisc_mode =
6738 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6739 				 "on#off");
6740 
6741 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6742 	.f = cmd_set_promisc_mode_parsed,
6743 	.data = (void *)1,
6744 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6745 	.tokens = {
6746 		(void *)&cmd_setpromisc_set,
6747 		(void *)&cmd_setpromisc_promisc,
6748 		(void *)&cmd_setpromisc_portall,
6749 		(void *)&cmd_setpromisc_mode,
6750 		NULL,
6751 	},
6752 };
6753 
6754 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6755 	.f = cmd_set_promisc_mode_parsed,
6756 	.data = (void *)0,
6757 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6758 	.tokens = {
6759 		(void *)&cmd_setpromisc_set,
6760 		(void *)&cmd_setpromisc_promisc,
6761 		(void *)&cmd_setpromisc_portnum,
6762 		(void *)&cmd_setpromisc_mode,
6763 		NULL,
6764 	},
6765 };
6766 
6767 /* *** SET ALLMULTI MODE *** */
6768 struct cmd_set_allmulti_mode_result {
6769 	cmdline_fixed_string_t set;
6770 	cmdline_fixed_string_t allmulti;
6771 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6772 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6773 	cmdline_fixed_string_t mode;
6774 };
6775 
6776 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6777 					__rte_unused struct cmdline *cl,
6778 					void *allports)
6779 {
6780 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6781 	int enable;
6782 	portid_t i;
6783 
6784 	if (!strcmp(res->mode, "on"))
6785 		enable = 1;
6786 	else
6787 		enable = 0;
6788 
6789 	/* all ports */
6790 	if (allports) {
6791 		RTE_ETH_FOREACH_DEV(i) {
6792 			eth_set_allmulticast_mode(i, enable);
6793 		}
6794 	}
6795 	else {
6796 		eth_set_allmulticast_mode(res->port_num, enable);
6797 	}
6798 }
6799 
6800 cmdline_parse_token_string_t cmd_setallmulti_set =
6801 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6802 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6803 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6804 				 "allmulti");
6805 cmdline_parse_token_string_t cmd_setallmulti_portall =
6806 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6807 				 "all");
6808 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6809 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6810 			      UINT16);
6811 cmdline_parse_token_string_t cmd_setallmulti_mode =
6812 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6813 				 "on#off");
6814 
6815 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6816 	.f = cmd_set_allmulti_mode_parsed,
6817 	.data = (void *)1,
6818 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6819 	.tokens = {
6820 		(void *)&cmd_setallmulti_set,
6821 		(void *)&cmd_setallmulti_allmulti,
6822 		(void *)&cmd_setallmulti_portall,
6823 		(void *)&cmd_setallmulti_mode,
6824 		NULL,
6825 	},
6826 };
6827 
6828 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6829 	.f = cmd_set_allmulti_mode_parsed,
6830 	.data = (void *)0,
6831 	.help_str = "set allmulti <port_id> on|off: "
6832 		"Set allmulti mode on port_id",
6833 	.tokens = {
6834 		(void *)&cmd_setallmulti_set,
6835 		(void *)&cmd_setallmulti_allmulti,
6836 		(void *)&cmd_setallmulti_portnum,
6837 		(void *)&cmd_setallmulti_mode,
6838 		NULL,
6839 	},
6840 };
6841 
6842 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6843 struct cmd_link_flow_ctrl_set_result {
6844 	cmdline_fixed_string_t set;
6845 	cmdline_fixed_string_t flow_ctrl;
6846 	cmdline_fixed_string_t rx;
6847 	cmdline_fixed_string_t rx_lfc_mode;
6848 	cmdline_fixed_string_t tx;
6849 	cmdline_fixed_string_t tx_lfc_mode;
6850 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6851 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6852 	cmdline_fixed_string_t autoneg_str;
6853 	cmdline_fixed_string_t autoneg;
6854 	cmdline_fixed_string_t hw_str;
6855 	uint32_t high_water;
6856 	cmdline_fixed_string_t lw_str;
6857 	uint32_t low_water;
6858 	cmdline_fixed_string_t pt_str;
6859 	uint16_t pause_time;
6860 	cmdline_fixed_string_t xon_str;
6861 	uint16_t send_xon;
6862 	portid_t port_id;
6863 };
6864 
6865 cmdline_parse_token_string_t cmd_lfc_set_set =
6866 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6867 				set, "set");
6868 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6869 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6870 				flow_ctrl, "flow_ctrl");
6871 cmdline_parse_token_string_t cmd_lfc_set_rx =
6872 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6873 				rx, "rx");
6874 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6875 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6876 				rx_lfc_mode, "on#off");
6877 cmdline_parse_token_string_t cmd_lfc_set_tx =
6878 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6879 				tx, "tx");
6880 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6881 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6882 				tx_lfc_mode, "on#off");
6883 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6884 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 				hw_str, "high_water");
6886 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6887 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6888 				high_water, UINT32);
6889 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6890 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6891 				lw_str, "low_water");
6892 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6893 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6894 				low_water, UINT32);
6895 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6896 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 				pt_str, "pause_time");
6898 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6899 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 				pause_time, UINT16);
6901 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6902 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6903 				xon_str, "send_xon");
6904 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6905 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 				send_xon, UINT16);
6907 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6908 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6910 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6911 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 				mac_ctrl_frame_fwd_mode, "on#off");
6913 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6914 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 				autoneg_str, "autoneg");
6916 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6917 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6918 				autoneg, "on#off");
6919 cmdline_parse_token_num_t cmd_lfc_set_portid =
6920 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6921 				port_id, UINT16);
6922 
6923 /* forward declaration */
6924 static void
6925 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6926 			      void *data);
6927 
6928 cmdline_parse_inst_t cmd_link_flow_control_set = {
6929 	.f = cmd_link_flow_ctrl_set_parsed,
6930 	.data = NULL,
6931 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6932 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6933 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6934 	.tokens = {
6935 		(void *)&cmd_lfc_set_set,
6936 		(void *)&cmd_lfc_set_flow_ctrl,
6937 		(void *)&cmd_lfc_set_rx,
6938 		(void *)&cmd_lfc_set_rx_mode,
6939 		(void *)&cmd_lfc_set_tx,
6940 		(void *)&cmd_lfc_set_tx_mode,
6941 		(void *)&cmd_lfc_set_high_water,
6942 		(void *)&cmd_lfc_set_low_water,
6943 		(void *)&cmd_lfc_set_pause_time,
6944 		(void *)&cmd_lfc_set_send_xon,
6945 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6946 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6947 		(void *)&cmd_lfc_set_autoneg_str,
6948 		(void *)&cmd_lfc_set_autoneg,
6949 		(void *)&cmd_lfc_set_portid,
6950 		NULL,
6951 	},
6952 };
6953 
6954 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6955 	.f = cmd_link_flow_ctrl_set_parsed,
6956 	.data = (void *)&cmd_link_flow_control_set_rx,
6957 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6958 		"Change rx flow control parameter",
6959 	.tokens = {
6960 		(void *)&cmd_lfc_set_set,
6961 		(void *)&cmd_lfc_set_flow_ctrl,
6962 		(void *)&cmd_lfc_set_rx,
6963 		(void *)&cmd_lfc_set_rx_mode,
6964 		(void *)&cmd_lfc_set_portid,
6965 		NULL,
6966 	},
6967 };
6968 
6969 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6970 	.f = cmd_link_flow_ctrl_set_parsed,
6971 	.data = (void *)&cmd_link_flow_control_set_tx,
6972 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6973 		"Change tx flow control parameter",
6974 	.tokens = {
6975 		(void *)&cmd_lfc_set_set,
6976 		(void *)&cmd_lfc_set_flow_ctrl,
6977 		(void *)&cmd_lfc_set_tx,
6978 		(void *)&cmd_lfc_set_tx_mode,
6979 		(void *)&cmd_lfc_set_portid,
6980 		NULL,
6981 	},
6982 };
6983 
6984 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6985 	.f = cmd_link_flow_ctrl_set_parsed,
6986 	.data = (void *)&cmd_link_flow_control_set_hw,
6987 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6988 		"Change high water flow control parameter",
6989 	.tokens = {
6990 		(void *)&cmd_lfc_set_set,
6991 		(void *)&cmd_lfc_set_flow_ctrl,
6992 		(void *)&cmd_lfc_set_high_water_str,
6993 		(void *)&cmd_lfc_set_high_water,
6994 		(void *)&cmd_lfc_set_portid,
6995 		NULL,
6996 	},
6997 };
6998 
6999 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7000 	.f = cmd_link_flow_ctrl_set_parsed,
7001 	.data = (void *)&cmd_link_flow_control_set_lw,
7002 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
7003 		"Change low water flow control parameter",
7004 	.tokens = {
7005 		(void *)&cmd_lfc_set_set,
7006 		(void *)&cmd_lfc_set_flow_ctrl,
7007 		(void *)&cmd_lfc_set_low_water_str,
7008 		(void *)&cmd_lfc_set_low_water,
7009 		(void *)&cmd_lfc_set_portid,
7010 		NULL,
7011 	},
7012 };
7013 
7014 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7015 	.f = cmd_link_flow_ctrl_set_parsed,
7016 	.data = (void *)&cmd_link_flow_control_set_pt,
7017 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
7018 		"Change pause time flow control parameter",
7019 	.tokens = {
7020 		(void *)&cmd_lfc_set_set,
7021 		(void *)&cmd_lfc_set_flow_ctrl,
7022 		(void *)&cmd_lfc_set_pause_time_str,
7023 		(void *)&cmd_lfc_set_pause_time,
7024 		(void *)&cmd_lfc_set_portid,
7025 		NULL,
7026 	},
7027 };
7028 
7029 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7030 	.f = cmd_link_flow_ctrl_set_parsed,
7031 	.data = (void *)&cmd_link_flow_control_set_xon,
7032 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
7033 		"Change send_xon flow control parameter",
7034 	.tokens = {
7035 		(void *)&cmd_lfc_set_set,
7036 		(void *)&cmd_lfc_set_flow_ctrl,
7037 		(void *)&cmd_lfc_set_send_xon_str,
7038 		(void *)&cmd_lfc_set_send_xon,
7039 		(void *)&cmd_lfc_set_portid,
7040 		NULL,
7041 	},
7042 };
7043 
7044 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7045 	.f = cmd_link_flow_ctrl_set_parsed,
7046 	.data = (void *)&cmd_link_flow_control_set_macfwd,
7047 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7048 		"Change mac ctrl fwd flow control parameter",
7049 	.tokens = {
7050 		(void *)&cmd_lfc_set_set,
7051 		(void *)&cmd_lfc_set_flow_ctrl,
7052 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7053 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7054 		(void *)&cmd_lfc_set_portid,
7055 		NULL,
7056 	},
7057 };
7058 
7059 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7060 	.f = cmd_link_flow_ctrl_set_parsed,
7061 	.data = (void *)&cmd_link_flow_control_set_autoneg,
7062 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
7063 		"Change autoneg flow control parameter",
7064 	.tokens = {
7065 		(void *)&cmd_lfc_set_set,
7066 		(void *)&cmd_lfc_set_flow_ctrl,
7067 		(void *)&cmd_lfc_set_autoneg_str,
7068 		(void *)&cmd_lfc_set_autoneg,
7069 		(void *)&cmd_lfc_set_portid,
7070 		NULL,
7071 	},
7072 };
7073 
7074 static void
7075 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7076 			      __rte_unused struct cmdline *cl,
7077 			      void *data)
7078 {
7079 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7080 	cmdline_parse_inst_t *cmd = data;
7081 	struct rte_eth_fc_conf fc_conf;
7082 	int rx_fc_en = 0;
7083 	int tx_fc_en = 0;
7084 	int ret;
7085 
7086 	/*
7087 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7088 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7089 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7090 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7091 	 */
7092 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7093 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7094 	};
7095 
7096 	/* Partial command line, retrieve current configuration */
7097 	if (cmd) {
7098 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7099 		if (ret != 0) {
7100 			printf("cannot get current flow ctrl parameters, return"
7101 			       "code = %d\n", ret);
7102 			return;
7103 		}
7104 
7105 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7106 		    (fc_conf.mode == RTE_FC_FULL))
7107 			rx_fc_en = 1;
7108 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7109 		    (fc_conf.mode == RTE_FC_FULL))
7110 			tx_fc_en = 1;
7111 	}
7112 
7113 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7114 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7115 
7116 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7117 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7118 
7119 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7120 
7121 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7122 		fc_conf.high_water = res->high_water;
7123 
7124 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7125 		fc_conf.low_water = res->low_water;
7126 
7127 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7128 		fc_conf.pause_time = res->pause_time;
7129 
7130 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7131 		fc_conf.send_xon = res->send_xon;
7132 
7133 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7134 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7135 			fc_conf.mac_ctrl_frame_fwd = 1;
7136 		else
7137 			fc_conf.mac_ctrl_frame_fwd = 0;
7138 	}
7139 
7140 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7141 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7142 
7143 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7144 	if (ret != 0)
7145 		printf("bad flow contrl parameter, return code = %d \n", ret);
7146 }
7147 
7148 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7149 struct cmd_priority_flow_ctrl_set_result {
7150 	cmdline_fixed_string_t set;
7151 	cmdline_fixed_string_t pfc_ctrl;
7152 	cmdline_fixed_string_t rx;
7153 	cmdline_fixed_string_t rx_pfc_mode;
7154 	cmdline_fixed_string_t tx;
7155 	cmdline_fixed_string_t tx_pfc_mode;
7156 	uint32_t high_water;
7157 	uint32_t low_water;
7158 	uint16_t pause_time;
7159 	uint8_t  priority;
7160 	portid_t port_id;
7161 };
7162 
7163 static void
7164 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7165 		       __rte_unused struct cmdline *cl,
7166 		       __rte_unused void *data)
7167 {
7168 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7169 	struct rte_eth_pfc_conf pfc_conf;
7170 	int rx_fc_enable, tx_fc_enable;
7171 	int ret;
7172 
7173 	/*
7174 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7175 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7176 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7177 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7178 	 */
7179 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7180 		{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7181 	};
7182 
7183 	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7184 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7185 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7186 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7187 	pfc_conf.fc.high_water = res->high_water;
7188 	pfc_conf.fc.low_water  = res->low_water;
7189 	pfc_conf.fc.pause_time = res->pause_time;
7190 	pfc_conf.priority      = res->priority;
7191 
7192 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7193 	if (ret != 0)
7194 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7195 }
7196 
7197 cmdline_parse_token_string_t cmd_pfc_set_set =
7198 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7199 				set, "set");
7200 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7201 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7202 				pfc_ctrl, "pfc_ctrl");
7203 cmdline_parse_token_string_t cmd_pfc_set_rx =
7204 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7205 				rx, "rx");
7206 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7207 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7208 				rx_pfc_mode, "on#off");
7209 cmdline_parse_token_string_t cmd_pfc_set_tx =
7210 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7211 				tx, "tx");
7212 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7213 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7214 				tx_pfc_mode, "on#off");
7215 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7216 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7217 				high_water, UINT32);
7218 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7219 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7220 				low_water, UINT32);
7221 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7222 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7223 				pause_time, UINT16);
7224 cmdline_parse_token_num_t cmd_pfc_set_priority =
7225 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7226 				priority, UINT8);
7227 cmdline_parse_token_num_t cmd_pfc_set_portid =
7228 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7229 				port_id, UINT16);
7230 
7231 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7232 	.f = cmd_priority_flow_ctrl_set_parsed,
7233 	.data = NULL,
7234 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7235 		"<pause_time> <priority> <port_id>: "
7236 		"Configure the Ethernet priority flow control",
7237 	.tokens = {
7238 		(void *)&cmd_pfc_set_set,
7239 		(void *)&cmd_pfc_set_flow_ctrl,
7240 		(void *)&cmd_pfc_set_rx,
7241 		(void *)&cmd_pfc_set_rx_mode,
7242 		(void *)&cmd_pfc_set_tx,
7243 		(void *)&cmd_pfc_set_tx_mode,
7244 		(void *)&cmd_pfc_set_high_water,
7245 		(void *)&cmd_pfc_set_low_water,
7246 		(void *)&cmd_pfc_set_pause_time,
7247 		(void *)&cmd_pfc_set_priority,
7248 		(void *)&cmd_pfc_set_portid,
7249 		NULL,
7250 	},
7251 };
7252 
7253 /* *** RESET CONFIGURATION *** */
7254 struct cmd_reset_result {
7255 	cmdline_fixed_string_t reset;
7256 	cmdline_fixed_string_t def;
7257 };
7258 
7259 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7260 			     struct cmdline *cl,
7261 			     __rte_unused void *data)
7262 {
7263 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7264 	set_def_fwd_config();
7265 }
7266 
7267 cmdline_parse_token_string_t cmd_reset_set =
7268 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7269 cmdline_parse_token_string_t cmd_reset_def =
7270 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7271 				 "default");
7272 
7273 cmdline_parse_inst_t cmd_reset = {
7274 	.f = cmd_reset_parsed,
7275 	.data = NULL,
7276 	.help_str = "set default: Reset default forwarding configuration",
7277 	.tokens = {
7278 		(void *)&cmd_reset_set,
7279 		(void *)&cmd_reset_def,
7280 		NULL,
7281 	},
7282 };
7283 
7284 /* *** START FORWARDING *** */
7285 struct cmd_start_result {
7286 	cmdline_fixed_string_t start;
7287 };
7288 
7289 cmdline_parse_token_string_t cmd_start_start =
7290 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7291 
7292 static void cmd_start_parsed(__rte_unused void *parsed_result,
7293 			     __rte_unused struct cmdline *cl,
7294 			     __rte_unused void *data)
7295 {
7296 	start_packet_forwarding(0);
7297 }
7298 
7299 cmdline_parse_inst_t cmd_start = {
7300 	.f = cmd_start_parsed,
7301 	.data = NULL,
7302 	.help_str = "start: Start packet forwarding",
7303 	.tokens = {
7304 		(void *)&cmd_start_start,
7305 		NULL,
7306 	},
7307 };
7308 
7309 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7310 struct cmd_start_tx_first_result {
7311 	cmdline_fixed_string_t start;
7312 	cmdline_fixed_string_t tx_first;
7313 };
7314 
7315 static void
7316 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7317 			  __rte_unused struct cmdline *cl,
7318 			  __rte_unused void *data)
7319 {
7320 	start_packet_forwarding(1);
7321 }
7322 
7323 cmdline_parse_token_string_t cmd_start_tx_first_start =
7324 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7325 				 "start");
7326 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7327 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7328 				 tx_first, "tx_first");
7329 
7330 cmdline_parse_inst_t cmd_start_tx_first = {
7331 	.f = cmd_start_tx_first_parsed,
7332 	.data = NULL,
7333 	.help_str = "start tx_first: Start packet forwarding, "
7334 		"after sending 1 burst of packets",
7335 	.tokens = {
7336 		(void *)&cmd_start_tx_first_start,
7337 		(void *)&cmd_start_tx_first_tx_first,
7338 		NULL,
7339 	},
7340 };
7341 
7342 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7343 struct cmd_start_tx_first_n_result {
7344 	cmdline_fixed_string_t start;
7345 	cmdline_fixed_string_t tx_first;
7346 	uint32_t tx_num;
7347 };
7348 
7349 static void
7350 cmd_start_tx_first_n_parsed(void *parsed_result,
7351 			  __rte_unused struct cmdline *cl,
7352 			  __rte_unused void *data)
7353 {
7354 	struct cmd_start_tx_first_n_result *res = parsed_result;
7355 
7356 	start_packet_forwarding(res->tx_num);
7357 }
7358 
7359 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7360 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7361 			start, "start");
7362 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7363 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7364 			tx_first, "tx_first");
7365 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7366 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7367 			tx_num, UINT32);
7368 
7369 cmdline_parse_inst_t cmd_start_tx_first_n = {
7370 	.f = cmd_start_tx_first_n_parsed,
7371 	.data = NULL,
7372 	.help_str = "start tx_first <num>: "
7373 		"packet forwarding, after sending <num> bursts of packets",
7374 	.tokens = {
7375 		(void *)&cmd_start_tx_first_n_start,
7376 		(void *)&cmd_start_tx_first_n_tx_first,
7377 		(void *)&cmd_start_tx_first_n_tx_num,
7378 		NULL,
7379 	},
7380 };
7381 
7382 /* *** SET LINK UP *** */
7383 struct cmd_set_link_up_result {
7384 	cmdline_fixed_string_t set;
7385 	cmdline_fixed_string_t link_up;
7386 	cmdline_fixed_string_t port;
7387 	portid_t port_id;
7388 };
7389 
7390 cmdline_parse_token_string_t cmd_set_link_up_set =
7391 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7392 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7393 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7394 				"link-up");
7395 cmdline_parse_token_string_t cmd_set_link_up_port =
7396 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7397 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7398 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7399 
7400 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7401 			     __rte_unused struct cmdline *cl,
7402 			     __rte_unused void *data)
7403 {
7404 	struct cmd_set_link_up_result *res = parsed_result;
7405 	dev_set_link_up(res->port_id);
7406 }
7407 
7408 cmdline_parse_inst_t cmd_set_link_up = {
7409 	.f = cmd_set_link_up_parsed,
7410 	.data = NULL,
7411 	.help_str = "set link-up port <port id>",
7412 	.tokens = {
7413 		(void *)&cmd_set_link_up_set,
7414 		(void *)&cmd_set_link_up_link_up,
7415 		(void *)&cmd_set_link_up_port,
7416 		(void *)&cmd_set_link_up_port_id,
7417 		NULL,
7418 	},
7419 };
7420 
7421 /* *** SET LINK DOWN *** */
7422 struct cmd_set_link_down_result {
7423 	cmdline_fixed_string_t set;
7424 	cmdline_fixed_string_t link_down;
7425 	cmdline_fixed_string_t port;
7426 	portid_t port_id;
7427 };
7428 
7429 cmdline_parse_token_string_t cmd_set_link_down_set =
7430 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7431 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7432 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7433 				"link-down");
7434 cmdline_parse_token_string_t cmd_set_link_down_port =
7435 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7436 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7437 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7438 
7439 static void cmd_set_link_down_parsed(
7440 				__rte_unused void *parsed_result,
7441 				__rte_unused struct cmdline *cl,
7442 				__rte_unused void *data)
7443 {
7444 	struct cmd_set_link_down_result *res = parsed_result;
7445 	dev_set_link_down(res->port_id);
7446 }
7447 
7448 cmdline_parse_inst_t cmd_set_link_down = {
7449 	.f = cmd_set_link_down_parsed,
7450 	.data = NULL,
7451 	.help_str = "set link-down port <port id>",
7452 	.tokens = {
7453 		(void *)&cmd_set_link_down_set,
7454 		(void *)&cmd_set_link_down_link_down,
7455 		(void *)&cmd_set_link_down_port,
7456 		(void *)&cmd_set_link_down_port_id,
7457 		NULL,
7458 	},
7459 };
7460 
7461 /* *** SHOW CFG *** */
7462 struct cmd_showcfg_result {
7463 	cmdline_fixed_string_t show;
7464 	cmdline_fixed_string_t cfg;
7465 	cmdline_fixed_string_t what;
7466 };
7467 
7468 static void cmd_showcfg_parsed(void *parsed_result,
7469 			       __rte_unused struct cmdline *cl,
7470 			       __rte_unused void *data)
7471 {
7472 	struct cmd_showcfg_result *res = parsed_result;
7473 	if (!strcmp(res->what, "rxtx"))
7474 		rxtx_config_display();
7475 	else if (!strcmp(res->what, "cores"))
7476 		fwd_lcores_config_display();
7477 	else if (!strcmp(res->what, "fwd"))
7478 		pkt_fwd_config_display(&cur_fwd_config);
7479 	else if (!strcmp(res->what, "txpkts"))
7480 		show_tx_pkt_segments();
7481 	else if (!strcmp(res->what, "txtimes"))
7482 		show_tx_pkt_times();
7483 }
7484 
7485 cmdline_parse_token_string_t cmd_showcfg_show =
7486 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7487 cmdline_parse_token_string_t cmd_showcfg_port =
7488 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7489 cmdline_parse_token_string_t cmd_showcfg_what =
7490 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7491 				 "rxtx#cores#fwd#txpkts#txtimes");
7492 
7493 cmdline_parse_inst_t cmd_showcfg = {
7494 	.f = cmd_showcfg_parsed,
7495 	.data = NULL,
7496 	.help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
7497 	.tokens = {
7498 		(void *)&cmd_showcfg_show,
7499 		(void *)&cmd_showcfg_port,
7500 		(void *)&cmd_showcfg_what,
7501 		NULL,
7502 	},
7503 };
7504 
7505 /* *** SHOW ALL PORT INFO *** */
7506 struct cmd_showportall_result {
7507 	cmdline_fixed_string_t show;
7508 	cmdline_fixed_string_t port;
7509 	cmdline_fixed_string_t what;
7510 	cmdline_fixed_string_t all;
7511 };
7512 
7513 static void cmd_showportall_parsed(void *parsed_result,
7514 				__rte_unused struct cmdline *cl,
7515 				__rte_unused void *data)
7516 {
7517 	portid_t i;
7518 
7519 	struct cmd_showportall_result *res = parsed_result;
7520 	if (!strcmp(res->show, "clear")) {
7521 		if (!strcmp(res->what, "stats"))
7522 			RTE_ETH_FOREACH_DEV(i)
7523 				nic_stats_clear(i);
7524 		else if (!strcmp(res->what, "xstats"))
7525 			RTE_ETH_FOREACH_DEV(i)
7526 				nic_xstats_clear(i);
7527 	} else if (!strcmp(res->what, "info"))
7528 		RTE_ETH_FOREACH_DEV(i)
7529 			port_infos_display(i);
7530 	else if (!strcmp(res->what, "summary")) {
7531 		port_summary_header_display();
7532 		RTE_ETH_FOREACH_DEV(i)
7533 			port_summary_display(i);
7534 	}
7535 	else if (!strcmp(res->what, "stats"))
7536 		RTE_ETH_FOREACH_DEV(i)
7537 			nic_stats_display(i);
7538 	else if (!strcmp(res->what, "xstats"))
7539 		RTE_ETH_FOREACH_DEV(i)
7540 			nic_xstats_display(i);
7541 	else if (!strcmp(res->what, "fdir"))
7542 		RTE_ETH_FOREACH_DEV(i)
7543 			fdir_get_infos(i);
7544 	else if (!strcmp(res->what, "stat_qmap"))
7545 		RTE_ETH_FOREACH_DEV(i)
7546 			nic_stats_mapping_display(i);
7547 	else if (!strcmp(res->what, "dcb_tc"))
7548 		RTE_ETH_FOREACH_DEV(i)
7549 			port_dcb_info_display(i);
7550 	else if (!strcmp(res->what, "cap"))
7551 		RTE_ETH_FOREACH_DEV(i)
7552 			port_offload_cap_display(i);
7553 }
7554 
7555 cmdline_parse_token_string_t cmd_showportall_show =
7556 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7557 				 "show#clear");
7558 cmdline_parse_token_string_t cmd_showportall_port =
7559 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7560 cmdline_parse_token_string_t cmd_showportall_what =
7561 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7562 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7563 cmdline_parse_token_string_t cmd_showportall_all =
7564 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7565 cmdline_parse_inst_t cmd_showportall = {
7566 	.f = cmd_showportall_parsed,
7567 	.data = NULL,
7568 	.help_str = "show|clear port "
7569 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7570 	.tokens = {
7571 		(void *)&cmd_showportall_show,
7572 		(void *)&cmd_showportall_port,
7573 		(void *)&cmd_showportall_what,
7574 		(void *)&cmd_showportall_all,
7575 		NULL,
7576 	},
7577 };
7578 
7579 /* *** SHOW PORT INFO *** */
7580 struct cmd_showport_result {
7581 	cmdline_fixed_string_t show;
7582 	cmdline_fixed_string_t port;
7583 	cmdline_fixed_string_t what;
7584 	uint16_t portnum;
7585 };
7586 
7587 static void cmd_showport_parsed(void *parsed_result,
7588 				__rte_unused struct cmdline *cl,
7589 				__rte_unused void *data)
7590 {
7591 	struct cmd_showport_result *res = parsed_result;
7592 	if (!strcmp(res->show, "clear")) {
7593 		if (!strcmp(res->what, "stats"))
7594 			nic_stats_clear(res->portnum);
7595 		else if (!strcmp(res->what, "xstats"))
7596 			nic_xstats_clear(res->portnum);
7597 	} else if (!strcmp(res->what, "info"))
7598 		port_infos_display(res->portnum);
7599 	else if (!strcmp(res->what, "summary")) {
7600 		port_summary_header_display();
7601 		port_summary_display(res->portnum);
7602 	}
7603 	else if (!strcmp(res->what, "stats"))
7604 		nic_stats_display(res->portnum);
7605 	else if (!strcmp(res->what, "xstats"))
7606 		nic_xstats_display(res->portnum);
7607 	else if (!strcmp(res->what, "fdir"))
7608 		 fdir_get_infos(res->portnum);
7609 	else if (!strcmp(res->what, "stat_qmap"))
7610 		nic_stats_mapping_display(res->portnum);
7611 	else if (!strcmp(res->what, "dcb_tc"))
7612 		port_dcb_info_display(res->portnum);
7613 	else if (!strcmp(res->what, "cap"))
7614 		port_offload_cap_display(res->portnum);
7615 }
7616 
7617 cmdline_parse_token_string_t cmd_showport_show =
7618 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7619 				 "show#clear");
7620 cmdline_parse_token_string_t cmd_showport_port =
7621 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7622 cmdline_parse_token_string_t cmd_showport_what =
7623 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7624 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7625 cmdline_parse_token_num_t cmd_showport_portnum =
7626 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7627 
7628 cmdline_parse_inst_t cmd_showport = {
7629 	.f = cmd_showport_parsed,
7630 	.data = NULL,
7631 	.help_str = "show|clear port "
7632 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7633 		"<port_id>",
7634 	.tokens = {
7635 		(void *)&cmd_showport_show,
7636 		(void *)&cmd_showport_port,
7637 		(void *)&cmd_showport_what,
7638 		(void *)&cmd_showport_portnum,
7639 		NULL,
7640 	},
7641 };
7642 
7643 /* *** SHOW DEVICE INFO *** */
7644 struct cmd_showdevice_result {
7645 	cmdline_fixed_string_t show;
7646 	cmdline_fixed_string_t device;
7647 	cmdline_fixed_string_t what;
7648 	cmdline_fixed_string_t identifier;
7649 };
7650 
7651 static void cmd_showdevice_parsed(void *parsed_result,
7652 				__rte_unused struct cmdline *cl,
7653 				__rte_unused void *data)
7654 {
7655 	struct cmd_showdevice_result *res = parsed_result;
7656 	if (!strcmp(res->what, "info")) {
7657 		if (!strcmp(res->identifier, "all"))
7658 			device_infos_display(NULL);
7659 		else
7660 			device_infos_display(res->identifier);
7661 	}
7662 }
7663 
7664 cmdline_parse_token_string_t cmd_showdevice_show =
7665 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7666 				 "show");
7667 cmdline_parse_token_string_t cmd_showdevice_device =
7668 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7669 cmdline_parse_token_string_t cmd_showdevice_what =
7670 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7671 				 "info");
7672 cmdline_parse_token_string_t cmd_showdevice_identifier =
7673 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7674 			identifier, NULL);
7675 
7676 cmdline_parse_inst_t cmd_showdevice = {
7677 	.f = cmd_showdevice_parsed,
7678 	.data = NULL,
7679 	.help_str = "show device info <identifier>|all",
7680 	.tokens = {
7681 		(void *)&cmd_showdevice_show,
7682 		(void *)&cmd_showdevice_device,
7683 		(void *)&cmd_showdevice_what,
7684 		(void *)&cmd_showdevice_identifier,
7685 		NULL,
7686 	},
7687 };
7688 /* *** SHOW QUEUE INFO *** */
7689 struct cmd_showqueue_result {
7690 	cmdline_fixed_string_t show;
7691 	cmdline_fixed_string_t type;
7692 	cmdline_fixed_string_t what;
7693 	uint16_t portnum;
7694 	uint16_t queuenum;
7695 };
7696 
7697 static void
7698 cmd_showqueue_parsed(void *parsed_result,
7699 	__rte_unused struct cmdline *cl,
7700 	__rte_unused void *data)
7701 {
7702 	struct cmd_showqueue_result *res = parsed_result;
7703 
7704 	if (!strcmp(res->type, "rxq"))
7705 		rx_queue_infos_display(res->portnum, res->queuenum);
7706 	else if (!strcmp(res->type, "txq"))
7707 		tx_queue_infos_display(res->portnum, res->queuenum);
7708 }
7709 
7710 cmdline_parse_token_string_t cmd_showqueue_show =
7711 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7712 cmdline_parse_token_string_t cmd_showqueue_type =
7713 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7714 cmdline_parse_token_string_t cmd_showqueue_what =
7715 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7716 cmdline_parse_token_num_t cmd_showqueue_portnum =
7717 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7718 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7719 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7720 
7721 cmdline_parse_inst_t cmd_showqueue = {
7722 	.f = cmd_showqueue_parsed,
7723 	.data = NULL,
7724 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7725 	.tokens = {
7726 		(void *)&cmd_showqueue_show,
7727 		(void *)&cmd_showqueue_type,
7728 		(void *)&cmd_showqueue_what,
7729 		(void *)&cmd_showqueue_portnum,
7730 		(void *)&cmd_showqueue_queuenum,
7731 		NULL,
7732 	},
7733 };
7734 
7735 /* show/clear fwd engine statistics */
7736 struct fwd_result {
7737 	cmdline_fixed_string_t action;
7738 	cmdline_fixed_string_t fwd;
7739 	cmdline_fixed_string_t stats;
7740 	cmdline_fixed_string_t all;
7741 };
7742 
7743 cmdline_parse_token_string_t cmd_fwd_action =
7744 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7745 cmdline_parse_token_string_t cmd_fwd_fwd =
7746 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7747 cmdline_parse_token_string_t cmd_fwd_stats =
7748 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7749 cmdline_parse_token_string_t cmd_fwd_all =
7750 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7751 
7752 static void
7753 cmd_showfwdall_parsed(void *parsed_result,
7754 		      __rte_unused struct cmdline *cl,
7755 		      __rte_unused void *data)
7756 {
7757 	struct fwd_result *res = parsed_result;
7758 
7759 	if (!strcmp(res->action, "show"))
7760 		fwd_stats_display();
7761 	else
7762 		fwd_stats_reset();
7763 }
7764 
7765 static cmdline_parse_inst_t cmd_showfwdall = {
7766 	.f = cmd_showfwdall_parsed,
7767 	.data = NULL,
7768 	.help_str = "show|clear fwd stats all",
7769 	.tokens = {
7770 		(void *)&cmd_fwd_action,
7771 		(void *)&cmd_fwd_fwd,
7772 		(void *)&cmd_fwd_stats,
7773 		(void *)&cmd_fwd_all,
7774 		NULL,
7775 	},
7776 };
7777 
7778 /* *** READ PORT REGISTER *** */
7779 struct cmd_read_reg_result {
7780 	cmdline_fixed_string_t read;
7781 	cmdline_fixed_string_t reg;
7782 	portid_t port_id;
7783 	uint32_t reg_off;
7784 };
7785 
7786 static void
7787 cmd_read_reg_parsed(void *parsed_result,
7788 		    __rte_unused struct cmdline *cl,
7789 		    __rte_unused void *data)
7790 {
7791 	struct cmd_read_reg_result *res = parsed_result;
7792 	port_reg_display(res->port_id, res->reg_off);
7793 }
7794 
7795 cmdline_parse_token_string_t cmd_read_reg_read =
7796 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7797 cmdline_parse_token_string_t cmd_read_reg_reg =
7798 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7799 cmdline_parse_token_num_t cmd_read_reg_port_id =
7800 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7801 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7802 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7803 
7804 cmdline_parse_inst_t cmd_read_reg = {
7805 	.f = cmd_read_reg_parsed,
7806 	.data = NULL,
7807 	.help_str = "read reg <port_id> <reg_off>",
7808 	.tokens = {
7809 		(void *)&cmd_read_reg_read,
7810 		(void *)&cmd_read_reg_reg,
7811 		(void *)&cmd_read_reg_port_id,
7812 		(void *)&cmd_read_reg_reg_off,
7813 		NULL,
7814 	},
7815 };
7816 
7817 /* *** READ PORT REGISTER BIT FIELD *** */
7818 struct cmd_read_reg_bit_field_result {
7819 	cmdline_fixed_string_t read;
7820 	cmdline_fixed_string_t regfield;
7821 	portid_t port_id;
7822 	uint32_t reg_off;
7823 	uint8_t bit1_pos;
7824 	uint8_t bit2_pos;
7825 };
7826 
7827 static void
7828 cmd_read_reg_bit_field_parsed(void *parsed_result,
7829 			      __rte_unused struct cmdline *cl,
7830 			      __rte_unused void *data)
7831 {
7832 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7833 	port_reg_bit_field_display(res->port_id, res->reg_off,
7834 				   res->bit1_pos, res->bit2_pos);
7835 }
7836 
7837 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7838 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7839 				 "read");
7840 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7841 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7842 				 regfield, "regfield");
7843 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7844 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7845 			      UINT16);
7846 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7847 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7848 			      UINT32);
7849 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7850 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7851 			      UINT8);
7852 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7853 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7854 			      UINT8);
7855 
7856 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7857 	.f = cmd_read_reg_bit_field_parsed,
7858 	.data = NULL,
7859 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7860 	"Read register bit field between bit_x and bit_y included",
7861 	.tokens = {
7862 		(void *)&cmd_read_reg_bit_field_read,
7863 		(void *)&cmd_read_reg_bit_field_regfield,
7864 		(void *)&cmd_read_reg_bit_field_port_id,
7865 		(void *)&cmd_read_reg_bit_field_reg_off,
7866 		(void *)&cmd_read_reg_bit_field_bit1_pos,
7867 		(void *)&cmd_read_reg_bit_field_bit2_pos,
7868 		NULL,
7869 	},
7870 };
7871 
7872 /* *** READ PORT REGISTER BIT *** */
7873 struct cmd_read_reg_bit_result {
7874 	cmdline_fixed_string_t read;
7875 	cmdline_fixed_string_t regbit;
7876 	portid_t port_id;
7877 	uint32_t reg_off;
7878 	uint8_t bit_pos;
7879 };
7880 
7881 static void
7882 cmd_read_reg_bit_parsed(void *parsed_result,
7883 			__rte_unused struct cmdline *cl,
7884 			__rte_unused void *data)
7885 {
7886 	struct cmd_read_reg_bit_result *res = parsed_result;
7887 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7888 }
7889 
7890 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7891 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7892 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7893 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7894 				 regbit, "regbit");
7895 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7896 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7897 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7898 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7899 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7900 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7901 
7902 cmdline_parse_inst_t cmd_read_reg_bit = {
7903 	.f = cmd_read_reg_bit_parsed,
7904 	.data = NULL,
7905 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7906 	.tokens = {
7907 		(void *)&cmd_read_reg_bit_read,
7908 		(void *)&cmd_read_reg_bit_regbit,
7909 		(void *)&cmd_read_reg_bit_port_id,
7910 		(void *)&cmd_read_reg_bit_reg_off,
7911 		(void *)&cmd_read_reg_bit_bit_pos,
7912 		NULL,
7913 	},
7914 };
7915 
7916 /* *** WRITE PORT REGISTER *** */
7917 struct cmd_write_reg_result {
7918 	cmdline_fixed_string_t write;
7919 	cmdline_fixed_string_t reg;
7920 	portid_t port_id;
7921 	uint32_t reg_off;
7922 	uint32_t value;
7923 };
7924 
7925 static void
7926 cmd_write_reg_parsed(void *parsed_result,
7927 		     __rte_unused struct cmdline *cl,
7928 		     __rte_unused void *data)
7929 {
7930 	struct cmd_write_reg_result *res = parsed_result;
7931 	port_reg_set(res->port_id, res->reg_off, res->value);
7932 }
7933 
7934 cmdline_parse_token_string_t cmd_write_reg_write =
7935 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7936 cmdline_parse_token_string_t cmd_write_reg_reg =
7937 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7938 cmdline_parse_token_num_t cmd_write_reg_port_id =
7939 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7940 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7941 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7942 cmdline_parse_token_num_t cmd_write_reg_value =
7943 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7944 
7945 cmdline_parse_inst_t cmd_write_reg = {
7946 	.f = cmd_write_reg_parsed,
7947 	.data = NULL,
7948 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
7949 	.tokens = {
7950 		(void *)&cmd_write_reg_write,
7951 		(void *)&cmd_write_reg_reg,
7952 		(void *)&cmd_write_reg_port_id,
7953 		(void *)&cmd_write_reg_reg_off,
7954 		(void *)&cmd_write_reg_value,
7955 		NULL,
7956 	},
7957 };
7958 
7959 /* *** WRITE PORT REGISTER BIT FIELD *** */
7960 struct cmd_write_reg_bit_field_result {
7961 	cmdline_fixed_string_t write;
7962 	cmdline_fixed_string_t regfield;
7963 	portid_t port_id;
7964 	uint32_t reg_off;
7965 	uint8_t bit1_pos;
7966 	uint8_t bit2_pos;
7967 	uint32_t value;
7968 };
7969 
7970 static void
7971 cmd_write_reg_bit_field_parsed(void *parsed_result,
7972 			       __rte_unused struct cmdline *cl,
7973 			       __rte_unused void *data)
7974 {
7975 	struct cmd_write_reg_bit_field_result *res = parsed_result;
7976 	port_reg_bit_field_set(res->port_id, res->reg_off,
7977 			  res->bit1_pos, res->bit2_pos, res->value);
7978 }
7979 
7980 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7981 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7982 				 "write");
7983 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7984 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7985 				 regfield, "regfield");
7986 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7987 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7988 			      UINT16);
7989 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7990 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7991 			      UINT32);
7992 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7993 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7994 			      UINT8);
7995 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7996 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7997 			      UINT8);
7998 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7999 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8000 			      UINT32);
8001 
8002 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8003 	.f = cmd_write_reg_bit_field_parsed,
8004 	.data = NULL,
8005 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8006 		"<reg_value>: "
8007 		"Set register bit field between bit_x and bit_y included",
8008 	.tokens = {
8009 		(void *)&cmd_write_reg_bit_field_write,
8010 		(void *)&cmd_write_reg_bit_field_regfield,
8011 		(void *)&cmd_write_reg_bit_field_port_id,
8012 		(void *)&cmd_write_reg_bit_field_reg_off,
8013 		(void *)&cmd_write_reg_bit_field_bit1_pos,
8014 		(void *)&cmd_write_reg_bit_field_bit2_pos,
8015 		(void *)&cmd_write_reg_bit_field_value,
8016 		NULL,
8017 	},
8018 };
8019 
8020 /* *** WRITE PORT REGISTER BIT *** */
8021 struct cmd_write_reg_bit_result {
8022 	cmdline_fixed_string_t write;
8023 	cmdline_fixed_string_t regbit;
8024 	portid_t port_id;
8025 	uint32_t reg_off;
8026 	uint8_t bit_pos;
8027 	uint8_t value;
8028 };
8029 
8030 static void
8031 cmd_write_reg_bit_parsed(void *parsed_result,
8032 			 __rte_unused struct cmdline *cl,
8033 			 __rte_unused void *data)
8034 {
8035 	struct cmd_write_reg_bit_result *res = parsed_result;
8036 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8037 }
8038 
8039 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8040 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8041 				 "write");
8042 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8043 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8044 				 regbit, "regbit");
8045 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8046 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8047 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8048 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8049 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8050 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8051 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8052 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8053 
8054 cmdline_parse_inst_t cmd_write_reg_bit = {
8055 	.f = cmd_write_reg_bit_parsed,
8056 	.data = NULL,
8057 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8058 		"0 <= bit_x <= 31",
8059 	.tokens = {
8060 		(void *)&cmd_write_reg_bit_write,
8061 		(void *)&cmd_write_reg_bit_regbit,
8062 		(void *)&cmd_write_reg_bit_port_id,
8063 		(void *)&cmd_write_reg_bit_reg_off,
8064 		(void *)&cmd_write_reg_bit_bit_pos,
8065 		(void *)&cmd_write_reg_bit_value,
8066 		NULL,
8067 	},
8068 };
8069 
8070 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8071 struct cmd_read_rxd_txd_result {
8072 	cmdline_fixed_string_t read;
8073 	cmdline_fixed_string_t rxd_txd;
8074 	portid_t port_id;
8075 	uint16_t queue_id;
8076 	uint16_t desc_id;
8077 };
8078 
8079 static void
8080 cmd_read_rxd_txd_parsed(void *parsed_result,
8081 			__rte_unused struct cmdline *cl,
8082 			__rte_unused void *data)
8083 {
8084 	struct cmd_read_rxd_txd_result *res = parsed_result;
8085 
8086 	if (!strcmp(res->rxd_txd, "rxd"))
8087 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8088 	else if (!strcmp(res->rxd_txd, "txd"))
8089 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8090 }
8091 
8092 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8093 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8094 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8095 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8096 				 "rxd#txd");
8097 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8098 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8099 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8100 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8101 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8102 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8103 
8104 cmdline_parse_inst_t cmd_read_rxd_txd = {
8105 	.f = cmd_read_rxd_txd_parsed,
8106 	.data = NULL,
8107 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8108 	.tokens = {
8109 		(void *)&cmd_read_rxd_txd_read,
8110 		(void *)&cmd_read_rxd_txd_rxd_txd,
8111 		(void *)&cmd_read_rxd_txd_port_id,
8112 		(void *)&cmd_read_rxd_txd_queue_id,
8113 		(void *)&cmd_read_rxd_txd_desc_id,
8114 		NULL,
8115 	},
8116 };
8117 
8118 /* *** QUIT *** */
8119 struct cmd_quit_result {
8120 	cmdline_fixed_string_t quit;
8121 };
8122 
8123 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8124 			    struct cmdline *cl,
8125 			    __rte_unused void *data)
8126 {
8127 	cmdline_quit(cl);
8128 }
8129 
8130 cmdline_parse_token_string_t cmd_quit_quit =
8131 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8132 
8133 cmdline_parse_inst_t cmd_quit = {
8134 	.f = cmd_quit_parsed,
8135 	.data = NULL,
8136 	.help_str = "quit: Exit application",
8137 	.tokens = {
8138 		(void *)&cmd_quit_quit,
8139 		NULL,
8140 	},
8141 };
8142 
8143 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8144 struct cmd_mac_addr_result {
8145 	cmdline_fixed_string_t mac_addr_cmd;
8146 	cmdline_fixed_string_t what;
8147 	uint16_t port_num;
8148 	struct rte_ether_addr address;
8149 };
8150 
8151 static void cmd_mac_addr_parsed(void *parsed_result,
8152 		__rte_unused struct cmdline *cl,
8153 		__rte_unused void *data)
8154 {
8155 	struct cmd_mac_addr_result *res = parsed_result;
8156 	int ret;
8157 
8158 	if (strcmp(res->what, "add") == 0)
8159 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8160 	else if (strcmp(res->what, "set") == 0)
8161 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8162 						       &res->address);
8163 	else
8164 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8165 
8166 	/* check the return value and print it if is < 0 */
8167 	if(ret < 0)
8168 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8169 
8170 }
8171 
8172 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8173 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8174 				"mac_addr");
8175 cmdline_parse_token_string_t cmd_mac_addr_what =
8176 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8177 				"add#remove#set");
8178 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8179 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8180 					UINT16);
8181 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8182 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8183 
8184 cmdline_parse_inst_t cmd_mac_addr = {
8185 	.f = cmd_mac_addr_parsed,
8186 	.data = (void *)0,
8187 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8188 			"Add/Remove/Set MAC address on port_id",
8189 	.tokens = {
8190 		(void *)&cmd_mac_addr_cmd,
8191 		(void *)&cmd_mac_addr_what,
8192 		(void *)&cmd_mac_addr_portnum,
8193 		(void *)&cmd_mac_addr_addr,
8194 		NULL,
8195 	},
8196 };
8197 
8198 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8199 struct cmd_eth_peer_result {
8200 	cmdline_fixed_string_t set;
8201 	cmdline_fixed_string_t eth_peer;
8202 	portid_t port_id;
8203 	cmdline_fixed_string_t peer_addr;
8204 };
8205 
8206 static void cmd_set_eth_peer_parsed(void *parsed_result,
8207 			__rte_unused struct cmdline *cl,
8208 			__rte_unused void *data)
8209 {
8210 		struct cmd_eth_peer_result *res = parsed_result;
8211 
8212 		if (test_done == 0) {
8213 			printf("Please stop forwarding first\n");
8214 			return;
8215 		}
8216 		if (!strcmp(res->eth_peer, "eth-peer")) {
8217 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8218 			fwd_config_setup();
8219 		}
8220 }
8221 cmdline_parse_token_string_t cmd_eth_peer_set =
8222 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8223 cmdline_parse_token_string_t cmd_eth_peer =
8224 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8225 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8226 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8227 cmdline_parse_token_string_t cmd_eth_peer_addr =
8228 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8229 
8230 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8231 	.f = cmd_set_eth_peer_parsed,
8232 	.data = NULL,
8233 	.help_str = "set eth-peer <port_id> <peer_mac>",
8234 	.tokens = {
8235 		(void *)&cmd_eth_peer_set,
8236 		(void *)&cmd_eth_peer,
8237 		(void *)&cmd_eth_peer_port_id,
8238 		(void *)&cmd_eth_peer_addr,
8239 		NULL,
8240 	},
8241 };
8242 
8243 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8244 struct cmd_set_qmap_result {
8245 	cmdline_fixed_string_t set;
8246 	cmdline_fixed_string_t qmap;
8247 	cmdline_fixed_string_t what;
8248 	portid_t port_id;
8249 	uint16_t queue_id;
8250 	uint8_t map_value;
8251 };
8252 
8253 static void
8254 cmd_set_qmap_parsed(void *parsed_result,
8255 		       __rte_unused struct cmdline *cl,
8256 		       __rte_unused void *data)
8257 {
8258 	struct cmd_set_qmap_result *res = parsed_result;
8259 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8260 
8261 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8262 }
8263 
8264 cmdline_parse_token_string_t cmd_setqmap_set =
8265 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8266 				 set, "set");
8267 cmdline_parse_token_string_t cmd_setqmap_qmap =
8268 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8269 				 qmap, "stat_qmap");
8270 cmdline_parse_token_string_t cmd_setqmap_what =
8271 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8272 				 what, "tx#rx");
8273 cmdline_parse_token_num_t cmd_setqmap_portid =
8274 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8275 			      port_id, UINT16);
8276 cmdline_parse_token_num_t cmd_setqmap_queueid =
8277 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8278 			      queue_id, UINT16);
8279 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8280 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8281 			      map_value, UINT8);
8282 
8283 cmdline_parse_inst_t cmd_set_qmap = {
8284 	.f = cmd_set_qmap_parsed,
8285 	.data = NULL,
8286 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8287 		"Set statistics mapping value on tx|rx queue_id of port_id",
8288 	.tokens = {
8289 		(void *)&cmd_setqmap_set,
8290 		(void *)&cmd_setqmap_qmap,
8291 		(void *)&cmd_setqmap_what,
8292 		(void *)&cmd_setqmap_portid,
8293 		(void *)&cmd_setqmap_queueid,
8294 		(void *)&cmd_setqmap_mapvalue,
8295 		NULL,
8296 	},
8297 };
8298 
8299 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8300 struct cmd_set_xstats_hide_zero_result {
8301 	cmdline_fixed_string_t keyword;
8302 	cmdline_fixed_string_t name;
8303 	cmdline_fixed_string_t on_off;
8304 };
8305 
8306 static void
8307 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8308 			__rte_unused struct cmdline *cl,
8309 			__rte_unused void *data)
8310 {
8311 	struct cmd_set_xstats_hide_zero_result *res;
8312 	uint16_t on_off = 0;
8313 
8314 	res = parsed_result;
8315 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8316 	set_xstats_hide_zero(on_off);
8317 }
8318 
8319 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8320 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8321 				 keyword, "set");
8322 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8323 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8324 				 name, "xstats-hide-zero");
8325 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8326 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8327 				 on_off, "on#off");
8328 
8329 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8330 	.f = cmd_set_xstats_hide_zero_parsed,
8331 	.data = NULL,
8332 	.help_str = "set xstats-hide-zero on|off",
8333 	.tokens = {
8334 		(void *)&cmd_set_xstats_hide_zero_keyword,
8335 		(void *)&cmd_set_xstats_hide_zero_name,
8336 		(void *)&cmd_set_xstats_hide_zero_on_off,
8337 		NULL,
8338 	},
8339 };
8340 
8341 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8342 struct cmd_set_record_core_cycles_result {
8343 	cmdline_fixed_string_t keyword;
8344 	cmdline_fixed_string_t name;
8345 	cmdline_fixed_string_t on_off;
8346 };
8347 
8348 static void
8349 cmd_set_record_core_cycles_parsed(void *parsed_result,
8350 			__rte_unused struct cmdline *cl,
8351 			__rte_unused void *data)
8352 {
8353 	struct cmd_set_record_core_cycles_result *res;
8354 	uint16_t on_off = 0;
8355 
8356 	res = parsed_result;
8357 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8358 	set_record_core_cycles(on_off);
8359 }
8360 
8361 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8362 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8363 				 keyword, "set");
8364 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8365 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8366 				 name, "record-core-cycles");
8367 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8368 	TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8369 				 on_off, "on#off");
8370 
8371 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8372 	.f = cmd_set_record_core_cycles_parsed,
8373 	.data = NULL,
8374 	.help_str = "set record-core-cycles on|off",
8375 	.tokens = {
8376 		(void *)&cmd_set_record_core_cycles_keyword,
8377 		(void *)&cmd_set_record_core_cycles_name,
8378 		(void *)&cmd_set_record_core_cycles_on_off,
8379 		NULL,
8380 	},
8381 };
8382 
8383 /* *** CONFIGURE UNICAST HASH TABLE *** */
8384 struct cmd_set_uc_hash_table {
8385 	cmdline_fixed_string_t set;
8386 	cmdline_fixed_string_t port;
8387 	portid_t port_id;
8388 	cmdline_fixed_string_t what;
8389 	struct rte_ether_addr address;
8390 	cmdline_fixed_string_t mode;
8391 };
8392 
8393 static void
8394 cmd_set_uc_hash_parsed(void *parsed_result,
8395 		       __rte_unused struct cmdline *cl,
8396 		       __rte_unused void *data)
8397 {
8398 	int ret=0;
8399 	struct cmd_set_uc_hash_table *res = parsed_result;
8400 
8401 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8402 
8403 	if (strcmp(res->what, "uta") == 0)
8404 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8405 						&res->address,(uint8_t)is_on);
8406 	if (ret < 0)
8407 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8408 
8409 }
8410 
8411 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8412 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8413 				 set, "set");
8414 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8415 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8416 				 port, "port");
8417 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8418 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8419 			      port_id, UINT16);
8420 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8421 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8422 				 what, "uta");
8423 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8424 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8425 				address);
8426 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8427 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8428 				 mode, "on#off");
8429 
8430 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8431 	.f = cmd_set_uc_hash_parsed,
8432 	.data = NULL,
8433 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8434 	.tokens = {
8435 		(void *)&cmd_set_uc_hash_set,
8436 		(void *)&cmd_set_uc_hash_port,
8437 		(void *)&cmd_set_uc_hash_portid,
8438 		(void *)&cmd_set_uc_hash_what,
8439 		(void *)&cmd_set_uc_hash_mac,
8440 		(void *)&cmd_set_uc_hash_mode,
8441 		NULL,
8442 	},
8443 };
8444 
8445 struct cmd_set_uc_all_hash_table {
8446 	cmdline_fixed_string_t set;
8447 	cmdline_fixed_string_t port;
8448 	portid_t port_id;
8449 	cmdline_fixed_string_t what;
8450 	cmdline_fixed_string_t value;
8451 	cmdline_fixed_string_t mode;
8452 };
8453 
8454 static void
8455 cmd_set_uc_all_hash_parsed(void *parsed_result,
8456 		       __rte_unused struct cmdline *cl,
8457 		       __rte_unused void *data)
8458 {
8459 	int ret=0;
8460 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8461 
8462 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8463 
8464 	if ((strcmp(res->what, "uta") == 0) &&
8465 		(strcmp(res->value, "all") == 0))
8466 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8467 	if (ret < 0)
8468 		printf("bad unicast hash table parameter,"
8469 			"return code = %d \n", ret);
8470 }
8471 
8472 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8473 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8474 				 set, "set");
8475 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8476 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8477 				 port, "port");
8478 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8479 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8480 			      port_id, UINT16);
8481 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8482 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8483 				 what, "uta");
8484 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8485 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8486 				value,"all");
8487 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8488 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8489 				 mode, "on#off");
8490 
8491 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8492 	.f = cmd_set_uc_all_hash_parsed,
8493 	.data = NULL,
8494 	.help_str = "set port <port_id> uta all on|off",
8495 	.tokens = {
8496 		(void *)&cmd_set_uc_all_hash_set,
8497 		(void *)&cmd_set_uc_all_hash_port,
8498 		(void *)&cmd_set_uc_all_hash_portid,
8499 		(void *)&cmd_set_uc_all_hash_what,
8500 		(void *)&cmd_set_uc_all_hash_value,
8501 		(void *)&cmd_set_uc_all_hash_mode,
8502 		NULL,
8503 	},
8504 };
8505 
8506 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8507 struct cmd_set_vf_macvlan_filter {
8508 	cmdline_fixed_string_t set;
8509 	cmdline_fixed_string_t port;
8510 	portid_t port_id;
8511 	cmdline_fixed_string_t vf;
8512 	uint8_t vf_id;
8513 	struct rte_ether_addr address;
8514 	cmdline_fixed_string_t filter_type;
8515 	cmdline_fixed_string_t mode;
8516 };
8517 
8518 static void
8519 cmd_set_vf_macvlan_parsed(void *parsed_result,
8520 		       __rte_unused struct cmdline *cl,
8521 		       __rte_unused void *data)
8522 {
8523 	int is_on, ret = 0;
8524 	struct cmd_set_vf_macvlan_filter *res = parsed_result;
8525 	struct rte_eth_mac_filter filter;
8526 
8527 	memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8528 
8529 	rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8530 
8531 	/* set VF MAC filter */
8532 	filter.is_vf = 1;
8533 
8534 	/* set VF ID */
8535 	filter.dst_id = res->vf_id;
8536 
8537 	if (!strcmp(res->filter_type, "exact-mac"))
8538 		filter.filter_type = RTE_MAC_PERFECT_MATCH;
8539 	else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8540 		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8541 	else if (!strcmp(res->filter_type, "hashmac"))
8542 		filter.filter_type = RTE_MAC_HASH_MATCH;
8543 	else if (!strcmp(res->filter_type, "hashmac-vlan"))
8544 		filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8545 
8546 	is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8547 
8548 	if (is_on)
8549 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8550 					RTE_ETH_FILTER_MACVLAN,
8551 					RTE_ETH_FILTER_ADD,
8552 					 &filter);
8553 	else
8554 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8555 					RTE_ETH_FILTER_MACVLAN,
8556 					RTE_ETH_FILTER_DELETE,
8557 					&filter);
8558 
8559 	if (ret < 0)
8560 		printf("bad set MAC hash parameter, return code = %d\n", ret);
8561 
8562 }
8563 
8564 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8565 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8566 				 set, "set");
8567 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8568 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8569 				 port, "port");
8570 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8571 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8572 			      port_id, UINT16);
8573 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8574 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8575 				 vf, "vf");
8576 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8577 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8578 				vf_id, UINT8);
8579 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8580 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8581 				address);
8582 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8583 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8584 				filter_type, "exact-mac#exact-mac-vlan"
8585 				"#hashmac#hashmac-vlan");
8586 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8587 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8588 				 mode, "on#off");
8589 
8590 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8591 	.f = cmd_set_vf_macvlan_parsed,
8592 	.data = NULL,
8593 	.help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8594 		"exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8595 		"Exact match rule: exact match of MAC or MAC and VLAN; "
8596 		"hash match rule: hash match of MAC and exact match of VLAN",
8597 	.tokens = {
8598 		(void *)&cmd_set_vf_macvlan_set,
8599 		(void *)&cmd_set_vf_macvlan_port,
8600 		(void *)&cmd_set_vf_macvlan_portid,
8601 		(void *)&cmd_set_vf_macvlan_vf,
8602 		(void *)&cmd_set_vf_macvlan_vf_id,
8603 		(void *)&cmd_set_vf_macvlan_mac,
8604 		(void *)&cmd_set_vf_macvlan_filter_type,
8605 		(void *)&cmd_set_vf_macvlan_mode,
8606 		NULL,
8607 	},
8608 };
8609 
8610 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8611 struct cmd_set_vf_traffic {
8612 	cmdline_fixed_string_t set;
8613 	cmdline_fixed_string_t port;
8614 	portid_t port_id;
8615 	cmdline_fixed_string_t vf;
8616 	uint8_t vf_id;
8617 	cmdline_fixed_string_t what;
8618 	cmdline_fixed_string_t mode;
8619 };
8620 
8621 static void
8622 cmd_set_vf_traffic_parsed(void *parsed_result,
8623 		       __rte_unused struct cmdline *cl,
8624 		       __rte_unused void *data)
8625 {
8626 	struct cmd_set_vf_traffic *res = parsed_result;
8627 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8628 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8629 
8630 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8631 }
8632 
8633 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8634 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8635 				 set, "set");
8636 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8637 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8638 				 port, "port");
8639 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8640 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8641 			      port_id, UINT16);
8642 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8643 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8644 				 vf, "vf");
8645 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8646 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8647 			      vf_id, UINT8);
8648 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8649 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8650 				 what, "tx#rx");
8651 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8652 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8653 				 mode, "on#off");
8654 
8655 cmdline_parse_inst_t cmd_set_vf_traffic = {
8656 	.f = cmd_set_vf_traffic_parsed,
8657 	.data = NULL,
8658 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8659 	.tokens = {
8660 		(void *)&cmd_setvf_traffic_set,
8661 		(void *)&cmd_setvf_traffic_port,
8662 		(void *)&cmd_setvf_traffic_portid,
8663 		(void *)&cmd_setvf_traffic_vf,
8664 		(void *)&cmd_setvf_traffic_vfid,
8665 		(void *)&cmd_setvf_traffic_what,
8666 		(void *)&cmd_setvf_traffic_mode,
8667 		NULL,
8668 	},
8669 };
8670 
8671 /* *** CONFIGURE VF RECEIVE MODE *** */
8672 struct cmd_set_vf_rxmode {
8673 	cmdline_fixed_string_t set;
8674 	cmdline_fixed_string_t port;
8675 	portid_t port_id;
8676 	cmdline_fixed_string_t vf;
8677 	uint8_t vf_id;
8678 	cmdline_fixed_string_t what;
8679 	cmdline_fixed_string_t mode;
8680 	cmdline_fixed_string_t on;
8681 };
8682 
8683 static void
8684 cmd_set_vf_rxmode_parsed(void *parsed_result,
8685 		       __rte_unused struct cmdline *cl,
8686 		       __rte_unused void *data)
8687 {
8688 	int ret = -ENOTSUP;
8689 	uint16_t vf_rxmode = 0;
8690 	struct cmd_set_vf_rxmode *res = parsed_result;
8691 
8692 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8693 	if (!strcmp(res->what,"rxmode")) {
8694 		if (!strcmp(res->mode, "AUPE"))
8695 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8696 		else if (!strcmp(res->mode, "ROPE"))
8697 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8698 		else if (!strcmp(res->mode, "BAM"))
8699 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8700 		else if (!strncmp(res->mode, "MPE",3))
8701 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8702 	}
8703 
8704 	RTE_SET_USED(is_on);
8705 
8706 #ifdef RTE_LIBRTE_IXGBE_PMD
8707 	if (ret == -ENOTSUP)
8708 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8709 						  vf_rxmode, (uint8_t)is_on);
8710 #endif
8711 #ifdef RTE_LIBRTE_BNXT_PMD
8712 	if (ret == -ENOTSUP)
8713 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8714 						 vf_rxmode, (uint8_t)is_on);
8715 #endif
8716 	if (ret < 0)
8717 		printf("bad VF receive mode parameter, return code = %d \n",
8718 		ret);
8719 }
8720 
8721 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8722 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8723 				 set, "set");
8724 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8725 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8726 				 port, "port");
8727 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8728 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8729 			      port_id, UINT16);
8730 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8731 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8732 				 vf, "vf");
8733 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8734 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8735 			      vf_id, UINT8);
8736 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8737 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8738 				 what, "rxmode");
8739 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8740 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8741 				 mode, "AUPE#ROPE#BAM#MPE");
8742 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8743 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8744 				 on, "on#off");
8745 
8746 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8747 	.f = cmd_set_vf_rxmode_parsed,
8748 	.data = NULL,
8749 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8750 		"AUPE|ROPE|BAM|MPE on|off",
8751 	.tokens = {
8752 		(void *)&cmd_set_vf_rxmode_set,
8753 		(void *)&cmd_set_vf_rxmode_port,
8754 		(void *)&cmd_set_vf_rxmode_portid,
8755 		(void *)&cmd_set_vf_rxmode_vf,
8756 		(void *)&cmd_set_vf_rxmode_vfid,
8757 		(void *)&cmd_set_vf_rxmode_what,
8758 		(void *)&cmd_set_vf_rxmode_mode,
8759 		(void *)&cmd_set_vf_rxmode_on,
8760 		NULL,
8761 	},
8762 };
8763 
8764 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8765 struct cmd_vf_mac_addr_result {
8766 	cmdline_fixed_string_t mac_addr_cmd;
8767 	cmdline_fixed_string_t what;
8768 	cmdline_fixed_string_t port;
8769 	uint16_t port_num;
8770 	cmdline_fixed_string_t vf;
8771 	uint8_t vf_num;
8772 	struct rte_ether_addr address;
8773 };
8774 
8775 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8776 		__rte_unused struct cmdline *cl,
8777 		__rte_unused void *data)
8778 {
8779 	struct cmd_vf_mac_addr_result *res = parsed_result;
8780 	int ret = -ENOTSUP;
8781 
8782 	if (strcmp(res->what, "add") != 0)
8783 		return;
8784 
8785 #ifdef RTE_LIBRTE_I40E_PMD
8786 	if (ret == -ENOTSUP)
8787 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8788 						   &res->address);
8789 #endif
8790 #ifdef RTE_LIBRTE_BNXT_PMD
8791 	if (ret == -ENOTSUP)
8792 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8793 						res->vf_num);
8794 #endif
8795 
8796 	if(ret < 0)
8797 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8798 
8799 }
8800 
8801 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8802 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8803 				mac_addr_cmd,"mac_addr");
8804 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8805 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8806 				what,"add");
8807 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8808 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8809 				port,"port");
8810 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8811 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8812 				port_num, UINT16);
8813 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8814 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8815 				vf,"vf");
8816 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8817 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8818 				vf_num, UINT8);
8819 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8820 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8821 				address);
8822 
8823 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8824 	.f = cmd_vf_mac_addr_parsed,
8825 	.data = (void *)0,
8826 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8827 		"Add MAC address filtering for a VF on port_id",
8828 	.tokens = {
8829 		(void *)&cmd_vf_mac_addr_cmd,
8830 		(void *)&cmd_vf_mac_addr_what,
8831 		(void *)&cmd_vf_mac_addr_port,
8832 		(void *)&cmd_vf_mac_addr_portnum,
8833 		(void *)&cmd_vf_mac_addr_vf,
8834 		(void *)&cmd_vf_mac_addr_vfnum,
8835 		(void *)&cmd_vf_mac_addr_addr,
8836 		NULL,
8837 	},
8838 };
8839 
8840 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8841 struct cmd_vf_rx_vlan_filter {
8842 	cmdline_fixed_string_t rx_vlan;
8843 	cmdline_fixed_string_t what;
8844 	uint16_t vlan_id;
8845 	cmdline_fixed_string_t port;
8846 	portid_t port_id;
8847 	cmdline_fixed_string_t vf;
8848 	uint64_t vf_mask;
8849 };
8850 
8851 static void
8852 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8853 			  __rte_unused struct cmdline *cl,
8854 			  __rte_unused void *data)
8855 {
8856 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8857 	int ret = -ENOTSUP;
8858 
8859 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8860 
8861 #ifdef RTE_LIBRTE_IXGBE_PMD
8862 	if (ret == -ENOTSUP)
8863 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8864 				res->vlan_id, res->vf_mask, is_add);
8865 #endif
8866 #ifdef RTE_LIBRTE_I40E_PMD
8867 	if (ret == -ENOTSUP)
8868 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8869 				res->vlan_id, res->vf_mask, is_add);
8870 #endif
8871 #ifdef RTE_LIBRTE_BNXT_PMD
8872 	if (ret == -ENOTSUP)
8873 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8874 				res->vlan_id, res->vf_mask, is_add);
8875 #endif
8876 
8877 	switch (ret) {
8878 	case 0:
8879 		break;
8880 	case -EINVAL:
8881 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8882 				res->vlan_id, res->vf_mask);
8883 		break;
8884 	case -ENODEV:
8885 		printf("invalid port_id %d\n", res->port_id);
8886 		break;
8887 	case -ENOTSUP:
8888 		printf("function not implemented or supported\n");
8889 		break;
8890 	default:
8891 		printf("programming error: (%s)\n", strerror(-ret));
8892 	}
8893 }
8894 
8895 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8896 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8897 				 rx_vlan, "rx_vlan");
8898 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8899 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8900 				 what, "add#rm");
8901 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8902 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8903 			      vlan_id, UINT16);
8904 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8905 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8906 				 port, "port");
8907 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8908 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8909 			      port_id, UINT16);
8910 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8911 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8912 				 vf, "vf");
8913 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8914 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8915 			      vf_mask, UINT64);
8916 
8917 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8918 	.f = cmd_vf_rx_vlan_filter_parsed,
8919 	.data = NULL,
8920 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8921 		"(vf_mask = hexadecimal VF mask)",
8922 	.tokens = {
8923 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8924 		(void *)&cmd_vf_rx_vlan_filter_what,
8925 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8926 		(void *)&cmd_vf_rx_vlan_filter_port,
8927 		(void *)&cmd_vf_rx_vlan_filter_portid,
8928 		(void *)&cmd_vf_rx_vlan_filter_vf,
8929 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8930 		NULL,
8931 	},
8932 };
8933 
8934 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8935 struct cmd_queue_rate_limit_result {
8936 	cmdline_fixed_string_t set;
8937 	cmdline_fixed_string_t port;
8938 	uint16_t port_num;
8939 	cmdline_fixed_string_t queue;
8940 	uint8_t queue_num;
8941 	cmdline_fixed_string_t rate;
8942 	uint16_t rate_num;
8943 };
8944 
8945 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8946 		__rte_unused struct cmdline *cl,
8947 		__rte_unused void *data)
8948 {
8949 	struct cmd_queue_rate_limit_result *res = parsed_result;
8950 	int ret = 0;
8951 
8952 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8953 		&& (strcmp(res->queue, "queue") == 0)
8954 		&& (strcmp(res->rate, "rate") == 0))
8955 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8956 					res->rate_num);
8957 	if (ret < 0)
8958 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8959 
8960 }
8961 
8962 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8963 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8964 				set, "set");
8965 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8966 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8967 				port, "port");
8968 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8969 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8970 				port_num, UINT16);
8971 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8972 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8973 				queue, "queue");
8974 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8975 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8976 				queue_num, UINT8);
8977 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8978 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8979 				rate, "rate");
8980 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8981 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8982 				rate_num, UINT16);
8983 
8984 cmdline_parse_inst_t cmd_queue_rate_limit = {
8985 	.f = cmd_queue_rate_limit_parsed,
8986 	.data = (void *)0,
8987 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8988 		"Set rate limit for a queue on port_id",
8989 	.tokens = {
8990 		(void *)&cmd_queue_rate_limit_set,
8991 		(void *)&cmd_queue_rate_limit_port,
8992 		(void *)&cmd_queue_rate_limit_portnum,
8993 		(void *)&cmd_queue_rate_limit_queue,
8994 		(void *)&cmd_queue_rate_limit_queuenum,
8995 		(void *)&cmd_queue_rate_limit_rate,
8996 		(void *)&cmd_queue_rate_limit_ratenum,
8997 		NULL,
8998 	},
8999 };
9000 
9001 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9002 struct cmd_vf_rate_limit_result {
9003 	cmdline_fixed_string_t set;
9004 	cmdline_fixed_string_t port;
9005 	uint16_t port_num;
9006 	cmdline_fixed_string_t vf;
9007 	uint8_t vf_num;
9008 	cmdline_fixed_string_t rate;
9009 	uint16_t rate_num;
9010 	cmdline_fixed_string_t q_msk;
9011 	uint64_t q_msk_val;
9012 };
9013 
9014 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9015 		__rte_unused struct cmdline *cl,
9016 		__rte_unused void *data)
9017 {
9018 	struct cmd_vf_rate_limit_result *res = parsed_result;
9019 	int ret = 0;
9020 
9021 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9022 		&& (strcmp(res->vf, "vf") == 0)
9023 		&& (strcmp(res->rate, "rate") == 0)
9024 		&& (strcmp(res->q_msk, "queue_mask") == 0))
9025 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
9026 					res->rate_num, res->q_msk_val);
9027 	if (ret < 0)
9028 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9029 
9030 }
9031 
9032 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9033 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9034 				set, "set");
9035 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9036 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9037 				port, "port");
9038 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9039 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9040 				port_num, UINT16);
9041 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9042 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9043 				vf, "vf");
9044 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9045 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9046 				vf_num, UINT8);
9047 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9048 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9049 				rate, "rate");
9050 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9051 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9052 				rate_num, UINT16);
9053 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9054 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9055 				q_msk, "queue_mask");
9056 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9057 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9058 				q_msk_val, UINT64);
9059 
9060 cmdline_parse_inst_t cmd_vf_rate_limit = {
9061 	.f = cmd_vf_rate_limit_parsed,
9062 	.data = (void *)0,
9063 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9064 		"queue_mask <queue_mask_value>: "
9065 		"Set rate limit for queues of VF on port_id",
9066 	.tokens = {
9067 		(void *)&cmd_vf_rate_limit_set,
9068 		(void *)&cmd_vf_rate_limit_port,
9069 		(void *)&cmd_vf_rate_limit_portnum,
9070 		(void *)&cmd_vf_rate_limit_vf,
9071 		(void *)&cmd_vf_rate_limit_vfnum,
9072 		(void *)&cmd_vf_rate_limit_rate,
9073 		(void *)&cmd_vf_rate_limit_ratenum,
9074 		(void *)&cmd_vf_rate_limit_q_msk,
9075 		(void *)&cmd_vf_rate_limit_q_msk_val,
9076 		NULL,
9077 	},
9078 };
9079 
9080 /* *** ADD TUNNEL FILTER OF A PORT *** */
9081 struct cmd_tunnel_filter_result {
9082 	cmdline_fixed_string_t cmd;
9083 	cmdline_fixed_string_t what;
9084 	portid_t port_id;
9085 	struct rte_ether_addr outer_mac;
9086 	struct rte_ether_addr inner_mac;
9087 	cmdline_ipaddr_t ip_value;
9088 	uint16_t inner_vlan;
9089 	cmdline_fixed_string_t tunnel_type;
9090 	cmdline_fixed_string_t filter_type;
9091 	uint32_t tenant_id;
9092 	uint16_t queue_num;
9093 };
9094 
9095 static void
9096 cmd_tunnel_filter_parsed(void *parsed_result,
9097 			  __rte_unused struct cmdline *cl,
9098 			  __rte_unused void *data)
9099 {
9100 	struct cmd_tunnel_filter_result *res = parsed_result;
9101 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9102 	int ret = 0;
9103 
9104 	memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9105 
9106 	rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9107 	rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9108 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
9109 
9110 	if (res->ip_value.family == AF_INET) {
9111 		tunnel_filter_conf.ip_addr.ipv4_addr =
9112 			res->ip_value.addr.ipv4.s_addr;
9113 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9114 	} else {
9115 		memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9116 			&(res->ip_value.addr.ipv6),
9117 			sizeof(struct in6_addr));
9118 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9119 	}
9120 
9121 	if (!strcmp(res->filter_type, "imac-ivlan"))
9122 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9123 	else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9124 		tunnel_filter_conf.filter_type =
9125 			RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9126 	else if (!strcmp(res->filter_type, "imac-tenid"))
9127 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9128 	else if (!strcmp(res->filter_type, "imac"))
9129 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9130 	else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9131 		tunnel_filter_conf.filter_type =
9132 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9133 	else if (!strcmp(res->filter_type, "oip"))
9134 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9135 	else if (!strcmp(res->filter_type, "iip"))
9136 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9137 	else {
9138 		printf("The filter type is not supported");
9139 		return;
9140 	}
9141 
9142 	if (!strcmp(res->tunnel_type, "vxlan"))
9143 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9144 	else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9145 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9146 	else if (!strcmp(res->tunnel_type, "nvgre"))
9147 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9148 	else if (!strcmp(res->tunnel_type, "ipingre"))
9149 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9150 	else {
9151 		printf("The tunnel type %s not supported.\n", res->tunnel_type);
9152 		return;
9153 	}
9154 
9155 	tunnel_filter_conf.tenant_id = res->tenant_id;
9156 	tunnel_filter_conf.queue_id = res->queue_num;
9157 	if (!strcmp(res->what, "add"))
9158 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9159 					RTE_ETH_FILTER_TUNNEL,
9160 					RTE_ETH_FILTER_ADD,
9161 					&tunnel_filter_conf);
9162 	else
9163 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9164 					RTE_ETH_FILTER_TUNNEL,
9165 					RTE_ETH_FILTER_DELETE,
9166 					&tunnel_filter_conf);
9167 	if (ret < 0)
9168 		printf("cmd_tunnel_filter_parsed error: (%s)\n",
9169 				strerror(-ret));
9170 
9171 }
9172 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9173 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9174 	cmd, "tunnel_filter");
9175 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9176 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9177 	what, "add#rm");
9178 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9179 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9180 	port_id, UINT16);
9181 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9182 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9183 	outer_mac);
9184 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9185 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9186 	inner_mac);
9187 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9188 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9189 	inner_vlan, UINT16);
9190 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9191 	TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9192 	ip_value);
9193 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9194 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9195 	tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9196 
9197 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9198 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9199 	filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9200 		"imac#omac-imac-tenid");
9201 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9202 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9203 	tenant_id, UINT32);
9204 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9205 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9206 	queue_num, UINT16);
9207 
9208 cmdline_parse_inst_t cmd_tunnel_filter = {
9209 	.f = cmd_tunnel_filter_parsed,
9210 	.data = (void *)0,
9211 	.help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9212 		"<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9213 		"imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9214 		"<queue_id>: Add/Rm tunnel filter of a port",
9215 	.tokens = {
9216 		(void *)&cmd_tunnel_filter_cmd,
9217 		(void *)&cmd_tunnel_filter_what,
9218 		(void *)&cmd_tunnel_filter_port_id,
9219 		(void *)&cmd_tunnel_filter_outer_mac,
9220 		(void *)&cmd_tunnel_filter_inner_mac,
9221 		(void *)&cmd_tunnel_filter_ip_value,
9222 		(void *)&cmd_tunnel_filter_innner_vlan,
9223 		(void *)&cmd_tunnel_filter_tunnel_type,
9224 		(void *)&cmd_tunnel_filter_filter_type,
9225 		(void *)&cmd_tunnel_filter_tenant_id,
9226 		(void *)&cmd_tunnel_filter_queue_num,
9227 		NULL,
9228 	},
9229 };
9230 
9231 /* *** CONFIGURE TUNNEL UDP PORT *** */
9232 struct cmd_tunnel_udp_config {
9233 	cmdline_fixed_string_t cmd;
9234 	cmdline_fixed_string_t what;
9235 	uint16_t udp_port;
9236 	portid_t port_id;
9237 };
9238 
9239 static void
9240 cmd_tunnel_udp_config_parsed(void *parsed_result,
9241 			  __rte_unused struct cmdline *cl,
9242 			  __rte_unused void *data)
9243 {
9244 	struct cmd_tunnel_udp_config *res = parsed_result;
9245 	struct rte_eth_udp_tunnel tunnel_udp;
9246 	int ret;
9247 
9248 	tunnel_udp.udp_port = res->udp_port;
9249 
9250 	if (!strcmp(res->cmd, "rx_vxlan_port"))
9251 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9252 
9253 	if (!strcmp(res->what, "add"))
9254 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9255 						      &tunnel_udp);
9256 	else
9257 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9258 							 &tunnel_udp);
9259 
9260 	if (ret < 0)
9261 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9262 }
9263 
9264 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9265 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9266 				cmd, "rx_vxlan_port");
9267 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9268 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9269 				what, "add#rm");
9270 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9271 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9272 				udp_port, UINT16);
9273 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9274 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9275 				port_id, UINT16);
9276 
9277 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9278 	.f = cmd_tunnel_udp_config_parsed,
9279 	.data = (void *)0,
9280 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9281 		"Add/Remove a tunneling UDP port filter",
9282 	.tokens = {
9283 		(void *)&cmd_tunnel_udp_config_cmd,
9284 		(void *)&cmd_tunnel_udp_config_what,
9285 		(void *)&cmd_tunnel_udp_config_udp_port,
9286 		(void *)&cmd_tunnel_udp_config_port_id,
9287 		NULL,
9288 	},
9289 };
9290 
9291 struct cmd_config_tunnel_udp_port {
9292 	cmdline_fixed_string_t port;
9293 	cmdline_fixed_string_t config;
9294 	portid_t port_id;
9295 	cmdline_fixed_string_t udp_tunnel_port;
9296 	cmdline_fixed_string_t action;
9297 	cmdline_fixed_string_t tunnel_type;
9298 	uint16_t udp_port;
9299 };
9300 
9301 static void
9302 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9303 			       __rte_unused struct cmdline *cl,
9304 			       __rte_unused void *data)
9305 {
9306 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9307 	struct rte_eth_udp_tunnel tunnel_udp;
9308 	int ret = 0;
9309 
9310 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9311 		return;
9312 
9313 	tunnel_udp.udp_port = res->udp_port;
9314 
9315 	if (!strcmp(res->tunnel_type, "vxlan")) {
9316 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9317 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9318 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9319 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9320 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9321 	} else {
9322 		printf("Invalid tunnel type\n");
9323 		return;
9324 	}
9325 
9326 	if (!strcmp(res->action, "add"))
9327 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9328 						      &tunnel_udp);
9329 	else
9330 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9331 							 &tunnel_udp);
9332 
9333 	if (ret < 0)
9334 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9335 }
9336 
9337 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9338 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9339 				 "port");
9340 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9341 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9342 				 "config");
9343 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9344 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9345 			      UINT16);
9346 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9347 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9348 				 udp_tunnel_port,
9349 				 "udp_tunnel_port");
9350 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9351 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9352 				 "add#rm");
9353 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9354 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9355 				 "vxlan#geneve#vxlan-gpe");
9356 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9357 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9358 			      UINT16);
9359 
9360 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9361 	.f = cmd_cfg_tunnel_udp_port_parsed,
9362 	.data = NULL,
9363 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9364 	.tokens = {
9365 		(void *)&cmd_config_tunnel_udp_port_port,
9366 		(void *)&cmd_config_tunnel_udp_port_config,
9367 		(void *)&cmd_config_tunnel_udp_port_port_id,
9368 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9369 		(void *)&cmd_config_tunnel_udp_port_action,
9370 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9371 		(void *)&cmd_config_tunnel_udp_port_value,
9372 		NULL,
9373 	},
9374 };
9375 
9376 /* *** GLOBAL CONFIG *** */
9377 struct cmd_global_config_result {
9378 	cmdline_fixed_string_t cmd;
9379 	portid_t port_id;
9380 	cmdline_fixed_string_t cfg_type;
9381 	uint8_t len;
9382 };
9383 
9384 static void
9385 cmd_global_config_parsed(void *parsed_result,
9386 			 __rte_unused struct cmdline *cl,
9387 			 __rte_unused void *data)
9388 {
9389 	struct cmd_global_config_result *res = parsed_result;
9390 	struct rte_eth_global_cfg conf;
9391 	int ret;
9392 
9393 	memset(&conf, 0, sizeof(conf));
9394 	conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9395 	conf.cfg.gre_key_len = res->len;
9396 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9397 				      RTE_ETH_FILTER_SET, &conf);
9398 #ifdef RTE_LIBRTE_I40E_PMD
9399 	if (ret == -ENOTSUP)
9400 		ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9401 #endif
9402 	if (ret != 0)
9403 		printf("Global config error\n");
9404 }
9405 
9406 cmdline_parse_token_string_t cmd_global_config_cmd =
9407 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9408 		"global_config");
9409 cmdline_parse_token_num_t cmd_global_config_port_id =
9410 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9411 			       UINT16);
9412 cmdline_parse_token_string_t cmd_global_config_type =
9413 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9414 		cfg_type, "gre-key-len");
9415 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9416 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9417 		len, UINT8);
9418 
9419 cmdline_parse_inst_t cmd_global_config = {
9420 	.f = cmd_global_config_parsed,
9421 	.data = (void *)NULL,
9422 	.help_str = "global_config <port_id> gre-key-len <key_len>",
9423 	.tokens = {
9424 		(void *)&cmd_global_config_cmd,
9425 		(void *)&cmd_global_config_port_id,
9426 		(void *)&cmd_global_config_type,
9427 		(void *)&cmd_global_config_gre_key_len,
9428 		NULL,
9429 	},
9430 };
9431 
9432 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9433 struct cmd_set_mirror_mask_result {
9434 	cmdline_fixed_string_t set;
9435 	cmdline_fixed_string_t port;
9436 	portid_t port_id;
9437 	cmdline_fixed_string_t mirror;
9438 	uint8_t rule_id;
9439 	cmdline_fixed_string_t what;
9440 	cmdline_fixed_string_t value;
9441 	cmdline_fixed_string_t dstpool;
9442 	uint8_t dstpool_id;
9443 	cmdline_fixed_string_t on;
9444 };
9445 
9446 cmdline_parse_token_string_t cmd_mirror_mask_set =
9447 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9448 				set, "set");
9449 cmdline_parse_token_string_t cmd_mirror_mask_port =
9450 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9451 				port, "port");
9452 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9453 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9454 				port_id, UINT16);
9455 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9456 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9457 				mirror, "mirror-rule");
9458 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9459 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9460 				rule_id, UINT8);
9461 cmdline_parse_token_string_t cmd_mirror_mask_what =
9462 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9463 				what, "pool-mirror-up#pool-mirror-down"
9464 				      "#vlan-mirror");
9465 cmdline_parse_token_string_t cmd_mirror_mask_value =
9466 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9467 				value, NULL);
9468 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9469 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9470 				dstpool, "dst-pool");
9471 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9472 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9473 				dstpool_id, UINT8);
9474 cmdline_parse_token_string_t cmd_mirror_mask_on =
9475 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9476 				on, "on#off");
9477 
9478 static void
9479 cmd_set_mirror_mask_parsed(void *parsed_result,
9480 		       __rte_unused struct cmdline *cl,
9481 		       __rte_unused void *data)
9482 {
9483 	int ret,nb_item,i;
9484 	struct cmd_set_mirror_mask_result *res = parsed_result;
9485 	struct rte_eth_mirror_conf mr_conf;
9486 
9487 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9488 
9489 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9490 
9491 	mr_conf.dst_pool = res->dstpool_id;
9492 
9493 	if (!strcmp(res->what, "pool-mirror-up")) {
9494 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9495 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9496 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9497 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9498 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9499 	} else if (!strcmp(res->what, "vlan-mirror")) {
9500 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9501 		nb_item = parse_item_list(res->value, "vlan",
9502 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9503 		if (nb_item <= 0)
9504 			return;
9505 
9506 		for (i = 0; i < nb_item; i++) {
9507 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9508 				printf("Invalid vlan_id: must be < 4096\n");
9509 				return;
9510 			}
9511 
9512 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9513 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9514 		}
9515 	}
9516 
9517 	if (!strcmp(res->on, "on"))
9518 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9519 						res->rule_id, 1);
9520 	else
9521 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9522 						res->rule_id, 0);
9523 	if (ret < 0)
9524 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9525 }
9526 
9527 cmdline_parse_inst_t cmd_set_mirror_mask = {
9528 		.f = cmd_set_mirror_mask_parsed,
9529 		.data = NULL,
9530 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9531 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9532 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9533 		.tokens = {
9534 			(void *)&cmd_mirror_mask_set,
9535 			(void *)&cmd_mirror_mask_port,
9536 			(void *)&cmd_mirror_mask_portid,
9537 			(void *)&cmd_mirror_mask_mirror,
9538 			(void *)&cmd_mirror_mask_ruleid,
9539 			(void *)&cmd_mirror_mask_what,
9540 			(void *)&cmd_mirror_mask_value,
9541 			(void *)&cmd_mirror_mask_dstpool,
9542 			(void *)&cmd_mirror_mask_poolid,
9543 			(void *)&cmd_mirror_mask_on,
9544 			NULL,
9545 		},
9546 };
9547 
9548 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9549 struct cmd_set_mirror_link_result {
9550 	cmdline_fixed_string_t set;
9551 	cmdline_fixed_string_t port;
9552 	portid_t port_id;
9553 	cmdline_fixed_string_t mirror;
9554 	uint8_t rule_id;
9555 	cmdline_fixed_string_t what;
9556 	cmdline_fixed_string_t dstpool;
9557 	uint8_t dstpool_id;
9558 	cmdline_fixed_string_t on;
9559 };
9560 
9561 cmdline_parse_token_string_t cmd_mirror_link_set =
9562 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9563 				 set, "set");
9564 cmdline_parse_token_string_t cmd_mirror_link_port =
9565 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9566 				port, "port");
9567 cmdline_parse_token_num_t cmd_mirror_link_portid =
9568 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9569 				port_id, UINT16);
9570 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9571 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9572 				mirror, "mirror-rule");
9573 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9574 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9575 			    rule_id, UINT8);
9576 cmdline_parse_token_string_t cmd_mirror_link_what =
9577 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9578 				what, "uplink-mirror#downlink-mirror");
9579 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9580 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9581 				dstpool, "dst-pool");
9582 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9583 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9584 				dstpool_id, UINT8);
9585 cmdline_parse_token_string_t cmd_mirror_link_on =
9586 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9587 				on, "on#off");
9588 
9589 static void
9590 cmd_set_mirror_link_parsed(void *parsed_result,
9591 		       __rte_unused struct cmdline *cl,
9592 		       __rte_unused void *data)
9593 {
9594 	int ret;
9595 	struct cmd_set_mirror_link_result *res = parsed_result;
9596 	struct rte_eth_mirror_conf mr_conf;
9597 
9598 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9599 	if (!strcmp(res->what, "uplink-mirror"))
9600 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9601 	else
9602 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9603 
9604 	mr_conf.dst_pool = res->dstpool_id;
9605 
9606 	if (!strcmp(res->on, "on"))
9607 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9608 						res->rule_id, 1);
9609 	else
9610 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9611 						res->rule_id, 0);
9612 
9613 	/* check the return value and print it if is < 0 */
9614 	if (ret < 0)
9615 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9616 
9617 }
9618 
9619 cmdline_parse_inst_t cmd_set_mirror_link = {
9620 		.f = cmd_set_mirror_link_parsed,
9621 		.data = NULL,
9622 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9623 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9624 		.tokens = {
9625 			(void *)&cmd_mirror_link_set,
9626 			(void *)&cmd_mirror_link_port,
9627 			(void *)&cmd_mirror_link_portid,
9628 			(void *)&cmd_mirror_link_mirror,
9629 			(void *)&cmd_mirror_link_ruleid,
9630 			(void *)&cmd_mirror_link_what,
9631 			(void *)&cmd_mirror_link_dstpool,
9632 			(void *)&cmd_mirror_link_poolid,
9633 			(void *)&cmd_mirror_link_on,
9634 			NULL,
9635 		},
9636 };
9637 
9638 /* *** RESET VM MIRROR RULE *** */
9639 struct cmd_rm_mirror_rule_result {
9640 	cmdline_fixed_string_t reset;
9641 	cmdline_fixed_string_t port;
9642 	portid_t port_id;
9643 	cmdline_fixed_string_t mirror;
9644 	uint8_t rule_id;
9645 };
9646 
9647 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9648 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9649 				 reset, "reset");
9650 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9651 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9652 				port, "port");
9653 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9654 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9655 				port_id, UINT16);
9656 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9657 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9658 				mirror, "mirror-rule");
9659 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9660 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9661 				rule_id, UINT8);
9662 
9663 static void
9664 cmd_reset_mirror_rule_parsed(void *parsed_result,
9665 		       __rte_unused struct cmdline *cl,
9666 		       __rte_unused void *data)
9667 {
9668 	int ret;
9669 	struct cmd_set_mirror_link_result *res = parsed_result;
9670         /* check rule_id */
9671 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9672 	if(ret < 0)
9673 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9674 }
9675 
9676 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9677 		.f = cmd_reset_mirror_rule_parsed,
9678 		.data = NULL,
9679 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9680 		.tokens = {
9681 			(void *)&cmd_rm_mirror_rule_reset,
9682 			(void *)&cmd_rm_mirror_rule_port,
9683 			(void *)&cmd_rm_mirror_rule_portid,
9684 			(void *)&cmd_rm_mirror_rule_mirror,
9685 			(void *)&cmd_rm_mirror_rule_ruleid,
9686 			NULL,
9687 		},
9688 };
9689 
9690 /* ******************************************************************************** */
9691 
9692 struct cmd_dump_result {
9693 	cmdline_fixed_string_t dump;
9694 };
9695 
9696 static void
9697 dump_struct_sizes(void)
9698 {
9699 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9700 	DUMP_SIZE(struct rte_mbuf);
9701 	DUMP_SIZE(struct rte_mempool);
9702 	DUMP_SIZE(struct rte_ring);
9703 #undef DUMP_SIZE
9704 }
9705 
9706 
9707 /* Dump the socket memory statistics on console */
9708 static void
9709 dump_socket_mem(FILE *f)
9710 {
9711 	struct rte_malloc_socket_stats socket_stats;
9712 	unsigned int i;
9713 	size_t total = 0;
9714 	size_t alloc = 0;
9715 	size_t free = 0;
9716 	unsigned int n_alloc = 0;
9717 	unsigned int n_free = 0;
9718 	static size_t last_allocs;
9719 	static size_t last_total;
9720 
9721 
9722 	for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9723 		if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9724 		    !socket_stats.heap_totalsz_bytes)
9725 			continue;
9726 		total += socket_stats.heap_totalsz_bytes;
9727 		alloc += socket_stats.heap_allocsz_bytes;
9728 		free += socket_stats.heap_freesz_bytes;
9729 		n_alloc += socket_stats.alloc_count;
9730 		n_free += socket_stats.free_count;
9731 		fprintf(f,
9732 			"Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9733 			i,
9734 			(double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9735 			(double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9736 			(double)socket_stats.heap_allocsz_bytes * 100 /
9737 			(double)socket_stats.heap_totalsz_bytes,
9738 			(double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9739 			socket_stats.alloc_count,
9740 			socket_stats.free_count);
9741 	}
9742 	fprintf(f,
9743 		"Total   : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9744 		(double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9745 		(double)alloc * 100 / (double)total,
9746 		(double)free / (1024 * 1024),
9747 		n_alloc, n_free);
9748 	if (last_allocs)
9749 		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9750 			((double)total - (double)last_total) / (1024 * 1024),
9751 			(double)(alloc - (double)last_allocs) / 1024 / 1024);
9752 	last_allocs = alloc;
9753 	last_total = total;
9754 }
9755 
9756 static void cmd_dump_parsed(void *parsed_result,
9757 			    __rte_unused struct cmdline *cl,
9758 			    __rte_unused void *data)
9759 {
9760 	struct cmd_dump_result *res = parsed_result;
9761 
9762 	if (!strcmp(res->dump, "dump_physmem"))
9763 		rte_dump_physmem_layout(stdout);
9764 	else if (!strcmp(res->dump, "dump_socket_mem"))
9765 		dump_socket_mem(stdout);
9766 	else if (!strcmp(res->dump, "dump_memzone"))
9767 		rte_memzone_dump(stdout);
9768 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9769 		dump_struct_sizes();
9770 	else if (!strcmp(res->dump, "dump_ring"))
9771 		rte_ring_list_dump(stdout);
9772 	else if (!strcmp(res->dump, "dump_mempool"))
9773 		rte_mempool_list_dump(stdout);
9774 	else if (!strcmp(res->dump, "dump_devargs"))
9775 		rte_devargs_dump(stdout);
9776 	else if (!strcmp(res->dump, "dump_log_types"))
9777 		rte_log_dump(stdout);
9778 }
9779 
9780 cmdline_parse_token_string_t cmd_dump_dump =
9781 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9782 		"dump_physmem#"
9783 		"dump_memzone#"
9784 		"dump_socket_mem#"
9785 		"dump_struct_sizes#"
9786 		"dump_ring#"
9787 		"dump_mempool#"
9788 		"dump_devargs#"
9789 		"dump_log_types");
9790 
9791 cmdline_parse_inst_t cmd_dump = {
9792 	.f = cmd_dump_parsed,  /* function to call */
9793 	.data = NULL,      /* 2nd arg of func */
9794 	.help_str = "Dump status",
9795 	.tokens = {        /* token list, NULL terminated */
9796 		(void *)&cmd_dump_dump,
9797 		NULL,
9798 	},
9799 };
9800 
9801 /* ******************************************************************************** */
9802 
9803 struct cmd_dump_one_result {
9804 	cmdline_fixed_string_t dump;
9805 	cmdline_fixed_string_t name;
9806 };
9807 
9808 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9809 				__rte_unused void *data)
9810 {
9811 	struct cmd_dump_one_result *res = parsed_result;
9812 
9813 	if (!strcmp(res->dump, "dump_ring")) {
9814 		struct rte_ring *r;
9815 		r = rte_ring_lookup(res->name);
9816 		if (r == NULL) {
9817 			cmdline_printf(cl, "Cannot find ring\n");
9818 			return;
9819 		}
9820 		rte_ring_dump(stdout, r);
9821 	} else if (!strcmp(res->dump, "dump_mempool")) {
9822 		struct rte_mempool *mp;
9823 		mp = rte_mempool_lookup(res->name);
9824 		if (mp == NULL) {
9825 			cmdline_printf(cl, "Cannot find mempool\n");
9826 			return;
9827 		}
9828 		rte_mempool_dump(stdout, mp);
9829 	}
9830 }
9831 
9832 cmdline_parse_token_string_t cmd_dump_one_dump =
9833 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9834 				 "dump_ring#dump_mempool");
9835 
9836 cmdline_parse_token_string_t cmd_dump_one_name =
9837 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9838 
9839 cmdline_parse_inst_t cmd_dump_one = {
9840 	.f = cmd_dump_one_parsed,  /* function to call */
9841 	.data = NULL,      /* 2nd arg of func */
9842 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9843 	.tokens = {        /* token list, NULL terminated */
9844 		(void *)&cmd_dump_one_dump,
9845 		(void *)&cmd_dump_one_name,
9846 		NULL,
9847 	},
9848 };
9849 
9850 /* *** Add/Del syn filter *** */
9851 struct cmd_syn_filter_result {
9852 	cmdline_fixed_string_t filter;
9853 	portid_t port_id;
9854 	cmdline_fixed_string_t ops;
9855 	cmdline_fixed_string_t priority;
9856 	cmdline_fixed_string_t high;
9857 	cmdline_fixed_string_t queue;
9858 	uint16_t queue_id;
9859 };
9860 
9861 static void
9862 cmd_syn_filter_parsed(void *parsed_result,
9863 			__rte_unused struct cmdline *cl,
9864 			__rte_unused void *data)
9865 {
9866 	struct cmd_syn_filter_result *res = parsed_result;
9867 	struct rte_eth_syn_filter syn_filter;
9868 	int ret = 0;
9869 
9870 	ret = rte_eth_dev_filter_supported(res->port_id,
9871 					RTE_ETH_FILTER_SYN);
9872 	if (ret < 0) {
9873 		printf("syn filter is not supported on port %u.\n",
9874 				res->port_id);
9875 		return;
9876 	}
9877 
9878 	memset(&syn_filter, 0, sizeof(syn_filter));
9879 
9880 	if (!strcmp(res->ops, "add")) {
9881 		if (!strcmp(res->high, "high"))
9882 			syn_filter.hig_pri = 1;
9883 		else
9884 			syn_filter.hig_pri = 0;
9885 
9886 		syn_filter.queue = res->queue_id;
9887 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9888 						RTE_ETH_FILTER_SYN,
9889 						RTE_ETH_FILTER_ADD,
9890 						&syn_filter);
9891 	} else
9892 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9893 						RTE_ETH_FILTER_SYN,
9894 						RTE_ETH_FILTER_DELETE,
9895 						&syn_filter);
9896 
9897 	if (ret < 0)
9898 		printf("syn filter programming error: (%s)\n",
9899 				strerror(-ret));
9900 }
9901 
9902 cmdline_parse_token_string_t cmd_syn_filter_filter =
9903 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9904 	filter, "syn_filter");
9905 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9906 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9907 	port_id, UINT16);
9908 cmdline_parse_token_string_t cmd_syn_filter_ops =
9909 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9910 	ops, "add#del");
9911 cmdline_parse_token_string_t cmd_syn_filter_priority =
9912 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9913 				priority, "priority");
9914 cmdline_parse_token_string_t cmd_syn_filter_high =
9915 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9916 				high, "high#low");
9917 cmdline_parse_token_string_t cmd_syn_filter_queue =
9918 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9919 				queue, "queue");
9920 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9921 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9922 				queue_id, UINT16);
9923 
9924 cmdline_parse_inst_t cmd_syn_filter = {
9925 	.f = cmd_syn_filter_parsed,
9926 	.data = NULL,
9927 	.help_str = "syn_filter <port_id> add|del priority high|low queue "
9928 		"<queue_id>: Add/Delete syn filter",
9929 	.tokens = {
9930 		(void *)&cmd_syn_filter_filter,
9931 		(void *)&cmd_syn_filter_port_id,
9932 		(void *)&cmd_syn_filter_ops,
9933 		(void *)&cmd_syn_filter_priority,
9934 		(void *)&cmd_syn_filter_high,
9935 		(void *)&cmd_syn_filter_queue,
9936 		(void *)&cmd_syn_filter_queue_id,
9937 		NULL,
9938 	},
9939 };
9940 
9941 /* *** queue region set *** */
9942 struct cmd_queue_region_result {
9943 	cmdline_fixed_string_t set;
9944 	cmdline_fixed_string_t port;
9945 	portid_t port_id;
9946 	cmdline_fixed_string_t cmd;
9947 	cmdline_fixed_string_t region;
9948 	uint8_t  region_id;
9949 	cmdline_fixed_string_t queue_start_index;
9950 	uint8_t  queue_id;
9951 	cmdline_fixed_string_t queue_num;
9952 	uint8_t  queue_num_value;
9953 };
9954 
9955 static void
9956 cmd_queue_region_parsed(void *parsed_result,
9957 			__rte_unused struct cmdline *cl,
9958 			__rte_unused void *data)
9959 {
9960 	struct cmd_queue_region_result *res = parsed_result;
9961 	int ret = -ENOTSUP;
9962 #ifdef RTE_LIBRTE_I40E_PMD
9963 	struct rte_pmd_i40e_queue_region_conf region_conf;
9964 	enum rte_pmd_i40e_queue_region_op op_type;
9965 #endif
9966 
9967 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9968 		return;
9969 
9970 #ifdef RTE_LIBRTE_I40E_PMD
9971 	memset(&region_conf, 0, sizeof(region_conf));
9972 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9973 	region_conf.region_id = res->region_id;
9974 	region_conf.queue_num = res->queue_num_value;
9975 	region_conf.queue_start_index = res->queue_id;
9976 
9977 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9978 				op_type, &region_conf);
9979 #endif
9980 
9981 	switch (ret) {
9982 	case 0:
9983 		break;
9984 	case -ENOTSUP:
9985 		printf("function not implemented or supported\n");
9986 		break;
9987 	default:
9988 		printf("queue region config error: (%s)\n", strerror(-ret));
9989 	}
9990 }
9991 
9992 cmdline_parse_token_string_t cmd_queue_region_set =
9993 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9994 		set, "set");
9995 cmdline_parse_token_string_t cmd_queue_region_port =
9996 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9997 cmdline_parse_token_num_t cmd_queue_region_port_id =
9998 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9999 				port_id, UINT16);
10000 cmdline_parse_token_string_t cmd_queue_region_cmd =
10001 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10002 				 cmd, "queue-region");
10003 cmdline_parse_token_string_t cmd_queue_region_id =
10004 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10005 				region, "region_id");
10006 cmdline_parse_token_num_t cmd_queue_region_index =
10007 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10008 				region_id, UINT8);
10009 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10010 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10011 				queue_start_index, "queue_start_index");
10012 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10013 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10014 				queue_id, UINT8);
10015 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10016 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10017 				queue_num, "queue_num");
10018 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10019 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10020 				queue_num_value, UINT8);
10021 
10022 cmdline_parse_inst_t cmd_queue_region = {
10023 	.f = cmd_queue_region_parsed,
10024 	.data = NULL,
10025 	.help_str = "set port <port_id> queue-region region_id <value> "
10026 		"queue_start_index <value> queue_num <value>: Set a queue region",
10027 	.tokens = {
10028 		(void *)&cmd_queue_region_set,
10029 		(void *)&cmd_queue_region_port,
10030 		(void *)&cmd_queue_region_port_id,
10031 		(void *)&cmd_queue_region_cmd,
10032 		(void *)&cmd_queue_region_id,
10033 		(void *)&cmd_queue_region_index,
10034 		(void *)&cmd_queue_region_queue_start_index,
10035 		(void *)&cmd_queue_region_queue_id,
10036 		(void *)&cmd_queue_region_queue_num,
10037 		(void *)&cmd_queue_region_queue_num_value,
10038 		NULL,
10039 	},
10040 };
10041 
10042 /* *** queue region and flowtype set *** */
10043 struct cmd_region_flowtype_result {
10044 	cmdline_fixed_string_t set;
10045 	cmdline_fixed_string_t port;
10046 	portid_t port_id;
10047 	cmdline_fixed_string_t cmd;
10048 	cmdline_fixed_string_t region;
10049 	uint8_t  region_id;
10050 	cmdline_fixed_string_t flowtype;
10051 	uint8_t  flowtype_id;
10052 };
10053 
10054 static void
10055 cmd_region_flowtype_parsed(void *parsed_result,
10056 			__rte_unused struct cmdline *cl,
10057 			__rte_unused void *data)
10058 {
10059 	struct cmd_region_flowtype_result *res = parsed_result;
10060 	int ret = -ENOTSUP;
10061 #ifdef RTE_LIBRTE_I40E_PMD
10062 	struct rte_pmd_i40e_queue_region_conf region_conf;
10063 	enum rte_pmd_i40e_queue_region_op op_type;
10064 #endif
10065 
10066 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10067 		return;
10068 
10069 #ifdef RTE_LIBRTE_I40E_PMD
10070 	memset(&region_conf, 0, sizeof(region_conf));
10071 
10072 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10073 	region_conf.region_id = res->region_id;
10074 	region_conf.hw_flowtype = res->flowtype_id;
10075 
10076 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10077 			op_type, &region_conf);
10078 #endif
10079 
10080 	switch (ret) {
10081 	case 0:
10082 		break;
10083 	case -ENOTSUP:
10084 		printf("function not implemented or supported\n");
10085 		break;
10086 	default:
10087 		printf("region flowtype config error: (%s)\n", strerror(-ret));
10088 	}
10089 }
10090 
10091 cmdline_parse_token_string_t cmd_region_flowtype_set =
10092 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10093 				set, "set");
10094 cmdline_parse_token_string_t cmd_region_flowtype_port =
10095 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10096 				port, "port");
10097 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10098 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10099 				port_id, UINT16);
10100 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10101 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10102 				cmd, "queue-region");
10103 cmdline_parse_token_string_t cmd_region_flowtype_index =
10104 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10105 				region, "region_id");
10106 cmdline_parse_token_num_t cmd_region_flowtype_id =
10107 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10108 				region_id, UINT8);
10109 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10110 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10111 				flowtype, "flowtype");
10112 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10113 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10114 				flowtype_id, UINT8);
10115 cmdline_parse_inst_t cmd_region_flowtype = {
10116 	.f = cmd_region_flowtype_parsed,
10117 	.data = NULL,
10118 	.help_str = "set port <port_id> queue-region region_id <value> "
10119 		"flowtype <value>: Set a flowtype region index",
10120 	.tokens = {
10121 		(void *)&cmd_region_flowtype_set,
10122 		(void *)&cmd_region_flowtype_port,
10123 		(void *)&cmd_region_flowtype_port_index,
10124 		(void *)&cmd_region_flowtype_cmd,
10125 		(void *)&cmd_region_flowtype_index,
10126 		(void *)&cmd_region_flowtype_id,
10127 		(void *)&cmd_region_flowtype_flow_index,
10128 		(void *)&cmd_region_flowtype_flow_id,
10129 		NULL,
10130 	},
10131 };
10132 
10133 /* *** User Priority (UP) to queue region (region_id) set *** */
10134 struct cmd_user_priority_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 user_priority;
10140 	uint8_t  user_priority_id;
10141 	cmdline_fixed_string_t region;
10142 	uint8_t  region_id;
10143 };
10144 
10145 static void
10146 cmd_user_priority_region_parsed(void *parsed_result,
10147 			__rte_unused struct cmdline *cl,
10148 			__rte_unused void *data)
10149 {
10150 	struct cmd_user_priority_region_result *res = parsed_result;
10151 	int ret = -ENOTSUP;
10152 #ifdef RTE_LIBRTE_I40E_PMD
10153 	struct rte_pmd_i40e_queue_region_conf region_conf;
10154 	enum rte_pmd_i40e_queue_region_op op_type;
10155 #endif
10156 
10157 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10158 		return;
10159 
10160 #ifdef RTE_LIBRTE_I40E_PMD
10161 	memset(&region_conf, 0, sizeof(region_conf));
10162 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10163 	region_conf.user_priority = res->user_priority_id;
10164 	region_conf.region_id = res->region_id;
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("user_priority region config error: (%s)\n",
10178 				strerror(-ret));
10179 	}
10180 }
10181 
10182 cmdline_parse_token_string_t cmd_user_priority_region_set =
10183 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10184 				set, "set");
10185 cmdline_parse_token_string_t cmd_user_priority_region_port =
10186 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10187 				port, "port");
10188 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10189 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10190 				port_id, UINT16);
10191 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10192 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10193 				cmd, "queue-region");
10194 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10195 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10196 				user_priority, "UP");
10197 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10198 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10199 				user_priority_id, UINT8);
10200 cmdline_parse_token_string_t cmd_user_priority_region_region =
10201 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10202 				region, "region_id");
10203 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10204 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10205 				region_id, UINT8);
10206 
10207 cmdline_parse_inst_t cmd_user_priority_region = {
10208 	.f = cmd_user_priority_region_parsed,
10209 	.data = NULL,
10210 	.help_str = "set port <port_id> queue-region UP <value> "
10211 		"region_id <value>: Set the mapping of User Priority (UP) "
10212 		"to queue region (region_id) ",
10213 	.tokens = {
10214 		(void *)&cmd_user_priority_region_set,
10215 		(void *)&cmd_user_priority_region_port,
10216 		(void *)&cmd_user_priority_region_port_index,
10217 		(void *)&cmd_user_priority_region_cmd,
10218 		(void *)&cmd_user_priority_region_UP,
10219 		(void *)&cmd_user_priority_region_UP_id,
10220 		(void *)&cmd_user_priority_region_region,
10221 		(void *)&cmd_user_priority_region_region_id,
10222 		NULL,
10223 	},
10224 };
10225 
10226 /* *** flush all queue region related configuration *** */
10227 struct cmd_flush_queue_region_result {
10228 	cmdline_fixed_string_t set;
10229 	cmdline_fixed_string_t port;
10230 	portid_t port_id;
10231 	cmdline_fixed_string_t cmd;
10232 	cmdline_fixed_string_t flush;
10233 	cmdline_fixed_string_t what;
10234 };
10235 
10236 static void
10237 cmd_flush_queue_region_parsed(void *parsed_result,
10238 			__rte_unused struct cmdline *cl,
10239 			__rte_unused void *data)
10240 {
10241 	struct cmd_flush_queue_region_result *res = parsed_result;
10242 	int ret = -ENOTSUP;
10243 #ifdef RTE_LIBRTE_I40E_PMD
10244 	struct rte_pmd_i40e_queue_region_conf region_conf;
10245 	enum rte_pmd_i40e_queue_region_op op_type;
10246 #endif
10247 
10248 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10249 		return;
10250 
10251 #ifdef RTE_LIBRTE_I40E_PMD
10252 	memset(&region_conf, 0, sizeof(region_conf));
10253 
10254 	if (strcmp(res->what, "on") == 0)
10255 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10256 	else
10257 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10258 
10259 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10260 				op_type, &region_conf);
10261 #endif
10262 
10263 	switch (ret) {
10264 	case 0:
10265 		break;
10266 	case -ENOTSUP:
10267 		printf("function not implemented or supported\n");
10268 		break;
10269 	default:
10270 		printf("queue region config flush error: (%s)\n",
10271 				strerror(-ret));
10272 	}
10273 }
10274 
10275 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10276 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10277 				set, "set");
10278 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10279 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10280 				port, "port");
10281 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10282 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10283 				port_id, UINT16);
10284 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10285 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10286 				cmd, "queue-region");
10287 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10288 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10289 				flush, "flush");
10290 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10291 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10292 				what, "on#off");
10293 
10294 cmdline_parse_inst_t cmd_flush_queue_region = {
10295 	.f = cmd_flush_queue_region_parsed,
10296 	.data = NULL,
10297 	.help_str = "set port <port_id> queue-region flush on|off"
10298 		": flush all queue region related configuration",
10299 	.tokens = {
10300 		(void *)&cmd_flush_queue_region_set,
10301 		(void *)&cmd_flush_queue_region_port,
10302 		(void *)&cmd_flush_queue_region_port_index,
10303 		(void *)&cmd_flush_queue_region_cmd,
10304 		(void *)&cmd_flush_queue_region_flush,
10305 		(void *)&cmd_flush_queue_region_what,
10306 		NULL,
10307 	},
10308 };
10309 
10310 /* *** get all queue region related configuration info *** */
10311 struct cmd_show_queue_region_info {
10312 	cmdline_fixed_string_t show;
10313 	cmdline_fixed_string_t port;
10314 	portid_t port_id;
10315 	cmdline_fixed_string_t cmd;
10316 };
10317 
10318 static void
10319 cmd_show_queue_region_info_parsed(void *parsed_result,
10320 			__rte_unused struct cmdline *cl,
10321 			__rte_unused void *data)
10322 {
10323 	struct cmd_show_queue_region_info *res = parsed_result;
10324 	int ret = -ENOTSUP;
10325 #ifdef RTE_LIBRTE_I40E_PMD
10326 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10327 	enum rte_pmd_i40e_queue_region_op op_type;
10328 #endif
10329 
10330 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10331 		return;
10332 
10333 #ifdef RTE_LIBRTE_I40E_PMD
10334 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10335 
10336 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10337 
10338 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10339 					op_type, &rte_pmd_regions);
10340 
10341 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10342 #endif
10343 
10344 	switch (ret) {
10345 	case 0:
10346 		break;
10347 	case -ENOTSUP:
10348 		printf("function not implemented or supported\n");
10349 		break;
10350 	default:
10351 		printf("queue region config info show error: (%s)\n",
10352 				strerror(-ret));
10353 	}
10354 }
10355 
10356 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10357 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10358 				show, "show");
10359 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10360 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10361 				port, "port");
10362 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10363 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10364 				port_id, UINT16);
10365 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10366 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10367 				cmd, "queue-region");
10368 
10369 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10370 	.f = cmd_show_queue_region_info_parsed,
10371 	.data = NULL,
10372 	.help_str = "show port <port_id> queue-region"
10373 		": show all queue region related configuration info",
10374 	.tokens = {
10375 		(void *)&cmd_show_queue_region_info_get,
10376 		(void *)&cmd_show_queue_region_info_port,
10377 		(void *)&cmd_show_queue_region_info_port_index,
10378 		(void *)&cmd_show_queue_region_info_cmd,
10379 		NULL,
10380 	},
10381 };
10382 
10383 /* *** ADD/REMOVE A 2tuple FILTER *** */
10384 struct cmd_2tuple_filter_result {
10385 	cmdline_fixed_string_t filter;
10386 	portid_t port_id;
10387 	cmdline_fixed_string_t ops;
10388 	cmdline_fixed_string_t dst_port;
10389 	uint16_t dst_port_value;
10390 	cmdline_fixed_string_t protocol;
10391 	uint8_t protocol_value;
10392 	cmdline_fixed_string_t mask;
10393 	uint8_t  mask_value;
10394 	cmdline_fixed_string_t tcp_flags;
10395 	uint8_t tcp_flags_value;
10396 	cmdline_fixed_string_t priority;
10397 	uint8_t  priority_value;
10398 	cmdline_fixed_string_t queue;
10399 	uint16_t  queue_id;
10400 };
10401 
10402 static void
10403 cmd_2tuple_filter_parsed(void *parsed_result,
10404 			__rte_unused struct cmdline *cl,
10405 			__rte_unused void *data)
10406 {
10407 	struct rte_eth_ntuple_filter filter;
10408 	struct cmd_2tuple_filter_result *res = parsed_result;
10409 	int ret = 0;
10410 
10411 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10412 	if (ret < 0) {
10413 		printf("ntuple filter is not supported on port %u.\n",
10414 			res->port_id);
10415 		return;
10416 	}
10417 
10418 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10419 
10420 	filter.flags = RTE_2TUPLE_FLAGS;
10421 	filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10422 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10423 	filter.proto = res->protocol_value;
10424 	filter.priority = res->priority_value;
10425 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10426 		printf("nonzero tcp_flags is only meaningful"
10427 			" when protocol is TCP.\n");
10428 		return;
10429 	}
10430 	if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10431 		printf("invalid TCP flags.\n");
10432 		return;
10433 	}
10434 
10435 	if (res->tcp_flags_value != 0) {
10436 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10437 		filter.tcp_flags = res->tcp_flags_value;
10438 	}
10439 
10440 	/* need convert to big endian. */
10441 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10442 	filter.queue = res->queue_id;
10443 
10444 	if (!strcmp(res->ops, "add"))
10445 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10446 				RTE_ETH_FILTER_NTUPLE,
10447 				RTE_ETH_FILTER_ADD,
10448 				&filter);
10449 	else
10450 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10451 				RTE_ETH_FILTER_NTUPLE,
10452 				RTE_ETH_FILTER_DELETE,
10453 				&filter);
10454 	if (ret < 0)
10455 		printf("2tuple filter programming error: (%s)\n",
10456 			strerror(-ret));
10457 
10458 }
10459 
10460 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10461 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10462 				 filter, "2tuple_filter");
10463 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10464 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10465 				port_id, UINT16);
10466 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10467 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10468 				 ops, "add#del");
10469 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10470 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10471 				dst_port, "dst_port");
10472 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10473 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10474 				dst_port_value, UINT16);
10475 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10476 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10477 				protocol, "protocol");
10478 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10479 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10480 				protocol_value, UINT8);
10481 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10482 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10483 				mask, "mask");
10484 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10485 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10486 				mask_value, INT8);
10487 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10488 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10489 				tcp_flags, "tcp_flags");
10490 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10491 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10492 				tcp_flags_value, UINT8);
10493 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10494 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10495 				priority, "priority");
10496 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10497 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10498 				priority_value, UINT8);
10499 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10500 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10501 				queue, "queue");
10502 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10503 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10504 				queue_id, UINT16);
10505 
10506 cmdline_parse_inst_t cmd_2tuple_filter = {
10507 	.f = cmd_2tuple_filter_parsed,
10508 	.data = NULL,
10509 	.help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10510 		"<value> mask <value> tcp_flags <value> priority <value> queue "
10511 		"<queue_id>: Add a 2tuple filter",
10512 	.tokens = {
10513 		(void *)&cmd_2tuple_filter_filter,
10514 		(void *)&cmd_2tuple_filter_port_id,
10515 		(void *)&cmd_2tuple_filter_ops,
10516 		(void *)&cmd_2tuple_filter_dst_port,
10517 		(void *)&cmd_2tuple_filter_dst_port_value,
10518 		(void *)&cmd_2tuple_filter_protocol,
10519 		(void *)&cmd_2tuple_filter_protocol_value,
10520 		(void *)&cmd_2tuple_filter_mask,
10521 		(void *)&cmd_2tuple_filter_mask_value,
10522 		(void *)&cmd_2tuple_filter_tcp_flags,
10523 		(void *)&cmd_2tuple_filter_tcp_flags_value,
10524 		(void *)&cmd_2tuple_filter_priority,
10525 		(void *)&cmd_2tuple_filter_priority_value,
10526 		(void *)&cmd_2tuple_filter_queue,
10527 		(void *)&cmd_2tuple_filter_queue_id,
10528 		NULL,
10529 	},
10530 };
10531 
10532 /* *** ADD/REMOVE A 5tuple FILTER *** */
10533 struct cmd_5tuple_filter_result {
10534 	cmdline_fixed_string_t filter;
10535 	portid_t port_id;
10536 	cmdline_fixed_string_t ops;
10537 	cmdline_fixed_string_t dst_ip;
10538 	cmdline_ipaddr_t dst_ip_value;
10539 	cmdline_fixed_string_t src_ip;
10540 	cmdline_ipaddr_t src_ip_value;
10541 	cmdline_fixed_string_t dst_port;
10542 	uint16_t dst_port_value;
10543 	cmdline_fixed_string_t src_port;
10544 	uint16_t src_port_value;
10545 	cmdline_fixed_string_t protocol;
10546 	uint8_t protocol_value;
10547 	cmdline_fixed_string_t mask;
10548 	uint8_t  mask_value;
10549 	cmdline_fixed_string_t tcp_flags;
10550 	uint8_t tcp_flags_value;
10551 	cmdline_fixed_string_t priority;
10552 	uint8_t  priority_value;
10553 	cmdline_fixed_string_t queue;
10554 	uint16_t  queue_id;
10555 };
10556 
10557 static void
10558 cmd_5tuple_filter_parsed(void *parsed_result,
10559 			__rte_unused struct cmdline *cl,
10560 			__rte_unused void *data)
10561 {
10562 	struct rte_eth_ntuple_filter filter;
10563 	struct cmd_5tuple_filter_result *res = parsed_result;
10564 	int ret = 0;
10565 
10566 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10567 	if (ret < 0) {
10568 		printf("ntuple filter is not supported on port %u.\n",
10569 			res->port_id);
10570 		return;
10571 	}
10572 
10573 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10574 
10575 	filter.flags = RTE_5TUPLE_FLAGS;
10576 	filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10577 	filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10578 	filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10579 	filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10580 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10581 	filter.proto = res->protocol_value;
10582 	filter.priority = res->priority_value;
10583 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10584 		printf("nonzero tcp_flags is only meaningful"
10585 			" when protocol is TCP.\n");
10586 		return;
10587 	}
10588 	if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10589 		printf("invalid TCP flags.\n");
10590 		return;
10591 	}
10592 
10593 	if (res->tcp_flags_value != 0) {
10594 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10595 		filter.tcp_flags = res->tcp_flags_value;
10596 	}
10597 
10598 	if (res->dst_ip_value.family == AF_INET)
10599 		/* no need to convert, already big endian. */
10600 		filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10601 	else {
10602 		if (filter.dst_ip_mask == 0) {
10603 			printf("can not support ipv6 involved compare.\n");
10604 			return;
10605 		}
10606 		filter.dst_ip = 0;
10607 	}
10608 
10609 	if (res->src_ip_value.family == AF_INET)
10610 		/* no need to convert, already big endian. */
10611 		filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10612 	else {
10613 		if (filter.src_ip_mask == 0) {
10614 			printf("can not support ipv6 involved compare.\n");
10615 			return;
10616 		}
10617 		filter.src_ip = 0;
10618 	}
10619 	/* need convert to big endian. */
10620 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10621 	filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10622 	filter.queue = res->queue_id;
10623 
10624 	if (!strcmp(res->ops, "add"))
10625 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10626 				RTE_ETH_FILTER_NTUPLE,
10627 				RTE_ETH_FILTER_ADD,
10628 				&filter);
10629 	else
10630 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10631 				RTE_ETH_FILTER_NTUPLE,
10632 				RTE_ETH_FILTER_DELETE,
10633 				&filter);
10634 	if (ret < 0)
10635 		printf("5tuple filter programming error: (%s)\n",
10636 			strerror(-ret));
10637 }
10638 
10639 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10640 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10641 				 filter, "5tuple_filter");
10642 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10643 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10644 				port_id, UINT16);
10645 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10646 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10647 				 ops, "add#del");
10648 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10649 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10650 				dst_ip, "dst_ip");
10651 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10652 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10653 				dst_ip_value);
10654 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10655 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10656 				src_ip, "src_ip");
10657 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10658 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10659 				src_ip_value);
10660 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10661 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10662 				dst_port, "dst_port");
10663 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10664 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10665 				dst_port_value, UINT16);
10666 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10667 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10668 				src_port, "src_port");
10669 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10670 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10671 				src_port_value, UINT16);
10672 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10673 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10674 				protocol, "protocol");
10675 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10676 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10677 				protocol_value, UINT8);
10678 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10679 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10680 				mask, "mask");
10681 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10682 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10683 				mask_value, INT8);
10684 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10685 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10686 				tcp_flags, "tcp_flags");
10687 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10688 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10689 				tcp_flags_value, UINT8);
10690 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10691 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10692 				priority, "priority");
10693 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10694 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10695 				priority_value, UINT8);
10696 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10697 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10698 				queue, "queue");
10699 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10700 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10701 				queue_id, UINT16);
10702 
10703 cmdline_parse_inst_t cmd_5tuple_filter = {
10704 	.f = cmd_5tuple_filter_parsed,
10705 	.data = NULL,
10706 	.help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10707 		"src_ip <value> dst_port <value> src_port <value> "
10708 		"protocol <value>  mask <value> tcp_flags <value> "
10709 		"priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10710 	.tokens = {
10711 		(void *)&cmd_5tuple_filter_filter,
10712 		(void *)&cmd_5tuple_filter_port_id,
10713 		(void *)&cmd_5tuple_filter_ops,
10714 		(void *)&cmd_5tuple_filter_dst_ip,
10715 		(void *)&cmd_5tuple_filter_dst_ip_value,
10716 		(void *)&cmd_5tuple_filter_src_ip,
10717 		(void *)&cmd_5tuple_filter_src_ip_value,
10718 		(void *)&cmd_5tuple_filter_dst_port,
10719 		(void *)&cmd_5tuple_filter_dst_port_value,
10720 		(void *)&cmd_5tuple_filter_src_port,
10721 		(void *)&cmd_5tuple_filter_src_port_value,
10722 		(void *)&cmd_5tuple_filter_protocol,
10723 		(void *)&cmd_5tuple_filter_protocol_value,
10724 		(void *)&cmd_5tuple_filter_mask,
10725 		(void *)&cmd_5tuple_filter_mask_value,
10726 		(void *)&cmd_5tuple_filter_tcp_flags,
10727 		(void *)&cmd_5tuple_filter_tcp_flags_value,
10728 		(void *)&cmd_5tuple_filter_priority,
10729 		(void *)&cmd_5tuple_filter_priority_value,
10730 		(void *)&cmd_5tuple_filter_queue,
10731 		(void *)&cmd_5tuple_filter_queue_id,
10732 		NULL,
10733 	},
10734 };
10735 
10736 /* *** ADD/REMOVE A flex FILTER *** */
10737 struct cmd_flex_filter_result {
10738 	cmdline_fixed_string_t filter;
10739 	cmdline_fixed_string_t ops;
10740 	portid_t port_id;
10741 	cmdline_fixed_string_t len;
10742 	uint8_t len_value;
10743 	cmdline_fixed_string_t bytes;
10744 	cmdline_fixed_string_t bytes_value;
10745 	cmdline_fixed_string_t mask;
10746 	cmdline_fixed_string_t mask_value;
10747 	cmdline_fixed_string_t priority;
10748 	uint8_t priority_value;
10749 	cmdline_fixed_string_t queue;
10750 	uint16_t queue_id;
10751 };
10752 
10753 static int xdigit2val(unsigned char c)
10754 {
10755 	int val;
10756 	if (isdigit(c))
10757 		val = c - '0';
10758 	else if (isupper(c))
10759 		val = c - 'A' + 10;
10760 	else
10761 		val = c - 'a' + 10;
10762 	return val;
10763 }
10764 
10765 static void
10766 cmd_flex_filter_parsed(void *parsed_result,
10767 			  __rte_unused struct cmdline *cl,
10768 			  __rte_unused void *data)
10769 {
10770 	int ret = 0;
10771 	struct rte_eth_flex_filter filter;
10772 	struct cmd_flex_filter_result *res = parsed_result;
10773 	char *bytes_ptr, *mask_ptr;
10774 	uint16_t len, i, j = 0;
10775 	char c;
10776 	int val;
10777 	uint8_t byte = 0;
10778 
10779 	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10780 		printf("the len exceed the max length 128\n");
10781 		return;
10782 	}
10783 	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10784 	filter.len = res->len_value;
10785 	filter.priority = res->priority_value;
10786 	filter.queue = res->queue_id;
10787 	bytes_ptr = res->bytes_value;
10788 	mask_ptr = res->mask_value;
10789 
10790 	 /* translate bytes string to array. */
10791 	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10792 		(bytes_ptr[1] == 'X')))
10793 		bytes_ptr += 2;
10794 	len = strnlen(bytes_ptr, res->len_value * 2);
10795 	if (len == 0 || (len % 8 != 0)) {
10796 		printf("please check len and bytes input\n");
10797 		return;
10798 	}
10799 	for (i = 0; i < len; i++) {
10800 		c = bytes_ptr[i];
10801 		if (isxdigit(c) == 0) {
10802 			/* invalid characters. */
10803 			printf("invalid input\n");
10804 			return;
10805 		}
10806 		val = xdigit2val(c);
10807 		if (i % 2) {
10808 			byte |= val;
10809 			filter.bytes[j] = byte;
10810 			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10811 			j++;
10812 			byte = 0;
10813 		} else
10814 			byte |= val << 4;
10815 	}
10816 	printf("\n");
10817 	 /* translate mask string to uint8_t array. */
10818 	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10819 		(mask_ptr[1] == 'X')))
10820 		mask_ptr += 2;
10821 	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10822 	if (len == 0) {
10823 		printf("invalid input\n");
10824 		return;
10825 	}
10826 	j = 0;
10827 	byte = 0;
10828 	for (i = 0; i < len; i++) {
10829 		c = mask_ptr[i];
10830 		if (isxdigit(c) == 0) {
10831 			/* invalid characters. */
10832 			printf("invalid input\n");
10833 			return;
10834 		}
10835 		val = xdigit2val(c);
10836 		if (i % 2) {
10837 			byte |= val;
10838 			filter.mask[j] = byte;
10839 			printf("mask[%d]:%02x ", j, filter.mask[j]);
10840 			j++;
10841 			byte = 0;
10842 		} else
10843 			byte |= val << 4;
10844 	}
10845 	printf("\n");
10846 
10847 	if (!strcmp(res->ops, "add"))
10848 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10849 				RTE_ETH_FILTER_FLEXIBLE,
10850 				RTE_ETH_FILTER_ADD,
10851 				&filter);
10852 	else
10853 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10854 				RTE_ETH_FILTER_FLEXIBLE,
10855 				RTE_ETH_FILTER_DELETE,
10856 				&filter);
10857 
10858 	if (ret < 0)
10859 		printf("flex filter setting error: (%s)\n", strerror(-ret));
10860 }
10861 
10862 cmdline_parse_token_string_t cmd_flex_filter_filter =
10863 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10864 				filter, "flex_filter");
10865 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10866 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10867 				port_id, UINT16);
10868 cmdline_parse_token_string_t cmd_flex_filter_ops =
10869 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10870 				ops, "add#del");
10871 cmdline_parse_token_string_t cmd_flex_filter_len =
10872 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10873 				len, "len");
10874 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10875 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10876 				len_value, UINT8);
10877 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10878 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10879 				bytes, "bytes");
10880 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10881 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10882 				bytes_value, NULL);
10883 cmdline_parse_token_string_t cmd_flex_filter_mask =
10884 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10885 				mask, "mask");
10886 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10887 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10888 				mask_value, NULL);
10889 cmdline_parse_token_string_t cmd_flex_filter_priority =
10890 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10891 				priority, "priority");
10892 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10893 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10894 				priority_value, UINT8);
10895 cmdline_parse_token_string_t cmd_flex_filter_queue =
10896 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10897 				queue, "queue");
10898 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10899 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10900 				queue_id, UINT16);
10901 cmdline_parse_inst_t cmd_flex_filter = {
10902 	.f = cmd_flex_filter_parsed,
10903 	.data = NULL,
10904 	.help_str = "flex_filter <port_id> add|del len <value> bytes "
10905 		"<value> mask <value> priority <value> queue <queue_id>: "
10906 		"Add/Del a flex filter",
10907 	.tokens = {
10908 		(void *)&cmd_flex_filter_filter,
10909 		(void *)&cmd_flex_filter_port_id,
10910 		(void *)&cmd_flex_filter_ops,
10911 		(void *)&cmd_flex_filter_len,
10912 		(void *)&cmd_flex_filter_len_value,
10913 		(void *)&cmd_flex_filter_bytes,
10914 		(void *)&cmd_flex_filter_bytes_value,
10915 		(void *)&cmd_flex_filter_mask,
10916 		(void *)&cmd_flex_filter_mask_value,
10917 		(void *)&cmd_flex_filter_priority,
10918 		(void *)&cmd_flex_filter_priority_value,
10919 		(void *)&cmd_flex_filter_queue,
10920 		(void *)&cmd_flex_filter_queue_id,
10921 		NULL,
10922 	},
10923 };
10924 
10925 /* *** Filters Control *** */
10926 
10927 /* *** deal with ethertype filter *** */
10928 struct cmd_ethertype_filter_result {
10929 	cmdline_fixed_string_t filter;
10930 	portid_t port_id;
10931 	cmdline_fixed_string_t ops;
10932 	cmdline_fixed_string_t mac;
10933 	struct rte_ether_addr mac_addr;
10934 	cmdline_fixed_string_t ethertype;
10935 	uint16_t ethertype_value;
10936 	cmdline_fixed_string_t drop;
10937 	cmdline_fixed_string_t queue;
10938 	uint16_t  queue_id;
10939 };
10940 
10941 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10942 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10943 				 filter, "ethertype_filter");
10944 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10945 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10946 			      port_id, UINT16);
10947 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10948 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10949 				 ops, "add#del");
10950 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10951 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10952 				 mac, "mac_addr#mac_ignr");
10953 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10954 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10955 				     mac_addr);
10956 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10957 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10958 				 ethertype, "ethertype");
10959 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10960 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10961 			      ethertype_value, UINT16);
10962 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10963 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10964 				 drop, "drop#fwd");
10965 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10966 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10967 				 queue, "queue");
10968 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10969 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10970 			      queue_id, UINT16);
10971 
10972 static void
10973 cmd_ethertype_filter_parsed(void *parsed_result,
10974 			  __rte_unused struct cmdline *cl,
10975 			  __rte_unused void *data)
10976 {
10977 	struct cmd_ethertype_filter_result *res = parsed_result;
10978 	struct rte_eth_ethertype_filter filter;
10979 	int ret = 0;
10980 
10981 	ret = rte_eth_dev_filter_supported(res->port_id,
10982 			RTE_ETH_FILTER_ETHERTYPE);
10983 	if (ret < 0) {
10984 		printf("ethertype filter is not supported on port %u.\n",
10985 			res->port_id);
10986 		return;
10987 	}
10988 
10989 	memset(&filter, 0, sizeof(filter));
10990 	if (!strcmp(res->mac, "mac_addr")) {
10991 		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10992 		rte_memcpy(&filter.mac_addr, &res->mac_addr,
10993 			sizeof(struct rte_ether_addr));
10994 	}
10995 	if (!strcmp(res->drop, "drop"))
10996 		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10997 	filter.ether_type = res->ethertype_value;
10998 	filter.queue = res->queue_id;
10999 
11000 	if (!strcmp(res->ops, "add"))
11001 		ret = rte_eth_dev_filter_ctrl(res->port_id,
11002 				RTE_ETH_FILTER_ETHERTYPE,
11003 				RTE_ETH_FILTER_ADD,
11004 				&filter);
11005 	else
11006 		ret = rte_eth_dev_filter_ctrl(res->port_id,
11007 				RTE_ETH_FILTER_ETHERTYPE,
11008 				RTE_ETH_FILTER_DELETE,
11009 				&filter);
11010 	if (ret < 0)
11011 		printf("ethertype filter programming error: (%s)\n",
11012 			strerror(-ret));
11013 }
11014 
11015 cmdline_parse_inst_t cmd_ethertype_filter = {
11016 	.f = cmd_ethertype_filter_parsed,
11017 	.data = NULL,
11018 	.help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11019 		"<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11020 		"Add or delete an ethertype filter entry",
11021 	.tokens = {
11022 		(void *)&cmd_ethertype_filter_filter,
11023 		(void *)&cmd_ethertype_filter_port_id,
11024 		(void *)&cmd_ethertype_filter_ops,
11025 		(void *)&cmd_ethertype_filter_mac,
11026 		(void *)&cmd_ethertype_filter_mac_addr,
11027 		(void *)&cmd_ethertype_filter_ethertype,
11028 		(void *)&cmd_ethertype_filter_ethertype_value,
11029 		(void *)&cmd_ethertype_filter_drop,
11030 		(void *)&cmd_ethertype_filter_queue,
11031 		(void *)&cmd_ethertype_filter_queue_id,
11032 		NULL,
11033 	},
11034 };
11035 
11036 /* *** deal with flow director filter *** */
11037 struct cmd_flow_director_result {
11038 	cmdline_fixed_string_t flow_director_filter;
11039 	portid_t port_id;
11040 	cmdline_fixed_string_t mode;
11041 	cmdline_fixed_string_t mode_value;
11042 	cmdline_fixed_string_t ops;
11043 	cmdline_fixed_string_t flow;
11044 	cmdline_fixed_string_t flow_type;
11045 	cmdline_fixed_string_t ether;
11046 	uint16_t ether_type;
11047 	cmdline_fixed_string_t src;
11048 	cmdline_ipaddr_t ip_src;
11049 	uint16_t port_src;
11050 	cmdline_fixed_string_t dst;
11051 	cmdline_ipaddr_t ip_dst;
11052 	uint16_t port_dst;
11053 	cmdline_fixed_string_t verify_tag;
11054 	uint32_t verify_tag_value;
11055 	cmdline_fixed_string_t tos;
11056 	uint8_t tos_value;
11057 	cmdline_fixed_string_t proto;
11058 	uint8_t proto_value;
11059 	cmdline_fixed_string_t ttl;
11060 	uint8_t ttl_value;
11061 	cmdline_fixed_string_t vlan;
11062 	uint16_t vlan_value;
11063 	cmdline_fixed_string_t flexbytes;
11064 	cmdline_fixed_string_t flexbytes_value;
11065 	cmdline_fixed_string_t pf_vf;
11066 	cmdline_fixed_string_t drop;
11067 	cmdline_fixed_string_t queue;
11068 	uint16_t  queue_id;
11069 	cmdline_fixed_string_t fd_id;
11070 	uint32_t  fd_id_value;
11071 	cmdline_fixed_string_t mac;
11072 	struct rte_ether_addr mac_addr;
11073 	cmdline_fixed_string_t tunnel;
11074 	cmdline_fixed_string_t tunnel_type;
11075 	cmdline_fixed_string_t tunnel_id;
11076 	uint32_t tunnel_id_value;
11077 	cmdline_fixed_string_t packet;
11078 	char filepath[];
11079 };
11080 
11081 static inline int
11082 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11083 {
11084 	char s[256];
11085 	const char *p, *p0 = q_arg;
11086 	char *end;
11087 	unsigned long int_fld;
11088 	char *str_fld[max_num];
11089 	int i;
11090 	unsigned size;
11091 	int ret = -1;
11092 
11093 	p = strchr(p0, '(');
11094 	if (p == NULL)
11095 		return -1;
11096 	++p;
11097 	p0 = strchr(p, ')');
11098 	if (p0 == NULL)
11099 		return -1;
11100 
11101 	size = p0 - p;
11102 	if (size >= sizeof(s))
11103 		return -1;
11104 
11105 	snprintf(s, sizeof(s), "%.*s", size, p);
11106 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11107 	if (ret < 0 || ret > max_num)
11108 		return -1;
11109 	for (i = 0; i < ret; i++) {
11110 		errno = 0;
11111 		int_fld = strtoul(str_fld[i], &end, 0);
11112 		if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11113 			return -1;
11114 		flexbytes[i] = (uint8_t)int_fld;
11115 	}
11116 	return ret;
11117 }
11118 
11119 static uint16_t
11120 str2flowtype(char *string)
11121 {
11122 	uint8_t i = 0;
11123 	static const struct {
11124 		char str[32];
11125 		uint16_t type;
11126 	} flowtype_str[] = {
11127 		{"raw", RTE_ETH_FLOW_RAW},
11128 		{"ipv4", RTE_ETH_FLOW_IPV4},
11129 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11130 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11131 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11132 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11133 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11134 		{"ipv6", RTE_ETH_FLOW_IPV6},
11135 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11136 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11137 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11138 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11139 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11140 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11141 	};
11142 
11143 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11144 		if (!strcmp(flowtype_str[i].str, string))
11145 			return flowtype_str[i].type;
11146 	}
11147 
11148 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11149 		return (uint16_t)atoi(string);
11150 
11151 	return RTE_ETH_FLOW_UNKNOWN;
11152 }
11153 
11154 static enum rte_eth_fdir_tunnel_type
11155 str2fdir_tunneltype(char *string)
11156 {
11157 	uint8_t i = 0;
11158 
11159 	static const struct {
11160 		char str[32];
11161 		enum rte_eth_fdir_tunnel_type type;
11162 	} tunneltype_str[] = {
11163 		{"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11164 		{"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11165 	};
11166 
11167 	for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11168 		if (!strcmp(tunneltype_str[i].str, string))
11169 			return tunneltype_str[i].type;
11170 	}
11171 	return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11172 }
11173 
11174 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11175 do { \
11176 	if ((ip_addr).family == AF_INET) \
11177 		(ip) = (ip_addr).addr.ipv4.s_addr; \
11178 	else { \
11179 		printf("invalid parameter.\n"); \
11180 		return; \
11181 	} \
11182 } while (0)
11183 
11184 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11185 do { \
11186 	if ((ip_addr).family == AF_INET6) \
11187 		rte_memcpy(&(ip), \
11188 				 &((ip_addr).addr.ipv6), \
11189 				 sizeof(struct in6_addr)); \
11190 	else { \
11191 		printf("invalid parameter.\n"); \
11192 		return; \
11193 	} \
11194 } while (0)
11195 
11196 static void
11197 cmd_flow_director_filter_parsed(void *parsed_result,
11198 			  __rte_unused struct cmdline *cl,
11199 			  __rte_unused void *data)
11200 {
11201 	struct cmd_flow_director_result *res = parsed_result;
11202 	struct rte_eth_fdir_filter entry;
11203 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11204 	char *end;
11205 	unsigned long vf_id;
11206 	int ret = 0;
11207 
11208 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11209 	if (ret < 0) {
11210 		printf("flow director is not supported on port %u.\n",
11211 			res->port_id);
11212 		return;
11213 	}
11214 	memset(flexbytes, 0, sizeof(flexbytes));
11215 	memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11216 
11217 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11218 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11219 			printf("Please set mode to MAC-VLAN.\n");
11220 			return;
11221 		}
11222 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11223 		if (strcmp(res->mode_value, "Tunnel")) {
11224 			printf("Please set mode to Tunnel.\n");
11225 			return;
11226 		}
11227 	} else {
11228 		if (!strcmp(res->mode_value, "raw")) {
11229 #ifdef RTE_LIBRTE_I40E_PMD
11230 			struct rte_pmd_i40e_flow_type_mapping
11231 					mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11232 			struct rte_pmd_i40e_pkt_template_conf conf;
11233 			uint16_t flow_type = str2flowtype(res->flow_type);
11234 			uint16_t i, port = res->port_id;
11235 			uint8_t add;
11236 
11237 			memset(&conf, 0, sizeof(conf));
11238 
11239 			if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11240 				printf("Invalid flow type specified.\n");
11241 				return;
11242 			}
11243 			ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11244 								 mapping);
11245 			if (ret)
11246 				return;
11247 			if (mapping[flow_type].pctype == 0ULL) {
11248 				printf("Invalid flow type specified.\n");
11249 				return;
11250 			}
11251 			for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11252 				if (mapping[flow_type].pctype & (1ULL << i)) {
11253 					conf.input.pctype = i;
11254 					break;
11255 				}
11256 			}
11257 
11258 			conf.input.packet = open_file(res->filepath,
11259 						&conf.input.length);
11260 			if (!conf.input.packet)
11261 				return;
11262 			if (!strcmp(res->drop, "drop"))
11263 				conf.action.behavior =
11264 					RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11265 			else
11266 				conf.action.behavior =
11267 					RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11268 			conf.action.report_status =
11269 					RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11270 			conf.action.rx_queue = res->queue_id;
11271 			conf.soft_id = res->fd_id_value;
11272 			add  = strcmp(res->ops, "del") ? 1 : 0;
11273 			ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11274 									&conf,
11275 									add);
11276 			if (ret < 0)
11277 				printf("flow director config error: (%s)\n",
11278 				       strerror(-ret));
11279 			close_file(conf.input.packet);
11280 #endif
11281 			return;
11282 		} else if (strcmp(res->mode_value, "IP")) {
11283 			printf("Please set mode to IP or raw.\n");
11284 			return;
11285 		}
11286 		entry.input.flow_type = str2flowtype(res->flow_type);
11287 	}
11288 
11289 	ret = parse_flexbytes(res->flexbytes_value,
11290 					flexbytes,
11291 					RTE_ETH_FDIR_MAX_FLEXLEN);
11292 	if (ret < 0) {
11293 		printf("error: Cannot parse flexbytes input.\n");
11294 		return;
11295 	}
11296 
11297 	switch (entry.input.flow_type) {
11298 	case RTE_ETH_FLOW_FRAG_IPV4:
11299 	case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11300 		entry.input.flow.ip4_flow.proto = res->proto_value;
11301 		/* fall-through */
11302 	case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11303 	case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11304 		IPV4_ADDR_TO_UINT(res->ip_dst,
11305 			entry.input.flow.ip4_flow.dst_ip);
11306 		IPV4_ADDR_TO_UINT(res->ip_src,
11307 			entry.input.flow.ip4_flow.src_ip);
11308 		entry.input.flow.ip4_flow.tos = res->tos_value;
11309 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
11310 		/* need convert to big endian. */
11311 		entry.input.flow.udp4_flow.dst_port =
11312 				rte_cpu_to_be_16(res->port_dst);
11313 		entry.input.flow.udp4_flow.src_port =
11314 				rte_cpu_to_be_16(res->port_src);
11315 		break;
11316 	case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11317 		IPV4_ADDR_TO_UINT(res->ip_dst,
11318 			entry.input.flow.sctp4_flow.ip.dst_ip);
11319 		IPV4_ADDR_TO_UINT(res->ip_src,
11320 			entry.input.flow.sctp4_flow.ip.src_ip);
11321 		entry.input.flow.ip4_flow.tos = res->tos_value;
11322 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
11323 		/* need convert to big endian. */
11324 		entry.input.flow.sctp4_flow.dst_port =
11325 				rte_cpu_to_be_16(res->port_dst);
11326 		entry.input.flow.sctp4_flow.src_port =
11327 				rte_cpu_to_be_16(res->port_src);
11328 		entry.input.flow.sctp4_flow.verify_tag =
11329 				rte_cpu_to_be_32(res->verify_tag_value);
11330 		break;
11331 	case RTE_ETH_FLOW_FRAG_IPV6:
11332 	case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11333 		entry.input.flow.ipv6_flow.proto = res->proto_value;
11334 		/* fall-through */
11335 	case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11336 	case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11337 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
11338 			entry.input.flow.ipv6_flow.dst_ip);
11339 		IPV6_ADDR_TO_ARRAY(res->ip_src,
11340 			entry.input.flow.ipv6_flow.src_ip);
11341 		entry.input.flow.ipv6_flow.tc = res->tos_value;
11342 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11343 		/* need convert to big endian. */
11344 		entry.input.flow.udp6_flow.dst_port =
11345 				rte_cpu_to_be_16(res->port_dst);
11346 		entry.input.flow.udp6_flow.src_port =
11347 				rte_cpu_to_be_16(res->port_src);
11348 		break;
11349 	case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11350 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
11351 			entry.input.flow.sctp6_flow.ip.dst_ip);
11352 		IPV6_ADDR_TO_ARRAY(res->ip_src,
11353 			entry.input.flow.sctp6_flow.ip.src_ip);
11354 		entry.input.flow.ipv6_flow.tc = res->tos_value;
11355 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11356 		/* need convert to big endian. */
11357 		entry.input.flow.sctp6_flow.dst_port =
11358 				rte_cpu_to_be_16(res->port_dst);
11359 		entry.input.flow.sctp6_flow.src_port =
11360 				rte_cpu_to_be_16(res->port_src);
11361 		entry.input.flow.sctp6_flow.verify_tag =
11362 				rte_cpu_to_be_32(res->verify_tag_value);
11363 		break;
11364 	case RTE_ETH_FLOW_L2_PAYLOAD:
11365 		entry.input.flow.l2_flow.ether_type =
11366 			rte_cpu_to_be_16(res->ether_type);
11367 		break;
11368 	default:
11369 		break;
11370 	}
11371 
11372 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11373 		rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11374 				 &res->mac_addr,
11375 				 sizeof(struct rte_ether_addr));
11376 
11377 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11378 		rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11379 				 &res->mac_addr,
11380 				 sizeof(struct rte_ether_addr));
11381 		entry.input.flow.tunnel_flow.tunnel_type =
11382 			str2fdir_tunneltype(res->tunnel_type);
11383 		entry.input.flow.tunnel_flow.tunnel_id =
11384 			rte_cpu_to_be_32(res->tunnel_id_value);
11385 	}
11386 
11387 	rte_memcpy(entry.input.flow_ext.flexbytes,
11388 		   flexbytes,
11389 		   RTE_ETH_FDIR_MAX_FLEXLEN);
11390 
11391 	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11392 
11393 	entry.action.flex_off = 0;  /*use 0 by default */
11394 	if (!strcmp(res->drop, "drop"))
11395 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
11396 	else
11397 		entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11398 
11399 	if (fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11400 	    fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11401 		if (!strcmp(res->pf_vf, "pf"))
11402 			entry.input.flow_ext.is_vf = 0;
11403 		else if (!strncmp(res->pf_vf, "vf", 2)) {
11404 			struct rte_eth_dev_info dev_info;
11405 
11406 			ret = eth_dev_info_get_print_err(res->port_id,
11407 						&dev_info);
11408 			if (ret != 0)
11409 				return;
11410 
11411 			errno = 0;
11412 			vf_id = strtoul(res->pf_vf + 2, &end, 10);
11413 			if (errno != 0 || *end != '\0' ||
11414 			    vf_id >= dev_info.max_vfs) {
11415 				printf("invalid parameter %s.\n", res->pf_vf);
11416 				return;
11417 			}
11418 			entry.input.flow_ext.is_vf = 1;
11419 			entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11420 		} else {
11421 			printf("invalid parameter %s.\n", res->pf_vf);
11422 			return;
11423 		}
11424 	}
11425 
11426 	/* set to report FD ID by default */
11427 	entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11428 	entry.action.rx_queue = res->queue_id;
11429 	entry.soft_id = res->fd_id_value;
11430 	if (!strcmp(res->ops, "add"))
11431 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11432 					     RTE_ETH_FILTER_ADD, &entry);
11433 	else if (!strcmp(res->ops, "del"))
11434 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11435 					     RTE_ETH_FILTER_DELETE, &entry);
11436 	else
11437 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11438 					     RTE_ETH_FILTER_UPDATE, &entry);
11439 	if (ret < 0)
11440 		printf("flow director programming error: (%s)\n",
11441 			strerror(-ret));
11442 }
11443 
11444 cmdline_parse_token_string_t cmd_flow_director_filter =
11445 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11446 				 flow_director_filter, "flow_director_filter");
11447 cmdline_parse_token_num_t cmd_flow_director_port_id =
11448 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11449 			      port_id, UINT16);
11450 cmdline_parse_token_string_t cmd_flow_director_ops =
11451 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11452 				 ops, "add#del#update");
11453 cmdline_parse_token_string_t cmd_flow_director_flow =
11454 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11455 				 flow, "flow");
11456 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11457 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11458 		flow_type, NULL);
11459 cmdline_parse_token_string_t cmd_flow_director_ether =
11460 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11461 				 ether, "ether");
11462 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11463 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11464 			      ether_type, UINT16);
11465 cmdline_parse_token_string_t cmd_flow_director_src =
11466 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11467 				 src, "src");
11468 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11469 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11470 				 ip_src);
11471 cmdline_parse_token_num_t cmd_flow_director_port_src =
11472 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11473 			      port_src, UINT16);
11474 cmdline_parse_token_string_t cmd_flow_director_dst =
11475 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11476 				 dst, "dst");
11477 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11478 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11479 				 ip_dst);
11480 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11481 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11482 			      port_dst, UINT16);
11483 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11484 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11485 				  verify_tag, "verify_tag");
11486 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11487 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11488 			      verify_tag_value, UINT32);
11489 cmdline_parse_token_string_t cmd_flow_director_tos =
11490 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11491 				 tos, "tos");
11492 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11493 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11494 			      tos_value, UINT8);
11495 cmdline_parse_token_string_t cmd_flow_director_proto =
11496 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11497 				 proto, "proto");
11498 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11499 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11500 			      proto_value, UINT8);
11501 cmdline_parse_token_string_t cmd_flow_director_ttl =
11502 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11503 				 ttl, "ttl");
11504 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11505 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11506 			      ttl_value, UINT8);
11507 cmdline_parse_token_string_t cmd_flow_director_vlan =
11508 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11509 				 vlan, "vlan");
11510 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11511 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11512 			      vlan_value, UINT16);
11513 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11514 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11515 				 flexbytes, "flexbytes");
11516 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11517 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11518 			      flexbytes_value, NULL);
11519 cmdline_parse_token_string_t cmd_flow_director_drop =
11520 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11521 				 drop, "drop#fwd");
11522 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11523 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11524 			      pf_vf, NULL);
11525 cmdline_parse_token_string_t cmd_flow_director_queue =
11526 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11527 				 queue, "queue");
11528 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11529 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11530 			      queue_id, UINT16);
11531 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11532 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11533 				 fd_id, "fd_id");
11534 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11535 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11536 			      fd_id_value, UINT32);
11537 
11538 cmdline_parse_token_string_t cmd_flow_director_mode =
11539 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11540 				 mode, "mode");
11541 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11542 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11543 				 mode_value, "IP");
11544 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11545 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11546 				 mode_value, "MAC-VLAN");
11547 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11548 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11549 				 mode_value, "Tunnel");
11550 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11551 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11552 				 mode_value, "raw");
11553 cmdline_parse_token_string_t cmd_flow_director_mac =
11554 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11555 				 mac, "mac");
11556 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11557 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11558 				    mac_addr);
11559 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11560 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11561 				 tunnel, "tunnel");
11562 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11563 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11564 				 tunnel_type, "NVGRE#VxLAN");
11565 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11566 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11567 				 tunnel_id, "tunnel-id");
11568 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11569 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11570 			      tunnel_id_value, UINT32);
11571 cmdline_parse_token_string_t cmd_flow_director_packet =
11572 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11573 				 packet, "packet");
11574 cmdline_parse_token_string_t cmd_flow_director_filepath =
11575 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11576 				 filepath, NULL);
11577 
11578 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11579 	.f = cmd_flow_director_filter_parsed,
11580 	.data = NULL,
11581 	.help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11582 		" ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11583 		"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11584 		"l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11585 		"proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11586 		"flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11587 		"fd_id <fd_id_value>: "
11588 		"Add or delete an ip flow director entry on NIC",
11589 	.tokens = {
11590 		(void *)&cmd_flow_director_filter,
11591 		(void *)&cmd_flow_director_port_id,
11592 		(void *)&cmd_flow_director_mode,
11593 		(void *)&cmd_flow_director_mode_ip,
11594 		(void *)&cmd_flow_director_ops,
11595 		(void *)&cmd_flow_director_flow,
11596 		(void *)&cmd_flow_director_flow_type,
11597 		(void *)&cmd_flow_director_src,
11598 		(void *)&cmd_flow_director_ip_src,
11599 		(void *)&cmd_flow_director_dst,
11600 		(void *)&cmd_flow_director_ip_dst,
11601 		(void *)&cmd_flow_director_tos,
11602 		(void *)&cmd_flow_director_tos_value,
11603 		(void *)&cmd_flow_director_proto,
11604 		(void *)&cmd_flow_director_proto_value,
11605 		(void *)&cmd_flow_director_ttl,
11606 		(void *)&cmd_flow_director_ttl_value,
11607 		(void *)&cmd_flow_director_vlan,
11608 		(void *)&cmd_flow_director_vlan_value,
11609 		(void *)&cmd_flow_director_flexbytes,
11610 		(void *)&cmd_flow_director_flexbytes_value,
11611 		(void *)&cmd_flow_director_drop,
11612 		(void *)&cmd_flow_director_pf_vf,
11613 		(void *)&cmd_flow_director_queue,
11614 		(void *)&cmd_flow_director_queue_id,
11615 		(void *)&cmd_flow_director_fd_id,
11616 		(void *)&cmd_flow_director_fd_id_value,
11617 		NULL,
11618 	},
11619 };
11620 
11621 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11622 	.f = cmd_flow_director_filter_parsed,
11623 	.data = NULL,
11624 	.help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11625 		"director entry on NIC",
11626 	.tokens = {
11627 		(void *)&cmd_flow_director_filter,
11628 		(void *)&cmd_flow_director_port_id,
11629 		(void *)&cmd_flow_director_mode,
11630 		(void *)&cmd_flow_director_mode_ip,
11631 		(void *)&cmd_flow_director_ops,
11632 		(void *)&cmd_flow_director_flow,
11633 		(void *)&cmd_flow_director_flow_type,
11634 		(void *)&cmd_flow_director_src,
11635 		(void *)&cmd_flow_director_ip_src,
11636 		(void *)&cmd_flow_director_port_src,
11637 		(void *)&cmd_flow_director_dst,
11638 		(void *)&cmd_flow_director_ip_dst,
11639 		(void *)&cmd_flow_director_port_dst,
11640 		(void *)&cmd_flow_director_tos,
11641 		(void *)&cmd_flow_director_tos_value,
11642 		(void *)&cmd_flow_director_ttl,
11643 		(void *)&cmd_flow_director_ttl_value,
11644 		(void *)&cmd_flow_director_vlan,
11645 		(void *)&cmd_flow_director_vlan_value,
11646 		(void *)&cmd_flow_director_flexbytes,
11647 		(void *)&cmd_flow_director_flexbytes_value,
11648 		(void *)&cmd_flow_director_drop,
11649 		(void *)&cmd_flow_director_pf_vf,
11650 		(void *)&cmd_flow_director_queue,
11651 		(void *)&cmd_flow_director_queue_id,
11652 		(void *)&cmd_flow_director_fd_id,
11653 		(void *)&cmd_flow_director_fd_id_value,
11654 		NULL,
11655 	},
11656 };
11657 
11658 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11659 	.f = cmd_flow_director_filter_parsed,
11660 	.data = NULL,
11661 	.help_str = "flow_director_filter ... : Add or delete a sctp flow "
11662 		"director entry on NIC",
11663 	.tokens = {
11664 		(void *)&cmd_flow_director_filter,
11665 		(void *)&cmd_flow_director_port_id,
11666 		(void *)&cmd_flow_director_mode,
11667 		(void *)&cmd_flow_director_mode_ip,
11668 		(void *)&cmd_flow_director_ops,
11669 		(void *)&cmd_flow_director_flow,
11670 		(void *)&cmd_flow_director_flow_type,
11671 		(void *)&cmd_flow_director_src,
11672 		(void *)&cmd_flow_director_ip_src,
11673 		(void *)&cmd_flow_director_port_src,
11674 		(void *)&cmd_flow_director_dst,
11675 		(void *)&cmd_flow_director_ip_dst,
11676 		(void *)&cmd_flow_director_port_dst,
11677 		(void *)&cmd_flow_director_verify_tag,
11678 		(void *)&cmd_flow_director_verify_tag_value,
11679 		(void *)&cmd_flow_director_tos,
11680 		(void *)&cmd_flow_director_tos_value,
11681 		(void *)&cmd_flow_director_ttl,
11682 		(void *)&cmd_flow_director_ttl_value,
11683 		(void *)&cmd_flow_director_vlan,
11684 		(void *)&cmd_flow_director_vlan_value,
11685 		(void *)&cmd_flow_director_flexbytes,
11686 		(void *)&cmd_flow_director_flexbytes_value,
11687 		(void *)&cmd_flow_director_drop,
11688 		(void *)&cmd_flow_director_pf_vf,
11689 		(void *)&cmd_flow_director_queue,
11690 		(void *)&cmd_flow_director_queue_id,
11691 		(void *)&cmd_flow_director_fd_id,
11692 		(void *)&cmd_flow_director_fd_id_value,
11693 		NULL,
11694 	},
11695 };
11696 
11697 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11698 	.f = cmd_flow_director_filter_parsed,
11699 	.data = NULL,
11700 	.help_str = "flow_director_filter ... : Add or delete a L2 flow "
11701 		"director entry on NIC",
11702 	.tokens = {
11703 		(void *)&cmd_flow_director_filter,
11704 		(void *)&cmd_flow_director_port_id,
11705 		(void *)&cmd_flow_director_mode,
11706 		(void *)&cmd_flow_director_mode_ip,
11707 		(void *)&cmd_flow_director_ops,
11708 		(void *)&cmd_flow_director_flow,
11709 		(void *)&cmd_flow_director_flow_type,
11710 		(void *)&cmd_flow_director_ether,
11711 		(void *)&cmd_flow_director_ether_type,
11712 		(void *)&cmd_flow_director_flexbytes,
11713 		(void *)&cmd_flow_director_flexbytes_value,
11714 		(void *)&cmd_flow_director_drop,
11715 		(void *)&cmd_flow_director_pf_vf,
11716 		(void *)&cmd_flow_director_queue,
11717 		(void *)&cmd_flow_director_queue_id,
11718 		(void *)&cmd_flow_director_fd_id,
11719 		(void *)&cmd_flow_director_fd_id_value,
11720 		NULL,
11721 	},
11722 };
11723 
11724 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11725 	.f = cmd_flow_director_filter_parsed,
11726 	.data = NULL,
11727 	.help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11728 		"director entry on NIC",
11729 	.tokens = {
11730 		(void *)&cmd_flow_director_filter,
11731 		(void *)&cmd_flow_director_port_id,
11732 		(void *)&cmd_flow_director_mode,
11733 		(void *)&cmd_flow_director_mode_mac_vlan,
11734 		(void *)&cmd_flow_director_ops,
11735 		(void *)&cmd_flow_director_mac,
11736 		(void *)&cmd_flow_director_mac_addr,
11737 		(void *)&cmd_flow_director_vlan,
11738 		(void *)&cmd_flow_director_vlan_value,
11739 		(void *)&cmd_flow_director_flexbytes,
11740 		(void *)&cmd_flow_director_flexbytes_value,
11741 		(void *)&cmd_flow_director_drop,
11742 		(void *)&cmd_flow_director_queue,
11743 		(void *)&cmd_flow_director_queue_id,
11744 		(void *)&cmd_flow_director_fd_id,
11745 		(void *)&cmd_flow_director_fd_id_value,
11746 		NULL,
11747 	},
11748 };
11749 
11750 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11751 	.f = cmd_flow_director_filter_parsed,
11752 	.data = NULL,
11753 	.help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11754 		"director entry on NIC",
11755 	.tokens = {
11756 		(void *)&cmd_flow_director_filter,
11757 		(void *)&cmd_flow_director_port_id,
11758 		(void *)&cmd_flow_director_mode,
11759 		(void *)&cmd_flow_director_mode_tunnel,
11760 		(void *)&cmd_flow_director_ops,
11761 		(void *)&cmd_flow_director_mac,
11762 		(void *)&cmd_flow_director_mac_addr,
11763 		(void *)&cmd_flow_director_vlan,
11764 		(void *)&cmd_flow_director_vlan_value,
11765 		(void *)&cmd_flow_director_tunnel,
11766 		(void *)&cmd_flow_director_tunnel_type,
11767 		(void *)&cmd_flow_director_tunnel_id,
11768 		(void *)&cmd_flow_director_tunnel_id_value,
11769 		(void *)&cmd_flow_director_flexbytes,
11770 		(void *)&cmd_flow_director_flexbytes_value,
11771 		(void *)&cmd_flow_director_drop,
11772 		(void *)&cmd_flow_director_queue,
11773 		(void *)&cmd_flow_director_queue_id,
11774 		(void *)&cmd_flow_director_fd_id,
11775 		(void *)&cmd_flow_director_fd_id_value,
11776 		NULL,
11777 	},
11778 };
11779 
11780 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11781 	.f = cmd_flow_director_filter_parsed,
11782 	.data = NULL,
11783 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
11784 		"director entry on NIC",
11785 	.tokens = {
11786 		(void *)&cmd_flow_director_filter,
11787 		(void *)&cmd_flow_director_port_id,
11788 		(void *)&cmd_flow_director_mode,
11789 		(void *)&cmd_flow_director_mode_raw,
11790 		(void *)&cmd_flow_director_ops,
11791 		(void *)&cmd_flow_director_flow,
11792 		(void *)&cmd_flow_director_flow_type,
11793 		(void *)&cmd_flow_director_drop,
11794 		(void *)&cmd_flow_director_queue,
11795 		(void *)&cmd_flow_director_queue_id,
11796 		(void *)&cmd_flow_director_fd_id,
11797 		(void *)&cmd_flow_director_fd_id_value,
11798 		(void *)&cmd_flow_director_packet,
11799 		(void *)&cmd_flow_director_filepath,
11800 		NULL,
11801 	},
11802 };
11803 
11804 struct cmd_flush_flow_director_result {
11805 	cmdline_fixed_string_t flush_flow_director;
11806 	portid_t port_id;
11807 };
11808 
11809 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11810 	TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11811 				 flush_flow_director, "flush_flow_director");
11812 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11813 	TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11814 			      port_id, UINT16);
11815 
11816 static void
11817 cmd_flush_flow_director_parsed(void *parsed_result,
11818 			  __rte_unused struct cmdline *cl,
11819 			  __rte_unused void *data)
11820 {
11821 	struct cmd_flow_director_result *res = parsed_result;
11822 	int ret = 0;
11823 
11824 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11825 	if (ret < 0) {
11826 		printf("flow director is not supported on port %u.\n",
11827 			res->port_id);
11828 		return;
11829 	}
11830 
11831 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11832 			RTE_ETH_FILTER_FLUSH, NULL);
11833 	if (ret < 0)
11834 		printf("flow director table flushing error: (%s)\n",
11835 			strerror(-ret));
11836 }
11837 
11838 cmdline_parse_inst_t cmd_flush_flow_director = {
11839 	.f = cmd_flush_flow_director_parsed,
11840 	.data = NULL,
11841 	.help_str = "flush_flow_director <port_id>: "
11842 		"Flush all flow director entries of a device on NIC",
11843 	.tokens = {
11844 		(void *)&cmd_flush_flow_director_flush,
11845 		(void *)&cmd_flush_flow_director_port_id,
11846 		NULL,
11847 	},
11848 };
11849 
11850 /* *** deal with flow director mask *** */
11851 struct cmd_flow_director_mask_result {
11852 	cmdline_fixed_string_t flow_director_mask;
11853 	portid_t port_id;
11854 	cmdline_fixed_string_t mode;
11855 	cmdline_fixed_string_t mode_value;
11856 	cmdline_fixed_string_t vlan;
11857 	uint16_t vlan_mask;
11858 	cmdline_fixed_string_t src_mask;
11859 	cmdline_ipaddr_t ipv4_src;
11860 	cmdline_ipaddr_t ipv6_src;
11861 	uint16_t port_src;
11862 	cmdline_fixed_string_t dst_mask;
11863 	cmdline_ipaddr_t ipv4_dst;
11864 	cmdline_ipaddr_t ipv6_dst;
11865 	uint16_t port_dst;
11866 	cmdline_fixed_string_t mac;
11867 	uint8_t mac_addr_byte_mask;
11868 	cmdline_fixed_string_t tunnel_id;
11869 	uint32_t tunnel_id_mask;
11870 	cmdline_fixed_string_t tunnel_type;
11871 	uint8_t tunnel_type_mask;
11872 };
11873 
11874 static void
11875 cmd_flow_director_mask_parsed(void *parsed_result,
11876 			  __rte_unused struct cmdline *cl,
11877 			  __rte_unused void *data)
11878 {
11879 	struct cmd_flow_director_mask_result *res = parsed_result;
11880 	struct rte_eth_fdir_masks *mask;
11881 	struct rte_port *port;
11882 
11883 	port = &ports[res->port_id];
11884 	/** Check if the port is not started **/
11885 	if (port->port_status != RTE_PORT_STOPPED) {
11886 		printf("Please stop port %d first\n", res->port_id);
11887 		return;
11888 	}
11889 
11890 	mask = &port->dev_conf.fdir_conf.mask;
11891 
11892 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11893 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11894 			printf("Please set mode to MAC-VLAN.\n");
11895 			return;
11896 		}
11897 
11898 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11899 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11900 		if (strcmp(res->mode_value, "Tunnel")) {
11901 			printf("Please set mode to Tunnel.\n");
11902 			return;
11903 		}
11904 
11905 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11906 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11907 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11908 		mask->tunnel_type_mask = res->tunnel_type_mask;
11909 	} else {
11910 		if (strcmp(res->mode_value, "IP")) {
11911 			printf("Please set mode to IP.\n");
11912 			return;
11913 		}
11914 
11915 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11916 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11917 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11918 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11919 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11920 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11921 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11922 	}
11923 
11924 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11925 }
11926 
11927 cmdline_parse_token_string_t cmd_flow_director_mask =
11928 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11929 				 flow_director_mask, "flow_director_mask");
11930 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11931 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11932 			      port_id, UINT16);
11933 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11934 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11935 				 vlan, "vlan");
11936 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11937 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11938 			      vlan_mask, UINT16);
11939 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11940 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11941 				 src_mask, "src_mask");
11942 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11943 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11944 				 ipv4_src);
11945 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11946 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11947 				 ipv6_src);
11948 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11949 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11950 			      port_src, UINT16);
11951 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11952 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11953 				 dst_mask, "dst_mask");
11954 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11955 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11956 				 ipv4_dst);
11957 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11958 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11959 				 ipv6_dst);
11960 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11961 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11962 			      port_dst, UINT16);
11963 
11964 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11965 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11966 				 mode, "mode");
11967 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11968 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11969 				 mode_value, "IP");
11970 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11971 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11972 				 mode_value, "MAC-VLAN");
11973 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11974 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11975 				 mode_value, "Tunnel");
11976 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11977 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11978 				 mac, "mac");
11979 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11980 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11981 			      mac_addr_byte_mask, UINT8);
11982 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11983 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11984 				 tunnel_type, "tunnel-type");
11985 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11986 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11987 			      tunnel_type_mask, UINT8);
11988 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11989 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11990 				 tunnel_id, "tunnel-id");
11991 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11992 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11993 			      tunnel_id_mask, UINT32);
11994 
11995 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11996 	.f = cmd_flow_director_mask_parsed,
11997 	.data = NULL,
11998 	.help_str = "flow_director_mask ... : "
11999 		"Set IP mode flow director's mask on NIC",
12000 	.tokens = {
12001 		(void *)&cmd_flow_director_mask,
12002 		(void *)&cmd_flow_director_mask_port_id,
12003 		(void *)&cmd_flow_director_mask_mode,
12004 		(void *)&cmd_flow_director_mask_mode_ip,
12005 		(void *)&cmd_flow_director_mask_vlan,
12006 		(void *)&cmd_flow_director_mask_vlan_value,
12007 		(void *)&cmd_flow_director_mask_src,
12008 		(void *)&cmd_flow_director_mask_ipv4_src,
12009 		(void *)&cmd_flow_director_mask_ipv6_src,
12010 		(void *)&cmd_flow_director_mask_port_src,
12011 		(void *)&cmd_flow_director_mask_dst,
12012 		(void *)&cmd_flow_director_mask_ipv4_dst,
12013 		(void *)&cmd_flow_director_mask_ipv6_dst,
12014 		(void *)&cmd_flow_director_mask_port_dst,
12015 		NULL,
12016 	},
12017 };
12018 
12019 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12020 	.f = cmd_flow_director_mask_parsed,
12021 	.data = NULL,
12022 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
12023 		"flow director's mask on NIC",
12024 	.tokens = {
12025 		(void *)&cmd_flow_director_mask,
12026 		(void *)&cmd_flow_director_mask_port_id,
12027 		(void *)&cmd_flow_director_mask_mode,
12028 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
12029 		(void *)&cmd_flow_director_mask_vlan,
12030 		(void *)&cmd_flow_director_mask_vlan_value,
12031 		NULL,
12032 	},
12033 };
12034 
12035 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12036 	.f = cmd_flow_director_mask_parsed,
12037 	.data = NULL,
12038 	.help_str = "flow_director_mask ... : Set tunnel mode "
12039 		"flow director's mask on NIC",
12040 	.tokens = {
12041 		(void *)&cmd_flow_director_mask,
12042 		(void *)&cmd_flow_director_mask_port_id,
12043 		(void *)&cmd_flow_director_mask_mode,
12044 		(void *)&cmd_flow_director_mask_mode_tunnel,
12045 		(void *)&cmd_flow_director_mask_vlan,
12046 		(void *)&cmd_flow_director_mask_vlan_value,
12047 		(void *)&cmd_flow_director_mask_mac,
12048 		(void *)&cmd_flow_director_mask_mac_value,
12049 		(void *)&cmd_flow_director_mask_tunnel_type,
12050 		(void *)&cmd_flow_director_mask_tunnel_type_value,
12051 		(void *)&cmd_flow_director_mask_tunnel_id,
12052 		(void *)&cmd_flow_director_mask_tunnel_id_value,
12053 		NULL,
12054 	},
12055 };
12056 
12057 /* *** deal with flow director mask on flexible payload *** */
12058 struct cmd_flow_director_flex_mask_result {
12059 	cmdline_fixed_string_t flow_director_flexmask;
12060 	portid_t port_id;
12061 	cmdline_fixed_string_t flow;
12062 	cmdline_fixed_string_t flow_type;
12063 	cmdline_fixed_string_t mask;
12064 };
12065 
12066 static void
12067 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12068 			  __rte_unused struct cmdline *cl,
12069 			  __rte_unused void *data)
12070 {
12071 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
12072 	struct rte_eth_fdir_info fdir_info;
12073 	struct rte_eth_fdir_flex_mask flex_mask;
12074 	struct rte_port *port;
12075 	uint64_t flow_type_mask;
12076 	uint16_t i;
12077 	int ret;
12078 
12079 	port = &ports[res->port_id];
12080 	/** Check if the port is not started **/
12081 	if (port->port_status != RTE_PORT_STOPPED) {
12082 		printf("Please stop port %d first\n", res->port_id);
12083 		return;
12084 	}
12085 
12086 	memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12087 	ret = parse_flexbytes(res->mask,
12088 			flex_mask.mask,
12089 			RTE_ETH_FDIR_MAX_FLEXLEN);
12090 	if (ret < 0) {
12091 		printf("error: Cannot parse mask input.\n");
12092 		return;
12093 	}
12094 
12095 	memset(&fdir_info, 0, sizeof(fdir_info));
12096 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12097 				RTE_ETH_FILTER_INFO, &fdir_info);
12098 	if (ret < 0) {
12099 		printf("Cannot get FDir filter info\n");
12100 		return;
12101 	}
12102 
12103 	if (!strcmp(res->flow_type, "none")) {
12104 		/* means don't specify the flow type */
12105 		flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12106 		for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12107 			memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12108 			       0, sizeof(struct rte_eth_fdir_flex_mask));
12109 		port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12110 		rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12111 				 &flex_mask,
12112 				 sizeof(struct rte_eth_fdir_flex_mask));
12113 		cmd_reconfig_device_queue(res->port_id, 1, 1);
12114 		return;
12115 	}
12116 	flow_type_mask = fdir_info.flow_types_mask[0];
12117 	if (!strcmp(res->flow_type, "all")) {
12118 		if (!flow_type_mask) {
12119 			printf("No flow type supported\n");
12120 			return;
12121 		}
12122 		for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12123 			if (flow_type_mask & (1ULL << i)) {
12124 				flex_mask.flow_type = i;
12125 				fdir_set_flex_mask(res->port_id, &flex_mask);
12126 			}
12127 		}
12128 		cmd_reconfig_device_queue(res->port_id, 1, 1);
12129 		return;
12130 	}
12131 	flex_mask.flow_type = str2flowtype(res->flow_type);
12132 	if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12133 		printf("Flow type %s not supported on port %d\n",
12134 				res->flow_type, res->port_id);
12135 		return;
12136 	}
12137 	fdir_set_flex_mask(res->port_id, &flex_mask);
12138 	cmd_reconfig_device_queue(res->port_id, 1, 1);
12139 }
12140 
12141 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12142 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12143 				 flow_director_flexmask,
12144 				 "flow_director_flex_mask");
12145 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12146 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12147 			      port_id, UINT16);
12148 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12149 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12150 				 flow, "flow");
12151 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12152 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12153 		flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12154 		"ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12155 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12156 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12157 				 mask, NULL);
12158 
12159 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12160 	.f = cmd_flow_director_flex_mask_parsed,
12161 	.data = NULL,
12162 	.help_str = "flow_director_flex_mask ... : "
12163 		"Set flow director's flex mask on NIC",
12164 	.tokens = {
12165 		(void *)&cmd_flow_director_flexmask,
12166 		(void *)&cmd_flow_director_flexmask_port_id,
12167 		(void *)&cmd_flow_director_flexmask_flow,
12168 		(void *)&cmd_flow_director_flexmask_flow_type,
12169 		(void *)&cmd_flow_director_flexmask_mask,
12170 		NULL,
12171 	},
12172 };
12173 
12174 /* *** deal with flow director flexible payload configuration *** */
12175 struct cmd_flow_director_flexpayload_result {
12176 	cmdline_fixed_string_t flow_director_flexpayload;
12177 	portid_t port_id;
12178 	cmdline_fixed_string_t payload_layer;
12179 	cmdline_fixed_string_t payload_cfg;
12180 };
12181 
12182 static inline int
12183 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12184 {
12185 	char s[256];
12186 	const char *p, *p0 = q_arg;
12187 	char *end;
12188 	unsigned long int_fld;
12189 	char *str_fld[max_num];
12190 	int i;
12191 	unsigned size;
12192 	int ret = -1;
12193 
12194 	p = strchr(p0, '(');
12195 	if (p == NULL)
12196 		return -1;
12197 	++p;
12198 	p0 = strchr(p, ')');
12199 	if (p0 == NULL)
12200 		return -1;
12201 
12202 	size = p0 - p;
12203 	if (size >= sizeof(s))
12204 		return -1;
12205 
12206 	snprintf(s, sizeof(s), "%.*s", size, p);
12207 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12208 	if (ret < 0 || ret > max_num)
12209 		return -1;
12210 	for (i = 0; i < ret; i++) {
12211 		errno = 0;
12212 		int_fld = strtoul(str_fld[i], &end, 0);
12213 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12214 			return -1;
12215 		offsets[i] = (uint16_t)int_fld;
12216 	}
12217 	return ret;
12218 }
12219 
12220 static void
12221 cmd_flow_director_flxpld_parsed(void *parsed_result,
12222 			  __rte_unused struct cmdline *cl,
12223 			  __rte_unused void *data)
12224 {
12225 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
12226 	struct rte_eth_flex_payload_cfg flex_cfg;
12227 	struct rte_port *port;
12228 	int ret = 0;
12229 
12230 	port = &ports[res->port_id];
12231 	/** Check if the port is not started **/
12232 	if (port->port_status != RTE_PORT_STOPPED) {
12233 		printf("Please stop port %d first\n", res->port_id);
12234 		return;
12235 	}
12236 
12237 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12238 
12239 	if (!strcmp(res->payload_layer, "raw"))
12240 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12241 	else if (!strcmp(res->payload_layer, "l2"))
12242 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12243 	else if (!strcmp(res->payload_layer, "l3"))
12244 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12245 	else if (!strcmp(res->payload_layer, "l4"))
12246 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12247 
12248 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12249 			    RTE_ETH_FDIR_MAX_FLEXLEN);
12250 	if (ret < 0) {
12251 		printf("error: Cannot parse flex payload input.\n");
12252 		return;
12253 	}
12254 
12255 	fdir_set_flex_payload(res->port_id, &flex_cfg);
12256 	cmd_reconfig_device_queue(res->port_id, 1, 1);
12257 }
12258 
12259 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12260 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12261 				 flow_director_flexpayload,
12262 				 "flow_director_flex_payload");
12263 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12264 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12265 			      port_id, UINT16);
12266 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12267 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12268 				 payload_layer, "raw#l2#l3#l4");
12269 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12270 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12271 				 payload_cfg, NULL);
12272 
12273 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12274 	.f = cmd_flow_director_flxpld_parsed,
12275 	.data = NULL,
12276 	.help_str = "flow_director_flexpayload ... : "
12277 		"Set flow director's flex payload on NIC",
12278 	.tokens = {
12279 		(void *)&cmd_flow_director_flexpayload,
12280 		(void *)&cmd_flow_director_flexpayload_port_id,
12281 		(void *)&cmd_flow_director_flexpayload_payload_layer,
12282 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
12283 		NULL,
12284 	},
12285 };
12286 
12287 /* Generic flow interface command. */
12288 extern cmdline_parse_inst_t cmd_flow;
12289 
12290 /* *** Classification Filters Control *** */
12291 /* *** Get symmetric hash enable per port *** */
12292 struct cmd_get_sym_hash_ena_per_port_result {
12293 	cmdline_fixed_string_t get_sym_hash_ena_per_port;
12294 	portid_t port_id;
12295 };
12296 
12297 static void
12298 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12299 				 __rte_unused struct cmdline *cl,
12300 				 __rte_unused void *data)
12301 {
12302 	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12303 	struct rte_eth_hash_filter_info info;
12304 	int ret;
12305 
12306 	if (rte_eth_dev_filter_supported(res->port_id,
12307 				RTE_ETH_FILTER_HASH) < 0) {
12308 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12309 							res->port_id);
12310 		return;
12311 	}
12312 
12313 	memset(&info, 0, sizeof(info));
12314 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12315 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12316 						RTE_ETH_FILTER_GET, &info);
12317 
12318 	if (ret < 0) {
12319 		printf("Cannot get symmetric hash enable per port "
12320 					"on port %u\n", res->port_id);
12321 		return;
12322 	}
12323 
12324 	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12325 				"enabled" : "disabled", res->port_id);
12326 }
12327 
12328 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12329 	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12330 		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12331 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12332 	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12333 		port_id, UINT16);
12334 
12335 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12336 	.f = cmd_get_sym_hash_per_port_parsed,
12337 	.data = NULL,
12338 	.help_str = "get_sym_hash_ena_per_port <port_id>",
12339 	.tokens = {
12340 		(void *)&cmd_get_sym_hash_ena_per_port_all,
12341 		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
12342 		NULL,
12343 	},
12344 };
12345 
12346 /* *** Set symmetric hash enable per port *** */
12347 struct cmd_set_sym_hash_ena_per_port_result {
12348 	cmdline_fixed_string_t set_sym_hash_ena_per_port;
12349 	cmdline_fixed_string_t enable;
12350 	portid_t port_id;
12351 };
12352 
12353 static void
12354 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12355 				 __rte_unused struct cmdline *cl,
12356 				 __rte_unused void *data)
12357 {
12358 	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12359 	struct rte_eth_hash_filter_info info;
12360 	int ret;
12361 
12362 	if (rte_eth_dev_filter_supported(res->port_id,
12363 				RTE_ETH_FILTER_HASH) < 0) {
12364 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12365 							res->port_id);
12366 		return;
12367 	}
12368 
12369 	memset(&info, 0, sizeof(info));
12370 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12371 	if (!strcmp(res->enable, "enable"))
12372 		info.info.enable = 1;
12373 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12374 					RTE_ETH_FILTER_SET, &info);
12375 	if (ret < 0) {
12376 		printf("Cannot set symmetric hash enable per port on "
12377 					"port %u\n", res->port_id);
12378 		return;
12379 	}
12380 	printf("Symmetric hash has been set to %s on port %u\n",
12381 					res->enable, res->port_id);
12382 }
12383 
12384 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12385 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12386 		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12387 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12388 	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12389 		port_id, UINT16);
12390 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12391 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12392 		enable, "enable#disable");
12393 
12394 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12395 	.f = cmd_set_sym_hash_per_port_parsed,
12396 	.data = NULL,
12397 	.help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12398 	.tokens = {
12399 		(void *)&cmd_set_sym_hash_ena_per_port_all,
12400 		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
12401 		(void *)&cmd_set_sym_hash_ena_per_port_enable,
12402 		NULL,
12403 	},
12404 };
12405 
12406 /* Get global config of hash function */
12407 struct cmd_get_hash_global_config_result {
12408 	cmdline_fixed_string_t get_hash_global_config;
12409 	portid_t port_id;
12410 };
12411 
12412 static char *
12413 flowtype_to_str(uint16_t ftype)
12414 {
12415 	uint16_t i;
12416 	static struct {
12417 		char str[16];
12418 		uint16_t ftype;
12419 	} ftype_table[] = {
12420 		{"ipv4", RTE_ETH_FLOW_IPV4},
12421 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12422 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12423 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12424 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12425 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12426 		{"ipv6", RTE_ETH_FLOW_IPV6},
12427 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12428 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12429 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12430 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12431 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12432 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12433 		{"port", RTE_ETH_FLOW_PORT},
12434 		{"vxlan", RTE_ETH_FLOW_VXLAN},
12435 		{"geneve", RTE_ETH_FLOW_GENEVE},
12436 		{"nvgre", RTE_ETH_FLOW_NVGRE},
12437 		{"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12438 	};
12439 
12440 	for (i = 0; i < RTE_DIM(ftype_table); i++) {
12441 		if (ftype_table[i].ftype == ftype)
12442 			return ftype_table[i].str;
12443 	}
12444 
12445 	return NULL;
12446 }
12447 
12448 static void
12449 cmd_get_hash_global_config_parsed(void *parsed_result,
12450 				  __rte_unused struct cmdline *cl,
12451 				  __rte_unused void *data)
12452 {
12453 	struct cmd_get_hash_global_config_result *res = parsed_result;
12454 	struct rte_eth_hash_filter_info info;
12455 	uint32_t idx, offset;
12456 	uint16_t i;
12457 	char *str;
12458 	int ret;
12459 
12460 	if (rte_eth_dev_filter_supported(res->port_id,
12461 			RTE_ETH_FILTER_HASH) < 0) {
12462 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12463 							res->port_id);
12464 		return;
12465 	}
12466 
12467 	memset(&info, 0, sizeof(info));
12468 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12469 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12470 					RTE_ETH_FILTER_GET, &info);
12471 	if (ret < 0) {
12472 		printf("Cannot get hash global configurations by port %d\n",
12473 							res->port_id);
12474 		return;
12475 	}
12476 
12477 	switch (info.info.global_conf.hash_func) {
12478 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12479 		printf("Hash function is Toeplitz\n");
12480 		break;
12481 	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12482 		printf("Hash function is Simple XOR\n");
12483 		break;
12484 	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12485 		printf("Hash function is Symmetric Toeplitz\n");
12486 		break;
12487 	default:
12488 		printf("Unknown hash function\n");
12489 		break;
12490 	}
12491 
12492 	for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12493 		idx = i / UINT64_BIT;
12494 		offset = i % UINT64_BIT;
12495 		if (!(info.info.global_conf.valid_bit_mask[idx] &
12496 						(1ULL << offset)))
12497 			continue;
12498 		str = flowtype_to_str(i);
12499 		if (!str)
12500 			continue;
12501 		printf("Symmetric hash is %s globally for flow type %s "
12502 							"by port %d\n",
12503 			((info.info.global_conf.sym_hash_enable_mask[idx] &
12504 			(1ULL << offset)) ? "enabled" : "disabled"), str,
12505 							res->port_id);
12506 	}
12507 }
12508 
12509 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12510 	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12511 		get_hash_global_config, "get_hash_global_config");
12512 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12513 	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12514 		port_id, UINT16);
12515 
12516 cmdline_parse_inst_t cmd_get_hash_global_config = {
12517 	.f = cmd_get_hash_global_config_parsed,
12518 	.data = NULL,
12519 	.help_str = "get_hash_global_config <port_id>",
12520 	.tokens = {
12521 		(void *)&cmd_get_hash_global_config_all,
12522 		(void *)&cmd_get_hash_global_config_port_id,
12523 		NULL,
12524 	},
12525 };
12526 
12527 /* Set global config of hash function */
12528 struct cmd_set_hash_global_config_result {
12529 	cmdline_fixed_string_t set_hash_global_config;
12530 	portid_t port_id;
12531 	cmdline_fixed_string_t hash_func;
12532 	cmdline_fixed_string_t flow_type;
12533 	cmdline_fixed_string_t enable;
12534 };
12535 
12536 static void
12537 cmd_set_hash_global_config_parsed(void *parsed_result,
12538 				  __rte_unused struct cmdline *cl,
12539 				  __rte_unused void *data)
12540 {
12541 	struct cmd_set_hash_global_config_result *res = parsed_result;
12542 	struct rte_eth_hash_filter_info info;
12543 	uint32_t ftype, idx, offset;
12544 	int ret;
12545 
12546 	if (rte_eth_dev_filter_supported(res->port_id,
12547 				RTE_ETH_FILTER_HASH) < 0) {
12548 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12549 							res->port_id);
12550 		return;
12551 	}
12552 	memset(&info, 0, sizeof(info));
12553 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12554 	if (!strcmp(res->hash_func, "toeplitz"))
12555 		info.info.global_conf.hash_func =
12556 			RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12557 	else if (!strcmp(res->hash_func, "simple_xor"))
12558 		info.info.global_conf.hash_func =
12559 			RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12560 	else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12561 		info.info.global_conf.hash_func =
12562 			RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12563 	else if (!strcmp(res->hash_func, "default"))
12564 		info.info.global_conf.hash_func =
12565 			RTE_ETH_HASH_FUNCTION_DEFAULT;
12566 
12567 	ftype = str2flowtype(res->flow_type);
12568 	idx = ftype / UINT64_BIT;
12569 	offset = ftype % UINT64_BIT;
12570 	info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12571 	if (!strcmp(res->enable, "enable"))
12572 		info.info.global_conf.sym_hash_enable_mask[idx] |=
12573 						(1ULL << offset);
12574 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12575 					RTE_ETH_FILTER_SET, &info);
12576 	if (ret < 0)
12577 		printf("Cannot set global hash configurations by port %d\n",
12578 							res->port_id);
12579 	else
12580 		printf("Global hash configurations have been set "
12581 			"successfully by port %d\n", res->port_id);
12582 }
12583 
12584 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12585 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12586 		set_hash_global_config, "set_hash_global_config");
12587 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12588 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12589 		port_id, UINT16);
12590 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12591 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12592 		hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12593 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12594 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12595 		flow_type,
12596 		"ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12597 		"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12598 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12599 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12600 		enable, "enable#disable");
12601 
12602 cmdline_parse_inst_t cmd_set_hash_global_config = {
12603 	.f = cmd_set_hash_global_config_parsed,
12604 	.data = NULL,
12605 	.help_str = "set_hash_global_config <port_id> "
12606 		"toeplitz|simple_xor|symmetric_toeplitz|default "
12607 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12608 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12609 		"l2_payload enable|disable",
12610 	.tokens = {
12611 		(void *)&cmd_set_hash_global_config_all,
12612 		(void *)&cmd_set_hash_global_config_port_id,
12613 		(void *)&cmd_set_hash_global_config_hash_func,
12614 		(void *)&cmd_set_hash_global_config_flow_type,
12615 		(void *)&cmd_set_hash_global_config_enable,
12616 		NULL,
12617 	},
12618 };
12619 
12620 /* Set hash input set */
12621 struct cmd_set_hash_input_set_result {
12622 	cmdline_fixed_string_t set_hash_input_set;
12623 	portid_t port_id;
12624 	cmdline_fixed_string_t flow_type;
12625 	cmdline_fixed_string_t inset_field;
12626 	cmdline_fixed_string_t select;
12627 };
12628 
12629 static enum rte_eth_input_set_field
12630 str2inset(char *string)
12631 {
12632 	uint16_t i;
12633 
12634 	static const struct {
12635 		char str[32];
12636 		enum rte_eth_input_set_field inset;
12637 	} inset_table[] = {
12638 		{"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12639 		{"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12640 		{"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12641 		{"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12642 		{"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12643 		{"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12644 		{"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12645 		{"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12646 		{"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12647 		{"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12648 		{"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12649 		{"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12650 		{"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12651 		{"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12652 		{"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12653 		{"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12654 		{"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12655 		{"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12656 		{"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12657 		{"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12658 		{"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12659 		{"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12660 		{"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12661 		{"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12662 		{"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12663 		{"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12664 		{"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12665 		{"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12666 		{"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12667 		{"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12668 		{"none", RTE_ETH_INPUT_SET_NONE},
12669 	};
12670 
12671 	for (i = 0; i < RTE_DIM(inset_table); i++) {
12672 		if (!strcmp(string, inset_table[i].str))
12673 			return inset_table[i].inset;
12674 	}
12675 
12676 	return RTE_ETH_INPUT_SET_UNKNOWN;
12677 }
12678 
12679 static void
12680 cmd_set_hash_input_set_parsed(void *parsed_result,
12681 			      __rte_unused struct cmdline *cl,
12682 			      __rte_unused void *data)
12683 {
12684 	struct cmd_set_hash_input_set_result *res = parsed_result;
12685 	struct rte_eth_hash_filter_info info;
12686 
12687 	memset(&info, 0, sizeof(info));
12688 	info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12689 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12690 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12691 	info.info.input_set_conf.inset_size = 1;
12692 	if (!strcmp(res->select, "select"))
12693 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12694 	else if (!strcmp(res->select, "add"))
12695 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12696 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12697 				RTE_ETH_FILTER_SET, &info);
12698 }
12699 
12700 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12701 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12702 		set_hash_input_set, "set_hash_input_set");
12703 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12704 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12705 		port_id, UINT16);
12706 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12707 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12708 		flow_type, NULL);
12709 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12710 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12711 		inset_field,
12712 		"ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12713 		"ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12714 		"udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12715 		"sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12716 		"fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12717 		"fld-8th#none");
12718 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12719 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12720 		select, "select#add");
12721 
12722 cmdline_parse_inst_t cmd_set_hash_input_set = {
12723 	.f = cmd_set_hash_input_set_parsed,
12724 	.data = NULL,
12725 	.help_str = "set_hash_input_set <port_id> "
12726 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12727 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12728 	"ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12729 	"ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12730 	"tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12731 	"gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12732 	"fld-7th|fld-8th|none select|add",
12733 	.tokens = {
12734 		(void *)&cmd_set_hash_input_set_cmd,
12735 		(void *)&cmd_set_hash_input_set_port_id,
12736 		(void *)&cmd_set_hash_input_set_flow_type,
12737 		(void *)&cmd_set_hash_input_set_field,
12738 		(void *)&cmd_set_hash_input_set_select,
12739 		NULL,
12740 	},
12741 };
12742 
12743 /* Set flow director input set */
12744 struct cmd_set_fdir_input_set_result {
12745 	cmdline_fixed_string_t set_fdir_input_set;
12746 	portid_t port_id;
12747 	cmdline_fixed_string_t flow_type;
12748 	cmdline_fixed_string_t inset_field;
12749 	cmdline_fixed_string_t select;
12750 };
12751 
12752 static void
12753 cmd_set_fdir_input_set_parsed(void *parsed_result,
12754 	__rte_unused struct cmdline *cl,
12755 	__rte_unused void *data)
12756 {
12757 	struct cmd_set_fdir_input_set_result *res = parsed_result;
12758 	struct rte_eth_fdir_filter_info info;
12759 
12760 	memset(&info, 0, sizeof(info));
12761 	info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12762 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12763 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12764 	info.info.input_set_conf.inset_size = 1;
12765 	if (!strcmp(res->select, "select"))
12766 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12767 	else if (!strcmp(res->select, "add"))
12768 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12769 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12770 		RTE_ETH_FILTER_SET, &info);
12771 }
12772 
12773 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12774 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12775 	set_fdir_input_set, "set_fdir_input_set");
12776 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12777 	TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12778 	port_id, UINT16);
12779 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12780 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12781 	flow_type,
12782 	"ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12783 	"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12784 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12785 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12786 	inset_field,
12787 	"ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12788 	"ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12789 	"ipv6-hop-limits#udp-src-port#udp-dst-port#"
12790 	"tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12791 	"sctp-veri-tag#none");
12792 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12793 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12794 	select, "select#add");
12795 
12796 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12797 	.f = cmd_set_fdir_input_set_parsed,
12798 	.data = NULL,
12799 	.help_str = "set_fdir_input_set <port_id> "
12800 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12801 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12802 	"ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12803 	"ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12804 	"ipv6-hop-limits|udp-src-port|udp-dst-port|"
12805 	"tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12806 	"sctp-veri-tag|none select|add",
12807 	.tokens = {
12808 		(void *)&cmd_set_fdir_input_set_cmd,
12809 		(void *)&cmd_set_fdir_input_set_port_id,
12810 		(void *)&cmd_set_fdir_input_set_flow_type,
12811 		(void *)&cmd_set_fdir_input_set_field,
12812 		(void *)&cmd_set_fdir_input_set_select,
12813 		NULL,
12814 	},
12815 };
12816 
12817 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12818 struct cmd_mcast_addr_result {
12819 	cmdline_fixed_string_t mcast_addr_cmd;
12820 	cmdline_fixed_string_t what;
12821 	uint16_t port_num;
12822 	struct rte_ether_addr mc_addr;
12823 };
12824 
12825 static void cmd_mcast_addr_parsed(void *parsed_result,
12826 		__rte_unused struct cmdline *cl,
12827 		__rte_unused void *data)
12828 {
12829 	struct cmd_mcast_addr_result *res = parsed_result;
12830 
12831 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12832 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12833 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12834 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12835 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12836 		return;
12837 	}
12838 	if (strcmp(res->what, "add") == 0)
12839 		mcast_addr_add(res->port_num, &res->mc_addr);
12840 	else
12841 		mcast_addr_remove(res->port_num, &res->mc_addr);
12842 }
12843 
12844 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12845 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12846 				 mcast_addr_cmd, "mcast_addr");
12847 cmdline_parse_token_string_t cmd_mcast_addr_what =
12848 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12849 				 "add#remove");
12850 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12851 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12852 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12853 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12854 
12855 cmdline_parse_inst_t cmd_mcast_addr = {
12856 	.f = cmd_mcast_addr_parsed,
12857 	.data = (void *)0,
12858 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12859 		"Add/Remove multicast MAC address on port_id",
12860 	.tokens = {
12861 		(void *)&cmd_mcast_addr_cmd,
12862 		(void *)&cmd_mcast_addr_what,
12863 		(void *)&cmd_mcast_addr_portnum,
12864 		(void *)&cmd_mcast_addr_addr,
12865 		NULL,
12866 	},
12867 };
12868 
12869 /* l2 tunnel config
12870  * only support E-tag now.
12871  */
12872 
12873 /* Ether type config */
12874 struct cmd_config_l2_tunnel_eth_type_result {
12875 	cmdline_fixed_string_t port;
12876 	cmdline_fixed_string_t config;
12877 	cmdline_fixed_string_t all;
12878 	portid_t id;
12879 	cmdline_fixed_string_t l2_tunnel;
12880 	cmdline_fixed_string_t l2_tunnel_type;
12881 	cmdline_fixed_string_t eth_type;
12882 	uint16_t eth_type_val;
12883 };
12884 
12885 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12886 	TOKEN_STRING_INITIALIZER
12887 		(struct cmd_config_l2_tunnel_eth_type_result,
12888 		 port, "port");
12889 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12890 	TOKEN_STRING_INITIALIZER
12891 		(struct cmd_config_l2_tunnel_eth_type_result,
12892 		 config, "config");
12893 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12894 	TOKEN_STRING_INITIALIZER
12895 		(struct cmd_config_l2_tunnel_eth_type_result,
12896 		 all, "all");
12897 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12898 	TOKEN_NUM_INITIALIZER
12899 		(struct cmd_config_l2_tunnel_eth_type_result,
12900 		 id, UINT16);
12901 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12902 	TOKEN_STRING_INITIALIZER
12903 		(struct cmd_config_l2_tunnel_eth_type_result,
12904 		 l2_tunnel, "l2-tunnel");
12905 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12906 	TOKEN_STRING_INITIALIZER
12907 		(struct cmd_config_l2_tunnel_eth_type_result,
12908 		 l2_tunnel_type, "E-tag");
12909 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12910 	TOKEN_STRING_INITIALIZER
12911 		(struct cmd_config_l2_tunnel_eth_type_result,
12912 		 eth_type, "ether-type");
12913 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12914 	TOKEN_NUM_INITIALIZER
12915 		(struct cmd_config_l2_tunnel_eth_type_result,
12916 		 eth_type_val, UINT16);
12917 
12918 static enum rte_eth_tunnel_type
12919 str2fdir_l2_tunnel_type(char *string)
12920 {
12921 	uint32_t i = 0;
12922 
12923 	static const struct {
12924 		char str[32];
12925 		enum rte_eth_tunnel_type type;
12926 	} l2_tunnel_type_str[] = {
12927 		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12928 	};
12929 
12930 	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12931 		if (!strcmp(l2_tunnel_type_str[i].str, string))
12932 			return l2_tunnel_type_str[i].type;
12933 	}
12934 	return RTE_TUNNEL_TYPE_NONE;
12935 }
12936 
12937 /* ether type config for all ports */
12938 static void
12939 cmd_config_l2_tunnel_eth_type_all_parsed
12940 	(void *parsed_result,
12941 	 __rte_unused struct cmdline *cl,
12942 	 __rte_unused void *data)
12943 {
12944 	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12945 	struct rte_eth_l2_tunnel_conf entry;
12946 	portid_t pid;
12947 
12948 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12949 	entry.ether_type = res->eth_type_val;
12950 
12951 	RTE_ETH_FOREACH_DEV(pid) {
12952 		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12953 	}
12954 }
12955 
12956 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12957 	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
12958 	.data = NULL,
12959 	.help_str = "port config all l2-tunnel E-tag ether-type <value>",
12960 	.tokens = {
12961 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12962 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12963 		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
12964 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12965 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12966 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12967 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12968 		NULL,
12969 	},
12970 };
12971 
12972 /* ether type config for a specific port */
12973 static void
12974 cmd_config_l2_tunnel_eth_type_specific_parsed(
12975 	void *parsed_result,
12976 	__rte_unused struct cmdline *cl,
12977 	__rte_unused void *data)
12978 {
12979 	struct cmd_config_l2_tunnel_eth_type_result *res =
12980 		 parsed_result;
12981 	struct rte_eth_l2_tunnel_conf entry;
12982 
12983 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12984 		return;
12985 
12986 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12987 	entry.ether_type = res->eth_type_val;
12988 
12989 	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12990 }
12991 
12992 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12993 	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12994 	.data = NULL,
12995 	.help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12996 	.tokens = {
12997 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12998 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12999 		(void *)&cmd_config_l2_tunnel_eth_type_id,
13000 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13001 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13002 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13003 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13004 		NULL,
13005 	},
13006 };
13007 
13008 /* Enable/disable l2 tunnel */
13009 struct cmd_config_l2_tunnel_en_dis_result {
13010 	cmdline_fixed_string_t port;
13011 	cmdline_fixed_string_t config;
13012 	cmdline_fixed_string_t all;
13013 	portid_t id;
13014 	cmdline_fixed_string_t l2_tunnel;
13015 	cmdline_fixed_string_t l2_tunnel_type;
13016 	cmdline_fixed_string_t en_dis;
13017 };
13018 
13019 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13020 	TOKEN_STRING_INITIALIZER
13021 		(struct cmd_config_l2_tunnel_en_dis_result,
13022 		 port, "port");
13023 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13024 	TOKEN_STRING_INITIALIZER
13025 		(struct cmd_config_l2_tunnel_en_dis_result,
13026 		 config, "config");
13027 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13028 	TOKEN_STRING_INITIALIZER
13029 		(struct cmd_config_l2_tunnel_en_dis_result,
13030 		 all, "all");
13031 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13032 	TOKEN_NUM_INITIALIZER
13033 		(struct cmd_config_l2_tunnel_en_dis_result,
13034 		 id, UINT16);
13035 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13036 	TOKEN_STRING_INITIALIZER
13037 		(struct cmd_config_l2_tunnel_en_dis_result,
13038 		 l2_tunnel, "l2-tunnel");
13039 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13040 	TOKEN_STRING_INITIALIZER
13041 		(struct cmd_config_l2_tunnel_en_dis_result,
13042 		 l2_tunnel_type, "E-tag");
13043 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13044 	TOKEN_STRING_INITIALIZER
13045 		(struct cmd_config_l2_tunnel_en_dis_result,
13046 		 en_dis, "enable#disable");
13047 
13048 /* enable/disable l2 tunnel for all ports */
13049 static void
13050 cmd_config_l2_tunnel_en_dis_all_parsed(
13051 	void *parsed_result,
13052 	__rte_unused struct cmdline *cl,
13053 	__rte_unused void *data)
13054 {
13055 	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13056 	struct rte_eth_l2_tunnel_conf entry;
13057 	portid_t pid;
13058 	uint8_t en;
13059 
13060 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13061 
13062 	if (!strcmp("enable", res->en_dis))
13063 		en = 1;
13064 	else
13065 		en = 0;
13066 
13067 	RTE_ETH_FOREACH_DEV(pid) {
13068 		rte_eth_dev_l2_tunnel_offload_set(pid,
13069 						  &entry,
13070 						  ETH_L2_TUNNEL_ENABLE_MASK,
13071 						  en);
13072 	}
13073 }
13074 
13075 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13076 	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
13077 	.data = NULL,
13078 	.help_str = "port config all l2-tunnel E-tag enable|disable",
13079 	.tokens = {
13080 		(void *)&cmd_config_l2_tunnel_en_dis_port,
13081 		(void *)&cmd_config_l2_tunnel_en_dis_config,
13082 		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
13083 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13084 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13085 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13086 		NULL,
13087 	},
13088 };
13089 
13090 /* enable/disable l2 tunnel for a port */
13091 static void
13092 cmd_config_l2_tunnel_en_dis_specific_parsed(
13093 	void *parsed_result,
13094 	__rte_unused struct cmdline *cl,
13095 	__rte_unused void *data)
13096 {
13097 	struct cmd_config_l2_tunnel_en_dis_result *res =
13098 		parsed_result;
13099 	struct rte_eth_l2_tunnel_conf entry;
13100 
13101 	if (port_id_is_invalid(res->id, ENABLED_WARN))
13102 		return;
13103 
13104 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13105 
13106 	if (!strcmp("enable", res->en_dis))
13107 		rte_eth_dev_l2_tunnel_offload_set(res->id,
13108 						  &entry,
13109 						  ETH_L2_TUNNEL_ENABLE_MASK,
13110 						  1);
13111 	else
13112 		rte_eth_dev_l2_tunnel_offload_set(res->id,
13113 						  &entry,
13114 						  ETH_L2_TUNNEL_ENABLE_MASK,
13115 						  0);
13116 }
13117 
13118 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13119 	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13120 	.data = NULL,
13121 	.help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13122 	.tokens = {
13123 		(void *)&cmd_config_l2_tunnel_en_dis_port,
13124 		(void *)&cmd_config_l2_tunnel_en_dis_config,
13125 		(void *)&cmd_config_l2_tunnel_en_dis_id,
13126 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13127 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13128 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13129 		NULL,
13130 	},
13131 };
13132 
13133 /* E-tag configuration */
13134 
13135 /* Common result structure for all E-tag configuration */
13136 struct cmd_config_e_tag_result {
13137 	cmdline_fixed_string_t e_tag;
13138 	cmdline_fixed_string_t set;
13139 	cmdline_fixed_string_t insertion;
13140 	cmdline_fixed_string_t stripping;
13141 	cmdline_fixed_string_t forwarding;
13142 	cmdline_fixed_string_t filter;
13143 	cmdline_fixed_string_t add;
13144 	cmdline_fixed_string_t del;
13145 	cmdline_fixed_string_t on;
13146 	cmdline_fixed_string_t off;
13147 	cmdline_fixed_string_t on_off;
13148 	cmdline_fixed_string_t port_tag_id;
13149 	uint32_t port_tag_id_val;
13150 	cmdline_fixed_string_t e_tag_id;
13151 	uint16_t e_tag_id_val;
13152 	cmdline_fixed_string_t dst_pool;
13153 	uint8_t dst_pool_val;
13154 	cmdline_fixed_string_t port;
13155 	portid_t port_id;
13156 	cmdline_fixed_string_t vf;
13157 	uint8_t vf_id;
13158 };
13159 
13160 /* Common CLI fields for all E-tag configuration */
13161 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13162 	TOKEN_STRING_INITIALIZER
13163 		(struct cmd_config_e_tag_result,
13164 		 e_tag, "E-tag");
13165 cmdline_parse_token_string_t cmd_config_e_tag_set =
13166 	TOKEN_STRING_INITIALIZER
13167 		(struct cmd_config_e_tag_result,
13168 		 set, "set");
13169 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13170 	TOKEN_STRING_INITIALIZER
13171 		(struct cmd_config_e_tag_result,
13172 		 insertion, "insertion");
13173 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13174 	TOKEN_STRING_INITIALIZER
13175 		(struct cmd_config_e_tag_result,
13176 		 stripping, "stripping");
13177 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13178 	TOKEN_STRING_INITIALIZER
13179 		(struct cmd_config_e_tag_result,
13180 		 forwarding, "forwarding");
13181 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13182 	TOKEN_STRING_INITIALIZER
13183 		(struct cmd_config_e_tag_result,
13184 		 filter, "filter");
13185 cmdline_parse_token_string_t cmd_config_e_tag_add =
13186 	TOKEN_STRING_INITIALIZER
13187 		(struct cmd_config_e_tag_result,
13188 		 add, "add");
13189 cmdline_parse_token_string_t cmd_config_e_tag_del =
13190 	TOKEN_STRING_INITIALIZER
13191 		(struct cmd_config_e_tag_result,
13192 		 del, "del");
13193 cmdline_parse_token_string_t cmd_config_e_tag_on =
13194 	TOKEN_STRING_INITIALIZER
13195 		(struct cmd_config_e_tag_result,
13196 		 on, "on");
13197 cmdline_parse_token_string_t cmd_config_e_tag_off =
13198 	TOKEN_STRING_INITIALIZER
13199 		(struct cmd_config_e_tag_result,
13200 		 off, "off");
13201 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13202 	TOKEN_STRING_INITIALIZER
13203 		(struct cmd_config_e_tag_result,
13204 		 on_off, "on#off");
13205 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13206 	TOKEN_STRING_INITIALIZER
13207 		(struct cmd_config_e_tag_result,
13208 		 port_tag_id, "port-tag-id");
13209 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13210 	TOKEN_NUM_INITIALIZER
13211 		(struct cmd_config_e_tag_result,
13212 		 port_tag_id_val, UINT32);
13213 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13214 	TOKEN_STRING_INITIALIZER
13215 		(struct cmd_config_e_tag_result,
13216 		 e_tag_id, "e-tag-id");
13217 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13218 	TOKEN_NUM_INITIALIZER
13219 		(struct cmd_config_e_tag_result,
13220 		 e_tag_id_val, UINT16);
13221 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13222 	TOKEN_STRING_INITIALIZER
13223 		(struct cmd_config_e_tag_result,
13224 		 dst_pool, "dst-pool");
13225 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13226 	TOKEN_NUM_INITIALIZER
13227 		(struct cmd_config_e_tag_result,
13228 		 dst_pool_val, UINT8);
13229 cmdline_parse_token_string_t cmd_config_e_tag_port =
13230 	TOKEN_STRING_INITIALIZER
13231 		(struct cmd_config_e_tag_result,
13232 		 port, "port");
13233 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13234 	TOKEN_NUM_INITIALIZER
13235 		(struct cmd_config_e_tag_result,
13236 		 port_id, UINT16);
13237 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13238 	TOKEN_STRING_INITIALIZER
13239 		(struct cmd_config_e_tag_result,
13240 		 vf, "vf");
13241 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13242 	TOKEN_NUM_INITIALIZER
13243 		(struct cmd_config_e_tag_result,
13244 		 vf_id, UINT8);
13245 
13246 /* E-tag insertion configuration */
13247 static void
13248 cmd_config_e_tag_insertion_en_parsed(
13249 	void *parsed_result,
13250 	__rte_unused struct cmdline *cl,
13251 	__rte_unused void *data)
13252 {
13253 	struct cmd_config_e_tag_result *res =
13254 		parsed_result;
13255 	struct rte_eth_l2_tunnel_conf entry;
13256 
13257 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13258 		return;
13259 
13260 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13261 	entry.tunnel_id = res->port_tag_id_val;
13262 	entry.vf_id = res->vf_id;
13263 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13264 					  &entry,
13265 					  ETH_L2_TUNNEL_INSERTION_MASK,
13266 					  1);
13267 }
13268 
13269 static void
13270 cmd_config_e_tag_insertion_dis_parsed(
13271 	void *parsed_result,
13272 	__rte_unused struct cmdline *cl,
13273 	__rte_unused void *data)
13274 {
13275 	struct cmd_config_e_tag_result *res =
13276 		parsed_result;
13277 	struct rte_eth_l2_tunnel_conf entry;
13278 
13279 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13280 		return;
13281 
13282 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13283 	entry.vf_id = res->vf_id;
13284 
13285 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13286 					  &entry,
13287 					  ETH_L2_TUNNEL_INSERTION_MASK,
13288 					  0);
13289 }
13290 
13291 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13292 	.f = cmd_config_e_tag_insertion_en_parsed,
13293 	.data = NULL,
13294 	.help_str = "E-tag ... : E-tag insertion enable",
13295 	.tokens = {
13296 		(void *)&cmd_config_e_tag_e_tag,
13297 		(void *)&cmd_config_e_tag_set,
13298 		(void *)&cmd_config_e_tag_insertion,
13299 		(void *)&cmd_config_e_tag_on,
13300 		(void *)&cmd_config_e_tag_port_tag_id,
13301 		(void *)&cmd_config_e_tag_port_tag_id_val,
13302 		(void *)&cmd_config_e_tag_port,
13303 		(void *)&cmd_config_e_tag_port_id,
13304 		(void *)&cmd_config_e_tag_vf,
13305 		(void *)&cmd_config_e_tag_vf_id,
13306 		NULL,
13307 	},
13308 };
13309 
13310 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13311 	.f = cmd_config_e_tag_insertion_dis_parsed,
13312 	.data = NULL,
13313 	.help_str = "E-tag ... : E-tag insertion disable",
13314 	.tokens = {
13315 		(void *)&cmd_config_e_tag_e_tag,
13316 		(void *)&cmd_config_e_tag_set,
13317 		(void *)&cmd_config_e_tag_insertion,
13318 		(void *)&cmd_config_e_tag_off,
13319 		(void *)&cmd_config_e_tag_port,
13320 		(void *)&cmd_config_e_tag_port_id,
13321 		(void *)&cmd_config_e_tag_vf,
13322 		(void *)&cmd_config_e_tag_vf_id,
13323 		NULL,
13324 	},
13325 };
13326 
13327 /* E-tag stripping configuration */
13328 static void
13329 cmd_config_e_tag_stripping_parsed(
13330 	void *parsed_result,
13331 	__rte_unused struct cmdline *cl,
13332 	__rte_unused void *data)
13333 {
13334 	struct cmd_config_e_tag_result *res =
13335 		parsed_result;
13336 	struct rte_eth_l2_tunnel_conf entry;
13337 
13338 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13339 		return;
13340 
13341 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13342 
13343 	if (!strcmp(res->on_off, "on"))
13344 		rte_eth_dev_l2_tunnel_offload_set
13345 			(res->port_id,
13346 			 &entry,
13347 			 ETH_L2_TUNNEL_STRIPPING_MASK,
13348 			 1);
13349 	else
13350 		rte_eth_dev_l2_tunnel_offload_set
13351 			(res->port_id,
13352 			 &entry,
13353 			 ETH_L2_TUNNEL_STRIPPING_MASK,
13354 			 0);
13355 }
13356 
13357 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13358 	.f = cmd_config_e_tag_stripping_parsed,
13359 	.data = NULL,
13360 	.help_str = "E-tag ... : E-tag stripping enable/disable",
13361 	.tokens = {
13362 		(void *)&cmd_config_e_tag_e_tag,
13363 		(void *)&cmd_config_e_tag_set,
13364 		(void *)&cmd_config_e_tag_stripping,
13365 		(void *)&cmd_config_e_tag_on_off,
13366 		(void *)&cmd_config_e_tag_port,
13367 		(void *)&cmd_config_e_tag_port_id,
13368 		NULL,
13369 	},
13370 };
13371 
13372 /* E-tag forwarding configuration */
13373 static void
13374 cmd_config_e_tag_forwarding_parsed(
13375 	void *parsed_result,
13376 	__rte_unused struct cmdline *cl,
13377 	__rte_unused void *data)
13378 {
13379 	struct cmd_config_e_tag_result *res = parsed_result;
13380 	struct rte_eth_l2_tunnel_conf entry;
13381 
13382 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13383 		return;
13384 
13385 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13386 
13387 	if (!strcmp(res->on_off, "on"))
13388 		rte_eth_dev_l2_tunnel_offload_set
13389 			(res->port_id,
13390 			 &entry,
13391 			 ETH_L2_TUNNEL_FORWARDING_MASK,
13392 			 1);
13393 	else
13394 		rte_eth_dev_l2_tunnel_offload_set
13395 			(res->port_id,
13396 			 &entry,
13397 			 ETH_L2_TUNNEL_FORWARDING_MASK,
13398 			 0);
13399 }
13400 
13401 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13402 	.f = cmd_config_e_tag_forwarding_parsed,
13403 	.data = NULL,
13404 	.help_str = "E-tag ... : E-tag forwarding enable/disable",
13405 	.tokens = {
13406 		(void *)&cmd_config_e_tag_e_tag,
13407 		(void *)&cmd_config_e_tag_set,
13408 		(void *)&cmd_config_e_tag_forwarding,
13409 		(void *)&cmd_config_e_tag_on_off,
13410 		(void *)&cmd_config_e_tag_port,
13411 		(void *)&cmd_config_e_tag_port_id,
13412 		NULL,
13413 	},
13414 };
13415 
13416 /* E-tag filter configuration */
13417 static void
13418 cmd_config_e_tag_filter_add_parsed(
13419 	void *parsed_result,
13420 	__rte_unused struct cmdline *cl,
13421 	__rte_unused void *data)
13422 {
13423 	struct cmd_config_e_tag_result *res = parsed_result;
13424 	struct rte_eth_l2_tunnel_conf entry;
13425 	int ret = 0;
13426 
13427 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13428 		return;
13429 
13430 	if (res->e_tag_id_val > 0x3fff) {
13431 		printf("e-tag-id must be equal or less than 0x3fff.\n");
13432 		return;
13433 	}
13434 
13435 	ret = rte_eth_dev_filter_supported(res->port_id,
13436 					   RTE_ETH_FILTER_L2_TUNNEL);
13437 	if (ret < 0) {
13438 		printf("E-tag filter is not supported on port %u.\n",
13439 		       res->port_id);
13440 		return;
13441 	}
13442 
13443 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13444 	entry.tunnel_id = res->e_tag_id_val;
13445 	entry.pool = res->dst_pool_val;
13446 
13447 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13448 				      RTE_ETH_FILTER_L2_TUNNEL,
13449 				      RTE_ETH_FILTER_ADD,
13450 				      &entry);
13451 	if (ret < 0)
13452 		printf("E-tag filter programming error: (%s)\n",
13453 		       strerror(-ret));
13454 }
13455 
13456 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13457 	.f = cmd_config_e_tag_filter_add_parsed,
13458 	.data = NULL,
13459 	.help_str = "E-tag ... : E-tag filter add",
13460 	.tokens = {
13461 		(void *)&cmd_config_e_tag_e_tag,
13462 		(void *)&cmd_config_e_tag_set,
13463 		(void *)&cmd_config_e_tag_filter,
13464 		(void *)&cmd_config_e_tag_add,
13465 		(void *)&cmd_config_e_tag_e_tag_id,
13466 		(void *)&cmd_config_e_tag_e_tag_id_val,
13467 		(void *)&cmd_config_e_tag_dst_pool,
13468 		(void *)&cmd_config_e_tag_dst_pool_val,
13469 		(void *)&cmd_config_e_tag_port,
13470 		(void *)&cmd_config_e_tag_port_id,
13471 		NULL,
13472 	},
13473 };
13474 
13475 static void
13476 cmd_config_e_tag_filter_del_parsed(
13477 	void *parsed_result,
13478 	__rte_unused struct cmdline *cl,
13479 	__rte_unused void *data)
13480 {
13481 	struct cmd_config_e_tag_result *res = parsed_result;
13482 	struct rte_eth_l2_tunnel_conf entry;
13483 	int ret = 0;
13484 
13485 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13486 		return;
13487 
13488 	if (res->e_tag_id_val > 0x3fff) {
13489 		printf("e-tag-id must be less than 0x3fff.\n");
13490 		return;
13491 	}
13492 
13493 	ret = rte_eth_dev_filter_supported(res->port_id,
13494 					   RTE_ETH_FILTER_L2_TUNNEL);
13495 	if (ret < 0) {
13496 		printf("E-tag filter is not supported on port %u.\n",
13497 		       res->port_id);
13498 		return;
13499 	}
13500 
13501 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13502 	entry.tunnel_id = res->e_tag_id_val;
13503 
13504 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13505 				      RTE_ETH_FILTER_L2_TUNNEL,
13506 				      RTE_ETH_FILTER_DELETE,
13507 				      &entry);
13508 	if (ret < 0)
13509 		printf("E-tag filter programming error: (%s)\n",
13510 		       strerror(-ret));
13511 }
13512 
13513 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13514 	.f = cmd_config_e_tag_filter_del_parsed,
13515 	.data = NULL,
13516 	.help_str = "E-tag ... : E-tag filter delete",
13517 	.tokens = {
13518 		(void *)&cmd_config_e_tag_e_tag,
13519 		(void *)&cmd_config_e_tag_set,
13520 		(void *)&cmd_config_e_tag_filter,
13521 		(void *)&cmd_config_e_tag_del,
13522 		(void *)&cmd_config_e_tag_e_tag_id,
13523 		(void *)&cmd_config_e_tag_e_tag_id_val,
13524 		(void *)&cmd_config_e_tag_port,
13525 		(void *)&cmd_config_e_tag_port_id,
13526 		NULL,
13527 	},
13528 };
13529 
13530 /* vf vlan anti spoof configuration */
13531 
13532 /* Common result structure for vf vlan anti spoof */
13533 struct cmd_vf_vlan_anti_spoof_result {
13534 	cmdline_fixed_string_t set;
13535 	cmdline_fixed_string_t vf;
13536 	cmdline_fixed_string_t vlan;
13537 	cmdline_fixed_string_t antispoof;
13538 	portid_t port_id;
13539 	uint32_t vf_id;
13540 	cmdline_fixed_string_t on_off;
13541 };
13542 
13543 /* Common CLI fields for vf vlan anti spoof enable disable */
13544 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13545 	TOKEN_STRING_INITIALIZER
13546 		(struct cmd_vf_vlan_anti_spoof_result,
13547 		 set, "set");
13548 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13549 	TOKEN_STRING_INITIALIZER
13550 		(struct cmd_vf_vlan_anti_spoof_result,
13551 		 vf, "vf");
13552 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13553 	TOKEN_STRING_INITIALIZER
13554 		(struct cmd_vf_vlan_anti_spoof_result,
13555 		 vlan, "vlan");
13556 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13557 	TOKEN_STRING_INITIALIZER
13558 		(struct cmd_vf_vlan_anti_spoof_result,
13559 		 antispoof, "antispoof");
13560 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13561 	TOKEN_NUM_INITIALIZER
13562 		(struct cmd_vf_vlan_anti_spoof_result,
13563 		 port_id, UINT16);
13564 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13565 	TOKEN_NUM_INITIALIZER
13566 		(struct cmd_vf_vlan_anti_spoof_result,
13567 		 vf_id, UINT32);
13568 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13569 	TOKEN_STRING_INITIALIZER
13570 		(struct cmd_vf_vlan_anti_spoof_result,
13571 		 on_off, "on#off");
13572 
13573 static void
13574 cmd_set_vf_vlan_anti_spoof_parsed(
13575 	void *parsed_result,
13576 	__rte_unused struct cmdline *cl,
13577 	__rte_unused void *data)
13578 {
13579 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13580 	int ret = -ENOTSUP;
13581 
13582 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13583 
13584 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13585 		return;
13586 
13587 #ifdef RTE_LIBRTE_IXGBE_PMD
13588 	if (ret == -ENOTSUP)
13589 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13590 				res->vf_id, is_on);
13591 #endif
13592 #ifdef RTE_LIBRTE_I40E_PMD
13593 	if (ret == -ENOTSUP)
13594 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13595 				res->vf_id, is_on);
13596 #endif
13597 #ifdef RTE_LIBRTE_BNXT_PMD
13598 	if (ret == -ENOTSUP)
13599 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13600 				res->vf_id, is_on);
13601 #endif
13602 
13603 	switch (ret) {
13604 	case 0:
13605 		break;
13606 	case -EINVAL:
13607 		printf("invalid vf_id %d\n", res->vf_id);
13608 		break;
13609 	case -ENODEV:
13610 		printf("invalid port_id %d\n", res->port_id);
13611 		break;
13612 	case -ENOTSUP:
13613 		printf("function not implemented\n");
13614 		break;
13615 	default:
13616 		printf("programming error: (%s)\n", strerror(-ret));
13617 	}
13618 }
13619 
13620 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13621 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
13622 	.data = NULL,
13623 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13624 	.tokens = {
13625 		(void *)&cmd_vf_vlan_anti_spoof_set,
13626 		(void *)&cmd_vf_vlan_anti_spoof_vf,
13627 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
13628 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
13629 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
13630 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
13631 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
13632 		NULL,
13633 	},
13634 };
13635 
13636 /* vf mac anti spoof configuration */
13637 
13638 /* Common result structure for vf mac anti spoof */
13639 struct cmd_vf_mac_anti_spoof_result {
13640 	cmdline_fixed_string_t set;
13641 	cmdline_fixed_string_t vf;
13642 	cmdline_fixed_string_t mac;
13643 	cmdline_fixed_string_t antispoof;
13644 	portid_t port_id;
13645 	uint32_t vf_id;
13646 	cmdline_fixed_string_t on_off;
13647 };
13648 
13649 /* Common CLI fields for vf mac anti spoof enable disable */
13650 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13651 	TOKEN_STRING_INITIALIZER
13652 		(struct cmd_vf_mac_anti_spoof_result,
13653 		 set, "set");
13654 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13655 	TOKEN_STRING_INITIALIZER
13656 		(struct cmd_vf_mac_anti_spoof_result,
13657 		 vf, "vf");
13658 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13659 	TOKEN_STRING_INITIALIZER
13660 		(struct cmd_vf_mac_anti_spoof_result,
13661 		 mac, "mac");
13662 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13663 	TOKEN_STRING_INITIALIZER
13664 		(struct cmd_vf_mac_anti_spoof_result,
13665 		 antispoof, "antispoof");
13666 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13667 	TOKEN_NUM_INITIALIZER
13668 		(struct cmd_vf_mac_anti_spoof_result,
13669 		 port_id, UINT16);
13670 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13671 	TOKEN_NUM_INITIALIZER
13672 		(struct cmd_vf_mac_anti_spoof_result,
13673 		 vf_id, UINT32);
13674 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13675 	TOKEN_STRING_INITIALIZER
13676 		(struct cmd_vf_mac_anti_spoof_result,
13677 		 on_off, "on#off");
13678 
13679 static void
13680 cmd_set_vf_mac_anti_spoof_parsed(
13681 	void *parsed_result,
13682 	__rte_unused struct cmdline *cl,
13683 	__rte_unused void *data)
13684 {
13685 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13686 	int ret = -ENOTSUP;
13687 
13688 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13689 
13690 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13691 		return;
13692 
13693 #ifdef RTE_LIBRTE_IXGBE_PMD
13694 	if (ret == -ENOTSUP)
13695 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13696 			res->vf_id, is_on);
13697 #endif
13698 #ifdef RTE_LIBRTE_I40E_PMD
13699 	if (ret == -ENOTSUP)
13700 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13701 			res->vf_id, is_on);
13702 #endif
13703 #ifdef RTE_LIBRTE_BNXT_PMD
13704 	if (ret == -ENOTSUP)
13705 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13706 			res->vf_id, is_on);
13707 #endif
13708 
13709 	switch (ret) {
13710 	case 0:
13711 		break;
13712 	case -EINVAL:
13713 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13714 		break;
13715 	case -ENODEV:
13716 		printf("invalid port_id %d\n", res->port_id);
13717 		break;
13718 	case -ENOTSUP:
13719 		printf("function not implemented\n");
13720 		break;
13721 	default:
13722 		printf("programming error: (%s)\n", strerror(-ret));
13723 	}
13724 }
13725 
13726 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13727 	.f = cmd_set_vf_mac_anti_spoof_parsed,
13728 	.data = NULL,
13729 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13730 	.tokens = {
13731 		(void *)&cmd_vf_mac_anti_spoof_set,
13732 		(void *)&cmd_vf_mac_anti_spoof_vf,
13733 		(void *)&cmd_vf_mac_anti_spoof_mac,
13734 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
13735 		(void *)&cmd_vf_mac_anti_spoof_port_id,
13736 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
13737 		(void *)&cmd_vf_mac_anti_spoof_on_off,
13738 		NULL,
13739 	},
13740 };
13741 
13742 /* vf vlan strip queue configuration */
13743 
13744 /* Common result structure for vf mac anti spoof */
13745 struct cmd_vf_vlan_stripq_result {
13746 	cmdline_fixed_string_t set;
13747 	cmdline_fixed_string_t vf;
13748 	cmdline_fixed_string_t vlan;
13749 	cmdline_fixed_string_t stripq;
13750 	portid_t port_id;
13751 	uint16_t vf_id;
13752 	cmdline_fixed_string_t on_off;
13753 };
13754 
13755 /* Common CLI fields for vf vlan strip enable disable */
13756 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13757 	TOKEN_STRING_INITIALIZER
13758 		(struct cmd_vf_vlan_stripq_result,
13759 		 set, "set");
13760 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13761 	TOKEN_STRING_INITIALIZER
13762 		(struct cmd_vf_vlan_stripq_result,
13763 		 vf, "vf");
13764 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13765 	TOKEN_STRING_INITIALIZER
13766 		(struct cmd_vf_vlan_stripq_result,
13767 		 vlan, "vlan");
13768 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13769 	TOKEN_STRING_INITIALIZER
13770 		(struct cmd_vf_vlan_stripq_result,
13771 		 stripq, "stripq");
13772 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13773 	TOKEN_NUM_INITIALIZER
13774 		(struct cmd_vf_vlan_stripq_result,
13775 		 port_id, UINT16);
13776 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13777 	TOKEN_NUM_INITIALIZER
13778 		(struct cmd_vf_vlan_stripq_result,
13779 		 vf_id, UINT16);
13780 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13781 	TOKEN_STRING_INITIALIZER
13782 		(struct cmd_vf_vlan_stripq_result,
13783 		 on_off, "on#off");
13784 
13785 static void
13786 cmd_set_vf_vlan_stripq_parsed(
13787 	void *parsed_result,
13788 	__rte_unused struct cmdline *cl,
13789 	__rte_unused void *data)
13790 {
13791 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
13792 	int ret = -ENOTSUP;
13793 
13794 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13795 
13796 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13797 		return;
13798 
13799 #ifdef RTE_LIBRTE_IXGBE_PMD
13800 	if (ret == -ENOTSUP)
13801 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13802 			res->vf_id, is_on);
13803 #endif
13804 #ifdef RTE_LIBRTE_I40E_PMD
13805 	if (ret == -ENOTSUP)
13806 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13807 			res->vf_id, is_on);
13808 #endif
13809 #ifdef RTE_LIBRTE_BNXT_PMD
13810 	if (ret == -ENOTSUP)
13811 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13812 			res->vf_id, is_on);
13813 #endif
13814 
13815 	switch (ret) {
13816 	case 0:
13817 		break;
13818 	case -EINVAL:
13819 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13820 		break;
13821 	case -ENODEV:
13822 		printf("invalid port_id %d\n", res->port_id);
13823 		break;
13824 	case -ENOTSUP:
13825 		printf("function not implemented\n");
13826 		break;
13827 	default:
13828 		printf("programming error: (%s)\n", strerror(-ret));
13829 	}
13830 }
13831 
13832 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13833 	.f = cmd_set_vf_vlan_stripq_parsed,
13834 	.data = NULL,
13835 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13836 	.tokens = {
13837 		(void *)&cmd_vf_vlan_stripq_set,
13838 		(void *)&cmd_vf_vlan_stripq_vf,
13839 		(void *)&cmd_vf_vlan_stripq_vlan,
13840 		(void *)&cmd_vf_vlan_stripq_stripq,
13841 		(void *)&cmd_vf_vlan_stripq_port_id,
13842 		(void *)&cmd_vf_vlan_stripq_vf_id,
13843 		(void *)&cmd_vf_vlan_stripq_on_off,
13844 		NULL,
13845 	},
13846 };
13847 
13848 /* vf vlan insert configuration */
13849 
13850 /* Common result structure for vf vlan insert */
13851 struct cmd_vf_vlan_insert_result {
13852 	cmdline_fixed_string_t set;
13853 	cmdline_fixed_string_t vf;
13854 	cmdline_fixed_string_t vlan;
13855 	cmdline_fixed_string_t insert;
13856 	portid_t port_id;
13857 	uint16_t vf_id;
13858 	uint16_t vlan_id;
13859 };
13860 
13861 /* Common CLI fields for vf vlan insert enable disable */
13862 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13863 	TOKEN_STRING_INITIALIZER
13864 		(struct cmd_vf_vlan_insert_result,
13865 		 set, "set");
13866 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13867 	TOKEN_STRING_INITIALIZER
13868 		(struct cmd_vf_vlan_insert_result,
13869 		 vf, "vf");
13870 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13871 	TOKEN_STRING_INITIALIZER
13872 		(struct cmd_vf_vlan_insert_result,
13873 		 vlan, "vlan");
13874 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13875 	TOKEN_STRING_INITIALIZER
13876 		(struct cmd_vf_vlan_insert_result,
13877 		 insert, "insert");
13878 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13879 	TOKEN_NUM_INITIALIZER
13880 		(struct cmd_vf_vlan_insert_result,
13881 		 port_id, UINT16);
13882 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13883 	TOKEN_NUM_INITIALIZER
13884 		(struct cmd_vf_vlan_insert_result,
13885 		 vf_id, UINT16);
13886 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13887 	TOKEN_NUM_INITIALIZER
13888 		(struct cmd_vf_vlan_insert_result,
13889 		 vlan_id, UINT16);
13890 
13891 static void
13892 cmd_set_vf_vlan_insert_parsed(
13893 	void *parsed_result,
13894 	__rte_unused struct cmdline *cl,
13895 	__rte_unused void *data)
13896 {
13897 	struct cmd_vf_vlan_insert_result *res = parsed_result;
13898 	int ret = -ENOTSUP;
13899 
13900 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13901 		return;
13902 
13903 #ifdef RTE_LIBRTE_IXGBE_PMD
13904 	if (ret == -ENOTSUP)
13905 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13906 			res->vlan_id);
13907 #endif
13908 #ifdef RTE_LIBRTE_I40E_PMD
13909 	if (ret == -ENOTSUP)
13910 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13911 			res->vlan_id);
13912 #endif
13913 #ifdef RTE_LIBRTE_BNXT_PMD
13914 	if (ret == -ENOTSUP)
13915 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13916 			res->vlan_id);
13917 #endif
13918 
13919 	switch (ret) {
13920 	case 0:
13921 		break;
13922 	case -EINVAL:
13923 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13924 		break;
13925 	case -ENODEV:
13926 		printf("invalid port_id %d\n", res->port_id);
13927 		break;
13928 	case -ENOTSUP:
13929 		printf("function not implemented\n");
13930 		break;
13931 	default:
13932 		printf("programming error: (%s)\n", strerror(-ret));
13933 	}
13934 }
13935 
13936 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13937 	.f = cmd_set_vf_vlan_insert_parsed,
13938 	.data = NULL,
13939 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13940 	.tokens = {
13941 		(void *)&cmd_vf_vlan_insert_set,
13942 		(void *)&cmd_vf_vlan_insert_vf,
13943 		(void *)&cmd_vf_vlan_insert_vlan,
13944 		(void *)&cmd_vf_vlan_insert_insert,
13945 		(void *)&cmd_vf_vlan_insert_port_id,
13946 		(void *)&cmd_vf_vlan_insert_vf_id,
13947 		(void *)&cmd_vf_vlan_insert_vlan_id,
13948 		NULL,
13949 	},
13950 };
13951 
13952 /* tx loopback configuration */
13953 
13954 /* Common result structure for tx loopback */
13955 struct cmd_tx_loopback_result {
13956 	cmdline_fixed_string_t set;
13957 	cmdline_fixed_string_t tx;
13958 	cmdline_fixed_string_t loopback;
13959 	portid_t port_id;
13960 	cmdline_fixed_string_t on_off;
13961 };
13962 
13963 /* Common CLI fields for tx loopback enable disable */
13964 cmdline_parse_token_string_t cmd_tx_loopback_set =
13965 	TOKEN_STRING_INITIALIZER
13966 		(struct cmd_tx_loopback_result,
13967 		 set, "set");
13968 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13969 	TOKEN_STRING_INITIALIZER
13970 		(struct cmd_tx_loopback_result,
13971 		 tx, "tx");
13972 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13973 	TOKEN_STRING_INITIALIZER
13974 		(struct cmd_tx_loopback_result,
13975 		 loopback, "loopback");
13976 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13977 	TOKEN_NUM_INITIALIZER
13978 		(struct cmd_tx_loopback_result,
13979 		 port_id, UINT16);
13980 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13981 	TOKEN_STRING_INITIALIZER
13982 		(struct cmd_tx_loopback_result,
13983 		 on_off, "on#off");
13984 
13985 static void
13986 cmd_set_tx_loopback_parsed(
13987 	void *parsed_result,
13988 	__rte_unused struct cmdline *cl,
13989 	__rte_unused void *data)
13990 {
13991 	struct cmd_tx_loopback_result *res = parsed_result;
13992 	int ret = -ENOTSUP;
13993 
13994 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13995 
13996 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13997 		return;
13998 
13999 #ifdef RTE_LIBRTE_IXGBE_PMD
14000 	if (ret == -ENOTSUP)
14001 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14002 #endif
14003 #ifdef RTE_LIBRTE_I40E_PMD
14004 	if (ret == -ENOTSUP)
14005 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14006 #endif
14007 #ifdef RTE_LIBRTE_BNXT_PMD
14008 	if (ret == -ENOTSUP)
14009 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14010 #endif
14011 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
14012 	if (ret == -ENOTSUP)
14013 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14014 #endif
14015 
14016 	switch (ret) {
14017 	case 0:
14018 		break;
14019 	case -EINVAL:
14020 		printf("invalid is_on %d\n", is_on);
14021 		break;
14022 	case -ENODEV:
14023 		printf("invalid port_id %d\n", res->port_id);
14024 		break;
14025 	case -ENOTSUP:
14026 		printf("function not implemented\n");
14027 		break;
14028 	default:
14029 		printf("programming error: (%s)\n", strerror(-ret));
14030 	}
14031 }
14032 
14033 cmdline_parse_inst_t cmd_set_tx_loopback = {
14034 	.f = cmd_set_tx_loopback_parsed,
14035 	.data = NULL,
14036 	.help_str = "set tx loopback <port_id> on|off",
14037 	.tokens = {
14038 		(void *)&cmd_tx_loopback_set,
14039 		(void *)&cmd_tx_loopback_tx,
14040 		(void *)&cmd_tx_loopback_loopback,
14041 		(void *)&cmd_tx_loopback_port_id,
14042 		(void *)&cmd_tx_loopback_on_off,
14043 		NULL,
14044 	},
14045 };
14046 
14047 /* all queues drop enable configuration */
14048 
14049 /* Common result structure for all queues drop enable */
14050 struct cmd_all_queues_drop_en_result {
14051 	cmdline_fixed_string_t set;
14052 	cmdline_fixed_string_t all;
14053 	cmdline_fixed_string_t queues;
14054 	cmdline_fixed_string_t drop;
14055 	portid_t port_id;
14056 	cmdline_fixed_string_t on_off;
14057 };
14058 
14059 /* Common CLI fields for tx loopback enable disable */
14060 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14061 	TOKEN_STRING_INITIALIZER
14062 		(struct cmd_all_queues_drop_en_result,
14063 		 set, "set");
14064 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14065 	TOKEN_STRING_INITIALIZER
14066 		(struct cmd_all_queues_drop_en_result,
14067 		 all, "all");
14068 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14069 	TOKEN_STRING_INITIALIZER
14070 		(struct cmd_all_queues_drop_en_result,
14071 		 queues, "queues");
14072 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14073 	TOKEN_STRING_INITIALIZER
14074 		(struct cmd_all_queues_drop_en_result,
14075 		 drop, "drop");
14076 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14077 	TOKEN_NUM_INITIALIZER
14078 		(struct cmd_all_queues_drop_en_result,
14079 		 port_id, UINT16);
14080 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14081 	TOKEN_STRING_INITIALIZER
14082 		(struct cmd_all_queues_drop_en_result,
14083 		 on_off, "on#off");
14084 
14085 static void
14086 cmd_set_all_queues_drop_en_parsed(
14087 	void *parsed_result,
14088 	__rte_unused struct cmdline *cl,
14089 	__rte_unused void *data)
14090 {
14091 	struct cmd_all_queues_drop_en_result *res = parsed_result;
14092 	int ret = -ENOTSUP;
14093 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14094 
14095 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14096 		return;
14097 
14098 #ifdef RTE_LIBRTE_IXGBE_PMD
14099 	if (ret == -ENOTSUP)
14100 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14101 #endif
14102 #ifdef RTE_LIBRTE_BNXT_PMD
14103 	if (ret == -ENOTSUP)
14104 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14105 #endif
14106 	switch (ret) {
14107 	case 0:
14108 		break;
14109 	case -EINVAL:
14110 		printf("invalid is_on %d\n", is_on);
14111 		break;
14112 	case -ENODEV:
14113 		printf("invalid port_id %d\n", res->port_id);
14114 		break;
14115 	case -ENOTSUP:
14116 		printf("function not implemented\n");
14117 		break;
14118 	default:
14119 		printf("programming error: (%s)\n", strerror(-ret));
14120 	}
14121 }
14122 
14123 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14124 	.f = cmd_set_all_queues_drop_en_parsed,
14125 	.data = NULL,
14126 	.help_str = "set all queues drop <port_id> on|off",
14127 	.tokens = {
14128 		(void *)&cmd_all_queues_drop_en_set,
14129 		(void *)&cmd_all_queues_drop_en_all,
14130 		(void *)&cmd_all_queues_drop_en_queues,
14131 		(void *)&cmd_all_queues_drop_en_drop,
14132 		(void *)&cmd_all_queues_drop_en_port_id,
14133 		(void *)&cmd_all_queues_drop_en_on_off,
14134 		NULL,
14135 	},
14136 };
14137 
14138 /* vf split drop enable configuration */
14139 
14140 /* Common result structure for vf split drop enable */
14141 struct cmd_vf_split_drop_en_result {
14142 	cmdline_fixed_string_t set;
14143 	cmdline_fixed_string_t vf;
14144 	cmdline_fixed_string_t split;
14145 	cmdline_fixed_string_t drop;
14146 	portid_t port_id;
14147 	uint16_t vf_id;
14148 	cmdline_fixed_string_t on_off;
14149 };
14150 
14151 /* Common CLI fields for vf split drop enable disable */
14152 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14153 	TOKEN_STRING_INITIALIZER
14154 		(struct cmd_vf_split_drop_en_result,
14155 		 set, "set");
14156 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14157 	TOKEN_STRING_INITIALIZER
14158 		(struct cmd_vf_split_drop_en_result,
14159 		 vf, "vf");
14160 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14161 	TOKEN_STRING_INITIALIZER
14162 		(struct cmd_vf_split_drop_en_result,
14163 		 split, "split");
14164 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14165 	TOKEN_STRING_INITIALIZER
14166 		(struct cmd_vf_split_drop_en_result,
14167 		 drop, "drop");
14168 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14169 	TOKEN_NUM_INITIALIZER
14170 		(struct cmd_vf_split_drop_en_result,
14171 		 port_id, UINT16);
14172 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14173 	TOKEN_NUM_INITIALIZER
14174 		(struct cmd_vf_split_drop_en_result,
14175 		 vf_id, UINT16);
14176 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14177 	TOKEN_STRING_INITIALIZER
14178 		(struct cmd_vf_split_drop_en_result,
14179 		 on_off, "on#off");
14180 
14181 static void
14182 cmd_set_vf_split_drop_en_parsed(
14183 	void *parsed_result,
14184 	__rte_unused struct cmdline *cl,
14185 	__rte_unused void *data)
14186 {
14187 	struct cmd_vf_split_drop_en_result *res = parsed_result;
14188 	int ret = -ENOTSUP;
14189 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14190 
14191 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14192 		return;
14193 
14194 #ifdef RTE_LIBRTE_IXGBE_PMD
14195 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14196 			is_on);
14197 #endif
14198 	switch (ret) {
14199 	case 0:
14200 		break;
14201 	case -EINVAL:
14202 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14203 		break;
14204 	case -ENODEV:
14205 		printf("invalid port_id %d\n", res->port_id);
14206 		break;
14207 	case -ENOTSUP:
14208 		printf("not supported on port %d\n", res->port_id);
14209 		break;
14210 	default:
14211 		printf("programming error: (%s)\n", strerror(-ret));
14212 	}
14213 }
14214 
14215 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14216 	.f = cmd_set_vf_split_drop_en_parsed,
14217 	.data = NULL,
14218 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
14219 	.tokens = {
14220 		(void *)&cmd_vf_split_drop_en_set,
14221 		(void *)&cmd_vf_split_drop_en_vf,
14222 		(void *)&cmd_vf_split_drop_en_split,
14223 		(void *)&cmd_vf_split_drop_en_drop,
14224 		(void *)&cmd_vf_split_drop_en_port_id,
14225 		(void *)&cmd_vf_split_drop_en_vf_id,
14226 		(void *)&cmd_vf_split_drop_en_on_off,
14227 		NULL,
14228 	},
14229 };
14230 
14231 /* vf mac address configuration */
14232 
14233 /* Common result structure for vf mac address */
14234 struct cmd_set_vf_mac_addr_result {
14235 	cmdline_fixed_string_t set;
14236 	cmdline_fixed_string_t vf;
14237 	cmdline_fixed_string_t mac;
14238 	cmdline_fixed_string_t addr;
14239 	portid_t port_id;
14240 	uint16_t vf_id;
14241 	struct rte_ether_addr mac_addr;
14242 
14243 };
14244 
14245 /* Common CLI fields for vf split drop enable disable */
14246 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14247 	TOKEN_STRING_INITIALIZER
14248 		(struct cmd_set_vf_mac_addr_result,
14249 		 set, "set");
14250 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14251 	TOKEN_STRING_INITIALIZER
14252 		(struct cmd_set_vf_mac_addr_result,
14253 		 vf, "vf");
14254 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14255 	TOKEN_STRING_INITIALIZER
14256 		(struct cmd_set_vf_mac_addr_result,
14257 		 mac, "mac");
14258 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14259 	TOKEN_STRING_INITIALIZER
14260 		(struct cmd_set_vf_mac_addr_result,
14261 		 addr, "addr");
14262 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14263 	TOKEN_NUM_INITIALIZER
14264 		(struct cmd_set_vf_mac_addr_result,
14265 		 port_id, UINT16);
14266 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14267 	TOKEN_NUM_INITIALIZER
14268 		(struct cmd_set_vf_mac_addr_result,
14269 		 vf_id, UINT16);
14270 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14271 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14272 		 mac_addr);
14273 
14274 static void
14275 cmd_set_vf_mac_addr_parsed(
14276 	void *parsed_result,
14277 	__rte_unused struct cmdline *cl,
14278 	__rte_unused void *data)
14279 {
14280 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
14281 	int ret = -ENOTSUP;
14282 
14283 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14284 		return;
14285 
14286 #ifdef RTE_LIBRTE_IXGBE_PMD
14287 	if (ret == -ENOTSUP)
14288 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14289 				&res->mac_addr);
14290 #endif
14291 #ifdef RTE_LIBRTE_I40E_PMD
14292 	if (ret == -ENOTSUP)
14293 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14294 				&res->mac_addr);
14295 #endif
14296 #ifdef RTE_LIBRTE_BNXT_PMD
14297 	if (ret == -ENOTSUP)
14298 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14299 				&res->mac_addr);
14300 #endif
14301 
14302 	switch (ret) {
14303 	case 0:
14304 		break;
14305 	case -EINVAL:
14306 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14307 		break;
14308 	case -ENODEV:
14309 		printf("invalid port_id %d\n", res->port_id);
14310 		break;
14311 	case -ENOTSUP:
14312 		printf("function not implemented\n");
14313 		break;
14314 	default:
14315 		printf("programming error: (%s)\n", strerror(-ret));
14316 	}
14317 }
14318 
14319 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14320 	.f = cmd_set_vf_mac_addr_parsed,
14321 	.data = NULL,
14322 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14323 	.tokens = {
14324 		(void *)&cmd_set_vf_mac_addr_set,
14325 		(void *)&cmd_set_vf_mac_addr_vf,
14326 		(void *)&cmd_set_vf_mac_addr_mac,
14327 		(void *)&cmd_set_vf_mac_addr_addr,
14328 		(void *)&cmd_set_vf_mac_addr_port_id,
14329 		(void *)&cmd_set_vf_mac_addr_vf_id,
14330 		(void *)&cmd_set_vf_mac_addr_mac_addr,
14331 		NULL,
14332 	},
14333 };
14334 
14335 /* MACsec configuration */
14336 
14337 /* Common result structure for MACsec offload enable */
14338 struct cmd_macsec_offload_on_result {
14339 	cmdline_fixed_string_t set;
14340 	cmdline_fixed_string_t macsec;
14341 	cmdline_fixed_string_t offload;
14342 	portid_t port_id;
14343 	cmdline_fixed_string_t on;
14344 	cmdline_fixed_string_t encrypt;
14345 	cmdline_fixed_string_t en_on_off;
14346 	cmdline_fixed_string_t replay_protect;
14347 	cmdline_fixed_string_t rp_on_off;
14348 };
14349 
14350 /* Common CLI fields for MACsec offload disable */
14351 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14352 	TOKEN_STRING_INITIALIZER
14353 		(struct cmd_macsec_offload_on_result,
14354 		 set, "set");
14355 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14356 	TOKEN_STRING_INITIALIZER
14357 		(struct cmd_macsec_offload_on_result,
14358 		 macsec, "macsec");
14359 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14360 	TOKEN_STRING_INITIALIZER
14361 		(struct cmd_macsec_offload_on_result,
14362 		 offload, "offload");
14363 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14364 	TOKEN_NUM_INITIALIZER
14365 		(struct cmd_macsec_offload_on_result,
14366 		 port_id, UINT16);
14367 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14368 	TOKEN_STRING_INITIALIZER
14369 		(struct cmd_macsec_offload_on_result,
14370 		 on, "on");
14371 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14372 	TOKEN_STRING_INITIALIZER
14373 		(struct cmd_macsec_offload_on_result,
14374 		 encrypt, "encrypt");
14375 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14376 	TOKEN_STRING_INITIALIZER
14377 		(struct cmd_macsec_offload_on_result,
14378 		 en_on_off, "on#off");
14379 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14380 	TOKEN_STRING_INITIALIZER
14381 		(struct cmd_macsec_offload_on_result,
14382 		 replay_protect, "replay-protect");
14383 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14384 	TOKEN_STRING_INITIALIZER
14385 		(struct cmd_macsec_offload_on_result,
14386 		 rp_on_off, "on#off");
14387 
14388 static void
14389 cmd_set_macsec_offload_on_parsed(
14390 	void *parsed_result,
14391 	__rte_unused struct cmdline *cl,
14392 	__rte_unused void *data)
14393 {
14394 	struct cmd_macsec_offload_on_result *res = parsed_result;
14395 	int ret = -ENOTSUP;
14396 	portid_t port_id = res->port_id;
14397 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14398 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14399 	struct rte_eth_dev_info dev_info;
14400 
14401 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14402 		return;
14403 	if (!port_is_stopped(port_id)) {
14404 		printf("Please stop port %d first\n", port_id);
14405 		return;
14406 	}
14407 
14408 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
14409 	if (ret != 0)
14410 		return;
14411 
14412 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14413 #ifdef RTE_LIBRTE_IXGBE_PMD
14414 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14415 #endif
14416 	}
14417 	RTE_SET_USED(en);
14418 	RTE_SET_USED(rp);
14419 
14420 	switch (ret) {
14421 	case 0:
14422 		ports[port_id].dev_conf.txmode.offloads |=
14423 						DEV_TX_OFFLOAD_MACSEC_INSERT;
14424 		cmd_reconfig_device_queue(port_id, 1, 1);
14425 		break;
14426 	case -ENODEV:
14427 		printf("invalid port_id %d\n", port_id);
14428 		break;
14429 	case -ENOTSUP:
14430 		printf("not supported on port %d\n", port_id);
14431 		break;
14432 	default:
14433 		printf("programming error: (%s)\n", strerror(-ret));
14434 	}
14435 }
14436 
14437 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14438 	.f = cmd_set_macsec_offload_on_parsed,
14439 	.data = NULL,
14440 	.help_str = "set macsec offload <port_id> on "
14441 		"encrypt on|off replay-protect on|off",
14442 	.tokens = {
14443 		(void *)&cmd_macsec_offload_on_set,
14444 		(void *)&cmd_macsec_offload_on_macsec,
14445 		(void *)&cmd_macsec_offload_on_offload,
14446 		(void *)&cmd_macsec_offload_on_port_id,
14447 		(void *)&cmd_macsec_offload_on_on,
14448 		(void *)&cmd_macsec_offload_on_encrypt,
14449 		(void *)&cmd_macsec_offload_on_en_on_off,
14450 		(void *)&cmd_macsec_offload_on_replay_protect,
14451 		(void *)&cmd_macsec_offload_on_rp_on_off,
14452 		NULL,
14453 	},
14454 };
14455 
14456 /* Common result structure for MACsec offload disable */
14457 struct cmd_macsec_offload_off_result {
14458 	cmdline_fixed_string_t set;
14459 	cmdline_fixed_string_t macsec;
14460 	cmdline_fixed_string_t offload;
14461 	portid_t port_id;
14462 	cmdline_fixed_string_t off;
14463 };
14464 
14465 /* Common CLI fields for MACsec offload disable */
14466 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14467 	TOKEN_STRING_INITIALIZER
14468 		(struct cmd_macsec_offload_off_result,
14469 		 set, "set");
14470 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14471 	TOKEN_STRING_INITIALIZER
14472 		(struct cmd_macsec_offload_off_result,
14473 		 macsec, "macsec");
14474 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14475 	TOKEN_STRING_INITIALIZER
14476 		(struct cmd_macsec_offload_off_result,
14477 		 offload, "offload");
14478 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14479 	TOKEN_NUM_INITIALIZER
14480 		(struct cmd_macsec_offload_off_result,
14481 		 port_id, UINT16);
14482 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14483 	TOKEN_STRING_INITIALIZER
14484 		(struct cmd_macsec_offload_off_result,
14485 		 off, "off");
14486 
14487 static void
14488 cmd_set_macsec_offload_off_parsed(
14489 	void *parsed_result,
14490 	__rte_unused struct cmdline *cl,
14491 	__rte_unused void *data)
14492 {
14493 	struct cmd_macsec_offload_off_result *res = parsed_result;
14494 	int ret = -ENOTSUP;
14495 	struct rte_eth_dev_info dev_info;
14496 	portid_t port_id = res->port_id;
14497 
14498 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14499 		return;
14500 	if (!port_is_stopped(port_id)) {
14501 		printf("Please stop port %d first\n", port_id);
14502 		return;
14503 	}
14504 
14505 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
14506 	if (ret != 0)
14507 		return;
14508 
14509 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14510 #ifdef RTE_LIBRTE_IXGBE_PMD
14511 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
14512 #endif
14513 	}
14514 	switch (ret) {
14515 	case 0:
14516 		ports[port_id].dev_conf.txmode.offloads &=
14517 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
14518 		cmd_reconfig_device_queue(port_id, 1, 1);
14519 		break;
14520 	case -ENODEV:
14521 		printf("invalid port_id %d\n", port_id);
14522 		break;
14523 	case -ENOTSUP:
14524 		printf("not supported on port %d\n", port_id);
14525 		break;
14526 	default:
14527 		printf("programming error: (%s)\n", strerror(-ret));
14528 	}
14529 }
14530 
14531 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14532 	.f = cmd_set_macsec_offload_off_parsed,
14533 	.data = NULL,
14534 	.help_str = "set macsec offload <port_id> off",
14535 	.tokens = {
14536 		(void *)&cmd_macsec_offload_off_set,
14537 		(void *)&cmd_macsec_offload_off_macsec,
14538 		(void *)&cmd_macsec_offload_off_offload,
14539 		(void *)&cmd_macsec_offload_off_port_id,
14540 		(void *)&cmd_macsec_offload_off_off,
14541 		NULL,
14542 	},
14543 };
14544 
14545 /* Common result structure for MACsec secure connection configure */
14546 struct cmd_macsec_sc_result {
14547 	cmdline_fixed_string_t set;
14548 	cmdline_fixed_string_t macsec;
14549 	cmdline_fixed_string_t sc;
14550 	cmdline_fixed_string_t tx_rx;
14551 	portid_t port_id;
14552 	struct rte_ether_addr mac;
14553 	uint16_t pi;
14554 };
14555 
14556 /* Common CLI fields for MACsec secure connection configure */
14557 cmdline_parse_token_string_t cmd_macsec_sc_set =
14558 	TOKEN_STRING_INITIALIZER
14559 		(struct cmd_macsec_sc_result,
14560 		 set, "set");
14561 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14562 	TOKEN_STRING_INITIALIZER
14563 		(struct cmd_macsec_sc_result,
14564 		 macsec, "macsec");
14565 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14566 	TOKEN_STRING_INITIALIZER
14567 		(struct cmd_macsec_sc_result,
14568 		 sc, "sc");
14569 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14570 	TOKEN_STRING_INITIALIZER
14571 		(struct cmd_macsec_sc_result,
14572 		 tx_rx, "tx#rx");
14573 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14574 	TOKEN_NUM_INITIALIZER
14575 		(struct cmd_macsec_sc_result,
14576 		 port_id, UINT16);
14577 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14578 	TOKEN_ETHERADDR_INITIALIZER
14579 		(struct cmd_macsec_sc_result,
14580 		 mac);
14581 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14582 	TOKEN_NUM_INITIALIZER
14583 		(struct cmd_macsec_sc_result,
14584 		 pi, UINT16);
14585 
14586 static void
14587 cmd_set_macsec_sc_parsed(
14588 	void *parsed_result,
14589 	__rte_unused struct cmdline *cl,
14590 	__rte_unused void *data)
14591 {
14592 	struct cmd_macsec_sc_result *res = parsed_result;
14593 	int ret = -ENOTSUP;
14594 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14595 
14596 #ifdef RTE_LIBRTE_IXGBE_PMD
14597 	ret = is_tx ?
14598 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14599 				res->mac.addr_bytes) :
14600 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14601 				res->mac.addr_bytes, res->pi);
14602 #endif
14603 	RTE_SET_USED(is_tx);
14604 
14605 	switch (ret) {
14606 	case 0:
14607 		break;
14608 	case -ENODEV:
14609 		printf("invalid port_id %d\n", res->port_id);
14610 		break;
14611 	case -ENOTSUP:
14612 		printf("not supported on port %d\n", res->port_id);
14613 		break;
14614 	default:
14615 		printf("programming error: (%s)\n", strerror(-ret));
14616 	}
14617 }
14618 
14619 cmdline_parse_inst_t cmd_set_macsec_sc = {
14620 	.f = cmd_set_macsec_sc_parsed,
14621 	.data = NULL,
14622 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14623 	.tokens = {
14624 		(void *)&cmd_macsec_sc_set,
14625 		(void *)&cmd_macsec_sc_macsec,
14626 		(void *)&cmd_macsec_sc_sc,
14627 		(void *)&cmd_macsec_sc_tx_rx,
14628 		(void *)&cmd_macsec_sc_port_id,
14629 		(void *)&cmd_macsec_sc_mac,
14630 		(void *)&cmd_macsec_sc_pi,
14631 		NULL,
14632 	},
14633 };
14634 
14635 /* Common result structure for MACsec secure connection configure */
14636 struct cmd_macsec_sa_result {
14637 	cmdline_fixed_string_t set;
14638 	cmdline_fixed_string_t macsec;
14639 	cmdline_fixed_string_t sa;
14640 	cmdline_fixed_string_t tx_rx;
14641 	portid_t port_id;
14642 	uint8_t idx;
14643 	uint8_t an;
14644 	uint32_t pn;
14645 	cmdline_fixed_string_t key;
14646 };
14647 
14648 /* Common CLI fields for MACsec secure connection configure */
14649 cmdline_parse_token_string_t cmd_macsec_sa_set =
14650 	TOKEN_STRING_INITIALIZER
14651 		(struct cmd_macsec_sa_result,
14652 		 set, "set");
14653 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14654 	TOKEN_STRING_INITIALIZER
14655 		(struct cmd_macsec_sa_result,
14656 		 macsec, "macsec");
14657 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14658 	TOKEN_STRING_INITIALIZER
14659 		(struct cmd_macsec_sa_result,
14660 		 sa, "sa");
14661 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14662 	TOKEN_STRING_INITIALIZER
14663 		(struct cmd_macsec_sa_result,
14664 		 tx_rx, "tx#rx");
14665 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14666 	TOKEN_NUM_INITIALIZER
14667 		(struct cmd_macsec_sa_result,
14668 		 port_id, UINT16);
14669 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14670 	TOKEN_NUM_INITIALIZER
14671 		(struct cmd_macsec_sa_result,
14672 		 idx, UINT8);
14673 cmdline_parse_token_num_t cmd_macsec_sa_an =
14674 	TOKEN_NUM_INITIALIZER
14675 		(struct cmd_macsec_sa_result,
14676 		 an, UINT8);
14677 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14678 	TOKEN_NUM_INITIALIZER
14679 		(struct cmd_macsec_sa_result,
14680 		 pn, UINT32);
14681 cmdline_parse_token_string_t cmd_macsec_sa_key =
14682 	TOKEN_STRING_INITIALIZER
14683 		(struct cmd_macsec_sa_result,
14684 		 key, NULL);
14685 
14686 static void
14687 cmd_set_macsec_sa_parsed(
14688 	void *parsed_result,
14689 	__rte_unused struct cmdline *cl,
14690 	__rte_unused void *data)
14691 {
14692 	struct cmd_macsec_sa_result *res = parsed_result;
14693 	int ret = -ENOTSUP;
14694 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14695 	uint8_t key[16] = { 0 };
14696 	uint8_t xdgt0;
14697 	uint8_t xdgt1;
14698 	int key_len;
14699 	int i;
14700 
14701 	key_len = strlen(res->key) / 2;
14702 	if (key_len > 16)
14703 		key_len = 16;
14704 
14705 	for (i = 0; i < key_len; i++) {
14706 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14707 		if (xdgt0 == 0xFF)
14708 			return;
14709 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14710 		if (xdgt1 == 0xFF)
14711 			return;
14712 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14713 	}
14714 
14715 #ifdef RTE_LIBRTE_IXGBE_PMD
14716 	ret = is_tx ?
14717 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14718 			res->idx, res->an, res->pn, key) :
14719 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14720 			res->idx, res->an, res->pn, key);
14721 #endif
14722 	RTE_SET_USED(is_tx);
14723 	RTE_SET_USED(key);
14724 
14725 	switch (ret) {
14726 	case 0:
14727 		break;
14728 	case -EINVAL:
14729 		printf("invalid idx %d or an %d\n", res->idx, res->an);
14730 		break;
14731 	case -ENODEV:
14732 		printf("invalid port_id %d\n", res->port_id);
14733 		break;
14734 	case -ENOTSUP:
14735 		printf("not supported on port %d\n", res->port_id);
14736 		break;
14737 	default:
14738 		printf("programming error: (%s)\n", strerror(-ret));
14739 	}
14740 }
14741 
14742 cmdline_parse_inst_t cmd_set_macsec_sa = {
14743 	.f = cmd_set_macsec_sa_parsed,
14744 	.data = NULL,
14745 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14746 	.tokens = {
14747 		(void *)&cmd_macsec_sa_set,
14748 		(void *)&cmd_macsec_sa_macsec,
14749 		(void *)&cmd_macsec_sa_sa,
14750 		(void *)&cmd_macsec_sa_tx_rx,
14751 		(void *)&cmd_macsec_sa_port_id,
14752 		(void *)&cmd_macsec_sa_idx,
14753 		(void *)&cmd_macsec_sa_an,
14754 		(void *)&cmd_macsec_sa_pn,
14755 		(void *)&cmd_macsec_sa_key,
14756 		NULL,
14757 	},
14758 };
14759 
14760 /* VF unicast promiscuous mode configuration */
14761 
14762 /* Common result structure for VF unicast promiscuous mode */
14763 struct cmd_vf_promisc_result {
14764 	cmdline_fixed_string_t set;
14765 	cmdline_fixed_string_t vf;
14766 	cmdline_fixed_string_t promisc;
14767 	portid_t port_id;
14768 	uint32_t vf_id;
14769 	cmdline_fixed_string_t on_off;
14770 };
14771 
14772 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14773 cmdline_parse_token_string_t cmd_vf_promisc_set =
14774 	TOKEN_STRING_INITIALIZER
14775 		(struct cmd_vf_promisc_result,
14776 		 set, "set");
14777 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14778 	TOKEN_STRING_INITIALIZER
14779 		(struct cmd_vf_promisc_result,
14780 		 vf, "vf");
14781 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14782 	TOKEN_STRING_INITIALIZER
14783 		(struct cmd_vf_promisc_result,
14784 		 promisc, "promisc");
14785 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14786 	TOKEN_NUM_INITIALIZER
14787 		(struct cmd_vf_promisc_result,
14788 		 port_id, UINT16);
14789 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14790 	TOKEN_NUM_INITIALIZER
14791 		(struct cmd_vf_promisc_result,
14792 		 vf_id, UINT32);
14793 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14794 	TOKEN_STRING_INITIALIZER
14795 		(struct cmd_vf_promisc_result,
14796 		 on_off, "on#off");
14797 
14798 static void
14799 cmd_set_vf_promisc_parsed(
14800 	void *parsed_result,
14801 	__rte_unused struct cmdline *cl,
14802 	__rte_unused void *data)
14803 {
14804 	struct cmd_vf_promisc_result *res = parsed_result;
14805 	int ret = -ENOTSUP;
14806 
14807 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14808 
14809 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14810 		return;
14811 
14812 #ifdef RTE_LIBRTE_I40E_PMD
14813 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14814 						  res->vf_id, is_on);
14815 #endif
14816 
14817 	switch (ret) {
14818 	case 0:
14819 		break;
14820 	case -EINVAL:
14821 		printf("invalid vf_id %d\n", res->vf_id);
14822 		break;
14823 	case -ENODEV:
14824 		printf("invalid port_id %d\n", res->port_id);
14825 		break;
14826 	case -ENOTSUP:
14827 		printf("function not implemented\n");
14828 		break;
14829 	default:
14830 		printf("programming error: (%s)\n", strerror(-ret));
14831 	}
14832 }
14833 
14834 cmdline_parse_inst_t cmd_set_vf_promisc = {
14835 	.f = cmd_set_vf_promisc_parsed,
14836 	.data = NULL,
14837 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
14838 		"Set unicast promiscuous mode for a VF from the PF",
14839 	.tokens = {
14840 		(void *)&cmd_vf_promisc_set,
14841 		(void *)&cmd_vf_promisc_vf,
14842 		(void *)&cmd_vf_promisc_promisc,
14843 		(void *)&cmd_vf_promisc_port_id,
14844 		(void *)&cmd_vf_promisc_vf_id,
14845 		(void *)&cmd_vf_promisc_on_off,
14846 		NULL,
14847 	},
14848 };
14849 
14850 /* VF multicast promiscuous mode configuration */
14851 
14852 /* Common result structure for VF multicast promiscuous mode */
14853 struct cmd_vf_allmulti_result {
14854 	cmdline_fixed_string_t set;
14855 	cmdline_fixed_string_t vf;
14856 	cmdline_fixed_string_t allmulti;
14857 	portid_t port_id;
14858 	uint32_t vf_id;
14859 	cmdline_fixed_string_t on_off;
14860 };
14861 
14862 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14863 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14864 	TOKEN_STRING_INITIALIZER
14865 		(struct cmd_vf_allmulti_result,
14866 		 set, "set");
14867 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14868 	TOKEN_STRING_INITIALIZER
14869 		(struct cmd_vf_allmulti_result,
14870 		 vf, "vf");
14871 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14872 	TOKEN_STRING_INITIALIZER
14873 		(struct cmd_vf_allmulti_result,
14874 		 allmulti, "allmulti");
14875 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14876 	TOKEN_NUM_INITIALIZER
14877 		(struct cmd_vf_allmulti_result,
14878 		 port_id, UINT16);
14879 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14880 	TOKEN_NUM_INITIALIZER
14881 		(struct cmd_vf_allmulti_result,
14882 		 vf_id, UINT32);
14883 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14884 	TOKEN_STRING_INITIALIZER
14885 		(struct cmd_vf_allmulti_result,
14886 		 on_off, "on#off");
14887 
14888 static void
14889 cmd_set_vf_allmulti_parsed(
14890 	void *parsed_result,
14891 	__rte_unused struct cmdline *cl,
14892 	__rte_unused void *data)
14893 {
14894 	struct cmd_vf_allmulti_result *res = parsed_result;
14895 	int ret = -ENOTSUP;
14896 
14897 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14898 
14899 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14900 		return;
14901 
14902 #ifdef RTE_LIBRTE_I40E_PMD
14903 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14904 						    res->vf_id, is_on);
14905 #endif
14906 
14907 	switch (ret) {
14908 	case 0:
14909 		break;
14910 	case -EINVAL:
14911 		printf("invalid vf_id %d\n", res->vf_id);
14912 		break;
14913 	case -ENODEV:
14914 		printf("invalid port_id %d\n", res->port_id);
14915 		break;
14916 	case -ENOTSUP:
14917 		printf("function not implemented\n");
14918 		break;
14919 	default:
14920 		printf("programming error: (%s)\n", strerror(-ret));
14921 	}
14922 }
14923 
14924 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14925 	.f = cmd_set_vf_allmulti_parsed,
14926 	.data = NULL,
14927 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14928 		"Set multicast promiscuous mode for a VF from the PF",
14929 	.tokens = {
14930 		(void *)&cmd_vf_allmulti_set,
14931 		(void *)&cmd_vf_allmulti_vf,
14932 		(void *)&cmd_vf_allmulti_allmulti,
14933 		(void *)&cmd_vf_allmulti_port_id,
14934 		(void *)&cmd_vf_allmulti_vf_id,
14935 		(void *)&cmd_vf_allmulti_on_off,
14936 		NULL,
14937 	},
14938 };
14939 
14940 /* vf broadcast mode configuration */
14941 
14942 /* Common result structure for vf broadcast */
14943 struct cmd_set_vf_broadcast_result {
14944 	cmdline_fixed_string_t set;
14945 	cmdline_fixed_string_t vf;
14946 	cmdline_fixed_string_t broadcast;
14947 	portid_t port_id;
14948 	uint16_t vf_id;
14949 	cmdline_fixed_string_t on_off;
14950 };
14951 
14952 /* Common CLI fields for vf broadcast enable disable */
14953 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14954 	TOKEN_STRING_INITIALIZER
14955 		(struct cmd_set_vf_broadcast_result,
14956 		 set, "set");
14957 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14958 	TOKEN_STRING_INITIALIZER
14959 		(struct cmd_set_vf_broadcast_result,
14960 		 vf, "vf");
14961 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14962 	TOKEN_STRING_INITIALIZER
14963 		(struct cmd_set_vf_broadcast_result,
14964 		 broadcast, "broadcast");
14965 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14966 	TOKEN_NUM_INITIALIZER
14967 		(struct cmd_set_vf_broadcast_result,
14968 		 port_id, UINT16);
14969 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14970 	TOKEN_NUM_INITIALIZER
14971 		(struct cmd_set_vf_broadcast_result,
14972 		 vf_id, UINT16);
14973 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14974 	TOKEN_STRING_INITIALIZER
14975 		(struct cmd_set_vf_broadcast_result,
14976 		 on_off, "on#off");
14977 
14978 static void
14979 cmd_set_vf_broadcast_parsed(
14980 	void *parsed_result,
14981 	__rte_unused struct cmdline *cl,
14982 	__rte_unused void *data)
14983 {
14984 	struct cmd_set_vf_broadcast_result *res = parsed_result;
14985 	int ret = -ENOTSUP;
14986 
14987 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14988 
14989 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14990 		return;
14991 
14992 #ifdef RTE_LIBRTE_I40E_PMD
14993 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14994 					    res->vf_id, is_on);
14995 #endif
14996 
14997 	switch (ret) {
14998 	case 0:
14999 		break;
15000 	case -EINVAL:
15001 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15002 		break;
15003 	case -ENODEV:
15004 		printf("invalid port_id %d\n", res->port_id);
15005 		break;
15006 	case -ENOTSUP:
15007 		printf("function not implemented\n");
15008 		break;
15009 	default:
15010 		printf("programming error: (%s)\n", strerror(-ret));
15011 	}
15012 }
15013 
15014 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15015 	.f = cmd_set_vf_broadcast_parsed,
15016 	.data = NULL,
15017 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
15018 	.tokens = {
15019 		(void *)&cmd_set_vf_broadcast_set,
15020 		(void *)&cmd_set_vf_broadcast_vf,
15021 		(void *)&cmd_set_vf_broadcast_broadcast,
15022 		(void *)&cmd_set_vf_broadcast_port_id,
15023 		(void *)&cmd_set_vf_broadcast_vf_id,
15024 		(void *)&cmd_set_vf_broadcast_on_off,
15025 		NULL,
15026 	},
15027 };
15028 
15029 /* vf vlan tag configuration */
15030 
15031 /* Common result structure for vf vlan tag */
15032 struct cmd_set_vf_vlan_tag_result {
15033 	cmdline_fixed_string_t set;
15034 	cmdline_fixed_string_t vf;
15035 	cmdline_fixed_string_t vlan;
15036 	cmdline_fixed_string_t tag;
15037 	portid_t port_id;
15038 	uint16_t vf_id;
15039 	cmdline_fixed_string_t on_off;
15040 };
15041 
15042 /* Common CLI fields for vf vlan tag enable disable */
15043 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15044 	TOKEN_STRING_INITIALIZER
15045 		(struct cmd_set_vf_vlan_tag_result,
15046 		 set, "set");
15047 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15048 	TOKEN_STRING_INITIALIZER
15049 		(struct cmd_set_vf_vlan_tag_result,
15050 		 vf, "vf");
15051 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15052 	TOKEN_STRING_INITIALIZER
15053 		(struct cmd_set_vf_vlan_tag_result,
15054 		 vlan, "vlan");
15055 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15056 	TOKEN_STRING_INITIALIZER
15057 		(struct cmd_set_vf_vlan_tag_result,
15058 		 tag, "tag");
15059 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15060 	TOKEN_NUM_INITIALIZER
15061 		(struct cmd_set_vf_vlan_tag_result,
15062 		 port_id, UINT16);
15063 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15064 	TOKEN_NUM_INITIALIZER
15065 		(struct cmd_set_vf_vlan_tag_result,
15066 		 vf_id, UINT16);
15067 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15068 	TOKEN_STRING_INITIALIZER
15069 		(struct cmd_set_vf_vlan_tag_result,
15070 		 on_off, "on#off");
15071 
15072 static void
15073 cmd_set_vf_vlan_tag_parsed(
15074 	void *parsed_result,
15075 	__rte_unused struct cmdline *cl,
15076 	__rte_unused void *data)
15077 {
15078 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15079 	int ret = -ENOTSUP;
15080 
15081 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15082 
15083 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15084 		return;
15085 
15086 #ifdef RTE_LIBRTE_I40E_PMD
15087 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15088 					   res->vf_id, is_on);
15089 #endif
15090 
15091 	switch (ret) {
15092 	case 0:
15093 		break;
15094 	case -EINVAL:
15095 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15096 		break;
15097 	case -ENODEV:
15098 		printf("invalid port_id %d\n", res->port_id);
15099 		break;
15100 	case -ENOTSUP:
15101 		printf("function not implemented\n");
15102 		break;
15103 	default:
15104 		printf("programming error: (%s)\n", strerror(-ret));
15105 	}
15106 }
15107 
15108 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15109 	.f = cmd_set_vf_vlan_tag_parsed,
15110 	.data = NULL,
15111 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15112 	.tokens = {
15113 		(void *)&cmd_set_vf_vlan_tag_set,
15114 		(void *)&cmd_set_vf_vlan_tag_vf,
15115 		(void *)&cmd_set_vf_vlan_tag_vlan,
15116 		(void *)&cmd_set_vf_vlan_tag_tag,
15117 		(void *)&cmd_set_vf_vlan_tag_port_id,
15118 		(void *)&cmd_set_vf_vlan_tag_vf_id,
15119 		(void *)&cmd_set_vf_vlan_tag_on_off,
15120 		NULL,
15121 	},
15122 };
15123 
15124 /* Common definition of VF and TC TX bandwidth configuration */
15125 struct cmd_vf_tc_bw_result {
15126 	cmdline_fixed_string_t set;
15127 	cmdline_fixed_string_t vf;
15128 	cmdline_fixed_string_t tc;
15129 	cmdline_fixed_string_t tx;
15130 	cmdline_fixed_string_t min_bw;
15131 	cmdline_fixed_string_t max_bw;
15132 	cmdline_fixed_string_t strict_link_prio;
15133 	portid_t port_id;
15134 	uint16_t vf_id;
15135 	uint8_t tc_no;
15136 	uint32_t bw;
15137 	cmdline_fixed_string_t bw_list;
15138 	uint8_t tc_map;
15139 };
15140 
15141 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15142 	TOKEN_STRING_INITIALIZER
15143 		(struct cmd_vf_tc_bw_result,
15144 		 set, "set");
15145 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15146 	TOKEN_STRING_INITIALIZER
15147 		(struct cmd_vf_tc_bw_result,
15148 		 vf, "vf");
15149 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15150 	TOKEN_STRING_INITIALIZER
15151 		(struct cmd_vf_tc_bw_result,
15152 		 tc, "tc");
15153 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15154 	TOKEN_STRING_INITIALIZER
15155 		(struct cmd_vf_tc_bw_result,
15156 		 tx, "tx");
15157 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15158 	TOKEN_STRING_INITIALIZER
15159 		(struct cmd_vf_tc_bw_result,
15160 		 strict_link_prio, "strict-link-priority");
15161 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15162 	TOKEN_STRING_INITIALIZER
15163 		(struct cmd_vf_tc_bw_result,
15164 		 min_bw, "min-bandwidth");
15165 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15166 	TOKEN_STRING_INITIALIZER
15167 		(struct cmd_vf_tc_bw_result,
15168 		 max_bw, "max-bandwidth");
15169 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15170 	TOKEN_NUM_INITIALIZER
15171 		(struct cmd_vf_tc_bw_result,
15172 		 port_id, UINT16);
15173 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15174 	TOKEN_NUM_INITIALIZER
15175 		(struct cmd_vf_tc_bw_result,
15176 		 vf_id, UINT16);
15177 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15178 	TOKEN_NUM_INITIALIZER
15179 		(struct cmd_vf_tc_bw_result,
15180 		 tc_no, UINT8);
15181 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15182 	TOKEN_NUM_INITIALIZER
15183 		(struct cmd_vf_tc_bw_result,
15184 		 bw, UINT32);
15185 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15186 	TOKEN_STRING_INITIALIZER
15187 		(struct cmd_vf_tc_bw_result,
15188 		 bw_list, NULL);
15189 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15190 	TOKEN_NUM_INITIALIZER
15191 		(struct cmd_vf_tc_bw_result,
15192 		 tc_map, UINT8);
15193 
15194 /* VF max bandwidth setting */
15195 static void
15196 cmd_vf_max_bw_parsed(
15197 	void *parsed_result,
15198 	__rte_unused struct cmdline *cl,
15199 	__rte_unused void *data)
15200 {
15201 	struct cmd_vf_tc_bw_result *res = parsed_result;
15202 	int ret = -ENOTSUP;
15203 
15204 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15205 		return;
15206 
15207 #ifdef RTE_LIBRTE_I40E_PMD
15208 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15209 					 res->vf_id, res->bw);
15210 #endif
15211 
15212 	switch (ret) {
15213 	case 0:
15214 		break;
15215 	case -EINVAL:
15216 		printf("invalid vf_id %d or bandwidth %d\n",
15217 		       res->vf_id, res->bw);
15218 		break;
15219 	case -ENODEV:
15220 		printf("invalid port_id %d\n", res->port_id);
15221 		break;
15222 	case -ENOTSUP:
15223 		printf("function not implemented\n");
15224 		break;
15225 	default:
15226 		printf("programming error: (%s)\n", strerror(-ret));
15227 	}
15228 }
15229 
15230 cmdline_parse_inst_t cmd_vf_max_bw = {
15231 	.f = cmd_vf_max_bw_parsed,
15232 	.data = NULL,
15233 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15234 	.tokens = {
15235 		(void *)&cmd_vf_tc_bw_set,
15236 		(void *)&cmd_vf_tc_bw_vf,
15237 		(void *)&cmd_vf_tc_bw_tx,
15238 		(void *)&cmd_vf_tc_bw_max_bw,
15239 		(void *)&cmd_vf_tc_bw_port_id,
15240 		(void *)&cmd_vf_tc_bw_vf_id,
15241 		(void *)&cmd_vf_tc_bw_bw,
15242 		NULL,
15243 	},
15244 };
15245 
15246 static int
15247 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15248 			   uint8_t *tc_num,
15249 			   char *str)
15250 {
15251 	uint32_t size;
15252 	const char *p, *p0 = str;
15253 	char s[256];
15254 	char *end;
15255 	char *str_fld[16];
15256 	uint16_t i;
15257 	int ret;
15258 
15259 	p = strchr(p0, '(');
15260 	if (p == NULL) {
15261 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15262 		return -1;
15263 	}
15264 	p++;
15265 	p0 = strchr(p, ')');
15266 	if (p0 == NULL) {
15267 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15268 		return -1;
15269 	}
15270 	size = p0 - p;
15271 	if (size >= sizeof(s)) {
15272 		printf("The string size exceeds the internal buffer size\n");
15273 		return -1;
15274 	}
15275 	snprintf(s, sizeof(s), "%.*s", size, p);
15276 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15277 	if (ret <= 0) {
15278 		printf("Failed to get the bandwidth list. ");
15279 		return -1;
15280 	}
15281 	*tc_num = ret;
15282 	for (i = 0; i < ret; i++)
15283 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15284 
15285 	return 0;
15286 }
15287 
15288 /* TC min bandwidth setting */
15289 static void
15290 cmd_vf_tc_min_bw_parsed(
15291 	void *parsed_result,
15292 	__rte_unused struct cmdline *cl,
15293 	__rte_unused void *data)
15294 {
15295 	struct cmd_vf_tc_bw_result *res = parsed_result;
15296 	uint8_t tc_num;
15297 	uint8_t bw[16];
15298 	int ret = -ENOTSUP;
15299 
15300 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15301 		return;
15302 
15303 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15304 	if (ret)
15305 		return;
15306 
15307 #ifdef RTE_LIBRTE_I40E_PMD
15308 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15309 					      tc_num, bw);
15310 #endif
15311 
15312 	switch (ret) {
15313 	case 0:
15314 		break;
15315 	case -EINVAL:
15316 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15317 		break;
15318 	case -ENODEV:
15319 		printf("invalid port_id %d\n", res->port_id);
15320 		break;
15321 	case -ENOTSUP:
15322 		printf("function not implemented\n");
15323 		break;
15324 	default:
15325 		printf("programming error: (%s)\n", strerror(-ret));
15326 	}
15327 }
15328 
15329 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15330 	.f = cmd_vf_tc_min_bw_parsed,
15331 	.data = NULL,
15332 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15333 		    " <bw1, bw2, ...>",
15334 	.tokens = {
15335 		(void *)&cmd_vf_tc_bw_set,
15336 		(void *)&cmd_vf_tc_bw_vf,
15337 		(void *)&cmd_vf_tc_bw_tc,
15338 		(void *)&cmd_vf_tc_bw_tx,
15339 		(void *)&cmd_vf_tc_bw_min_bw,
15340 		(void *)&cmd_vf_tc_bw_port_id,
15341 		(void *)&cmd_vf_tc_bw_vf_id,
15342 		(void *)&cmd_vf_tc_bw_bw_list,
15343 		NULL,
15344 	},
15345 };
15346 
15347 static void
15348 cmd_tc_min_bw_parsed(
15349 	void *parsed_result,
15350 	__rte_unused struct cmdline *cl,
15351 	__rte_unused void *data)
15352 {
15353 	struct cmd_vf_tc_bw_result *res = parsed_result;
15354 	struct rte_port *port;
15355 	uint8_t tc_num;
15356 	uint8_t bw[16];
15357 	int ret = -ENOTSUP;
15358 
15359 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15360 		return;
15361 
15362 	port = &ports[res->port_id];
15363 	/** Check if the port is not started **/
15364 	if (port->port_status != RTE_PORT_STOPPED) {
15365 		printf("Please stop port %d first\n", res->port_id);
15366 		return;
15367 	}
15368 
15369 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15370 	if (ret)
15371 		return;
15372 
15373 #ifdef RTE_LIBRTE_IXGBE_PMD
15374 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15375 #endif
15376 
15377 	switch (ret) {
15378 	case 0:
15379 		break;
15380 	case -EINVAL:
15381 		printf("invalid bandwidth\n");
15382 		break;
15383 	case -ENODEV:
15384 		printf("invalid port_id %d\n", res->port_id);
15385 		break;
15386 	case -ENOTSUP:
15387 		printf("function not implemented\n");
15388 		break;
15389 	default:
15390 		printf("programming error: (%s)\n", strerror(-ret));
15391 	}
15392 }
15393 
15394 cmdline_parse_inst_t cmd_tc_min_bw = {
15395 	.f = cmd_tc_min_bw_parsed,
15396 	.data = NULL,
15397 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15398 	.tokens = {
15399 		(void *)&cmd_vf_tc_bw_set,
15400 		(void *)&cmd_vf_tc_bw_tc,
15401 		(void *)&cmd_vf_tc_bw_tx,
15402 		(void *)&cmd_vf_tc_bw_min_bw,
15403 		(void *)&cmd_vf_tc_bw_port_id,
15404 		(void *)&cmd_vf_tc_bw_bw_list,
15405 		NULL,
15406 	},
15407 };
15408 
15409 /* TC max bandwidth setting */
15410 static void
15411 cmd_vf_tc_max_bw_parsed(
15412 	void *parsed_result,
15413 	__rte_unused struct cmdline *cl,
15414 	__rte_unused void *data)
15415 {
15416 	struct cmd_vf_tc_bw_result *res = parsed_result;
15417 	int ret = -ENOTSUP;
15418 
15419 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15420 		return;
15421 
15422 #ifdef RTE_LIBRTE_I40E_PMD
15423 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15424 					    res->tc_no, res->bw);
15425 #endif
15426 
15427 	switch (ret) {
15428 	case 0:
15429 		break;
15430 	case -EINVAL:
15431 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15432 		       res->vf_id, res->tc_no, res->bw);
15433 		break;
15434 	case -ENODEV:
15435 		printf("invalid port_id %d\n", res->port_id);
15436 		break;
15437 	case -ENOTSUP:
15438 		printf("function not implemented\n");
15439 		break;
15440 	default:
15441 		printf("programming error: (%s)\n", strerror(-ret));
15442 	}
15443 }
15444 
15445 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15446 	.f = cmd_vf_tc_max_bw_parsed,
15447 	.data = NULL,
15448 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15449 		    " <bandwidth>",
15450 	.tokens = {
15451 		(void *)&cmd_vf_tc_bw_set,
15452 		(void *)&cmd_vf_tc_bw_vf,
15453 		(void *)&cmd_vf_tc_bw_tc,
15454 		(void *)&cmd_vf_tc_bw_tx,
15455 		(void *)&cmd_vf_tc_bw_max_bw,
15456 		(void *)&cmd_vf_tc_bw_port_id,
15457 		(void *)&cmd_vf_tc_bw_vf_id,
15458 		(void *)&cmd_vf_tc_bw_tc_no,
15459 		(void *)&cmd_vf_tc_bw_bw,
15460 		NULL,
15461 	},
15462 };
15463 
15464 /** Set VXLAN encapsulation details */
15465 struct cmd_set_vxlan_result {
15466 	cmdline_fixed_string_t set;
15467 	cmdline_fixed_string_t vxlan;
15468 	cmdline_fixed_string_t pos_token;
15469 	cmdline_fixed_string_t ip_version;
15470 	uint32_t vlan_present:1;
15471 	uint32_t vni;
15472 	uint16_t udp_src;
15473 	uint16_t udp_dst;
15474 	cmdline_ipaddr_t ip_src;
15475 	cmdline_ipaddr_t ip_dst;
15476 	uint16_t tci;
15477 	uint8_t tos;
15478 	uint8_t ttl;
15479 	struct rte_ether_addr eth_src;
15480 	struct rte_ether_addr eth_dst;
15481 };
15482 
15483 cmdline_parse_token_string_t cmd_set_vxlan_set =
15484 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15485 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15486 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15487 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15488 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15489 				 "vxlan-tos-ttl");
15490 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15491 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15492 				 "vxlan-with-vlan");
15493 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15494 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15495 				 "ip-version");
15496 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15497 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15498 				 "ipv4#ipv6");
15499 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15500 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15501 				 "vni");
15502 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15503 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15504 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15505 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15506 				 "udp-src");
15507 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15508 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15509 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15510 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15511 				 "udp-dst");
15512 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15513 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15514 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15515 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15516 				 "ip-tos");
15517 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15518 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15519 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15520 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15521 				 "ip-ttl");
15522 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15523 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15524 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15525 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15526 				 "ip-src");
15527 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15528 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15529 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15530 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15531 				 "ip-dst");
15532 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15533 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15534 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15535 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15536 				 "vlan-tci");
15537 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15538 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15539 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15540 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15541 				 "eth-src");
15542 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15543 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15544 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15545 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15546 				 "eth-dst");
15547 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15548 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15549 
15550 static void cmd_set_vxlan_parsed(void *parsed_result,
15551 	__rte_unused struct cmdline *cl,
15552 	__rte_unused void *data)
15553 {
15554 	struct cmd_set_vxlan_result *res = parsed_result;
15555 	union {
15556 		uint32_t vxlan_id;
15557 		uint8_t vni[4];
15558 	} id = {
15559 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15560 	};
15561 
15562 	vxlan_encap_conf.select_tos_ttl = 0;
15563 	if (strcmp(res->vxlan, "vxlan") == 0)
15564 		vxlan_encap_conf.select_vlan = 0;
15565 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15566 		vxlan_encap_conf.select_vlan = 1;
15567 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15568 		vxlan_encap_conf.select_vlan = 0;
15569 		vxlan_encap_conf.select_tos_ttl = 1;
15570 	}
15571 	if (strcmp(res->ip_version, "ipv4") == 0)
15572 		vxlan_encap_conf.select_ipv4 = 1;
15573 	else if (strcmp(res->ip_version, "ipv6") == 0)
15574 		vxlan_encap_conf.select_ipv4 = 0;
15575 	else
15576 		return;
15577 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15578 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15579 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15580 	vxlan_encap_conf.ip_tos = res->tos;
15581 	vxlan_encap_conf.ip_ttl = res->ttl;
15582 	if (vxlan_encap_conf.select_ipv4) {
15583 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15584 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15585 	} else {
15586 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15587 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15588 	}
15589 	if (vxlan_encap_conf.select_vlan)
15590 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15591 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15592 		   RTE_ETHER_ADDR_LEN);
15593 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15594 		   RTE_ETHER_ADDR_LEN);
15595 }
15596 
15597 cmdline_parse_inst_t cmd_set_vxlan = {
15598 	.f = cmd_set_vxlan_parsed,
15599 	.data = NULL,
15600 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15601 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15602 		" eth-src <eth-src> eth-dst <eth-dst>",
15603 	.tokens = {
15604 		(void *)&cmd_set_vxlan_set,
15605 		(void *)&cmd_set_vxlan_vxlan,
15606 		(void *)&cmd_set_vxlan_ip_version,
15607 		(void *)&cmd_set_vxlan_ip_version_value,
15608 		(void *)&cmd_set_vxlan_vni,
15609 		(void *)&cmd_set_vxlan_vni_value,
15610 		(void *)&cmd_set_vxlan_udp_src,
15611 		(void *)&cmd_set_vxlan_udp_src_value,
15612 		(void *)&cmd_set_vxlan_udp_dst,
15613 		(void *)&cmd_set_vxlan_udp_dst_value,
15614 		(void *)&cmd_set_vxlan_ip_src,
15615 		(void *)&cmd_set_vxlan_ip_src_value,
15616 		(void *)&cmd_set_vxlan_ip_dst,
15617 		(void *)&cmd_set_vxlan_ip_dst_value,
15618 		(void *)&cmd_set_vxlan_eth_src,
15619 		(void *)&cmd_set_vxlan_eth_src_value,
15620 		(void *)&cmd_set_vxlan_eth_dst,
15621 		(void *)&cmd_set_vxlan_eth_dst_value,
15622 		NULL,
15623 	},
15624 };
15625 
15626 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15627 	.f = cmd_set_vxlan_parsed,
15628 	.data = NULL,
15629 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15630 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15631 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15632 		" eth-dst <eth-dst>",
15633 	.tokens = {
15634 		(void *)&cmd_set_vxlan_set,
15635 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
15636 		(void *)&cmd_set_vxlan_ip_version,
15637 		(void *)&cmd_set_vxlan_ip_version_value,
15638 		(void *)&cmd_set_vxlan_vni,
15639 		(void *)&cmd_set_vxlan_vni_value,
15640 		(void *)&cmd_set_vxlan_udp_src,
15641 		(void *)&cmd_set_vxlan_udp_src_value,
15642 		(void *)&cmd_set_vxlan_udp_dst,
15643 		(void *)&cmd_set_vxlan_udp_dst_value,
15644 		(void *)&cmd_set_vxlan_ip_tos,
15645 		(void *)&cmd_set_vxlan_ip_tos_value,
15646 		(void *)&cmd_set_vxlan_ip_ttl,
15647 		(void *)&cmd_set_vxlan_ip_ttl_value,
15648 		(void *)&cmd_set_vxlan_ip_src,
15649 		(void *)&cmd_set_vxlan_ip_src_value,
15650 		(void *)&cmd_set_vxlan_ip_dst,
15651 		(void *)&cmd_set_vxlan_ip_dst_value,
15652 		(void *)&cmd_set_vxlan_eth_src,
15653 		(void *)&cmd_set_vxlan_eth_src_value,
15654 		(void *)&cmd_set_vxlan_eth_dst,
15655 		(void *)&cmd_set_vxlan_eth_dst_value,
15656 		NULL,
15657 	},
15658 };
15659 
15660 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15661 	.f = cmd_set_vxlan_parsed,
15662 	.data = NULL,
15663 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15664 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15665 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15666 		" <eth-dst>",
15667 	.tokens = {
15668 		(void *)&cmd_set_vxlan_set,
15669 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
15670 		(void *)&cmd_set_vxlan_ip_version,
15671 		(void *)&cmd_set_vxlan_ip_version_value,
15672 		(void *)&cmd_set_vxlan_vni,
15673 		(void *)&cmd_set_vxlan_vni_value,
15674 		(void *)&cmd_set_vxlan_udp_src,
15675 		(void *)&cmd_set_vxlan_udp_src_value,
15676 		(void *)&cmd_set_vxlan_udp_dst,
15677 		(void *)&cmd_set_vxlan_udp_dst_value,
15678 		(void *)&cmd_set_vxlan_ip_src,
15679 		(void *)&cmd_set_vxlan_ip_src_value,
15680 		(void *)&cmd_set_vxlan_ip_dst,
15681 		(void *)&cmd_set_vxlan_ip_dst_value,
15682 		(void *)&cmd_set_vxlan_vlan,
15683 		(void *)&cmd_set_vxlan_vlan_value,
15684 		(void *)&cmd_set_vxlan_eth_src,
15685 		(void *)&cmd_set_vxlan_eth_src_value,
15686 		(void *)&cmd_set_vxlan_eth_dst,
15687 		(void *)&cmd_set_vxlan_eth_dst_value,
15688 		NULL,
15689 	},
15690 };
15691 
15692 /** Set NVGRE encapsulation details */
15693 struct cmd_set_nvgre_result {
15694 	cmdline_fixed_string_t set;
15695 	cmdline_fixed_string_t nvgre;
15696 	cmdline_fixed_string_t pos_token;
15697 	cmdline_fixed_string_t ip_version;
15698 	uint32_t tni;
15699 	cmdline_ipaddr_t ip_src;
15700 	cmdline_ipaddr_t ip_dst;
15701 	uint16_t tci;
15702 	struct rte_ether_addr eth_src;
15703 	struct rte_ether_addr eth_dst;
15704 };
15705 
15706 cmdline_parse_token_string_t cmd_set_nvgre_set =
15707 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15708 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15709 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15710 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15711 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15712 				 "nvgre-with-vlan");
15713 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15714 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15715 				 "ip-version");
15716 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15717 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15718 				 "ipv4#ipv6");
15719 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15720 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15721 				 "tni");
15722 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15723 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15724 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15725 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15726 				 "ip-src");
15727 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15728 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15729 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15730 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15731 				 "ip-dst");
15732 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15733 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15734 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15735 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15736 				 "vlan-tci");
15737 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15738 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15739 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15740 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15741 				 "eth-src");
15742 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15743 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15744 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15745 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15746 				 "eth-dst");
15747 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15748 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15749 
15750 static void cmd_set_nvgre_parsed(void *parsed_result,
15751 	__rte_unused struct cmdline *cl,
15752 	__rte_unused void *data)
15753 {
15754 	struct cmd_set_nvgre_result *res = parsed_result;
15755 	union {
15756 		uint32_t nvgre_tni;
15757 		uint8_t tni[4];
15758 	} id = {
15759 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15760 	};
15761 
15762 	if (strcmp(res->nvgre, "nvgre") == 0)
15763 		nvgre_encap_conf.select_vlan = 0;
15764 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15765 		nvgre_encap_conf.select_vlan = 1;
15766 	if (strcmp(res->ip_version, "ipv4") == 0)
15767 		nvgre_encap_conf.select_ipv4 = 1;
15768 	else if (strcmp(res->ip_version, "ipv6") == 0)
15769 		nvgre_encap_conf.select_ipv4 = 0;
15770 	else
15771 		return;
15772 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15773 	if (nvgre_encap_conf.select_ipv4) {
15774 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15775 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15776 	} else {
15777 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15778 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15779 	}
15780 	if (nvgre_encap_conf.select_vlan)
15781 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15782 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15783 		   RTE_ETHER_ADDR_LEN);
15784 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15785 		   RTE_ETHER_ADDR_LEN);
15786 }
15787 
15788 cmdline_parse_inst_t cmd_set_nvgre = {
15789 	.f = cmd_set_nvgre_parsed,
15790 	.data = NULL,
15791 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15792 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15793 		" eth-dst <eth-dst>",
15794 	.tokens = {
15795 		(void *)&cmd_set_nvgre_set,
15796 		(void *)&cmd_set_nvgre_nvgre,
15797 		(void *)&cmd_set_nvgre_ip_version,
15798 		(void *)&cmd_set_nvgre_ip_version_value,
15799 		(void *)&cmd_set_nvgre_tni,
15800 		(void *)&cmd_set_nvgre_tni_value,
15801 		(void *)&cmd_set_nvgre_ip_src,
15802 		(void *)&cmd_set_nvgre_ip_src_value,
15803 		(void *)&cmd_set_nvgre_ip_dst,
15804 		(void *)&cmd_set_nvgre_ip_dst_value,
15805 		(void *)&cmd_set_nvgre_eth_src,
15806 		(void *)&cmd_set_nvgre_eth_src_value,
15807 		(void *)&cmd_set_nvgre_eth_dst,
15808 		(void *)&cmd_set_nvgre_eth_dst_value,
15809 		NULL,
15810 	},
15811 };
15812 
15813 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15814 	.f = cmd_set_nvgre_parsed,
15815 	.data = NULL,
15816 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15817 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15818 		" eth-src <eth-src> eth-dst <eth-dst>",
15819 	.tokens = {
15820 		(void *)&cmd_set_nvgre_set,
15821 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
15822 		(void *)&cmd_set_nvgre_ip_version,
15823 		(void *)&cmd_set_nvgre_ip_version_value,
15824 		(void *)&cmd_set_nvgre_tni,
15825 		(void *)&cmd_set_nvgre_tni_value,
15826 		(void *)&cmd_set_nvgre_ip_src,
15827 		(void *)&cmd_set_nvgre_ip_src_value,
15828 		(void *)&cmd_set_nvgre_ip_dst,
15829 		(void *)&cmd_set_nvgre_ip_dst_value,
15830 		(void *)&cmd_set_nvgre_vlan,
15831 		(void *)&cmd_set_nvgre_vlan_value,
15832 		(void *)&cmd_set_nvgre_eth_src,
15833 		(void *)&cmd_set_nvgre_eth_src_value,
15834 		(void *)&cmd_set_nvgre_eth_dst,
15835 		(void *)&cmd_set_nvgre_eth_dst_value,
15836 		NULL,
15837 	},
15838 };
15839 
15840 /** Set L2 encapsulation details */
15841 struct cmd_set_l2_encap_result {
15842 	cmdline_fixed_string_t set;
15843 	cmdline_fixed_string_t l2_encap;
15844 	cmdline_fixed_string_t pos_token;
15845 	cmdline_fixed_string_t ip_version;
15846 	uint32_t vlan_present:1;
15847 	uint16_t tci;
15848 	struct rte_ether_addr eth_src;
15849 	struct rte_ether_addr eth_dst;
15850 };
15851 
15852 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15853 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15854 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15855 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15856 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15857 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15858 				 "l2_encap-with-vlan");
15859 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15860 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15861 				 "ip-version");
15862 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15863 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15864 				 "ipv4#ipv6");
15865 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15866 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15867 				 "vlan-tci");
15868 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15869 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15870 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15871 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15872 				 "eth-src");
15873 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15874 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15875 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15876 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15877 				 "eth-dst");
15878 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15879 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15880 
15881 static void cmd_set_l2_encap_parsed(void *parsed_result,
15882 	__rte_unused struct cmdline *cl,
15883 	__rte_unused void *data)
15884 {
15885 	struct cmd_set_l2_encap_result *res = parsed_result;
15886 
15887 	if (strcmp(res->l2_encap, "l2_encap") == 0)
15888 		l2_encap_conf.select_vlan = 0;
15889 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15890 		l2_encap_conf.select_vlan = 1;
15891 	if (strcmp(res->ip_version, "ipv4") == 0)
15892 		l2_encap_conf.select_ipv4 = 1;
15893 	else if (strcmp(res->ip_version, "ipv6") == 0)
15894 		l2_encap_conf.select_ipv4 = 0;
15895 	else
15896 		return;
15897 	if (l2_encap_conf.select_vlan)
15898 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15899 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15900 		   RTE_ETHER_ADDR_LEN);
15901 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15902 		   RTE_ETHER_ADDR_LEN);
15903 }
15904 
15905 cmdline_parse_inst_t cmd_set_l2_encap = {
15906 	.f = cmd_set_l2_encap_parsed,
15907 	.data = NULL,
15908 	.help_str = "set l2_encap ip-version ipv4|ipv6"
15909 		" eth-src <eth-src> eth-dst <eth-dst>",
15910 	.tokens = {
15911 		(void *)&cmd_set_l2_encap_set,
15912 		(void *)&cmd_set_l2_encap_l2_encap,
15913 		(void *)&cmd_set_l2_encap_ip_version,
15914 		(void *)&cmd_set_l2_encap_ip_version_value,
15915 		(void *)&cmd_set_l2_encap_eth_src,
15916 		(void *)&cmd_set_l2_encap_eth_src_value,
15917 		(void *)&cmd_set_l2_encap_eth_dst,
15918 		(void *)&cmd_set_l2_encap_eth_dst_value,
15919 		NULL,
15920 	},
15921 };
15922 
15923 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15924 	.f = cmd_set_l2_encap_parsed,
15925 	.data = NULL,
15926 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15927 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15928 	.tokens = {
15929 		(void *)&cmd_set_l2_encap_set,
15930 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15931 		(void *)&cmd_set_l2_encap_ip_version,
15932 		(void *)&cmd_set_l2_encap_ip_version_value,
15933 		(void *)&cmd_set_l2_encap_vlan,
15934 		(void *)&cmd_set_l2_encap_vlan_value,
15935 		(void *)&cmd_set_l2_encap_eth_src,
15936 		(void *)&cmd_set_l2_encap_eth_src_value,
15937 		(void *)&cmd_set_l2_encap_eth_dst,
15938 		(void *)&cmd_set_l2_encap_eth_dst_value,
15939 		NULL,
15940 	},
15941 };
15942 
15943 /** Set L2 decapsulation details */
15944 struct cmd_set_l2_decap_result {
15945 	cmdline_fixed_string_t set;
15946 	cmdline_fixed_string_t l2_decap;
15947 	cmdline_fixed_string_t pos_token;
15948 	uint32_t vlan_present:1;
15949 };
15950 
15951 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15952 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15953 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15954 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15955 				 "l2_decap");
15956 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15957 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15958 				 "l2_decap-with-vlan");
15959 
15960 static void cmd_set_l2_decap_parsed(void *parsed_result,
15961 	__rte_unused struct cmdline *cl,
15962 	__rte_unused void *data)
15963 {
15964 	struct cmd_set_l2_decap_result *res = parsed_result;
15965 
15966 	if (strcmp(res->l2_decap, "l2_decap") == 0)
15967 		l2_decap_conf.select_vlan = 0;
15968 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15969 		l2_decap_conf.select_vlan = 1;
15970 }
15971 
15972 cmdline_parse_inst_t cmd_set_l2_decap = {
15973 	.f = cmd_set_l2_decap_parsed,
15974 	.data = NULL,
15975 	.help_str = "set l2_decap",
15976 	.tokens = {
15977 		(void *)&cmd_set_l2_decap_set,
15978 		(void *)&cmd_set_l2_decap_l2_decap,
15979 		NULL,
15980 	},
15981 };
15982 
15983 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15984 	.f = cmd_set_l2_decap_parsed,
15985 	.data = NULL,
15986 	.help_str = "set l2_decap-with-vlan",
15987 	.tokens = {
15988 		(void *)&cmd_set_l2_decap_set,
15989 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15990 		NULL,
15991 	},
15992 };
15993 
15994 /** Set MPLSoGRE encapsulation details */
15995 struct cmd_set_mplsogre_encap_result {
15996 	cmdline_fixed_string_t set;
15997 	cmdline_fixed_string_t mplsogre;
15998 	cmdline_fixed_string_t pos_token;
15999 	cmdline_fixed_string_t ip_version;
16000 	uint32_t vlan_present:1;
16001 	uint32_t label;
16002 	cmdline_ipaddr_t ip_src;
16003 	cmdline_ipaddr_t ip_dst;
16004 	uint16_t tci;
16005 	struct rte_ether_addr eth_src;
16006 	struct rte_ether_addr eth_dst;
16007 };
16008 
16009 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16010 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16011 				 "set");
16012 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16013 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16014 				 "mplsogre_encap");
16015 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16016 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16017 				 mplsogre, "mplsogre_encap-with-vlan");
16018 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16019 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16020 				 pos_token, "ip-version");
16021 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16022 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16023 				 ip_version, "ipv4#ipv6");
16024 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16025 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16026 				 pos_token, "label");
16027 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16028 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16029 			      UINT32);
16030 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16031 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16032 				 pos_token, "ip-src");
16033 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16034 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16035 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16036 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16037 				 pos_token, "ip-dst");
16038 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16039 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16040 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16041 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16042 				 pos_token, "vlan-tci");
16043 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16044 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16045 			      UINT16);
16046 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16047 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16048 				 pos_token, "eth-src");
16049 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16050 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16051 				    eth_src);
16052 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16053 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16054 				 pos_token, "eth-dst");
16055 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16056 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16057 				    eth_dst);
16058 
16059 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16060 	__rte_unused struct cmdline *cl,
16061 	__rte_unused void *data)
16062 {
16063 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
16064 	union {
16065 		uint32_t mplsogre_label;
16066 		uint8_t label[4];
16067 	} id = {
16068 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16069 	};
16070 
16071 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16072 		mplsogre_encap_conf.select_vlan = 0;
16073 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16074 		mplsogre_encap_conf.select_vlan = 1;
16075 	if (strcmp(res->ip_version, "ipv4") == 0)
16076 		mplsogre_encap_conf.select_ipv4 = 1;
16077 	else if (strcmp(res->ip_version, "ipv6") == 0)
16078 		mplsogre_encap_conf.select_ipv4 = 0;
16079 	else
16080 		return;
16081 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16082 	if (mplsogre_encap_conf.select_ipv4) {
16083 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16084 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16085 	} else {
16086 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16087 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16088 	}
16089 	if (mplsogre_encap_conf.select_vlan)
16090 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16091 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16092 		   RTE_ETHER_ADDR_LEN);
16093 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16094 		   RTE_ETHER_ADDR_LEN);
16095 }
16096 
16097 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16098 	.f = cmd_set_mplsogre_encap_parsed,
16099 	.data = NULL,
16100 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16101 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16102 		" eth-dst <eth-dst>",
16103 	.tokens = {
16104 		(void *)&cmd_set_mplsogre_encap_set,
16105 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16106 		(void *)&cmd_set_mplsogre_encap_ip_version,
16107 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
16108 		(void *)&cmd_set_mplsogre_encap_label,
16109 		(void *)&cmd_set_mplsogre_encap_label_value,
16110 		(void *)&cmd_set_mplsogre_encap_ip_src,
16111 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
16112 		(void *)&cmd_set_mplsogre_encap_ip_dst,
16113 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
16114 		(void *)&cmd_set_mplsogre_encap_eth_src,
16115 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
16116 		(void *)&cmd_set_mplsogre_encap_eth_dst,
16117 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
16118 		NULL,
16119 	},
16120 };
16121 
16122 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16123 	.f = cmd_set_mplsogre_encap_parsed,
16124 	.data = NULL,
16125 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16126 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
16127 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16128 	.tokens = {
16129 		(void *)&cmd_set_mplsogre_encap_set,
16130 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16131 		(void *)&cmd_set_mplsogre_encap_ip_version,
16132 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
16133 		(void *)&cmd_set_mplsogre_encap_label,
16134 		(void *)&cmd_set_mplsogre_encap_label_value,
16135 		(void *)&cmd_set_mplsogre_encap_ip_src,
16136 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
16137 		(void *)&cmd_set_mplsogre_encap_ip_dst,
16138 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
16139 		(void *)&cmd_set_mplsogre_encap_vlan,
16140 		(void *)&cmd_set_mplsogre_encap_vlan_value,
16141 		(void *)&cmd_set_mplsogre_encap_eth_src,
16142 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
16143 		(void *)&cmd_set_mplsogre_encap_eth_dst,
16144 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
16145 		NULL,
16146 	},
16147 };
16148 
16149 /** Set MPLSoGRE decapsulation details */
16150 struct cmd_set_mplsogre_decap_result {
16151 	cmdline_fixed_string_t set;
16152 	cmdline_fixed_string_t mplsogre;
16153 	cmdline_fixed_string_t pos_token;
16154 	cmdline_fixed_string_t ip_version;
16155 	uint32_t vlan_present:1;
16156 };
16157 
16158 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16159 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16160 				 "set");
16161 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16162 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16163 				 "mplsogre_decap");
16164 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16165 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16166 				 mplsogre, "mplsogre_decap-with-vlan");
16167 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16168 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16169 				 pos_token, "ip-version");
16170 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16171 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16172 				 ip_version, "ipv4#ipv6");
16173 
16174 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16175 	__rte_unused struct cmdline *cl,
16176 	__rte_unused void *data)
16177 {
16178 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
16179 
16180 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16181 		mplsogre_decap_conf.select_vlan = 0;
16182 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16183 		mplsogre_decap_conf.select_vlan = 1;
16184 	if (strcmp(res->ip_version, "ipv4") == 0)
16185 		mplsogre_decap_conf.select_ipv4 = 1;
16186 	else if (strcmp(res->ip_version, "ipv6") == 0)
16187 		mplsogre_decap_conf.select_ipv4 = 0;
16188 }
16189 
16190 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16191 	.f = cmd_set_mplsogre_decap_parsed,
16192 	.data = NULL,
16193 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16194 	.tokens = {
16195 		(void *)&cmd_set_mplsogre_decap_set,
16196 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16197 		(void *)&cmd_set_mplsogre_decap_ip_version,
16198 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
16199 		NULL,
16200 	},
16201 };
16202 
16203 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16204 	.f = cmd_set_mplsogre_decap_parsed,
16205 	.data = NULL,
16206 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16207 	.tokens = {
16208 		(void *)&cmd_set_mplsogre_decap_set,
16209 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16210 		(void *)&cmd_set_mplsogre_decap_ip_version,
16211 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
16212 		NULL,
16213 	},
16214 };
16215 
16216 /** Set MPLSoUDP encapsulation details */
16217 struct cmd_set_mplsoudp_encap_result {
16218 	cmdline_fixed_string_t set;
16219 	cmdline_fixed_string_t mplsoudp;
16220 	cmdline_fixed_string_t pos_token;
16221 	cmdline_fixed_string_t ip_version;
16222 	uint32_t vlan_present:1;
16223 	uint32_t label;
16224 	uint16_t udp_src;
16225 	uint16_t udp_dst;
16226 	cmdline_ipaddr_t ip_src;
16227 	cmdline_ipaddr_t ip_dst;
16228 	uint16_t tci;
16229 	struct rte_ether_addr eth_src;
16230 	struct rte_ether_addr eth_dst;
16231 };
16232 
16233 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16234 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16235 				 "set");
16236 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16237 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16238 				 "mplsoudp_encap");
16239 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16240 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16241 				 mplsoudp, "mplsoudp_encap-with-vlan");
16242 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16243 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16244 				 pos_token, "ip-version");
16245 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16246 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16247 				 ip_version, "ipv4#ipv6");
16248 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16249 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16250 				 pos_token, "label");
16251 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16252 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16253 			      UINT32);
16254 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16255 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16256 				 pos_token, "udp-src");
16257 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16258 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16259 			      UINT16);
16260 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16261 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16262 				 pos_token, "udp-dst");
16263 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16264 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16265 			      UINT16);
16266 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16267 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16268 				 pos_token, "ip-src");
16269 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16270 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16271 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16272 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16273 				 pos_token, "ip-dst");
16274 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16275 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16276 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16277 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16278 				 pos_token, "vlan-tci");
16279 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16280 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16281 			      UINT16);
16282 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16283 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16284 				 pos_token, "eth-src");
16285 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16286 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16287 				    eth_src);
16288 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16289 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16290 				 pos_token, "eth-dst");
16291 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16292 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16293 				    eth_dst);
16294 
16295 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16296 	__rte_unused struct cmdline *cl,
16297 	__rte_unused void *data)
16298 {
16299 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16300 	union {
16301 		uint32_t mplsoudp_label;
16302 		uint8_t label[4];
16303 	} id = {
16304 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16305 	};
16306 
16307 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16308 		mplsoudp_encap_conf.select_vlan = 0;
16309 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16310 		mplsoudp_encap_conf.select_vlan = 1;
16311 	if (strcmp(res->ip_version, "ipv4") == 0)
16312 		mplsoudp_encap_conf.select_ipv4 = 1;
16313 	else if (strcmp(res->ip_version, "ipv6") == 0)
16314 		mplsoudp_encap_conf.select_ipv4 = 0;
16315 	else
16316 		return;
16317 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16318 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16319 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16320 	if (mplsoudp_encap_conf.select_ipv4) {
16321 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16322 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16323 	} else {
16324 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16325 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16326 	}
16327 	if (mplsoudp_encap_conf.select_vlan)
16328 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16329 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16330 		   RTE_ETHER_ADDR_LEN);
16331 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16332 		   RTE_ETHER_ADDR_LEN);
16333 }
16334 
16335 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16336 	.f = cmd_set_mplsoudp_encap_parsed,
16337 	.data = NULL,
16338 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16339 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16340 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16341 	.tokens = {
16342 		(void *)&cmd_set_mplsoudp_encap_set,
16343 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16344 		(void *)&cmd_set_mplsoudp_encap_ip_version,
16345 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
16346 		(void *)&cmd_set_mplsoudp_encap_label,
16347 		(void *)&cmd_set_mplsoudp_encap_label_value,
16348 		(void *)&cmd_set_mplsoudp_encap_udp_src,
16349 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
16350 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
16351 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16352 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16353 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16354 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16355 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16356 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16357 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16358 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16359 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16360 		NULL,
16361 	},
16362 };
16363 
16364 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16365 	.f = cmd_set_mplsoudp_encap_parsed,
16366 	.data = NULL,
16367 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16368 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
16369 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16370 		" eth-src <eth-src> eth-dst <eth-dst>",
16371 	.tokens = {
16372 		(void *)&cmd_set_mplsoudp_encap_set,
16373 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16374 		(void *)&cmd_set_mplsoudp_encap_ip_version,
16375 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
16376 		(void *)&cmd_set_mplsoudp_encap_label,
16377 		(void *)&cmd_set_mplsoudp_encap_label_value,
16378 		(void *)&cmd_set_mplsoudp_encap_udp_src,
16379 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
16380 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
16381 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16382 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16383 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16384 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16385 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16386 		(void *)&cmd_set_mplsoudp_encap_vlan,
16387 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
16388 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16389 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16390 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16391 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16392 		NULL,
16393 	},
16394 };
16395 
16396 /** Set MPLSoUDP decapsulation details */
16397 struct cmd_set_mplsoudp_decap_result {
16398 	cmdline_fixed_string_t set;
16399 	cmdline_fixed_string_t mplsoudp;
16400 	cmdline_fixed_string_t pos_token;
16401 	cmdline_fixed_string_t ip_version;
16402 	uint32_t vlan_present:1;
16403 };
16404 
16405 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16406 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16407 				 "set");
16408 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16409 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16410 				 "mplsoudp_decap");
16411 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16412 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16413 				 mplsoudp, "mplsoudp_decap-with-vlan");
16414 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16415 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16416 				 pos_token, "ip-version");
16417 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16418 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16419 				 ip_version, "ipv4#ipv6");
16420 
16421 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16422 	__rte_unused struct cmdline *cl,
16423 	__rte_unused void *data)
16424 {
16425 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16426 
16427 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16428 		mplsoudp_decap_conf.select_vlan = 0;
16429 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16430 		mplsoudp_decap_conf.select_vlan = 1;
16431 	if (strcmp(res->ip_version, "ipv4") == 0)
16432 		mplsoudp_decap_conf.select_ipv4 = 1;
16433 	else if (strcmp(res->ip_version, "ipv6") == 0)
16434 		mplsoudp_decap_conf.select_ipv4 = 0;
16435 }
16436 
16437 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16438 	.f = cmd_set_mplsoudp_decap_parsed,
16439 	.data = NULL,
16440 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16441 	.tokens = {
16442 		(void *)&cmd_set_mplsoudp_decap_set,
16443 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16444 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16445 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16446 		NULL,
16447 	},
16448 };
16449 
16450 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16451 	.f = cmd_set_mplsoudp_decap_parsed,
16452 	.data = NULL,
16453 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16454 	.tokens = {
16455 		(void *)&cmd_set_mplsoudp_decap_set,
16456 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16457 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16458 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16459 		NULL,
16460 	},
16461 };
16462 
16463 /* Strict link priority scheduling mode setting */
16464 static void
16465 cmd_strict_link_prio_parsed(
16466 	void *parsed_result,
16467 	__rte_unused struct cmdline *cl,
16468 	__rte_unused void *data)
16469 {
16470 	struct cmd_vf_tc_bw_result *res = parsed_result;
16471 	int ret = -ENOTSUP;
16472 
16473 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16474 		return;
16475 
16476 #ifdef RTE_LIBRTE_I40E_PMD
16477 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16478 #endif
16479 
16480 	switch (ret) {
16481 	case 0:
16482 		break;
16483 	case -EINVAL:
16484 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16485 		break;
16486 	case -ENODEV:
16487 		printf("invalid port_id %d\n", res->port_id);
16488 		break;
16489 	case -ENOTSUP:
16490 		printf("function not implemented\n");
16491 		break;
16492 	default:
16493 		printf("programming error: (%s)\n", strerror(-ret));
16494 	}
16495 }
16496 
16497 cmdline_parse_inst_t cmd_strict_link_prio = {
16498 	.f = cmd_strict_link_prio_parsed,
16499 	.data = NULL,
16500 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16501 	.tokens = {
16502 		(void *)&cmd_vf_tc_bw_set,
16503 		(void *)&cmd_vf_tc_bw_tx,
16504 		(void *)&cmd_vf_tc_bw_strict_link_prio,
16505 		(void *)&cmd_vf_tc_bw_port_id,
16506 		(void *)&cmd_vf_tc_bw_tc_map,
16507 		NULL,
16508 	},
16509 };
16510 
16511 /* Load dynamic device personalization*/
16512 struct cmd_ddp_add_result {
16513 	cmdline_fixed_string_t ddp;
16514 	cmdline_fixed_string_t add;
16515 	portid_t port_id;
16516 	char filepath[];
16517 };
16518 
16519 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16520 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16521 cmdline_parse_token_string_t cmd_ddp_add_add =
16522 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16523 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16524 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16525 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16526 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16527 
16528 static void
16529 cmd_ddp_add_parsed(
16530 	void *parsed_result,
16531 	__rte_unused struct cmdline *cl,
16532 	__rte_unused void *data)
16533 {
16534 	struct cmd_ddp_add_result *res = parsed_result;
16535 	uint8_t *buff;
16536 	uint32_t size;
16537 	char *filepath;
16538 	char *file_fld[2];
16539 	int file_num;
16540 	int ret = -ENOTSUP;
16541 
16542 	if (!all_ports_stopped()) {
16543 		printf("Please stop all ports first\n");
16544 		return;
16545 	}
16546 
16547 	filepath = strdup(res->filepath);
16548 	if (filepath == NULL) {
16549 		printf("Failed to allocate memory\n");
16550 		return;
16551 	}
16552 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16553 
16554 	buff = open_file(file_fld[0], &size);
16555 	if (!buff) {
16556 		free((void *)filepath);
16557 		return;
16558 	}
16559 
16560 #ifdef RTE_LIBRTE_I40E_PMD
16561 	if (ret == -ENOTSUP)
16562 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16563 					       buff, size,
16564 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
16565 #endif
16566 
16567 	if (ret == -EEXIST)
16568 		printf("Profile has already existed.\n");
16569 	else if (ret < 0)
16570 		printf("Failed to load profile.\n");
16571 	else if (file_num == 2)
16572 		save_file(file_fld[1], buff, size);
16573 
16574 	close_file(buff);
16575 	free((void *)filepath);
16576 }
16577 
16578 cmdline_parse_inst_t cmd_ddp_add = {
16579 	.f = cmd_ddp_add_parsed,
16580 	.data = NULL,
16581 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16582 	.tokens = {
16583 		(void *)&cmd_ddp_add_ddp,
16584 		(void *)&cmd_ddp_add_add,
16585 		(void *)&cmd_ddp_add_port_id,
16586 		(void *)&cmd_ddp_add_filepath,
16587 		NULL,
16588 	},
16589 };
16590 
16591 /* Delete dynamic device personalization*/
16592 struct cmd_ddp_del_result {
16593 	cmdline_fixed_string_t ddp;
16594 	cmdline_fixed_string_t del;
16595 	portid_t port_id;
16596 	char filepath[];
16597 };
16598 
16599 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16600 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16601 cmdline_parse_token_string_t cmd_ddp_del_del =
16602 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16603 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16604 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16605 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16606 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16607 
16608 static void
16609 cmd_ddp_del_parsed(
16610 	void *parsed_result,
16611 	__rte_unused struct cmdline *cl,
16612 	__rte_unused void *data)
16613 {
16614 	struct cmd_ddp_del_result *res = parsed_result;
16615 	uint8_t *buff;
16616 	uint32_t size;
16617 	int ret = -ENOTSUP;
16618 
16619 	if (!all_ports_stopped()) {
16620 		printf("Please stop all ports first\n");
16621 		return;
16622 	}
16623 
16624 	buff = open_file(res->filepath, &size);
16625 	if (!buff)
16626 		return;
16627 
16628 #ifdef RTE_LIBRTE_I40E_PMD
16629 	if (ret == -ENOTSUP)
16630 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16631 					       buff, size,
16632 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
16633 #endif
16634 
16635 	if (ret == -EACCES)
16636 		printf("Profile does not exist.\n");
16637 	else if (ret < 0)
16638 		printf("Failed to delete profile.\n");
16639 
16640 	close_file(buff);
16641 }
16642 
16643 cmdline_parse_inst_t cmd_ddp_del = {
16644 	.f = cmd_ddp_del_parsed,
16645 	.data = NULL,
16646 	.help_str = "ddp del <port_id> <backup_profile_path>",
16647 	.tokens = {
16648 		(void *)&cmd_ddp_del_ddp,
16649 		(void *)&cmd_ddp_del_del,
16650 		(void *)&cmd_ddp_del_port_id,
16651 		(void *)&cmd_ddp_del_filepath,
16652 		NULL,
16653 	},
16654 };
16655 
16656 /* Get dynamic device personalization profile info */
16657 struct cmd_ddp_info_result {
16658 	cmdline_fixed_string_t ddp;
16659 	cmdline_fixed_string_t get;
16660 	cmdline_fixed_string_t info;
16661 	char filepath[];
16662 };
16663 
16664 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16665 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16666 cmdline_parse_token_string_t cmd_ddp_info_get =
16667 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16668 cmdline_parse_token_string_t cmd_ddp_info_info =
16669 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16670 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16671 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16672 
16673 static void
16674 cmd_ddp_info_parsed(
16675 	void *parsed_result,
16676 	__rte_unused struct cmdline *cl,
16677 	__rte_unused void *data)
16678 {
16679 	struct cmd_ddp_info_result *res = parsed_result;
16680 	uint8_t *pkg;
16681 	uint32_t pkg_size;
16682 	int ret = -ENOTSUP;
16683 #ifdef RTE_LIBRTE_I40E_PMD
16684 	uint32_t i, j, n;
16685 	uint8_t *buff;
16686 	uint32_t buff_size = 0;
16687 	struct rte_pmd_i40e_profile_info info;
16688 	uint32_t dev_num = 0;
16689 	struct rte_pmd_i40e_ddp_device_id *devs;
16690 	uint32_t proto_num = 0;
16691 	struct rte_pmd_i40e_proto_info *proto = NULL;
16692 	uint32_t pctype_num = 0;
16693 	struct rte_pmd_i40e_ptype_info *pctype;
16694 	uint32_t ptype_num = 0;
16695 	struct rte_pmd_i40e_ptype_info *ptype;
16696 	uint8_t proto_id;
16697 
16698 #endif
16699 
16700 	pkg = open_file(res->filepath, &pkg_size);
16701 	if (!pkg)
16702 		return;
16703 
16704 #ifdef RTE_LIBRTE_I40E_PMD
16705 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16706 				(uint8_t *)&info, sizeof(info),
16707 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16708 	if (!ret) {
16709 		printf("Global Track id:       0x%x\n", info.track_id);
16710 		printf("Global Version:        %d.%d.%d.%d\n",
16711 			info.version.major,
16712 			info.version.minor,
16713 			info.version.update,
16714 			info.version.draft);
16715 		printf("Global Package name:   %s\n\n", info.name);
16716 	}
16717 
16718 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16719 				(uint8_t *)&info, sizeof(info),
16720 				RTE_PMD_I40E_PKG_INFO_HEADER);
16721 	if (!ret) {
16722 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
16723 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
16724 			info.version.major,
16725 			info.version.minor,
16726 			info.version.update,
16727 			info.version.draft);
16728 		printf("i40e Profile name:     %s\n\n", info.name);
16729 	}
16730 
16731 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16732 				(uint8_t *)&buff_size, sizeof(buff_size),
16733 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16734 	if (!ret && buff_size) {
16735 		buff = (uint8_t *)malloc(buff_size);
16736 		if (buff) {
16737 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16738 						buff, buff_size,
16739 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16740 			if (!ret)
16741 				printf("Package Notes:\n%s\n\n", buff);
16742 			free(buff);
16743 		}
16744 	}
16745 
16746 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16747 				(uint8_t *)&dev_num, sizeof(dev_num),
16748 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16749 	if (!ret && dev_num) {
16750 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16751 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16752 		if (devs) {
16753 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16754 						(uint8_t *)devs, buff_size,
16755 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16756 			if (!ret) {
16757 				printf("List of supported devices:\n");
16758 				for (i = 0; i < dev_num; i++) {
16759 					printf("  %04X:%04X %04X:%04X\n",
16760 						devs[i].vendor_dev_id >> 16,
16761 						devs[i].vendor_dev_id & 0xFFFF,
16762 						devs[i].sub_vendor_dev_id >> 16,
16763 						devs[i].sub_vendor_dev_id & 0xFFFF);
16764 				}
16765 				printf("\n");
16766 			}
16767 			free(devs);
16768 		}
16769 	}
16770 
16771 	/* get information about protocols and packet types */
16772 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16773 		(uint8_t *)&proto_num, sizeof(proto_num),
16774 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16775 	if (ret || !proto_num)
16776 		goto no_print_return;
16777 
16778 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16779 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16780 	if (!proto)
16781 		goto no_print_return;
16782 
16783 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16784 					buff_size,
16785 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16786 	if (!ret) {
16787 		printf("List of used protocols:\n");
16788 		for (i = 0; i < proto_num; i++)
16789 			printf("  %2u: %s\n", proto[i].proto_id,
16790 			       proto[i].name);
16791 		printf("\n");
16792 	}
16793 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16794 		(uint8_t *)&pctype_num, sizeof(pctype_num),
16795 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16796 	if (ret || !pctype_num)
16797 		goto no_print_pctypes;
16798 
16799 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16800 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16801 	if (!pctype)
16802 		goto no_print_pctypes;
16803 
16804 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16805 					buff_size,
16806 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16807 	if (ret) {
16808 		free(pctype);
16809 		goto no_print_pctypes;
16810 	}
16811 
16812 	printf("List of defined packet classification types:\n");
16813 	for (i = 0; i < pctype_num; i++) {
16814 		printf("  %2u:", pctype[i].ptype_id);
16815 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16816 			proto_id = pctype[i].protocols[j];
16817 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16818 				for (n = 0; n < proto_num; n++) {
16819 					if (proto[n].proto_id == proto_id) {
16820 						printf(" %s", proto[n].name);
16821 						break;
16822 					}
16823 				}
16824 			}
16825 		}
16826 		printf("\n");
16827 	}
16828 	printf("\n");
16829 	free(pctype);
16830 
16831 no_print_pctypes:
16832 
16833 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16834 					sizeof(ptype_num),
16835 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16836 	if (ret || !ptype_num)
16837 		goto no_print_return;
16838 
16839 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16840 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16841 	if (!ptype)
16842 		goto no_print_return;
16843 
16844 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16845 					buff_size,
16846 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16847 	if (ret) {
16848 		free(ptype);
16849 		goto no_print_return;
16850 	}
16851 	printf("List of defined packet types:\n");
16852 	for (i = 0; i < ptype_num; i++) {
16853 		printf("  %2u:", ptype[i].ptype_id);
16854 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16855 			proto_id = ptype[i].protocols[j];
16856 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16857 				for (n = 0; n < proto_num; n++) {
16858 					if (proto[n].proto_id == proto_id) {
16859 						printf(" %s", proto[n].name);
16860 						break;
16861 					}
16862 				}
16863 			}
16864 		}
16865 		printf("\n");
16866 	}
16867 	free(ptype);
16868 	printf("\n");
16869 
16870 	ret = 0;
16871 no_print_return:
16872 	if (proto)
16873 		free(proto);
16874 #endif
16875 	if (ret == -ENOTSUP)
16876 		printf("Function not supported in PMD driver\n");
16877 	close_file(pkg);
16878 }
16879 
16880 cmdline_parse_inst_t cmd_ddp_get_info = {
16881 	.f = cmd_ddp_info_parsed,
16882 	.data = NULL,
16883 	.help_str = "ddp get info <profile_path>",
16884 	.tokens = {
16885 		(void *)&cmd_ddp_info_ddp,
16886 		(void *)&cmd_ddp_info_get,
16887 		(void *)&cmd_ddp_info_info,
16888 		(void *)&cmd_ddp_info_filepath,
16889 		NULL,
16890 	},
16891 };
16892 
16893 /* Get dynamic device personalization profile info list*/
16894 #define PROFILE_INFO_SIZE 48
16895 #define MAX_PROFILE_NUM 16
16896 
16897 struct cmd_ddp_get_list_result {
16898 	cmdline_fixed_string_t ddp;
16899 	cmdline_fixed_string_t get;
16900 	cmdline_fixed_string_t list;
16901 	portid_t port_id;
16902 };
16903 
16904 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16905 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16906 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16907 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16908 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16909 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16910 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16911 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16912 
16913 static void
16914 cmd_ddp_get_list_parsed(
16915 	__rte_unused void *parsed_result,
16916 	__rte_unused struct cmdline *cl,
16917 	__rte_unused void *data)
16918 {
16919 #ifdef RTE_LIBRTE_I40E_PMD
16920 	struct cmd_ddp_get_list_result *res = parsed_result;
16921 	struct rte_pmd_i40e_profile_list *p_list;
16922 	struct rte_pmd_i40e_profile_info *p_info;
16923 	uint32_t p_num;
16924 	uint32_t size;
16925 	uint32_t i;
16926 #endif
16927 	int ret = -ENOTSUP;
16928 
16929 #ifdef RTE_LIBRTE_I40E_PMD
16930 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16931 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16932 	if (!p_list) {
16933 		printf("%s: Failed to malloc buffer\n", __func__);
16934 		return;
16935 	}
16936 
16937 	if (ret == -ENOTSUP)
16938 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16939 						(uint8_t *)p_list, size);
16940 
16941 	if (!ret) {
16942 		p_num = p_list->p_count;
16943 		printf("Profile number is: %d\n\n", p_num);
16944 
16945 		for (i = 0; i < p_num; i++) {
16946 			p_info = &p_list->p_info[i];
16947 			printf("Profile %d:\n", i);
16948 			printf("Track id:     0x%x\n", p_info->track_id);
16949 			printf("Version:      %d.%d.%d.%d\n",
16950 			       p_info->version.major,
16951 			       p_info->version.minor,
16952 			       p_info->version.update,
16953 			       p_info->version.draft);
16954 			printf("Profile name: %s\n\n", p_info->name);
16955 		}
16956 	}
16957 
16958 	free(p_list);
16959 #endif
16960 
16961 	if (ret < 0)
16962 		printf("Failed to get ddp list\n");
16963 }
16964 
16965 cmdline_parse_inst_t cmd_ddp_get_list = {
16966 	.f = cmd_ddp_get_list_parsed,
16967 	.data = NULL,
16968 	.help_str = "ddp get list <port_id>",
16969 	.tokens = {
16970 		(void *)&cmd_ddp_get_list_ddp,
16971 		(void *)&cmd_ddp_get_list_get,
16972 		(void *)&cmd_ddp_get_list_list,
16973 		(void *)&cmd_ddp_get_list_port_id,
16974 		NULL,
16975 	},
16976 };
16977 
16978 /* Configure input set */
16979 struct cmd_cfg_input_set_result {
16980 	cmdline_fixed_string_t port;
16981 	cmdline_fixed_string_t cfg;
16982 	portid_t port_id;
16983 	cmdline_fixed_string_t pctype;
16984 	uint8_t pctype_id;
16985 	cmdline_fixed_string_t inset_type;
16986 	cmdline_fixed_string_t opt;
16987 	cmdline_fixed_string_t field;
16988 	uint8_t field_idx;
16989 };
16990 
16991 static void
16992 cmd_cfg_input_set_parsed(
16993 	__rte_unused void *parsed_result,
16994 	__rte_unused struct cmdline *cl,
16995 	__rte_unused void *data)
16996 {
16997 #ifdef RTE_LIBRTE_I40E_PMD
16998 	struct cmd_cfg_input_set_result *res = parsed_result;
16999 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17000 	struct rte_pmd_i40e_inset inset;
17001 #endif
17002 	int ret = -ENOTSUP;
17003 
17004 	if (!all_ports_stopped()) {
17005 		printf("Please stop all ports first\n");
17006 		return;
17007 	}
17008 
17009 #ifdef RTE_LIBRTE_I40E_PMD
17010 	if (!strcmp(res->inset_type, "hash_inset"))
17011 		inset_type = INSET_HASH;
17012 	else if (!strcmp(res->inset_type, "fdir_inset"))
17013 		inset_type = INSET_FDIR;
17014 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17015 		inset_type = INSET_FDIR_FLX;
17016 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17017 				     &inset, inset_type);
17018 	if (ret) {
17019 		printf("Failed to get input set.\n");
17020 		return;
17021 	}
17022 
17023 	if (!strcmp(res->opt, "get")) {
17024 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
17025 						   res->field_idx);
17026 		if (ret)
17027 			printf("Field index %d is enabled.\n", res->field_idx);
17028 		else
17029 			printf("Field index %d is disabled.\n", res->field_idx);
17030 		return;
17031 	} else if (!strcmp(res->opt, "set"))
17032 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17033 						   res->field_idx);
17034 	else if (!strcmp(res->opt, "clear"))
17035 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17036 						     res->field_idx);
17037 	if (ret) {
17038 		printf("Failed to configure input set field.\n");
17039 		return;
17040 	}
17041 
17042 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17043 				     &inset, inset_type);
17044 	if (ret) {
17045 		printf("Failed to set input set.\n");
17046 		return;
17047 	}
17048 #endif
17049 
17050 	if (ret == -ENOTSUP)
17051 		printf("Function not supported\n");
17052 }
17053 
17054 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17055 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17056 				 port, "port");
17057 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17058 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17059 				 cfg, "config");
17060 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17061 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17062 			      port_id, UINT16);
17063 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17064 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17065 				 pctype, "pctype");
17066 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17067 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17068 			      pctype_id, UINT8);
17069 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17070 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17071 				 inset_type,
17072 				 "hash_inset#fdir_inset#fdir_flx_inset");
17073 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17074 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17075 				 opt, "get#set#clear");
17076 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17077 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17078 				 field, "field");
17079 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17080 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17081 			      field_idx, UINT8);
17082 
17083 cmdline_parse_inst_t cmd_cfg_input_set = {
17084 	.f = cmd_cfg_input_set_parsed,
17085 	.data = NULL,
17086 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17087 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17088 	.tokens = {
17089 		(void *)&cmd_cfg_input_set_port,
17090 		(void *)&cmd_cfg_input_set_cfg,
17091 		(void *)&cmd_cfg_input_set_port_id,
17092 		(void *)&cmd_cfg_input_set_pctype,
17093 		(void *)&cmd_cfg_input_set_pctype_id,
17094 		(void *)&cmd_cfg_input_set_inset_type,
17095 		(void *)&cmd_cfg_input_set_opt,
17096 		(void *)&cmd_cfg_input_set_field,
17097 		(void *)&cmd_cfg_input_set_field_idx,
17098 		NULL,
17099 	},
17100 };
17101 
17102 /* Clear input set */
17103 struct cmd_clear_input_set_result {
17104 	cmdline_fixed_string_t port;
17105 	cmdline_fixed_string_t cfg;
17106 	portid_t port_id;
17107 	cmdline_fixed_string_t pctype;
17108 	uint8_t pctype_id;
17109 	cmdline_fixed_string_t inset_type;
17110 	cmdline_fixed_string_t clear;
17111 	cmdline_fixed_string_t all;
17112 };
17113 
17114 static void
17115 cmd_clear_input_set_parsed(
17116 	__rte_unused void *parsed_result,
17117 	__rte_unused struct cmdline *cl,
17118 	__rte_unused void *data)
17119 {
17120 #ifdef RTE_LIBRTE_I40E_PMD
17121 	struct cmd_clear_input_set_result *res = parsed_result;
17122 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17123 	struct rte_pmd_i40e_inset inset;
17124 #endif
17125 	int ret = -ENOTSUP;
17126 
17127 	if (!all_ports_stopped()) {
17128 		printf("Please stop all ports first\n");
17129 		return;
17130 	}
17131 
17132 #ifdef RTE_LIBRTE_I40E_PMD
17133 	if (!strcmp(res->inset_type, "hash_inset"))
17134 		inset_type = INSET_HASH;
17135 	else if (!strcmp(res->inset_type, "fdir_inset"))
17136 		inset_type = INSET_FDIR;
17137 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17138 		inset_type = INSET_FDIR_FLX;
17139 
17140 	memset(&inset, 0, sizeof(inset));
17141 
17142 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17143 				     &inset, inset_type);
17144 	if (ret) {
17145 		printf("Failed to clear input set.\n");
17146 		return;
17147 	}
17148 
17149 #endif
17150 
17151 	if (ret == -ENOTSUP)
17152 		printf("Function not supported\n");
17153 }
17154 
17155 cmdline_parse_token_string_t cmd_clear_input_set_port =
17156 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17157 				 port, "port");
17158 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17159 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17160 				 cfg, "config");
17161 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17162 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17163 			      port_id, UINT16);
17164 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17165 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17166 				 pctype, "pctype");
17167 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17168 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17169 			      pctype_id, UINT8);
17170 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17171 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17172 				 inset_type,
17173 				 "hash_inset#fdir_inset#fdir_flx_inset");
17174 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17175 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17176 				 clear, "clear");
17177 cmdline_parse_token_string_t cmd_clear_input_set_all =
17178 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17179 				 all, "all");
17180 
17181 cmdline_parse_inst_t cmd_clear_input_set = {
17182 	.f = cmd_clear_input_set_parsed,
17183 	.data = NULL,
17184 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17185 		    "fdir_inset|fdir_flx_inset clear all",
17186 	.tokens = {
17187 		(void *)&cmd_clear_input_set_port,
17188 		(void *)&cmd_clear_input_set_cfg,
17189 		(void *)&cmd_clear_input_set_port_id,
17190 		(void *)&cmd_clear_input_set_pctype,
17191 		(void *)&cmd_clear_input_set_pctype_id,
17192 		(void *)&cmd_clear_input_set_inset_type,
17193 		(void *)&cmd_clear_input_set_clear,
17194 		(void *)&cmd_clear_input_set_all,
17195 		NULL,
17196 	},
17197 };
17198 
17199 /* show vf stats */
17200 
17201 /* Common result structure for show vf stats */
17202 struct cmd_show_vf_stats_result {
17203 	cmdline_fixed_string_t show;
17204 	cmdline_fixed_string_t vf;
17205 	cmdline_fixed_string_t stats;
17206 	portid_t port_id;
17207 	uint16_t vf_id;
17208 };
17209 
17210 /* Common CLI fields show vf stats*/
17211 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17212 	TOKEN_STRING_INITIALIZER
17213 		(struct cmd_show_vf_stats_result,
17214 		 show, "show");
17215 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17216 	TOKEN_STRING_INITIALIZER
17217 		(struct cmd_show_vf_stats_result,
17218 		 vf, "vf");
17219 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17220 	TOKEN_STRING_INITIALIZER
17221 		(struct cmd_show_vf_stats_result,
17222 		 stats, "stats");
17223 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17224 	TOKEN_NUM_INITIALIZER
17225 		(struct cmd_show_vf_stats_result,
17226 		 port_id, UINT16);
17227 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17228 	TOKEN_NUM_INITIALIZER
17229 		(struct cmd_show_vf_stats_result,
17230 		 vf_id, UINT16);
17231 
17232 static void
17233 cmd_show_vf_stats_parsed(
17234 	void *parsed_result,
17235 	__rte_unused struct cmdline *cl,
17236 	__rte_unused void *data)
17237 {
17238 	struct cmd_show_vf_stats_result *res = parsed_result;
17239 	struct rte_eth_stats stats;
17240 	int ret = -ENOTSUP;
17241 	static const char *nic_stats_border = "########################";
17242 
17243 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17244 		return;
17245 
17246 	memset(&stats, 0, sizeof(stats));
17247 
17248 #ifdef RTE_LIBRTE_I40E_PMD
17249 	if (ret == -ENOTSUP)
17250 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17251 						res->vf_id,
17252 						&stats);
17253 #endif
17254 #ifdef RTE_LIBRTE_BNXT_PMD
17255 	if (ret == -ENOTSUP)
17256 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17257 						res->vf_id,
17258 						&stats);
17259 #endif
17260 
17261 	switch (ret) {
17262 	case 0:
17263 		break;
17264 	case -EINVAL:
17265 		printf("invalid vf_id %d\n", res->vf_id);
17266 		break;
17267 	case -ENODEV:
17268 		printf("invalid port_id %d\n", res->port_id);
17269 		break;
17270 	case -ENOTSUP:
17271 		printf("function not implemented\n");
17272 		break;
17273 	default:
17274 		printf("programming error: (%s)\n", strerror(-ret));
17275 	}
17276 
17277 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
17278 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17279 
17280 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
17281 	       "%-"PRIu64"\n",
17282 	       stats.ipackets, stats.imissed, stats.ibytes);
17283 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
17284 	printf("  RX-nombuf:  %-10"PRIu64"\n",
17285 	       stats.rx_nombuf);
17286 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
17287 	       "%-"PRIu64"\n",
17288 	       stats.opackets, stats.oerrors, stats.obytes);
17289 
17290 	printf("  %s############################%s\n",
17291 			       nic_stats_border, nic_stats_border);
17292 }
17293 
17294 cmdline_parse_inst_t cmd_show_vf_stats = {
17295 	.f = cmd_show_vf_stats_parsed,
17296 	.data = NULL,
17297 	.help_str = "show vf stats <port_id> <vf_id>",
17298 	.tokens = {
17299 		(void *)&cmd_show_vf_stats_show,
17300 		(void *)&cmd_show_vf_stats_vf,
17301 		(void *)&cmd_show_vf_stats_stats,
17302 		(void *)&cmd_show_vf_stats_port_id,
17303 		(void *)&cmd_show_vf_stats_vf_id,
17304 		NULL,
17305 	},
17306 };
17307 
17308 /* clear vf stats */
17309 
17310 /* Common result structure for clear vf stats */
17311 struct cmd_clear_vf_stats_result {
17312 	cmdline_fixed_string_t clear;
17313 	cmdline_fixed_string_t vf;
17314 	cmdline_fixed_string_t stats;
17315 	portid_t port_id;
17316 	uint16_t vf_id;
17317 };
17318 
17319 /* Common CLI fields clear vf stats*/
17320 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17321 	TOKEN_STRING_INITIALIZER
17322 		(struct cmd_clear_vf_stats_result,
17323 		 clear, "clear");
17324 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17325 	TOKEN_STRING_INITIALIZER
17326 		(struct cmd_clear_vf_stats_result,
17327 		 vf, "vf");
17328 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17329 	TOKEN_STRING_INITIALIZER
17330 		(struct cmd_clear_vf_stats_result,
17331 		 stats, "stats");
17332 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17333 	TOKEN_NUM_INITIALIZER
17334 		(struct cmd_clear_vf_stats_result,
17335 		 port_id, UINT16);
17336 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17337 	TOKEN_NUM_INITIALIZER
17338 		(struct cmd_clear_vf_stats_result,
17339 		 vf_id, UINT16);
17340 
17341 static void
17342 cmd_clear_vf_stats_parsed(
17343 	void *parsed_result,
17344 	__rte_unused struct cmdline *cl,
17345 	__rte_unused void *data)
17346 {
17347 	struct cmd_clear_vf_stats_result *res = parsed_result;
17348 	int ret = -ENOTSUP;
17349 
17350 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17351 		return;
17352 
17353 #ifdef RTE_LIBRTE_I40E_PMD
17354 	if (ret == -ENOTSUP)
17355 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17356 						  res->vf_id);
17357 #endif
17358 #ifdef RTE_LIBRTE_BNXT_PMD
17359 	if (ret == -ENOTSUP)
17360 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17361 						  res->vf_id);
17362 #endif
17363 
17364 	switch (ret) {
17365 	case 0:
17366 		break;
17367 	case -EINVAL:
17368 		printf("invalid vf_id %d\n", res->vf_id);
17369 		break;
17370 	case -ENODEV:
17371 		printf("invalid port_id %d\n", res->port_id);
17372 		break;
17373 	case -ENOTSUP:
17374 		printf("function not implemented\n");
17375 		break;
17376 	default:
17377 		printf("programming error: (%s)\n", strerror(-ret));
17378 	}
17379 }
17380 
17381 cmdline_parse_inst_t cmd_clear_vf_stats = {
17382 	.f = cmd_clear_vf_stats_parsed,
17383 	.data = NULL,
17384 	.help_str = "clear vf stats <port_id> <vf_id>",
17385 	.tokens = {
17386 		(void *)&cmd_clear_vf_stats_clear,
17387 		(void *)&cmd_clear_vf_stats_vf,
17388 		(void *)&cmd_clear_vf_stats_stats,
17389 		(void *)&cmd_clear_vf_stats_port_id,
17390 		(void *)&cmd_clear_vf_stats_vf_id,
17391 		NULL,
17392 	},
17393 };
17394 
17395 /* port config pctype mapping reset */
17396 
17397 /* Common result structure for port config pctype mapping reset */
17398 struct cmd_pctype_mapping_reset_result {
17399 	cmdline_fixed_string_t port;
17400 	cmdline_fixed_string_t config;
17401 	portid_t port_id;
17402 	cmdline_fixed_string_t pctype;
17403 	cmdline_fixed_string_t mapping;
17404 	cmdline_fixed_string_t reset;
17405 };
17406 
17407 /* Common CLI fields for port config pctype mapping reset*/
17408 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17409 	TOKEN_STRING_INITIALIZER
17410 		(struct cmd_pctype_mapping_reset_result,
17411 		 port, "port");
17412 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17413 	TOKEN_STRING_INITIALIZER
17414 		(struct cmd_pctype_mapping_reset_result,
17415 		 config, "config");
17416 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17417 	TOKEN_NUM_INITIALIZER
17418 		(struct cmd_pctype_mapping_reset_result,
17419 		 port_id, UINT16);
17420 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17421 	TOKEN_STRING_INITIALIZER
17422 		(struct cmd_pctype_mapping_reset_result,
17423 		 pctype, "pctype");
17424 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17425 	TOKEN_STRING_INITIALIZER
17426 		(struct cmd_pctype_mapping_reset_result,
17427 		 mapping, "mapping");
17428 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17429 	TOKEN_STRING_INITIALIZER
17430 		(struct cmd_pctype_mapping_reset_result,
17431 		 reset, "reset");
17432 
17433 static void
17434 cmd_pctype_mapping_reset_parsed(
17435 	void *parsed_result,
17436 	__rte_unused struct cmdline *cl,
17437 	__rte_unused void *data)
17438 {
17439 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
17440 	int ret = -ENOTSUP;
17441 
17442 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17443 		return;
17444 
17445 #ifdef RTE_LIBRTE_I40E_PMD
17446 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17447 #endif
17448 
17449 	switch (ret) {
17450 	case 0:
17451 		break;
17452 	case -ENODEV:
17453 		printf("invalid port_id %d\n", res->port_id);
17454 		break;
17455 	case -ENOTSUP:
17456 		printf("function not implemented\n");
17457 		break;
17458 	default:
17459 		printf("programming error: (%s)\n", strerror(-ret));
17460 	}
17461 }
17462 
17463 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17464 	.f = cmd_pctype_mapping_reset_parsed,
17465 	.data = NULL,
17466 	.help_str = "port config <port_id> pctype mapping reset",
17467 	.tokens = {
17468 		(void *)&cmd_pctype_mapping_reset_port,
17469 		(void *)&cmd_pctype_mapping_reset_config,
17470 		(void *)&cmd_pctype_mapping_reset_port_id,
17471 		(void *)&cmd_pctype_mapping_reset_pctype,
17472 		(void *)&cmd_pctype_mapping_reset_mapping,
17473 		(void *)&cmd_pctype_mapping_reset_reset,
17474 		NULL,
17475 	},
17476 };
17477 
17478 /* show port pctype mapping */
17479 
17480 /* Common result structure for show port pctype mapping */
17481 struct cmd_pctype_mapping_get_result {
17482 	cmdline_fixed_string_t show;
17483 	cmdline_fixed_string_t port;
17484 	portid_t port_id;
17485 	cmdline_fixed_string_t pctype;
17486 	cmdline_fixed_string_t mapping;
17487 };
17488 
17489 /* Common CLI fields for pctype mapping get */
17490 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17491 	TOKEN_STRING_INITIALIZER
17492 		(struct cmd_pctype_mapping_get_result,
17493 		 show, "show");
17494 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17495 	TOKEN_STRING_INITIALIZER
17496 		(struct cmd_pctype_mapping_get_result,
17497 		 port, "port");
17498 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17499 	TOKEN_NUM_INITIALIZER
17500 		(struct cmd_pctype_mapping_get_result,
17501 		 port_id, UINT16);
17502 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17503 	TOKEN_STRING_INITIALIZER
17504 		(struct cmd_pctype_mapping_get_result,
17505 		 pctype, "pctype");
17506 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17507 	TOKEN_STRING_INITIALIZER
17508 		(struct cmd_pctype_mapping_get_result,
17509 		 mapping, "mapping");
17510 
17511 static void
17512 cmd_pctype_mapping_get_parsed(
17513 	void *parsed_result,
17514 	__rte_unused struct cmdline *cl,
17515 	__rte_unused void *data)
17516 {
17517 	struct cmd_pctype_mapping_get_result *res = parsed_result;
17518 	int ret = -ENOTSUP;
17519 #ifdef RTE_LIBRTE_I40E_PMD
17520 	struct rte_pmd_i40e_flow_type_mapping
17521 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17522 	int i, j, first_pctype;
17523 #endif
17524 
17525 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17526 		return;
17527 
17528 #ifdef RTE_LIBRTE_I40E_PMD
17529 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17530 #endif
17531 
17532 	switch (ret) {
17533 	case 0:
17534 		break;
17535 	case -ENODEV:
17536 		printf("invalid port_id %d\n", res->port_id);
17537 		return;
17538 	case -ENOTSUP:
17539 		printf("function not implemented\n");
17540 		return;
17541 	default:
17542 		printf("programming error: (%s)\n", strerror(-ret));
17543 		return;
17544 	}
17545 
17546 #ifdef RTE_LIBRTE_I40E_PMD
17547 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17548 		if (mapping[i].pctype != 0ULL) {
17549 			first_pctype = 1;
17550 
17551 			printf("pctype: ");
17552 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17553 				if (mapping[i].pctype & (1ULL << j)) {
17554 					printf(first_pctype ?
17555 					       "%02d" : ",%02d", j);
17556 					first_pctype = 0;
17557 				}
17558 			}
17559 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
17560 		}
17561 	}
17562 #endif
17563 }
17564 
17565 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17566 	.f = cmd_pctype_mapping_get_parsed,
17567 	.data = NULL,
17568 	.help_str = "show port <port_id> pctype mapping",
17569 	.tokens = {
17570 		(void *)&cmd_pctype_mapping_get_show,
17571 		(void *)&cmd_pctype_mapping_get_port,
17572 		(void *)&cmd_pctype_mapping_get_port_id,
17573 		(void *)&cmd_pctype_mapping_get_pctype,
17574 		(void *)&cmd_pctype_mapping_get_mapping,
17575 		NULL,
17576 	},
17577 };
17578 
17579 /* port config pctype mapping update */
17580 
17581 /* Common result structure for port config pctype mapping update */
17582 struct cmd_pctype_mapping_update_result {
17583 	cmdline_fixed_string_t port;
17584 	cmdline_fixed_string_t config;
17585 	portid_t port_id;
17586 	cmdline_fixed_string_t pctype;
17587 	cmdline_fixed_string_t mapping;
17588 	cmdline_fixed_string_t update;
17589 	cmdline_fixed_string_t pctype_list;
17590 	uint16_t flow_type;
17591 };
17592 
17593 /* Common CLI fields for pctype mapping update*/
17594 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17595 	TOKEN_STRING_INITIALIZER
17596 		(struct cmd_pctype_mapping_update_result,
17597 		 port, "port");
17598 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17599 	TOKEN_STRING_INITIALIZER
17600 		(struct cmd_pctype_mapping_update_result,
17601 		 config, "config");
17602 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17603 	TOKEN_NUM_INITIALIZER
17604 		(struct cmd_pctype_mapping_update_result,
17605 		 port_id, UINT16);
17606 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17607 	TOKEN_STRING_INITIALIZER
17608 		(struct cmd_pctype_mapping_update_result,
17609 		 pctype, "pctype");
17610 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17611 	TOKEN_STRING_INITIALIZER
17612 		(struct cmd_pctype_mapping_update_result,
17613 		 mapping, "mapping");
17614 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17615 	TOKEN_STRING_INITIALIZER
17616 		(struct cmd_pctype_mapping_update_result,
17617 		 update, "update");
17618 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17619 	TOKEN_STRING_INITIALIZER
17620 		(struct cmd_pctype_mapping_update_result,
17621 		 pctype_list, NULL);
17622 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17623 	TOKEN_NUM_INITIALIZER
17624 		(struct cmd_pctype_mapping_update_result,
17625 		 flow_type, UINT16);
17626 
17627 static void
17628 cmd_pctype_mapping_update_parsed(
17629 	void *parsed_result,
17630 	__rte_unused struct cmdline *cl,
17631 	__rte_unused void *data)
17632 {
17633 	struct cmd_pctype_mapping_update_result *res = parsed_result;
17634 	int ret = -ENOTSUP;
17635 #ifdef RTE_LIBRTE_I40E_PMD
17636 	struct rte_pmd_i40e_flow_type_mapping mapping;
17637 	unsigned int i;
17638 	unsigned int nb_item;
17639 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17640 #endif
17641 
17642 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17643 		return;
17644 
17645 #ifdef RTE_LIBRTE_I40E_PMD
17646 	nb_item = parse_item_list(res->pctype_list, "pctypes",
17647 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17648 	mapping.flow_type = res->flow_type;
17649 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17650 		mapping.pctype |= (1ULL << pctype_list[i]);
17651 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17652 						&mapping,
17653 						1,
17654 						0);
17655 #endif
17656 
17657 	switch (ret) {
17658 	case 0:
17659 		break;
17660 	case -EINVAL:
17661 		printf("invalid pctype or flow type\n");
17662 		break;
17663 	case -ENODEV:
17664 		printf("invalid port_id %d\n", res->port_id);
17665 		break;
17666 	case -ENOTSUP:
17667 		printf("function not implemented\n");
17668 		break;
17669 	default:
17670 		printf("programming error: (%s)\n", strerror(-ret));
17671 	}
17672 }
17673 
17674 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17675 	.f = cmd_pctype_mapping_update_parsed,
17676 	.data = NULL,
17677 	.help_str = "port config <port_id> pctype mapping update"
17678 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17679 	.tokens = {
17680 		(void *)&cmd_pctype_mapping_update_port,
17681 		(void *)&cmd_pctype_mapping_update_config,
17682 		(void *)&cmd_pctype_mapping_update_port_id,
17683 		(void *)&cmd_pctype_mapping_update_pctype,
17684 		(void *)&cmd_pctype_mapping_update_mapping,
17685 		(void *)&cmd_pctype_mapping_update_update,
17686 		(void *)&cmd_pctype_mapping_update_pc_type,
17687 		(void *)&cmd_pctype_mapping_update_flow_type,
17688 		NULL,
17689 	},
17690 };
17691 
17692 /* ptype mapping get */
17693 
17694 /* Common result structure for ptype mapping get */
17695 struct cmd_ptype_mapping_get_result {
17696 	cmdline_fixed_string_t ptype;
17697 	cmdline_fixed_string_t mapping;
17698 	cmdline_fixed_string_t get;
17699 	portid_t port_id;
17700 	uint8_t valid_only;
17701 };
17702 
17703 /* Common CLI fields for ptype mapping get */
17704 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17705 	TOKEN_STRING_INITIALIZER
17706 		(struct cmd_ptype_mapping_get_result,
17707 		 ptype, "ptype");
17708 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17709 	TOKEN_STRING_INITIALIZER
17710 		(struct cmd_ptype_mapping_get_result,
17711 		 mapping, "mapping");
17712 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17713 	TOKEN_STRING_INITIALIZER
17714 		(struct cmd_ptype_mapping_get_result,
17715 		 get, "get");
17716 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17717 	TOKEN_NUM_INITIALIZER
17718 		(struct cmd_ptype_mapping_get_result,
17719 		 port_id, UINT16);
17720 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17721 	TOKEN_NUM_INITIALIZER
17722 		(struct cmd_ptype_mapping_get_result,
17723 		 valid_only, UINT8);
17724 
17725 static void
17726 cmd_ptype_mapping_get_parsed(
17727 	void *parsed_result,
17728 	__rte_unused struct cmdline *cl,
17729 	__rte_unused void *data)
17730 {
17731 	struct cmd_ptype_mapping_get_result *res = parsed_result;
17732 	int ret = -ENOTSUP;
17733 #ifdef RTE_LIBRTE_I40E_PMD
17734 	int max_ptype_num = 256;
17735 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17736 	uint16_t count;
17737 	int i;
17738 #endif
17739 
17740 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17741 		return;
17742 
17743 #ifdef RTE_LIBRTE_I40E_PMD
17744 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17745 					mapping,
17746 					max_ptype_num,
17747 					&count,
17748 					res->valid_only);
17749 #endif
17750 
17751 	switch (ret) {
17752 	case 0:
17753 		break;
17754 	case -ENODEV:
17755 		printf("invalid port_id %d\n", res->port_id);
17756 		break;
17757 	case -ENOTSUP:
17758 		printf("function not implemented\n");
17759 		break;
17760 	default:
17761 		printf("programming error: (%s)\n", strerror(-ret));
17762 	}
17763 
17764 #ifdef RTE_LIBRTE_I40E_PMD
17765 	if (!ret) {
17766 		for (i = 0; i < count; i++)
17767 			printf("%3d\t0x%08x\n",
17768 				mapping[i].hw_ptype, mapping[i].sw_ptype);
17769 	}
17770 #endif
17771 }
17772 
17773 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17774 	.f = cmd_ptype_mapping_get_parsed,
17775 	.data = NULL,
17776 	.help_str = "ptype mapping get <port_id> <valid_only>",
17777 	.tokens = {
17778 		(void *)&cmd_ptype_mapping_get_ptype,
17779 		(void *)&cmd_ptype_mapping_get_mapping,
17780 		(void *)&cmd_ptype_mapping_get_get,
17781 		(void *)&cmd_ptype_mapping_get_port_id,
17782 		(void *)&cmd_ptype_mapping_get_valid_only,
17783 		NULL,
17784 	},
17785 };
17786 
17787 /* ptype mapping replace */
17788 
17789 /* Common result structure for ptype mapping replace */
17790 struct cmd_ptype_mapping_replace_result {
17791 	cmdline_fixed_string_t ptype;
17792 	cmdline_fixed_string_t mapping;
17793 	cmdline_fixed_string_t replace;
17794 	portid_t port_id;
17795 	uint32_t target;
17796 	uint8_t mask;
17797 	uint32_t pkt_type;
17798 };
17799 
17800 /* Common CLI fields for ptype mapping replace */
17801 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17802 	TOKEN_STRING_INITIALIZER
17803 		(struct cmd_ptype_mapping_replace_result,
17804 		 ptype, "ptype");
17805 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17806 	TOKEN_STRING_INITIALIZER
17807 		(struct cmd_ptype_mapping_replace_result,
17808 		 mapping, "mapping");
17809 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17810 	TOKEN_STRING_INITIALIZER
17811 		(struct cmd_ptype_mapping_replace_result,
17812 		 replace, "replace");
17813 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17814 	TOKEN_NUM_INITIALIZER
17815 		(struct cmd_ptype_mapping_replace_result,
17816 		 port_id, UINT16);
17817 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17818 	TOKEN_NUM_INITIALIZER
17819 		(struct cmd_ptype_mapping_replace_result,
17820 		 target, UINT32);
17821 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17822 	TOKEN_NUM_INITIALIZER
17823 		(struct cmd_ptype_mapping_replace_result,
17824 		 mask, UINT8);
17825 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17826 	TOKEN_NUM_INITIALIZER
17827 		(struct cmd_ptype_mapping_replace_result,
17828 		 pkt_type, UINT32);
17829 
17830 static void
17831 cmd_ptype_mapping_replace_parsed(
17832 	void *parsed_result,
17833 	__rte_unused struct cmdline *cl,
17834 	__rte_unused void *data)
17835 {
17836 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
17837 	int ret = -ENOTSUP;
17838 
17839 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17840 		return;
17841 
17842 #ifdef RTE_LIBRTE_I40E_PMD
17843 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17844 					res->target,
17845 					res->mask,
17846 					res->pkt_type);
17847 #endif
17848 
17849 	switch (ret) {
17850 	case 0:
17851 		break;
17852 	case -EINVAL:
17853 		printf("invalid ptype 0x%8x or 0x%8x\n",
17854 				res->target, res->pkt_type);
17855 		break;
17856 	case -ENODEV:
17857 		printf("invalid port_id %d\n", res->port_id);
17858 		break;
17859 	case -ENOTSUP:
17860 		printf("function not implemented\n");
17861 		break;
17862 	default:
17863 		printf("programming error: (%s)\n", strerror(-ret));
17864 	}
17865 }
17866 
17867 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17868 	.f = cmd_ptype_mapping_replace_parsed,
17869 	.data = NULL,
17870 	.help_str =
17871 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17872 	.tokens = {
17873 		(void *)&cmd_ptype_mapping_replace_ptype,
17874 		(void *)&cmd_ptype_mapping_replace_mapping,
17875 		(void *)&cmd_ptype_mapping_replace_replace,
17876 		(void *)&cmd_ptype_mapping_replace_port_id,
17877 		(void *)&cmd_ptype_mapping_replace_target,
17878 		(void *)&cmd_ptype_mapping_replace_mask,
17879 		(void *)&cmd_ptype_mapping_replace_pkt_type,
17880 		NULL,
17881 	},
17882 };
17883 
17884 /* ptype mapping reset */
17885 
17886 /* Common result structure for ptype mapping reset */
17887 struct cmd_ptype_mapping_reset_result {
17888 	cmdline_fixed_string_t ptype;
17889 	cmdline_fixed_string_t mapping;
17890 	cmdline_fixed_string_t reset;
17891 	portid_t port_id;
17892 };
17893 
17894 /* Common CLI fields for ptype mapping reset*/
17895 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17896 	TOKEN_STRING_INITIALIZER
17897 		(struct cmd_ptype_mapping_reset_result,
17898 		 ptype, "ptype");
17899 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17900 	TOKEN_STRING_INITIALIZER
17901 		(struct cmd_ptype_mapping_reset_result,
17902 		 mapping, "mapping");
17903 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17904 	TOKEN_STRING_INITIALIZER
17905 		(struct cmd_ptype_mapping_reset_result,
17906 		 reset, "reset");
17907 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17908 	TOKEN_NUM_INITIALIZER
17909 		(struct cmd_ptype_mapping_reset_result,
17910 		 port_id, UINT16);
17911 
17912 static void
17913 cmd_ptype_mapping_reset_parsed(
17914 	void *parsed_result,
17915 	__rte_unused struct cmdline *cl,
17916 	__rte_unused void *data)
17917 {
17918 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
17919 	int ret = -ENOTSUP;
17920 
17921 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17922 		return;
17923 
17924 #ifdef RTE_LIBRTE_I40E_PMD
17925 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17926 #endif
17927 
17928 	switch (ret) {
17929 	case 0:
17930 		break;
17931 	case -ENODEV:
17932 		printf("invalid port_id %d\n", res->port_id);
17933 		break;
17934 	case -ENOTSUP:
17935 		printf("function not implemented\n");
17936 		break;
17937 	default:
17938 		printf("programming error: (%s)\n", strerror(-ret));
17939 	}
17940 }
17941 
17942 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17943 	.f = cmd_ptype_mapping_reset_parsed,
17944 	.data = NULL,
17945 	.help_str = "ptype mapping reset <port_id>",
17946 	.tokens = {
17947 		(void *)&cmd_ptype_mapping_reset_ptype,
17948 		(void *)&cmd_ptype_mapping_reset_mapping,
17949 		(void *)&cmd_ptype_mapping_reset_reset,
17950 		(void *)&cmd_ptype_mapping_reset_port_id,
17951 		NULL,
17952 	},
17953 };
17954 
17955 /* ptype mapping update */
17956 
17957 /* Common result structure for ptype mapping update */
17958 struct cmd_ptype_mapping_update_result {
17959 	cmdline_fixed_string_t ptype;
17960 	cmdline_fixed_string_t mapping;
17961 	cmdline_fixed_string_t reset;
17962 	portid_t port_id;
17963 	uint8_t hw_ptype;
17964 	uint32_t sw_ptype;
17965 };
17966 
17967 /* Common CLI fields for ptype mapping update*/
17968 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17969 	TOKEN_STRING_INITIALIZER
17970 		(struct cmd_ptype_mapping_update_result,
17971 		 ptype, "ptype");
17972 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17973 	TOKEN_STRING_INITIALIZER
17974 		(struct cmd_ptype_mapping_update_result,
17975 		 mapping, "mapping");
17976 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17977 	TOKEN_STRING_INITIALIZER
17978 		(struct cmd_ptype_mapping_update_result,
17979 		 reset, "update");
17980 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17981 	TOKEN_NUM_INITIALIZER
17982 		(struct cmd_ptype_mapping_update_result,
17983 		 port_id, UINT16);
17984 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17985 	TOKEN_NUM_INITIALIZER
17986 		(struct cmd_ptype_mapping_update_result,
17987 		 hw_ptype, UINT8);
17988 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17989 	TOKEN_NUM_INITIALIZER
17990 		(struct cmd_ptype_mapping_update_result,
17991 		 sw_ptype, UINT32);
17992 
17993 static void
17994 cmd_ptype_mapping_update_parsed(
17995 	void *parsed_result,
17996 	__rte_unused struct cmdline *cl,
17997 	__rte_unused void *data)
17998 {
17999 	struct cmd_ptype_mapping_update_result *res = parsed_result;
18000 	int ret = -ENOTSUP;
18001 #ifdef RTE_LIBRTE_I40E_PMD
18002 	struct rte_pmd_i40e_ptype_mapping mapping;
18003 #endif
18004 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18005 		return;
18006 
18007 #ifdef RTE_LIBRTE_I40E_PMD
18008 	mapping.hw_ptype = res->hw_ptype;
18009 	mapping.sw_ptype = res->sw_ptype;
18010 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18011 						&mapping,
18012 						1,
18013 						0);
18014 #endif
18015 
18016 	switch (ret) {
18017 	case 0:
18018 		break;
18019 	case -EINVAL:
18020 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
18021 		break;
18022 	case -ENODEV:
18023 		printf("invalid port_id %d\n", res->port_id);
18024 		break;
18025 	case -ENOTSUP:
18026 		printf("function not implemented\n");
18027 		break;
18028 	default:
18029 		printf("programming error: (%s)\n", strerror(-ret));
18030 	}
18031 }
18032 
18033 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18034 	.f = cmd_ptype_mapping_update_parsed,
18035 	.data = NULL,
18036 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18037 	.tokens = {
18038 		(void *)&cmd_ptype_mapping_update_ptype,
18039 		(void *)&cmd_ptype_mapping_update_mapping,
18040 		(void *)&cmd_ptype_mapping_update_update,
18041 		(void *)&cmd_ptype_mapping_update_port_id,
18042 		(void *)&cmd_ptype_mapping_update_hw_ptype,
18043 		(void *)&cmd_ptype_mapping_update_sw_ptype,
18044 		NULL,
18045 	},
18046 };
18047 
18048 /* Common result structure for file commands */
18049 struct cmd_cmdfile_result {
18050 	cmdline_fixed_string_t load;
18051 	cmdline_fixed_string_t filename;
18052 };
18053 
18054 /* Common CLI fields for file commands */
18055 cmdline_parse_token_string_t cmd_load_cmdfile =
18056 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18057 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18058 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18059 
18060 static void
18061 cmd_load_from_file_parsed(
18062 	void *parsed_result,
18063 	__rte_unused struct cmdline *cl,
18064 	__rte_unused void *data)
18065 {
18066 	struct cmd_cmdfile_result *res = parsed_result;
18067 
18068 	cmdline_read_from_file(res->filename);
18069 }
18070 
18071 cmdline_parse_inst_t cmd_load_from_file = {
18072 	.f = cmd_load_from_file_parsed,
18073 	.data = NULL,
18074 	.help_str = "load <filename>",
18075 	.tokens = {
18076 		(void *)&cmd_load_cmdfile,
18077 		(void *)&cmd_load_cmdfile_filename,
18078 		NULL,
18079 	},
18080 };
18081 
18082 /* Get Rx offloads capabilities */
18083 struct cmd_rx_offload_get_capa_result {
18084 	cmdline_fixed_string_t show;
18085 	cmdline_fixed_string_t port;
18086 	portid_t port_id;
18087 	cmdline_fixed_string_t rx_offload;
18088 	cmdline_fixed_string_t capabilities;
18089 };
18090 
18091 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18092 	TOKEN_STRING_INITIALIZER
18093 		(struct cmd_rx_offload_get_capa_result,
18094 		 show, "show");
18095 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18096 	TOKEN_STRING_INITIALIZER
18097 		(struct cmd_rx_offload_get_capa_result,
18098 		 port, "port");
18099 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18100 	TOKEN_NUM_INITIALIZER
18101 		(struct cmd_rx_offload_get_capa_result,
18102 		 port_id, UINT16);
18103 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18104 	TOKEN_STRING_INITIALIZER
18105 		(struct cmd_rx_offload_get_capa_result,
18106 		 rx_offload, "rx_offload");
18107 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18108 	TOKEN_STRING_INITIALIZER
18109 		(struct cmd_rx_offload_get_capa_result,
18110 		 capabilities, "capabilities");
18111 
18112 static void
18113 print_rx_offloads(uint64_t offloads)
18114 {
18115 	uint64_t single_offload;
18116 	int begin;
18117 	int end;
18118 	int bit;
18119 
18120 	if (offloads == 0)
18121 		return;
18122 
18123 	begin = __builtin_ctzll(offloads);
18124 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18125 
18126 	single_offload = 1ULL << begin;
18127 	for (bit = begin; bit < end; bit++) {
18128 		if (offloads & single_offload)
18129 			printf(" %s",
18130 			       rte_eth_dev_rx_offload_name(single_offload));
18131 		single_offload <<= 1;
18132 	}
18133 }
18134 
18135 static void
18136 cmd_rx_offload_get_capa_parsed(
18137 	void *parsed_result,
18138 	__rte_unused struct cmdline *cl,
18139 	__rte_unused void *data)
18140 {
18141 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
18142 	struct rte_eth_dev_info dev_info;
18143 	portid_t port_id = res->port_id;
18144 	uint64_t queue_offloads;
18145 	uint64_t port_offloads;
18146 	int ret;
18147 
18148 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18149 	if (ret != 0)
18150 		return;
18151 
18152 	queue_offloads = dev_info.rx_queue_offload_capa;
18153 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18154 
18155 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
18156 	printf("  Per Queue :");
18157 	print_rx_offloads(queue_offloads);
18158 
18159 	printf("\n");
18160 	printf("  Per Port  :");
18161 	print_rx_offloads(port_offloads);
18162 	printf("\n\n");
18163 }
18164 
18165 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18166 	.f = cmd_rx_offload_get_capa_parsed,
18167 	.data = NULL,
18168 	.help_str = "show port <port_id> rx_offload capabilities",
18169 	.tokens = {
18170 		(void *)&cmd_rx_offload_get_capa_show,
18171 		(void *)&cmd_rx_offload_get_capa_port,
18172 		(void *)&cmd_rx_offload_get_capa_port_id,
18173 		(void *)&cmd_rx_offload_get_capa_rx_offload,
18174 		(void *)&cmd_rx_offload_get_capa_capabilities,
18175 		NULL,
18176 	}
18177 };
18178 
18179 /* Get Rx offloads configuration */
18180 struct cmd_rx_offload_get_configuration_result {
18181 	cmdline_fixed_string_t show;
18182 	cmdline_fixed_string_t port;
18183 	portid_t port_id;
18184 	cmdline_fixed_string_t rx_offload;
18185 	cmdline_fixed_string_t configuration;
18186 };
18187 
18188 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18189 	TOKEN_STRING_INITIALIZER
18190 		(struct cmd_rx_offload_get_configuration_result,
18191 		 show, "show");
18192 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18193 	TOKEN_STRING_INITIALIZER
18194 		(struct cmd_rx_offload_get_configuration_result,
18195 		 port, "port");
18196 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18197 	TOKEN_NUM_INITIALIZER
18198 		(struct cmd_rx_offload_get_configuration_result,
18199 		 port_id, UINT16);
18200 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18201 	TOKEN_STRING_INITIALIZER
18202 		(struct cmd_rx_offload_get_configuration_result,
18203 		 rx_offload, "rx_offload");
18204 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18205 	TOKEN_STRING_INITIALIZER
18206 		(struct cmd_rx_offload_get_configuration_result,
18207 		 configuration, "configuration");
18208 
18209 static void
18210 cmd_rx_offload_get_configuration_parsed(
18211 	void *parsed_result,
18212 	__rte_unused struct cmdline *cl,
18213 	__rte_unused void *data)
18214 {
18215 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18216 	struct rte_eth_dev_info dev_info;
18217 	portid_t port_id = res->port_id;
18218 	struct rte_port *port = &ports[port_id];
18219 	uint64_t port_offloads;
18220 	uint64_t queue_offloads;
18221 	uint16_t nb_rx_queues;
18222 	int q;
18223 	int ret;
18224 
18225 	printf("Rx Offloading Configuration of port %d :\n", port_id);
18226 
18227 	port_offloads = port->dev_conf.rxmode.offloads;
18228 	printf("  Port :");
18229 	print_rx_offloads(port_offloads);
18230 	printf("\n");
18231 
18232 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18233 	if (ret != 0)
18234 		return;
18235 
18236 	nb_rx_queues = dev_info.nb_rx_queues;
18237 	for (q = 0; q < nb_rx_queues; q++) {
18238 		queue_offloads = port->rx_conf[q].offloads;
18239 		printf("  Queue[%2d] :", q);
18240 		print_rx_offloads(queue_offloads);
18241 		printf("\n");
18242 	}
18243 	printf("\n");
18244 }
18245 
18246 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18247 	.f = cmd_rx_offload_get_configuration_parsed,
18248 	.data = NULL,
18249 	.help_str = "show port <port_id> rx_offload configuration",
18250 	.tokens = {
18251 		(void *)&cmd_rx_offload_get_configuration_show,
18252 		(void *)&cmd_rx_offload_get_configuration_port,
18253 		(void *)&cmd_rx_offload_get_configuration_port_id,
18254 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
18255 		(void *)&cmd_rx_offload_get_configuration_configuration,
18256 		NULL,
18257 	}
18258 };
18259 
18260 /* Enable/Disable a per port offloading */
18261 struct cmd_config_per_port_rx_offload_result {
18262 	cmdline_fixed_string_t port;
18263 	cmdline_fixed_string_t config;
18264 	portid_t port_id;
18265 	cmdline_fixed_string_t rx_offload;
18266 	cmdline_fixed_string_t offload;
18267 	cmdline_fixed_string_t on_off;
18268 };
18269 
18270 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18271 	TOKEN_STRING_INITIALIZER
18272 		(struct cmd_config_per_port_rx_offload_result,
18273 		 port, "port");
18274 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18275 	TOKEN_STRING_INITIALIZER
18276 		(struct cmd_config_per_port_rx_offload_result,
18277 		 config, "config");
18278 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18279 	TOKEN_NUM_INITIALIZER
18280 		(struct cmd_config_per_port_rx_offload_result,
18281 		 port_id, UINT16);
18282 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18283 	TOKEN_STRING_INITIALIZER
18284 		(struct cmd_config_per_port_rx_offload_result,
18285 		 rx_offload, "rx_offload");
18286 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18287 	TOKEN_STRING_INITIALIZER
18288 		(struct cmd_config_per_port_rx_offload_result,
18289 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18290 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18291 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18292 			   "scatter#timestamp#security#keep_crc#rss_hash");
18293 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18294 	TOKEN_STRING_INITIALIZER
18295 		(struct cmd_config_per_port_rx_offload_result,
18296 		 on_off, "on#off");
18297 
18298 static uint64_t
18299 search_rx_offload(const char *name)
18300 {
18301 	uint64_t single_offload;
18302 	const char *single_name;
18303 	int found = 0;
18304 	unsigned int bit;
18305 
18306 	single_offload = 1;
18307 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18308 		single_name = rte_eth_dev_rx_offload_name(single_offload);
18309 		if (!strcasecmp(single_name, name)) {
18310 			found = 1;
18311 			break;
18312 		}
18313 		single_offload <<= 1;
18314 	}
18315 
18316 	if (found)
18317 		return single_offload;
18318 
18319 	return 0;
18320 }
18321 
18322 static void
18323 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18324 				__rte_unused struct cmdline *cl,
18325 				__rte_unused void *data)
18326 {
18327 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18328 	portid_t port_id = res->port_id;
18329 	struct rte_eth_dev_info dev_info;
18330 	struct rte_port *port = &ports[port_id];
18331 	uint64_t single_offload;
18332 	uint16_t nb_rx_queues;
18333 	int q;
18334 	int ret;
18335 
18336 	if (port->port_status != RTE_PORT_STOPPED) {
18337 		printf("Error: Can't config offload when Port %d "
18338 		       "is not stopped\n", port_id);
18339 		return;
18340 	}
18341 
18342 	single_offload = search_rx_offload(res->offload);
18343 	if (single_offload == 0) {
18344 		printf("Unknown offload name: %s\n", res->offload);
18345 		return;
18346 	}
18347 
18348 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18349 	if (ret != 0)
18350 		return;
18351 
18352 	nb_rx_queues = dev_info.nb_rx_queues;
18353 	if (!strcmp(res->on_off, "on")) {
18354 		port->dev_conf.rxmode.offloads |= single_offload;
18355 		for (q = 0; q < nb_rx_queues; q++)
18356 			port->rx_conf[q].offloads |= single_offload;
18357 	} else {
18358 		port->dev_conf.rxmode.offloads &= ~single_offload;
18359 		for (q = 0; q < nb_rx_queues; q++)
18360 			port->rx_conf[q].offloads &= ~single_offload;
18361 	}
18362 
18363 	cmd_reconfig_device_queue(port_id, 1, 1);
18364 }
18365 
18366 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18367 	.f = cmd_config_per_port_rx_offload_parsed,
18368 	.data = NULL,
18369 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18370 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18371 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18372 		    "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18373 		    "on|off",
18374 	.tokens = {
18375 		(void *)&cmd_config_per_port_rx_offload_result_port,
18376 		(void *)&cmd_config_per_port_rx_offload_result_config,
18377 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
18378 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18379 		(void *)&cmd_config_per_port_rx_offload_result_offload,
18380 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
18381 		NULL,
18382 	}
18383 };
18384 
18385 /* Enable/Disable a per queue offloading */
18386 struct cmd_config_per_queue_rx_offload_result {
18387 	cmdline_fixed_string_t port;
18388 	portid_t port_id;
18389 	cmdline_fixed_string_t rxq;
18390 	uint16_t queue_id;
18391 	cmdline_fixed_string_t rx_offload;
18392 	cmdline_fixed_string_t offload;
18393 	cmdline_fixed_string_t on_off;
18394 };
18395 
18396 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18397 	TOKEN_STRING_INITIALIZER
18398 		(struct cmd_config_per_queue_rx_offload_result,
18399 		 port, "port");
18400 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18401 	TOKEN_NUM_INITIALIZER
18402 		(struct cmd_config_per_queue_rx_offload_result,
18403 		 port_id, UINT16);
18404 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18405 	TOKEN_STRING_INITIALIZER
18406 		(struct cmd_config_per_queue_rx_offload_result,
18407 		 rxq, "rxq");
18408 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18409 	TOKEN_NUM_INITIALIZER
18410 		(struct cmd_config_per_queue_rx_offload_result,
18411 		 queue_id, UINT16);
18412 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18413 	TOKEN_STRING_INITIALIZER
18414 		(struct cmd_config_per_queue_rx_offload_result,
18415 		 rx_offload, "rx_offload");
18416 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18417 	TOKEN_STRING_INITIALIZER
18418 		(struct cmd_config_per_queue_rx_offload_result,
18419 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18420 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18421 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18422 			   "scatter#timestamp#security#keep_crc");
18423 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18424 	TOKEN_STRING_INITIALIZER
18425 		(struct cmd_config_per_queue_rx_offload_result,
18426 		 on_off, "on#off");
18427 
18428 static void
18429 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18430 				__rte_unused struct cmdline *cl,
18431 				__rte_unused void *data)
18432 {
18433 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18434 	struct rte_eth_dev_info dev_info;
18435 	portid_t port_id = res->port_id;
18436 	uint16_t queue_id = res->queue_id;
18437 	struct rte_port *port = &ports[port_id];
18438 	uint64_t single_offload;
18439 	int ret;
18440 
18441 	if (port->port_status != RTE_PORT_STOPPED) {
18442 		printf("Error: Can't config offload when Port %d "
18443 		       "is not stopped\n", port_id);
18444 		return;
18445 	}
18446 
18447 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18448 	if (ret != 0)
18449 		return;
18450 
18451 	if (queue_id >= dev_info.nb_rx_queues) {
18452 		printf("Error: input queue_id should be 0 ... "
18453 		       "%d\n", dev_info.nb_rx_queues - 1);
18454 		return;
18455 	}
18456 
18457 	single_offload = search_rx_offload(res->offload);
18458 	if (single_offload == 0) {
18459 		printf("Unknown offload name: %s\n", res->offload);
18460 		return;
18461 	}
18462 
18463 	if (!strcmp(res->on_off, "on"))
18464 		port->rx_conf[queue_id].offloads |= single_offload;
18465 	else
18466 		port->rx_conf[queue_id].offloads &= ~single_offload;
18467 
18468 	cmd_reconfig_device_queue(port_id, 1, 1);
18469 }
18470 
18471 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18472 	.f = cmd_config_per_queue_rx_offload_parsed,
18473 	.data = NULL,
18474 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
18475 		    "vlan_strip|ipv4_cksum|"
18476 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18477 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18478 		    "jumbo_frame|scatter|timestamp|security|keep_crc "
18479 		    "on|off",
18480 	.tokens = {
18481 		(void *)&cmd_config_per_queue_rx_offload_result_port,
18482 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
18483 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
18484 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18485 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18486 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
18487 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
18488 		NULL,
18489 	}
18490 };
18491 
18492 /* Get Tx offloads capabilities */
18493 struct cmd_tx_offload_get_capa_result {
18494 	cmdline_fixed_string_t show;
18495 	cmdline_fixed_string_t port;
18496 	portid_t port_id;
18497 	cmdline_fixed_string_t tx_offload;
18498 	cmdline_fixed_string_t capabilities;
18499 };
18500 
18501 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18502 	TOKEN_STRING_INITIALIZER
18503 		(struct cmd_tx_offload_get_capa_result,
18504 		 show, "show");
18505 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18506 	TOKEN_STRING_INITIALIZER
18507 		(struct cmd_tx_offload_get_capa_result,
18508 		 port, "port");
18509 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18510 	TOKEN_NUM_INITIALIZER
18511 		(struct cmd_tx_offload_get_capa_result,
18512 		 port_id, UINT16);
18513 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18514 	TOKEN_STRING_INITIALIZER
18515 		(struct cmd_tx_offload_get_capa_result,
18516 		 tx_offload, "tx_offload");
18517 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18518 	TOKEN_STRING_INITIALIZER
18519 		(struct cmd_tx_offload_get_capa_result,
18520 		 capabilities, "capabilities");
18521 
18522 static void
18523 print_tx_offloads(uint64_t offloads)
18524 {
18525 	uint64_t single_offload;
18526 	int begin;
18527 	int end;
18528 	int bit;
18529 
18530 	if (offloads == 0)
18531 		return;
18532 
18533 	begin = __builtin_ctzll(offloads);
18534 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18535 
18536 	single_offload = 1ULL << begin;
18537 	for (bit = begin; bit < end; bit++) {
18538 		if (offloads & single_offload)
18539 			printf(" %s",
18540 			       rte_eth_dev_tx_offload_name(single_offload));
18541 		single_offload <<= 1;
18542 	}
18543 }
18544 
18545 static void
18546 cmd_tx_offload_get_capa_parsed(
18547 	void *parsed_result,
18548 	__rte_unused struct cmdline *cl,
18549 	__rte_unused void *data)
18550 {
18551 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
18552 	struct rte_eth_dev_info dev_info;
18553 	portid_t port_id = res->port_id;
18554 	uint64_t queue_offloads;
18555 	uint64_t port_offloads;
18556 	int ret;
18557 
18558 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18559 	if (ret != 0)
18560 		return;
18561 
18562 	queue_offloads = dev_info.tx_queue_offload_capa;
18563 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18564 
18565 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
18566 	printf("  Per Queue :");
18567 	print_tx_offloads(queue_offloads);
18568 
18569 	printf("\n");
18570 	printf("  Per Port  :");
18571 	print_tx_offloads(port_offloads);
18572 	printf("\n\n");
18573 }
18574 
18575 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18576 	.f = cmd_tx_offload_get_capa_parsed,
18577 	.data = NULL,
18578 	.help_str = "show port <port_id> tx_offload capabilities",
18579 	.tokens = {
18580 		(void *)&cmd_tx_offload_get_capa_show,
18581 		(void *)&cmd_tx_offload_get_capa_port,
18582 		(void *)&cmd_tx_offload_get_capa_port_id,
18583 		(void *)&cmd_tx_offload_get_capa_tx_offload,
18584 		(void *)&cmd_tx_offload_get_capa_capabilities,
18585 		NULL,
18586 	}
18587 };
18588 
18589 /* Get Tx offloads configuration */
18590 struct cmd_tx_offload_get_configuration_result {
18591 	cmdline_fixed_string_t show;
18592 	cmdline_fixed_string_t port;
18593 	portid_t port_id;
18594 	cmdline_fixed_string_t tx_offload;
18595 	cmdline_fixed_string_t configuration;
18596 };
18597 
18598 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18599 	TOKEN_STRING_INITIALIZER
18600 		(struct cmd_tx_offload_get_configuration_result,
18601 		 show, "show");
18602 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18603 	TOKEN_STRING_INITIALIZER
18604 		(struct cmd_tx_offload_get_configuration_result,
18605 		 port, "port");
18606 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18607 	TOKEN_NUM_INITIALIZER
18608 		(struct cmd_tx_offload_get_configuration_result,
18609 		 port_id, UINT16);
18610 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18611 	TOKEN_STRING_INITIALIZER
18612 		(struct cmd_tx_offload_get_configuration_result,
18613 		 tx_offload, "tx_offload");
18614 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18615 	TOKEN_STRING_INITIALIZER
18616 		(struct cmd_tx_offload_get_configuration_result,
18617 		 configuration, "configuration");
18618 
18619 static void
18620 cmd_tx_offload_get_configuration_parsed(
18621 	void *parsed_result,
18622 	__rte_unused struct cmdline *cl,
18623 	__rte_unused void *data)
18624 {
18625 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18626 	struct rte_eth_dev_info dev_info;
18627 	portid_t port_id = res->port_id;
18628 	struct rte_port *port = &ports[port_id];
18629 	uint64_t port_offloads;
18630 	uint64_t queue_offloads;
18631 	uint16_t nb_tx_queues;
18632 	int q;
18633 	int ret;
18634 
18635 	printf("Tx Offloading Configuration of port %d :\n", port_id);
18636 
18637 	port_offloads = port->dev_conf.txmode.offloads;
18638 	printf("  Port :");
18639 	print_tx_offloads(port_offloads);
18640 	printf("\n");
18641 
18642 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18643 	if (ret != 0)
18644 		return;
18645 
18646 	nb_tx_queues = dev_info.nb_tx_queues;
18647 	for (q = 0; q < nb_tx_queues; q++) {
18648 		queue_offloads = port->tx_conf[q].offloads;
18649 		printf("  Queue[%2d] :", q);
18650 		print_tx_offloads(queue_offloads);
18651 		printf("\n");
18652 	}
18653 	printf("\n");
18654 }
18655 
18656 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18657 	.f = cmd_tx_offload_get_configuration_parsed,
18658 	.data = NULL,
18659 	.help_str = "show port <port_id> tx_offload configuration",
18660 	.tokens = {
18661 		(void *)&cmd_tx_offload_get_configuration_show,
18662 		(void *)&cmd_tx_offload_get_configuration_port,
18663 		(void *)&cmd_tx_offload_get_configuration_port_id,
18664 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
18665 		(void *)&cmd_tx_offload_get_configuration_configuration,
18666 		NULL,
18667 	}
18668 };
18669 
18670 /* Enable/Disable a per port offloading */
18671 struct cmd_config_per_port_tx_offload_result {
18672 	cmdline_fixed_string_t port;
18673 	cmdline_fixed_string_t config;
18674 	portid_t port_id;
18675 	cmdline_fixed_string_t tx_offload;
18676 	cmdline_fixed_string_t offload;
18677 	cmdline_fixed_string_t on_off;
18678 };
18679 
18680 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18681 	TOKEN_STRING_INITIALIZER
18682 		(struct cmd_config_per_port_tx_offload_result,
18683 		 port, "port");
18684 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18685 	TOKEN_STRING_INITIALIZER
18686 		(struct cmd_config_per_port_tx_offload_result,
18687 		 config, "config");
18688 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18689 	TOKEN_NUM_INITIALIZER
18690 		(struct cmd_config_per_port_tx_offload_result,
18691 		 port_id, UINT16);
18692 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18693 	TOKEN_STRING_INITIALIZER
18694 		(struct cmd_config_per_port_tx_offload_result,
18695 		 tx_offload, "tx_offload");
18696 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18697 	TOKEN_STRING_INITIALIZER
18698 		(struct cmd_config_per_port_tx_offload_result,
18699 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18700 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18701 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18702 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18703 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18704 			  "send_on_timestamp");
18705 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18706 	TOKEN_STRING_INITIALIZER
18707 		(struct cmd_config_per_port_tx_offload_result,
18708 		 on_off, "on#off");
18709 
18710 static uint64_t
18711 search_tx_offload(const char *name)
18712 {
18713 	uint64_t single_offload;
18714 	const char *single_name;
18715 	int found = 0;
18716 	unsigned int bit;
18717 
18718 	single_offload = 1;
18719 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18720 		single_name = rte_eth_dev_tx_offload_name(single_offload);
18721 		if (single_name == NULL)
18722 			break;
18723 		if (!strcasecmp(single_name, name)) {
18724 			found = 1;
18725 			break;
18726 		} else if (!strcasecmp(single_name, "UNKNOWN"))
18727 			break;
18728 		single_offload <<= 1;
18729 	}
18730 
18731 	if (found)
18732 		return single_offload;
18733 
18734 	return 0;
18735 }
18736 
18737 static void
18738 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18739 				__rte_unused struct cmdline *cl,
18740 				__rte_unused void *data)
18741 {
18742 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18743 	portid_t port_id = res->port_id;
18744 	struct rte_eth_dev_info dev_info;
18745 	struct rte_port *port = &ports[port_id];
18746 	uint64_t single_offload;
18747 	uint16_t nb_tx_queues;
18748 	int q;
18749 	int ret;
18750 
18751 	if (port->port_status != RTE_PORT_STOPPED) {
18752 		printf("Error: Can't config offload when Port %d "
18753 		       "is not stopped\n", port_id);
18754 		return;
18755 	}
18756 
18757 	single_offload = search_tx_offload(res->offload);
18758 	if (single_offload == 0) {
18759 		printf("Unknown offload name: %s\n", res->offload);
18760 		return;
18761 	}
18762 
18763 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18764 	if (ret != 0)
18765 		return;
18766 
18767 	nb_tx_queues = dev_info.nb_tx_queues;
18768 	if (!strcmp(res->on_off, "on")) {
18769 		port->dev_conf.txmode.offloads |= single_offload;
18770 		for (q = 0; q < nb_tx_queues; q++)
18771 			port->tx_conf[q].offloads |= single_offload;
18772 	} else {
18773 		port->dev_conf.txmode.offloads &= ~single_offload;
18774 		for (q = 0; q < nb_tx_queues; q++)
18775 			port->tx_conf[q].offloads &= ~single_offload;
18776 	}
18777 
18778 	cmd_reconfig_device_queue(port_id, 1, 1);
18779 }
18780 
18781 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18782 	.f = cmd_config_per_port_tx_offload_parsed,
18783 	.data = NULL,
18784 	.help_str = "port config <port_id> tx_offload "
18785 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18786 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18787 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18788 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18789 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18790 		    "send_on_timestamp on|off",
18791 	.tokens = {
18792 		(void *)&cmd_config_per_port_tx_offload_result_port,
18793 		(void *)&cmd_config_per_port_tx_offload_result_config,
18794 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
18795 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18796 		(void *)&cmd_config_per_port_tx_offload_result_offload,
18797 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
18798 		NULL,
18799 	}
18800 };
18801 
18802 /* Enable/Disable a per queue offloading */
18803 struct cmd_config_per_queue_tx_offload_result {
18804 	cmdline_fixed_string_t port;
18805 	portid_t port_id;
18806 	cmdline_fixed_string_t txq;
18807 	uint16_t queue_id;
18808 	cmdline_fixed_string_t tx_offload;
18809 	cmdline_fixed_string_t offload;
18810 	cmdline_fixed_string_t on_off;
18811 };
18812 
18813 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18814 	TOKEN_STRING_INITIALIZER
18815 		(struct cmd_config_per_queue_tx_offload_result,
18816 		 port, "port");
18817 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18818 	TOKEN_NUM_INITIALIZER
18819 		(struct cmd_config_per_queue_tx_offload_result,
18820 		 port_id, UINT16);
18821 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18822 	TOKEN_STRING_INITIALIZER
18823 		(struct cmd_config_per_queue_tx_offload_result,
18824 		 txq, "txq");
18825 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18826 	TOKEN_NUM_INITIALIZER
18827 		(struct cmd_config_per_queue_tx_offload_result,
18828 		 queue_id, UINT16);
18829 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18830 	TOKEN_STRING_INITIALIZER
18831 		(struct cmd_config_per_queue_tx_offload_result,
18832 		 tx_offload, "tx_offload");
18833 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18834 	TOKEN_STRING_INITIALIZER
18835 		(struct cmd_config_per_queue_tx_offload_result,
18836 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18837 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18838 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18839 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18840 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
18841 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18842 	TOKEN_STRING_INITIALIZER
18843 		(struct cmd_config_per_queue_tx_offload_result,
18844 		 on_off, "on#off");
18845 
18846 static void
18847 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18848 				__rte_unused struct cmdline *cl,
18849 				__rte_unused void *data)
18850 {
18851 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18852 	struct rte_eth_dev_info dev_info;
18853 	portid_t port_id = res->port_id;
18854 	uint16_t queue_id = res->queue_id;
18855 	struct rte_port *port = &ports[port_id];
18856 	uint64_t single_offload;
18857 	int ret;
18858 
18859 	if (port->port_status != RTE_PORT_STOPPED) {
18860 		printf("Error: Can't config offload when Port %d "
18861 		       "is not stopped\n", port_id);
18862 		return;
18863 	}
18864 
18865 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18866 	if (ret != 0)
18867 		return;
18868 
18869 	if (queue_id >= dev_info.nb_tx_queues) {
18870 		printf("Error: input queue_id should be 0 ... "
18871 		       "%d\n", dev_info.nb_tx_queues - 1);
18872 		return;
18873 	}
18874 
18875 	single_offload = search_tx_offload(res->offload);
18876 	if (single_offload == 0) {
18877 		printf("Unknown offload name: %s\n", res->offload);
18878 		return;
18879 	}
18880 
18881 	if (!strcmp(res->on_off, "on"))
18882 		port->tx_conf[queue_id].offloads |= single_offload;
18883 	else
18884 		port->tx_conf[queue_id].offloads &= ~single_offload;
18885 
18886 	cmd_reconfig_device_queue(port_id, 1, 1);
18887 }
18888 
18889 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18890 	.f = cmd_config_per_queue_tx_offload_parsed,
18891 	.data = NULL,
18892 	.help_str = "port <port_id> txq <queue_id> tx_offload "
18893 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18894 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18895 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18896 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18897 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
18898 		    "on|off",
18899 	.tokens = {
18900 		(void *)&cmd_config_per_queue_tx_offload_result_port,
18901 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
18902 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
18903 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18904 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18905 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
18906 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
18907 		NULL,
18908 	}
18909 };
18910 
18911 /* *** configure tx_metadata for specific port *** */
18912 struct cmd_config_tx_metadata_specific_result {
18913 	cmdline_fixed_string_t port;
18914 	cmdline_fixed_string_t keyword;
18915 	uint16_t port_id;
18916 	cmdline_fixed_string_t item;
18917 	uint32_t value;
18918 };
18919 
18920 static void
18921 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18922 				__rte_unused struct cmdline *cl,
18923 				__rte_unused void *data)
18924 {
18925 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18926 
18927 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18928 		return;
18929 	ports[res->port_id].tx_metadata = res->value;
18930 	/* Add/remove callback to insert valid metadata in every Tx packet. */
18931 	if (ports[res->port_id].tx_metadata)
18932 		add_tx_md_callback(res->port_id);
18933 	else
18934 		remove_tx_md_callback(res->port_id);
18935 	rte_flow_dynf_metadata_register();
18936 }
18937 
18938 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18939 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18940 			port, "port");
18941 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18942 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18943 			keyword, "config");
18944 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18945 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18946 			port_id, UINT16);
18947 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18948 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18949 			item, "tx_metadata");
18950 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18951 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18952 			value, UINT32);
18953 
18954 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18955 	.f = cmd_config_tx_metadata_specific_parsed,
18956 	.data = NULL,
18957 	.help_str = "port config <port_id> tx_metadata <value>",
18958 	.tokens = {
18959 		(void *)&cmd_config_tx_metadata_specific_port,
18960 		(void *)&cmd_config_tx_metadata_specific_keyword,
18961 		(void *)&cmd_config_tx_metadata_specific_id,
18962 		(void *)&cmd_config_tx_metadata_specific_item,
18963 		(void *)&cmd_config_tx_metadata_specific_value,
18964 		NULL,
18965 	},
18966 };
18967 
18968 /* *** set dynf *** */
18969 struct cmd_config_tx_dynf_specific_result {
18970 	cmdline_fixed_string_t port;
18971 	cmdline_fixed_string_t keyword;
18972 	uint16_t port_id;
18973 	cmdline_fixed_string_t item;
18974 	cmdline_fixed_string_t name;
18975 	cmdline_fixed_string_t value;
18976 };
18977 
18978 static void
18979 cmd_config_dynf_specific_parsed(void *parsed_result,
18980 				__rte_unused struct cmdline *cl,
18981 				__rte_unused void *data)
18982 {
18983 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18984 	struct rte_mbuf_dynflag desc_flag;
18985 	int flag;
18986 	uint64_t old_port_flags;
18987 
18988 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18989 		return;
18990 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18991 	if (flag <= 0) {
18992 		if (strlcpy(desc_flag.name, res->name,
18993 			    RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18994 			printf("Flag name too long\n");
18995 			return;
18996 		}
18997 		desc_flag.flags = 0;
18998 		flag = rte_mbuf_dynflag_register(&desc_flag);
18999 		if (flag < 0) {
19000 			printf("Can't register flag\n");
19001 			return;
19002 		}
19003 		strcpy(dynf_names[flag], desc_flag.name);
19004 	}
19005 	old_port_flags = ports[res->port_id].mbuf_dynf;
19006 	if (!strcmp(res->value, "set")) {
19007 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
19008 		if (old_port_flags == 0)
19009 			add_tx_dynf_callback(res->port_id);
19010 	} else {
19011 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19012 		if (ports[res->port_id].mbuf_dynf == 0)
19013 			remove_tx_dynf_callback(res->port_id);
19014 	}
19015 }
19016 
19017 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19018 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19019 			keyword, "port");
19020 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19021 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19022 			keyword, "config");
19023 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19024 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19025 			port_id, UINT16);
19026 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19027 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19028 			item, "dynf");
19029 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19030 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19031 			name, NULL);
19032 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19033 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19034 			value, "set#clear");
19035 
19036 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19037 	.f = cmd_config_dynf_specific_parsed,
19038 	.data = NULL,
19039 	.help_str = "port config <port id> dynf <name> set|clear",
19040 	.tokens = {
19041 		(void *)&cmd_config_tx_dynf_specific_port,
19042 		(void *)&cmd_config_tx_dynf_specific_keyword,
19043 		(void *)&cmd_config_tx_dynf_specific_port_id,
19044 		(void *)&cmd_config_tx_dynf_specific_item,
19045 		(void *)&cmd_config_tx_dynf_specific_name,
19046 		(void *)&cmd_config_tx_dynf_specific_value,
19047 		NULL,
19048 	},
19049 };
19050 
19051 /* *** display tx_metadata per port configuration *** */
19052 struct cmd_show_tx_metadata_result {
19053 	cmdline_fixed_string_t cmd_show;
19054 	cmdline_fixed_string_t cmd_port;
19055 	cmdline_fixed_string_t cmd_keyword;
19056 	portid_t cmd_pid;
19057 };
19058 
19059 static void
19060 cmd_show_tx_metadata_parsed(void *parsed_result,
19061 		__rte_unused struct cmdline *cl,
19062 		__rte_unused void *data)
19063 {
19064 	struct cmd_show_tx_metadata_result *res = parsed_result;
19065 
19066 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19067 		printf("invalid port id %u\n", res->cmd_pid);
19068 		return;
19069 	}
19070 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19071 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19072 		       ports[res->cmd_pid].tx_metadata);
19073 	}
19074 }
19075 
19076 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19077 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19078 			cmd_show, "show");
19079 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19080 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19081 			cmd_port, "port");
19082 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19083 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19084 			cmd_pid, UINT16);
19085 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19086 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19087 			cmd_keyword, "tx_metadata");
19088 
19089 cmdline_parse_inst_t cmd_show_tx_metadata = {
19090 	.f = cmd_show_tx_metadata_parsed,
19091 	.data = NULL,
19092 	.help_str = "show port <port_id> tx_metadata",
19093 	.tokens = {
19094 		(void *)&cmd_show_tx_metadata_show,
19095 		(void *)&cmd_show_tx_metadata_port,
19096 		(void *)&cmd_show_tx_metadata_pid,
19097 		(void *)&cmd_show_tx_metadata_keyword,
19098 		NULL,
19099 	},
19100 };
19101 
19102 /* show port supported ptypes */
19103 
19104 /* Common result structure for show port ptypes */
19105 struct cmd_show_port_supported_ptypes_result {
19106 	cmdline_fixed_string_t show;
19107 	cmdline_fixed_string_t port;
19108 	portid_t port_id;
19109 	cmdline_fixed_string_t ptypes;
19110 };
19111 
19112 /* Common CLI fields for show port ptypes */
19113 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19114 	TOKEN_STRING_INITIALIZER
19115 		(struct cmd_show_port_supported_ptypes_result,
19116 		 show, "show");
19117 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19118 	TOKEN_STRING_INITIALIZER
19119 		(struct cmd_show_port_supported_ptypes_result,
19120 		 port, "port");
19121 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19122 	TOKEN_NUM_INITIALIZER
19123 		(struct cmd_show_port_supported_ptypes_result,
19124 		 port_id, UINT16);
19125 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19126 	TOKEN_STRING_INITIALIZER
19127 		(struct cmd_show_port_supported_ptypes_result,
19128 		 ptypes, "ptypes");
19129 
19130 static void
19131 cmd_show_port_supported_ptypes_parsed(
19132 	void *parsed_result,
19133 	__rte_unused struct cmdline *cl,
19134 	__rte_unused void *data)
19135 {
19136 #define RSVD_PTYPE_MASK       0xf0000000
19137 #define MAX_PTYPES_PER_LAYER  16
19138 #define LTYPE_NAMESIZE        32
19139 #define PTYPE_NAMESIZE        256
19140 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19141 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19142 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19143 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19144 	uint16_t port_id = res->port_id;
19145 	int ret, i;
19146 
19147 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19148 	if (ret < 0)
19149 		return;
19150 
19151 	while (ptype_mask != RSVD_PTYPE_MASK) {
19152 
19153 		switch (ptype_mask) {
19154 		case RTE_PTYPE_L2_MASK:
19155 			strlcpy(ltype, "L2", sizeof(ltype));
19156 			break;
19157 		case RTE_PTYPE_L3_MASK:
19158 			strlcpy(ltype, "L3", sizeof(ltype));
19159 			break;
19160 		case RTE_PTYPE_L4_MASK:
19161 			strlcpy(ltype, "L4", sizeof(ltype));
19162 			break;
19163 		case RTE_PTYPE_TUNNEL_MASK:
19164 			strlcpy(ltype, "Tunnel", sizeof(ltype));
19165 			break;
19166 		case RTE_PTYPE_INNER_L2_MASK:
19167 			strlcpy(ltype, "Inner L2", sizeof(ltype));
19168 			break;
19169 		case RTE_PTYPE_INNER_L3_MASK:
19170 			strlcpy(ltype, "Inner L3", sizeof(ltype));
19171 			break;
19172 		case RTE_PTYPE_INNER_L4_MASK:
19173 			strlcpy(ltype, "Inner L4", sizeof(ltype));
19174 			break;
19175 		default:
19176 			return;
19177 		}
19178 
19179 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19180 						       ptype_mask, ptypes,
19181 						       MAX_PTYPES_PER_LAYER);
19182 
19183 		if (ret > 0)
19184 			printf("Supported %s ptypes:\n", ltype);
19185 		else
19186 			printf("%s ptypes unsupported\n", ltype);
19187 
19188 		for (i = 0; i < ret; ++i) {
19189 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19190 			printf("%s\n", buf);
19191 		}
19192 
19193 		ptype_mask <<= 4;
19194 	}
19195 }
19196 
19197 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19198 	.f = cmd_show_port_supported_ptypes_parsed,
19199 	.data = NULL,
19200 	.help_str = "show port <port_id> ptypes",
19201 	.tokens = {
19202 		(void *)&cmd_show_port_supported_ptypes_show,
19203 		(void *)&cmd_show_port_supported_ptypes_port,
19204 		(void *)&cmd_show_port_supported_ptypes_port_id,
19205 		(void *)&cmd_show_port_supported_ptypes_ptypes,
19206 		NULL,
19207 	},
19208 };
19209 
19210 /* *** display rx/tx descriptor status *** */
19211 struct cmd_show_rx_tx_desc_status_result {
19212 	cmdline_fixed_string_t cmd_show;
19213 	cmdline_fixed_string_t cmd_port;
19214 	cmdline_fixed_string_t cmd_keyword;
19215 	cmdline_fixed_string_t cmd_desc;
19216 	cmdline_fixed_string_t cmd_status;
19217 	portid_t cmd_pid;
19218 	portid_t cmd_qid;
19219 	portid_t cmd_did;
19220 };
19221 
19222 static void
19223 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19224 		__rte_unused struct cmdline *cl,
19225 		__rte_unused void *data)
19226 {
19227 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19228 	int rc;
19229 
19230 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19231 		printf("invalid port id %u\n", res->cmd_pid);
19232 		return;
19233 	}
19234 
19235 	if (!strcmp(res->cmd_keyword, "rxq")) {
19236 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19237 					     res->cmd_did);
19238 		if (rc < 0) {
19239 			printf("Invalid queueid = %d\n", res->cmd_qid);
19240 			return;
19241 		}
19242 		if (rc == RTE_ETH_RX_DESC_AVAIL)
19243 			printf("Desc status = AVAILABLE\n");
19244 		else if (rc == RTE_ETH_RX_DESC_DONE)
19245 			printf("Desc status = DONE\n");
19246 		else
19247 			printf("Desc status = UNAVAILABLE\n");
19248 	} else if (!strcmp(res->cmd_keyword, "txq")) {
19249 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19250 					     res->cmd_did);
19251 		if (rc < 0) {
19252 			printf("Invalid queueid = %d\n", res->cmd_qid);
19253 			return;
19254 		}
19255 		if (rc == RTE_ETH_TX_DESC_FULL)
19256 			printf("Desc status = FULL\n");
19257 		else if (rc == RTE_ETH_TX_DESC_DONE)
19258 			printf("Desc status = DONE\n");
19259 		else
19260 			printf("Desc status = UNAVAILABLE\n");
19261 	}
19262 }
19263 
19264 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19265 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19266 			cmd_show, "show");
19267 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19268 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19269 			cmd_port, "port");
19270 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19271 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19272 			cmd_pid, UINT16);
19273 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19274 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19275 			cmd_keyword, "rxq#txq");
19276 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19277 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19278 			cmd_qid, UINT16);
19279 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19280 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19281 			cmd_desc, "desc");
19282 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19283 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19284 			cmd_did, UINT16);
19285 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19286 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19287 			cmd_status, "status");
19288 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19289 	.f = cmd_show_rx_tx_desc_status_parsed,
19290 	.data = NULL,
19291 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19292 		"status",
19293 	.tokens = {
19294 		(void *)&cmd_show_rx_tx_desc_status_show,
19295 		(void *)&cmd_show_rx_tx_desc_status_port,
19296 		(void *)&cmd_show_rx_tx_desc_status_pid,
19297 		(void *)&cmd_show_rx_tx_desc_status_keyword,
19298 		(void *)&cmd_show_rx_tx_desc_status_qid,
19299 		(void *)&cmd_show_rx_tx_desc_status_desc,
19300 		(void *)&cmd_show_rx_tx_desc_status_did,
19301 		(void *)&cmd_show_rx_tx_desc_status_status,
19302 		NULL,
19303 	},
19304 };
19305 
19306 /* Common result structure for set port ptypes */
19307 struct cmd_set_port_ptypes_result {
19308 	cmdline_fixed_string_t set;
19309 	cmdline_fixed_string_t port;
19310 	portid_t port_id;
19311 	cmdline_fixed_string_t ptype_mask;
19312 	uint32_t mask;
19313 };
19314 
19315 /* Common CLI fields for set port ptypes */
19316 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19317 	TOKEN_STRING_INITIALIZER
19318 		(struct cmd_set_port_ptypes_result,
19319 		 set, "set");
19320 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19321 	TOKEN_STRING_INITIALIZER
19322 		(struct cmd_set_port_ptypes_result,
19323 		 port, "port");
19324 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19325 	TOKEN_NUM_INITIALIZER
19326 		(struct cmd_set_port_ptypes_result,
19327 		 port_id, UINT16);
19328 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19329 	TOKEN_STRING_INITIALIZER
19330 		(struct cmd_set_port_ptypes_result,
19331 		 ptype_mask, "ptype_mask");
19332 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19333 	TOKEN_NUM_INITIALIZER
19334 		(struct cmd_set_port_ptypes_result,
19335 		 mask, UINT32);
19336 
19337 static void
19338 cmd_set_port_ptypes_parsed(
19339 	void *parsed_result,
19340 	__rte_unused struct cmdline *cl,
19341 	__rte_unused void *data)
19342 {
19343 	struct cmd_set_port_ptypes_result *res = parsed_result;
19344 #define PTYPE_NAMESIZE        256
19345 	char ptype_name[PTYPE_NAMESIZE];
19346 	uint16_t port_id = res->port_id;
19347 	uint32_t ptype_mask = res->mask;
19348 	int ret, i;
19349 
19350 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19351 					       NULL, 0);
19352 	if (ret <= 0) {
19353 		printf("Port %d doesn't support any ptypes.\n", port_id);
19354 		return;
19355 	}
19356 
19357 	uint32_t ptypes[ret];
19358 
19359 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19360 	if (ret < 0) {
19361 		printf("Unable to set requested ptypes for Port %d\n", port_id);
19362 		return;
19363 	}
19364 
19365 	printf("Successfully set following ptypes for Port %d\n", port_id);
19366 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19367 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19368 		printf("%s\n", ptype_name);
19369 	}
19370 
19371 	clear_ptypes = false;
19372 }
19373 
19374 cmdline_parse_inst_t cmd_set_port_ptypes = {
19375 	.f = cmd_set_port_ptypes_parsed,
19376 	.data = NULL,
19377 	.help_str = "set port <port_id> ptype_mask <mask>",
19378 	.tokens = {
19379 		(void *)&cmd_set_port_ptypes_set,
19380 		(void *)&cmd_set_port_ptypes_port,
19381 		(void *)&cmd_set_port_ptypes_port_id,
19382 		(void *)&cmd_set_port_ptypes_mask_str,
19383 		(void *)&cmd_set_port_ptypes_mask_u32,
19384 		NULL,
19385 	},
19386 };
19387 
19388 /* *** display mac addresses added to a port *** */
19389 struct cmd_showport_macs_result {
19390 	cmdline_fixed_string_t cmd_show;
19391 	cmdline_fixed_string_t cmd_port;
19392 	cmdline_fixed_string_t cmd_keyword;
19393 	portid_t cmd_pid;
19394 };
19395 
19396 static void
19397 cmd_showport_macs_parsed(void *parsed_result,
19398 		__rte_unused struct cmdline *cl,
19399 		__rte_unused void *data)
19400 {
19401 	struct cmd_showport_macs_result *res = parsed_result;
19402 
19403 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19404 		return;
19405 
19406 	if (!strcmp(res->cmd_keyword, "macs"))
19407 		show_macs(res->cmd_pid);
19408 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19409 		show_mcast_macs(res->cmd_pid);
19410 }
19411 
19412 cmdline_parse_token_string_t cmd_showport_macs_show =
19413 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19414 			cmd_show, "show");
19415 cmdline_parse_token_string_t cmd_showport_macs_port =
19416 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19417 			cmd_port, "port");
19418 cmdline_parse_token_num_t cmd_showport_macs_pid =
19419 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19420 			cmd_pid, UINT16);
19421 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19422 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19423 			cmd_keyword, "macs#mcast_macs");
19424 
19425 cmdline_parse_inst_t cmd_showport_macs = {
19426 	.f = cmd_showport_macs_parsed,
19427 	.data = NULL,
19428 	.help_str = "show port <port_id> macs|mcast_macs",
19429 	.tokens = {
19430 		(void *)&cmd_showport_macs_show,
19431 		(void *)&cmd_showport_macs_port,
19432 		(void *)&cmd_showport_macs_pid,
19433 		(void *)&cmd_showport_macs_keyword,
19434 		NULL,
19435 	},
19436 };
19437 
19438 /* ******************************************************************************** */
19439 
19440 /* list of instructions */
19441 cmdline_parse_ctx_t main_ctx[] = {
19442 	(cmdline_parse_inst_t *)&cmd_help_brief,
19443 	(cmdline_parse_inst_t *)&cmd_help_long,
19444 	(cmdline_parse_inst_t *)&cmd_quit,
19445 	(cmdline_parse_inst_t *)&cmd_load_from_file,
19446 	(cmdline_parse_inst_t *)&cmd_showport,
19447 	(cmdline_parse_inst_t *)&cmd_showqueue,
19448 	(cmdline_parse_inst_t *)&cmd_showportall,
19449 	(cmdline_parse_inst_t *)&cmd_showdevice,
19450 	(cmdline_parse_inst_t *)&cmd_showcfg,
19451 	(cmdline_parse_inst_t *)&cmd_showfwdall,
19452 	(cmdline_parse_inst_t *)&cmd_start,
19453 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
19454 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19455 	(cmdline_parse_inst_t *)&cmd_set_link_up,
19456 	(cmdline_parse_inst_t *)&cmd_set_link_down,
19457 	(cmdline_parse_inst_t *)&cmd_reset,
19458 	(cmdline_parse_inst_t *)&cmd_set_numbers,
19459 	(cmdline_parse_inst_t *)&cmd_set_log,
19460 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
19461 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
19462 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
19463 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
19464 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19465 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19466 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19467 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19468 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19469 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19470 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19471 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19472 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
19473 	(cmdline_parse_inst_t *)&cmd_set_link_check,
19474 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19475 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
19476 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19477 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
19478 #ifdef RTE_LIBRTE_PMD_BOND
19479 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19480 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
19481 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19482 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19483 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19484 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
19485 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19486 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19487 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19488 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19489 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19490 #endif
19491 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
19492 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
19493 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19494 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19495 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19496 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19497 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19498 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19499 	(cmdline_parse_inst_t *)&cmd_csum_set,
19500 	(cmdline_parse_inst_t *)&cmd_csum_show,
19501 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
19502 	(cmdline_parse_inst_t *)&cmd_tso_set,
19503 	(cmdline_parse_inst_t *)&cmd_tso_show,
19504 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19505 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19506 	(cmdline_parse_inst_t *)&cmd_gro_enable,
19507 	(cmdline_parse_inst_t *)&cmd_gro_flush,
19508 	(cmdline_parse_inst_t *)&cmd_gro_show,
19509 	(cmdline_parse_inst_t *)&cmd_gso_enable,
19510 	(cmdline_parse_inst_t *)&cmd_gso_size,
19511 	(cmdline_parse_inst_t *)&cmd_gso_show,
19512 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19513 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19514 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19515 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19516 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19517 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19518 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19519 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19520 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19521 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19522 	(cmdline_parse_inst_t *)&cmd_config_dcb,
19523 	(cmdline_parse_inst_t *)&cmd_read_reg,
19524 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19525 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
19526 	(cmdline_parse_inst_t *)&cmd_write_reg,
19527 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19528 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
19529 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19530 	(cmdline_parse_inst_t *)&cmd_stop,
19531 	(cmdline_parse_inst_t *)&cmd_mac_addr,
19532 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19533 	(cmdline_parse_inst_t *)&cmd_set_qmap,
19534 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19535 	(cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19536 	(cmdline_parse_inst_t *)&cmd_operate_port,
19537 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
19538 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
19539 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
19540 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
19541 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19542 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
19543 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
19544 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
19545 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19546 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
19547 	(cmdline_parse_inst_t *)&cmd_config_mtu,
19548 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19549 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19550 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19551 	(cmdline_parse_inst_t *)&cmd_config_rss,
19552 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19553 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19554 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19555 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19556 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
19557 	(cmdline_parse_inst_t *)&cmd_showport_reta,
19558 	(cmdline_parse_inst_t *)&cmd_showport_macs,
19559 	(cmdline_parse_inst_t *)&cmd_config_burst,
19560 	(cmdline_parse_inst_t *)&cmd_config_thresh,
19561 	(cmdline_parse_inst_t *)&cmd_config_threshold,
19562 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19563 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19564 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19565 	(cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19566 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19567 	(cmdline_parse_inst_t *)&cmd_tunnel_filter,
19568 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19569 	(cmdline_parse_inst_t *)&cmd_global_config,
19570 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19571 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
19572 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19573 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19574 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19575 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19576 	(cmdline_parse_inst_t *)&cmd_dump,
19577 	(cmdline_parse_inst_t *)&cmd_dump_one,
19578 	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
19579 	(cmdline_parse_inst_t *)&cmd_syn_filter,
19580 	(cmdline_parse_inst_t *)&cmd_2tuple_filter,
19581 	(cmdline_parse_inst_t *)&cmd_5tuple_filter,
19582 	(cmdline_parse_inst_t *)&cmd_flex_filter,
19583 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19584 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19585 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19586 	(cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19587 	(cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19588 	(cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19589 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19590 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
19591 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19592 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19593 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19594 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19595 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19596 	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19597 	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19598 	(cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19599 	(cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19600 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19601 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19602 	(cmdline_parse_inst_t *)&cmd_flow,
19603 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19604 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19605 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19606 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19607 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
19608 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
19609 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
19610 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
19611 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19612 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19613 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19614 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19615 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19616 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
19617 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19618 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19619 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19620 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19621 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19622 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19623 	(cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19624 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19625 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19626 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19627 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19628 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19629 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19630 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19631 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19632 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19633 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19634 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19635 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19636 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19637 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19638 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19639 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19640 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19641 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19642 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19643 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19644 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19645 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19646 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19647 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
19648 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19649 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19650 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
19651 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
19652 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
19653 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19654 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19655 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
19656 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19657 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
19658 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19659 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
19660 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19661 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19662 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19663 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19664 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19665 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19666 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19667 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19668 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19669 	(cmdline_parse_inst_t *)&cmd_ddp_add,
19670 	(cmdline_parse_inst_t *)&cmd_ddp_del,
19671 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
19672 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
19673 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
19674 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
19675 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
19676 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19677 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19678 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19679 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19680 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19681 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19682 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19683 
19684 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19685 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19686 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19687 	(cmdline_parse_inst_t *)&cmd_queue_region,
19688 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
19689 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
19690 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
19691 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19692 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19693 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19694 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19695 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19696 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19697 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19698 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19699 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19700 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19701 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19702 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19703 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19704 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19705 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19706 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19707 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19708 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19709 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19710 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19711 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19712 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19713 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19714 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19715 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19716 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19717 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19718 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19719 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19720 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19721 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19722 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19723 #ifdef RTE_LIBRTE_BPF
19724 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19725 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19726 #endif
19727 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19728 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19729 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19730 	(cmdline_parse_inst_t *)&cmd_set_raw,
19731 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
19732 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19733 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19734 	NULL,
19735 };
19736 
19737 /* read cmdline commands from file */
19738 void
19739 cmdline_read_from_file(const char *filename)
19740 {
19741 	struct cmdline *cl;
19742 
19743 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19744 	if (cl == NULL) {
19745 		printf("Failed to create file based cmdline context: %s\n",
19746 		       filename);
19747 		return;
19748 	}
19749 
19750 	cmdline_interact(cl);
19751 	cmdline_quit(cl);
19752 
19753 	cmdline_free(cl);
19754 
19755 	printf("Read CLI commands from %s\n", filename);
19756 }
19757 
19758 /* prompt function, called from main on MASTER lcore */
19759 void
19760 prompt(void)
19761 {
19762 	/* initialize non-constant commands */
19763 	cmd_set_fwd_mode_init();
19764 	cmd_set_fwd_retry_mode_init();
19765 
19766 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19767 	if (testpmd_cl == NULL)
19768 		return;
19769 	cmdline_interact(testpmd_cl);
19770 	cmdline_stdin_exit(testpmd_cl);
19771 }
19772 
19773 void
19774 prompt_exit(void)
19775 {
19776 	if (testpmd_cl != NULL)
19777 		cmdline_quit(testpmd_cl);
19778 }
19779 
19780 static void
19781 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19782 {
19783 	if (id == (portid_t)RTE_PORT_ALL) {
19784 		portid_t pid;
19785 
19786 		RTE_ETH_FOREACH_DEV(pid) {
19787 			/* check if need_reconfig has been set to 1 */
19788 			if (ports[pid].need_reconfig == 0)
19789 				ports[pid].need_reconfig = dev;
19790 			/* check if need_reconfig_queues has been set to 1 */
19791 			if (ports[pid].need_reconfig_queues == 0)
19792 				ports[pid].need_reconfig_queues = queue;
19793 		}
19794 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19795 		/* check if need_reconfig has been set to 1 */
19796 		if (ports[id].need_reconfig == 0)
19797 			ports[id].need_reconfig = dev;
19798 		/* check if need_reconfig_queues has been set to 1 */
19799 		if (ports[id].need_reconfig_queues == 0)
19800 			ports[id].need_reconfig_queues = queue;
19801 	}
19802 }
19803