xref: /dpdk/app/test-pmd/cmdline.c (revision 089e5ed727a15da2729cfee9b63533dd120bd04c)
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 #ifndef __linux__
15 #ifndef __FreeBSD__
16 #include <net/socket.h>
17 #else
18 #include <sys/socket.h>
19 #endif
20 #endif
21 #include <netinet/in.h>
22 
23 #include <sys/queue.h>
24 
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
27 #include <rte_log.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
34 #include <rte_eal.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
39 #include <rte_ring.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
42 #include <rte_pci.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_flow.h>
48 #include <rte_gro.h>
49 
50 #include <cmdline_rdline.h>
51 #include <cmdline_parse.h>
52 #include <cmdline_parse_num.h>
53 #include <cmdline_parse_string.h>
54 #include <cmdline_parse_ipaddr.h>
55 #include <cmdline_parse_etheraddr.h>
56 #include <cmdline_socket.h>
57 #include <cmdline.h>
58 #ifdef RTE_LIBRTE_PMD_BOND
59 #include <rte_eth_bond.h>
60 #include <rte_eth_bond_8023ad.h>
61 #endif
62 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
63 #include <rte_pmd_dpaa.h>
64 #endif
65 #ifdef RTE_LIBRTE_IXGBE_PMD
66 #include <rte_pmd_ixgbe.h>
67 #endif
68 #ifdef RTE_LIBRTE_I40E_PMD
69 #include <rte_pmd_i40e.h>
70 #endif
71 #ifdef RTE_LIBRTE_BNXT_PMD
72 #include <rte_pmd_bnxt.h>
73 #endif
74 #include "testpmd.h"
75 #include "cmdline_mtr.h"
76 #include "cmdline_tm.h"
77 #include "bpf_cmd.h"
78 
79 static struct cmdline *testpmd_cl;
80 
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
82 
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 	cmdline_fixed_string_t help;
86 };
87 
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
89                                   struct cmdline *cl,
90                                   __attribute__((unused)) void *data)
91 {
92 	cmdline_printf(
93 		cl,
94 		"\n"
95 		"Help is available for the following sections:\n\n"
96 		"    help control                    : Start and stop forwarding.\n"
97 		"    help display                    : Displaying port, stats and config "
98 		"information.\n"
99 		"    help config                     : Configuration information.\n"
100 		"    help ports                      : Configuring ports.\n"
101 		"    help registers                  : Reading and setting port registers.\n"
102 		"    help filters                    : Filters configuration help.\n"
103 		"    help traffic_management         : Traffic Management commmands.\n"
104 		"    help devices                    : Device related cmds.\n"
105 		"    help all                        : All of the above sections.\n\n"
106 	);
107 
108 }
109 
110 cmdline_parse_token_string_t cmd_help_brief_help =
111 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
112 
113 cmdline_parse_inst_t cmd_help_brief = {
114 	.f = cmd_help_brief_parsed,
115 	.data = NULL,
116 	.help_str = "help: Show help",
117 	.tokens = {
118 		(void *)&cmd_help_brief_help,
119 		NULL,
120 	},
121 };
122 
123 /* *** Help command with help sections. *** */
124 struct cmd_help_long_result {
125 	cmdline_fixed_string_t help;
126 	cmdline_fixed_string_t section;
127 };
128 
129 static void cmd_help_long_parsed(void *parsed_result,
130                                  struct cmdline *cl,
131                                  __attribute__((unused)) void *data)
132 {
133 	int show_all = 0;
134 	struct cmd_help_long_result *res = parsed_result;
135 
136 	if (!strcmp(res->section, "all"))
137 		show_all = 1;
138 
139 	if (show_all || !strcmp(res->section, "control")) {
140 
141 		cmdline_printf(
142 			cl,
143 			"\n"
144 			"Control forwarding:\n"
145 			"-------------------\n\n"
146 
147 			"start\n"
148 			"    Start packet forwarding with current configuration.\n\n"
149 
150 			"start tx_first\n"
151 			"    Start packet forwarding with current config"
152 			" after sending one burst of packets.\n\n"
153 
154 			"stop\n"
155 			"    Stop packet forwarding, and display accumulated"
156 			" statistics.\n\n"
157 
158 			"quit\n"
159 			"    Quit to prompt.\n\n"
160 		);
161 	}
162 
163 	if (show_all || !strcmp(res->section, "display")) {
164 
165 		cmdline_printf(
166 			cl,
167 			"\n"
168 			"Display:\n"
169 			"--------\n\n"
170 
171 			"show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
172 			"    Display information for port_id, or all.\n\n"
173 
174 			"show port X rss reta (size) (mask0,mask1,...)\n"
175 			"    Display the rss redirection table entry indicated"
176 			" by masks on port X. size is used to indicate the"
177 			" hardware supported reta size\n\n"
178 
179 			"show port (port_id) rss-hash [key]\n"
180 			"    Display the RSS hash functions and RSS hash key of port\n\n"
181 
182 			"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
183 			"    Clear information for port_id, or all.\n\n"
184 
185 			"show (rxq|txq) info (port_id) (queue_id)\n"
186 			"    Display information for configured RX/TX queue.\n\n"
187 
188 			"show config (rxtx|cores|fwd|txpkts)\n"
189 			"    Display the given configuration.\n\n"
190 
191 			"read rxd (port_id) (queue_id) (rxd_id)\n"
192 			"    Display an RX descriptor of a port RX queue.\n\n"
193 
194 			"read txd (port_id) (queue_id) (txd_id)\n"
195 			"    Display a TX descriptor of a port TX queue.\n\n"
196 
197 			"ddp get list (port_id)\n"
198 			"    Get ddp profile info list\n\n"
199 
200 			"ddp get info (profile_path)\n"
201 			"    Get ddp profile information.\n\n"
202 
203 			"show vf stats (port_id) (vf_id)\n"
204 			"    Display a VF's statistics.\n\n"
205 
206 			"clear vf stats (port_id) (vf_id)\n"
207 			"    Reset a VF's statistics.\n\n"
208 
209 			"show port (port_id) pctype mapping\n"
210 			"    Get flow ptype to pctype mapping on a port\n\n"
211 
212 			"show port meter stats (port_id) (meter_id) (clear)\n"
213 			"    Get meter stats on a port\n\n"
214 
215 			"show fwd stats all\n"
216 			"    Display statistics for all fwd engines.\n\n"
217 
218 			"clear fwd stats all\n"
219 			"    Clear statistics for all fwd engines.\n\n"
220 
221 			"show port (port_id) rx_offload capabilities\n"
222 			"    List all per queue and per port Rx offloading"
223 			" capabilities of a port\n\n"
224 
225 			"show port (port_id) rx_offload configuration\n"
226 			"    List port level and all queue level"
227 			" Rx offloading configuration\n\n"
228 
229 			"show port (port_id) tx_offload capabilities\n"
230 			"    List all per queue and per port"
231 			" Tx offloading capabilities of a port\n\n"
232 
233 			"show port (port_id) tx_offload configuration\n"
234 			"    List port level and all queue level"
235 			" Tx offloading configuration\n\n"
236 
237 			"show port (port_id) tx_metadata\n"
238 			"    Show Tx metadata value set"
239 			" for a specific port\n\n"
240 
241 			"show device info (<identifier>|all)"
242 			"       Show general information about devices probed.\n\n"
243 		);
244 	}
245 
246 	if (show_all || !strcmp(res->section, "config")) {
247 		cmdline_printf(
248 			cl,
249 			"\n"
250 			"Configuration:\n"
251 			"--------------\n"
252 			"Configuration changes only become active when"
253 			" forwarding is started/restarted.\n\n"
254 
255 			"set default\n"
256 			"    Reset forwarding to the default configuration.\n\n"
257 
258 			"set verbose (level)\n"
259 			"    Set the debug verbosity level X.\n\n"
260 
261 			"set log global|(type) (level)\n"
262 			"    Set the log level.\n\n"
263 
264 			"set nbport (num)\n"
265 			"    Set number of ports.\n\n"
266 
267 			"set nbcore (num)\n"
268 			"    Set number of cores.\n\n"
269 
270 			"set coremask (mask)\n"
271 			"    Set the forwarding cores hexadecimal mask.\n\n"
272 
273 			"set portmask (mask)\n"
274 			"    Set the forwarding ports hexadecimal mask.\n\n"
275 
276 			"set burst (num)\n"
277 			"    Set number of packets per burst.\n\n"
278 
279 			"set burst tx delay (microseconds) retry (num)\n"
280 			"    Set the transmit delay time and number of retries,"
281 			" effective when retry is enabled.\n\n"
282 
283 			"set txpkts (x[,y]*)\n"
284 			"    Set the length of each segment of TXONLY"
285 			" and optionally CSUM packets.\n\n"
286 
287 			"set txsplit (off|on|rand)\n"
288 			"    Set the split policy for the TX packets."
289 			" Right now only applicable for CSUM and TXONLY"
290 			" modes\n\n"
291 
292 			"set corelist (x[,y]*)\n"
293 			"    Set the list of forwarding cores.\n\n"
294 
295 			"set portlist (x[,y]*)\n"
296 			"    Set the list of forwarding ports.\n\n"
297 
298 			"set port setup on (iterator|event)\n"
299 			"    Select how attached port is retrieved for setup.\n\n"
300 
301 			"set tx loopback (port_id) (on|off)\n"
302 			"    Enable or disable tx loopback.\n\n"
303 
304 			"set all queues drop (port_id) (on|off)\n"
305 			"    Set drop enable bit for all queues.\n\n"
306 
307 			"set vf split drop (port_id) (vf_id) (on|off)\n"
308 			"    Set split drop enable bit for a VF from the PF.\n\n"
309 
310 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
311 			"    Set MAC antispoof for a VF from the PF.\n\n"
312 
313 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
314 			"    Enable MACsec offload.\n\n"
315 
316 			"set macsec offload (port_id) off\n"
317 			"    Disable MACsec offload.\n\n"
318 
319 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
320 			"    Configure MACsec secure connection (SC).\n\n"
321 
322 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
323 			"    Configure MACsec secure association (SA).\n\n"
324 
325 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
326 			"    Set VF broadcast for a VF from the PF.\n\n"
327 
328 			"vlan set strip (on|off) (port_id)\n"
329 			"    Set the VLAN strip on a port.\n\n"
330 
331 			"vlan set stripq (on|off) (port_id,queue_id)\n"
332 			"    Set the VLAN strip for a queue on a port.\n\n"
333 
334 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
335 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
336 
337 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
338 			"    Set VLAN insert for a VF from the PF.\n\n"
339 
340 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
341 			"    Set VLAN antispoof for a VF from the PF.\n\n"
342 
343 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
344 			"    Set VLAN tag for a VF from the PF.\n\n"
345 
346 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
347 			"    Set a VF's max bandwidth(Mbps).\n\n"
348 
349 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
350 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
351 
352 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
353 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
354 
355 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
356 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
357 
358 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
359 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
360 
361 			"vlan set filter (on|off) (port_id)\n"
362 			"    Set the VLAN filter on a port.\n\n"
363 
364 			"vlan set qinq (on|off) (port_id)\n"
365 			"    Set the VLAN QinQ (extended queue in queue)"
366 			" on a port.\n\n"
367 
368 			"vlan set (inner|outer) tpid (value) (port_id)\n"
369 			"    Set the VLAN TPID for Packet Filtering on"
370 			" a port\n\n"
371 
372 			"rx_vlan add (vlan_id|all) (port_id)\n"
373 			"    Add a vlan_id, or all identifiers, to the set"
374 			" of VLAN identifiers filtered by port_id.\n\n"
375 
376 			"rx_vlan rm (vlan_id|all) (port_id)\n"
377 			"    Remove a vlan_id, or all identifiers, from the set"
378 			" of VLAN identifiers filtered by port_id.\n\n"
379 
380 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
381 			"    Add a vlan_id, to the set of VLAN identifiers"
382 			"filtered for VF(s) from port_id.\n\n"
383 
384 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
385 			"    Remove a vlan_id, to the set of VLAN identifiers"
386 			"filtered for VF(s) from port_id.\n\n"
387 
388 			"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
389 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
390 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
391 			"   add a tunnel filter of a port.\n\n"
392 
393 			"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
394 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
395 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
396 			"   remove a tunnel filter of a port.\n\n"
397 
398 			"rx_vxlan_port add (udp_port) (port_id)\n"
399 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
400 
401 			"rx_vxlan_port rm (udp_port) (port_id)\n"
402 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
403 
404 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
405 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
406 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
407 
408 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
409 			"    Set port based TX VLAN insertion.\n\n"
410 
411 			"tx_vlan reset (port_id)\n"
412 			"    Disable hardware insertion of a VLAN header in"
413 			" packets sent on a port.\n\n"
414 
415 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
416 			"    Select hardware or software calculation of the"
417 			" checksum when transmitting a packet using the"
418 			" csum forward engine.\n"
419 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
420 			"    outer-ip concerns the outer IP layer in"
421 			"    outer-udp concerns the outer UDP layer in"
422 			" case the packet is recognized as a tunnel packet by"
423 			" the forward engine (vxlan, gre and ipip are supported)\n"
424 			"    Please check the NIC datasheet for HW limits.\n\n"
425 
426 			"csum parse-tunnel (on|off) (tx_port_id)\n"
427 			"    If disabled, treat tunnel packets as non-tunneled"
428 			" packets (treat inner headers as payload). The port\n"
429 			"    argument is the port used for TX in csum forward"
430 			" engine.\n\n"
431 
432 			"csum show (port_id)\n"
433 			"    Display tx checksum offload configuration\n\n"
434 
435 			"tso set (segsize) (portid)\n"
436 			"    Enable TCP Segmentation Offload in csum forward"
437 			" engine.\n"
438 			"    Please check the NIC datasheet for HW limits.\n\n"
439 
440 			"tso show (portid)"
441 			"    Display the status of TCP Segmentation Offload.\n\n"
442 
443 			"set port (port_id) gro on|off\n"
444 			"    Enable or disable Generic Receive Offload in"
445 			" csum forwarding engine.\n\n"
446 
447 			"show port (port_id) gro\n"
448 			"    Display GRO configuration.\n\n"
449 
450 			"set gro flush (cycles)\n"
451 			"    Set the cycle to flush GROed packets from"
452 			" reassembly tables.\n\n"
453 
454 			"set port (port_id) gso (on|off)"
455 			"    Enable or disable Generic Segmentation Offload in"
456 			" csum forwarding engine.\n\n"
457 
458 			"set gso segsz (length)\n"
459 			"    Set max packet length for output GSO segments,"
460 			" including packet header and payload.\n\n"
461 
462 			"show port (port_id) gso\n"
463 			"    Show GSO configuration.\n\n"
464 
465 			"set fwd (%s)\n"
466 			"    Set packet forwarding mode.\n\n"
467 
468 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
469 			"    Add a MAC address on port_id.\n\n"
470 
471 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
472 			"    Remove a MAC address from port_id.\n\n"
473 
474 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 			"    Set the default MAC address for port_id.\n\n"
476 
477 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
478 			"    Add a MAC address for a VF on the port.\n\n"
479 
480 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
481 			"    Set the MAC address for a VF from the PF.\n\n"
482 
483 			"set eth-peer (port_id) (peer_addr)\n"
484 			"    set the peer address for certain port.\n\n"
485 
486 			"set port (port_id) uta (mac_address|all) (on|off)\n"
487 			"    Add/Remove a or all unicast hash filter(s)"
488 			"from port X.\n\n"
489 
490 			"set promisc (port_id|all) (on|off)\n"
491 			"    Set the promiscuous mode on port_id, or all.\n\n"
492 
493 			"set allmulti (port_id|all) (on|off)\n"
494 			"    Set the allmulti mode on port_id, or all.\n\n"
495 
496 			"set vf promisc (port_id) (vf_id) (on|off)\n"
497 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
498 
499 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
500 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
501 
502 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
503 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
504 			" (on|off) autoneg (on|off) (port_id)\n"
505 			"set flow_ctrl rx (on|off) (portid)\n"
506 			"set flow_ctrl tx (on|off) (portid)\n"
507 			"set flow_ctrl high_water (high_water) (portid)\n"
508 			"set flow_ctrl low_water (low_water) (portid)\n"
509 			"set flow_ctrl pause_time (pause_time) (portid)\n"
510 			"set flow_ctrl send_xon (send_xon) (portid)\n"
511 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
512 			"set flow_ctrl autoneg (on|off) (port_id)\n"
513 			"    Set the link flow control parameter on a port.\n\n"
514 
515 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
516 			" (low_water) (pause_time) (priority) (port_id)\n"
517 			"    Set the priority flow control parameter on a"
518 			" port.\n\n"
519 
520 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
521 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
522 			" queue on port.\n"
523 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
524 			" on port 0 to mapping 5.\n\n"
525 
526 			"set xstats-hide-zero on|off\n"
527 			"    Set the option to hide the zero values"
528 			" for xstats display.\n"
529 
530 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
531 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
532 
533 			"set port (port_id) vf (vf_id) (mac_addr)"
534 			" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
535 			"   Add/Remove unicast or multicast MAC addr filter"
536 			" for a VF.\n\n"
537 
538 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
539 			"|MPE) (on|off)\n"
540 			"    AUPE:accepts untagged VLAN;"
541 			"ROPE:accept unicast hash\n\n"
542 			"    BAM:accepts broadcast packets;"
543 			"MPE:accepts all multicast packets\n\n"
544 			"    Enable/Disable a VF receive mode of a port\n\n"
545 
546 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
547 			"    Set rate limit for a queue of a port\n\n"
548 
549 			"set port (port_id) vf (vf_id) rate (rate_num) "
550 			"queue_mask (queue_mask_value)\n"
551 			"    Set rate limit for queues in VF of a port\n\n"
552 
553 			"set port (port_id) mirror-rule (rule_id)"
554 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
555 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
556 			"   Set pool or vlan type mirror rule on a port.\n"
557 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
558 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
559 			" to pool 0.\n\n"
560 
561 			"set port (port_id) mirror-rule (rule_id)"
562 			" (uplink-mirror|downlink-mirror) dst-pool"
563 			" (pool_id) (on|off)\n"
564 			"   Set uplink or downlink type mirror rule on a port.\n"
565 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
566 			" 0 on' enable mirror income traffic to pool 0.\n\n"
567 
568 			"reset port (port_id) mirror-rule (rule_id)\n"
569 			"   Reset a mirror rule.\n\n"
570 
571 			"set flush_rx (on|off)\n"
572 			"   Flush (default) or don't flush RX streams before"
573 			" forwarding. Mainly used with PCAP drivers.\n\n"
574 
575 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
576 			"   Set the bypass mode for the lowest port on bypass enabled"
577 			" NIC.\n\n"
578 
579 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
580 			"mode (normal|bypass|isolate) (port_id)\n"
581 			"   Set the event required to initiate specified bypass mode for"
582 			" the lowest port on a bypass enabled NIC where:\n"
583 			"       timeout   = enable bypass after watchdog timeout.\n"
584 			"       os_on     = enable bypass when OS/board is powered on.\n"
585 			"       os_off    = enable bypass when OS/board is powered off.\n"
586 			"       power_on  = enable bypass when power supply is turned on.\n"
587 			"       power_off = enable bypass when power supply is turned off."
588 			"\n\n"
589 
590 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
591 			"   Set the bypass watchdog timeout to 'n' seconds"
592 			" where 0 = instant.\n\n"
593 
594 			"show bypass config (port_id)\n"
595 			"   Show the bypass configuration for a bypass enabled NIC"
596 			" using the lowest port on the NIC.\n\n"
597 
598 #ifdef RTE_LIBRTE_PMD_BOND
599 			"create bonded device (mode) (socket)\n"
600 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
601 
602 			"add bonding slave (slave_id) (port_id)\n"
603 			"	Add a slave device to a bonded device.\n\n"
604 
605 			"remove bonding slave (slave_id) (port_id)\n"
606 			"	Remove a slave device from a bonded device.\n\n"
607 
608 			"set bonding mode (value) (port_id)\n"
609 			"	Set the bonding mode on a bonded device.\n\n"
610 
611 			"set bonding primary (slave_id) (port_id)\n"
612 			"	Set the primary slave for a bonded device.\n\n"
613 
614 			"show bonding config (port_id)\n"
615 			"	Show the bonding config for port_id.\n\n"
616 
617 			"set bonding mac_addr (port_id) (address)\n"
618 			"	Set the MAC address of a bonded device.\n\n"
619 
620 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
621 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
622 
623 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
624 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
625 
626 			"set bonding mon_period (port_id) (value)\n"
627 			"	Set the bonding link status monitoring polling period in ms.\n\n"
628 
629 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
630 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
631 
632 #endif
633 			"set link-up port (port_id)\n"
634 			"	Set link up for a port.\n\n"
635 
636 			"set link-down port (port_id)\n"
637 			"	Set link down for a port.\n\n"
638 
639 			"E-tag set insertion on port-tag-id (value)"
640 			" port (port_id) vf (vf_id)\n"
641 			"    Enable E-tag insertion for a VF on a port\n\n"
642 
643 			"E-tag set insertion off port (port_id) vf (vf_id)\n"
644 			"    Disable E-tag insertion for a VF on a port\n\n"
645 
646 			"E-tag set stripping (on|off) port (port_id)\n"
647 			"    Enable/disable E-tag stripping on a port\n\n"
648 
649 			"E-tag set forwarding (on|off) port (port_id)\n"
650 			"    Enable/disable E-tag based forwarding"
651 			" on a port\n\n"
652 
653 			"E-tag set filter add e-tag-id (value) dst-pool"
654 			" (pool_id) port (port_id)\n"
655 			"    Add an E-tag forwarding filter on a port\n\n"
656 
657 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
658 			"    Delete an E-tag forwarding filter on a port\n\n"
659 
660 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
661 			"    Load a profile package on a port\n\n"
662 
663 			"ddp del (port_id) (backup_profile_path)\n"
664 			"    Delete a profile package from a port\n\n"
665 
666 			"ptype mapping get (port_id) (valid_only)\n"
667 			"    Get ptype mapping on a port\n\n"
668 
669 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
670 			"    Replace target with the pkt_type in ptype mapping\n\n"
671 
672 			"ptype mapping reset (port_id)\n"
673 			"    Reset ptype mapping on a port\n\n"
674 
675 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
676 			"    Update a ptype mapping item on a port\n\n"
677 
678 			"set port (port_id) queue-region region_id (value) "
679 			"queue_start_index (value) queue_num (value)\n"
680 			"    Set a queue region on a port\n\n"
681 
682 			"set port (port_id) queue-region region_id (value) "
683 			"flowtype (value)\n"
684 			"    Set a flowtype region index on a port\n\n"
685 
686 			"set port (port_id) queue-region UP (value) region_id (value)\n"
687 			"    Set the mapping of User Priority to "
688 			"queue region on a port\n\n"
689 
690 			"set port (port_id) queue-region flush (on|off)\n"
691 			"    flush all queue region related configuration\n\n"
692 
693 			"show port meter cap (port_id)\n"
694 			"    Show port meter capability information\n\n"
695 
696 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
697 			"    meter profile add - srtcm rfc 2697\n\n"
698 
699 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
700 			"    meter profile add - trtcm rfc 2698\n\n"
701 
702 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
703 			"    meter profile add - trtcm rfc 4115\n\n"
704 
705 			"del port meter profile (port_id) (profile_id)\n"
706 			"    meter profile delete\n\n"
707 
708 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
709 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
710 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
711 			"(dscp_tbl_entry63)]\n"
712 			"    meter create\n\n"
713 
714 			"enable port meter (port_id) (mtr_id)\n"
715 			"    meter enable\n\n"
716 
717 			"disable port meter (port_id) (mtr_id)\n"
718 			"    meter disable\n\n"
719 
720 			"del port meter (port_id) (mtr_id)\n"
721 			"    meter delete\n\n"
722 
723 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
724 			"    meter update meter profile\n\n"
725 
726 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
727 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
728 			"    update meter dscp table entries\n\n"
729 
730 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
731 			"(action0) [(action1) (action2)]\n"
732 			"    meter update policer action\n\n"
733 
734 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
735 			"    meter update stats\n\n"
736 
737 			"show port (port_id) queue-region\n"
738 			"    show all queue region related configuration info\n\n"
739 
740 			, list_pkt_forwarding_modes()
741 		);
742 	}
743 
744 	if (show_all || !strcmp(res->section, "ports")) {
745 
746 		cmdline_printf(
747 			cl,
748 			"\n"
749 			"Port Operations:\n"
750 			"----------------\n\n"
751 
752 			"port start (port_id|all)\n"
753 			"    Start all ports or port_id.\n\n"
754 
755 			"port stop (port_id|all)\n"
756 			"    Stop all ports or port_id.\n\n"
757 
758 			"port close (port_id|all)\n"
759 			"    Close all ports or port_id.\n\n"
760 
761 			"port attach (ident)\n"
762 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
763 
764 			"port detach (port_id)\n"
765 			"    Detach physical or virtual dev by port_id\n\n"
766 
767 			"port config (port_id|all)"
768 			" speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
769 			" duplex (half|full|auto)\n"
770 			"    Set speed and duplex for all ports or port_id\n\n"
771 
772 			"port config (port_id|all) loopback (mode)\n"
773 			"    Set loopback mode for all ports or port_id\n\n"
774 
775 			"port config all (rxq|txq|rxd|txd) (value)\n"
776 			"    Set number for rxq/txq/rxd/txd.\n\n"
777 
778 			"port config all max-pkt-len (value)\n"
779 			"    Set the max packet length.\n\n"
780 
781 			"port config all drop-en (on|off)\n"
782 			"    Enable or disable packet drop on all RX queues of all ports when no "
783 			"receive buffers available.\n\n"
784 
785 			"port config all rss (all|default|ip|tcp|udp|sctp|"
786 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
787 			"    Set the RSS mode.\n\n"
788 
789 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
790 			"    Set the RSS redirection table.\n\n"
791 
792 			"port config (port_id) dcb vt (on|off) (traffic_class)"
793 			" pfc (on|off)\n"
794 			"    Set the DCB mode.\n\n"
795 
796 			"port config all burst (value)\n"
797 			"    Set the number of packets per burst.\n\n"
798 
799 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
800 			" (value)\n"
801 			"    Set the ring prefetch/host/writeback threshold"
802 			" for tx/rx queue.\n\n"
803 
804 			"port config all (txfreet|txrst|rxfreet) (value)\n"
805 			"    Set free threshold for rx/tx, or set"
806 			" tx rs bit threshold.\n\n"
807 			"port config mtu X value\n"
808 			"    Set the MTU of port X to a given value\n\n"
809 
810 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
811 			"    Set a rx/tx queue's ring size configuration, the new"
812 			" value will take effect after command that (re-)start the port"
813 			" or command that setup the specific queue\n\n"
814 
815 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
816 			"    Start/stop a rx/tx queue of port X. Only take effect"
817 			" when port X is started\n\n"
818 
819 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
820 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
821 			" take effect when port X is stopped.\n\n"
822 
823 			"port (port_id) (rxq|txq) (queue_id) setup\n"
824 			"    Setup a rx/tx queue of port X.\n\n"
825 
826 			"port config (port_id|all) l2-tunnel E-tag ether-type"
827 			" (value)\n"
828 			"    Set the value of E-tag ether-type.\n\n"
829 
830 			"port config (port_id|all) l2-tunnel E-tag"
831 			" (enable|disable)\n"
832 			"    Enable/disable the E-tag support.\n\n"
833 
834 			"port config (port_id) pctype mapping reset\n"
835 			"    Reset flow type to pctype mapping on a port\n\n"
836 
837 			"port config (port_id) pctype mapping update"
838 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
839 			"    Update a flow type to pctype mapping item on a port\n\n"
840 
841 			"port config (port_id) pctype (pctype_id) hash_inset|"
842 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
843 			" (field_idx)\n"
844 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
845 
846 			"port config (port_id) pctype (pctype_id) hash_inset|"
847 			"fdir_inset|fdir_flx_inset clear all"
848 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
849 
850 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
851 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
852 
853 			"port config <port_id> rx_offload vlan_strip|"
854 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
855 			"outer_ipv4_cksum|macsec_strip|header_split|"
856 			"vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
857 			"scatter|timestamp|security|keep_crc on|off\n"
858 			"     Enable or disable a per port Rx offloading"
859 			" on all Rx queues of a port\n\n"
860 
861 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
862 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 			"outer_ipv4_cksum|macsec_strip|header_split|"
864 			"vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
865 			"scatter|timestamp|security|keep_crc on|off\n"
866 			"    Enable or disable a per queue Rx offloading"
867 			" only on a specific Rx queue\n\n"
868 
869 			"port config (port_id) tx_offload vlan_insert|"
870 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
871 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
872 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
873 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
874 			"security|match_metadata on|off\n"
875 			"    Enable or disable a per port Tx offloading"
876 			" on all Tx queues of a port\n\n"
877 
878 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
879 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
880 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
881 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
882 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
883 			" on|off\n"
884 			"    Enable or disable a per queue Tx offloading"
885 			" only on a specific Tx queue\n\n"
886 
887 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
888 			"    Load an eBPF program as a callback"
889 			" for particular RX/TX queue\n\n"
890 
891 			"bpf-unload rx|tx (port) (queue)\n"
892 			"    Unload previously loaded eBPF program"
893 			" for particular RX/TX queue\n\n"
894 
895 			"port config (port_id) tx_metadata (value)\n"
896 			"    Set Tx metadata value per port. Testpmd will add this value"
897 			" to any Tx packet sent from this port\n\n"
898 		);
899 	}
900 
901 	if (show_all || !strcmp(res->section, "registers")) {
902 
903 		cmdline_printf(
904 			cl,
905 			"\n"
906 			"Registers:\n"
907 			"----------\n\n"
908 
909 			"read reg (port_id) (address)\n"
910 			"    Display value of a port register.\n\n"
911 
912 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
913 			"    Display a port register bit field.\n\n"
914 
915 			"read regbit (port_id) (address) (bit_x)\n"
916 			"    Display a single port register bit.\n\n"
917 
918 			"write reg (port_id) (address) (value)\n"
919 			"    Set value of a port register.\n\n"
920 
921 			"write regfield (port_id) (address) (bit_x) (bit_y)"
922 			" (value)\n"
923 			"    Set bit field of a port register.\n\n"
924 
925 			"write regbit (port_id) (address) (bit_x) (value)\n"
926 			"    Set single bit value of a port register.\n\n"
927 		);
928 	}
929 	if (show_all || !strcmp(res->section, "filters")) {
930 
931 		cmdline_printf(
932 			cl,
933 			"\n"
934 			"filters:\n"
935 			"--------\n\n"
936 
937 			"ethertype_filter (port_id) (add|del)"
938 			" (mac_addr|mac_ignr) (mac_address) ethertype"
939 			" (ether_type) (drop|fwd) queue (queue_id)\n"
940 			"    Add/Del an ethertype filter.\n\n"
941 
942 			"2tuple_filter (port_id) (add|del)"
943 			" dst_port (dst_port_value) protocol (protocol_value)"
944 			" mask (mask_value) tcp_flags (tcp_flags_value)"
945 			" priority (prio_value) queue (queue_id)\n"
946 			"    Add/Del a 2tuple filter.\n\n"
947 
948 			"5tuple_filter (port_id) (add|del)"
949 			" dst_ip (dst_address) src_ip (src_address)"
950 			" dst_port (dst_port_value) src_port (src_port_value)"
951 			" protocol (protocol_value)"
952 			" mask (mask_value) tcp_flags (tcp_flags_value)"
953 			" priority (prio_value) queue (queue_id)\n"
954 			"    Add/Del a 5tuple filter.\n\n"
955 
956 			"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
957 			"    Add/Del syn filter.\n\n"
958 
959 			"flex_filter (port_id) (add|del) len (len_value)"
960 			" bytes (bytes_value) mask (mask_value)"
961 			" priority (prio_value) queue (queue_id)\n"
962 			"    Add/Del a flex filter.\n\n"
963 
964 			"flow_director_filter (port_id) mode IP (add|del|update)"
965 			" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
966 			" src (src_ip_address) dst (dst_ip_address)"
967 			" tos (tos_value) proto (proto_value) ttl (ttl_value)"
968 			" vlan (vlan_value) flexbytes (flexbytes_value)"
969 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
970 			" fd_id (fd_id_value)\n"
971 			"    Add/Del an IP type flow director filter.\n\n"
972 
973 			"flow_director_filter (port_id) mode IP (add|del|update)"
974 			" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
975 			" src (src_ip_address) (src_port)"
976 			" dst (dst_ip_address) (dst_port)"
977 			" tos (tos_value) ttl (ttl_value)"
978 			" vlan (vlan_value) flexbytes (flexbytes_value)"
979 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
980 			" fd_id (fd_id_value)\n"
981 			"    Add/Del an UDP/TCP type flow director filter.\n\n"
982 
983 			"flow_director_filter (port_id) mode IP (add|del|update)"
984 			" flow (ipv4-sctp|ipv6-sctp)"
985 			" src (src_ip_address) (src_port)"
986 			" dst (dst_ip_address) (dst_port)"
987 			" tag (verification_tag) "
988 			" tos (tos_value) ttl (ttl_value)"
989 			" vlan (vlan_value)"
990 			" flexbytes (flexbytes_value) (drop|fwd)"
991 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
992 			"    Add/Del a SCTP type flow director filter.\n\n"
993 
994 			"flow_director_filter (port_id) mode IP (add|del|update)"
995 			" flow l2_payload ether (ethertype)"
996 			" flexbytes (flexbytes_value) (drop|fwd)"
997 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
998 			"    Add/Del a l2 payload type flow director filter.\n\n"
999 
1000 			"flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1001 			" mac (mac_address) vlan (vlan_value)"
1002 			" flexbytes (flexbytes_value) (drop|fwd)"
1003 			" queue (queue_id) fd_id (fd_id_value)\n"
1004 			"    Add/Del a MAC-VLAN flow director filter.\n\n"
1005 
1006 			"flow_director_filter (port_id) mode Tunnel (add|del|update)"
1007 			" mac (mac_address) vlan (vlan_value)"
1008 			" tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1009 			" flexbytes (flexbytes_value) (drop|fwd)"
1010 			" queue (queue_id) fd_id (fd_id_value)\n"
1011 			"    Add/Del a Tunnel flow director filter.\n\n"
1012 
1013 			"flow_director_filter (port_id) mode raw (add|del|update)"
1014 			" flow (flow_id) (drop|fwd) queue (queue_id)"
1015 			" fd_id (fd_id_value) packet (packet file name)\n"
1016 			"    Add/Del a raw type flow director filter.\n\n"
1017 
1018 			"flush_flow_director (port_id)\n"
1019 			"    Flush all flow director entries of a device.\n\n"
1020 
1021 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
1022 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
1023 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1024 			"    Set flow director IP mask.\n\n"
1025 
1026 			"flow_director_mask (port_id) mode MAC-VLAN"
1027 			" vlan (vlan_value)\n"
1028 			"    Set flow director MAC-VLAN mask.\n\n"
1029 
1030 			"flow_director_mask (port_id) mode Tunnel"
1031 			" vlan (vlan_value) mac (mac_value)"
1032 			" tunnel-type (tunnel_type_value)"
1033 			" tunnel-id (tunnel_id_value)\n"
1034 			"    Set flow director Tunnel mask.\n\n"
1035 
1036 			"flow_director_flex_mask (port_id)"
1037 			" flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1038 			"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1039 			" (mask)\n"
1040 			"    Configure mask of flex payload.\n\n"
1041 
1042 			"flow_director_flex_payload (port_id)"
1043 			" (raw|l2|l3|l4) (config)\n"
1044 			"    Configure flex payload selection.\n\n"
1045 
1046 			"get_sym_hash_ena_per_port (port_id)\n"
1047 			"    get symmetric hash enable configuration per port.\n\n"
1048 
1049 			"set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1050 			"    set symmetric hash enable configuration per port"
1051 			" to enable or disable.\n\n"
1052 
1053 			"get_hash_global_config (port_id)\n"
1054 			"    Get the global configurations of hash filters.\n\n"
1055 
1056 			"set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1057 			" (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1058 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1059 			" (enable|disable)\n"
1060 			"    Set the global configurations of hash filters.\n\n"
1061 
1062 			"set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1063 			"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1064 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1065 			"l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1066 			"src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1067 			"ipv6-next-header|udp-src-port|udp-dst-port|"
1068 			"tcp-src-port|tcp-dst-port|sctp-src-port|"
1069 			"sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1070 			"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1071 			"fld-8th|none) (select|add)\n"
1072 			"    Set the input set for hash.\n\n"
1073 
1074 			"set_fdir_input_set (port_id) "
1075 			"(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1076 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 			"l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1078 			"dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1079 			"ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1080 			"udp-dst-port|tcp-src-port|tcp-dst-port|"
1081 			"sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1082 			" (select|add)\n"
1083 			"    Set the input set for FDir.\n\n"
1084 
1085 			"flow validate {port_id}"
1086 			" [group {group_id}] [priority {level}]"
1087 			" [ingress] [egress]"
1088 			" pattern {item} [/ {item} [...]] / end"
1089 			" actions {action} [/ {action} [...]] / end\n"
1090 			"    Check whether a flow rule can be created.\n\n"
1091 
1092 			"flow create {port_id}"
1093 			" [group {group_id}] [priority {level}]"
1094 			" [ingress] [egress]"
1095 			" pattern {item} [/ {item} [...]] / end"
1096 			" actions {action} [/ {action} [...]] / end\n"
1097 			"    Create a flow rule.\n\n"
1098 
1099 			"flow destroy {port_id} rule {rule_id} [...]\n"
1100 			"    Destroy specific flow rules.\n\n"
1101 
1102 			"flow flush {port_id}\n"
1103 			"    Destroy all flow rules.\n\n"
1104 
1105 			"flow query {port_id} {rule_id} {action}\n"
1106 			"    Query an existing flow rule.\n\n"
1107 
1108 			"flow list {port_id} [group {group_id}] [...]\n"
1109 			"    List existing flow rules sorted by priority,"
1110 			" filtered by group identifiers.\n\n"
1111 
1112 			"flow isolate {port_id} {boolean}\n"
1113 			"    Restrict ingress traffic to the defined"
1114 			" flow rules\n\n"
1115 
1116 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1117 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1118 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1119 			"       Configure the VXLAN encapsulation for flows.\n\n"
1120 
1121 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1122 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1123 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1124 			" eth-dst (eth-dst)\n"
1125 			"       Configure the VXLAN encapsulation for flows.\n\n"
1126 
1127 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1128 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1129 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1130 			" eth-dst (eth-dst)\n"
1131 			"       Configure the VXLAN encapsulation for flows.\n\n"
1132 
1133 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1134 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1135 			" (eth-dst)\n"
1136 			"       Configure the NVGRE encapsulation for flows.\n\n"
1137 
1138 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1139 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1140 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1141 			"       Configure the NVGRE encapsulation for flows.\n\n"
1142 
1143 			"set raw_encap {flow items}\n"
1144 			"	Configure the encapsulation with raw data.\n\n"
1145 
1146 			"set raw_decap {flow items}\n"
1147 			"	Configure the decapsulation with raw data.\n\n"
1148 
1149 		);
1150 	}
1151 
1152 	if (show_all || !strcmp(res->section, "traffic_management")) {
1153 		cmdline_printf(
1154 			cl,
1155 			"\n"
1156 			"Traffic Management:\n"
1157 			"--------------\n"
1158 			"show port tm cap (port_id)\n"
1159 			"       Display the port TM capability.\n\n"
1160 
1161 			"show port tm level cap (port_id) (level_id)\n"
1162 			"       Display the port TM hierarchical level capability.\n\n"
1163 
1164 			"show port tm node cap (port_id) (node_id)\n"
1165 			"       Display the port TM node capability.\n\n"
1166 
1167 			"show port tm node type (port_id) (node_id)\n"
1168 			"       Display the port TM node type.\n\n"
1169 
1170 			"show port tm node stats (port_id) (node_id) (clear)\n"
1171 			"       Display the port TM node stats.\n\n"
1172 
1173 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1174 			"set port tm hierarchy default (port_id)\n"
1175 			"       Set default traffic Management hierarchy on a port\n\n"
1176 #endif
1177 
1178 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1179 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1180 			" (packet_length_adjust)\n"
1181 			"       Add port tm node private shaper profile.\n\n"
1182 
1183 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1184 			"       Delete port tm node private shaper profile.\n\n"
1185 
1186 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1187 			" (shaper_profile_id)\n"
1188 			"       Add/update port tm node shared shaper.\n\n"
1189 
1190 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1191 			"       Delete port tm node shared shaper.\n\n"
1192 
1193 			"set port tm node shaper profile (port_id) (node_id)"
1194 			" (shaper_profile_id)\n"
1195 			"       Set port tm node shaper profile.\n\n"
1196 
1197 			"add port tm node wred profile (port_id) (wred_profile_id)"
1198 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1199 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1200 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1201 			"       Add port tm node wred profile.\n\n"
1202 
1203 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1204 			"       Delete port tm node wred profile.\n\n"
1205 
1206 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1207 			" (priority) (weight) (level_id) (shaper_profile_id)"
1208 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1209 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1210 			"       Add port tm nonleaf node.\n\n"
1211 
1212 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1213 			" (priority) (weight) (level_id) (shaper_profile_id)"
1214 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1215 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1216 			"       Add port tm leaf node.\n\n"
1217 
1218 			"del port tm node (port_id) (node_id)\n"
1219 			"       Delete port tm node.\n\n"
1220 
1221 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1222 			" (priority) (weight)\n"
1223 			"       Set port tm node parent.\n\n"
1224 
1225 			"suspend port tm node (port_id) (node_id)"
1226 			"       Suspend tm node.\n\n"
1227 
1228 			"resume port tm node (port_id) (node_id)"
1229 			"       Resume tm node.\n\n"
1230 
1231 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1232 			"       Commit tm hierarchy.\n\n"
1233 
1234 			"set port tm mark ip_ecn (port) (green) (yellow)"
1235 			" (red)\n"
1236 			"    Enables/Disables the traffic management marking"
1237 			" for IP ECN (Explicit Congestion Notification)"
1238 			" packets on a given port\n\n"
1239 
1240 			"set port tm mark ip_dscp (port) (green) (yellow)"
1241 			" (red)\n"
1242 			"    Enables/Disables the traffic management marking"
1243 			" on the port for IP dscp packets\n\n"
1244 
1245 			"set port tm mark vlan_dei (port) (green) (yellow)"
1246 			" (red)\n"
1247 			"    Enables/Disables the traffic management marking"
1248 			" on the port for VLAN packets with DEI enabled\n\n"
1249 		);
1250 	}
1251 
1252 	if (show_all || !strcmp(res->section, "devices")) {
1253 		cmdline_printf(
1254 			cl,
1255 			"\n"
1256 			"Device Operations:\n"
1257 			"--------------\n"
1258 			"device detach (identifier)\n"
1259 			"       Detach device by identifier.\n\n"
1260 		);
1261 	}
1262 
1263 }
1264 
1265 cmdline_parse_token_string_t cmd_help_long_help =
1266 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1267 
1268 cmdline_parse_token_string_t cmd_help_long_section =
1269 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1270 			"all#control#display#config#"
1271 			"ports#registers#filters#traffic_management#devices");
1272 
1273 cmdline_parse_inst_t cmd_help_long = {
1274 	.f = cmd_help_long_parsed,
1275 	.data = NULL,
1276 	.help_str = "help all|control|display|config|ports|register|"
1277 		"filters|traffic_management|devices: "
1278 		"Show help",
1279 	.tokens = {
1280 		(void *)&cmd_help_long_help,
1281 		(void *)&cmd_help_long_section,
1282 		NULL,
1283 	},
1284 };
1285 
1286 
1287 /* *** start/stop/close all ports *** */
1288 struct cmd_operate_port_result {
1289 	cmdline_fixed_string_t keyword;
1290 	cmdline_fixed_string_t name;
1291 	cmdline_fixed_string_t value;
1292 };
1293 
1294 static void cmd_operate_port_parsed(void *parsed_result,
1295 				__attribute__((unused)) struct cmdline *cl,
1296 				__attribute__((unused)) void *data)
1297 {
1298 	struct cmd_operate_port_result *res = parsed_result;
1299 
1300 	if (!strcmp(res->name, "start"))
1301 		start_port(RTE_PORT_ALL);
1302 	else if (!strcmp(res->name, "stop"))
1303 		stop_port(RTE_PORT_ALL);
1304 	else if (!strcmp(res->name, "close"))
1305 		close_port(RTE_PORT_ALL);
1306 	else if (!strcmp(res->name, "reset"))
1307 		reset_port(RTE_PORT_ALL);
1308 	else
1309 		printf("Unknown parameter\n");
1310 }
1311 
1312 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1313 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1314 								"port");
1315 cmdline_parse_token_string_t cmd_operate_port_all_port =
1316 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1317 						"start#stop#close#reset");
1318 cmdline_parse_token_string_t cmd_operate_port_all_all =
1319 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1320 
1321 cmdline_parse_inst_t cmd_operate_port = {
1322 	.f = cmd_operate_port_parsed,
1323 	.data = NULL,
1324 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1325 	.tokens = {
1326 		(void *)&cmd_operate_port_all_cmd,
1327 		(void *)&cmd_operate_port_all_port,
1328 		(void *)&cmd_operate_port_all_all,
1329 		NULL,
1330 	},
1331 };
1332 
1333 /* *** start/stop/close specific port *** */
1334 struct cmd_operate_specific_port_result {
1335 	cmdline_fixed_string_t keyword;
1336 	cmdline_fixed_string_t name;
1337 	uint8_t value;
1338 };
1339 
1340 static void cmd_operate_specific_port_parsed(void *parsed_result,
1341 			__attribute__((unused)) struct cmdline *cl,
1342 				__attribute__((unused)) void *data)
1343 {
1344 	struct cmd_operate_specific_port_result *res = parsed_result;
1345 
1346 	if (!strcmp(res->name, "start"))
1347 		start_port(res->value);
1348 	else if (!strcmp(res->name, "stop"))
1349 		stop_port(res->value);
1350 	else if (!strcmp(res->name, "close"))
1351 		close_port(res->value);
1352 	else if (!strcmp(res->name, "reset"))
1353 		reset_port(res->value);
1354 	else
1355 		printf("Unknown parameter\n");
1356 }
1357 
1358 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1359 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1360 							keyword, "port");
1361 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1362 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1363 						name, "start#stop#close#reset");
1364 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1365 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1366 							value, UINT8);
1367 
1368 cmdline_parse_inst_t cmd_operate_specific_port = {
1369 	.f = cmd_operate_specific_port_parsed,
1370 	.data = NULL,
1371 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1372 	.tokens = {
1373 		(void *)&cmd_operate_specific_port_cmd,
1374 		(void *)&cmd_operate_specific_port_port,
1375 		(void *)&cmd_operate_specific_port_id,
1376 		NULL,
1377 	},
1378 };
1379 
1380 /* *** enable port setup (after attach) via iterator or event *** */
1381 struct cmd_set_port_setup_on_result {
1382 	cmdline_fixed_string_t set;
1383 	cmdline_fixed_string_t port;
1384 	cmdline_fixed_string_t setup;
1385 	cmdline_fixed_string_t on;
1386 	cmdline_fixed_string_t mode;
1387 };
1388 
1389 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1390 				__attribute__((unused)) struct cmdline *cl,
1391 				__attribute__((unused)) void *data)
1392 {
1393 	struct cmd_set_port_setup_on_result *res = parsed_result;
1394 
1395 	if (strcmp(res->mode, "event") == 0)
1396 		setup_on_probe_event = true;
1397 	else if (strcmp(res->mode, "iterator") == 0)
1398 		setup_on_probe_event = false;
1399 	else
1400 		printf("Unknown mode\n");
1401 }
1402 
1403 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1404 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1405 			set, "set");
1406 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1407 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 			port, "port");
1409 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1410 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 			setup, "setup");
1412 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1413 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1414 			on, "on");
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1416 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 			mode, "iterator#event");
1418 
1419 cmdline_parse_inst_t cmd_set_port_setup_on = {
1420 	.f = cmd_set_port_setup_on_parsed,
1421 	.data = NULL,
1422 	.help_str = "set port setup on iterator|event",
1423 	.tokens = {
1424 		(void *)&cmd_set_port_setup_on_set,
1425 		(void *)&cmd_set_port_setup_on_port,
1426 		(void *)&cmd_set_port_setup_on_setup,
1427 		(void *)&cmd_set_port_setup_on_on,
1428 		(void *)&cmd_set_port_setup_on_mode,
1429 		NULL,
1430 	},
1431 };
1432 
1433 /* *** attach a specified port *** */
1434 struct cmd_operate_attach_port_result {
1435 	cmdline_fixed_string_t port;
1436 	cmdline_fixed_string_t keyword;
1437 	cmdline_fixed_string_t identifier;
1438 };
1439 
1440 static void cmd_operate_attach_port_parsed(void *parsed_result,
1441 				__attribute__((unused)) struct cmdline *cl,
1442 				__attribute__((unused)) void *data)
1443 {
1444 	struct cmd_operate_attach_port_result *res = parsed_result;
1445 
1446 	if (!strcmp(res->keyword, "attach"))
1447 		attach_port(res->identifier);
1448 	else
1449 		printf("Unknown parameter\n");
1450 }
1451 
1452 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1453 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1454 			port, "port");
1455 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1456 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1457 			keyword, "attach");
1458 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1459 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1460 			identifier, NULL);
1461 
1462 cmdline_parse_inst_t cmd_operate_attach_port = {
1463 	.f = cmd_operate_attach_port_parsed,
1464 	.data = NULL,
1465 	.help_str = "port attach <identifier>: "
1466 		"(identifier: pci address or virtual dev name)",
1467 	.tokens = {
1468 		(void *)&cmd_operate_attach_port_port,
1469 		(void *)&cmd_operate_attach_port_keyword,
1470 		(void *)&cmd_operate_attach_port_identifier,
1471 		NULL,
1472 	},
1473 };
1474 
1475 /* *** detach a specified port *** */
1476 struct cmd_operate_detach_port_result {
1477 	cmdline_fixed_string_t port;
1478 	cmdline_fixed_string_t keyword;
1479 	portid_t port_id;
1480 };
1481 
1482 static void cmd_operate_detach_port_parsed(void *parsed_result,
1483 				__attribute__((unused)) struct cmdline *cl,
1484 				__attribute__((unused)) void *data)
1485 {
1486 	struct cmd_operate_detach_port_result *res = parsed_result;
1487 
1488 	if (!strcmp(res->keyword, "detach"))
1489 		detach_port_device(res->port_id);
1490 	else
1491 		printf("Unknown parameter\n");
1492 }
1493 
1494 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1495 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1496 			port, "port");
1497 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1498 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1499 			keyword, "detach");
1500 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1501 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1502 			port_id, UINT16);
1503 
1504 cmdline_parse_inst_t cmd_operate_detach_port = {
1505 	.f = cmd_operate_detach_port_parsed,
1506 	.data = NULL,
1507 	.help_str = "port detach <port_id>",
1508 	.tokens = {
1509 		(void *)&cmd_operate_detach_port_port,
1510 		(void *)&cmd_operate_detach_port_keyword,
1511 		(void *)&cmd_operate_detach_port_port_id,
1512 		NULL,
1513 	},
1514 };
1515 
1516 /* *** detach device by identifier *** */
1517 struct cmd_operate_detach_device_result {
1518 	cmdline_fixed_string_t device;
1519 	cmdline_fixed_string_t keyword;
1520 	cmdline_fixed_string_t identifier;
1521 };
1522 
1523 static void cmd_operate_detach_device_parsed(void *parsed_result,
1524 				__attribute__((unused)) struct cmdline *cl,
1525 				__attribute__((unused)) void *data)
1526 {
1527 	struct cmd_operate_detach_device_result *res = parsed_result;
1528 
1529 	if (!strcmp(res->keyword, "detach"))
1530 		detach_device(res->identifier);
1531 	else
1532 		printf("Unknown parameter\n");
1533 }
1534 
1535 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1536 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1537 			device, "device");
1538 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1539 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1540 			keyword, "detach");
1541 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1542 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1543 			identifier, NULL);
1544 
1545 cmdline_parse_inst_t cmd_operate_detach_device = {
1546 	.f = cmd_operate_detach_device_parsed,
1547 	.data = NULL,
1548 	.help_str = "device detach <identifier>:"
1549 		"(identifier: pci address or virtual dev name)",
1550 	.tokens = {
1551 		(void *)&cmd_operate_detach_device_device,
1552 		(void *)&cmd_operate_detach_device_keyword,
1553 		(void *)&cmd_operate_detach_device_identifier,
1554 		NULL,
1555 	},
1556 };
1557 /* *** configure speed for all ports *** */
1558 struct cmd_config_speed_all {
1559 	cmdline_fixed_string_t port;
1560 	cmdline_fixed_string_t keyword;
1561 	cmdline_fixed_string_t all;
1562 	cmdline_fixed_string_t item1;
1563 	cmdline_fixed_string_t item2;
1564 	cmdline_fixed_string_t value1;
1565 	cmdline_fixed_string_t value2;
1566 };
1567 
1568 static int
1569 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1570 {
1571 
1572 	int duplex;
1573 
1574 	if (!strcmp(duplexstr, "half")) {
1575 		duplex = ETH_LINK_HALF_DUPLEX;
1576 	} else if (!strcmp(duplexstr, "full")) {
1577 		duplex = ETH_LINK_FULL_DUPLEX;
1578 	} else if (!strcmp(duplexstr, "auto")) {
1579 		duplex = ETH_LINK_FULL_DUPLEX;
1580 	} else {
1581 		printf("Unknown duplex parameter\n");
1582 		return -1;
1583 	}
1584 
1585 	if (!strcmp(speedstr, "10")) {
1586 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1587 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1588 	} else if (!strcmp(speedstr, "100")) {
1589 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1590 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1591 	} else {
1592 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1593 			printf("Invalid speed/duplex parameters\n");
1594 			return -1;
1595 		}
1596 		if (!strcmp(speedstr, "1000")) {
1597 			*speed = ETH_LINK_SPEED_1G;
1598 		} else if (!strcmp(speedstr, "10000")) {
1599 			*speed = ETH_LINK_SPEED_10G;
1600 		} else if (!strcmp(speedstr, "25000")) {
1601 			*speed = ETH_LINK_SPEED_25G;
1602 		} else if (!strcmp(speedstr, "40000")) {
1603 			*speed = ETH_LINK_SPEED_40G;
1604 		} else if (!strcmp(speedstr, "50000")) {
1605 			*speed = ETH_LINK_SPEED_50G;
1606 		} else if (!strcmp(speedstr, "100000")) {
1607 			*speed = ETH_LINK_SPEED_100G;
1608 		} else if (!strcmp(speedstr, "auto")) {
1609 			*speed = ETH_LINK_SPEED_AUTONEG;
1610 		} else {
1611 			printf("Unknown speed parameter\n");
1612 			return -1;
1613 		}
1614 	}
1615 
1616 	return 0;
1617 }
1618 
1619 static void
1620 cmd_config_speed_all_parsed(void *parsed_result,
1621 			__attribute__((unused)) struct cmdline *cl,
1622 			__attribute__((unused)) void *data)
1623 {
1624 	struct cmd_config_speed_all *res = parsed_result;
1625 	uint32_t link_speed;
1626 	portid_t pid;
1627 
1628 	if (!all_ports_stopped()) {
1629 		printf("Please stop all ports first\n");
1630 		return;
1631 	}
1632 
1633 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1634 			&link_speed) < 0)
1635 		return;
1636 
1637 	RTE_ETH_FOREACH_DEV(pid) {
1638 		ports[pid].dev_conf.link_speeds = link_speed;
1639 	}
1640 
1641 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1642 }
1643 
1644 cmdline_parse_token_string_t cmd_config_speed_all_port =
1645 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1646 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1647 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1648 							"config");
1649 cmdline_parse_token_string_t cmd_config_speed_all_all =
1650 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1651 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1652 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1653 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1654 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1655 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1656 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1657 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1658 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1659 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1660 						"half#full#auto");
1661 
1662 cmdline_parse_inst_t cmd_config_speed_all = {
1663 	.f = cmd_config_speed_all_parsed,
1664 	.data = NULL,
1665 	.help_str = "port config all speed "
1666 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1667 							"half|full|auto",
1668 	.tokens = {
1669 		(void *)&cmd_config_speed_all_port,
1670 		(void *)&cmd_config_speed_all_keyword,
1671 		(void *)&cmd_config_speed_all_all,
1672 		(void *)&cmd_config_speed_all_item1,
1673 		(void *)&cmd_config_speed_all_value1,
1674 		(void *)&cmd_config_speed_all_item2,
1675 		(void *)&cmd_config_speed_all_value2,
1676 		NULL,
1677 	},
1678 };
1679 
1680 /* *** configure speed for specific port *** */
1681 struct cmd_config_speed_specific {
1682 	cmdline_fixed_string_t port;
1683 	cmdline_fixed_string_t keyword;
1684 	portid_t id;
1685 	cmdline_fixed_string_t item1;
1686 	cmdline_fixed_string_t item2;
1687 	cmdline_fixed_string_t value1;
1688 	cmdline_fixed_string_t value2;
1689 };
1690 
1691 static void
1692 cmd_config_speed_specific_parsed(void *parsed_result,
1693 				__attribute__((unused)) struct cmdline *cl,
1694 				__attribute__((unused)) void *data)
1695 {
1696 	struct cmd_config_speed_specific *res = parsed_result;
1697 	uint32_t link_speed;
1698 
1699 	if (!all_ports_stopped()) {
1700 		printf("Please stop all ports first\n");
1701 		return;
1702 	}
1703 
1704 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1705 		return;
1706 
1707 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1708 			&link_speed) < 0)
1709 		return;
1710 
1711 	ports[res->id].dev_conf.link_speeds = link_speed;
1712 
1713 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1714 }
1715 
1716 
1717 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1718 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1719 								"port");
1720 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1721 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1722 								"config");
1723 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1724 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1725 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1726 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1727 								"speed");
1728 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1729 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1730 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1731 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1732 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1733 								"duplex");
1734 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1735 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1736 							"half#full#auto");
1737 
1738 cmdline_parse_inst_t cmd_config_speed_specific = {
1739 	.f = cmd_config_speed_specific_parsed,
1740 	.data = NULL,
1741 	.help_str = "port config <port_id> speed "
1742 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1743 							"half|full|auto",
1744 	.tokens = {
1745 		(void *)&cmd_config_speed_specific_port,
1746 		(void *)&cmd_config_speed_specific_keyword,
1747 		(void *)&cmd_config_speed_specific_id,
1748 		(void *)&cmd_config_speed_specific_item1,
1749 		(void *)&cmd_config_speed_specific_value1,
1750 		(void *)&cmd_config_speed_specific_item2,
1751 		(void *)&cmd_config_speed_specific_value2,
1752 		NULL,
1753 	},
1754 };
1755 
1756 /* *** configure loopback for all ports *** */
1757 struct cmd_config_loopback_all {
1758 	cmdline_fixed_string_t port;
1759 	cmdline_fixed_string_t keyword;
1760 	cmdline_fixed_string_t all;
1761 	cmdline_fixed_string_t item;
1762 	uint32_t mode;
1763 };
1764 
1765 static void
1766 cmd_config_loopback_all_parsed(void *parsed_result,
1767 			__attribute__((unused)) struct cmdline *cl,
1768 			__attribute__((unused)) void *data)
1769 {
1770 	struct cmd_config_loopback_all *res = parsed_result;
1771 	portid_t pid;
1772 
1773 	if (!all_ports_stopped()) {
1774 		printf("Please stop all ports first\n");
1775 		return;
1776 	}
1777 
1778 	RTE_ETH_FOREACH_DEV(pid) {
1779 		ports[pid].dev_conf.lpbk_mode = res->mode;
1780 	}
1781 
1782 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1783 }
1784 
1785 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1786 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1787 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1788 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1789 							"config");
1790 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1791 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1792 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1793 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1794 							"loopback");
1795 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1796 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1797 
1798 cmdline_parse_inst_t cmd_config_loopback_all = {
1799 	.f = cmd_config_loopback_all_parsed,
1800 	.data = NULL,
1801 	.help_str = "port config all loopback <mode>",
1802 	.tokens = {
1803 		(void *)&cmd_config_loopback_all_port,
1804 		(void *)&cmd_config_loopback_all_keyword,
1805 		(void *)&cmd_config_loopback_all_all,
1806 		(void *)&cmd_config_loopback_all_item,
1807 		(void *)&cmd_config_loopback_all_mode,
1808 		NULL,
1809 	},
1810 };
1811 
1812 /* *** configure loopback for specific port *** */
1813 struct cmd_config_loopback_specific {
1814 	cmdline_fixed_string_t port;
1815 	cmdline_fixed_string_t keyword;
1816 	uint16_t port_id;
1817 	cmdline_fixed_string_t item;
1818 	uint32_t mode;
1819 };
1820 
1821 static void
1822 cmd_config_loopback_specific_parsed(void *parsed_result,
1823 				__attribute__((unused)) struct cmdline *cl,
1824 				__attribute__((unused)) void *data)
1825 {
1826 	struct cmd_config_loopback_specific *res = parsed_result;
1827 
1828 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1829 		return;
1830 
1831 	if (!port_is_stopped(res->port_id)) {
1832 		printf("Please stop port %u first\n", res->port_id);
1833 		return;
1834 	}
1835 
1836 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1837 
1838 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1839 }
1840 
1841 
1842 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1843 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1844 								"port");
1845 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1846 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1847 								"config");
1848 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1849 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1850 								UINT16);
1851 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1852 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1853 								"loopback");
1854 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1855 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1856 			      UINT32);
1857 
1858 cmdline_parse_inst_t cmd_config_loopback_specific = {
1859 	.f = cmd_config_loopback_specific_parsed,
1860 	.data = NULL,
1861 	.help_str = "port config <port_id> loopback <mode>",
1862 	.tokens = {
1863 		(void *)&cmd_config_loopback_specific_port,
1864 		(void *)&cmd_config_loopback_specific_keyword,
1865 		(void *)&cmd_config_loopback_specific_id,
1866 		(void *)&cmd_config_loopback_specific_item,
1867 		(void *)&cmd_config_loopback_specific_mode,
1868 		NULL,
1869 	},
1870 };
1871 
1872 /* *** configure txq/rxq, txd/rxd *** */
1873 struct cmd_config_rx_tx {
1874 	cmdline_fixed_string_t port;
1875 	cmdline_fixed_string_t keyword;
1876 	cmdline_fixed_string_t all;
1877 	cmdline_fixed_string_t name;
1878 	uint16_t value;
1879 };
1880 
1881 static void
1882 cmd_config_rx_tx_parsed(void *parsed_result,
1883 			__attribute__((unused)) struct cmdline *cl,
1884 			__attribute__((unused)) void *data)
1885 {
1886 	struct cmd_config_rx_tx *res = parsed_result;
1887 
1888 	if (!all_ports_stopped()) {
1889 		printf("Please stop all ports first\n");
1890 		return;
1891 	}
1892 	if (!strcmp(res->name, "rxq")) {
1893 		if (!res->value && !nb_txq) {
1894 			printf("Warning: Either rx or tx queues should be non zero\n");
1895 			return;
1896 		}
1897 		if (check_nb_rxq(res->value) != 0)
1898 			return;
1899 		nb_rxq = res->value;
1900 	}
1901 	else if (!strcmp(res->name, "txq")) {
1902 		if (!res->value && !nb_rxq) {
1903 			printf("Warning: Either rx or tx queues should be non zero\n");
1904 			return;
1905 		}
1906 		if (check_nb_txq(res->value) != 0)
1907 			return;
1908 		nb_txq = res->value;
1909 	}
1910 	else if (!strcmp(res->name, "rxd")) {
1911 		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1912 			printf("rxd %d invalid - must be > 0 && <= %d\n",
1913 					res->value, RTE_TEST_RX_DESC_MAX);
1914 			return;
1915 		}
1916 		nb_rxd = res->value;
1917 	} else if (!strcmp(res->name, "txd")) {
1918 		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1919 			printf("txd %d invalid - must be > 0 && <= %d\n",
1920 					res->value, RTE_TEST_TX_DESC_MAX);
1921 			return;
1922 		}
1923 		nb_txd = res->value;
1924 	} else {
1925 		printf("Unknown parameter\n");
1926 		return;
1927 	}
1928 
1929 	fwd_config_setup();
1930 
1931 	init_port_config();
1932 
1933 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1934 }
1935 
1936 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1937 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1938 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1939 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1940 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1941 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1942 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1943 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1944 						"rxq#txq#rxd#txd");
1945 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1946 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1947 
1948 cmdline_parse_inst_t cmd_config_rx_tx = {
1949 	.f = cmd_config_rx_tx_parsed,
1950 	.data = NULL,
1951 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1952 	.tokens = {
1953 		(void *)&cmd_config_rx_tx_port,
1954 		(void *)&cmd_config_rx_tx_keyword,
1955 		(void *)&cmd_config_rx_tx_all,
1956 		(void *)&cmd_config_rx_tx_name,
1957 		(void *)&cmd_config_rx_tx_value,
1958 		NULL,
1959 	},
1960 };
1961 
1962 /* *** config max packet length *** */
1963 struct cmd_config_max_pkt_len_result {
1964 	cmdline_fixed_string_t port;
1965 	cmdline_fixed_string_t keyword;
1966 	cmdline_fixed_string_t all;
1967 	cmdline_fixed_string_t name;
1968 	uint32_t value;
1969 };
1970 
1971 static void
1972 cmd_config_max_pkt_len_parsed(void *parsed_result,
1973 				__attribute__((unused)) struct cmdline *cl,
1974 				__attribute__((unused)) void *data)
1975 {
1976 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1977 	portid_t pid;
1978 
1979 	if (!all_ports_stopped()) {
1980 		printf("Please stop all ports first\n");
1981 		return;
1982 	}
1983 
1984 	RTE_ETH_FOREACH_DEV(pid) {
1985 		struct rte_port *port = &ports[pid];
1986 		uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1987 
1988 		if (!strcmp(res->name, "max-pkt-len")) {
1989 			if (res->value < RTE_ETHER_MIN_LEN) {
1990 				printf("max-pkt-len can not be less than %d\n",
1991 						RTE_ETHER_MIN_LEN);
1992 				return;
1993 			}
1994 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1995 				return;
1996 
1997 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1998 			if (res->value > RTE_ETHER_MAX_LEN)
1999 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2000 			else
2001 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2002 			port->dev_conf.rxmode.offloads = rx_offloads;
2003 		} else {
2004 			printf("Unknown parameter\n");
2005 			return;
2006 		}
2007 	}
2008 
2009 	init_port_config();
2010 
2011 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2012 }
2013 
2014 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2015 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2016 								"port");
2017 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2018 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2019 								"config");
2020 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2021 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2022 								"all");
2023 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2024 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2025 								"max-pkt-len");
2026 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2027 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2028 								UINT32);
2029 
2030 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2031 	.f = cmd_config_max_pkt_len_parsed,
2032 	.data = NULL,
2033 	.help_str = "port config all max-pkt-len <value>",
2034 	.tokens = {
2035 		(void *)&cmd_config_max_pkt_len_port,
2036 		(void *)&cmd_config_max_pkt_len_keyword,
2037 		(void *)&cmd_config_max_pkt_len_all,
2038 		(void *)&cmd_config_max_pkt_len_name,
2039 		(void *)&cmd_config_max_pkt_len_value,
2040 		NULL,
2041 	},
2042 };
2043 
2044 /* *** configure port MTU *** */
2045 struct cmd_config_mtu_result {
2046 	cmdline_fixed_string_t port;
2047 	cmdline_fixed_string_t keyword;
2048 	cmdline_fixed_string_t mtu;
2049 	portid_t port_id;
2050 	uint16_t value;
2051 };
2052 
2053 static void
2054 cmd_config_mtu_parsed(void *parsed_result,
2055 		      __attribute__((unused)) struct cmdline *cl,
2056 		      __attribute__((unused)) void *data)
2057 {
2058 	struct cmd_config_mtu_result *res = parsed_result;
2059 
2060 	if (res->value < RTE_ETHER_MIN_LEN) {
2061 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2062 		return;
2063 	}
2064 	port_mtu_set(res->port_id, res->value);
2065 }
2066 
2067 cmdline_parse_token_string_t cmd_config_mtu_port =
2068 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2069 				 "port");
2070 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2071 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2072 				 "config");
2073 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2074 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2075 				 "mtu");
2076 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2077 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2078 cmdline_parse_token_num_t cmd_config_mtu_value =
2079 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2080 
2081 cmdline_parse_inst_t cmd_config_mtu = {
2082 	.f = cmd_config_mtu_parsed,
2083 	.data = NULL,
2084 	.help_str = "port config mtu <port_id> <value>",
2085 	.tokens = {
2086 		(void *)&cmd_config_mtu_port,
2087 		(void *)&cmd_config_mtu_keyword,
2088 		(void *)&cmd_config_mtu_mtu,
2089 		(void *)&cmd_config_mtu_port_id,
2090 		(void *)&cmd_config_mtu_value,
2091 		NULL,
2092 	},
2093 };
2094 
2095 /* *** configure rx mode *** */
2096 struct cmd_config_rx_mode_flag {
2097 	cmdline_fixed_string_t port;
2098 	cmdline_fixed_string_t keyword;
2099 	cmdline_fixed_string_t all;
2100 	cmdline_fixed_string_t name;
2101 	cmdline_fixed_string_t value;
2102 };
2103 
2104 static void
2105 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2106 				__attribute__((unused)) struct cmdline *cl,
2107 				__attribute__((unused)) void *data)
2108 {
2109 	struct cmd_config_rx_mode_flag *res = parsed_result;
2110 
2111 	if (!all_ports_stopped()) {
2112 		printf("Please stop all ports first\n");
2113 		return;
2114 	}
2115 
2116 	if (!strcmp(res->name, "drop-en")) {
2117 		if (!strcmp(res->value, "on"))
2118 			rx_drop_en = 1;
2119 		else if (!strcmp(res->value, "off"))
2120 			rx_drop_en = 0;
2121 		else {
2122 			printf("Unknown parameter\n");
2123 			return;
2124 		}
2125 	} else {
2126 		printf("Unknown parameter\n");
2127 		return;
2128 	}
2129 
2130 	init_port_config();
2131 
2132 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2133 }
2134 
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2136 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2138 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2139 								"config");
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2141 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2142 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2143 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2144 					"drop-en");
2145 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2146 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2147 							"on#off");
2148 
2149 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2150 	.f = cmd_config_rx_mode_flag_parsed,
2151 	.data = NULL,
2152 	.help_str = "port config all drop-en on|off",
2153 	.tokens = {
2154 		(void *)&cmd_config_rx_mode_flag_port,
2155 		(void *)&cmd_config_rx_mode_flag_keyword,
2156 		(void *)&cmd_config_rx_mode_flag_all,
2157 		(void *)&cmd_config_rx_mode_flag_name,
2158 		(void *)&cmd_config_rx_mode_flag_value,
2159 		NULL,
2160 	},
2161 };
2162 
2163 /* *** configure rss *** */
2164 struct cmd_config_rss {
2165 	cmdline_fixed_string_t port;
2166 	cmdline_fixed_string_t keyword;
2167 	cmdline_fixed_string_t all;
2168 	cmdline_fixed_string_t name;
2169 	cmdline_fixed_string_t value;
2170 };
2171 
2172 static void
2173 cmd_config_rss_parsed(void *parsed_result,
2174 			__attribute__((unused)) struct cmdline *cl,
2175 			__attribute__((unused)) void *data)
2176 {
2177 	struct cmd_config_rss *res = parsed_result;
2178 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2179 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2180 	int use_default = 0;
2181 	int all_updated = 1;
2182 	int diag;
2183 	uint16_t i;
2184 	int ret;
2185 
2186 	if (!strcmp(res->value, "all"))
2187 		rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2188 				ETH_RSS_UDP | ETH_RSS_SCTP |
2189 					ETH_RSS_L2_PAYLOAD;
2190 	else if (!strcmp(res->value, "ip"))
2191 		rss_conf.rss_hf = ETH_RSS_IP;
2192 	else if (!strcmp(res->value, "udp"))
2193 		rss_conf.rss_hf = ETH_RSS_UDP;
2194 	else if (!strcmp(res->value, "tcp"))
2195 		rss_conf.rss_hf = ETH_RSS_TCP;
2196 	else if (!strcmp(res->value, "sctp"))
2197 		rss_conf.rss_hf = ETH_RSS_SCTP;
2198 	else if (!strcmp(res->value, "ether"))
2199 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2200 	else if (!strcmp(res->value, "port"))
2201 		rss_conf.rss_hf = ETH_RSS_PORT;
2202 	else if (!strcmp(res->value, "vxlan"))
2203 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2204 	else if (!strcmp(res->value, "geneve"))
2205 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2206 	else if (!strcmp(res->value, "nvgre"))
2207 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2208 	else if (!strcmp(res->value, "none"))
2209 		rss_conf.rss_hf = 0;
2210 	else if (!strcmp(res->value, "default"))
2211 		use_default = 1;
2212 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2213 						atoi(res->value) < 64)
2214 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2215 	else {
2216 		printf("Unknown parameter\n");
2217 		return;
2218 	}
2219 	rss_conf.rss_key = NULL;
2220 	/* Update global configuration for RSS types. */
2221 	RTE_ETH_FOREACH_DEV(i) {
2222 		struct rte_eth_rss_conf local_rss_conf;
2223 
2224 		ret = eth_dev_info_get_print_err(i, &dev_info);
2225 		if (ret != 0)
2226 			return;
2227 
2228 		if (use_default)
2229 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2230 
2231 		local_rss_conf = rss_conf;
2232 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2233 			dev_info.flow_type_rss_offloads;
2234 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2235 			printf("Port %u modified RSS hash function based on hardware support,"
2236 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2237 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2238 		}
2239 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2240 		if (diag < 0) {
2241 			all_updated = 0;
2242 			printf("Configuration of RSS hash at ethernet port %d "
2243 				"failed with error (%d): %s.\n",
2244 				i, -diag, strerror(-diag));
2245 		}
2246 	}
2247 	if (all_updated && !use_default)
2248 		rss_hf = rss_conf.rss_hf;
2249 }
2250 
2251 cmdline_parse_token_string_t cmd_config_rss_port =
2252 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2253 cmdline_parse_token_string_t cmd_config_rss_keyword =
2254 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2255 cmdline_parse_token_string_t cmd_config_rss_all =
2256 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2257 cmdline_parse_token_string_t cmd_config_rss_name =
2258 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2259 cmdline_parse_token_string_t cmd_config_rss_value =
2260 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2261 
2262 cmdline_parse_inst_t cmd_config_rss = {
2263 	.f = cmd_config_rss_parsed,
2264 	.data = NULL,
2265 	.help_str = "port config all rss "
2266 		"all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2267 	.tokens = {
2268 		(void *)&cmd_config_rss_port,
2269 		(void *)&cmd_config_rss_keyword,
2270 		(void *)&cmd_config_rss_all,
2271 		(void *)&cmd_config_rss_name,
2272 		(void *)&cmd_config_rss_value,
2273 		NULL,
2274 	},
2275 };
2276 
2277 /* *** configure rss hash key *** */
2278 struct cmd_config_rss_hash_key {
2279 	cmdline_fixed_string_t port;
2280 	cmdline_fixed_string_t config;
2281 	portid_t port_id;
2282 	cmdline_fixed_string_t rss_hash_key;
2283 	cmdline_fixed_string_t rss_type;
2284 	cmdline_fixed_string_t key;
2285 };
2286 
2287 static uint8_t
2288 hexa_digit_to_value(char hexa_digit)
2289 {
2290 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2291 		return (uint8_t) (hexa_digit - '0');
2292 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2293 		return (uint8_t) ((hexa_digit - 'a') + 10);
2294 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2295 		return (uint8_t) ((hexa_digit - 'A') + 10);
2296 	/* Invalid hexa digit */
2297 	return 0xFF;
2298 }
2299 
2300 static uint8_t
2301 parse_and_check_key_hexa_digit(char *key, int idx)
2302 {
2303 	uint8_t hexa_v;
2304 
2305 	hexa_v = hexa_digit_to_value(key[idx]);
2306 	if (hexa_v == 0xFF)
2307 		printf("invalid key: character %c at position %d is not a "
2308 		       "valid hexa digit\n", key[idx], idx);
2309 	return hexa_v;
2310 }
2311 
2312 static void
2313 cmd_config_rss_hash_key_parsed(void *parsed_result,
2314 			       __attribute__((unused)) struct cmdline *cl,
2315 			       __attribute__((unused)) void *data)
2316 {
2317 	struct cmd_config_rss_hash_key *res = parsed_result;
2318 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2319 	uint8_t xdgt0;
2320 	uint8_t xdgt1;
2321 	int i;
2322 	struct rte_eth_dev_info dev_info;
2323 	uint8_t hash_key_size;
2324 	uint32_t key_len;
2325 	int ret;
2326 
2327 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2328 	if (ret != 0)
2329 		return;
2330 
2331 	if (dev_info.hash_key_size > 0 &&
2332 			dev_info.hash_key_size <= sizeof(hash_key))
2333 		hash_key_size = dev_info.hash_key_size;
2334 	else {
2335 		printf("dev_info did not provide a valid hash key size\n");
2336 		return;
2337 	}
2338 	/* Check the length of the RSS hash key */
2339 	key_len = strlen(res->key);
2340 	if (key_len != (hash_key_size * 2)) {
2341 		printf("key length: %d invalid - key must be a string of %d"
2342 			   " hexa-decimal numbers\n",
2343 			   (int) key_len, hash_key_size * 2);
2344 		return;
2345 	}
2346 	/* Translate RSS hash key into binary representation */
2347 	for (i = 0; i < hash_key_size; i++) {
2348 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2349 		if (xdgt0 == 0xFF)
2350 			return;
2351 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2352 		if (xdgt1 == 0xFF)
2353 			return;
2354 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2355 	}
2356 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2357 			hash_key_size);
2358 }
2359 
2360 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2361 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2362 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2363 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2364 				 "config");
2365 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2366 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2367 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2368 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2369 				 rss_hash_key, "rss-hash-key");
2370 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2371 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2372 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2373 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2374 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2375 				 "ipv6-tcp-ex#ipv6-udp-ex");
2376 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2377 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2378 
2379 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2380 	.f = cmd_config_rss_hash_key_parsed,
2381 	.data = NULL,
2382 	.help_str = "port config <port_id> rss-hash-key "
2383 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2384 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2385 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2386 		"<string of hex digits (variable length, NIC dependent)>",
2387 	.tokens = {
2388 		(void *)&cmd_config_rss_hash_key_port,
2389 		(void *)&cmd_config_rss_hash_key_config,
2390 		(void *)&cmd_config_rss_hash_key_port_id,
2391 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2392 		(void *)&cmd_config_rss_hash_key_rss_type,
2393 		(void *)&cmd_config_rss_hash_key_value,
2394 		NULL,
2395 	},
2396 };
2397 
2398 /* *** configure port rxq/txq ring size *** */
2399 struct cmd_config_rxtx_ring_size {
2400 	cmdline_fixed_string_t port;
2401 	cmdline_fixed_string_t config;
2402 	portid_t portid;
2403 	cmdline_fixed_string_t rxtxq;
2404 	uint16_t qid;
2405 	cmdline_fixed_string_t rsize;
2406 	uint16_t size;
2407 };
2408 
2409 static void
2410 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2411 				 __attribute__((unused)) struct cmdline *cl,
2412 				 __attribute__((unused)) void *data)
2413 {
2414 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2415 	struct rte_port *port;
2416 	uint8_t isrx;
2417 
2418 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2419 		return;
2420 
2421 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2422 		printf("Invalid port id\n");
2423 		return;
2424 	}
2425 
2426 	port = &ports[res->portid];
2427 
2428 	if (!strcmp(res->rxtxq, "rxq"))
2429 		isrx = 1;
2430 	else if (!strcmp(res->rxtxq, "txq"))
2431 		isrx = 0;
2432 	else {
2433 		printf("Unknown parameter\n");
2434 		return;
2435 	}
2436 
2437 	if (isrx && rx_queue_id_is_invalid(res->qid))
2438 		return;
2439 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2440 		return;
2441 
2442 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2443 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2444 		       rx_free_thresh);
2445 		return;
2446 	}
2447 
2448 	if (isrx)
2449 		port->nb_rx_desc[res->qid] = res->size;
2450 	else
2451 		port->nb_tx_desc[res->qid] = res->size;
2452 
2453 	cmd_reconfig_device_queue(res->portid, 0, 1);
2454 }
2455 
2456 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2457 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2458 				 port, "port");
2459 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2460 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2461 				 config, "config");
2462 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2463 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2464 				 portid, UINT16);
2465 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2466 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2467 				 rxtxq, "rxq#txq");
2468 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2469 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2470 			      qid, UINT16);
2471 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2472 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2473 				 rsize, "ring_size");
2474 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2475 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2476 			      size, UINT16);
2477 
2478 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2479 	.f = cmd_config_rxtx_ring_size_parsed,
2480 	.data = NULL,
2481 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2482 	.tokens = {
2483 		(void *)&cmd_config_rxtx_ring_size_port,
2484 		(void *)&cmd_config_rxtx_ring_size_config,
2485 		(void *)&cmd_config_rxtx_ring_size_portid,
2486 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2487 		(void *)&cmd_config_rxtx_ring_size_qid,
2488 		(void *)&cmd_config_rxtx_ring_size_rsize,
2489 		(void *)&cmd_config_rxtx_ring_size_size,
2490 		NULL,
2491 	},
2492 };
2493 
2494 /* *** configure port rxq/txq start/stop *** */
2495 struct cmd_config_rxtx_queue {
2496 	cmdline_fixed_string_t port;
2497 	portid_t portid;
2498 	cmdline_fixed_string_t rxtxq;
2499 	uint16_t qid;
2500 	cmdline_fixed_string_t opname;
2501 };
2502 
2503 static void
2504 cmd_config_rxtx_queue_parsed(void *parsed_result,
2505 			__attribute__((unused)) struct cmdline *cl,
2506 			__attribute__((unused)) void *data)
2507 {
2508 	struct cmd_config_rxtx_queue *res = parsed_result;
2509 	uint8_t isrx;
2510 	uint8_t isstart;
2511 	int ret = 0;
2512 
2513 	if (test_done == 0) {
2514 		printf("Please stop forwarding first\n");
2515 		return;
2516 	}
2517 
2518 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2519 		return;
2520 
2521 	if (port_is_started(res->portid) != 1) {
2522 		printf("Please start port %u first\n", res->portid);
2523 		return;
2524 	}
2525 
2526 	if (!strcmp(res->rxtxq, "rxq"))
2527 		isrx = 1;
2528 	else if (!strcmp(res->rxtxq, "txq"))
2529 		isrx = 0;
2530 	else {
2531 		printf("Unknown parameter\n");
2532 		return;
2533 	}
2534 
2535 	if (isrx && rx_queue_id_is_invalid(res->qid))
2536 		return;
2537 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2538 		return;
2539 
2540 	if (!strcmp(res->opname, "start"))
2541 		isstart = 1;
2542 	else if (!strcmp(res->opname, "stop"))
2543 		isstart = 0;
2544 	else {
2545 		printf("Unknown parameter\n");
2546 		return;
2547 	}
2548 
2549 	if (isstart && isrx)
2550 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2551 	else if (!isstart && isrx)
2552 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2553 	else if (isstart && !isrx)
2554 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2555 	else
2556 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2557 
2558 	if (ret == -ENOTSUP)
2559 		printf("Function not supported in PMD driver\n");
2560 }
2561 
2562 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2563 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2564 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2565 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2566 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2567 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2568 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2569 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2570 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2571 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2572 						"start#stop");
2573 
2574 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2575 	.f = cmd_config_rxtx_queue_parsed,
2576 	.data = NULL,
2577 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2578 	.tokens = {
2579 		(void *)&cmd_config_rxtx_queue_port,
2580 		(void *)&cmd_config_rxtx_queue_portid,
2581 		(void *)&cmd_config_rxtx_queue_rxtxq,
2582 		(void *)&cmd_config_rxtx_queue_qid,
2583 		(void *)&cmd_config_rxtx_queue_opname,
2584 		NULL,
2585 	},
2586 };
2587 
2588 /* *** configure port rxq/txq deferred start on/off *** */
2589 struct cmd_config_deferred_start_rxtx_queue {
2590 	cmdline_fixed_string_t port;
2591 	portid_t port_id;
2592 	cmdline_fixed_string_t rxtxq;
2593 	uint16_t qid;
2594 	cmdline_fixed_string_t opname;
2595 	cmdline_fixed_string_t state;
2596 };
2597 
2598 static void
2599 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2600 			__attribute__((unused)) struct cmdline *cl,
2601 			__attribute__((unused)) void *data)
2602 {
2603 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2604 	struct rte_port *port;
2605 	uint8_t isrx;
2606 	uint8_t ison;
2607 	uint8_t needreconfig = 0;
2608 
2609 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2610 		return;
2611 
2612 	if (port_is_started(res->port_id) != 0) {
2613 		printf("Please stop port %u first\n", res->port_id);
2614 		return;
2615 	}
2616 
2617 	port = &ports[res->port_id];
2618 
2619 	isrx = !strcmp(res->rxtxq, "rxq");
2620 
2621 	if (isrx && rx_queue_id_is_invalid(res->qid))
2622 		return;
2623 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2624 		return;
2625 
2626 	ison = !strcmp(res->state, "on");
2627 
2628 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2629 		port->rx_conf[res->qid].rx_deferred_start = ison;
2630 		needreconfig = 1;
2631 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2632 		port->tx_conf[res->qid].tx_deferred_start = ison;
2633 		needreconfig = 1;
2634 	}
2635 
2636 	if (needreconfig)
2637 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2638 }
2639 
2640 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2641 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2642 						port, "port");
2643 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2644 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2645 						port_id, UINT16);
2646 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2647 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2648 						rxtxq, "rxq#txq");
2649 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2650 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2651 						qid, UINT16);
2652 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2653 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2654 						opname, "deferred_start");
2655 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2656 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2657 						state, "on#off");
2658 
2659 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2660 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2661 	.data = NULL,
2662 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2663 	.tokens = {
2664 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2665 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2666 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2667 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2668 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2669 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2670 		NULL,
2671 	},
2672 };
2673 
2674 /* *** configure port rxq/txq setup *** */
2675 struct cmd_setup_rxtx_queue {
2676 	cmdline_fixed_string_t port;
2677 	portid_t portid;
2678 	cmdline_fixed_string_t rxtxq;
2679 	uint16_t qid;
2680 	cmdline_fixed_string_t setup;
2681 };
2682 
2683 /* Common CLI fields for queue setup */
2684 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2685 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2686 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2687 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2688 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2689 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2690 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2691 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2692 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2693 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2694 
2695 static void
2696 cmd_setup_rxtx_queue_parsed(
2697 	void *parsed_result,
2698 	__attribute__((unused)) struct cmdline *cl,
2699 	__attribute__((unused)) void *data)
2700 {
2701 	struct cmd_setup_rxtx_queue *res = parsed_result;
2702 	struct rte_port *port;
2703 	struct rte_mempool *mp;
2704 	unsigned int socket_id;
2705 	uint8_t isrx = 0;
2706 	int ret;
2707 
2708 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2709 		return;
2710 
2711 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2712 		printf("Invalid port id\n");
2713 		return;
2714 	}
2715 
2716 	if (!strcmp(res->rxtxq, "rxq"))
2717 		isrx = 1;
2718 	else if (!strcmp(res->rxtxq, "txq"))
2719 		isrx = 0;
2720 	else {
2721 		printf("Unknown parameter\n");
2722 		return;
2723 	}
2724 
2725 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2726 		printf("Invalid rx queue\n");
2727 		return;
2728 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2729 		printf("Invalid tx queue\n");
2730 		return;
2731 	}
2732 
2733 	port = &ports[res->portid];
2734 	if (isrx) {
2735 		socket_id = rxring_numa[res->portid];
2736 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2737 			socket_id = port->socket_id;
2738 
2739 		mp = mbuf_pool_find(socket_id);
2740 		if (mp == NULL) {
2741 			printf("Failed to setup RX queue: "
2742 				"No mempool allocation"
2743 				" on the socket %d\n",
2744 				rxring_numa[res->portid]);
2745 			return;
2746 		}
2747 		ret = rte_eth_rx_queue_setup(res->portid,
2748 					     res->qid,
2749 					     port->nb_rx_desc[res->qid],
2750 					     socket_id,
2751 					     &port->rx_conf[res->qid],
2752 					     mp);
2753 		if (ret)
2754 			printf("Failed to setup RX queue\n");
2755 	} else {
2756 		socket_id = txring_numa[res->portid];
2757 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2758 			socket_id = port->socket_id;
2759 
2760 		ret = rte_eth_tx_queue_setup(res->portid,
2761 					     res->qid,
2762 					     port->nb_tx_desc[res->qid],
2763 					     socket_id,
2764 					     &port->tx_conf[res->qid]);
2765 		if (ret)
2766 			printf("Failed to setup TX queue\n");
2767 	}
2768 }
2769 
2770 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2771 	.f = cmd_setup_rxtx_queue_parsed,
2772 	.data = NULL,
2773 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2774 	.tokens = {
2775 		(void *)&cmd_setup_rxtx_queue_port,
2776 		(void *)&cmd_setup_rxtx_queue_portid,
2777 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2778 		(void *)&cmd_setup_rxtx_queue_qid,
2779 		(void *)&cmd_setup_rxtx_queue_setup,
2780 		NULL,
2781 	},
2782 };
2783 
2784 
2785 /* *** Configure RSS RETA *** */
2786 struct cmd_config_rss_reta {
2787 	cmdline_fixed_string_t port;
2788 	cmdline_fixed_string_t keyword;
2789 	portid_t port_id;
2790 	cmdline_fixed_string_t name;
2791 	cmdline_fixed_string_t list_name;
2792 	cmdline_fixed_string_t list_of_items;
2793 };
2794 
2795 static int
2796 parse_reta_config(const char *str,
2797 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2798 		  uint16_t nb_entries)
2799 {
2800 	int i;
2801 	unsigned size;
2802 	uint16_t hash_index, idx, shift;
2803 	uint16_t nb_queue;
2804 	char s[256];
2805 	const char *p, *p0 = str;
2806 	char *end;
2807 	enum fieldnames {
2808 		FLD_HASH_INDEX = 0,
2809 		FLD_QUEUE,
2810 		_NUM_FLD
2811 	};
2812 	unsigned long int_fld[_NUM_FLD];
2813 	char *str_fld[_NUM_FLD];
2814 
2815 	while ((p = strchr(p0,'(')) != NULL) {
2816 		++p;
2817 		if((p0 = strchr(p,')')) == NULL)
2818 			return -1;
2819 
2820 		size = p0 - p;
2821 		if(size >= sizeof(s))
2822 			return -1;
2823 
2824 		snprintf(s, sizeof(s), "%.*s", size, p);
2825 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2826 			return -1;
2827 		for (i = 0; i < _NUM_FLD; i++) {
2828 			errno = 0;
2829 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2830 			if (errno != 0 || end == str_fld[i] ||
2831 					int_fld[i] > 65535)
2832 				return -1;
2833 		}
2834 
2835 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2836 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2837 
2838 		if (hash_index >= nb_entries) {
2839 			printf("Invalid RETA hash index=%d\n", hash_index);
2840 			return -1;
2841 		}
2842 
2843 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2844 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2845 		reta_conf[idx].mask |= (1ULL << shift);
2846 		reta_conf[idx].reta[shift] = nb_queue;
2847 	}
2848 
2849 	return 0;
2850 }
2851 
2852 static void
2853 cmd_set_rss_reta_parsed(void *parsed_result,
2854 			__attribute__((unused)) struct cmdline *cl,
2855 			__attribute__((unused)) void *data)
2856 {
2857 	int ret;
2858 	struct rte_eth_dev_info dev_info;
2859 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2860 	struct cmd_config_rss_reta *res = parsed_result;
2861 
2862 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2863 	if (ret != 0)
2864 		return;
2865 
2866 	if (dev_info.reta_size == 0) {
2867 		printf("Redirection table size is 0 which is "
2868 					"invalid for RSS\n");
2869 		return;
2870 	} else
2871 		printf("The reta size of port %d is %u\n",
2872 			res->port_id, dev_info.reta_size);
2873 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2874 		printf("Currently do not support more than %u entries of "
2875 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
2876 		return;
2877 	}
2878 
2879 	memset(reta_conf, 0, sizeof(reta_conf));
2880 	if (!strcmp(res->list_name, "reta")) {
2881 		if (parse_reta_config(res->list_of_items, reta_conf,
2882 						dev_info.reta_size)) {
2883 			printf("Invalid RSS Redirection Table "
2884 					"config entered\n");
2885 			return;
2886 		}
2887 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2888 				reta_conf, dev_info.reta_size);
2889 		if (ret != 0)
2890 			printf("Bad redirection table parameter, "
2891 					"return code = %d \n", ret);
2892 	}
2893 }
2894 
2895 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2896 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2897 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2898 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2899 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2900 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2901 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2902 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2903 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2904 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2905 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2906         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2907                                  NULL);
2908 cmdline_parse_inst_t cmd_config_rss_reta = {
2909 	.f = cmd_set_rss_reta_parsed,
2910 	.data = NULL,
2911 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2912 	.tokens = {
2913 		(void *)&cmd_config_rss_reta_port,
2914 		(void *)&cmd_config_rss_reta_keyword,
2915 		(void *)&cmd_config_rss_reta_port_id,
2916 		(void *)&cmd_config_rss_reta_name,
2917 		(void *)&cmd_config_rss_reta_list_name,
2918 		(void *)&cmd_config_rss_reta_list_of_items,
2919 		NULL,
2920 	},
2921 };
2922 
2923 /* *** SHOW PORT RETA INFO *** */
2924 struct cmd_showport_reta {
2925 	cmdline_fixed_string_t show;
2926 	cmdline_fixed_string_t port;
2927 	portid_t port_id;
2928 	cmdline_fixed_string_t rss;
2929 	cmdline_fixed_string_t reta;
2930 	uint16_t size;
2931 	cmdline_fixed_string_t list_of_items;
2932 };
2933 
2934 static int
2935 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2936 			   uint16_t nb_entries,
2937 			   char *str)
2938 {
2939 	uint32_t size;
2940 	const char *p, *p0 = str;
2941 	char s[256];
2942 	char *end;
2943 	char *str_fld[8];
2944 	uint16_t i;
2945 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2946 			RTE_RETA_GROUP_SIZE;
2947 	int ret;
2948 
2949 	p = strchr(p0, '(');
2950 	if (p == NULL)
2951 		return -1;
2952 	p++;
2953 	p0 = strchr(p, ')');
2954 	if (p0 == NULL)
2955 		return -1;
2956 	size = p0 - p;
2957 	if (size >= sizeof(s)) {
2958 		printf("The string size exceeds the internal buffer size\n");
2959 		return -1;
2960 	}
2961 	snprintf(s, sizeof(s), "%.*s", size, p);
2962 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2963 	if (ret <= 0 || ret != num) {
2964 		printf("The bits of masks do not match the number of "
2965 					"reta entries: %u\n", num);
2966 		return -1;
2967 	}
2968 	for (i = 0; i < ret; i++)
2969 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2970 
2971 	return 0;
2972 }
2973 
2974 static void
2975 cmd_showport_reta_parsed(void *parsed_result,
2976 			 __attribute__((unused)) struct cmdline *cl,
2977 			 __attribute__((unused)) void *data)
2978 {
2979 	struct cmd_showport_reta *res = parsed_result;
2980 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2981 	struct rte_eth_dev_info dev_info;
2982 	uint16_t max_reta_size;
2983 	int ret;
2984 
2985 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2986 	if (ret != 0)
2987 		return;
2988 
2989 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2990 	if (res->size == 0 || res->size > max_reta_size) {
2991 		printf("Invalid redirection table size: %u (1-%u)\n",
2992 			res->size, max_reta_size);
2993 		return;
2994 	}
2995 
2996 	memset(reta_conf, 0, sizeof(reta_conf));
2997 	if (showport_parse_reta_config(reta_conf, res->size,
2998 				res->list_of_items) < 0) {
2999 		printf("Invalid string: %s for reta masks\n",
3000 					res->list_of_items);
3001 		return;
3002 	}
3003 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3004 }
3005 
3006 cmdline_parse_token_string_t cmd_showport_reta_show =
3007 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3008 cmdline_parse_token_string_t cmd_showport_reta_port =
3009 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3010 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3011 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3012 cmdline_parse_token_string_t cmd_showport_reta_rss =
3013 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3014 cmdline_parse_token_string_t cmd_showport_reta_reta =
3015 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3016 cmdline_parse_token_num_t cmd_showport_reta_size =
3017 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3018 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3019 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3020 					list_of_items, NULL);
3021 
3022 cmdline_parse_inst_t cmd_showport_reta = {
3023 	.f = cmd_showport_reta_parsed,
3024 	.data = NULL,
3025 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3026 	.tokens = {
3027 		(void *)&cmd_showport_reta_show,
3028 		(void *)&cmd_showport_reta_port,
3029 		(void *)&cmd_showport_reta_port_id,
3030 		(void *)&cmd_showport_reta_rss,
3031 		(void *)&cmd_showport_reta_reta,
3032 		(void *)&cmd_showport_reta_size,
3033 		(void *)&cmd_showport_reta_list_of_items,
3034 		NULL,
3035 	},
3036 };
3037 
3038 /* *** Show RSS hash configuration *** */
3039 struct cmd_showport_rss_hash {
3040 	cmdline_fixed_string_t show;
3041 	cmdline_fixed_string_t port;
3042 	portid_t port_id;
3043 	cmdline_fixed_string_t rss_hash;
3044 	cmdline_fixed_string_t rss_type;
3045 	cmdline_fixed_string_t key; /* optional argument */
3046 };
3047 
3048 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3049 				__attribute__((unused)) struct cmdline *cl,
3050 				void *show_rss_key)
3051 {
3052 	struct cmd_showport_rss_hash *res = parsed_result;
3053 
3054 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3055 }
3056 
3057 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3058 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3059 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3060 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3061 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3062 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3063 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3064 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3065 				 "rss-hash");
3066 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3067 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3068 
3069 cmdline_parse_inst_t cmd_showport_rss_hash = {
3070 	.f = cmd_showport_rss_hash_parsed,
3071 	.data = NULL,
3072 	.help_str = "show port <port_id> rss-hash",
3073 	.tokens = {
3074 		(void *)&cmd_showport_rss_hash_show,
3075 		(void *)&cmd_showport_rss_hash_port,
3076 		(void *)&cmd_showport_rss_hash_port_id,
3077 		(void *)&cmd_showport_rss_hash_rss_hash,
3078 		NULL,
3079 	},
3080 };
3081 
3082 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3083 	.f = cmd_showport_rss_hash_parsed,
3084 	.data = (void *)1,
3085 	.help_str = "show port <port_id> rss-hash key",
3086 	.tokens = {
3087 		(void *)&cmd_showport_rss_hash_show,
3088 		(void *)&cmd_showport_rss_hash_port,
3089 		(void *)&cmd_showport_rss_hash_port_id,
3090 		(void *)&cmd_showport_rss_hash_rss_hash,
3091 		(void *)&cmd_showport_rss_hash_rss_key,
3092 		NULL,
3093 	},
3094 };
3095 
3096 /* *** Configure DCB *** */
3097 struct cmd_config_dcb {
3098 	cmdline_fixed_string_t port;
3099 	cmdline_fixed_string_t config;
3100 	portid_t port_id;
3101 	cmdline_fixed_string_t dcb;
3102 	cmdline_fixed_string_t vt;
3103 	cmdline_fixed_string_t vt_en;
3104 	uint8_t num_tcs;
3105 	cmdline_fixed_string_t pfc;
3106 	cmdline_fixed_string_t pfc_en;
3107 };
3108 
3109 static void
3110 cmd_config_dcb_parsed(void *parsed_result,
3111                         __attribute__((unused)) struct cmdline *cl,
3112                         __attribute__((unused)) void *data)
3113 {
3114 	struct cmd_config_dcb *res = parsed_result;
3115 	portid_t port_id = res->port_id;
3116 	struct rte_port *port;
3117 	uint8_t pfc_en;
3118 	int ret;
3119 
3120 	port = &ports[port_id];
3121 	/** Check if the port is not started **/
3122 	if (port->port_status != RTE_PORT_STOPPED) {
3123 		printf("Please stop port %d first\n", port_id);
3124 		return;
3125 	}
3126 
3127 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3128 		printf("The invalid number of traffic class,"
3129 			" only 4 or 8 allowed.\n");
3130 		return;
3131 	}
3132 
3133 	if (nb_fwd_lcores < res->num_tcs) {
3134 		printf("nb_cores shouldn't be less than number of TCs.\n");
3135 		return;
3136 	}
3137 	if (!strncmp(res->pfc_en, "on", 2))
3138 		pfc_en = 1;
3139 	else
3140 		pfc_en = 0;
3141 
3142 	/* DCB in VT mode */
3143 	if (!strncmp(res->vt_en, "on", 2))
3144 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3145 				(enum rte_eth_nb_tcs)res->num_tcs,
3146 				pfc_en);
3147 	else
3148 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3149 				(enum rte_eth_nb_tcs)res->num_tcs,
3150 				pfc_en);
3151 
3152 
3153 	if (ret != 0) {
3154 		printf("Cannot initialize network ports.\n");
3155 		return;
3156 	}
3157 
3158 	cmd_reconfig_device_queue(port_id, 1, 1);
3159 }
3160 
3161 cmdline_parse_token_string_t cmd_config_dcb_port =
3162         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3163 cmdline_parse_token_string_t cmd_config_dcb_config =
3164         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3165 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3166 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3167 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3168         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3169 cmdline_parse_token_string_t cmd_config_dcb_vt =
3170         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3171 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3172         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3173 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3174         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3175 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3176         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3177 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3178         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3179 
3180 cmdline_parse_inst_t cmd_config_dcb = {
3181 	.f = cmd_config_dcb_parsed,
3182 	.data = NULL,
3183 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3184 	.tokens = {
3185 		(void *)&cmd_config_dcb_port,
3186 		(void *)&cmd_config_dcb_config,
3187 		(void *)&cmd_config_dcb_port_id,
3188 		(void *)&cmd_config_dcb_dcb,
3189 		(void *)&cmd_config_dcb_vt,
3190 		(void *)&cmd_config_dcb_vt_en,
3191 		(void *)&cmd_config_dcb_num_tcs,
3192 		(void *)&cmd_config_dcb_pfc,
3193 		(void *)&cmd_config_dcb_pfc_en,
3194                 NULL,
3195         },
3196 };
3197 
3198 /* *** configure number of packets per burst *** */
3199 struct cmd_config_burst {
3200 	cmdline_fixed_string_t port;
3201 	cmdline_fixed_string_t keyword;
3202 	cmdline_fixed_string_t all;
3203 	cmdline_fixed_string_t name;
3204 	uint16_t value;
3205 };
3206 
3207 static void
3208 cmd_config_burst_parsed(void *parsed_result,
3209 			__attribute__((unused)) struct cmdline *cl,
3210 			__attribute__((unused)) void *data)
3211 {
3212 	struct cmd_config_burst *res = parsed_result;
3213 	struct rte_eth_dev_info dev_info;
3214 	uint16_t rec_nb_pkts;
3215 	int ret;
3216 
3217 	if (!all_ports_stopped()) {
3218 		printf("Please stop all ports first\n");
3219 		return;
3220 	}
3221 
3222 	if (!strcmp(res->name, "burst")) {
3223 		if (res->value == 0) {
3224 			/* If user gives a value of zero, query the PMD for
3225 			 * its recommended Rx burst size. Testpmd uses a single
3226 			 * size for all ports, so assume all ports are the same
3227 			 * NIC model and use the values from Port 0.
3228 			 */
3229 			ret = eth_dev_info_get_print_err(0, &dev_info);
3230 			if (ret != 0)
3231 				return;
3232 
3233 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3234 
3235 			if (rec_nb_pkts == 0) {
3236 				printf("PMD does not recommend a burst size.\n"
3237 					"User provided value must be between"
3238 					" 1 and %d\n", MAX_PKT_BURST);
3239 				return;
3240 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3241 				printf("PMD recommended burst size of %d"
3242 					" exceeds maximum value of %d\n",
3243 					rec_nb_pkts, MAX_PKT_BURST);
3244 				return;
3245 			}
3246 			printf("Using PMD-provided burst value of %d\n",
3247 				rec_nb_pkts);
3248 			nb_pkt_per_burst = rec_nb_pkts;
3249 		} else if (res->value > MAX_PKT_BURST) {
3250 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3251 			return;
3252 		} else
3253 			nb_pkt_per_burst = res->value;
3254 	} else {
3255 		printf("Unknown parameter\n");
3256 		return;
3257 	}
3258 
3259 	init_port_config();
3260 
3261 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3262 }
3263 
3264 cmdline_parse_token_string_t cmd_config_burst_port =
3265 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3266 cmdline_parse_token_string_t cmd_config_burst_keyword =
3267 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3268 cmdline_parse_token_string_t cmd_config_burst_all =
3269 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3270 cmdline_parse_token_string_t cmd_config_burst_name =
3271 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3272 cmdline_parse_token_num_t cmd_config_burst_value =
3273 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3274 
3275 cmdline_parse_inst_t cmd_config_burst = {
3276 	.f = cmd_config_burst_parsed,
3277 	.data = NULL,
3278 	.help_str = "port config all burst <value>",
3279 	.tokens = {
3280 		(void *)&cmd_config_burst_port,
3281 		(void *)&cmd_config_burst_keyword,
3282 		(void *)&cmd_config_burst_all,
3283 		(void *)&cmd_config_burst_name,
3284 		(void *)&cmd_config_burst_value,
3285 		NULL,
3286 	},
3287 };
3288 
3289 /* *** configure rx/tx queues *** */
3290 struct cmd_config_thresh {
3291 	cmdline_fixed_string_t port;
3292 	cmdline_fixed_string_t keyword;
3293 	cmdline_fixed_string_t all;
3294 	cmdline_fixed_string_t name;
3295 	uint8_t value;
3296 };
3297 
3298 static void
3299 cmd_config_thresh_parsed(void *parsed_result,
3300 			__attribute__((unused)) struct cmdline *cl,
3301 			__attribute__((unused)) void *data)
3302 {
3303 	struct cmd_config_thresh *res = parsed_result;
3304 
3305 	if (!all_ports_stopped()) {
3306 		printf("Please stop all ports first\n");
3307 		return;
3308 	}
3309 
3310 	if (!strcmp(res->name, "txpt"))
3311 		tx_pthresh = res->value;
3312 	else if(!strcmp(res->name, "txht"))
3313 		tx_hthresh = res->value;
3314 	else if(!strcmp(res->name, "txwt"))
3315 		tx_wthresh = res->value;
3316 	else if(!strcmp(res->name, "rxpt"))
3317 		rx_pthresh = res->value;
3318 	else if(!strcmp(res->name, "rxht"))
3319 		rx_hthresh = res->value;
3320 	else if(!strcmp(res->name, "rxwt"))
3321 		rx_wthresh = res->value;
3322 	else {
3323 		printf("Unknown parameter\n");
3324 		return;
3325 	}
3326 
3327 	init_port_config();
3328 
3329 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3330 }
3331 
3332 cmdline_parse_token_string_t cmd_config_thresh_port =
3333 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3334 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3335 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3336 cmdline_parse_token_string_t cmd_config_thresh_all =
3337 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3338 cmdline_parse_token_string_t cmd_config_thresh_name =
3339 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3340 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3341 cmdline_parse_token_num_t cmd_config_thresh_value =
3342 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3343 
3344 cmdline_parse_inst_t cmd_config_thresh = {
3345 	.f = cmd_config_thresh_parsed,
3346 	.data = NULL,
3347 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3348 	.tokens = {
3349 		(void *)&cmd_config_thresh_port,
3350 		(void *)&cmd_config_thresh_keyword,
3351 		(void *)&cmd_config_thresh_all,
3352 		(void *)&cmd_config_thresh_name,
3353 		(void *)&cmd_config_thresh_value,
3354 		NULL,
3355 	},
3356 };
3357 
3358 /* *** configure free/rs threshold *** */
3359 struct cmd_config_threshold {
3360 	cmdline_fixed_string_t port;
3361 	cmdline_fixed_string_t keyword;
3362 	cmdline_fixed_string_t all;
3363 	cmdline_fixed_string_t name;
3364 	uint16_t value;
3365 };
3366 
3367 static void
3368 cmd_config_threshold_parsed(void *parsed_result,
3369 			__attribute__((unused)) struct cmdline *cl,
3370 			__attribute__((unused)) void *data)
3371 {
3372 	struct cmd_config_threshold *res = parsed_result;
3373 
3374 	if (!all_ports_stopped()) {
3375 		printf("Please stop all ports first\n");
3376 		return;
3377 	}
3378 
3379 	if (!strcmp(res->name, "txfreet"))
3380 		tx_free_thresh = res->value;
3381 	else if (!strcmp(res->name, "txrst"))
3382 		tx_rs_thresh = res->value;
3383 	else if (!strcmp(res->name, "rxfreet"))
3384 		rx_free_thresh = res->value;
3385 	else {
3386 		printf("Unknown parameter\n");
3387 		return;
3388 	}
3389 
3390 	init_port_config();
3391 
3392 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3393 }
3394 
3395 cmdline_parse_token_string_t cmd_config_threshold_port =
3396 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3397 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3398 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3399 								"config");
3400 cmdline_parse_token_string_t cmd_config_threshold_all =
3401 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3402 cmdline_parse_token_string_t cmd_config_threshold_name =
3403 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3404 						"txfreet#txrst#rxfreet");
3405 cmdline_parse_token_num_t cmd_config_threshold_value =
3406 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3407 
3408 cmdline_parse_inst_t cmd_config_threshold = {
3409 	.f = cmd_config_threshold_parsed,
3410 	.data = NULL,
3411 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3412 	.tokens = {
3413 		(void *)&cmd_config_threshold_port,
3414 		(void *)&cmd_config_threshold_keyword,
3415 		(void *)&cmd_config_threshold_all,
3416 		(void *)&cmd_config_threshold_name,
3417 		(void *)&cmd_config_threshold_value,
3418 		NULL,
3419 	},
3420 };
3421 
3422 /* *** stop *** */
3423 struct cmd_stop_result {
3424 	cmdline_fixed_string_t stop;
3425 };
3426 
3427 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3428 			    __attribute__((unused)) struct cmdline *cl,
3429 			    __attribute__((unused)) void *data)
3430 {
3431 	stop_packet_forwarding();
3432 }
3433 
3434 cmdline_parse_token_string_t cmd_stop_stop =
3435 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3436 
3437 cmdline_parse_inst_t cmd_stop = {
3438 	.f = cmd_stop_parsed,
3439 	.data = NULL,
3440 	.help_str = "stop: Stop packet forwarding",
3441 	.tokens = {
3442 		(void *)&cmd_stop_stop,
3443 		NULL,
3444 	},
3445 };
3446 
3447 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3448 
3449 unsigned int
3450 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3451 		unsigned int *parsed_items, int check_unique_values)
3452 {
3453 	unsigned int nb_item;
3454 	unsigned int value;
3455 	unsigned int i;
3456 	unsigned int j;
3457 	int value_ok;
3458 	char c;
3459 
3460 	/*
3461 	 * First parse all items in the list and store their value.
3462 	 */
3463 	value = 0;
3464 	nb_item = 0;
3465 	value_ok = 0;
3466 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3467 		c = str[i];
3468 		if ((c >= '0') && (c <= '9')) {
3469 			value = (unsigned int) (value * 10 + (c - '0'));
3470 			value_ok = 1;
3471 			continue;
3472 		}
3473 		if (c != ',') {
3474 			printf("character %c is not a decimal digit\n", c);
3475 			return 0;
3476 		}
3477 		if (! value_ok) {
3478 			printf("No valid value before comma\n");
3479 			return 0;
3480 		}
3481 		if (nb_item < max_items) {
3482 			parsed_items[nb_item] = value;
3483 			value_ok = 0;
3484 			value = 0;
3485 		}
3486 		nb_item++;
3487 	}
3488 	if (nb_item >= max_items) {
3489 		printf("Number of %s = %u > %u (maximum items)\n",
3490 		       item_name, nb_item + 1, max_items);
3491 		return 0;
3492 	}
3493 	parsed_items[nb_item++] = value;
3494 	if (! check_unique_values)
3495 		return nb_item;
3496 
3497 	/*
3498 	 * Then, check that all values in the list are differents.
3499 	 * No optimization here...
3500 	 */
3501 	for (i = 0; i < nb_item; i++) {
3502 		for (j = i + 1; j < nb_item; j++) {
3503 			if (parsed_items[j] == parsed_items[i]) {
3504 				printf("duplicated %s %u at index %u and %u\n",
3505 				       item_name, parsed_items[i], i, j);
3506 				return 0;
3507 			}
3508 		}
3509 	}
3510 	return nb_item;
3511 }
3512 
3513 struct cmd_set_list_result {
3514 	cmdline_fixed_string_t cmd_keyword;
3515 	cmdline_fixed_string_t list_name;
3516 	cmdline_fixed_string_t list_of_items;
3517 };
3518 
3519 static void cmd_set_list_parsed(void *parsed_result,
3520 				__attribute__((unused)) struct cmdline *cl,
3521 				__attribute__((unused)) void *data)
3522 {
3523 	struct cmd_set_list_result *res;
3524 	union {
3525 		unsigned int lcorelist[RTE_MAX_LCORE];
3526 		unsigned int portlist[RTE_MAX_ETHPORTS];
3527 	} parsed_items;
3528 	unsigned int nb_item;
3529 
3530 	if (test_done == 0) {
3531 		printf("Please stop forwarding first\n");
3532 		return;
3533 	}
3534 
3535 	res = parsed_result;
3536 	if (!strcmp(res->list_name, "corelist")) {
3537 		nb_item = parse_item_list(res->list_of_items, "core",
3538 					  RTE_MAX_LCORE,
3539 					  parsed_items.lcorelist, 1);
3540 		if (nb_item > 0) {
3541 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3542 			fwd_config_setup();
3543 		}
3544 		return;
3545 	}
3546 	if (!strcmp(res->list_name, "portlist")) {
3547 		nb_item = parse_item_list(res->list_of_items, "port",
3548 					  RTE_MAX_ETHPORTS,
3549 					  parsed_items.portlist, 1);
3550 		if (nb_item > 0) {
3551 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3552 			fwd_config_setup();
3553 		}
3554 	}
3555 }
3556 
3557 cmdline_parse_token_string_t cmd_set_list_keyword =
3558 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3559 				 "set");
3560 cmdline_parse_token_string_t cmd_set_list_name =
3561 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3562 				 "corelist#portlist");
3563 cmdline_parse_token_string_t cmd_set_list_of_items =
3564 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3565 				 NULL);
3566 
3567 cmdline_parse_inst_t cmd_set_fwd_list = {
3568 	.f = cmd_set_list_parsed,
3569 	.data = NULL,
3570 	.help_str = "set corelist|portlist <list0[,list1]*>",
3571 	.tokens = {
3572 		(void *)&cmd_set_list_keyword,
3573 		(void *)&cmd_set_list_name,
3574 		(void *)&cmd_set_list_of_items,
3575 		NULL,
3576 	},
3577 };
3578 
3579 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3580 
3581 struct cmd_setmask_result {
3582 	cmdline_fixed_string_t set;
3583 	cmdline_fixed_string_t mask;
3584 	uint64_t hexavalue;
3585 };
3586 
3587 static void cmd_set_mask_parsed(void *parsed_result,
3588 				__attribute__((unused)) struct cmdline *cl,
3589 				__attribute__((unused)) void *data)
3590 {
3591 	struct cmd_setmask_result *res = parsed_result;
3592 
3593 	if (test_done == 0) {
3594 		printf("Please stop forwarding first\n");
3595 		return;
3596 	}
3597 	if (!strcmp(res->mask, "coremask")) {
3598 		set_fwd_lcores_mask(res->hexavalue);
3599 		fwd_config_setup();
3600 	} else if (!strcmp(res->mask, "portmask")) {
3601 		set_fwd_ports_mask(res->hexavalue);
3602 		fwd_config_setup();
3603 	}
3604 }
3605 
3606 cmdline_parse_token_string_t cmd_setmask_set =
3607 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3608 cmdline_parse_token_string_t cmd_setmask_mask =
3609 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3610 				 "coremask#portmask");
3611 cmdline_parse_token_num_t cmd_setmask_value =
3612 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3613 
3614 cmdline_parse_inst_t cmd_set_fwd_mask = {
3615 	.f = cmd_set_mask_parsed,
3616 	.data = NULL,
3617 	.help_str = "set coremask|portmask <hexadecimal value>",
3618 	.tokens = {
3619 		(void *)&cmd_setmask_set,
3620 		(void *)&cmd_setmask_mask,
3621 		(void *)&cmd_setmask_value,
3622 		NULL,
3623 	},
3624 };
3625 
3626 /*
3627  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3628  */
3629 struct cmd_set_result {
3630 	cmdline_fixed_string_t set;
3631 	cmdline_fixed_string_t what;
3632 	uint16_t value;
3633 };
3634 
3635 static void cmd_set_parsed(void *parsed_result,
3636 			   __attribute__((unused)) struct cmdline *cl,
3637 			   __attribute__((unused)) void *data)
3638 {
3639 	struct cmd_set_result *res = parsed_result;
3640 	if (!strcmp(res->what, "nbport")) {
3641 		set_fwd_ports_number(res->value);
3642 		fwd_config_setup();
3643 	} else if (!strcmp(res->what, "nbcore")) {
3644 		set_fwd_lcores_number(res->value);
3645 		fwd_config_setup();
3646 	} else if (!strcmp(res->what, "burst"))
3647 		set_nb_pkt_per_burst(res->value);
3648 	else if (!strcmp(res->what, "verbose"))
3649 		set_verbose_level(res->value);
3650 }
3651 
3652 cmdline_parse_token_string_t cmd_set_set =
3653 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3654 cmdline_parse_token_string_t cmd_set_what =
3655 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3656 				 "nbport#nbcore#burst#verbose");
3657 cmdline_parse_token_num_t cmd_set_value =
3658 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3659 
3660 cmdline_parse_inst_t cmd_set_numbers = {
3661 	.f = cmd_set_parsed,
3662 	.data = NULL,
3663 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3664 	.tokens = {
3665 		(void *)&cmd_set_set,
3666 		(void *)&cmd_set_what,
3667 		(void *)&cmd_set_value,
3668 		NULL,
3669 	},
3670 };
3671 
3672 /* *** SET LOG LEVEL CONFIGURATION *** */
3673 
3674 struct cmd_set_log_result {
3675 	cmdline_fixed_string_t set;
3676 	cmdline_fixed_string_t log;
3677 	cmdline_fixed_string_t type;
3678 	uint32_t level;
3679 };
3680 
3681 static void
3682 cmd_set_log_parsed(void *parsed_result,
3683 		   __attribute__((unused)) struct cmdline *cl,
3684 		   __attribute__((unused)) void *data)
3685 {
3686 	struct cmd_set_log_result *res;
3687 	int ret;
3688 
3689 	res = parsed_result;
3690 	if (!strcmp(res->type, "global"))
3691 		rte_log_set_global_level(res->level);
3692 	else {
3693 		ret = rte_log_set_level_regexp(res->type, res->level);
3694 		if (ret < 0)
3695 			printf("Unable to set log level\n");
3696 	}
3697 }
3698 
3699 cmdline_parse_token_string_t cmd_set_log_set =
3700 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3701 cmdline_parse_token_string_t cmd_set_log_log =
3702 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3703 cmdline_parse_token_string_t cmd_set_log_type =
3704 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3705 cmdline_parse_token_num_t cmd_set_log_level =
3706 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3707 
3708 cmdline_parse_inst_t cmd_set_log = {
3709 	.f = cmd_set_log_parsed,
3710 	.data = NULL,
3711 	.help_str = "set log global|<type> <level>",
3712 	.tokens = {
3713 		(void *)&cmd_set_log_set,
3714 		(void *)&cmd_set_log_log,
3715 		(void *)&cmd_set_log_type,
3716 		(void *)&cmd_set_log_level,
3717 		NULL,
3718 	},
3719 };
3720 
3721 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3722 
3723 struct cmd_set_txpkts_result {
3724 	cmdline_fixed_string_t cmd_keyword;
3725 	cmdline_fixed_string_t txpkts;
3726 	cmdline_fixed_string_t seg_lengths;
3727 };
3728 
3729 static void
3730 cmd_set_txpkts_parsed(void *parsed_result,
3731 		      __attribute__((unused)) struct cmdline *cl,
3732 		      __attribute__((unused)) void *data)
3733 {
3734 	struct cmd_set_txpkts_result *res;
3735 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3736 	unsigned int nb_segs;
3737 
3738 	res = parsed_result;
3739 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3740 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3741 	if (nb_segs > 0)
3742 		set_tx_pkt_segments(seg_lengths, nb_segs);
3743 }
3744 
3745 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3746 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3747 				 cmd_keyword, "set");
3748 cmdline_parse_token_string_t cmd_set_txpkts_name =
3749 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3750 				 txpkts, "txpkts");
3751 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3752 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3753 				 seg_lengths, NULL);
3754 
3755 cmdline_parse_inst_t cmd_set_txpkts = {
3756 	.f = cmd_set_txpkts_parsed,
3757 	.data = NULL,
3758 	.help_str = "set txpkts <len0[,len1]*>",
3759 	.tokens = {
3760 		(void *)&cmd_set_txpkts_keyword,
3761 		(void *)&cmd_set_txpkts_name,
3762 		(void *)&cmd_set_txpkts_lengths,
3763 		NULL,
3764 	},
3765 };
3766 
3767 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3768 
3769 struct cmd_set_txsplit_result {
3770 	cmdline_fixed_string_t cmd_keyword;
3771 	cmdline_fixed_string_t txsplit;
3772 	cmdline_fixed_string_t mode;
3773 };
3774 
3775 static void
3776 cmd_set_txsplit_parsed(void *parsed_result,
3777 		      __attribute__((unused)) struct cmdline *cl,
3778 		      __attribute__((unused)) void *data)
3779 {
3780 	struct cmd_set_txsplit_result *res;
3781 
3782 	res = parsed_result;
3783 	set_tx_pkt_split(res->mode);
3784 }
3785 
3786 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3787 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3788 				 cmd_keyword, "set");
3789 cmdline_parse_token_string_t cmd_set_txsplit_name =
3790 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3791 				 txsplit, "txsplit");
3792 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3793 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3794 				 mode, NULL);
3795 
3796 cmdline_parse_inst_t cmd_set_txsplit = {
3797 	.f = cmd_set_txsplit_parsed,
3798 	.data = NULL,
3799 	.help_str = "set txsplit on|off|rand",
3800 	.tokens = {
3801 		(void *)&cmd_set_txsplit_keyword,
3802 		(void *)&cmd_set_txsplit_name,
3803 		(void *)&cmd_set_txsplit_mode,
3804 		NULL,
3805 	},
3806 };
3807 
3808 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3809 struct cmd_rx_vlan_filter_all_result {
3810 	cmdline_fixed_string_t rx_vlan;
3811 	cmdline_fixed_string_t what;
3812 	cmdline_fixed_string_t all;
3813 	portid_t port_id;
3814 };
3815 
3816 static void
3817 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3818 			      __attribute__((unused)) struct cmdline *cl,
3819 			      __attribute__((unused)) void *data)
3820 {
3821 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3822 
3823 	if (!strcmp(res->what, "add"))
3824 		rx_vlan_all_filter_set(res->port_id, 1);
3825 	else
3826 		rx_vlan_all_filter_set(res->port_id, 0);
3827 }
3828 
3829 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3830 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3831 				 rx_vlan, "rx_vlan");
3832 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3833 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3834 				 what, "add#rm");
3835 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3836 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3837 				 all, "all");
3838 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3839 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3840 			      port_id, UINT16);
3841 
3842 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3843 	.f = cmd_rx_vlan_filter_all_parsed,
3844 	.data = NULL,
3845 	.help_str = "rx_vlan add|rm all <port_id>: "
3846 		"Add/Remove all identifiers to/from the set of VLAN "
3847 		"identifiers filtered by a port",
3848 	.tokens = {
3849 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
3850 		(void *)&cmd_rx_vlan_filter_all_what,
3851 		(void *)&cmd_rx_vlan_filter_all_all,
3852 		(void *)&cmd_rx_vlan_filter_all_portid,
3853 		NULL,
3854 	},
3855 };
3856 
3857 /* *** VLAN OFFLOAD SET ON A PORT *** */
3858 struct cmd_vlan_offload_result {
3859 	cmdline_fixed_string_t vlan;
3860 	cmdline_fixed_string_t set;
3861 	cmdline_fixed_string_t vlan_type;
3862 	cmdline_fixed_string_t what;
3863 	cmdline_fixed_string_t on;
3864 	cmdline_fixed_string_t port_id;
3865 };
3866 
3867 static void
3868 cmd_vlan_offload_parsed(void *parsed_result,
3869 			  __attribute__((unused)) struct cmdline *cl,
3870 			  __attribute__((unused)) void *data)
3871 {
3872 	int on;
3873 	struct cmd_vlan_offload_result *res = parsed_result;
3874 	char *str;
3875 	int i, len = 0;
3876 	portid_t port_id = 0;
3877 	unsigned int tmp;
3878 
3879 	str = res->port_id;
3880 	len = strnlen(str, STR_TOKEN_SIZE);
3881 	i = 0;
3882 	/* Get port_id first */
3883 	while(i < len){
3884 		if(str[i] == ',')
3885 			break;
3886 
3887 		i++;
3888 	}
3889 	str[i]='\0';
3890 	tmp = strtoul(str, NULL, 0);
3891 	/* If port_id greater that what portid_t can represent, return */
3892 	if(tmp >= RTE_MAX_ETHPORTS)
3893 		return;
3894 	port_id = (portid_t)tmp;
3895 
3896 	if (!strcmp(res->on, "on"))
3897 		on = 1;
3898 	else
3899 		on = 0;
3900 
3901 	if (!strcmp(res->what, "strip"))
3902 		rx_vlan_strip_set(port_id,  on);
3903 	else if(!strcmp(res->what, "stripq")){
3904 		uint16_t queue_id = 0;
3905 
3906 		/* No queue_id, return */
3907 		if(i + 1 >= len) {
3908 			printf("must specify (port,queue_id)\n");
3909 			return;
3910 		}
3911 		tmp = strtoul(str + i + 1, NULL, 0);
3912 		/* If queue_id greater that what 16-bits can represent, return */
3913 		if(tmp > 0xffff)
3914 			return;
3915 
3916 		queue_id = (uint16_t)tmp;
3917 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3918 	}
3919 	else if (!strcmp(res->what, "filter"))
3920 		rx_vlan_filter_set(port_id, on);
3921 	else
3922 		vlan_extend_set(port_id, on);
3923 
3924 	return;
3925 }
3926 
3927 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3928 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3929 				 vlan, "vlan");
3930 cmdline_parse_token_string_t cmd_vlan_offload_set =
3931 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3932 				 set, "set");
3933 cmdline_parse_token_string_t cmd_vlan_offload_what =
3934 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3935 				 what, "strip#filter#qinq#stripq");
3936 cmdline_parse_token_string_t cmd_vlan_offload_on =
3937 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3938 			      on, "on#off");
3939 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3940 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3941 			      port_id, NULL);
3942 
3943 cmdline_parse_inst_t cmd_vlan_offload = {
3944 	.f = cmd_vlan_offload_parsed,
3945 	.data = NULL,
3946 	.help_str = "vlan set strip|filter|qinq|stripq on|off "
3947 		"<port_id[,queue_id]>: "
3948 		"Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3949 	.tokens = {
3950 		(void *)&cmd_vlan_offload_vlan,
3951 		(void *)&cmd_vlan_offload_set,
3952 		(void *)&cmd_vlan_offload_what,
3953 		(void *)&cmd_vlan_offload_on,
3954 		(void *)&cmd_vlan_offload_portid,
3955 		NULL,
3956 	},
3957 };
3958 
3959 /* *** VLAN TPID SET ON A PORT *** */
3960 struct cmd_vlan_tpid_result {
3961 	cmdline_fixed_string_t vlan;
3962 	cmdline_fixed_string_t set;
3963 	cmdline_fixed_string_t vlan_type;
3964 	cmdline_fixed_string_t what;
3965 	uint16_t tp_id;
3966 	portid_t port_id;
3967 };
3968 
3969 static void
3970 cmd_vlan_tpid_parsed(void *parsed_result,
3971 			  __attribute__((unused)) struct cmdline *cl,
3972 			  __attribute__((unused)) void *data)
3973 {
3974 	struct cmd_vlan_tpid_result *res = parsed_result;
3975 	enum rte_vlan_type vlan_type;
3976 
3977 	if (!strcmp(res->vlan_type, "inner"))
3978 		vlan_type = ETH_VLAN_TYPE_INNER;
3979 	else if (!strcmp(res->vlan_type, "outer"))
3980 		vlan_type = ETH_VLAN_TYPE_OUTER;
3981 	else {
3982 		printf("Unknown vlan type\n");
3983 		return;
3984 	}
3985 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3986 }
3987 
3988 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3989 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3990 				 vlan, "vlan");
3991 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3992 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3993 				 set, "set");
3994 cmdline_parse_token_string_t cmd_vlan_type =
3995 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3996 				 vlan_type, "inner#outer");
3997 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3998 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3999 				 what, "tpid");
4000 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4001 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4002 			      tp_id, UINT16);
4003 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4004 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4005 			      port_id, UINT16);
4006 
4007 cmdline_parse_inst_t cmd_vlan_tpid = {
4008 	.f = cmd_vlan_tpid_parsed,
4009 	.data = NULL,
4010 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4011 		"Set the VLAN Ether type",
4012 	.tokens = {
4013 		(void *)&cmd_vlan_tpid_vlan,
4014 		(void *)&cmd_vlan_tpid_set,
4015 		(void *)&cmd_vlan_type,
4016 		(void *)&cmd_vlan_tpid_what,
4017 		(void *)&cmd_vlan_tpid_tpid,
4018 		(void *)&cmd_vlan_tpid_portid,
4019 		NULL,
4020 	},
4021 };
4022 
4023 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4024 struct cmd_rx_vlan_filter_result {
4025 	cmdline_fixed_string_t rx_vlan;
4026 	cmdline_fixed_string_t what;
4027 	uint16_t vlan_id;
4028 	portid_t port_id;
4029 };
4030 
4031 static void
4032 cmd_rx_vlan_filter_parsed(void *parsed_result,
4033 			  __attribute__((unused)) struct cmdline *cl,
4034 			  __attribute__((unused)) void *data)
4035 {
4036 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4037 
4038 	if (!strcmp(res->what, "add"))
4039 		rx_vft_set(res->port_id, res->vlan_id, 1);
4040 	else
4041 		rx_vft_set(res->port_id, res->vlan_id, 0);
4042 }
4043 
4044 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4045 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4046 				 rx_vlan, "rx_vlan");
4047 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4048 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4049 				 what, "add#rm");
4050 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4051 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4052 			      vlan_id, UINT16);
4053 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4054 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4055 			      port_id, UINT16);
4056 
4057 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4058 	.f = cmd_rx_vlan_filter_parsed,
4059 	.data = NULL,
4060 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4061 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4062 		"identifiers filtered by a port",
4063 	.tokens = {
4064 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4065 		(void *)&cmd_rx_vlan_filter_what,
4066 		(void *)&cmd_rx_vlan_filter_vlanid,
4067 		(void *)&cmd_rx_vlan_filter_portid,
4068 		NULL,
4069 	},
4070 };
4071 
4072 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4073 struct cmd_tx_vlan_set_result {
4074 	cmdline_fixed_string_t tx_vlan;
4075 	cmdline_fixed_string_t set;
4076 	portid_t port_id;
4077 	uint16_t vlan_id;
4078 };
4079 
4080 static void
4081 cmd_tx_vlan_set_parsed(void *parsed_result,
4082 		       __attribute__((unused)) struct cmdline *cl,
4083 		       __attribute__((unused)) void *data)
4084 {
4085 	struct cmd_tx_vlan_set_result *res = parsed_result;
4086 
4087 	if (!port_is_stopped(res->port_id)) {
4088 		printf("Please stop port %d first\n", res->port_id);
4089 		return;
4090 	}
4091 
4092 	tx_vlan_set(res->port_id, res->vlan_id);
4093 
4094 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4095 }
4096 
4097 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4098 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4099 				 tx_vlan, "tx_vlan");
4100 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4101 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4102 				 set, "set");
4103 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4104 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4105 			      port_id, UINT16);
4106 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4107 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4108 			      vlan_id, UINT16);
4109 
4110 cmdline_parse_inst_t cmd_tx_vlan_set = {
4111 	.f = cmd_tx_vlan_set_parsed,
4112 	.data = NULL,
4113 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4114 		"Enable hardware insertion of a single VLAN header "
4115 		"with a given TAG Identifier in packets sent on a port",
4116 	.tokens = {
4117 		(void *)&cmd_tx_vlan_set_tx_vlan,
4118 		(void *)&cmd_tx_vlan_set_set,
4119 		(void *)&cmd_tx_vlan_set_portid,
4120 		(void *)&cmd_tx_vlan_set_vlanid,
4121 		NULL,
4122 	},
4123 };
4124 
4125 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4126 struct cmd_tx_vlan_set_qinq_result {
4127 	cmdline_fixed_string_t tx_vlan;
4128 	cmdline_fixed_string_t set;
4129 	portid_t port_id;
4130 	uint16_t vlan_id;
4131 	uint16_t vlan_id_outer;
4132 };
4133 
4134 static void
4135 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4136 			    __attribute__((unused)) struct cmdline *cl,
4137 			    __attribute__((unused)) void *data)
4138 {
4139 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4140 
4141 	if (!port_is_stopped(res->port_id)) {
4142 		printf("Please stop port %d first\n", res->port_id);
4143 		return;
4144 	}
4145 
4146 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4147 
4148 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4149 }
4150 
4151 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4152 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4153 		tx_vlan, "tx_vlan");
4154 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4155 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4156 		set, "set");
4157 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4158 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4159 		port_id, UINT16);
4160 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4161 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4162 		vlan_id, UINT16);
4163 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4164 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4165 		vlan_id_outer, UINT16);
4166 
4167 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4168 	.f = cmd_tx_vlan_set_qinq_parsed,
4169 	.data = NULL,
4170 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4171 		"Enable hardware insertion of double VLAN header "
4172 		"with given TAG Identifiers in packets sent on a port",
4173 	.tokens = {
4174 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4175 		(void *)&cmd_tx_vlan_set_qinq_set,
4176 		(void *)&cmd_tx_vlan_set_qinq_portid,
4177 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4178 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4179 		NULL,
4180 	},
4181 };
4182 
4183 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4184 struct cmd_tx_vlan_set_pvid_result {
4185 	cmdline_fixed_string_t tx_vlan;
4186 	cmdline_fixed_string_t set;
4187 	cmdline_fixed_string_t pvid;
4188 	portid_t port_id;
4189 	uint16_t vlan_id;
4190 	cmdline_fixed_string_t mode;
4191 };
4192 
4193 static void
4194 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4195 			    __attribute__((unused)) struct cmdline *cl,
4196 			    __attribute__((unused)) void *data)
4197 {
4198 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4199 
4200 	if (strcmp(res->mode, "on") == 0)
4201 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4202 	else
4203 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4204 }
4205 
4206 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4207 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4208 				 tx_vlan, "tx_vlan");
4209 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4210 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4211 				 set, "set");
4212 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4213 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4214 				 pvid, "pvid");
4215 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4216 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4217 			     port_id, UINT16);
4218 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4219 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4220 			      vlan_id, UINT16);
4221 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4222 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4223 				 mode, "on#off");
4224 
4225 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4226 	.f = cmd_tx_vlan_set_pvid_parsed,
4227 	.data = NULL,
4228 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4229 	.tokens = {
4230 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4231 		(void *)&cmd_tx_vlan_set_pvid_set,
4232 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4233 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4234 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4235 		(void *)&cmd_tx_vlan_set_pvid_mode,
4236 		NULL,
4237 	},
4238 };
4239 
4240 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4241 struct cmd_tx_vlan_reset_result {
4242 	cmdline_fixed_string_t tx_vlan;
4243 	cmdline_fixed_string_t reset;
4244 	portid_t port_id;
4245 };
4246 
4247 static void
4248 cmd_tx_vlan_reset_parsed(void *parsed_result,
4249 			 __attribute__((unused)) struct cmdline *cl,
4250 			 __attribute__((unused)) void *data)
4251 {
4252 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4253 
4254 	if (!port_is_stopped(res->port_id)) {
4255 		printf("Please stop port %d first\n", res->port_id);
4256 		return;
4257 	}
4258 
4259 	tx_vlan_reset(res->port_id);
4260 
4261 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4262 }
4263 
4264 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4265 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4266 				 tx_vlan, "tx_vlan");
4267 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4268 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4269 				 reset, "reset");
4270 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4271 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4272 			      port_id, UINT16);
4273 
4274 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4275 	.f = cmd_tx_vlan_reset_parsed,
4276 	.data = NULL,
4277 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4278 		"VLAN header in packets sent on a port",
4279 	.tokens = {
4280 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4281 		(void *)&cmd_tx_vlan_reset_reset,
4282 		(void *)&cmd_tx_vlan_reset_portid,
4283 		NULL,
4284 	},
4285 };
4286 
4287 
4288 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4289 struct cmd_csum_result {
4290 	cmdline_fixed_string_t csum;
4291 	cmdline_fixed_string_t mode;
4292 	cmdline_fixed_string_t proto;
4293 	cmdline_fixed_string_t hwsw;
4294 	portid_t port_id;
4295 };
4296 
4297 static void
4298 csum_show(int port_id)
4299 {
4300 	struct rte_eth_dev_info dev_info;
4301 	uint64_t tx_offloads;
4302 	int ret;
4303 
4304 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4305 	printf("Parse tunnel is %s\n",
4306 		(ports[port_id].parse_tunnel) ? "on" : "off");
4307 	printf("IP checksum offload is %s\n",
4308 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4309 	printf("UDP checksum offload is %s\n",
4310 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4311 	printf("TCP checksum offload is %s\n",
4312 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4313 	printf("SCTP checksum offload is %s\n",
4314 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4315 	printf("Outer-Ip checksum offload is %s\n",
4316 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4317 	printf("Outer-Udp checksum offload is %s\n",
4318 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4319 
4320 	/* display warnings if configuration is not supported by the NIC */
4321 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4322 	if (ret != 0)
4323 		return;
4324 
4325 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4326 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4327 		printf("Warning: hardware IP checksum enabled but not "
4328 			"supported by port %d\n", port_id);
4329 	}
4330 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4331 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4332 		printf("Warning: hardware UDP checksum enabled but not "
4333 			"supported by port %d\n", port_id);
4334 	}
4335 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4336 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4337 		printf("Warning: hardware TCP checksum enabled but not "
4338 			"supported by port %d\n", port_id);
4339 	}
4340 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4341 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4342 		printf("Warning: hardware SCTP checksum enabled but not "
4343 			"supported by port %d\n", port_id);
4344 	}
4345 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4346 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4347 		printf("Warning: hardware outer IP checksum enabled but not "
4348 			"supported by port %d\n", port_id);
4349 	}
4350 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4351 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4352 			== 0) {
4353 		printf("Warning: hardware outer UDP checksum enabled but not "
4354 			"supported by port %d\n", port_id);
4355 	}
4356 }
4357 
4358 static void
4359 cmd_config_queue_tx_offloads(struct rte_port *port)
4360 {
4361 	int k;
4362 
4363 	/* Apply queue tx offloads configuration */
4364 	for (k = 0; k < port->dev_info.max_rx_queues; k++)
4365 		port->tx_conf[k].offloads =
4366 			port->dev_conf.txmode.offloads;
4367 }
4368 
4369 static void
4370 cmd_csum_parsed(void *parsed_result,
4371 		       __attribute__((unused)) struct cmdline *cl,
4372 		       __attribute__((unused)) void *data)
4373 {
4374 	struct cmd_csum_result *res = parsed_result;
4375 	int hw = 0;
4376 	uint64_t csum_offloads = 0;
4377 	struct rte_eth_dev_info dev_info;
4378 	int ret;
4379 
4380 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4381 		printf("invalid port %d\n", res->port_id);
4382 		return;
4383 	}
4384 	if (!port_is_stopped(res->port_id)) {
4385 		printf("Please stop port %d first\n", res->port_id);
4386 		return;
4387 	}
4388 
4389 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4390 	if (ret != 0)
4391 		return;
4392 
4393 	if (!strcmp(res->mode, "set")) {
4394 
4395 		if (!strcmp(res->hwsw, "hw"))
4396 			hw = 1;
4397 
4398 		if (!strcmp(res->proto, "ip")) {
4399 			if (hw == 0 || (dev_info.tx_offload_capa &
4400 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4401 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4402 			} else {
4403 				printf("IP checksum offload is not supported "
4404 				       "by port %u\n", res->port_id);
4405 			}
4406 		} else if (!strcmp(res->proto, "udp")) {
4407 			if (hw == 0 || (dev_info.tx_offload_capa &
4408 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4409 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4410 			} else {
4411 				printf("UDP checksum offload is not supported "
4412 				       "by port %u\n", res->port_id);
4413 			}
4414 		} else if (!strcmp(res->proto, "tcp")) {
4415 			if (hw == 0 || (dev_info.tx_offload_capa &
4416 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4417 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4418 			} else {
4419 				printf("TCP checksum offload is not supported "
4420 				       "by port %u\n", res->port_id);
4421 			}
4422 		} else if (!strcmp(res->proto, "sctp")) {
4423 			if (hw == 0 || (dev_info.tx_offload_capa &
4424 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4425 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4426 			} else {
4427 				printf("SCTP checksum offload is not supported "
4428 				       "by port %u\n", res->port_id);
4429 			}
4430 		} else if (!strcmp(res->proto, "outer-ip")) {
4431 			if (hw == 0 || (dev_info.tx_offload_capa &
4432 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4433 				csum_offloads |=
4434 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4435 			} else {
4436 				printf("Outer IP checksum offload is not "
4437 				       "supported by port %u\n", res->port_id);
4438 			}
4439 		} else if (!strcmp(res->proto, "outer-udp")) {
4440 			if (hw == 0 || (dev_info.tx_offload_capa &
4441 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4442 				csum_offloads |=
4443 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4444 			} else {
4445 				printf("Outer UDP checksum offload is not "
4446 				       "supported by port %u\n", res->port_id);
4447 			}
4448 		}
4449 
4450 		if (hw) {
4451 			ports[res->port_id].dev_conf.txmode.offloads |=
4452 							csum_offloads;
4453 		} else {
4454 			ports[res->port_id].dev_conf.txmode.offloads &=
4455 							(~csum_offloads);
4456 		}
4457 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4458 	}
4459 	csum_show(res->port_id);
4460 
4461 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4462 }
4463 
4464 cmdline_parse_token_string_t cmd_csum_csum =
4465 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4466 				csum, "csum");
4467 cmdline_parse_token_string_t cmd_csum_mode =
4468 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4469 				mode, "set");
4470 cmdline_parse_token_string_t cmd_csum_proto =
4471 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4472 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4473 cmdline_parse_token_string_t cmd_csum_hwsw =
4474 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4475 				hwsw, "hw#sw");
4476 cmdline_parse_token_num_t cmd_csum_portid =
4477 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4478 				port_id, UINT16);
4479 
4480 cmdline_parse_inst_t cmd_csum_set = {
4481 	.f = cmd_csum_parsed,
4482 	.data = NULL,
4483 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4484 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4485 		"using csum forward engine",
4486 	.tokens = {
4487 		(void *)&cmd_csum_csum,
4488 		(void *)&cmd_csum_mode,
4489 		(void *)&cmd_csum_proto,
4490 		(void *)&cmd_csum_hwsw,
4491 		(void *)&cmd_csum_portid,
4492 		NULL,
4493 	},
4494 };
4495 
4496 cmdline_parse_token_string_t cmd_csum_mode_show =
4497 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4498 				mode, "show");
4499 
4500 cmdline_parse_inst_t cmd_csum_show = {
4501 	.f = cmd_csum_parsed,
4502 	.data = NULL,
4503 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4504 	.tokens = {
4505 		(void *)&cmd_csum_csum,
4506 		(void *)&cmd_csum_mode_show,
4507 		(void *)&cmd_csum_portid,
4508 		NULL,
4509 	},
4510 };
4511 
4512 /* Enable/disable tunnel parsing */
4513 struct cmd_csum_tunnel_result {
4514 	cmdline_fixed_string_t csum;
4515 	cmdline_fixed_string_t parse;
4516 	cmdline_fixed_string_t onoff;
4517 	portid_t port_id;
4518 };
4519 
4520 static void
4521 cmd_csum_tunnel_parsed(void *parsed_result,
4522 		       __attribute__((unused)) struct cmdline *cl,
4523 		       __attribute__((unused)) void *data)
4524 {
4525 	struct cmd_csum_tunnel_result *res = parsed_result;
4526 
4527 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4528 		return;
4529 
4530 	if (!strcmp(res->onoff, "on"))
4531 		ports[res->port_id].parse_tunnel = 1;
4532 	else
4533 		ports[res->port_id].parse_tunnel = 0;
4534 
4535 	csum_show(res->port_id);
4536 }
4537 
4538 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4539 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4540 				csum, "csum");
4541 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4542 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4543 				parse, "parse-tunnel");
4544 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4545 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4546 				onoff, "on#off");
4547 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4548 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4549 				port_id, UINT16);
4550 
4551 cmdline_parse_inst_t cmd_csum_tunnel = {
4552 	.f = cmd_csum_tunnel_parsed,
4553 	.data = NULL,
4554 	.help_str = "csum parse-tunnel on|off <port_id>: "
4555 		"Enable/Disable parsing of tunnels for csum engine",
4556 	.tokens = {
4557 		(void *)&cmd_csum_tunnel_csum,
4558 		(void *)&cmd_csum_tunnel_parse,
4559 		(void *)&cmd_csum_tunnel_onoff,
4560 		(void *)&cmd_csum_tunnel_portid,
4561 		NULL,
4562 	},
4563 };
4564 
4565 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4566 struct cmd_tso_set_result {
4567 	cmdline_fixed_string_t tso;
4568 	cmdline_fixed_string_t mode;
4569 	uint16_t tso_segsz;
4570 	portid_t port_id;
4571 };
4572 
4573 static void
4574 cmd_tso_set_parsed(void *parsed_result,
4575 		       __attribute__((unused)) struct cmdline *cl,
4576 		       __attribute__((unused)) void *data)
4577 {
4578 	struct cmd_tso_set_result *res = parsed_result;
4579 	struct rte_eth_dev_info dev_info;
4580 	int ret;
4581 
4582 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4583 		return;
4584 	if (!port_is_stopped(res->port_id)) {
4585 		printf("Please stop port %d first\n", res->port_id);
4586 		return;
4587 	}
4588 
4589 	if (!strcmp(res->mode, "set"))
4590 		ports[res->port_id].tso_segsz = res->tso_segsz;
4591 
4592 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4593 	if (ret != 0)
4594 		return;
4595 
4596 	if ((ports[res->port_id].tso_segsz != 0) &&
4597 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4598 		printf("Error: TSO is not supported by port %d\n",
4599 		       res->port_id);
4600 		return;
4601 	}
4602 
4603 	if (ports[res->port_id].tso_segsz == 0) {
4604 		ports[res->port_id].dev_conf.txmode.offloads &=
4605 						~DEV_TX_OFFLOAD_TCP_TSO;
4606 		printf("TSO for non-tunneled packets is disabled\n");
4607 	} else {
4608 		ports[res->port_id].dev_conf.txmode.offloads |=
4609 						DEV_TX_OFFLOAD_TCP_TSO;
4610 		printf("TSO segment size for non-tunneled packets is %d\n",
4611 			ports[res->port_id].tso_segsz);
4612 	}
4613 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4614 
4615 	/* display warnings if configuration is not supported by the NIC */
4616 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4617 	if (ret != 0)
4618 		return;
4619 
4620 	if ((ports[res->port_id].tso_segsz != 0) &&
4621 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4622 		printf("Warning: TSO enabled but not "
4623 			"supported by port %d\n", res->port_id);
4624 	}
4625 
4626 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4627 }
4628 
4629 cmdline_parse_token_string_t cmd_tso_set_tso =
4630 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4631 				tso, "tso");
4632 cmdline_parse_token_string_t cmd_tso_set_mode =
4633 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4634 				mode, "set");
4635 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4636 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4637 				tso_segsz, UINT16);
4638 cmdline_parse_token_num_t cmd_tso_set_portid =
4639 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4640 				port_id, UINT16);
4641 
4642 cmdline_parse_inst_t cmd_tso_set = {
4643 	.f = cmd_tso_set_parsed,
4644 	.data = NULL,
4645 	.help_str = "tso set <tso_segsz> <port_id>: "
4646 		"Set TSO segment size of non-tunneled packets for csum engine "
4647 		"(0 to disable)",
4648 	.tokens = {
4649 		(void *)&cmd_tso_set_tso,
4650 		(void *)&cmd_tso_set_mode,
4651 		(void *)&cmd_tso_set_tso_segsz,
4652 		(void *)&cmd_tso_set_portid,
4653 		NULL,
4654 	},
4655 };
4656 
4657 cmdline_parse_token_string_t cmd_tso_show_mode =
4658 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4659 				mode, "show");
4660 
4661 
4662 cmdline_parse_inst_t cmd_tso_show = {
4663 	.f = cmd_tso_set_parsed,
4664 	.data = NULL,
4665 	.help_str = "tso show <port_id>: "
4666 		"Show TSO segment size of non-tunneled packets for csum engine",
4667 	.tokens = {
4668 		(void *)&cmd_tso_set_tso,
4669 		(void *)&cmd_tso_show_mode,
4670 		(void *)&cmd_tso_set_portid,
4671 		NULL,
4672 	},
4673 };
4674 
4675 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4676 struct cmd_tunnel_tso_set_result {
4677 	cmdline_fixed_string_t tso;
4678 	cmdline_fixed_string_t mode;
4679 	uint16_t tso_segsz;
4680 	portid_t port_id;
4681 };
4682 
4683 static struct rte_eth_dev_info
4684 check_tunnel_tso_nic_support(portid_t port_id)
4685 {
4686 	struct rte_eth_dev_info dev_info;
4687 
4688 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4689 		return dev_info;
4690 
4691 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4692 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4693 		       "not enabled for port %d\n", port_id);
4694 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4695 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4696 		       "not enabled for port %d\n", port_id);
4697 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4698 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
4699 		       "not enabled for port %d\n", port_id);
4700 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4701 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4702 		       "not enabled for port %d\n", port_id);
4703 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4704 		printf("Warning: IP TUNNEL TSO not supported therefore "
4705 		       "not enabled for port %d\n", port_id);
4706 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4707 		printf("Warning: UDP TUNNEL TSO not supported therefore "
4708 		       "not enabled for port %d\n", port_id);
4709 	return dev_info;
4710 }
4711 
4712 static void
4713 cmd_tunnel_tso_set_parsed(void *parsed_result,
4714 			  __attribute__((unused)) struct cmdline *cl,
4715 			  __attribute__((unused)) void *data)
4716 {
4717 	struct cmd_tunnel_tso_set_result *res = parsed_result;
4718 	struct rte_eth_dev_info dev_info;
4719 
4720 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4721 		return;
4722 	if (!port_is_stopped(res->port_id)) {
4723 		printf("Please stop port %d first\n", res->port_id);
4724 		return;
4725 	}
4726 
4727 	if (!strcmp(res->mode, "set"))
4728 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4729 
4730 	dev_info = check_tunnel_tso_nic_support(res->port_id);
4731 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4732 		ports[res->port_id].dev_conf.txmode.offloads &=
4733 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4734 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4735 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4736 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4737 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
4738 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
4739 		printf("TSO for tunneled packets is disabled\n");
4740 	} else {
4741 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4742 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4743 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4744 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4745 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
4746 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4747 
4748 		ports[res->port_id].dev_conf.txmode.offloads |=
4749 			(tso_offloads & dev_info.tx_offload_capa);
4750 		printf("TSO segment size for tunneled packets is %d\n",
4751 			ports[res->port_id].tunnel_tso_segsz);
4752 
4753 		/* Below conditions are needed to make it work:
4754 		 * (1) tunnel TSO is supported by the NIC;
4755 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4756 		 * are recognized;
4757 		 * (3) for tunneled pkts with outer L3 of IPv4,
4758 		 * "csum set outer-ip" must be set to hw, because after tso,
4759 		 * total_len of outer IP header is changed, and the checksum
4760 		 * of outer IP header calculated by sw should be wrong; that
4761 		 * is not necessary for IPv6 tunneled pkts because there's no
4762 		 * checksum in IP header anymore.
4763 		 */
4764 
4765 		if (!ports[res->port_id].parse_tunnel)
4766 			printf("Warning: csum parse_tunnel must be set "
4767 				"so that tunneled packets are recognized\n");
4768 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4769 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4770 			printf("Warning: csum set outer-ip must be set to hw "
4771 				"if outer L3 is IPv4; not necessary for IPv6\n");
4772 	}
4773 
4774 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4775 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4776 }
4777 
4778 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4779 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4780 				tso, "tunnel_tso");
4781 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4782 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4783 				mode, "set");
4784 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4785 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4786 				tso_segsz, UINT16);
4787 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4788 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4789 				port_id, UINT16);
4790 
4791 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4792 	.f = cmd_tunnel_tso_set_parsed,
4793 	.data = NULL,
4794 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4795 		"Set TSO segment size of tunneled packets for csum engine "
4796 		"(0 to disable)",
4797 	.tokens = {
4798 		(void *)&cmd_tunnel_tso_set_tso,
4799 		(void *)&cmd_tunnel_tso_set_mode,
4800 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4801 		(void *)&cmd_tunnel_tso_set_portid,
4802 		NULL,
4803 	},
4804 };
4805 
4806 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4807 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4808 				mode, "show");
4809 
4810 
4811 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4812 	.f = cmd_tunnel_tso_set_parsed,
4813 	.data = NULL,
4814 	.help_str = "tunnel_tso show <port_id> "
4815 		"Show TSO segment size of tunneled packets for csum engine",
4816 	.tokens = {
4817 		(void *)&cmd_tunnel_tso_set_tso,
4818 		(void *)&cmd_tunnel_tso_show_mode,
4819 		(void *)&cmd_tunnel_tso_set_portid,
4820 		NULL,
4821 	},
4822 };
4823 
4824 /* *** SET GRO FOR A PORT *** */
4825 struct cmd_gro_enable_result {
4826 	cmdline_fixed_string_t cmd_set;
4827 	cmdline_fixed_string_t cmd_port;
4828 	cmdline_fixed_string_t cmd_keyword;
4829 	cmdline_fixed_string_t cmd_onoff;
4830 	portid_t cmd_pid;
4831 };
4832 
4833 static void
4834 cmd_gro_enable_parsed(void *parsed_result,
4835 		__attribute__((unused)) struct cmdline *cl,
4836 		__attribute__((unused)) void *data)
4837 {
4838 	struct cmd_gro_enable_result *res;
4839 
4840 	res = parsed_result;
4841 	if (!strcmp(res->cmd_keyword, "gro"))
4842 		setup_gro(res->cmd_onoff, res->cmd_pid);
4843 }
4844 
4845 cmdline_parse_token_string_t cmd_gro_enable_set =
4846 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4847 			cmd_set, "set");
4848 cmdline_parse_token_string_t cmd_gro_enable_port =
4849 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4850 			cmd_keyword, "port");
4851 cmdline_parse_token_num_t cmd_gro_enable_pid =
4852 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4853 			cmd_pid, UINT16);
4854 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4855 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4856 			cmd_keyword, "gro");
4857 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4858 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4859 			cmd_onoff, "on#off");
4860 
4861 cmdline_parse_inst_t cmd_gro_enable = {
4862 	.f = cmd_gro_enable_parsed,
4863 	.data = NULL,
4864 	.help_str = "set port <port_id> gro on|off",
4865 	.tokens = {
4866 		(void *)&cmd_gro_enable_set,
4867 		(void *)&cmd_gro_enable_port,
4868 		(void *)&cmd_gro_enable_pid,
4869 		(void *)&cmd_gro_enable_keyword,
4870 		(void *)&cmd_gro_enable_onoff,
4871 		NULL,
4872 	},
4873 };
4874 
4875 /* *** DISPLAY GRO CONFIGURATION *** */
4876 struct cmd_gro_show_result {
4877 	cmdline_fixed_string_t cmd_show;
4878 	cmdline_fixed_string_t cmd_port;
4879 	cmdline_fixed_string_t cmd_keyword;
4880 	portid_t cmd_pid;
4881 };
4882 
4883 static void
4884 cmd_gro_show_parsed(void *parsed_result,
4885 		__attribute__((unused)) struct cmdline *cl,
4886 		__attribute__((unused)) void *data)
4887 {
4888 	struct cmd_gro_show_result *res;
4889 
4890 	res = parsed_result;
4891 	if (!strcmp(res->cmd_keyword, "gro"))
4892 		show_gro(res->cmd_pid);
4893 }
4894 
4895 cmdline_parse_token_string_t cmd_gro_show_show =
4896 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4897 			cmd_show, "show");
4898 cmdline_parse_token_string_t cmd_gro_show_port =
4899 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4900 			cmd_port, "port");
4901 cmdline_parse_token_num_t cmd_gro_show_pid =
4902 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4903 			cmd_pid, UINT16);
4904 cmdline_parse_token_string_t cmd_gro_show_keyword =
4905 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4906 			cmd_keyword, "gro");
4907 
4908 cmdline_parse_inst_t cmd_gro_show = {
4909 	.f = cmd_gro_show_parsed,
4910 	.data = NULL,
4911 	.help_str = "show port <port_id> gro",
4912 	.tokens = {
4913 		(void *)&cmd_gro_show_show,
4914 		(void *)&cmd_gro_show_port,
4915 		(void *)&cmd_gro_show_pid,
4916 		(void *)&cmd_gro_show_keyword,
4917 		NULL,
4918 	},
4919 };
4920 
4921 /* *** SET FLUSH CYCLES FOR GRO *** */
4922 struct cmd_gro_flush_result {
4923 	cmdline_fixed_string_t cmd_set;
4924 	cmdline_fixed_string_t cmd_keyword;
4925 	cmdline_fixed_string_t cmd_flush;
4926 	uint8_t cmd_cycles;
4927 };
4928 
4929 static void
4930 cmd_gro_flush_parsed(void *parsed_result,
4931 		__attribute__((unused)) struct cmdline *cl,
4932 		__attribute__((unused)) void *data)
4933 {
4934 	struct cmd_gro_flush_result *res;
4935 
4936 	res = parsed_result;
4937 	if ((!strcmp(res->cmd_keyword, "gro")) &&
4938 			(!strcmp(res->cmd_flush, "flush")))
4939 		setup_gro_flush_cycles(res->cmd_cycles);
4940 }
4941 
4942 cmdline_parse_token_string_t cmd_gro_flush_set =
4943 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4944 			cmd_set, "set");
4945 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4946 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4947 			cmd_keyword, "gro");
4948 cmdline_parse_token_string_t cmd_gro_flush_flush =
4949 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4950 			cmd_flush, "flush");
4951 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4952 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4953 			cmd_cycles, UINT8);
4954 
4955 cmdline_parse_inst_t cmd_gro_flush = {
4956 	.f = cmd_gro_flush_parsed,
4957 	.data = NULL,
4958 	.help_str = "set gro flush <cycles>",
4959 	.tokens = {
4960 		(void *)&cmd_gro_flush_set,
4961 		(void *)&cmd_gro_flush_keyword,
4962 		(void *)&cmd_gro_flush_flush,
4963 		(void *)&cmd_gro_flush_cycles,
4964 		NULL,
4965 	},
4966 };
4967 
4968 /* *** ENABLE/DISABLE GSO *** */
4969 struct cmd_gso_enable_result {
4970 	cmdline_fixed_string_t cmd_set;
4971 	cmdline_fixed_string_t cmd_port;
4972 	cmdline_fixed_string_t cmd_keyword;
4973 	cmdline_fixed_string_t cmd_mode;
4974 	portid_t cmd_pid;
4975 };
4976 
4977 static void
4978 cmd_gso_enable_parsed(void *parsed_result,
4979 		__attribute__((unused)) struct cmdline *cl,
4980 		__attribute__((unused)) void *data)
4981 {
4982 	struct cmd_gso_enable_result *res;
4983 
4984 	res = parsed_result;
4985 	if (!strcmp(res->cmd_keyword, "gso"))
4986 		setup_gso(res->cmd_mode, res->cmd_pid);
4987 }
4988 
4989 cmdline_parse_token_string_t cmd_gso_enable_set =
4990 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4991 			cmd_set, "set");
4992 cmdline_parse_token_string_t cmd_gso_enable_port =
4993 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4994 			cmd_port, "port");
4995 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4996 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4997 			cmd_keyword, "gso");
4998 cmdline_parse_token_string_t cmd_gso_enable_mode =
4999 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5000 			cmd_mode, "on#off");
5001 cmdline_parse_token_num_t cmd_gso_enable_pid =
5002 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5003 			cmd_pid, UINT16);
5004 
5005 cmdline_parse_inst_t cmd_gso_enable = {
5006 	.f = cmd_gso_enable_parsed,
5007 	.data = NULL,
5008 	.help_str = "set port <port_id> gso on|off",
5009 	.tokens = {
5010 		(void *)&cmd_gso_enable_set,
5011 		(void *)&cmd_gso_enable_port,
5012 		(void *)&cmd_gso_enable_pid,
5013 		(void *)&cmd_gso_enable_keyword,
5014 		(void *)&cmd_gso_enable_mode,
5015 		NULL,
5016 	},
5017 };
5018 
5019 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5020 struct cmd_gso_size_result {
5021 	cmdline_fixed_string_t cmd_set;
5022 	cmdline_fixed_string_t cmd_keyword;
5023 	cmdline_fixed_string_t cmd_segsz;
5024 	uint16_t cmd_size;
5025 };
5026 
5027 static void
5028 cmd_gso_size_parsed(void *parsed_result,
5029 		       __attribute__((unused)) struct cmdline *cl,
5030 		       __attribute__((unused)) void *data)
5031 {
5032 	struct cmd_gso_size_result *res = parsed_result;
5033 
5034 	if (test_done == 0) {
5035 		printf("Before setting GSO segsz, please first"
5036 				" stop fowarding\n");
5037 		return;
5038 	}
5039 
5040 	if (!strcmp(res->cmd_keyword, "gso") &&
5041 			!strcmp(res->cmd_segsz, "segsz")) {
5042 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5043 			printf("gso_size should be larger than %zu."
5044 					" Please input a legal value\n",
5045 					RTE_GSO_SEG_SIZE_MIN);
5046 		else
5047 			gso_max_segment_size = res->cmd_size;
5048 	}
5049 }
5050 
5051 cmdline_parse_token_string_t cmd_gso_size_set =
5052 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5053 				cmd_set, "set");
5054 cmdline_parse_token_string_t cmd_gso_size_keyword =
5055 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5056 				cmd_keyword, "gso");
5057 cmdline_parse_token_string_t cmd_gso_size_segsz =
5058 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5059 				cmd_segsz, "segsz");
5060 cmdline_parse_token_num_t cmd_gso_size_size =
5061 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5062 				cmd_size, UINT16);
5063 
5064 cmdline_parse_inst_t cmd_gso_size = {
5065 	.f = cmd_gso_size_parsed,
5066 	.data = NULL,
5067 	.help_str = "set gso segsz <length>",
5068 	.tokens = {
5069 		(void *)&cmd_gso_size_set,
5070 		(void *)&cmd_gso_size_keyword,
5071 		(void *)&cmd_gso_size_segsz,
5072 		(void *)&cmd_gso_size_size,
5073 		NULL,
5074 	},
5075 };
5076 
5077 /* *** SHOW GSO CONFIGURATION *** */
5078 struct cmd_gso_show_result {
5079 	cmdline_fixed_string_t cmd_show;
5080 	cmdline_fixed_string_t cmd_port;
5081 	cmdline_fixed_string_t cmd_keyword;
5082 	portid_t cmd_pid;
5083 };
5084 
5085 static void
5086 cmd_gso_show_parsed(void *parsed_result,
5087 		       __attribute__((unused)) struct cmdline *cl,
5088 		       __attribute__((unused)) void *data)
5089 {
5090 	struct cmd_gso_show_result *res = parsed_result;
5091 
5092 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5093 		printf("invalid port id %u\n", res->cmd_pid);
5094 		return;
5095 	}
5096 	if (!strcmp(res->cmd_keyword, "gso")) {
5097 		if (gso_ports[res->cmd_pid].enable) {
5098 			printf("Max GSO'd packet size: %uB\n"
5099 					"Supported GSO types: TCP/IPv4, "
5100 					"UDP/IPv4, VxLAN with inner "
5101 					"TCP/IPv4 packet, GRE with inner "
5102 					"TCP/IPv4 packet\n",
5103 					gso_max_segment_size);
5104 		} else
5105 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5106 	}
5107 }
5108 
5109 cmdline_parse_token_string_t cmd_gso_show_show =
5110 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5111 		cmd_show, "show");
5112 cmdline_parse_token_string_t cmd_gso_show_port =
5113 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5114 		cmd_port, "port");
5115 cmdline_parse_token_string_t cmd_gso_show_keyword =
5116 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5117 				cmd_keyword, "gso");
5118 cmdline_parse_token_num_t cmd_gso_show_pid =
5119 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5120 				cmd_pid, UINT16);
5121 
5122 cmdline_parse_inst_t cmd_gso_show = {
5123 	.f = cmd_gso_show_parsed,
5124 	.data = NULL,
5125 	.help_str = "show port <port_id> gso",
5126 	.tokens = {
5127 		(void *)&cmd_gso_show_show,
5128 		(void *)&cmd_gso_show_port,
5129 		(void *)&cmd_gso_show_pid,
5130 		(void *)&cmd_gso_show_keyword,
5131 		NULL,
5132 	},
5133 };
5134 
5135 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5136 struct cmd_set_flush_rx {
5137 	cmdline_fixed_string_t set;
5138 	cmdline_fixed_string_t flush_rx;
5139 	cmdline_fixed_string_t mode;
5140 };
5141 
5142 static void
5143 cmd_set_flush_rx_parsed(void *parsed_result,
5144 		__attribute__((unused)) struct cmdline *cl,
5145 		__attribute__((unused)) void *data)
5146 {
5147 	struct cmd_set_flush_rx *res = parsed_result;
5148 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5149 }
5150 
5151 cmdline_parse_token_string_t cmd_setflushrx_set =
5152 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5153 			set, "set");
5154 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5155 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5156 			flush_rx, "flush_rx");
5157 cmdline_parse_token_string_t cmd_setflushrx_mode =
5158 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5159 			mode, "on#off");
5160 
5161 
5162 cmdline_parse_inst_t cmd_set_flush_rx = {
5163 	.f = cmd_set_flush_rx_parsed,
5164 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5165 	.data = NULL,
5166 	.tokens = {
5167 		(void *)&cmd_setflushrx_set,
5168 		(void *)&cmd_setflushrx_flush_rx,
5169 		(void *)&cmd_setflushrx_mode,
5170 		NULL,
5171 	},
5172 };
5173 
5174 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5175 struct cmd_set_link_check {
5176 	cmdline_fixed_string_t set;
5177 	cmdline_fixed_string_t link_check;
5178 	cmdline_fixed_string_t mode;
5179 };
5180 
5181 static void
5182 cmd_set_link_check_parsed(void *parsed_result,
5183 		__attribute__((unused)) struct cmdline *cl,
5184 		__attribute__((unused)) void *data)
5185 {
5186 	struct cmd_set_link_check *res = parsed_result;
5187 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5188 }
5189 
5190 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5191 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5192 			set, "set");
5193 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5194 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5195 			link_check, "link_check");
5196 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5197 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5198 			mode, "on#off");
5199 
5200 
5201 cmdline_parse_inst_t cmd_set_link_check = {
5202 	.f = cmd_set_link_check_parsed,
5203 	.help_str = "set link_check on|off: Enable/Disable link status check "
5204 	            "when starting/stopping a port",
5205 	.data = NULL,
5206 	.tokens = {
5207 		(void *)&cmd_setlinkcheck_set,
5208 		(void *)&cmd_setlinkcheck_link_check,
5209 		(void *)&cmd_setlinkcheck_mode,
5210 		NULL,
5211 	},
5212 };
5213 
5214 /* *** SET NIC BYPASS MODE *** */
5215 struct cmd_set_bypass_mode_result {
5216 	cmdline_fixed_string_t set;
5217 	cmdline_fixed_string_t bypass;
5218 	cmdline_fixed_string_t mode;
5219 	cmdline_fixed_string_t value;
5220 	portid_t port_id;
5221 };
5222 
5223 static void
5224 cmd_set_bypass_mode_parsed(void *parsed_result,
5225 		__attribute__((unused)) struct cmdline *cl,
5226 		__attribute__((unused)) void *data)
5227 {
5228 	struct cmd_set_bypass_mode_result *res = parsed_result;
5229 	portid_t port_id = res->port_id;
5230 	int32_t rc = -EINVAL;
5231 
5232 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5233 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5234 
5235 	if (!strcmp(res->value, "bypass"))
5236 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5237 	else if (!strcmp(res->value, "isolate"))
5238 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5239 	else
5240 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5241 
5242 	/* Set the bypass mode for the relevant port. */
5243 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5244 #endif
5245 	if (rc != 0)
5246 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5247 }
5248 
5249 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5250 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5251 			set, "set");
5252 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5253 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5254 			bypass, "bypass");
5255 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5256 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5257 			mode, "mode");
5258 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5259 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5260 			value, "normal#bypass#isolate");
5261 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5262 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5263 				port_id, UINT16);
5264 
5265 cmdline_parse_inst_t cmd_set_bypass_mode = {
5266 	.f = cmd_set_bypass_mode_parsed,
5267 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5268 	            "Set the NIC bypass mode for port_id",
5269 	.data = NULL,
5270 	.tokens = {
5271 		(void *)&cmd_setbypass_mode_set,
5272 		(void *)&cmd_setbypass_mode_bypass,
5273 		(void *)&cmd_setbypass_mode_mode,
5274 		(void *)&cmd_setbypass_mode_value,
5275 		(void *)&cmd_setbypass_mode_port,
5276 		NULL,
5277 	},
5278 };
5279 
5280 /* *** SET NIC BYPASS EVENT *** */
5281 struct cmd_set_bypass_event_result {
5282 	cmdline_fixed_string_t set;
5283 	cmdline_fixed_string_t bypass;
5284 	cmdline_fixed_string_t event;
5285 	cmdline_fixed_string_t event_value;
5286 	cmdline_fixed_string_t mode;
5287 	cmdline_fixed_string_t mode_value;
5288 	portid_t port_id;
5289 };
5290 
5291 static void
5292 cmd_set_bypass_event_parsed(void *parsed_result,
5293 		__attribute__((unused)) struct cmdline *cl,
5294 		__attribute__((unused)) void *data)
5295 {
5296 	int32_t rc = -EINVAL;
5297 	struct cmd_set_bypass_event_result *res = parsed_result;
5298 	portid_t port_id = res->port_id;
5299 
5300 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5301 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5302 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5303 
5304 	if (!strcmp(res->event_value, "timeout"))
5305 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5306 	else if (!strcmp(res->event_value, "os_on"))
5307 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5308 	else if (!strcmp(res->event_value, "os_off"))
5309 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5310 	else if (!strcmp(res->event_value, "power_on"))
5311 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5312 	else if (!strcmp(res->event_value, "power_off"))
5313 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5314 	else
5315 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5316 
5317 	if (!strcmp(res->mode_value, "bypass"))
5318 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5319 	else if (!strcmp(res->mode_value, "isolate"))
5320 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5321 	else
5322 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5323 
5324 	/* Set the watchdog timeout. */
5325 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5326 
5327 		rc = -EINVAL;
5328 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5329 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5330 							   bypass_timeout);
5331 		}
5332 		if (rc != 0) {
5333 			printf("Failed to set timeout value %u "
5334 			"for port %d, errto code: %d.\n",
5335 			bypass_timeout, port_id, rc);
5336 		}
5337 	}
5338 
5339 	/* Set the bypass event to transition to bypass mode. */
5340 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5341 					      bypass_mode);
5342 #endif
5343 
5344 	if (rc != 0)
5345 		printf("\t Failed to set bypass event for port = %d.\n",
5346 		       port_id);
5347 }
5348 
5349 cmdline_parse_token_string_t cmd_setbypass_event_set =
5350 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5351 			set, "set");
5352 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5353 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5354 			bypass, "bypass");
5355 cmdline_parse_token_string_t cmd_setbypass_event_event =
5356 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5357 			event, "event");
5358 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5359 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5360 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5361 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5362 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5363 			mode, "mode");
5364 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5365 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5366 			mode_value, "normal#bypass#isolate");
5367 cmdline_parse_token_num_t cmd_setbypass_event_port =
5368 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5369 				port_id, UINT16);
5370 
5371 cmdline_parse_inst_t cmd_set_bypass_event = {
5372 	.f = cmd_set_bypass_event_parsed,
5373 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5374 		"power_off mode normal|bypass|isolate <port_id>: "
5375 		"Set the NIC bypass event mode for port_id",
5376 	.data = NULL,
5377 	.tokens = {
5378 		(void *)&cmd_setbypass_event_set,
5379 		(void *)&cmd_setbypass_event_bypass,
5380 		(void *)&cmd_setbypass_event_event,
5381 		(void *)&cmd_setbypass_event_event_value,
5382 		(void *)&cmd_setbypass_event_mode,
5383 		(void *)&cmd_setbypass_event_mode_value,
5384 		(void *)&cmd_setbypass_event_port,
5385 		NULL,
5386 	},
5387 };
5388 
5389 
5390 /* *** SET NIC BYPASS TIMEOUT *** */
5391 struct cmd_set_bypass_timeout_result {
5392 	cmdline_fixed_string_t set;
5393 	cmdline_fixed_string_t bypass;
5394 	cmdline_fixed_string_t timeout;
5395 	cmdline_fixed_string_t value;
5396 };
5397 
5398 static void
5399 cmd_set_bypass_timeout_parsed(void *parsed_result,
5400 		__attribute__((unused)) struct cmdline *cl,
5401 		__attribute__((unused)) void *data)
5402 {
5403 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5404 
5405 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5406 	if (!strcmp(res->value, "1.5"))
5407 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5408 	else if (!strcmp(res->value, "2"))
5409 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5410 	else if (!strcmp(res->value, "3"))
5411 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5412 	else if (!strcmp(res->value, "4"))
5413 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5414 	else if (!strcmp(res->value, "8"))
5415 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5416 	else if (!strcmp(res->value, "16"))
5417 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5418 	else if (!strcmp(res->value, "32"))
5419 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5420 	else
5421 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5422 #endif
5423 }
5424 
5425 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5426 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5427 			set, "set");
5428 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5429 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5430 			bypass, "bypass");
5431 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5432 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5433 			timeout, "timeout");
5434 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5435 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5436 			value, "0#1.5#2#3#4#8#16#32");
5437 
5438 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5439 	.f = cmd_set_bypass_timeout_parsed,
5440 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5441 		"Set the NIC bypass watchdog timeout in seconds",
5442 	.data = NULL,
5443 	.tokens = {
5444 		(void *)&cmd_setbypass_timeout_set,
5445 		(void *)&cmd_setbypass_timeout_bypass,
5446 		(void *)&cmd_setbypass_timeout_timeout,
5447 		(void *)&cmd_setbypass_timeout_value,
5448 		NULL,
5449 	},
5450 };
5451 
5452 /* *** SHOW NIC BYPASS MODE *** */
5453 struct cmd_show_bypass_config_result {
5454 	cmdline_fixed_string_t show;
5455 	cmdline_fixed_string_t bypass;
5456 	cmdline_fixed_string_t config;
5457 	portid_t port_id;
5458 };
5459 
5460 static void
5461 cmd_show_bypass_config_parsed(void *parsed_result,
5462 		__attribute__((unused)) struct cmdline *cl,
5463 		__attribute__((unused)) void *data)
5464 {
5465 	struct cmd_show_bypass_config_result *res = parsed_result;
5466 	portid_t port_id = res->port_id;
5467 	int rc = -EINVAL;
5468 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5469 	uint32_t event_mode;
5470 	uint32_t bypass_mode;
5471 	uint32_t timeout = bypass_timeout;
5472 	int i;
5473 
5474 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5475 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5476 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5477 		{"UNKNOWN", "normal", "bypass", "isolate"};
5478 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5479 		"NONE",
5480 		"OS/board on",
5481 		"power supply on",
5482 		"OS/board off",
5483 		"power supply off",
5484 		"timeout"};
5485 	int num_events = (sizeof events) / (sizeof events[0]);
5486 
5487 	/* Display the bypass mode.*/
5488 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5489 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5490 		return;
5491 	}
5492 	else {
5493 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5494 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5495 
5496 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5497 	}
5498 
5499 	/* Display the bypass timeout.*/
5500 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5501 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5502 
5503 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5504 
5505 	/* Display the bypass events and associated modes. */
5506 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5507 
5508 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5509 			printf("\tFailed to get bypass mode for event = %s\n",
5510 				events[i]);
5511 		} else {
5512 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5513 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5514 
5515 			printf("\tbypass event: %-16s = %s\n", events[i],
5516 				modes[event_mode]);
5517 		}
5518 	}
5519 #endif
5520 	if (rc != 0)
5521 		printf("\tFailed to get bypass configuration for port = %d\n",
5522 		       port_id);
5523 }
5524 
5525 cmdline_parse_token_string_t cmd_showbypass_config_show =
5526 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5527 			show, "show");
5528 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5529 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5530 			bypass, "bypass");
5531 cmdline_parse_token_string_t cmd_showbypass_config_config =
5532 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5533 			config, "config");
5534 cmdline_parse_token_num_t cmd_showbypass_config_port =
5535 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5536 				port_id, UINT16);
5537 
5538 cmdline_parse_inst_t cmd_show_bypass_config = {
5539 	.f = cmd_show_bypass_config_parsed,
5540 	.help_str = "show bypass config <port_id>: "
5541 	            "Show the NIC bypass config for port_id",
5542 	.data = NULL,
5543 	.tokens = {
5544 		(void *)&cmd_showbypass_config_show,
5545 		(void *)&cmd_showbypass_config_bypass,
5546 		(void *)&cmd_showbypass_config_config,
5547 		(void *)&cmd_showbypass_config_port,
5548 		NULL,
5549 	},
5550 };
5551 
5552 #ifdef RTE_LIBRTE_PMD_BOND
5553 /* *** SET BONDING MODE *** */
5554 struct cmd_set_bonding_mode_result {
5555 	cmdline_fixed_string_t set;
5556 	cmdline_fixed_string_t bonding;
5557 	cmdline_fixed_string_t mode;
5558 	uint8_t value;
5559 	portid_t port_id;
5560 };
5561 
5562 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5563 		__attribute__((unused))  struct cmdline *cl,
5564 		__attribute__((unused)) void *data)
5565 {
5566 	struct cmd_set_bonding_mode_result *res = parsed_result;
5567 	portid_t port_id = res->port_id;
5568 
5569 	/* Set the bonding mode for the relevant port. */
5570 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5571 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5572 }
5573 
5574 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5576 		set, "set");
5577 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5579 		bonding, "bonding");
5580 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5581 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5582 		mode, "mode");
5583 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5584 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5585 		value, UINT8);
5586 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5587 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5588 		port_id, UINT16);
5589 
5590 cmdline_parse_inst_t cmd_set_bonding_mode = {
5591 		.f = cmd_set_bonding_mode_parsed,
5592 		.help_str = "set bonding mode <mode_value> <port_id>: "
5593 			"Set the bonding mode for port_id",
5594 		.data = NULL,
5595 		.tokens = {
5596 				(void *) &cmd_setbonding_mode_set,
5597 				(void *) &cmd_setbonding_mode_bonding,
5598 				(void *) &cmd_setbonding_mode_mode,
5599 				(void *) &cmd_setbonding_mode_value,
5600 				(void *) &cmd_setbonding_mode_port,
5601 				NULL
5602 		}
5603 };
5604 
5605 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5606 struct cmd_set_bonding_lacp_dedicated_queues_result {
5607 	cmdline_fixed_string_t set;
5608 	cmdline_fixed_string_t bonding;
5609 	cmdline_fixed_string_t lacp;
5610 	cmdline_fixed_string_t dedicated_queues;
5611 	portid_t port_id;
5612 	cmdline_fixed_string_t mode;
5613 };
5614 
5615 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5616 		__attribute__((unused))  struct cmdline *cl,
5617 		__attribute__((unused)) void *data)
5618 {
5619 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5620 	portid_t port_id = res->port_id;
5621 	struct rte_port *port;
5622 
5623 	port = &ports[port_id];
5624 
5625 	/** Check if the port is not started **/
5626 	if (port->port_status != RTE_PORT_STOPPED) {
5627 		printf("Please stop port %d first\n", port_id);
5628 		return;
5629 	}
5630 
5631 	if (!strcmp(res->mode, "enable")) {
5632 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5633 			printf("Dedicate queues for LACP control packets"
5634 					" enabled\n");
5635 		else
5636 			printf("Enabling dedicate queues for LACP control "
5637 					"packets on port %d failed\n", port_id);
5638 	} else if (!strcmp(res->mode, "disable")) {
5639 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5640 			printf("Dedicated queues for LACP control packets "
5641 					"disabled\n");
5642 		else
5643 			printf("Disabling dedicated queues for LACP control "
5644 					"traffic on port %d failed\n", port_id);
5645 	}
5646 }
5647 
5648 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5650 		set, "set");
5651 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5653 		bonding, "bonding");
5654 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5655 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5656 		lacp, "lacp");
5657 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5658 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5659 		dedicated_queues, "dedicated_queues");
5660 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5661 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5662 		port_id, UINT16);
5663 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5665 		mode, "enable#disable");
5666 
5667 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5668 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5669 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5670 			"enable|disable: "
5671 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5672 		.data = NULL,
5673 		.tokens = {
5674 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5675 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5676 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5677 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5678 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5679 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5680 			NULL
5681 		}
5682 };
5683 
5684 /* *** SET BALANCE XMIT POLICY *** */
5685 struct cmd_set_bonding_balance_xmit_policy_result {
5686 	cmdline_fixed_string_t set;
5687 	cmdline_fixed_string_t bonding;
5688 	cmdline_fixed_string_t balance_xmit_policy;
5689 	portid_t port_id;
5690 	cmdline_fixed_string_t policy;
5691 };
5692 
5693 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5694 		__attribute__((unused))  struct cmdline *cl,
5695 		__attribute__((unused)) void *data)
5696 {
5697 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5698 	portid_t port_id = res->port_id;
5699 	uint8_t policy;
5700 
5701 	if (!strcmp(res->policy, "l2")) {
5702 		policy = BALANCE_XMIT_POLICY_LAYER2;
5703 	} else if (!strcmp(res->policy, "l23")) {
5704 		policy = BALANCE_XMIT_POLICY_LAYER23;
5705 	} else if (!strcmp(res->policy, "l34")) {
5706 		policy = BALANCE_XMIT_POLICY_LAYER34;
5707 	} else {
5708 		printf("\t Invalid xmit policy selection");
5709 		return;
5710 	}
5711 
5712 	/* Set the bonding mode for the relevant port. */
5713 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5714 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5715 				port_id);
5716 	}
5717 }
5718 
5719 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5720 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5721 		set, "set");
5722 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5724 		bonding, "bonding");
5725 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5726 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5727 		balance_xmit_policy, "balance_xmit_policy");
5728 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5729 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5730 		port_id, UINT16);
5731 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5732 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5733 		policy, "l2#l23#l34");
5734 
5735 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5736 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
5737 		.help_str = "set bonding balance_xmit_policy <port_id> "
5738 			"l2|l23|l34: "
5739 			"Set the bonding balance_xmit_policy for port_id",
5740 		.data = NULL,
5741 		.tokens = {
5742 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5743 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5744 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5745 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5746 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5747 				NULL
5748 		}
5749 };
5750 
5751 /* *** SHOW NIC BONDING CONFIGURATION *** */
5752 struct cmd_show_bonding_config_result {
5753 	cmdline_fixed_string_t show;
5754 	cmdline_fixed_string_t bonding;
5755 	cmdline_fixed_string_t config;
5756 	portid_t port_id;
5757 };
5758 
5759 static void cmd_show_bonding_config_parsed(void *parsed_result,
5760 		__attribute__((unused))  struct cmdline *cl,
5761 		__attribute__((unused)) void *data)
5762 {
5763 	struct cmd_show_bonding_config_result *res = parsed_result;
5764 	int bonding_mode, agg_mode;
5765 	portid_t slaves[RTE_MAX_ETHPORTS];
5766 	int num_slaves, num_active_slaves;
5767 	int primary_id;
5768 	int i;
5769 	portid_t port_id = res->port_id;
5770 
5771 	/* Display the bonding mode.*/
5772 	bonding_mode = rte_eth_bond_mode_get(port_id);
5773 	if (bonding_mode < 0) {
5774 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5775 		return;
5776 	} else
5777 		printf("\tBonding mode: %d\n", bonding_mode);
5778 
5779 	if (bonding_mode == BONDING_MODE_BALANCE) {
5780 		int balance_xmit_policy;
5781 
5782 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5783 		if (balance_xmit_policy < 0) {
5784 			printf("\tFailed to get balance xmit policy for port = %d\n",
5785 					port_id);
5786 			return;
5787 		} else {
5788 			printf("\tBalance Xmit Policy: ");
5789 
5790 			switch (balance_xmit_policy) {
5791 			case BALANCE_XMIT_POLICY_LAYER2:
5792 				printf("BALANCE_XMIT_POLICY_LAYER2");
5793 				break;
5794 			case BALANCE_XMIT_POLICY_LAYER23:
5795 				printf("BALANCE_XMIT_POLICY_LAYER23");
5796 				break;
5797 			case BALANCE_XMIT_POLICY_LAYER34:
5798 				printf("BALANCE_XMIT_POLICY_LAYER34");
5799 				break;
5800 			}
5801 			printf("\n");
5802 		}
5803 	}
5804 
5805 	if (bonding_mode == BONDING_MODE_8023AD) {
5806 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5807 		printf("\tIEEE802.3AD Aggregator Mode: ");
5808 		switch (agg_mode) {
5809 		case AGG_BANDWIDTH:
5810 			printf("bandwidth");
5811 			break;
5812 		case AGG_STABLE:
5813 			printf("stable");
5814 			break;
5815 		case AGG_COUNT:
5816 			printf("count");
5817 			break;
5818 		}
5819 		printf("\n");
5820 	}
5821 
5822 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5823 
5824 	if (num_slaves < 0) {
5825 		printf("\tFailed to get slave list for port = %d\n", port_id);
5826 		return;
5827 	}
5828 	if (num_slaves > 0) {
5829 		printf("\tSlaves (%d): [", num_slaves);
5830 		for (i = 0; i < num_slaves - 1; i++)
5831 			printf("%d ", slaves[i]);
5832 
5833 		printf("%d]\n", slaves[num_slaves - 1]);
5834 	} else {
5835 		printf("\tSlaves: []\n");
5836 
5837 	}
5838 
5839 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5840 			RTE_MAX_ETHPORTS);
5841 
5842 	if (num_active_slaves < 0) {
5843 		printf("\tFailed to get active slave list for port = %d\n", port_id);
5844 		return;
5845 	}
5846 	if (num_active_slaves > 0) {
5847 		printf("\tActive Slaves (%d): [", num_active_slaves);
5848 		for (i = 0; i < num_active_slaves - 1; i++)
5849 			printf("%d ", slaves[i]);
5850 
5851 		printf("%d]\n", slaves[num_active_slaves - 1]);
5852 
5853 	} else {
5854 		printf("\tActive Slaves: []\n");
5855 
5856 	}
5857 
5858 	primary_id = rte_eth_bond_primary_get(port_id);
5859 	if (primary_id < 0) {
5860 		printf("\tFailed to get primary slave for port = %d\n", port_id);
5861 		return;
5862 	} else
5863 		printf("\tPrimary: [%d]\n", primary_id);
5864 
5865 }
5866 
5867 cmdline_parse_token_string_t cmd_showbonding_config_show =
5868 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5869 		show, "show");
5870 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5872 		bonding, "bonding");
5873 cmdline_parse_token_string_t cmd_showbonding_config_config =
5874 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5875 		config, "config");
5876 cmdline_parse_token_num_t cmd_showbonding_config_port =
5877 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5878 		port_id, UINT16);
5879 
5880 cmdline_parse_inst_t cmd_show_bonding_config = {
5881 		.f = cmd_show_bonding_config_parsed,
5882 		.help_str = "show bonding config <port_id>: "
5883 			"Show the bonding config for port_id",
5884 		.data = NULL,
5885 		.tokens = {
5886 				(void *)&cmd_showbonding_config_show,
5887 				(void *)&cmd_showbonding_config_bonding,
5888 				(void *)&cmd_showbonding_config_config,
5889 				(void *)&cmd_showbonding_config_port,
5890 				NULL
5891 		}
5892 };
5893 
5894 /* *** SET BONDING PRIMARY *** */
5895 struct cmd_set_bonding_primary_result {
5896 	cmdline_fixed_string_t set;
5897 	cmdline_fixed_string_t bonding;
5898 	cmdline_fixed_string_t primary;
5899 	portid_t slave_id;
5900 	portid_t port_id;
5901 };
5902 
5903 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5904 		__attribute__((unused))  struct cmdline *cl,
5905 		__attribute__((unused)) void *data)
5906 {
5907 	struct cmd_set_bonding_primary_result *res = parsed_result;
5908 	portid_t master_port_id = res->port_id;
5909 	portid_t slave_port_id = res->slave_id;
5910 
5911 	/* Set the primary slave for a bonded device. */
5912 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5913 		printf("\t Failed to set primary slave for port = %d.\n",
5914 				master_port_id);
5915 		return;
5916 	}
5917 	init_port_config();
5918 }
5919 
5920 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5922 		set, "set");
5923 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5925 		bonding, "bonding");
5926 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5928 		primary, "primary");
5929 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5930 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5931 		slave_id, UINT16);
5932 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5934 		port_id, UINT16);
5935 
5936 cmdline_parse_inst_t cmd_set_bonding_primary = {
5937 		.f = cmd_set_bonding_primary_parsed,
5938 		.help_str = "set bonding primary <slave_id> <port_id>: "
5939 			"Set the primary slave for port_id",
5940 		.data = NULL,
5941 		.tokens = {
5942 				(void *)&cmd_setbonding_primary_set,
5943 				(void *)&cmd_setbonding_primary_bonding,
5944 				(void *)&cmd_setbonding_primary_primary,
5945 				(void *)&cmd_setbonding_primary_slave,
5946 				(void *)&cmd_setbonding_primary_port,
5947 				NULL
5948 		}
5949 };
5950 
5951 /* *** ADD SLAVE *** */
5952 struct cmd_add_bonding_slave_result {
5953 	cmdline_fixed_string_t add;
5954 	cmdline_fixed_string_t bonding;
5955 	cmdline_fixed_string_t slave;
5956 	portid_t slave_id;
5957 	portid_t port_id;
5958 };
5959 
5960 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5961 		__attribute__((unused))  struct cmdline *cl,
5962 		__attribute__((unused)) void *data)
5963 {
5964 	struct cmd_add_bonding_slave_result *res = parsed_result;
5965 	portid_t master_port_id = res->port_id;
5966 	portid_t slave_port_id = res->slave_id;
5967 
5968 	/* add the slave for a bonded device. */
5969 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5970 		printf("\t Failed to add slave %d to master port = %d.\n",
5971 				slave_port_id, master_port_id);
5972 		return;
5973 	}
5974 	init_port_config();
5975 	set_port_slave_flag(slave_port_id);
5976 }
5977 
5978 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5979 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5980 		add, "add");
5981 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5982 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5983 		bonding, "bonding");
5984 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5985 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5986 		slave, "slave");
5987 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5988 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5989 		slave_id, UINT16);
5990 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5991 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5992 		port_id, UINT16);
5993 
5994 cmdline_parse_inst_t cmd_add_bonding_slave = {
5995 		.f = cmd_add_bonding_slave_parsed,
5996 		.help_str = "add bonding slave <slave_id> <port_id>: "
5997 			"Add a slave device to a bonded device",
5998 		.data = NULL,
5999 		.tokens = {
6000 				(void *)&cmd_addbonding_slave_add,
6001 				(void *)&cmd_addbonding_slave_bonding,
6002 				(void *)&cmd_addbonding_slave_slave,
6003 				(void *)&cmd_addbonding_slave_slaveid,
6004 				(void *)&cmd_addbonding_slave_port,
6005 				NULL
6006 		}
6007 };
6008 
6009 /* *** REMOVE SLAVE *** */
6010 struct cmd_remove_bonding_slave_result {
6011 	cmdline_fixed_string_t remove;
6012 	cmdline_fixed_string_t bonding;
6013 	cmdline_fixed_string_t slave;
6014 	portid_t slave_id;
6015 	portid_t port_id;
6016 };
6017 
6018 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6019 		__attribute__((unused))  struct cmdline *cl,
6020 		__attribute__((unused)) void *data)
6021 {
6022 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6023 	portid_t master_port_id = res->port_id;
6024 	portid_t slave_port_id = res->slave_id;
6025 
6026 	/* remove the slave from a bonded device. */
6027 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6028 		printf("\t Failed to remove slave %d from master port = %d.\n",
6029 				slave_port_id, master_port_id);
6030 		return;
6031 	}
6032 	init_port_config();
6033 	clear_port_slave_flag(slave_port_id);
6034 }
6035 
6036 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6037 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6038 				remove, "remove");
6039 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6040 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6041 				bonding, "bonding");
6042 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6043 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6044 				slave, "slave");
6045 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6046 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6047 				slave_id, UINT16);
6048 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6049 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6050 				port_id, UINT16);
6051 
6052 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6053 		.f = cmd_remove_bonding_slave_parsed,
6054 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6055 			"Remove a slave device from a bonded device",
6056 		.data = NULL,
6057 		.tokens = {
6058 				(void *)&cmd_removebonding_slave_remove,
6059 				(void *)&cmd_removebonding_slave_bonding,
6060 				(void *)&cmd_removebonding_slave_slave,
6061 				(void *)&cmd_removebonding_slave_slaveid,
6062 				(void *)&cmd_removebonding_slave_port,
6063 				NULL
6064 		}
6065 };
6066 
6067 /* *** CREATE BONDED DEVICE *** */
6068 struct cmd_create_bonded_device_result {
6069 	cmdline_fixed_string_t create;
6070 	cmdline_fixed_string_t bonded;
6071 	cmdline_fixed_string_t device;
6072 	uint8_t mode;
6073 	uint8_t socket;
6074 };
6075 
6076 static int bond_dev_num = 0;
6077 
6078 static void cmd_create_bonded_device_parsed(void *parsed_result,
6079 		__attribute__((unused))  struct cmdline *cl,
6080 		__attribute__((unused)) void *data)
6081 {
6082 	struct cmd_create_bonded_device_result *res = parsed_result;
6083 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6084 	int port_id;
6085 
6086 	if (test_done == 0) {
6087 		printf("Please stop forwarding first\n");
6088 		return;
6089 	}
6090 
6091 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6092 			bond_dev_num++);
6093 
6094 	/* Create a new bonded device. */
6095 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6096 	if (port_id < 0) {
6097 		printf("\t Failed to create bonded device.\n");
6098 		return;
6099 	} else {
6100 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6101 				port_id);
6102 
6103 		/* Update number of ports */
6104 		nb_ports = rte_eth_dev_count_avail();
6105 		reconfig(port_id, res->socket);
6106 		rte_eth_promiscuous_enable(port_id);
6107 		ports[port_id].need_setup = 0;
6108 		ports[port_id].port_status = RTE_PORT_STOPPED;
6109 	}
6110 
6111 }
6112 
6113 cmdline_parse_token_string_t cmd_createbonded_device_create =
6114 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6115 				create, "create");
6116 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6117 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6118 				bonded, "bonded");
6119 cmdline_parse_token_string_t cmd_createbonded_device_device =
6120 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6121 				device, "device");
6122 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6123 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6124 				mode, UINT8);
6125 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6126 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6127 				socket, UINT8);
6128 
6129 cmdline_parse_inst_t cmd_create_bonded_device = {
6130 		.f = cmd_create_bonded_device_parsed,
6131 		.help_str = "create bonded device <mode> <socket>: "
6132 			"Create a new bonded device with specific bonding mode and socket",
6133 		.data = NULL,
6134 		.tokens = {
6135 				(void *)&cmd_createbonded_device_create,
6136 				(void *)&cmd_createbonded_device_bonded,
6137 				(void *)&cmd_createbonded_device_device,
6138 				(void *)&cmd_createbonded_device_mode,
6139 				(void *)&cmd_createbonded_device_socket,
6140 				NULL
6141 		}
6142 };
6143 
6144 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6145 struct cmd_set_bond_mac_addr_result {
6146 	cmdline_fixed_string_t set;
6147 	cmdline_fixed_string_t bonding;
6148 	cmdline_fixed_string_t mac_addr;
6149 	uint16_t port_num;
6150 	struct rte_ether_addr address;
6151 };
6152 
6153 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6154 		__attribute__((unused))  struct cmdline *cl,
6155 		__attribute__((unused)) void *data)
6156 {
6157 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6158 	int ret;
6159 
6160 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6161 		return;
6162 
6163 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6164 
6165 	/* check the return value and print it if is < 0 */
6166 	if (ret < 0)
6167 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6168 }
6169 
6170 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6171 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6172 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6173 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6174 				"bonding");
6175 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6176 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6177 				"mac_addr");
6178 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6179 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6180 				port_num, UINT16);
6181 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6182 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6183 
6184 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6185 		.f = cmd_set_bond_mac_addr_parsed,
6186 		.data = (void *) 0,
6187 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6188 		.tokens = {
6189 				(void *)&cmd_set_bond_mac_addr_set,
6190 				(void *)&cmd_set_bond_mac_addr_bonding,
6191 				(void *)&cmd_set_bond_mac_addr_mac,
6192 				(void *)&cmd_set_bond_mac_addr_portnum,
6193 				(void *)&cmd_set_bond_mac_addr_addr,
6194 				NULL
6195 		}
6196 };
6197 
6198 
6199 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6200 struct cmd_set_bond_mon_period_result {
6201 	cmdline_fixed_string_t set;
6202 	cmdline_fixed_string_t bonding;
6203 	cmdline_fixed_string_t mon_period;
6204 	uint16_t port_num;
6205 	uint32_t period_ms;
6206 };
6207 
6208 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6209 		__attribute__((unused))  struct cmdline *cl,
6210 		__attribute__((unused)) void *data)
6211 {
6212 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6213 	int ret;
6214 
6215 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6216 
6217 	/* check the return value and print it if is < 0 */
6218 	if (ret < 0)
6219 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6220 }
6221 
6222 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6223 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6224 				set, "set");
6225 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6226 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6227 				bonding, "bonding");
6228 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6229 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6230 				mon_period,	"mon_period");
6231 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6232 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6233 				port_num, UINT16);
6234 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6235 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6236 				period_ms, UINT32);
6237 
6238 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6239 		.f = cmd_set_bond_mon_period_parsed,
6240 		.data = (void *) 0,
6241 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6242 		.tokens = {
6243 				(void *)&cmd_set_bond_mon_period_set,
6244 				(void *)&cmd_set_bond_mon_period_bonding,
6245 				(void *)&cmd_set_bond_mon_period_mon_period,
6246 				(void *)&cmd_set_bond_mon_period_portnum,
6247 				(void *)&cmd_set_bond_mon_period_period_ms,
6248 				NULL
6249 		}
6250 };
6251 
6252 
6253 
6254 struct cmd_set_bonding_agg_mode_policy_result {
6255 	cmdline_fixed_string_t set;
6256 	cmdline_fixed_string_t bonding;
6257 	cmdline_fixed_string_t agg_mode;
6258 	uint16_t port_num;
6259 	cmdline_fixed_string_t policy;
6260 };
6261 
6262 
6263 static void
6264 cmd_set_bonding_agg_mode(void *parsed_result,
6265 		__attribute__((unused)) struct cmdline *cl,
6266 		__attribute__((unused)) void *data)
6267 {
6268 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6269 	uint8_t policy = AGG_BANDWIDTH;
6270 
6271 	if (!strcmp(res->policy, "bandwidth"))
6272 		policy = AGG_BANDWIDTH;
6273 	else if (!strcmp(res->policy, "stable"))
6274 		policy = AGG_STABLE;
6275 	else if (!strcmp(res->policy, "count"))
6276 		policy = AGG_COUNT;
6277 
6278 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6279 }
6280 
6281 
6282 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6283 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6284 				set, "set");
6285 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6286 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6287 				bonding, "bonding");
6288 
6289 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6290 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6291 				agg_mode, "agg_mode");
6292 
6293 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6294 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6295 				port_num, UINT16);
6296 
6297 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6298 	TOKEN_STRING_INITIALIZER(
6299 			struct cmd_set_bonding_balance_xmit_policy_result,
6300 		policy, "stable#bandwidth#count");
6301 
6302 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6303 	.f = cmd_set_bonding_agg_mode,
6304 	.data = (void *) 0,
6305 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6306 	.tokens = {
6307 			(void *)&cmd_set_bonding_agg_mode_set,
6308 			(void *)&cmd_set_bonding_agg_mode_bonding,
6309 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6310 			(void *)&cmd_set_bonding_agg_mode_portnum,
6311 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6312 			NULL
6313 		}
6314 };
6315 
6316 
6317 #endif /* RTE_LIBRTE_PMD_BOND */
6318 
6319 /* *** SET FORWARDING MODE *** */
6320 struct cmd_set_fwd_mode_result {
6321 	cmdline_fixed_string_t set;
6322 	cmdline_fixed_string_t fwd;
6323 	cmdline_fixed_string_t mode;
6324 };
6325 
6326 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6327 				    __attribute__((unused)) struct cmdline *cl,
6328 				    __attribute__((unused)) void *data)
6329 {
6330 	struct cmd_set_fwd_mode_result *res = parsed_result;
6331 
6332 	retry_enabled = 0;
6333 	set_pkt_forwarding_mode(res->mode);
6334 }
6335 
6336 cmdline_parse_token_string_t cmd_setfwd_set =
6337 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6338 cmdline_parse_token_string_t cmd_setfwd_fwd =
6339 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6340 cmdline_parse_token_string_t cmd_setfwd_mode =
6341 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6342 		"" /* defined at init */);
6343 
6344 cmdline_parse_inst_t cmd_set_fwd_mode = {
6345 	.f = cmd_set_fwd_mode_parsed,
6346 	.data = NULL,
6347 	.help_str = NULL, /* defined at init */
6348 	.tokens = {
6349 		(void *)&cmd_setfwd_set,
6350 		(void *)&cmd_setfwd_fwd,
6351 		(void *)&cmd_setfwd_mode,
6352 		NULL,
6353 	},
6354 };
6355 
6356 static void cmd_set_fwd_mode_init(void)
6357 {
6358 	char *modes, *c;
6359 	static char token[128];
6360 	static char help[256];
6361 	cmdline_parse_token_string_t *token_struct;
6362 
6363 	modes = list_pkt_forwarding_modes();
6364 	snprintf(help, sizeof(help), "set fwd %s: "
6365 		"Set packet forwarding mode", modes);
6366 	cmd_set_fwd_mode.help_str = help;
6367 
6368 	/* string token separator is # */
6369 	for (c = token; *modes != '\0'; modes++)
6370 		if (*modes == '|')
6371 			*c++ = '#';
6372 		else
6373 			*c++ = *modes;
6374 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6375 	token_struct->string_data.str = token;
6376 }
6377 
6378 /* *** SET RETRY FORWARDING MODE *** */
6379 struct cmd_set_fwd_retry_mode_result {
6380 	cmdline_fixed_string_t set;
6381 	cmdline_fixed_string_t fwd;
6382 	cmdline_fixed_string_t mode;
6383 	cmdline_fixed_string_t retry;
6384 };
6385 
6386 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6387 			    __attribute__((unused)) struct cmdline *cl,
6388 			    __attribute__((unused)) void *data)
6389 {
6390 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6391 
6392 	retry_enabled = 1;
6393 	set_pkt_forwarding_mode(res->mode);
6394 }
6395 
6396 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6397 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6398 			set, "set");
6399 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6400 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6401 			fwd, "fwd");
6402 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6403 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6404 			mode,
6405 		"" /* defined at init */);
6406 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6407 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6408 			retry, "retry");
6409 
6410 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6411 	.f = cmd_set_fwd_retry_mode_parsed,
6412 	.data = NULL,
6413 	.help_str = NULL, /* defined at init */
6414 	.tokens = {
6415 		(void *)&cmd_setfwd_retry_set,
6416 		(void *)&cmd_setfwd_retry_fwd,
6417 		(void *)&cmd_setfwd_retry_mode,
6418 		(void *)&cmd_setfwd_retry_retry,
6419 		NULL,
6420 	},
6421 };
6422 
6423 static void cmd_set_fwd_retry_mode_init(void)
6424 {
6425 	char *modes, *c;
6426 	static char token[128];
6427 	static char help[256];
6428 	cmdline_parse_token_string_t *token_struct;
6429 
6430 	modes = list_pkt_forwarding_retry_modes();
6431 	snprintf(help, sizeof(help), "set fwd %s retry: "
6432 		"Set packet forwarding mode with retry", modes);
6433 	cmd_set_fwd_retry_mode.help_str = help;
6434 
6435 	/* string token separator is # */
6436 	for (c = token; *modes != '\0'; modes++)
6437 		if (*modes == '|')
6438 			*c++ = '#';
6439 		else
6440 			*c++ = *modes;
6441 	token_struct = (cmdline_parse_token_string_t *)
6442 		cmd_set_fwd_retry_mode.tokens[2];
6443 	token_struct->string_data.str = token;
6444 }
6445 
6446 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6447 struct cmd_set_burst_tx_retry_result {
6448 	cmdline_fixed_string_t set;
6449 	cmdline_fixed_string_t burst;
6450 	cmdline_fixed_string_t tx;
6451 	cmdline_fixed_string_t delay;
6452 	uint32_t time;
6453 	cmdline_fixed_string_t retry;
6454 	uint32_t retry_num;
6455 };
6456 
6457 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6458 					__attribute__((unused)) struct cmdline *cl,
6459 					__attribute__((unused)) void *data)
6460 {
6461 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6462 
6463 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6464 		&& !strcmp(res->tx, "tx")) {
6465 		if (!strcmp(res->delay, "delay"))
6466 			burst_tx_delay_time = res->time;
6467 		if (!strcmp(res->retry, "retry"))
6468 			burst_tx_retry_num = res->retry_num;
6469 	}
6470 
6471 }
6472 
6473 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6474 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6475 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6476 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6477 				 "burst");
6478 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6479 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6480 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6481 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6482 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6483 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6484 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6485 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6486 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6487 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6488 
6489 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6490 	.f = cmd_set_burst_tx_retry_parsed,
6491 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6492 	.tokens = {
6493 		(void *)&cmd_set_burst_tx_retry_set,
6494 		(void *)&cmd_set_burst_tx_retry_burst,
6495 		(void *)&cmd_set_burst_tx_retry_tx,
6496 		(void *)&cmd_set_burst_tx_retry_delay,
6497 		(void *)&cmd_set_burst_tx_retry_time,
6498 		(void *)&cmd_set_burst_tx_retry_retry,
6499 		(void *)&cmd_set_burst_tx_retry_retry_num,
6500 		NULL,
6501 	},
6502 };
6503 
6504 /* *** SET PROMISC MODE *** */
6505 struct cmd_set_promisc_mode_result {
6506 	cmdline_fixed_string_t set;
6507 	cmdline_fixed_string_t promisc;
6508 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6509 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6510 	cmdline_fixed_string_t mode;
6511 };
6512 
6513 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6514 					__attribute__((unused)) struct cmdline *cl,
6515 					void *allports)
6516 {
6517 	struct cmd_set_promisc_mode_result *res = parsed_result;
6518 	int enable;
6519 	portid_t i;
6520 
6521 	if (!strcmp(res->mode, "on"))
6522 		enable = 1;
6523 	else
6524 		enable = 0;
6525 
6526 	/* all ports */
6527 	if (allports) {
6528 		RTE_ETH_FOREACH_DEV(i) {
6529 			if (enable)
6530 				rte_eth_promiscuous_enable(i);
6531 			else
6532 				rte_eth_promiscuous_disable(i);
6533 		}
6534 	}
6535 	else {
6536 		if (enable)
6537 			rte_eth_promiscuous_enable(res->port_num);
6538 		else
6539 			rte_eth_promiscuous_disable(res->port_num);
6540 	}
6541 }
6542 
6543 cmdline_parse_token_string_t cmd_setpromisc_set =
6544 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6545 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6546 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6547 				 "promisc");
6548 cmdline_parse_token_string_t cmd_setpromisc_portall =
6549 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6550 				 "all");
6551 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6552 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6553 			      UINT16);
6554 cmdline_parse_token_string_t cmd_setpromisc_mode =
6555 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6556 				 "on#off");
6557 
6558 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6559 	.f = cmd_set_promisc_mode_parsed,
6560 	.data = (void *)1,
6561 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6562 	.tokens = {
6563 		(void *)&cmd_setpromisc_set,
6564 		(void *)&cmd_setpromisc_promisc,
6565 		(void *)&cmd_setpromisc_portall,
6566 		(void *)&cmd_setpromisc_mode,
6567 		NULL,
6568 	},
6569 };
6570 
6571 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6572 	.f = cmd_set_promisc_mode_parsed,
6573 	.data = (void *)0,
6574 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6575 	.tokens = {
6576 		(void *)&cmd_setpromisc_set,
6577 		(void *)&cmd_setpromisc_promisc,
6578 		(void *)&cmd_setpromisc_portnum,
6579 		(void *)&cmd_setpromisc_mode,
6580 		NULL,
6581 	},
6582 };
6583 
6584 /* *** SET ALLMULTI MODE *** */
6585 struct cmd_set_allmulti_mode_result {
6586 	cmdline_fixed_string_t set;
6587 	cmdline_fixed_string_t allmulti;
6588 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6589 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6590 	cmdline_fixed_string_t mode;
6591 };
6592 
6593 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6594 					__attribute__((unused)) struct cmdline *cl,
6595 					void *allports)
6596 {
6597 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6598 	int enable;
6599 	portid_t i;
6600 
6601 	if (!strcmp(res->mode, "on"))
6602 		enable = 1;
6603 	else
6604 		enable = 0;
6605 
6606 	/* all ports */
6607 	if (allports) {
6608 		RTE_ETH_FOREACH_DEV(i) {
6609 			if (enable)
6610 				rte_eth_allmulticast_enable(i);
6611 			else
6612 				rte_eth_allmulticast_disable(i);
6613 		}
6614 	}
6615 	else {
6616 		if (enable)
6617 			rte_eth_allmulticast_enable(res->port_num);
6618 		else
6619 			rte_eth_allmulticast_disable(res->port_num);
6620 	}
6621 }
6622 
6623 cmdline_parse_token_string_t cmd_setallmulti_set =
6624 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6625 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6626 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6627 				 "allmulti");
6628 cmdline_parse_token_string_t cmd_setallmulti_portall =
6629 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6630 				 "all");
6631 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6632 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6633 			      UINT16);
6634 cmdline_parse_token_string_t cmd_setallmulti_mode =
6635 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6636 				 "on#off");
6637 
6638 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6639 	.f = cmd_set_allmulti_mode_parsed,
6640 	.data = (void *)1,
6641 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6642 	.tokens = {
6643 		(void *)&cmd_setallmulti_set,
6644 		(void *)&cmd_setallmulti_allmulti,
6645 		(void *)&cmd_setallmulti_portall,
6646 		(void *)&cmd_setallmulti_mode,
6647 		NULL,
6648 	},
6649 };
6650 
6651 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6652 	.f = cmd_set_allmulti_mode_parsed,
6653 	.data = (void *)0,
6654 	.help_str = "set allmulti <port_id> on|off: "
6655 		"Set allmulti mode on port_id",
6656 	.tokens = {
6657 		(void *)&cmd_setallmulti_set,
6658 		(void *)&cmd_setallmulti_allmulti,
6659 		(void *)&cmd_setallmulti_portnum,
6660 		(void *)&cmd_setallmulti_mode,
6661 		NULL,
6662 	},
6663 };
6664 
6665 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6666 struct cmd_link_flow_ctrl_set_result {
6667 	cmdline_fixed_string_t set;
6668 	cmdline_fixed_string_t flow_ctrl;
6669 	cmdline_fixed_string_t rx;
6670 	cmdline_fixed_string_t rx_lfc_mode;
6671 	cmdline_fixed_string_t tx;
6672 	cmdline_fixed_string_t tx_lfc_mode;
6673 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6674 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6675 	cmdline_fixed_string_t autoneg_str;
6676 	cmdline_fixed_string_t autoneg;
6677 	cmdline_fixed_string_t hw_str;
6678 	uint32_t high_water;
6679 	cmdline_fixed_string_t lw_str;
6680 	uint32_t low_water;
6681 	cmdline_fixed_string_t pt_str;
6682 	uint16_t pause_time;
6683 	cmdline_fixed_string_t xon_str;
6684 	uint16_t send_xon;
6685 	portid_t port_id;
6686 };
6687 
6688 cmdline_parse_token_string_t cmd_lfc_set_set =
6689 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6690 				set, "set");
6691 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6692 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6693 				flow_ctrl, "flow_ctrl");
6694 cmdline_parse_token_string_t cmd_lfc_set_rx =
6695 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6696 				rx, "rx");
6697 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6698 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6699 				rx_lfc_mode, "on#off");
6700 cmdline_parse_token_string_t cmd_lfc_set_tx =
6701 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 				tx, "tx");
6703 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6704 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6705 				tx_lfc_mode, "on#off");
6706 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6707 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6708 				hw_str, "high_water");
6709 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6710 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6711 				high_water, UINT32);
6712 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6713 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6714 				lw_str, "low_water");
6715 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6716 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6717 				low_water, UINT32);
6718 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6719 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6720 				pt_str, "pause_time");
6721 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6722 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6723 				pause_time, UINT16);
6724 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6725 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6726 				xon_str, "send_xon");
6727 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6728 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6729 				send_xon, UINT16);
6730 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6731 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6732 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6733 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6734 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6735 				mac_ctrl_frame_fwd_mode, "on#off");
6736 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6737 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6738 				autoneg_str, "autoneg");
6739 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6740 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6741 				autoneg, "on#off");
6742 cmdline_parse_token_num_t cmd_lfc_set_portid =
6743 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6744 				port_id, UINT16);
6745 
6746 /* forward declaration */
6747 static void
6748 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6749 			      void *data);
6750 
6751 cmdline_parse_inst_t cmd_link_flow_control_set = {
6752 	.f = cmd_link_flow_ctrl_set_parsed,
6753 	.data = NULL,
6754 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6755 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6756 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6757 	.tokens = {
6758 		(void *)&cmd_lfc_set_set,
6759 		(void *)&cmd_lfc_set_flow_ctrl,
6760 		(void *)&cmd_lfc_set_rx,
6761 		(void *)&cmd_lfc_set_rx_mode,
6762 		(void *)&cmd_lfc_set_tx,
6763 		(void *)&cmd_lfc_set_tx_mode,
6764 		(void *)&cmd_lfc_set_high_water,
6765 		(void *)&cmd_lfc_set_low_water,
6766 		(void *)&cmd_lfc_set_pause_time,
6767 		(void *)&cmd_lfc_set_send_xon,
6768 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6769 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6770 		(void *)&cmd_lfc_set_autoneg_str,
6771 		(void *)&cmd_lfc_set_autoneg,
6772 		(void *)&cmd_lfc_set_portid,
6773 		NULL,
6774 	},
6775 };
6776 
6777 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6778 	.f = cmd_link_flow_ctrl_set_parsed,
6779 	.data = (void *)&cmd_link_flow_control_set_rx,
6780 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6781 		"Change rx flow control parameter",
6782 	.tokens = {
6783 		(void *)&cmd_lfc_set_set,
6784 		(void *)&cmd_lfc_set_flow_ctrl,
6785 		(void *)&cmd_lfc_set_rx,
6786 		(void *)&cmd_lfc_set_rx_mode,
6787 		(void *)&cmd_lfc_set_portid,
6788 		NULL,
6789 	},
6790 };
6791 
6792 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6793 	.f = cmd_link_flow_ctrl_set_parsed,
6794 	.data = (void *)&cmd_link_flow_control_set_tx,
6795 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6796 		"Change tx flow control parameter",
6797 	.tokens = {
6798 		(void *)&cmd_lfc_set_set,
6799 		(void *)&cmd_lfc_set_flow_ctrl,
6800 		(void *)&cmd_lfc_set_tx,
6801 		(void *)&cmd_lfc_set_tx_mode,
6802 		(void *)&cmd_lfc_set_portid,
6803 		NULL,
6804 	},
6805 };
6806 
6807 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6808 	.f = cmd_link_flow_ctrl_set_parsed,
6809 	.data = (void *)&cmd_link_flow_control_set_hw,
6810 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6811 		"Change high water flow control parameter",
6812 	.tokens = {
6813 		(void *)&cmd_lfc_set_set,
6814 		(void *)&cmd_lfc_set_flow_ctrl,
6815 		(void *)&cmd_lfc_set_high_water_str,
6816 		(void *)&cmd_lfc_set_high_water,
6817 		(void *)&cmd_lfc_set_portid,
6818 		NULL,
6819 	},
6820 };
6821 
6822 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6823 	.f = cmd_link_flow_ctrl_set_parsed,
6824 	.data = (void *)&cmd_link_flow_control_set_lw,
6825 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
6826 		"Change low water flow control parameter",
6827 	.tokens = {
6828 		(void *)&cmd_lfc_set_set,
6829 		(void *)&cmd_lfc_set_flow_ctrl,
6830 		(void *)&cmd_lfc_set_low_water_str,
6831 		(void *)&cmd_lfc_set_low_water,
6832 		(void *)&cmd_lfc_set_portid,
6833 		NULL,
6834 	},
6835 };
6836 
6837 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6838 	.f = cmd_link_flow_ctrl_set_parsed,
6839 	.data = (void *)&cmd_link_flow_control_set_pt,
6840 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
6841 		"Change pause time flow control parameter",
6842 	.tokens = {
6843 		(void *)&cmd_lfc_set_set,
6844 		(void *)&cmd_lfc_set_flow_ctrl,
6845 		(void *)&cmd_lfc_set_pause_time_str,
6846 		(void *)&cmd_lfc_set_pause_time,
6847 		(void *)&cmd_lfc_set_portid,
6848 		NULL,
6849 	},
6850 };
6851 
6852 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6853 	.f = cmd_link_flow_ctrl_set_parsed,
6854 	.data = (void *)&cmd_link_flow_control_set_xon,
6855 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
6856 		"Change send_xon flow control parameter",
6857 	.tokens = {
6858 		(void *)&cmd_lfc_set_set,
6859 		(void *)&cmd_lfc_set_flow_ctrl,
6860 		(void *)&cmd_lfc_set_send_xon_str,
6861 		(void *)&cmd_lfc_set_send_xon,
6862 		(void *)&cmd_lfc_set_portid,
6863 		NULL,
6864 	},
6865 };
6866 
6867 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6868 	.f = cmd_link_flow_ctrl_set_parsed,
6869 	.data = (void *)&cmd_link_flow_control_set_macfwd,
6870 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6871 		"Change mac ctrl fwd flow control parameter",
6872 	.tokens = {
6873 		(void *)&cmd_lfc_set_set,
6874 		(void *)&cmd_lfc_set_flow_ctrl,
6875 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6876 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6877 		(void *)&cmd_lfc_set_portid,
6878 		NULL,
6879 	},
6880 };
6881 
6882 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6883 	.f = cmd_link_flow_ctrl_set_parsed,
6884 	.data = (void *)&cmd_link_flow_control_set_autoneg,
6885 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
6886 		"Change autoneg flow control parameter",
6887 	.tokens = {
6888 		(void *)&cmd_lfc_set_set,
6889 		(void *)&cmd_lfc_set_flow_ctrl,
6890 		(void *)&cmd_lfc_set_autoneg_str,
6891 		(void *)&cmd_lfc_set_autoneg,
6892 		(void *)&cmd_lfc_set_portid,
6893 		NULL,
6894 	},
6895 };
6896 
6897 static void
6898 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6899 			      __attribute__((unused)) struct cmdline *cl,
6900 			      void *data)
6901 {
6902 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6903 	cmdline_parse_inst_t *cmd = data;
6904 	struct rte_eth_fc_conf fc_conf;
6905 	int rx_fc_en = 0;
6906 	int tx_fc_en = 0;
6907 	int ret;
6908 
6909 	/*
6910 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6911 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6912 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6913 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6914 	 */
6915 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6916 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6917 	};
6918 
6919 	/* Partial command line, retrieve current configuration */
6920 	if (cmd) {
6921 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6922 		if (ret != 0) {
6923 			printf("cannot get current flow ctrl parameters, return"
6924 			       "code = %d\n", ret);
6925 			return;
6926 		}
6927 
6928 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6929 		    (fc_conf.mode == RTE_FC_FULL))
6930 			rx_fc_en = 1;
6931 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6932 		    (fc_conf.mode == RTE_FC_FULL))
6933 			tx_fc_en = 1;
6934 	}
6935 
6936 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6937 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6938 
6939 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6940 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6941 
6942 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6943 
6944 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6945 		fc_conf.high_water = res->high_water;
6946 
6947 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6948 		fc_conf.low_water = res->low_water;
6949 
6950 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6951 		fc_conf.pause_time = res->pause_time;
6952 
6953 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6954 		fc_conf.send_xon = res->send_xon;
6955 
6956 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6957 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6958 			fc_conf.mac_ctrl_frame_fwd = 1;
6959 		else
6960 			fc_conf.mac_ctrl_frame_fwd = 0;
6961 	}
6962 
6963 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6964 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6965 
6966 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6967 	if (ret != 0)
6968 		printf("bad flow contrl parameter, return code = %d \n", ret);
6969 }
6970 
6971 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6972 struct cmd_priority_flow_ctrl_set_result {
6973 	cmdline_fixed_string_t set;
6974 	cmdline_fixed_string_t pfc_ctrl;
6975 	cmdline_fixed_string_t rx;
6976 	cmdline_fixed_string_t rx_pfc_mode;
6977 	cmdline_fixed_string_t tx;
6978 	cmdline_fixed_string_t tx_pfc_mode;
6979 	uint32_t high_water;
6980 	uint32_t low_water;
6981 	uint16_t pause_time;
6982 	uint8_t  priority;
6983 	portid_t port_id;
6984 };
6985 
6986 static void
6987 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6988 		       __attribute__((unused)) struct cmdline *cl,
6989 		       __attribute__((unused)) void *data)
6990 {
6991 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6992 	struct rte_eth_pfc_conf pfc_conf;
6993 	int rx_fc_enable, tx_fc_enable;
6994 	int ret;
6995 
6996 	/*
6997 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6998 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6999 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7000 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7001 	 */
7002 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7003 			{RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7004 	};
7005 
7006 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7007 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7008 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7009 	pfc_conf.fc.high_water = res->high_water;
7010 	pfc_conf.fc.low_water  = res->low_water;
7011 	pfc_conf.fc.pause_time = res->pause_time;
7012 	pfc_conf.priority      = res->priority;
7013 
7014 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7015 	if (ret != 0)
7016 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7017 }
7018 
7019 cmdline_parse_token_string_t cmd_pfc_set_set =
7020 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7021 				set, "set");
7022 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7023 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7024 				pfc_ctrl, "pfc_ctrl");
7025 cmdline_parse_token_string_t cmd_pfc_set_rx =
7026 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7027 				rx, "rx");
7028 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7029 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7030 				rx_pfc_mode, "on#off");
7031 cmdline_parse_token_string_t cmd_pfc_set_tx =
7032 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7033 				tx, "tx");
7034 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7035 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7036 				tx_pfc_mode, "on#off");
7037 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7038 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7039 				high_water, UINT32);
7040 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7041 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7042 				low_water, UINT32);
7043 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7044 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7045 				pause_time, UINT16);
7046 cmdline_parse_token_num_t cmd_pfc_set_priority =
7047 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7048 				priority, UINT8);
7049 cmdline_parse_token_num_t cmd_pfc_set_portid =
7050 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7051 				port_id, UINT16);
7052 
7053 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7054 	.f = cmd_priority_flow_ctrl_set_parsed,
7055 	.data = NULL,
7056 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7057 		"<pause_time> <priority> <port_id>: "
7058 		"Configure the Ethernet priority flow control",
7059 	.tokens = {
7060 		(void *)&cmd_pfc_set_set,
7061 		(void *)&cmd_pfc_set_flow_ctrl,
7062 		(void *)&cmd_pfc_set_rx,
7063 		(void *)&cmd_pfc_set_rx_mode,
7064 		(void *)&cmd_pfc_set_tx,
7065 		(void *)&cmd_pfc_set_tx_mode,
7066 		(void *)&cmd_pfc_set_high_water,
7067 		(void *)&cmd_pfc_set_low_water,
7068 		(void *)&cmd_pfc_set_pause_time,
7069 		(void *)&cmd_pfc_set_priority,
7070 		(void *)&cmd_pfc_set_portid,
7071 		NULL,
7072 	},
7073 };
7074 
7075 /* *** RESET CONFIGURATION *** */
7076 struct cmd_reset_result {
7077 	cmdline_fixed_string_t reset;
7078 	cmdline_fixed_string_t def;
7079 };
7080 
7081 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7082 			     struct cmdline *cl,
7083 			     __attribute__((unused)) void *data)
7084 {
7085 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7086 	set_def_fwd_config();
7087 }
7088 
7089 cmdline_parse_token_string_t cmd_reset_set =
7090 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7091 cmdline_parse_token_string_t cmd_reset_def =
7092 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7093 				 "default");
7094 
7095 cmdline_parse_inst_t cmd_reset = {
7096 	.f = cmd_reset_parsed,
7097 	.data = NULL,
7098 	.help_str = "set default: Reset default forwarding configuration",
7099 	.tokens = {
7100 		(void *)&cmd_reset_set,
7101 		(void *)&cmd_reset_def,
7102 		NULL,
7103 	},
7104 };
7105 
7106 /* *** START FORWARDING *** */
7107 struct cmd_start_result {
7108 	cmdline_fixed_string_t start;
7109 };
7110 
7111 cmdline_parse_token_string_t cmd_start_start =
7112 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7113 
7114 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7115 			     __attribute__((unused)) struct cmdline *cl,
7116 			     __attribute__((unused)) void *data)
7117 {
7118 	start_packet_forwarding(0);
7119 }
7120 
7121 cmdline_parse_inst_t cmd_start = {
7122 	.f = cmd_start_parsed,
7123 	.data = NULL,
7124 	.help_str = "start: Start packet forwarding",
7125 	.tokens = {
7126 		(void *)&cmd_start_start,
7127 		NULL,
7128 	},
7129 };
7130 
7131 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7132 struct cmd_start_tx_first_result {
7133 	cmdline_fixed_string_t start;
7134 	cmdline_fixed_string_t tx_first;
7135 };
7136 
7137 static void
7138 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7139 			  __attribute__((unused)) struct cmdline *cl,
7140 			  __attribute__((unused)) void *data)
7141 {
7142 	start_packet_forwarding(1);
7143 }
7144 
7145 cmdline_parse_token_string_t cmd_start_tx_first_start =
7146 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7147 				 "start");
7148 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7149 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7150 				 tx_first, "tx_first");
7151 
7152 cmdline_parse_inst_t cmd_start_tx_first = {
7153 	.f = cmd_start_tx_first_parsed,
7154 	.data = NULL,
7155 	.help_str = "start tx_first: Start packet forwarding, "
7156 		"after sending 1 burst of packets",
7157 	.tokens = {
7158 		(void *)&cmd_start_tx_first_start,
7159 		(void *)&cmd_start_tx_first_tx_first,
7160 		NULL,
7161 	},
7162 };
7163 
7164 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7165 struct cmd_start_tx_first_n_result {
7166 	cmdline_fixed_string_t start;
7167 	cmdline_fixed_string_t tx_first;
7168 	uint32_t tx_num;
7169 };
7170 
7171 static void
7172 cmd_start_tx_first_n_parsed(void *parsed_result,
7173 			  __attribute__((unused)) struct cmdline *cl,
7174 			  __attribute__((unused)) void *data)
7175 {
7176 	struct cmd_start_tx_first_n_result *res = parsed_result;
7177 
7178 	start_packet_forwarding(res->tx_num);
7179 }
7180 
7181 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7182 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7183 			start, "start");
7184 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7185 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7186 			tx_first, "tx_first");
7187 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7188 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7189 			tx_num, UINT32);
7190 
7191 cmdline_parse_inst_t cmd_start_tx_first_n = {
7192 	.f = cmd_start_tx_first_n_parsed,
7193 	.data = NULL,
7194 	.help_str = "start tx_first <num>: "
7195 		"packet forwarding, after sending <num> bursts of packets",
7196 	.tokens = {
7197 		(void *)&cmd_start_tx_first_n_start,
7198 		(void *)&cmd_start_tx_first_n_tx_first,
7199 		(void *)&cmd_start_tx_first_n_tx_num,
7200 		NULL,
7201 	},
7202 };
7203 
7204 /* *** SET LINK UP *** */
7205 struct cmd_set_link_up_result {
7206 	cmdline_fixed_string_t set;
7207 	cmdline_fixed_string_t link_up;
7208 	cmdline_fixed_string_t port;
7209 	portid_t port_id;
7210 };
7211 
7212 cmdline_parse_token_string_t cmd_set_link_up_set =
7213 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7214 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7215 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7216 				"link-up");
7217 cmdline_parse_token_string_t cmd_set_link_up_port =
7218 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7219 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7220 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7221 
7222 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7223 			     __attribute__((unused)) struct cmdline *cl,
7224 			     __attribute__((unused)) void *data)
7225 {
7226 	struct cmd_set_link_up_result *res = parsed_result;
7227 	dev_set_link_up(res->port_id);
7228 }
7229 
7230 cmdline_parse_inst_t cmd_set_link_up = {
7231 	.f = cmd_set_link_up_parsed,
7232 	.data = NULL,
7233 	.help_str = "set link-up port <port id>",
7234 	.tokens = {
7235 		(void *)&cmd_set_link_up_set,
7236 		(void *)&cmd_set_link_up_link_up,
7237 		(void *)&cmd_set_link_up_port,
7238 		(void *)&cmd_set_link_up_port_id,
7239 		NULL,
7240 	},
7241 };
7242 
7243 /* *** SET LINK DOWN *** */
7244 struct cmd_set_link_down_result {
7245 	cmdline_fixed_string_t set;
7246 	cmdline_fixed_string_t link_down;
7247 	cmdline_fixed_string_t port;
7248 	portid_t port_id;
7249 };
7250 
7251 cmdline_parse_token_string_t cmd_set_link_down_set =
7252 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7253 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7254 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7255 				"link-down");
7256 cmdline_parse_token_string_t cmd_set_link_down_port =
7257 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7258 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7259 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7260 
7261 static void cmd_set_link_down_parsed(
7262 				__attribute__((unused)) void *parsed_result,
7263 				__attribute__((unused)) struct cmdline *cl,
7264 				__attribute__((unused)) void *data)
7265 {
7266 	struct cmd_set_link_down_result *res = parsed_result;
7267 	dev_set_link_down(res->port_id);
7268 }
7269 
7270 cmdline_parse_inst_t cmd_set_link_down = {
7271 	.f = cmd_set_link_down_parsed,
7272 	.data = NULL,
7273 	.help_str = "set link-down port <port id>",
7274 	.tokens = {
7275 		(void *)&cmd_set_link_down_set,
7276 		(void *)&cmd_set_link_down_link_down,
7277 		(void *)&cmd_set_link_down_port,
7278 		(void *)&cmd_set_link_down_port_id,
7279 		NULL,
7280 	},
7281 };
7282 
7283 /* *** SHOW CFG *** */
7284 struct cmd_showcfg_result {
7285 	cmdline_fixed_string_t show;
7286 	cmdline_fixed_string_t cfg;
7287 	cmdline_fixed_string_t what;
7288 };
7289 
7290 static void cmd_showcfg_parsed(void *parsed_result,
7291 			       __attribute__((unused)) struct cmdline *cl,
7292 			       __attribute__((unused)) void *data)
7293 {
7294 	struct cmd_showcfg_result *res = parsed_result;
7295 	if (!strcmp(res->what, "rxtx"))
7296 		rxtx_config_display();
7297 	else if (!strcmp(res->what, "cores"))
7298 		fwd_lcores_config_display();
7299 	else if (!strcmp(res->what, "fwd"))
7300 		pkt_fwd_config_display(&cur_fwd_config);
7301 	else if (!strcmp(res->what, "txpkts"))
7302 		show_tx_pkt_segments();
7303 }
7304 
7305 cmdline_parse_token_string_t cmd_showcfg_show =
7306 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7307 cmdline_parse_token_string_t cmd_showcfg_port =
7308 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7309 cmdline_parse_token_string_t cmd_showcfg_what =
7310 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7311 				 "rxtx#cores#fwd#txpkts");
7312 
7313 cmdline_parse_inst_t cmd_showcfg = {
7314 	.f = cmd_showcfg_parsed,
7315 	.data = NULL,
7316 	.help_str = "show config rxtx|cores|fwd|txpkts",
7317 	.tokens = {
7318 		(void *)&cmd_showcfg_show,
7319 		(void *)&cmd_showcfg_port,
7320 		(void *)&cmd_showcfg_what,
7321 		NULL,
7322 	},
7323 };
7324 
7325 /* *** SHOW ALL PORT INFO *** */
7326 struct cmd_showportall_result {
7327 	cmdline_fixed_string_t show;
7328 	cmdline_fixed_string_t port;
7329 	cmdline_fixed_string_t what;
7330 	cmdline_fixed_string_t all;
7331 };
7332 
7333 static void cmd_showportall_parsed(void *parsed_result,
7334 				__attribute__((unused)) struct cmdline *cl,
7335 				__attribute__((unused)) void *data)
7336 {
7337 	portid_t i;
7338 
7339 	struct cmd_showportall_result *res = parsed_result;
7340 	if (!strcmp(res->show, "clear")) {
7341 		if (!strcmp(res->what, "stats"))
7342 			RTE_ETH_FOREACH_DEV(i)
7343 				nic_stats_clear(i);
7344 		else if (!strcmp(res->what, "xstats"))
7345 			RTE_ETH_FOREACH_DEV(i)
7346 				nic_xstats_clear(i);
7347 	} else if (!strcmp(res->what, "info"))
7348 		RTE_ETH_FOREACH_DEV(i)
7349 			port_infos_display(i);
7350 	else if (!strcmp(res->what, "summary")) {
7351 		port_summary_header_display();
7352 		RTE_ETH_FOREACH_DEV(i)
7353 			port_summary_display(i);
7354 	}
7355 	else if (!strcmp(res->what, "stats"))
7356 		RTE_ETH_FOREACH_DEV(i)
7357 			nic_stats_display(i);
7358 	else if (!strcmp(res->what, "xstats"))
7359 		RTE_ETH_FOREACH_DEV(i)
7360 			nic_xstats_display(i);
7361 	else if (!strcmp(res->what, "fdir"))
7362 		RTE_ETH_FOREACH_DEV(i)
7363 			fdir_get_infos(i);
7364 	else if (!strcmp(res->what, "stat_qmap"))
7365 		RTE_ETH_FOREACH_DEV(i)
7366 			nic_stats_mapping_display(i);
7367 	else if (!strcmp(res->what, "dcb_tc"))
7368 		RTE_ETH_FOREACH_DEV(i)
7369 			port_dcb_info_display(i);
7370 	else if (!strcmp(res->what, "cap"))
7371 		RTE_ETH_FOREACH_DEV(i)
7372 			port_offload_cap_display(i);
7373 }
7374 
7375 cmdline_parse_token_string_t cmd_showportall_show =
7376 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7377 				 "show#clear");
7378 cmdline_parse_token_string_t cmd_showportall_port =
7379 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7380 cmdline_parse_token_string_t cmd_showportall_what =
7381 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7382 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7383 cmdline_parse_token_string_t cmd_showportall_all =
7384 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7385 cmdline_parse_inst_t cmd_showportall = {
7386 	.f = cmd_showportall_parsed,
7387 	.data = NULL,
7388 	.help_str = "show|clear port "
7389 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7390 	.tokens = {
7391 		(void *)&cmd_showportall_show,
7392 		(void *)&cmd_showportall_port,
7393 		(void *)&cmd_showportall_what,
7394 		(void *)&cmd_showportall_all,
7395 		NULL,
7396 	},
7397 };
7398 
7399 /* *** SHOW PORT INFO *** */
7400 struct cmd_showport_result {
7401 	cmdline_fixed_string_t show;
7402 	cmdline_fixed_string_t port;
7403 	cmdline_fixed_string_t what;
7404 	uint16_t portnum;
7405 };
7406 
7407 static void cmd_showport_parsed(void *parsed_result,
7408 				__attribute__((unused)) struct cmdline *cl,
7409 				__attribute__((unused)) void *data)
7410 {
7411 	struct cmd_showport_result *res = parsed_result;
7412 	if (!strcmp(res->show, "clear")) {
7413 		if (!strcmp(res->what, "stats"))
7414 			nic_stats_clear(res->portnum);
7415 		else if (!strcmp(res->what, "xstats"))
7416 			nic_xstats_clear(res->portnum);
7417 	} else if (!strcmp(res->what, "info"))
7418 		port_infos_display(res->portnum);
7419 	else if (!strcmp(res->what, "summary")) {
7420 		port_summary_header_display();
7421 		port_summary_display(res->portnum);
7422 	}
7423 	else if (!strcmp(res->what, "stats"))
7424 		nic_stats_display(res->portnum);
7425 	else if (!strcmp(res->what, "xstats"))
7426 		nic_xstats_display(res->portnum);
7427 	else if (!strcmp(res->what, "fdir"))
7428 		 fdir_get_infos(res->portnum);
7429 	else if (!strcmp(res->what, "stat_qmap"))
7430 		nic_stats_mapping_display(res->portnum);
7431 	else if (!strcmp(res->what, "dcb_tc"))
7432 		port_dcb_info_display(res->portnum);
7433 	else if (!strcmp(res->what, "cap"))
7434 		port_offload_cap_display(res->portnum);
7435 }
7436 
7437 cmdline_parse_token_string_t cmd_showport_show =
7438 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7439 				 "show#clear");
7440 cmdline_parse_token_string_t cmd_showport_port =
7441 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7442 cmdline_parse_token_string_t cmd_showport_what =
7443 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7444 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7445 cmdline_parse_token_num_t cmd_showport_portnum =
7446 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7447 
7448 cmdline_parse_inst_t cmd_showport = {
7449 	.f = cmd_showport_parsed,
7450 	.data = NULL,
7451 	.help_str = "show|clear port "
7452 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7453 		"<port_id>",
7454 	.tokens = {
7455 		(void *)&cmd_showport_show,
7456 		(void *)&cmd_showport_port,
7457 		(void *)&cmd_showport_what,
7458 		(void *)&cmd_showport_portnum,
7459 		NULL,
7460 	},
7461 };
7462 
7463 /* *** SHOW DEVICE INFO *** */
7464 struct cmd_showdevice_result {
7465 	cmdline_fixed_string_t show;
7466 	cmdline_fixed_string_t device;
7467 	cmdline_fixed_string_t what;
7468 	cmdline_fixed_string_t identifier;
7469 };
7470 
7471 static void cmd_showdevice_parsed(void *parsed_result,
7472 				__attribute__((unused)) struct cmdline *cl,
7473 				__attribute__((unused)) void *data)
7474 {
7475 	struct cmd_showdevice_result *res = parsed_result;
7476 	if (!strcmp(res->what, "info")) {
7477 		if (!strcmp(res->identifier, "all"))
7478 			device_infos_display(NULL);
7479 		else
7480 			device_infos_display(res->identifier);
7481 	}
7482 }
7483 
7484 cmdline_parse_token_string_t cmd_showdevice_show =
7485 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7486 				 "show");
7487 cmdline_parse_token_string_t cmd_showdevice_device =
7488 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7489 cmdline_parse_token_string_t cmd_showdevice_what =
7490 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7491 				 "info");
7492 cmdline_parse_token_string_t cmd_showdevice_identifier =
7493 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7494 			identifier, NULL);
7495 
7496 cmdline_parse_inst_t cmd_showdevice = {
7497 	.f = cmd_showdevice_parsed,
7498 	.data = NULL,
7499 	.help_str = "show device info <identifier>|all",
7500 	.tokens = {
7501 		(void *)&cmd_showdevice_show,
7502 		(void *)&cmd_showdevice_device,
7503 		(void *)&cmd_showdevice_what,
7504 		(void *)&cmd_showdevice_identifier,
7505 		NULL,
7506 	},
7507 };
7508 /* *** SHOW QUEUE INFO *** */
7509 struct cmd_showqueue_result {
7510 	cmdline_fixed_string_t show;
7511 	cmdline_fixed_string_t type;
7512 	cmdline_fixed_string_t what;
7513 	uint16_t portnum;
7514 	uint16_t queuenum;
7515 };
7516 
7517 static void
7518 cmd_showqueue_parsed(void *parsed_result,
7519 	__attribute__((unused)) struct cmdline *cl,
7520 	__attribute__((unused)) void *data)
7521 {
7522 	struct cmd_showqueue_result *res = parsed_result;
7523 
7524 	if (!strcmp(res->type, "rxq"))
7525 		rx_queue_infos_display(res->portnum, res->queuenum);
7526 	else if (!strcmp(res->type, "txq"))
7527 		tx_queue_infos_display(res->portnum, res->queuenum);
7528 }
7529 
7530 cmdline_parse_token_string_t cmd_showqueue_show =
7531 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7532 cmdline_parse_token_string_t cmd_showqueue_type =
7533 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7534 cmdline_parse_token_string_t cmd_showqueue_what =
7535 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7536 cmdline_parse_token_num_t cmd_showqueue_portnum =
7537 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7538 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7539 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7540 
7541 cmdline_parse_inst_t cmd_showqueue = {
7542 	.f = cmd_showqueue_parsed,
7543 	.data = NULL,
7544 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7545 	.tokens = {
7546 		(void *)&cmd_showqueue_show,
7547 		(void *)&cmd_showqueue_type,
7548 		(void *)&cmd_showqueue_what,
7549 		(void *)&cmd_showqueue_portnum,
7550 		(void *)&cmd_showqueue_queuenum,
7551 		NULL,
7552 	},
7553 };
7554 
7555 /* show/clear fwd engine statistics */
7556 struct fwd_result {
7557 	cmdline_fixed_string_t action;
7558 	cmdline_fixed_string_t fwd;
7559 	cmdline_fixed_string_t stats;
7560 	cmdline_fixed_string_t all;
7561 };
7562 
7563 cmdline_parse_token_string_t cmd_fwd_action =
7564 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7565 cmdline_parse_token_string_t cmd_fwd_fwd =
7566 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7567 cmdline_parse_token_string_t cmd_fwd_stats =
7568 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7569 cmdline_parse_token_string_t cmd_fwd_all =
7570 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7571 
7572 static void
7573 cmd_showfwdall_parsed(void *parsed_result,
7574 		      __rte_unused struct cmdline *cl,
7575 		      __rte_unused void *data)
7576 {
7577 	struct fwd_result *res = parsed_result;
7578 
7579 	if (!strcmp(res->action, "show"))
7580 		fwd_stats_display();
7581 	else
7582 		fwd_stats_reset();
7583 }
7584 
7585 static cmdline_parse_inst_t cmd_showfwdall = {
7586 	.f = cmd_showfwdall_parsed,
7587 	.data = NULL,
7588 	.help_str = "show|clear fwd stats all",
7589 	.tokens = {
7590 		(void *)&cmd_fwd_action,
7591 		(void *)&cmd_fwd_fwd,
7592 		(void *)&cmd_fwd_stats,
7593 		(void *)&cmd_fwd_all,
7594 		NULL,
7595 	},
7596 };
7597 
7598 /* *** READ PORT REGISTER *** */
7599 struct cmd_read_reg_result {
7600 	cmdline_fixed_string_t read;
7601 	cmdline_fixed_string_t reg;
7602 	portid_t port_id;
7603 	uint32_t reg_off;
7604 };
7605 
7606 static void
7607 cmd_read_reg_parsed(void *parsed_result,
7608 		    __attribute__((unused)) struct cmdline *cl,
7609 		    __attribute__((unused)) void *data)
7610 {
7611 	struct cmd_read_reg_result *res = parsed_result;
7612 	port_reg_display(res->port_id, res->reg_off);
7613 }
7614 
7615 cmdline_parse_token_string_t cmd_read_reg_read =
7616 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7617 cmdline_parse_token_string_t cmd_read_reg_reg =
7618 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7619 cmdline_parse_token_num_t cmd_read_reg_port_id =
7620 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7621 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7622 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7623 
7624 cmdline_parse_inst_t cmd_read_reg = {
7625 	.f = cmd_read_reg_parsed,
7626 	.data = NULL,
7627 	.help_str = "read reg <port_id> <reg_off>",
7628 	.tokens = {
7629 		(void *)&cmd_read_reg_read,
7630 		(void *)&cmd_read_reg_reg,
7631 		(void *)&cmd_read_reg_port_id,
7632 		(void *)&cmd_read_reg_reg_off,
7633 		NULL,
7634 	},
7635 };
7636 
7637 /* *** READ PORT REGISTER BIT FIELD *** */
7638 struct cmd_read_reg_bit_field_result {
7639 	cmdline_fixed_string_t read;
7640 	cmdline_fixed_string_t regfield;
7641 	portid_t port_id;
7642 	uint32_t reg_off;
7643 	uint8_t bit1_pos;
7644 	uint8_t bit2_pos;
7645 };
7646 
7647 static void
7648 cmd_read_reg_bit_field_parsed(void *parsed_result,
7649 			      __attribute__((unused)) struct cmdline *cl,
7650 			      __attribute__((unused)) void *data)
7651 {
7652 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7653 	port_reg_bit_field_display(res->port_id, res->reg_off,
7654 				   res->bit1_pos, res->bit2_pos);
7655 }
7656 
7657 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7658 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7659 				 "read");
7660 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7661 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7662 				 regfield, "regfield");
7663 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7664 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7665 			      UINT16);
7666 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7667 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7668 			      UINT32);
7669 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7670 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7671 			      UINT8);
7672 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7673 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7674 			      UINT8);
7675 
7676 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7677 	.f = cmd_read_reg_bit_field_parsed,
7678 	.data = NULL,
7679 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7680 	"Read register bit field between bit_x and bit_y included",
7681 	.tokens = {
7682 		(void *)&cmd_read_reg_bit_field_read,
7683 		(void *)&cmd_read_reg_bit_field_regfield,
7684 		(void *)&cmd_read_reg_bit_field_port_id,
7685 		(void *)&cmd_read_reg_bit_field_reg_off,
7686 		(void *)&cmd_read_reg_bit_field_bit1_pos,
7687 		(void *)&cmd_read_reg_bit_field_bit2_pos,
7688 		NULL,
7689 	},
7690 };
7691 
7692 /* *** READ PORT REGISTER BIT *** */
7693 struct cmd_read_reg_bit_result {
7694 	cmdline_fixed_string_t read;
7695 	cmdline_fixed_string_t regbit;
7696 	portid_t port_id;
7697 	uint32_t reg_off;
7698 	uint8_t bit_pos;
7699 };
7700 
7701 static void
7702 cmd_read_reg_bit_parsed(void *parsed_result,
7703 			__attribute__((unused)) struct cmdline *cl,
7704 			__attribute__((unused)) void *data)
7705 {
7706 	struct cmd_read_reg_bit_result *res = parsed_result;
7707 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7708 }
7709 
7710 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7711 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7712 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7713 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7714 				 regbit, "regbit");
7715 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7716 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7717 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7718 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7719 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7720 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7721 
7722 cmdline_parse_inst_t cmd_read_reg_bit = {
7723 	.f = cmd_read_reg_bit_parsed,
7724 	.data = NULL,
7725 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7726 	.tokens = {
7727 		(void *)&cmd_read_reg_bit_read,
7728 		(void *)&cmd_read_reg_bit_regbit,
7729 		(void *)&cmd_read_reg_bit_port_id,
7730 		(void *)&cmd_read_reg_bit_reg_off,
7731 		(void *)&cmd_read_reg_bit_bit_pos,
7732 		NULL,
7733 	},
7734 };
7735 
7736 /* *** WRITE PORT REGISTER *** */
7737 struct cmd_write_reg_result {
7738 	cmdline_fixed_string_t write;
7739 	cmdline_fixed_string_t reg;
7740 	portid_t port_id;
7741 	uint32_t reg_off;
7742 	uint32_t value;
7743 };
7744 
7745 static void
7746 cmd_write_reg_parsed(void *parsed_result,
7747 		     __attribute__((unused)) struct cmdline *cl,
7748 		     __attribute__((unused)) void *data)
7749 {
7750 	struct cmd_write_reg_result *res = parsed_result;
7751 	port_reg_set(res->port_id, res->reg_off, res->value);
7752 }
7753 
7754 cmdline_parse_token_string_t cmd_write_reg_write =
7755 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7756 cmdline_parse_token_string_t cmd_write_reg_reg =
7757 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7758 cmdline_parse_token_num_t cmd_write_reg_port_id =
7759 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7760 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7761 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7762 cmdline_parse_token_num_t cmd_write_reg_value =
7763 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7764 
7765 cmdline_parse_inst_t cmd_write_reg = {
7766 	.f = cmd_write_reg_parsed,
7767 	.data = NULL,
7768 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
7769 	.tokens = {
7770 		(void *)&cmd_write_reg_write,
7771 		(void *)&cmd_write_reg_reg,
7772 		(void *)&cmd_write_reg_port_id,
7773 		(void *)&cmd_write_reg_reg_off,
7774 		(void *)&cmd_write_reg_value,
7775 		NULL,
7776 	},
7777 };
7778 
7779 /* *** WRITE PORT REGISTER BIT FIELD *** */
7780 struct cmd_write_reg_bit_field_result {
7781 	cmdline_fixed_string_t write;
7782 	cmdline_fixed_string_t regfield;
7783 	portid_t port_id;
7784 	uint32_t reg_off;
7785 	uint8_t bit1_pos;
7786 	uint8_t bit2_pos;
7787 	uint32_t value;
7788 };
7789 
7790 static void
7791 cmd_write_reg_bit_field_parsed(void *parsed_result,
7792 			       __attribute__((unused)) struct cmdline *cl,
7793 			       __attribute__((unused)) void *data)
7794 {
7795 	struct cmd_write_reg_bit_field_result *res = parsed_result;
7796 	port_reg_bit_field_set(res->port_id, res->reg_off,
7797 			  res->bit1_pos, res->bit2_pos, res->value);
7798 }
7799 
7800 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7801 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7802 				 "write");
7803 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7804 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7805 				 regfield, "regfield");
7806 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7807 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7808 			      UINT16);
7809 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7810 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7811 			      UINT32);
7812 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7813 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7814 			      UINT8);
7815 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7816 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7817 			      UINT8);
7818 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7819 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7820 			      UINT32);
7821 
7822 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7823 	.f = cmd_write_reg_bit_field_parsed,
7824 	.data = NULL,
7825 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7826 		"<reg_value>: "
7827 		"Set register bit field between bit_x and bit_y included",
7828 	.tokens = {
7829 		(void *)&cmd_write_reg_bit_field_write,
7830 		(void *)&cmd_write_reg_bit_field_regfield,
7831 		(void *)&cmd_write_reg_bit_field_port_id,
7832 		(void *)&cmd_write_reg_bit_field_reg_off,
7833 		(void *)&cmd_write_reg_bit_field_bit1_pos,
7834 		(void *)&cmd_write_reg_bit_field_bit2_pos,
7835 		(void *)&cmd_write_reg_bit_field_value,
7836 		NULL,
7837 	},
7838 };
7839 
7840 /* *** WRITE PORT REGISTER BIT *** */
7841 struct cmd_write_reg_bit_result {
7842 	cmdline_fixed_string_t write;
7843 	cmdline_fixed_string_t regbit;
7844 	portid_t port_id;
7845 	uint32_t reg_off;
7846 	uint8_t bit_pos;
7847 	uint8_t value;
7848 };
7849 
7850 static void
7851 cmd_write_reg_bit_parsed(void *parsed_result,
7852 			 __attribute__((unused)) struct cmdline *cl,
7853 			 __attribute__((unused)) void *data)
7854 {
7855 	struct cmd_write_reg_bit_result *res = parsed_result;
7856 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7857 }
7858 
7859 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7860 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7861 				 "write");
7862 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7863 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7864 				 regbit, "regbit");
7865 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7866 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7867 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7868 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7869 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7870 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7871 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7872 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7873 
7874 cmdline_parse_inst_t cmd_write_reg_bit = {
7875 	.f = cmd_write_reg_bit_parsed,
7876 	.data = NULL,
7877 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7878 		"0 <= bit_x <= 31",
7879 	.tokens = {
7880 		(void *)&cmd_write_reg_bit_write,
7881 		(void *)&cmd_write_reg_bit_regbit,
7882 		(void *)&cmd_write_reg_bit_port_id,
7883 		(void *)&cmd_write_reg_bit_reg_off,
7884 		(void *)&cmd_write_reg_bit_bit_pos,
7885 		(void *)&cmd_write_reg_bit_value,
7886 		NULL,
7887 	},
7888 };
7889 
7890 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7891 struct cmd_read_rxd_txd_result {
7892 	cmdline_fixed_string_t read;
7893 	cmdline_fixed_string_t rxd_txd;
7894 	portid_t port_id;
7895 	uint16_t queue_id;
7896 	uint16_t desc_id;
7897 };
7898 
7899 static void
7900 cmd_read_rxd_txd_parsed(void *parsed_result,
7901 			__attribute__((unused)) struct cmdline *cl,
7902 			__attribute__((unused)) void *data)
7903 {
7904 	struct cmd_read_rxd_txd_result *res = parsed_result;
7905 
7906 	if (!strcmp(res->rxd_txd, "rxd"))
7907 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7908 	else if (!strcmp(res->rxd_txd, "txd"))
7909 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7910 }
7911 
7912 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7913 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7914 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7915 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7916 				 "rxd#txd");
7917 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7918 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7919 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7920 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7921 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7922 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7923 
7924 cmdline_parse_inst_t cmd_read_rxd_txd = {
7925 	.f = cmd_read_rxd_txd_parsed,
7926 	.data = NULL,
7927 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7928 	.tokens = {
7929 		(void *)&cmd_read_rxd_txd_read,
7930 		(void *)&cmd_read_rxd_txd_rxd_txd,
7931 		(void *)&cmd_read_rxd_txd_port_id,
7932 		(void *)&cmd_read_rxd_txd_queue_id,
7933 		(void *)&cmd_read_rxd_txd_desc_id,
7934 		NULL,
7935 	},
7936 };
7937 
7938 /* *** QUIT *** */
7939 struct cmd_quit_result {
7940 	cmdline_fixed_string_t quit;
7941 };
7942 
7943 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7944 			    struct cmdline *cl,
7945 			    __attribute__((unused)) void *data)
7946 {
7947 	cmdline_quit(cl);
7948 }
7949 
7950 cmdline_parse_token_string_t cmd_quit_quit =
7951 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7952 
7953 cmdline_parse_inst_t cmd_quit = {
7954 	.f = cmd_quit_parsed,
7955 	.data = NULL,
7956 	.help_str = "quit: Exit application",
7957 	.tokens = {
7958 		(void *)&cmd_quit_quit,
7959 		NULL,
7960 	},
7961 };
7962 
7963 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7964 struct cmd_mac_addr_result {
7965 	cmdline_fixed_string_t mac_addr_cmd;
7966 	cmdline_fixed_string_t what;
7967 	uint16_t port_num;
7968 	struct rte_ether_addr address;
7969 };
7970 
7971 static void cmd_mac_addr_parsed(void *parsed_result,
7972 		__attribute__((unused)) struct cmdline *cl,
7973 		__attribute__((unused)) void *data)
7974 {
7975 	struct cmd_mac_addr_result *res = parsed_result;
7976 	int ret;
7977 
7978 	if (strcmp(res->what, "add") == 0)
7979 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7980 	else if (strcmp(res->what, "set") == 0)
7981 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7982 						       &res->address);
7983 	else
7984 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7985 
7986 	/* check the return value and print it if is < 0 */
7987 	if(ret < 0)
7988 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7989 
7990 }
7991 
7992 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7993 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7994 				"mac_addr");
7995 cmdline_parse_token_string_t cmd_mac_addr_what =
7996 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7997 				"add#remove#set");
7998 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7999 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8000 					UINT16);
8001 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8002 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8003 
8004 cmdline_parse_inst_t cmd_mac_addr = {
8005 	.f = cmd_mac_addr_parsed,
8006 	.data = (void *)0,
8007 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8008 			"Add/Remove/Set MAC address on port_id",
8009 	.tokens = {
8010 		(void *)&cmd_mac_addr_cmd,
8011 		(void *)&cmd_mac_addr_what,
8012 		(void *)&cmd_mac_addr_portnum,
8013 		(void *)&cmd_mac_addr_addr,
8014 		NULL,
8015 	},
8016 };
8017 
8018 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8019 struct cmd_eth_peer_result {
8020 	cmdline_fixed_string_t set;
8021 	cmdline_fixed_string_t eth_peer;
8022 	portid_t port_id;
8023 	cmdline_fixed_string_t peer_addr;
8024 };
8025 
8026 static void cmd_set_eth_peer_parsed(void *parsed_result,
8027 			__attribute__((unused)) struct cmdline *cl,
8028 			__attribute__((unused)) void *data)
8029 {
8030 		struct cmd_eth_peer_result *res = parsed_result;
8031 
8032 		if (test_done == 0) {
8033 			printf("Please stop forwarding first\n");
8034 			return;
8035 		}
8036 		if (!strcmp(res->eth_peer, "eth-peer")) {
8037 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8038 			fwd_config_setup();
8039 		}
8040 }
8041 cmdline_parse_token_string_t cmd_eth_peer_set =
8042 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8043 cmdline_parse_token_string_t cmd_eth_peer =
8044 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8045 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8046 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8047 cmdline_parse_token_string_t cmd_eth_peer_addr =
8048 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8049 
8050 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8051 	.f = cmd_set_eth_peer_parsed,
8052 	.data = NULL,
8053 	.help_str = "set eth-peer <port_id> <peer_mac>",
8054 	.tokens = {
8055 		(void *)&cmd_eth_peer_set,
8056 		(void *)&cmd_eth_peer,
8057 		(void *)&cmd_eth_peer_port_id,
8058 		(void *)&cmd_eth_peer_addr,
8059 		NULL,
8060 	},
8061 };
8062 
8063 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8064 struct cmd_set_qmap_result {
8065 	cmdline_fixed_string_t set;
8066 	cmdline_fixed_string_t qmap;
8067 	cmdline_fixed_string_t what;
8068 	portid_t port_id;
8069 	uint16_t queue_id;
8070 	uint8_t map_value;
8071 };
8072 
8073 static void
8074 cmd_set_qmap_parsed(void *parsed_result,
8075 		       __attribute__((unused)) struct cmdline *cl,
8076 		       __attribute__((unused)) void *data)
8077 {
8078 	struct cmd_set_qmap_result *res = parsed_result;
8079 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8080 
8081 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8082 }
8083 
8084 cmdline_parse_token_string_t cmd_setqmap_set =
8085 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8086 				 set, "set");
8087 cmdline_parse_token_string_t cmd_setqmap_qmap =
8088 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8089 				 qmap, "stat_qmap");
8090 cmdline_parse_token_string_t cmd_setqmap_what =
8091 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8092 				 what, "tx#rx");
8093 cmdline_parse_token_num_t cmd_setqmap_portid =
8094 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8095 			      port_id, UINT16);
8096 cmdline_parse_token_num_t cmd_setqmap_queueid =
8097 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8098 			      queue_id, UINT16);
8099 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8100 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8101 			      map_value, UINT8);
8102 
8103 cmdline_parse_inst_t cmd_set_qmap = {
8104 	.f = cmd_set_qmap_parsed,
8105 	.data = NULL,
8106 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8107 		"Set statistics mapping value on tx|rx queue_id of port_id",
8108 	.tokens = {
8109 		(void *)&cmd_setqmap_set,
8110 		(void *)&cmd_setqmap_qmap,
8111 		(void *)&cmd_setqmap_what,
8112 		(void *)&cmd_setqmap_portid,
8113 		(void *)&cmd_setqmap_queueid,
8114 		(void *)&cmd_setqmap_mapvalue,
8115 		NULL,
8116 	},
8117 };
8118 
8119 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8120 struct cmd_set_xstats_hide_zero_result {
8121 	cmdline_fixed_string_t keyword;
8122 	cmdline_fixed_string_t name;
8123 	cmdline_fixed_string_t on_off;
8124 };
8125 
8126 static void
8127 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8128 			__attribute__((unused)) struct cmdline *cl,
8129 			__attribute__((unused)) void *data)
8130 {
8131 	struct cmd_set_xstats_hide_zero_result *res;
8132 	uint16_t on_off = 0;
8133 
8134 	res = parsed_result;
8135 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8136 	set_xstats_hide_zero(on_off);
8137 }
8138 
8139 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8140 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8141 				 keyword, "set");
8142 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8143 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8144 				 name, "xstats-hide-zero");
8145 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8146 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8147 				 on_off, "on#off");
8148 
8149 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8150 	.f = cmd_set_xstats_hide_zero_parsed,
8151 	.data = NULL,
8152 	.help_str = "set xstats-hide-zero on|off",
8153 	.tokens = {
8154 		(void *)&cmd_set_xstats_hide_zero_keyword,
8155 		(void *)&cmd_set_xstats_hide_zero_name,
8156 		(void *)&cmd_set_xstats_hide_zero_on_off,
8157 		NULL,
8158 	},
8159 };
8160 
8161 /* *** CONFIGURE UNICAST HASH TABLE *** */
8162 struct cmd_set_uc_hash_table {
8163 	cmdline_fixed_string_t set;
8164 	cmdline_fixed_string_t port;
8165 	portid_t port_id;
8166 	cmdline_fixed_string_t what;
8167 	struct rte_ether_addr address;
8168 	cmdline_fixed_string_t mode;
8169 };
8170 
8171 static void
8172 cmd_set_uc_hash_parsed(void *parsed_result,
8173 		       __attribute__((unused)) struct cmdline *cl,
8174 		       __attribute__((unused)) void *data)
8175 {
8176 	int ret=0;
8177 	struct cmd_set_uc_hash_table *res = parsed_result;
8178 
8179 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8180 
8181 	if (strcmp(res->what, "uta") == 0)
8182 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8183 						&res->address,(uint8_t)is_on);
8184 	if (ret < 0)
8185 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8186 
8187 }
8188 
8189 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8190 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8191 				 set, "set");
8192 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8193 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8194 				 port, "port");
8195 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8196 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8197 			      port_id, UINT16);
8198 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8199 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8200 				 what, "uta");
8201 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8202 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8203 				address);
8204 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8205 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8206 				 mode, "on#off");
8207 
8208 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8209 	.f = cmd_set_uc_hash_parsed,
8210 	.data = NULL,
8211 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8212 	.tokens = {
8213 		(void *)&cmd_set_uc_hash_set,
8214 		(void *)&cmd_set_uc_hash_port,
8215 		(void *)&cmd_set_uc_hash_portid,
8216 		(void *)&cmd_set_uc_hash_what,
8217 		(void *)&cmd_set_uc_hash_mac,
8218 		(void *)&cmd_set_uc_hash_mode,
8219 		NULL,
8220 	},
8221 };
8222 
8223 struct cmd_set_uc_all_hash_table {
8224 	cmdline_fixed_string_t set;
8225 	cmdline_fixed_string_t port;
8226 	portid_t port_id;
8227 	cmdline_fixed_string_t what;
8228 	cmdline_fixed_string_t value;
8229 	cmdline_fixed_string_t mode;
8230 };
8231 
8232 static void
8233 cmd_set_uc_all_hash_parsed(void *parsed_result,
8234 		       __attribute__((unused)) struct cmdline *cl,
8235 		       __attribute__((unused)) void *data)
8236 {
8237 	int ret=0;
8238 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8239 
8240 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8241 
8242 	if ((strcmp(res->what, "uta") == 0) &&
8243 		(strcmp(res->value, "all") == 0))
8244 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8245 	if (ret < 0)
8246 		printf("bad unicast hash table parameter,"
8247 			"return code = %d \n", ret);
8248 }
8249 
8250 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8251 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8252 				 set, "set");
8253 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8254 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8255 				 port, "port");
8256 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8257 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8258 			      port_id, UINT16);
8259 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8260 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8261 				 what, "uta");
8262 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8263 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8264 				value,"all");
8265 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8266 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8267 				 mode, "on#off");
8268 
8269 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8270 	.f = cmd_set_uc_all_hash_parsed,
8271 	.data = NULL,
8272 	.help_str = "set port <port_id> uta all on|off",
8273 	.tokens = {
8274 		(void *)&cmd_set_uc_all_hash_set,
8275 		(void *)&cmd_set_uc_all_hash_port,
8276 		(void *)&cmd_set_uc_all_hash_portid,
8277 		(void *)&cmd_set_uc_all_hash_what,
8278 		(void *)&cmd_set_uc_all_hash_value,
8279 		(void *)&cmd_set_uc_all_hash_mode,
8280 		NULL,
8281 	},
8282 };
8283 
8284 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8285 struct cmd_set_vf_macvlan_filter {
8286 	cmdline_fixed_string_t set;
8287 	cmdline_fixed_string_t port;
8288 	portid_t port_id;
8289 	cmdline_fixed_string_t vf;
8290 	uint8_t vf_id;
8291 	struct rte_ether_addr address;
8292 	cmdline_fixed_string_t filter_type;
8293 	cmdline_fixed_string_t mode;
8294 };
8295 
8296 static void
8297 cmd_set_vf_macvlan_parsed(void *parsed_result,
8298 		       __attribute__((unused)) struct cmdline *cl,
8299 		       __attribute__((unused)) void *data)
8300 {
8301 	int is_on, ret = 0;
8302 	struct cmd_set_vf_macvlan_filter *res = parsed_result;
8303 	struct rte_eth_mac_filter filter;
8304 
8305 	memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8306 
8307 	rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8308 
8309 	/* set VF MAC filter */
8310 	filter.is_vf = 1;
8311 
8312 	/* set VF ID */
8313 	filter.dst_id = res->vf_id;
8314 
8315 	if (!strcmp(res->filter_type, "exact-mac"))
8316 		filter.filter_type = RTE_MAC_PERFECT_MATCH;
8317 	else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8318 		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8319 	else if (!strcmp(res->filter_type, "hashmac"))
8320 		filter.filter_type = RTE_MAC_HASH_MATCH;
8321 	else if (!strcmp(res->filter_type, "hashmac-vlan"))
8322 		filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8323 
8324 	is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8325 
8326 	if (is_on)
8327 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8328 					RTE_ETH_FILTER_MACVLAN,
8329 					RTE_ETH_FILTER_ADD,
8330 					 &filter);
8331 	else
8332 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8333 					RTE_ETH_FILTER_MACVLAN,
8334 					RTE_ETH_FILTER_DELETE,
8335 					&filter);
8336 
8337 	if (ret < 0)
8338 		printf("bad set MAC hash parameter, return code = %d\n", ret);
8339 
8340 }
8341 
8342 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8343 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8344 				 set, "set");
8345 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8346 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8347 				 port, "port");
8348 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8349 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8350 			      port_id, UINT16);
8351 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8352 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8353 				 vf, "vf");
8354 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8355 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8356 				vf_id, UINT8);
8357 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8358 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8359 				address);
8360 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8361 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8362 				filter_type, "exact-mac#exact-mac-vlan"
8363 				"#hashmac#hashmac-vlan");
8364 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8365 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8366 				 mode, "on#off");
8367 
8368 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8369 	.f = cmd_set_vf_macvlan_parsed,
8370 	.data = NULL,
8371 	.help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8372 		"exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8373 		"Exact match rule: exact match of MAC or MAC and VLAN; "
8374 		"hash match rule: hash match of MAC and exact match of VLAN",
8375 	.tokens = {
8376 		(void *)&cmd_set_vf_macvlan_set,
8377 		(void *)&cmd_set_vf_macvlan_port,
8378 		(void *)&cmd_set_vf_macvlan_portid,
8379 		(void *)&cmd_set_vf_macvlan_vf,
8380 		(void *)&cmd_set_vf_macvlan_vf_id,
8381 		(void *)&cmd_set_vf_macvlan_mac,
8382 		(void *)&cmd_set_vf_macvlan_filter_type,
8383 		(void *)&cmd_set_vf_macvlan_mode,
8384 		NULL,
8385 	},
8386 };
8387 
8388 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8389 struct cmd_set_vf_traffic {
8390 	cmdline_fixed_string_t set;
8391 	cmdline_fixed_string_t port;
8392 	portid_t port_id;
8393 	cmdline_fixed_string_t vf;
8394 	uint8_t vf_id;
8395 	cmdline_fixed_string_t what;
8396 	cmdline_fixed_string_t mode;
8397 };
8398 
8399 static void
8400 cmd_set_vf_traffic_parsed(void *parsed_result,
8401 		       __attribute__((unused)) struct cmdline *cl,
8402 		       __attribute__((unused)) void *data)
8403 {
8404 	struct cmd_set_vf_traffic *res = parsed_result;
8405 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8406 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8407 
8408 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8409 }
8410 
8411 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8412 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8413 				 set, "set");
8414 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8415 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8416 				 port, "port");
8417 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8418 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8419 			      port_id, UINT16);
8420 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8421 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8422 				 vf, "vf");
8423 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8424 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8425 			      vf_id, UINT8);
8426 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8427 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8428 				 what, "tx#rx");
8429 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8430 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8431 				 mode, "on#off");
8432 
8433 cmdline_parse_inst_t cmd_set_vf_traffic = {
8434 	.f = cmd_set_vf_traffic_parsed,
8435 	.data = NULL,
8436 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8437 	.tokens = {
8438 		(void *)&cmd_setvf_traffic_set,
8439 		(void *)&cmd_setvf_traffic_port,
8440 		(void *)&cmd_setvf_traffic_portid,
8441 		(void *)&cmd_setvf_traffic_vf,
8442 		(void *)&cmd_setvf_traffic_vfid,
8443 		(void *)&cmd_setvf_traffic_what,
8444 		(void *)&cmd_setvf_traffic_mode,
8445 		NULL,
8446 	},
8447 };
8448 
8449 /* *** CONFIGURE VF RECEIVE MODE *** */
8450 struct cmd_set_vf_rxmode {
8451 	cmdline_fixed_string_t set;
8452 	cmdline_fixed_string_t port;
8453 	portid_t port_id;
8454 	cmdline_fixed_string_t vf;
8455 	uint8_t vf_id;
8456 	cmdline_fixed_string_t what;
8457 	cmdline_fixed_string_t mode;
8458 	cmdline_fixed_string_t on;
8459 };
8460 
8461 static void
8462 cmd_set_vf_rxmode_parsed(void *parsed_result,
8463 		       __attribute__((unused)) struct cmdline *cl,
8464 		       __attribute__((unused)) void *data)
8465 {
8466 	int ret = -ENOTSUP;
8467 	uint16_t vf_rxmode = 0;
8468 	struct cmd_set_vf_rxmode *res = parsed_result;
8469 
8470 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8471 	if (!strcmp(res->what,"rxmode")) {
8472 		if (!strcmp(res->mode, "AUPE"))
8473 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8474 		else if (!strcmp(res->mode, "ROPE"))
8475 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8476 		else if (!strcmp(res->mode, "BAM"))
8477 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8478 		else if (!strncmp(res->mode, "MPE",3))
8479 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8480 	}
8481 
8482 	RTE_SET_USED(is_on);
8483 
8484 #ifdef RTE_LIBRTE_IXGBE_PMD
8485 	if (ret == -ENOTSUP)
8486 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8487 						  vf_rxmode, (uint8_t)is_on);
8488 #endif
8489 #ifdef RTE_LIBRTE_BNXT_PMD
8490 	if (ret == -ENOTSUP)
8491 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8492 						 vf_rxmode, (uint8_t)is_on);
8493 #endif
8494 	if (ret < 0)
8495 		printf("bad VF receive mode parameter, return code = %d \n",
8496 		ret);
8497 }
8498 
8499 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8500 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8501 				 set, "set");
8502 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8503 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8504 				 port, "port");
8505 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8506 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8507 			      port_id, UINT16);
8508 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8509 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8510 				 vf, "vf");
8511 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8512 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8513 			      vf_id, UINT8);
8514 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8515 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8516 				 what, "rxmode");
8517 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8518 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8519 				 mode, "AUPE#ROPE#BAM#MPE");
8520 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8521 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8522 				 on, "on#off");
8523 
8524 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8525 	.f = cmd_set_vf_rxmode_parsed,
8526 	.data = NULL,
8527 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8528 		"AUPE|ROPE|BAM|MPE on|off",
8529 	.tokens = {
8530 		(void *)&cmd_set_vf_rxmode_set,
8531 		(void *)&cmd_set_vf_rxmode_port,
8532 		(void *)&cmd_set_vf_rxmode_portid,
8533 		(void *)&cmd_set_vf_rxmode_vf,
8534 		(void *)&cmd_set_vf_rxmode_vfid,
8535 		(void *)&cmd_set_vf_rxmode_what,
8536 		(void *)&cmd_set_vf_rxmode_mode,
8537 		(void *)&cmd_set_vf_rxmode_on,
8538 		NULL,
8539 	},
8540 };
8541 
8542 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8543 struct cmd_vf_mac_addr_result {
8544 	cmdline_fixed_string_t mac_addr_cmd;
8545 	cmdline_fixed_string_t what;
8546 	cmdline_fixed_string_t port;
8547 	uint16_t port_num;
8548 	cmdline_fixed_string_t vf;
8549 	uint8_t vf_num;
8550 	struct rte_ether_addr address;
8551 };
8552 
8553 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8554 		__attribute__((unused)) struct cmdline *cl,
8555 		__attribute__((unused)) void *data)
8556 {
8557 	struct cmd_vf_mac_addr_result *res = parsed_result;
8558 	int ret = -ENOTSUP;
8559 
8560 	if (strcmp(res->what, "add") != 0)
8561 		return;
8562 
8563 #ifdef RTE_LIBRTE_I40E_PMD
8564 	if (ret == -ENOTSUP)
8565 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8566 						   &res->address);
8567 #endif
8568 #ifdef RTE_LIBRTE_BNXT_PMD
8569 	if (ret == -ENOTSUP)
8570 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8571 						res->vf_num);
8572 #endif
8573 
8574 	if(ret < 0)
8575 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8576 
8577 }
8578 
8579 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8580 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8581 				mac_addr_cmd,"mac_addr");
8582 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8583 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8584 				what,"add");
8585 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8586 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8587 				port,"port");
8588 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8589 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8590 				port_num, UINT16);
8591 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8592 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8593 				vf,"vf");
8594 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8595 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8596 				vf_num, UINT8);
8597 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8598 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8599 				address);
8600 
8601 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8602 	.f = cmd_vf_mac_addr_parsed,
8603 	.data = (void *)0,
8604 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8605 		"Add MAC address filtering for a VF on port_id",
8606 	.tokens = {
8607 		(void *)&cmd_vf_mac_addr_cmd,
8608 		(void *)&cmd_vf_mac_addr_what,
8609 		(void *)&cmd_vf_mac_addr_port,
8610 		(void *)&cmd_vf_mac_addr_portnum,
8611 		(void *)&cmd_vf_mac_addr_vf,
8612 		(void *)&cmd_vf_mac_addr_vfnum,
8613 		(void *)&cmd_vf_mac_addr_addr,
8614 		NULL,
8615 	},
8616 };
8617 
8618 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8619 struct cmd_vf_rx_vlan_filter {
8620 	cmdline_fixed_string_t rx_vlan;
8621 	cmdline_fixed_string_t what;
8622 	uint16_t vlan_id;
8623 	cmdline_fixed_string_t port;
8624 	portid_t port_id;
8625 	cmdline_fixed_string_t vf;
8626 	uint64_t vf_mask;
8627 };
8628 
8629 static void
8630 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8631 			  __attribute__((unused)) struct cmdline *cl,
8632 			  __attribute__((unused)) void *data)
8633 {
8634 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8635 	int ret = -ENOTSUP;
8636 
8637 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8638 
8639 #ifdef RTE_LIBRTE_IXGBE_PMD
8640 	if (ret == -ENOTSUP)
8641 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8642 				res->vlan_id, res->vf_mask, is_add);
8643 #endif
8644 #ifdef RTE_LIBRTE_I40E_PMD
8645 	if (ret == -ENOTSUP)
8646 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8647 				res->vlan_id, res->vf_mask, is_add);
8648 #endif
8649 #ifdef RTE_LIBRTE_BNXT_PMD
8650 	if (ret == -ENOTSUP)
8651 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8652 				res->vlan_id, res->vf_mask, is_add);
8653 #endif
8654 
8655 	switch (ret) {
8656 	case 0:
8657 		break;
8658 	case -EINVAL:
8659 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8660 				res->vlan_id, res->vf_mask);
8661 		break;
8662 	case -ENODEV:
8663 		printf("invalid port_id %d\n", res->port_id);
8664 		break;
8665 	case -ENOTSUP:
8666 		printf("function not implemented or supported\n");
8667 		break;
8668 	default:
8669 		printf("programming error: (%s)\n", strerror(-ret));
8670 	}
8671 }
8672 
8673 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8674 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8675 				 rx_vlan, "rx_vlan");
8676 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8677 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8678 				 what, "add#rm");
8679 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8680 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8681 			      vlan_id, UINT16);
8682 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8683 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8684 				 port, "port");
8685 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8686 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8687 			      port_id, UINT16);
8688 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8689 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8690 				 vf, "vf");
8691 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8692 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8693 			      vf_mask, UINT64);
8694 
8695 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8696 	.f = cmd_vf_rx_vlan_filter_parsed,
8697 	.data = NULL,
8698 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8699 		"(vf_mask = hexadecimal VF mask)",
8700 	.tokens = {
8701 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8702 		(void *)&cmd_vf_rx_vlan_filter_what,
8703 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8704 		(void *)&cmd_vf_rx_vlan_filter_port,
8705 		(void *)&cmd_vf_rx_vlan_filter_portid,
8706 		(void *)&cmd_vf_rx_vlan_filter_vf,
8707 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8708 		NULL,
8709 	},
8710 };
8711 
8712 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8713 struct cmd_queue_rate_limit_result {
8714 	cmdline_fixed_string_t set;
8715 	cmdline_fixed_string_t port;
8716 	uint16_t port_num;
8717 	cmdline_fixed_string_t queue;
8718 	uint8_t queue_num;
8719 	cmdline_fixed_string_t rate;
8720 	uint16_t rate_num;
8721 };
8722 
8723 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8724 		__attribute__((unused)) struct cmdline *cl,
8725 		__attribute__((unused)) void *data)
8726 {
8727 	struct cmd_queue_rate_limit_result *res = parsed_result;
8728 	int ret = 0;
8729 
8730 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8731 		&& (strcmp(res->queue, "queue") == 0)
8732 		&& (strcmp(res->rate, "rate") == 0))
8733 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8734 					res->rate_num);
8735 	if (ret < 0)
8736 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8737 
8738 }
8739 
8740 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8741 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8742 				set, "set");
8743 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8744 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8745 				port, "port");
8746 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8747 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8748 				port_num, UINT16);
8749 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8750 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8751 				queue, "queue");
8752 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8753 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8754 				queue_num, UINT8);
8755 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8756 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8757 				rate, "rate");
8758 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8759 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8760 				rate_num, UINT16);
8761 
8762 cmdline_parse_inst_t cmd_queue_rate_limit = {
8763 	.f = cmd_queue_rate_limit_parsed,
8764 	.data = (void *)0,
8765 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8766 		"Set rate limit for a queue on port_id",
8767 	.tokens = {
8768 		(void *)&cmd_queue_rate_limit_set,
8769 		(void *)&cmd_queue_rate_limit_port,
8770 		(void *)&cmd_queue_rate_limit_portnum,
8771 		(void *)&cmd_queue_rate_limit_queue,
8772 		(void *)&cmd_queue_rate_limit_queuenum,
8773 		(void *)&cmd_queue_rate_limit_rate,
8774 		(void *)&cmd_queue_rate_limit_ratenum,
8775 		NULL,
8776 	},
8777 };
8778 
8779 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8780 struct cmd_vf_rate_limit_result {
8781 	cmdline_fixed_string_t set;
8782 	cmdline_fixed_string_t port;
8783 	uint16_t port_num;
8784 	cmdline_fixed_string_t vf;
8785 	uint8_t vf_num;
8786 	cmdline_fixed_string_t rate;
8787 	uint16_t rate_num;
8788 	cmdline_fixed_string_t q_msk;
8789 	uint64_t q_msk_val;
8790 };
8791 
8792 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8793 		__attribute__((unused)) struct cmdline *cl,
8794 		__attribute__((unused)) void *data)
8795 {
8796 	struct cmd_vf_rate_limit_result *res = parsed_result;
8797 	int ret = 0;
8798 
8799 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8800 		&& (strcmp(res->vf, "vf") == 0)
8801 		&& (strcmp(res->rate, "rate") == 0)
8802 		&& (strcmp(res->q_msk, "queue_mask") == 0))
8803 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
8804 					res->rate_num, res->q_msk_val);
8805 	if (ret < 0)
8806 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8807 
8808 }
8809 
8810 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8811 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8812 				set, "set");
8813 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8814 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8815 				port, "port");
8816 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8817 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8818 				port_num, UINT16);
8819 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8820 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8821 				vf, "vf");
8822 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8823 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8824 				vf_num, UINT8);
8825 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8826 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8827 				rate, "rate");
8828 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8829 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8830 				rate_num, UINT16);
8831 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8832 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8833 				q_msk, "queue_mask");
8834 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8835 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8836 				q_msk_val, UINT64);
8837 
8838 cmdline_parse_inst_t cmd_vf_rate_limit = {
8839 	.f = cmd_vf_rate_limit_parsed,
8840 	.data = (void *)0,
8841 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8842 		"queue_mask <queue_mask_value>: "
8843 		"Set rate limit for queues of VF on port_id",
8844 	.tokens = {
8845 		(void *)&cmd_vf_rate_limit_set,
8846 		(void *)&cmd_vf_rate_limit_port,
8847 		(void *)&cmd_vf_rate_limit_portnum,
8848 		(void *)&cmd_vf_rate_limit_vf,
8849 		(void *)&cmd_vf_rate_limit_vfnum,
8850 		(void *)&cmd_vf_rate_limit_rate,
8851 		(void *)&cmd_vf_rate_limit_ratenum,
8852 		(void *)&cmd_vf_rate_limit_q_msk,
8853 		(void *)&cmd_vf_rate_limit_q_msk_val,
8854 		NULL,
8855 	},
8856 };
8857 
8858 /* *** ADD TUNNEL FILTER OF A PORT *** */
8859 struct cmd_tunnel_filter_result {
8860 	cmdline_fixed_string_t cmd;
8861 	cmdline_fixed_string_t what;
8862 	portid_t port_id;
8863 	struct rte_ether_addr outer_mac;
8864 	struct rte_ether_addr inner_mac;
8865 	cmdline_ipaddr_t ip_value;
8866 	uint16_t inner_vlan;
8867 	cmdline_fixed_string_t tunnel_type;
8868 	cmdline_fixed_string_t filter_type;
8869 	uint32_t tenant_id;
8870 	uint16_t queue_num;
8871 };
8872 
8873 static void
8874 cmd_tunnel_filter_parsed(void *parsed_result,
8875 			  __attribute__((unused)) struct cmdline *cl,
8876 			  __attribute__((unused)) void *data)
8877 {
8878 	struct cmd_tunnel_filter_result *res = parsed_result;
8879 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8880 	int ret = 0;
8881 
8882 	memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8883 
8884 	rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8885 	rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8886 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
8887 
8888 	if (res->ip_value.family == AF_INET) {
8889 		tunnel_filter_conf.ip_addr.ipv4_addr =
8890 			res->ip_value.addr.ipv4.s_addr;
8891 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8892 	} else {
8893 		memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8894 			&(res->ip_value.addr.ipv6),
8895 			sizeof(struct in6_addr));
8896 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8897 	}
8898 
8899 	if (!strcmp(res->filter_type, "imac-ivlan"))
8900 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8901 	else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8902 		tunnel_filter_conf.filter_type =
8903 			RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8904 	else if (!strcmp(res->filter_type, "imac-tenid"))
8905 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8906 	else if (!strcmp(res->filter_type, "imac"))
8907 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8908 	else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8909 		tunnel_filter_conf.filter_type =
8910 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8911 	else if (!strcmp(res->filter_type, "oip"))
8912 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8913 	else if (!strcmp(res->filter_type, "iip"))
8914 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8915 	else {
8916 		printf("The filter type is not supported");
8917 		return;
8918 	}
8919 
8920 	if (!strcmp(res->tunnel_type, "vxlan"))
8921 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8922 	else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8923 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8924 	else if (!strcmp(res->tunnel_type, "nvgre"))
8925 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8926 	else if (!strcmp(res->tunnel_type, "ipingre"))
8927 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8928 	else {
8929 		printf("The tunnel type %s not supported.\n", res->tunnel_type);
8930 		return;
8931 	}
8932 
8933 	tunnel_filter_conf.tenant_id = res->tenant_id;
8934 	tunnel_filter_conf.queue_id = res->queue_num;
8935 	if (!strcmp(res->what, "add"))
8936 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8937 					RTE_ETH_FILTER_TUNNEL,
8938 					RTE_ETH_FILTER_ADD,
8939 					&tunnel_filter_conf);
8940 	else
8941 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8942 					RTE_ETH_FILTER_TUNNEL,
8943 					RTE_ETH_FILTER_DELETE,
8944 					&tunnel_filter_conf);
8945 	if (ret < 0)
8946 		printf("cmd_tunnel_filter_parsed error: (%s)\n",
8947 				strerror(-ret));
8948 
8949 }
8950 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8951 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8952 	cmd, "tunnel_filter");
8953 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8954 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8955 	what, "add#rm");
8956 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8957 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8958 	port_id, UINT16);
8959 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8960 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8961 	outer_mac);
8962 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8963 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8964 	inner_mac);
8965 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8966 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8967 	inner_vlan, UINT16);
8968 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8969 	TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8970 	ip_value);
8971 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8972 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8973 	tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8974 
8975 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8976 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8977 	filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8978 		"imac#omac-imac-tenid");
8979 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8980 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8981 	tenant_id, UINT32);
8982 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8983 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8984 	queue_num, UINT16);
8985 
8986 cmdline_parse_inst_t cmd_tunnel_filter = {
8987 	.f = cmd_tunnel_filter_parsed,
8988 	.data = (void *)0,
8989 	.help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8990 		"<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8991 		"imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8992 		"<queue_id>: Add/Rm tunnel filter of a port",
8993 	.tokens = {
8994 		(void *)&cmd_tunnel_filter_cmd,
8995 		(void *)&cmd_tunnel_filter_what,
8996 		(void *)&cmd_tunnel_filter_port_id,
8997 		(void *)&cmd_tunnel_filter_outer_mac,
8998 		(void *)&cmd_tunnel_filter_inner_mac,
8999 		(void *)&cmd_tunnel_filter_ip_value,
9000 		(void *)&cmd_tunnel_filter_innner_vlan,
9001 		(void *)&cmd_tunnel_filter_tunnel_type,
9002 		(void *)&cmd_tunnel_filter_filter_type,
9003 		(void *)&cmd_tunnel_filter_tenant_id,
9004 		(void *)&cmd_tunnel_filter_queue_num,
9005 		NULL,
9006 	},
9007 };
9008 
9009 /* *** CONFIGURE TUNNEL UDP PORT *** */
9010 struct cmd_tunnel_udp_config {
9011 	cmdline_fixed_string_t cmd;
9012 	cmdline_fixed_string_t what;
9013 	uint16_t udp_port;
9014 	portid_t port_id;
9015 };
9016 
9017 static void
9018 cmd_tunnel_udp_config_parsed(void *parsed_result,
9019 			  __attribute__((unused)) struct cmdline *cl,
9020 			  __attribute__((unused)) void *data)
9021 {
9022 	struct cmd_tunnel_udp_config *res = parsed_result;
9023 	struct rte_eth_udp_tunnel tunnel_udp;
9024 	int ret;
9025 
9026 	tunnel_udp.udp_port = res->udp_port;
9027 
9028 	if (!strcmp(res->cmd, "rx_vxlan_port"))
9029 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9030 
9031 	if (!strcmp(res->what, "add"))
9032 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9033 						      &tunnel_udp);
9034 	else
9035 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9036 							 &tunnel_udp);
9037 
9038 	if (ret < 0)
9039 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9040 }
9041 
9042 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9043 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9044 				cmd, "rx_vxlan_port");
9045 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9046 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9047 				what, "add#rm");
9048 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9049 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9050 				udp_port, UINT16);
9051 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9052 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9053 				port_id, UINT16);
9054 
9055 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9056 	.f = cmd_tunnel_udp_config_parsed,
9057 	.data = (void *)0,
9058 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9059 		"Add/Remove a tunneling UDP port filter",
9060 	.tokens = {
9061 		(void *)&cmd_tunnel_udp_config_cmd,
9062 		(void *)&cmd_tunnel_udp_config_what,
9063 		(void *)&cmd_tunnel_udp_config_udp_port,
9064 		(void *)&cmd_tunnel_udp_config_port_id,
9065 		NULL,
9066 	},
9067 };
9068 
9069 struct cmd_config_tunnel_udp_port {
9070 	cmdline_fixed_string_t port;
9071 	cmdline_fixed_string_t config;
9072 	portid_t port_id;
9073 	cmdline_fixed_string_t udp_tunnel_port;
9074 	cmdline_fixed_string_t action;
9075 	cmdline_fixed_string_t tunnel_type;
9076 	uint16_t udp_port;
9077 };
9078 
9079 static void
9080 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9081 			       __attribute__((unused)) struct cmdline *cl,
9082 			       __attribute__((unused)) void *data)
9083 {
9084 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9085 	struct rte_eth_udp_tunnel tunnel_udp;
9086 	int ret = 0;
9087 
9088 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9089 		return;
9090 
9091 	tunnel_udp.udp_port = res->udp_port;
9092 
9093 	if (!strcmp(res->tunnel_type, "vxlan")) {
9094 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9095 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9096 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9097 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9098 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9099 	} else {
9100 		printf("Invalid tunnel type\n");
9101 		return;
9102 	}
9103 
9104 	if (!strcmp(res->action, "add"))
9105 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9106 						      &tunnel_udp);
9107 	else
9108 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9109 							 &tunnel_udp);
9110 
9111 	if (ret < 0)
9112 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9113 }
9114 
9115 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9116 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9117 				 "port");
9118 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9119 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9120 				 "config");
9121 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9122 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9123 			      UINT16);
9124 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9125 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9126 				 udp_tunnel_port,
9127 				 "udp_tunnel_port");
9128 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9129 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9130 				 "add#rm");
9131 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9132 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9133 				 "vxlan#geneve#vxlan-gpe");
9134 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9135 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9136 			      UINT16);
9137 
9138 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9139 	.f = cmd_cfg_tunnel_udp_port_parsed,
9140 	.data = NULL,
9141 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9142 	.tokens = {
9143 		(void *)&cmd_config_tunnel_udp_port_port,
9144 		(void *)&cmd_config_tunnel_udp_port_config,
9145 		(void *)&cmd_config_tunnel_udp_port_port_id,
9146 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9147 		(void *)&cmd_config_tunnel_udp_port_action,
9148 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9149 		(void *)&cmd_config_tunnel_udp_port_value,
9150 		NULL,
9151 	},
9152 };
9153 
9154 /* *** GLOBAL CONFIG *** */
9155 struct cmd_global_config_result {
9156 	cmdline_fixed_string_t cmd;
9157 	portid_t port_id;
9158 	cmdline_fixed_string_t cfg_type;
9159 	uint8_t len;
9160 };
9161 
9162 static void
9163 cmd_global_config_parsed(void *parsed_result,
9164 			 __attribute__((unused)) struct cmdline *cl,
9165 			 __attribute__((unused)) void *data)
9166 {
9167 	struct cmd_global_config_result *res = parsed_result;
9168 	struct rte_eth_global_cfg conf;
9169 	int ret;
9170 
9171 	memset(&conf, 0, sizeof(conf));
9172 	conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9173 	conf.cfg.gre_key_len = res->len;
9174 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9175 				      RTE_ETH_FILTER_SET, &conf);
9176 	if (ret != 0)
9177 		printf("Global config error\n");
9178 }
9179 
9180 cmdline_parse_token_string_t cmd_global_config_cmd =
9181 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9182 		"global_config");
9183 cmdline_parse_token_num_t cmd_global_config_port_id =
9184 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9185 			       UINT16);
9186 cmdline_parse_token_string_t cmd_global_config_type =
9187 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9188 		cfg_type, "gre-key-len");
9189 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9190 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9191 		len, UINT8);
9192 
9193 cmdline_parse_inst_t cmd_global_config = {
9194 	.f = cmd_global_config_parsed,
9195 	.data = (void *)NULL,
9196 	.help_str = "global_config <port_id> gre-key-len <key_len>",
9197 	.tokens = {
9198 		(void *)&cmd_global_config_cmd,
9199 		(void *)&cmd_global_config_port_id,
9200 		(void *)&cmd_global_config_type,
9201 		(void *)&cmd_global_config_gre_key_len,
9202 		NULL,
9203 	},
9204 };
9205 
9206 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9207 struct cmd_set_mirror_mask_result {
9208 	cmdline_fixed_string_t set;
9209 	cmdline_fixed_string_t port;
9210 	portid_t port_id;
9211 	cmdline_fixed_string_t mirror;
9212 	uint8_t rule_id;
9213 	cmdline_fixed_string_t what;
9214 	cmdline_fixed_string_t value;
9215 	cmdline_fixed_string_t dstpool;
9216 	uint8_t dstpool_id;
9217 	cmdline_fixed_string_t on;
9218 };
9219 
9220 cmdline_parse_token_string_t cmd_mirror_mask_set =
9221 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9222 				set, "set");
9223 cmdline_parse_token_string_t cmd_mirror_mask_port =
9224 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9225 				port, "port");
9226 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9227 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9228 				port_id, UINT16);
9229 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9230 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9231 				mirror, "mirror-rule");
9232 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9233 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9234 				rule_id, UINT8);
9235 cmdline_parse_token_string_t cmd_mirror_mask_what =
9236 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9237 				what, "pool-mirror-up#pool-mirror-down"
9238 				      "#vlan-mirror");
9239 cmdline_parse_token_string_t cmd_mirror_mask_value =
9240 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9241 				value, NULL);
9242 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9243 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9244 				dstpool, "dst-pool");
9245 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9246 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9247 				dstpool_id, UINT8);
9248 cmdline_parse_token_string_t cmd_mirror_mask_on =
9249 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9250 				on, "on#off");
9251 
9252 static void
9253 cmd_set_mirror_mask_parsed(void *parsed_result,
9254 		       __attribute__((unused)) struct cmdline *cl,
9255 		       __attribute__((unused)) void *data)
9256 {
9257 	int ret,nb_item,i;
9258 	struct cmd_set_mirror_mask_result *res = parsed_result;
9259 	struct rte_eth_mirror_conf mr_conf;
9260 
9261 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9262 
9263 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9264 
9265 	mr_conf.dst_pool = res->dstpool_id;
9266 
9267 	if (!strcmp(res->what, "pool-mirror-up")) {
9268 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9269 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9270 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9271 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9272 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9273 	} else if (!strcmp(res->what, "vlan-mirror")) {
9274 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9275 		nb_item = parse_item_list(res->value, "vlan",
9276 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9277 		if (nb_item <= 0)
9278 			return;
9279 
9280 		for (i = 0; i < nb_item; i++) {
9281 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9282 				printf("Invalid vlan_id: must be < 4096\n");
9283 				return;
9284 			}
9285 
9286 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9287 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9288 		}
9289 	}
9290 
9291 	if (!strcmp(res->on, "on"))
9292 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9293 						res->rule_id, 1);
9294 	else
9295 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9296 						res->rule_id, 0);
9297 	if (ret < 0)
9298 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9299 }
9300 
9301 cmdline_parse_inst_t cmd_set_mirror_mask = {
9302 		.f = cmd_set_mirror_mask_parsed,
9303 		.data = NULL,
9304 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9305 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9306 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9307 		.tokens = {
9308 			(void *)&cmd_mirror_mask_set,
9309 			(void *)&cmd_mirror_mask_port,
9310 			(void *)&cmd_mirror_mask_portid,
9311 			(void *)&cmd_mirror_mask_mirror,
9312 			(void *)&cmd_mirror_mask_ruleid,
9313 			(void *)&cmd_mirror_mask_what,
9314 			(void *)&cmd_mirror_mask_value,
9315 			(void *)&cmd_mirror_mask_dstpool,
9316 			(void *)&cmd_mirror_mask_poolid,
9317 			(void *)&cmd_mirror_mask_on,
9318 			NULL,
9319 		},
9320 };
9321 
9322 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9323 struct cmd_set_mirror_link_result {
9324 	cmdline_fixed_string_t set;
9325 	cmdline_fixed_string_t port;
9326 	portid_t port_id;
9327 	cmdline_fixed_string_t mirror;
9328 	uint8_t rule_id;
9329 	cmdline_fixed_string_t what;
9330 	cmdline_fixed_string_t dstpool;
9331 	uint8_t dstpool_id;
9332 	cmdline_fixed_string_t on;
9333 };
9334 
9335 cmdline_parse_token_string_t cmd_mirror_link_set =
9336 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9337 				 set, "set");
9338 cmdline_parse_token_string_t cmd_mirror_link_port =
9339 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9340 				port, "port");
9341 cmdline_parse_token_num_t cmd_mirror_link_portid =
9342 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9343 				port_id, UINT16);
9344 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9345 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9346 				mirror, "mirror-rule");
9347 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9348 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9349 			    rule_id, UINT8);
9350 cmdline_parse_token_string_t cmd_mirror_link_what =
9351 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9352 				what, "uplink-mirror#downlink-mirror");
9353 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9354 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9355 				dstpool, "dst-pool");
9356 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9357 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9358 				dstpool_id, UINT8);
9359 cmdline_parse_token_string_t cmd_mirror_link_on =
9360 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9361 				on, "on#off");
9362 
9363 static void
9364 cmd_set_mirror_link_parsed(void *parsed_result,
9365 		       __attribute__((unused)) struct cmdline *cl,
9366 		       __attribute__((unused)) void *data)
9367 {
9368 	int ret;
9369 	struct cmd_set_mirror_link_result *res = parsed_result;
9370 	struct rte_eth_mirror_conf mr_conf;
9371 
9372 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9373 	if (!strcmp(res->what, "uplink-mirror"))
9374 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9375 	else
9376 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9377 
9378 	mr_conf.dst_pool = res->dstpool_id;
9379 
9380 	if (!strcmp(res->on, "on"))
9381 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9382 						res->rule_id, 1);
9383 	else
9384 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9385 						res->rule_id, 0);
9386 
9387 	/* check the return value and print it if is < 0 */
9388 	if (ret < 0)
9389 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9390 
9391 }
9392 
9393 cmdline_parse_inst_t cmd_set_mirror_link = {
9394 		.f = cmd_set_mirror_link_parsed,
9395 		.data = NULL,
9396 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9397 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9398 		.tokens = {
9399 			(void *)&cmd_mirror_link_set,
9400 			(void *)&cmd_mirror_link_port,
9401 			(void *)&cmd_mirror_link_portid,
9402 			(void *)&cmd_mirror_link_mirror,
9403 			(void *)&cmd_mirror_link_ruleid,
9404 			(void *)&cmd_mirror_link_what,
9405 			(void *)&cmd_mirror_link_dstpool,
9406 			(void *)&cmd_mirror_link_poolid,
9407 			(void *)&cmd_mirror_link_on,
9408 			NULL,
9409 		},
9410 };
9411 
9412 /* *** RESET VM MIRROR RULE *** */
9413 struct cmd_rm_mirror_rule_result {
9414 	cmdline_fixed_string_t reset;
9415 	cmdline_fixed_string_t port;
9416 	portid_t port_id;
9417 	cmdline_fixed_string_t mirror;
9418 	uint8_t rule_id;
9419 };
9420 
9421 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9422 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9423 				 reset, "reset");
9424 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9425 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9426 				port, "port");
9427 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9428 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9429 				port_id, UINT16);
9430 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9431 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9432 				mirror, "mirror-rule");
9433 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9434 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9435 				rule_id, UINT8);
9436 
9437 static void
9438 cmd_reset_mirror_rule_parsed(void *parsed_result,
9439 		       __attribute__((unused)) struct cmdline *cl,
9440 		       __attribute__((unused)) void *data)
9441 {
9442 	int ret;
9443 	struct cmd_set_mirror_link_result *res = parsed_result;
9444         /* check rule_id */
9445 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9446 	if(ret < 0)
9447 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9448 }
9449 
9450 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9451 		.f = cmd_reset_mirror_rule_parsed,
9452 		.data = NULL,
9453 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9454 		.tokens = {
9455 			(void *)&cmd_rm_mirror_rule_reset,
9456 			(void *)&cmd_rm_mirror_rule_port,
9457 			(void *)&cmd_rm_mirror_rule_portid,
9458 			(void *)&cmd_rm_mirror_rule_mirror,
9459 			(void *)&cmd_rm_mirror_rule_ruleid,
9460 			NULL,
9461 		},
9462 };
9463 
9464 /* ******************************************************************************** */
9465 
9466 struct cmd_dump_result {
9467 	cmdline_fixed_string_t dump;
9468 };
9469 
9470 static void
9471 dump_struct_sizes(void)
9472 {
9473 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9474 	DUMP_SIZE(struct rte_mbuf);
9475 	DUMP_SIZE(struct rte_mempool);
9476 	DUMP_SIZE(struct rte_ring);
9477 #undef DUMP_SIZE
9478 }
9479 
9480 static void cmd_dump_parsed(void *parsed_result,
9481 			    __attribute__((unused)) struct cmdline *cl,
9482 			    __attribute__((unused)) void *data)
9483 {
9484 	struct cmd_dump_result *res = parsed_result;
9485 
9486 	if (!strcmp(res->dump, "dump_physmem"))
9487 		rte_dump_physmem_layout(stdout);
9488 	else if (!strcmp(res->dump, "dump_memzone"))
9489 		rte_memzone_dump(stdout);
9490 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9491 		dump_struct_sizes();
9492 	else if (!strcmp(res->dump, "dump_ring"))
9493 		rte_ring_list_dump(stdout);
9494 	else if (!strcmp(res->dump, "dump_mempool"))
9495 		rte_mempool_list_dump(stdout);
9496 	else if (!strcmp(res->dump, "dump_devargs"))
9497 		rte_devargs_dump(stdout);
9498 	else if (!strcmp(res->dump, "dump_log_types"))
9499 		rte_log_dump(stdout);
9500 }
9501 
9502 cmdline_parse_token_string_t cmd_dump_dump =
9503 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9504 		"dump_physmem#"
9505 		"dump_memzone#"
9506 		"dump_struct_sizes#"
9507 		"dump_ring#"
9508 		"dump_mempool#"
9509 		"dump_devargs#"
9510 		"dump_log_types");
9511 
9512 cmdline_parse_inst_t cmd_dump = {
9513 	.f = cmd_dump_parsed,  /* function to call */
9514 	.data = NULL,      /* 2nd arg of func */
9515 	.help_str = "Dump status",
9516 	.tokens = {        /* token list, NULL terminated */
9517 		(void *)&cmd_dump_dump,
9518 		NULL,
9519 	},
9520 };
9521 
9522 /* ******************************************************************************** */
9523 
9524 struct cmd_dump_one_result {
9525 	cmdline_fixed_string_t dump;
9526 	cmdline_fixed_string_t name;
9527 };
9528 
9529 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9530 				__attribute__((unused)) void *data)
9531 {
9532 	struct cmd_dump_one_result *res = parsed_result;
9533 
9534 	if (!strcmp(res->dump, "dump_ring")) {
9535 		struct rte_ring *r;
9536 		r = rte_ring_lookup(res->name);
9537 		if (r == NULL) {
9538 			cmdline_printf(cl, "Cannot find ring\n");
9539 			return;
9540 		}
9541 		rte_ring_dump(stdout, r);
9542 	} else if (!strcmp(res->dump, "dump_mempool")) {
9543 		struct rte_mempool *mp;
9544 		mp = rte_mempool_lookup(res->name);
9545 		if (mp == NULL) {
9546 			cmdline_printf(cl, "Cannot find mempool\n");
9547 			return;
9548 		}
9549 		rte_mempool_dump(stdout, mp);
9550 	}
9551 }
9552 
9553 cmdline_parse_token_string_t cmd_dump_one_dump =
9554 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9555 				 "dump_ring#dump_mempool");
9556 
9557 cmdline_parse_token_string_t cmd_dump_one_name =
9558 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9559 
9560 cmdline_parse_inst_t cmd_dump_one = {
9561 	.f = cmd_dump_one_parsed,  /* function to call */
9562 	.data = NULL,      /* 2nd arg of func */
9563 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9564 	.tokens = {        /* token list, NULL terminated */
9565 		(void *)&cmd_dump_one_dump,
9566 		(void *)&cmd_dump_one_name,
9567 		NULL,
9568 	},
9569 };
9570 
9571 /* *** Add/Del syn filter *** */
9572 struct cmd_syn_filter_result {
9573 	cmdline_fixed_string_t filter;
9574 	portid_t port_id;
9575 	cmdline_fixed_string_t ops;
9576 	cmdline_fixed_string_t priority;
9577 	cmdline_fixed_string_t high;
9578 	cmdline_fixed_string_t queue;
9579 	uint16_t queue_id;
9580 };
9581 
9582 static void
9583 cmd_syn_filter_parsed(void *parsed_result,
9584 			__attribute__((unused)) struct cmdline *cl,
9585 			__attribute__((unused)) void *data)
9586 {
9587 	struct cmd_syn_filter_result *res = parsed_result;
9588 	struct rte_eth_syn_filter syn_filter;
9589 	int ret = 0;
9590 
9591 	ret = rte_eth_dev_filter_supported(res->port_id,
9592 					RTE_ETH_FILTER_SYN);
9593 	if (ret < 0) {
9594 		printf("syn filter is not supported on port %u.\n",
9595 				res->port_id);
9596 		return;
9597 	}
9598 
9599 	memset(&syn_filter, 0, sizeof(syn_filter));
9600 
9601 	if (!strcmp(res->ops, "add")) {
9602 		if (!strcmp(res->high, "high"))
9603 			syn_filter.hig_pri = 1;
9604 		else
9605 			syn_filter.hig_pri = 0;
9606 
9607 		syn_filter.queue = res->queue_id;
9608 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9609 						RTE_ETH_FILTER_SYN,
9610 						RTE_ETH_FILTER_ADD,
9611 						&syn_filter);
9612 	} else
9613 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9614 						RTE_ETH_FILTER_SYN,
9615 						RTE_ETH_FILTER_DELETE,
9616 						&syn_filter);
9617 
9618 	if (ret < 0)
9619 		printf("syn filter programming error: (%s)\n",
9620 				strerror(-ret));
9621 }
9622 
9623 cmdline_parse_token_string_t cmd_syn_filter_filter =
9624 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9625 	filter, "syn_filter");
9626 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9627 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9628 	port_id, UINT16);
9629 cmdline_parse_token_string_t cmd_syn_filter_ops =
9630 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9631 	ops, "add#del");
9632 cmdline_parse_token_string_t cmd_syn_filter_priority =
9633 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9634 				priority, "priority");
9635 cmdline_parse_token_string_t cmd_syn_filter_high =
9636 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9637 				high, "high#low");
9638 cmdline_parse_token_string_t cmd_syn_filter_queue =
9639 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9640 				queue, "queue");
9641 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9642 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9643 				queue_id, UINT16);
9644 
9645 cmdline_parse_inst_t cmd_syn_filter = {
9646 	.f = cmd_syn_filter_parsed,
9647 	.data = NULL,
9648 	.help_str = "syn_filter <port_id> add|del priority high|low queue "
9649 		"<queue_id>: Add/Delete syn filter",
9650 	.tokens = {
9651 		(void *)&cmd_syn_filter_filter,
9652 		(void *)&cmd_syn_filter_port_id,
9653 		(void *)&cmd_syn_filter_ops,
9654 		(void *)&cmd_syn_filter_priority,
9655 		(void *)&cmd_syn_filter_high,
9656 		(void *)&cmd_syn_filter_queue,
9657 		(void *)&cmd_syn_filter_queue_id,
9658 		NULL,
9659 	},
9660 };
9661 
9662 /* *** queue region set *** */
9663 struct cmd_queue_region_result {
9664 	cmdline_fixed_string_t set;
9665 	cmdline_fixed_string_t port;
9666 	portid_t port_id;
9667 	cmdline_fixed_string_t cmd;
9668 	cmdline_fixed_string_t region;
9669 	uint8_t  region_id;
9670 	cmdline_fixed_string_t queue_start_index;
9671 	uint8_t  queue_id;
9672 	cmdline_fixed_string_t queue_num;
9673 	uint8_t  queue_num_value;
9674 };
9675 
9676 static void
9677 cmd_queue_region_parsed(void *parsed_result,
9678 			__attribute__((unused)) struct cmdline *cl,
9679 			__attribute__((unused)) void *data)
9680 {
9681 	struct cmd_queue_region_result *res = parsed_result;
9682 	int ret = -ENOTSUP;
9683 #ifdef RTE_LIBRTE_I40E_PMD
9684 	struct rte_pmd_i40e_queue_region_conf region_conf;
9685 	enum rte_pmd_i40e_queue_region_op op_type;
9686 #endif
9687 
9688 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9689 		return;
9690 
9691 #ifdef RTE_LIBRTE_I40E_PMD
9692 	memset(&region_conf, 0, sizeof(region_conf));
9693 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9694 	region_conf.region_id = res->region_id;
9695 	region_conf.queue_num = res->queue_num_value;
9696 	region_conf.queue_start_index = res->queue_id;
9697 
9698 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9699 				op_type, &region_conf);
9700 #endif
9701 
9702 	switch (ret) {
9703 	case 0:
9704 		break;
9705 	case -ENOTSUP:
9706 		printf("function not implemented or supported\n");
9707 		break;
9708 	default:
9709 		printf("queue region config error: (%s)\n", strerror(-ret));
9710 	}
9711 }
9712 
9713 cmdline_parse_token_string_t cmd_queue_region_set =
9714 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9715 		set, "set");
9716 cmdline_parse_token_string_t cmd_queue_region_port =
9717 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9718 cmdline_parse_token_num_t cmd_queue_region_port_id =
9719 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9720 				port_id, UINT16);
9721 cmdline_parse_token_string_t cmd_queue_region_cmd =
9722 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9723 				 cmd, "queue-region");
9724 cmdline_parse_token_string_t cmd_queue_region_id =
9725 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9726 				region, "region_id");
9727 cmdline_parse_token_num_t cmd_queue_region_index =
9728 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9729 				region_id, UINT8);
9730 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9731 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9732 				queue_start_index, "queue_start_index");
9733 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9734 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9735 				queue_id, UINT8);
9736 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9737 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9738 				queue_num, "queue_num");
9739 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9740 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9741 				queue_num_value, UINT8);
9742 
9743 cmdline_parse_inst_t cmd_queue_region = {
9744 	.f = cmd_queue_region_parsed,
9745 	.data = NULL,
9746 	.help_str = "set port <port_id> queue-region region_id <value> "
9747 		"queue_start_index <value> queue_num <value>: Set a queue region",
9748 	.tokens = {
9749 		(void *)&cmd_queue_region_set,
9750 		(void *)&cmd_queue_region_port,
9751 		(void *)&cmd_queue_region_port_id,
9752 		(void *)&cmd_queue_region_cmd,
9753 		(void *)&cmd_queue_region_id,
9754 		(void *)&cmd_queue_region_index,
9755 		(void *)&cmd_queue_region_queue_start_index,
9756 		(void *)&cmd_queue_region_queue_id,
9757 		(void *)&cmd_queue_region_queue_num,
9758 		(void *)&cmd_queue_region_queue_num_value,
9759 		NULL,
9760 	},
9761 };
9762 
9763 /* *** queue region and flowtype set *** */
9764 struct cmd_region_flowtype_result {
9765 	cmdline_fixed_string_t set;
9766 	cmdline_fixed_string_t port;
9767 	portid_t port_id;
9768 	cmdline_fixed_string_t cmd;
9769 	cmdline_fixed_string_t region;
9770 	uint8_t  region_id;
9771 	cmdline_fixed_string_t flowtype;
9772 	uint8_t  flowtype_id;
9773 };
9774 
9775 static void
9776 cmd_region_flowtype_parsed(void *parsed_result,
9777 			__attribute__((unused)) struct cmdline *cl,
9778 			__attribute__((unused)) void *data)
9779 {
9780 	struct cmd_region_flowtype_result *res = parsed_result;
9781 	int ret = -ENOTSUP;
9782 #ifdef RTE_LIBRTE_I40E_PMD
9783 	struct rte_pmd_i40e_queue_region_conf region_conf;
9784 	enum rte_pmd_i40e_queue_region_op op_type;
9785 #endif
9786 
9787 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9788 		return;
9789 
9790 #ifdef RTE_LIBRTE_I40E_PMD
9791 	memset(&region_conf, 0, sizeof(region_conf));
9792 
9793 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9794 	region_conf.region_id = res->region_id;
9795 	region_conf.hw_flowtype = res->flowtype_id;
9796 
9797 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9798 			op_type, &region_conf);
9799 #endif
9800 
9801 	switch (ret) {
9802 	case 0:
9803 		break;
9804 	case -ENOTSUP:
9805 		printf("function not implemented or supported\n");
9806 		break;
9807 	default:
9808 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9809 	}
9810 }
9811 
9812 cmdline_parse_token_string_t cmd_region_flowtype_set =
9813 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9814 				set, "set");
9815 cmdline_parse_token_string_t cmd_region_flowtype_port =
9816 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9817 				port, "port");
9818 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9819 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9820 				port_id, UINT16);
9821 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9822 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9823 				cmd, "queue-region");
9824 cmdline_parse_token_string_t cmd_region_flowtype_index =
9825 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9826 				region, "region_id");
9827 cmdline_parse_token_num_t cmd_region_flowtype_id =
9828 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9829 				region_id, UINT8);
9830 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9831 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9832 				flowtype, "flowtype");
9833 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9834 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9835 				flowtype_id, UINT8);
9836 cmdline_parse_inst_t cmd_region_flowtype = {
9837 	.f = cmd_region_flowtype_parsed,
9838 	.data = NULL,
9839 	.help_str = "set port <port_id> queue-region region_id <value> "
9840 		"flowtype <value>: Set a flowtype region index",
9841 	.tokens = {
9842 		(void *)&cmd_region_flowtype_set,
9843 		(void *)&cmd_region_flowtype_port,
9844 		(void *)&cmd_region_flowtype_port_index,
9845 		(void *)&cmd_region_flowtype_cmd,
9846 		(void *)&cmd_region_flowtype_index,
9847 		(void *)&cmd_region_flowtype_id,
9848 		(void *)&cmd_region_flowtype_flow_index,
9849 		(void *)&cmd_region_flowtype_flow_id,
9850 		NULL,
9851 	},
9852 };
9853 
9854 /* *** User Priority (UP) to queue region (region_id) set *** */
9855 struct cmd_user_priority_region_result {
9856 	cmdline_fixed_string_t set;
9857 	cmdline_fixed_string_t port;
9858 	portid_t port_id;
9859 	cmdline_fixed_string_t cmd;
9860 	cmdline_fixed_string_t user_priority;
9861 	uint8_t  user_priority_id;
9862 	cmdline_fixed_string_t region;
9863 	uint8_t  region_id;
9864 };
9865 
9866 static void
9867 cmd_user_priority_region_parsed(void *parsed_result,
9868 			__attribute__((unused)) struct cmdline *cl,
9869 			__attribute__((unused)) void *data)
9870 {
9871 	struct cmd_user_priority_region_result *res = parsed_result;
9872 	int ret = -ENOTSUP;
9873 #ifdef RTE_LIBRTE_I40E_PMD
9874 	struct rte_pmd_i40e_queue_region_conf region_conf;
9875 	enum rte_pmd_i40e_queue_region_op op_type;
9876 #endif
9877 
9878 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9879 		return;
9880 
9881 #ifdef RTE_LIBRTE_I40E_PMD
9882 	memset(&region_conf, 0, sizeof(region_conf));
9883 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9884 	region_conf.user_priority = res->user_priority_id;
9885 	region_conf.region_id = res->region_id;
9886 
9887 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9888 				op_type, &region_conf);
9889 #endif
9890 
9891 	switch (ret) {
9892 	case 0:
9893 		break;
9894 	case -ENOTSUP:
9895 		printf("function not implemented or supported\n");
9896 		break;
9897 	default:
9898 		printf("user_priority region config error: (%s)\n",
9899 				strerror(-ret));
9900 	}
9901 }
9902 
9903 cmdline_parse_token_string_t cmd_user_priority_region_set =
9904 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9905 				set, "set");
9906 cmdline_parse_token_string_t cmd_user_priority_region_port =
9907 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9908 				port, "port");
9909 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9910 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9911 				port_id, UINT16);
9912 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9913 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9914 				cmd, "queue-region");
9915 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9916 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9917 				user_priority, "UP");
9918 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9919 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9920 				user_priority_id, UINT8);
9921 cmdline_parse_token_string_t cmd_user_priority_region_region =
9922 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9923 				region, "region_id");
9924 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9925 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9926 				region_id, UINT8);
9927 
9928 cmdline_parse_inst_t cmd_user_priority_region = {
9929 	.f = cmd_user_priority_region_parsed,
9930 	.data = NULL,
9931 	.help_str = "set port <port_id> queue-region UP <value> "
9932 		"region_id <value>: Set the mapping of User Priority (UP) "
9933 		"to queue region (region_id) ",
9934 	.tokens = {
9935 		(void *)&cmd_user_priority_region_set,
9936 		(void *)&cmd_user_priority_region_port,
9937 		(void *)&cmd_user_priority_region_port_index,
9938 		(void *)&cmd_user_priority_region_cmd,
9939 		(void *)&cmd_user_priority_region_UP,
9940 		(void *)&cmd_user_priority_region_UP_id,
9941 		(void *)&cmd_user_priority_region_region,
9942 		(void *)&cmd_user_priority_region_region_id,
9943 		NULL,
9944 	},
9945 };
9946 
9947 /* *** flush all queue region related configuration *** */
9948 struct cmd_flush_queue_region_result {
9949 	cmdline_fixed_string_t set;
9950 	cmdline_fixed_string_t port;
9951 	portid_t port_id;
9952 	cmdline_fixed_string_t cmd;
9953 	cmdline_fixed_string_t flush;
9954 	cmdline_fixed_string_t what;
9955 };
9956 
9957 static void
9958 cmd_flush_queue_region_parsed(void *parsed_result,
9959 			__attribute__((unused)) struct cmdline *cl,
9960 			__attribute__((unused)) void *data)
9961 {
9962 	struct cmd_flush_queue_region_result *res = parsed_result;
9963 	int ret = -ENOTSUP;
9964 #ifdef RTE_LIBRTE_I40E_PMD
9965 	struct rte_pmd_i40e_queue_region_conf region_conf;
9966 	enum rte_pmd_i40e_queue_region_op op_type;
9967 #endif
9968 
9969 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9970 		return;
9971 
9972 #ifdef RTE_LIBRTE_I40E_PMD
9973 	memset(&region_conf, 0, sizeof(region_conf));
9974 
9975 	if (strcmp(res->what, "on") == 0)
9976 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9977 	else
9978 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9979 
9980 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9981 				op_type, &region_conf);
9982 #endif
9983 
9984 	switch (ret) {
9985 	case 0:
9986 		break;
9987 	case -ENOTSUP:
9988 		printf("function not implemented or supported\n");
9989 		break;
9990 	default:
9991 		printf("queue region config flush error: (%s)\n",
9992 				strerror(-ret));
9993 	}
9994 }
9995 
9996 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9997 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9998 				set, "set");
9999 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10000 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10001 				port, "port");
10002 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10003 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10004 				port_id, UINT16);
10005 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10006 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10007 				cmd, "queue-region");
10008 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10009 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10010 				flush, "flush");
10011 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10012 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10013 				what, "on#off");
10014 
10015 cmdline_parse_inst_t cmd_flush_queue_region = {
10016 	.f = cmd_flush_queue_region_parsed,
10017 	.data = NULL,
10018 	.help_str = "set port <port_id> queue-region flush on|off"
10019 		": flush all queue region related configuration",
10020 	.tokens = {
10021 		(void *)&cmd_flush_queue_region_set,
10022 		(void *)&cmd_flush_queue_region_port,
10023 		(void *)&cmd_flush_queue_region_port_index,
10024 		(void *)&cmd_flush_queue_region_cmd,
10025 		(void *)&cmd_flush_queue_region_flush,
10026 		(void *)&cmd_flush_queue_region_what,
10027 		NULL,
10028 	},
10029 };
10030 
10031 /* *** get all queue region related configuration info *** */
10032 struct cmd_show_queue_region_info {
10033 	cmdline_fixed_string_t show;
10034 	cmdline_fixed_string_t port;
10035 	portid_t port_id;
10036 	cmdline_fixed_string_t cmd;
10037 };
10038 
10039 static void
10040 cmd_show_queue_region_info_parsed(void *parsed_result,
10041 			__attribute__((unused)) struct cmdline *cl,
10042 			__attribute__((unused)) void *data)
10043 {
10044 	struct cmd_show_queue_region_info *res = parsed_result;
10045 	int ret = -ENOTSUP;
10046 #ifdef RTE_LIBRTE_I40E_PMD
10047 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10048 	enum rte_pmd_i40e_queue_region_op op_type;
10049 #endif
10050 
10051 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10052 		return;
10053 
10054 #ifdef RTE_LIBRTE_I40E_PMD
10055 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10056 
10057 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10058 
10059 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10060 					op_type, &rte_pmd_regions);
10061 
10062 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10063 #endif
10064 
10065 	switch (ret) {
10066 	case 0:
10067 		break;
10068 	case -ENOTSUP:
10069 		printf("function not implemented or supported\n");
10070 		break;
10071 	default:
10072 		printf("queue region config info show error: (%s)\n",
10073 				strerror(-ret));
10074 	}
10075 }
10076 
10077 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10078 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10079 				show, "show");
10080 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10081 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10082 				port, "port");
10083 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10084 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10085 				port_id, UINT16);
10086 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10087 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10088 				cmd, "queue-region");
10089 
10090 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10091 	.f = cmd_show_queue_region_info_parsed,
10092 	.data = NULL,
10093 	.help_str = "show port <port_id> queue-region"
10094 		": show all queue region related configuration info",
10095 	.tokens = {
10096 		(void *)&cmd_show_queue_region_info_get,
10097 		(void *)&cmd_show_queue_region_info_port,
10098 		(void *)&cmd_show_queue_region_info_port_index,
10099 		(void *)&cmd_show_queue_region_info_cmd,
10100 		NULL,
10101 	},
10102 };
10103 
10104 /* *** ADD/REMOVE A 2tuple FILTER *** */
10105 struct cmd_2tuple_filter_result {
10106 	cmdline_fixed_string_t filter;
10107 	portid_t port_id;
10108 	cmdline_fixed_string_t ops;
10109 	cmdline_fixed_string_t dst_port;
10110 	uint16_t dst_port_value;
10111 	cmdline_fixed_string_t protocol;
10112 	uint8_t protocol_value;
10113 	cmdline_fixed_string_t mask;
10114 	uint8_t  mask_value;
10115 	cmdline_fixed_string_t tcp_flags;
10116 	uint8_t tcp_flags_value;
10117 	cmdline_fixed_string_t priority;
10118 	uint8_t  priority_value;
10119 	cmdline_fixed_string_t queue;
10120 	uint16_t  queue_id;
10121 };
10122 
10123 static void
10124 cmd_2tuple_filter_parsed(void *parsed_result,
10125 			__attribute__((unused)) struct cmdline *cl,
10126 			__attribute__((unused)) void *data)
10127 {
10128 	struct rte_eth_ntuple_filter filter;
10129 	struct cmd_2tuple_filter_result *res = parsed_result;
10130 	int ret = 0;
10131 
10132 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10133 	if (ret < 0) {
10134 		printf("ntuple filter is not supported on port %u.\n",
10135 			res->port_id);
10136 		return;
10137 	}
10138 
10139 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10140 
10141 	filter.flags = RTE_2TUPLE_FLAGS;
10142 	filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10143 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10144 	filter.proto = res->protocol_value;
10145 	filter.priority = res->priority_value;
10146 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10147 		printf("nonzero tcp_flags is only meaningful"
10148 			" when protocol is TCP.\n");
10149 		return;
10150 	}
10151 	if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10152 		printf("invalid TCP flags.\n");
10153 		return;
10154 	}
10155 
10156 	if (res->tcp_flags_value != 0) {
10157 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10158 		filter.tcp_flags = res->tcp_flags_value;
10159 	}
10160 
10161 	/* need convert to big endian. */
10162 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10163 	filter.queue = res->queue_id;
10164 
10165 	if (!strcmp(res->ops, "add"))
10166 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10167 				RTE_ETH_FILTER_NTUPLE,
10168 				RTE_ETH_FILTER_ADD,
10169 				&filter);
10170 	else
10171 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10172 				RTE_ETH_FILTER_NTUPLE,
10173 				RTE_ETH_FILTER_DELETE,
10174 				&filter);
10175 	if (ret < 0)
10176 		printf("2tuple filter programming error: (%s)\n",
10177 			strerror(-ret));
10178 
10179 }
10180 
10181 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10182 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10183 				 filter, "2tuple_filter");
10184 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10185 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10186 				port_id, UINT16);
10187 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10188 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10189 				 ops, "add#del");
10190 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10191 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10192 				dst_port, "dst_port");
10193 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10194 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10195 				dst_port_value, UINT16);
10196 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10197 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10198 				protocol, "protocol");
10199 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10200 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10201 				protocol_value, UINT8);
10202 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10203 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10204 				mask, "mask");
10205 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10206 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10207 				mask_value, INT8);
10208 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10209 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10210 				tcp_flags, "tcp_flags");
10211 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10212 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10213 				tcp_flags_value, UINT8);
10214 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10215 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10216 				priority, "priority");
10217 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10218 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10219 				priority_value, UINT8);
10220 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10221 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10222 				queue, "queue");
10223 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10224 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10225 				queue_id, UINT16);
10226 
10227 cmdline_parse_inst_t cmd_2tuple_filter = {
10228 	.f = cmd_2tuple_filter_parsed,
10229 	.data = NULL,
10230 	.help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10231 		"<value> mask <value> tcp_flags <value> priority <value> queue "
10232 		"<queue_id>: Add a 2tuple filter",
10233 	.tokens = {
10234 		(void *)&cmd_2tuple_filter_filter,
10235 		(void *)&cmd_2tuple_filter_port_id,
10236 		(void *)&cmd_2tuple_filter_ops,
10237 		(void *)&cmd_2tuple_filter_dst_port,
10238 		(void *)&cmd_2tuple_filter_dst_port_value,
10239 		(void *)&cmd_2tuple_filter_protocol,
10240 		(void *)&cmd_2tuple_filter_protocol_value,
10241 		(void *)&cmd_2tuple_filter_mask,
10242 		(void *)&cmd_2tuple_filter_mask_value,
10243 		(void *)&cmd_2tuple_filter_tcp_flags,
10244 		(void *)&cmd_2tuple_filter_tcp_flags_value,
10245 		(void *)&cmd_2tuple_filter_priority,
10246 		(void *)&cmd_2tuple_filter_priority_value,
10247 		(void *)&cmd_2tuple_filter_queue,
10248 		(void *)&cmd_2tuple_filter_queue_id,
10249 		NULL,
10250 	},
10251 };
10252 
10253 /* *** ADD/REMOVE A 5tuple FILTER *** */
10254 struct cmd_5tuple_filter_result {
10255 	cmdline_fixed_string_t filter;
10256 	portid_t port_id;
10257 	cmdline_fixed_string_t ops;
10258 	cmdline_fixed_string_t dst_ip;
10259 	cmdline_ipaddr_t dst_ip_value;
10260 	cmdline_fixed_string_t src_ip;
10261 	cmdline_ipaddr_t src_ip_value;
10262 	cmdline_fixed_string_t dst_port;
10263 	uint16_t dst_port_value;
10264 	cmdline_fixed_string_t src_port;
10265 	uint16_t src_port_value;
10266 	cmdline_fixed_string_t protocol;
10267 	uint8_t protocol_value;
10268 	cmdline_fixed_string_t mask;
10269 	uint8_t  mask_value;
10270 	cmdline_fixed_string_t tcp_flags;
10271 	uint8_t tcp_flags_value;
10272 	cmdline_fixed_string_t priority;
10273 	uint8_t  priority_value;
10274 	cmdline_fixed_string_t queue;
10275 	uint16_t  queue_id;
10276 };
10277 
10278 static void
10279 cmd_5tuple_filter_parsed(void *parsed_result,
10280 			__attribute__((unused)) struct cmdline *cl,
10281 			__attribute__((unused)) void *data)
10282 {
10283 	struct rte_eth_ntuple_filter filter;
10284 	struct cmd_5tuple_filter_result *res = parsed_result;
10285 	int ret = 0;
10286 
10287 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10288 	if (ret < 0) {
10289 		printf("ntuple filter is not supported on port %u.\n",
10290 			res->port_id);
10291 		return;
10292 	}
10293 
10294 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10295 
10296 	filter.flags = RTE_5TUPLE_FLAGS;
10297 	filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10298 	filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10299 	filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10300 	filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10301 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10302 	filter.proto = res->protocol_value;
10303 	filter.priority = res->priority_value;
10304 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10305 		printf("nonzero tcp_flags is only meaningful"
10306 			" when protocol is TCP.\n");
10307 		return;
10308 	}
10309 	if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10310 		printf("invalid TCP flags.\n");
10311 		return;
10312 	}
10313 
10314 	if (res->tcp_flags_value != 0) {
10315 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10316 		filter.tcp_flags = res->tcp_flags_value;
10317 	}
10318 
10319 	if (res->dst_ip_value.family == AF_INET)
10320 		/* no need to convert, already big endian. */
10321 		filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10322 	else {
10323 		if (filter.dst_ip_mask == 0) {
10324 			printf("can not support ipv6 involved compare.\n");
10325 			return;
10326 		}
10327 		filter.dst_ip = 0;
10328 	}
10329 
10330 	if (res->src_ip_value.family == AF_INET)
10331 		/* no need to convert, already big endian. */
10332 		filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10333 	else {
10334 		if (filter.src_ip_mask == 0) {
10335 			printf("can not support ipv6 involved compare.\n");
10336 			return;
10337 		}
10338 		filter.src_ip = 0;
10339 	}
10340 	/* need convert to big endian. */
10341 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10342 	filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10343 	filter.queue = res->queue_id;
10344 
10345 	if (!strcmp(res->ops, "add"))
10346 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10347 				RTE_ETH_FILTER_NTUPLE,
10348 				RTE_ETH_FILTER_ADD,
10349 				&filter);
10350 	else
10351 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10352 				RTE_ETH_FILTER_NTUPLE,
10353 				RTE_ETH_FILTER_DELETE,
10354 				&filter);
10355 	if (ret < 0)
10356 		printf("5tuple filter programming error: (%s)\n",
10357 			strerror(-ret));
10358 }
10359 
10360 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10361 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10362 				 filter, "5tuple_filter");
10363 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10364 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10365 				port_id, UINT16);
10366 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10367 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10368 				 ops, "add#del");
10369 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10370 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10371 				dst_ip, "dst_ip");
10372 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10373 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10374 				dst_ip_value);
10375 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10376 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10377 				src_ip, "src_ip");
10378 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10379 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10380 				src_ip_value);
10381 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10382 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10383 				dst_port, "dst_port");
10384 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10385 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10386 				dst_port_value, UINT16);
10387 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10388 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10389 				src_port, "src_port");
10390 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10391 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10392 				src_port_value, UINT16);
10393 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10394 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10395 				protocol, "protocol");
10396 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10397 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10398 				protocol_value, UINT8);
10399 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10400 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10401 				mask, "mask");
10402 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10403 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10404 				mask_value, INT8);
10405 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10406 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10407 				tcp_flags, "tcp_flags");
10408 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10409 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10410 				tcp_flags_value, UINT8);
10411 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10412 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10413 				priority, "priority");
10414 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10415 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10416 				priority_value, UINT8);
10417 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10418 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10419 				queue, "queue");
10420 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10421 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10422 				queue_id, UINT16);
10423 
10424 cmdline_parse_inst_t cmd_5tuple_filter = {
10425 	.f = cmd_5tuple_filter_parsed,
10426 	.data = NULL,
10427 	.help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10428 		"src_ip <value> dst_port <value> src_port <value> "
10429 		"protocol <value>  mask <value> tcp_flags <value> "
10430 		"priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10431 	.tokens = {
10432 		(void *)&cmd_5tuple_filter_filter,
10433 		(void *)&cmd_5tuple_filter_port_id,
10434 		(void *)&cmd_5tuple_filter_ops,
10435 		(void *)&cmd_5tuple_filter_dst_ip,
10436 		(void *)&cmd_5tuple_filter_dst_ip_value,
10437 		(void *)&cmd_5tuple_filter_src_ip,
10438 		(void *)&cmd_5tuple_filter_src_ip_value,
10439 		(void *)&cmd_5tuple_filter_dst_port,
10440 		(void *)&cmd_5tuple_filter_dst_port_value,
10441 		(void *)&cmd_5tuple_filter_src_port,
10442 		(void *)&cmd_5tuple_filter_src_port_value,
10443 		(void *)&cmd_5tuple_filter_protocol,
10444 		(void *)&cmd_5tuple_filter_protocol_value,
10445 		(void *)&cmd_5tuple_filter_mask,
10446 		(void *)&cmd_5tuple_filter_mask_value,
10447 		(void *)&cmd_5tuple_filter_tcp_flags,
10448 		(void *)&cmd_5tuple_filter_tcp_flags_value,
10449 		(void *)&cmd_5tuple_filter_priority,
10450 		(void *)&cmd_5tuple_filter_priority_value,
10451 		(void *)&cmd_5tuple_filter_queue,
10452 		(void *)&cmd_5tuple_filter_queue_id,
10453 		NULL,
10454 	},
10455 };
10456 
10457 /* *** ADD/REMOVE A flex FILTER *** */
10458 struct cmd_flex_filter_result {
10459 	cmdline_fixed_string_t filter;
10460 	cmdline_fixed_string_t ops;
10461 	portid_t port_id;
10462 	cmdline_fixed_string_t len;
10463 	uint8_t len_value;
10464 	cmdline_fixed_string_t bytes;
10465 	cmdline_fixed_string_t bytes_value;
10466 	cmdline_fixed_string_t mask;
10467 	cmdline_fixed_string_t mask_value;
10468 	cmdline_fixed_string_t priority;
10469 	uint8_t priority_value;
10470 	cmdline_fixed_string_t queue;
10471 	uint16_t queue_id;
10472 };
10473 
10474 static int xdigit2val(unsigned char c)
10475 {
10476 	int val;
10477 	if (isdigit(c))
10478 		val = c - '0';
10479 	else if (isupper(c))
10480 		val = c - 'A' + 10;
10481 	else
10482 		val = c - 'a' + 10;
10483 	return val;
10484 }
10485 
10486 static void
10487 cmd_flex_filter_parsed(void *parsed_result,
10488 			  __attribute__((unused)) struct cmdline *cl,
10489 			  __attribute__((unused)) void *data)
10490 {
10491 	int ret = 0;
10492 	struct rte_eth_flex_filter filter;
10493 	struct cmd_flex_filter_result *res = parsed_result;
10494 	char *bytes_ptr, *mask_ptr;
10495 	uint16_t len, i, j = 0;
10496 	char c;
10497 	int val;
10498 	uint8_t byte = 0;
10499 
10500 	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10501 		printf("the len exceed the max length 128\n");
10502 		return;
10503 	}
10504 	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10505 	filter.len = res->len_value;
10506 	filter.priority = res->priority_value;
10507 	filter.queue = res->queue_id;
10508 	bytes_ptr = res->bytes_value;
10509 	mask_ptr = res->mask_value;
10510 
10511 	 /* translate bytes string to array. */
10512 	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10513 		(bytes_ptr[1] == 'X')))
10514 		bytes_ptr += 2;
10515 	len = strnlen(bytes_ptr, res->len_value * 2);
10516 	if (len == 0 || (len % 8 != 0)) {
10517 		printf("please check len and bytes input\n");
10518 		return;
10519 	}
10520 	for (i = 0; i < len; i++) {
10521 		c = bytes_ptr[i];
10522 		if (isxdigit(c) == 0) {
10523 			/* invalid characters. */
10524 			printf("invalid input\n");
10525 			return;
10526 		}
10527 		val = xdigit2val(c);
10528 		if (i % 2) {
10529 			byte |= val;
10530 			filter.bytes[j] = byte;
10531 			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10532 			j++;
10533 			byte = 0;
10534 		} else
10535 			byte |= val << 4;
10536 	}
10537 	printf("\n");
10538 	 /* translate mask string to uint8_t array. */
10539 	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10540 		(mask_ptr[1] == 'X')))
10541 		mask_ptr += 2;
10542 	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10543 	if (len == 0) {
10544 		printf("invalid input\n");
10545 		return;
10546 	}
10547 	j = 0;
10548 	byte = 0;
10549 	for (i = 0; i < len; i++) {
10550 		c = mask_ptr[i];
10551 		if (isxdigit(c) == 0) {
10552 			/* invalid characters. */
10553 			printf("invalid input\n");
10554 			return;
10555 		}
10556 		val = xdigit2val(c);
10557 		if (i % 2) {
10558 			byte |= val;
10559 			filter.mask[j] = byte;
10560 			printf("mask[%d]:%02x ", j, filter.mask[j]);
10561 			j++;
10562 			byte = 0;
10563 		} else
10564 			byte |= val << 4;
10565 	}
10566 	printf("\n");
10567 
10568 	if (!strcmp(res->ops, "add"))
10569 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10570 				RTE_ETH_FILTER_FLEXIBLE,
10571 				RTE_ETH_FILTER_ADD,
10572 				&filter);
10573 	else
10574 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10575 				RTE_ETH_FILTER_FLEXIBLE,
10576 				RTE_ETH_FILTER_DELETE,
10577 				&filter);
10578 
10579 	if (ret < 0)
10580 		printf("flex filter setting error: (%s)\n", strerror(-ret));
10581 }
10582 
10583 cmdline_parse_token_string_t cmd_flex_filter_filter =
10584 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10585 				filter, "flex_filter");
10586 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10587 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10588 				port_id, UINT16);
10589 cmdline_parse_token_string_t cmd_flex_filter_ops =
10590 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10591 				ops, "add#del");
10592 cmdline_parse_token_string_t cmd_flex_filter_len =
10593 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10594 				len, "len");
10595 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10596 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10597 				len_value, UINT8);
10598 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10599 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10600 				bytes, "bytes");
10601 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10602 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10603 				bytes_value, NULL);
10604 cmdline_parse_token_string_t cmd_flex_filter_mask =
10605 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10606 				mask, "mask");
10607 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10608 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10609 				mask_value, NULL);
10610 cmdline_parse_token_string_t cmd_flex_filter_priority =
10611 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10612 				priority, "priority");
10613 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10614 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10615 				priority_value, UINT8);
10616 cmdline_parse_token_string_t cmd_flex_filter_queue =
10617 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10618 				queue, "queue");
10619 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10620 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10621 				queue_id, UINT16);
10622 cmdline_parse_inst_t cmd_flex_filter = {
10623 	.f = cmd_flex_filter_parsed,
10624 	.data = NULL,
10625 	.help_str = "flex_filter <port_id> add|del len <value> bytes "
10626 		"<value> mask <value> priority <value> queue <queue_id>: "
10627 		"Add/Del a flex filter",
10628 	.tokens = {
10629 		(void *)&cmd_flex_filter_filter,
10630 		(void *)&cmd_flex_filter_port_id,
10631 		(void *)&cmd_flex_filter_ops,
10632 		(void *)&cmd_flex_filter_len,
10633 		(void *)&cmd_flex_filter_len_value,
10634 		(void *)&cmd_flex_filter_bytes,
10635 		(void *)&cmd_flex_filter_bytes_value,
10636 		(void *)&cmd_flex_filter_mask,
10637 		(void *)&cmd_flex_filter_mask_value,
10638 		(void *)&cmd_flex_filter_priority,
10639 		(void *)&cmd_flex_filter_priority_value,
10640 		(void *)&cmd_flex_filter_queue,
10641 		(void *)&cmd_flex_filter_queue_id,
10642 		NULL,
10643 	},
10644 };
10645 
10646 /* *** Filters Control *** */
10647 
10648 /* *** deal with ethertype filter *** */
10649 struct cmd_ethertype_filter_result {
10650 	cmdline_fixed_string_t filter;
10651 	portid_t port_id;
10652 	cmdline_fixed_string_t ops;
10653 	cmdline_fixed_string_t mac;
10654 	struct rte_ether_addr mac_addr;
10655 	cmdline_fixed_string_t ethertype;
10656 	uint16_t ethertype_value;
10657 	cmdline_fixed_string_t drop;
10658 	cmdline_fixed_string_t queue;
10659 	uint16_t  queue_id;
10660 };
10661 
10662 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10663 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10664 				 filter, "ethertype_filter");
10665 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10666 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10667 			      port_id, UINT16);
10668 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10669 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10670 				 ops, "add#del");
10671 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10672 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10673 				 mac, "mac_addr#mac_ignr");
10674 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10675 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10676 				     mac_addr);
10677 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10678 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10679 				 ethertype, "ethertype");
10680 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10681 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10682 			      ethertype_value, UINT16);
10683 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10684 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10685 				 drop, "drop#fwd");
10686 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10687 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10688 				 queue, "queue");
10689 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10690 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10691 			      queue_id, UINT16);
10692 
10693 static void
10694 cmd_ethertype_filter_parsed(void *parsed_result,
10695 			  __attribute__((unused)) struct cmdline *cl,
10696 			  __attribute__((unused)) void *data)
10697 {
10698 	struct cmd_ethertype_filter_result *res = parsed_result;
10699 	struct rte_eth_ethertype_filter filter;
10700 	int ret = 0;
10701 
10702 	ret = rte_eth_dev_filter_supported(res->port_id,
10703 			RTE_ETH_FILTER_ETHERTYPE);
10704 	if (ret < 0) {
10705 		printf("ethertype filter is not supported on port %u.\n",
10706 			res->port_id);
10707 		return;
10708 	}
10709 
10710 	memset(&filter, 0, sizeof(filter));
10711 	if (!strcmp(res->mac, "mac_addr")) {
10712 		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10713 		rte_memcpy(&filter.mac_addr, &res->mac_addr,
10714 			sizeof(struct rte_ether_addr));
10715 	}
10716 	if (!strcmp(res->drop, "drop"))
10717 		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10718 	filter.ether_type = res->ethertype_value;
10719 	filter.queue = res->queue_id;
10720 
10721 	if (!strcmp(res->ops, "add"))
10722 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10723 				RTE_ETH_FILTER_ETHERTYPE,
10724 				RTE_ETH_FILTER_ADD,
10725 				&filter);
10726 	else
10727 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10728 				RTE_ETH_FILTER_ETHERTYPE,
10729 				RTE_ETH_FILTER_DELETE,
10730 				&filter);
10731 	if (ret < 0)
10732 		printf("ethertype filter programming error: (%s)\n",
10733 			strerror(-ret));
10734 }
10735 
10736 cmdline_parse_inst_t cmd_ethertype_filter = {
10737 	.f = cmd_ethertype_filter_parsed,
10738 	.data = NULL,
10739 	.help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10740 		"<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10741 		"Add or delete an ethertype filter entry",
10742 	.tokens = {
10743 		(void *)&cmd_ethertype_filter_filter,
10744 		(void *)&cmd_ethertype_filter_port_id,
10745 		(void *)&cmd_ethertype_filter_ops,
10746 		(void *)&cmd_ethertype_filter_mac,
10747 		(void *)&cmd_ethertype_filter_mac_addr,
10748 		(void *)&cmd_ethertype_filter_ethertype,
10749 		(void *)&cmd_ethertype_filter_ethertype_value,
10750 		(void *)&cmd_ethertype_filter_drop,
10751 		(void *)&cmd_ethertype_filter_queue,
10752 		(void *)&cmd_ethertype_filter_queue_id,
10753 		NULL,
10754 	},
10755 };
10756 
10757 /* *** deal with flow director filter *** */
10758 struct cmd_flow_director_result {
10759 	cmdline_fixed_string_t flow_director_filter;
10760 	portid_t port_id;
10761 	cmdline_fixed_string_t mode;
10762 	cmdline_fixed_string_t mode_value;
10763 	cmdline_fixed_string_t ops;
10764 	cmdline_fixed_string_t flow;
10765 	cmdline_fixed_string_t flow_type;
10766 	cmdline_fixed_string_t ether;
10767 	uint16_t ether_type;
10768 	cmdline_fixed_string_t src;
10769 	cmdline_ipaddr_t ip_src;
10770 	uint16_t port_src;
10771 	cmdline_fixed_string_t dst;
10772 	cmdline_ipaddr_t ip_dst;
10773 	uint16_t port_dst;
10774 	cmdline_fixed_string_t verify_tag;
10775 	uint32_t verify_tag_value;
10776 	cmdline_fixed_string_t tos;
10777 	uint8_t tos_value;
10778 	cmdline_fixed_string_t proto;
10779 	uint8_t proto_value;
10780 	cmdline_fixed_string_t ttl;
10781 	uint8_t ttl_value;
10782 	cmdline_fixed_string_t vlan;
10783 	uint16_t vlan_value;
10784 	cmdline_fixed_string_t flexbytes;
10785 	cmdline_fixed_string_t flexbytes_value;
10786 	cmdline_fixed_string_t pf_vf;
10787 	cmdline_fixed_string_t drop;
10788 	cmdline_fixed_string_t queue;
10789 	uint16_t  queue_id;
10790 	cmdline_fixed_string_t fd_id;
10791 	uint32_t  fd_id_value;
10792 	cmdline_fixed_string_t mac;
10793 	struct rte_ether_addr mac_addr;
10794 	cmdline_fixed_string_t tunnel;
10795 	cmdline_fixed_string_t tunnel_type;
10796 	cmdline_fixed_string_t tunnel_id;
10797 	uint32_t tunnel_id_value;
10798 	cmdline_fixed_string_t packet;
10799 	char filepath[];
10800 };
10801 
10802 static inline int
10803 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10804 {
10805 	char s[256];
10806 	const char *p, *p0 = q_arg;
10807 	char *end;
10808 	unsigned long int_fld;
10809 	char *str_fld[max_num];
10810 	int i;
10811 	unsigned size;
10812 	int ret = -1;
10813 
10814 	p = strchr(p0, '(');
10815 	if (p == NULL)
10816 		return -1;
10817 	++p;
10818 	p0 = strchr(p, ')');
10819 	if (p0 == NULL)
10820 		return -1;
10821 
10822 	size = p0 - p;
10823 	if (size >= sizeof(s))
10824 		return -1;
10825 
10826 	snprintf(s, sizeof(s), "%.*s", size, p);
10827 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10828 	if (ret < 0 || ret > max_num)
10829 		return -1;
10830 	for (i = 0; i < ret; i++) {
10831 		errno = 0;
10832 		int_fld = strtoul(str_fld[i], &end, 0);
10833 		if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10834 			return -1;
10835 		flexbytes[i] = (uint8_t)int_fld;
10836 	}
10837 	return ret;
10838 }
10839 
10840 static uint16_t
10841 str2flowtype(char *string)
10842 {
10843 	uint8_t i = 0;
10844 	static const struct {
10845 		char str[32];
10846 		uint16_t type;
10847 	} flowtype_str[] = {
10848 		{"raw", RTE_ETH_FLOW_RAW},
10849 		{"ipv4", RTE_ETH_FLOW_IPV4},
10850 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10851 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10852 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10853 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10854 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10855 		{"ipv6", RTE_ETH_FLOW_IPV6},
10856 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10857 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10858 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10859 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10860 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10861 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10862 	};
10863 
10864 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10865 		if (!strcmp(flowtype_str[i].str, string))
10866 			return flowtype_str[i].type;
10867 	}
10868 
10869 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10870 		return (uint16_t)atoi(string);
10871 
10872 	return RTE_ETH_FLOW_UNKNOWN;
10873 }
10874 
10875 static enum rte_eth_fdir_tunnel_type
10876 str2fdir_tunneltype(char *string)
10877 {
10878 	uint8_t i = 0;
10879 
10880 	static const struct {
10881 		char str[32];
10882 		enum rte_eth_fdir_tunnel_type type;
10883 	} tunneltype_str[] = {
10884 		{"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10885 		{"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10886 	};
10887 
10888 	for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10889 		if (!strcmp(tunneltype_str[i].str, string))
10890 			return tunneltype_str[i].type;
10891 	}
10892 	return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10893 }
10894 
10895 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10896 do { \
10897 	if ((ip_addr).family == AF_INET) \
10898 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10899 	else { \
10900 		printf("invalid parameter.\n"); \
10901 		return; \
10902 	} \
10903 } while (0)
10904 
10905 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10906 do { \
10907 	if ((ip_addr).family == AF_INET6) \
10908 		rte_memcpy(&(ip), \
10909 				 &((ip_addr).addr.ipv6), \
10910 				 sizeof(struct in6_addr)); \
10911 	else { \
10912 		printf("invalid parameter.\n"); \
10913 		return; \
10914 	} \
10915 } while (0)
10916 
10917 static void
10918 cmd_flow_director_filter_parsed(void *parsed_result,
10919 			  __attribute__((unused)) struct cmdline *cl,
10920 			  __attribute__((unused)) void *data)
10921 {
10922 	struct cmd_flow_director_result *res = parsed_result;
10923 	struct rte_eth_fdir_filter entry;
10924 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10925 	char *end;
10926 	unsigned long vf_id;
10927 	int ret = 0;
10928 
10929 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10930 	if (ret < 0) {
10931 		printf("flow director is not supported on port %u.\n",
10932 			res->port_id);
10933 		return;
10934 	}
10935 	memset(flexbytes, 0, sizeof(flexbytes));
10936 	memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10937 
10938 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10939 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10940 			printf("Please set mode to MAC-VLAN.\n");
10941 			return;
10942 		}
10943 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10944 		if (strcmp(res->mode_value, "Tunnel")) {
10945 			printf("Please set mode to Tunnel.\n");
10946 			return;
10947 		}
10948 	} else {
10949 		if (!strcmp(res->mode_value, "raw")) {
10950 #ifdef RTE_LIBRTE_I40E_PMD
10951 			struct rte_pmd_i40e_flow_type_mapping
10952 					mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10953 			struct rte_pmd_i40e_pkt_template_conf conf;
10954 			uint16_t flow_type = str2flowtype(res->flow_type);
10955 			uint16_t i, port = res->port_id;
10956 			uint8_t add;
10957 
10958 			memset(&conf, 0, sizeof(conf));
10959 
10960 			if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10961 				printf("Invalid flow type specified.\n");
10962 				return;
10963 			}
10964 			ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10965 								 mapping);
10966 			if (ret)
10967 				return;
10968 			if (mapping[flow_type].pctype == 0ULL) {
10969 				printf("Invalid flow type specified.\n");
10970 				return;
10971 			}
10972 			for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10973 				if (mapping[flow_type].pctype & (1ULL << i)) {
10974 					conf.input.pctype = i;
10975 					break;
10976 				}
10977 			}
10978 
10979 			conf.input.packet = open_file(res->filepath,
10980 						&conf.input.length);
10981 			if (!conf.input.packet)
10982 				return;
10983 			if (!strcmp(res->drop, "drop"))
10984 				conf.action.behavior =
10985 					RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10986 			else
10987 				conf.action.behavior =
10988 					RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10989 			conf.action.report_status =
10990 					RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10991 			conf.action.rx_queue = res->queue_id;
10992 			conf.soft_id = res->fd_id_value;
10993 			add  = strcmp(res->ops, "del") ? 1 : 0;
10994 			ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10995 									&conf,
10996 									add);
10997 			if (ret < 0)
10998 				printf("flow director config error: (%s)\n",
10999 				       strerror(-ret));
11000 			close_file(conf.input.packet);
11001 #endif
11002 			return;
11003 		} else if (strcmp(res->mode_value, "IP")) {
11004 			printf("Please set mode to IP or raw.\n");
11005 			return;
11006 		}
11007 		entry.input.flow_type = str2flowtype(res->flow_type);
11008 	}
11009 
11010 	ret = parse_flexbytes(res->flexbytes_value,
11011 					flexbytes,
11012 					RTE_ETH_FDIR_MAX_FLEXLEN);
11013 	if (ret < 0) {
11014 		printf("error: Cannot parse flexbytes input.\n");
11015 		return;
11016 	}
11017 
11018 	switch (entry.input.flow_type) {
11019 	case RTE_ETH_FLOW_FRAG_IPV4:
11020 	case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11021 		entry.input.flow.ip4_flow.proto = res->proto_value;
11022 		/* fall-through */
11023 	case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11024 	case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11025 		IPV4_ADDR_TO_UINT(res->ip_dst,
11026 			entry.input.flow.ip4_flow.dst_ip);
11027 		IPV4_ADDR_TO_UINT(res->ip_src,
11028 			entry.input.flow.ip4_flow.src_ip);
11029 		entry.input.flow.ip4_flow.tos = res->tos_value;
11030 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
11031 		/* need convert to big endian. */
11032 		entry.input.flow.udp4_flow.dst_port =
11033 				rte_cpu_to_be_16(res->port_dst);
11034 		entry.input.flow.udp4_flow.src_port =
11035 				rte_cpu_to_be_16(res->port_src);
11036 		break;
11037 	case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11038 		IPV4_ADDR_TO_UINT(res->ip_dst,
11039 			entry.input.flow.sctp4_flow.ip.dst_ip);
11040 		IPV4_ADDR_TO_UINT(res->ip_src,
11041 			entry.input.flow.sctp4_flow.ip.src_ip);
11042 		entry.input.flow.ip4_flow.tos = res->tos_value;
11043 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
11044 		/* need convert to big endian. */
11045 		entry.input.flow.sctp4_flow.dst_port =
11046 				rte_cpu_to_be_16(res->port_dst);
11047 		entry.input.flow.sctp4_flow.src_port =
11048 				rte_cpu_to_be_16(res->port_src);
11049 		entry.input.flow.sctp4_flow.verify_tag =
11050 				rte_cpu_to_be_32(res->verify_tag_value);
11051 		break;
11052 	case RTE_ETH_FLOW_FRAG_IPV6:
11053 	case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11054 		entry.input.flow.ipv6_flow.proto = res->proto_value;
11055 		/* fall-through */
11056 	case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11057 	case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11058 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
11059 			entry.input.flow.ipv6_flow.dst_ip);
11060 		IPV6_ADDR_TO_ARRAY(res->ip_src,
11061 			entry.input.flow.ipv6_flow.src_ip);
11062 		entry.input.flow.ipv6_flow.tc = res->tos_value;
11063 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11064 		/* need convert to big endian. */
11065 		entry.input.flow.udp6_flow.dst_port =
11066 				rte_cpu_to_be_16(res->port_dst);
11067 		entry.input.flow.udp6_flow.src_port =
11068 				rte_cpu_to_be_16(res->port_src);
11069 		break;
11070 	case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11071 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
11072 			entry.input.flow.sctp6_flow.ip.dst_ip);
11073 		IPV6_ADDR_TO_ARRAY(res->ip_src,
11074 			entry.input.flow.sctp6_flow.ip.src_ip);
11075 		entry.input.flow.ipv6_flow.tc = res->tos_value;
11076 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11077 		/* need convert to big endian. */
11078 		entry.input.flow.sctp6_flow.dst_port =
11079 				rte_cpu_to_be_16(res->port_dst);
11080 		entry.input.flow.sctp6_flow.src_port =
11081 				rte_cpu_to_be_16(res->port_src);
11082 		entry.input.flow.sctp6_flow.verify_tag =
11083 				rte_cpu_to_be_32(res->verify_tag_value);
11084 		break;
11085 	case RTE_ETH_FLOW_L2_PAYLOAD:
11086 		entry.input.flow.l2_flow.ether_type =
11087 			rte_cpu_to_be_16(res->ether_type);
11088 		break;
11089 	default:
11090 		break;
11091 	}
11092 
11093 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11094 		rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11095 				 &res->mac_addr,
11096 				 sizeof(struct rte_ether_addr));
11097 
11098 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11099 		rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11100 				 &res->mac_addr,
11101 				 sizeof(struct rte_ether_addr));
11102 		entry.input.flow.tunnel_flow.tunnel_type =
11103 			str2fdir_tunneltype(res->tunnel_type);
11104 		entry.input.flow.tunnel_flow.tunnel_id =
11105 			rte_cpu_to_be_32(res->tunnel_id_value);
11106 	}
11107 
11108 	rte_memcpy(entry.input.flow_ext.flexbytes,
11109 		   flexbytes,
11110 		   RTE_ETH_FDIR_MAX_FLEXLEN);
11111 
11112 	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11113 
11114 	entry.action.flex_off = 0;  /*use 0 by default */
11115 	if (!strcmp(res->drop, "drop"))
11116 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
11117 	else
11118 		entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11119 
11120 	if (fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11121 	    fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11122 		if (!strcmp(res->pf_vf, "pf"))
11123 			entry.input.flow_ext.is_vf = 0;
11124 		else if (!strncmp(res->pf_vf, "vf", 2)) {
11125 			struct rte_eth_dev_info dev_info;
11126 
11127 			ret = eth_dev_info_get_print_err(res->port_id,
11128 						&dev_info);
11129 			if (ret != 0)
11130 				return;
11131 
11132 			errno = 0;
11133 			vf_id = strtoul(res->pf_vf + 2, &end, 10);
11134 			if (errno != 0 || *end != '\0' ||
11135 			    vf_id >= dev_info.max_vfs) {
11136 				printf("invalid parameter %s.\n", res->pf_vf);
11137 				return;
11138 			}
11139 			entry.input.flow_ext.is_vf = 1;
11140 			entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11141 		} else {
11142 			printf("invalid parameter %s.\n", res->pf_vf);
11143 			return;
11144 		}
11145 	}
11146 
11147 	/* set to report FD ID by default */
11148 	entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11149 	entry.action.rx_queue = res->queue_id;
11150 	entry.soft_id = res->fd_id_value;
11151 	if (!strcmp(res->ops, "add"))
11152 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11153 					     RTE_ETH_FILTER_ADD, &entry);
11154 	else if (!strcmp(res->ops, "del"))
11155 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11156 					     RTE_ETH_FILTER_DELETE, &entry);
11157 	else
11158 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11159 					     RTE_ETH_FILTER_UPDATE, &entry);
11160 	if (ret < 0)
11161 		printf("flow director programming error: (%s)\n",
11162 			strerror(-ret));
11163 }
11164 
11165 cmdline_parse_token_string_t cmd_flow_director_filter =
11166 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11167 				 flow_director_filter, "flow_director_filter");
11168 cmdline_parse_token_num_t cmd_flow_director_port_id =
11169 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11170 			      port_id, UINT16);
11171 cmdline_parse_token_string_t cmd_flow_director_ops =
11172 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11173 				 ops, "add#del#update");
11174 cmdline_parse_token_string_t cmd_flow_director_flow =
11175 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11176 				 flow, "flow");
11177 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11178 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11179 		flow_type, NULL);
11180 cmdline_parse_token_string_t cmd_flow_director_ether =
11181 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11182 				 ether, "ether");
11183 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11184 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11185 			      ether_type, UINT16);
11186 cmdline_parse_token_string_t cmd_flow_director_src =
11187 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11188 				 src, "src");
11189 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11190 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11191 				 ip_src);
11192 cmdline_parse_token_num_t cmd_flow_director_port_src =
11193 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11194 			      port_src, UINT16);
11195 cmdline_parse_token_string_t cmd_flow_director_dst =
11196 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11197 				 dst, "dst");
11198 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11199 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11200 				 ip_dst);
11201 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11202 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11203 			      port_dst, UINT16);
11204 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11205 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11206 				  verify_tag, "verify_tag");
11207 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11208 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11209 			      verify_tag_value, UINT32);
11210 cmdline_parse_token_string_t cmd_flow_director_tos =
11211 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11212 				 tos, "tos");
11213 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11214 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11215 			      tos_value, UINT8);
11216 cmdline_parse_token_string_t cmd_flow_director_proto =
11217 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11218 				 proto, "proto");
11219 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11220 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11221 			      proto_value, UINT8);
11222 cmdline_parse_token_string_t cmd_flow_director_ttl =
11223 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11224 				 ttl, "ttl");
11225 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11226 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11227 			      ttl_value, UINT8);
11228 cmdline_parse_token_string_t cmd_flow_director_vlan =
11229 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11230 				 vlan, "vlan");
11231 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11232 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11233 			      vlan_value, UINT16);
11234 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11235 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11236 				 flexbytes, "flexbytes");
11237 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11238 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11239 			      flexbytes_value, NULL);
11240 cmdline_parse_token_string_t cmd_flow_director_drop =
11241 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11242 				 drop, "drop#fwd");
11243 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11244 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11245 			      pf_vf, NULL);
11246 cmdline_parse_token_string_t cmd_flow_director_queue =
11247 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11248 				 queue, "queue");
11249 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11250 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11251 			      queue_id, UINT16);
11252 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11253 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 				 fd_id, "fd_id");
11255 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11256 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11257 			      fd_id_value, UINT32);
11258 
11259 cmdline_parse_token_string_t cmd_flow_director_mode =
11260 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11261 				 mode, "mode");
11262 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11263 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11264 				 mode_value, "IP");
11265 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11266 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11267 				 mode_value, "MAC-VLAN");
11268 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11269 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11270 				 mode_value, "Tunnel");
11271 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11272 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11273 				 mode_value, "raw");
11274 cmdline_parse_token_string_t cmd_flow_director_mac =
11275 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11276 				 mac, "mac");
11277 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11278 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11279 				    mac_addr);
11280 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11281 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11282 				 tunnel, "tunnel");
11283 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11284 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11285 				 tunnel_type, "NVGRE#VxLAN");
11286 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11287 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11288 				 tunnel_id, "tunnel-id");
11289 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11290 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11291 			      tunnel_id_value, UINT32);
11292 cmdline_parse_token_string_t cmd_flow_director_packet =
11293 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11294 				 packet, "packet");
11295 cmdline_parse_token_string_t cmd_flow_director_filepath =
11296 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11297 				 filepath, NULL);
11298 
11299 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11300 	.f = cmd_flow_director_filter_parsed,
11301 	.data = NULL,
11302 	.help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11303 		" ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11304 		"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11305 		"l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11306 		"proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11307 		"flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11308 		"fd_id <fd_id_value>: "
11309 		"Add or delete an ip flow director entry on NIC",
11310 	.tokens = {
11311 		(void *)&cmd_flow_director_filter,
11312 		(void *)&cmd_flow_director_port_id,
11313 		(void *)&cmd_flow_director_mode,
11314 		(void *)&cmd_flow_director_mode_ip,
11315 		(void *)&cmd_flow_director_ops,
11316 		(void *)&cmd_flow_director_flow,
11317 		(void *)&cmd_flow_director_flow_type,
11318 		(void *)&cmd_flow_director_src,
11319 		(void *)&cmd_flow_director_ip_src,
11320 		(void *)&cmd_flow_director_dst,
11321 		(void *)&cmd_flow_director_ip_dst,
11322 		(void *)&cmd_flow_director_tos,
11323 		(void *)&cmd_flow_director_tos_value,
11324 		(void *)&cmd_flow_director_proto,
11325 		(void *)&cmd_flow_director_proto_value,
11326 		(void *)&cmd_flow_director_ttl,
11327 		(void *)&cmd_flow_director_ttl_value,
11328 		(void *)&cmd_flow_director_vlan,
11329 		(void *)&cmd_flow_director_vlan_value,
11330 		(void *)&cmd_flow_director_flexbytes,
11331 		(void *)&cmd_flow_director_flexbytes_value,
11332 		(void *)&cmd_flow_director_drop,
11333 		(void *)&cmd_flow_director_pf_vf,
11334 		(void *)&cmd_flow_director_queue,
11335 		(void *)&cmd_flow_director_queue_id,
11336 		(void *)&cmd_flow_director_fd_id,
11337 		(void *)&cmd_flow_director_fd_id_value,
11338 		NULL,
11339 	},
11340 };
11341 
11342 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11343 	.f = cmd_flow_director_filter_parsed,
11344 	.data = NULL,
11345 	.help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11346 		"director entry on NIC",
11347 	.tokens = {
11348 		(void *)&cmd_flow_director_filter,
11349 		(void *)&cmd_flow_director_port_id,
11350 		(void *)&cmd_flow_director_mode,
11351 		(void *)&cmd_flow_director_mode_ip,
11352 		(void *)&cmd_flow_director_ops,
11353 		(void *)&cmd_flow_director_flow,
11354 		(void *)&cmd_flow_director_flow_type,
11355 		(void *)&cmd_flow_director_src,
11356 		(void *)&cmd_flow_director_ip_src,
11357 		(void *)&cmd_flow_director_port_src,
11358 		(void *)&cmd_flow_director_dst,
11359 		(void *)&cmd_flow_director_ip_dst,
11360 		(void *)&cmd_flow_director_port_dst,
11361 		(void *)&cmd_flow_director_tos,
11362 		(void *)&cmd_flow_director_tos_value,
11363 		(void *)&cmd_flow_director_ttl,
11364 		(void *)&cmd_flow_director_ttl_value,
11365 		(void *)&cmd_flow_director_vlan,
11366 		(void *)&cmd_flow_director_vlan_value,
11367 		(void *)&cmd_flow_director_flexbytes,
11368 		(void *)&cmd_flow_director_flexbytes_value,
11369 		(void *)&cmd_flow_director_drop,
11370 		(void *)&cmd_flow_director_pf_vf,
11371 		(void *)&cmd_flow_director_queue,
11372 		(void *)&cmd_flow_director_queue_id,
11373 		(void *)&cmd_flow_director_fd_id,
11374 		(void *)&cmd_flow_director_fd_id_value,
11375 		NULL,
11376 	},
11377 };
11378 
11379 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11380 	.f = cmd_flow_director_filter_parsed,
11381 	.data = NULL,
11382 	.help_str = "flow_director_filter ... : Add or delete a sctp flow "
11383 		"director entry on NIC",
11384 	.tokens = {
11385 		(void *)&cmd_flow_director_filter,
11386 		(void *)&cmd_flow_director_port_id,
11387 		(void *)&cmd_flow_director_mode,
11388 		(void *)&cmd_flow_director_mode_ip,
11389 		(void *)&cmd_flow_director_ops,
11390 		(void *)&cmd_flow_director_flow,
11391 		(void *)&cmd_flow_director_flow_type,
11392 		(void *)&cmd_flow_director_src,
11393 		(void *)&cmd_flow_director_ip_src,
11394 		(void *)&cmd_flow_director_port_src,
11395 		(void *)&cmd_flow_director_dst,
11396 		(void *)&cmd_flow_director_ip_dst,
11397 		(void *)&cmd_flow_director_port_dst,
11398 		(void *)&cmd_flow_director_verify_tag,
11399 		(void *)&cmd_flow_director_verify_tag_value,
11400 		(void *)&cmd_flow_director_tos,
11401 		(void *)&cmd_flow_director_tos_value,
11402 		(void *)&cmd_flow_director_ttl,
11403 		(void *)&cmd_flow_director_ttl_value,
11404 		(void *)&cmd_flow_director_vlan,
11405 		(void *)&cmd_flow_director_vlan_value,
11406 		(void *)&cmd_flow_director_flexbytes,
11407 		(void *)&cmd_flow_director_flexbytes_value,
11408 		(void *)&cmd_flow_director_drop,
11409 		(void *)&cmd_flow_director_pf_vf,
11410 		(void *)&cmd_flow_director_queue,
11411 		(void *)&cmd_flow_director_queue_id,
11412 		(void *)&cmd_flow_director_fd_id,
11413 		(void *)&cmd_flow_director_fd_id_value,
11414 		NULL,
11415 	},
11416 };
11417 
11418 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11419 	.f = cmd_flow_director_filter_parsed,
11420 	.data = NULL,
11421 	.help_str = "flow_director_filter ... : Add or delete a L2 flow "
11422 		"director entry on NIC",
11423 	.tokens = {
11424 		(void *)&cmd_flow_director_filter,
11425 		(void *)&cmd_flow_director_port_id,
11426 		(void *)&cmd_flow_director_mode,
11427 		(void *)&cmd_flow_director_mode_ip,
11428 		(void *)&cmd_flow_director_ops,
11429 		(void *)&cmd_flow_director_flow,
11430 		(void *)&cmd_flow_director_flow_type,
11431 		(void *)&cmd_flow_director_ether,
11432 		(void *)&cmd_flow_director_ether_type,
11433 		(void *)&cmd_flow_director_flexbytes,
11434 		(void *)&cmd_flow_director_flexbytes_value,
11435 		(void *)&cmd_flow_director_drop,
11436 		(void *)&cmd_flow_director_pf_vf,
11437 		(void *)&cmd_flow_director_queue,
11438 		(void *)&cmd_flow_director_queue_id,
11439 		(void *)&cmd_flow_director_fd_id,
11440 		(void *)&cmd_flow_director_fd_id_value,
11441 		NULL,
11442 	},
11443 };
11444 
11445 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11446 	.f = cmd_flow_director_filter_parsed,
11447 	.data = NULL,
11448 	.help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11449 		"director entry on NIC",
11450 	.tokens = {
11451 		(void *)&cmd_flow_director_filter,
11452 		(void *)&cmd_flow_director_port_id,
11453 		(void *)&cmd_flow_director_mode,
11454 		(void *)&cmd_flow_director_mode_mac_vlan,
11455 		(void *)&cmd_flow_director_ops,
11456 		(void *)&cmd_flow_director_mac,
11457 		(void *)&cmd_flow_director_mac_addr,
11458 		(void *)&cmd_flow_director_vlan,
11459 		(void *)&cmd_flow_director_vlan_value,
11460 		(void *)&cmd_flow_director_flexbytes,
11461 		(void *)&cmd_flow_director_flexbytes_value,
11462 		(void *)&cmd_flow_director_drop,
11463 		(void *)&cmd_flow_director_queue,
11464 		(void *)&cmd_flow_director_queue_id,
11465 		(void *)&cmd_flow_director_fd_id,
11466 		(void *)&cmd_flow_director_fd_id_value,
11467 		NULL,
11468 	},
11469 };
11470 
11471 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11472 	.f = cmd_flow_director_filter_parsed,
11473 	.data = NULL,
11474 	.help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11475 		"director entry on NIC",
11476 	.tokens = {
11477 		(void *)&cmd_flow_director_filter,
11478 		(void *)&cmd_flow_director_port_id,
11479 		(void *)&cmd_flow_director_mode,
11480 		(void *)&cmd_flow_director_mode_tunnel,
11481 		(void *)&cmd_flow_director_ops,
11482 		(void *)&cmd_flow_director_mac,
11483 		(void *)&cmd_flow_director_mac_addr,
11484 		(void *)&cmd_flow_director_vlan,
11485 		(void *)&cmd_flow_director_vlan_value,
11486 		(void *)&cmd_flow_director_tunnel,
11487 		(void *)&cmd_flow_director_tunnel_type,
11488 		(void *)&cmd_flow_director_tunnel_id,
11489 		(void *)&cmd_flow_director_tunnel_id_value,
11490 		(void *)&cmd_flow_director_flexbytes,
11491 		(void *)&cmd_flow_director_flexbytes_value,
11492 		(void *)&cmd_flow_director_drop,
11493 		(void *)&cmd_flow_director_queue,
11494 		(void *)&cmd_flow_director_queue_id,
11495 		(void *)&cmd_flow_director_fd_id,
11496 		(void *)&cmd_flow_director_fd_id_value,
11497 		NULL,
11498 	},
11499 };
11500 
11501 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11502 	.f = cmd_flow_director_filter_parsed,
11503 	.data = NULL,
11504 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
11505 		"director entry on NIC",
11506 	.tokens = {
11507 		(void *)&cmd_flow_director_filter,
11508 		(void *)&cmd_flow_director_port_id,
11509 		(void *)&cmd_flow_director_mode,
11510 		(void *)&cmd_flow_director_mode_raw,
11511 		(void *)&cmd_flow_director_ops,
11512 		(void *)&cmd_flow_director_flow,
11513 		(void *)&cmd_flow_director_flow_type,
11514 		(void *)&cmd_flow_director_drop,
11515 		(void *)&cmd_flow_director_queue,
11516 		(void *)&cmd_flow_director_queue_id,
11517 		(void *)&cmd_flow_director_fd_id,
11518 		(void *)&cmd_flow_director_fd_id_value,
11519 		(void *)&cmd_flow_director_packet,
11520 		(void *)&cmd_flow_director_filepath,
11521 		NULL,
11522 	},
11523 };
11524 
11525 struct cmd_flush_flow_director_result {
11526 	cmdline_fixed_string_t flush_flow_director;
11527 	portid_t port_id;
11528 };
11529 
11530 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11531 	TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11532 				 flush_flow_director, "flush_flow_director");
11533 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11534 	TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11535 			      port_id, UINT16);
11536 
11537 static void
11538 cmd_flush_flow_director_parsed(void *parsed_result,
11539 			  __attribute__((unused)) struct cmdline *cl,
11540 			  __attribute__((unused)) void *data)
11541 {
11542 	struct cmd_flow_director_result *res = parsed_result;
11543 	int ret = 0;
11544 
11545 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11546 	if (ret < 0) {
11547 		printf("flow director is not supported on port %u.\n",
11548 			res->port_id);
11549 		return;
11550 	}
11551 
11552 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11553 			RTE_ETH_FILTER_FLUSH, NULL);
11554 	if (ret < 0)
11555 		printf("flow director table flushing error: (%s)\n",
11556 			strerror(-ret));
11557 }
11558 
11559 cmdline_parse_inst_t cmd_flush_flow_director = {
11560 	.f = cmd_flush_flow_director_parsed,
11561 	.data = NULL,
11562 	.help_str = "flush_flow_director <port_id>: "
11563 		"Flush all flow director entries of a device on NIC",
11564 	.tokens = {
11565 		(void *)&cmd_flush_flow_director_flush,
11566 		(void *)&cmd_flush_flow_director_port_id,
11567 		NULL,
11568 	},
11569 };
11570 
11571 /* *** deal with flow director mask *** */
11572 struct cmd_flow_director_mask_result {
11573 	cmdline_fixed_string_t flow_director_mask;
11574 	portid_t port_id;
11575 	cmdline_fixed_string_t mode;
11576 	cmdline_fixed_string_t mode_value;
11577 	cmdline_fixed_string_t vlan;
11578 	uint16_t vlan_mask;
11579 	cmdline_fixed_string_t src_mask;
11580 	cmdline_ipaddr_t ipv4_src;
11581 	cmdline_ipaddr_t ipv6_src;
11582 	uint16_t port_src;
11583 	cmdline_fixed_string_t dst_mask;
11584 	cmdline_ipaddr_t ipv4_dst;
11585 	cmdline_ipaddr_t ipv6_dst;
11586 	uint16_t port_dst;
11587 	cmdline_fixed_string_t mac;
11588 	uint8_t mac_addr_byte_mask;
11589 	cmdline_fixed_string_t tunnel_id;
11590 	uint32_t tunnel_id_mask;
11591 	cmdline_fixed_string_t tunnel_type;
11592 	uint8_t tunnel_type_mask;
11593 };
11594 
11595 static void
11596 cmd_flow_director_mask_parsed(void *parsed_result,
11597 			  __attribute__((unused)) struct cmdline *cl,
11598 			  __attribute__((unused)) void *data)
11599 {
11600 	struct cmd_flow_director_mask_result *res = parsed_result;
11601 	struct rte_eth_fdir_masks *mask;
11602 	struct rte_port *port;
11603 
11604 	port = &ports[res->port_id];
11605 	/** Check if the port is not started **/
11606 	if (port->port_status != RTE_PORT_STOPPED) {
11607 		printf("Please stop port %d first\n", res->port_id);
11608 		return;
11609 	}
11610 
11611 	mask = &port->dev_conf.fdir_conf.mask;
11612 
11613 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11614 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11615 			printf("Please set mode to MAC-VLAN.\n");
11616 			return;
11617 		}
11618 
11619 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11620 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11621 		if (strcmp(res->mode_value, "Tunnel")) {
11622 			printf("Please set mode to Tunnel.\n");
11623 			return;
11624 		}
11625 
11626 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11627 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11628 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11629 		mask->tunnel_type_mask = res->tunnel_type_mask;
11630 	} else {
11631 		if (strcmp(res->mode_value, "IP")) {
11632 			printf("Please set mode to IP.\n");
11633 			return;
11634 		}
11635 
11636 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11637 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11638 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11639 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11640 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11641 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11642 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11643 	}
11644 
11645 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11646 }
11647 
11648 cmdline_parse_token_string_t cmd_flow_director_mask =
11649 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11650 				 flow_director_mask, "flow_director_mask");
11651 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11652 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11653 			      port_id, UINT16);
11654 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11655 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11656 				 vlan, "vlan");
11657 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11658 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11659 			      vlan_mask, UINT16);
11660 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11661 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11662 				 src_mask, "src_mask");
11663 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11664 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11665 				 ipv4_src);
11666 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11667 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11668 				 ipv6_src);
11669 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11670 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11671 			      port_src, UINT16);
11672 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11673 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11674 				 dst_mask, "dst_mask");
11675 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11676 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11677 				 ipv4_dst);
11678 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11679 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11680 				 ipv6_dst);
11681 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11682 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11683 			      port_dst, UINT16);
11684 
11685 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11686 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11687 				 mode, "mode");
11688 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11689 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11690 				 mode_value, "IP");
11691 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11692 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11693 				 mode_value, "MAC-VLAN");
11694 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11695 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11696 				 mode_value, "Tunnel");
11697 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11698 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11699 				 mac, "mac");
11700 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11701 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11702 			      mac_addr_byte_mask, UINT8);
11703 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11704 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11705 				 tunnel_type, "tunnel-type");
11706 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11707 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11708 			      tunnel_type_mask, UINT8);
11709 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11710 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11711 				 tunnel_id, "tunnel-id");
11712 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11713 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11714 			      tunnel_id_mask, UINT32);
11715 
11716 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11717 	.f = cmd_flow_director_mask_parsed,
11718 	.data = NULL,
11719 	.help_str = "flow_director_mask ... : "
11720 		"Set IP mode flow director's mask on NIC",
11721 	.tokens = {
11722 		(void *)&cmd_flow_director_mask,
11723 		(void *)&cmd_flow_director_mask_port_id,
11724 		(void *)&cmd_flow_director_mask_mode,
11725 		(void *)&cmd_flow_director_mask_mode_ip,
11726 		(void *)&cmd_flow_director_mask_vlan,
11727 		(void *)&cmd_flow_director_mask_vlan_value,
11728 		(void *)&cmd_flow_director_mask_src,
11729 		(void *)&cmd_flow_director_mask_ipv4_src,
11730 		(void *)&cmd_flow_director_mask_ipv6_src,
11731 		(void *)&cmd_flow_director_mask_port_src,
11732 		(void *)&cmd_flow_director_mask_dst,
11733 		(void *)&cmd_flow_director_mask_ipv4_dst,
11734 		(void *)&cmd_flow_director_mask_ipv6_dst,
11735 		(void *)&cmd_flow_director_mask_port_dst,
11736 		NULL,
11737 	},
11738 };
11739 
11740 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11741 	.f = cmd_flow_director_mask_parsed,
11742 	.data = NULL,
11743 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
11744 		"flow director's mask on NIC",
11745 	.tokens = {
11746 		(void *)&cmd_flow_director_mask,
11747 		(void *)&cmd_flow_director_mask_port_id,
11748 		(void *)&cmd_flow_director_mask_mode,
11749 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
11750 		(void *)&cmd_flow_director_mask_vlan,
11751 		(void *)&cmd_flow_director_mask_vlan_value,
11752 		NULL,
11753 	},
11754 };
11755 
11756 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11757 	.f = cmd_flow_director_mask_parsed,
11758 	.data = NULL,
11759 	.help_str = "flow_director_mask ... : Set tunnel mode "
11760 		"flow director's mask on NIC",
11761 	.tokens = {
11762 		(void *)&cmd_flow_director_mask,
11763 		(void *)&cmd_flow_director_mask_port_id,
11764 		(void *)&cmd_flow_director_mask_mode,
11765 		(void *)&cmd_flow_director_mask_mode_tunnel,
11766 		(void *)&cmd_flow_director_mask_vlan,
11767 		(void *)&cmd_flow_director_mask_vlan_value,
11768 		(void *)&cmd_flow_director_mask_mac,
11769 		(void *)&cmd_flow_director_mask_mac_value,
11770 		(void *)&cmd_flow_director_mask_tunnel_type,
11771 		(void *)&cmd_flow_director_mask_tunnel_type_value,
11772 		(void *)&cmd_flow_director_mask_tunnel_id,
11773 		(void *)&cmd_flow_director_mask_tunnel_id_value,
11774 		NULL,
11775 	},
11776 };
11777 
11778 /* *** deal with flow director mask on flexible payload *** */
11779 struct cmd_flow_director_flex_mask_result {
11780 	cmdline_fixed_string_t flow_director_flexmask;
11781 	portid_t port_id;
11782 	cmdline_fixed_string_t flow;
11783 	cmdline_fixed_string_t flow_type;
11784 	cmdline_fixed_string_t mask;
11785 };
11786 
11787 static void
11788 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11789 			  __attribute__((unused)) struct cmdline *cl,
11790 			  __attribute__((unused)) void *data)
11791 {
11792 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
11793 	struct rte_eth_fdir_info fdir_info;
11794 	struct rte_eth_fdir_flex_mask flex_mask;
11795 	struct rte_port *port;
11796 	uint64_t flow_type_mask;
11797 	uint16_t i;
11798 	int ret;
11799 
11800 	port = &ports[res->port_id];
11801 	/** Check if the port is not started **/
11802 	if (port->port_status != RTE_PORT_STOPPED) {
11803 		printf("Please stop port %d first\n", res->port_id);
11804 		return;
11805 	}
11806 
11807 	memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11808 	ret = parse_flexbytes(res->mask,
11809 			flex_mask.mask,
11810 			RTE_ETH_FDIR_MAX_FLEXLEN);
11811 	if (ret < 0) {
11812 		printf("error: Cannot parse mask input.\n");
11813 		return;
11814 	}
11815 
11816 	memset(&fdir_info, 0, sizeof(fdir_info));
11817 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11818 				RTE_ETH_FILTER_INFO, &fdir_info);
11819 	if (ret < 0) {
11820 		printf("Cannot get FDir filter info\n");
11821 		return;
11822 	}
11823 
11824 	if (!strcmp(res->flow_type, "none")) {
11825 		/* means don't specify the flow type */
11826 		flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11827 		for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11828 			memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11829 			       0, sizeof(struct rte_eth_fdir_flex_mask));
11830 		port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11831 		rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11832 				 &flex_mask,
11833 				 sizeof(struct rte_eth_fdir_flex_mask));
11834 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11835 		return;
11836 	}
11837 	flow_type_mask = fdir_info.flow_types_mask[0];
11838 	if (!strcmp(res->flow_type, "all")) {
11839 		if (!flow_type_mask) {
11840 			printf("No flow type supported\n");
11841 			return;
11842 		}
11843 		for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11844 			if (flow_type_mask & (1ULL << i)) {
11845 				flex_mask.flow_type = i;
11846 				fdir_set_flex_mask(res->port_id, &flex_mask);
11847 			}
11848 		}
11849 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11850 		return;
11851 	}
11852 	flex_mask.flow_type = str2flowtype(res->flow_type);
11853 	if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11854 		printf("Flow type %s not supported on port %d\n",
11855 				res->flow_type, res->port_id);
11856 		return;
11857 	}
11858 	fdir_set_flex_mask(res->port_id, &flex_mask);
11859 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11860 }
11861 
11862 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11863 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11864 				 flow_director_flexmask,
11865 				 "flow_director_flex_mask");
11866 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11867 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11868 			      port_id, UINT16);
11869 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11870 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11871 				 flow, "flow");
11872 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11873 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11874 		flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11875 		"ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11876 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11877 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11878 				 mask, NULL);
11879 
11880 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11881 	.f = cmd_flow_director_flex_mask_parsed,
11882 	.data = NULL,
11883 	.help_str = "flow_director_flex_mask ... : "
11884 		"Set flow director's flex mask on NIC",
11885 	.tokens = {
11886 		(void *)&cmd_flow_director_flexmask,
11887 		(void *)&cmd_flow_director_flexmask_port_id,
11888 		(void *)&cmd_flow_director_flexmask_flow,
11889 		(void *)&cmd_flow_director_flexmask_flow_type,
11890 		(void *)&cmd_flow_director_flexmask_mask,
11891 		NULL,
11892 	},
11893 };
11894 
11895 /* *** deal with flow director flexible payload configuration *** */
11896 struct cmd_flow_director_flexpayload_result {
11897 	cmdline_fixed_string_t flow_director_flexpayload;
11898 	portid_t port_id;
11899 	cmdline_fixed_string_t payload_layer;
11900 	cmdline_fixed_string_t payload_cfg;
11901 };
11902 
11903 static inline int
11904 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11905 {
11906 	char s[256];
11907 	const char *p, *p0 = q_arg;
11908 	char *end;
11909 	unsigned long int_fld;
11910 	char *str_fld[max_num];
11911 	int i;
11912 	unsigned size;
11913 	int ret = -1;
11914 
11915 	p = strchr(p0, '(');
11916 	if (p == NULL)
11917 		return -1;
11918 	++p;
11919 	p0 = strchr(p, ')');
11920 	if (p0 == NULL)
11921 		return -1;
11922 
11923 	size = p0 - p;
11924 	if (size >= sizeof(s))
11925 		return -1;
11926 
11927 	snprintf(s, sizeof(s), "%.*s", size, p);
11928 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11929 	if (ret < 0 || ret > max_num)
11930 		return -1;
11931 	for (i = 0; i < ret; i++) {
11932 		errno = 0;
11933 		int_fld = strtoul(str_fld[i], &end, 0);
11934 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11935 			return -1;
11936 		offsets[i] = (uint16_t)int_fld;
11937 	}
11938 	return ret;
11939 }
11940 
11941 static void
11942 cmd_flow_director_flxpld_parsed(void *parsed_result,
11943 			  __attribute__((unused)) struct cmdline *cl,
11944 			  __attribute__((unused)) void *data)
11945 {
11946 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
11947 	struct rte_eth_flex_payload_cfg flex_cfg;
11948 	struct rte_port *port;
11949 	int ret = 0;
11950 
11951 	port = &ports[res->port_id];
11952 	/** Check if the port is not started **/
11953 	if (port->port_status != RTE_PORT_STOPPED) {
11954 		printf("Please stop port %d first\n", res->port_id);
11955 		return;
11956 	}
11957 
11958 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11959 
11960 	if (!strcmp(res->payload_layer, "raw"))
11961 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11962 	else if (!strcmp(res->payload_layer, "l2"))
11963 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11964 	else if (!strcmp(res->payload_layer, "l3"))
11965 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11966 	else if (!strcmp(res->payload_layer, "l4"))
11967 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11968 
11969 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11970 			    RTE_ETH_FDIR_MAX_FLEXLEN);
11971 	if (ret < 0) {
11972 		printf("error: Cannot parse flex payload input.\n");
11973 		return;
11974 	}
11975 
11976 	fdir_set_flex_payload(res->port_id, &flex_cfg);
11977 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11978 }
11979 
11980 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11981 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11982 				 flow_director_flexpayload,
11983 				 "flow_director_flex_payload");
11984 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11985 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11986 			      port_id, UINT16);
11987 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11988 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11989 				 payload_layer, "raw#l2#l3#l4");
11990 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11991 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11992 				 payload_cfg, NULL);
11993 
11994 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11995 	.f = cmd_flow_director_flxpld_parsed,
11996 	.data = NULL,
11997 	.help_str = "flow_director_flexpayload ... : "
11998 		"Set flow director's flex payload on NIC",
11999 	.tokens = {
12000 		(void *)&cmd_flow_director_flexpayload,
12001 		(void *)&cmd_flow_director_flexpayload_port_id,
12002 		(void *)&cmd_flow_director_flexpayload_payload_layer,
12003 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
12004 		NULL,
12005 	},
12006 };
12007 
12008 /* Generic flow interface command. */
12009 extern cmdline_parse_inst_t cmd_flow;
12010 
12011 /* *** Classification Filters Control *** */
12012 /* *** Get symmetric hash enable per port *** */
12013 struct cmd_get_sym_hash_ena_per_port_result {
12014 	cmdline_fixed_string_t get_sym_hash_ena_per_port;
12015 	portid_t port_id;
12016 };
12017 
12018 static void
12019 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12020 				 __rte_unused struct cmdline *cl,
12021 				 __rte_unused void *data)
12022 {
12023 	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12024 	struct rte_eth_hash_filter_info info;
12025 	int ret;
12026 
12027 	if (rte_eth_dev_filter_supported(res->port_id,
12028 				RTE_ETH_FILTER_HASH) < 0) {
12029 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12030 							res->port_id);
12031 		return;
12032 	}
12033 
12034 	memset(&info, 0, sizeof(info));
12035 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12036 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12037 						RTE_ETH_FILTER_GET, &info);
12038 
12039 	if (ret < 0) {
12040 		printf("Cannot get symmetric hash enable per port "
12041 					"on port %u\n", res->port_id);
12042 		return;
12043 	}
12044 
12045 	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12046 				"enabled" : "disabled", res->port_id);
12047 }
12048 
12049 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12050 	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12051 		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12052 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12053 	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12054 		port_id, UINT16);
12055 
12056 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12057 	.f = cmd_get_sym_hash_per_port_parsed,
12058 	.data = NULL,
12059 	.help_str = "get_sym_hash_ena_per_port <port_id>",
12060 	.tokens = {
12061 		(void *)&cmd_get_sym_hash_ena_per_port_all,
12062 		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
12063 		NULL,
12064 	},
12065 };
12066 
12067 /* *** Set symmetric hash enable per port *** */
12068 struct cmd_set_sym_hash_ena_per_port_result {
12069 	cmdline_fixed_string_t set_sym_hash_ena_per_port;
12070 	cmdline_fixed_string_t enable;
12071 	portid_t port_id;
12072 };
12073 
12074 static void
12075 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12076 				 __rte_unused struct cmdline *cl,
12077 				 __rte_unused void *data)
12078 {
12079 	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12080 	struct rte_eth_hash_filter_info info;
12081 	int ret;
12082 
12083 	if (rte_eth_dev_filter_supported(res->port_id,
12084 				RTE_ETH_FILTER_HASH) < 0) {
12085 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12086 							res->port_id);
12087 		return;
12088 	}
12089 
12090 	memset(&info, 0, sizeof(info));
12091 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12092 	if (!strcmp(res->enable, "enable"))
12093 		info.info.enable = 1;
12094 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12095 					RTE_ETH_FILTER_SET, &info);
12096 	if (ret < 0) {
12097 		printf("Cannot set symmetric hash enable per port on "
12098 					"port %u\n", res->port_id);
12099 		return;
12100 	}
12101 	printf("Symmetric hash has been set to %s on port %u\n",
12102 					res->enable, res->port_id);
12103 }
12104 
12105 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12106 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12107 		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12108 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12109 	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12110 		port_id, UINT16);
12111 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12112 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12113 		enable, "enable#disable");
12114 
12115 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12116 	.f = cmd_set_sym_hash_per_port_parsed,
12117 	.data = NULL,
12118 	.help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12119 	.tokens = {
12120 		(void *)&cmd_set_sym_hash_ena_per_port_all,
12121 		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
12122 		(void *)&cmd_set_sym_hash_ena_per_port_enable,
12123 		NULL,
12124 	},
12125 };
12126 
12127 /* Get global config of hash function */
12128 struct cmd_get_hash_global_config_result {
12129 	cmdline_fixed_string_t get_hash_global_config;
12130 	portid_t port_id;
12131 };
12132 
12133 static char *
12134 flowtype_to_str(uint16_t ftype)
12135 {
12136 	uint16_t i;
12137 	static struct {
12138 		char str[16];
12139 		uint16_t ftype;
12140 	} ftype_table[] = {
12141 		{"ipv4", RTE_ETH_FLOW_IPV4},
12142 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12143 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12144 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12145 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12146 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12147 		{"ipv6", RTE_ETH_FLOW_IPV6},
12148 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12149 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12150 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12151 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12152 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12153 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12154 		{"port", RTE_ETH_FLOW_PORT},
12155 		{"vxlan", RTE_ETH_FLOW_VXLAN},
12156 		{"geneve", RTE_ETH_FLOW_GENEVE},
12157 		{"nvgre", RTE_ETH_FLOW_NVGRE},
12158 		{"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12159 	};
12160 
12161 	for (i = 0; i < RTE_DIM(ftype_table); i++) {
12162 		if (ftype_table[i].ftype == ftype)
12163 			return ftype_table[i].str;
12164 	}
12165 
12166 	return NULL;
12167 }
12168 
12169 static void
12170 cmd_get_hash_global_config_parsed(void *parsed_result,
12171 				  __rte_unused struct cmdline *cl,
12172 				  __rte_unused void *data)
12173 {
12174 	struct cmd_get_hash_global_config_result *res = parsed_result;
12175 	struct rte_eth_hash_filter_info info;
12176 	uint32_t idx, offset;
12177 	uint16_t i;
12178 	char *str;
12179 	int ret;
12180 
12181 	if (rte_eth_dev_filter_supported(res->port_id,
12182 			RTE_ETH_FILTER_HASH) < 0) {
12183 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12184 							res->port_id);
12185 		return;
12186 	}
12187 
12188 	memset(&info, 0, sizeof(info));
12189 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12190 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12191 					RTE_ETH_FILTER_GET, &info);
12192 	if (ret < 0) {
12193 		printf("Cannot get hash global configurations by port %d\n",
12194 							res->port_id);
12195 		return;
12196 	}
12197 
12198 	switch (info.info.global_conf.hash_func) {
12199 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12200 		printf("Hash function is Toeplitz\n");
12201 		break;
12202 	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12203 		printf("Hash function is Simple XOR\n");
12204 		break;
12205 	default:
12206 		printf("Unknown hash function\n");
12207 		break;
12208 	}
12209 
12210 	for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12211 		idx = i / UINT64_BIT;
12212 		offset = i % UINT64_BIT;
12213 		if (!(info.info.global_conf.valid_bit_mask[idx] &
12214 						(1ULL << offset)))
12215 			continue;
12216 		str = flowtype_to_str(i);
12217 		if (!str)
12218 			continue;
12219 		printf("Symmetric hash is %s globally for flow type %s "
12220 							"by port %d\n",
12221 			((info.info.global_conf.sym_hash_enable_mask[idx] &
12222 			(1ULL << offset)) ? "enabled" : "disabled"), str,
12223 							res->port_id);
12224 	}
12225 }
12226 
12227 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12228 	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12229 		get_hash_global_config, "get_hash_global_config");
12230 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12231 	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12232 		port_id, UINT16);
12233 
12234 cmdline_parse_inst_t cmd_get_hash_global_config = {
12235 	.f = cmd_get_hash_global_config_parsed,
12236 	.data = NULL,
12237 	.help_str = "get_hash_global_config <port_id>",
12238 	.tokens = {
12239 		(void *)&cmd_get_hash_global_config_all,
12240 		(void *)&cmd_get_hash_global_config_port_id,
12241 		NULL,
12242 	},
12243 };
12244 
12245 /* Set global config of hash function */
12246 struct cmd_set_hash_global_config_result {
12247 	cmdline_fixed_string_t set_hash_global_config;
12248 	portid_t port_id;
12249 	cmdline_fixed_string_t hash_func;
12250 	cmdline_fixed_string_t flow_type;
12251 	cmdline_fixed_string_t enable;
12252 };
12253 
12254 static void
12255 cmd_set_hash_global_config_parsed(void *parsed_result,
12256 				  __rte_unused struct cmdline *cl,
12257 				  __rte_unused void *data)
12258 {
12259 	struct cmd_set_hash_global_config_result *res = parsed_result;
12260 	struct rte_eth_hash_filter_info info;
12261 	uint32_t ftype, idx, offset;
12262 	int ret;
12263 
12264 	if (rte_eth_dev_filter_supported(res->port_id,
12265 				RTE_ETH_FILTER_HASH) < 0) {
12266 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12267 							res->port_id);
12268 		return;
12269 	}
12270 	memset(&info, 0, sizeof(info));
12271 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12272 	if (!strcmp(res->hash_func, "toeplitz"))
12273 		info.info.global_conf.hash_func =
12274 			RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12275 	else if (!strcmp(res->hash_func, "simple_xor"))
12276 		info.info.global_conf.hash_func =
12277 			RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12278 	else if (!strcmp(res->hash_func, "default"))
12279 		info.info.global_conf.hash_func =
12280 			RTE_ETH_HASH_FUNCTION_DEFAULT;
12281 
12282 	ftype = str2flowtype(res->flow_type);
12283 	idx = ftype / UINT64_BIT;
12284 	offset = ftype % UINT64_BIT;
12285 	info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12286 	if (!strcmp(res->enable, "enable"))
12287 		info.info.global_conf.sym_hash_enable_mask[idx] |=
12288 						(1ULL << offset);
12289 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12290 					RTE_ETH_FILTER_SET, &info);
12291 	if (ret < 0)
12292 		printf("Cannot set global hash configurations by port %d\n",
12293 							res->port_id);
12294 	else
12295 		printf("Global hash configurations have been set "
12296 			"successfully by port %d\n", res->port_id);
12297 }
12298 
12299 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12300 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12301 		set_hash_global_config, "set_hash_global_config");
12302 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12303 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12304 		port_id, UINT16);
12305 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12306 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12307 		hash_func, "toeplitz#simple_xor#default");
12308 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12309 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12310 		flow_type,
12311 		"ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12312 		"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12313 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12314 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12315 		enable, "enable#disable");
12316 
12317 cmdline_parse_inst_t cmd_set_hash_global_config = {
12318 	.f = cmd_set_hash_global_config_parsed,
12319 	.data = NULL,
12320 	.help_str = "set_hash_global_config <port_id> "
12321 		"toeplitz|simple_xor|default "
12322 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12323 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12324 		"l2_payload enable|disable",
12325 	.tokens = {
12326 		(void *)&cmd_set_hash_global_config_all,
12327 		(void *)&cmd_set_hash_global_config_port_id,
12328 		(void *)&cmd_set_hash_global_config_hash_func,
12329 		(void *)&cmd_set_hash_global_config_flow_type,
12330 		(void *)&cmd_set_hash_global_config_enable,
12331 		NULL,
12332 	},
12333 };
12334 
12335 /* Set hash input set */
12336 struct cmd_set_hash_input_set_result {
12337 	cmdline_fixed_string_t set_hash_input_set;
12338 	portid_t port_id;
12339 	cmdline_fixed_string_t flow_type;
12340 	cmdline_fixed_string_t inset_field;
12341 	cmdline_fixed_string_t select;
12342 };
12343 
12344 static enum rte_eth_input_set_field
12345 str2inset(char *string)
12346 {
12347 	uint16_t i;
12348 
12349 	static const struct {
12350 		char str[32];
12351 		enum rte_eth_input_set_field inset;
12352 	} inset_table[] = {
12353 		{"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12354 		{"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12355 		{"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12356 		{"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12357 		{"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12358 		{"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12359 		{"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12360 		{"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12361 		{"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12362 		{"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12363 		{"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12364 		{"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12365 		{"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12366 		{"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12367 		{"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12368 		{"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12369 		{"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12370 		{"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12371 		{"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12372 		{"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12373 		{"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12374 		{"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12375 		{"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12376 		{"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12377 		{"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12378 		{"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12379 		{"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12380 		{"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12381 		{"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12382 		{"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12383 		{"none", RTE_ETH_INPUT_SET_NONE},
12384 	};
12385 
12386 	for (i = 0; i < RTE_DIM(inset_table); i++) {
12387 		if (!strcmp(string, inset_table[i].str))
12388 			return inset_table[i].inset;
12389 	}
12390 
12391 	return RTE_ETH_INPUT_SET_UNKNOWN;
12392 }
12393 
12394 static void
12395 cmd_set_hash_input_set_parsed(void *parsed_result,
12396 			      __rte_unused struct cmdline *cl,
12397 			      __rte_unused void *data)
12398 {
12399 	struct cmd_set_hash_input_set_result *res = parsed_result;
12400 	struct rte_eth_hash_filter_info info;
12401 
12402 	memset(&info, 0, sizeof(info));
12403 	info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12404 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12405 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12406 	info.info.input_set_conf.inset_size = 1;
12407 	if (!strcmp(res->select, "select"))
12408 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12409 	else if (!strcmp(res->select, "add"))
12410 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12411 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12412 				RTE_ETH_FILTER_SET, &info);
12413 }
12414 
12415 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12416 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12417 		set_hash_input_set, "set_hash_input_set");
12418 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12419 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12420 		port_id, UINT16);
12421 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12422 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12423 		flow_type, NULL);
12424 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12425 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12426 		inset_field,
12427 		"ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12428 		"ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12429 		"udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12430 		"sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12431 		"fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12432 		"fld-8th#none");
12433 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12434 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12435 		select, "select#add");
12436 
12437 cmdline_parse_inst_t cmd_set_hash_input_set = {
12438 	.f = cmd_set_hash_input_set_parsed,
12439 	.data = NULL,
12440 	.help_str = "set_hash_input_set <port_id> "
12441 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12442 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12443 	"ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12444 	"ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12445 	"tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12446 	"gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12447 	"fld-7th|fld-8th|none select|add",
12448 	.tokens = {
12449 		(void *)&cmd_set_hash_input_set_cmd,
12450 		(void *)&cmd_set_hash_input_set_port_id,
12451 		(void *)&cmd_set_hash_input_set_flow_type,
12452 		(void *)&cmd_set_hash_input_set_field,
12453 		(void *)&cmd_set_hash_input_set_select,
12454 		NULL,
12455 	},
12456 };
12457 
12458 /* Set flow director input set */
12459 struct cmd_set_fdir_input_set_result {
12460 	cmdline_fixed_string_t set_fdir_input_set;
12461 	portid_t port_id;
12462 	cmdline_fixed_string_t flow_type;
12463 	cmdline_fixed_string_t inset_field;
12464 	cmdline_fixed_string_t select;
12465 };
12466 
12467 static void
12468 cmd_set_fdir_input_set_parsed(void *parsed_result,
12469 	__rte_unused struct cmdline *cl,
12470 	__rte_unused void *data)
12471 {
12472 	struct cmd_set_fdir_input_set_result *res = parsed_result;
12473 	struct rte_eth_fdir_filter_info info;
12474 
12475 	memset(&info, 0, sizeof(info));
12476 	info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12477 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12478 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12479 	info.info.input_set_conf.inset_size = 1;
12480 	if (!strcmp(res->select, "select"))
12481 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12482 	else if (!strcmp(res->select, "add"))
12483 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12484 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12485 		RTE_ETH_FILTER_SET, &info);
12486 }
12487 
12488 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12489 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12490 	set_fdir_input_set, "set_fdir_input_set");
12491 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12492 	TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12493 	port_id, UINT16);
12494 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12495 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12496 	flow_type,
12497 	"ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12498 	"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12499 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12500 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12501 	inset_field,
12502 	"ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12503 	"ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12504 	"ipv6-hop-limits#udp-src-port#udp-dst-port#"
12505 	"tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12506 	"sctp-veri-tag#none");
12507 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12508 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12509 	select, "select#add");
12510 
12511 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12512 	.f = cmd_set_fdir_input_set_parsed,
12513 	.data = NULL,
12514 	.help_str = "set_fdir_input_set <port_id> "
12515 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12516 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12517 	"ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12518 	"ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12519 	"ipv6-hop-limits|udp-src-port|udp-dst-port|"
12520 	"tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12521 	"sctp-veri-tag|none select|add",
12522 	.tokens = {
12523 		(void *)&cmd_set_fdir_input_set_cmd,
12524 		(void *)&cmd_set_fdir_input_set_port_id,
12525 		(void *)&cmd_set_fdir_input_set_flow_type,
12526 		(void *)&cmd_set_fdir_input_set_field,
12527 		(void *)&cmd_set_fdir_input_set_select,
12528 		NULL,
12529 	},
12530 };
12531 
12532 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12533 struct cmd_mcast_addr_result {
12534 	cmdline_fixed_string_t mcast_addr_cmd;
12535 	cmdline_fixed_string_t what;
12536 	uint16_t port_num;
12537 	struct rte_ether_addr mc_addr;
12538 };
12539 
12540 static void cmd_mcast_addr_parsed(void *parsed_result,
12541 		__attribute__((unused)) struct cmdline *cl,
12542 		__attribute__((unused)) void *data)
12543 {
12544 	struct cmd_mcast_addr_result *res = parsed_result;
12545 
12546 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12547 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12548 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12549 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12550 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12551 		return;
12552 	}
12553 	if (strcmp(res->what, "add") == 0)
12554 		mcast_addr_add(res->port_num, &res->mc_addr);
12555 	else
12556 		mcast_addr_remove(res->port_num, &res->mc_addr);
12557 }
12558 
12559 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12560 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12561 				 mcast_addr_cmd, "mcast_addr");
12562 cmdline_parse_token_string_t cmd_mcast_addr_what =
12563 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12564 				 "add#remove");
12565 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12566 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12567 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12568 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12569 
12570 cmdline_parse_inst_t cmd_mcast_addr = {
12571 	.f = cmd_mcast_addr_parsed,
12572 	.data = (void *)0,
12573 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12574 		"Add/Remove multicast MAC address on port_id",
12575 	.tokens = {
12576 		(void *)&cmd_mcast_addr_cmd,
12577 		(void *)&cmd_mcast_addr_what,
12578 		(void *)&cmd_mcast_addr_portnum,
12579 		(void *)&cmd_mcast_addr_addr,
12580 		NULL,
12581 	},
12582 };
12583 
12584 /* l2 tunnel config
12585  * only support E-tag now.
12586  */
12587 
12588 /* Ether type config */
12589 struct cmd_config_l2_tunnel_eth_type_result {
12590 	cmdline_fixed_string_t port;
12591 	cmdline_fixed_string_t config;
12592 	cmdline_fixed_string_t all;
12593 	portid_t id;
12594 	cmdline_fixed_string_t l2_tunnel;
12595 	cmdline_fixed_string_t l2_tunnel_type;
12596 	cmdline_fixed_string_t eth_type;
12597 	uint16_t eth_type_val;
12598 };
12599 
12600 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12601 	TOKEN_STRING_INITIALIZER
12602 		(struct cmd_config_l2_tunnel_eth_type_result,
12603 		 port, "port");
12604 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12605 	TOKEN_STRING_INITIALIZER
12606 		(struct cmd_config_l2_tunnel_eth_type_result,
12607 		 config, "config");
12608 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12609 	TOKEN_STRING_INITIALIZER
12610 		(struct cmd_config_l2_tunnel_eth_type_result,
12611 		 all, "all");
12612 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12613 	TOKEN_NUM_INITIALIZER
12614 		(struct cmd_config_l2_tunnel_eth_type_result,
12615 		 id, UINT16);
12616 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12617 	TOKEN_STRING_INITIALIZER
12618 		(struct cmd_config_l2_tunnel_eth_type_result,
12619 		 l2_tunnel, "l2-tunnel");
12620 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12621 	TOKEN_STRING_INITIALIZER
12622 		(struct cmd_config_l2_tunnel_eth_type_result,
12623 		 l2_tunnel_type, "E-tag");
12624 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12625 	TOKEN_STRING_INITIALIZER
12626 		(struct cmd_config_l2_tunnel_eth_type_result,
12627 		 eth_type, "ether-type");
12628 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12629 	TOKEN_NUM_INITIALIZER
12630 		(struct cmd_config_l2_tunnel_eth_type_result,
12631 		 eth_type_val, UINT16);
12632 
12633 static enum rte_eth_tunnel_type
12634 str2fdir_l2_tunnel_type(char *string)
12635 {
12636 	uint32_t i = 0;
12637 
12638 	static const struct {
12639 		char str[32];
12640 		enum rte_eth_tunnel_type type;
12641 	} l2_tunnel_type_str[] = {
12642 		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12643 	};
12644 
12645 	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12646 		if (!strcmp(l2_tunnel_type_str[i].str, string))
12647 			return l2_tunnel_type_str[i].type;
12648 	}
12649 	return RTE_TUNNEL_TYPE_NONE;
12650 }
12651 
12652 /* ether type config for all ports */
12653 static void
12654 cmd_config_l2_tunnel_eth_type_all_parsed
12655 	(void *parsed_result,
12656 	 __attribute__((unused)) struct cmdline *cl,
12657 	 __attribute__((unused)) void *data)
12658 {
12659 	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12660 	struct rte_eth_l2_tunnel_conf entry;
12661 	portid_t pid;
12662 
12663 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12664 	entry.ether_type = res->eth_type_val;
12665 
12666 	RTE_ETH_FOREACH_DEV(pid) {
12667 		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12668 	}
12669 }
12670 
12671 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12672 	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
12673 	.data = NULL,
12674 	.help_str = "port config all l2-tunnel E-tag ether-type <value>",
12675 	.tokens = {
12676 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12677 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12678 		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
12679 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12680 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12681 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12682 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12683 		NULL,
12684 	},
12685 };
12686 
12687 /* ether type config for a specific port */
12688 static void
12689 cmd_config_l2_tunnel_eth_type_specific_parsed(
12690 	void *parsed_result,
12691 	__attribute__((unused)) struct cmdline *cl,
12692 	__attribute__((unused)) void *data)
12693 {
12694 	struct cmd_config_l2_tunnel_eth_type_result *res =
12695 		 parsed_result;
12696 	struct rte_eth_l2_tunnel_conf entry;
12697 
12698 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12699 		return;
12700 
12701 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12702 	entry.ether_type = res->eth_type_val;
12703 
12704 	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12705 }
12706 
12707 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12708 	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12709 	.data = NULL,
12710 	.help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12711 	.tokens = {
12712 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12713 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12714 		(void *)&cmd_config_l2_tunnel_eth_type_id,
12715 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12716 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12717 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12718 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12719 		NULL,
12720 	},
12721 };
12722 
12723 /* Enable/disable l2 tunnel */
12724 struct cmd_config_l2_tunnel_en_dis_result {
12725 	cmdline_fixed_string_t port;
12726 	cmdline_fixed_string_t config;
12727 	cmdline_fixed_string_t all;
12728 	portid_t id;
12729 	cmdline_fixed_string_t l2_tunnel;
12730 	cmdline_fixed_string_t l2_tunnel_type;
12731 	cmdline_fixed_string_t en_dis;
12732 };
12733 
12734 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12735 	TOKEN_STRING_INITIALIZER
12736 		(struct cmd_config_l2_tunnel_en_dis_result,
12737 		 port, "port");
12738 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12739 	TOKEN_STRING_INITIALIZER
12740 		(struct cmd_config_l2_tunnel_en_dis_result,
12741 		 config, "config");
12742 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12743 	TOKEN_STRING_INITIALIZER
12744 		(struct cmd_config_l2_tunnel_en_dis_result,
12745 		 all, "all");
12746 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12747 	TOKEN_NUM_INITIALIZER
12748 		(struct cmd_config_l2_tunnel_en_dis_result,
12749 		 id, UINT16);
12750 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12751 	TOKEN_STRING_INITIALIZER
12752 		(struct cmd_config_l2_tunnel_en_dis_result,
12753 		 l2_tunnel, "l2-tunnel");
12754 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12755 	TOKEN_STRING_INITIALIZER
12756 		(struct cmd_config_l2_tunnel_en_dis_result,
12757 		 l2_tunnel_type, "E-tag");
12758 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12759 	TOKEN_STRING_INITIALIZER
12760 		(struct cmd_config_l2_tunnel_en_dis_result,
12761 		 en_dis, "enable#disable");
12762 
12763 /* enable/disable l2 tunnel for all ports */
12764 static void
12765 cmd_config_l2_tunnel_en_dis_all_parsed(
12766 	void *parsed_result,
12767 	__attribute__((unused)) struct cmdline *cl,
12768 	__attribute__((unused)) void *data)
12769 {
12770 	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12771 	struct rte_eth_l2_tunnel_conf entry;
12772 	portid_t pid;
12773 	uint8_t en;
12774 
12775 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12776 
12777 	if (!strcmp("enable", res->en_dis))
12778 		en = 1;
12779 	else
12780 		en = 0;
12781 
12782 	RTE_ETH_FOREACH_DEV(pid) {
12783 		rte_eth_dev_l2_tunnel_offload_set(pid,
12784 						  &entry,
12785 						  ETH_L2_TUNNEL_ENABLE_MASK,
12786 						  en);
12787 	}
12788 }
12789 
12790 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12791 	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
12792 	.data = NULL,
12793 	.help_str = "port config all l2-tunnel E-tag enable|disable",
12794 	.tokens = {
12795 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12796 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12797 		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
12798 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12799 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12800 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12801 		NULL,
12802 	},
12803 };
12804 
12805 /* enable/disable l2 tunnel for a port */
12806 static void
12807 cmd_config_l2_tunnel_en_dis_specific_parsed(
12808 	void *parsed_result,
12809 	__attribute__((unused)) struct cmdline *cl,
12810 	__attribute__((unused)) void *data)
12811 {
12812 	struct cmd_config_l2_tunnel_en_dis_result *res =
12813 		parsed_result;
12814 	struct rte_eth_l2_tunnel_conf entry;
12815 
12816 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12817 		return;
12818 
12819 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12820 
12821 	if (!strcmp("enable", res->en_dis))
12822 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12823 						  &entry,
12824 						  ETH_L2_TUNNEL_ENABLE_MASK,
12825 						  1);
12826 	else
12827 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12828 						  &entry,
12829 						  ETH_L2_TUNNEL_ENABLE_MASK,
12830 						  0);
12831 }
12832 
12833 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12834 	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12835 	.data = NULL,
12836 	.help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12837 	.tokens = {
12838 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12839 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12840 		(void *)&cmd_config_l2_tunnel_en_dis_id,
12841 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12842 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12843 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12844 		NULL,
12845 	},
12846 };
12847 
12848 /* E-tag configuration */
12849 
12850 /* Common result structure for all E-tag configuration */
12851 struct cmd_config_e_tag_result {
12852 	cmdline_fixed_string_t e_tag;
12853 	cmdline_fixed_string_t set;
12854 	cmdline_fixed_string_t insertion;
12855 	cmdline_fixed_string_t stripping;
12856 	cmdline_fixed_string_t forwarding;
12857 	cmdline_fixed_string_t filter;
12858 	cmdline_fixed_string_t add;
12859 	cmdline_fixed_string_t del;
12860 	cmdline_fixed_string_t on;
12861 	cmdline_fixed_string_t off;
12862 	cmdline_fixed_string_t on_off;
12863 	cmdline_fixed_string_t port_tag_id;
12864 	uint32_t port_tag_id_val;
12865 	cmdline_fixed_string_t e_tag_id;
12866 	uint16_t e_tag_id_val;
12867 	cmdline_fixed_string_t dst_pool;
12868 	uint8_t dst_pool_val;
12869 	cmdline_fixed_string_t port;
12870 	portid_t port_id;
12871 	cmdline_fixed_string_t vf;
12872 	uint8_t vf_id;
12873 };
12874 
12875 /* Common CLI fields for all E-tag configuration */
12876 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12877 	TOKEN_STRING_INITIALIZER
12878 		(struct cmd_config_e_tag_result,
12879 		 e_tag, "E-tag");
12880 cmdline_parse_token_string_t cmd_config_e_tag_set =
12881 	TOKEN_STRING_INITIALIZER
12882 		(struct cmd_config_e_tag_result,
12883 		 set, "set");
12884 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12885 	TOKEN_STRING_INITIALIZER
12886 		(struct cmd_config_e_tag_result,
12887 		 insertion, "insertion");
12888 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12889 	TOKEN_STRING_INITIALIZER
12890 		(struct cmd_config_e_tag_result,
12891 		 stripping, "stripping");
12892 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12893 	TOKEN_STRING_INITIALIZER
12894 		(struct cmd_config_e_tag_result,
12895 		 forwarding, "forwarding");
12896 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12897 	TOKEN_STRING_INITIALIZER
12898 		(struct cmd_config_e_tag_result,
12899 		 filter, "filter");
12900 cmdline_parse_token_string_t cmd_config_e_tag_add =
12901 	TOKEN_STRING_INITIALIZER
12902 		(struct cmd_config_e_tag_result,
12903 		 add, "add");
12904 cmdline_parse_token_string_t cmd_config_e_tag_del =
12905 	TOKEN_STRING_INITIALIZER
12906 		(struct cmd_config_e_tag_result,
12907 		 del, "del");
12908 cmdline_parse_token_string_t cmd_config_e_tag_on =
12909 	TOKEN_STRING_INITIALIZER
12910 		(struct cmd_config_e_tag_result,
12911 		 on, "on");
12912 cmdline_parse_token_string_t cmd_config_e_tag_off =
12913 	TOKEN_STRING_INITIALIZER
12914 		(struct cmd_config_e_tag_result,
12915 		 off, "off");
12916 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12917 	TOKEN_STRING_INITIALIZER
12918 		(struct cmd_config_e_tag_result,
12919 		 on_off, "on#off");
12920 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12921 	TOKEN_STRING_INITIALIZER
12922 		(struct cmd_config_e_tag_result,
12923 		 port_tag_id, "port-tag-id");
12924 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12925 	TOKEN_NUM_INITIALIZER
12926 		(struct cmd_config_e_tag_result,
12927 		 port_tag_id_val, UINT32);
12928 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12929 	TOKEN_STRING_INITIALIZER
12930 		(struct cmd_config_e_tag_result,
12931 		 e_tag_id, "e-tag-id");
12932 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12933 	TOKEN_NUM_INITIALIZER
12934 		(struct cmd_config_e_tag_result,
12935 		 e_tag_id_val, UINT16);
12936 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12937 	TOKEN_STRING_INITIALIZER
12938 		(struct cmd_config_e_tag_result,
12939 		 dst_pool, "dst-pool");
12940 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12941 	TOKEN_NUM_INITIALIZER
12942 		(struct cmd_config_e_tag_result,
12943 		 dst_pool_val, UINT8);
12944 cmdline_parse_token_string_t cmd_config_e_tag_port =
12945 	TOKEN_STRING_INITIALIZER
12946 		(struct cmd_config_e_tag_result,
12947 		 port, "port");
12948 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12949 	TOKEN_NUM_INITIALIZER
12950 		(struct cmd_config_e_tag_result,
12951 		 port_id, UINT16);
12952 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12953 	TOKEN_STRING_INITIALIZER
12954 		(struct cmd_config_e_tag_result,
12955 		 vf, "vf");
12956 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12957 	TOKEN_NUM_INITIALIZER
12958 		(struct cmd_config_e_tag_result,
12959 		 vf_id, UINT8);
12960 
12961 /* E-tag insertion configuration */
12962 static void
12963 cmd_config_e_tag_insertion_en_parsed(
12964 	void *parsed_result,
12965 	__attribute__((unused)) struct cmdline *cl,
12966 	__attribute__((unused)) void *data)
12967 {
12968 	struct cmd_config_e_tag_result *res =
12969 		parsed_result;
12970 	struct rte_eth_l2_tunnel_conf entry;
12971 
12972 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12973 		return;
12974 
12975 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12976 	entry.tunnel_id = res->port_tag_id_val;
12977 	entry.vf_id = res->vf_id;
12978 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12979 					  &entry,
12980 					  ETH_L2_TUNNEL_INSERTION_MASK,
12981 					  1);
12982 }
12983 
12984 static void
12985 cmd_config_e_tag_insertion_dis_parsed(
12986 	void *parsed_result,
12987 	__attribute__((unused)) struct cmdline *cl,
12988 	__attribute__((unused)) void *data)
12989 {
12990 	struct cmd_config_e_tag_result *res =
12991 		parsed_result;
12992 	struct rte_eth_l2_tunnel_conf entry;
12993 
12994 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12995 		return;
12996 
12997 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12998 	entry.vf_id = res->vf_id;
12999 
13000 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13001 					  &entry,
13002 					  ETH_L2_TUNNEL_INSERTION_MASK,
13003 					  0);
13004 }
13005 
13006 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13007 	.f = cmd_config_e_tag_insertion_en_parsed,
13008 	.data = NULL,
13009 	.help_str = "E-tag ... : E-tag insertion enable",
13010 	.tokens = {
13011 		(void *)&cmd_config_e_tag_e_tag,
13012 		(void *)&cmd_config_e_tag_set,
13013 		(void *)&cmd_config_e_tag_insertion,
13014 		(void *)&cmd_config_e_tag_on,
13015 		(void *)&cmd_config_e_tag_port_tag_id,
13016 		(void *)&cmd_config_e_tag_port_tag_id_val,
13017 		(void *)&cmd_config_e_tag_port,
13018 		(void *)&cmd_config_e_tag_port_id,
13019 		(void *)&cmd_config_e_tag_vf,
13020 		(void *)&cmd_config_e_tag_vf_id,
13021 		NULL,
13022 	},
13023 };
13024 
13025 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13026 	.f = cmd_config_e_tag_insertion_dis_parsed,
13027 	.data = NULL,
13028 	.help_str = "E-tag ... : E-tag insertion disable",
13029 	.tokens = {
13030 		(void *)&cmd_config_e_tag_e_tag,
13031 		(void *)&cmd_config_e_tag_set,
13032 		(void *)&cmd_config_e_tag_insertion,
13033 		(void *)&cmd_config_e_tag_off,
13034 		(void *)&cmd_config_e_tag_port,
13035 		(void *)&cmd_config_e_tag_port_id,
13036 		(void *)&cmd_config_e_tag_vf,
13037 		(void *)&cmd_config_e_tag_vf_id,
13038 		NULL,
13039 	},
13040 };
13041 
13042 /* E-tag stripping configuration */
13043 static void
13044 cmd_config_e_tag_stripping_parsed(
13045 	void *parsed_result,
13046 	__attribute__((unused)) struct cmdline *cl,
13047 	__attribute__((unused)) void *data)
13048 {
13049 	struct cmd_config_e_tag_result *res =
13050 		parsed_result;
13051 	struct rte_eth_l2_tunnel_conf entry;
13052 
13053 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13054 		return;
13055 
13056 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13057 
13058 	if (!strcmp(res->on_off, "on"))
13059 		rte_eth_dev_l2_tunnel_offload_set
13060 			(res->port_id,
13061 			 &entry,
13062 			 ETH_L2_TUNNEL_STRIPPING_MASK,
13063 			 1);
13064 	else
13065 		rte_eth_dev_l2_tunnel_offload_set
13066 			(res->port_id,
13067 			 &entry,
13068 			 ETH_L2_TUNNEL_STRIPPING_MASK,
13069 			 0);
13070 }
13071 
13072 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13073 	.f = cmd_config_e_tag_stripping_parsed,
13074 	.data = NULL,
13075 	.help_str = "E-tag ... : E-tag stripping enable/disable",
13076 	.tokens = {
13077 		(void *)&cmd_config_e_tag_e_tag,
13078 		(void *)&cmd_config_e_tag_set,
13079 		(void *)&cmd_config_e_tag_stripping,
13080 		(void *)&cmd_config_e_tag_on_off,
13081 		(void *)&cmd_config_e_tag_port,
13082 		(void *)&cmd_config_e_tag_port_id,
13083 		NULL,
13084 	},
13085 };
13086 
13087 /* E-tag forwarding configuration */
13088 static void
13089 cmd_config_e_tag_forwarding_parsed(
13090 	void *parsed_result,
13091 	__attribute__((unused)) struct cmdline *cl,
13092 	__attribute__((unused)) void *data)
13093 {
13094 	struct cmd_config_e_tag_result *res = parsed_result;
13095 	struct rte_eth_l2_tunnel_conf entry;
13096 
13097 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13098 		return;
13099 
13100 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13101 
13102 	if (!strcmp(res->on_off, "on"))
13103 		rte_eth_dev_l2_tunnel_offload_set
13104 			(res->port_id,
13105 			 &entry,
13106 			 ETH_L2_TUNNEL_FORWARDING_MASK,
13107 			 1);
13108 	else
13109 		rte_eth_dev_l2_tunnel_offload_set
13110 			(res->port_id,
13111 			 &entry,
13112 			 ETH_L2_TUNNEL_FORWARDING_MASK,
13113 			 0);
13114 }
13115 
13116 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13117 	.f = cmd_config_e_tag_forwarding_parsed,
13118 	.data = NULL,
13119 	.help_str = "E-tag ... : E-tag forwarding enable/disable",
13120 	.tokens = {
13121 		(void *)&cmd_config_e_tag_e_tag,
13122 		(void *)&cmd_config_e_tag_set,
13123 		(void *)&cmd_config_e_tag_forwarding,
13124 		(void *)&cmd_config_e_tag_on_off,
13125 		(void *)&cmd_config_e_tag_port,
13126 		(void *)&cmd_config_e_tag_port_id,
13127 		NULL,
13128 	},
13129 };
13130 
13131 /* E-tag filter configuration */
13132 static void
13133 cmd_config_e_tag_filter_add_parsed(
13134 	void *parsed_result,
13135 	__attribute__((unused)) struct cmdline *cl,
13136 	__attribute__((unused)) void *data)
13137 {
13138 	struct cmd_config_e_tag_result *res = parsed_result;
13139 	struct rte_eth_l2_tunnel_conf entry;
13140 	int ret = 0;
13141 
13142 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13143 		return;
13144 
13145 	if (res->e_tag_id_val > 0x3fff) {
13146 		printf("e-tag-id must be equal or less than 0x3fff.\n");
13147 		return;
13148 	}
13149 
13150 	ret = rte_eth_dev_filter_supported(res->port_id,
13151 					   RTE_ETH_FILTER_L2_TUNNEL);
13152 	if (ret < 0) {
13153 		printf("E-tag filter is not supported on port %u.\n",
13154 		       res->port_id);
13155 		return;
13156 	}
13157 
13158 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13159 	entry.tunnel_id = res->e_tag_id_val;
13160 	entry.pool = res->dst_pool_val;
13161 
13162 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13163 				      RTE_ETH_FILTER_L2_TUNNEL,
13164 				      RTE_ETH_FILTER_ADD,
13165 				      &entry);
13166 	if (ret < 0)
13167 		printf("E-tag filter programming error: (%s)\n",
13168 		       strerror(-ret));
13169 }
13170 
13171 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13172 	.f = cmd_config_e_tag_filter_add_parsed,
13173 	.data = NULL,
13174 	.help_str = "E-tag ... : E-tag filter add",
13175 	.tokens = {
13176 		(void *)&cmd_config_e_tag_e_tag,
13177 		(void *)&cmd_config_e_tag_set,
13178 		(void *)&cmd_config_e_tag_filter,
13179 		(void *)&cmd_config_e_tag_add,
13180 		(void *)&cmd_config_e_tag_e_tag_id,
13181 		(void *)&cmd_config_e_tag_e_tag_id_val,
13182 		(void *)&cmd_config_e_tag_dst_pool,
13183 		(void *)&cmd_config_e_tag_dst_pool_val,
13184 		(void *)&cmd_config_e_tag_port,
13185 		(void *)&cmd_config_e_tag_port_id,
13186 		NULL,
13187 	},
13188 };
13189 
13190 static void
13191 cmd_config_e_tag_filter_del_parsed(
13192 	void *parsed_result,
13193 	__attribute__((unused)) struct cmdline *cl,
13194 	__attribute__((unused)) void *data)
13195 {
13196 	struct cmd_config_e_tag_result *res = parsed_result;
13197 	struct rte_eth_l2_tunnel_conf entry;
13198 	int ret = 0;
13199 
13200 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13201 		return;
13202 
13203 	if (res->e_tag_id_val > 0x3fff) {
13204 		printf("e-tag-id must be less than 0x3fff.\n");
13205 		return;
13206 	}
13207 
13208 	ret = rte_eth_dev_filter_supported(res->port_id,
13209 					   RTE_ETH_FILTER_L2_TUNNEL);
13210 	if (ret < 0) {
13211 		printf("E-tag filter is not supported on port %u.\n",
13212 		       res->port_id);
13213 		return;
13214 	}
13215 
13216 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13217 	entry.tunnel_id = res->e_tag_id_val;
13218 
13219 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13220 				      RTE_ETH_FILTER_L2_TUNNEL,
13221 				      RTE_ETH_FILTER_DELETE,
13222 				      &entry);
13223 	if (ret < 0)
13224 		printf("E-tag filter programming error: (%s)\n",
13225 		       strerror(-ret));
13226 }
13227 
13228 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13229 	.f = cmd_config_e_tag_filter_del_parsed,
13230 	.data = NULL,
13231 	.help_str = "E-tag ... : E-tag filter delete",
13232 	.tokens = {
13233 		(void *)&cmd_config_e_tag_e_tag,
13234 		(void *)&cmd_config_e_tag_set,
13235 		(void *)&cmd_config_e_tag_filter,
13236 		(void *)&cmd_config_e_tag_del,
13237 		(void *)&cmd_config_e_tag_e_tag_id,
13238 		(void *)&cmd_config_e_tag_e_tag_id_val,
13239 		(void *)&cmd_config_e_tag_port,
13240 		(void *)&cmd_config_e_tag_port_id,
13241 		NULL,
13242 	},
13243 };
13244 
13245 /* vf vlan anti spoof configuration */
13246 
13247 /* Common result structure for vf vlan anti spoof */
13248 struct cmd_vf_vlan_anti_spoof_result {
13249 	cmdline_fixed_string_t set;
13250 	cmdline_fixed_string_t vf;
13251 	cmdline_fixed_string_t vlan;
13252 	cmdline_fixed_string_t antispoof;
13253 	portid_t port_id;
13254 	uint32_t vf_id;
13255 	cmdline_fixed_string_t on_off;
13256 };
13257 
13258 /* Common CLI fields for vf vlan anti spoof enable disable */
13259 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13260 	TOKEN_STRING_INITIALIZER
13261 		(struct cmd_vf_vlan_anti_spoof_result,
13262 		 set, "set");
13263 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13264 	TOKEN_STRING_INITIALIZER
13265 		(struct cmd_vf_vlan_anti_spoof_result,
13266 		 vf, "vf");
13267 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13268 	TOKEN_STRING_INITIALIZER
13269 		(struct cmd_vf_vlan_anti_spoof_result,
13270 		 vlan, "vlan");
13271 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13272 	TOKEN_STRING_INITIALIZER
13273 		(struct cmd_vf_vlan_anti_spoof_result,
13274 		 antispoof, "antispoof");
13275 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13276 	TOKEN_NUM_INITIALIZER
13277 		(struct cmd_vf_vlan_anti_spoof_result,
13278 		 port_id, UINT16);
13279 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13280 	TOKEN_NUM_INITIALIZER
13281 		(struct cmd_vf_vlan_anti_spoof_result,
13282 		 vf_id, UINT32);
13283 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13284 	TOKEN_STRING_INITIALIZER
13285 		(struct cmd_vf_vlan_anti_spoof_result,
13286 		 on_off, "on#off");
13287 
13288 static void
13289 cmd_set_vf_vlan_anti_spoof_parsed(
13290 	void *parsed_result,
13291 	__attribute__((unused)) struct cmdline *cl,
13292 	__attribute__((unused)) void *data)
13293 {
13294 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13295 	int ret = -ENOTSUP;
13296 
13297 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13298 
13299 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13300 		return;
13301 
13302 #ifdef RTE_LIBRTE_IXGBE_PMD
13303 	if (ret == -ENOTSUP)
13304 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13305 				res->vf_id, is_on);
13306 #endif
13307 #ifdef RTE_LIBRTE_I40E_PMD
13308 	if (ret == -ENOTSUP)
13309 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13310 				res->vf_id, is_on);
13311 #endif
13312 #ifdef RTE_LIBRTE_BNXT_PMD
13313 	if (ret == -ENOTSUP)
13314 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13315 				res->vf_id, is_on);
13316 #endif
13317 
13318 	switch (ret) {
13319 	case 0:
13320 		break;
13321 	case -EINVAL:
13322 		printf("invalid vf_id %d\n", res->vf_id);
13323 		break;
13324 	case -ENODEV:
13325 		printf("invalid port_id %d\n", res->port_id);
13326 		break;
13327 	case -ENOTSUP:
13328 		printf("function not implemented\n");
13329 		break;
13330 	default:
13331 		printf("programming error: (%s)\n", strerror(-ret));
13332 	}
13333 }
13334 
13335 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13336 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
13337 	.data = NULL,
13338 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13339 	.tokens = {
13340 		(void *)&cmd_vf_vlan_anti_spoof_set,
13341 		(void *)&cmd_vf_vlan_anti_spoof_vf,
13342 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
13343 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
13344 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
13345 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
13346 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
13347 		NULL,
13348 	},
13349 };
13350 
13351 /* vf mac anti spoof configuration */
13352 
13353 /* Common result structure for vf mac anti spoof */
13354 struct cmd_vf_mac_anti_spoof_result {
13355 	cmdline_fixed_string_t set;
13356 	cmdline_fixed_string_t vf;
13357 	cmdline_fixed_string_t mac;
13358 	cmdline_fixed_string_t antispoof;
13359 	portid_t port_id;
13360 	uint32_t vf_id;
13361 	cmdline_fixed_string_t on_off;
13362 };
13363 
13364 /* Common CLI fields for vf mac anti spoof enable disable */
13365 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13366 	TOKEN_STRING_INITIALIZER
13367 		(struct cmd_vf_mac_anti_spoof_result,
13368 		 set, "set");
13369 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13370 	TOKEN_STRING_INITIALIZER
13371 		(struct cmd_vf_mac_anti_spoof_result,
13372 		 vf, "vf");
13373 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13374 	TOKEN_STRING_INITIALIZER
13375 		(struct cmd_vf_mac_anti_spoof_result,
13376 		 mac, "mac");
13377 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13378 	TOKEN_STRING_INITIALIZER
13379 		(struct cmd_vf_mac_anti_spoof_result,
13380 		 antispoof, "antispoof");
13381 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13382 	TOKEN_NUM_INITIALIZER
13383 		(struct cmd_vf_mac_anti_spoof_result,
13384 		 port_id, UINT16);
13385 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13386 	TOKEN_NUM_INITIALIZER
13387 		(struct cmd_vf_mac_anti_spoof_result,
13388 		 vf_id, UINT32);
13389 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13390 	TOKEN_STRING_INITIALIZER
13391 		(struct cmd_vf_mac_anti_spoof_result,
13392 		 on_off, "on#off");
13393 
13394 static void
13395 cmd_set_vf_mac_anti_spoof_parsed(
13396 	void *parsed_result,
13397 	__attribute__((unused)) struct cmdline *cl,
13398 	__attribute__((unused)) void *data)
13399 {
13400 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13401 	int ret = -ENOTSUP;
13402 
13403 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13404 
13405 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13406 		return;
13407 
13408 #ifdef RTE_LIBRTE_IXGBE_PMD
13409 	if (ret == -ENOTSUP)
13410 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13411 			res->vf_id, is_on);
13412 #endif
13413 #ifdef RTE_LIBRTE_I40E_PMD
13414 	if (ret == -ENOTSUP)
13415 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13416 			res->vf_id, is_on);
13417 #endif
13418 #ifdef RTE_LIBRTE_BNXT_PMD
13419 	if (ret == -ENOTSUP)
13420 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13421 			res->vf_id, is_on);
13422 #endif
13423 
13424 	switch (ret) {
13425 	case 0:
13426 		break;
13427 	case -EINVAL:
13428 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13429 		break;
13430 	case -ENODEV:
13431 		printf("invalid port_id %d\n", res->port_id);
13432 		break;
13433 	case -ENOTSUP:
13434 		printf("function not implemented\n");
13435 		break;
13436 	default:
13437 		printf("programming error: (%s)\n", strerror(-ret));
13438 	}
13439 }
13440 
13441 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13442 	.f = cmd_set_vf_mac_anti_spoof_parsed,
13443 	.data = NULL,
13444 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13445 	.tokens = {
13446 		(void *)&cmd_vf_mac_anti_spoof_set,
13447 		(void *)&cmd_vf_mac_anti_spoof_vf,
13448 		(void *)&cmd_vf_mac_anti_spoof_mac,
13449 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
13450 		(void *)&cmd_vf_mac_anti_spoof_port_id,
13451 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
13452 		(void *)&cmd_vf_mac_anti_spoof_on_off,
13453 		NULL,
13454 	},
13455 };
13456 
13457 /* vf vlan strip queue configuration */
13458 
13459 /* Common result structure for vf mac anti spoof */
13460 struct cmd_vf_vlan_stripq_result {
13461 	cmdline_fixed_string_t set;
13462 	cmdline_fixed_string_t vf;
13463 	cmdline_fixed_string_t vlan;
13464 	cmdline_fixed_string_t stripq;
13465 	portid_t port_id;
13466 	uint16_t vf_id;
13467 	cmdline_fixed_string_t on_off;
13468 };
13469 
13470 /* Common CLI fields for vf vlan strip enable disable */
13471 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13472 	TOKEN_STRING_INITIALIZER
13473 		(struct cmd_vf_vlan_stripq_result,
13474 		 set, "set");
13475 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13476 	TOKEN_STRING_INITIALIZER
13477 		(struct cmd_vf_vlan_stripq_result,
13478 		 vf, "vf");
13479 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13480 	TOKEN_STRING_INITIALIZER
13481 		(struct cmd_vf_vlan_stripq_result,
13482 		 vlan, "vlan");
13483 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13484 	TOKEN_STRING_INITIALIZER
13485 		(struct cmd_vf_vlan_stripq_result,
13486 		 stripq, "stripq");
13487 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13488 	TOKEN_NUM_INITIALIZER
13489 		(struct cmd_vf_vlan_stripq_result,
13490 		 port_id, UINT16);
13491 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13492 	TOKEN_NUM_INITIALIZER
13493 		(struct cmd_vf_vlan_stripq_result,
13494 		 vf_id, UINT16);
13495 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13496 	TOKEN_STRING_INITIALIZER
13497 		(struct cmd_vf_vlan_stripq_result,
13498 		 on_off, "on#off");
13499 
13500 static void
13501 cmd_set_vf_vlan_stripq_parsed(
13502 	void *parsed_result,
13503 	__attribute__((unused)) struct cmdline *cl,
13504 	__attribute__((unused)) void *data)
13505 {
13506 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
13507 	int ret = -ENOTSUP;
13508 
13509 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13510 
13511 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13512 		return;
13513 
13514 #ifdef RTE_LIBRTE_IXGBE_PMD
13515 	if (ret == -ENOTSUP)
13516 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13517 			res->vf_id, is_on);
13518 #endif
13519 #ifdef RTE_LIBRTE_I40E_PMD
13520 	if (ret == -ENOTSUP)
13521 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13522 			res->vf_id, is_on);
13523 #endif
13524 #ifdef RTE_LIBRTE_BNXT_PMD
13525 	if (ret == -ENOTSUP)
13526 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13527 			res->vf_id, is_on);
13528 #endif
13529 
13530 	switch (ret) {
13531 	case 0:
13532 		break;
13533 	case -EINVAL:
13534 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13535 		break;
13536 	case -ENODEV:
13537 		printf("invalid port_id %d\n", res->port_id);
13538 		break;
13539 	case -ENOTSUP:
13540 		printf("function not implemented\n");
13541 		break;
13542 	default:
13543 		printf("programming error: (%s)\n", strerror(-ret));
13544 	}
13545 }
13546 
13547 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13548 	.f = cmd_set_vf_vlan_stripq_parsed,
13549 	.data = NULL,
13550 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13551 	.tokens = {
13552 		(void *)&cmd_vf_vlan_stripq_set,
13553 		(void *)&cmd_vf_vlan_stripq_vf,
13554 		(void *)&cmd_vf_vlan_stripq_vlan,
13555 		(void *)&cmd_vf_vlan_stripq_stripq,
13556 		(void *)&cmd_vf_vlan_stripq_port_id,
13557 		(void *)&cmd_vf_vlan_stripq_vf_id,
13558 		(void *)&cmd_vf_vlan_stripq_on_off,
13559 		NULL,
13560 	},
13561 };
13562 
13563 /* vf vlan insert configuration */
13564 
13565 /* Common result structure for vf vlan insert */
13566 struct cmd_vf_vlan_insert_result {
13567 	cmdline_fixed_string_t set;
13568 	cmdline_fixed_string_t vf;
13569 	cmdline_fixed_string_t vlan;
13570 	cmdline_fixed_string_t insert;
13571 	portid_t port_id;
13572 	uint16_t vf_id;
13573 	uint16_t vlan_id;
13574 };
13575 
13576 /* Common CLI fields for vf vlan insert enable disable */
13577 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13578 	TOKEN_STRING_INITIALIZER
13579 		(struct cmd_vf_vlan_insert_result,
13580 		 set, "set");
13581 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13582 	TOKEN_STRING_INITIALIZER
13583 		(struct cmd_vf_vlan_insert_result,
13584 		 vf, "vf");
13585 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13586 	TOKEN_STRING_INITIALIZER
13587 		(struct cmd_vf_vlan_insert_result,
13588 		 vlan, "vlan");
13589 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13590 	TOKEN_STRING_INITIALIZER
13591 		(struct cmd_vf_vlan_insert_result,
13592 		 insert, "insert");
13593 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13594 	TOKEN_NUM_INITIALIZER
13595 		(struct cmd_vf_vlan_insert_result,
13596 		 port_id, UINT16);
13597 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13598 	TOKEN_NUM_INITIALIZER
13599 		(struct cmd_vf_vlan_insert_result,
13600 		 vf_id, UINT16);
13601 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13602 	TOKEN_NUM_INITIALIZER
13603 		(struct cmd_vf_vlan_insert_result,
13604 		 vlan_id, UINT16);
13605 
13606 static void
13607 cmd_set_vf_vlan_insert_parsed(
13608 	void *parsed_result,
13609 	__attribute__((unused)) struct cmdline *cl,
13610 	__attribute__((unused)) void *data)
13611 {
13612 	struct cmd_vf_vlan_insert_result *res = parsed_result;
13613 	int ret = -ENOTSUP;
13614 
13615 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13616 		return;
13617 
13618 #ifdef RTE_LIBRTE_IXGBE_PMD
13619 	if (ret == -ENOTSUP)
13620 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13621 			res->vlan_id);
13622 #endif
13623 #ifdef RTE_LIBRTE_I40E_PMD
13624 	if (ret == -ENOTSUP)
13625 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13626 			res->vlan_id);
13627 #endif
13628 #ifdef RTE_LIBRTE_BNXT_PMD
13629 	if (ret == -ENOTSUP)
13630 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13631 			res->vlan_id);
13632 #endif
13633 
13634 	switch (ret) {
13635 	case 0:
13636 		break;
13637 	case -EINVAL:
13638 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13639 		break;
13640 	case -ENODEV:
13641 		printf("invalid port_id %d\n", res->port_id);
13642 		break;
13643 	case -ENOTSUP:
13644 		printf("function not implemented\n");
13645 		break;
13646 	default:
13647 		printf("programming error: (%s)\n", strerror(-ret));
13648 	}
13649 }
13650 
13651 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13652 	.f = cmd_set_vf_vlan_insert_parsed,
13653 	.data = NULL,
13654 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13655 	.tokens = {
13656 		(void *)&cmd_vf_vlan_insert_set,
13657 		(void *)&cmd_vf_vlan_insert_vf,
13658 		(void *)&cmd_vf_vlan_insert_vlan,
13659 		(void *)&cmd_vf_vlan_insert_insert,
13660 		(void *)&cmd_vf_vlan_insert_port_id,
13661 		(void *)&cmd_vf_vlan_insert_vf_id,
13662 		(void *)&cmd_vf_vlan_insert_vlan_id,
13663 		NULL,
13664 	},
13665 };
13666 
13667 /* tx loopback configuration */
13668 
13669 /* Common result structure for tx loopback */
13670 struct cmd_tx_loopback_result {
13671 	cmdline_fixed_string_t set;
13672 	cmdline_fixed_string_t tx;
13673 	cmdline_fixed_string_t loopback;
13674 	portid_t port_id;
13675 	cmdline_fixed_string_t on_off;
13676 };
13677 
13678 /* Common CLI fields for tx loopback enable disable */
13679 cmdline_parse_token_string_t cmd_tx_loopback_set =
13680 	TOKEN_STRING_INITIALIZER
13681 		(struct cmd_tx_loopback_result,
13682 		 set, "set");
13683 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13684 	TOKEN_STRING_INITIALIZER
13685 		(struct cmd_tx_loopback_result,
13686 		 tx, "tx");
13687 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13688 	TOKEN_STRING_INITIALIZER
13689 		(struct cmd_tx_loopback_result,
13690 		 loopback, "loopback");
13691 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13692 	TOKEN_NUM_INITIALIZER
13693 		(struct cmd_tx_loopback_result,
13694 		 port_id, UINT16);
13695 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13696 	TOKEN_STRING_INITIALIZER
13697 		(struct cmd_tx_loopback_result,
13698 		 on_off, "on#off");
13699 
13700 static void
13701 cmd_set_tx_loopback_parsed(
13702 	void *parsed_result,
13703 	__attribute__((unused)) struct cmdline *cl,
13704 	__attribute__((unused)) void *data)
13705 {
13706 	struct cmd_tx_loopback_result *res = parsed_result;
13707 	int ret = -ENOTSUP;
13708 
13709 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13710 
13711 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13712 		return;
13713 
13714 #ifdef RTE_LIBRTE_IXGBE_PMD
13715 	if (ret == -ENOTSUP)
13716 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13717 #endif
13718 #ifdef RTE_LIBRTE_I40E_PMD
13719 	if (ret == -ENOTSUP)
13720 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13721 #endif
13722 #ifdef RTE_LIBRTE_BNXT_PMD
13723 	if (ret == -ENOTSUP)
13724 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13725 #endif
13726 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13727 	if (ret == -ENOTSUP)
13728 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13729 #endif
13730 
13731 	switch (ret) {
13732 	case 0:
13733 		break;
13734 	case -EINVAL:
13735 		printf("invalid is_on %d\n", is_on);
13736 		break;
13737 	case -ENODEV:
13738 		printf("invalid port_id %d\n", res->port_id);
13739 		break;
13740 	case -ENOTSUP:
13741 		printf("function not implemented\n");
13742 		break;
13743 	default:
13744 		printf("programming error: (%s)\n", strerror(-ret));
13745 	}
13746 }
13747 
13748 cmdline_parse_inst_t cmd_set_tx_loopback = {
13749 	.f = cmd_set_tx_loopback_parsed,
13750 	.data = NULL,
13751 	.help_str = "set tx loopback <port_id> on|off",
13752 	.tokens = {
13753 		(void *)&cmd_tx_loopback_set,
13754 		(void *)&cmd_tx_loopback_tx,
13755 		(void *)&cmd_tx_loopback_loopback,
13756 		(void *)&cmd_tx_loopback_port_id,
13757 		(void *)&cmd_tx_loopback_on_off,
13758 		NULL,
13759 	},
13760 };
13761 
13762 /* all queues drop enable configuration */
13763 
13764 /* Common result structure for all queues drop enable */
13765 struct cmd_all_queues_drop_en_result {
13766 	cmdline_fixed_string_t set;
13767 	cmdline_fixed_string_t all;
13768 	cmdline_fixed_string_t queues;
13769 	cmdline_fixed_string_t drop;
13770 	portid_t port_id;
13771 	cmdline_fixed_string_t on_off;
13772 };
13773 
13774 /* Common CLI fields for tx loopback enable disable */
13775 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13776 	TOKEN_STRING_INITIALIZER
13777 		(struct cmd_all_queues_drop_en_result,
13778 		 set, "set");
13779 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13780 	TOKEN_STRING_INITIALIZER
13781 		(struct cmd_all_queues_drop_en_result,
13782 		 all, "all");
13783 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13784 	TOKEN_STRING_INITIALIZER
13785 		(struct cmd_all_queues_drop_en_result,
13786 		 queues, "queues");
13787 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13788 	TOKEN_STRING_INITIALIZER
13789 		(struct cmd_all_queues_drop_en_result,
13790 		 drop, "drop");
13791 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13792 	TOKEN_NUM_INITIALIZER
13793 		(struct cmd_all_queues_drop_en_result,
13794 		 port_id, UINT16);
13795 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13796 	TOKEN_STRING_INITIALIZER
13797 		(struct cmd_all_queues_drop_en_result,
13798 		 on_off, "on#off");
13799 
13800 static void
13801 cmd_set_all_queues_drop_en_parsed(
13802 	void *parsed_result,
13803 	__attribute__((unused)) struct cmdline *cl,
13804 	__attribute__((unused)) void *data)
13805 {
13806 	struct cmd_all_queues_drop_en_result *res = parsed_result;
13807 	int ret = -ENOTSUP;
13808 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13809 
13810 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13811 		return;
13812 
13813 #ifdef RTE_LIBRTE_IXGBE_PMD
13814 	if (ret == -ENOTSUP)
13815 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13816 #endif
13817 #ifdef RTE_LIBRTE_BNXT_PMD
13818 	if (ret == -ENOTSUP)
13819 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13820 #endif
13821 	switch (ret) {
13822 	case 0:
13823 		break;
13824 	case -EINVAL:
13825 		printf("invalid is_on %d\n", is_on);
13826 		break;
13827 	case -ENODEV:
13828 		printf("invalid port_id %d\n", res->port_id);
13829 		break;
13830 	case -ENOTSUP:
13831 		printf("function not implemented\n");
13832 		break;
13833 	default:
13834 		printf("programming error: (%s)\n", strerror(-ret));
13835 	}
13836 }
13837 
13838 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13839 	.f = cmd_set_all_queues_drop_en_parsed,
13840 	.data = NULL,
13841 	.help_str = "set all queues drop <port_id> on|off",
13842 	.tokens = {
13843 		(void *)&cmd_all_queues_drop_en_set,
13844 		(void *)&cmd_all_queues_drop_en_all,
13845 		(void *)&cmd_all_queues_drop_en_queues,
13846 		(void *)&cmd_all_queues_drop_en_drop,
13847 		(void *)&cmd_all_queues_drop_en_port_id,
13848 		(void *)&cmd_all_queues_drop_en_on_off,
13849 		NULL,
13850 	},
13851 };
13852 
13853 /* vf split drop enable configuration */
13854 
13855 /* Common result structure for vf split drop enable */
13856 struct cmd_vf_split_drop_en_result {
13857 	cmdline_fixed_string_t set;
13858 	cmdline_fixed_string_t vf;
13859 	cmdline_fixed_string_t split;
13860 	cmdline_fixed_string_t drop;
13861 	portid_t port_id;
13862 	uint16_t vf_id;
13863 	cmdline_fixed_string_t on_off;
13864 };
13865 
13866 /* Common CLI fields for vf split drop enable disable */
13867 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13868 	TOKEN_STRING_INITIALIZER
13869 		(struct cmd_vf_split_drop_en_result,
13870 		 set, "set");
13871 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13872 	TOKEN_STRING_INITIALIZER
13873 		(struct cmd_vf_split_drop_en_result,
13874 		 vf, "vf");
13875 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13876 	TOKEN_STRING_INITIALIZER
13877 		(struct cmd_vf_split_drop_en_result,
13878 		 split, "split");
13879 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13880 	TOKEN_STRING_INITIALIZER
13881 		(struct cmd_vf_split_drop_en_result,
13882 		 drop, "drop");
13883 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13884 	TOKEN_NUM_INITIALIZER
13885 		(struct cmd_vf_split_drop_en_result,
13886 		 port_id, UINT16);
13887 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13888 	TOKEN_NUM_INITIALIZER
13889 		(struct cmd_vf_split_drop_en_result,
13890 		 vf_id, UINT16);
13891 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13892 	TOKEN_STRING_INITIALIZER
13893 		(struct cmd_vf_split_drop_en_result,
13894 		 on_off, "on#off");
13895 
13896 static void
13897 cmd_set_vf_split_drop_en_parsed(
13898 	void *parsed_result,
13899 	__attribute__((unused)) struct cmdline *cl,
13900 	__attribute__((unused)) void *data)
13901 {
13902 	struct cmd_vf_split_drop_en_result *res = parsed_result;
13903 	int ret = -ENOTSUP;
13904 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13905 
13906 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13907 		return;
13908 
13909 #ifdef RTE_LIBRTE_IXGBE_PMD
13910 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13911 			is_on);
13912 #endif
13913 	switch (ret) {
13914 	case 0:
13915 		break;
13916 	case -EINVAL:
13917 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13918 		break;
13919 	case -ENODEV:
13920 		printf("invalid port_id %d\n", res->port_id);
13921 		break;
13922 	case -ENOTSUP:
13923 		printf("not supported on port %d\n", res->port_id);
13924 		break;
13925 	default:
13926 		printf("programming error: (%s)\n", strerror(-ret));
13927 	}
13928 }
13929 
13930 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13931 	.f = cmd_set_vf_split_drop_en_parsed,
13932 	.data = NULL,
13933 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
13934 	.tokens = {
13935 		(void *)&cmd_vf_split_drop_en_set,
13936 		(void *)&cmd_vf_split_drop_en_vf,
13937 		(void *)&cmd_vf_split_drop_en_split,
13938 		(void *)&cmd_vf_split_drop_en_drop,
13939 		(void *)&cmd_vf_split_drop_en_port_id,
13940 		(void *)&cmd_vf_split_drop_en_vf_id,
13941 		(void *)&cmd_vf_split_drop_en_on_off,
13942 		NULL,
13943 	},
13944 };
13945 
13946 /* vf mac address configuration */
13947 
13948 /* Common result structure for vf mac address */
13949 struct cmd_set_vf_mac_addr_result {
13950 	cmdline_fixed_string_t set;
13951 	cmdline_fixed_string_t vf;
13952 	cmdline_fixed_string_t mac;
13953 	cmdline_fixed_string_t addr;
13954 	portid_t port_id;
13955 	uint16_t vf_id;
13956 	struct rte_ether_addr mac_addr;
13957 
13958 };
13959 
13960 /* Common CLI fields for vf split drop enable disable */
13961 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13962 	TOKEN_STRING_INITIALIZER
13963 		(struct cmd_set_vf_mac_addr_result,
13964 		 set, "set");
13965 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13966 	TOKEN_STRING_INITIALIZER
13967 		(struct cmd_set_vf_mac_addr_result,
13968 		 vf, "vf");
13969 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13970 	TOKEN_STRING_INITIALIZER
13971 		(struct cmd_set_vf_mac_addr_result,
13972 		 mac, "mac");
13973 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13974 	TOKEN_STRING_INITIALIZER
13975 		(struct cmd_set_vf_mac_addr_result,
13976 		 addr, "addr");
13977 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13978 	TOKEN_NUM_INITIALIZER
13979 		(struct cmd_set_vf_mac_addr_result,
13980 		 port_id, UINT16);
13981 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13982 	TOKEN_NUM_INITIALIZER
13983 		(struct cmd_set_vf_mac_addr_result,
13984 		 vf_id, UINT16);
13985 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13986 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13987 		 mac_addr);
13988 
13989 static void
13990 cmd_set_vf_mac_addr_parsed(
13991 	void *parsed_result,
13992 	__attribute__((unused)) struct cmdline *cl,
13993 	__attribute__((unused)) void *data)
13994 {
13995 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
13996 	int ret = -ENOTSUP;
13997 
13998 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13999 		return;
14000 
14001 #ifdef RTE_LIBRTE_IXGBE_PMD
14002 	if (ret == -ENOTSUP)
14003 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14004 				&res->mac_addr);
14005 #endif
14006 #ifdef RTE_LIBRTE_I40E_PMD
14007 	if (ret == -ENOTSUP)
14008 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14009 				&res->mac_addr);
14010 #endif
14011 #ifdef RTE_LIBRTE_BNXT_PMD
14012 	if (ret == -ENOTSUP)
14013 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14014 				&res->mac_addr);
14015 #endif
14016 
14017 	switch (ret) {
14018 	case 0:
14019 		break;
14020 	case -EINVAL:
14021 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14022 		break;
14023 	case -ENODEV:
14024 		printf("invalid port_id %d\n", res->port_id);
14025 		break;
14026 	case -ENOTSUP:
14027 		printf("function not implemented\n");
14028 		break;
14029 	default:
14030 		printf("programming error: (%s)\n", strerror(-ret));
14031 	}
14032 }
14033 
14034 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14035 	.f = cmd_set_vf_mac_addr_parsed,
14036 	.data = NULL,
14037 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14038 	.tokens = {
14039 		(void *)&cmd_set_vf_mac_addr_set,
14040 		(void *)&cmd_set_vf_mac_addr_vf,
14041 		(void *)&cmd_set_vf_mac_addr_mac,
14042 		(void *)&cmd_set_vf_mac_addr_addr,
14043 		(void *)&cmd_set_vf_mac_addr_port_id,
14044 		(void *)&cmd_set_vf_mac_addr_vf_id,
14045 		(void *)&cmd_set_vf_mac_addr_mac_addr,
14046 		NULL,
14047 	},
14048 };
14049 
14050 /* MACsec configuration */
14051 
14052 /* Common result structure for MACsec offload enable */
14053 struct cmd_macsec_offload_on_result {
14054 	cmdline_fixed_string_t set;
14055 	cmdline_fixed_string_t macsec;
14056 	cmdline_fixed_string_t offload;
14057 	portid_t port_id;
14058 	cmdline_fixed_string_t on;
14059 	cmdline_fixed_string_t encrypt;
14060 	cmdline_fixed_string_t en_on_off;
14061 	cmdline_fixed_string_t replay_protect;
14062 	cmdline_fixed_string_t rp_on_off;
14063 };
14064 
14065 /* Common CLI fields for MACsec offload disable */
14066 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14067 	TOKEN_STRING_INITIALIZER
14068 		(struct cmd_macsec_offload_on_result,
14069 		 set, "set");
14070 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14071 	TOKEN_STRING_INITIALIZER
14072 		(struct cmd_macsec_offload_on_result,
14073 		 macsec, "macsec");
14074 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14075 	TOKEN_STRING_INITIALIZER
14076 		(struct cmd_macsec_offload_on_result,
14077 		 offload, "offload");
14078 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14079 	TOKEN_NUM_INITIALIZER
14080 		(struct cmd_macsec_offload_on_result,
14081 		 port_id, UINT16);
14082 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14083 	TOKEN_STRING_INITIALIZER
14084 		(struct cmd_macsec_offload_on_result,
14085 		 on, "on");
14086 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14087 	TOKEN_STRING_INITIALIZER
14088 		(struct cmd_macsec_offload_on_result,
14089 		 encrypt, "encrypt");
14090 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14091 	TOKEN_STRING_INITIALIZER
14092 		(struct cmd_macsec_offload_on_result,
14093 		 en_on_off, "on#off");
14094 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14095 	TOKEN_STRING_INITIALIZER
14096 		(struct cmd_macsec_offload_on_result,
14097 		 replay_protect, "replay-protect");
14098 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14099 	TOKEN_STRING_INITIALIZER
14100 		(struct cmd_macsec_offload_on_result,
14101 		 rp_on_off, "on#off");
14102 
14103 static void
14104 cmd_set_macsec_offload_on_parsed(
14105 	void *parsed_result,
14106 	__attribute__((unused)) struct cmdline *cl,
14107 	__attribute__((unused)) void *data)
14108 {
14109 	struct cmd_macsec_offload_on_result *res = parsed_result;
14110 	int ret = -ENOTSUP;
14111 	portid_t port_id = res->port_id;
14112 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14113 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14114 	struct rte_eth_dev_info dev_info;
14115 
14116 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14117 		return;
14118 	if (!port_is_stopped(port_id)) {
14119 		printf("Please stop port %d first\n", port_id);
14120 		return;
14121 	}
14122 
14123 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
14124 	if (ret != 0)
14125 		return;
14126 
14127 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14128 #ifdef RTE_LIBRTE_IXGBE_PMD
14129 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14130 #endif
14131 	}
14132 	RTE_SET_USED(en);
14133 	RTE_SET_USED(rp);
14134 
14135 	switch (ret) {
14136 	case 0:
14137 		ports[port_id].dev_conf.txmode.offloads |=
14138 						DEV_TX_OFFLOAD_MACSEC_INSERT;
14139 		cmd_reconfig_device_queue(port_id, 1, 1);
14140 		break;
14141 	case -ENODEV:
14142 		printf("invalid port_id %d\n", port_id);
14143 		break;
14144 	case -ENOTSUP:
14145 		printf("not supported on port %d\n", port_id);
14146 		break;
14147 	default:
14148 		printf("programming error: (%s)\n", strerror(-ret));
14149 	}
14150 }
14151 
14152 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14153 	.f = cmd_set_macsec_offload_on_parsed,
14154 	.data = NULL,
14155 	.help_str = "set macsec offload <port_id> on "
14156 		"encrypt on|off replay-protect on|off",
14157 	.tokens = {
14158 		(void *)&cmd_macsec_offload_on_set,
14159 		(void *)&cmd_macsec_offload_on_macsec,
14160 		(void *)&cmd_macsec_offload_on_offload,
14161 		(void *)&cmd_macsec_offload_on_port_id,
14162 		(void *)&cmd_macsec_offload_on_on,
14163 		(void *)&cmd_macsec_offload_on_encrypt,
14164 		(void *)&cmd_macsec_offload_on_en_on_off,
14165 		(void *)&cmd_macsec_offload_on_replay_protect,
14166 		(void *)&cmd_macsec_offload_on_rp_on_off,
14167 		NULL,
14168 	},
14169 };
14170 
14171 /* Common result structure for MACsec offload disable */
14172 struct cmd_macsec_offload_off_result {
14173 	cmdline_fixed_string_t set;
14174 	cmdline_fixed_string_t macsec;
14175 	cmdline_fixed_string_t offload;
14176 	portid_t port_id;
14177 	cmdline_fixed_string_t off;
14178 };
14179 
14180 /* Common CLI fields for MACsec offload disable */
14181 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14182 	TOKEN_STRING_INITIALIZER
14183 		(struct cmd_macsec_offload_off_result,
14184 		 set, "set");
14185 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14186 	TOKEN_STRING_INITIALIZER
14187 		(struct cmd_macsec_offload_off_result,
14188 		 macsec, "macsec");
14189 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14190 	TOKEN_STRING_INITIALIZER
14191 		(struct cmd_macsec_offload_off_result,
14192 		 offload, "offload");
14193 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14194 	TOKEN_NUM_INITIALIZER
14195 		(struct cmd_macsec_offload_off_result,
14196 		 port_id, UINT16);
14197 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14198 	TOKEN_STRING_INITIALIZER
14199 		(struct cmd_macsec_offload_off_result,
14200 		 off, "off");
14201 
14202 static void
14203 cmd_set_macsec_offload_off_parsed(
14204 	void *parsed_result,
14205 	__attribute__((unused)) struct cmdline *cl,
14206 	__attribute__((unused)) void *data)
14207 {
14208 	struct cmd_macsec_offload_off_result *res = parsed_result;
14209 	int ret = -ENOTSUP;
14210 	struct rte_eth_dev_info dev_info;
14211 	portid_t port_id = res->port_id;
14212 
14213 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14214 		return;
14215 	if (!port_is_stopped(port_id)) {
14216 		printf("Please stop port %d first\n", port_id);
14217 		return;
14218 	}
14219 
14220 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
14221 	if (ret != 0)
14222 		return;
14223 
14224 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14225 #ifdef RTE_LIBRTE_IXGBE_PMD
14226 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
14227 #endif
14228 	}
14229 	switch (ret) {
14230 	case 0:
14231 		ports[port_id].dev_conf.txmode.offloads &=
14232 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
14233 		cmd_reconfig_device_queue(port_id, 1, 1);
14234 		break;
14235 	case -ENODEV:
14236 		printf("invalid port_id %d\n", port_id);
14237 		break;
14238 	case -ENOTSUP:
14239 		printf("not supported on port %d\n", port_id);
14240 		break;
14241 	default:
14242 		printf("programming error: (%s)\n", strerror(-ret));
14243 	}
14244 }
14245 
14246 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14247 	.f = cmd_set_macsec_offload_off_parsed,
14248 	.data = NULL,
14249 	.help_str = "set macsec offload <port_id> off",
14250 	.tokens = {
14251 		(void *)&cmd_macsec_offload_off_set,
14252 		(void *)&cmd_macsec_offload_off_macsec,
14253 		(void *)&cmd_macsec_offload_off_offload,
14254 		(void *)&cmd_macsec_offload_off_port_id,
14255 		(void *)&cmd_macsec_offload_off_off,
14256 		NULL,
14257 	},
14258 };
14259 
14260 /* Common result structure for MACsec secure connection configure */
14261 struct cmd_macsec_sc_result {
14262 	cmdline_fixed_string_t set;
14263 	cmdline_fixed_string_t macsec;
14264 	cmdline_fixed_string_t sc;
14265 	cmdline_fixed_string_t tx_rx;
14266 	portid_t port_id;
14267 	struct rte_ether_addr mac;
14268 	uint16_t pi;
14269 };
14270 
14271 /* Common CLI fields for MACsec secure connection configure */
14272 cmdline_parse_token_string_t cmd_macsec_sc_set =
14273 	TOKEN_STRING_INITIALIZER
14274 		(struct cmd_macsec_sc_result,
14275 		 set, "set");
14276 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14277 	TOKEN_STRING_INITIALIZER
14278 		(struct cmd_macsec_sc_result,
14279 		 macsec, "macsec");
14280 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14281 	TOKEN_STRING_INITIALIZER
14282 		(struct cmd_macsec_sc_result,
14283 		 sc, "sc");
14284 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14285 	TOKEN_STRING_INITIALIZER
14286 		(struct cmd_macsec_sc_result,
14287 		 tx_rx, "tx#rx");
14288 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14289 	TOKEN_NUM_INITIALIZER
14290 		(struct cmd_macsec_sc_result,
14291 		 port_id, UINT16);
14292 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14293 	TOKEN_ETHERADDR_INITIALIZER
14294 		(struct cmd_macsec_sc_result,
14295 		 mac);
14296 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14297 	TOKEN_NUM_INITIALIZER
14298 		(struct cmd_macsec_sc_result,
14299 		 pi, UINT16);
14300 
14301 static void
14302 cmd_set_macsec_sc_parsed(
14303 	void *parsed_result,
14304 	__attribute__((unused)) struct cmdline *cl,
14305 	__attribute__((unused)) void *data)
14306 {
14307 	struct cmd_macsec_sc_result *res = parsed_result;
14308 	int ret = -ENOTSUP;
14309 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14310 
14311 #ifdef RTE_LIBRTE_IXGBE_PMD
14312 	ret = is_tx ?
14313 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14314 				res->mac.addr_bytes) :
14315 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14316 				res->mac.addr_bytes, res->pi);
14317 #endif
14318 	RTE_SET_USED(is_tx);
14319 
14320 	switch (ret) {
14321 	case 0:
14322 		break;
14323 	case -ENODEV:
14324 		printf("invalid port_id %d\n", res->port_id);
14325 		break;
14326 	case -ENOTSUP:
14327 		printf("not supported on port %d\n", res->port_id);
14328 		break;
14329 	default:
14330 		printf("programming error: (%s)\n", strerror(-ret));
14331 	}
14332 }
14333 
14334 cmdline_parse_inst_t cmd_set_macsec_sc = {
14335 	.f = cmd_set_macsec_sc_parsed,
14336 	.data = NULL,
14337 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14338 	.tokens = {
14339 		(void *)&cmd_macsec_sc_set,
14340 		(void *)&cmd_macsec_sc_macsec,
14341 		(void *)&cmd_macsec_sc_sc,
14342 		(void *)&cmd_macsec_sc_tx_rx,
14343 		(void *)&cmd_macsec_sc_port_id,
14344 		(void *)&cmd_macsec_sc_mac,
14345 		(void *)&cmd_macsec_sc_pi,
14346 		NULL,
14347 	},
14348 };
14349 
14350 /* Common result structure for MACsec secure connection configure */
14351 struct cmd_macsec_sa_result {
14352 	cmdline_fixed_string_t set;
14353 	cmdline_fixed_string_t macsec;
14354 	cmdline_fixed_string_t sa;
14355 	cmdline_fixed_string_t tx_rx;
14356 	portid_t port_id;
14357 	uint8_t idx;
14358 	uint8_t an;
14359 	uint32_t pn;
14360 	cmdline_fixed_string_t key;
14361 };
14362 
14363 /* Common CLI fields for MACsec secure connection configure */
14364 cmdline_parse_token_string_t cmd_macsec_sa_set =
14365 	TOKEN_STRING_INITIALIZER
14366 		(struct cmd_macsec_sa_result,
14367 		 set, "set");
14368 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14369 	TOKEN_STRING_INITIALIZER
14370 		(struct cmd_macsec_sa_result,
14371 		 macsec, "macsec");
14372 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14373 	TOKEN_STRING_INITIALIZER
14374 		(struct cmd_macsec_sa_result,
14375 		 sa, "sa");
14376 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14377 	TOKEN_STRING_INITIALIZER
14378 		(struct cmd_macsec_sa_result,
14379 		 tx_rx, "tx#rx");
14380 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14381 	TOKEN_NUM_INITIALIZER
14382 		(struct cmd_macsec_sa_result,
14383 		 port_id, UINT16);
14384 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14385 	TOKEN_NUM_INITIALIZER
14386 		(struct cmd_macsec_sa_result,
14387 		 idx, UINT8);
14388 cmdline_parse_token_num_t cmd_macsec_sa_an =
14389 	TOKEN_NUM_INITIALIZER
14390 		(struct cmd_macsec_sa_result,
14391 		 an, UINT8);
14392 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14393 	TOKEN_NUM_INITIALIZER
14394 		(struct cmd_macsec_sa_result,
14395 		 pn, UINT32);
14396 cmdline_parse_token_string_t cmd_macsec_sa_key =
14397 	TOKEN_STRING_INITIALIZER
14398 		(struct cmd_macsec_sa_result,
14399 		 key, NULL);
14400 
14401 static void
14402 cmd_set_macsec_sa_parsed(
14403 	void *parsed_result,
14404 	__attribute__((unused)) struct cmdline *cl,
14405 	__attribute__((unused)) void *data)
14406 {
14407 	struct cmd_macsec_sa_result *res = parsed_result;
14408 	int ret = -ENOTSUP;
14409 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14410 	uint8_t key[16] = { 0 };
14411 	uint8_t xdgt0;
14412 	uint8_t xdgt1;
14413 	int key_len;
14414 	int i;
14415 
14416 	key_len = strlen(res->key) / 2;
14417 	if (key_len > 16)
14418 		key_len = 16;
14419 
14420 	for (i = 0; i < key_len; i++) {
14421 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14422 		if (xdgt0 == 0xFF)
14423 			return;
14424 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14425 		if (xdgt1 == 0xFF)
14426 			return;
14427 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14428 	}
14429 
14430 #ifdef RTE_LIBRTE_IXGBE_PMD
14431 	ret = is_tx ?
14432 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14433 			res->idx, res->an, res->pn, key) :
14434 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14435 			res->idx, res->an, res->pn, key);
14436 #endif
14437 	RTE_SET_USED(is_tx);
14438 	RTE_SET_USED(key);
14439 
14440 	switch (ret) {
14441 	case 0:
14442 		break;
14443 	case -EINVAL:
14444 		printf("invalid idx %d or an %d\n", res->idx, res->an);
14445 		break;
14446 	case -ENODEV:
14447 		printf("invalid port_id %d\n", res->port_id);
14448 		break;
14449 	case -ENOTSUP:
14450 		printf("not supported on port %d\n", res->port_id);
14451 		break;
14452 	default:
14453 		printf("programming error: (%s)\n", strerror(-ret));
14454 	}
14455 }
14456 
14457 cmdline_parse_inst_t cmd_set_macsec_sa = {
14458 	.f = cmd_set_macsec_sa_parsed,
14459 	.data = NULL,
14460 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14461 	.tokens = {
14462 		(void *)&cmd_macsec_sa_set,
14463 		(void *)&cmd_macsec_sa_macsec,
14464 		(void *)&cmd_macsec_sa_sa,
14465 		(void *)&cmd_macsec_sa_tx_rx,
14466 		(void *)&cmd_macsec_sa_port_id,
14467 		(void *)&cmd_macsec_sa_idx,
14468 		(void *)&cmd_macsec_sa_an,
14469 		(void *)&cmd_macsec_sa_pn,
14470 		(void *)&cmd_macsec_sa_key,
14471 		NULL,
14472 	},
14473 };
14474 
14475 /* VF unicast promiscuous mode configuration */
14476 
14477 /* Common result structure for VF unicast promiscuous mode */
14478 struct cmd_vf_promisc_result {
14479 	cmdline_fixed_string_t set;
14480 	cmdline_fixed_string_t vf;
14481 	cmdline_fixed_string_t promisc;
14482 	portid_t port_id;
14483 	uint32_t vf_id;
14484 	cmdline_fixed_string_t on_off;
14485 };
14486 
14487 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14488 cmdline_parse_token_string_t cmd_vf_promisc_set =
14489 	TOKEN_STRING_INITIALIZER
14490 		(struct cmd_vf_promisc_result,
14491 		 set, "set");
14492 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14493 	TOKEN_STRING_INITIALIZER
14494 		(struct cmd_vf_promisc_result,
14495 		 vf, "vf");
14496 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14497 	TOKEN_STRING_INITIALIZER
14498 		(struct cmd_vf_promisc_result,
14499 		 promisc, "promisc");
14500 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14501 	TOKEN_NUM_INITIALIZER
14502 		(struct cmd_vf_promisc_result,
14503 		 port_id, UINT16);
14504 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14505 	TOKEN_NUM_INITIALIZER
14506 		(struct cmd_vf_promisc_result,
14507 		 vf_id, UINT32);
14508 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14509 	TOKEN_STRING_INITIALIZER
14510 		(struct cmd_vf_promisc_result,
14511 		 on_off, "on#off");
14512 
14513 static void
14514 cmd_set_vf_promisc_parsed(
14515 	void *parsed_result,
14516 	__attribute__((unused)) struct cmdline *cl,
14517 	__attribute__((unused)) void *data)
14518 {
14519 	struct cmd_vf_promisc_result *res = parsed_result;
14520 	int ret = -ENOTSUP;
14521 
14522 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14523 
14524 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14525 		return;
14526 
14527 #ifdef RTE_LIBRTE_I40E_PMD
14528 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14529 						  res->vf_id, is_on);
14530 #endif
14531 
14532 	switch (ret) {
14533 	case 0:
14534 		break;
14535 	case -EINVAL:
14536 		printf("invalid vf_id %d\n", res->vf_id);
14537 		break;
14538 	case -ENODEV:
14539 		printf("invalid port_id %d\n", res->port_id);
14540 		break;
14541 	case -ENOTSUP:
14542 		printf("function not implemented\n");
14543 		break;
14544 	default:
14545 		printf("programming error: (%s)\n", strerror(-ret));
14546 	}
14547 }
14548 
14549 cmdline_parse_inst_t cmd_set_vf_promisc = {
14550 	.f = cmd_set_vf_promisc_parsed,
14551 	.data = NULL,
14552 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
14553 		"Set unicast promiscuous mode for a VF from the PF",
14554 	.tokens = {
14555 		(void *)&cmd_vf_promisc_set,
14556 		(void *)&cmd_vf_promisc_vf,
14557 		(void *)&cmd_vf_promisc_promisc,
14558 		(void *)&cmd_vf_promisc_port_id,
14559 		(void *)&cmd_vf_promisc_vf_id,
14560 		(void *)&cmd_vf_promisc_on_off,
14561 		NULL,
14562 	},
14563 };
14564 
14565 /* VF multicast promiscuous mode configuration */
14566 
14567 /* Common result structure for VF multicast promiscuous mode */
14568 struct cmd_vf_allmulti_result {
14569 	cmdline_fixed_string_t set;
14570 	cmdline_fixed_string_t vf;
14571 	cmdline_fixed_string_t allmulti;
14572 	portid_t port_id;
14573 	uint32_t vf_id;
14574 	cmdline_fixed_string_t on_off;
14575 };
14576 
14577 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14578 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14579 	TOKEN_STRING_INITIALIZER
14580 		(struct cmd_vf_allmulti_result,
14581 		 set, "set");
14582 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14583 	TOKEN_STRING_INITIALIZER
14584 		(struct cmd_vf_allmulti_result,
14585 		 vf, "vf");
14586 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14587 	TOKEN_STRING_INITIALIZER
14588 		(struct cmd_vf_allmulti_result,
14589 		 allmulti, "allmulti");
14590 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14591 	TOKEN_NUM_INITIALIZER
14592 		(struct cmd_vf_allmulti_result,
14593 		 port_id, UINT16);
14594 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14595 	TOKEN_NUM_INITIALIZER
14596 		(struct cmd_vf_allmulti_result,
14597 		 vf_id, UINT32);
14598 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14599 	TOKEN_STRING_INITIALIZER
14600 		(struct cmd_vf_allmulti_result,
14601 		 on_off, "on#off");
14602 
14603 static void
14604 cmd_set_vf_allmulti_parsed(
14605 	void *parsed_result,
14606 	__attribute__((unused)) struct cmdline *cl,
14607 	__attribute__((unused)) void *data)
14608 {
14609 	struct cmd_vf_allmulti_result *res = parsed_result;
14610 	int ret = -ENOTSUP;
14611 
14612 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14613 
14614 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14615 		return;
14616 
14617 #ifdef RTE_LIBRTE_I40E_PMD
14618 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14619 						    res->vf_id, is_on);
14620 #endif
14621 
14622 	switch (ret) {
14623 	case 0:
14624 		break;
14625 	case -EINVAL:
14626 		printf("invalid vf_id %d\n", res->vf_id);
14627 		break;
14628 	case -ENODEV:
14629 		printf("invalid port_id %d\n", res->port_id);
14630 		break;
14631 	case -ENOTSUP:
14632 		printf("function not implemented\n");
14633 		break;
14634 	default:
14635 		printf("programming error: (%s)\n", strerror(-ret));
14636 	}
14637 }
14638 
14639 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14640 	.f = cmd_set_vf_allmulti_parsed,
14641 	.data = NULL,
14642 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14643 		"Set multicast promiscuous mode for a VF from the PF",
14644 	.tokens = {
14645 		(void *)&cmd_vf_allmulti_set,
14646 		(void *)&cmd_vf_allmulti_vf,
14647 		(void *)&cmd_vf_allmulti_allmulti,
14648 		(void *)&cmd_vf_allmulti_port_id,
14649 		(void *)&cmd_vf_allmulti_vf_id,
14650 		(void *)&cmd_vf_allmulti_on_off,
14651 		NULL,
14652 	},
14653 };
14654 
14655 /* vf broadcast mode configuration */
14656 
14657 /* Common result structure for vf broadcast */
14658 struct cmd_set_vf_broadcast_result {
14659 	cmdline_fixed_string_t set;
14660 	cmdline_fixed_string_t vf;
14661 	cmdline_fixed_string_t broadcast;
14662 	portid_t port_id;
14663 	uint16_t vf_id;
14664 	cmdline_fixed_string_t on_off;
14665 };
14666 
14667 /* Common CLI fields for vf broadcast enable disable */
14668 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14669 	TOKEN_STRING_INITIALIZER
14670 		(struct cmd_set_vf_broadcast_result,
14671 		 set, "set");
14672 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14673 	TOKEN_STRING_INITIALIZER
14674 		(struct cmd_set_vf_broadcast_result,
14675 		 vf, "vf");
14676 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14677 	TOKEN_STRING_INITIALIZER
14678 		(struct cmd_set_vf_broadcast_result,
14679 		 broadcast, "broadcast");
14680 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14681 	TOKEN_NUM_INITIALIZER
14682 		(struct cmd_set_vf_broadcast_result,
14683 		 port_id, UINT16);
14684 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14685 	TOKEN_NUM_INITIALIZER
14686 		(struct cmd_set_vf_broadcast_result,
14687 		 vf_id, UINT16);
14688 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14689 	TOKEN_STRING_INITIALIZER
14690 		(struct cmd_set_vf_broadcast_result,
14691 		 on_off, "on#off");
14692 
14693 static void
14694 cmd_set_vf_broadcast_parsed(
14695 	void *parsed_result,
14696 	__attribute__((unused)) struct cmdline *cl,
14697 	__attribute__((unused)) void *data)
14698 {
14699 	struct cmd_set_vf_broadcast_result *res = parsed_result;
14700 	int ret = -ENOTSUP;
14701 
14702 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14703 
14704 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14705 		return;
14706 
14707 #ifdef RTE_LIBRTE_I40E_PMD
14708 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14709 					    res->vf_id, is_on);
14710 #endif
14711 
14712 	switch (ret) {
14713 	case 0:
14714 		break;
14715 	case -EINVAL:
14716 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14717 		break;
14718 	case -ENODEV:
14719 		printf("invalid port_id %d\n", res->port_id);
14720 		break;
14721 	case -ENOTSUP:
14722 		printf("function not implemented\n");
14723 		break;
14724 	default:
14725 		printf("programming error: (%s)\n", strerror(-ret));
14726 	}
14727 }
14728 
14729 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14730 	.f = cmd_set_vf_broadcast_parsed,
14731 	.data = NULL,
14732 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
14733 	.tokens = {
14734 		(void *)&cmd_set_vf_broadcast_set,
14735 		(void *)&cmd_set_vf_broadcast_vf,
14736 		(void *)&cmd_set_vf_broadcast_broadcast,
14737 		(void *)&cmd_set_vf_broadcast_port_id,
14738 		(void *)&cmd_set_vf_broadcast_vf_id,
14739 		(void *)&cmd_set_vf_broadcast_on_off,
14740 		NULL,
14741 	},
14742 };
14743 
14744 /* vf vlan tag configuration */
14745 
14746 /* Common result structure for vf vlan tag */
14747 struct cmd_set_vf_vlan_tag_result {
14748 	cmdline_fixed_string_t set;
14749 	cmdline_fixed_string_t vf;
14750 	cmdline_fixed_string_t vlan;
14751 	cmdline_fixed_string_t tag;
14752 	portid_t port_id;
14753 	uint16_t vf_id;
14754 	cmdline_fixed_string_t on_off;
14755 };
14756 
14757 /* Common CLI fields for vf vlan tag enable disable */
14758 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14759 	TOKEN_STRING_INITIALIZER
14760 		(struct cmd_set_vf_vlan_tag_result,
14761 		 set, "set");
14762 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14763 	TOKEN_STRING_INITIALIZER
14764 		(struct cmd_set_vf_vlan_tag_result,
14765 		 vf, "vf");
14766 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14767 	TOKEN_STRING_INITIALIZER
14768 		(struct cmd_set_vf_vlan_tag_result,
14769 		 vlan, "vlan");
14770 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14771 	TOKEN_STRING_INITIALIZER
14772 		(struct cmd_set_vf_vlan_tag_result,
14773 		 tag, "tag");
14774 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14775 	TOKEN_NUM_INITIALIZER
14776 		(struct cmd_set_vf_vlan_tag_result,
14777 		 port_id, UINT16);
14778 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14779 	TOKEN_NUM_INITIALIZER
14780 		(struct cmd_set_vf_vlan_tag_result,
14781 		 vf_id, UINT16);
14782 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14783 	TOKEN_STRING_INITIALIZER
14784 		(struct cmd_set_vf_vlan_tag_result,
14785 		 on_off, "on#off");
14786 
14787 static void
14788 cmd_set_vf_vlan_tag_parsed(
14789 	void *parsed_result,
14790 	__attribute__((unused)) struct cmdline *cl,
14791 	__attribute__((unused)) void *data)
14792 {
14793 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14794 	int ret = -ENOTSUP;
14795 
14796 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14797 
14798 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14799 		return;
14800 
14801 #ifdef RTE_LIBRTE_I40E_PMD
14802 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14803 					   res->vf_id, is_on);
14804 #endif
14805 
14806 	switch (ret) {
14807 	case 0:
14808 		break;
14809 	case -EINVAL:
14810 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14811 		break;
14812 	case -ENODEV:
14813 		printf("invalid port_id %d\n", res->port_id);
14814 		break;
14815 	case -ENOTSUP:
14816 		printf("function not implemented\n");
14817 		break;
14818 	default:
14819 		printf("programming error: (%s)\n", strerror(-ret));
14820 	}
14821 }
14822 
14823 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14824 	.f = cmd_set_vf_vlan_tag_parsed,
14825 	.data = NULL,
14826 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14827 	.tokens = {
14828 		(void *)&cmd_set_vf_vlan_tag_set,
14829 		(void *)&cmd_set_vf_vlan_tag_vf,
14830 		(void *)&cmd_set_vf_vlan_tag_vlan,
14831 		(void *)&cmd_set_vf_vlan_tag_tag,
14832 		(void *)&cmd_set_vf_vlan_tag_port_id,
14833 		(void *)&cmd_set_vf_vlan_tag_vf_id,
14834 		(void *)&cmd_set_vf_vlan_tag_on_off,
14835 		NULL,
14836 	},
14837 };
14838 
14839 /* Common definition of VF and TC TX bandwidth configuration */
14840 struct cmd_vf_tc_bw_result {
14841 	cmdline_fixed_string_t set;
14842 	cmdline_fixed_string_t vf;
14843 	cmdline_fixed_string_t tc;
14844 	cmdline_fixed_string_t tx;
14845 	cmdline_fixed_string_t min_bw;
14846 	cmdline_fixed_string_t max_bw;
14847 	cmdline_fixed_string_t strict_link_prio;
14848 	portid_t port_id;
14849 	uint16_t vf_id;
14850 	uint8_t tc_no;
14851 	uint32_t bw;
14852 	cmdline_fixed_string_t bw_list;
14853 	uint8_t tc_map;
14854 };
14855 
14856 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14857 	TOKEN_STRING_INITIALIZER
14858 		(struct cmd_vf_tc_bw_result,
14859 		 set, "set");
14860 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14861 	TOKEN_STRING_INITIALIZER
14862 		(struct cmd_vf_tc_bw_result,
14863 		 vf, "vf");
14864 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14865 	TOKEN_STRING_INITIALIZER
14866 		(struct cmd_vf_tc_bw_result,
14867 		 tc, "tc");
14868 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14869 	TOKEN_STRING_INITIALIZER
14870 		(struct cmd_vf_tc_bw_result,
14871 		 tx, "tx");
14872 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14873 	TOKEN_STRING_INITIALIZER
14874 		(struct cmd_vf_tc_bw_result,
14875 		 strict_link_prio, "strict-link-priority");
14876 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14877 	TOKEN_STRING_INITIALIZER
14878 		(struct cmd_vf_tc_bw_result,
14879 		 min_bw, "min-bandwidth");
14880 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14881 	TOKEN_STRING_INITIALIZER
14882 		(struct cmd_vf_tc_bw_result,
14883 		 max_bw, "max-bandwidth");
14884 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14885 	TOKEN_NUM_INITIALIZER
14886 		(struct cmd_vf_tc_bw_result,
14887 		 port_id, UINT16);
14888 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14889 	TOKEN_NUM_INITIALIZER
14890 		(struct cmd_vf_tc_bw_result,
14891 		 vf_id, UINT16);
14892 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14893 	TOKEN_NUM_INITIALIZER
14894 		(struct cmd_vf_tc_bw_result,
14895 		 tc_no, UINT8);
14896 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14897 	TOKEN_NUM_INITIALIZER
14898 		(struct cmd_vf_tc_bw_result,
14899 		 bw, UINT32);
14900 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14901 	TOKEN_STRING_INITIALIZER
14902 		(struct cmd_vf_tc_bw_result,
14903 		 bw_list, NULL);
14904 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14905 	TOKEN_NUM_INITIALIZER
14906 		(struct cmd_vf_tc_bw_result,
14907 		 tc_map, UINT8);
14908 
14909 /* VF max bandwidth setting */
14910 static void
14911 cmd_vf_max_bw_parsed(
14912 	void *parsed_result,
14913 	__attribute__((unused)) struct cmdline *cl,
14914 	__attribute__((unused)) void *data)
14915 {
14916 	struct cmd_vf_tc_bw_result *res = parsed_result;
14917 	int ret = -ENOTSUP;
14918 
14919 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14920 		return;
14921 
14922 #ifdef RTE_LIBRTE_I40E_PMD
14923 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14924 					 res->vf_id, res->bw);
14925 #endif
14926 
14927 	switch (ret) {
14928 	case 0:
14929 		break;
14930 	case -EINVAL:
14931 		printf("invalid vf_id %d or bandwidth %d\n",
14932 		       res->vf_id, res->bw);
14933 		break;
14934 	case -ENODEV:
14935 		printf("invalid port_id %d\n", res->port_id);
14936 		break;
14937 	case -ENOTSUP:
14938 		printf("function not implemented\n");
14939 		break;
14940 	default:
14941 		printf("programming error: (%s)\n", strerror(-ret));
14942 	}
14943 }
14944 
14945 cmdline_parse_inst_t cmd_vf_max_bw = {
14946 	.f = cmd_vf_max_bw_parsed,
14947 	.data = NULL,
14948 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14949 	.tokens = {
14950 		(void *)&cmd_vf_tc_bw_set,
14951 		(void *)&cmd_vf_tc_bw_vf,
14952 		(void *)&cmd_vf_tc_bw_tx,
14953 		(void *)&cmd_vf_tc_bw_max_bw,
14954 		(void *)&cmd_vf_tc_bw_port_id,
14955 		(void *)&cmd_vf_tc_bw_vf_id,
14956 		(void *)&cmd_vf_tc_bw_bw,
14957 		NULL,
14958 	},
14959 };
14960 
14961 static int
14962 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14963 			   uint8_t *tc_num,
14964 			   char *str)
14965 {
14966 	uint32_t size;
14967 	const char *p, *p0 = str;
14968 	char s[256];
14969 	char *end;
14970 	char *str_fld[16];
14971 	uint16_t i;
14972 	int ret;
14973 
14974 	p = strchr(p0, '(');
14975 	if (p == NULL) {
14976 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14977 		return -1;
14978 	}
14979 	p++;
14980 	p0 = strchr(p, ')');
14981 	if (p0 == NULL) {
14982 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14983 		return -1;
14984 	}
14985 	size = p0 - p;
14986 	if (size >= sizeof(s)) {
14987 		printf("The string size exceeds the internal buffer size\n");
14988 		return -1;
14989 	}
14990 	snprintf(s, sizeof(s), "%.*s", size, p);
14991 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14992 	if (ret <= 0) {
14993 		printf("Failed to get the bandwidth list. ");
14994 		return -1;
14995 	}
14996 	*tc_num = ret;
14997 	for (i = 0; i < ret; i++)
14998 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14999 
15000 	return 0;
15001 }
15002 
15003 /* TC min bandwidth setting */
15004 static void
15005 cmd_vf_tc_min_bw_parsed(
15006 	void *parsed_result,
15007 	__attribute__((unused)) struct cmdline *cl,
15008 	__attribute__((unused)) void *data)
15009 {
15010 	struct cmd_vf_tc_bw_result *res = parsed_result;
15011 	uint8_t tc_num;
15012 	uint8_t bw[16];
15013 	int ret = -ENOTSUP;
15014 
15015 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15016 		return;
15017 
15018 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15019 	if (ret)
15020 		return;
15021 
15022 #ifdef RTE_LIBRTE_I40E_PMD
15023 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15024 					      tc_num, bw);
15025 #endif
15026 
15027 	switch (ret) {
15028 	case 0:
15029 		break;
15030 	case -EINVAL:
15031 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15032 		break;
15033 	case -ENODEV:
15034 		printf("invalid port_id %d\n", res->port_id);
15035 		break;
15036 	case -ENOTSUP:
15037 		printf("function not implemented\n");
15038 		break;
15039 	default:
15040 		printf("programming error: (%s)\n", strerror(-ret));
15041 	}
15042 }
15043 
15044 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15045 	.f = cmd_vf_tc_min_bw_parsed,
15046 	.data = NULL,
15047 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15048 		    " <bw1, bw2, ...>",
15049 	.tokens = {
15050 		(void *)&cmd_vf_tc_bw_set,
15051 		(void *)&cmd_vf_tc_bw_vf,
15052 		(void *)&cmd_vf_tc_bw_tc,
15053 		(void *)&cmd_vf_tc_bw_tx,
15054 		(void *)&cmd_vf_tc_bw_min_bw,
15055 		(void *)&cmd_vf_tc_bw_port_id,
15056 		(void *)&cmd_vf_tc_bw_vf_id,
15057 		(void *)&cmd_vf_tc_bw_bw_list,
15058 		NULL,
15059 	},
15060 };
15061 
15062 static void
15063 cmd_tc_min_bw_parsed(
15064 	void *parsed_result,
15065 	__attribute__((unused)) struct cmdline *cl,
15066 	__attribute__((unused)) void *data)
15067 {
15068 	struct cmd_vf_tc_bw_result *res = parsed_result;
15069 	struct rte_port *port;
15070 	uint8_t tc_num;
15071 	uint8_t bw[16];
15072 	int ret = -ENOTSUP;
15073 
15074 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15075 		return;
15076 
15077 	port = &ports[res->port_id];
15078 	/** Check if the port is not started **/
15079 	if (port->port_status != RTE_PORT_STOPPED) {
15080 		printf("Please stop port %d first\n", res->port_id);
15081 		return;
15082 	}
15083 
15084 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15085 	if (ret)
15086 		return;
15087 
15088 #ifdef RTE_LIBRTE_IXGBE_PMD
15089 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15090 #endif
15091 
15092 	switch (ret) {
15093 	case 0:
15094 		break;
15095 	case -EINVAL:
15096 		printf("invalid bandwidth\n");
15097 		break;
15098 	case -ENODEV:
15099 		printf("invalid port_id %d\n", res->port_id);
15100 		break;
15101 	case -ENOTSUP:
15102 		printf("function not implemented\n");
15103 		break;
15104 	default:
15105 		printf("programming error: (%s)\n", strerror(-ret));
15106 	}
15107 }
15108 
15109 cmdline_parse_inst_t cmd_tc_min_bw = {
15110 	.f = cmd_tc_min_bw_parsed,
15111 	.data = NULL,
15112 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15113 	.tokens = {
15114 		(void *)&cmd_vf_tc_bw_set,
15115 		(void *)&cmd_vf_tc_bw_tc,
15116 		(void *)&cmd_vf_tc_bw_tx,
15117 		(void *)&cmd_vf_tc_bw_min_bw,
15118 		(void *)&cmd_vf_tc_bw_port_id,
15119 		(void *)&cmd_vf_tc_bw_bw_list,
15120 		NULL,
15121 	},
15122 };
15123 
15124 /* TC max bandwidth setting */
15125 static void
15126 cmd_vf_tc_max_bw_parsed(
15127 	void *parsed_result,
15128 	__attribute__((unused)) struct cmdline *cl,
15129 	__attribute__((unused)) void *data)
15130 {
15131 	struct cmd_vf_tc_bw_result *res = parsed_result;
15132 	int ret = -ENOTSUP;
15133 
15134 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15135 		return;
15136 
15137 #ifdef RTE_LIBRTE_I40E_PMD
15138 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15139 					    res->tc_no, res->bw);
15140 #endif
15141 
15142 	switch (ret) {
15143 	case 0:
15144 		break;
15145 	case -EINVAL:
15146 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15147 		       res->vf_id, res->tc_no, res->bw);
15148 		break;
15149 	case -ENODEV:
15150 		printf("invalid port_id %d\n", res->port_id);
15151 		break;
15152 	case -ENOTSUP:
15153 		printf("function not implemented\n");
15154 		break;
15155 	default:
15156 		printf("programming error: (%s)\n", strerror(-ret));
15157 	}
15158 }
15159 
15160 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15161 	.f = cmd_vf_tc_max_bw_parsed,
15162 	.data = NULL,
15163 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15164 		    " <bandwidth>",
15165 	.tokens = {
15166 		(void *)&cmd_vf_tc_bw_set,
15167 		(void *)&cmd_vf_tc_bw_vf,
15168 		(void *)&cmd_vf_tc_bw_tc,
15169 		(void *)&cmd_vf_tc_bw_tx,
15170 		(void *)&cmd_vf_tc_bw_max_bw,
15171 		(void *)&cmd_vf_tc_bw_port_id,
15172 		(void *)&cmd_vf_tc_bw_vf_id,
15173 		(void *)&cmd_vf_tc_bw_tc_no,
15174 		(void *)&cmd_vf_tc_bw_bw,
15175 		NULL,
15176 	},
15177 };
15178 
15179 
15180 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15181 
15182 /* *** Set Port default Traffic Management Hierarchy *** */
15183 struct cmd_set_port_tm_hierarchy_default_result {
15184 	cmdline_fixed_string_t set;
15185 	cmdline_fixed_string_t port;
15186 	cmdline_fixed_string_t tm;
15187 	cmdline_fixed_string_t hierarchy;
15188 	cmdline_fixed_string_t def;
15189 	portid_t port_id;
15190 };
15191 
15192 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15193 	TOKEN_STRING_INITIALIZER(
15194 		struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15195 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15196 	TOKEN_STRING_INITIALIZER(
15197 		struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15198 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15199 	TOKEN_STRING_INITIALIZER(
15200 		struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15201 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15202 	TOKEN_STRING_INITIALIZER(
15203 		struct cmd_set_port_tm_hierarchy_default_result,
15204 			hierarchy, "hierarchy");
15205 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15206 	TOKEN_STRING_INITIALIZER(
15207 		struct cmd_set_port_tm_hierarchy_default_result,
15208 			def, "default");
15209 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15210 	TOKEN_NUM_INITIALIZER(
15211 		struct cmd_set_port_tm_hierarchy_default_result,
15212 			port_id, UINT16);
15213 
15214 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15215 	__attribute__((unused)) struct cmdline *cl,
15216 	__attribute__((unused)) void *data)
15217 {
15218 	struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15219 	struct rte_port *p;
15220 	portid_t port_id = res->port_id;
15221 
15222 	if (port_id_is_invalid(port_id, ENABLED_WARN))
15223 		return;
15224 
15225 	p = &ports[port_id];
15226 
15227 	/* Forward mode: tm */
15228 	if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15229 		printf("  softnicfwd mode not enabled(error)\n");
15230 		return;
15231 	}
15232 
15233 	/* Set the default tm hierarchy */
15234 	p->softport.default_tm_hierarchy_enable = 1;
15235 }
15236 
15237 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15238 	.f = cmd_set_port_tm_hierarchy_default_parsed,
15239 	.data = NULL,
15240 	.help_str = "set port tm hierarchy default <port_id>",
15241 	.tokens = {
15242 		(void *)&cmd_set_port_tm_hierarchy_default_set,
15243 		(void *)&cmd_set_port_tm_hierarchy_default_port,
15244 		(void *)&cmd_set_port_tm_hierarchy_default_tm,
15245 		(void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15246 		(void *)&cmd_set_port_tm_hierarchy_default_default,
15247 		(void *)&cmd_set_port_tm_hierarchy_default_port_id,
15248 		NULL,
15249 	},
15250 };
15251 #endif
15252 
15253 /** Set VXLAN encapsulation details */
15254 struct cmd_set_vxlan_result {
15255 	cmdline_fixed_string_t set;
15256 	cmdline_fixed_string_t vxlan;
15257 	cmdline_fixed_string_t pos_token;
15258 	cmdline_fixed_string_t ip_version;
15259 	uint32_t vlan_present:1;
15260 	uint32_t vni;
15261 	uint16_t udp_src;
15262 	uint16_t udp_dst;
15263 	cmdline_ipaddr_t ip_src;
15264 	cmdline_ipaddr_t ip_dst;
15265 	uint16_t tci;
15266 	uint8_t tos;
15267 	uint8_t ttl;
15268 	struct rte_ether_addr eth_src;
15269 	struct rte_ether_addr eth_dst;
15270 };
15271 
15272 cmdline_parse_token_string_t cmd_set_vxlan_set =
15273 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15274 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15275 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15276 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15277 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15278 				 "vxlan-tos-ttl");
15279 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15280 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15281 				 "vxlan-with-vlan");
15282 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15283 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15284 				 "ip-version");
15285 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15286 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15287 				 "ipv4#ipv6");
15288 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15289 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15290 				 "vni");
15291 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15292 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15293 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15294 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15295 				 "udp-src");
15296 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15297 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15298 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15299 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15300 				 "udp-dst");
15301 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15302 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15303 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15304 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15305 				 "ip-tos");
15306 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15307 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15308 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15309 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15310 				 "ip-ttl");
15311 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15312 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15313 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15314 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15315 				 "ip-src");
15316 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15317 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15318 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15319 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15320 				 "ip-dst");
15321 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15322 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15323 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15324 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15325 				 "vlan-tci");
15326 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15327 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15328 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15329 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15330 				 "eth-src");
15331 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15332 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15333 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15334 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15335 				 "eth-dst");
15336 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15337 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15338 
15339 static void cmd_set_vxlan_parsed(void *parsed_result,
15340 	__attribute__((unused)) struct cmdline *cl,
15341 	__attribute__((unused)) void *data)
15342 {
15343 	struct cmd_set_vxlan_result *res = parsed_result;
15344 	union {
15345 		uint32_t vxlan_id;
15346 		uint8_t vni[4];
15347 	} id = {
15348 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15349 	};
15350 
15351 	vxlan_encap_conf.select_tos_ttl = 0;
15352 	if (strcmp(res->vxlan, "vxlan") == 0)
15353 		vxlan_encap_conf.select_vlan = 0;
15354 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15355 		vxlan_encap_conf.select_vlan = 1;
15356 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15357 		vxlan_encap_conf.select_vlan = 0;
15358 		vxlan_encap_conf.select_tos_ttl = 1;
15359 	}
15360 	if (strcmp(res->ip_version, "ipv4") == 0)
15361 		vxlan_encap_conf.select_ipv4 = 1;
15362 	else if (strcmp(res->ip_version, "ipv6") == 0)
15363 		vxlan_encap_conf.select_ipv4 = 0;
15364 	else
15365 		return;
15366 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15367 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15368 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15369 	vxlan_encap_conf.ip_tos = res->tos;
15370 	vxlan_encap_conf.ip_ttl = res->ttl;
15371 	if (vxlan_encap_conf.select_ipv4) {
15372 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15373 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15374 	} else {
15375 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15376 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15377 	}
15378 	if (vxlan_encap_conf.select_vlan)
15379 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15380 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15381 		   RTE_ETHER_ADDR_LEN);
15382 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15383 		   RTE_ETHER_ADDR_LEN);
15384 }
15385 
15386 cmdline_parse_inst_t cmd_set_vxlan = {
15387 	.f = cmd_set_vxlan_parsed,
15388 	.data = NULL,
15389 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15390 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15391 		" eth-src <eth-src> eth-dst <eth-dst>",
15392 	.tokens = {
15393 		(void *)&cmd_set_vxlan_set,
15394 		(void *)&cmd_set_vxlan_vxlan,
15395 		(void *)&cmd_set_vxlan_ip_version,
15396 		(void *)&cmd_set_vxlan_ip_version_value,
15397 		(void *)&cmd_set_vxlan_vni,
15398 		(void *)&cmd_set_vxlan_vni_value,
15399 		(void *)&cmd_set_vxlan_udp_src,
15400 		(void *)&cmd_set_vxlan_udp_src_value,
15401 		(void *)&cmd_set_vxlan_udp_dst,
15402 		(void *)&cmd_set_vxlan_udp_dst_value,
15403 		(void *)&cmd_set_vxlan_ip_src,
15404 		(void *)&cmd_set_vxlan_ip_src_value,
15405 		(void *)&cmd_set_vxlan_ip_dst,
15406 		(void *)&cmd_set_vxlan_ip_dst_value,
15407 		(void *)&cmd_set_vxlan_eth_src,
15408 		(void *)&cmd_set_vxlan_eth_src_value,
15409 		(void *)&cmd_set_vxlan_eth_dst,
15410 		(void *)&cmd_set_vxlan_eth_dst_value,
15411 		NULL,
15412 	},
15413 };
15414 
15415 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15416 	.f = cmd_set_vxlan_parsed,
15417 	.data = NULL,
15418 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15419 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15420 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15421 		" eth-dst <eth-dst>",
15422 	.tokens = {
15423 		(void *)&cmd_set_vxlan_set,
15424 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
15425 		(void *)&cmd_set_vxlan_ip_version,
15426 		(void *)&cmd_set_vxlan_ip_version_value,
15427 		(void *)&cmd_set_vxlan_vni,
15428 		(void *)&cmd_set_vxlan_vni_value,
15429 		(void *)&cmd_set_vxlan_udp_src,
15430 		(void *)&cmd_set_vxlan_udp_src_value,
15431 		(void *)&cmd_set_vxlan_udp_dst,
15432 		(void *)&cmd_set_vxlan_udp_dst_value,
15433 		(void *)&cmd_set_vxlan_ip_tos,
15434 		(void *)&cmd_set_vxlan_ip_tos_value,
15435 		(void *)&cmd_set_vxlan_ip_ttl,
15436 		(void *)&cmd_set_vxlan_ip_ttl_value,
15437 		(void *)&cmd_set_vxlan_ip_src,
15438 		(void *)&cmd_set_vxlan_ip_src_value,
15439 		(void *)&cmd_set_vxlan_ip_dst,
15440 		(void *)&cmd_set_vxlan_ip_dst_value,
15441 		(void *)&cmd_set_vxlan_eth_src,
15442 		(void *)&cmd_set_vxlan_eth_src_value,
15443 		(void *)&cmd_set_vxlan_eth_dst,
15444 		(void *)&cmd_set_vxlan_eth_dst_value,
15445 		NULL,
15446 	},
15447 };
15448 
15449 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15450 	.f = cmd_set_vxlan_parsed,
15451 	.data = NULL,
15452 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15453 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15454 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15455 		" <eth-dst>",
15456 	.tokens = {
15457 		(void *)&cmd_set_vxlan_set,
15458 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
15459 		(void *)&cmd_set_vxlan_ip_version,
15460 		(void *)&cmd_set_vxlan_ip_version_value,
15461 		(void *)&cmd_set_vxlan_vni,
15462 		(void *)&cmd_set_vxlan_vni_value,
15463 		(void *)&cmd_set_vxlan_udp_src,
15464 		(void *)&cmd_set_vxlan_udp_src_value,
15465 		(void *)&cmd_set_vxlan_udp_dst,
15466 		(void *)&cmd_set_vxlan_udp_dst_value,
15467 		(void *)&cmd_set_vxlan_ip_src,
15468 		(void *)&cmd_set_vxlan_ip_src_value,
15469 		(void *)&cmd_set_vxlan_ip_dst,
15470 		(void *)&cmd_set_vxlan_ip_dst_value,
15471 		(void *)&cmd_set_vxlan_vlan,
15472 		(void *)&cmd_set_vxlan_vlan_value,
15473 		(void *)&cmd_set_vxlan_eth_src,
15474 		(void *)&cmd_set_vxlan_eth_src_value,
15475 		(void *)&cmd_set_vxlan_eth_dst,
15476 		(void *)&cmd_set_vxlan_eth_dst_value,
15477 		NULL,
15478 	},
15479 };
15480 
15481 /** Set NVGRE encapsulation details */
15482 struct cmd_set_nvgre_result {
15483 	cmdline_fixed_string_t set;
15484 	cmdline_fixed_string_t nvgre;
15485 	cmdline_fixed_string_t pos_token;
15486 	cmdline_fixed_string_t ip_version;
15487 	uint32_t tni;
15488 	cmdline_ipaddr_t ip_src;
15489 	cmdline_ipaddr_t ip_dst;
15490 	uint16_t tci;
15491 	struct rte_ether_addr eth_src;
15492 	struct rte_ether_addr eth_dst;
15493 };
15494 
15495 cmdline_parse_token_string_t cmd_set_nvgre_set =
15496 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15497 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15498 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15499 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15500 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15501 				 "nvgre-with-vlan");
15502 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15503 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15504 				 "ip-version");
15505 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15506 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15507 				 "ipv4#ipv6");
15508 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15509 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15510 				 "tni");
15511 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15512 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15513 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15514 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15515 				 "ip-src");
15516 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15517 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15518 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15519 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15520 				 "ip-dst");
15521 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15522 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15523 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15524 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15525 				 "vlan-tci");
15526 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15527 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15528 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15529 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15530 				 "eth-src");
15531 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15532 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15533 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15534 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15535 				 "eth-dst");
15536 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15537 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15538 
15539 static void cmd_set_nvgre_parsed(void *parsed_result,
15540 	__attribute__((unused)) struct cmdline *cl,
15541 	__attribute__((unused)) void *data)
15542 {
15543 	struct cmd_set_nvgre_result *res = parsed_result;
15544 	union {
15545 		uint32_t nvgre_tni;
15546 		uint8_t tni[4];
15547 	} id = {
15548 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15549 	};
15550 
15551 	if (strcmp(res->nvgre, "nvgre") == 0)
15552 		nvgre_encap_conf.select_vlan = 0;
15553 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15554 		nvgre_encap_conf.select_vlan = 1;
15555 	if (strcmp(res->ip_version, "ipv4") == 0)
15556 		nvgre_encap_conf.select_ipv4 = 1;
15557 	else if (strcmp(res->ip_version, "ipv6") == 0)
15558 		nvgre_encap_conf.select_ipv4 = 0;
15559 	else
15560 		return;
15561 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15562 	if (nvgre_encap_conf.select_ipv4) {
15563 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15564 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15565 	} else {
15566 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15567 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15568 	}
15569 	if (nvgre_encap_conf.select_vlan)
15570 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15571 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15572 		   RTE_ETHER_ADDR_LEN);
15573 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15574 		   RTE_ETHER_ADDR_LEN);
15575 }
15576 
15577 cmdline_parse_inst_t cmd_set_nvgre = {
15578 	.f = cmd_set_nvgre_parsed,
15579 	.data = NULL,
15580 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15581 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15582 		" eth-dst <eth-dst>",
15583 	.tokens = {
15584 		(void *)&cmd_set_nvgre_set,
15585 		(void *)&cmd_set_nvgre_nvgre,
15586 		(void *)&cmd_set_nvgre_ip_version,
15587 		(void *)&cmd_set_nvgre_ip_version_value,
15588 		(void *)&cmd_set_nvgre_tni,
15589 		(void *)&cmd_set_nvgre_tni_value,
15590 		(void *)&cmd_set_nvgre_ip_src,
15591 		(void *)&cmd_set_nvgre_ip_src_value,
15592 		(void *)&cmd_set_nvgre_ip_dst,
15593 		(void *)&cmd_set_nvgre_ip_dst_value,
15594 		(void *)&cmd_set_nvgre_eth_src,
15595 		(void *)&cmd_set_nvgre_eth_src_value,
15596 		(void *)&cmd_set_nvgre_eth_dst,
15597 		(void *)&cmd_set_nvgre_eth_dst_value,
15598 		NULL,
15599 	},
15600 };
15601 
15602 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15603 	.f = cmd_set_nvgre_parsed,
15604 	.data = NULL,
15605 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15606 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15607 		" eth-src <eth-src> eth-dst <eth-dst>",
15608 	.tokens = {
15609 		(void *)&cmd_set_nvgre_set,
15610 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
15611 		(void *)&cmd_set_nvgre_ip_version,
15612 		(void *)&cmd_set_nvgre_ip_version_value,
15613 		(void *)&cmd_set_nvgre_tni,
15614 		(void *)&cmd_set_nvgre_tni_value,
15615 		(void *)&cmd_set_nvgre_ip_src,
15616 		(void *)&cmd_set_nvgre_ip_src_value,
15617 		(void *)&cmd_set_nvgre_ip_dst,
15618 		(void *)&cmd_set_nvgre_ip_dst_value,
15619 		(void *)&cmd_set_nvgre_vlan,
15620 		(void *)&cmd_set_nvgre_vlan_value,
15621 		(void *)&cmd_set_nvgre_eth_src,
15622 		(void *)&cmd_set_nvgre_eth_src_value,
15623 		(void *)&cmd_set_nvgre_eth_dst,
15624 		(void *)&cmd_set_nvgre_eth_dst_value,
15625 		NULL,
15626 	},
15627 };
15628 
15629 /** Set L2 encapsulation details */
15630 struct cmd_set_l2_encap_result {
15631 	cmdline_fixed_string_t set;
15632 	cmdline_fixed_string_t l2_encap;
15633 	cmdline_fixed_string_t pos_token;
15634 	cmdline_fixed_string_t ip_version;
15635 	uint32_t vlan_present:1;
15636 	uint16_t tci;
15637 	struct rte_ether_addr eth_src;
15638 	struct rte_ether_addr eth_dst;
15639 };
15640 
15641 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15642 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15643 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15644 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15645 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15646 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15647 				 "l2_encap-with-vlan");
15648 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15649 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15650 				 "ip-version");
15651 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15652 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15653 				 "ipv4#ipv6");
15654 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15655 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15656 				 "vlan-tci");
15657 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15658 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15659 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15660 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15661 				 "eth-src");
15662 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15663 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15664 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15665 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15666 				 "eth-dst");
15667 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15668 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15669 
15670 static void cmd_set_l2_encap_parsed(void *parsed_result,
15671 	__attribute__((unused)) struct cmdline *cl,
15672 	__attribute__((unused)) void *data)
15673 {
15674 	struct cmd_set_l2_encap_result *res = parsed_result;
15675 
15676 	if (strcmp(res->l2_encap, "l2_encap") == 0)
15677 		l2_encap_conf.select_vlan = 0;
15678 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15679 		l2_encap_conf.select_vlan = 1;
15680 	if (strcmp(res->ip_version, "ipv4") == 0)
15681 		l2_encap_conf.select_ipv4 = 1;
15682 	else if (strcmp(res->ip_version, "ipv6") == 0)
15683 		l2_encap_conf.select_ipv4 = 0;
15684 	else
15685 		return;
15686 	if (l2_encap_conf.select_vlan)
15687 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15688 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15689 		   RTE_ETHER_ADDR_LEN);
15690 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15691 		   RTE_ETHER_ADDR_LEN);
15692 }
15693 
15694 cmdline_parse_inst_t cmd_set_l2_encap = {
15695 	.f = cmd_set_l2_encap_parsed,
15696 	.data = NULL,
15697 	.help_str = "set l2_encap ip-version ipv4|ipv6"
15698 		" eth-src <eth-src> eth-dst <eth-dst>",
15699 	.tokens = {
15700 		(void *)&cmd_set_l2_encap_set,
15701 		(void *)&cmd_set_l2_encap_l2_encap,
15702 		(void *)&cmd_set_l2_encap_ip_version,
15703 		(void *)&cmd_set_l2_encap_ip_version_value,
15704 		(void *)&cmd_set_l2_encap_eth_src,
15705 		(void *)&cmd_set_l2_encap_eth_src_value,
15706 		(void *)&cmd_set_l2_encap_eth_dst,
15707 		(void *)&cmd_set_l2_encap_eth_dst_value,
15708 		NULL,
15709 	},
15710 };
15711 
15712 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15713 	.f = cmd_set_l2_encap_parsed,
15714 	.data = NULL,
15715 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15716 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15717 	.tokens = {
15718 		(void *)&cmd_set_l2_encap_set,
15719 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15720 		(void *)&cmd_set_l2_encap_ip_version,
15721 		(void *)&cmd_set_l2_encap_ip_version_value,
15722 		(void *)&cmd_set_l2_encap_vlan,
15723 		(void *)&cmd_set_l2_encap_vlan_value,
15724 		(void *)&cmd_set_l2_encap_eth_src,
15725 		(void *)&cmd_set_l2_encap_eth_src_value,
15726 		(void *)&cmd_set_l2_encap_eth_dst,
15727 		(void *)&cmd_set_l2_encap_eth_dst_value,
15728 		NULL,
15729 	},
15730 };
15731 
15732 /** Set L2 decapsulation details */
15733 struct cmd_set_l2_decap_result {
15734 	cmdline_fixed_string_t set;
15735 	cmdline_fixed_string_t l2_decap;
15736 	cmdline_fixed_string_t pos_token;
15737 	uint32_t vlan_present:1;
15738 };
15739 
15740 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15741 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15742 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15743 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15744 				 "l2_decap");
15745 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15746 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15747 				 "l2_decap-with-vlan");
15748 
15749 static void cmd_set_l2_decap_parsed(void *parsed_result,
15750 	__attribute__((unused)) struct cmdline *cl,
15751 	__attribute__((unused)) void *data)
15752 {
15753 	struct cmd_set_l2_decap_result *res = parsed_result;
15754 
15755 	if (strcmp(res->l2_decap, "l2_decap") == 0)
15756 		l2_decap_conf.select_vlan = 0;
15757 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15758 		l2_decap_conf.select_vlan = 1;
15759 }
15760 
15761 cmdline_parse_inst_t cmd_set_l2_decap = {
15762 	.f = cmd_set_l2_decap_parsed,
15763 	.data = NULL,
15764 	.help_str = "set l2_decap",
15765 	.tokens = {
15766 		(void *)&cmd_set_l2_decap_set,
15767 		(void *)&cmd_set_l2_decap_l2_decap,
15768 		NULL,
15769 	},
15770 };
15771 
15772 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15773 	.f = cmd_set_l2_decap_parsed,
15774 	.data = NULL,
15775 	.help_str = "set l2_decap-with-vlan",
15776 	.tokens = {
15777 		(void *)&cmd_set_l2_decap_set,
15778 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15779 		NULL,
15780 	},
15781 };
15782 
15783 /** Set MPLSoGRE encapsulation details */
15784 struct cmd_set_mplsogre_encap_result {
15785 	cmdline_fixed_string_t set;
15786 	cmdline_fixed_string_t mplsogre;
15787 	cmdline_fixed_string_t pos_token;
15788 	cmdline_fixed_string_t ip_version;
15789 	uint32_t vlan_present:1;
15790 	uint32_t label;
15791 	cmdline_ipaddr_t ip_src;
15792 	cmdline_ipaddr_t ip_dst;
15793 	uint16_t tci;
15794 	struct rte_ether_addr eth_src;
15795 	struct rte_ether_addr eth_dst;
15796 };
15797 
15798 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15799 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15800 				 "set");
15801 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15802 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15803 				 "mplsogre_encap");
15804 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15805 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15806 				 mplsogre, "mplsogre_encap-with-vlan");
15807 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15808 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15809 				 pos_token, "ip-version");
15810 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15811 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15812 				 ip_version, "ipv4#ipv6");
15813 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15814 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15815 				 pos_token, "label");
15816 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15817 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15818 			      UINT32);
15819 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15820 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15821 				 pos_token, "ip-src");
15822 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15823 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15824 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15825 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15826 				 pos_token, "ip-dst");
15827 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15828 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15829 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15830 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15831 				 pos_token, "vlan-tci");
15832 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15833 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15834 			      UINT16);
15835 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15836 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15837 				 pos_token, "eth-src");
15838 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15839 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15840 				    eth_src);
15841 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15842 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15843 				 pos_token, "eth-dst");
15844 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15845 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15846 				    eth_dst);
15847 
15848 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15849 	__attribute__((unused)) struct cmdline *cl,
15850 	__attribute__((unused)) void *data)
15851 {
15852 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
15853 	union {
15854 		uint32_t mplsogre_label;
15855 		uint8_t label[4];
15856 	} id = {
15857 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15858 	};
15859 
15860 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15861 		mplsogre_encap_conf.select_vlan = 0;
15862 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15863 		mplsogre_encap_conf.select_vlan = 1;
15864 	if (strcmp(res->ip_version, "ipv4") == 0)
15865 		mplsogre_encap_conf.select_ipv4 = 1;
15866 	else if (strcmp(res->ip_version, "ipv6") == 0)
15867 		mplsogre_encap_conf.select_ipv4 = 0;
15868 	else
15869 		return;
15870 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15871 	if (mplsogre_encap_conf.select_ipv4) {
15872 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15873 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15874 	} else {
15875 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15876 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15877 	}
15878 	if (mplsogre_encap_conf.select_vlan)
15879 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15880 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15881 		   RTE_ETHER_ADDR_LEN);
15882 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15883 		   RTE_ETHER_ADDR_LEN);
15884 }
15885 
15886 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15887 	.f = cmd_set_mplsogre_encap_parsed,
15888 	.data = NULL,
15889 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15890 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15891 		" eth-dst <eth-dst>",
15892 	.tokens = {
15893 		(void *)&cmd_set_mplsogre_encap_set,
15894 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15895 		(void *)&cmd_set_mplsogre_encap_ip_version,
15896 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
15897 		(void *)&cmd_set_mplsogre_encap_label,
15898 		(void *)&cmd_set_mplsogre_encap_label_value,
15899 		(void *)&cmd_set_mplsogre_encap_ip_src,
15900 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
15901 		(void *)&cmd_set_mplsogre_encap_ip_dst,
15902 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
15903 		(void *)&cmd_set_mplsogre_encap_eth_src,
15904 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
15905 		(void *)&cmd_set_mplsogre_encap_eth_dst,
15906 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
15907 		NULL,
15908 	},
15909 };
15910 
15911 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15912 	.f = cmd_set_mplsogre_encap_parsed,
15913 	.data = NULL,
15914 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15915 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
15916 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15917 	.tokens = {
15918 		(void *)&cmd_set_mplsogre_encap_set,
15919 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15920 		(void *)&cmd_set_mplsogre_encap_ip_version,
15921 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
15922 		(void *)&cmd_set_mplsogre_encap_label,
15923 		(void *)&cmd_set_mplsogre_encap_label_value,
15924 		(void *)&cmd_set_mplsogre_encap_ip_src,
15925 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
15926 		(void *)&cmd_set_mplsogre_encap_ip_dst,
15927 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
15928 		(void *)&cmd_set_mplsogre_encap_vlan,
15929 		(void *)&cmd_set_mplsogre_encap_vlan_value,
15930 		(void *)&cmd_set_mplsogre_encap_eth_src,
15931 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
15932 		(void *)&cmd_set_mplsogre_encap_eth_dst,
15933 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
15934 		NULL,
15935 	},
15936 };
15937 
15938 /** Set MPLSoGRE decapsulation details */
15939 struct cmd_set_mplsogre_decap_result {
15940 	cmdline_fixed_string_t set;
15941 	cmdline_fixed_string_t mplsogre;
15942 	cmdline_fixed_string_t pos_token;
15943 	cmdline_fixed_string_t ip_version;
15944 	uint32_t vlan_present:1;
15945 };
15946 
15947 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15948 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15949 				 "set");
15950 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15951 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15952 				 "mplsogre_decap");
15953 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15954 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15955 				 mplsogre, "mplsogre_decap-with-vlan");
15956 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15957 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15958 				 pos_token, "ip-version");
15959 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15960 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15961 				 ip_version, "ipv4#ipv6");
15962 
15963 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15964 	__attribute__((unused)) struct cmdline *cl,
15965 	__attribute__((unused)) void *data)
15966 {
15967 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
15968 
15969 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15970 		mplsogre_decap_conf.select_vlan = 0;
15971 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15972 		mplsogre_decap_conf.select_vlan = 1;
15973 	if (strcmp(res->ip_version, "ipv4") == 0)
15974 		mplsogre_decap_conf.select_ipv4 = 1;
15975 	else if (strcmp(res->ip_version, "ipv6") == 0)
15976 		mplsogre_decap_conf.select_ipv4 = 0;
15977 }
15978 
15979 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15980 	.f = cmd_set_mplsogre_decap_parsed,
15981 	.data = NULL,
15982 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15983 	.tokens = {
15984 		(void *)&cmd_set_mplsogre_decap_set,
15985 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15986 		(void *)&cmd_set_mplsogre_decap_ip_version,
15987 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
15988 		NULL,
15989 	},
15990 };
15991 
15992 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15993 	.f = cmd_set_mplsogre_decap_parsed,
15994 	.data = NULL,
15995 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15996 	.tokens = {
15997 		(void *)&cmd_set_mplsogre_decap_set,
15998 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15999 		(void *)&cmd_set_mplsogre_decap_ip_version,
16000 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
16001 		NULL,
16002 	},
16003 };
16004 
16005 /** Set MPLSoUDP encapsulation details */
16006 struct cmd_set_mplsoudp_encap_result {
16007 	cmdline_fixed_string_t set;
16008 	cmdline_fixed_string_t mplsoudp;
16009 	cmdline_fixed_string_t pos_token;
16010 	cmdline_fixed_string_t ip_version;
16011 	uint32_t vlan_present:1;
16012 	uint32_t label;
16013 	uint16_t udp_src;
16014 	uint16_t udp_dst;
16015 	cmdline_ipaddr_t ip_src;
16016 	cmdline_ipaddr_t ip_dst;
16017 	uint16_t tci;
16018 	struct rte_ether_addr eth_src;
16019 	struct rte_ether_addr eth_dst;
16020 };
16021 
16022 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16023 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16024 				 "set");
16025 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16026 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16027 				 "mplsoudp_encap");
16028 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16029 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16030 				 mplsoudp, "mplsoudp_encap-with-vlan");
16031 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16032 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16033 				 pos_token, "ip-version");
16034 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16035 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16036 				 ip_version, "ipv4#ipv6");
16037 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16038 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16039 				 pos_token, "label");
16040 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16041 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16042 			      UINT32);
16043 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16044 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16045 				 pos_token, "udp-src");
16046 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16047 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16048 			      UINT16);
16049 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16050 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16051 				 pos_token, "udp-dst");
16052 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16053 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16054 			      UINT16);
16055 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16056 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16057 				 pos_token, "ip-src");
16058 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16059 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16060 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16061 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16062 				 pos_token, "ip-dst");
16063 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16064 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16065 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16066 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16067 				 pos_token, "vlan-tci");
16068 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16069 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16070 			      UINT16);
16071 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16072 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16073 				 pos_token, "eth-src");
16074 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16075 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16076 				    eth_src);
16077 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16078 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16079 				 pos_token, "eth-dst");
16080 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16081 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16082 				    eth_dst);
16083 
16084 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16085 	__attribute__((unused)) struct cmdline *cl,
16086 	__attribute__((unused)) void *data)
16087 {
16088 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16089 	union {
16090 		uint32_t mplsoudp_label;
16091 		uint8_t label[4];
16092 	} id = {
16093 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16094 	};
16095 
16096 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16097 		mplsoudp_encap_conf.select_vlan = 0;
16098 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16099 		mplsoudp_encap_conf.select_vlan = 1;
16100 	if (strcmp(res->ip_version, "ipv4") == 0)
16101 		mplsoudp_encap_conf.select_ipv4 = 1;
16102 	else if (strcmp(res->ip_version, "ipv6") == 0)
16103 		mplsoudp_encap_conf.select_ipv4 = 0;
16104 	else
16105 		return;
16106 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16107 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16108 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16109 	if (mplsoudp_encap_conf.select_ipv4) {
16110 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16111 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16112 	} else {
16113 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16114 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16115 	}
16116 	if (mplsoudp_encap_conf.select_vlan)
16117 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16118 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16119 		   RTE_ETHER_ADDR_LEN);
16120 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16121 		   RTE_ETHER_ADDR_LEN);
16122 }
16123 
16124 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16125 	.f = cmd_set_mplsoudp_encap_parsed,
16126 	.data = NULL,
16127 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16128 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16129 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16130 	.tokens = {
16131 		(void *)&cmd_set_mplsoudp_encap_set,
16132 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16133 		(void *)&cmd_set_mplsoudp_encap_ip_version,
16134 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
16135 		(void *)&cmd_set_mplsoudp_encap_label,
16136 		(void *)&cmd_set_mplsoudp_encap_label_value,
16137 		(void *)&cmd_set_mplsoudp_encap_udp_src,
16138 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
16139 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
16140 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16141 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16142 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16143 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16144 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16145 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16146 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16147 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16148 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16149 		NULL,
16150 	},
16151 };
16152 
16153 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16154 	.f = cmd_set_mplsoudp_encap_parsed,
16155 	.data = NULL,
16156 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16157 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
16158 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16159 		" eth-src <eth-src> eth-dst <eth-dst>",
16160 	.tokens = {
16161 		(void *)&cmd_set_mplsoudp_encap_set,
16162 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16163 		(void *)&cmd_set_mplsoudp_encap_ip_version,
16164 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
16165 		(void *)&cmd_set_mplsoudp_encap_label,
16166 		(void *)&cmd_set_mplsoudp_encap_label_value,
16167 		(void *)&cmd_set_mplsoudp_encap_udp_src,
16168 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
16169 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
16170 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16171 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16172 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16173 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16174 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16175 		(void *)&cmd_set_mplsoudp_encap_vlan,
16176 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
16177 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16178 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16179 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16180 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16181 		NULL,
16182 	},
16183 };
16184 
16185 /** Set MPLSoUDP decapsulation details */
16186 struct cmd_set_mplsoudp_decap_result {
16187 	cmdline_fixed_string_t set;
16188 	cmdline_fixed_string_t mplsoudp;
16189 	cmdline_fixed_string_t pos_token;
16190 	cmdline_fixed_string_t ip_version;
16191 	uint32_t vlan_present:1;
16192 };
16193 
16194 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16195 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16196 				 "set");
16197 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16198 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16199 				 "mplsoudp_decap");
16200 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16201 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16202 				 mplsoudp, "mplsoudp_decap-with-vlan");
16203 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16204 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16205 				 pos_token, "ip-version");
16206 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16207 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16208 				 ip_version, "ipv4#ipv6");
16209 
16210 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16211 	__attribute__((unused)) struct cmdline *cl,
16212 	__attribute__((unused)) void *data)
16213 {
16214 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16215 
16216 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16217 		mplsoudp_decap_conf.select_vlan = 0;
16218 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16219 		mplsoudp_decap_conf.select_vlan = 1;
16220 	if (strcmp(res->ip_version, "ipv4") == 0)
16221 		mplsoudp_decap_conf.select_ipv4 = 1;
16222 	else if (strcmp(res->ip_version, "ipv6") == 0)
16223 		mplsoudp_decap_conf.select_ipv4 = 0;
16224 }
16225 
16226 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16227 	.f = cmd_set_mplsoudp_decap_parsed,
16228 	.data = NULL,
16229 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16230 	.tokens = {
16231 		(void *)&cmd_set_mplsoudp_decap_set,
16232 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16233 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16234 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16235 		NULL,
16236 	},
16237 };
16238 
16239 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16240 	.f = cmd_set_mplsoudp_decap_parsed,
16241 	.data = NULL,
16242 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16243 	.tokens = {
16244 		(void *)&cmd_set_mplsoudp_decap_set,
16245 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16246 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16247 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16248 		NULL,
16249 	},
16250 };
16251 
16252 /* Strict link priority scheduling mode setting */
16253 static void
16254 cmd_strict_link_prio_parsed(
16255 	void *parsed_result,
16256 	__attribute__((unused)) struct cmdline *cl,
16257 	__attribute__((unused)) void *data)
16258 {
16259 	struct cmd_vf_tc_bw_result *res = parsed_result;
16260 	int ret = -ENOTSUP;
16261 
16262 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16263 		return;
16264 
16265 #ifdef RTE_LIBRTE_I40E_PMD
16266 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16267 #endif
16268 
16269 	switch (ret) {
16270 	case 0:
16271 		break;
16272 	case -EINVAL:
16273 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16274 		break;
16275 	case -ENODEV:
16276 		printf("invalid port_id %d\n", res->port_id);
16277 		break;
16278 	case -ENOTSUP:
16279 		printf("function not implemented\n");
16280 		break;
16281 	default:
16282 		printf("programming error: (%s)\n", strerror(-ret));
16283 	}
16284 }
16285 
16286 cmdline_parse_inst_t cmd_strict_link_prio = {
16287 	.f = cmd_strict_link_prio_parsed,
16288 	.data = NULL,
16289 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16290 	.tokens = {
16291 		(void *)&cmd_vf_tc_bw_set,
16292 		(void *)&cmd_vf_tc_bw_tx,
16293 		(void *)&cmd_vf_tc_bw_strict_link_prio,
16294 		(void *)&cmd_vf_tc_bw_port_id,
16295 		(void *)&cmd_vf_tc_bw_tc_map,
16296 		NULL,
16297 	},
16298 };
16299 
16300 /* Load dynamic device personalization*/
16301 struct cmd_ddp_add_result {
16302 	cmdline_fixed_string_t ddp;
16303 	cmdline_fixed_string_t add;
16304 	portid_t port_id;
16305 	char filepath[];
16306 };
16307 
16308 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16309 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16310 cmdline_parse_token_string_t cmd_ddp_add_add =
16311 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16312 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16313 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16314 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16315 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16316 
16317 static void
16318 cmd_ddp_add_parsed(
16319 	void *parsed_result,
16320 	__attribute__((unused)) struct cmdline *cl,
16321 	__attribute__((unused)) void *data)
16322 {
16323 	struct cmd_ddp_add_result *res = parsed_result;
16324 	uint8_t *buff;
16325 	uint32_t size;
16326 	char *filepath;
16327 	char *file_fld[2];
16328 	int file_num;
16329 	int ret = -ENOTSUP;
16330 
16331 	if (!all_ports_stopped()) {
16332 		printf("Please stop all ports first\n");
16333 		return;
16334 	}
16335 
16336 	filepath = strdup(res->filepath);
16337 	if (filepath == NULL) {
16338 		printf("Failed to allocate memory\n");
16339 		return;
16340 	}
16341 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16342 
16343 	buff = open_file(file_fld[0], &size);
16344 	if (!buff) {
16345 		free((void *)filepath);
16346 		return;
16347 	}
16348 
16349 #ifdef RTE_LIBRTE_I40E_PMD
16350 	if (ret == -ENOTSUP)
16351 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16352 					       buff, size,
16353 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
16354 #endif
16355 
16356 	if (ret == -EEXIST)
16357 		printf("Profile has already existed.\n");
16358 	else if (ret < 0)
16359 		printf("Failed to load profile.\n");
16360 	else if (file_num == 2)
16361 		save_file(file_fld[1], buff, size);
16362 
16363 	close_file(buff);
16364 	free((void *)filepath);
16365 }
16366 
16367 cmdline_parse_inst_t cmd_ddp_add = {
16368 	.f = cmd_ddp_add_parsed,
16369 	.data = NULL,
16370 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16371 	.tokens = {
16372 		(void *)&cmd_ddp_add_ddp,
16373 		(void *)&cmd_ddp_add_add,
16374 		(void *)&cmd_ddp_add_port_id,
16375 		(void *)&cmd_ddp_add_filepath,
16376 		NULL,
16377 	},
16378 };
16379 
16380 /* Delete dynamic device personalization*/
16381 struct cmd_ddp_del_result {
16382 	cmdline_fixed_string_t ddp;
16383 	cmdline_fixed_string_t del;
16384 	portid_t port_id;
16385 	char filepath[];
16386 };
16387 
16388 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16389 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16390 cmdline_parse_token_string_t cmd_ddp_del_del =
16391 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16392 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16393 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16394 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16395 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16396 
16397 static void
16398 cmd_ddp_del_parsed(
16399 	void *parsed_result,
16400 	__attribute__((unused)) struct cmdline *cl,
16401 	__attribute__((unused)) void *data)
16402 {
16403 	struct cmd_ddp_del_result *res = parsed_result;
16404 	uint8_t *buff;
16405 	uint32_t size;
16406 	int ret = -ENOTSUP;
16407 
16408 	if (!all_ports_stopped()) {
16409 		printf("Please stop all ports first\n");
16410 		return;
16411 	}
16412 
16413 	buff = open_file(res->filepath, &size);
16414 	if (!buff)
16415 		return;
16416 
16417 #ifdef RTE_LIBRTE_I40E_PMD
16418 	if (ret == -ENOTSUP)
16419 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16420 					       buff, size,
16421 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
16422 #endif
16423 
16424 	if (ret == -EACCES)
16425 		printf("Profile does not exist.\n");
16426 	else if (ret < 0)
16427 		printf("Failed to delete profile.\n");
16428 
16429 	close_file(buff);
16430 }
16431 
16432 cmdline_parse_inst_t cmd_ddp_del = {
16433 	.f = cmd_ddp_del_parsed,
16434 	.data = NULL,
16435 	.help_str = "ddp del <port_id> <backup_profile_path>",
16436 	.tokens = {
16437 		(void *)&cmd_ddp_del_ddp,
16438 		(void *)&cmd_ddp_del_del,
16439 		(void *)&cmd_ddp_del_port_id,
16440 		(void *)&cmd_ddp_del_filepath,
16441 		NULL,
16442 	},
16443 };
16444 
16445 /* Get dynamic device personalization profile info */
16446 struct cmd_ddp_info_result {
16447 	cmdline_fixed_string_t ddp;
16448 	cmdline_fixed_string_t get;
16449 	cmdline_fixed_string_t info;
16450 	char filepath[];
16451 };
16452 
16453 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16454 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16455 cmdline_parse_token_string_t cmd_ddp_info_get =
16456 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16457 cmdline_parse_token_string_t cmd_ddp_info_info =
16458 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16459 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16460 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16461 
16462 static void
16463 cmd_ddp_info_parsed(
16464 	void *parsed_result,
16465 	__attribute__((unused)) struct cmdline *cl,
16466 	__attribute__((unused)) void *data)
16467 {
16468 	struct cmd_ddp_info_result *res = parsed_result;
16469 	uint8_t *pkg;
16470 	uint32_t pkg_size;
16471 	int ret = -ENOTSUP;
16472 #ifdef RTE_LIBRTE_I40E_PMD
16473 	uint32_t i, j, n;
16474 	uint8_t *buff;
16475 	uint32_t buff_size = 0;
16476 	struct rte_pmd_i40e_profile_info info;
16477 	uint32_t dev_num = 0;
16478 	struct rte_pmd_i40e_ddp_device_id *devs;
16479 	uint32_t proto_num = 0;
16480 	struct rte_pmd_i40e_proto_info *proto = NULL;
16481 	uint32_t pctype_num = 0;
16482 	struct rte_pmd_i40e_ptype_info *pctype;
16483 	uint32_t ptype_num = 0;
16484 	struct rte_pmd_i40e_ptype_info *ptype;
16485 	uint8_t proto_id;
16486 
16487 #endif
16488 
16489 	pkg = open_file(res->filepath, &pkg_size);
16490 	if (!pkg)
16491 		return;
16492 
16493 #ifdef RTE_LIBRTE_I40E_PMD
16494 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16495 				(uint8_t *)&info, sizeof(info),
16496 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16497 	if (!ret) {
16498 		printf("Global Track id:       0x%x\n", info.track_id);
16499 		printf("Global Version:        %d.%d.%d.%d\n",
16500 			info.version.major,
16501 			info.version.minor,
16502 			info.version.update,
16503 			info.version.draft);
16504 		printf("Global Package name:   %s\n\n", info.name);
16505 	}
16506 
16507 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16508 				(uint8_t *)&info, sizeof(info),
16509 				RTE_PMD_I40E_PKG_INFO_HEADER);
16510 	if (!ret) {
16511 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
16512 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
16513 			info.version.major,
16514 			info.version.minor,
16515 			info.version.update,
16516 			info.version.draft);
16517 		printf("i40e Profile name:     %s\n\n", info.name);
16518 	}
16519 
16520 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16521 				(uint8_t *)&buff_size, sizeof(buff_size),
16522 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16523 	if (!ret && buff_size) {
16524 		buff = (uint8_t *)malloc(buff_size);
16525 		if (buff) {
16526 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16527 						buff, buff_size,
16528 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16529 			if (!ret)
16530 				printf("Package Notes:\n%s\n\n", buff);
16531 			free(buff);
16532 		}
16533 	}
16534 
16535 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16536 				(uint8_t *)&dev_num, sizeof(dev_num),
16537 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16538 	if (!ret && dev_num) {
16539 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16540 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16541 		if (devs) {
16542 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16543 						(uint8_t *)devs, buff_size,
16544 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16545 			if (!ret) {
16546 				printf("List of supported devices:\n");
16547 				for (i = 0; i < dev_num; i++) {
16548 					printf("  %04X:%04X %04X:%04X\n",
16549 						devs[i].vendor_dev_id >> 16,
16550 						devs[i].vendor_dev_id & 0xFFFF,
16551 						devs[i].sub_vendor_dev_id >> 16,
16552 						devs[i].sub_vendor_dev_id & 0xFFFF);
16553 				}
16554 				printf("\n");
16555 			}
16556 			free(devs);
16557 		}
16558 	}
16559 
16560 	/* get information about protocols and packet types */
16561 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16562 		(uint8_t *)&proto_num, sizeof(proto_num),
16563 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16564 	if (ret || !proto_num)
16565 		goto no_print_return;
16566 
16567 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16568 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16569 	if (!proto)
16570 		goto no_print_return;
16571 
16572 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16573 					buff_size,
16574 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16575 	if (!ret) {
16576 		printf("List of used protocols:\n");
16577 		for (i = 0; i < proto_num; i++)
16578 			printf("  %2u: %s\n", proto[i].proto_id,
16579 			       proto[i].name);
16580 		printf("\n");
16581 	}
16582 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16583 		(uint8_t *)&pctype_num, sizeof(pctype_num),
16584 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16585 	if (ret || !pctype_num)
16586 		goto no_print_pctypes;
16587 
16588 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16589 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16590 	if (!pctype)
16591 		goto no_print_pctypes;
16592 
16593 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16594 					buff_size,
16595 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16596 	if (ret) {
16597 		free(pctype);
16598 		goto no_print_pctypes;
16599 	}
16600 
16601 	printf("List of defined packet classification types:\n");
16602 	for (i = 0; i < pctype_num; i++) {
16603 		printf("  %2u:", pctype[i].ptype_id);
16604 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16605 			proto_id = pctype[i].protocols[j];
16606 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16607 				for (n = 0; n < proto_num; n++) {
16608 					if (proto[n].proto_id == proto_id) {
16609 						printf(" %s", proto[n].name);
16610 						break;
16611 					}
16612 				}
16613 			}
16614 		}
16615 		printf("\n");
16616 	}
16617 	printf("\n");
16618 	free(pctype);
16619 
16620 no_print_pctypes:
16621 
16622 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16623 					sizeof(ptype_num),
16624 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16625 	if (ret || !ptype_num)
16626 		goto no_print_return;
16627 
16628 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16629 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16630 	if (!ptype)
16631 		goto no_print_return;
16632 
16633 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16634 					buff_size,
16635 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16636 	if (ret) {
16637 		free(ptype);
16638 		goto no_print_return;
16639 	}
16640 	printf("List of defined packet types:\n");
16641 	for (i = 0; i < ptype_num; i++) {
16642 		printf("  %2u:", ptype[i].ptype_id);
16643 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16644 			proto_id = ptype[i].protocols[j];
16645 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16646 				for (n = 0; n < proto_num; n++) {
16647 					if (proto[n].proto_id == proto_id) {
16648 						printf(" %s", proto[n].name);
16649 						break;
16650 					}
16651 				}
16652 			}
16653 		}
16654 		printf("\n");
16655 	}
16656 	free(ptype);
16657 	printf("\n");
16658 
16659 	ret = 0;
16660 no_print_return:
16661 	if (proto)
16662 		free(proto);
16663 #endif
16664 	if (ret == -ENOTSUP)
16665 		printf("Function not supported in PMD driver\n");
16666 	close_file(pkg);
16667 }
16668 
16669 cmdline_parse_inst_t cmd_ddp_get_info = {
16670 	.f = cmd_ddp_info_parsed,
16671 	.data = NULL,
16672 	.help_str = "ddp get info <profile_path>",
16673 	.tokens = {
16674 		(void *)&cmd_ddp_info_ddp,
16675 		(void *)&cmd_ddp_info_get,
16676 		(void *)&cmd_ddp_info_info,
16677 		(void *)&cmd_ddp_info_filepath,
16678 		NULL,
16679 	},
16680 };
16681 
16682 /* Get dynamic device personalization profile info list*/
16683 #define PROFILE_INFO_SIZE 48
16684 #define MAX_PROFILE_NUM 16
16685 
16686 struct cmd_ddp_get_list_result {
16687 	cmdline_fixed_string_t ddp;
16688 	cmdline_fixed_string_t get;
16689 	cmdline_fixed_string_t list;
16690 	portid_t port_id;
16691 };
16692 
16693 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16694 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16695 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16696 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16697 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16698 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16699 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16700 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16701 
16702 static void
16703 cmd_ddp_get_list_parsed(
16704 	__attribute__((unused)) void *parsed_result,
16705 	__attribute__((unused)) struct cmdline *cl,
16706 	__attribute__((unused)) void *data)
16707 {
16708 #ifdef RTE_LIBRTE_I40E_PMD
16709 	struct cmd_ddp_get_list_result *res = parsed_result;
16710 	struct rte_pmd_i40e_profile_list *p_list;
16711 	struct rte_pmd_i40e_profile_info *p_info;
16712 	uint32_t p_num;
16713 	uint32_t size;
16714 	uint32_t i;
16715 #endif
16716 	int ret = -ENOTSUP;
16717 
16718 #ifdef RTE_LIBRTE_I40E_PMD
16719 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16720 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16721 	if (!p_list)
16722 		printf("%s: Failed to malloc buffer\n", __func__);
16723 
16724 	if (ret == -ENOTSUP)
16725 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16726 						(uint8_t *)p_list, size);
16727 
16728 	if (!ret) {
16729 		p_num = p_list->p_count;
16730 		printf("Profile number is: %d\n\n", p_num);
16731 
16732 		for (i = 0; i < p_num; i++) {
16733 			p_info = &p_list->p_info[i];
16734 			printf("Profile %d:\n", i);
16735 			printf("Track id:     0x%x\n", p_info->track_id);
16736 			printf("Version:      %d.%d.%d.%d\n",
16737 			       p_info->version.major,
16738 			       p_info->version.minor,
16739 			       p_info->version.update,
16740 			       p_info->version.draft);
16741 			printf("Profile name: %s\n\n", p_info->name);
16742 		}
16743 	}
16744 
16745 	free(p_list);
16746 #endif
16747 
16748 	if (ret < 0)
16749 		printf("Failed to get ddp list\n");
16750 }
16751 
16752 cmdline_parse_inst_t cmd_ddp_get_list = {
16753 	.f = cmd_ddp_get_list_parsed,
16754 	.data = NULL,
16755 	.help_str = "ddp get list <port_id>",
16756 	.tokens = {
16757 		(void *)&cmd_ddp_get_list_ddp,
16758 		(void *)&cmd_ddp_get_list_get,
16759 		(void *)&cmd_ddp_get_list_list,
16760 		(void *)&cmd_ddp_get_list_port_id,
16761 		NULL,
16762 	},
16763 };
16764 
16765 /* Configure input set */
16766 struct cmd_cfg_input_set_result {
16767 	cmdline_fixed_string_t port;
16768 	cmdline_fixed_string_t cfg;
16769 	portid_t port_id;
16770 	cmdline_fixed_string_t pctype;
16771 	uint8_t pctype_id;
16772 	cmdline_fixed_string_t inset_type;
16773 	cmdline_fixed_string_t opt;
16774 	cmdline_fixed_string_t field;
16775 	uint8_t field_idx;
16776 };
16777 
16778 static void
16779 cmd_cfg_input_set_parsed(
16780 	__attribute__((unused)) void *parsed_result,
16781 	__attribute__((unused)) struct cmdline *cl,
16782 	__attribute__((unused)) void *data)
16783 {
16784 #ifdef RTE_LIBRTE_I40E_PMD
16785 	struct cmd_cfg_input_set_result *res = parsed_result;
16786 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16787 	struct rte_pmd_i40e_inset inset;
16788 #endif
16789 	int ret = -ENOTSUP;
16790 
16791 	if (!all_ports_stopped()) {
16792 		printf("Please stop all ports first\n");
16793 		return;
16794 	}
16795 
16796 #ifdef RTE_LIBRTE_I40E_PMD
16797 	if (!strcmp(res->inset_type, "hash_inset"))
16798 		inset_type = INSET_HASH;
16799 	else if (!strcmp(res->inset_type, "fdir_inset"))
16800 		inset_type = INSET_FDIR;
16801 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16802 		inset_type = INSET_FDIR_FLX;
16803 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16804 				     &inset, inset_type);
16805 	if (ret) {
16806 		printf("Failed to get input set.\n");
16807 		return;
16808 	}
16809 
16810 	if (!strcmp(res->opt, "get")) {
16811 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
16812 						   res->field_idx);
16813 		if (ret)
16814 			printf("Field index %d is enabled.\n", res->field_idx);
16815 		else
16816 			printf("Field index %d is disabled.\n", res->field_idx);
16817 		return;
16818 	} else if (!strcmp(res->opt, "set"))
16819 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16820 						   res->field_idx);
16821 	else if (!strcmp(res->opt, "clear"))
16822 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16823 						     res->field_idx);
16824 	if (ret) {
16825 		printf("Failed to configure input set field.\n");
16826 		return;
16827 	}
16828 
16829 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16830 				     &inset, inset_type);
16831 	if (ret) {
16832 		printf("Failed to set input set.\n");
16833 		return;
16834 	}
16835 #endif
16836 
16837 	if (ret == -ENOTSUP)
16838 		printf("Function not supported\n");
16839 }
16840 
16841 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16842 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16843 				 port, "port");
16844 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16845 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16846 				 cfg, "config");
16847 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16848 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16849 			      port_id, UINT16);
16850 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16851 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16852 				 pctype, "pctype");
16853 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16854 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16855 			      pctype_id, UINT8);
16856 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16857 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16858 				 inset_type,
16859 				 "hash_inset#fdir_inset#fdir_flx_inset");
16860 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16861 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16862 				 opt, "get#set#clear");
16863 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16864 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16865 				 field, "field");
16866 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16867 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16868 			      field_idx, UINT8);
16869 
16870 cmdline_parse_inst_t cmd_cfg_input_set = {
16871 	.f = cmd_cfg_input_set_parsed,
16872 	.data = NULL,
16873 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16874 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16875 	.tokens = {
16876 		(void *)&cmd_cfg_input_set_port,
16877 		(void *)&cmd_cfg_input_set_cfg,
16878 		(void *)&cmd_cfg_input_set_port_id,
16879 		(void *)&cmd_cfg_input_set_pctype,
16880 		(void *)&cmd_cfg_input_set_pctype_id,
16881 		(void *)&cmd_cfg_input_set_inset_type,
16882 		(void *)&cmd_cfg_input_set_opt,
16883 		(void *)&cmd_cfg_input_set_field,
16884 		(void *)&cmd_cfg_input_set_field_idx,
16885 		NULL,
16886 	},
16887 };
16888 
16889 /* Clear input set */
16890 struct cmd_clear_input_set_result {
16891 	cmdline_fixed_string_t port;
16892 	cmdline_fixed_string_t cfg;
16893 	portid_t port_id;
16894 	cmdline_fixed_string_t pctype;
16895 	uint8_t pctype_id;
16896 	cmdline_fixed_string_t inset_type;
16897 	cmdline_fixed_string_t clear;
16898 	cmdline_fixed_string_t all;
16899 };
16900 
16901 static void
16902 cmd_clear_input_set_parsed(
16903 	__attribute__((unused)) void *parsed_result,
16904 	__attribute__((unused)) struct cmdline *cl,
16905 	__attribute__((unused)) void *data)
16906 {
16907 #ifdef RTE_LIBRTE_I40E_PMD
16908 	struct cmd_clear_input_set_result *res = parsed_result;
16909 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16910 	struct rte_pmd_i40e_inset inset;
16911 #endif
16912 	int ret = -ENOTSUP;
16913 
16914 	if (!all_ports_stopped()) {
16915 		printf("Please stop all ports first\n");
16916 		return;
16917 	}
16918 
16919 #ifdef RTE_LIBRTE_I40E_PMD
16920 	if (!strcmp(res->inset_type, "hash_inset"))
16921 		inset_type = INSET_HASH;
16922 	else if (!strcmp(res->inset_type, "fdir_inset"))
16923 		inset_type = INSET_FDIR;
16924 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16925 		inset_type = INSET_FDIR_FLX;
16926 
16927 	memset(&inset, 0, sizeof(inset));
16928 
16929 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16930 				     &inset, inset_type);
16931 	if (ret) {
16932 		printf("Failed to clear input set.\n");
16933 		return;
16934 	}
16935 
16936 #endif
16937 
16938 	if (ret == -ENOTSUP)
16939 		printf("Function not supported\n");
16940 }
16941 
16942 cmdline_parse_token_string_t cmd_clear_input_set_port =
16943 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16944 				 port, "port");
16945 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16946 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16947 				 cfg, "config");
16948 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16949 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16950 			      port_id, UINT16);
16951 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16952 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16953 				 pctype, "pctype");
16954 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16955 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16956 			      pctype_id, UINT8);
16957 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16958 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16959 				 inset_type,
16960 				 "hash_inset#fdir_inset#fdir_flx_inset");
16961 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16962 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16963 				 clear, "clear");
16964 cmdline_parse_token_string_t cmd_clear_input_set_all =
16965 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16966 				 all, "all");
16967 
16968 cmdline_parse_inst_t cmd_clear_input_set = {
16969 	.f = cmd_clear_input_set_parsed,
16970 	.data = NULL,
16971 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16972 		    "fdir_inset|fdir_flx_inset clear all",
16973 	.tokens = {
16974 		(void *)&cmd_clear_input_set_port,
16975 		(void *)&cmd_clear_input_set_cfg,
16976 		(void *)&cmd_clear_input_set_port_id,
16977 		(void *)&cmd_clear_input_set_pctype,
16978 		(void *)&cmd_clear_input_set_pctype_id,
16979 		(void *)&cmd_clear_input_set_inset_type,
16980 		(void *)&cmd_clear_input_set_clear,
16981 		(void *)&cmd_clear_input_set_all,
16982 		NULL,
16983 	},
16984 };
16985 
16986 /* show vf stats */
16987 
16988 /* Common result structure for show vf stats */
16989 struct cmd_show_vf_stats_result {
16990 	cmdline_fixed_string_t show;
16991 	cmdline_fixed_string_t vf;
16992 	cmdline_fixed_string_t stats;
16993 	portid_t port_id;
16994 	uint16_t vf_id;
16995 };
16996 
16997 /* Common CLI fields show vf stats*/
16998 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16999 	TOKEN_STRING_INITIALIZER
17000 		(struct cmd_show_vf_stats_result,
17001 		 show, "show");
17002 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17003 	TOKEN_STRING_INITIALIZER
17004 		(struct cmd_show_vf_stats_result,
17005 		 vf, "vf");
17006 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17007 	TOKEN_STRING_INITIALIZER
17008 		(struct cmd_show_vf_stats_result,
17009 		 stats, "stats");
17010 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17011 	TOKEN_NUM_INITIALIZER
17012 		(struct cmd_show_vf_stats_result,
17013 		 port_id, UINT16);
17014 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17015 	TOKEN_NUM_INITIALIZER
17016 		(struct cmd_show_vf_stats_result,
17017 		 vf_id, UINT16);
17018 
17019 static void
17020 cmd_show_vf_stats_parsed(
17021 	void *parsed_result,
17022 	__attribute__((unused)) struct cmdline *cl,
17023 	__attribute__((unused)) void *data)
17024 {
17025 	struct cmd_show_vf_stats_result *res = parsed_result;
17026 	struct rte_eth_stats stats;
17027 	int ret = -ENOTSUP;
17028 	static const char *nic_stats_border = "########################";
17029 
17030 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17031 		return;
17032 
17033 	memset(&stats, 0, sizeof(stats));
17034 
17035 #ifdef RTE_LIBRTE_I40E_PMD
17036 	if (ret == -ENOTSUP)
17037 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17038 						res->vf_id,
17039 						&stats);
17040 #endif
17041 #ifdef RTE_LIBRTE_BNXT_PMD
17042 	if (ret == -ENOTSUP)
17043 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17044 						res->vf_id,
17045 						&stats);
17046 #endif
17047 
17048 	switch (ret) {
17049 	case 0:
17050 		break;
17051 	case -EINVAL:
17052 		printf("invalid vf_id %d\n", res->vf_id);
17053 		break;
17054 	case -ENODEV:
17055 		printf("invalid port_id %d\n", res->port_id);
17056 		break;
17057 	case -ENOTSUP:
17058 		printf("function not implemented\n");
17059 		break;
17060 	default:
17061 		printf("programming error: (%s)\n", strerror(-ret));
17062 	}
17063 
17064 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
17065 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17066 
17067 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
17068 	       "%-"PRIu64"\n",
17069 	       stats.ipackets, stats.imissed, stats.ibytes);
17070 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
17071 	printf("  RX-nombuf:  %-10"PRIu64"\n",
17072 	       stats.rx_nombuf);
17073 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
17074 	       "%-"PRIu64"\n",
17075 	       stats.opackets, stats.oerrors, stats.obytes);
17076 
17077 	printf("  %s############################%s\n",
17078 			       nic_stats_border, nic_stats_border);
17079 }
17080 
17081 cmdline_parse_inst_t cmd_show_vf_stats = {
17082 	.f = cmd_show_vf_stats_parsed,
17083 	.data = NULL,
17084 	.help_str = "show vf stats <port_id> <vf_id>",
17085 	.tokens = {
17086 		(void *)&cmd_show_vf_stats_show,
17087 		(void *)&cmd_show_vf_stats_vf,
17088 		(void *)&cmd_show_vf_stats_stats,
17089 		(void *)&cmd_show_vf_stats_port_id,
17090 		(void *)&cmd_show_vf_stats_vf_id,
17091 		NULL,
17092 	},
17093 };
17094 
17095 /* clear vf stats */
17096 
17097 /* Common result structure for clear vf stats */
17098 struct cmd_clear_vf_stats_result {
17099 	cmdline_fixed_string_t clear;
17100 	cmdline_fixed_string_t vf;
17101 	cmdline_fixed_string_t stats;
17102 	portid_t port_id;
17103 	uint16_t vf_id;
17104 };
17105 
17106 /* Common CLI fields clear vf stats*/
17107 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17108 	TOKEN_STRING_INITIALIZER
17109 		(struct cmd_clear_vf_stats_result,
17110 		 clear, "clear");
17111 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17112 	TOKEN_STRING_INITIALIZER
17113 		(struct cmd_clear_vf_stats_result,
17114 		 vf, "vf");
17115 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17116 	TOKEN_STRING_INITIALIZER
17117 		(struct cmd_clear_vf_stats_result,
17118 		 stats, "stats");
17119 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17120 	TOKEN_NUM_INITIALIZER
17121 		(struct cmd_clear_vf_stats_result,
17122 		 port_id, UINT16);
17123 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17124 	TOKEN_NUM_INITIALIZER
17125 		(struct cmd_clear_vf_stats_result,
17126 		 vf_id, UINT16);
17127 
17128 static void
17129 cmd_clear_vf_stats_parsed(
17130 	void *parsed_result,
17131 	__attribute__((unused)) struct cmdline *cl,
17132 	__attribute__((unused)) void *data)
17133 {
17134 	struct cmd_clear_vf_stats_result *res = parsed_result;
17135 	int ret = -ENOTSUP;
17136 
17137 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17138 		return;
17139 
17140 #ifdef RTE_LIBRTE_I40E_PMD
17141 	if (ret == -ENOTSUP)
17142 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17143 						  res->vf_id);
17144 #endif
17145 #ifdef RTE_LIBRTE_BNXT_PMD
17146 	if (ret == -ENOTSUP)
17147 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17148 						  res->vf_id);
17149 #endif
17150 
17151 	switch (ret) {
17152 	case 0:
17153 		break;
17154 	case -EINVAL:
17155 		printf("invalid vf_id %d\n", res->vf_id);
17156 		break;
17157 	case -ENODEV:
17158 		printf("invalid port_id %d\n", res->port_id);
17159 		break;
17160 	case -ENOTSUP:
17161 		printf("function not implemented\n");
17162 		break;
17163 	default:
17164 		printf("programming error: (%s)\n", strerror(-ret));
17165 	}
17166 }
17167 
17168 cmdline_parse_inst_t cmd_clear_vf_stats = {
17169 	.f = cmd_clear_vf_stats_parsed,
17170 	.data = NULL,
17171 	.help_str = "clear vf stats <port_id> <vf_id>",
17172 	.tokens = {
17173 		(void *)&cmd_clear_vf_stats_clear,
17174 		(void *)&cmd_clear_vf_stats_vf,
17175 		(void *)&cmd_clear_vf_stats_stats,
17176 		(void *)&cmd_clear_vf_stats_port_id,
17177 		(void *)&cmd_clear_vf_stats_vf_id,
17178 		NULL,
17179 	},
17180 };
17181 
17182 /* port config pctype mapping reset */
17183 
17184 /* Common result structure for port config pctype mapping reset */
17185 struct cmd_pctype_mapping_reset_result {
17186 	cmdline_fixed_string_t port;
17187 	cmdline_fixed_string_t config;
17188 	portid_t port_id;
17189 	cmdline_fixed_string_t pctype;
17190 	cmdline_fixed_string_t mapping;
17191 	cmdline_fixed_string_t reset;
17192 };
17193 
17194 /* Common CLI fields for port config pctype mapping reset*/
17195 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17196 	TOKEN_STRING_INITIALIZER
17197 		(struct cmd_pctype_mapping_reset_result,
17198 		 port, "port");
17199 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17200 	TOKEN_STRING_INITIALIZER
17201 		(struct cmd_pctype_mapping_reset_result,
17202 		 config, "config");
17203 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17204 	TOKEN_NUM_INITIALIZER
17205 		(struct cmd_pctype_mapping_reset_result,
17206 		 port_id, UINT16);
17207 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17208 	TOKEN_STRING_INITIALIZER
17209 		(struct cmd_pctype_mapping_reset_result,
17210 		 pctype, "pctype");
17211 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17212 	TOKEN_STRING_INITIALIZER
17213 		(struct cmd_pctype_mapping_reset_result,
17214 		 mapping, "mapping");
17215 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17216 	TOKEN_STRING_INITIALIZER
17217 		(struct cmd_pctype_mapping_reset_result,
17218 		 reset, "reset");
17219 
17220 static void
17221 cmd_pctype_mapping_reset_parsed(
17222 	void *parsed_result,
17223 	__attribute__((unused)) struct cmdline *cl,
17224 	__attribute__((unused)) void *data)
17225 {
17226 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
17227 	int ret = -ENOTSUP;
17228 
17229 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17230 		return;
17231 
17232 #ifdef RTE_LIBRTE_I40E_PMD
17233 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17234 #endif
17235 
17236 	switch (ret) {
17237 	case 0:
17238 		break;
17239 	case -ENODEV:
17240 		printf("invalid port_id %d\n", res->port_id);
17241 		break;
17242 	case -ENOTSUP:
17243 		printf("function not implemented\n");
17244 		break;
17245 	default:
17246 		printf("programming error: (%s)\n", strerror(-ret));
17247 	}
17248 }
17249 
17250 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17251 	.f = cmd_pctype_mapping_reset_parsed,
17252 	.data = NULL,
17253 	.help_str = "port config <port_id> pctype mapping reset",
17254 	.tokens = {
17255 		(void *)&cmd_pctype_mapping_reset_port,
17256 		(void *)&cmd_pctype_mapping_reset_config,
17257 		(void *)&cmd_pctype_mapping_reset_port_id,
17258 		(void *)&cmd_pctype_mapping_reset_pctype,
17259 		(void *)&cmd_pctype_mapping_reset_mapping,
17260 		(void *)&cmd_pctype_mapping_reset_reset,
17261 		NULL,
17262 	},
17263 };
17264 
17265 /* show port pctype mapping */
17266 
17267 /* Common result structure for show port pctype mapping */
17268 struct cmd_pctype_mapping_get_result {
17269 	cmdline_fixed_string_t show;
17270 	cmdline_fixed_string_t port;
17271 	portid_t port_id;
17272 	cmdline_fixed_string_t pctype;
17273 	cmdline_fixed_string_t mapping;
17274 };
17275 
17276 /* Common CLI fields for pctype mapping get */
17277 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17278 	TOKEN_STRING_INITIALIZER
17279 		(struct cmd_pctype_mapping_get_result,
17280 		 show, "show");
17281 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17282 	TOKEN_STRING_INITIALIZER
17283 		(struct cmd_pctype_mapping_get_result,
17284 		 port, "port");
17285 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17286 	TOKEN_NUM_INITIALIZER
17287 		(struct cmd_pctype_mapping_get_result,
17288 		 port_id, UINT16);
17289 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17290 	TOKEN_STRING_INITIALIZER
17291 		(struct cmd_pctype_mapping_get_result,
17292 		 pctype, "pctype");
17293 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17294 	TOKEN_STRING_INITIALIZER
17295 		(struct cmd_pctype_mapping_get_result,
17296 		 mapping, "mapping");
17297 
17298 static void
17299 cmd_pctype_mapping_get_parsed(
17300 	void *parsed_result,
17301 	__attribute__((unused)) struct cmdline *cl,
17302 	__attribute__((unused)) void *data)
17303 {
17304 	struct cmd_pctype_mapping_get_result *res = parsed_result;
17305 	int ret = -ENOTSUP;
17306 #ifdef RTE_LIBRTE_I40E_PMD
17307 	struct rte_pmd_i40e_flow_type_mapping
17308 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17309 	int i, j, first_pctype;
17310 #endif
17311 
17312 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17313 		return;
17314 
17315 #ifdef RTE_LIBRTE_I40E_PMD
17316 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17317 #endif
17318 
17319 	switch (ret) {
17320 	case 0:
17321 		break;
17322 	case -ENODEV:
17323 		printf("invalid port_id %d\n", res->port_id);
17324 		return;
17325 	case -ENOTSUP:
17326 		printf("function not implemented\n");
17327 		return;
17328 	default:
17329 		printf("programming error: (%s)\n", strerror(-ret));
17330 		return;
17331 	}
17332 
17333 #ifdef RTE_LIBRTE_I40E_PMD
17334 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17335 		if (mapping[i].pctype != 0ULL) {
17336 			first_pctype = 1;
17337 
17338 			printf("pctype: ");
17339 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17340 				if (mapping[i].pctype & (1ULL << j)) {
17341 					printf(first_pctype ?
17342 					       "%02d" : ",%02d", j);
17343 					first_pctype = 0;
17344 				}
17345 			}
17346 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
17347 		}
17348 	}
17349 #endif
17350 }
17351 
17352 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17353 	.f = cmd_pctype_mapping_get_parsed,
17354 	.data = NULL,
17355 	.help_str = "show port <port_id> pctype mapping",
17356 	.tokens = {
17357 		(void *)&cmd_pctype_mapping_get_show,
17358 		(void *)&cmd_pctype_mapping_get_port,
17359 		(void *)&cmd_pctype_mapping_get_port_id,
17360 		(void *)&cmd_pctype_mapping_get_pctype,
17361 		(void *)&cmd_pctype_mapping_get_mapping,
17362 		NULL,
17363 	},
17364 };
17365 
17366 /* port config pctype mapping update */
17367 
17368 /* Common result structure for port config pctype mapping update */
17369 struct cmd_pctype_mapping_update_result {
17370 	cmdline_fixed_string_t port;
17371 	cmdline_fixed_string_t config;
17372 	portid_t port_id;
17373 	cmdline_fixed_string_t pctype;
17374 	cmdline_fixed_string_t mapping;
17375 	cmdline_fixed_string_t update;
17376 	cmdline_fixed_string_t pctype_list;
17377 	uint16_t flow_type;
17378 };
17379 
17380 /* Common CLI fields for pctype mapping update*/
17381 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17382 	TOKEN_STRING_INITIALIZER
17383 		(struct cmd_pctype_mapping_update_result,
17384 		 port, "port");
17385 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17386 	TOKEN_STRING_INITIALIZER
17387 		(struct cmd_pctype_mapping_update_result,
17388 		 config, "config");
17389 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17390 	TOKEN_NUM_INITIALIZER
17391 		(struct cmd_pctype_mapping_update_result,
17392 		 port_id, UINT16);
17393 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17394 	TOKEN_STRING_INITIALIZER
17395 		(struct cmd_pctype_mapping_update_result,
17396 		 pctype, "pctype");
17397 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17398 	TOKEN_STRING_INITIALIZER
17399 		(struct cmd_pctype_mapping_update_result,
17400 		 mapping, "mapping");
17401 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17402 	TOKEN_STRING_INITIALIZER
17403 		(struct cmd_pctype_mapping_update_result,
17404 		 update, "update");
17405 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17406 	TOKEN_STRING_INITIALIZER
17407 		(struct cmd_pctype_mapping_update_result,
17408 		 pctype_list, NULL);
17409 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17410 	TOKEN_NUM_INITIALIZER
17411 		(struct cmd_pctype_mapping_update_result,
17412 		 flow_type, UINT16);
17413 
17414 static void
17415 cmd_pctype_mapping_update_parsed(
17416 	void *parsed_result,
17417 	__attribute__((unused)) struct cmdline *cl,
17418 	__attribute__((unused)) void *data)
17419 {
17420 	struct cmd_pctype_mapping_update_result *res = parsed_result;
17421 	int ret = -ENOTSUP;
17422 #ifdef RTE_LIBRTE_I40E_PMD
17423 	struct rte_pmd_i40e_flow_type_mapping mapping;
17424 	unsigned int i;
17425 	unsigned int nb_item;
17426 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17427 #endif
17428 
17429 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17430 		return;
17431 
17432 #ifdef RTE_LIBRTE_I40E_PMD
17433 	nb_item = parse_item_list(res->pctype_list, "pctypes",
17434 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17435 	mapping.flow_type = res->flow_type;
17436 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17437 		mapping.pctype |= (1ULL << pctype_list[i]);
17438 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17439 						&mapping,
17440 						1,
17441 						0);
17442 #endif
17443 
17444 	switch (ret) {
17445 	case 0:
17446 		break;
17447 	case -EINVAL:
17448 		printf("invalid pctype or flow type\n");
17449 		break;
17450 	case -ENODEV:
17451 		printf("invalid port_id %d\n", res->port_id);
17452 		break;
17453 	case -ENOTSUP:
17454 		printf("function not implemented\n");
17455 		break;
17456 	default:
17457 		printf("programming error: (%s)\n", strerror(-ret));
17458 	}
17459 }
17460 
17461 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17462 	.f = cmd_pctype_mapping_update_parsed,
17463 	.data = NULL,
17464 	.help_str = "port config <port_id> pctype mapping update"
17465 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17466 	.tokens = {
17467 		(void *)&cmd_pctype_mapping_update_port,
17468 		(void *)&cmd_pctype_mapping_update_config,
17469 		(void *)&cmd_pctype_mapping_update_port_id,
17470 		(void *)&cmd_pctype_mapping_update_pctype,
17471 		(void *)&cmd_pctype_mapping_update_mapping,
17472 		(void *)&cmd_pctype_mapping_update_update,
17473 		(void *)&cmd_pctype_mapping_update_pc_type,
17474 		(void *)&cmd_pctype_mapping_update_flow_type,
17475 		NULL,
17476 	},
17477 };
17478 
17479 /* ptype mapping get */
17480 
17481 /* Common result structure for ptype mapping get */
17482 struct cmd_ptype_mapping_get_result {
17483 	cmdline_fixed_string_t ptype;
17484 	cmdline_fixed_string_t mapping;
17485 	cmdline_fixed_string_t get;
17486 	portid_t port_id;
17487 	uint8_t valid_only;
17488 };
17489 
17490 /* Common CLI fields for ptype mapping get */
17491 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17492 	TOKEN_STRING_INITIALIZER
17493 		(struct cmd_ptype_mapping_get_result,
17494 		 ptype, "ptype");
17495 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17496 	TOKEN_STRING_INITIALIZER
17497 		(struct cmd_ptype_mapping_get_result,
17498 		 mapping, "mapping");
17499 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17500 	TOKEN_STRING_INITIALIZER
17501 		(struct cmd_ptype_mapping_get_result,
17502 		 get, "get");
17503 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17504 	TOKEN_NUM_INITIALIZER
17505 		(struct cmd_ptype_mapping_get_result,
17506 		 port_id, UINT16);
17507 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17508 	TOKEN_NUM_INITIALIZER
17509 		(struct cmd_ptype_mapping_get_result,
17510 		 valid_only, UINT8);
17511 
17512 static void
17513 cmd_ptype_mapping_get_parsed(
17514 	void *parsed_result,
17515 	__attribute__((unused)) struct cmdline *cl,
17516 	__attribute__((unused)) void *data)
17517 {
17518 	struct cmd_ptype_mapping_get_result *res = parsed_result;
17519 	int ret = -ENOTSUP;
17520 #ifdef RTE_LIBRTE_I40E_PMD
17521 	int max_ptype_num = 256;
17522 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17523 	uint16_t count;
17524 	int i;
17525 #endif
17526 
17527 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17528 		return;
17529 
17530 #ifdef RTE_LIBRTE_I40E_PMD
17531 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17532 					mapping,
17533 					max_ptype_num,
17534 					&count,
17535 					res->valid_only);
17536 #endif
17537 
17538 	switch (ret) {
17539 	case 0:
17540 		break;
17541 	case -ENODEV:
17542 		printf("invalid port_id %d\n", res->port_id);
17543 		break;
17544 	case -ENOTSUP:
17545 		printf("function not implemented\n");
17546 		break;
17547 	default:
17548 		printf("programming error: (%s)\n", strerror(-ret));
17549 	}
17550 
17551 #ifdef RTE_LIBRTE_I40E_PMD
17552 	if (!ret) {
17553 		for (i = 0; i < count; i++)
17554 			printf("%3d\t0x%08x\n",
17555 				mapping[i].hw_ptype, mapping[i].sw_ptype);
17556 	}
17557 #endif
17558 }
17559 
17560 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17561 	.f = cmd_ptype_mapping_get_parsed,
17562 	.data = NULL,
17563 	.help_str = "ptype mapping get <port_id> <valid_only>",
17564 	.tokens = {
17565 		(void *)&cmd_ptype_mapping_get_ptype,
17566 		(void *)&cmd_ptype_mapping_get_mapping,
17567 		(void *)&cmd_ptype_mapping_get_get,
17568 		(void *)&cmd_ptype_mapping_get_port_id,
17569 		(void *)&cmd_ptype_mapping_get_valid_only,
17570 		NULL,
17571 	},
17572 };
17573 
17574 /* ptype mapping replace */
17575 
17576 /* Common result structure for ptype mapping replace */
17577 struct cmd_ptype_mapping_replace_result {
17578 	cmdline_fixed_string_t ptype;
17579 	cmdline_fixed_string_t mapping;
17580 	cmdline_fixed_string_t replace;
17581 	portid_t port_id;
17582 	uint32_t target;
17583 	uint8_t mask;
17584 	uint32_t pkt_type;
17585 };
17586 
17587 /* Common CLI fields for ptype mapping replace */
17588 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17589 	TOKEN_STRING_INITIALIZER
17590 		(struct cmd_ptype_mapping_replace_result,
17591 		 ptype, "ptype");
17592 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17593 	TOKEN_STRING_INITIALIZER
17594 		(struct cmd_ptype_mapping_replace_result,
17595 		 mapping, "mapping");
17596 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17597 	TOKEN_STRING_INITIALIZER
17598 		(struct cmd_ptype_mapping_replace_result,
17599 		 replace, "replace");
17600 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17601 	TOKEN_NUM_INITIALIZER
17602 		(struct cmd_ptype_mapping_replace_result,
17603 		 port_id, UINT16);
17604 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17605 	TOKEN_NUM_INITIALIZER
17606 		(struct cmd_ptype_mapping_replace_result,
17607 		 target, UINT32);
17608 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17609 	TOKEN_NUM_INITIALIZER
17610 		(struct cmd_ptype_mapping_replace_result,
17611 		 mask, UINT8);
17612 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17613 	TOKEN_NUM_INITIALIZER
17614 		(struct cmd_ptype_mapping_replace_result,
17615 		 pkt_type, UINT32);
17616 
17617 static void
17618 cmd_ptype_mapping_replace_parsed(
17619 	void *parsed_result,
17620 	__attribute__((unused)) struct cmdline *cl,
17621 	__attribute__((unused)) void *data)
17622 {
17623 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
17624 	int ret = -ENOTSUP;
17625 
17626 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17627 		return;
17628 
17629 #ifdef RTE_LIBRTE_I40E_PMD
17630 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17631 					res->target,
17632 					res->mask,
17633 					res->pkt_type);
17634 #endif
17635 
17636 	switch (ret) {
17637 	case 0:
17638 		break;
17639 	case -EINVAL:
17640 		printf("invalid ptype 0x%8x or 0x%8x\n",
17641 				res->target, res->pkt_type);
17642 		break;
17643 	case -ENODEV:
17644 		printf("invalid port_id %d\n", res->port_id);
17645 		break;
17646 	case -ENOTSUP:
17647 		printf("function not implemented\n");
17648 		break;
17649 	default:
17650 		printf("programming error: (%s)\n", strerror(-ret));
17651 	}
17652 }
17653 
17654 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17655 	.f = cmd_ptype_mapping_replace_parsed,
17656 	.data = NULL,
17657 	.help_str =
17658 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17659 	.tokens = {
17660 		(void *)&cmd_ptype_mapping_replace_ptype,
17661 		(void *)&cmd_ptype_mapping_replace_mapping,
17662 		(void *)&cmd_ptype_mapping_replace_replace,
17663 		(void *)&cmd_ptype_mapping_replace_port_id,
17664 		(void *)&cmd_ptype_mapping_replace_target,
17665 		(void *)&cmd_ptype_mapping_replace_mask,
17666 		(void *)&cmd_ptype_mapping_replace_pkt_type,
17667 		NULL,
17668 	},
17669 };
17670 
17671 /* ptype mapping reset */
17672 
17673 /* Common result structure for ptype mapping reset */
17674 struct cmd_ptype_mapping_reset_result {
17675 	cmdline_fixed_string_t ptype;
17676 	cmdline_fixed_string_t mapping;
17677 	cmdline_fixed_string_t reset;
17678 	portid_t port_id;
17679 };
17680 
17681 /* Common CLI fields for ptype mapping reset*/
17682 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17683 	TOKEN_STRING_INITIALIZER
17684 		(struct cmd_ptype_mapping_reset_result,
17685 		 ptype, "ptype");
17686 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17687 	TOKEN_STRING_INITIALIZER
17688 		(struct cmd_ptype_mapping_reset_result,
17689 		 mapping, "mapping");
17690 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17691 	TOKEN_STRING_INITIALIZER
17692 		(struct cmd_ptype_mapping_reset_result,
17693 		 reset, "reset");
17694 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17695 	TOKEN_NUM_INITIALIZER
17696 		(struct cmd_ptype_mapping_reset_result,
17697 		 port_id, UINT16);
17698 
17699 static void
17700 cmd_ptype_mapping_reset_parsed(
17701 	void *parsed_result,
17702 	__attribute__((unused)) struct cmdline *cl,
17703 	__attribute__((unused)) void *data)
17704 {
17705 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
17706 	int ret = -ENOTSUP;
17707 
17708 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17709 		return;
17710 
17711 #ifdef RTE_LIBRTE_I40E_PMD
17712 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17713 #endif
17714 
17715 	switch (ret) {
17716 	case 0:
17717 		break;
17718 	case -ENODEV:
17719 		printf("invalid port_id %d\n", res->port_id);
17720 		break;
17721 	case -ENOTSUP:
17722 		printf("function not implemented\n");
17723 		break;
17724 	default:
17725 		printf("programming error: (%s)\n", strerror(-ret));
17726 	}
17727 }
17728 
17729 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17730 	.f = cmd_ptype_mapping_reset_parsed,
17731 	.data = NULL,
17732 	.help_str = "ptype mapping reset <port_id>",
17733 	.tokens = {
17734 		(void *)&cmd_ptype_mapping_reset_ptype,
17735 		(void *)&cmd_ptype_mapping_reset_mapping,
17736 		(void *)&cmd_ptype_mapping_reset_reset,
17737 		(void *)&cmd_ptype_mapping_reset_port_id,
17738 		NULL,
17739 	},
17740 };
17741 
17742 /* ptype mapping update */
17743 
17744 /* Common result structure for ptype mapping update */
17745 struct cmd_ptype_mapping_update_result {
17746 	cmdline_fixed_string_t ptype;
17747 	cmdline_fixed_string_t mapping;
17748 	cmdline_fixed_string_t reset;
17749 	portid_t port_id;
17750 	uint8_t hw_ptype;
17751 	uint32_t sw_ptype;
17752 };
17753 
17754 /* Common CLI fields for ptype mapping update*/
17755 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17756 	TOKEN_STRING_INITIALIZER
17757 		(struct cmd_ptype_mapping_update_result,
17758 		 ptype, "ptype");
17759 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17760 	TOKEN_STRING_INITIALIZER
17761 		(struct cmd_ptype_mapping_update_result,
17762 		 mapping, "mapping");
17763 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17764 	TOKEN_STRING_INITIALIZER
17765 		(struct cmd_ptype_mapping_update_result,
17766 		 reset, "update");
17767 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17768 	TOKEN_NUM_INITIALIZER
17769 		(struct cmd_ptype_mapping_update_result,
17770 		 port_id, UINT16);
17771 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17772 	TOKEN_NUM_INITIALIZER
17773 		(struct cmd_ptype_mapping_update_result,
17774 		 hw_ptype, UINT8);
17775 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17776 	TOKEN_NUM_INITIALIZER
17777 		(struct cmd_ptype_mapping_update_result,
17778 		 sw_ptype, UINT32);
17779 
17780 static void
17781 cmd_ptype_mapping_update_parsed(
17782 	void *parsed_result,
17783 	__attribute__((unused)) struct cmdline *cl,
17784 	__attribute__((unused)) void *data)
17785 {
17786 	struct cmd_ptype_mapping_update_result *res = parsed_result;
17787 	int ret = -ENOTSUP;
17788 #ifdef RTE_LIBRTE_I40E_PMD
17789 	struct rte_pmd_i40e_ptype_mapping mapping;
17790 #endif
17791 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17792 		return;
17793 
17794 #ifdef RTE_LIBRTE_I40E_PMD
17795 	mapping.hw_ptype = res->hw_ptype;
17796 	mapping.sw_ptype = res->sw_ptype;
17797 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17798 						&mapping,
17799 						1,
17800 						0);
17801 #endif
17802 
17803 	switch (ret) {
17804 	case 0:
17805 		break;
17806 	case -EINVAL:
17807 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
17808 		break;
17809 	case -ENODEV:
17810 		printf("invalid port_id %d\n", res->port_id);
17811 		break;
17812 	case -ENOTSUP:
17813 		printf("function not implemented\n");
17814 		break;
17815 	default:
17816 		printf("programming error: (%s)\n", strerror(-ret));
17817 	}
17818 }
17819 
17820 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17821 	.f = cmd_ptype_mapping_update_parsed,
17822 	.data = NULL,
17823 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17824 	.tokens = {
17825 		(void *)&cmd_ptype_mapping_update_ptype,
17826 		(void *)&cmd_ptype_mapping_update_mapping,
17827 		(void *)&cmd_ptype_mapping_update_update,
17828 		(void *)&cmd_ptype_mapping_update_port_id,
17829 		(void *)&cmd_ptype_mapping_update_hw_ptype,
17830 		(void *)&cmd_ptype_mapping_update_sw_ptype,
17831 		NULL,
17832 	},
17833 };
17834 
17835 /* Common result structure for file commands */
17836 struct cmd_cmdfile_result {
17837 	cmdline_fixed_string_t load;
17838 	cmdline_fixed_string_t filename;
17839 };
17840 
17841 /* Common CLI fields for file commands */
17842 cmdline_parse_token_string_t cmd_load_cmdfile =
17843 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17844 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17845 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17846 
17847 static void
17848 cmd_load_from_file_parsed(
17849 	void *parsed_result,
17850 	__attribute__((unused)) struct cmdline *cl,
17851 	__attribute__((unused)) void *data)
17852 {
17853 	struct cmd_cmdfile_result *res = parsed_result;
17854 
17855 	cmdline_read_from_file(res->filename);
17856 }
17857 
17858 cmdline_parse_inst_t cmd_load_from_file = {
17859 	.f = cmd_load_from_file_parsed,
17860 	.data = NULL,
17861 	.help_str = "load <filename>",
17862 	.tokens = {
17863 		(void *)&cmd_load_cmdfile,
17864 		(void *)&cmd_load_cmdfile_filename,
17865 		NULL,
17866 	},
17867 };
17868 
17869 /* Get Rx offloads capabilities */
17870 struct cmd_rx_offload_get_capa_result {
17871 	cmdline_fixed_string_t show;
17872 	cmdline_fixed_string_t port;
17873 	portid_t port_id;
17874 	cmdline_fixed_string_t rx_offload;
17875 	cmdline_fixed_string_t capabilities;
17876 };
17877 
17878 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17879 	TOKEN_STRING_INITIALIZER
17880 		(struct cmd_rx_offload_get_capa_result,
17881 		 show, "show");
17882 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17883 	TOKEN_STRING_INITIALIZER
17884 		(struct cmd_rx_offload_get_capa_result,
17885 		 port, "port");
17886 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17887 	TOKEN_NUM_INITIALIZER
17888 		(struct cmd_rx_offload_get_capa_result,
17889 		 port_id, UINT16);
17890 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17891 	TOKEN_STRING_INITIALIZER
17892 		(struct cmd_rx_offload_get_capa_result,
17893 		 rx_offload, "rx_offload");
17894 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17895 	TOKEN_STRING_INITIALIZER
17896 		(struct cmd_rx_offload_get_capa_result,
17897 		 capabilities, "capabilities");
17898 
17899 static void
17900 print_rx_offloads(uint64_t offloads)
17901 {
17902 	uint64_t single_offload;
17903 	int begin;
17904 	int end;
17905 	int bit;
17906 
17907 	if (offloads == 0)
17908 		return;
17909 
17910 	begin = __builtin_ctzll(offloads);
17911 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17912 
17913 	single_offload = 1ULL << begin;
17914 	for (bit = begin; bit < end; bit++) {
17915 		if (offloads & single_offload)
17916 			printf(" %s",
17917 			       rte_eth_dev_rx_offload_name(single_offload));
17918 		single_offload <<= 1;
17919 	}
17920 }
17921 
17922 static void
17923 cmd_rx_offload_get_capa_parsed(
17924 	void *parsed_result,
17925 	__attribute__((unused)) struct cmdline *cl,
17926 	__attribute__((unused)) void *data)
17927 {
17928 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
17929 	struct rte_eth_dev_info dev_info;
17930 	portid_t port_id = res->port_id;
17931 	uint64_t queue_offloads;
17932 	uint64_t port_offloads;
17933 	int ret;
17934 
17935 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
17936 	if (ret != 0)
17937 		return;
17938 
17939 	queue_offloads = dev_info.rx_queue_offload_capa;
17940 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17941 
17942 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
17943 	printf("  Per Queue :");
17944 	print_rx_offloads(queue_offloads);
17945 
17946 	printf("\n");
17947 	printf("  Per Port  :");
17948 	print_rx_offloads(port_offloads);
17949 	printf("\n\n");
17950 }
17951 
17952 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17953 	.f = cmd_rx_offload_get_capa_parsed,
17954 	.data = NULL,
17955 	.help_str = "show port <port_id> rx_offload capabilities",
17956 	.tokens = {
17957 		(void *)&cmd_rx_offload_get_capa_show,
17958 		(void *)&cmd_rx_offload_get_capa_port,
17959 		(void *)&cmd_rx_offload_get_capa_port_id,
17960 		(void *)&cmd_rx_offload_get_capa_rx_offload,
17961 		(void *)&cmd_rx_offload_get_capa_capabilities,
17962 		NULL,
17963 	}
17964 };
17965 
17966 /* Get Rx offloads configuration */
17967 struct cmd_rx_offload_get_configuration_result {
17968 	cmdline_fixed_string_t show;
17969 	cmdline_fixed_string_t port;
17970 	portid_t port_id;
17971 	cmdline_fixed_string_t rx_offload;
17972 	cmdline_fixed_string_t configuration;
17973 };
17974 
17975 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17976 	TOKEN_STRING_INITIALIZER
17977 		(struct cmd_rx_offload_get_configuration_result,
17978 		 show, "show");
17979 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17980 	TOKEN_STRING_INITIALIZER
17981 		(struct cmd_rx_offload_get_configuration_result,
17982 		 port, "port");
17983 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17984 	TOKEN_NUM_INITIALIZER
17985 		(struct cmd_rx_offload_get_configuration_result,
17986 		 port_id, UINT16);
17987 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17988 	TOKEN_STRING_INITIALIZER
17989 		(struct cmd_rx_offload_get_configuration_result,
17990 		 rx_offload, "rx_offload");
17991 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17992 	TOKEN_STRING_INITIALIZER
17993 		(struct cmd_rx_offload_get_configuration_result,
17994 		 configuration, "configuration");
17995 
17996 static void
17997 cmd_rx_offload_get_configuration_parsed(
17998 	void *parsed_result,
17999 	__attribute__((unused)) struct cmdline *cl,
18000 	__attribute__((unused)) void *data)
18001 {
18002 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18003 	struct rte_eth_dev_info dev_info;
18004 	portid_t port_id = res->port_id;
18005 	struct rte_port *port = &ports[port_id];
18006 	uint64_t port_offloads;
18007 	uint64_t queue_offloads;
18008 	uint16_t nb_rx_queues;
18009 	int q;
18010 	int ret;
18011 
18012 	printf("Rx Offloading Configuration of port %d :\n", port_id);
18013 
18014 	port_offloads = port->dev_conf.rxmode.offloads;
18015 	printf("  Port :");
18016 	print_rx_offloads(port_offloads);
18017 	printf("\n");
18018 
18019 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18020 	if (ret != 0)
18021 		return;
18022 
18023 	nb_rx_queues = dev_info.nb_rx_queues;
18024 	for (q = 0; q < nb_rx_queues; q++) {
18025 		queue_offloads = port->rx_conf[q].offloads;
18026 		printf("  Queue[%2d] :", q);
18027 		print_rx_offloads(queue_offloads);
18028 		printf("\n");
18029 	}
18030 	printf("\n");
18031 }
18032 
18033 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18034 	.f = cmd_rx_offload_get_configuration_parsed,
18035 	.data = NULL,
18036 	.help_str = "show port <port_id> rx_offload configuration",
18037 	.tokens = {
18038 		(void *)&cmd_rx_offload_get_configuration_show,
18039 		(void *)&cmd_rx_offload_get_configuration_port,
18040 		(void *)&cmd_rx_offload_get_configuration_port_id,
18041 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
18042 		(void *)&cmd_rx_offload_get_configuration_configuration,
18043 		NULL,
18044 	}
18045 };
18046 
18047 /* Enable/Disable a per port offloading */
18048 struct cmd_config_per_port_rx_offload_result {
18049 	cmdline_fixed_string_t port;
18050 	cmdline_fixed_string_t config;
18051 	portid_t port_id;
18052 	cmdline_fixed_string_t rx_offload;
18053 	cmdline_fixed_string_t offload;
18054 	cmdline_fixed_string_t on_off;
18055 };
18056 
18057 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18058 	TOKEN_STRING_INITIALIZER
18059 		(struct cmd_config_per_port_rx_offload_result,
18060 		 port, "port");
18061 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18062 	TOKEN_STRING_INITIALIZER
18063 		(struct cmd_config_per_port_rx_offload_result,
18064 		 config, "config");
18065 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18066 	TOKEN_NUM_INITIALIZER
18067 		(struct cmd_config_per_port_rx_offload_result,
18068 		 port_id, UINT16);
18069 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18070 	TOKEN_STRING_INITIALIZER
18071 		(struct cmd_config_per_port_rx_offload_result,
18072 		 rx_offload, "rx_offload");
18073 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18074 	TOKEN_STRING_INITIALIZER
18075 		(struct cmd_config_per_port_rx_offload_result,
18076 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18077 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18078 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18079 			   "crc_strip#scatter#timestamp#security#keep_crc");
18080 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18081 	TOKEN_STRING_INITIALIZER
18082 		(struct cmd_config_per_port_rx_offload_result,
18083 		 on_off, "on#off");
18084 
18085 static uint64_t
18086 search_rx_offload(const char *name)
18087 {
18088 	uint64_t single_offload;
18089 	const char *single_name;
18090 	int found = 0;
18091 	unsigned int bit;
18092 
18093 	single_offload = 1;
18094 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18095 		single_name = rte_eth_dev_rx_offload_name(single_offload);
18096 		if (!strcasecmp(single_name, name)) {
18097 			found = 1;
18098 			break;
18099 		}
18100 		single_offload <<= 1;
18101 	}
18102 
18103 	if (found)
18104 		return single_offload;
18105 
18106 	return 0;
18107 }
18108 
18109 static void
18110 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18111 				__attribute__((unused)) struct cmdline *cl,
18112 				__attribute__((unused)) void *data)
18113 {
18114 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18115 	portid_t port_id = res->port_id;
18116 	struct rte_eth_dev_info dev_info;
18117 	struct rte_port *port = &ports[port_id];
18118 	uint64_t single_offload;
18119 	uint16_t nb_rx_queues;
18120 	int q;
18121 	int ret;
18122 
18123 	if (port->port_status != RTE_PORT_STOPPED) {
18124 		printf("Error: Can't config offload when Port %d "
18125 		       "is not stopped\n", port_id);
18126 		return;
18127 	}
18128 
18129 	single_offload = search_rx_offload(res->offload);
18130 	if (single_offload == 0) {
18131 		printf("Unknown offload name: %s\n", res->offload);
18132 		return;
18133 	}
18134 
18135 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18136 	if (ret != 0)
18137 		return;
18138 
18139 	nb_rx_queues = dev_info.nb_rx_queues;
18140 	if (!strcmp(res->on_off, "on")) {
18141 		port->dev_conf.rxmode.offloads |= single_offload;
18142 		for (q = 0; q < nb_rx_queues; q++)
18143 			port->rx_conf[q].offloads |= single_offload;
18144 	} else {
18145 		port->dev_conf.rxmode.offloads &= ~single_offload;
18146 		for (q = 0; q < nb_rx_queues; q++)
18147 			port->rx_conf[q].offloads &= ~single_offload;
18148 	}
18149 
18150 	cmd_reconfig_device_queue(port_id, 1, 1);
18151 }
18152 
18153 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18154 	.f = cmd_config_per_port_rx_offload_parsed,
18155 	.data = NULL,
18156 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18157 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18158 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18159 		    "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18160 		    "on|off",
18161 	.tokens = {
18162 		(void *)&cmd_config_per_port_rx_offload_result_port,
18163 		(void *)&cmd_config_per_port_rx_offload_result_config,
18164 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
18165 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18166 		(void *)&cmd_config_per_port_rx_offload_result_offload,
18167 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
18168 		NULL,
18169 	}
18170 };
18171 
18172 /* Enable/Disable a per queue offloading */
18173 struct cmd_config_per_queue_rx_offload_result {
18174 	cmdline_fixed_string_t port;
18175 	portid_t port_id;
18176 	cmdline_fixed_string_t rxq;
18177 	uint16_t queue_id;
18178 	cmdline_fixed_string_t rx_offload;
18179 	cmdline_fixed_string_t offload;
18180 	cmdline_fixed_string_t on_off;
18181 };
18182 
18183 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18184 	TOKEN_STRING_INITIALIZER
18185 		(struct cmd_config_per_queue_rx_offload_result,
18186 		 port, "port");
18187 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18188 	TOKEN_NUM_INITIALIZER
18189 		(struct cmd_config_per_queue_rx_offload_result,
18190 		 port_id, UINT16);
18191 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18192 	TOKEN_STRING_INITIALIZER
18193 		(struct cmd_config_per_queue_rx_offload_result,
18194 		 rxq, "rxq");
18195 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18196 	TOKEN_NUM_INITIALIZER
18197 		(struct cmd_config_per_queue_rx_offload_result,
18198 		 queue_id, UINT16);
18199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18200 	TOKEN_STRING_INITIALIZER
18201 		(struct cmd_config_per_queue_rx_offload_result,
18202 		 rx_offload, "rx_offload");
18203 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18204 	TOKEN_STRING_INITIALIZER
18205 		(struct cmd_config_per_queue_rx_offload_result,
18206 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18207 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18208 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18209 			   "crc_strip#scatter#timestamp#security#keep_crc");
18210 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18211 	TOKEN_STRING_INITIALIZER
18212 		(struct cmd_config_per_queue_rx_offload_result,
18213 		 on_off, "on#off");
18214 
18215 static void
18216 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18217 				__attribute__((unused)) struct cmdline *cl,
18218 				__attribute__((unused)) void *data)
18219 {
18220 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18221 	struct rte_eth_dev_info dev_info;
18222 	portid_t port_id = res->port_id;
18223 	uint16_t queue_id = res->queue_id;
18224 	struct rte_port *port = &ports[port_id];
18225 	uint64_t single_offload;
18226 	int ret;
18227 
18228 	if (port->port_status != RTE_PORT_STOPPED) {
18229 		printf("Error: Can't config offload when Port %d "
18230 		       "is not stopped\n", port_id);
18231 		return;
18232 	}
18233 
18234 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18235 	if (ret != 0)
18236 		return;
18237 
18238 	if (queue_id >= dev_info.nb_rx_queues) {
18239 		printf("Error: input queue_id should be 0 ... "
18240 		       "%d\n", dev_info.nb_rx_queues - 1);
18241 		return;
18242 	}
18243 
18244 	single_offload = search_rx_offload(res->offload);
18245 	if (single_offload == 0) {
18246 		printf("Unknown offload name: %s\n", res->offload);
18247 		return;
18248 	}
18249 
18250 	if (!strcmp(res->on_off, "on"))
18251 		port->rx_conf[queue_id].offloads |= single_offload;
18252 	else
18253 		port->rx_conf[queue_id].offloads &= ~single_offload;
18254 
18255 	cmd_reconfig_device_queue(port_id, 1, 1);
18256 }
18257 
18258 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18259 	.f = cmd_config_per_queue_rx_offload_parsed,
18260 	.data = NULL,
18261 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
18262 		    "vlan_strip|ipv4_cksum|"
18263 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18264 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18265 		    "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18266 		    "on|off",
18267 	.tokens = {
18268 		(void *)&cmd_config_per_queue_rx_offload_result_port,
18269 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
18270 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
18271 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18272 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18273 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
18274 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
18275 		NULL,
18276 	}
18277 };
18278 
18279 /* Get Tx offloads capabilities */
18280 struct cmd_tx_offload_get_capa_result {
18281 	cmdline_fixed_string_t show;
18282 	cmdline_fixed_string_t port;
18283 	portid_t port_id;
18284 	cmdline_fixed_string_t tx_offload;
18285 	cmdline_fixed_string_t capabilities;
18286 };
18287 
18288 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18289 	TOKEN_STRING_INITIALIZER
18290 		(struct cmd_tx_offload_get_capa_result,
18291 		 show, "show");
18292 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18293 	TOKEN_STRING_INITIALIZER
18294 		(struct cmd_tx_offload_get_capa_result,
18295 		 port, "port");
18296 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18297 	TOKEN_NUM_INITIALIZER
18298 		(struct cmd_tx_offload_get_capa_result,
18299 		 port_id, UINT16);
18300 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18301 	TOKEN_STRING_INITIALIZER
18302 		(struct cmd_tx_offload_get_capa_result,
18303 		 tx_offload, "tx_offload");
18304 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18305 	TOKEN_STRING_INITIALIZER
18306 		(struct cmd_tx_offload_get_capa_result,
18307 		 capabilities, "capabilities");
18308 
18309 static void
18310 print_tx_offloads(uint64_t offloads)
18311 {
18312 	uint64_t single_offload;
18313 	int begin;
18314 	int end;
18315 	int bit;
18316 
18317 	if (offloads == 0)
18318 		return;
18319 
18320 	begin = __builtin_ctzll(offloads);
18321 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18322 
18323 	single_offload = 1ULL << begin;
18324 	for (bit = begin; bit < end; bit++) {
18325 		if (offloads & single_offload)
18326 			printf(" %s",
18327 			       rte_eth_dev_tx_offload_name(single_offload));
18328 		single_offload <<= 1;
18329 	}
18330 }
18331 
18332 static void
18333 cmd_tx_offload_get_capa_parsed(
18334 	void *parsed_result,
18335 	__attribute__((unused)) struct cmdline *cl,
18336 	__attribute__((unused)) void *data)
18337 {
18338 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
18339 	struct rte_eth_dev_info dev_info;
18340 	portid_t port_id = res->port_id;
18341 	uint64_t queue_offloads;
18342 	uint64_t port_offloads;
18343 	int ret;
18344 
18345 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18346 	if (ret != 0)
18347 		return;
18348 
18349 	queue_offloads = dev_info.tx_queue_offload_capa;
18350 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18351 
18352 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
18353 	printf("  Per Queue :");
18354 	print_tx_offloads(queue_offloads);
18355 
18356 	printf("\n");
18357 	printf("  Per Port  :");
18358 	print_tx_offloads(port_offloads);
18359 	printf("\n\n");
18360 }
18361 
18362 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18363 	.f = cmd_tx_offload_get_capa_parsed,
18364 	.data = NULL,
18365 	.help_str = "show port <port_id> tx_offload capabilities",
18366 	.tokens = {
18367 		(void *)&cmd_tx_offload_get_capa_show,
18368 		(void *)&cmd_tx_offload_get_capa_port,
18369 		(void *)&cmd_tx_offload_get_capa_port_id,
18370 		(void *)&cmd_tx_offload_get_capa_tx_offload,
18371 		(void *)&cmd_tx_offload_get_capa_capabilities,
18372 		NULL,
18373 	}
18374 };
18375 
18376 /* Get Tx offloads configuration */
18377 struct cmd_tx_offload_get_configuration_result {
18378 	cmdline_fixed_string_t show;
18379 	cmdline_fixed_string_t port;
18380 	portid_t port_id;
18381 	cmdline_fixed_string_t tx_offload;
18382 	cmdline_fixed_string_t configuration;
18383 };
18384 
18385 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18386 	TOKEN_STRING_INITIALIZER
18387 		(struct cmd_tx_offload_get_configuration_result,
18388 		 show, "show");
18389 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18390 	TOKEN_STRING_INITIALIZER
18391 		(struct cmd_tx_offload_get_configuration_result,
18392 		 port, "port");
18393 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18394 	TOKEN_NUM_INITIALIZER
18395 		(struct cmd_tx_offload_get_configuration_result,
18396 		 port_id, UINT16);
18397 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18398 	TOKEN_STRING_INITIALIZER
18399 		(struct cmd_tx_offload_get_configuration_result,
18400 		 tx_offload, "tx_offload");
18401 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18402 	TOKEN_STRING_INITIALIZER
18403 		(struct cmd_tx_offload_get_configuration_result,
18404 		 configuration, "configuration");
18405 
18406 static void
18407 cmd_tx_offload_get_configuration_parsed(
18408 	void *parsed_result,
18409 	__attribute__((unused)) struct cmdline *cl,
18410 	__attribute__((unused)) void *data)
18411 {
18412 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18413 	struct rte_eth_dev_info dev_info;
18414 	portid_t port_id = res->port_id;
18415 	struct rte_port *port = &ports[port_id];
18416 	uint64_t port_offloads;
18417 	uint64_t queue_offloads;
18418 	uint16_t nb_tx_queues;
18419 	int q;
18420 	int ret;
18421 
18422 	printf("Tx Offloading Configuration of port %d :\n", port_id);
18423 
18424 	port_offloads = port->dev_conf.txmode.offloads;
18425 	printf("  Port :");
18426 	print_tx_offloads(port_offloads);
18427 	printf("\n");
18428 
18429 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18430 	if (ret != 0)
18431 		return;
18432 
18433 	nb_tx_queues = dev_info.nb_tx_queues;
18434 	for (q = 0; q < nb_tx_queues; q++) {
18435 		queue_offloads = port->tx_conf[q].offloads;
18436 		printf("  Queue[%2d] :", q);
18437 		print_tx_offloads(queue_offloads);
18438 		printf("\n");
18439 	}
18440 	printf("\n");
18441 }
18442 
18443 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18444 	.f = cmd_tx_offload_get_configuration_parsed,
18445 	.data = NULL,
18446 	.help_str = "show port <port_id> tx_offload configuration",
18447 	.tokens = {
18448 		(void *)&cmd_tx_offload_get_configuration_show,
18449 		(void *)&cmd_tx_offload_get_configuration_port,
18450 		(void *)&cmd_tx_offload_get_configuration_port_id,
18451 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
18452 		(void *)&cmd_tx_offload_get_configuration_configuration,
18453 		NULL,
18454 	}
18455 };
18456 
18457 /* Enable/Disable a per port offloading */
18458 struct cmd_config_per_port_tx_offload_result {
18459 	cmdline_fixed_string_t port;
18460 	cmdline_fixed_string_t config;
18461 	portid_t port_id;
18462 	cmdline_fixed_string_t tx_offload;
18463 	cmdline_fixed_string_t offload;
18464 	cmdline_fixed_string_t on_off;
18465 };
18466 
18467 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18468 	TOKEN_STRING_INITIALIZER
18469 		(struct cmd_config_per_port_tx_offload_result,
18470 		 port, "port");
18471 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18472 	TOKEN_STRING_INITIALIZER
18473 		(struct cmd_config_per_port_tx_offload_result,
18474 		 config, "config");
18475 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18476 	TOKEN_NUM_INITIALIZER
18477 		(struct cmd_config_per_port_tx_offload_result,
18478 		 port_id, UINT16);
18479 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18480 	TOKEN_STRING_INITIALIZER
18481 		(struct cmd_config_per_port_tx_offload_result,
18482 		 tx_offload, "tx_offload");
18483 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18484 	TOKEN_STRING_INITIALIZER
18485 		(struct cmd_config_per_port_tx_offload_result,
18486 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18487 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18488 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18489 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18490 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18491 			  "match_metadata");
18492 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18493 	TOKEN_STRING_INITIALIZER
18494 		(struct cmd_config_per_port_tx_offload_result,
18495 		 on_off, "on#off");
18496 
18497 static uint64_t
18498 search_tx_offload(const char *name)
18499 {
18500 	uint64_t single_offload;
18501 	const char *single_name;
18502 	int found = 0;
18503 	unsigned int bit;
18504 
18505 	single_offload = 1;
18506 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18507 		single_name = rte_eth_dev_tx_offload_name(single_offload);
18508 		if (single_name == NULL)
18509 			break;
18510 		if (!strcasecmp(single_name, name)) {
18511 			found = 1;
18512 			break;
18513 		} else if (!strcasecmp(single_name, "UNKNOWN"))
18514 			break;
18515 		single_offload <<= 1;
18516 	}
18517 
18518 	if (found)
18519 		return single_offload;
18520 
18521 	return 0;
18522 }
18523 
18524 static void
18525 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18526 				__attribute__((unused)) struct cmdline *cl,
18527 				__attribute__((unused)) void *data)
18528 {
18529 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18530 	portid_t port_id = res->port_id;
18531 	struct rte_eth_dev_info dev_info;
18532 	struct rte_port *port = &ports[port_id];
18533 	uint64_t single_offload;
18534 	uint16_t nb_tx_queues;
18535 	int q;
18536 	int ret;
18537 
18538 	if (port->port_status != RTE_PORT_STOPPED) {
18539 		printf("Error: Can't config offload when Port %d "
18540 		       "is not stopped\n", port_id);
18541 		return;
18542 	}
18543 
18544 	single_offload = search_tx_offload(res->offload);
18545 	if (single_offload == 0) {
18546 		printf("Unknown offload name: %s\n", res->offload);
18547 		return;
18548 	}
18549 
18550 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18551 	if (ret != 0)
18552 		return;
18553 
18554 	nb_tx_queues = dev_info.nb_tx_queues;
18555 	if (!strcmp(res->on_off, "on")) {
18556 		port->dev_conf.txmode.offloads |= single_offload;
18557 		for (q = 0; q < nb_tx_queues; q++)
18558 			port->tx_conf[q].offloads |= single_offload;
18559 	} else {
18560 		port->dev_conf.txmode.offloads &= ~single_offload;
18561 		for (q = 0; q < nb_tx_queues; q++)
18562 			port->tx_conf[q].offloads &= ~single_offload;
18563 	}
18564 
18565 	cmd_reconfig_device_queue(port_id, 1, 1);
18566 }
18567 
18568 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18569 	.f = cmd_config_per_port_tx_offload_parsed,
18570 	.data = NULL,
18571 	.help_str = "port config <port_id> tx_offload "
18572 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18573 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18574 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18575 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18576 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18577 		    "match_metadata on|off",
18578 	.tokens = {
18579 		(void *)&cmd_config_per_port_tx_offload_result_port,
18580 		(void *)&cmd_config_per_port_tx_offload_result_config,
18581 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
18582 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18583 		(void *)&cmd_config_per_port_tx_offload_result_offload,
18584 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
18585 		NULL,
18586 	}
18587 };
18588 
18589 /* Enable/Disable a per queue offloading */
18590 struct cmd_config_per_queue_tx_offload_result {
18591 	cmdline_fixed_string_t port;
18592 	portid_t port_id;
18593 	cmdline_fixed_string_t txq;
18594 	uint16_t queue_id;
18595 	cmdline_fixed_string_t tx_offload;
18596 	cmdline_fixed_string_t offload;
18597 	cmdline_fixed_string_t on_off;
18598 };
18599 
18600 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18601 	TOKEN_STRING_INITIALIZER
18602 		(struct cmd_config_per_queue_tx_offload_result,
18603 		 port, "port");
18604 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18605 	TOKEN_NUM_INITIALIZER
18606 		(struct cmd_config_per_queue_tx_offload_result,
18607 		 port_id, UINT16);
18608 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18609 	TOKEN_STRING_INITIALIZER
18610 		(struct cmd_config_per_queue_tx_offload_result,
18611 		 txq, "txq");
18612 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18613 	TOKEN_NUM_INITIALIZER
18614 		(struct cmd_config_per_queue_tx_offload_result,
18615 		 queue_id, UINT16);
18616 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18617 	TOKEN_STRING_INITIALIZER
18618 		(struct cmd_config_per_queue_tx_offload_result,
18619 		 tx_offload, "tx_offload");
18620 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18621 	TOKEN_STRING_INITIALIZER
18622 		(struct cmd_config_per_queue_tx_offload_result,
18623 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18624 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18625 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18626 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18627 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
18628 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18629 	TOKEN_STRING_INITIALIZER
18630 		(struct cmd_config_per_queue_tx_offload_result,
18631 		 on_off, "on#off");
18632 
18633 static void
18634 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18635 				__attribute__((unused)) struct cmdline *cl,
18636 				__attribute__((unused)) void *data)
18637 {
18638 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18639 	struct rte_eth_dev_info dev_info;
18640 	portid_t port_id = res->port_id;
18641 	uint16_t queue_id = res->queue_id;
18642 	struct rte_port *port = &ports[port_id];
18643 	uint64_t single_offload;
18644 	int ret;
18645 
18646 	if (port->port_status != RTE_PORT_STOPPED) {
18647 		printf("Error: Can't config offload when Port %d "
18648 		       "is not stopped\n", port_id);
18649 		return;
18650 	}
18651 
18652 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18653 	if (ret != 0)
18654 		return;
18655 
18656 	if (queue_id >= dev_info.nb_tx_queues) {
18657 		printf("Error: input queue_id should be 0 ... "
18658 		       "%d\n", dev_info.nb_tx_queues - 1);
18659 		return;
18660 	}
18661 
18662 	single_offload = search_tx_offload(res->offload);
18663 	if (single_offload == 0) {
18664 		printf("Unknown offload name: %s\n", res->offload);
18665 		return;
18666 	}
18667 
18668 	if (!strcmp(res->on_off, "on"))
18669 		port->tx_conf[queue_id].offloads |= single_offload;
18670 	else
18671 		port->tx_conf[queue_id].offloads &= ~single_offload;
18672 
18673 	cmd_reconfig_device_queue(port_id, 1, 1);
18674 }
18675 
18676 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18677 	.f = cmd_config_per_queue_tx_offload_parsed,
18678 	.data = NULL,
18679 	.help_str = "port <port_id> txq <queue_id> tx_offload "
18680 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18681 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18682 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18683 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18684 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
18685 		    "on|off",
18686 	.tokens = {
18687 		(void *)&cmd_config_per_queue_tx_offload_result_port,
18688 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
18689 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
18690 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18691 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18692 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
18693 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
18694 		NULL,
18695 	}
18696 };
18697 
18698 /* *** configure tx_metadata for specific port *** */
18699 struct cmd_config_tx_metadata_specific_result {
18700 	cmdline_fixed_string_t port;
18701 	cmdline_fixed_string_t keyword;
18702 	uint16_t port_id;
18703 	cmdline_fixed_string_t item;
18704 	uint32_t value;
18705 };
18706 
18707 static void
18708 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18709 				__attribute__((unused)) struct cmdline *cl,
18710 				__attribute__((unused)) void *data)
18711 {
18712 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18713 
18714 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18715 		return;
18716 	ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18717 	/* Add/remove callback to insert valid metadata in every Tx packet. */
18718 	if (ports[res->port_id].tx_metadata)
18719 		add_tx_md_callback(res->port_id);
18720 	else
18721 		remove_tx_md_callback(res->port_id);
18722 }
18723 
18724 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18725 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18726 			port, "port");
18727 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18728 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18729 			keyword, "config");
18730 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18731 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18732 			port_id, UINT16);
18733 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18734 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18735 			item, "tx_metadata");
18736 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18737 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18738 			value, UINT32);
18739 
18740 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18741 	.f = cmd_config_tx_metadata_specific_parsed,
18742 	.data = NULL,
18743 	.help_str = "port config <port_id> tx_metadata <value>",
18744 	.tokens = {
18745 		(void *)&cmd_config_tx_metadata_specific_port,
18746 		(void *)&cmd_config_tx_metadata_specific_keyword,
18747 		(void *)&cmd_config_tx_metadata_specific_id,
18748 		(void *)&cmd_config_tx_metadata_specific_item,
18749 		(void *)&cmd_config_tx_metadata_specific_value,
18750 		NULL,
18751 	},
18752 };
18753 
18754 /* *** display tx_metadata per port configuration *** */
18755 struct cmd_show_tx_metadata_result {
18756 	cmdline_fixed_string_t cmd_show;
18757 	cmdline_fixed_string_t cmd_port;
18758 	cmdline_fixed_string_t cmd_keyword;
18759 	portid_t cmd_pid;
18760 };
18761 
18762 static void
18763 cmd_show_tx_metadata_parsed(void *parsed_result,
18764 		__attribute__((unused)) struct cmdline *cl,
18765 		__attribute__((unused)) void *data)
18766 {
18767 	struct cmd_show_tx_metadata_result *res = parsed_result;
18768 
18769 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18770 		printf("invalid port id %u\n", res->cmd_pid);
18771 		return;
18772 	}
18773 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18774 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18775 			rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18776 	}
18777 }
18778 
18779 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18780 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18781 			cmd_show, "show");
18782 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18783 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18784 			cmd_port, "port");
18785 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18786 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18787 			cmd_pid, UINT16);
18788 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18789 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18790 			cmd_keyword, "tx_metadata");
18791 
18792 cmdline_parse_inst_t cmd_show_tx_metadata = {
18793 	.f = cmd_show_tx_metadata_parsed,
18794 	.data = NULL,
18795 	.help_str = "show port <port_id> tx_metadata",
18796 	.tokens = {
18797 		(void *)&cmd_show_tx_metadata_show,
18798 		(void *)&cmd_show_tx_metadata_port,
18799 		(void *)&cmd_show_tx_metadata_pid,
18800 		(void *)&cmd_show_tx_metadata_keyword,
18801 		NULL,
18802 	},
18803 };
18804 
18805 /* ******************************************************************************** */
18806 
18807 /* list of instructions */
18808 cmdline_parse_ctx_t main_ctx[] = {
18809 	(cmdline_parse_inst_t *)&cmd_help_brief,
18810 	(cmdline_parse_inst_t *)&cmd_help_long,
18811 	(cmdline_parse_inst_t *)&cmd_quit,
18812 	(cmdline_parse_inst_t *)&cmd_load_from_file,
18813 	(cmdline_parse_inst_t *)&cmd_showport,
18814 	(cmdline_parse_inst_t *)&cmd_showqueue,
18815 	(cmdline_parse_inst_t *)&cmd_showportall,
18816 	(cmdline_parse_inst_t *)&cmd_showdevice,
18817 	(cmdline_parse_inst_t *)&cmd_showcfg,
18818 	(cmdline_parse_inst_t *)&cmd_showfwdall,
18819 	(cmdline_parse_inst_t *)&cmd_start,
18820 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
18821 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18822 	(cmdline_parse_inst_t *)&cmd_set_link_up,
18823 	(cmdline_parse_inst_t *)&cmd_set_link_down,
18824 	(cmdline_parse_inst_t *)&cmd_reset,
18825 	(cmdline_parse_inst_t *)&cmd_set_numbers,
18826 	(cmdline_parse_inst_t *)&cmd_set_log,
18827 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
18828 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
18829 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
18830 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18831 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18832 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18833 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18834 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18835 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18836 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18837 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18838 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
18839 	(cmdline_parse_inst_t *)&cmd_set_link_check,
18840 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18841 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
18842 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18843 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
18844 #ifdef RTE_LIBRTE_PMD_BOND
18845 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18846 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
18847 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18848 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18849 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18850 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
18851 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18852 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18853 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18854 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18855 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18856 #endif
18857 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
18858 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
18859 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18860 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18861 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18862 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18863 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18864 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18865 	(cmdline_parse_inst_t *)&cmd_csum_set,
18866 	(cmdline_parse_inst_t *)&cmd_csum_show,
18867 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
18868 	(cmdline_parse_inst_t *)&cmd_tso_set,
18869 	(cmdline_parse_inst_t *)&cmd_tso_show,
18870 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18871 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18872 	(cmdline_parse_inst_t *)&cmd_gro_enable,
18873 	(cmdline_parse_inst_t *)&cmd_gro_flush,
18874 	(cmdline_parse_inst_t *)&cmd_gro_show,
18875 	(cmdline_parse_inst_t *)&cmd_gso_enable,
18876 	(cmdline_parse_inst_t *)&cmd_gso_size,
18877 	(cmdline_parse_inst_t *)&cmd_gso_show,
18878 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18879 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18880 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18881 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18882 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18883 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18884 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18885 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18886 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18887 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18888 	(cmdline_parse_inst_t *)&cmd_config_dcb,
18889 	(cmdline_parse_inst_t *)&cmd_read_reg,
18890 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18891 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
18892 	(cmdline_parse_inst_t *)&cmd_write_reg,
18893 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18894 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
18895 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18896 	(cmdline_parse_inst_t *)&cmd_stop,
18897 	(cmdline_parse_inst_t *)&cmd_mac_addr,
18898 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18899 	(cmdline_parse_inst_t *)&cmd_set_qmap,
18900 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18901 	(cmdline_parse_inst_t *)&cmd_operate_port,
18902 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
18903 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
18904 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
18905 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
18906 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18907 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
18908 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
18909 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
18910 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18911 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
18912 	(cmdline_parse_inst_t *)&cmd_config_mtu,
18913 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18914 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18915 	(cmdline_parse_inst_t *)&cmd_config_rss,
18916 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18917 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18918 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18919 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18920 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
18921 	(cmdline_parse_inst_t *)&cmd_showport_reta,
18922 	(cmdline_parse_inst_t *)&cmd_config_burst,
18923 	(cmdline_parse_inst_t *)&cmd_config_thresh,
18924 	(cmdline_parse_inst_t *)&cmd_config_threshold,
18925 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18926 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18927 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18928 	(cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18929 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18930 	(cmdline_parse_inst_t *)&cmd_tunnel_filter,
18931 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18932 	(cmdline_parse_inst_t *)&cmd_global_config,
18933 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18934 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
18935 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18936 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18937 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18938 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18939 	(cmdline_parse_inst_t *)&cmd_dump,
18940 	(cmdline_parse_inst_t *)&cmd_dump_one,
18941 	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
18942 	(cmdline_parse_inst_t *)&cmd_syn_filter,
18943 	(cmdline_parse_inst_t *)&cmd_2tuple_filter,
18944 	(cmdline_parse_inst_t *)&cmd_5tuple_filter,
18945 	(cmdline_parse_inst_t *)&cmd_flex_filter,
18946 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18947 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18948 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18949 	(cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18950 	(cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18951 	(cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18952 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18953 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
18954 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18955 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18956 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18957 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18958 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18959 	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18960 	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18961 	(cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18962 	(cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18963 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18964 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18965 	(cmdline_parse_inst_t *)&cmd_flow,
18966 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18967 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18968 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18969 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18970 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
18971 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
18972 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
18973 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
18974 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18975 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18976 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18977 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18978 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18979 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
18980 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18981 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18982 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18983 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18984 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18985 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18986 	(cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18987 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18988 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18989 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18990 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18991 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18992 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18993 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18994 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18995 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18996 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18997 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18998 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18999 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19000 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19001 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19002 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19003 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19004 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19005 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19006 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19007 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19008 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19009 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19010 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
19011 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19012 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19013 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
19014 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
19015 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19016 	(cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19017 #endif
19018 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
19019 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19020 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19021 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
19022 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19023 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
19024 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19025 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
19026 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19027 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19028 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19029 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19030 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19031 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19032 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19033 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19034 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19035 	(cmdline_parse_inst_t *)&cmd_ddp_add,
19036 	(cmdline_parse_inst_t *)&cmd_ddp_del,
19037 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
19038 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
19039 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
19040 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
19041 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
19042 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19043 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19044 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19045 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19046 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19047 
19048 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19049 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19050 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19051 	(cmdline_parse_inst_t *)&cmd_queue_region,
19052 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
19053 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
19054 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
19055 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19056 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19057 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19058 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19059 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19060 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19061 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19062 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19063 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19064 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19065 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19066 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19067 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19068 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19069 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19070 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19071 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19072 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19073 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19074 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19075 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19076 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19077 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19078 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19079 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19080 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19081 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19082 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19083 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19084 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19085 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19086 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19087 #ifdef RTE_LIBRTE_BPF
19088 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19089 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19090 #endif
19091 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19092 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19093 	(cmdline_parse_inst_t *)&cmd_set_raw,
19094 	NULL,
19095 };
19096 
19097 /* read cmdline commands from file */
19098 void
19099 cmdline_read_from_file(const char *filename)
19100 {
19101 	struct cmdline *cl;
19102 
19103 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19104 	if (cl == NULL) {
19105 		printf("Failed to create file based cmdline context: %s\n",
19106 		       filename);
19107 		return;
19108 	}
19109 
19110 	cmdline_interact(cl);
19111 	cmdline_quit(cl);
19112 
19113 	cmdline_free(cl);
19114 
19115 	printf("Read CLI commands from %s\n", filename);
19116 }
19117 
19118 /* prompt function, called from main on MASTER lcore */
19119 void
19120 prompt(void)
19121 {
19122 	/* initialize non-constant commands */
19123 	cmd_set_fwd_mode_init();
19124 	cmd_set_fwd_retry_mode_init();
19125 
19126 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19127 	if (testpmd_cl == NULL)
19128 		return;
19129 	cmdline_interact(testpmd_cl);
19130 	cmdline_stdin_exit(testpmd_cl);
19131 }
19132 
19133 void
19134 prompt_exit(void)
19135 {
19136 	if (testpmd_cl != NULL)
19137 		cmdline_quit(testpmd_cl);
19138 }
19139 
19140 static void
19141 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19142 {
19143 	if (id == (portid_t)RTE_PORT_ALL) {
19144 		portid_t pid;
19145 
19146 		RTE_ETH_FOREACH_DEV(pid) {
19147 			/* check if need_reconfig has been set to 1 */
19148 			if (ports[pid].need_reconfig == 0)
19149 				ports[pid].need_reconfig = dev;
19150 			/* check if need_reconfig_queues has been set to 1 */
19151 			if (ports[pid].need_reconfig_queues == 0)
19152 				ports[pid].need_reconfig_queues = queue;
19153 		}
19154 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19155 		/* check if need_reconfig has been set to 1 */
19156 		if (ports[id].need_reconfig == 0)
19157 			ports[id].need_reconfig = dev;
19158 		/* check if need_reconfig_queues has been set to 1 */
19159 		if (ports[id].need_reconfig_queues == 0)
19160 			ports[id].need_reconfig_queues = queue;
19161 	}
19162 }
19163